@abstractframework/continuum 0.7.4 → 0.7.5

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 (66) hide show
  1. package/bin/hub_proxy.js +10 -1
  2. package/dist/assets/{abnfDiagram-VRR7QNED-BxjhPlKw.js → abnfDiagram-VRR7QNED-BtFu_otg.js} +2 -2
  3. package/dist/assets/{arc-_FbN2P3P.js → arc-PtY0Mhfw.js} +2 -2
  4. package/dist/assets/{architectureDiagram-ZJ3FMSHR-BCV-dnM4.js → architectureDiagram-ZJ3FMSHR-BTa0RXXs.js} +2 -2
  5. package/dist/assets/{blockDiagram-677ZJIJ3-Dy6_Bfr-.js → blockDiagram-677ZJIJ3-Bm_dMRNm.js} +2 -2
  6. package/dist/assets/{c4Diagram-LMCZKHZV-CDCz0hvp.js → c4Diagram-LMCZKHZV-D-gXkpEL.js} +2 -2
  7. package/dist/assets/channel-DsSfhQWy.js +2 -0
  8. package/dist/assets/{chunk-2Q5K7J3B-CQXku2fA.js → chunk-2Q5K7J3B-4iUxUWvp.js} +2 -2
  9. package/dist/assets/{chunk-32BRIVSS-DtKcX2Bi.js → chunk-32BRIVSS-J_7md9qA.js} +2 -2
  10. package/dist/assets/{chunk-5VM5RSS4-Bzx01bb4.js → chunk-5VM5RSS4-b5MXEYzS.js} +2 -2
  11. package/dist/assets/{chunk-EX3LRPZG-DkLvwLXU.js → chunk-EX3LRPZG-D2usM9-t.js} +2 -2
  12. package/dist/assets/{chunk-JWPE2WC7-BHJIdcoD.js → chunk-JWPE2WC7-LO7654jR.js} +2 -2
  13. package/dist/assets/{chunk-MOJQB5TN-D9jiV5_z.js → chunk-MOJQB5TN-CqdTDVnN.js} +2 -2
  14. package/dist/assets/{chunk-RYQCIY6F-DamDSI2y.js → chunk-RYQCIY6F-BC4SNqd3.js} +2 -2
  15. package/dist/assets/{chunk-V7JOEXUC-CxvPsUwk.js → chunk-V7JOEXUC-C7OuIhlU.js} +2 -2
  16. package/dist/assets/{chunk-VR4S4FIN-DSppuzPr.js → chunk-VR4S4FIN-ByfCxFc8.js} +2 -2
  17. package/dist/assets/{chunk-XXDRQBXY-ZbuFYbo7.js → chunk-XXDRQBXY-TIHSo6li.js} +2 -2
  18. package/dist/assets/classDiagram-OUVF2IWQ-Cuon3qgh.js +2 -0
  19. package/dist/assets/classDiagram-v2-EOCWNBFH-Cuon3qgh.js +2 -0
  20. package/dist/assets/{cose-bilkent-JH36ORCC-UbbsWpVp.js → cose-bilkent-JH36ORCC-BMP5k3l5.js} +2 -2
  21. package/dist/assets/{cynefin-VYW2F7L2-D9Abr-kX.js → cynefin-VYW2F7L2-6RPwnMI9.js} +2 -2
  22. package/dist/assets/{cynefinDiagram-TSTJHNR4-BnnJ9CTo.js → cynefinDiagram-TSTJHNR4-D5zNuufH.js} +2 -2
  23. package/dist/assets/{dagre-VKFMJZFB-DFwcUGid.js → dagre-VKFMJZFB-CSmwEda8.js} +2 -2
  24. package/dist/assets/{diagram-FQU43EPY-By4TQsrB.js → diagram-FQU43EPY-B1jvgtwz.js} +2 -2
  25. package/dist/assets/{diagram-G47NLZAW-CXSnSJkj.js → diagram-G47NLZAW-BwO3Caa9.js} +2 -2
  26. package/dist/assets/{diagram-NH7WQ7WH-BzQeJ-p1.js → diagram-NH7WQ7WH-D4RkZb7N.js} +2 -2
  27. package/dist/assets/{diagram-OA4YK3LP-DvtP4108.js → diagram-OA4YK3LP-zBxOmt0y.js} +2 -2
  28. package/dist/assets/{diagram-WEI45ONY-KvsZ3VNQ.js → diagram-WEI45ONY-BBBc64d2.js} +2 -2
  29. package/dist/assets/{ebnfDiagram-CCIWWBDH-CzLqZFsO.js → ebnfDiagram-CCIWWBDH-Bqo1FZQz.js} +2 -2
  30. package/dist/assets/{erDiagram-Q63AITRT-CQWyXKfX.js → erDiagram-Q63AITRT-sbolcH7L.js} +2 -2
  31. package/dist/assets/{flowDiagram-23GEKE2U-s4L-sKWk.js → flowDiagram-23GEKE2U-Cq8S_YPi.js} +2 -2
  32. package/dist/assets/{ganttDiagram-NO4QXBWP-BReDLFsU.js → ganttDiagram-NO4QXBWP-DRhVaDvI.js} +2 -2
  33. package/dist/assets/{gitGraphDiagram-IHSO6WYX-CEzFOhrL.js → gitGraphDiagram-IHSO6WYX-BxAeBUvP.js} +2 -2
  34. package/dist/assets/index-vNbbkx-g.js +135 -0
  35. package/dist/assets/{infoDiagram-FWYZ7A6U-MNtISf3v.js → infoDiagram-FWYZ7A6U-D9X1VAoO.js} +2 -2
  36. package/dist/assets/{ishikawaDiagram-FXEZZL3T-6O8VElo9.js → ishikawaDiagram-FXEZZL3T-BIOOhYRr.js} +2 -2
  37. package/dist/assets/{journeyDiagram-5HDEW3XC-CB-ZuAF1.js → journeyDiagram-5HDEW3XC-8cMDSpng.js} +2 -2
  38. package/dist/assets/{kanban-definition-HUTT4EX6-waS8GFlU.js → kanban-definition-HUTT4EX6-CkE1Um_-.js} +2 -2
  39. package/dist/assets/{linear-BypRlxdJ.js → linear-Bs238ImQ.js} +2 -2
  40. package/dist/assets/{mermaid.core-DFl7RhFX.js → mermaid.core-DzIYYQn8.js} +5 -5
  41. package/dist/assets/{mindmap-definition-LN4V7U3C-BZN-zc9E.js → mindmap-definition-LN4V7U3C-BxeOjVge.js} +2 -2
  42. package/dist/assets/{pegDiagram-2B236MQR-SchySTJf.js → pegDiagram-2B236MQR-m7bjJqVe.js} +2 -2
  43. package/dist/assets/{pieDiagram-ENE6RG2P-CQ2pvh8Q.js → pieDiagram-ENE6RG2P-B56L6nYJ.js} +2 -2
  44. package/dist/assets/{quadrantDiagram-ABIIQ3AL-C6vQnfAs.js → quadrantDiagram-ABIIQ3AL-dAtTzRio.js} +2 -2
  45. package/dist/assets/{railroadDiagram-RFXS5EU6-Cmb7FtAP.js → railroadDiagram-RFXS5EU6-hkFsje6a.js} +2 -2
  46. package/dist/assets/{requirementDiagram-TGXJPOKE-DAXFIRCv.js → requirementDiagram-TGXJPOKE-Dze7FQkc.js} +2 -2
  47. package/dist/assets/{sankeyDiagram-HTMAVEWB-BWr5ag-s.js → sankeyDiagram-HTMAVEWB-DFT1Nd-Y.js} +2 -2
  48. package/dist/assets/{sequenceDiagram-DBY2YBRQ-Dj_80TqD.js → sequenceDiagram-DBY2YBRQ-C9fvIl0Q.js} +2 -2
  49. package/dist/assets/{sizeCapture-X5ZJPWSS-DAEm627l.js → sizeCapture-X5ZJPWSS-xowue550.js} +2 -2
  50. package/dist/assets/{stateDiagram-2N3HPSRC-FgjCzeK0.js → stateDiagram-2N3HPSRC-42n0x3dd.js} +2 -2
  51. package/dist/assets/stateDiagram-v2-6OUMAXLB-BI-gRWJH.js +2 -0
  52. package/dist/assets/{swimlanes-5IMT3BWC-BEQjgozZ.js → swimlanes-5IMT3BWC-BGfW8H8z.js} +3 -3
  53. package/dist/assets/swimlanesDiagram-G3AALYLV-Chl6_Vw6.js +9 -0
  54. package/dist/assets/{timeline-definition-FHXFAJF6-CYTxFiHP.js → timeline-definition-FHXFAJF6-DQ9caGxo.js} +2 -2
  55. package/dist/assets/{vennDiagram-L72KCM5P-DAdkafCo.js → vennDiagram-L72KCM5P-CTSbmHJt.js} +2 -2
  56. package/dist/assets/{wardleyDiagram-EHGQE667-BkG_3-sh.js → wardleyDiagram-EHGQE667-B9vWU45w.js} +2 -2
  57. package/dist/assets/{xychartDiagram-FW5EYKEG-Db2wjkzJ.js → xychartDiagram-FW5EYKEG-C7mYWvgJ.js} +2 -2
  58. package/dist/index.html +1 -1
  59. package/dist/llms.txt +1 -1
  60. package/package.json +1 -1
  61. package/dist/assets/channel-DZQms9UX.js +0 -2
  62. package/dist/assets/classDiagram-OUVF2IWQ-CkT3O2cp.js +0 -2
  63. package/dist/assets/classDiagram-v2-EOCWNBFH-CkT3O2cp.js +0 -2
  64. package/dist/assets/index-mKJDH7Ot.js +0 -135
  65. package/dist/assets/stateDiagram-v2-6OUMAXLB-D1LWa2Hy.js +0 -2
  66. package/dist/assets/swimlanesDiagram-G3AALYLV-CMtZqccP.js +0 -9
@@ -0,0 +1,135 @@
1
+ var Y_=Object.defineProperty;var X_=(s,n,r)=>n in s?Y_(s,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[n]=r;var Ja=(s,n,r)=>X_(s,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 Z_(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Gu={exports:{}},Ro={},Ku={exports:{}},_t={};/**
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 Mf;function eg(){if(Mf)return _t;Mf=1;var s=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"),h=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),g=Symbol.iterator;function w(k){return k===null||typeof k!="object"?null:(k=g&&k[g]||k["@@iterator"],typeof k=="function"?k:null)}var L={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,$={};function T(k,C,re){this.props=k,this.context=C,this.refs=$,this.updater=re||L}T.prototype.isReactComponent={},T.prototype.setState=function(k,C){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,C,"setState")},T.prototype.forceUpdate=function(k){this.updater.enqueueForceUpdate(this,k,"forceUpdate")};function H(){}H.prototype=T.prototype;function z(k,C,re){this.props=k,this.context=C,this.refs=$,this.updater=re||L}var R=z.prototype=new H;R.constructor=z,E(R,T.prototype),R.isPureReactComponent=!0;var M=Array.isArray,A=Object.prototype.hasOwnProperty,V={current:null},Q={key:!0,ref:!0,__self:!0,__source:!0};function oe(k,C,re){var he,ce={},O=null,we=null;if(C!=null)for(he in C.ref!==void 0&&(we=C.ref),C.key!==void 0&&(O=""+C.key),C)A.call(C,he)&&!Q.hasOwnProperty(he)&&(ce[he]=C[he]);var $e=arguments.length-2;if($e===1)ce.children=re;else if(1<$e){for(var Oe=Array($e),Re=0;Re<$e;Re++)Oe[Re]=arguments[Re+2];ce.children=Oe}if(k&&k.defaultProps)for(he in $e=k.defaultProps,$e)ce[he]===void 0&&(ce[he]=$e[he]);return{$$typeof:s,type:k,key:O,ref:we,props:ce,_owner:V.current}}function be(k,C){return{$$typeof:s,type:k.type,key:C,ref:k.ref,props:k.props,_owner:k._owner}}function Ne(k){return typeof k=="object"&&k!==null&&k.$$typeof===s}function je(k){var C={"=":"=0",":":"=2"};return"$"+k.replace(/[=:]/g,function(re){return C[re]})}var Ce=/\/+/g;function q(k,C){return typeof k=="object"&&k!==null&&k.key!=null?je(""+k.key):C.toString(36)}function te(k,C,re,he,ce){var O=typeof k;(O==="undefined"||O==="boolean")&&(k=null);var we=!1;if(k===null)we=!0;else switch(O){case"string":case"number":we=!0;break;case"object":switch(k.$$typeof){case s:case n:we=!0}}if(we)return we=k,ce=ce(we),k=he===""?"."+q(we,0):he,M(ce)?(re="",k!=null&&(re=k.replace(Ce,"$&/")+"/"),te(ce,C,re,"",function(Re){return Re})):ce!=null&&(Ne(ce)&&(ce=be(ce,re+(!ce.key||we&&we.key===ce.key?"":(""+ce.key).replace(Ce,"$&/")+"/")+k)),C.push(ce)),1;if(we=0,he=he===""?".":he+":",M(k))for(var $e=0;$e<k.length;$e++){O=k[$e];var Oe=he+q(O,$e);we+=te(O,C,re,Oe,ce)}else if(Oe=w(k),typeof Oe=="function")for(k=Oe.call(k),$e=0;!(O=k.next()).done;)O=O.value,Oe=he+q(O,$e++),we+=te(O,C,re,Oe,ce);else if(O==="object")throw C=String(k),Error("Objects are not valid as a React child (found: "+(C==="[object Object]"?"object with keys {"+Object.keys(k).join(", ")+"}":C)+"). If you meant to render a collection of children, use an array instead.");return we}function Y(k,C,re){if(k==null)return k;var he=[],ce=0;return te(k,he,"","",function(O){return C.call(re,O,ce++)}),he}function U(k){if(k._status===-1){var C=k._result;C=C(),C.then(function(re){(k._status===0||k._status===-1)&&(k._status=1,k._result=re)},function(re){(k._status===0||k._status===-1)&&(k._status=2,k._result=re)}),k._status===-1&&(k._status=0,k._result=C)}if(k._status===1)return k._result.default;throw k._result}var X={current:null},I={transition:null},ee={ReactCurrentDispatcher:X,ReactCurrentBatchConfig:I,ReactCurrentOwner:V};function ae(){throw Error("act(...) is not supported in production builds of React.")}return _t.Children={map:Y,forEach:function(k,C,re){Y(k,function(){C.apply(this,arguments)},re)},count:function(k){var C=0;return Y(k,function(){C++}),C},toArray:function(k){return Y(k,function(C){return C})||[]},only:function(k){if(!Ne(k))throw Error("React.Children.only expected to receive a single React element child.");return k}},_t.Component=T,_t.Fragment=r,_t.Profiler=l,_t.PureComponent=z,_t.StrictMode=i,_t.Suspense=h,_t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ee,_t.act=ae,_t.cloneElement=function(k,C,re){if(k==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+k+".");var he=E({},k.props),ce=k.key,O=k.ref,we=k._owner;if(C!=null){if(C.ref!==void 0&&(O=C.ref,we=V.current),C.key!==void 0&&(ce=""+C.key),k.type&&k.type.defaultProps)var $e=k.type.defaultProps;for(Oe in C)A.call(C,Oe)&&!Q.hasOwnProperty(Oe)&&(he[Oe]=C[Oe]===void 0&&$e!==void 0?$e[Oe]:C[Oe])}var Oe=arguments.length-2;if(Oe===1)he.children=re;else if(1<Oe){$e=Array(Oe);for(var Re=0;Re<Oe;Re++)$e[Re]=arguments[Re+2];he.children=$e}return{$$typeof:s,type:k.type,key:ce,ref:O,props:he,_owner:we}},_t.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},_t.createElement=oe,_t.createFactory=function(k){var C=oe.bind(null,k);return C.type=k,C},_t.createRef=function(){return{current:null}},_t.forwardRef=function(k){return{$$typeof:d,render:k}},_t.isValidElement=Ne,_t.lazy=function(k){return{$$typeof:v,_payload:{_status:-1,_result:k},_init:U}},_t.memo=function(k,C){return{$$typeof:x,type:k,compare:C===void 0?null:C}},_t.startTransition=function(k){var C=I.transition;I.transition={};try{k()}finally{I.transition=C}},_t.unstable_act=ae,_t.useCallback=function(k,C){return X.current.useCallback(k,C)},_t.useContext=function(k){return X.current.useContext(k)},_t.useDebugValue=function(){},_t.useDeferredValue=function(k){return X.current.useDeferredValue(k)},_t.useEffect=function(k,C){return X.current.useEffect(k,C)},_t.useId=function(){return X.current.useId()},_t.useImperativeHandle=function(k,C,re){return X.current.useImperativeHandle(k,C,re)},_t.useInsertionEffect=function(k,C){return X.current.useInsertionEffect(k,C)},_t.useLayoutEffect=function(k,C){return X.current.useLayoutEffect(k,C)},_t.useMemo=function(k,C){return X.current.useMemo(k,C)},_t.useReducer=function(k,C,re){return X.current.useReducer(k,C,re)},_t.useRef=function(k){return X.current.useRef(k)},_t.useState=function(k){return X.current.useState(k)},_t.useSyncExternalStore=function(k,C,re){return X.current.useSyncExternalStore(k,C,re)},_t.useTransition=function(){return X.current.useTransition()},_t.version="18.3.1",_t}var Rf;function Wd(){return Rf||(Rf=1,Ku.exports=eg()),Ku.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 Pf;function tg(){if(Pf)return Ro;Pf=1;var s=Wd(),n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,l=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function m(d,h,x){var v,g={},w=null,L=null;x!==void 0&&(w=""+x),h.key!==void 0&&(w=""+h.key),h.ref!==void 0&&(L=h.ref);for(v in h)i.call(h,v)&&!u.hasOwnProperty(v)&&(g[v]=h[v]);if(d&&d.defaultProps)for(v in h=d.defaultProps,h)g[v]===void 0&&(g[v]=h[v]);return{$$typeof:n,type:d,key:w,ref:L,props:g,_owner:l.current}}return Ro.Fragment=r,Ro.jsx=m,Ro.jsxs=m,Ro}var zf;function ng(){return zf||(zf=1,Gu.exports=tg()),Gu.exports}var e=ng(),f=Wd();const Wt=Z_(f);var hc={},Ju={exports:{}},Un={},Qu={exports:{}},Yu={};/**
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 If;function sg(){return If||(If=1,(function(s){function n(I,ee){var ae=I.length;I.push(ee);e:for(;0<ae;){var k=ae-1>>>1,C=I[k];if(0<l(C,ee))I[k]=ee,I[ae]=C,ae=k;else break e}}function r(I){return I.length===0?null:I[0]}function i(I){if(I.length===0)return null;var ee=I[0],ae=I.pop();if(ae!==ee){I[0]=ae;e:for(var k=0,C=I.length,re=C>>>1;k<re;){var he=2*(k+1)-1,ce=I[he],O=he+1,we=I[O];if(0>l(ce,ae))O<C&&0>l(we,ce)?(I[k]=we,I[O]=ae,k=O):(I[k]=ce,I[he]=ae,k=he);else if(O<C&&0>l(we,ae))I[k]=we,I[O]=ae,k=O;else break e}}return ee}function l(I,ee){var ae=I.sortIndex-ee.sortIndex;return ae!==0?ae:I.id-ee.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;s.unstable_now=function(){return u.now()}}else{var m=Date,d=m.now();s.unstable_now=function(){return m.now()-d}}var h=[],x=[],v=1,g=null,w=3,L=!1,E=!1,$=!1,T=typeof setTimeout=="function"?setTimeout:null,H=typeof clearTimeout=="function"?clearTimeout:null,z=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function R(I){for(var ee=r(x);ee!==null;){if(ee.callback===null)i(x);else if(ee.startTime<=I)i(x),ee.sortIndex=ee.expirationTime,n(h,ee);else break;ee=r(x)}}function M(I){if($=!1,R(I),!E)if(r(h)!==null)E=!0,U(A);else{var ee=r(x);ee!==null&&X(M,ee.startTime-I)}}function A(I,ee){E=!1,$&&($=!1,H(oe),oe=-1),L=!0;var ae=w;try{for(R(ee),g=r(h);g!==null&&(!(g.expirationTime>ee)||I&&!je());){var k=g.callback;if(typeof k=="function"){g.callback=null,w=g.priorityLevel;var C=k(g.expirationTime<=ee);ee=s.unstable_now(),typeof C=="function"?g.callback=C:g===r(h)&&i(h),R(ee)}else i(h);g=r(h)}if(g!==null)var re=!0;else{var he=r(x);he!==null&&X(M,he.startTime-ee),re=!1}return re}finally{g=null,w=ae,L=!1}}var V=!1,Q=null,oe=-1,be=5,Ne=-1;function je(){return!(s.unstable_now()-Ne<be)}function Ce(){if(Q!==null){var I=s.unstable_now();Ne=I;var ee=!0;try{ee=Q(!0,I)}finally{ee?q():(V=!1,Q=null)}}else V=!1}var q;if(typeof z=="function")q=function(){z(Ce)};else if(typeof MessageChannel<"u"){var te=new MessageChannel,Y=te.port2;te.port1.onmessage=Ce,q=function(){Y.postMessage(null)}}else q=function(){T(Ce,0)};function U(I){Q=I,V||(V=!0,q())}function X(I,ee){oe=T(function(){I(s.unstable_now())},ee)}s.unstable_IdlePriority=5,s.unstable_ImmediatePriority=1,s.unstable_LowPriority=4,s.unstable_NormalPriority=3,s.unstable_Profiling=null,s.unstable_UserBlockingPriority=2,s.unstable_cancelCallback=function(I){I.callback=null},s.unstable_continueExecution=function(){E||L||(E=!0,U(A))},s.unstable_forceFrameRate=function(I){0>I||125<I?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):be=0<I?Math.floor(1e3/I):5},s.unstable_getCurrentPriorityLevel=function(){return w},s.unstable_getFirstCallbackNode=function(){return r(h)},s.unstable_next=function(I){switch(w){case 1:case 2:case 3:var ee=3;break;default:ee=w}var ae=w;w=ee;try{return I()}finally{w=ae}},s.unstable_pauseExecution=function(){},s.unstable_requestPaint=function(){},s.unstable_runWithPriority=function(I,ee){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var ae=w;w=I;try{return ee()}finally{w=ae}},s.unstable_scheduleCallback=function(I,ee,ae){var k=s.unstable_now();switch(typeof ae=="object"&&ae!==null?(ae=ae.delay,ae=typeof ae=="number"&&0<ae?k+ae:k):ae=k,I){case 1:var C=-1;break;case 2:C=250;break;case 5:C=1073741823;break;case 4:C=1e4;break;default:C=5e3}return C=ae+C,I={id:v++,callback:ee,priorityLevel:I,startTime:ae,expirationTime:C,sortIndex:-1},ae>k?(I.sortIndex=ae,n(x,I),r(h)===null&&I===r(x)&&($?(H(oe),oe=-1):$=!0,X(M,ae-k))):(I.sortIndex=C,n(h,I),E||L||(E=!0,U(A))),I},s.unstable_shouldYield=je,s.unstable_wrapCallback=function(I){var ee=w;return function(){var ae=w;w=ee;try{return I.apply(this,arguments)}finally{w=ae}}}})(Yu)),Yu}var Df;function ag(){return Df||(Df=1,Qu.exports=sg()),Qu.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 Of;function rg(){if(Of)return Un;Of=1;var s=Wd(),n=ag();function r(t){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+t,o=1;o<arguments.length;o++)a+="&args[]="+encodeURIComponent(arguments[o]);return"Minified React error #"+t+"; visit "+a+" 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,a){m(t,a),m(t+"Capture",a)}function m(t,a){for(l[t]=a,t=0;t<a.length;t++)i.add(a[t])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,x=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},g={};function w(t){return h.call(g,t)?!0:h.call(v,t)?!1:x.test(t)?g[t]=!0:(v[t]=!0,!1)}function L(t,a,o,c){if(o!==null&&o.type===0)return!1;switch(typeof a){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 E(t,a,o,c){if(a===null||typeof a>"u"||L(t,a,o,c))return!0;if(c)return!1;if(o!==null)switch(o.type){case 3:return!a;case 4:return a===!1;case 5:return isNaN(a);case 6:return isNaN(a)||1>a}return!1}function $(t,a,o,c,_,y,j){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=c,this.attributeNamespace=_,this.mustUseProperty=o,this.propertyName=t,this.type=a,this.sanitizeURL=y,this.removeEmptyString=j}var T={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){T[t]=new $(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var a=t[0];T[a]=new $(a,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){T[t]=new $(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){T[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){T[t]=new $(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){T[t]=new $(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){T[t]=new $(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){T[t]=new $(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){T[t]=new $(t,5,!1,t.toLowerCase(),null,!1,!1)});var H=/[\-:]([a-z])/g;function z(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 a=t.replace(H,z);T[a]=new $(a,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var a=t.replace(H,z);T[a]=new $(a,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var a=t.replace(H,z);T[a]=new $(a,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){T[t]=new $(t,1,!1,t.toLowerCase(),null,!1,!1)}),T.xlinkHref=new $("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){T[t]=new $(t,1,!1,t.toLowerCase(),null,!0,!0)});function R(t,a,o,c){var _=T.hasOwnProperty(a)?T[a]:null;(_!==null?_.type!==0:c||!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(E(a,o,_,c)&&(o=null),c||_===null?w(a)&&(o===null?t.removeAttribute(a):t.setAttribute(a,""+o)):_.mustUseProperty?t[_.propertyName]=o===null?_.type===3?!1:"":o:(a=_.attributeName,c=_.attributeNamespace,o===null?t.removeAttribute(a):(_=_.type,o=_===3||_===4&&o===!0?"":""+o,c?t.setAttributeNS(c,a,o):t.setAttribute(a,o))))}var M=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,A=Symbol.for("react.element"),V=Symbol.for("react.portal"),Q=Symbol.for("react.fragment"),oe=Symbol.for("react.strict_mode"),be=Symbol.for("react.profiler"),Ne=Symbol.for("react.provider"),je=Symbol.for("react.context"),Ce=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),te=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),X=Symbol.for("react.offscreen"),I=Symbol.iterator;function ee(t){return t===null||typeof t!="object"?null:(t=I&&t[I]||t["@@iterator"],typeof t=="function"?t:null)}var ae=Object.assign,k;function C(t){if(k===void 0)try{throw Error()}catch(o){var a=o.stack.trim().match(/\n( *(at )?)/);k=a&&a[1]||""}return`
34
+ `+k+t}var re=!1;function he(t,a){if(!t||re)return"";re=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(a)if(a=function(){throw Error()},Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(a,[])}catch(_e){var c=_e}Reflect.construct(t,[],a)}else{try{a.call()}catch(_e){c=_e}t.call(a.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
+ `),y=c.stack.split(`
36
+ `),j=_.length-1,B=y.length-1;1<=j&&0<=B&&_[j]!==y[B];)B--;for(;1<=j&&0<=B;j--,B--)if(_[j]!==y[B]){if(j!==1||B!==1)do if(j--,B--,0>B||_[j]!==y[B]){var K=`
37
+ `+_[j].replace(" at new "," at ");return t.displayName&&K.includes("<anonymous>")&&(K=K.replace("<anonymous>",t.displayName)),K}while(1<=j&&0<=B);break}}}finally{re=!1,Error.prepareStackTrace=o}return(t=t?t.displayName||t.name:"")?C(t):""}function ce(t){switch(t.tag){case 5:return C(t.type);case 16:return C("Lazy");case 13:return C("Suspense");case 19:return C("SuspenseList");case 0:case 2:case 15:return t=he(t.type,!1),t;case 11:return t=he(t.type.render,!1),t;case 1:return t=he(t.type,!0),t;default:return""}}function O(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 Q:return"Fragment";case V:return"Portal";case be:return"Profiler";case oe:return"StrictMode";case q:return"Suspense";case te:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case je:return(t.displayName||"Context")+".Consumer";case Ne:return(t._context.displayName||"Context")+".Provider";case Ce:var a=t.render;return t=t.displayName,t||(t=a.displayName||a.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Y:return a=t.displayName||null,a!==null?a:O(t.type)||"Memo";case U:a=t._payload,t=t._init;try{return O(t(a))}catch{}}return null}function we(t){var a=t.type;switch(t.tag){case 24:return"Cache";case 9:return(a.displayName||"Context")+".Consumer";case 10:return(a._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=a.render,t=t.displayName||t.name||"",a.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return a;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return O(a);case 8:return a===oe?"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 a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a}return null}function $e(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Oe(t){var a=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function Re(t){var a=Oe(t)?"checked":"value",o=Object.getOwnPropertyDescriptor(t.constructor.prototype,a),c=""+t[a];if(!t.hasOwnProperty(a)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var _=o.get,y=o.set;return Object.defineProperty(t,a,{configurable:!0,get:function(){return _.call(this)},set:function(j){c=""+j,y.call(this,j)}}),Object.defineProperty(t,a,{enumerable:o.enumerable}),{getValue:function(){return c},setValue:function(j){c=""+j},stopTracking:function(){t._valueTracker=null,delete t[a]}}}}function it(t){t._valueTracker||(t._valueTracker=Re(t))}function Be(t){if(!t)return!1;var a=t._valueTracker;if(!a)return!0;var o=a.getValue(),c="";return t&&(c=Oe(t)?t.checked?"true":"false":t.value),t=c,t!==o?(a.setValue(t),!0):!1}function ot(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 Ve(t,a){var o=a.checked;return ae({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??t._wrapperState.initialChecked})}function ct(t,a){var o=a.defaultValue==null?"":a.defaultValue,c=a.checked!=null?a.checked:a.defaultChecked;o=$e(a.value!=null?a.value:o),t._wrapperState={initialChecked:c,initialValue:o,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function et(t,a){a=a.checked,a!=null&&R(t,"checked",a,!1)}function fe(t,a){et(t,a);var o=$e(a.value),c=a.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}a.hasOwnProperty("value")?Ee(t,a.type,o):a.hasOwnProperty("defaultValue")&&Ee(t,a.type,$e(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(t.defaultChecked=!!a.defaultChecked)}function ue(t,a,o){if(a.hasOwnProperty("value")||a.hasOwnProperty("defaultValue")){var c=a.type;if(!(c!=="submit"&&c!=="reset"||a.value!==void 0&&a.value!==null))return;a=""+t._wrapperState.initialValue,o||a===t.value||(t.value=a),t.defaultValue=a}o=t.name,o!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,o!==""&&(t.name=o)}function Ee(t,a,o){(a!=="number"||ot(t.ownerDocument)!==t)&&(o==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+o&&(t.defaultValue=""+o))}var se=Array.isArray;function W(t,a,o,c){if(t=t.options,a){a={};for(var _=0;_<o.length;_++)a["$"+o[_]]=!0;for(o=0;o<t.length;o++)_=a.hasOwnProperty("$"+t[o].value),t[o].selected!==_&&(t[o].selected=_),_&&c&&(t[o].defaultSelected=!0)}else{for(o=""+$e(o),a=null,_=0;_<t.length;_++){if(t[_].value===o){t[_].selected=!0,c&&(t[_].defaultSelected=!0);return}a!==null||t[_].disabled||(a=t[_])}a!==null&&(a.selected=!0)}}function ie(t,a){if(a.dangerouslySetInnerHTML!=null)throw Error(r(91));return ae({},a,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function Se(t,a){var o=a.value;if(o==null){if(o=a.children,a=a.defaultValue,o!=null){if(a!=null)throw Error(r(92));if(se(o)){if(1<o.length)throw Error(r(93));o=o[0]}a=o}a==null&&(a=""),o=a}t._wrapperState={initialValue:$e(o)}}function Je(t,a){var o=$e(a.value),c=$e(a.defaultValue);o!=null&&(o=""+o,o!==t.value&&(t.value=o),a.defaultValue==null&&t.defaultValue!==o&&(t.defaultValue=o)),c!=null&&(t.defaultValue=""+c)}function F(t){var a=t.textContent;a===t._wrapperState.initialValue&&a!==""&&a!==null&&(t.value=a)}function de(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 ye(t,a){return t==null||t==="http://www.w3.org/1999/xhtml"?de(a):t==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var xe,ke=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(a,o,c,_){MSApp.execUnsafeLocalFunction(function(){return t(a,o,c,_)})}:t})(function(t,a){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=a;else{for(xe=xe||document.createElement("div"),xe.innerHTML="<svg>"+a.valueOf().toString()+"</svg>",a=xe.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;a.firstChild;)t.appendChild(a.firstChild)}});function J(t,a){if(a){var o=t.firstChild;if(o&&o===t.lastChild&&o.nodeType===3){o.nodeValue=a;return}}t.textContent=a}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},Z=["Webkit","ms","Moz","O"];Object.keys(P).forEach(function(t){Z.forEach(function(a){a=a+t.charAt(0).toUpperCase()+t.substring(1),P[a]=P[t]})});function Pe(t,a,o){return a==null||typeof a=="boolean"||a===""?"":o||typeof a!="number"||a===0||P.hasOwnProperty(t)&&P[t]?(""+a).trim():a+"px"}function Fe(t,a){t=t.style;for(var o in a)if(a.hasOwnProperty(o)){var c=o.indexOf("--")===0,_=Pe(o,a[o],c);o==="float"&&(o="cssFloat"),c?t.setProperty(o,_):t[o]=_}}var Xe=ae({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 dt(t,a){if(a){if(Xe[t]&&(a.children!=null||a.dangerouslySetInnerHTML!=null))throw Error(r(137,t));if(a.dangerouslySetInnerHTML!=null){if(a.children!=null)throw Error(r(60));if(typeof a.dangerouslySetInnerHTML!="object"||!("__html"in a.dangerouslySetInnerHTML))throw Error(r(61))}if(a.style!=null&&typeof a.style!="object")throw Error(r(62))}}function ft(t,a){if(t.indexOf("-")===-1)return typeof a.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Le=null;function st(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var pt=null,Dt=null,wt=null;function en(t){if(t=kr(t)){if(typeof pt!="function")throw Error(r(280));var a=t.stateNode;a&&(a=xi(a),pt(t.stateNode,t.type,a))}}function ge(t){Dt?wt?wt.push(t):wt=[t]:Dt=t}function Te(){if(Dt){var t=Dt,a=wt;if(wt=Dt=null,en(t),a)for(t=0;t<a.length;t++)en(a[t])}}function Ye(t,a){return t(a)}function vt(){}var gt=!1;function jt(t,a,o){if(gt)return t(a,o);gt=!0;try{return Ye(t,a,o)}finally{gt=!1,(Dt!==null||wt!==null)&&(vt(),Te())}}function lt(t,a){var o=t.stateNode;if(o===null)return null;var c=xi(o);if(c===null)return null;o=c[a];e:switch(a){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,a,typeof o));return o}var En=!1;if(d)try{var js={};Object.defineProperty(js,"passive",{get:function(){En=!0}}),window.addEventListener("test",js,js),window.removeEventListener("test",js,js)}catch{En=!1}function sr(t,a,o,c,_,y,j,B,K){var _e=Array.prototype.slice.call(arguments,3);try{a.apply(o,_e)}catch(Me){this.onError(Me)}}var ks=!1,as=null,tn=!1,Vs=null,Gs={onError:function(t){ks=!0,as=t}};function Ss(t,a,o,c,_,y,j,B,K){ks=!1,as=null,sr.apply(Gs,arguments)}function qi(t,a,o,c,_,y,j,B,K){if(Ss.apply(this,arguments),ks){if(ks){var _e=as;ks=!1,as=null}else throw Error(r(198));tn||(tn=!0,Vs=_e)}}function Ns(t){var a=t,o=t;if(t.alternate)for(;a.return;)a=a.return;else{t=a;do a=t,(a.flags&4098)!==0&&(o=a.return),t=a.return;while(t)}return a.tag===3?o:null}function Ur(t){if(t.tag===13){var a=t.memoizedState;if(a===null&&(t=t.alternate,t!==null&&(a=t.memoizedState)),a!==null)return a.dehydrated}return null}function ht(t){if(Ns(t)!==t)throw Error(r(188))}function Gt(t){var a=t.alternate;if(!a){if(a=Ns(t),a===null)throw Error(r(188));return a!==t?null:t}for(var o=t,c=a;;){var _=o.return;if(_===null)break;var y=_.alternate;if(y===null){if(c=_.return,c!==null){o=c;continue}break}if(_.child===y.child){for(y=_.child;y;){if(y===o)return ht(_),t;if(y===c)return ht(_),a;y=y.sibling}throw Error(r(188))}if(o.return!==c.return)o=_,c=y;else{for(var j=!1,B=_.child;B;){if(B===o){j=!0,o=_,c=y;break}if(B===c){j=!0,c=_,o=y;break}B=B.sibling}if(!j){for(B=y.child;B;){if(B===o){j=!0,o=y,c=_;break}if(B===c){j=!0,c=y,o=_;break}B=B.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:a}function ar(t){return t=Gt(t),t!==null?zt(t):null}function zt(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var a=zt(t);if(a!==null)return a;t=t.sibling}return null}var rr=n.unstable_scheduleCallback,Bi=n.unstable_cancelCallback,ul=n.unstable_shouldYield,Ui=n.unstable_requestPaint,Ot=n.unstable_now,Wr=n.unstable_getCurrentPriorityLevel,Hr=n.unstable_ImmediatePriority,ir=n.unstable_UserBlockingPriority,Ks=n.unstable_NormalPriority,dl=n.unstable_LowPriority,Vr=n.unstable_IdlePriority,rs=null,mn=null;function Gr(t){if(mn&&typeof mn.onCommitFiberRoot=="function")try{mn.onCommitFiberRoot(rs,t,void 0,(t.current.flags&128)===128)}catch{}}var fn=Math.clz32?Math.clz32:fl,ml=Math.log,ga=Math.LN2;function fl(t){return t>>>=0,t===0?32:31-(ml(t)/ga|0)|0}var ya=64,Kr=4194304;function or(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 xn(t,a){var o=t.pendingLanes;if(o===0)return 0;var c=0,_=t.suspendedLanes,y=t.pingedLanes,j=o&268435455;if(j!==0){var B=j&~_;B!==0?c=or(B):(y&=j,y!==0&&(c=or(y)))}else j=o&~_,j!==0?c=or(j):y!==0&&(c=or(y));if(c===0)return 0;if(a!==0&&a!==c&&(a&_)===0&&(_=c&-c,y=a&-a,_>=y||_===16&&(y&4194240)!==0))return a;if((c&4)!==0&&(c|=o&16),a=t.entangledLanes,a!==0)for(t=t.entanglements,a&=c;0<a;)o=31-fn(a),_=1<<o,c|=t[o],a&=~_;return c}function Js(t,a){switch(t){case 1:case 2:case 4:return a+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 a+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 Jr(t,a){for(var o=t.suspendedLanes,c=t.pingedLanes,_=t.expirationTimes,y=t.pendingLanes;0<y;){var j=31-fn(y),B=1<<j,K=_[j];K===-1?((B&o)===0||(B&c)!==0)&&(_[j]=Js(B,a)):K<=a&&(t.expiredLanes|=B),y&=~B}}function Cs(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function Kt(){var t=ya;return ya<<=1,(ya&4194240)===0&&(ya=64),t}function Xt(t){for(var a=[],o=0;31>o;o++)a.push(t);return a}function $s(t,a,o){t.pendingLanes|=a,a!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,a=31-fn(a),t[a]=o}function va(t,a){var o=t.pendingLanes&~a;t.pendingLanes=a,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=a,t.mutableReadLanes&=a,t.entangledLanes&=a,a=t.entanglements;var c=t.eventTimes;for(t=t.expirationTimes;0<o;){var _=31-fn(o),y=1<<_;a[_]=0,c[_]=-1,t[_]=-1,o&=~y}}function Es(t,a){var o=t.entangledLanes|=a;for(t=t.entanglements;o;){var c=31-fn(o),_=1<<c;_&a|t[c]&a&&(t[c]|=a),o&=~_}}var kt=0;function Jt(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var is,Qr,Rn,Yr,Wi,lr=!1,cr=[],os=null,Vn=null,Tn=null,Ts=new Map,ln=new Map,hn=[],Ic="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,a){switch(t){case"focusin":case"focusout":os=null;break;case"dragenter":case"dragleave":Vn=null;break;case"mouseover":case"mouseout":Tn=null;break;case"pointerover":case"pointerout":Ts.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":ln.delete(a.pointerId)}}function Et(t,a,o,c,_,y){return t===null||t.nativeEvent!==y?(t={blockedOn:a,domEventName:o,eventSystemFlags:c,nativeEvent:y,targetContainers:[_]},a!==null&&(a=kr(a),a!==null&&Qr(a)),t):(t.eventSystemFlags|=c,a=t.targetContainers,_!==null&&a.indexOf(_)===-1&&a.push(_),t)}function Gn(t,a,o,c,_){switch(a){case"focusin":return os=Et(os,t,a,o,c,_),!0;case"dragenter":return Vn=Et(Vn,t,a,o,c,_),!0;case"mouseover":return Tn=Et(Tn,t,a,o,c,_),!0;case"pointerover":var y=_.pointerId;return Ts.set(y,Et(Ts.get(y)||null,t,a,o,c,_)),!0;case"gotpointercapture":return y=_.pointerId,ln.set(y,Et(ln.get(y)||null,t,a,o,c,_)),!0}return!1}function Pn(t){var a=oa(t.target);if(a!==null){var o=Ns(a);if(o!==null){if(a=o.tag,a===13){if(a=Ur(o),a!==null){t.blockedOn=a,Wi(t.priority,function(){Rn(o)});return}}else if(a===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 a=t.targetContainers;0<a.length;){var o=fr(t.domEventName,t.eventSystemFlags,a[0],t.nativeEvent);if(o===null){o=t.nativeEvent;var c=new o.constructor(o.type,o);Le=c,o.target.dispatchEvent(c),Le=null}else return a=kr(o),a!==null&&Qr(a),t.blockedOn=o,!1;a.shift()}return!0}function Xr(t,a,o){ba(t)&&o.delete(a)}function hl(){lr=!1,os!==null&&ba(os)&&(os=null),Vn!==null&&ba(Vn)&&(Vn=null),Tn!==null&&ba(Tn)&&(Tn=null),Ts.forEach(Xr),ln.forEach(Xr)}function bn(t,a){t.blockedOn===a&&(t.blockedOn=null,lr||(lr=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,hl)))}function wa(t){function a(_){return bn(_,t)}if(0<cr.length){bn(cr[0],t);for(var o=1;o<cr.length;o++){var c=cr[o];c.blockedOn===t&&(c.blockedOn=null)}}for(os!==null&&bn(os,t),Vn!==null&&bn(Vn,t),Tn!==null&&bn(Tn,t),Ts.forEach(a),ln.forEach(a),o=0;o<hn.length;o++)c=hn[o],c.blockedOn===t&&(c.blockedOn=null);for(;0<hn.length&&(o=hn[0],o.blockedOn===null);)Pn(o),o.blockedOn===null&&hn.shift()}var ls=M.ReactCurrentBatchConfig,ur=!0;function Hi(t,a,o,c){var _=kt,y=ls.transition;ls.transition=null;try{kt=1,Zr(t,a,o,c)}finally{kt=_,ls.transition=y}}function dr(t,a,o,c){var _=kt,y=ls.transition;ls.transition=null;try{kt=4,Zr(t,a,o,c)}finally{kt=_,ls.transition=y}}function Zr(t,a,o,c){if(ur){var _=fr(t,a,o,c);if(_===null)aa(t,a,c,mr,o),xa(t,c);else if(Gn(_,t,a,o,c))c.stopPropagation();else if(xa(t,c),a&4&&-1<Ic.indexOf(t)){for(;_!==null;){var y=kr(_);if(y!==null&&is(y),y=fr(t,a,o,c),y===null&&aa(t,a,c,mr,o),y===_)break;_=y}_!==null&&c.stopPropagation()}else aa(t,a,c,null,o)}}var mr=null;function fr(t,a,o,c){if(mr=null,t=st(c),t=oa(t),t!==null)if(a=Ns(t),a===null)t=null;else if(o=a.tag,o===13){if(t=Ur(a),t!==null)return t;t=null}else if(o===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;t=null}else a!==t&&(t=null);return mr=t,null}function Vi(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(Wr()){case Hr:return 1;case ir:return 4;case Ks:case dl:return 16;case Vr:return 536870912;default:return 16}default:return 16}}var zn=null,cs=null,Qs=null;function ei(){if(Qs)return Qs;var t,a=cs,o=a.length,c,_="value"in zn?zn.value:zn.textContent,y=_.length;for(t=0;t<o&&a[t]===_[t];t++);var j=o-t;for(c=1;c<=j&&a[o-c]===_[y-c];c++);return Qs=_.slice(t,1<c?1-c:void 0)}function ja(t){var a=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&a===13&&(t=13)):t=a,t===10&&(t=13),32<=t||t===13?t:0}function ka(){return!0}function Ys(){return!1}function nn(t){function a(o,c,_,y,j){this._reactName=o,this._targetInst=_,this.type=c,this.nativeEvent=y,this.target=j,this.currentTarget=null;for(var B in t)t.hasOwnProperty(B)&&(o=t[B],this[B]=o?o(y):y[B]);return this.isDefaultPrevented=(y.defaultPrevented!=null?y.defaultPrevented:y.returnValue===!1)?ka:Ys,this.isPropagationStopped=Ys,this}return ae(a.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}),a}var Sa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Qt=nn(Sa),As=ae({},Sa,{view:0,detail:0}),Gi=nn(As),ti,hr,Xs,Na=ae({},As,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:wn,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Xs&&(Xs&&t.type==="mousemove"?(ti=t.screenX-Xs.screenX,hr=t.screenY-Xs.screenY):hr=ti=0,Xs=t),ti)},movementY:function(t){return"movementY"in t?t.movementY:hr}}),Ki=nn(Na),Ji=ae({},Na,{dataTransfer:0}),pl=nn(Ji),_l=ae({},As,{relatedTarget:0}),ni=nn(_l),gl=ae({},Sa,{animationName:0,elapsedTime:0,pseudoElement:0}),Qi=nn(gl),yl=ae({},Sa,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Yi=nn(yl),Xi=ae({},Sa,{data:0}),Zs=nn(Xi),Zi={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},si={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"},Dc={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function vl(t){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(t):(t=Dc[t])?!!a[t]:!1}function wn(){return vl}var Ls=ae({},As,{key:function(t){if(t.key){var a=Zi[t.key]||t.key;if(a!=="Unidentified")return a}return t.type==="keypress"?(t=ja(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?si[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:wn,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}}),Ms=nn(Ls),eo=ae({},Na,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ai=nn(eo),to=ae({},As,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:wn}),Oc=nn(to),Ca=ae({},Sa,{propertyName:0,elapsedTime:0,pseudoElement:0}),pr=nn(Ca),Yn=ae({},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}),ea=nn(Yn),xl=[9,13,27,32],ri=d&&"CompositionEvent"in window,$a=null;d&&"documentMode"in document&&($a=document.documentMode);var Fc=d&&"TextEvent"in window&&!$a,bl=d&&(!ri||$a&&8<$a&&11>=$a),ii=" ",ta=!1;function oi(t,a){switch(t){case"keyup":return xl.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function no(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Rs=!1;function wl(t,a){switch(t){case"compositionend":return no(a);case"keypress":return a.which!==32?null:(ta=!0,ii);case"textInput":return t=a.data,t===ii&&ta?null:t;default:return null}}function Ea(t,a){if(Rs)return t==="compositionend"||!ri&&oi(t,a)?(t=ei(),Qs=cs=zn=null,Rs=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return bl&&a.locale!=="ko"?null:a.data;default:return null}}var so={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 jl(t){var a=t&&t.nodeName&&t.nodeName.toLowerCase();return a==="input"?!!so[t.type]:a==="textarea"}function Ta(t,a,o,c){ge(c),a=br(a,"onChange"),0<a.length&&(o=new Qt("onChange","change",null,o,c),t.push({event:o,listeners:a}))}var na=null,Aa=null;function kl(t){ds(t,0)}function _r(t){var a=Da(t);if(Be(a))return t}function qc(t,a){if(t==="change")return a}var Ps=!1;if(d){var sa;if(d){var ao="oninput"in document;if(!ao){var gr=document.createElement("div");gr.setAttribute("oninput","return;"),ao=typeof gr.oninput=="function"}sa=ao}else sa=!1;Ps=sa&&(!document.documentMode||9<document.documentMode)}function li(){na&&(na.detachEvent("onpropertychange",Sl),Aa=na=null)}function Sl(t){if(t.propertyName==="value"&&_r(Aa)){var a=[];Ta(a,Aa,t,st(t)),jt(kl,a)}}function ci(t,a,o){t==="focusin"?(li(),na=a,Aa=o,na.attachEvent("onpropertychange",Sl)):t==="focusout"&&li()}function ui(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return _r(Aa)}function Bc(t,a){if(t==="click")return _r(a)}function Uc(t,a){if(t==="input"||t==="change")return _r(a)}function Wc(t,a){return t===a&&(t!==0||1/t===1/a)||t!==t&&a!==a}var In=typeof Object.is=="function"?Object.is:Wc;function yr(t,a){if(In(t,a))return!0;if(typeof t!="object"||t===null||typeof a!="object"||a===null)return!1;var o=Object.keys(t),c=Object.keys(a);if(o.length!==c.length)return!1;for(c=0;c<o.length;c++){var _=o[c];if(!h.call(a,_)||!In(t[_],a[_]))return!1}return!0}function ro(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Nl(t,a){var o=ro(t);t=0;for(var c;o;){if(o.nodeType===3){if(c=t+o.textContent.length,t<=a&&c>=a)return{node:o,offset:a-t};t=c}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=ro(o)}}function Cl(t,a){return t&&a?t===a?!0:t&&t.nodeType===3?!1:a&&a.nodeType===3?Cl(t,a.parentNode):"contains"in t?t.contains(a):t.compareDocumentPosition?!!(t.compareDocumentPosition(a)&16):!1:!1}function di(){for(var t=window,a=ot();a instanceof t.HTMLIFrameElement;){try{var o=typeof a.contentWindow.location.href=="string"}catch{o=!1}if(o)t=a.contentWindow;else break;a=ot(t.document)}return a}function io(t){var a=t&&t.nodeName&&t.nodeName.toLowerCase();return a&&(a==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||a==="textarea"||t.contentEditable==="true")}function $l(t){var a=di(),o=t.focusedElem,c=t.selectionRange;if(a!==o&&o&&o.ownerDocument&&Cl(o.ownerDocument.documentElement,o)){if(c!==null&&io(o)){if(a=c.start,t=c.end,t===void 0&&(t=a),"selectionStart"in o)o.selectionStart=a,o.selectionEnd=Math.min(t,o.value.length);else if(t=(a=o.ownerDocument||document)&&a.defaultView||window,t.getSelection){t=t.getSelection();var _=o.textContent.length,y=Math.min(c.start,_);c=c.end===void 0?y:Math.min(c.end,_),!t.extend&&y>c&&(_=c,c=y,y=_),_=Nl(o,y);var j=Nl(o,c);_&&j&&(t.rangeCount!==1||t.anchorNode!==_.node||t.anchorOffset!==_.offset||t.focusNode!==j.node||t.focusOffset!==j.offset)&&(a=a.createRange(),a.setStart(_.node,_.offset),t.removeAllRanges(),y>c?(t.addRange(a),t.extend(j.node,j.offset)):(a.setEnd(j.node,j.offset),t.addRange(a)))}}for(a=[],t=o;t=t.parentNode;)t.nodeType===1&&a.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o<a.length;o++)t=a[o],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var El=d&&"documentMode"in document&&11>=document.documentMode,La=null,mi=null,zs=null,fi=!1;function vr(t,a,o){var c=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;fi||La==null||La!==ot(c)||(c=La,"selectionStart"in c&&io(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}),zs&&yr(zs,c)||(zs=c,c=br(mi,"onSelect"),0<c.length&&(a=new Qt("onSelect","select",null,a,o),t.push({event:a,listeners:c}),a.target=La)))}function xr(t,a){var o={};return o[t.toLowerCase()]=a.toLowerCase(),o["Webkit"+t]="webkit"+a,o["Moz"+t]="moz"+a,o}var Ma={animationend:xr("Animation","AnimationEnd"),animationiteration:xr("Animation","AnimationIteration"),animationstart:xr("Animation","AnimationStart"),transitionend:xr("Transition","TransitionEnd")},oo={},lo={};d&&(lo=document.createElement("div").style,"AnimationEvent"in window||(delete Ma.animationend.animation,delete Ma.animationiteration.animation,delete Ma.animationstart.animation),"TransitionEvent"in window||delete Ma.transitionend.transition);function hi(t){if(oo[t])return oo[t];if(!Ma[t])return t;var a=Ma[t],o;for(o in a)if(a.hasOwnProperty(o)&&o in lo)return oo[t]=a[o];return t}var co=hi("animationend"),Tl=hi("animationiteration"),uo=hi("animationstart"),mo=hi("transitionend"),Al=new Map,Ll="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 us(t,a){Al.set(t,a),u(a,[t])}for(var pi=0;pi<Ll.length;pi++){var fo=Ll[pi],Dn=fo.toLowerCase(),At=fo[0].toUpperCase()+fo.slice(1);us(Dn,"on"+At)}us(co,"onAnimationEnd"),us(Tl,"onAnimationIteration"),us(uo,"onAnimationStart"),us("dblclick","onDoubleClick"),us("focusin","onFocus"),us("focusout","onBlur"),us(mo,"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 qt="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(" "),ho=new Set("cancel close invalid load scroll toggle".split(" ").concat(qt));function Ml(t,a,o){var c=t.type||"unknown-event";t.currentTarget=o,qi(c,a,void 0,t),t.currentTarget=null}function ds(t,a){a=(a&4)!==0;for(var o=0;o<t.length;o++){var c=t[o],_=c.event;c=c.listeners;e:{var y=void 0;if(a)for(var j=c.length-1;0<=j;j--){var B=c[j],K=B.instance,_e=B.currentTarget;if(B=B.listener,K!==y&&_.isPropagationStopped())break e;Ml(_,B,_e),y=K}else for(j=0;j<c.length;j++){if(B=c[j],K=B.instance,_e=B.currentTarget,B=B.listener,K!==y&&_.isPropagationStopped())break e;Ml(_,B,_e),y=K}}}if(tn)throw t=Vs,tn=!1,Vs=null,t}function xt(t,a){var o=a[go];o===void 0&&(o=a[go]=new Set);var c=t+"__bubble";o.has(c)||(Ra(a,t,2,!1),o.add(c))}function Kn(t,a,o){var c=0;a&&(c|=4),Ra(o,t,c,a)}var ms="_reactListening"+Math.random().toString(36).slice(2);function fs(t){if(!t[ms]){t[ms]=!0,i.forEach(function(o){o!=="selectionchange"&&(ho.has(o)||Kn(o,!1,t),Kn(o,!0,t))});var a=t.nodeType===9?t:t.ownerDocument;a===null||a[ms]||(a[ms]=!0,Kn("selectionchange",!1,a))}}function Ra(t,a,o,c){switch(Vi(a)){case 1:var _=Hi;break;case 4:_=dr;break;default:_=Zr}o=_.bind(null,a,o,t),_=void 0,!En||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(_=!0),c?_!==void 0?t.addEventListener(a,o,{capture:!0,passive:_}):t.addEventListener(a,o,!0):_!==void 0?t.addEventListener(a,o,{passive:_}):t.addEventListener(a,o,!1)}function aa(t,a,o,c,_){var y=c;if((a&1)===0&&(a&2)===0&&c!==null)e:for(;;){if(c===null)return;var j=c.tag;if(j===3||j===4){var B=c.stateNode.containerInfo;if(B===_||B.nodeType===8&&B.parentNode===_)break;if(j===4)for(j=c.return;j!==null;){var K=j.tag;if((K===3||K===4)&&(K=j.stateNode.containerInfo,K===_||K.nodeType===8&&K.parentNode===_))return;j=j.return}for(;B!==null;){if(j=oa(B),j===null)return;if(K=j.tag,K===5||K===6){c=y=j;continue e}B=B.parentNode}}c=c.return}jt(function(){var _e=y,Me=st(o),Ie=[];e:{var Ae=Al.get(t);if(Ae!==void 0){var He=Qt,Qe=t;switch(t){case"keypress":if(ja(o)===0)break e;case"keydown":case"keyup":He=Ms;break;case"focusin":Qe="focus",He=ni;break;case"focusout":Qe="blur",He=ni;break;case"beforeblur":case"afterblur":He=ni;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":He=Ki;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":He=pl;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":He=Oc;break;case co:case Tl:case uo:He=Qi;break;case mo:He=pr;break;case"scroll":He=Gi;break;case"wheel":He=ea;break;case"copy":case"cut":case"paste":He=Yi;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":He=ai}var Ze=(a&4)!==0,Yt=!Ze&&t==="scroll",me=Ze?Ae!==null?Ae+"Capture":null:Ae;Ze=[];for(var ne=_e,pe;ne!==null;){pe=ne;var De=pe.stateNode;if(pe.tag===5&&De!==null&&(pe=De,me!==null&&(De=lt(ne,me),De!=null&&Ze.push(ra(ne,De,pe)))),Yt)break;ne=ne.return}0<Ze.length&&(Ae=new He(Ae,Qe,null,o,Me),Ie.push({event:Ae,listeners:Ze}))}}if((a&7)===0){e:{if(Ae=t==="mouseover"||t==="pointerover",He=t==="mouseout"||t==="pointerout",Ae&&o!==Le&&(Qe=o.relatedTarget||o.fromElement)&&(oa(Qe)||Qe[_s]))break e;if((He||Ae)&&(Ae=Me.window===Me?Me:(Ae=Me.ownerDocument)?Ae.defaultView||Ae.parentWindow:window,He?(Qe=o.relatedTarget||o.toElement,He=_e,Qe=Qe?oa(Qe):null,Qe!==null&&(Yt=Ns(Qe),Qe!==Yt||Qe.tag!==5&&Qe.tag!==6)&&(Qe=null)):(He=null,Qe=_e),He!==Qe)){if(Ze=Ki,De="onMouseLeave",me="onMouseEnter",ne="mouse",(t==="pointerout"||t==="pointerover")&&(Ze=ai,De="onPointerLeave",me="onPointerEnter",ne="pointer"),Yt=He==null?Ae:Da(He),pe=Qe==null?Ae:Da(Qe),Ae=new Ze(De,ne+"leave",He,o,Me),Ae.target=Yt,Ae.relatedTarget=pe,De=null,oa(Me)===_e&&(Ze=new Ze(me,ne+"enter",Qe,o,Me),Ze.target=pe,Ze.relatedTarget=Yt,De=Ze),Yt=De,He&&Qe)t:{for(Ze=He,me=Qe,ne=0,pe=Ze;pe;pe=ia(pe))ne++;for(pe=0,De=me;De;De=ia(De))pe++;for(;0<ne-pe;)Ze=ia(Ze),ne--;for(;0<pe-ne;)me=ia(me),pe--;for(;ne--;){if(Ze===me||me!==null&&Ze===me.alternate)break t;Ze=ia(Ze),me=ia(me)}Ze=null}else Ze=null;He!==null&&_i(Ie,Ae,He,Ze,!1),Qe!==null&&Yt!==null&&_i(Ie,Yt,Qe,Ze,!0)}}e:{if(Ae=_e?Da(_e):window,He=Ae.nodeName&&Ae.nodeName.toLowerCase(),He==="select"||He==="input"&&Ae.type==="file")var tt=qc;else if(jl(Ae))if(Ps)tt=Uc;else{tt=ui;var at=ci}else(He=Ae.nodeName)&&He.toLowerCase()==="input"&&(Ae.type==="checkbox"||Ae.type==="radio")&&(tt=Bc);if(tt&&(tt=tt(t,_e))){Ta(Ie,tt,o,Me);break e}at&&at(t,Ae,_e),t==="focusout"&&(at=Ae._wrapperState)&&at.controlled&&Ae.type==="number"&&Ee(Ae,"number",Ae.value)}switch(at=_e?Da(_e):window,t){case"focusin":(jl(at)||at.contentEditable==="true")&&(La=at,mi=_e,zs=null);break;case"focusout":zs=mi=La=null;break;case"mousedown":fi=!0;break;case"contextmenu":case"mouseup":case"dragend":fi=!1,vr(Ie,o,Me);break;case"selectionchange":if(El)break;case"keydown":case"keyup":vr(Ie,o,Me)}var rt;if(ri)e:{switch(t){case"compositionstart":var mt="onCompositionStart";break e;case"compositionend":mt="onCompositionEnd";break e;case"compositionupdate":mt="onCompositionUpdate";break e}mt=void 0}else Rs?oi(t,o)&&(mt="onCompositionEnd"):t==="keydown"&&o.keyCode===229&&(mt="onCompositionStart");mt&&(bl&&o.locale!=="ko"&&(Rs||mt!=="onCompositionStart"?mt==="onCompositionEnd"&&Rs&&(rt=ei()):(zn=Me,cs="value"in zn?zn.value:zn.textContent,Rs=!0)),at=br(_e,mt),0<at.length&&(mt=new Zs(mt,t,null,o,Me),Ie.push({event:mt,listeners:at}),rt?mt.data=rt:(rt=no(o),rt!==null&&(mt.data=rt)))),(rt=Fc?wl(t,o):Ea(t,o))&&(_e=br(_e,"onBeforeInput"),0<_e.length&&(Me=new Zs("onBeforeInput","beforeinput",null,o,Me),Ie.push({event:Me,listeners:_e}),Me.data=rt))}ds(Ie,a)})}function ra(t,a,o){return{instance:t,listener:a,currentTarget:o}}function br(t,a){for(var o=a+"Capture",c=[];t!==null;){var _=t,y=_.stateNode;_.tag===5&&y!==null&&(_=y,y=lt(t,o),y!=null&&c.unshift(ra(t,y,_)),y=lt(t,a),y!=null&&c.push(ra(t,y,_))),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 _i(t,a,o,c,_){for(var y=a._reactName,j=[];o!==null&&o!==c;){var B=o,K=B.alternate,_e=B.stateNode;if(K!==null&&K===c)break;B.tag===5&&_e!==null&&(B=_e,_?(K=lt(o,y),K!=null&&j.unshift(ra(o,K,B))):_||(K=lt(o,y),K!=null&&j.push(ra(o,K,B)))),o=o.return}j.length!==0&&t.push({event:a,listeners:j})}var Hc=/\r\n?/g,Vc=/\u0000|\uFFFD/g;function po(t){return(typeof t=="string"?t:""+t).replace(Hc,`
38
+ `).replace(Vc,"")}function wr(t,a,o){if(a=po(a),po(t)!==a&&o)throw Error(r(425))}function hs(){}var _o=null,jn=null;function jr(t,a){return t==="textarea"||t==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var On=typeof setTimeout=="function"?setTimeout:void 0,gi=typeof clearTimeout=="function"?clearTimeout:void 0,yi=typeof Promise=="function"?Promise:void 0,ps=typeof queueMicrotask=="function"?queueMicrotask:typeof yi<"u"?function(t){return yi.resolve(null).then(t).catch(Xn)}:On;function Xn(t){setTimeout(function(){throw t})}function Pa(t,a){var o=a,c=0;do{var _=o.nextSibling;if(t.removeChild(o),_&&_.nodeType===8)if(o=_.data,o==="/$"){if(c===0){t.removeChild(_),wa(a);return}c--}else o!=="$"&&o!=="$?"&&o!=="$!"||c++;o=_}while(o);wa(a)}function Is(t){for(;t!=null;t=t.nextSibling){var a=t.nodeType;if(a===1||a===3)break;if(a===8){if(a=t.data,a==="$"||a==="$!"||a==="$?")break;if(a==="/$")return null}}return t}function vi(t){t=t.previousSibling;for(var a=0;t;){if(t.nodeType===8){var o=t.data;if(o==="$"||o==="$!"||o==="$?"){if(a===0)return t;a--}else o==="/$"&&a++}t=t.previousSibling}return null}var za=Math.random().toString(36).slice(2),Zn="__reactFiber$"+za,Ia="__reactProps$"+za,_s="__reactContainer$"+za,go="__reactEvents$"+za,Rl="__reactListeners$"+za,Gc="__reactHandles$"+za;function oa(t){var a=t[Zn];if(a)return a;for(var o=t.parentNode;o;){if(a=o[_s]||o[Zn]){if(o=a.alternate,a.child!==null||o!==null&&o.child!==null)for(t=vi(t);t!==null;){if(o=t[Zn])return o;t=vi(t)}return a}t=o,o=t.parentNode}return null}function kr(t){return t=t[Zn]||t[_s],!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 xi(t){return t[Ia]||null}var Sr=[],Oa=-1;function Ds(t){return{current:t}}function Rt(t){0>Oa||(t.current=Sr[Oa],Sr[Oa]=null,Oa--)}function Lt(t,a){Oa++,Sr[Oa]=t.current,t.current=a}var gs={},sn=Ds(gs),kn=Ds(!1),Os=gs;function la(t,a){var o=t.type.contextTypes;if(!o)return gs;var c=t.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===a)return c.__reactInternalMemoizedMaskedChildContext;var _={},y;for(y in o)_[y]=a[y];return c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=a,t.__reactInternalMemoizedMaskedChildContext=_),_}function pn(t){return t=t.childContextTypes,t!=null}function Nr(){Rt(kn),Rt(sn)}function yo(t,a,o){if(sn.current!==gs)throw Error(r(168));Lt(sn,a),Lt(kn,o)}function vo(t,a,o){var c=t.stateNode;if(a=a.childContextTypes,typeof c.getChildContext!="function")return o;c=c.getChildContext();for(var _ in c)if(!(_ in a))throw Error(r(108,we(t)||"Unknown",_));return ae({},o,c)}function p(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||gs,Os=sn.current,Lt(sn,t),Lt(kn,kn.current),!0}function b(t,a,o){var c=t.stateNode;if(!c)throw Error(r(169));o?(t=vo(t,a,Os),c.__reactInternalMemoizedMergedChildContext=t,Rt(kn),Rt(sn),Lt(sn,t)):Rt(kn),Lt(kn,o)}var N=null,S=!1,D=!1;function le(t){N===null?N=[t]:N.push(t)}function G(t){S=!0,le(t)}function ve(){if(!D&&N!==null){D=!0;var t=0,a=kt;try{var o=N;for(kt=1;t<o.length;t++){var c=o[t];do c=c(!0);while(c!==null)}N=null,S=!1}catch(_){throw N!==null&&(N=N.slice(t+1)),rr(Hr,ve),_}finally{kt=a,D=!1}}return null}var ze=[],qe=0,We=null,Pt=0,Nt=[],Ht=0,yt=null,nt=1,Ft="";function Ct(t,a){ze[qe++]=Pt,ze[qe++]=We,We=t,Pt=a}function Ge(t,a,o){Nt[Ht++]=nt,Nt[Ht++]=Ft,Nt[Ht++]=yt,yt=t;var c=nt;t=Ft;var _=32-fn(c)-1;c&=~(1<<_),o+=1;var y=32-fn(a)+_;if(30<y){var j=_-_%5;y=(c&(1<<j)-1).toString(32),c>>=j,_-=j,nt=1<<32-fn(a)+_|o<<_|c,Ft=y+t}else nt=1<<y|o<<_|c,Ft=t}function It(t){t.return!==null&&(Ct(t,1),Ge(t,1,0))}function _n(t){for(;t===We;)We=ze[--qe],ze[qe]=null,Pt=ze[--qe],ze[qe]=null;for(;t===yt;)yt=Nt[--Ht],Nt[Ht]=null,Ft=Nt[--Ht],Nt[Ht]=null,nt=Nt[--Ht],Nt[Ht]=null}var Mt=null,$t=null,ut=!1,Tt=null;function Cr(t,a){var o=ss(5,null,null,0);o.elementType="DELETED",o.stateNode=a,o.return=t,a=t.deletions,a===null?(t.deletions=[o],t.flags|=16):a.push(o)}function im(t,a){switch(t.tag){case 5:var o=t.type;return a=a.nodeType!==1||o.toLowerCase()!==a.nodeName.toLowerCase()?null:a,a!==null?(t.stateNode=a,Mt=t,$t=Is(a.firstChild),!0):!1;case 6:return a=t.pendingProps===""||a.nodeType!==3?null:a,a!==null?(t.stateNode=a,Mt=t,$t=null,!0):!1;case 13:return a=a.nodeType!==8?null:a,a!==null?(o=yt!==null?{id:nt,overflow:Ft}:null,t.memoizedState={dehydrated:a,treeContext:o,retryLane:1073741824},o=ss(18,null,null,0),o.stateNode=a,o.return=t,t.child=o,Mt=t,$t=null,!0):!1;default:return!1}}function Kc(t){return(t.mode&1)!==0&&(t.flags&128)===0}function Jc(t){if(ut){var a=$t;if(a){var o=a;if(!im(t,a)){if(Kc(t))throw Error(r(418));a=Is(o.nextSibling);var c=Mt;a&&im(t,a)?Cr(c,o):(t.flags=t.flags&-4097|2,ut=!1,Mt=t)}}else{if(Kc(t))throw Error(r(418));t.flags=t.flags&-4097|2,ut=!1,Mt=t}}}function om(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;Mt=t}function Pl(t){if(t!==Mt)return!1;if(!ut)return om(t),ut=!0,!1;var a;if((a=t.tag!==3)&&!(a=t.tag!==5)&&(a=t.type,a=a!=="head"&&a!=="body"&&!jr(t.type,t.memoizedProps)),a&&(a=$t)){if(Kc(t))throw lm(),Error(r(418));for(;a;)Cr(t,a),a=Is(a.nextSibling)}if(om(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(r(317));e:{for(t=t.nextSibling,a=0;t;){if(t.nodeType===8){var o=t.data;if(o==="/$"){if(a===0){$t=Is(t.nextSibling);break e}a--}else o!=="$"&&o!=="$!"&&o!=="$?"||a++}t=t.nextSibling}$t=null}}else $t=Mt?Is(t.stateNode.nextSibling):null;return!0}function lm(){for(var t=$t;t;)t=Is(t.nextSibling)}function bi(){$t=Mt=null,ut=!1}function Qc(t){Tt===null?Tt=[t]:Tt.push(t)}var g_=M.ReactCurrentBatchConfig;function xo(t,a,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,y=""+t;return a!==null&&a.ref!==null&&typeof a.ref=="function"&&a.ref._stringRef===y?a.ref:(a=function(j){var B=_.refs;j===null?delete B[y]:B[y]=j},a._stringRef=y,a)}if(typeof t!="string")throw Error(r(284));if(!o._owner)throw Error(r(290,t))}return t}function zl(t,a){throw t=Object.prototype.toString.call(a),Error(r(31,t==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":t))}function cm(t){var a=t._init;return a(t._payload)}function um(t){function a(me,ne){if(t){var pe=me.deletions;pe===null?(me.deletions=[ne],me.flags|=16):pe.push(ne)}}function o(me,ne){if(!t)return null;for(;ne!==null;)a(me,ne),ne=ne.sibling;return null}function c(me,ne){for(me=new Map;ne!==null;)ne.key!==null?me.set(ne.key,ne):me.set(ne.index,ne),ne=ne.sibling;return me}function _(me,ne){return me=Ga(me,ne),me.index=0,me.sibling=null,me}function y(me,ne,pe){return me.index=pe,t?(pe=me.alternate,pe!==null?(pe=pe.index,pe<ne?(me.flags|=2,ne):pe):(me.flags|=2,ne)):(me.flags|=1048576,ne)}function j(me){return t&&me.alternate===null&&(me.flags|=2),me}function B(me,ne,pe,De){return ne===null||ne.tag!==6?(ne=qu(pe,me.mode,De),ne.return=me,ne):(ne=_(ne,pe),ne.return=me,ne)}function K(me,ne,pe,De){var tt=pe.type;return tt===Q?Me(me,ne,pe.props.children,De,pe.key):ne!==null&&(ne.elementType===tt||typeof tt=="object"&&tt!==null&&tt.$$typeof===U&&cm(tt)===ne.type)?(De=_(ne,pe.props),De.ref=xo(me,ne,pe),De.return=me,De):(De=ic(pe.type,pe.key,pe.props,null,me.mode,De),De.ref=xo(me,ne,pe),De.return=me,De)}function _e(me,ne,pe,De){return ne===null||ne.tag!==4||ne.stateNode.containerInfo!==pe.containerInfo||ne.stateNode.implementation!==pe.implementation?(ne=Bu(pe,me.mode,De),ne.return=me,ne):(ne=_(ne,pe.children||[]),ne.return=me,ne)}function Me(me,ne,pe,De,tt){return ne===null||ne.tag!==7?(ne=Pr(pe,me.mode,De,tt),ne.return=me,ne):(ne=_(ne,pe),ne.return=me,ne)}function Ie(me,ne,pe){if(typeof ne=="string"&&ne!==""||typeof ne=="number")return ne=qu(""+ne,me.mode,pe),ne.return=me,ne;if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case A:return pe=ic(ne.type,ne.key,ne.props,null,me.mode,pe),pe.ref=xo(me,null,ne),pe.return=me,pe;case V:return ne=Bu(ne,me.mode,pe),ne.return=me,ne;case U:var De=ne._init;return Ie(me,De(ne._payload),pe)}if(se(ne)||ee(ne))return ne=Pr(ne,me.mode,pe,null),ne.return=me,ne;zl(me,ne)}return null}function Ae(me,ne,pe,De){var tt=ne!==null?ne.key:null;if(typeof pe=="string"&&pe!==""||typeof pe=="number")return tt!==null?null:B(me,ne,""+pe,De);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case A:return pe.key===tt?K(me,ne,pe,De):null;case V:return pe.key===tt?_e(me,ne,pe,De):null;case U:return tt=pe._init,Ae(me,ne,tt(pe._payload),De)}if(se(pe)||ee(pe))return tt!==null?null:Me(me,ne,pe,De,null);zl(me,pe)}return null}function He(me,ne,pe,De,tt){if(typeof De=="string"&&De!==""||typeof De=="number")return me=me.get(pe)||null,B(ne,me,""+De,tt);if(typeof De=="object"&&De!==null){switch(De.$$typeof){case A:return me=me.get(De.key===null?pe:De.key)||null,K(ne,me,De,tt);case V:return me=me.get(De.key===null?pe:De.key)||null,_e(ne,me,De,tt);case U:var at=De._init;return He(me,ne,pe,at(De._payload),tt)}if(se(De)||ee(De))return me=me.get(pe)||null,Me(ne,me,De,tt,null);zl(ne,De)}return null}function Qe(me,ne,pe,De){for(var tt=null,at=null,rt=ne,mt=ne=0,dn=null;rt!==null&&mt<pe.length;mt++){rt.index>mt?(dn=rt,rt=null):dn=rt.sibling;var St=Ae(me,rt,pe[mt],De);if(St===null){rt===null&&(rt=dn);break}t&&rt&&St.alternate===null&&a(me,rt),ne=y(St,ne,mt),at===null?tt=St:at.sibling=St,at=St,rt=dn}if(mt===pe.length)return o(me,rt),ut&&Ct(me,mt),tt;if(rt===null){for(;mt<pe.length;mt++)rt=Ie(me,pe[mt],De),rt!==null&&(ne=y(rt,ne,mt),at===null?tt=rt:at.sibling=rt,at=rt);return ut&&Ct(me,mt),tt}for(rt=c(me,rt);mt<pe.length;mt++)dn=He(rt,me,mt,pe[mt],De),dn!==null&&(t&&dn.alternate!==null&&rt.delete(dn.key===null?mt:dn.key),ne=y(dn,ne,mt),at===null?tt=dn:at.sibling=dn,at=dn);return t&&rt.forEach(function(Ka){return a(me,Ka)}),ut&&Ct(me,mt),tt}function Ze(me,ne,pe,De){var tt=ee(pe);if(typeof tt!="function")throw Error(r(150));if(pe=tt.call(pe),pe==null)throw Error(r(151));for(var at=tt=null,rt=ne,mt=ne=0,dn=null,St=pe.next();rt!==null&&!St.done;mt++,St=pe.next()){rt.index>mt?(dn=rt,rt=null):dn=rt.sibling;var Ka=Ae(me,rt,St.value,De);if(Ka===null){rt===null&&(rt=dn);break}t&&rt&&Ka.alternate===null&&a(me,rt),ne=y(Ka,ne,mt),at===null?tt=Ka:at.sibling=Ka,at=Ka,rt=dn}if(St.done)return o(me,rt),ut&&Ct(me,mt),tt;if(rt===null){for(;!St.done;mt++,St=pe.next())St=Ie(me,St.value,De),St!==null&&(ne=y(St,ne,mt),at===null?tt=St:at.sibling=St,at=St);return ut&&Ct(me,mt),tt}for(rt=c(me,rt);!St.done;mt++,St=pe.next())St=He(rt,me,mt,St.value,De),St!==null&&(t&&St.alternate!==null&&rt.delete(St.key===null?mt:St.key),ne=y(St,ne,mt),at===null?tt=St:at.sibling=St,at=St);return t&&rt.forEach(function(Q_){return a(me,Q_)}),ut&&Ct(me,mt),tt}function Yt(me,ne,pe,De){if(typeof pe=="object"&&pe!==null&&pe.type===Q&&pe.key===null&&(pe=pe.props.children),typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case A:e:{for(var tt=pe.key,at=ne;at!==null;){if(at.key===tt){if(tt=pe.type,tt===Q){if(at.tag===7){o(me,at.sibling),ne=_(at,pe.props.children),ne.return=me,me=ne;break e}}else if(at.elementType===tt||typeof tt=="object"&&tt!==null&&tt.$$typeof===U&&cm(tt)===at.type){o(me,at.sibling),ne=_(at,pe.props),ne.ref=xo(me,at,pe),ne.return=me,me=ne;break e}o(me,at);break}else a(me,at);at=at.sibling}pe.type===Q?(ne=Pr(pe.props.children,me.mode,De,pe.key),ne.return=me,me=ne):(De=ic(pe.type,pe.key,pe.props,null,me.mode,De),De.ref=xo(me,ne,pe),De.return=me,me=De)}return j(me);case V:e:{for(at=pe.key;ne!==null;){if(ne.key===at)if(ne.tag===4&&ne.stateNode.containerInfo===pe.containerInfo&&ne.stateNode.implementation===pe.implementation){o(me,ne.sibling),ne=_(ne,pe.children||[]),ne.return=me,me=ne;break e}else{o(me,ne);break}else a(me,ne);ne=ne.sibling}ne=Bu(pe,me.mode,De),ne.return=me,me=ne}return j(me);case U:return at=pe._init,Yt(me,ne,at(pe._payload),De)}if(se(pe))return Qe(me,ne,pe,De);if(ee(pe))return Ze(me,ne,pe,De);zl(me,pe)}return typeof pe=="string"&&pe!==""||typeof pe=="number"?(pe=""+pe,ne!==null&&ne.tag===6?(o(me,ne.sibling),ne=_(ne,pe),ne.return=me,me=ne):(o(me,ne),ne=qu(pe,me.mode,De),ne.return=me,me=ne),j(me)):o(me,ne)}return Yt}var wi=um(!0),dm=um(!1),Il=Ds(null),Dl=null,ji=null,Yc=null;function Xc(){Yc=ji=Dl=null}function Zc(t){var a=Il.current;Rt(Il),t._currentValue=a}function eu(t,a,o){for(;t!==null;){var c=t.alternate;if((t.childLanes&a)!==a?(t.childLanes|=a,c!==null&&(c.childLanes|=a)):c!==null&&(c.childLanes&a)!==a&&(c.childLanes|=a),t===o)break;t=t.return}}function ki(t,a){Dl=t,Yc=ji=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&a)!==0&&(Fn=!0),t.firstContext=null)}function es(t){var a=t._currentValue;if(Yc!==t)if(t={context:t,memoizedValue:a,next:null},ji===null){if(Dl===null)throw Error(r(308));ji=t,Dl.dependencies={lanes:0,firstContext:t}}else ji=ji.next=t;return a}var $r=null;function tu(t){$r===null?$r=[t]:$r.push(t)}function mm(t,a,o,c){var _=a.interleaved;return _===null?(o.next=o,tu(a)):(o.next=_.next,_.next=o),a.interleaved=o,ca(t,c)}function ca(t,a){t.lanes|=a;var o=t.alternate;for(o!==null&&(o.lanes|=a),o=t,t=t.return;t!==null;)t.childLanes|=a,o=t.alternate,o!==null&&(o.childLanes|=a),o=t,t=t.return;return o.tag===3?o.stateNode:null}var Fa=!1;function nu(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function fm(t,a){t=t.updateQueue,a.updateQueue===t&&(a.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function ua(t,a){return{eventTime:t,lane:a,tag:0,payload:null,callback:null,next:null}}function qa(t,a,o){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(bt&2)!==0){var _=c.pending;return _===null?a.next=a:(a.next=_.next,_.next=a),c.pending=a,ca(t,o)}return _=c.interleaved,_===null?(a.next=a,tu(c)):(a.next=_.next,_.next=a),c.interleaved=a,ca(t,o)}function Ol(t,a,o){if(a=a.updateQueue,a!==null&&(a=a.shared,(o&4194240)!==0)){var c=a.lanes;c&=t.pendingLanes,o|=c,a.lanes=o,Es(t,o)}}function hm(t,a){var o=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,o===c)){var _=null,y=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};y===null?_=y=j:y=y.next=j,o=o.next}while(o!==null);y===null?_=y=a:y=y.next=a}else _=y=a;o={baseState:c.baseState,firstBaseUpdate:_,lastBaseUpdate:y,shared:c.shared,effects:c.effects},t.updateQueue=o;return}t=o.lastBaseUpdate,t===null?o.firstBaseUpdate=a:t.next=a,o.lastBaseUpdate=a}function Fl(t,a,o,c){var _=t.updateQueue;Fa=!1;var y=_.firstBaseUpdate,j=_.lastBaseUpdate,B=_.shared.pending;if(B!==null){_.shared.pending=null;var K=B,_e=K.next;K.next=null,j===null?y=_e:j.next=_e,j=K;var Me=t.alternate;Me!==null&&(Me=Me.updateQueue,B=Me.lastBaseUpdate,B!==j&&(B===null?Me.firstBaseUpdate=_e:B.next=_e,Me.lastBaseUpdate=K))}if(y!==null){var Ie=_.baseState;j=0,Me=_e=K=null,B=y;do{var Ae=B.lane,He=B.eventTime;if((c&Ae)===Ae){Me!==null&&(Me=Me.next={eventTime:He,lane:0,tag:B.tag,payload:B.payload,callback:B.callback,next:null});e:{var Qe=t,Ze=B;switch(Ae=a,He=o,Ze.tag){case 1:if(Qe=Ze.payload,typeof Qe=="function"){Ie=Qe.call(He,Ie,Ae);break e}Ie=Qe;break e;case 3:Qe.flags=Qe.flags&-65537|128;case 0:if(Qe=Ze.payload,Ae=typeof Qe=="function"?Qe.call(He,Ie,Ae):Qe,Ae==null)break e;Ie=ae({},Ie,Ae);break e;case 2:Fa=!0}}B.callback!==null&&B.lane!==0&&(t.flags|=64,Ae=_.effects,Ae===null?_.effects=[B]:Ae.push(B))}else He={eventTime:He,lane:Ae,tag:B.tag,payload:B.payload,callback:B.callback,next:null},Me===null?(_e=Me=He,K=Ie):Me=Me.next=He,j|=Ae;if(B=B.next,B===null){if(B=_.shared.pending,B===null)break;Ae=B,B=Ae.next,Ae.next=null,_.lastBaseUpdate=Ae,_.shared.pending=null}}while(!0);if(Me===null&&(K=Ie),_.baseState=K,_.firstBaseUpdate=_e,_.lastBaseUpdate=Me,a=_.shared.interleaved,a!==null){_=a;do j|=_.lane,_=_.next;while(_!==a)}else y===null&&(_.shared.lanes=0);Ar|=j,t.lanes=j,t.memoizedState=Ie}}function pm(t,a,o){if(t=a.effects,a.effects=null,t!==null)for(a=0;a<t.length;a++){var c=t[a],_=c.callback;if(_!==null){if(c.callback=null,c=o,typeof _!="function")throw Error(r(191,_));_.call(c)}}}var bo={},Fs=Ds(bo),wo=Ds(bo),jo=Ds(bo);function Er(t){if(t===bo)throw Error(r(174));return t}function su(t,a){switch(Lt(jo,a),Lt(wo,t),Lt(Fs,bo),t=a.nodeType,t){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:ye(null,"");break;default:t=t===8?a.parentNode:a,a=t.namespaceURI||null,t=t.tagName,a=ye(a,t)}Rt(Fs),Lt(Fs,a)}function Si(){Rt(Fs),Rt(wo),Rt(jo)}function _m(t){Er(jo.current);var a=Er(Fs.current),o=ye(a,t.type);a!==o&&(Lt(wo,t),Lt(Fs,o))}function au(t){wo.current===t&&(Rt(Fs),Rt(wo))}var Bt=Ds(0);function ql(t){for(var a=t;a!==null;){if(a.tag===13){var o=a.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||o.data==="$?"||o.data==="$!"))return a}else if(a.tag===19&&a.memoizedProps.revealOrder!==void 0){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var ru=[];function iu(){for(var t=0;t<ru.length;t++)ru[t]._workInProgressVersionPrimary=null;ru.length=0}var Bl=M.ReactCurrentDispatcher,ou=M.ReactCurrentBatchConfig,Tr=0,Ut=null,an=null,cn=null,Ul=!1,ko=!1,So=0,y_=0;function Sn(){throw Error(r(321))}function lu(t,a){if(a===null)return!1;for(var o=0;o<a.length&&o<t.length;o++)if(!In(t[o],a[o]))return!1;return!0}function cu(t,a,o,c,_,y){if(Tr=y,Ut=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,Bl.current=t===null||t.memoizedState===null?w_:j_,t=o(c,_),ko){y=0;do{if(ko=!1,So=0,25<=y)throw Error(r(301));y+=1,cn=an=null,a.updateQueue=null,Bl.current=k_,t=o(c,_)}while(ko)}if(Bl.current=Vl,a=an!==null&&an.next!==null,Tr=0,cn=an=Ut=null,Ul=!1,a)throw Error(r(300));return t}function uu(){var t=So!==0;return So=0,t}function qs(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return cn===null?Ut.memoizedState=cn=t:cn=cn.next=t,cn}function ts(){if(an===null){var t=Ut.alternate;t=t!==null?t.memoizedState:null}else t=an.next;var a=cn===null?Ut.memoizedState:cn.next;if(a!==null)cn=a,an=t;else{if(t===null)throw Error(r(310));an=t,t={memoizedState:an.memoizedState,baseState:an.baseState,baseQueue:an.baseQueue,queue:an.queue,next:null},cn===null?Ut.memoizedState=cn=t:cn=cn.next=t}return cn}function No(t,a){return typeof a=="function"?a(t):a}function du(t){var a=ts(),o=a.queue;if(o===null)throw Error(r(311));o.lastRenderedReducer=t;var c=an,_=c.baseQueue,y=o.pending;if(y!==null){if(_!==null){var j=_.next;_.next=y.next,y.next=j}c.baseQueue=_=y,o.pending=null}if(_!==null){y=_.next,c=c.baseState;var B=j=null,K=null,_e=y;do{var Me=_e.lane;if((Tr&Me)===Me)K!==null&&(K=K.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 Ie={lane:Me,action:_e.action,hasEagerState:_e.hasEagerState,eagerState:_e.eagerState,next:null};K===null?(B=K=Ie,j=c):K=K.next=Ie,Ut.lanes|=Me,Ar|=Me}_e=_e.next}while(_e!==null&&_e!==y);K===null?j=c:K.next=B,In(c,a.memoizedState)||(Fn=!0),a.memoizedState=c,a.baseState=j,a.baseQueue=K,o.lastRenderedState=c}if(t=o.interleaved,t!==null){_=t;do y=_.lane,Ut.lanes|=y,Ar|=y,_=_.next;while(_!==t)}else _===null&&(o.lanes=0);return[a.memoizedState,o.dispatch]}function mu(t){var a=ts(),o=a.queue;if(o===null)throw Error(r(311));o.lastRenderedReducer=t;var c=o.dispatch,_=o.pending,y=a.memoizedState;if(_!==null){o.pending=null;var j=_=_.next;do y=t(y,j.action),j=j.next;while(j!==_);In(y,a.memoizedState)||(Fn=!0),a.memoizedState=y,a.baseQueue===null&&(a.baseState=y),o.lastRenderedState=y}return[y,c]}function gm(){}function ym(t,a){var o=Ut,c=ts(),_=a(),y=!In(c.memoizedState,_);if(y&&(c.memoizedState=_,Fn=!0),c=c.queue,fu(bm.bind(null,o,c,t),[t]),c.getSnapshot!==a||y||cn!==null&&cn.memoizedState.tag&1){if(o.flags|=2048,Co(9,xm.bind(null,o,c,_,a),void 0,null),un===null)throw Error(r(349));(Tr&30)!==0||vm(o,a,_)}return _}function vm(t,a,o){t.flags|=16384,t={getSnapshot:a,value:o},a=Ut.updateQueue,a===null?(a={lastEffect:null,stores:null},Ut.updateQueue=a,a.stores=[t]):(o=a.stores,o===null?a.stores=[t]:o.push(t))}function xm(t,a,o,c){a.value=o,a.getSnapshot=c,wm(a)&&jm(t)}function bm(t,a,o){return o(function(){wm(a)&&jm(t)})}function wm(t){var a=t.getSnapshot;t=t.value;try{var o=a();return!In(t,o)}catch{return!0}}function jm(t){var a=ca(t,1);a!==null&&bs(a,t,1,-1)}function km(t){var a=qs();return typeof t=="function"&&(t=t()),a.memoizedState=a.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:No,lastRenderedState:t},a.queue=t,t=t.dispatch=b_.bind(null,Ut,t),[a.memoizedState,t]}function Co(t,a,o,c){return t={tag:t,create:a,destroy:o,deps:c,next:null},a=Ut.updateQueue,a===null?(a={lastEffect:null,stores:null},Ut.updateQueue=a,a.lastEffect=t.next=t):(o=a.lastEffect,o===null?a.lastEffect=t.next=t:(c=o.next,o.next=t,t.next=c,a.lastEffect=t)),t}function Sm(){return ts().memoizedState}function Wl(t,a,o,c){var _=qs();Ut.flags|=t,_.memoizedState=Co(1|a,o,void 0,c===void 0?null:c)}function Hl(t,a,o,c){var _=ts();c=c===void 0?null:c;var y=void 0;if(an!==null){var j=an.memoizedState;if(y=j.destroy,c!==null&&lu(c,j.deps)){_.memoizedState=Co(a,o,y,c);return}}Ut.flags|=t,_.memoizedState=Co(1|a,o,y,c)}function Nm(t,a){return Wl(8390656,8,t,a)}function fu(t,a){return Hl(2048,8,t,a)}function Cm(t,a){return Hl(4,2,t,a)}function $m(t,a){return Hl(4,4,t,a)}function Em(t,a){if(typeof a=="function")return t=t(),a(t),function(){a(null)};if(a!=null)return t=t(),a.current=t,function(){a.current=null}}function Tm(t,a,o){return o=o!=null?o.concat([t]):null,Hl(4,4,Em.bind(null,a,t),o)}function hu(){}function Am(t,a){var o=ts();a=a===void 0?null:a;var c=o.memoizedState;return c!==null&&a!==null&&lu(a,c[1])?c[0]:(o.memoizedState=[t,a],t)}function Lm(t,a){var o=ts();a=a===void 0?null:a;var c=o.memoizedState;return c!==null&&a!==null&&lu(a,c[1])?c[0]:(t=t(),o.memoizedState=[t,a],t)}function Mm(t,a,o){return(Tr&21)===0?(t.baseState&&(t.baseState=!1,Fn=!0),t.memoizedState=o):(In(o,a)||(o=Kt(),Ut.lanes|=o,Ar|=o,t.baseState=!0),a)}function v_(t,a){var o=kt;kt=o!==0&&4>o?o:4,t(!0);var c=ou.transition;ou.transition={};try{t(!1),a()}finally{kt=o,ou.transition=c}}function Rm(){return ts().memoizedState}function x_(t,a,o){var c=Ha(t);if(o={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null},Pm(t))zm(a,o);else if(o=mm(t,a,o,c),o!==null){var _=Ln();bs(o,t,c,_),Im(o,a,c)}}function b_(t,a,o){var c=Ha(t),_={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null};if(Pm(t))zm(a,_);else{var y=t.alternate;if(t.lanes===0&&(y===null||y.lanes===0)&&(y=a.lastRenderedReducer,y!==null))try{var j=a.lastRenderedState,B=y(j,o);if(_.hasEagerState=!0,_.eagerState=B,In(B,j)){var K=a.interleaved;K===null?(_.next=_,tu(a)):(_.next=K.next,K.next=_),a.interleaved=_;return}}catch{}finally{}o=mm(t,a,_,c),o!==null&&(_=Ln(),bs(o,t,c,_),Im(o,a,c))}}function Pm(t){var a=t.alternate;return t===Ut||a!==null&&a===Ut}function zm(t,a){ko=Ul=!0;var o=t.pending;o===null?a.next=a:(a.next=o.next,o.next=a),t.pending=a}function Im(t,a,o){if((o&4194240)!==0){var c=a.lanes;c&=t.pendingLanes,o|=c,a.lanes=o,Es(t,o)}}var Vl={readContext:es,useCallback:Sn,useContext:Sn,useEffect:Sn,useImperativeHandle:Sn,useInsertionEffect:Sn,useLayoutEffect:Sn,useMemo:Sn,useReducer:Sn,useRef:Sn,useState:Sn,useDebugValue:Sn,useDeferredValue:Sn,useTransition:Sn,useMutableSource:Sn,useSyncExternalStore:Sn,useId:Sn,unstable_isNewReconciler:!1},w_={readContext:es,useCallback:function(t,a){return qs().memoizedState=[t,a===void 0?null:a],t},useContext:es,useEffect:Nm,useImperativeHandle:function(t,a,o){return o=o!=null?o.concat([t]):null,Wl(4194308,4,Em.bind(null,a,t),o)},useLayoutEffect:function(t,a){return Wl(4194308,4,t,a)},useInsertionEffect:function(t,a){return Wl(4,2,t,a)},useMemo:function(t,a){var o=qs();return a=a===void 0?null:a,t=t(),o.memoizedState=[t,a],t},useReducer:function(t,a,o){var c=qs();return a=o!==void 0?o(a):a,c.memoizedState=c.baseState=a,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:a},c.queue=t,t=t.dispatch=x_.bind(null,Ut,t),[c.memoizedState,t]},useRef:function(t){var a=qs();return t={current:t},a.memoizedState=t},useState:km,useDebugValue:hu,useDeferredValue:function(t){return qs().memoizedState=t},useTransition:function(){var t=km(!1),a=t[0];return t=v_.bind(null,t[1]),qs().memoizedState=t,[a,t]},useMutableSource:function(){},useSyncExternalStore:function(t,a,o){var c=Ut,_=qs();if(ut){if(o===void 0)throw Error(r(407));o=o()}else{if(o=a(),un===null)throw Error(r(349));(Tr&30)!==0||vm(c,a,o)}_.memoizedState=o;var y={value:o,getSnapshot:a};return _.queue=y,Nm(bm.bind(null,c,y,t),[t]),c.flags|=2048,Co(9,xm.bind(null,c,y,o,a),void 0,null),o},useId:function(){var t=qs(),a=un.identifierPrefix;if(ut){var o=Ft,c=nt;o=(c&~(1<<32-fn(c)-1)).toString(32)+o,a=":"+a+"R"+o,o=So++,0<o&&(a+="H"+o.toString(32)),a+=":"}else o=y_++,a=":"+a+"r"+o.toString(32)+":";return t.memoizedState=a},unstable_isNewReconciler:!1},j_={readContext:es,useCallback:Am,useContext:es,useEffect:fu,useImperativeHandle:Tm,useInsertionEffect:Cm,useLayoutEffect:$m,useMemo:Lm,useReducer:du,useRef:Sm,useState:function(){return du(No)},useDebugValue:hu,useDeferredValue:function(t){var a=ts();return Mm(a,an.memoizedState,t)},useTransition:function(){var t=du(No)[0],a=ts().memoizedState;return[t,a]},useMutableSource:gm,useSyncExternalStore:ym,useId:Rm,unstable_isNewReconciler:!1},k_={readContext:es,useCallback:Am,useContext:es,useEffect:fu,useImperativeHandle:Tm,useInsertionEffect:Cm,useLayoutEffect:$m,useMemo:Lm,useReducer:mu,useRef:Sm,useState:function(){return mu(No)},useDebugValue:hu,useDeferredValue:function(t){var a=ts();return an===null?a.memoizedState=t:Mm(a,an.memoizedState,t)},useTransition:function(){var t=mu(No)[0],a=ts().memoizedState;return[t,a]},useMutableSource:gm,useSyncExternalStore:ym,useId:Rm,unstable_isNewReconciler:!1};function ys(t,a){if(t&&t.defaultProps){a=ae({},a),t=t.defaultProps;for(var o in t)a[o]===void 0&&(a[o]=t[o]);return a}return a}function pu(t,a,o,c){a=t.memoizedState,o=o(c,a),o=o==null?a:ae({},a,o),t.memoizedState=o,t.lanes===0&&(t.updateQueue.baseState=o)}var Gl={isMounted:function(t){return(t=t._reactInternals)?Ns(t)===t:!1},enqueueSetState:function(t,a,o){t=t._reactInternals;var c=Ln(),_=Ha(t),y=ua(c,_);y.payload=a,o!=null&&(y.callback=o),a=qa(t,y,_),a!==null&&(bs(a,t,_,c),Ol(a,t,_))},enqueueReplaceState:function(t,a,o){t=t._reactInternals;var c=Ln(),_=Ha(t),y=ua(c,_);y.tag=1,y.payload=a,o!=null&&(y.callback=o),a=qa(t,y,_),a!==null&&(bs(a,t,_,c),Ol(a,t,_))},enqueueForceUpdate:function(t,a){t=t._reactInternals;var o=Ln(),c=Ha(t),_=ua(o,c);_.tag=2,a!=null&&(_.callback=a),a=qa(t,_,c),a!==null&&(bs(a,t,c,o),Ol(a,t,c))}};function Dm(t,a,o,c,_,y,j){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,y,j):a.prototype&&a.prototype.isPureReactComponent?!yr(o,c)||!yr(_,y):!0}function Om(t,a,o){var c=!1,_=gs,y=a.contextType;return typeof y=="object"&&y!==null?y=es(y):(_=pn(a)?Os:sn.current,c=a.contextTypes,y=(c=c!=null)?la(t,_):gs),a=new a(o,y),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Gl,t.stateNode=a,a._reactInternals=t,c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=_,t.__reactInternalMemoizedMaskedChildContext=y),a}function Fm(t,a,o,c){t=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(o,c),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(o,c),a.state!==t&&Gl.enqueueReplaceState(a,a.state,null)}function _u(t,a,o,c){var _=t.stateNode;_.props=o,_.state=t.memoizedState,_.refs={},nu(t);var y=a.contextType;typeof y=="object"&&y!==null?_.context=es(y):(y=pn(a)?Os:sn.current,_.context=la(t,y)),_.state=t.memoizedState,y=a.getDerivedStateFromProps,typeof y=="function"&&(pu(t,a,y,o),_.state=t.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof _.getSnapshotBeforeUpdate=="function"||typeof _.UNSAFE_componentWillMount!="function"&&typeof _.componentWillMount!="function"||(a=_.state,typeof _.componentWillMount=="function"&&_.componentWillMount(),typeof _.UNSAFE_componentWillMount=="function"&&_.UNSAFE_componentWillMount(),a!==_.state&&Gl.enqueueReplaceState(_,_.state,null),Fl(t,o,_,c),_.state=t.memoizedState),typeof _.componentDidMount=="function"&&(t.flags|=4194308)}function Ni(t,a){try{var o="",c=a;do o+=ce(c),c=c.return;while(c);var _=o}catch(y){_=`
39
+ Error generating stack: `+y.message+`
40
+ `+y.stack}return{value:t,source:a,stack:_,digest:null}}function gu(t,a,o){return{value:t,source:null,stack:o??null,digest:a??null}}function yu(t,a){try{console.error(a.value)}catch(o){setTimeout(function(){throw o})}}var S_=typeof WeakMap=="function"?WeakMap:Map;function qm(t,a,o){o=ua(-1,o),o.tag=3,o.payload={element:null};var c=a.value;return o.callback=function(){ec||(ec=!0,Mu=c),yu(t,a)},o}function Bm(t,a,o){o=ua(-1,o),o.tag=3;var c=t.type.getDerivedStateFromError;if(typeof c=="function"){var _=a.value;o.payload=function(){return c(_)},o.callback=function(){yu(t,a)}}var y=t.stateNode;return y!==null&&typeof y.componentDidCatch=="function"&&(o.callback=function(){yu(t,a),typeof c!="function"&&(Ua===null?Ua=new Set([this]):Ua.add(this));var j=a.stack;this.componentDidCatch(a.value,{componentStack:j!==null?j:""})}),o}function Um(t,a,o){var c=t.pingCache;if(c===null){c=t.pingCache=new S_;var _=new Set;c.set(a,_)}else _=c.get(a),_===void 0&&(_=new Set,c.set(a,_));_.has(o)||(_.add(o),t=O_.bind(null,t,a,o),a.then(t,t))}function Wm(t){do{var a;if((a=t.tag===13)&&(a=t.memoizedState,a=a!==null?a.dehydrated!==null:!0),a)return t;t=t.return}while(t!==null);return null}function Hm(t,a,o,c,_){return(t.mode&1)===0?(t===a?t.flags|=65536:(t.flags|=128,o.flags|=131072,o.flags&=-52805,o.tag===1&&(o.alternate===null?o.tag=17:(a=ua(-1,1),a.tag=2,qa(o,a,1))),o.lanes|=1),t):(t.flags|=65536,t.lanes=_,t)}var N_=M.ReactCurrentOwner,Fn=!1;function An(t,a,o,c){a.child=t===null?dm(a,null,o,c):wi(a,t.child,o,c)}function Vm(t,a,o,c,_){o=o.render;var y=a.ref;return ki(a,_),c=cu(t,a,o,c,y,_),o=uu(),t!==null&&!Fn?(a.updateQueue=t.updateQueue,a.flags&=-2053,t.lanes&=~_,da(t,a,_)):(ut&&o&&It(a),a.flags|=1,An(t,a,c,_),a.child)}function Gm(t,a,o,c,_){if(t===null){var y=o.type;return typeof y=="function"&&!Fu(y)&&y.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(a.tag=15,a.type=y,Km(t,a,y,c,_)):(t=ic(o.type,null,c,a,a.mode,_),t.ref=a.ref,t.return=a,a.child=t)}if(y=t.child,(t.lanes&_)===0){var j=y.memoizedProps;if(o=o.compare,o=o!==null?o:yr,o(j,c)&&t.ref===a.ref)return da(t,a,_)}return a.flags|=1,t=Ga(y,c),t.ref=a.ref,t.return=a,a.child=t}function Km(t,a,o,c,_){if(t!==null){var y=t.memoizedProps;if(yr(y,c)&&t.ref===a.ref)if(Fn=!1,a.pendingProps=c=y,(t.lanes&_)!==0)(t.flags&131072)!==0&&(Fn=!0);else return a.lanes=t.lanes,da(t,a,_)}return vu(t,a,o,c,_)}function Jm(t,a,o){var c=a.pendingProps,_=c.children,y=t!==null?t.memoizedState:null;if(c.mode==="hidden")if((a.mode&1)===0)a.memoizedState={baseLanes:0,cachePool:null,transitions:null},Lt($i,Jn),Jn|=o;else{if((o&1073741824)===0)return t=y!==null?y.baseLanes|o:o,a.lanes=a.childLanes=1073741824,a.memoizedState={baseLanes:t,cachePool:null,transitions:null},a.updateQueue=null,Lt($i,Jn),Jn|=t,null;a.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=y!==null?y.baseLanes:o,Lt($i,Jn),Jn|=c}else y!==null?(c=y.baseLanes|o,a.memoizedState=null):c=o,Lt($i,Jn),Jn|=c;return An(t,a,_,o),a.child}function Qm(t,a){var o=a.ref;(t===null&&o!==null||t!==null&&t.ref!==o)&&(a.flags|=512,a.flags|=2097152)}function vu(t,a,o,c,_){var y=pn(o)?Os:sn.current;return y=la(a,y),ki(a,_),o=cu(t,a,o,c,y,_),c=uu(),t!==null&&!Fn?(a.updateQueue=t.updateQueue,a.flags&=-2053,t.lanes&=~_,da(t,a,_)):(ut&&c&&It(a),a.flags|=1,An(t,a,o,_),a.child)}function Ym(t,a,o,c,_){if(pn(o)){var y=!0;p(a)}else y=!1;if(ki(a,_),a.stateNode===null)Jl(t,a),Om(a,o,c),_u(a,o,c,_),c=!0;else if(t===null){var j=a.stateNode,B=a.memoizedProps;j.props=B;var K=j.context,_e=o.contextType;typeof _e=="object"&&_e!==null?_e=es(_e):(_e=pn(o)?Os:sn.current,_e=la(a,_e));var Me=o.getDerivedStateFromProps,Ie=typeof Me=="function"||typeof j.getSnapshotBeforeUpdate=="function";Ie||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(B!==c||K!==_e)&&Fm(a,j,c,_e),Fa=!1;var Ae=a.memoizedState;j.state=Ae,Fl(a,c,j,_),K=a.memoizedState,B!==c||Ae!==K||kn.current||Fa?(typeof Me=="function"&&(pu(a,o,Me,c),K=a.memoizedState),(B=Fa||Dm(a,o,B,c,Ae,K,_e))?(Ie||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"&&(a.flags|=4194308)):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=c,a.memoizedState=K),j.props=c,j.state=K,j.context=_e,c=B):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),c=!1)}else{j=a.stateNode,fm(t,a),B=a.memoizedProps,_e=a.type===a.elementType?B:ys(a.type,B),j.props=_e,Ie=a.pendingProps,Ae=j.context,K=o.contextType,typeof K=="object"&&K!==null?K=es(K):(K=pn(o)?Os:sn.current,K=la(a,K));var He=o.getDerivedStateFromProps;(Me=typeof He=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(B!==Ie||Ae!==K)&&Fm(a,j,c,K),Fa=!1,Ae=a.memoizedState,j.state=Ae,Fl(a,c,j,_);var Qe=a.memoizedState;B!==Ie||Ae!==Qe||kn.current||Fa?(typeof He=="function"&&(pu(a,o,He,c),Qe=a.memoizedState),(_e=Fa||Dm(a,o,_e,c,Ae,Qe,K)||!1)?(Me||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(c,Qe,K),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(c,Qe,K)),typeof j.componentDidUpdate=="function"&&(a.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof j.componentDidUpdate!="function"||B===t.memoizedProps&&Ae===t.memoizedState||(a.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||B===t.memoizedProps&&Ae===t.memoizedState||(a.flags|=1024),a.memoizedProps=c,a.memoizedState=Qe),j.props=c,j.state=Qe,j.context=K,c=_e):(typeof j.componentDidUpdate!="function"||B===t.memoizedProps&&Ae===t.memoizedState||(a.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||B===t.memoizedProps&&Ae===t.memoizedState||(a.flags|=1024),c=!1)}return xu(t,a,o,c,y,_)}function xu(t,a,o,c,_,y){Qm(t,a);var j=(a.flags&128)!==0;if(!c&&!j)return _&&b(a,o,!1),da(t,a,y);c=a.stateNode,N_.current=a;var B=j&&typeof o.getDerivedStateFromError!="function"?null:c.render();return a.flags|=1,t!==null&&j?(a.child=wi(a,t.child,null,y),a.child=wi(a,null,B,y)):An(t,a,B,y),a.memoizedState=c.state,_&&b(a,o,!0),a.child}function Xm(t){var a=t.stateNode;a.pendingContext?yo(t,a.pendingContext,a.pendingContext!==a.context):a.context&&yo(t,a.context,!1),su(t,a.containerInfo)}function Zm(t,a,o,c,_){return bi(),Qc(_),a.flags|=256,An(t,a,o,c),a.child}var bu={dehydrated:null,treeContext:null,retryLane:0};function wu(t){return{baseLanes:t,cachePool:null,transitions:null}}function ef(t,a,o){var c=a.pendingProps,_=Bt.current,y=!1,j=(a.flags&128)!==0,B;if((B=j)||(B=t!==null&&t.memoizedState===null?!1:(_&2)!==0),B?(y=!0,a.flags&=-129):(t===null||t.memoizedState!==null)&&(_|=1),Lt(Bt,_&1),t===null)return Jc(a),t=a.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((a.mode&1)===0?a.lanes=1:t.data==="$!"?a.lanes=8:a.lanes=1073741824,null):(j=c.children,t=c.fallback,y?(c=a.mode,y=a.child,j={mode:"hidden",children:j},(c&1)===0&&y!==null?(y.childLanes=0,y.pendingProps=j):y=oc(j,c,0,null),t=Pr(t,c,o,null),y.return=a,t.return=a,y.sibling=t,a.child=y,a.child.memoizedState=wu(o),a.memoizedState=bu,t):ju(a,j));if(_=t.memoizedState,_!==null&&(B=_.dehydrated,B!==null))return C_(t,a,j,c,B,_,o);if(y){y=c.fallback,j=a.mode,_=t.child,B=_.sibling;var K={mode:"hidden",children:c.children};return(j&1)===0&&a.child!==_?(c=a.child,c.childLanes=0,c.pendingProps=K,a.deletions=null):(c=Ga(_,K),c.subtreeFlags=_.subtreeFlags&14680064),B!==null?y=Ga(B,y):(y=Pr(y,j,o,null),y.flags|=2),y.return=a,c.return=a,c.sibling=y,a.child=c,c=y,y=a.child,j=t.child.memoizedState,j=j===null?wu(o):{baseLanes:j.baseLanes|o,cachePool:null,transitions:j.transitions},y.memoizedState=j,y.childLanes=t.childLanes&~o,a.memoizedState=bu,c}return y=t.child,t=y.sibling,c=Ga(y,{mode:"visible",children:c.children}),(a.mode&1)===0&&(c.lanes=o),c.return=a,c.sibling=null,t!==null&&(o=a.deletions,o===null?(a.deletions=[t],a.flags|=16):o.push(t)),a.child=c,a.memoizedState=null,c}function ju(t,a){return a=oc({mode:"visible",children:a},t.mode,0,null),a.return=t,t.child=a}function Kl(t,a,o,c){return c!==null&&Qc(c),wi(a,t.child,null,o),t=ju(a,a.pendingProps.children),t.flags|=2,a.memoizedState=null,t}function C_(t,a,o,c,_,y,j){if(o)return a.flags&256?(a.flags&=-257,c=gu(Error(r(422))),Kl(t,a,j,c)):a.memoizedState!==null?(a.child=t.child,a.flags|=128,null):(y=c.fallback,_=a.mode,c=oc({mode:"visible",children:c.children},_,0,null),y=Pr(y,_,j,null),y.flags|=2,c.return=a,y.return=a,c.sibling=y,a.child=c,(a.mode&1)!==0&&wi(a,t.child,null,j),a.child.memoizedState=wu(j),a.memoizedState=bu,y);if((a.mode&1)===0)return Kl(t,a,j,null);if(_.data==="$!"){if(c=_.nextSibling&&_.nextSibling.dataset,c)var B=c.dgst;return c=B,y=Error(r(419)),c=gu(y,c,void 0),Kl(t,a,j,c)}if(B=(j&t.childLanes)!==0,Fn||B){if(c=un,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&&_!==y.retryLane&&(y.retryLane=_,ca(t,_),bs(c,t,_,-1))}return Ou(),c=gu(Error(r(421))),Kl(t,a,j,c)}return _.data==="$?"?(a.flags|=128,a.child=t.child,a=F_.bind(null,t),_._reactRetry=a,null):(t=y.treeContext,$t=Is(_.nextSibling),Mt=a,ut=!0,Tt=null,t!==null&&(Nt[Ht++]=nt,Nt[Ht++]=Ft,Nt[Ht++]=yt,nt=t.id,Ft=t.overflow,yt=a),a=ju(a,c.children),a.flags|=4096,a)}function tf(t,a,o){t.lanes|=a;var c=t.alternate;c!==null&&(c.lanes|=a),eu(t.return,a,o)}function ku(t,a,o,c,_){var y=t.memoizedState;y===null?t.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:c,tail:o,tailMode:_}:(y.isBackwards=a,y.rendering=null,y.renderingStartTime=0,y.last=c,y.tail=o,y.tailMode=_)}function nf(t,a,o){var c=a.pendingProps,_=c.revealOrder,y=c.tail;if(An(t,a,c.children,o),c=Bt.current,(c&2)!==0)c=c&1|2,a.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=a.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&tf(t,o,a);else if(t.tag===19)tf(t,o,a);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===a)break e;for(;t.sibling===null;){if(t.return===null||t.return===a)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}c&=1}if(Lt(Bt,c),(a.mode&1)===0)a.memoizedState=null;else switch(_){case"forwards":for(o=a.child,_=null;o!==null;)t=o.alternate,t!==null&&ql(t)===null&&(_=o),o=o.sibling;o=_,o===null?(_=a.child,a.child=null):(_=o.sibling,o.sibling=null),ku(a,!1,_,o,y);break;case"backwards":for(o=null,_=a.child,a.child=null;_!==null;){if(t=_.alternate,t!==null&&ql(t)===null){a.child=_;break}t=_.sibling,_.sibling=o,o=_,_=t}ku(a,!0,o,null,y);break;case"together":ku(a,!1,null,null,void 0);break;default:a.memoizedState=null}return a.child}function Jl(t,a){(a.mode&1)===0&&t!==null&&(t.alternate=null,a.alternate=null,a.flags|=2)}function da(t,a,o){if(t!==null&&(a.dependencies=t.dependencies),Ar|=a.lanes,(o&a.childLanes)===0)return null;if(t!==null&&a.child!==t.child)throw Error(r(153));if(a.child!==null){for(t=a.child,o=Ga(t,t.pendingProps),a.child=o,o.return=a;t.sibling!==null;)t=t.sibling,o=o.sibling=Ga(t,t.pendingProps),o.return=a;o.sibling=null}return a.child}function $_(t,a,o){switch(a.tag){case 3:Xm(a),bi();break;case 5:_m(a);break;case 1:pn(a.type)&&p(a);break;case 4:su(a,a.stateNode.containerInfo);break;case 10:var c=a.type._context,_=a.memoizedProps.value;Lt(Il,c._currentValue),c._currentValue=_;break;case 13:if(c=a.memoizedState,c!==null)return c.dehydrated!==null?(Lt(Bt,Bt.current&1),a.flags|=128,null):(o&a.child.childLanes)!==0?ef(t,a,o):(Lt(Bt,Bt.current&1),t=da(t,a,o),t!==null?t.sibling:null);Lt(Bt,Bt.current&1);break;case 19:if(c=(o&a.childLanes)!==0,(t.flags&128)!==0){if(c)return nf(t,a,o);a.flags|=128}if(_=a.memoizedState,_!==null&&(_.rendering=null,_.tail=null,_.lastEffect=null),Lt(Bt,Bt.current),c)break;return null;case 22:case 23:return a.lanes=0,Jm(t,a,o)}return da(t,a,o)}var sf,Su,af,rf;sf=function(t,a){for(var o=a.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===a)break;for(;o.sibling===null;){if(o.return===null||o.return===a)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},Su=function(){},af=function(t,a,o,c){var _=t.memoizedProps;if(_!==c){t=a.stateNode,Er(Fs.current);var y=null;switch(o){case"input":_=Ve(t,_),c=Ve(t,c),y=[];break;case"select":_=ae({},_,{value:void 0}),c=ae({},c,{value:void 0}),y=[];break;case"textarea":_=ie(t,_),c=ie(t,c),y=[];break;default:typeof _.onClick!="function"&&typeof c.onClick=="function"&&(t.onclick=hs)}dt(o,c);var j;o=null;for(_e in _)if(!c.hasOwnProperty(_e)&&_.hasOwnProperty(_e)&&_[_e]!=null)if(_e==="style"){var B=_[_e];for(j in B)B.hasOwnProperty(j)&&(o||(o={}),o[j]="")}else _e!=="dangerouslySetInnerHTML"&&_e!=="children"&&_e!=="suppressContentEditableWarning"&&_e!=="suppressHydrationWarning"&&_e!=="autoFocus"&&(l.hasOwnProperty(_e)?y||(y=[]):(y=y||[]).push(_e,null));for(_e in c){var K=c[_e];if(B=_!=null?_[_e]:void 0,c.hasOwnProperty(_e)&&K!==B&&(K!=null||B!=null))if(_e==="style")if(B){for(j in B)!B.hasOwnProperty(j)||K&&K.hasOwnProperty(j)||(o||(o={}),o[j]="");for(j in K)K.hasOwnProperty(j)&&B[j]!==K[j]&&(o||(o={}),o[j]=K[j])}else o||(y||(y=[]),y.push(_e,o)),o=K;else _e==="dangerouslySetInnerHTML"?(K=K?K.__html:void 0,B=B?B.__html:void 0,K!=null&&B!==K&&(y=y||[]).push(_e,K)):_e==="children"?typeof K!="string"&&typeof K!="number"||(y=y||[]).push(_e,""+K):_e!=="suppressContentEditableWarning"&&_e!=="suppressHydrationWarning"&&(l.hasOwnProperty(_e)?(K!=null&&_e==="onScroll"&&xt("scroll",t),y||B===K||(y=[])):(y=y||[]).push(_e,K))}o&&(y=y||[]).push("style",o);var _e=y;(a.updateQueue=_e)&&(a.flags|=4)}},rf=function(t,a,o,c){o!==c&&(a.flags|=4)};function $o(t,a){if(!ut)switch(t.tailMode){case"hidden":a=t.tail;for(var o=null;a!==null;)a.alternate!==null&&(o=a),a=a.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?a||t.tail===null?t.tail=null:t.tail.sibling=null:c.sibling=null}}function Nn(t){var a=t.alternate!==null&&t.alternate.child===t.child,o=0,c=0;if(a)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,a}function E_(t,a,o){var c=a.pendingProps;switch(_n(a),a.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Nn(a),null;case 1:return pn(a.type)&&Nr(),Nn(a),null;case 3:return c=a.stateNode,Si(),Rt(kn),Rt(sn),iu(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(t===null||t.child===null)&&(Pl(a)?a.flags|=4:t===null||t.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,Tt!==null&&(zu(Tt),Tt=null))),Su(t,a),Nn(a),null;case 5:au(a);var _=Er(jo.current);if(o=a.type,t!==null&&a.stateNode!=null)af(t,a,o,c,_),t.ref!==a.ref&&(a.flags|=512,a.flags|=2097152);else{if(!c){if(a.stateNode===null)throw Error(r(166));return Nn(a),null}if(t=Er(Fs.current),Pl(a)){c=a.stateNode,o=a.type;var y=a.memoizedProps;switch(c[Zn]=a,c[Ia]=y,t=(a.mode&1)!==0,o){case"dialog":xt("cancel",c),xt("close",c);break;case"iframe":case"object":case"embed":xt("load",c);break;case"video":case"audio":for(_=0;_<qt.length;_++)xt(qt[_],c);break;case"source":xt("error",c);break;case"img":case"image":case"link":xt("error",c),xt("load",c);break;case"details":xt("toggle",c);break;case"input":ct(c,y),xt("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!y.multiple},xt("invalid",c);break;case"textarea":Se(c,y),xt("invalid",c)}dt(o,y),_=null;for(var j in y)if(y.hasOwnProperty(j)){var B=y[j];j==="children"?typeof B=="string"?c.textContent!==B&&(y.suppressHydrationWarning!==!0&&wr(c.textContent,B,t),_=["children",B]):typeof B=="number"&&c.textContent!==""+B&&(y.suppressHydrationWarning!==!0&&wr(c.textContent,B,t),_=["children",""+B]):l.hasOwnProperty(j)&&B!=null&&j==="onScroll"&&xt("scroll",c)}switch(o){case"input":it(c),ue(c,y,!0);break;case"textarea":it(c),F(c);break;case"select":case"option":break;default:typeof y.onClick=="function"&&(c.onclick=hs)}c=_,a.updateQueue=c,c!==null&&(a.flags|=4)}else{j=_.nodeType===9?_:_.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=de(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]=a,t[Ia]=c,sf(t,a,!1,!1),a.stateNode=t;e:{switch(j=ft(o,c),o){case"dialog":xt("cancel",t),xt("close",t),_=c;break;case"iframe":case"object":case"embed":xt("load",t),_=c;break;case"video":case"audio":for(_=0;_<qt.length;_++)xt(qt[_],t);_=c;break;case"source":xt("error",t),_=c;break;case"img":case"image":case"link":xt("error",t),xt("load",t),_=c;break;case"details":xt("toggle",t),_=c;break;case"input":ct(t,c),_=Ve(t,c),xt("invalid",t);break;case"option":_=c;break;case"select":t._wrapperState={wasMultiple:!!c.multiple},_=ae({},c,{value:void 0}),xt("invalid",t);break;case"textarea":Se(t,c),_=ie(t,c),xt("invalid",t);break;default:_=c}dt(o,_),B=_;for(y in B)if(B.hasOwnProperty(y)){var K=B[y];y==="style"?Fe(t,K):y==="dangerouslySetInnerHTML"?(K=K?K.__html:void 0,K!=null&&ke(t,K)):y==="children"?typeof K=="string"?(o!=="textarea"||K!=="")&&J(t,K):typeof K=="number"&&J(t,""+K):y!=="suppressContentEditableWarning"&&y!=="suppressHydrationWarning"&&y!=="autoFocus"&&(l.hasOwnProperty(y)?K!=null&&y==="onScroll"&&xt("scroll",t):K!=null&&R(t,y,K,j))}switch(o){case"input":it(t),ue(t,c,!1);break;case"textarea":it(t),F(t);break;case"option":c.value!=null&&t.setAttribute("value",""+$e(c.value));break;case"select":t.multiple=!!c.multiple,y=c.value,y!=null?W(t,!!c.multiple,y,!1):c.defaultValue!=null&&W(t,!!c.multiple,c.defaultValue,!0);break;default:typeof _.onClick=="function"&&(t.onclick=hs)}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&&(a.flags|=4)}a.ref!==null&&(a.flags|=512,a.flags|=2097152)}return Nn(a),null;case 6:if(t&&a.stateNode!=null)rf(t,a,t.memoizedProps,c);else{if(typeof c!="string"&&a.stateNode===null)throw Error(r(166));if(o=Er(jo.current),Er(Fs.current),Pl(a)){if(c=a.stateNode,o=a.memoizedProps,c[Zn]=a,(y=c.nodeValue!==o)&&(t=Mt,t!==null))switch(t.tag){case 3:wr(c.nodeValue,o,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&wr(c.nodeValue,o,(t.mode&1)!==0)}y&&(a.flags|=4)}else c=(o.nodeType===9?o:o.ownerDocument).createTextNode(c),c[Zn]=a,a.stateNode=c}return Nn(a),null;case 13:if(Rt(Bt),c=a.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(ut&&$t!==null&&(a.mode&1)!==0&&(a.flags&128)===0)lm(),bi(),a.flags|=98560,y=!1;else if(y=Pl(a),c!==null&&c.dehydrated!==null){if(t===null){if(!y)throw Error(r(318));if(y=a.memoizedState,y=y!==null?y.dehydrated:null,!y)throw Error(r(317));y[Zn]=a}else bi(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Nn(a),y=!1}else Tt!==null&&(zu(Tt),Tt=null),y=!0;if(!y)return a.flags&65536?a:null}return(a.flags&128)!==0?(a.lanes=o,a):(c=c!==null,c!==(t!==null&&t.memoizedState!==null)&&c&&(a.child.flags|=8192,(a.mode&1)!==0&&(t===null||(Bt.current&1)!==0?rn===0&&(rn=3):Ou())),a.updateQueue!==null&&(a.flags|=4),Nn(a),null);case 4:return Si(),Su(t,a),t===null&&fs(a.stateNode.containerInfo),Nn(a),null;case 10:return Zc(a.type._context),Nn(a),null;case 17:return pn(a.type)&&Nr(),Nn(a),null;case 19:if(Rt(Bt),y=a.memoizedState,y===null)return Nn(a),null;if(c=(a.flags&128)!==0,j=y.rendering,j===null)if(c)$o(y,!1);else{if(rn!==0||t!==null&&(t.flags&128)!==0)for(t=a.child;t!==null;){if(j=ql(t),j!==null){for(a.flags|=128,$o(y,!1),c=j.updateQueue,c!==null&&(a.updateQueue=c,a.flags|=4),a.subtreeFlags=0,c=o,o=a.child;o!==null;)y=o,t=c,y.flags&=14680066,j=y.alternate,j===null?(y.childLanes=0,y.lanes=t,y.child=null,y.subtreeFlags=0,y.memoizedProps=null,y.memoizedState=null,y.updateQueue=null,y.dependencies=null,y.stateNode=null):(y.childLanes=j.childLanes,y.lanes=j.lanes,y.child=j.child,y.subtreeFlags=0,y.deletions=null,y.memoizedProps=j.memoizedProps,y.memoizedState=j.memoizedState,y.updateQueue=j.updateQueue,y.type=j.type,t=j.dependencies,y.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),o=o.sibling;return Lt(Bt,Bt.current&1|2),a.child}t=t.sibling}y.tail!==null&&Ot()>Ei&&(a.flags|=128,c=!0,$o(y,!1),a.lanes=4194304)}else{if(!c)if(t=ql(j),t!==null){if(a.flags|=128,c=!0,o=t.updateQueue,o!==null&&(a.updateQueue=o,a.flags|=4),$o(y,!0),y.tail===null&&y.tailMode==="hidden"&&!j.alternate&&!ut)return Nn(a),null}else 2*Ot()-y.renderingStartTime>Ei&&o!==1073741824&&(a.flags|=128,c=!0,$o(y,!1),a.lanes=4194304);y.isBackwards?(j.sibling=a.child,a.child=j):(o=y.last,o!==null?o.sibling=j:a.child=j,y.last=j)}return y.tail!==null?(a=y.tail,y.rendering=a,y.tail=a.sibling,y.renderingStartTime=Ot(),a.sibling=null,o=Bt.current,Lt(Bt,c?o&1|2:o&1),a):(Nn(a),null);case 22:case 23:return Du(),c=a.memoizedState!==null,t!==null&&t.memoizedState!==null!==c&&(a.flags|=8192),c&&(a.mode&1)!==0?(Jn&1073741824)!==0&&(Nn(a),a.subtreeFlags&6&&(a.flags|=8192)):Nn(a),null;case 24:return null;case 25:return null}throw Error(r(156,a.tag))}function T_(t,a){switch(_n(a),a.tag){case 1:return pn(a.type)&&Nr(),t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 3:return Si(),Rt(kn),Rt(sn),iu(),t=a.flags,(t&65536)!==0&&(t&128)===0?(a.flags=t&-65537|128,a):null;case 5:return au(a),null;case 13:if(Rt(Bt),t=a.memoizedState,t!==null&&t.dehydrated!==null){if(a.alternate===null)throw Error(r(340));bi()}return t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 19:return Rt(Bt),null;case 4:return Si(),null;case 10:return Zc(a.type._context),null;case 22:case 23:return Du(),null;case 24:return null;default:return null}}var Ql=!1,Cn=!1,A_=typeof WeakSet=="function"?WeakSet:Set,Ke=null;function Ci(t,a){var o=t.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(c){Vt(t,a,c)}else o.current=null}function Nu(t,a,o){try{o()}catch(c){Vt(t,a,c)}}var of=!1;function L_(t,a){if(_o=ur,t=di(),io(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,y=c.focusNode;c=c.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var j=0,B=-1,K=-1,_e=0,Me=0,Ie=t,Ae=null;t:for(;;){for(var He;Ie!==o||_!==0&&Ie.nodeType!==3||(B=j+_),Ie!==y||c!==0&&Ie.nodeType!==3||(K=j+c),Ie.nodeType===3&&(j+=Ie.nodeValue.length),(He=Ie.firstChild)!==null;)Ae=Ie,Ie=He;for(;;){if(Ie===t)break t;if(Ae===o&&++_e===_&&(B=j),Ae===y&&++Me===c&&(K=j),(He=Ie.nextSibling)!==null)break;Ie=Ae,Ae=Ie.parentNode}Ie=He}o=B===-1||K===-1?null:{start:B,end:K}}else o=null}o=o||{start:0,end:0}}else o=null;for(jn={focusedElem:t,selectionRange:o},ur=!1,Ke=a;Ke!==null;)if(a=Ke,t=a.child,(a.subtreeFlags&1028)!==0&&t!==null)t.return=a,Ke=t;else for(;Ke!==null;){a=Ke;try{var Qe=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(Qe!==null){var Ze=Qe.memoizedProps,Yt=Qe.memoizedState,me=a.stateNode,ne=me.getSnapshotBeforeUpdate(a.elementType===a.type?Ze:ys(a.type,Ze),Yt);me.__reactInternalSnapshotBeforeUpdate=ne}break;case 3:var pe=a.stateNode.containerInfo;pe.nodeType===1?pe.textContent="":pe.nodeType===9&&pe.documentElement&&pe.removeChild(pe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(De){Vt(a,a.return,De)}if(t=a.sibling,t!==null){t.return=a.return,Ke=t;break}Ke=a.return}return Qe=of,of=!1,Qe}function Eo(t,a,o){var c=a.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var _=c=c.next;do{if((_.tag&t)===t){var y=_.destroy;_.destroy=void 0,y!==void 0&&Nu(a,o,y)}_=_.next}while(_!==c)}}function Yl(t,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var o=a=a.next;do{if((o.tag&t)===t){var c=o.create;o.destroy=c()}o=o.next}while(o!==a)}}function Cu(t){var a=t.ref;if(a!==null){var o=t.stateNode;switch(t.tag){case 5:t=o;break;default:t=o}typeof a=="function"?a(t):a.current=t}}function lf(t){var a=t.alternate;a!==null&&(t.alternate=null,lf(a)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(a=t.stateNode,a!==null&&(delete a[Zn],delete a[Ia],delete a[go],delete a[Rl],delete a[Gc])),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 cf(t){return t.tag===5||t.tag===3||t.tag===4}function uf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||cf(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 $u(t,a,o){var c=t.tag;if(c===5||c===6)t=t.stateNode,a?o.nodeType===8?o.parentNode.insertBefore(t,a):o.insertBefore(t,a):(o.nodeType===8?(a=o.parentNode,a.insertBefore(t,o)):(a=o,a.appendChild(t)),o=o._reactRootContainer,o!=null||a.onclick!==null||(a.onclick=hs));else if(c!==4&&(t=t.child,t!==null))for($u(t,a,o),t=t.sibling;t!==null;)$u(t,a,o),t=t.sibling}function Eu(t,a,o){var c=t.tag;if(c===5||c===6)t=t.stateNode,a?o.insertBefore(t,a):o.appendChild(t);else if(c!==4&&(t=t.child,t!==null))for(Eu(t,a,o),t=t.sibling;t!==null;)Eu(t,a,o),t=t.sibling}var gn=null,vs=!1;function Ba(t,a,o){for(o=o.child;o!==null;)df(t,a,o),o=o.sibling}function df(t,a,o){if(mn&&typeof mn.onCommitFiberUnmount=="function")try{mn.onCommitFiberUnmount(rs,o)}catch{}switch(o.tag){case 5:Cn||Ci(o,a);case 6:var c=gn,_=vs;gn=null,Ba(t,a,o),gn=c,vs=_,gn!==null&&(vs?(t=gn,o=o.stateNode,t.nodeType===8?t.parentNode.removeChild(o):t.removeChild(o)):gn.removeChild(o.stateNode));break;case 18:gn!==null&&(vs?(t=gn,o=o.stateNode,t.nodeType===8?Pa(t.parentNode,o):t.nodeType===1&&Pa(t,o),wa(t)):Pa(gn,o.stateNode));break;case 4:c=gn,_=vs,gn=o.stateNode.containerInfo,vs=!0,Ba(t,a,o),gn=c,vs=_;break;case 0:case 11:case 14:case 15:if(!Cn&&(c=o.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){_=c=c.next;do{var y=_,j=y.destroy;y=y.tag,j!==void 0&&((y&2)!==0||(y&4)!==0)&&Nu(o,a,j),_=_.next}while(_!==c)}Ba(t,a,o);break;case 1:if(!Cn&&(Ci(o,a),c=o.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=o.memoizedProps,c.state=o.memoizedState,c.componentWillUnmount()}catch(B){Vt(o,a,B)}Ba(t,a,o);break;case 21:Ba(t,a,o);break;case 22:o.mode&1?(Cn=(c=Cn)||o.memoizedState!==null,Ba(t,a,o),Cn=c):Ba(t,a,o);break;default:Ba(t,a,o)}}function mf(t){var a=t.updateQueue;if(a!==null){t.updateQueue=null;var o=t.stateNode;o===null&&(o=t.stateNode=new A_),a.forEach(function(c){var _=q_.bind(null,t,c);o.has(c)||(o.add(c),c.then(_,_))})}}function xs(t,a){var o=a.deletions;if(o!==null)for(var c=0;c<o.length;c++){var _=o[c];try{var y=t,j=a,B=j;e:for(;B!==null;){switch(B.tag){case 5:gn=B.stateNode,vs=!1;break e;case 3:gn=B.stateNode.containerInfo,vs=!0;break e;case 4:gn=B.stateNode.containerInfo,vs=!0;break e}B=B.return}if(gn===null)throw Error(r(160));df(y,j,_),gn=null,vs=!1;var K=_.alternate;K!==null&&(K.return=null),_.return=null}catch(_e){Vt(_,a,_e)}}if(a.subtreeFlags&12854)for(a=a.child;a!==null;)ff(a,t),a=a.sibling}function ff(t,a){var o=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(xs(a,t),Bs(t),c&4){try{Eo(3,t,t.return),Yl(3,t)}catch(Ze){Vt(t,t.return,Ze)}try{Eo(5,t,t.return)}catch(Ze){Vt(t,t.return,Ze)}}break;case 1:xs(a,t),Bs(t),c&512&&o!==null&&Ci(o,o.return);break;case 5:if(xs(a,t),Bs(t),c&512&&o!==null&&Ci(o,o.return),t.flags&32){var _=t.stateNode;try{J(_,"")}catch(Ze){Vt(t,t.return,Ze)}}if(c&4&&(_=t.stateNode,_!=null)){var y=t.memoizedProps,j=o!==null?o.memoizedProps:y,B=t.type,K=t.updateQueue;if(t.updateQueue=null,K!==null)try{B==="input"&&y.type==="radio"&&y.name!=null&&et(_,y),ft(B,j);var _e=ft(B,y);for(j=0;j<K.length;j+=2){var Me=K[j],Ie=K[j+1];Me==="style"?Fe(_,Ie):Me==="dangerouslySetInnerHTML"?ke(_,Ie):Me==="children"?J(_,Ie):R(_,Me,Ie,_e)}switch(B){case"input":fe(_,y);break;case"textarea":Je(_,y);break;case"select":var Ae=_._wrapperState.wasMultiple;_._wrapperState.wasMultiple=!!y.multiple;var He=y.value;He!=null?W(_,!!y.multiple,He,!1):Ae!==!!y.multiple&&(y.defaultValue!=null?W(_,!!y.multiple,y.defaultValue,!0):W(_,!!y.multiple,y.multiple?[]:"",!1))}_[Ia]=y}catch(Ze){Vt(t,t.return,Ze)}}break;case 6:if(xs(a,t),Bs(t),c&4){if(t.stateNode===null)throw Error(r(162));_=t.stateNode,y=t.memoizedProps;try{_.nodeValue=y}catch(Ze){Vt(t,t.return,Ze)}}break;case 3:if(xs(a,t),Bs(t),c&4&&o!==null&&o.memoizedState.isDehydrated)try{wa(a.containerInfo)}catch(Ze){Vt(t,t.return,Ze)}break;case 4:xs(a,t),Bs(t);break;case 13:xs(a,t),Bs(t),_=t.child,_.flags&8192&&(y=_.memoizedState!==null,_.stateNode.isHidden=y,!y||_.alternate!==null&&_.alternate.memoizedState!==null||(Lu=Ot())),c&4&&mf(t);break;case 22:if(Me=o!==null&&o.memoizedState!==null,t.mode&1?(Cn=(_e=Cn)||Me,xs(a,t),Cn=_e):xs(a,t),Bs(t),c&8192){if(_e=t.memoizedState!==null,(t.stateNode.isHidden=_e)&&!Me&&(t.mode&1)!==0)for(Ke=t,Me=t.child;Me!==null;){for(Ie=Ke=Me;Ke!==null;){switch(Ae=Ke,He=Ae.child,Ae.tag){case 0:case 11:case 14:case 15:Eo(4,Ae,Ae.return);break;case 1:Ci(Ae,Ae.return);var Qe=Ae.stateNode;if(typeof Qe.componentWillUnmount=="function"){c=Ae,o=Ae.return;try{a=c,Qe.props=a.memoizedProps,Qe.state=a.memoizedState,Qe.componentWillUnmount()}catch(Ze){Vt(c,o,Ze)}}break;case 5:Ci(Ae,Ae.return);break;case 22:if(Ae.memoizedState!==null){_f(Ie);continue}}He!==null?(He.return=Ae,Ke=He):_f(Ie)}Me=Me.sibling}e:for(Me=null,Ie=t;;){if(Ie.tag===5){if(Me===null){Me=Ie;try{_=Ie.stateNode,_e?(y=_.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none"):(B=Ie.stateNode,K=Ie.memoizedProps.style,j=K!=null&&K.hasOwnProperty("display")?K.display:null,B.style.display=Pe("display",j))}catch(Ze){Vt(t,t.return,Ze)}}}else if(Ie.tag===6){if(Me===null)try{Ie.stateNode.nodeValue=_e?"":Ie.memoizedProps}catch(Ze){Vt(t,t.return,Ze)}}else if((Ie.tag!==22&&Ie.tag!==23||Ie.memoizedState===null||Ie===t)&&Ie.child!==null){Ie.child.return=Ie,Ie=Ie.child;continue}if(Ie===t)break e;for(;Ie.sibling===null;){if(Ie.return===null||Ie.return===t)break e;Me===Ie&&(Me=null),Ie=Ie.return}Me===Ie&&(Me=null),Ie.sibling.return=Ie.return,Ie=Ie.sibling}}break;case 19:xs(a,t),Bs(t),c&4&&mf(t);break;case 21:break;default:xs(a,t),Bs(t)}}function Bs(t){var a=t.flags;if(a&2){try{e:{for(var o=t.return;o!==null;){if(cf(o)){var c=o;break e}o=o.return}throw Error(r(160))}switch(c.tag){case 5:var _=c.stateNode;c.flags&32&&(J(_,""),c.flags&=-33);var y=uf(t);Eu(t,y,_);break;case 3:case 4:var j=c.stateNode.containerInfo,B=uf(t);$u(t,B,j);break;default:throw Error(r(161))}}catch(K){Vt(t,t.return,K)}t.flags&=-3}a&4096&&(t.flags&=-4097)}function M_(t,a,o){Ke=t,hf(t)}function hf(t,a,o){for(var c=(t.mode&1)!==0;Ke!==null;){var _=Ke,y=_.child;if(_.tag===22&&c){var j=_.memoizedState!==null||Ql;if(!j){var B=_.alternate,K=B!==null&&B.memoizedState!==null||Cn;B=Ql;var _e=Cn;if(Ql=j,(Cn=K)&&!_e)for(Ke=_;Ke!==null;)j=Ke,K=j.child,j.tag===22&&j.memoizedState!==null?gf(_):K!==null?(K.return=j,Ke=K):gf(_);for(;y!==null;)Ke=y,hf(y),y=y.sibling;Ke=_,Ql=B,Cn=_e}pf(t)}else(_.subtreeFlags&8772)!==0&&y!==null?(y.return=_,Ke=y):pf(t)}}function pf(t){for(;Ke!==null;){var a=Ke;if((a.flags&8772)!==0){var o=a.alternate;try{if((a.flags&8772)!==0)switch(a.tag){case 0:case 11:case 15:Cn||Yl(5,a);break;case 1:var c=a.stateNode;if(a.flags&4&&!Cn)if(o===null)c.componentDidMount();else{var _=a.elementType===a.type?o.memoizedProps:ys(a.type,o.memoizedProps);c.componentDidUpdate(_,o.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var y=a.updateQueue;y!==null&&pm(a,y,c);break;case 3:var j=a.updateQueue;if(j!==null){if(o=null,a.child!==null)switch(a.child.tag){case 5:o=a.child.stateNode;break;case 1:o=a.child.stateNode}pm(a,j,o)}break;case 5:var B=a.stateNode;if(o===null&&a.flags&4){o=B;var K=a.memoizedProps;switch(a.type){case"button":case"input":case"select":case"textarea":K.autoFocus&&o.focus();break;case"img":K.src&&(o.src=K.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(a.memoizedState===null){var _e=a.alternate;if(_e!==null){var Me=_e.memoizedState;if(Me!==null){var Ie=Me.dehydrated;Ie!==null&&wa(Ie)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}Cn||a.flags&512&&Cu(a)}catch(Ae){Vt(a,a.return,Ae)}}if(a===t){Ke=null;break}if(o=a.sibling,o!==null){o.return=a.return,Ke=o;break}Ke=a.return}}function _f(t){for(;Ke!==null;){var a=Ke;if(a===t){Ke=null;break}var o=a.sibling;if(o!==null){o.return=a.return,Ke=o;break}Ke=a.return}}function gf(t){for(;Ke!==null;){var a=Ke;try{switch(a.tag){case 0:case 11:case 15:var o=a.return;try{Yl(4,a)}catch(K){Vt(a,o,K)}break;case 1:var c=a.stateNode;if(typeof c.componentDidMount=="function"){var _=a.return;try{c.componentDidMount()}catch(K){Vt(a,_,K)}}var y=a.return;try{Cu(a)}catch(K){Vt(a,y,K)}break;case 5:var j=a.return;try{Cu(a)}catch(K){Vt(a,j,K)}}}catch(K){Vt(a,a.return,K)}if(a===t){Ke=null;break}var B=a.sibling;if(B!==null){B.return=a.return,Ke=B;break}Ke=a.return}}var R_=Math.ceil,Xl=M.ReactCurrentDispatcher,Tu=M.ReactCurrentOwner,ns=M.ReactCurrentBatchConfig,bt=0,un=null,Zt=null,yn=0,Jn=0,$i=Ds(0),rn=0,To=null,Ar=0,Zl=0,Au=0,Ao=null,qn=null,Lu=0,Ei=1/0,ma=null,ec=!1,Mu=null,Ua=null,tc=!1,Wa=null,nc=0,Lo=0,Ru=null,sc=-1,ac=0;function Ln(){return(bt&6)!==0?Ot():sc!==-1?sc:sc=Ot()}function Ha(t){return(t.mode&1)===0?1:(bt&2)!==0&&yn!==0?yn&-yn:g_.transition!==null?(ac===0&&(ac=Kt()),ac):(t=kt,t!==0||(t=window.event,t=t===void 0?16:Vi(t.type)),t)}function bs(t,a,o,c){if(50<Lo)throw Lo=0,Ru=null,Error(r(185));$s(t,o,c),((bt&2)===0||t!==un)&&(t===un&&((bt&2)===0&&(Zl|=o),rn===4&&Va(t,yn)),Bn(t,c),o===1&&bt===0&&(a.mode&1)===0&&(Ei=Ot()+500,S&&ve()))}function Bn(t,a){var o=t.callbackNode;Jr(t,a);var c=xn(t,t===un?yn:0);if(c===0)o!==null&&Bi(o),t.callbackNode=null,t.callbackPriority=0;else if(a=c&-c,t.callbackPriority!==a){if(o!=null&&Bi(o),a===1)t.tag===0?G(vf.bind(null,t)):le(vf.bind(null,t)),ps(function(){(bt&6)===0&&ve()}),o=null;else{switch(Jt(c)){case 1:o=Hr;break;case 4:o=ir;break;case 16:o=Ks;break;case 536870912:o=Vr;break;default:o=Ks}o=Cf(o,yf.bind(null,t))}t.callbackPriority=a,t.callbackNode=o}}function yf(t,a){if(sc=-1,ac=0,(bt&6)!==0)throw Error(r(327));var o=t.callbackNode;if(Ti()&&t.callbackNode!==o)return null;var c=xn(t,t===un?yn:0);if(c===0)return null;if((c&30)!==0||(c&t.expiredLanes)!==0||a)a=rc(t,c);else{a=c;var _=bt;bt|=2;var y=bf();(un!==t||yn!==a)&&(ma=null,Ei=Ot()+500,Mr(t,a));do try{I_();break}catch(B){xf(t,B)}while(!0);Xc(),Xl.current=y,bt=_,Zt!==null?a=0:(un=null,yn=0,a=rn)}if(a!==0){if(a===2&&(_=Cs(t),_!==0&&(c=_,a=Pu(t,_))),a===1)throw o=To,Mr(t,0),Va(t,c),Bn(t,Ot()),o;if(a===6)Va(t,c);else{if(_=t.current.alternate,(c&30)===0&&!P_(_)&&(a=rc(t,c),a===2&&(y=Cs(t),y!==0&&(c=y,a=Pu(t,y))),a===1))throw o=To,Mr(t,0),Va(t,c),Bn(t,Ot()),o;switch(t.finishedWork=_,t.finishedLanes=c,a){case 0:case 1:throw Error(r(345));case 2:Rr(t,qn,ma);break;case 3:if(Va(t,c),(c&130023424)===c&&(a=Lu+500-Ot(),10<a)){if(xn(t,0)!==0)break;if(_=t.suspendedLanes,(_&c)!==c){Ln(),t.pingedLanes|=t.suspendedLanes&_;break}t.timeoutHandle=On(Rr.bind(null,t,qn,ma),a);break}Rr(t,qn,ma);break;case 4:if(Va(t,c),(c&4194240)===c)break;for(a=t.eventTimes,_=-1;0<c;){var j=31-fn(c);y=1<<j,j=a[j],j>_&&(_=j),c&=~y}if(c=_,c=Ot()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*R_(c/1960))-c,10<c){t.timeoutHandle=On(Rr.bind(null,t,qn,ma),c);break}Rr(t,qn,ma);break;case 5:Rr(t,qn,ma);break;default:throw Error(r(329))}}}return Bn(t,Ot()),t.callbackNode===o?yf.bind(null,t):null}function Pu(t,a){var o=Ao;return t.current.memoizedState.isDehydrated&&(Mr(t,a).flags|=256),t=rc(t,a),t!==2&&(a=qn,qn=o,a!==null&&zu(a)),t}function zu(t){qn===null?qn=t:qn.push.apply(qn,t)}function P_(t){for(var a=t;;){if(a.flags&16384){var o=a.updateQueue;if(o!==null&&(o=o.stores,o!==null))for(var c=0;c<o.length;c++){var _=o[c],y=_.getSnapshot;_=_.value;try{if(!In(y(),_))return!1}catch{return!1}}}if(o=a.child,a.subtreeFlags&16384&&o!==null)o.return=a,a=o;else{if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function Va(t,a){for(a&=~Au,a&=~Zl,t.suspendedLanes|=a,t.pingedLanes&=~a,t=t.expirationTimes;0<a;){var o=31-fn(a),c=1<<o;t[o]=-1,a&=~c}}function vf(t){if((bt&6)!==0)throw Error(r(327));Ti();var a=xn(t,0);if((a&1)===0)return Bn(t,Ot()),null;var o=rc(t,a);if(t.tag!==0&&o===2){var c=Cs(t);c!==0&&(a=c,o=Pu(t,c))}if(o===1)throw o=To,Mr(t,0),Va(t,a),Bn(t,Ot()),o;if(o===6)throw Error(r(345));return t.finishedWork=t.current.alternate,t.finishedLanes=a,Rr(t,qn,ma),Bn(t,Ot()),null}function Iu(t,a){var o=bt;bt|=1;try{return t(a)}finally{bt=o,bt===0&&(Ei=Ot()+500,S&&ve())}}function Lr(t){Wa!==null&&Wa.tag===0&&(bt&6)===0&&Ti();var a=bt;bt|=1;var o=ns.transition,c=kt;try{if(ns.transition=null,kt=1,t)return t()}finally{kt=c,ns.transition=o,bt=a,(bt&6)===0&&ve()}}function Du(){Jn=$i.current,Rt($i)}function Mr(t,a){t.finishedWork=null,t.finishedLanes=0;var o=t.timeoutHandle;if(o!==-1&&(t.timeoutHandle=-1,gi(o)),Zt!==null)for(o=Zt.return;o!==null;){var c=o;switch(_n(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&Nr();break;case 3:Si(),Rt(kn),Rt(sn),iu();break;case 5:au(c);break;case 4:Si();break;case 13:Rt(Bt);break;case 19:Rt(Bt);break;case 10:Zc(c.type._context);break;case 22:case 23:Du()}o=o.return}if(un=t,Zt=t=Ga(t.current,null),yn=Jn=a,rn=0,To=null,Au=Zl=Ar=0,qn=Ao=null,$r!==null){for(a=0;a<$r.length;a++)if(o=$r[a],c=o.interleaved,c!==null){o.interleaved=null;var _=c.next,y=o.pending;if(y!==null){var j=y.next;y.next=_,c.next=j}o.pending=c}$r=null}return t}function xf(t,a){do{var o=Zt;try{if(Xc(),Bl.current=Vl,Ul){for(var c=Ut.memoizedState;c!==null;){var _=c.queue;_!==null&&(_.pending=null),c=c.next}Ul=!1}if(Tr=0,cn=an=Ut=null,ko=!1,So=0,Tu.current=null,o===null||o.return===null){rn=1,To=a,Zt=null;break}e:{var y=t,j=o.return,B=o,K=a;if(a=yn,B.flags|=32768,K!==null&&typeof K=="object"&&typeof K.then=="function"){var _e=K,Me=B,Ie=Me.tag;if((Me.mode&1)===0&&(Ie===0||Ie===11||Ie===15)){var Ae=Me.alternate;Ae?(Me.updateQueue=Ae.updateQueue,Me.memoizedState=Ae.memoizedState,Me.lanes=Ae.lanes):(Me.updateQueue=null,Me.memoizedState=null)}var He=Wm(j);if(He!==null){He.flags&=-257,Hm(He,j,B,y,a),He.mode&1&&Um(y,_e,a),a=He,K=_e;var Qe=a.updateQueue;if(Qe===null){var Ze=new Set;Ze.add(K),a.updateQueue=Ze}else Qe.add(K);break e}else{if((a&1)===0){Um(y,_e,a),Ou();break e}K=Error(r(426))}}else if(ut&&B.mode&1){var Yt=Wm(j);if(Yt!==null){(Yt.flags&65536)===0&&(Yt.flags|=256),Hm(Yt,j,B,y,a),Qc(Ni(K,B));break e}}y=K=Ni(K,B),rn!==4&&(rn=2),Ao===null?Ao=[y]:Ao.push(y),y=j;do{switch(y.tag){case 3:y.flags|=65536,a&=-a,y.lanes|=a;var me=qm(y,K,a);hm(y,me);break e;case 1:B=K;var ne=y.type,pe=y.stateNode;if((y.flags&128)===0&&(typeof ne.getDerivedStateFromError=="function"||pe!==null&&typeof pe.componentDidCatch=="function"&&(Ua===null||!Ua.has(pe)))){y.flags|=65536,a&=-a,y.lanes|=a;var De=Bm(y,B,a);hm(y,De);break e}}y=y.return}while(y!==null)}jf(o)}catch(tt){a=tt,Zt===o&&o!==null&&(Zt=o=o.return);continue}break}while(!0)}function bf(){var t=Xl.current;return Xl.current=Vl,t===null?Vl:t}function Ou(){(rn===0||rn===3||rn===2)&&(rn=4),un===null||(Ar&268435455)===0&&(Zl&268435455)===0||Va(un,yn)}function rc(t,a){var o=bt;bt|=2;var c=bf();(un!==t||yn!==a)&&(ma=null,Mr(t,a));do try{z_();break}catch(_){xf(t,_)}while(!0);if(Xc(),bt=o,Xl.current=c,Zt!==null)throw Error(r(261));return un=null,yn=0,rn}function z_(){for(;Zt!==null;)wf(Zt)}function I_(){for(;Zt!==null&&!ul();)wf(Zt)}function wf(t){var a=Nf(t.alternate,t,Jn);t.memoizedProps=t.pendingProps,a===null?jf(t):Zt=a,Tu.current=null}function jf(t){var a=t;do{var o=a.alternate;if(t=a.return,(a.flags&32768)===0){if(o=E_(o,a,Jn),o!==null){Zt=o;return}}else{if(o=T_(o,a),o!==null){o.flags&=32767,Zt=o;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{rn=6,Zt=null;return}}if(a=a.sibling,a!==null){Zt=a;return}Zt=a=t}while(a!==null);rn===0&&(rn=5)}function Rr(t,a,o){var c=kt,_=ns.transition;try{ns.transition=null,kt=1,D_(t,a,o,c)}finally{ns.transition=_,kt=c}return null}function D_(t,a,o,c){do Ti();while(Wa!==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 y=o.lanes|o.childLanes;if(va(t,y),t===un&&(Zt=un=null,yn=0),(o.subtreeFlags&2064)===0&&(o.flags&2064)===0||tc||(tc=!0,Cf(Ks,function(){return Ti(),null})),y=(o.flags&15990)!==0,(o.subtreeFlags&15990)!==0||y){y=ns.transition,ns.transition=null;var j=kt;kt=1;var B=bt;bt|=4,Tu.current=null,L_(t,o),ff(o,t),$l(jn),ur=!!_o,jn=_o=null,t.current=o,M_(o),Ui(),bt=B,kt=j,ns.transition=y}else t.current=o;if(tc&&(tc=!1,Wa=t,nc=_),y=t.pendingLanes,y===0&&(Ua=null),Gr(o.stateNode),Bn(t,Ot()),a!==null)for(c=t.onRecoverableError,o=0;o<a.length;o++)_=a[o],c(_.value,{componentStack:_.stack,digest:_.digest});if(ec)throw ec=!1,t=Mu,Mu=null,t;return(nc&1)!==0&&t.tag!==0&&Ti(),y=t.pendingLanes,(y&1)!==0?t===Ru?Lo++:(Lo=0,Ru=t):Lo=0,ve(),null}function Ti(){if(Wa!==null){var t=Jt(nc),a=ns.transition,o=kt;try{if(ns.transition=null,kt=16>t?16:t,Wa===null)var c=!1;else{if(t=Wa,Wa=null,nc=0,(bt&6)!==0)throw Error(r(331));var _=bt;for(bt|=4,Ke=t.current;Ke!==null;){var y=Ke,j=y.child;if((Ke.flags&16)!==0){var B=y.deletions;if(B!==null){for(var K=0;K<B.length;K++){var _e=B[K];for(Ke=_e;Ke!==null;){var Me=Ke;switch(Me.tag){case 0:case 11:case 15:Eo(8,Me,y)}var Ie=Me.child;if(Ie!==null)Ie.return=Me,Ke=Ie;else for(;Ke!==null;){Me=Ke;var Ae=Me.sibling,He=Me.return;if(lf(Me),Me===_e){Ke=null;break}if(Ae!==null){Ae.return=He,Ke=Ae;break}Ke=He}}}var Qe=y.alternate;if(Qe!==null){var Ze=Qe.child;if(Ze!==null){Qe.child=null;do{var Yt=Ze.sibling;Ze.sibling=null,Ze=Yt}while(Ze!==null)}}Ke=y}}if((y.subtreeFlags&2064)!==0&&j!==null)j.return=y,Ke=j;else e:for(;Ke!==null;){if(y=Ke,(y.flags&2048)!==0)switch(y.tag){case 0:case 11:case 15:Eo(9,y,y.return)}var me=y.sibling;if(me!==null){me.return=y.return,Ke=me;break e}Ke=y.return}}var ne=t.current;for(Ke=ne;Ke!==null;){j=Ke;var pe=j.child;if((j.subtreeFlags&2064)!==0&&pe!==null)pe.return=j,Ke=pe;else e:for(j=ne;Ke!==null;){if(B=Ke,(B.flags&2048)!==0)try{switch(B.tag){case 0:case 11:case 15:Yl(9,B)}}catch(tt){Vt(B,B.return,tt)}if(B===j){Ke=null;break e}var De=B.sibling;if(De!==null){De.return=B.return,Ke=De;break e}Ke=B.return}}if(bt=_,ve(),mn&&typeof mn.onPostCommitFiberRoot=="function")try{mn.onPostCommitFiberRoot(rs,t)}catch{}c=!0}return c}finally{kt=o,ns.transition=a}}return!1}function kf(t,a,o){a=Ni(o,a),a=qm(t,a,1),t=qa(t,a,1),a=Ln(),t!==null&&($s(t,1,a),Bn(t,a))}function Vt(t,a,o){if(t.tag===3)kf(t,t,o);else for(;a!==null;){if(a.tag===3){kf(a,t,o);break}else if(a.tag===1){var c=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Ua===null||!Ua.has(c))){t=Ni(o,t),t=Bm(a,t,1),a=qa(a,t,1),t=Ln(),a!==null&&($s(a,1,t),Bn(a,t));break}}a=a.return}}function O_(t,a,o){var c=t.pingCache;c!==null&&c.delete(a),a=Ln(),t.pingedLanes|=t.suspendedLanes&o,un===t&&(yn&o)===o&&(rn===4||rn===3&&(yn&130023424)===yn&&500>Ot()-Lu?Mr(t,0):Au|=o),Bn(t,a)}function Sf(t,a){a===0&&((t.mode&1)===0?a=1:(a=Kr,Kr<<=1,(Kr&130023424)===0&&(Kr=4194304)));var o=Ln();t=ca(t,a),t!==null&&($s(t,a,o),Bn(t,o))}function F_(t){var a=t.memoizedState,o=0;a!==null&&(o=a.retryLane),Sf(t,o)}function q_(t,a){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(a),Sf(t,o)}var Nf;Nf=function(t,a,o){if(t!==null)if(t.memoizedProps!==a.pendingProps||kn.current)Fn=!0;else{if((t.lanes&o)===0&&(a.flags&128)===0)return Fn=!1,$_(t,a,o);Fn=(t.flags&131072)!==0}else Fn=!1,ut&&(a.flags&1048576)!==0&&Ge(a,Pt,a.index);switch(a.lanes=0,a.tag){case 2:var c=a.type;Jl(t,a),t=a.pendingProps;var _=la(a,sn.current);ki(a,o),_=cu(null,a,c,t,_,o);var y=uu();return a.flags|=1,typeof _=="object"&&_!==null&&typeof _.render=="function"&&_.$$typeof===void 0?(a.tag=1,a.memoizedState=null,a.updateQueue=null,pn(c)?(y=!0,p(a)):y=!1,a.memoizedState=_.state!==null&&_.state!==void 0?_.state:null,nu(a),_.updater=Gl,a.stateNode=_,_._reactInternals=a,_u(a,c,t,o),a=xu(null,a,c,!0,y,o)):(a.tag=0,ut&&y&&It(a),An(null,a,_,o),a=a.child),a;case 16:c=a.elementType;e:{switch(Jl(t,a),t=a.pendingProps,_=c._init,c=_(c._payload),a.type=c,_=a.tag=U_(c),t=ys(c,t),_){case 0:a=vu(null,a,c,t,o);break e;case 1:a=Ym(null,a,c,t,o);break e;case 11:a=Vm(null,a,c,t,o);break e;case 14:a=Gm(null,a,c,ys(c.type,t),o);break e}throw Error(r(306,c,""))}return a;case 0:return c=a.type,_=a.pendingProps,_=a.elementType===c?_:ys(c,_),vu(t,a,c,_,o);case 1:return c=a.type,_=a.pendingProps,_=a.elementType===c?_:ys(c,_),Ym(t,a,c,_,o);case 3:e:{if(Xm(a),t===null)throw Error(r(387));c=a.pendingProps,y=a.memoizedState,_=y.element,fm(t,a),Fl(a,c,null,o);var j=a.memoizedState;if(c=j.element,y.isDehydrated)if(y={element:c,isDehydrated:!1,cache:j.cache,pendingSuspenseBoundaries:j.pendingSuspenseBoundaries,transitions:j.transitions},a.updateQueue.baseState=y,a.memoizedState=y,a.flags&256){_=Ni(Error(r(423)),a),a=Zm(t,a,c,o,_);break e}else if(c!==_){_=Ni(Error(r(424)),a),a=Zm(t,a,c,o,_);break e}else for($t=Is(a.stateNode.containerInfo.firstChild),Mt=a,ut=!0,Tt=null,o=dm(a,null,c,o),a.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(bi(),c===_){a=da(t,a,o);break e}An(t,a,c,o)}a=a.child}return a;case 5:return _m(a),t===null&&Jc(a),c=a.type,_=a.pendingProps,y=t!==null?t.memoizedProps:null,j=_.children,jr(c,_)?j=null:y!==null&&jr(c,y)&&(a.flags|=32),Qm(t,a),An(t,a,j,o),a.child;case 6:return t===null&&Jc(a),null;case 13:return ef(t,a,o);case 4:return su(a,a.stateNode.containerInfo),c=a.pendingProps,t===null?a.child=wi(a,null,c,o):An(t,a,c,o),a.child;case 11:return c=a.type,_=a.pendingProps,_=a.elementType===c?_:ys(c,_),Vm(t,a,c,_,o);case 7:return An(t,a,a.pendingProps,o),a.child;case 8:return An(t,a,a.pendingProps.children,o),a.child;case 12:return An(t,a,a.pendingProps.children,o),a.child;case 10:e:{if(c=a.type._context,_=a.pendingProps,y=a.memoizedProps,j=_.value,Lt(Il,c._currentValue),c._currentValue=j,y!==null)if(In(y.value,j)){if(y.children===_.children&&!kn.current){a=da(t,a,o);break e}}else for(y=a.child,y!==null&&(y.return=a);y!==null;){var B=y.dependencies;if(B!==null){j=y.child;for(var K=B.firstContext;K!==null;){if(K.context===c){if(y.tag===1){K=ua(-1,o&-o),K.tag=2;var _e=y.updateQueue;if(_e!==null){_e=_e.shared;var Me=_e.pending;Me===null?K.next=K:(K.next=Me.next,Me.next=K),_e.pending=K}}y.lanes|=o,K=y.alternate,K!==null&&(K.lanes|=o),eu(y.return,o,a),B.lanes|=o;break}K=K.next}}else if(y.tag===10)j=y.type===a.type?null:y.child;else if(y.tag===18){if(j=y.return,j===null)throw Error(r(341));j.lanes|=o,B=j.alternate,B!==null&&(B.lanes|=o),eu(j,o,a),j=y.sibling}else j=y.child;if(j!==null)j.return=y;else for(j=y;j!==null;){if(j===a){j=null;break}if(y=j.sibling,y!==null){y.return=j.return,j=y;break}j=j.return}y=j}An(t,a,_.children,o),a=a.child}return a;case 9:return _=a.type,c=a.pendingProps.children,ki(a,o),_=es(_),c=c(_),a.flags|=1,An(t,a,c,o),a.child;case 14:return c=a.type,_=ys(c,a.pendingProps),_=ys(c.type,_),Gm(t,a,c,_,o);case 15:return Km(t,a,a.type,a.pendingProps,o);case 17:return c=a.type,_=a.pendingProps,_=a.elementType===c?_:ys(c,_),Jl(t,a),a.tag=1,pn(c)?(t=!0,p(a)):t=!1,ki(a,o),Om(a,c,_),_u(a,c,_,o),xu(null,a,c,!0,t,o);case 19:return nf(t,a,o);case 22:return Jm(t,a,o)}throw Error(r(156,a.tag))};function Cf(t,a){return rr(t,a)}function B_(t,a,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=a,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 ss(t,a,o,c){return new B_(t,a,o,c)}function Fu(t){return t=t.prototype,!(!t||!t.isReactComponent)}function U_(t){if(typeof t=="function")return Fu(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Ce)return 11;if(t===Y)return 14}return 2}function Ga(t,a){var o=t.alternate;return o===null?(o=ss(t.tag,a,t.key,t.mode),o.elementType=t.elementType,o.type=t.type,o.stateNode=t.stateNode,o.alternate=t,t.alternate=o):(o.pendingProps=a,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,a=t.dependencies,o.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},o.sibling=t.sibling,o.index=t.index,o.ref=t.ref,o}function ic(t,a,o,c,_,y){var j=2;if(c=t,typeof t=="function")Fu(t)&&(j=1);else if(typeof t=="string")j=5;else e:switch(t){case Q:return Pr(o.children,_,y,a);case oe:j=8,_|=8;break;case be:return t=ss(12,o,a,_|2),t.elementType=be,t.lanes=y,t;case q:return t=ss(13,o,a,_),t.elementType=q,t.lanes=y,t;case te:return t=ss(19,o,a,_),t.elementType=te,t.lanes=y,t;case X:return oc(o,_,y,a);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Ne:j=10;break e;case je:j=9;break e;case Ce:j=11;break e;case Y:j=14;break e;case U:j=16,c=null;break e}throw Error(r(130,t==null?t:typeof t,""))}return a=ss(j,o,a,_),a.elementType=t,a.type=c,a.lanes=y,a}function Pr(t,a,o,c){return t=ss(7,t,c,a),t.lanes=o,t}function oc(t,a,o,c){return t=ss(22,t,c,a),t.elementType=X,t.lanes=o,t.stateNode={isHidden:!1},t}function qu(t,a,o){return t=ss(6,t,null,a),t.lanes=o,t}function Bu(t,a,o){return a=ss(4,t.children!==null?t.children:[],t.key,a),a.lanes=o,a.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},a}function W_(t,a,o,c,_){this.tag=a,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 Uu(t,a,o,c,_,y,j,B,K){return t=new W_(t,a,o,B,K),a===1?(a=1,y===!0&&(a|=8)):a=0,y=ss(3,null,null,a),t.current=y,y.stateNode=t,y.memoizedState={element:c,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},nu(y),t}function H_(t,a,o){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:V,key:c==null?null:""+c,children:t,containerInfo:a,implementation:o}}function $f(t){if(!t)return gs;t=t._reactInternals;e:{if(Ns(t)!==t||t.tag!==1)throw Error(r(170));var a=t;do{switch(a.tag){case 3:a=a.stateNode.context;break e;case 1:if(pn(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break e}}a=a.return}while(a!==null);throw Error(r(171))}if(t.tag===1){var o=t.type;if(pn(o))return vo(t,o,a)}return a}function Ef(t,a,o,c,_,y,j,B,K){return t=Uu(o,c,!0,t,_,y,j,B,K),t.context=$f(null),o=t.current,c=Ln(),_=Ha(o),y=ua(c,_),y.callback=a??null,qa(o,y,_),t.current.lanes=_,$s(t,_,c),Bn(t,c),t}function lc(t,a,o,c){var _=a.current,y=Ln(),j=Ha(_);return o=$f(o),a.context===null?a.context=o:a.pendingContext=o,a=ua(y,j),a.payload={element:t},c=c===void 0?null:c,c!==null&&(a.callback=c),t=qa(_,a,j),t!==null&&(bs(t,_,j,y),Ol(t,_,j)),j}function cc(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 Tf(t,a){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var o=t.retryLane;t.retryLane=o!==0&&o<a?o:a}}function Wu(t,a){Tf(t,a),(t=t.alternate)&&Tf(t,a)}function V_(){return null}var Af=typeof reportError=="function"?reportError:function(t){console.error(t)};function Hu(t){this._internalRoot=t}uc.prototype.render=Hu.prototype.render=function(t){var a=this._internalRoot;if(a===null)throw Error(r(409));lc(t,a,null,null)},uc.prototype.unmount=Hu.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var a=t.containerInfo;Lr(function(){lc(null,t,null,null)}),a[_s]=null}};function uc(t){this._internalRoot=t}uc.prototype.unstable_scheduleHydration=function(t){if(t){var a=Yr();t={blockedOn:null,target:t,priority:a};for(var o=0;o<hn.length&&a!==0&&a<hn[o].priority;o++);hn.splice(o,0,t),o===0&&Pn(t)}};function Vu(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function dc(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function Lf(){}function G_(t,a,o,c,_){if(_){if(typeof c=="function"){var y=c;c=function(){var _e=cc(j);y.call(_e)}}var j=Ef(a,c,t,0,null,!1,!1,"",Lf);return t._reactRootContainer=j,t[_s]=j.current,fs(t.nodeType===8?t.parentNode:t),Lr(),j}for(;_=t.lastChild;)t.removeChild(_);if(typeof c=="function"){var B=c;c=function(){var _e=cc(K);B.call(_e)}}var K=Uu(t,0,!1,null,null,!1,!1,"",Lf);return t._reactRootContainer=K,t[_s]=K.current,fs(t.nodeType===8?t.parentNode:t),Lr(function(){lc(a,K,o,c)}),K}function mc(t,a,o,c,_){var y=o._reactRootContainer;if(y){var j=y;if(typeof _=="function"){var B=_;_=function(){var K=cc(j);B.call(K)}}lc(a,j,t,_)}else j=G_(o,a,t,_,c);return cc(j)}is=function(t){switch(t.tag){case 3:var a=t.stateNode;if(a.current.memoizedState.isDehydrated){var o=or(a.pendingLanes);o!==0&&(Es(a,o|1),Bn(a,Ot()),(bt&6)===0&&(Ei=Ot()+500,ve()))}break;case 13:Lr(function(){var c=ca(t,1);if(c!==null){var _=Ln();bs(c,t,1,_)}}),Wu(t,1)}},Qr=function(t){if(t.tag===13){var a=ca(t,134217728);if(a!==null){var o=Ln();bs(a,t,134217728,o)}Wu(t,134217728)}},Rn=function(t){if(t.tag===13){var a=Ha(t),o=ca(t,a);if(o!==null){var c=Ln();bs(o,t,a,c)}Wu(t,a)}},Yr=function(){return kt},Wi=function(t,a){var o=kt;try{return kt=t,a()}finally{kt=o}},pt=function(t,a,o){switch(a){case"input":if(fe(t,o),a=o.name,o.type==="radio"&&a!=null){for(o=t;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll("input[name="+JSON.stringify(""+a)+'][type="radio"]'),a=0;a<o.length;a++){var c=o[a];if(c!==t&&c.form===t.form){var _=xi(c);if(!_)throw Error(r(90));Be(c),fe(c,_)}}}break;case"textarea":Je(t,o);break;case"select":a=o.value,a!=null&&W(t,!!o.multiple,a,!1)}},Ye=Iu,vt=Lr;var K_={usingClientEntryPoint:!1,Events:[kr,Da,xi,ge,Te,Iu]},Mo={findFiberByHostInstance:oa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},J_={bundleType:Mo.bundleType,version:Mo.version,rendererPackageName:Mo.rendererPackageName,rendererConfig:Mo.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:M.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=ar(t),t===null?null:t.stateNode},findFiberByHostInstance:Mo.findFiberByHostInstance||V_,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 fc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!fc.isDisabled&&fc.supportsFiber)try{rs=fc.inject(J_),mn=fc}catch{}}return Un.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=K_,Un.createPortal=function(t,a){var o=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Vu(a))throw Error(r(200));return H_(t,a,null,o)},Un.createRoot=function(t,a){if(!Vu(t))throw Error(r(299));var o=!1,c="",_=Af;return a!=null&&(a.unstable_strictMode===!0&&(o=!0),a.identifierPrefix!==void 0&&(c=a.identifierPrefix),a.onRecoverableError!==void 0&&(_=a.onRecoverableError)),a=Uu(t,1,!1,null,null,o,!1,c,_),t[_s]=a.current,fs(t.nodeType===8?t.parentNode:t),new Hu(a)},Un.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var a=t._reactInternals;if(a===void 0)throw typeof t.render=="function"?Error(r(188)):(t=Object.keys(t).join(","),Error(r(268,t)));return t=ar(a),t=t===null?null:t.stateNode,t},Un.flushSync=function(t){return Lr(t)},Un.hydrate=function(t,a,o){if(!dc(a))throw Error(r(200));return mc(null,t,a,!0,o)},Un.hydrateRoot=function(t,a,o){if(!Vu(t))throw Error(r(405));var c=o!=null&&o.hydratedSources||null,_=!1,y="",j=Af;if(o!=null&&(o.unstable_strictMode===!0&&(_=!0),o.identifierPrefix!==void 0&&(y=o.identifierPrefix),o.onRecoverableError!==void 0&&(j=o.onRecoverableError)),a=Ef(a,null,t,1,o??null,_,!1,y,j),t[_s]=a.current,fs(t),c)for(t=0;t<c.length;t++)o=c[t],_=o._getVersion,_=_(o._source),a.mutableSourceEagerHydrationData==null?a.mutableSourceEagerHydrationData=[o,_]:a.mutableSourceEagerHydrationData.push(o,_);return new uc(a)},Un.render=function(t,a,o){if(!dc(a))throw Error(r(200));return mc(null,t,a,!1,o)},Un.unmountComponentAtNode=function(t){if(!dc(t))throw Error(r(40));return t._reactRootContainer?(Lr(function(){mc(null,null,t,!1,function(){t._reactRootContainer=null,t[_s]=null})}),!0):!1},Un.unstable_batchedUpdates=Iu,Un.unstable_renderSubtreeIntoContainer=function(t,a,o,c){if(!dc(o))throw Error(r(200));if(t==null||t._reactInternals===void 0)throw Error(r(38));return mc(t,a,o,!1,c)},Un.version="18.3.1-next-f1338f8080-20240426",Un}var Ff;function Xh(){if(Ff)return Ju.exports;Ff=1;function s(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(n){console.error(n)}}return s(),Ju.exports=rg(),Ju.exports}var qf;function ig(){if(qf)return hc;qf=1;var s=Xh();return hc.createRoot=s.createRoot,hc.hydrateRoot=s.hydrateRoot,hc}var og=ig();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(s=>({id:s.id,label:s.label}));function lg(s){return`theme-${String(s||"").trim()||"dark"}`}function Bf(s){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(lg(s))}catch{}}const kd=[{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}],Sd=[{id:"compact",label:"Compact",density:.85},{id:"standard",label:"Standard",density:1},{id:"spacious",label:"Spacious",density:1.2}];function cg(s){const n=String(s).trim();return kd.find(r=>r.id===n)||kd[1]}function ug(s){const n=String(s).trim();return Sd.find(r=>r.id===n)||Sd[1]}function Uf(s){try{const n=document.documentElement,r=cg(s.font_scale||"md"),i=ug(s.header_density||"standard");n.style.setProperty("--font-scale",String(r.scale)),n.style.setProperty("--header-density",String(i.density))}catch{}}function dg(s){try{return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(s).matches}catch{return!1}}function mg(s){const[n,r]=f.useState(()=>dg(s));return f.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const i=window.matchMedia(s),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)}},[s]),n}let Po=null;function fg(s,n){const r=Math.max(0,Math.round(s));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(s-n.height-Math.max(0,n.offsetTop)));return{vvHeight:i,keyboardInset:l}}function hg(){if(Po)return Po;if(typeof window>"u"||typeof document>"u")return()=>{};const s=window.visualViewport;if(!s)return()=>{};const n=document.documentElement;let r=0;const i=()=>{r=0;const{vvHeight:u,keyboardInset:m}=fg(window.innerHeight,{height:s.height,offsetTop:s.offsetTop,scale:s.scale||1});n.style.setProperty("--vv-height",`${u}px`),n.style.setProperty("--keyboard-inset",`${m}px`)},l=()=>{r||(r=window.requestAnimationFrame(i))};return i(),s.addEventListener("resize",l),s.addEventListener("scroll",l),window.addEventListener("orientationchange",l),Po=()=>{s.removeEventListener("resize",l),s.removeEventListener("scroll",l),window.removeEventListener("orientationchange",l),r&&window.cancelAnimationFrame(r),n.style.removeProperty("--vv-height"),n.style.removeProperty("--keyboard-inset"),Po=null},Po}var ep=Xh();function Ai(...s){return s.filter(Boolean).join(" ")}function qr({value:s,options:n,placeholder:r="Select…",disabled:i=!1,loading:l=!1,searchable:u=!0,searchPlaceholder:m="Search…",allowCustom:d=!1,clearable:h=!1,minPopoverWidth:x=240,variant:v="panel",className:g,triggerClassName:w,ariaLabel:L,id:E,includeValueOption:$=!1,onOpen:T,customOptionLabel:H,validateCustomValue:z,onChange:R,renderOption:M,renderValue:A}){const V=f.useRef(null),Q=f.useRef(null),oe=f.useRef(null),be=f.useRef(T),Ne=f.useId(),je=E||`af-select-${Ne.replace(/[^a-zA-Z0-9_-]/g,"")}`,Ce=`${je}-listbox`,[q,te]=f.useState(!1),[Y,U]=f.useState(""),[X,I]=f.useState(0),[ee,ae]=f.useState("bottom"),[k,C]=f.useState({left:0,top:0,width:0});f.useEffect(()=>{be.current=T},[T]);const re=f.useMemo(()=>{if(!$)return n;const se=String(s??"").trim();return!se||n.some(W=>W.value===se)?n:[...n,{value:se,label:se}]},[$,n,s]),he=f.useMemo(()=>{const se=String(s??"");return re.find(W=>W.value===se)||null},[re,s]),ce=f.useMemo(()=>(he==null?void 0:he.label)||String(s||"").trim()||"",[he,s]),O=f.useMemo(()=>{const se=Y.trim().toLowerCase();return se?re.filter(W=>W.label.toLowerCase().includes(se)||W.value.toLowerCase().includes(se)):re},[re,Y]),we=f.useMemo(()=>{if(!d)return null;const se=Y.trim();if(!se||re.some(Se=>Se.value===se))return null;const ie=(z==null?void 0:z(se,{options:re}))||"";return{value:se,label:H?H(se):`Use "${se}"`,disabled:!!ie,reason:ie}},[d,H,re,Y,z]),$e=f.useMemo(()=>{const se=we?[we,...O]:O;if(se.length>0)return se;const W=String(s??"").trim();return l&&W?[{value:W,label:ce||W}]:se},[we,O,l,ce,s]),Oe=f.useCallback(()=>{const se=V.current;if(!se)return;const W=se.getBoundingClientRect(),ie=Math.max(W.width,x),Se=Math.max(8,Math.min(W.left,window.innerWidth-ie-8)),Je=window.innerHeight-W.bottom,F=W.top,de=Je>=220||Je>=F?"bottom":"top";ae(de);const ye=de==="bottom"?W.bottom+6:W.top-6;C({left:Se,top:ye,width:ie})},[x]),Re=f.useCallback(()=>{te(!1),U("")},[]);f.useEffect(()=>{var se;q&&((se=be.current)==null||se.call(be))},[q]),f.useEffect(()=>{if(!q)return;Oe();const se=()=>Oe();return window.addEventListener("resize",se),window.addEventListener("scroll",se,!0),()=>{window.removeEventListener("resize",se),window.removeEventListener("scroll",se,!0)}},[q,Oe]),f.useEffect(()=>{if(!q)return;const se=W=>{var Se,Je;const ie=W.target;ie&&((Se=V.current)!=null&&Se.contains(ie)||(Je=Q.current)!=null&&Je.contains(ie)||Re())};return document.addEventListener("mousedown",se,!0),()=>document.removeEventListener("mousedown",se,!0)},[q,Re]),f.useEffect(()=>{if(!q)return;const se=Math.max(0,$e.findIndex(W=>W.value===s));I(se===-1?0:se),u&&setTimeout(()=>{var W;return(W=oe.current)==null?void 0:W.focus()},0)},[q,u,s,$e]);const it=se=>{var ie;const W=$e.find(Se=>Se.value===se);W!=null&&W.disabled||(R(se),Re(),(ie=V.current)==null||ie.focus())},Be=se=>{var W,ie;if(se.key==="Escape")return se.preventDefault(),Re(),(W=V.current)==null||W.focus(),!0;if(se.key==="Tab")return Re(),(ie=V.current)==null||ie.focus(),!1;if(se.key==="ArrowDown")return se.preventDefault(),I(Se=>Math.min(Se+1,Math.max(0,$e.length-1))),!0;if(se.key==="ArrowUp")return se.preventDefault(),I(Se=>Math.max(Se-1,0)),!0;if(se.key==="Home")return se.preventDefault(),I(0),!0;if(se.key==="End")return se.preventDefault(),I(Math.max(0,$e.length-1)),!0;if(se.key==="Enter"){se.preventDefault();const Se=$e[X];return Se&&it(Se.value),!0}return!1},ot=se=>{if(!i){if(q){if(Be(se))return;if(se.key===" "&&!u){se.preventDefault();const W=$e[X];W&&it(W.value)}return}(se.key==="Enter"||se.key===" "||se.key==="ArrowDown"||se.key==="ArrowUp")&&(se.preventDefault(),te(!0))}},Ve=!!String(s||"").trim(),ct=Ve?ce:r,et=we!=null&&we.disabled?we.reason||"Unavailable":"",fe=q&&$e.length>0?`${je}-opt-${X}`:void 0,ue=e.jsx("span",{className:Ai("af-select-value",!Ve&&"af-select-value--placeholder"),children:l&&!Ve?"Loading…":ct}),Ee=A?A(he,String(s||"")):ue;return e.jsxs("span",{className:Ai("af-select",v==="pin"?"af-select--pin":"af-select--panel",g),children:[e.jsxs("button",{ref:V,id:je,type:"button",className:Ai("af-select-trigger",h&&Ve&&"af-select-trigger--clearable",w),disabled:i,onMouseDown:se=>se.stopPropagation(),onClick:se=>{se.stopPropagation(),!i&&te(W=>!W)},onKeyDown:ot,role:u?void 0:"combobox","aria-haspopup":"listbox","aria-expanded":q,"aria-controls":q?Ce:void 0,"aria-activedescendant":u?void 0:fe,"aria-label":L,children:[Ee,e.jsx("span",{className:Ai("af-select-caret",q&&"af-select-caret--open"),children:"▾"})]}),h&&Ve?e.jsx("button",{type:"button",className:"af-select-clear-btn","aria-label":"Clear selection",disabled:i,onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{var W;se.preventDefault(),se.stopPropagation(),R(""),Re(),(W=V.current)==null||W.focus()},title:"Clear",children:"×"}):null,q?ep.createPortal(e.jsxs("div",{ref:Q,className:Ai("af-select-popover",ee==="top"&&"af-select-popover--top"),style:{position:"fixed",left:`${k.left}px`,top:`${k.top}px`,width:`${k.width}px`},onMouseDown:se=>se.stopPropagation(),onClick:se=>se.stopPropagation(),onWheel:se=>se.stopPropagation(),onKeyDown:Be,tabIndex:-1,children:[u?e.jsxs("div",{className:"af-select-search",children:[e.jsx("input",{ref:oe,className:"af-select-search-input",value:Y,onChange:se=>U(se.target.value),placeholder:m,onKeyDown:Be,role:"combobox","aria-expanded":!0,"aria-controls":Ce,"aria-activedescendant":fe,"aria-invalid":!!et,"aria-describedby":et?`${je}-custom-error`:void 0}),et?e.jsx("div",{id:`${je}-custom-error`,className:"af-select-custom-error",role:"alert",children:et}):null]}):null,e.jsx("div",{className:"af-select-options",role:"listbox",id:Ce,"aria-label":L,children:l&&$e.length===0?e.jsx("div",{className:"af-select-empty",children:"Loading…"}):$e.length===0?e.jsx("div",{className:"af-select-empty",children:"No results"}):$e.map((se,W)=>{var ye;const ie=se.value===s,Se=W===X,Je=String(se.group||"").trim(),F=W>0?String(((ye=$e[W-1])==null?void 0:ye.group)||"").trim():"",de=!!Je&&Je!==F;return e.jsxs(Wt.Fragment,{children:[de?e.jsx("div",{className:"af-select-group",role:"presentation",children:Je}):null,e.jsx("div",{id:`${je}-opt-${W}`,role:"option","aria-selected":ie,className:Ai("af-select-option",ie&&"af-select-option--selected",Se&&"af-select-option--highlighted",se.disabled&&"af-select-option--disabled"),title:se.disabled?se.reason||"Unavailable":void 0,onMouseEnter:()=>I(W),onMouseDown:xe=>{xe.preventDefault(),xe.stopPropagation()},onClick:()=>it(se.value),"aria-disabled":se.disabled?!0:void 0,children:M?M(se,{selected:ie,highlighted:Se}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"af-select-option-label",children:[e.jsx("span",{children:se.label}),se.reason?e.jsx("small",{className:"af-select-option-reason",children:se.reason}):null]}),ie?e.jsx("span",{className:"af-select-check",children:"✓"}):null]})})]},se.value)})})]}),document.body):null]})}function pg(s){const n=new Set,r=[];for(const i of s||[]){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 _g(s){const n=new Set,r=[];for(const i of s||[]){const l=String(i||"").trim();!l||n.has(l)||(n.add(l),r.push(l))}return r.sort(),r}const Nd="Provided by connected pin";function gg(s){const n=s.disabled===!0,r=s.layout||"stack",i=s.allowGatewayDefault!==!1,l=String(s.gatewayDefaultLabel||"(gateway default)"),u=String(s.providerLabel||"Provider"),m=String(s.modelLabel||"Model"),d=String(s.providerPlaceholder||"(select)"),h=String(s.modelPlaceholder||"(select)"),x=String(s.provider||"").trim(),v=String(s.model||"").trim(),g=pg(s.providers),w=_g(s.models),L=typeof s.markSaved=="object"?s.markSaved:null,E=(M,A,V,Q)=>s.markSaved&&!V&&!Q&&(!L||L[A]===M)?`${M} (saved)`:M,$=n||!!s.loadingProviders,T=n||!!s.loadingModels,H=[...i?[{value:"",label:l}]:[],...g.map(M=>({value:M.name,label:M.display_name?`${M.display_name} (${M.name})`:M.name})),...s.markSaved&&x&&!g.some(M=>M.name===x)?[{value:x,label:E(x,"provider",s.loadingProviders,s.providerError)}]:[]],z=[...i?[{value:"",label:l}]:[],...w.map(M=>{var A;return{value:M,label:((A=s.modelDisplayNames)==null?void 0:A[M])||M}}),...s.markSaved&&v&&!w.includes(v)?[{value:v,label:E(v,"model",s.loadingModels,s.modelError)}]:[]],R=(M,A)=>e.jsxs("div",{className:"af-pmp__pinned","data-pinned":M,children:[e.jsx("span",{className:"af-pmp__pinned-text",children:Nd}),A?e.jsxs("span",{className:"mono muted",children:[" · ",A]}):null]});return e.jsxs("div",{className:s.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}),s.providerPinned?R("provider",x):e.jsx(qr,{value:x,options:H,placeholder:i?l:d,disabled:$,loading:!!s.loadingProviders,searchable:!0,allowCustom:s.allowCustomProvider===!0,clearable:i,variant:"panel",triggerClassName:s.selectClassName,ariaLabel:u,onChange:M=>s.onChange({provider:String(M||"").trim(),model:""})}),s.loadingProviders?e.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading providers…"}):null,s.providerError?e.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:s.providerError}):null]}),e.jsxs("div",{style:r==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[e.jsx("label",{children:m}),s.modelPinned?R("model",v):e.jsx(qr,{value:v,options:z,placeholder:i?l:h,disabled:T,loading:!!s.loadingModels,searchable:!0,allowCustom:s.allowCustomModel===!0,clearable:i,variant:"panel",triggerClassName:s.selectClassName,ariaLabel:m,onChange:M=>s.onChange({provider:x,model:String(M||"").trim()})}),s.loadingModels?e.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading models…"}):null,s.modelError?e.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:s.modelError}):null]})]})}function yg(s){if(s===!1||s&&typeof s=="object"&&s.mode==="off")return!1;if(!s||typeof s!="object")return;const n=s;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 vg(s){var r;const n=(r=s==null?void 0:s.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 Wf(s){const n=yg(s);return n===!1?"off":n?String(n.num_draft_tokens):""}function xg(s){if(s==="off")return!1;if(!(!/^\d+$/.test(s)||Number(s)<1))return{mode:"native_mtp",num_draft_tokens:Number(s),require_acceleration:!0}}function bg(s){const n=vg(s.capabilities),r=Wf(s.value),i=(n==null?void 0:n.supported_depths.map(String))||[],l=Wf(n==null?void 0:n.default),u=s.inheritLabel||"Workflow / Gateway default",m=l?`${u} (${l==="off"?"Off":`depth ${l}`})`:u,d=s.error||(s.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(qr,{ariaLabel:"MTP depth",value:r,placeholder:m,disabled:s.disabled||s.loading,options:[{value:"",label:m},{value:"off",label:"Off"},...i.map(h=>({value:h,label:`Depth ${h}`})),...r&&r!=="off"&&!i.includes(r)?[{value:r,label:`Depth ${r} (saved)`}]:[]],onChange:h=>s.onChange(xg(h))}),d&&!s.hideNote?e.jsx("div",{role:"status",className:"af-pmp__hint",children:d}):null]})}const Hf="api/gateway",Fi="api/connection/gateway";function ws(s){const n=String(s||"");if(n.startsWith("/"))throw new Error(`gatewayApiPath takes a route relative to the gateway API, got ${JSON.stringify(n)}.`);return n?`${Hf}/${n}`:Hf}function Xu(s,n){const r=String(n||"");if(r.startsWith("/"))throw new Error(`joinBaseUrl takes a relative path, got ${JSON.stringify(r)}.`);let i=String(s??"");for(;i.endsWith("/");)i=i.slice(0,-1);return i?`${i}/${r}`:r}function wg(s){if(!s)return"";const n=[`${s.provider} / ${s.model}`];return s.reasoning&&n.push(`reasoning ${s.reasoning}`),s.speculation===!1?n.push("MTP off"):s.speculation&&n.push(`MTP depth ${s.speculation.num_draft_tokens}`),n.join(" · ")}function jg(s,n="Gateway default"){const r=wg(s);return r?`${n} · ${r}`:n}const kg="The gateway does not say which reasoning levels this model supports.",Sg="Set anyway",Ng="Reasoning and MTP choices appear when the gateway can describe the selected model.",Cg="Reasoning choices appear when the gateway can describe the selected model.";function $g(s){const n=s.disabled===!0,r=s.value||{provider:"",model:""},i=!String(r.provider||"").trim()&&!String(r.model||"").trim(),l=s.layout==="compact",u=s.pinned||{},m=!!(u.provider||u.model),[d,h]=f.useState(!i),x=l||m||!(i&&!d),v=i&&(l||m||!d),g=f.useRef(i);f.useEffect(()=>{i&&!g.current&&h(!1),g.current=i},[i]);const[w,L]=f.useState([]),[E,$]=f.useState(!1),[T,H]=f.useState(""),[z,R]=f.useState([]),[M,A]=f.useState({}),[V,Q]=f.useState(!1),[oe,be]=f.useState(""),Ne=f.useRef(s);Ne.current=s;const[je,Ce]=f.useState({status:"idle",value:null,message:""}),q=s.fetchGatewayDefault;f.useEffect(()=>{if(!q||n)return;let W=!0;const ie=Se=>Ce(Je=>JSON.stringify(Je)===JSON.stringify(Se)?Je:Se);return Ce(Se=>Se.status==="idle"?{...Se,status:"loading"}:Se),q().then(Se=>{var Je;W&&(Se?(Je=Se.warnings)!=null&&Je.length?ie({status:"unusable",value:Se,message:Se.warnings.join(" ")}):ie({status:"resolved",value:Se,message:""}):ie({status:"none",value:null,message:""}))}).catch(Se=>{W&&ie({status:"error",value:null,message:String((Se==null?void 0:Se.message)||Se)})}),()=>{W=!1}},[q,n]);const te=je.status==="resolved"?je.value:null,Y=f.useRef({provider:String(r.provider||"").trim(),model:String(r.model||"").trim()});f.useEffect(()=>{if(!x||u.provider||n)return;let W=!0;return $(!0),(async()=>{try{const ie=await Ne.current.fetchProviders();if(!W)return;L(Array.isArray(ie)?ie:[]),H("")}catch(ie){if(!W)return;L([]),H(`#FALLBACK provider discovery failed: ${String((ie==null?void 0:ie.message)||ie)}`)}finally{W&&$(!1)}})(),()=>{W=!1}},[x,u.provider,n]);const U=String(r.provider||"").trim();f.useEffect(()=>{if(!U||n||u.model){R([]),be(""),Q(!1);return}let W=!0;return R([]),Q(!0),be(""),(async()=>{try{const ie=await Ne.current.fetchModels(U);if(!W)return;const Se=[],Je={};for(const F of Array.isArray(ie)?ie:[]){const de=typeof F=="string"?F:String((F==null?void 0:F.id)||"");de&&(Se.push(de),typeof F!="string"&&(F!=null&&F.label)&&F.label!==de&&(Je[de]=String(F.label)))}R(Se),A(Je)}catch(ie){if(!W)return;R([]),be(`#FALLBACK model discovery failed: ${String((ie==null?void 0:ie.message)||ie)}`)}finally{W&&Q(!1)}})(),()=>{W=!1}},[U,n,u.model]);const X=String(r.model||"").trim(),I=s.defaultModeLabel||"Gateway default",ee=je.status==="none"?`${I} · none configured`:jg(te,I),ae=s.customModeLabel||"Custom",k=s.effectiveDefault||(je.value?{provider:je.value.provider,model:je.value.model}:void 0),C=U||(k==null?void 0:k.provider)||"",re=X||(U?"":k==null?void 0:k.model)||"",[he,ce]=f.useState({levels:[],error:"",loading:!1}),[O,we]=f.useState(!1),$e=!!s.fetchModelCapabilities,[Oe,Re]=f.useState();f.useEffect(()=>{let W=!0;if(Re(void 0),ce({levels:[],error:"",loading:$e&&!!re}),!(!$e||!re||n))return Ne.current.fetchModelCapabilities(re,C).then(ie=>{var ye;if(!W)return;if(ie!=null&&ie.error)throw new Error(String(ie.error));Re(ie);const Se=(ie==null?void 0:ie.capabilities)||ie||{},Je=Se.reasoning_levels||Se.thinking_levels,F=Array.isArray(Je)?[...new Set(Je.filter(xe=>typeof xe=="string"&&!!xe.trim()))]:[];!F.length&&Se.thinking_support===!0&&((ye=Se.thinking_control)!=null&&ye.prompt_disable_token)&&F.push("off","auto");const de=typeof Se.thinking_support=="boolean"?Se.thinking_support:void 0;ce({levels:F,support:de,error:"",loading:!1})}).catch(ie=>{W&&ce({levels:[],error:String((ie==null?void 0:ie.message)||ie),loading:!1})}),()=>{W=!1}},[C,re,$e,n]),f.useEffect(()=>we(!1),[C,re]);const it=s.inheritLabel||"Workflow / Gateway default",Be=v&&(te!=null&&te.reasoning)?`${it} (${te.reasoning})`:it,ot=!v||s.optionsInDefaultMode!==!1,Ve=s.reasoningLadder?[...new Set(s.reasoningLadder.filter(W=>typeof W=="string"&&W.trim()))]:null,ct=he.loading?"loading":he.levels.length||he.support===!0?"supported":he.support===!1?"unsupported":"unknown",et=s.unknownReasoning==="allow-override"&&!!(Ve!=null&&Ve.length),fe=String(r.reasoning||"").trim();let ue=[],Ee=!1;if(!Ve)ue=he.levels.map(W=>({value:W,label:W}));else if(ct==="supported"||ct==="loading"){const W=he.levels;ue=[...Ve,...W.filter(Se=>!Ve.includes(Se))].map(Se=>!W.length||W.includes(Se)?{value:Se,label:Se}:{value:Se,label:Se,disabled:!0,reason:"This model does not advertise it"})}else ct==="unknown"&&et&&(Ee=!O,ue=Ve.map(W=>({value:W,label:W})));fe&&!ue.some(W=>W.value===fe)&&ue.push({value:fe,label:`${fe} (saved)`});const se=($e||et)&&(ue.length>0||ct==="unknown"&&et);return e.jsxs("div",{className:`af-pmp${l?" af-pmp--compact":""}${s.className?` ${s.className}`:""}`,"data-gateway-default":q?je.status:void 0,children:[l||m?null:e.jsxs("div",{className:"af-pmp__seg",role:"tablist","aria-label":"Provider mode",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":v,className:`af-pmp__seg-btn${v?" is-active":""}`,onClick:()=>{h(!1),s.onChange({...r,provider:"",model:"",...$e?{reasoning:""}:{}})},disabled:n,title:ee,"data-default-choice":"",children:ee}),e.jsx("button",{type:"button",role:"tab","aria-selected":!v,className:`af-pmp__seg-btn${v?"":" is-active"}`,onClick:()=>{h(!0)},disabled:n,children:ae})]}),je.status==="error"||je.status==="unusable"?e.jsx("div",{role:"status",className:"af-pmp__hint","data-gateway-default-problem":je.status,children:je.status==="error"?`The gateway's default could not be read: ${je.message}`:`Gateway warning: ${je.message}`}):null,x?e.jsx(gg,{provider:U,model:X,providers:w,models:z,modelDisplayNames:M,markSaved:Y.current,providerPinned:u.provider,modelPinned:u.model,disabled:n,loadingProviders:E,loadingModels:V,providerError:T||void 0,modelError:oe||void 0,providerLabel:s.providerLabel,modelLabel:s.modelLabel,allowGatewayDefault:l,gatewayDefaultLabel:l?ee:void 0,allowCustomProvider:s.allowCustom!==!1,allowCustomModel:s.allowCustom!==!1,onChange:W=>s.onChange({...r,provider:W.provider,model:W.model,...$e?{reasoning:""}:{}})}):e.jsx("div",{className:"af-pmp__hint",children:s.defaultHint||"The gateway picks its configured default provider and model for this task."}),ot&&u.reasoning?e.jsxs("div",{className:"af-pmp__reasoning",children:[e.jsx("label",{children:s.reasoningLabel||"Reasoning effort"}),e.jsx("div",{className:"af-pmp__pinned","data-pinned":"reasoning",children:Nd})]}):ot&&se?e.jsxs("div",{className:"af-pmp__reasoning","data-reasoning-state":ct,children:[e.jsx("label",{children:s.reasoningLabel||"Reasoning effort"}),e.jsx(qr,{ariaLabel:s.reasoningLabel||"Reasoning effort",placeholder:Be,value:r.reasoning||"",options:[{value:"",label:Be},...ue],disabled:n||he.loading||Ee,onChange:W=>s.onChange({...r,reasoning:W})}),ct==="unknown"&&et?e.jsxs("div",{className:"af-pmp__hint","data-reasoning-unknown":"",children:[kg," ",e.jsxs("label",{className:"af-pmp__override",children:[e.jsx("input",{type:"checkbox",checked:O,disabled:n,onChange:W=>{we(W.target.checked),!W.target.checked&&r.reasoning&&s.onChange({...r,reasoning:""})}})," ",Sg]})]}):null]}):null,ot&&s.enableSpeculation&&u.speculation?e.jsxs("div",{className:"af-pmp__speculation",children:[e.jsx("label",{children:"MTP depth"}),e.jsx("div",{className:"af-pmp__pinned","data-pinned":"speculation",children:Nd})]}):ot&&s.enableSpeculation?e.jsx(bg,{value:r.speculation,inheritLabel:it,onChange:W=>s.onChange({...r,speculation:W}),capabilities:Oe,disabled:n,loading:he.loading,hideNote:!!he.error}):null,ot&&he.error?e.jsxs("div",{role:"status",className:"af-pmp__hint","data-discovery":"unavailable",children:[s.enableSpeculation?Ng:Cg,e.jsxs("details",{className:"af-pmp__details",children:[e.jsx("summary",{children:"Technical details"}),e.jsx("span",{children:he.error})]})]}):null]})}function Vf(...s){return s.filter(Boolean).join(" ")}function Eg({kicker:s="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:h,userId:x,userPlaceholder:v="admin",onUserIdChange:g,token:w,tokenPlaceholder:L="Paste Gateway user token",showToken:E=!1,onTokenChange:$,onShowTokenChange:T,remember:H=!1,rememberLabel:z="Remember this browser",onRememberChange:R,loading:M=!1,submitting:A=!1,submitDisabled:V=!1,submitLabel:Q="Sign in",submittingLabel:oe="Signing in...",closeLabel:be="Close",signOutLabel:Ne="Sign out",showClose:je=!1,showSignOut:Ce=!1,error:q,message:te,className:Y,onSubmit:U,onClose:X,onSignOut:I}){const ee=M||A,ae=ee||V||!String(x||"").trim()||!String(w||"").trim(),k=C=>{C.preventDefault(),!ae&&U()};return e.jsxs("form",{className:Vf("af-gateway-signin",Y),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:s}),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:Vf("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:C=>h==null?void 0:h(C.target.value),placeholder:d,autoComplete:"url",disabled:ee})]}):null,e.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-user",children:"Gateway user"}),e.jsx("input",{id:"gateway-session-user",value:x,onChange:C=>g(C.target.value),placeholder:v,autoComplete:"username",disabled:ee}),e.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-token",children:"Gateway token"}),e.jsxs("div",{className:"af-gateway-signin__token-input",children:[e.jsx("input",{id:"gateway-session-token",type:E?"text":"password",value:w,onChange:C=>$(C.target.value),placeholder:L,autoComplete:"off","data-1p-ignore":"","data-lpignore":"true","data-bwignore":"",spellCheck:!1,disabled:ee}),e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>T==null?void 0:T(!E),disabled:ee,children:E?"Hide":"Show"})]}),e.jsxs("label",{className:"af-gateway-signin__checkbox",children:[e.jsx("input",{type:"checkbox",checked:!!H,onChange:C=>R==null?void 0:R(C.target.checked),disabled:ee}),z]})]}),q?e.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--error",children:q}):null,!q&&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:[je?e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:X,disabled:ee,children:be}):null,Ce?e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>void(I==null?void 0:I()),disabled:ee,children:Ne}):null,e.jsx("button",{className:"af-gateway-signin__primary",type:"submit",disabled:ae,children:A?oe:Q})]})]})}function Tg(s){return s==="light"?"Light":"Dark"}function Ag(s){const n=s.themes&&s.themes.length?s.themes:Zh,r=s.showSwatches!==!1,i=s.variant||"panel",l=f.useMemo(()=>{const m={};for(const d of n)m[d.id]=d;return m},[n]),u=f.useMemo(()=>n.map(m=>({value:m.id,label:m.label,group:Tg(m.group)})),[n]);return e.jsx(qr,{value:s.value,options:u,placeholder:s.placeholder||"Select theme…",disabled:s.disabled===!0,searchable:!0,allowCustom:!1,clearable:!1,variant:i,className:s.className,triggerClassName:s.triggerClassName,onChange:m=>s.onChange(String(m||"").trim()),renderValue:(m,d)=>{const h=String(d||"").trim(),x=l[h],v=(x==null?void 0:x.label)||h||s.placeholder||"Select theme…",g=(x==null?void 0:x.swatches)||null,w=!h;return e.jsxs("span",{className:"af-theme-value",children:[e.jsx("span",{className:`af-theme-label ${w?"af-theme-label--placeholder":""}`.trim(),children:v}),r&&g?e.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:g.map((L,E)=>e.jsx("span",{className:"af-theme-swatch",style:{background:L}},`${h}:${E}`))}):null]})},renderOption:(m,d)=>{const h=String(m.value||"").trim(),x=l[h],v=(x==null?void 0:x.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((g,w)=>e.jsx("span",{className:"af-theme-swatch",style:{background:g}},`${h}:${w}`))}):null,d.selected?e.jsx("span",{className:"af-select-check",children:"✓"}):null]})]})}})}function Lg(s){const n=s.scales&&s.scales.length?s.scales:kd,r=s.variant||"panel",i=f.useMemo(()=>n.map(l=>({value:l.id,label:l.label})),[n]);return e.jsx(qr,{value:s.value,options:i,placeholder:s.placeholder||"Font size…",disabled:s.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:r,className:s.className,triggerClassName:s.triggerClassName,onChange:l=>s.onChange(String(l||"").trim())})}function Mg(s){const n=s.densities&&s.densities.length?s.densities:Sd,r=s.variant||"panel",i=f.useMemo(()=>n.map(l=>({value:l.id,label:l.label})),[n]);return e.jsx(qr,{value:s.value,options:i,placeholder:s.placeholder||"Header size…",disabled:s.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:r,className:s.className,triggerClassName:s.triggerClassName,onChange:l=>s.onChange(String(l||"").trim())})}const Rg=new Set(["board","inbox","server","agent","playCircle","list","gear"]);function Pg(s){switch(s){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"})]});case"image":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("circle",{cx:"9",cy:"9",r:"2"}),e.jsx("path",{d:"M21 15l-3.1-3.1a2 2 0 0 0-2.8 0L6 21"})]});case"video":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"}),e.jsx("path",{d:"M16 10.5l5.2-3.1a.5.5 0 0 1 .8.4v8.4a.5.5 0 0 1-.8.4L16 13.5"})]});case"camera":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3z"}),e.jsx("circle",{cx:"12",cy:"13",r:"3"})]});case"music":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M9 18V5l12-2v13"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("circle",{cx:"18",cy:"16",r:"3"})]});case"database":return e.jsxs(e.Fragment,{children:[e.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),e.jsx("path",{d:"M3 5v14a9 3 0 0 0 18 0V5"}),e.jsx("path",{d:"M3 12a9 3 0 0 0 18 0"})]});case"branch":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M6 3v12"}),e.jsx("circle",{cx:"18",cy:"6",r:"3"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]});case"loop":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M17 2l4 4-4 4"}),e.jsx("path",{d:"M3 11v-1a4 4 0 0 1 4-4h14"}),e.jsx("path",{d:"M7 22l-4-4 4-4"}),e.jsx("path",{d:"M21 13v1a4 4 0 0 1-4 4H3"})]});case"variable":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M8 21s-4-3-4-9 4-9 4-9"}),e.jsx("path",{d:"M16 3s4 3 4 9-4 9-4 9"}),e.jsx("path",{d:"M15 9l-6 6"}),e.jsx("path",{d:"M9 9l6 6"})]});case"minus":return e.jsx("path",{d:"M5 12h14"});case"divide":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"6",r:"1.25",fill:"currentColor",stroke:"none"}),e.jsx("path",{d:"M5 12h14"}),e.jsx("circle",{cx:"12",cy:"18",r:"1.25",fill:"currentColor",stroke:"none"})]});case"function":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3"}),e.jsx("path",{d:"M9 11.2h5.7"})]});case"zoomIn":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"}),e.jsx("path",{d:"M11 8v6"}),e.jsx("path",{d:"M8 11h6"})]});case"zoomOut":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"}),e.jsx("path",{d:"M8 11h6"})]});case"fitView":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}),e.jsx("path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}),e.jsx("path",{d:"M3 16v3a2 2 0 0 0 2 2h3"}),e.jsx("path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"})]});case"lock":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"4",y:"11",width:"16",height:"10",rx:"2"}),e.jsx("path",{d:"M8 11V7a4 4 0 0 1 8 0v4"})]});default:return null}}function Ue({name:s,size:n=16,className:r,title:i,...l}){const u=i?void 0:!0,m=Rg.has(s);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,Pg(s)]})}function zg(s){return!String(s.unavailableReason||"").trim()&&!s.busy}function Ig(s){return zg(s)?!s.checked:null}let Dg=0;function Di(s){const{label:n,checked:r,onChange:i,description:l,reasonVisible:u=!0,describedBy:m,hint:d,busy:h=!1,variant:x="inline",ariaLabel:v,className:g,id:w,action:L}=s,E=String(s.unavailableReason||"").trim(),$=!!E,T=m||(w?`${w}-reason`:$?`af-switch-reason-${++Dg}`:void 0),H=["af-switch",x==="row"?"af-switch--row":x==="sm"?"af-switch--sm":"",$?"af-switch--unavailable":"",g||""].filter(Boolean).join(" "),z=M=>{const A=Ig({checked:r,unavailableReason:E,busy:h});if(A===null){M.preventDefault();return}i==null||i(A)},R=e.jsxs("button",{type:"button",role:"switch",id:w,className:H,"data-action":L,"aria-checked":r?"true":"false","aria-disabled":$?"true":void 0,"aria-describedby":$?T:void 0,"aria-busy":h?"true":void 0,"aria-label":v,"aria-description":l?void 0:d,title:$?d?`${E}
41
+ ${d}`:E:d,onClick:z,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?R:e.jsxs("span",{className:x==="row"?"af-switch-wrap af-switch-wrap--row":"af-switch-wrap",children:[R,e.jsx("span",{id:T,className:u?"af-switch__reason":"af-switch__reason af-switch__reason--hidden",children:E})]})}const Og=150,tp="data-af-tip";function Fg(s,n,r,i=6,l=8){let u="top",m=s.top-i-n.height;if(m<l){const x=s.bottom+i;(x+n.height<=r.height-l||r.height-s.bottom>s.top)&&(m=x,u="bottom")}let h=(s.left+s.right)/2-n.width/2;return h=Math.max(l,Math.min(h,r.width-l-n.width)),m=Math.max(l,Math.min(m,r.height-l-n.height)),{top:Math.round(m),left:Math.round(h),side:u}}let Gf=0;function np(s){return s?String(s.getAttribute(tp)||"").trim():""}function Zu(s,n){const r=s;if(!r||typeof r.closest!="function")return null;const i=r.closest(`[${tp}]`);return!i||!n.contains(i)||!np(i)?null:i}function qg(s,n={}){if(!s)throw new Error("bindAfTooltips: a root (document or element) is required");const r=s.nodeType===9?s:s.ownerDocument,i=r.defaultView||globalThis,l=typeof n.delayMs=="number"&&n.delayMs>=0?n.delayMs:Og;Gf+=1;const u=r.createElement("div");u.className="af-tooltip",u.setAttribute("role","tooltip");const m=`af-tooltip-${Gf}`;u.setAttribute("id",m),u.hidden=!0,(r.body||r.documentElement).appendChild(u);let d=null,h=null,x=null,v=null,g=!1,w=null;const L=()=>{x&&clearTimeout(x),x=null,h=null},E=()=>{v&&clearTimeout(v),v=null},$=()=>{if(!d)return;const Y=d.getBoundingClientRect(),U=u.getBoundingClientRect(),X=Fg(Y,{width:U.width,height:U.height},{width:i.innerWidth,height:i.innerHeight});u.style.top=`${X.top}px`,u.style.left=`${X.left}px`,u.setAttribute("data-side",X.side)},T=()=>{if(L(),E(),!d)return;String(d.getAttribute("aria-describedby")||"").split(/\s+/).includes(m)&&(w?d.setAttribute("aria-describedby",w):d.removeAttribute("aria-describedby")),w=null,d=null,u.hidden=!0,u.textContent=""},H=Y=>{L(),E(),d&&d!==Y&&T();const U=np(Y);if(!U||Y.isConnected===!1)return;if(d=Y,u.textContent=U,u.hidden=!1,String(Y.getAttribute("aria-label")||"").trim()!==U){const I=Y.getAttribute("aria-describedby");w=I&&I!==m?I:null,Y.setAttribute("aria-describedby",w?`${w} ${m}`:m)}$()},z=Y=>{E(),d!==Y&&h!==Y&&(L(),h=Y,x=setTimeout(()=>{const U=h;x=null,h=null,U&&H(U)},l))},R=()=>{L(),d&&(E(),v=setTimeout(T,100))},M=Y=>{try{if(typeof Y.matches=="function")return Y.matches(":focus-visible")}catch{}return g},A=Y=>{if(Y.pointerType==="touch")return;if(u.contains(Y.target)){E();return}const X=Zu(Y.target,s);X&&z(X)},V=Y=>{const X=Y.relatedTarget||null;if(!(X&&(u.contains(X)||d&&d.contains(X)||h&&h.contains(X)))){if(h&&!d){L();return}d&&R()}},Q=Y=>{const U=Y.relatedTarget||null;U&&(u.contains(U)||d&&d.contains(U))||R()},oe=Y=>{const U=Zu(Y.target,s);U&&M(U)&&z(U)},be=Y=>{const U=Zu(Y.target,s);U&&(U===d||U===h)&&T()},Ne=()=>{g=!1,T()},je=Y=>{if(Y.key==="Escape"||Y.key==="Esc"){d?(Y.preventDefault(),T()):L();return}!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&(g=!0)},Ce=()=>T(),q=s;q.addEventListener("pointerover",A),q.addEventListener("pointerout",V),q.addEventListener("focusin",oe),q.addEventListener("focusout",be),u.addEventListener("pointerover",A),u.addEventListener("pointerout",Q),r.addEventListener("pointerdown",Ne,!0),i.addEventListener("keydown",je,!0),i.addEventListener("scroll",Ce,!0),i.addEventListener("resize",Ce);let te=!1;return()=>{te||(te=!0,T(),q.removeEventListener("pointerover",A),q.removeEventListener("pointerout",V),q.removeEventListener("focusin",oe),q.removeEventListener("focusout",be),u.removeEventListener("pointerover",A),u.removeEventListener("pointerout",Q),r.removeEventListener("pointerdown",Ne,!0),i.removeEventListener("keydown",je,!0),i.removeEventListener("scroll",Ce,!0),i.removeEventListener("resize",Ce),u.parentNode&&u.parentNode.removeChild(u))}}const pc=new WeakMap;function Bg(s){let n=pc.get(s);n||(n={count:0,release:qg(s)},pc.set(s,n)),n.count+=1;let r=!1;return()=>{if(r)return;r=!0;const i=pc.get(s);i&&(i.count-=1,i.count<=0&&(i.release(),pc.delete(s)))}}function Hd(){f.useEffect(()=>{if(!(typeof document>"u"))return Bg(document)},[])}const ed=1;function Xa(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}const Ug=["granted","denied","structurally_unavailable","trust_gated"],Wg=["attachable","requires_review","blocked"],Hg=["default","operator","structural"],Vg=["grant","deny","clear"],Gg=new Set(["__proto__","constructor","prototype"]);function Kg(s,n){if(!Xa(s))return{ok:!1,reason:`${n}: cell is not an object`};const r=String(s.availability||"");if(!Ug.includes(r))return{ok:!1,reason:`${n}: unknown availability "${r}"`};const i=String(s.provenance||"");if(!Hg.includes(i))return{ok:!1,reason:`${n}: unknown provenance "${i}"`};let l;if(r==="trust_gated"){const u=String(s.trust_state||"");if(!Wg.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=s[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:s.assigned===!0,resolved_value:s.resolved_value===!0,provenance:i,availability:r,executable:s.executable!==!1,reason:typeof s.reason=="string"?s.reason:void 0,trust_state:l}}}function sp(s){if(!Xa(s))return{ok:!1,reason:"payload is not an object"};const n=s.schema_version;if(typeof n!="number"||!Number.isFinite(n))return{ok:!1,reason:"payload has no numeric schema_version"};if(Math.floor(n)!==ed)return{ok:!1,reason:`unsupported schema_version ${n} (this build understands ${ed}); refusing to render grant state from an unknown schema`};if(!Array.isArray(s.phases)||s.phases.length===0)return{ok:!1,reason:"payload has no phases"};if(!Array.isArray(s.sections))return{ok:!1,reason:"payload has no sections"};const r=[],i=new Set;for(const m of s.phases){if(!Xa(m)||typeof m.id!="string"||!m.id.trim())return{ok:!1,reason:"phase without a string id"};const d=m.id.trim();if(Gg.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 s.sections){if(!Xa(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 h=[],x=new Set;for(const v of m.items){if(!Xa(v)||typeof v.id!="string"||!v.id.trim())return{ok:!1,reason:`section "${d}": item without a string id`};const g=v.id.trim();if(x.has(g))return{ok:!1,reason:`section "${d}": duplicate item id "${g}"`};if(x.add(g),v.cells!==void 0&&!Xa(v.cells))return{ok:!1,reason:`section "${d}" item "${g}": cells is not an object`};const w=Object.create(null),L=Xa(v.cells)?v.cells:{};for(const[E,$]of Object.entries(L)){if(!i.has(E))return{ok:!1,reason:`section "${d}" item "${g}": cell for undeclared phase "${E}"`};const T=Kg($,`section "${d}" item "${g}" phase "${E}"`);if(!T.ok)return T;w[E]=T.cell}h.push({id:g,label:typeof v.label=="string"?v.label:void 0,description:typeof v.description=="string"?v.description:void 0,cells:w})}l.push({id:d,label:typeof m.label=="string"?m.label:void 0,items:h})}return{ok:!0,payload:{schema_version:ed,phases:r,sections:l}}}function Jg(s,n,r,i){for(const l of s)if(l.section===n&&l.item===r&&l.phase===i)return l.op;return null}function Vd(s,n,r,i,l){const u=s.sections.find(E=>E.id===r),m=u==null?void 0:u.items.find(E=>E.id===i),d=m&&m.cells[l]||null,h=Jg(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 x=d.availability==="structurally_unavailable"||d.availability==="trust_gated"&&d.trust_state==="blocked";let v=d.resolved_value;h==="grant"?v=!0:h==="deny"?v=!1:h==="clear"&&(v=d.provenance==="operator"?null:d.resolved_value);const g=d.availability==="trust_gated"&&d.trust_state==="requires_review",w=x?!1:v;let L;return x?L={kind:"blocked",blocked_kind:d.availability==="trust_gated"?"trust":"structural"}:g&&w!==!0?L={kind:"approval"}:L={kind:"tristate",options:["grant","clear","deny"],active_op:h!==null?h:d.assigned?d.resolved_value?"grant":"deny":"clear"},{cell:d,pending:h,effective_value:w,interactive:!x,approval_required:g,standing_config:!x&&d.executable===!1,reason:d.reason||(x?d.availability:null),control:L}}function Qg(s,n,r){const i=Vd(s,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 Yg(s,n){const r=new Set,i=[];for(const l of n){if(!Xa(l)||!Vg.includes(l.op))continue;const u=`${l.section}\0${l.item}\0${l.phase}`;if(r.has(u))continue;r.add(u);const m=Vd(s,[],l.section,l.item,l.phase);!m.cell||!m.interactive||i.push(l)}return i}function Xg(s){return s==="grant"?"Grant":s==="deny"?"Deny":"Default"}function Zg(s){const{view:n,disabled:r}=s,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:()=>s.onAct("grant"),"aria-label":`Approve and enable: ${s.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":s.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:()=>s.onAct(m),children:Xg(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 ey(s){const n=s.disabled===!0,r=f.useMemo(()=>sp(s.payload),[s.payload]),i=f.useMemo(()=>r.ok?Yg(r.payload,s.patches):s.patches,[r,s.patches]);if(!r.ok)return e.jsxs("div",{className:`af-matrix af-matrix--refused ${s.className||""}`.trim(),children:[e.jsx("div",{className:"af-matrix__title",children:s.title||"Phase capabilities"}),e.jsxs("div",{className:"af-matrix__refusal",children:["Cannot render capability state: ",r.reason]})]});const l=r.payload,u=(m,d,h,x)=>{if(n)return;const v=Qg(l,i,{section:m,item:d,phase:h,op:x});s.onPatchesChange(v)};return e.jsxs("div",{className:`af-matrix ${s.className||""}`.trim(),children:[e.jsxs("div",{className:"af-matrix__header",children:[e.jsx("div",{className:"af-matrix__title",children:s.title||"Phase capabilities"}),s.subtitle?e.jsx("div",{className:"af-matrix__subtitle",children:s.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(h=>{const x=Vd(l,i,m.id,d.id,h.id);return e.jsx("td",{className:"af-matrix__cell-td",children:e.jsx(Zg,{view:x,cellLabel:`${d.label||d.id} — ${h.label||h.id}`,disabled:n,onAct:v=>u(m.id,d.id,h.id,v)})},h.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))]})})]})}function ap(s){return!!(s&&s.ok===!0&&s.has_session===!0)}function ty(s){const n=s||{},r=n.connectionPath||Fi,i=n.variant||"dismissable",l=f.useRef(n.onStatusChange);l.current=n.onStatusChange;const u=f.useRef(i);u.current=i;const m=f.useRef(!!n.autoOpenMidSession);m.current=!!n.autoOpenMidSession;const[d,h]=f.useState(null),[x,v]=f.useState("loading"),[g,w]=f.useState(!1),L=f.useRef(!1),E=f.useRef(!1),$=f.useRef("loading"),T=f.useRef("none"),H=f.useRef(!1),z=f.useRef(0),R=f.useCallback(te=>{var U;z.current+=1,h(te),(U=l.current)==null||U.call(l,te);const Y=ap(te);if(Y)v("connected"),$.current="connected",L.current=!1,T.current="none",E.current||w(!1);else if(te!==null){const X=$.current;v("disconnected"),$.current="disconnected",X!=="disconnected"&&(T.current=H.current?"signout":X==="connected"?"mid":"boot");const I=u.current==="blocking"||T.current!=="mid"||m.current;!L.current&&I&&w(!0)}te!==null&&(E.current=Y)},[]),M=f.useCallback(async()=>{const te=z.current;try{const Y=await Cd(r);if(z.current!==te)return;R(Y)}catch{if(z.current!==te)return;R(null)}},[r,R]),[A,V]=f.useState(!1),[Q,oe]=f.useState(null),be=f.useCallback(async()=>{V(!0),oe(null),z.current+=1;let te=null;try{await ip(r)}catch(Y){te=String((Y==null?void 0:Y.message)||Y||"Sign-out request failed")}H.current=!0;try{await M()}finally{H.current=!1}return oe(te),V(!1),te===null&&$.current!=="connected"},[r,M]),Ne=f.useRef(!1);f.useEffect(()=>{Ne.current||(Ne.current=!0,M())},[M]);const je=f.useCallback(()=>{w(!0)},[]),Ce=f.useCallback(()=>{const te=$.current;i==="blocking"&&te==="disconnected"||(te==="disconnected"&&(L.current=!0),w(!1))},[i]),q=f.useMemo(()=>({isOpen:g,onClose:Ce,blocking:i==="blocking"&&x!=="connected",appName:n.appName,connectionPath:r,defaultGatewayUrl:n.defaultGatewayUrl,initialStatus:d,onStatusChange:R}),[g,Ce,i,x,n.appName,r,n.defaultGatewayUrl,d,R]);return{status:d,phase:x,connected:x==="connected",modalOpen:g,signingOut:A,signOutError:Q,openModal:je,refresh:M,signOut:be,modalProps:q}}const ny="default";function Za(s){return typeof s=="string"?s.trim():""}function Kf(s){return Array.isArray(s)?s.filter(n=>typeof n=="string"):void 0}function sy(s){var x;if(!s||!ap(s))return null;const n=(x=s.gateway)==null?void 0:x.principal;if(!n||typeof n!="object")return null;const r=Za(n.user_id);if(!r)return null;const i={userId:r},l=Za(n.tenant_id);l&&(i.tenantId=l);const u=Za(n.runtime_id);u&&(i.runtimeId=u);const m=Kf(n.roles);m&&(i.roles=m);const d=Kf(n.scopes);d&&(i.scopes=d);const h=Za(n.source);return h&&(i.source=h),typeof n.admin=="boolean"&&(i.admin=n.admin),i}function rp(s){const n=Za(s.displayName)||Za(s.userId),r=Za(s.tenantId);return r&&r!==ny?`${r}/${n}`:n}function Gd(s){const n=Za(s);if(!n)return"";try{return new URL(n).host||n}catch{return n}}async function Cd(s=Fi){const n=await fetch(s),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 ay(s,n=Fi){const r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),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 ip(s=Fi){const n=await fetch(s,{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 td(s){let n=String(s||"").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 ry(s){var d,h;if(!s)return{label:"Signed out",tone:"warn"};if(!s.has_session)return{label:"Signed out",tone:"warn"};const n=s.gateway||{},r=(d=n.principal)==null?void 0:d.user_id,i=(h=n.principal)==null?void 0:h.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=typeof s.gateway_status=="number"?s.gateway_status:null,u=Gd(s.gateway_url);if(l===0)return{label:`Gateway${u?` at ${u}`:""} did not answer — is it running?`,tone:"err"};if(l===502||l===503||l===504)return{label:`Gateway unavailable (HTTP ${l}) — try again shortly`,tone:"err"};if(l!==null&&l>=500)return{label:`Gateway error (HTTP ${l}) — try again shortly`,tone:"err"};if(l!==null&&l>=400&&l!==401&&l!==403)return{label:`Gateway answered HTTP ${l} — check the gateway URL`,tone:"err"};const m=n.error||n.detail;return typeof m=="string"&&m.trim()?{label:"Session rejected — sign in again",tone:"err"}:{label:"Sign in required",tone:"err"}}function iy(s){const n=s.connectionPath||Fi,[r,i]=f.useState(!1),[l,u]=f.useState(!1),[m,d]=f.useState(null),[h,x]=f.useState(!1);f.useEffect(()=>{s.isOpen||x(!1)},[s.isOpen]);const[v,g]=f.useState(s.defaultGatewayUrl||"http://127.0.0.1:8080"),[w,L]=f.useState("admin"),[E,$]=f.useState(""),[T,H]=f.useState(!1),[z,R]=f.useState(!0),[M,A]=f.useState(""),[V,Q]=f.useState(""),oe=f.useMemo(()=>ry(m),[m]),be=q=>{var te;d(q),(te=s.onStatusChange)==null||te.call(s,q)},Ne=f.useRef(!1);if(f.useEffect(()=>{var te;if(!s.isOpen)return;const q=!Ne.current;if(Ne.current=!0,q&&s.initialStatus!==void 0&&s.initialStatus!==null){const Y=s.initialStatus;be(Y),typeof Y.gateway_url=="string"&&Y.gateway_url.trim()&&g(td(Y.gateway_url));const U=(te=Y.gateway)==null?void 0:te.principal;U!=null&&U.user_id&&L(U.user_id);return}i(!0),A(""),Cd(n).then(Y=>{var X;be(Y),typeof Y.gateway_url=="string"&&Y.gateway_url.trim()&&g(td(Y.gateway_url));const U=(X=Y.gateway)==null?void 0:X.principal;U!=null&&U.user_id&&L(U.user_id)}).catch(Y=>A(`Failed to load connection status: ${String((Y==null?void 0:Y.message)||Y)}`)).finally(()=>i(!1))},[s.isOpen]),f.useEffect(()=>{if(!s.isOpen)return;const q=te=>{te.key==="Escape"&&!te.defaultPrevented&&!s.blocking&&(te.preventDefault(),s.onClose())};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[s.isOpen,s.blocking,s.onClose]),!s.isOpen||h)return null;const je=async()=>{u(!0),A(""),Q("");try{const q=td(v);g(q);const te=await ay({gateway_url:q,gateway_user_id:w,gateway_token:E,persist:z},n);be(te),$(""),x(!0),s.onClose()}catch(q){A(String((q==null?void 0:q.message)||q))}finally{u(!1)}},Ce=async()=>{u(!0),A(""),Q("");try{await ip(n),$("");const q=await Cd(n).catch(()=>null);be(q),Q("Signed out. This browser no longer holds a gateway session.")}catch(q){A(String((q==null?void 0:q.message)||q))}finally{u(!1)}};return e.jsx("div",{className:"af-connect-overlay",role:"presentation",onMouseDown:q=>{!s.blocking&&q.target===q.currentTarget&&s.onClose()},children:e.jsx("div",{className:"af-connect-modal",role:"dialog","aria-modal":"true","aria-label":"Gateway connection",children:e.jsx(Eg,{kicker:`${s.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:oe.label,statusTone:oe.tone,showGatewayUrl:!0,gatewayUrl:v,onGatewayUrlChange:q=>g(q),userId:w,onUserIdChange:L,token:E,tokenPlaceholder:m!=null&&m.has_session?"(browser session already signed in)":"Paste Gateway user token",showToken:T,onTokenChange:$,onShowTokenChange:H,remember:z,rememberLabel:"Keep this browser signed in",onRememberChange:R,loading:r,submitting:l,submittingLabel:"Signing in...",showClose:!s.blocking,onClose:s.onClose,showSignOut:!s.blocking&&!!(m!=null&&m.has_session),onSignOut:Ce,error:M,message:V,onSubmit:je})})})}function oy(){return globalThis.crypto}function ly(s){if(s.length<16)throw new Error("uuidV4FromBytes: needs 16 bytes");const n=Array.from(s.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 Zo(){const s=oy();if(s&&typeof s.randomUUID=="function")try{return s.randomUUID()}catch{}if(s&&typeof s.getRandomValues=="function")return ly(s.getRandomValues(new Uint8Array(16)));throw new Error("randomId: Web Crypto (crypto.getRandomValues) is unavailable")}function Kd(s){return globalThis.isSecureContext!==!1?null:`This page is loaded over http, so ${s} 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 nd={neutral:"var(--text-secondary)",muted:"var(--text-muted)",accent:"var(--accent)",info:"var(--info)",success:"var(--success)",warning:"var(--warning)",error:"var(--error)"},cy=/^var\(--[a-z0-9-]+\)$/i;function uy(s,n){const r=s||"neutral";if(r==="custom"){const i=String(n||"").trim();return cy.test(i)?i:nd.neutral}return nd[r]||nd.neutral}function dy(s,n,r){return[s,`${s}--${n.tone||"neutral"}`,n.size==="sm"?`${s}--sm`:"",r||"",n.className||""].filter(Boolean).join(" ")}function my(s){return{"--af-chip-hue":uy(s.tone,s.hue)}}function Wn(s){return e.jsxs("span",{className:dy("af-chip",s,s.onRemove?"af-chip--removable":""),style:my(s),title:s.title,children:[e.jsx("span",{className:"af-chip__label",children:s.children}),s.onRemove?e.jsx("button",{type:"button",className:"af-chip__remove","aria-label":s.removeLabel||"Remove",onClick:n=>{var r;n.stopPropagation(),(r=s.onRemove)==null||r.call(s)},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]})}const fy='button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';function hy(s,n=!1){if(!s)return null;const r=s.querySelector(".af-drawer__body")||s,i=r.querySelector("[data-autofocus]");return i||(n?s:r.querySelector("textarea:not(:disabled)")||r.querySelector(fy)||s)}function py(){try{return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}function Jf(s){return s==="auto"?"var(--af-topbar-h, 0px)":typeof s=="number"&&Number.isFinite(s)?s:0}function $d(s){const n=s.closeOnEscape!==!1,r=f.useRef(null);f.useEffect(()=>{if(!s.open||!n)return;const m=d=>{d.key!=="Escape"||d.defaultPrevented||(d.preventDefault(),s.onClose())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[s.open,n,s.onClose]);const i=f.useRef(null),l=s.manageFocus!==!1,u=f.useRef(!1);return f.useEffect(()=>{var x;if(!u.current){u.current=!0;return}if(!l||typeof document>"u")return;const m=r.current;if(s.open){if(i.current=document.activeElement,m&&m.contains(document.activeElement))return;const v=window.setTimeout(()=>{var g;(g=hy(m,py()))==null||g.focus({preventScroll:!0})},0);return()=>window.clearTimeout(v)}const d=i.current;i.current=null;const h=document.activeElement;d&&d.isConnected&&(!h||h===document.body||m&&m.contains(h))&&((x=d.focus)==null||x.call(d,{preventScroll:!0}))},[s.open,l]),f.useEffect(()=>{const m=r.current;m&&(s.open?m.removeAttribute("inert"):m.setAttribute("inert",""))},[s.open]),e.jsxs(e.Fragment,{children:[s.backdrop&&s.open?e.jsx("div",{className:"af-drawer-backdrop","aria-hidden":"true",onClick:s.onClose,style:{top:Jf(s.topOffset)}}):null,e.jsxs("div",{ref:r,className:`af-drawer${s.side==="left"?" af-drawer--left":""}${s.topOffset?" af-drawer--offset":""}${s.open?" af-drawer--open":""}${s.className?` ${s.className}`:""}`,style:{width:s.width||420,top:Jf(s.topOffset),display:s.open?void 0:"none"},role:"complementary","aria-label":s.label,"aria-hidden":s.open?void 0:!0,tabIndex:-1,children:[s.title!==void 0?e.jsxs("div",{className:"af-drawer__header",children:[e.jsx("div",{className:"af-drawer__title",children:s.title}),e.jsxs("div",{className:"af-drawer__header-actions",children:[s.headerActions,e.jsx("button",{type:"button",className:"af-drawer__close","aria-label":"Close panel",onClick:s.onClose,children:"×"})]})]}):null,e.jsx("div",{className:"af-drawer__body",children:s.children})]})]})}function _y(s,n,r,i=4,l=8){let u=s.bottom+i,m=!1;if(u+n.height>r.height-l){const x=s.top-i-n.height;(x>=l||s.top>r.height-s.bottom)&&(u=x,m=!0)}let d=s.left,h=!1;return d+n.width>r.width-l&&(d=s.right-n.width,h=!0),d=Math.max(l,Math.min(d,r.width-l-n.width)),u=Math.max(l,u),{top:Math.round(u),left:Math.round(d),up:m,leftward:h}}let Qf=0;function gy(s,n,r={}){if(!s||!n)throw new Error("bindAfMenu: button and menu are required");const i=r.document||s.ownerDocument,l=i.defaultView||globalThis;n.getAttribute("id")||(Qf+=1,n.setAttribute("id",`af-menu-${Qf}`)),s.setAttribute("aria-haspopup","menu"),s.setAttribute("aria-expanded","false"),s.setAttribute("aria-controls",String(n.getAttribute("id"))),n.setAttribute("role","menu"),n.hidden=!0;const u=()=>{const R=Array.from(n.querySelectorAll(".af-menu__item")),M=R.filter(A=>!A.hidden&&!A.hasAttribute("disabled"));for(const A of R)A.setAttribute("role","menuitem"),A.setAttribute("tabindex","-1");return M};u();let m=!1;const d=()=>{if(!m)return;const R=s.getBoundingClientRect(),M=n.getBoundingClientRect(),A=_y(R,{width:M.width,height:M.height},{width:l.innerWidth,height:l.innerHeight});n.style.top=`${A.top}px`,n.style.left=`${A.left}px`,n.setAttribute("data-placement",`${A.up?"top":"bottom"}-${A.leftward?"end":"start"}`)},h=R=>{const M=u();if(!M.length)return;const A=(R%M.length+M.length)%M.length;M[A].focus({preventScroll:!0})},x=R=>{m||(m=!0,n.hidden=!1,s.setAttribute("aria-expanded","true"),d(),h(R),i.addEventListener("pointerdown",g,!0),i.addEventListener("mousedown",g,!0),l.addEventListener("scroll",d,!0),l.addEventListener("resize",w),l.addEventListener("keydown",$,!0),r.onOpen&&r.onOpen())},v=R=>{m&&(m=!1,n.hidden=!0,s.setAttribute("aria-expanded","false"),i.removeEventListener("pointerdown",g,!0),i.removeEventListener("mousedown",g,!0),l.removeEventListener("scroll",d,!0),l.removeEventListener("resize",w),l.removeEventListener("keydown",$,!0),R&&s.focus({preventScroll:!0}),r.onClose&&r.onClose())};function g(R){const M=R.target;M&&(n.contains(M)||s.contains(M))||v(!1)}function w(){v(!1)}const L=R=>{R.preventDefault(),m?v(!0):x(0)},E=R=>{R.key==="ArrowDown"||(R.key==="Enter"||R.key===" ")&&!m?(R.preventDefault(),x(0)):R.key==="ArrowUp"&&(R.preventDefault(),x(-1))},$=R=>{if(!m||R.key!=="Escape"&&R.key!=="Esc")return;const M=R.target;M&&M!==s&&!n.contains(M)&&M!==i.body||(R.preventDefault(),v(!0))},T=R=>{if(!m)return;const A=u().indexOf(i.activeElement);R.key==="ArrowDown"?(R.preventDefault(),h(A+1)):R.key==="ArrowUp"?(R.preventDefault(),h(A<0?-1:A-1)):R.key==="Home"?(R.preventDefault(),h(0)):R.key==="End"?(R.preventDefault(),h(-1)):R.key==="Tab"&&v(!1)},H=R=>{const M=R.target,A=M&&typeof M.closest=="function"?M.closest(".af-menu__item"):null;if(!A||!n.contains(A))return;const V=i.activeElement,Q=!V||V===i.body||n.contains(V);v(Q)};s.addEventListener("click",L),s.addEventListener("keydown",E),n.addEventListener("keydown",T),n.addEventListener("click",H);let z=!1;return()=>{z||(z=!0,v(!1),s.removeEventListener("click",L),s.removeEventListener("keydown",E),n.removeEventListener("keydown",T),n.removeEventListener("click",H))}}function yy(s){const n=f.useRef(null),r=f.useRef(null),i=s.items.filter(u=>u&&!u.hidden),l=i.length>0;return f.useEffect(()=>{if(!(!l||!n.current||!r.current))return gy(n.current,r.current)},[l]),l?e.jsxs("div",{className:`af-menu${s.className?` ${s.className}`:""}`,children:[e.jsx("button",{type:"button",ref:n,className:`af-menu__button${s.buttonClassName?` ${s.buttonClassName}`:""}`,"aria-label":s.label,title:s.title,"data-af-tip":s.tip,"aria-haspopup":"menu","aria-expanded":"false",children:s.buttonContent!==void 0?s.buttonContent:e.jsx("span",{"aria-hidden":"true",children:"⋯"})}),e.jsxs("div",{className:"af-menu__list",role:"menu",ref:r,hidden:!0,children:[s.header!==void 0&&s.header!==null?e.jsx("div",{className:"af-menu__header",role:"presentation",children:s.header}):null,i.map(u=>e.jsx("button",{type:"button",role:"menuitem",tabIndex:-1,"data-menu-id":u.id,className:`af-menu__item${u.danger?" af-menu__item--danger":""}`,onClick:()=>u.onSelect(),children:u.label},u.id))]})]}):null}const vy={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"},xy={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"}},by={framework:vy,apps:xy},Lc=by;function op(){return{...Lc.framework}}function wy(){return Object.keys(Lc.apps).sort()}function jy(s,n){const r=Object.prototype.hasOwnProperty.call(Lc.apps,s)?Lc.apps[s]:void 0;if(!r)throw new Error(`appIdentity: unknown application id "${s}" (known: ${wy().join(", ")})`);return{id:s,name:r.name,version:n,website:r.website,repo:r.repo,docs:r.docs,issues:r.issues,feedback:r.feedback}}async function ky(s,n){try{const r=await s(ws("about"),{method:"GET",headers:{Accept:"application/json"},signal:n});if(!r.ok)return el(null,`HTTP ${r.status}`);const i=await r.json().catch(()=>null);return el(i)}catch(r){return el(null,String((r==null?void 0:r.message)||r||"request failed"))}}const Sy={framework:null,frameworkNote:"checking…",gateway:null,gatewayNote:"checking…"};function Ri(s){return typeof s=="string"?s.trim():""}function el(s,n){if(n!=null)return{framework:null,gateway:null,gatewayNote:`unavailable (${String(n).trim()||"unknown error"})`};const r=s&&typeof s=="object"&&!Array.isArray(s)?s:{},i=Ri(r.abstractgateway),l=Ri(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 Ny(s){const n=op();return[{id:"website",label:"Website",href:s.website,title:s.website},{id:"source",label:"Source",href:s.repo,title:s.repo},{id:"docs",label:"Docs",href:s.docs,title:s.docs},{id:"issues",label:"Issues",href:s.issues,title:s.issues},{id:"feedback",label:"Feedback",href:s.feedback,title:s.feedback},{id:"contact",label:"Contact",href:`mailto:${n.contact_email}`,title:n.contact_email}]}function Cy(s){const n=s||{},r=Ri(n.framework),i=Ri(n.gateway);return[["AbstractFramework",r||Ri(n.frameworkNote)||"not reported"],["AbstractGateway",i||Ri(n.gatewayNote)||"not connected"]]}const $y='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';function Ey(s,n,r){if(s.key!=="Tab"||!n)return;const i=Array.from(n.querySelectorAll($y));if(i.length===0){s.preventDefault();return}const l=i[0],u=i[i.length-1],m=!!r&&n.contains(r);s.shiftKey?(r===l||!m)&&(s.preventDefault(),u.focus()):(r===u||!m)&&(s.preventDefault(),l.focus())}function Ty(s){const n=op();return e.jsxs("div",{className:`af-about-card${s.className?` ${s.className}`:""}`,"data-app":s.identity.id,children:[e.jsxs("div",{className:"af-about-card__head",children:[e.jsxs("h2",{className:"af-about-card__name",id:s.titleId,children:[s.identity.name," ",e.jsx("span",{className:"af-about-card__version",children:s.identity.version})]}),s.action]}),e.jsx("dl",{className:"af-about-card__versions",children:Cy(s.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":`${s.identity.name} links`,children:Ny(s.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))}),s.extra!==void 0&&s.extra!==null?e.jsx("div",{className:"af-about-card__extra",children:s.extra}):null,e.jsx("p",{className:"af-about-card__legal",children:n.copyright})]})}function Ay(s){Hd();const n=f.useRef(null),r=f.useRef(null),i=f.useId(),l=f.useRef(s.onClose);return l.current=s.onClose,f.useEffect(()=>{var d;if(!s.open)return;const u=document.activeElement;(d=n.current)==null||d.focus();const m=h=>{if(!h.defaultPrevented){if(h.key==="Escape"){h.preventDefault(),l.current();return}Ey(h,r.current,document.activeElement)}};return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m),u&&typeof u.focus=="function"&&u.focus()}},[s.open]),s.open?e.jsx("div",{className:"af-appearance-overlay af-about-overlay",onClick:s.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(Ty,{identity:s.identity,versions:s.versions,extra:s.extra,titleId:i,action:e.jsx("button",{ref:n,type:"button",className:"af-about-card__close","data-action":"close-about",onClick:s.onClose,"aria-label":"Close","data-af-tip":"Close About",children:e.jsx(Ue,{name:"x",size:16})})})})}):null}const Ec={theme:"dark",font_scale:"md",header_density:"standard"};function Ly(s){const n=s&&typeof s=="object"?s:{};return{theme:typeof n.theme=="string"&&n.theme?n.theme:Ec.theme,font_scale:typeof n.font_scale=="string"&&n.font_scale?n.font_scale:Ec.font_scale,header_density:typeof n.header_density=="string"&&n.header_density?n.header_density:Ec.header_density}}function My(s){return`af_appearance_${s}_v1`}function Ry(s,n){const r=My(s),i=f.useMemo(()=>({...Ec}),[JSON.stringify({})]),[l,u]=f.useState(()=>{let m=i;try{const d=localStorage.getItem(r)??(n!=null&&n.legacyKey?localStorage.getItem(n.legacyKey):null);d&&(m=Ly({...i,...JSON.parse(d)}))}catch{}try{Bf(m.theme),Uf({font_scale:m.font_scale,header_density:m.header_density})}catch{}return m});return f.useEffect(()=>{Bf(l.theme),Uf({font_scale:l.font_scale,header_density:l.header_density});try{localStorage.setItem(r,JSON.stringify(l))}catch{}},[r,l]),[l,u]}function lp(s){return f.useEffect(()=>{if(!s.open)return;const n=r=>{r.key!=="Escape"||r.defaultPrevented||(r.preventDefault(),s.onClose())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[s.open,s.onClose]),s.open?e.jsx("div",{className:"af-appearance-overlay",onClick:s.onClose,role:"presentation",children:e.jsxs("div",{className:"af-appearance",role:"dialog","aria-modal":"true","aria-label":s.title||"Appearance",onClick:n=>n.stopPropagation(),children:[e.jsx("div",{className:"af-appearance__title",children:s.title||"Appearance"}),e.jsx("div",{className:"af-appearance__note",children:s.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(Ag,{value:s.value.theme,onChange:n=>s.onChange({...s.value,theme:n})}),e.jsx("label",{className:"af-appearance__label",children:"Font size"}),e.jsx(Lg,{value:s.value.font_scale,onChange:n=>s.onChange({...s.value,font_scale:n})}),e.jsx("label",{className:"af-appearance__label",children:"Header size"}),e.jsx(Mg,{value:s.value.header_density,onChange:n=>s.onChange({...s.value,header_density:n})})]}),e.jsx("div",{className:"af-appearance__actions",children:e.jsx("button",{type:"button",className:"af-appearance__close",onClick:s.onClose,children:"Close"})})]})}):null}function Py(s,n){return{label:n?"Disconnecting…":s==="connected"?"Disconnect":s==="loading"?"Connecting…":"Connect",title:s==="connected"?"Disconnect from gateway":s==="loading"?"Checking gateway session…":"Connect to gateway"}}function zy(s){return typeof s.openModal=="function"&&typeof s.signOut=="function"}function Iy(s,n){return zy(s)?{phase:s.phase,signingOut:s.signingOut===!0,connect:s.openModal,disconnect:async()=>{await s.signOut()===!0&&(n==null||n())},status:s.status,signOutError:s.signOutError||null}:{phase:s.phase,signingOut:s.signingOut===!0,connect:s.onConnect,disconnect:async()=>{s.onDisconnect()},status:s.status??null,signOutError:s.signOutError||null}}function Dy(s,n){const r=Gd(n);return`Signed in as ${rp(s)}${r?` · gateway ${r}`:""}`}const sd="--af-topbar-h";function Oy(s,n=!0){f.useEffect(()=>{if(!n||typeof window>"u"||typeof document>"u")return;const r=s.current;if(!r)return;const i=r.closest("[data-af-topbar], header")||r.parentElement||r,l=document.documentElement;let u="";const m=()=>{u=`${Math.max(0,Math.round(i.getBoundingClientRect().bottom))}px`,l.style.setProperty(sd,u)};m();const d=typeof ResizeObserver<"u"?new ResizeObserver(m):null;d==null||d.observe(i);const h={passive:!0,capture:!0};return window.addEventListener("resize",m),window.addEventListener("scroll",m,h),()=>{d==null||d.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("scroll",m,h),u&&l.style.getPropertyValue(sd)===u&&l.style.removeProperty(sd)}},[s,n])}function Fy(s){const n=typeof navigator<"u"?navigator.clipboard:void 0;return!n||typeof n.writeText!="function"?null:()=>{n.writeText(s).catch(()=>{})}}function qy(s){var M,A;const n=Iy(s.connection,s.onSignOut),{phase:r,signingOut:i}=n,[l,u]=f.useState(!1),[m,d]=f.useState(!1),[h,x]=f.useState(void 0),v=f.useRef(null);Hd(),Oy(v,s.publishHeight!==!1);const g=s.about,w=s.appearance,L=!!(w&&"value"in w),E=g&&!g.versions?g.fetch:void 0,$=f.useRef(E);$.current=E,f.useEffect(()=>{const V=$.current;if(!l||!V)return;const Q=typeof AbortController<"u"?new AbortController:null;let oe=!0;return x(Sy),ky(V,Q==null?void 0:Q.signal).then(be=>{oe&&x(be)}),()=>{oe=!1,Q==null||Q.abort()}},[l]);const T=Py(r,i),H=s.identity&&r==="connected"?sy(n.status):null,z=()=>void n.disconnect();let R=null;if(H&&s.identity){const V=rp(H),Q=Dy(H,(M=n.status)==null?void 0:M.gateway_url),oe=e.jsxs(e.Fragment,{children:[e.jsx(Ue,{name:"user",size:14}),e.jsx("span",{className:"af-topbar__identity-label",children:V})]});if(s.identity==="badge")R=e.jsx("span",{className:"af-topbar__identity af-topbar__identity--badge","data-af-identity":"badge","data-af-tip":Q,"aria-label":Q,children:oe});else{const be=Fy(H.userId),Ne=Gd((A=n.status)==null?void 0:A.gateway_url);R=e.jsx(yy,{label:`Account: ${Q}`,tip:Q,className:"af-topbar__account",buttonClassName:"af-topbar__identity af-topbar__identity--menu",buttonContent:oe,header:e.jsxs("span",{className:"af-topbar__account-head","data-af-identity":"menu",children:[e.jsxs("span",{className:"af-topbar__account-who",children:["Signed in as ",V]}),Ne?e.jsxs("span",{className:"af-topbar__account-host",children:["Gateway ",Ne]}):null]}),items:[{id:"copy-user-id",label:"Copy user id",onSelect:be||(()=>{}),hidden:!be},{id:"disconnect",label:"Disconnect",onSelect:z,danger:!0,hidden:i}]})}}return e.jsxs("div",{ref:v,className:`af-topbar${s.className?` ${s.className}`:""}`,role:"group","aria-label":"App actions",children:[s.extraActions,s.docs?e.jsx("button",{type:"button",className:`af-topbar__btn af-topbar__btn--docs${s.docs.open?" is-active":""}`,"aria-pressed":s.docs.open,"aria-label":s.docs.label||"Docs assistant","data-af-tip":s.docs.label||"Docs assistant",onClick:s.docs.onToggle,children:e.jsx(Ue,{name:"book",size:16})}):null,s.assistant?e.jsx("button",{type:"button",className:`af-topbar__btn af-topbar__btn--assistant${s.assistant.open?" is-active":""}`,"aria-pressed":s.assistant.open,"aria-label":s.assistant.label||"Open assistant","data-af-tip":s.assistant.label||"Assistant",onClick:s.assistant.onToggle,children:e.jsx(Ue,{name:"sparkle",size:16})}):null,w?e.jsx("button",{type:"button",className:"af-topbar__btn af-topbar__btn--appearance","aria-label":w.label||"Appearance (theme and typography)","data-af-tip":w.label||"Appearance (theme and text size)","aria-haspopup":L?"dialog":void 0,onClick:()=>{"value"in w?d(!0):w.onOpen()},children:e.jsx(Ue,{name:"contrast",size:16})}):null,g?e.jsx("button",{type:"button",className:"af-topbar__btn af-topbar__btn--about","aria-label":g.label||`About ${g.identity.name}`,"data-af-tip":g.label||`About ${g.identity.name}`,"aria-haspopup":"dialog",onClick:()=>{var V;u(!0),(V=g.onOpen)==null||V.call(g)},children:e.jsx(Ue,{name:"info",size:16})}):null,R,n.signOutError?e.jsxs("span",{className:"af-topbar__signout-error",role:"alert","data-af-tip":`Disconnect failed: ${n.signOutError}`,"aria-label":`Disconnect failed: ${n.signOutError}`,children:[e.jsx(Ue,{name:"warning",size:14}),e.jsx("span",{className:"af-topbar__signout-error-label",children:"Disconnect failed"})]}):null,e.jsxs("button",{type:"button",className:`af-topbar__pill af-topbar__pill--${r}`,onClick:r==="connected"?z:n.connect,disabled:i,title:T.title,"aria-label":T.title,children:[e.jsx("span",{className:`af-topbar__dot af-topbar__dot--${r}`,"aria-hidden":"true"}),e.jsx("span",{className:"af-topbar__pill-label",children:T.label})]}),g?e.jsx(Ay,{open:l,onClose:()=>u(!1),identity:g.identity,versions:g.versions||(g.fetch?h:void 0),extra:g.extra}):null,w&&"value"in w?e.jsx(lp,{open:m,onClose:()=>d(!1),value:w.value,onChange:w.onChange,title:w.title,note:w.note}):null]})}const cp=()=>{var s;return(s=globalThis.navigator)==null?void 0:s.mediaDevices};function By(s){var l;const n=Kd("the microphone");if(n)return n;const r=String((s==null?void 0:s.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=cp())!=null&&l.getUserMedia))return"This browser cannot record audio.";const i=String((s==null?void 0:s.message)||s||"").trim();return i?`The microphone did not start: ${i.replace(/\.$/,"")}.`:"The microphone did not start."}async function Uy(s){const n=cp();if(!(n!=null&&n.getUserMedia))throw Object.assign(new Error("This browser cannot record audio."),{name:"NotSupportedError"});return n.getUserMedia({audio:s?{deviceId:{exact:s}}:!0})}function up(){const s=globalThis;return s.AudioContext||s.webkitAudioContext||null}function Wy(){const s=up();return!!(s&&s.prototype&&typeof s.prototype.createMediaStreamDestination=="function")}function Hy(s,n,r=1){const i=up();if(!i)return()=>{};const l=new i,u=l.createMediaStreamSource(s),m=l.createAnalyser();m.fftSize=1024,u.connect(m);const d=new Float32Array(m.fftSize);let h=!0;const v=setInterval(()=>{if(!h)return;m.getFloatTimeDomainData(d);let g=0;for(let w=0;w<d.length;w+=1)g+=d[w]*d[w];n(Math.min(1,Math.sqrt(g/d.length)*4*r))},50);return()=>{var g;h=!1,clearInterval(v);try{u.disconnect()}catch{}(g=l.close)==null||g.call(l)}}function Yf(s){const n=Number(s);return s==null||s===""||!Number.isFinite(n)?1:Math.min(1,Math.max(0,n))}function Xf(s){return(s&&typeof s=="object"?s.capture_mode:s)==="toggle"?"toggle":"hold"}async function*Vy(s){var i,l,u;const n=new AbortController,r=()=>n.abort();(i=s.signal)!=null&&i.aborted?r():(l=s.signal)==null||l.addEventListener("abort",r,{once:!0});try{const m=await fetch(s.path,{method:"POST",headers:{"Content-Type":"application/json",...s.csrfToken?{"x-abstract-csrf":s.csrfToken}:{},...s.headers||{}},body:JSON.stringify(s.body),signal:n.signal});if(!m.ok){const v=await m.json().catch(()=>null),g=v&&typeof v=="object"&&v.detail?String(v.detail):`HTTP ${m.status}`;throw new Error(g)}if(!m.body)throw new Error("TTS stream has no body");const d=m.body.getReader(),h=new TextDecoder;let x="";for(;;){const{done:v,value:g}=await d.read();x+=v?h.decode():h.decode(g,{stream:!0}),v&&x.trim()&&(x+=`
42
+ `);let w;for(;(w=x.indexOf(`
43
+ `))>=0;){const L=x.slice(0,w).trim();if(x=x.slice(w+1),!L)continue;let E=null;try{E=JSON.parse(L)}catch{throw new Error("TTS stream returned invalid JSON.")}if(E&&E.type==="error")throw new Error(String(E.error||"TTS stream error"));const $=E&&typeof E.audio_b64=="string"?E.audio_b64:"";if($){const T=atob($),H=new Uint8Array(T.length);for(let z=0;z<T.length;z+=1)H[z]=T.charCodeAt(z);yield H.buffer}if(E&&(E.type==="done"||E.type==="cancelled"))return}if(v)throw new Error("TTS stream ended before synthesis completed.")}}finally{(u=s.signal)==null||u.removeEventListener("abort",r),n.abort()}}function zo(s,n){const r=String((n==null?void 0:n.message)||n||"").trim().replace(/\.$/,"");return r?`${s}: ${r}.`:`${s}.`}const Gy=350;function Ky(){var n;if(typeof window>"u")return!1;const s=navigator;return!!((n=s==null?void 0:s.mediaDevices)!=null&&n.getUserMedia)&&typeof window.MediaRecorder=="function"}function Jy(){if(typeof window>"u")return!1;const s=window;return!!(s!=null&&s.AudioContext||s!=null&&s.webkitAudioContext)}function Qy(){const s=window.MediaRecorder,n=i=>{var l;try{return!!((l=s==null?void 0:s.isTypeSupported)!=null&&l.call(s,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 ad(s,n){var l;const r=n.slice(0),i=(l=s.decodeAudioData)==null?void 0:l.bind(s);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 Yy(s){const n=new Uint8Array(s);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(s);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 Xy(s,n){const r=new Uint8Array(n),i=new Uint8Array(s.length+r.length);i.set(s,0),i.set(r,s.length);const l=new DataView(i.buffer);return l.setUint32(4,i.length-8,!0),l.setUint32(s.length-4,r.length,!0),i.buffer}const _c=new WeakMap;function Zy(s,n){const r=s;if(!(typeof r.setSinkId!="function"||_c.get(s)===n)){_c.set(s,n);try{Promise.resolve(r.setSinkId(n)).catch(()=>_c.delete(s))}catch{_c.delete(s)}}}function dp(s){const n=f.useRef(s);n.current=s;const r=F=>{var de,ye;return(ye=(de=n.current).on_error)==null?void 0:ye.call(de,F)},i=f.useMemo(()=>Jy()&&(typeof s.tts=="function"||typeof s.tts_stream=="function"),[s.tts,s.tts_stream]),l=f.useMemo(()=>Ky()&&typeof s.transcribe=="function",[s.transcribe]),[u,m]=f.useState({key:"",status:"idle"}),d=f.useRef(u),h=f.useCallback(F=>{d.current=F,m(de=>de.key===F.key&&de.status===F.status?de:F)},[]),x=f.useRef(""),v=f.useRef(""),g=f.useRef(null),w=f.useRef(null),L=f.useRef(null),E=f.useRef(null),$=f.useRef(0),T=f.useRef(0),H=f.useRef(0),z=f.useRef(null),R=f.useRef([]),M=f.useRef(0),A=f.useRef(!0),V=f.useRef(!1),Q=()=>{try{const F=globalThis,de=(F==null?void 0:F.AudioContext)||(F==null?void 0:F.webkitAudioContext);if(!de)return null;if(!g.current){const ke=new de,J=ke.createGain();J.gain.value=1,J.connect(ke.destination),g.current=ke,w.current=J}const ye=g.current,xe=w.current;if(!ye||!xe)return null;Zy(ye,n.current.output_device_id||""),xe.gain.value=Yf(n.current.volume)*(n.current.muted?0:1);try{ye.state==="suspended"&&ye.resume()}catch{}return{ctx:ye,gain:xe}}catch{return null}};f.useEffect(()=>{const F=w.current;F&&(F.gain.value=Yf(s.volume)*(s.muted?0:1))},[s.volume,s.muted]);const oe=f.useCallback(()=>{const F=L.current;if(L.current=null,!!F){try{F.onended=null}catch{}try{F.stop()}catch{}try{F.disconnect()}catch{}}},[]),be=f.useCallback(()=>{var F;oe(),H.current+=1,(F=z.current)==null||F.abort(),z.current=null,R.current=[],M.current=0,A.current=!0,V.current=!1,v.current="",x.current="",E.current=null,$.current=0,T.current=0,h({key:"",status:"idle"})},[oe,h]);f.useEffect(()=>()=>{var F,de;be();try{(F=w.current)==null||F.disconnect()}catch{}try{(de=g.current)==null||de.close()}catch{}g.current=null,w.current=null,E.current=null},[]);const Ne=async(F,de,ye)=>{const xe=H.current,ke=Q();if(!ke)throw new Error("TTS playback is not supported in this browser");const{ctx:J,gain:P}=ke;try{J.state==="suspended"&&await J.resume()}catch{}if(xe!==H.current)return;oe();const Z=J.createBufferSource();Z.buffer=de,Z.connect(P);const Pe=Number.isFinite(Number(de.duration))?Number(de.duration):0,Fe=Math.max(0,Math.min(Number(ye||0),Pe>0?Math.max(0,Pe-.01):0));T.current=J.currentTime-Fe,$.current=Fe,L.current=Z,x.current=F,Z.onended=()=>{L.current===Z&&(L.current=null,$.current=0,T.current=0,x.current="",h({key:"",status:"idle"}))},Z.start(0,Fe),h({key:F,status:"playing"})},je=(F,de)=>{if(de!==H.current)return;const ye=Q();if(!ye)return;const xe=R.current,ke=M.current;if(ke>=xe.length){A.current&&(x.current="",$.current=0,T.current=0,h({key:"",status:"idle"}));return}const J=xe[ke],{ctx:P,gain:Z}=ye;oe();const Pe=P.createBufferSource();Pe.buffer=J,Pe.connect(Z);const Fe=Number.isFinite(Number(J.duration))?Number(J.duration):0,Xe=Math.max(0,Math.min(Number($.current||0),Fe>0?Math.max(0,Fe-.01):0));T.current=P.currentTime-Xe,L.current=Pe,x.current=F,Pe.onended=()=>{de===H.current&&L.current===Pe&&(L.current=null,M.current=ke+1,$.current=0,je(F,de))};try{P.state==="suspended"&&P.resume()}catch{}Pe.start(0,Xe),h({key:F,status:"playing"})},Ce=async(F,de,ye)=>{var Z;const xe=Q();if(!xe){r==null||r("This browser cannot play spoken replies.");return}oe();const ke=++H.current;(Z=z.current)==null||Z.abort();const J=new AbortController;z.current=J,R.current=[],M.current=0,A.current=!1,V.current=!1,E.current=null,$.current=0,T.current=0,x.current=F,v.current=F,h({key:F,status:"loading"}),r==null||r("");let P=null;try{for await(const Pe of ye(de,J.signal)){if(ke!==H.current)return;let Fe;try{Fe=await ad(xe.ctx,Pe),P||(P=Yy(Pe))}catch{if(!P)continue;try{Fe=await ad(xe.ctx,Xy(P,Pe))}catch{continue}}if(ke!==H.current)return;R.current.push(Fe),!L.current&&!V.current&&(v.current="",je(F,ke))}if(ke!==H.current)return;if(A.current=!0,R.current.length===0){r==null||r("Reading aloud failed: the voice engine returned no audio."),be();return}!L.current&&!V.current&&je(F,ke)}catch(Pe){if(ke!==H.current)return;r==null||r(zo("Reading aloud failed",Pe)),be()}finally{z.current===J&&(z.current=null)}},q=f.useCallback(async(F,de)=>{var Xe;const ye=String(F||"").trim(),xe=String(de||"").trim();if(!ye||!xe)return;const ke=n.current.tts,J=n.current.tts_stream;if(typeof ke!="function"&&typeof J!="function"){r==null||r("Reading aloud is not available on this gateway.");return}const P=Q();if(!P){r==null||r("This browser cannot play spoken replies.");return}const Z=d.current,Pe=Z.key===ye;if(Pe&&Z.status==="playing"){if(L.current){const dt=Math.max(0,P.ctx.currentTime-Number(T.current||0));$.current=dt}else $.current=0;V.current=!0,oe(),h({key:ye,status:"paused"});return}if(Pe&&Z.status==="paused"){if(R.current.length>0){r==null||r(""),V.current=!1,h({key:ye,status:"playing"}),je(ye,H.current);return}const dt=E.current;if(dt){r==null||r(""),V.current=!1;try{await Ne(ye,dt,$.current)}catch(ft){r==null||r(zo("Reading aloud failed",ft)),h({key:"",status:"idle"})}return}}if(Pe&&Z.status==="loading")return;if(typeof J=="function"){await Ce(ye,xe,J);return}oe(),H.current+=1,(Xe=z.current)==null||Xe.abort(),z.current=null;const Fe=H.current;R.current=[],M.current=0,A.current=!0,V.current=!1,E.current=null,$.current=0,T.current=0,x.current=ye,v.current=ye,h({key:ye,status:"loading"}),r==null||r("");try{const dt=await ke(xe);if(v.current!==ye||H.current!==Fe)return;const ft=await ad(P.ctx,dt);if(v.current!==ye||H.current!==Fe)return;E.current=ft,$.current=0,await Ne(ye,ft,0)}catch(dt){if(H.current!==Fe)return;v.current===ye&&(v.current="",x.current="",h({key:"",status:"idle"})),r==null||r(zo("Reading aloud failed",dt))}},[]),[te,Y]=f.useState(!1),[U,X]=f.useState(!1),I=f.useRef(!1),ee=f.useRef(l);ee.current=l;const ae=f.useCallback(F=>{I.current=F,Y(de=>de===F?de:F)},[]),k=f.useRef(!1),C=f.useRef(null),re=f.useRef(null),he=f.useRef([]),ce=f.useRef(""),O=f.useRef(0),we=f.useRef(!1),$e=f.useRef(!1),[Oe,Re]=f.useState(0),it=f.useRef(0),Be=f.useRef(null),ot=f.useRef(0),Ve=f.useRef(new Set),ct=f.useRef(null),et=f.useCallback(F=>{const de=Math.round(Math.min(1,Math.max(0,Number(F)||0))*20)/20;if(de!==ot.current){ot.current=de;for(const ye of Array.from(Ve.current))ye(de)}},[]),fe=f.useCallback(F=>(Ve.current.add(F),F(ot.current),()=>{Ve.current.delete(F)}),[]),ue=f.useRef(new Set),Ee=f.useCallback(F=>(ue.current.add(F),()=>{ue.current.delete(F)}),[]);function se(){var ye,xe;const F=ct.current;ct.current=null;try{F==null||F()}catch{}et(0);try{(xe=(ye=C.current)==null?void 0:ye.getTracks)==null||xe.call(ye).forEach(ke=>{try{ke.stop()}catch{}})}catch{}C.current=null;const de=Be.current;Be.current=null;try{de==null||de.close()}catch{}}const W=f.useCallback(()=>{O.current+=1,we.current=!1;const F=re.current;if(F){F.onstop=null,F.ondataavailable=null,F.onerror=null;try{F.stop()}catch{}}re.current=null,se(),ae(!1),k.current=!1,X(!1),Re(0),he.current=[]},[ae]);f.useEffect(()=>()=>W(),[W]);async function ie(F,de){var J,P;if(r==null||r(""),k.current)return;const ye=it.current?Date.now()-it.current:1/0;if(!F||!F.size||ye<Gy){Re(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 xe=n.current.transcribe;if(typeof xe!="function"){r==null||r("Speech to text is not available on this gateway.");return}k.current=!0;const ke=O.current;X(!0),Re(Date.now());try{const Z=await xe(F,de),Pe=typeof Z=="string"||!Z?{text:String(Z||"")}:Z,Fe=String(Pe.text||"").trim();if(ke!==O.current)return;if(Fe){(P=(J=n.current).on_transcript)==null||P.call(J,Fe,{...Pe,text:Fe});for(const Xe of Array.from(ue.current))Xe(Fe,{...Pe,text:Fe})}else r==null||r("Nothing was heard. Check the microphone in Settings → Voice (Test), then try again.")}catch(Z){if(ke===O.current){const Pe=String((Z==null?void 0:Z.message)||Z||"").trim().replace(/\.$/,"");r==null||r(Pe?`Transcription failed: ${Pe}.`:"Transcription failed.")}}finally{ke===O.current&&(k.current=!1,X(!1),Re(0))}}const Se=f.useCallback(async()=>{if(r==null||r(""),!ee.current){r==null||r(Kd("the microphone")??"Voice recording is not supported in this browser (MediaRecorder/getUserMedia unavailable).");return}if(k.current||we.current||I.current||re.current)return;he.current=[];const F=O.current;we.current=!0,$e.current=!1;try{const de=await Uy(n.current.input_device_id||"");if(F!==O.current){de.getTracks().forEach(Z=>Z.stop());return}if($e.current){$e.current=!1,de.getTracks().forEach(Z=>Z.stop()),Re(0);return}C.current=de;const ye=Number(n.current.input_gain??1);try{ct.current=Hy(de,et,Number.isFinite(ye)&&ye>0?ye:1)}catch{}const xe=Qy();ce.current=xe;let ke=de;const J=Number(n.current.input_gain??1);if(Number.isFinite(J)&&J>0&&J!==1&&Wy()){const Z=globalThis.AudioContext||globalThis.webkitAudioContext,Pe=new Z,Fe=Pe.createGain();Fe.gain.value=J;const Xe=Pe.createMediaStreamDestination();Pe.createMediaStreamSource(de).connect(Fe),Fe.connect(Xe),Be.current=Pe,ke=Xe.stream}const P=xe?new MediaRecorder(ke,{mimeType:xe}):new MediaRecorder(ke);re.current=P,P.ondataavailable=Z=>{if(F===O.current)try{Z!=null&&Z.data&&he.current.push(Z.data)}catch{}},P.onerror=()=>{F===O.current&&(r==null||r("Recording failed. Try again, or pick another microphone in Settings → Voice."))},P.onstop=()=>{if(F===O.current){ae(!1),se(),re.current=null;try{const Z=new Blob(he.current,{type:ce.current||""});ie(Z,ce.current)}catch(Z){r==null||r(zo("The recording could not be prepared",Z))}}},P.start(),it.current=Date.now(),Re(it.current),ae(!0)}catch(de){if(F!==O.current)return;se(),re.current=null,ae(!1),Re(0),r==null||r(By(de))}finally{F===O.current&&(we.current=!1)}},[]),Je=f.useCallback(()=>{const F=re.current;if(we.current&&!F){$e.current=!0;return}if(!(!I.current||!F)){ae(!1);try{F.stop()}catch(de){r==null||r(zo("The recording could not stop",de))}}},[]);return f.useEffect(()=>{if(!te||n.current.stop_on_pointerup===!1||n.current.stop_on_pointerup===void 0&&Xf(n.current.capture_mode)==="toggle")return;const F=()=>Je();return window.addEventListener("pointerup",F),window.addEventListener("pointercancel",F),()=>{window.removeEventListener("pointerup",F),window.removeEventListener("pointercancel",F)}},[te]),{tts_supported:i,tts_playback:u,toggle_tts:q,stop_tts:be,voice_ptt_supported:l,voice_ptt_recording:te,voice_ptt_busy:U,start_voice_ptt_recording:Se,stop_voice_ptt_recording:Je,cancel_voice_ptt_recording:W,voice_ptt_since:Oe,subscribe_level:fe,voice_capture_mode:Xf(s.capture_mode),add_transcript_listener:Ee}}const mp=72;function ev(s,n=mp){const r=Math.max(1,Math.floor(n)),i=new Array(r).fill(0),l=s.length;if(!l)return i;const u=l/r;let m=0;for(let d=0;d<r;d+=1){const h=Math.floor(d*u),x=Math.max(h+1,Math.floor((d+1)*u));let v=0;for(let g=h;g<x&&g<l;g+=1){const w=Math.abs(Number(s[g])||0);w>v&&(v=w)}i[d]=v,v>m&&(m=v)}return m<=0?i:i.map(d=>d/m)}function gc(s){if(typeof s!="number"||!Number.isFinite(s)||s<0)return"--:--";const n=Math.floor(s),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 tv(s,n,r){return!(n>0)||!(r>0)?0:Math.min(r,Math.max(0,s/n*r))}function nv(s,n){const[r,i]=f.useState({peaks:n??null,note:""});return f.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(!s||!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(s)).arrayBuffer();m=new u;const h=await m.decodeAudioData(d);l&&i({peaks:ev(h.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}},[s,n]),r}function fp(s){const n=f.useRef(null),r=f.useRef(null),[i,l]=f.useState(!1),[u,m]=f.useState(0),[d,h]=f.useState(null),[x,v]=f.useState(""),{peaks:g,note:w}=nv(s.src,s.peaks),L=g??new Array(mp).fill(0),E=d&&d>0?Math.min(1,u/d):0,$=s.name?`Audio ${s.name}`:"Audio",T=f.useCallback(()=>{const M=n.current;M&&(M.paused?M.play().catch(A=>v(A instanceof Error?A.message:String(A))):M.pause())},[]),H=f.useCallback(M=>{const A=n.current;!A||!Number.isFinite(M)||(A.currentTime=M,m(M))},[]),z=M=>{var V;const A=(V=r.current)==null?void 0:V.getBoundingClientRect();!A||!d||H(tv(M-A.left,A.width,d))},R=M=>{if(!d)return;const A=M.key==="ArrowRight"||M.key==="ArrowUp"?5:M.key==="ArrowLeft"||M.key==="ArrowDown"?-5:0;A?(M.preventDefault(),H(Math.min(d,Math.max(0,u+A)))):M.key==="Home"?(M.preventDefault(),H(0)):M.key==="End"?(M.preventDefault(),H(d)):(M.key===" "||M.key==="Enter")&&(M.preventDefault(),T())};return e.jsxs("div",{className:`af-audio${s.className?` ${s.className}`:""}`,"data-playing":i?"true":"false",children:[e.jsx("audio",{ref:n,src:s.src,preload:"metadata",onPlay:()=>l(!0),onPause:()=>l(!1),onEnded:()=>l(!1),onTimeUpdate:M=>m(M.currentTarget.currentTime),onLoadedMetadata:M=>h(Number.isFinite(M.currentTarget.duration)?M.currentTarget.duration:null),onDurationChange:M=>h(Number.isFinite(M.currentTarget.duration)?M.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:T,children:e.jsx(Ue,{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":`${gc(u)} of ${gc(d)}`,title:w||void 0,"data-waveform":g?"decoded":"flat",onKeyDown:R,onPointerDown:M=>{var A,V;(V=(A=M.currentTarget).setPointerCapture)==null||V.call(A,M.pointerId),z(M.clientX)},onPointerMove:M=>{M.buttons&1&&z(M.clientX)},children:e.jsx("svg",{viewBox:`0 0 ${L.length*2} 32`,preserveAspectRatio:"none","aria-hidden":"true",focusable:"false",children:L.map((M,A)=>{const V=Math.max(1.5,M*30),Q=(A+.5)/L.length<=E;return e.jsx("rect",{className:Q?"af-audio__bar af-audio__bar--played":"af-audio__bar",x:A*2+.3,y:16-V/2,width:1.4,height:V,rx:.6},A)})})}),e.jsxs("span",{className:"af-audio__time","aria-hidden":"true",children:[gc(u)," / ",gc(d)]}),x?e.jsx("p",{className:"af-audio__error",role:"alert",children:x}):null]})}const Br=s=>new Set(s.split(/\s+/).filter(Boolean)),sv=Br("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"),av=Br("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"),rv=Br("if then else elif fi for while do done case esac in function return export local readonly set unset echo exit source"),iv=Br("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"),Zf=Br("true false null yes no on off"),ov={c:{line:["//"],block:["/*","*/"],strings:['"',"'","`"],keywords:sv},python:{line:["#"],strings:['"',"'"],triple:!0,keywords:av},shell:{line:["#"],strings:['"',"'"],keywords:rv},sql:{line:["--"],block:["/*","*/"],strings:["'",'"'],keywords:iv},data:{line:["#"],strings:['"',"'"],keywords:Zf},json:{line:[],strings:['"'],keywords:Zf},css:{line:[],block:["/*","*/"],strings:['"',"'"],keywords:Br("")},markup:{line:[],block:["<!--","-->"],strings:['"',"'"],keywords:Br("")}},lv={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 Jd(s){const n=String(s||"").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 lv[l]||""}const cv=s=>s>="0"&&s<="9",uv=s=>/[A-Za-z_$]/.test(s),eh=s=>/[A-Za-z0-9_$]/.test(s);function hp(s,n){const r=String(s??""),i=ov[n];if(!i)return r?[{kind:"plain",text:r}]:[];const l=[];let u="";const m=(h,x)=>{if(x){if(h==="plain"){u+=x;return}u&&l.push({kind:"plain",text:u}),u="",l.push({kind:h,text:x})}};let d=0;for(;d<r.length;){const h=r[d];if(i.line.find(v=>r.startsWith(v,d))){const v=r.indexOf(`
44
+ `,d),g=v===-1?r.length:v;m("comment",r.slice(d,g)),d=g;continue}if(i.block&&r.startsWith(i.block[0],d)){const v=r.indexOf(i.block[1],d+i.block[0].length),g=v===-1?r.length:v+i.block[1].length;m("comment",r.slice(d,g)),d=g;continue}if(i.strings.includes(h)){const v=i.triple&&r.startsWith(h.repeat(3),d)?h.repeat(3):"";if(v){const L=r.indexOf(v,d+3),E=L===-1?r.length:L+3;m("string",r.slice(d,E)),d=E;continue}let g=d+1;for(;g<r.length&&r[g]!==h&&(h==="`"||r[g]!==`
45
+ `);)g+=r[g]==="\\"?2:1;const w=Math.min(r.length,g+1);m("string",r.slice(d,w)),d=w;continue}if(cv(h)&&!(d>0&&eh(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(uv(h)){let v=d+1;for(;v<r.length&&eh(r[v]);)v+=1;const g=r.slice(d,v),w=n==="sql"?i.keywords.has(g.toLowerCase()):i.keywords.has(g);m(w?"keyword":"plain",g),d=v;continue}m("plain",h),d+=1}return u&&l.push({kind:"plain",text:u}),l}function yc({text:s,language:n="",lineNumbers:r=!0,className:i,ariaLabel:l}){const u=Jd(n),m=hp(s,u),d=r?String(s??"").split(`
46
+ `).length:0;return e.jsx("pre",{className:`af-code${r?" af-code--numbered":""}${i?` ${i}`:""}`,"data-language":u||"text","aria-label":l,style:r?{"--af-code-gutter":`${String(d).length+1}ch`}:void 0,children:e.jsx("code",{children:r?dv(m).map((h,x)=>e.jsxs("span",{className:"af-code__line","data-line":x+1,children:[h.map((v,g)=>th(v,g)),`
47
+ `]},x)):m.map((h,x)=>th(h,x))})})}function th(s,n){return s.kind==="plain"?e.jsx(Wt.Fragment,{children:s.text},n):e.jsx("span",{className:`af-code__${s.kind}`,children:s.text},n)}function dv(s){const n=[[]];for(const r of s)r.text.split(`
48
+ `).forEach((l,u)=>{u>0&&n.push([]),l&&n[n.length-1].push({kind:r.kind,text:l})});return n}const pp=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Jo=6e4,Qo=60*Jo,vc=24*Qo;function ll(s){if(s==null||s==="")return NaN;if(s instanceof Date)return s.getTime();if(typeof s=="number")return Number.isFinite(s)?s<1e12?s*1e3:s:NaN;const n=String(s).trim();return/^\d+(\.\d+)?$/.test(n)?ll(Number(n)):Date.parse(n)}function nh(s){return s<10?`0${s}`:String(s)}function sh(s,n){const r=ll(s);if(!Number.isFinite(r))return"";const i=new Date(r),l=i.getFullYear()===new Date(n).getFullYear();return`${pp[i.getMonth()]} ${i.getDate()}${l?"":`, ${i.getFullYear()}`}`}function _p(s){const n=ll(s);if(!Number.isFinite(n))return"";const r=new Date(n);return`${pp[r.getMonth()]} ${r.getDate()}, ${r.getFullYear()}, ${nh(r.getHours())}:${nh(r.getMinutes())}`}function gp(s,n){const r=ll(s);if(!Number.isFinite(r)||!Number.isFinite(n))return"";const i=n-r;if(i<0){const u=-i;if(u<Jo)return"due now";if(u<Qo)return`in ${Math.round(u/Jo)} min`;if(u<vc)return`in ${Math.round(u/Qo)} h`;const m=Math.round(u/vc);return m<7?`in ${m} ${m===1?"day":"days"}`:sh(r,n)}if(i<Jo)return"just now";if(i<Qo)return`${Math.floor(i/Jo)} min ago`;if(i<vc)return`${Math.floor(i/Qo)} h ago`;const l=Math.floor(i/vc);return l===1?"yesterday":l<7?`${l} days ago`:sh(r,n)}const mv=new Set("png jpg jpeg gif webp bmp ico avif".split(" ")),fv=new Set("mp3 wav ogg oga opus m4a aac flac weba".split(" ")),hv=new Set("mp4 m4v webm mov ogv mkv".split(" ")),pv=new Set("mts cts".split(" ")),_v=new Set(["video/mp2t"]),gv=new Set("txt log csv tsv rst adoc org tex diff patch lock".split(" "));function yv(s){const n=String(s||"").split("/").pop()||"",r=n.lastIndexOf(".");return r>0?n.slice(r+1).toLowerCase():n.toLowerCase()}function yp(s,n=""){const r=yv(s),i=String(n||"").split(";",1)[0].trim().toLowerCase();return r==="md"||r==="markdown"||i==="text/markdown"?"markdown":r==="json"||i==="application/json"||i.endsWith("+json")?"json":r==="pdf"||i==="application/pdf"?"pdf":mv.has(r)?"image":fv.has(r)?"audio":hv.has(r)?"video":Jd(s)||pv.has(r)?"code":gv.has(r)?"text":i.startsWith("image/")&&i!=="image/svg+xml"?"image":i.startsWith("audio/")?"audio":i.startsWith("video/")&&!_v.has(i)?"video":i.startsWith("text/")?"text":["application/javascript","application/xml","application/x-yaml","application/toml"].includes(i)?"code":"binary"}function vv(s){return s==="markdown"||s==="code"||s==="json"||s==="text"}function vp(s){if(typeof s!="number"||!Number.isFinite(s)||s<0)return"";if(s<1024)return`${s} B`;const n=["KiB","MiB","GiB","TiB"];let r=s/1024,i=0;for(;r>=1024&&i<n.length-1;)r/=1024,i+=1;return`${r<10?r.toFixed(1):Math.round(r)} ${n[i]}`}function xv(s){const n=s.kind??yp(s.name,s.contentType),r=vp(s.sizeBytes),i=s.modified!==void 0?gp(s.modified,s.nowMs):"";return e.jsxs("section",{className:`af-file-viewer${s.className?` ${s.className}`:""}`,"aria-label":`Preview of ${s.name}`,"data-kind":n,children:[e.jsxs("header",{className:"af-file-viewer__head",children:[e.jsx(Ue,{name:"file",size:15}),e.jsxs("span",{className:"af-file-viewer__title",children:[e.jsx("strong",{className:"af-file-viewer__name",title:s.path||s.name,children:s.name}),r||i?e.jsxs("span",{className:"af-file-viewer__meta",children:[r?e.jsx("span",{"data-meta":"size",children:r}):null,r&&i?e.jsx("span",{"aria-hidden":"true",children:" · "}):null,i?e.jsx("time",{"data-meta":"modified",title:_p(s.modified),dateTime:new Date(ll(s.modified)).toISOString(),children:i}):null]}):null]}),s.actions,s.onDownload?e.jsx("button",{type:"button",className:"af-file-viewer__icon-btn","data-action":"download-file",onClick:s.onDownload,title:"Download","aria-label":`Download ${s.name}`,children:e.jsx(Ue,{name:"download",size:15})}):null,s.onClose?e.jsx("button",{type:"button",className:"af-file-viewer__icon-btn","data-action":"close-preview",onClick:s.onClose,title:"Close","aria-label":"Close the preview",children:e.jsx(Ue,{name:"x",size:15})}):null]}),e.jsx("div",{className:"af-file-viewer__body",children:s.status==="loading"?e.jsx("p",{className:"af-file-viewer__muted",role:"status",children:"Loading preview…"}):s.status==="error"?e.jsx("p",{className:"af-file-viewer__error",role:"alert",children:s.error||"The preview could not be loaded."}):e.jsxs(e.Fragment,{children:[s.partialNote?e.jsx("p",{className:"af-file-viewer__muted",role:"status",children:s.partialNote}):null,e.jsx(bv,{kind:n,p:s})]})})]})}function bv({kind:s,p:n}){const r=n.text??"";switch(s){case"image":return n.url?e.jsx("img",{className:"af-file-viewer__image",src:n.url,alt:n.name}):e.jsx(Io,{});case"audio":return n.url?e.jsx(fp,{src:n.url,name:n.name}):e.jsx(Io,{});case"video":return n.url?e.jsx("video",{className:"af-file-viewer__image af-file-viewer__video",src:n.url,controls:!0,playsInline:!0,preload:"metadata","aria-label":n.name}):e.jsx(Io,{});case"pdf":return n.url?e.jsx("object",{className:"af-file-viewer__pdf",data:n.url,type:"application/pdf","aria-label":n.name,children:e.jsx("p",{className:"af-file-viewer__muted",children:"This browser cannot show PDFs inline. Use Download to open it."})}):e.jsx(Io,{});case"markdown":return n.renderMarkdown?e.jsx("div",{className:"af-file-viewer__markdown",children:n.renderMarkdown(r)}):e.jsx(yc,{text:r,language:""});case"json":{let i=r,l="";try{i=JSON.stringify(JSON.parse(r),null,2)}catch{l=n.partialNote?"":"Not valid JSON; shown as text."}return e.jsxs(e.Fragment,{children:[l?e.jsx("p",{className:"af-file-viewer__muted",children:l}):null,e.jsx(yc,{text:i,language:"json"})]})}case"code":return e.jsx(yc,{text:r,language:n.name});case"text":return e.jsx(yc,{text:r,language:"",lineNumbers:!1});default:return e.jsx(Io,{})}}function Io(){return e.jsx("p",{className:"af-file-viewer__muted",children:"No preview for this file type. Use Download to open it."})}function wv(s){const n=String(s??"").trim();if(!n||!(n.startsWith("{")&&n.endsWith("}")||n.startsWith("[")&&n.endsWith("]")))return null;try{return JSON.parse(n)}catch{return null}}async function on(s){var r;const n=String(s||"");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 jv=3,kv=Number.MAX_SAFE_INTEGER;function xp(s){return!!s&&typeof s=="object"&&!Array.isArray(s)}function bp(s){return Array.isArray(s)}function Sv(s){if(s==null)return"";if(typeof s=="string")return s;try{return JSON.stringify(s,null,2)}catch{return String(s)}}function Pi({kind:s,children:n}){return e.jsx("span",{className:`pc-json-token ${s}`,children:n})}function Nv(s){const n=JSON.stringify(s.value),r=n.length>96||n.includes("\\n")||n.includes("\\r")||n.includes("\\t"),[i,l]=f.useState(!r||s.expansionMode==="unfolded");return f.useEffect(()=>{r&&l(s.expansionMode==="unfolded")},[r,s.expansionMode,s.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(Pi,{kind:"string",children:n})}function Cv(s,n,r){return s===null?e.jsx(Pi,{kind:"null",children:"null"}):typeof s=="string"?e.jsx(Nv,{value:s,expansionMode:n,expansionVersion:r}):typeof s=="number"?e.jsx(Pi,{kind:"number",children:String(s)}):typeof s=="boolean"?e.jsx(Pi,{kind:"boolean",children:s?"true":"false"}):e.jsx(Pi,{kind:"string",children:JSON.stringify(String(s))})}function $v(s){return bp(s)?s.length===1?"1 item":`${s.length} items`:xp(s)?Object.keys(s).length===1?"1 key":`${Object.keys(s).length} keys`:""}function wp(s){const{label:n,value:r,depth:i,collapseAfterDepth:l,expansionMode:u,expansionVersion:m,trailingComma:d}=s,h=i*14,x=xp(r),v=bp(r),g=x||v,w=i<l,[L,E]=f.useState(w);f.useEffect(()=>{E(w)},[w,m]);const $=n?e.jsxs(e.Fragment,{children:[e.jsx(Pi,{kind:"key",children:JSON.stringify(n)}),": "]}):null;if(!g)return e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:h},children:[$,Cv(r,u,m),d?",":""]});const T=v?"[":"{",H=v?"]":"}",z=$v(r),R=L?`${T}`:`${T}…${H}${z?` (${z})`:""}`,M=v?r.map((A,V)=>({key:String(V),label:void 0,value:A})):Object.entries(r).map(([A,V])=>({key:A,label:A,value:V}));return e.jsxs("details",{className:"pc-json-viewer__details",open:L,onToggle:A=>E(A.currentTarget.open),children:[e.jsxs("summary",{className:"pc-json-viewer__summary",style:{paddingLeft:h},children:[$,e.jsx("span",{className:"pc-json-viewer__caret","aria-hidden":"true",children:L?"▾":"▸"}),e.jsx("span",{className:"pc-json-viewer__punct",children:R}),!L&&d?e.jsx("span",{className:"pc-json-viewer__punct",children:","}):null]}),L?e.jsx("div",{className:"pc-json-viewer__children",children:M.length===0?e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:h},children:[e.jsx("span",{className:"pc-json-viewer__punct",children:H}),d?",":""]}):e.jsxs(e.Fragment,{children:[M.map((A,V)=>{const Q=V===M.length-1;return e.jsx(wp,{label:A.label,value:A.value,depth:i+1,collapseAfterDepth:l,expansionMode:u,expansionVersion:m,trailingComma:!Q},`${i}:${n||"root"}:${A.key}`)}),e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:h},children:[e.jsx("span",{className:"pc-json-viewer__punct",children:H}),d?",":""]})]})}):null]})}function Ev(s){const n=s.trim();if(!n)return s;if(n.startsWith("{")&&n.endsWith("}")||n.startsWith("[")&&n.endsWith("]"))try{return JSON.parse(n)}catch{return s}return s}function Tc(s){const{value:n,className:r,showCopy:i=!0}=s,[l,u]=f.useState({mode:"folded",version:0}),[m,d]=f.useState("idle"),h=typeof s.collapseAfterDepth=="number"&&(Number.isFinite(s.collapseAfterDepth)||s.collapseAfterDepth===1/0)&&s.collapseAfterDepth>=0?s.collapseAfterDepth===1/0?Number.MAX_SAFE_INTEGER:Math.trunc(s.collapseAfterDepth):jv,x=l.mode==="unfolded"?kv:h,v=f.useMemo(()=>typeof n=="string"?Ev(n):n,[n]),g=f.useMemo(()=>Sv(n),[n]),w=["pc-json-viewer",r].filter(Boolean).join(" ");f.useEffect(()=>{u(E=>({mode:"folded",version:E.version+1}))},[v]);const L=()=>{u(E=>({mode:E.mode==="unfolded"?"folded":"unfolded",version:E.version+1}))};return e.jsxs("div",{className:w,children:[e.jsxs("div",{className:"pc-json-viewer__toolbar",children:[e.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__toggle-all",onClick: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 on(g).then(E=>{d(E?"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(wp,{value:v,depth:0,collapseAfterDepth:x,expansionMode:l.mode,expansionVersion:l.version,trailingComma:!1})})]})}function Tv({code:s,lang:n}){const[r,i]=f.useState("idle"),l=f.useRef(null);f.useEffect(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]);const u=hp(s,Jd(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 on(s);i(m?"copied":"failed"),l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>i("idle"),900)},children:e.jsx(Ue,{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 Do(s,n){const r=String(s??"");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 g=n.needlesLower[v];if(!g)continue;const w=l.indexOf(g,u);if(w===-1)continue;const L=n.needles[v]||"";L&&(m===-1||w<m||w===m&&L.length>d.length)&&(m=w,d=L)}if(m===-1||!d){i.push(r.slice(u));break}m>u&&i.push(r.slice(u,m));const h=n.hits===0&&n.id?n.id:void 0,x=r.slice(m,m+d.length);i.push(e.jsx("span",{id:h,className:n.className,children:x},`hl:${n.hits}`)),n.hits+=1,u=m+d.length}return i}function jp(s){const n=String(s||"").trim();if(n&&/^(https?:|mailto:|tel:|#|\/)/i.test(n))return n}const Ed="http://same-origin.invalid/";function Av(s){try{const n=new URL(s,Ed);return n.protocol==="http:"&&n.origin===new URL(Ed).origin}catch{return!1}}function kp(s){const n=String(s||"").trim();return jp(n)??(n&&Av(n)?n:void 0)}let Or=null;function Lv(s){const n=String(s||"").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??Ed;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 Sp(s,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}`},s)}function ah(s){return!!s&&/[\p{L}\p{N}]/u.test(s)}function pa(s,n){const r=[],i=String(s??"");let l=0,u="";const m=()=>{if(u){for(const d of Do(u,n))r.push(d);u=""}};for(;l<i.length;){const d=i[l];if(d==="!"&&i[l+1]==="["){const h=i.indexOf("]",l+2);if(h!==-1&&i[h+1]==="("){const x=i.indexOf(")",h+2);if(x!==-1){const v=i.slice(l+2,h),g=kp(i.slice(h+2,x));if(g&&Or&&!Or(g)){m(),r.push(Sp(`img:${l}`,g,v)),l=x+1;continue}if(g){m(),r.push(e.jsxs("span",{className:"pc-md_image_inline",children:[e.jsx("img",{className:"pc-md_img",src:g,alt:v,loading:"lazy"}),v?e.jsx("span",{className:"pc-md_img_caption",children:n?Do(v,n):v}):null]},`img:${l}`)),l=x+1;continue}}}}if(d==="["){const h=i.indexOf("]",l+1);if(h!==-1&&i[h+1]==="("){const x=i.indexOf(")",h+2);if(x!==-1){const v=i.slice(l+1,h),g=jp(i.slice(h+2,x));if(g){m(),r.push(e.jsx("a",{className:"pc-md_link",href:g,target:g.startsWith("#")?void 0:"_blank",rel:"noreferrer",children:pa(v,n)},`link:${l}`)),l=x+1;continue}}}}if(d==="`"){const h=i.indexOf("`",l+1);if(h!==-1){m();const x=i.slice(l+1,h);r.push(e.jsx("code",{children:n?Do(x,n):x},`code:${l}`)),l=h+1;continue}}if(d==="_"&&!ah(i[l-1])){const h=i[l+1]==="_"?"__":"_",x=h.length;if(i[l+x]&&!/\s/.test(i[l+x])&&i[l+x]!=="_"){let v=i.indexOf(h,l+x);for(;v!==-1&&(/\s/.test(i[v-1]||" ")||ah(i[v+x])||x===1&&i[v+1]==="_");)v=i.indexOf(h,v+1);if(v!==-1&&v>l+x){m();const g=i.slice(l+x,v),w=pa(g,n);r.push(x===2?e.jsx("strong",{children:w},`ubold:${l}`):e.jsx("em",{children:w},`uem:${l}`)),l=v+x;continue}}}if(d==="*"&&i[l+1]==="*"){const h=i.indexOf("**",l+2);if(h!==-1){m();const x=i.slice(l+2,h);r.push(e.jsx("strong",{children:n?Do(x,n):x},`bold:${l}`)),l=h+2;continue}}if(d==="*"&&i[l+1]!=="*"){const h=i.indexOf("*",l+1);if(h!==-1){m();const x=i.slice(l+1,h);r.push(e.jsx("em",{children:n?Do(x,n):x},`em:${l}`)),l=h+1;continue}}u+=d,l+=1}return m(),r}function Mv(s){return String(s??"").replace(/\r\n/g,`
49
+ `).replace(/\r/g,`
50
+ `).split(`
51
+ `)}function Ac(s){const r=String(s??"").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 Rv(s){const n=[];for(const l of s){const u=Ac(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 h={ordered:l.ordered,start:l.start,items:[]};d.children.push(h),i.push({indent:l.indent,node:h}),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 h=m.node.items,x=h[h.length-1];x?x.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 Np(s,n,r){const i=s.items.map((l,u)=>e.jsxs("li",{children:[pa(l.content,n),l.children.map((m,d)=>Np(m,n,`${r}:${u}:${d}`))]},`${r}:li:${u}`));return s.ordered?e.jsx("ol",{className:"pc-md_ol",start:s.start!==1?s.start:void 0,children:i},r):e.jsx("ul",{className:"pc-md_ul",children:i},r)}function Pv(s,n,r){return Rv(s).map((i,l)=>Np(i,n,`${r}:${l}`))}function rh(s){let n=String(s??"").trim();return n?(n.startsWith("|")&&(n=n.slice(1)),n.endsWith("|")&&(n=n.slice(0,-1)),n.split("|").map(r=>String(r??"").trim())):[]}function ih(s){let n=String(s??"").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 oh=/^(#{1,5})\s+(.*)$/;function lh(s){return s.trim().startsWith("```")}function ch(s){return s.trimStart().startsWith(">")}function Qn(s){const n=Or;Or=s.images==="link"?s.inlineImage||Lv:null;try{return zv(s)}finally{Or=n}}function zv({text:s,className:n,highlight:r,highlights:i,highlightClassName:l,highlightId:u}){const m=Mv(s),d=[],h=[];Array.isArray(i)&&h.push(...i),typeof r=="string"&&r.trim()&&h.push(r);const x=Array.from(new Set(h.map(L=>String(L??"").trim()).filter(Boolean))).filter(L=>L.length>=4),v=x.length?{needles:x,needlesLower:x.map(L=>L.toLowerCase()),className:l||"pc-md_hl",id:u,hits:0}:null;let g=0;for(;g<m.length;){const L=String(m[g]??"");if(!L.trim()){g+=1;continue}const E=L.trim();if(/^([-_*])(\s*\1){2,}$/.test(E)){d.push(e.jsx("hr",{className:"pc-md_hr"},`hr:${g}`)),g+=1;continue}const $=L.match(/^\s*!\[([^\]]*)\]\(([^)]+)\)\s*$/);if($){const z=kp($[2]||"");if(z&&Or&&!Or(z)){d.push(e.jsx("p",{className:"pc-md_p",children:Sp(`img:${g}`,z,$[1]||"")},`p:${g}`)),g+=1;continue}if(z){const R=$[1]||"";d.push(e.jsxs("figure",{className:"pc-md_figure",children:[e.jsx("img",{className:"pc-md_img",src:z,alt:R,loading:"lazy"}),R?e.jsx("figcaption",{children:pa(R,v)}):null]},`figure:${g}`)),g+=1;continue}}if(lh(L)){const R=L.trim().replace(/```/g,"").trim(),M=[];for(g+=1;g<m.length&&!String(m[g]??"").trim().startsWith("```");)M.push(String(m[g]??"")),g+=1;g<m.length&&(g+=1);const A=M.join(`
52
+ `);d.push(e.jsx(Tv,{code:A,lang:R},`pre:${g}`));continue}const T=L.match(oh);if(T){const z=T[1].length,R=T[2]||"",M=pa(R,v);z===1?d.push(e.jsx("h1",{children:M},`h1:${g}`)):z===2?d.push(e.jsx("h2",{children:M},`h2:${g}`)):z===3?d.push(e.jsx("h3",{children:M},`h3:${g}`)):z===4?d.push(e.jsx("h4",{children:M},`h4:${g}`)):d.push(e.jsx("h5",{children:M},`h5:${g}`)),g+=1;continue}if(ch(L)){const z=[];for(;g<m.length&&String(m[g]??"").trimStart().startsWith(">");){const M=String(m[g]??"").trimStart();z.push(M.replace(/^>\s?/,"")),g+=1}d.push(e.jsx("blockquote",{className:"pc-md_quote",children:z.map((R,M)=>e.jsxs(Wt.Fragment,{children:[pa(R,v),M<z.length-1?e.jsx("br",{}):null]},`q:${g}:${M}`))},`quote:${g}`));continue}if(L.includes("|")&&g+1<m.length&&ih(String(m[g+1]??""))){const z=rh(L),R=Math.max(1,z.length),M=[];for(g+=2;g<m.length;){const A=String(m[g]??"");if(!A.trim()||!A.includes("|"))break;const V=rh(A),Q=[];for(let oe=0;oe<R;oe++)Q.push(V[oe]??"");M.push(Q),g+=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:z.slice(0,R).map((A,V)=>e.jsx("th",{children:pa(A,v)},`th:${g}:${V}`))})}),e.jsx("tbody",{children:M.map((A,V)=>e.jsx("tr",{children:A.map((Q,oe)=>e.jsx("td",{children:pa(Q,v)},`td:${g}:${V}:${oe}`))},`tr:${g}:${V}`))})]})},`table:${g}`));continue}if(Ac(L)){const z=[];for(;g<m.length;){const R=String(m[g]??"");if(!R.trim()||R.trimStart().startsWith("```"))break;if(Ac(R)||/^\s{2,}\S/.test(R)){z.push(R),g+=1;continue}break}d.push(e.jsx(Wt.Fragment,{children:Pv(z,v,`list:${g}`)},`list:${g}`));continue}const H=[];for(;g<m.length&&String(m[g]??"").trim()&&!(H.length>0&&Ac(String(m[g]??"")));){const z=String(m[g]??"");if(H.length>0&&(oh.test(z)||lh(z)||ch(z))||H.length>0&&z.includes("|")&&g+1<m.length&&ih(String(m[g+1]??"")))break;H.push(z),g+=1}d.push(e.jsx("p",{className:"pc-md_p",children:H.map((z,R)=>e.jsxs(Wt.Fragment,{children:[pa(z,v),R<H.length-1?e.jsx("br",{}):null]},`pl:${g}:${R}`))},`p:${g}`))}const w=["pc-md",n].filter(Boolean).join(" ");return e.jsx("div",{className:w,children:d})}function Iv(s){const n=String(s.text??""),r=f.useMemo(()=>wv(n),[n]),i=["pc-chat-content",s.className].filter(Boolean).join(" ");return r!==null?e.jsx("div",{className:i,children:e.jsx(Tc,{value:r,collapseAfterDepth:s.jsonCollapseAfterDepth})}):s.renderMarkdown?e.jsx("div",{className:i,children:s.renderMarkdown(n)}):e.jsx("div",{className:i,children:e.jsx(Qn,{text:n,images:s.images,inlineImage:s.inlineImage})})}const Dv=new Set("html htm xhtml xht shtml svg svgz xml xsl xslt mht mhtml".split(" ")),Ov=new Set(["application/pdf","application/json","text/plain","text/markdown","text/csv","text/tab-separated-values","text/x-python","text/javascript","application/javascript","text/css","text/x-c","text/x-shellscript","text/x-typescript","image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","video/mp4","video/webm","video/quicktime","audio/mpeg","audio/mp4","audio/aac","audio/wav","audio/x-wav","audio/ogg","audio/webm","audio/flac"]);function Cp(s){const n=String(s??"");if(!n.trim())return!1;try{const r=typeof window<"u"&&window.location?window.location.href:"http://same-origin.invalid/",i=new URL(n,r).protocol;return i==="blob:"||i==="data:"}catch{return!0}}function Fv(s,n){const r=String(n||"").split("/").pop()||"",i=r.lastIndexOf(".");if(i>0&&Dv.has(r.slice(i+1).toLowerCase()))return!1;const l=String(s||"").split(";",1)[0].trim().toLowerCase();return!l||l==="text/html"||l.includes("xml")?!1:Ov.has(l)}function qv(s){const n=r=>!!r&&(!Cp(r)||Fv(s.contentType,s.name));if(n(s.href))return s.href;if(n(s.src))return s.src}function Bv(s){const{markdownImages:n,inlineImage:r,renderMarkdown:i,...l}=s;return e.jsx(xv,{...l,nowMs:s.nowMs??Date.now(),renderMarkdown:i||(u=>e.jsx(Qn,{text:u,...n?{images:n}:{},...r?{inlineImage:r}:{}}))})}function Uv({sandbox:s,className:n}){return s?e.jsxs("div",{className:`pc-tool-sandbox is-${s.state}${n?` ${n}`:""}`,"data-sandbox-kind":s.kind,children:[e.jsx("div",{className:"pc-tool-sandbox__line",children:s.line}),s.rows.length?e.jsxs("ul",{className:"pc-tool-sandbox__rows","aria-label":"Workspaces the sandbox enforced",children:[s.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}`)),s.builtinRefused?e.jsxs("li",{className:"pc-tool-sandbox__builtin",children:[s.builtinRefused," built-in protected ",s.builtinRefused===1?"folder":"folders"," refused"]}):null]}):null]}):null}function uh(s){if(s.decision==="denied")return"Denied by this chat's policy";const n=s.setAt?_p(s.setAt):"",i=[s.setBy?`set by ${s.setBy}`:"",n?`at ${n}`:""].filter(Boolean).join(" ");return`Allowed by this chat's policy${i?` (${i})`:""}`}const vn="not reported",Mn=s=>s===void 0?vn:Math.round(s).toLocaleString(),$n=s=>{if(s===void 0)return vn;if(s<6e4)return`${(s/1e3).toFixed(1)}s`;const n=Math.round(s/1e3);return`${Math.floor(n/60)}m ${String(n%60).padStart(2,"0")}s`},$p=s=>s===void 0?vn:`${Math.round(s).toLocaleString()} tok/s`,Wv=(s,n)=>n>0?`${Math.round(s/n*100)}%`:"",Fr=(s,n,r=`${n}s`)=>`${s.toLocaleString()} ${s===1?n:r}`,Hv=s=>{const n=s.split("#")[0].replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||s};function Vv(s){const n=new Map;for(const r of s)r&&n.set(r,(n.get(r)||0)+1);return[...n].map(([r,i])=>i>1?`${r} ×${i}`:r).join(" · ")}function Mc(s){const n=[],r=(s.models||[]).map(Hv),i=s.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 Gv(s){const n=s.modelCalls||[],r=[],i=[{label:"Input",value:Mn(s.inputTokens)},{label:"Output",value:Mn(s.outputTokens)}];if(s.reasoningTokens!==void 0&&i.push({label:"Reasoning",value:Mn(s.reasoningTokens),hint:"part of output"}),i.push({label:"Total",value:Mn(s.totalTokens)}),r.push({heading:`Usage · ${Fr(s.llmCalls,"model call")}`,rows:i}),s.measuredCacheCalls){const u=s.cachedTokens||0,m=s.fedTokens||0,d=[{label:"Reused from cache",value:`${Mn(u)}${u+m?` (${Wv(u,u+m)})`:""}`},{label:"Newly processed",value:Mn(s.fedTokens)},{label:"Outcome",value:Vv(n.map(h=>h.cacheOutcome))||(s.cacheOutcomes||[]).join(" · ")||vn},{label:"Backend",value:(s.cacheBackends||[]).join(", ")||vn}];s.measuredCacheCalls!==s.llmCalls&&d.push({label:"Measured on",value:`${s.measuredCacheCalls} of ${s.llmCalls} calls`}),r.push({heading:"Prompt cache",rows:d})}else s.llmCalls&&r.push({heading:"Prompt cache",rows:[{label:"Cache reuse",value:vn}]});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:s.totalTokens===void 0?vn:`${s.totalTokens.toLocaleString()} total`,sections:r,footer:Mc(s)}}function xc(s,n,r,i){if(s===void 0)return vn;const l=[$n(s)];return n!==void 0&&l.push(`${n.toLocaleString()} ${i}${r!==void 0?` at ${$p(r)}`:""}`),l.join(" · ")}function Kv(s){var x,v,g;const n=s.modelCalls||[],r=[],i=s.durationMs,l=[{label:"Wall clock",value:$n(i)}];if(l.push({label:"Model",value:s.genTimeMs===void 0?vn:`${$n(s.genTimeMs)} · ${Fr(s.timedCalls||0,"call")}${s.timedCalls!==s.llmCalls?` (of ${s.llmCalls})`:""}`}),l.push({label:"Tools",value:s.toolTimeMs!==void 0?`${$n(s.toolTimeMs)} · ${Fr(s.toolBatches||0,"batch","batches")}`:s.toolCalls?vn:"none",hint:s.toolTimeIncludesApproval?"includes approval wait":void 0}),i!==void 0&&s.genTimeMs!==void 0){const w=i-s.genTimeMs-(s.toolTimeMs||0);l.push({label:"Orchestration",value:w>=0?$n(w):"overlaps (parallel runs)",hint:"wall − model − tools: routing, hand-offs, model load"})}r.push({heading:"Turn",rows:l});const u=[],m=s.ttftCalls||0,d=s.promptPhaseCalls||0;s.promptPhaseMs!==void 0?u.push({label:m&&m===d?"Prefill (TTFT)":"Prefill",value:xc(s.promptPhaseMs,s.promptPhaseNewTokens,s.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"}):s.prefillMs!==void 0&&s.prefillNewTokensPerSecond!==void 0?u.push({label:"Prefill",value:xc(s.prefillMs,s.prefillNewTokens,s.prefillNewTokensPerSecond,"new tok"),hint:"derived: prompt ÷ provider rate"}):s.prefillMs!==void 0?u.push({label:"Prefill",value:`${$n(s.prefillMs)}${s.promptTokensPerSecond!==void 0?` at ${$p(s.promptTokensPerSecond)}`:""}`,hint:"provider rate over all prompt tokens, restored included"}):u.push({label:"Prefill",value:vn}),s.cachedTokens&&(s.promptPhaseMs??s.prefillMs)!==void 0&&u.push({label:"Restored",value:`${s.cachedTokens.toLocaleString()} tok from cache`,hint:"not recomputed"}),u.push({label:"Generation",value:s.generationPhaseMs!==void 0?xc(s.generationPhaseMs,s.generationPhaseTokens,s.generationPhaseTokensPerSecond,"tok"):xc(s.decodeMs,s.outputTokens,s.generationTokensPerSecond,"tok")}),s.measuredSpeedCalls&&s.measuredSpeedCalls!==s.llmCalls&&u.push({label:"Speeds from",value:`${s.measuredSpeedCalls} of ${s.llmCalls} calls`}),r.push({heading:"Model",rows:u});const h=s.speculation;if(h){const w=(h.draftKinds||[]).map(E=>E.toUpperCase()).join(", "),L=[{label:"Mode",value:`${h.used?"on":"off"}${w?` · ${w}`:""}${(x=h.modes)!=null&&x.length?` (${h.modes.join(", ")})`:""}`,hint:h.calls!==s.llmCalls||h.used!==h.calls?`used on ${h.used} of ${s.llmCalls} calls`:void 0},{label:"Acceptance",value:h.acceptanceRate===void 0?vn:`${Math.round(h.acceptanceRate*100)}% · ${Mn(h.acceptedTokens)} of ${Mn(h.draftedTokens)} drafted`}];((v=h.draftLengths)!=null&&v.length||h.rounds!==void 0)&&L.push({label:"Draft length",value:`${(g=h.draftLengths)!=null&&g.length?`${h.draftLengths.join("/")} tok/round`:vn}${h.rounds!==void 0?` · ${h.rounds.toLocaleString()} rounds`:""}`}),r.push({heading:"Speculation",rows:L})}return s.slowestToolBatch&&r.push({heading:"Tools",rows:[{label:"Total",value:`${$n(s.toolTimeMs)} · ${Fr(s.toolBatches||0,"batch","batches")}`},{label:"Slowest",value:`${$n(s.slowestToolBatch.ms)} · ${Ep(s.slowestToolBatch)}`}],note:s.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((w,L)=>[String(L+1),w.promptMs===void 0?"—":`${$n(w.promptMs)}${w.promptSource==="rate"?"*":""}`,w.promptNewTokensPerSecond===void 0?"—":Math.round(w.promptNewTokensPerSecond).toLocaleString(),w.generationMs===void 0?"—":$n(w.generationMs),w.generationTokensPerSecond===void 0?"—":Math.round(w.generationTokensPerSecond).toLocaleString(),w.cacheOutcome||"—"])},note:n.some(w=>w.promptSource==="rate")?"* derived from the provider's prompt rate (no TTFT event).":void 0}),{kind:"time",title:"Time",headline:i===void 0?vn:`${$n(i)} wall clock`,sections:r,footer:Mc(s)}}function Ep(s){return s.tools.length===1?`${s.tools[0]} ×${s.calls}`:`${Fr(s.calls,"call")} (${s.tools.join(", ")})`}function Jv(s){const n=[],r=(s.toolsWaiting||0)+(s.toolsRunning||0);if(!s.toolCalls&&!r)return n.push({heading:"Outcome",rows:[{label:"Tools called",value:"none"}]}),{kind:"tools",title:"Tools",headline:"none",sections:n,footer:Mc(s)};const i=[{label:"Succeeded",value:(s.toolCalls-(s.toolsFailed||0)).toLocaleString()},{label:"Failed",value:(s.toolsFailed||0).toLocaleString()}];s.toolsRunning&&i.push({label:"Running",value:s.toolsRunning.toLocaleString()}),s.toolsWaiting&&i.push({label:"Awaiting approval",value:s.toolsWaiting.toLocaleString(),hint:"not run yet — not a failure"}),n.push({heading:"Outcome",rows:i});const l=Object.entries(s.toolBreakdown||{}).sort((d,h)=>h[1].calls-d[1].calls||d[0].localeCompare(h[0]));l.length&&n.push({heading:"By tool",table:{columns:["Tool","Calls","Failed","Time"],rows:l.map(([d,h])=>[d,h.calls.toLocaleString(),h.failed.toLocaleString(),h.ms!==void 0?`${$n(h.ms)}${h.sharedBatches?" +shared":""}`:h.sharedBatches?"shared":vn])},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,h])=>({label:d,value:Object.entries(h.errors).sort((x,v)=>v[1]-x[1]).map(([x,v])=>v>1?`${x} ×${v}`:x).join(" · ")}))});const m=[{label:"Tool time",value:s.toolTimeMs===void 0?vn:`${$n(s.toolTimeMs)} · ${Fr(s.toolBatches||0,"batch","batches")}`}];return s.slowestToolBatch&&m.push({label:"Slowest batch",value:`${$n(s.slowestToolBatch.ms)} · ${Ep(s.slowestToolBatch)}`}),n.push({heading:"Timing",rows:m,note:s.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),{kind:"tools",title:"Tools",headline:`${Fr(s.toolCalls,"call")}${s.toolsFailed?` · ${s.toolsFailed} failed`:""}`,sections:n,footer:Mc(s)}}function rd(s,n){return s==="tokens"?Gv(n):s==="time"?Kv(n):Jv(n)}function Qv(s){const n=s.detail;return e.jsxs("div",{ref:s.panelRef,id:s.id,role:"tooltip",className:`pc-stat-detail pc-stat-detail--${n.kind}`,style:s.style,onMouseEnter:s.onMouseEnter,onMouseLeave:s.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===vn?"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 Yv(s){const[n,r]=f.useState(!!s.defaultOpen),[i,l]=f.useState(null),u=f.useRef(null),m=f.useRef(null),d=f.useRef(null),h=`pc-stat-${f.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,x=f.useCallback(()=>{d.current!==null&&window.clearTimeout(d.current),d.current=null},[]),v=f.useCallback(()=>{x(),r(!0)},[x]),g=f.useCallback(()=>{x(),d.current=window.setTimeout(()=>r(!1),120)},[x]);f.useEffect(()=>x,[x]),f.useLayoutEffect(()=>{if(!n){l(null);return}const $=()=>{const T=u.current,H=m.current;if(!T||!H)return;const z=T.getBoundingClientRect(),R=H.offsetWidth,M=H.offsetHeight,A=window.innerWidth,V=window.innerHeight,Q=z.top-fa-M,oe=z.bottom+fa,be=Q>=fa?Q:oe+M<=V-fa?oe:Math.max(fa,V-fa-M),Ne=Math.min(Math.max(fa,z.left),Math.max(fa,A-fa-R));l({top:be,left:Ne})};return $(),window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[n]),f.useEffect(()=>{if(!n)return;const $=T=>{T.key==="Escape"&&r(!1)};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[n]);const w=typeof s.onClick=="function",L=w?"button":"span",E=n?e.jsx(Qv,{detail:s.detail,id:h,panelRef:m,onMouseEnter:x,onMouseLeave:g,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,...w?{type:"button"}:{tabIndex:0},className:["pc-chat-stat","pc-chat-stat--detail",w?"pc-chat-stat--clickable":"",s.className].filter(Boolean).join(" "),"aria-label":`${s.label} — ${s.detail.title.toLowerCase()} details`,"aria-describedby":n?h:void 0,"data-stat-kind":s.detail.kind,onMouseEnter:v,onMouseLeave:g,onFocus:v,onBlur:()=>r(!1),onKeyDown:$=>{$.key==="Escape"&&r(!1)},onClick:w?()=>{var $;return($=s.onClick)==null?void 0:$.call(s)}:void 0,children:[s.icon?e.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:s.icon}):null,e.jsx("span",{className:"pc-chat-stat-label",children:s.label})]}),E&&typeof document<"u"?ep.createPortal(E,document.body):E]})}function Tp(s){if(typeof s!="string")return s;try{return JSON.parse(s)}catch{return s}}function Xv(s){const n=Tp(s);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 Ap({tool:s,showCopy:n=!0}){const[r,i]=f.useState(!1),l=Tp(s.arguments),u=Xv(s.arguments),m=["file path","path"].includes(u.label)&&u.value.length>60?`${u.value.split(/[\\/]/).pop()} · ${u.value.slice(0,24)}…`:u.value,d=s.error&&/^File ['"].+['"] does not exist\.?$/.test(s.error)?"File not found. Expand for the exact path.":s.error&&s.error.length>180?`${s.error.slice(0,100)}…${s.error.slice(-70)}`:s.error,h={running:"Running",waiting:"Approval needed",completed:"Done",failed:"Failed"},x=s.startedAt&&s.endedAt?Date.parse(s.endedAt)-Date.parse(s.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--${s.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(Ue,{name:s.status==="completed"?"check":s.status==="failed"?"x":s.status==="waiting"?"warning":"loader",size:15})}),e.jsx("strong",{children:s.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:h[s.status]}),s.policy?e.jsx("span",{className:"pc-tool-activity__policy","data-policy":s.policy.decision,title:uh(s.policy),children:s.policy.decision==="denied"?"Denied by this chat's policy":"Allowed by this chat's policy"}):null,Number.isFinite(x)&&x>=0?e.jsxs("span",{className:"pc-tool-activity__duration","data-approval-wait":s.approvalWait?"":void 0,title:s.approvalWait?"Timed from request to result: includes the wait for your decision.":void 0,children:[$n(x),s.approvalWait?" incl. approval wait":""]}):null,e.jsx("span",{className:"pc-tool-activity__chevron","aria-hidden":"true",children:e.jsx(Ue,{name:"chevronRight",size:13})}),s.error?e.jsx("span",{className:"pc-tool-activity__error",title:s.error,children:d}):null]}),e.jsxs("div",{className:"pc-tool-activity__detail",children:[s.policy?e.jsxs("p",{className:"pc-tool-activity__policy-line","data-policy":s.policy.decision,children:[uh(s.policy),s.policy.matched?` · matched ${s.policy.matched}`:""]}):null,e.jsx(Uv,{sandbox:s.sandbox}),s.error?e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Error"}),e.jsx("pre",{className:"pc-tool-activity__output",children:s.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 on(JSON.stringify(s,null,2))),children:[e.jsx(Ue,{name:"copy",size:13}),r?"Copied":"Copy details"]}):null]}),v?e.jsx("dl",{className:"pc-tool-activity__parameters",children:v.map(([g,w])=>e.jsxs(Wt.Fragment,{children:[e.jsx("dt",{children:g}),e.jsx("dd",{children:w&&typeof w=="object"?e.jsx(Tc,{value:w}):e.jsx("code",{children:typeof w=="string"?w:JSON.stringify(w)})})]},g))}):s.arguments===void 0?e.jsx("p",{children:"Arguments are unavailable in this ledger."}):e.jsx(Tc,{value:l}),s.output!==void 0?e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Result"}),typeof s.output=="string"?e.jsx("pre",{className:"pc-tool-activity__output",children:s.output}):e.jsx("div",{className:"pc-tool-activity__output",children:e.jsx(Tc,{value:s.output})})]}):null]})]})}function Zv({tools:s,showCopy:n}){const r=i=>s.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(Ue,{name:"terminal",size:14}),e.jsx("strong",{children:"Tools"}),e.jsxs("span",{children:[s.length," ",s.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]}),s.map(i=>e.jsx(Ap,{tool:i,showCopy:n},i.id))]})}function ex(s){const n=s.totalTokens!==void 0?rd("tokens",s):null,r=rd("tools",s),i=s.durationMs!==void 0?rd("time",s):null;return[...n?[{label:`${s.totalTokens.toLocaleString()} tokens`,detail:n}]:[],{label:`${s.toolCalls} ${s.toolCalls===1?"tool":"tools"}`,detail:r},...s.changedFiles.length?[{label:`${s.changedFiles.length} ${s.changedFiles.length===1?"file":"files"} changed`,title:s.changedFiles.join(`
53
+ `)}]:[],...i?[{label:$n(s.durationMs),detail:i}]:[]]}function tx(s){const n=String(s.role||"").trim().toLowerCase()||"system",r=String(s.kind||"").trim().toLowerCase(),i=String(s.level||"").trim().toLowerCase();return n==="system"&&r==="report_bug"?{label:String(s.title||"").trim()||"Bug report",icon:"warning",variant:"report_bug"}:n==="system"&&r==="report_feature"?{label:String(s.title||"").trim()||"Feature request",icon:"check",variant:"report_feature"}:n==="user"?{label:String(s.title||"").trim()||"You",icon:"user",variant:"user"}:n==="assistant"?{label:String(s.title||"").trim()||"Agent",icon:"bot",variant:"assistant"}:{label:String(s.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 nx=new Set(["blob:","data:","http:","https:"]);function Rc(s){const n=String(s||"").trim();if(n)try{const r=typeof window<"u"&&window.location?window.location.href:"http://same-origin.invalid/";return nx.has(new URL(n,r).protocol)?n:void 0}catch{return}}function Lp(s,n){return Cp(s)?{href:s,download:n||"file"}:{href:s,target:"_blank",rel:"noopener noreferrer"}}function sx({item:s,onOpen:n,markdown:r}){const[i,l]=f.useState(!1),u=Rc(s.src),m=String(s.name||s.label||"").trim()||"File",d=qv({href:s.href?Rc(s.href):void 0,src:u,contentType:s.contentType,name:s.name||s.label}),h=yp(m,s.contentType),x=vv(h),v=typeof s.text=="string";if(!u&&!d&&!v)return null;const g=vp(s.size),w=String(s.label||"").trim()||m;return e.jsxs("figure",{className:"pc-chat-media__item pc-chat-media__item--file","data-file-kind":h,children:[e.jsxs("div",{className:"pc-chat-media__file-row",children:[e.jsx(Ue,{name:"file",size:14}),e.jsx("span",{className:"pc-chat-media__file-name",title:m,children:w}),g?e.jsx("span",{className:"pc-chat-media__file-size",children:g}):null,n?e.jsx("button",{type:"button",className:"pc-chat-media__file-open","data-action":"open-file",onClick:()=>n({...s,src:u||"",...d?{href:d}:{href:void 0}}),children:"Open"}):e.jsx("button",{type:"button",className:"pc-chat-media__file-open","data-action":"toggle-file","aria-expanded":i,onClick:()=>l(L=>!L),children:i?"Close":"Open"}),d?e.jsx("a",{className:"pc-chat-media__link",...Lp(d,String(s.name||"").trim()||w),children:"Raw file"}):null]}),i&&!n?e.jsx(Bv,{className:"pc-chat-media__viewer",name:m,kind:h,contentType:s.contentType,sizeBytes:s.size,status:x&&!v?"error":"ready",error:x&&!v?d?"No preview text was supplied for this file; open the raw file.":"No preview text was supplied for this file.":void 0,markdownImages:r.images||"link",...r.inlineImage?{inlineImage:r.inlineImage}:{},...r.renderMarkdown?{renderMarkdown:r.renderMarkdown}:{},...v?{text:s.text}:{},...u&&!x?{url:u}:{},onClose:()=>l(!1)}):null]})}function ax({item:s,onOpenFile:n,markdown:r}){const[i,l]=f.useState(!1);if(s.kind==="file")return e.jsx(sx,{item:s,onOpen:n,markdown:r||{}});const u=Rc(s.src),m=s.href?Rc(s.href):void 0,d=s.kind==="image"||s.kind==="audio"||s.kind==="video"?s.kind:null;if(!d||!u&&!m)return null;const h=d==="image"?"Image":d==="video"?"Video":"Audio",x=String(s.label||"").trim()||`Generated ${h.toLowerCase()}`,v=()=>l(!0);return e.jsxs("figure",{className:`pc-chat-media__item pc-chat-media__item--${d}`,children:[u&&d==="image"?e.jsx("img",{className:"pc-chat-media__image",src:u,alt:x,loading:"lazy",onError:v}):null,u&&d==="video"?e.jsx("video",{className:"pc-chat-media__video",src:u,controls:!0,playsInline:!0,preload:"metadata","aria-label":x,onError:v}):null,u&&d==="audio"?e.jsx(fp,{className:"pc-chat-media__audio",src:u,name:x}):null,d==="audio"&&String(s.transcript||"").trim()?e.jsxs("details",{className:"pc-chat-media__transcript",children:[e.jsx("summary",{children:"Transcript"}),e.jsx("p",{className:"pc-chat-media__transcript-text",children:String(s.transcript).trim()})]}):null,i?e.jsxs("div",{className:"pc-chat-media__error",role:"note",children:[h," could not be decoded by this browser",m?"; open the raw file with the link.":"."]}):null,m?e.jsx("figcaption",{className:"pc-chat-media__caption",children:e.jsx("a",{className:"pc-chat-media__link",...Lp(m,String(s.name||"").trim()||x),children:x})}):null]})}function rx(s){return s==="loading"?{icon:"loader",title:"Generating audio…",spinning:!0}:s==="playing"?{icon:"pause",title:"Pause",spinning:!1}:s==="paused"?{icon:"play",title:"Resume",spinning:!1}:{icon:"speaker",title:"Speak (TTS)",spinning:!1}}function ix(s){var A,V;const n=s.message,r=f.useMemo(()=>tx(n),[n.kind,n.level,n.role,n.title]),i=String(n.ts||"").trim(),l=f.useMemo(()=>{if(!i)return"";const Q=new Date(i);return Number.isFinite(Q.getTime())?Q.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""},[i]),[u,m]=f.useState("idle"),d=f.useRef(null);f.useEffect(()=>()=>{d.current!==null&&window.clearTimeout(d.current)},[]);const h=n.live,x=!h&&typeof s.onSpeakToggle=="function"&&r.variant==="assistant"&&!!String(n.content||"").trim(),v=x&&((A=s.getSpeakState)==null?void 0:A.call(s,n))||"idle",g=rx(v),w=s.showCopy!==!1,L=Array.isArray(s.attachments)?s.attachments:Array.isArray(n.attachments)?n.attachments:[],E=n.statistics,$=n.stats,T=f.useMemo(()=>Array.isArray(s.stats)?s.stats:Array.isArray($)?$:E?ex(E):[],[s.stats,$,E]),H=Array.isArray(n.media)?n.media:[],z=String(h?h.reasoning||"":n.reasoning||""),R=!!String(n.content||"").trim();if(n.toolActivity)return e.jsx(Ap,{tool:n.toolActivity,showCopy:s.showCopy});const M=s.renderFooter?s.renderFooter(n):null;if(((V=s.variant)==null?void 0:V.call(s,n))==="hint"||n.kind==="tool_policy_decision"){const Q=String(n.level||"").trim().toLowerCase();return e.jsxs("div",{className:["pc-chat-hint",Q==="warn"||Q==="error"?`pc-chat-hint--${Q}`:"",s.className].filter(Boolean).join(" "),role:"note","data-variant":"hint",children:[e.jsx("span",{className:"pc-chat-hint__text",children:String(n.content||"")}),M!=null&&M!==!1?e.jsx("div",{className:"pc-chat-footer",children:M}):null]})}return e.jsxs("div",{className:["pc-chat-item",`pc-chat-item--${r.variant}`,h?"pc-chat-item--live":"",s.className].filter(Boolean).join(" "),...h?{"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(Ue,{name:r.icon,size:14})}),e.jsx("span",{className:"pc-chat-role",children:r.label}),h?e.jsxs("span",{className:"pc-chat-live-indicator",title:h.label?`Pending: ${h.label}`:"The reply is still being written",children:[e.jsx("span",{className:"pc-chat-live-dot","aria-hidden":"true"}),h.label||"streaming"]}):null,h!=null&&h.caption?e.jsx("span",{className:"pc-chat-live-caption",children:h.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:[x?e.jsx("button",{className:"pc-chat-icon-btn",type:"button","aria-label":g.title,title:g.title,"data-speak-state":v,onClick:()=>{var Q;return(Q=s.onSpeakToggle)==null?void 0:Q.call(s,n)},children:e.jsx(Ue,{name:g.icon,size:22,className:g.spinning?"pc-chat-speak-spinner":void 0},g.icon)}):null,w?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 Q=await on(String(n.content||""));m(Q?"copied":"failed"),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>m("idle"),900)},children:e.jsx(Ue,{name:"copy",size:22})}):null]})]}),z.trim()?e.jsxs("details",{className:"pc-chat-thinking",children:[e.jsx("summary",{children:"Thinking"}),e.jsx("div",{className:"pc-chat-thinking-body",children:z})]}):null,R||!h&&!H.length?e.jsx("div",{className:"pc-chat-body",children:e.jsx(Iv,{text:String(n.content||""),renderMarkdown:s.renderMarkdown,jsonCollapseAfterDepth:s.jsonCollapseAfterDepth,images:s.images||(r.variant==="user"?"inline":"link"),inlineImage:s.inlineImage})}):null,H.length?e.jsx("div",{className:"pc-chat-media",children:H.slice(0,24).map((Q,oe)=>e.jsx(ax,{item:Q,onOpenFile:s.onOpenMedia,markdown:{renderMarkdown:s.renderMarkdown,images:s.images,inlineImage:s.inlineImage}},Q.id||`${Q.kind}:${Q.src}:${oe}`))}):null,L.length?e.jsx("div",{className:"pc-chat-attachments","aria-label":"Attachments",children:L.slice(0,24).map((Q,oe)=>{const be=String(Q.label||"").trim()||"attachment",Ne=String(Q.target||"").trim(),je=String(Q.title||"").trim(),Ce=!!Q.disabled||typeof Q.onClick!="function";return e.jsxs("button",{type:"button",className:"pc-chat-attachment-chip",title:je||be,onClick:Ce?void 0:Q.onClick,disabled:Ce,children:[e.jsx(Ue,{name:"paperclip",size:14}),Ne?e.jsx("span",{className:`pc-chat-attachment-target pc-chat-attachment-target--${Ne}`,children:Ne}):null,e.jsx("span",{className:"pc-chat-attachment-name",children:be})]},Q.id||`${be}:${oe}`)})}):null,T.length?e.jsx("div",{className:"pc-chat-stats","aria-label":"Stats",children:T.slice(0,12).map((Q,oe)=>{const be=String(Q.label||"").trim();if(!be)return null;if(Q.detail)return e.jsx(Yv,{label:be,detail:Q.detail,icon:Q.icon,onClick:Q.onClick},Q.id||`${be}:${oe}`);const Ne=String(Q.title||"").trim(),je=typeof Q.onClick=="function",Ce=je?"button":"span";return e.jsxs(Ce,{...je?{type:"button"}:{},className:["pc-chat-stat",je?"pc-chat-stat--clickable":""].filter(Boolean).join(" "),title:Ne||void 0,onClick:je?()=>{var q;return(q=Q.onClick)==null?void 0:q.call(Q)}:void 0,children:[Q.icon?e.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:Q.icon}):null,e.jsx("span",{className:"pc-chat-stat-label",children:be})]},Q.id||`${be}:${oe}`)})}):null,M!=null&&M!==!1?e.jsx("div",{className:"pc-chat-footer",children:M}):null]})}function ox(s,n){const r=Math.max(0,Math.trunc(n));return s.scrollHeight-s.scrollTop-s.clientHeight<=r}function zc(s){const n=typeof s.autoScrollThresholdPx=="number"&&Number.isFinite(s.autoScrollThresholdPx)?s.autoScrollThresholdPx:120,r=s.autoScroll!==!1,i=f.useRef(null),l=f.useRef(null),[u,m]=f.useState(!0),d=f.useMemo(()=>Array.isArray(s.messages)?s.messages:[],[s.messages]),h=f.useMemo(()=>{var g;const v=[];for(const w of d){const L=v[v.length-1];w.toolActivity&&((g=L==null?void 0:L[0])!=null&&g.toolActivity)&&L[0].runId===w.runId?L.push(w):v.push([w])}return v},[d]);f.useEffect(()=>{if(!r)return;const v=i.current;if(!v)return;const g=()=>{m(ox(v,n))};return v.addEventListener("scroll",g,{passive:!0}),g(),()=>v.removeEventListener("scroll",g)},[r,n]);const x=f.useMemo(()=>{let v=0;for(const g of d)if(v+=String(g.content??"").length,Array.isArray(g.media))for(const w of g.media)v+=String((w==null?void 0:w.src)??"").length+1;return`${d.length}:${v}:${String(s.afterKey??"")}`},[d,s.afterKey]);return f.useEffect(()=>{if(!r||!u)return;const v=i.current;v&&(v.scrollTop=v.scrollHeight)},[r,u,x]),f.useEffect(()=>{if(!r)return;const v=i.current;if(!v)return;const g=()=>{u&&(v.scrollTop=v.scrollHeight)};return v.addEventListener("load",g,!0),v.addEventListener("loadedmetadata",g,!0),()=>{v.removeEventListener("load",g,!0),v.removeEventListener("loadedmetadata",g,!0)}},[r,u]),e.jsxs("div",{ref:i,className:["pc-chat-thread",s.className].filter(Boolean).join(" "),children:[d.length?null:s.empty||null,h.map((v,g)=>{var E;const w=v[0],L=String(w.id||"")||String(w.ts||"")+":"+String(w.role||"")+":"+g;return w.toolActivity?e.jsx(Zv,{tools:v.map($=>$.toolActivity),showCopy:(E=s.messageProps)==null?void 0:E.showCopy},L):e.jsx(ix,{message:w,...s.messageProps||{}},L)}),s.after,e.jsx("div",{ref:l})]})}const cl=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 lx(s){return!!(s&&typeof s[Symbol.asyncIterator]=="function")}function cx(s){const[n,r]=f.useState([]),i=s.messages??n,l=$=>{s.onMessagesChange&&s.onMessagesChange($),s.messages===void 0&&r($)},u=f.useRef(i);u.current=i;const[m,d]=f.useState(""),[h,x]=f.useState(!1),v=f.useRef(null),g=s.assistantName||"Assistant",w=!!s.blockedNotice,L=async $=>{const T=String($||"").trim();if(!T||h||w)return;d("");const H=u.current,z=[...H,{role:"user",content:T,ts:new Date().toISOString()}];l(z),x(!0);const R=new AbortController;v.current=R;try{const M=s.ask(T,{signal:R.signal,history:H});if(lx(M)){let A="";const V=[...z,{role:"assistant",title:g,content:"",ts:new Date().toISOString()}];l(V);for await(const Q of M){if(R.signal.aborted)break;A+=String(Q??""),l([...z,{role:"assistant",title:g,content:A,ts:new Date().toISOString()}])}!A.trim()&&!R.signal.aborted&&l([...z,{role:"assistant",title:g,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}else{const A=String(await M??"").trim();l([...z,A?{role:"assistant",title:g,content:A,ts:new Date().toISOString()}:{role:"assistant",title:g,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}}catch(M){R.signal.aborted||l([...u.current,{role:"assistant",title:g,content:`#FALLBACK assistant request failed: ${String((M==null?void 0:M.message)||M||"unknown error")}`,level:"error",ts:new Date().toISOString()}])}finally{v.current===R&&(v.current=null),x(!1)}},E=f.useMemo(()=>i.length>0?null:e.jsxs("div",{className:"pc-assistant__empty",children:[e.jsx("div",{className:"pc-assistant__empty-text",children:s.emptyState||"Ask about this app — answers are grounded in its documentation."}),s.suggestions&&s.suggestions.length>0?e.jsx("div",{className:"pc-assistant__suggestions",children:s.suggestions.map($=>e.jsx("button",{type:"button",className:"pc-assistant__suggestion",onClick:()=>void L($),disabled:h||w,children:$},$))}):null]}),[i.length,s.emptyState,s.suggestions,h,w]);return e.jsxs("div",{className:`pc-assistant${s.className?` ${s.className}`:""}`,children:[e.jsxs("div",{className:"pc-assistant__thread",children:[E,e.jsx(zc,{messages:i,autoScroll:!0}),w?e.jsx("div",{className:"pc-assistant__blocked",children:s.blockedNotice}):null]}),e.jsx("div",{className:"pc-assistant__composer",children:e.jsx(cl,{value:m,onChange:d,onSubmit:()=>void L(m),placeholder:s.placeholder||"Ask about this app…",disabled:w,busy:h,rows:2,actions:h?e.jsx("button",{type:"button",className:"pc-btn",onClick:()=>{var $;($=v.current)==null||$.abort()},children:"Stop"}):null})})]})}function ux(s){if(!s)return!1;for(let n=0;n<s.length;n+=1)if(s[n]==="Files")return!0;return!1}function Mp(s){const n=[],r=[],i=s==null?void 0:s.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,h=typeof m.getAsFile=="function"?m.getAsFile():null;d!=null&&d.isDirectory?r.push(d.name||(h==null?void 0:h.name)||"folder"):h&&n.push(h)}return{files:n,folders:r}}const l=s==null?void 0:s.files;if(l)for(let u=0;u<l.length;u+=1)l[u]&&n.push(l[u]);return{files:n,folders:r}}function dx(s){return s.length?s.length===1?`"${s[0]}" is a folder. Folders are not supported: drop the files inside it instead.`:`${s.length} folders were dropped. Folders are not supported: drop the files inside them instead.`:""}const mx={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/heic":"heic","image/tiff":"tiff","image/bmp":"bmp"};function Oo(s){return String(s).padStart(2,"0")}function fx(s,n,r){const i=String(s||"").trim();if(i&&!/^image\.(png|jpe?g|gif|webp|heic|tiff?|bmp)$/i.test(i))return i;const l=mx[String(n||"").toLowerCase()]||i.split(".").pop()||"bin",u=`${r.getFullYear()}-${Oo(r.getMonth()+1)}-${Oo(r.getDate())} at ${Oo(r.getHours())}.${Oo(r.getMinutes())}.${Oo(r.getSeconds())}`;return`${String(n||"").startsWith("image/")||!i?"Pasted image":"Pasted file"} ${u}.${l}`}function hx(s,n=new Date){if(!s)return[];const r=s.types?Array.from(s.types):[];if(r.includes("text/plain")&&r.includes("text/html"))return[];const{files:i}=Mp(s);return i.map(l=>{const u=fx(l.name,l.type,n);return u===l.name?l:new File([l],u,{type:l.type,lastModified:l.lastModified})})}const Yo="llm.delta",Mi="llm.delta_end";function px(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:null}function zr(s){return typeof s=="string"&&s.trim()!==""}function _x(s){return typeof s=="number"&&Number.isInteger(s)&&s>=0}function gx(s){return"reason"in s}function yx(s,n){const r=px(s),i=r==null?void 0:r.kind,l=n||(typeof i=="string"&&i?i:r&&"reason"in r?Mi:Yo),u=h=>{throw new Error(`Malformed ${l} event from the gateway: ${h}`)};if(n!==void 0&&n!==Yo&&n!==Mi&&u(`unknown event name ${JSON.stringify(n)}`),!r)return u("the payload is not an object");i!==void 0&&i!==Yo&&i!==Mi&&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`),zr(r.run_id)||u("run_id is missing"),zr(r.call_id)||u("call_id is missing"),_x(r.seq)||u("seq is not a non-negative integer");const m=n||i?(n||i)===Mi:"reason"in r;r.root_run_id!==void 0&&!zr(r.root_run_id)&&u("root_run_id is not a run id"),r.parent_run_id!==void 0&&r.parent_run_id!==null&&!zr(r.parent_run_id)&&u("parent_run_id is neither a run id nor null");const d={run_id:r.run_id,...zr(r.root_run_id)?{root_run_id:r.root_run_id}:{},...r.parent_run_id!==void 0?{parent_run_id:r.parent_run_id}:{},...zr(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:Mi,...d,reason:r.reason,...zr(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:Yo,...d,text:r.text,channel:r.channel,snapshot:r.snapshot})}function vx(s,n){if(s!==Yo&&s!==Mi)return null;let r=n;if(typeof n=="string")try{r=JSON.parse(n)}catch{throw new Error(`Malformed ${s} event from the gateway: data is not JSON`)}return yx(r,s)}async function Rp(s,n){let r="";try{const i=await s.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 ${s.status}): ${r.trim()||s.statusText||"no reason given"}`)}const xx={registry_scope:"tenant_catalog",bundle_id:"docs-qa",bundle_version:"0.1.1",flow_id:"docsqa001"},Pp="docs";function bx(s){return ws(`docs/corpus?${new URLSearchParams({app:String(s||"")})}`)}function id(s){return`${String(s||"app")}-docs-assistant:${Zo()}`}function wx(s){const n={prompt:s.question,docs:s.docs,app:s.appName,use_session_history:!0};return s.attachments&&s.attachments.length&&(n.context={attachments:s.attachments}),{...xx,session_id:s.sessionId,kind:Pp,input_data:n}}function zp(s){const n=s==null?void 0:s.output;if(typeof n=="string")return n.trim();const r=n==null?void 0:n.response;return typeof r=="string"?r.trim():""}function jx(s){const n=s&&typeof s=="object"?s:{},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*kx(s,n){const r=s.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,`
54
+ `);let h=l.indexOf(`
55
+
56
+ `);for(;h>=0;){const x=l.slice(0,h);l=l.slice(h+2);let v="message";const g=[];for(const w of x.split(`
57
+ `))w.startsWith("event:")?v=w.slice(6).trim():w.startsWith("data:")&&g.push(w.slice(5).replace(/^ /,""));g.length&&(yield{event:v,data:g.join(`
58
+ `)}),h=l.indexOf(`
59
+
60
+ `)}}}finally{n==null||n.removeEventListener("abort",u)}}function Sx(s,n){return new Promise((r,i)=>{if(n.aborted)return i(new DOMException("Aborted","AbortError"));const l=setTimeout(()=>{n.removeEventListener("abort",u),r()},s),u=()=>{clearTimeout(l),i(new DOMException("Aborted","AbortError"))};n.addEventListener("abort",u,{once:!0})})}async function er(s,n){if(!s.ok)throw await Rp(s,n);return s.json()}function Nx(s){const n=s.pollMs??1e3,r=s.timeoutMs??18e4;let i=null;return async(l,u)=>{var E;const{fetchGateway:m,source:d}=s;if(i===null){const $=await m(bx(d.app),{signal:u.signal,headers:{Accept:"application/json"}}),T=await er($,`The ${d.name} documentation could not be read, so nothing was asked`),H=typeof(T==null?void 0:T.text)=="string"?T.text:"";if(!H.trim())throw new Error(`The gateway returned an empty ${d.name} documentation corpus, so nothing was asked.`);i=H}const h=String(i),x=[];for(const $ of u.files||[]){const T=new FormData;T.append("session_id",u.sessionId),T.append("file",$,$.name||"upload.bin"),T.append("filename",$.name||"upload.bin"),$.type&&T.append("content_type",$.type);const H=await er(await m(ws("attachments/upload"),{method:"POST",body:T,signal:u.signal}),`"${$.name}" could not be attached`),z=H==null?void 0:H.attachment;if(!z||typeof z.$artifact!="string"||!z.$artifact)throw new Error(`"${$.name}" could not be attached: the gateway returned no attachment reference.`);x.push(z)}const v=await er(await m(ws("runs/start"),{method:"POST",signal:u.signal,headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(wx({question:l,docs:h,appName:d.name,sessionId:u.sessionId,attachments:x}))}),"The docs-qa workflow could not start"),g=String((v==null?void 0:v.run_id)||"");if(!g)throw new Error("The gateway did not return a run id for the docs-qa workflow.");const w=new AbortController,L=()=>w.abort();u.signal.addEventListener("abort",L,{once:!0}),u.onText&&(async()=>{var $;try{const T=await m(ws(`runs/${encodeURIComponent(g)}/ledger/stream?after=0`),{signal:w.signal,headers:{Accept:"text/event-stream"}});if(!T.ok||!T.body)return;let H="",z="";for await(const R of kx(T.body,w.signal)){const M=vx(R.event,R.data);!M||gx(M)||M.channel!=="content"||M.run_id!==g||(M.call_id!==H&&(H=M.call_id,z=""),z=M.snapshot?M.text:z+M.text,($=u.onText)==null||$.call(u,z))}}catch{}})();try{const $=Date.now()+r;for(;;){await Sx(n,u.signal);const T=await er(await m(ws(`runs/${encodeURIComponent(g)}`),{signal:u.signal}),"The docs-qa run could not be read"),H=String((T==null?void 0:T.status)||"").toLowerCase();if(H==="completed"){(E=u.onHistory)==null||E.call(u,(T==null?void 0:T.session_history)??null);const z=zp(T);if(!z)throw new Error(`The docs-qa run ${g} completed without an answer.`);return z}if(H==="failed"||H==="cancelled"){const z=T==null?void 0:T.error,R=typeof z=="string"?z:typeof(z==null?void 0:z.message)=="string"?z.message:"";throw new Error(`The docs-qa run ${H}${R?`: ${R}`:""}.`)}if(H==="waiting")throw new Error(`The docs-qa run ${g} is waiting for input it should never need. Inspect it in Observer.`);if(Date.now()>=$)throw new Error(`The docs-qa run ${g} is still running after ${Math.round(r/1e3)} s. It stays in the gateway's history.`)}}finally{u.signal.removeEventListener("abort",L),w.abort()}}}async function Cx(s,n,r={}){const i=new URLSearchParams({root_only:"true",kind:Pp,limit:"500",include_ledger_len:"false"}),l=await er(await s(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 h of Array.isArray(l==null?void 0:l.items)?l.items:[]){const x=String((h==null?void 0:h.session_id)||"");if(!x.startsWith(u)||!(h!=null&&h.run_id))continue;const v=m.get(x)||{runs:[],updatedAt:""};v.runs.push({id:String(h.run_id),created:String(h.created_at||"")});const g=String(h.updated_at||h.created_at||"");g>v.updatedAt&&(v.updatedAt=g),m.set(x,v)}const d=[...m.entries()].sort((h,x)=>h[1].updatedAt<x[1].updatedAt?1:-1).slice(0,r.max??20);return Promise.all(d.map(async([h,x])=>{var w;const v=x.runs.sort((L,E)=>L.created<E.created?-1:1).map(L=>L.id);let g="";try{const L=await er(await s(ws(`runs/${encodeURIComponent(v[0])}/input_data`),{signal:r.signal}),"");g=String(((w=L==null?void 0:L.input_data)==null?void 0:w.prompt)||"").trim()}catch{g=""}return{sessionId:h,title:g||"Untitled question",updatedAt:x.updatedAt,runIds:v}}))}async function $x(s,n,r,i){var u;const l=[];for(const m of n.runIds){const[d,h]=await Promise.all([er(await s(ws(`runs/${encodeURIComponent(m)}/input_data`),{signal:i}),"A past question could not be read"),er(await s(ws(`runs/${encodeURIComponent(m)}`),{signal:i}),"A past answer could not be read")]),x=String(((u=d==null?void 0:d.input_data)==null?void 0:u.prompt)||"").trim();x&&l.push({id:`u-${m}`,role:"user",content:x,ts:String((h==null?void 0:h.created_at)||"")||void 0});const v=zp(h),g=String((h==null?void 0:h.status)||"").toLowerCase();l.push(v?{id:`a-${m}`,role:"assistant",title:r,content:v,ts:String((h==null?void 0:h.updated_at)||"")||void 0}:{id:`a-${m}`,role:"assistant",title:r,level:"warn",content:g==="completed"?"This answer was empty.":`No answer: the run is ${g||"unknown"}.`})}return l}function Ex(s){const[n,r]=f.useState(null);return s.state==="loading"?e.jsx("div",{className:"pc-docs-history__note",role:"status",children:"Loading past conversations…"}):s.state==="error"?e.jsx("div",{className:"pc-docs-history__note pc-docs-history__note--error",role:"alert",children:s.error||"The history could not be read."}):s.items.length?e.jsx("ul",{className:"pc-docs-history","aria-label":"Past conversations",children:s.items.map(i=>e.jsx("li",{className:`pc-docs-history__row${i.sessionId===s.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),s.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:()=>s.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:[gp(i.updatedAt,s.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(Ue,{name:"archive",size:16})})]})},i.sessionId))}):e.jsx("div",{className:"pc-docs-history__note",children:"No past conversations yet."})}const Tx=/^image\/(png|jpe?g|gif|webp|avif|bmp|svg\+xml)$/i;function Ax(s){const n=f.useRef(null),[r,i]=f.useState(!1),l=!!s.blockedNotice,u=!!s.busy,m=s.files||[],d=typeof s.onAddFiles=="function"&&!l,h=e.jsxs("div",{className:"pc-docs-assistant__empty",children:[e.jsxs("p",{className:"pc-docs-assistant__empty-text",children:["Ask anything about ",s.source.name,"."]}),s.suggestions&&s.suggestions.length?e.jsx("div",{className:"pc-docs-assistant__suggestions",children:s.suggestions.map(x=>e.jsx("button",{type:"button",className:"pc-docs-assistant__suggestion",disabled:u||l,onClick:()=>{var v;return(v=s.onSuggestion)==null?void 0:v.call(s,x)},children:x},x))}):null]});return e.jsxs("div",{className:`pc-docs-assistant${r?" is-dragging":""}`,onDragOver:x=>{var v;!d||!ux((v=x.dataTransfer)==null?void 0:v.types)||(x.preventDefault(),i(!0))},onDragLeave:()=>i(!1),onDrop:x=>{var g,w;if(!d)return;x.preventDefault(),i(!1);const v=Mp(x.dataTransfer);v.files.length&&((g=s.onAddFiles)==null||g.call(s,v.files)),v.folders.length&&((w=s.onNotice)==null||w.call(s,dx(v.folders)))},children:[e.jsx(zc,{className:"pc-docs-assistant__thread",messages:s.messages,autoScroll:!0,empty:h,messageProps:{showCopy:!0}}),l?e.jsx("div",{className:"pc-docs-assistant__blocked",role:"status",children:s.blockedNotice}):null,s.notice?e.jsx("div",{className:"pc-docs-assistant__notice",role:"status",children:s.notice}):null,e.jsx("div",{className:"pc-docs-assistant__composer",children:e.jsx(cl,{value:s.draft,onChange:s.onDraftChange,onSubmit:s.onSend,placeholder:s.placeholder||`Ask about ${s.source.name}…`,ariaLabel:`Question about ${s.source.name}`,disabled:l,busy:u,rows:1,sendLabel:"Send",busyLabel:"Answering…",onPaste:x=>{var g;if(!d)return;const v=hx(x.clipboardData);v.length&&(x.preventDefault(),(g=s.onAddFiles)==null||g.call(s,v))},leading:m.length?e.jsx("div",{className:"pc-chat-attachments pc-docs-assistant__files",role:"list","aria-label":"Attached files",children:m.map(x=>e.jsxs("span",{role:"listitem",className:"pc-chat-attachment-chip",children:[e.jsx(Ue,{name:"paperclip",size:14}),e.jsx("span",{className:"pc-chat-attachment-name",children:x.name}),s.onRemoveFile&&!u?e.jsx("button",{type:"button",className:"pc-docs-assistant__file-remove","aria-label":`Remove ${x.name}`,"data-af-tip":`Remove ${x.name}`,onClick:()=>{var v;return(v=s.onRemoveFile)==null?void 0:v.call(s,x.id)},children:e.jsx(Ue,{name:"x",size:12})}):null]},x.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 x;return(x=n.current)==null?void 0:x.click()},children:e.jsx(Ue,{name:"paperclip",size:16})}),e.jsx("input",{ref:n,type:"file",multiple:!0,hidden:!0,"aria-hidden":"true",tabIndex:-1,onChange:x=>{var g;const v=Array.from(x.currentTarget.files||[]);x.currentTarget.value="",v.length&&((g=s.onAddFiles)==null||g.call(s,v))}})]}):null,u&&s.onStop?e.jsx("button",{type:"button",className:"pc-docs-assistant__icon-btn","aria-label":"Stop","data-af-tip":"Stop the answer",onClick:s.onStop,children:e.jsx(Ue,{name:"stop",size:14})}):null]})})}),e.jsxs("div",{className:"pc-docs-assistant__footer",title:`Answers come from ${s.source.name}'s documentation (llms.txt) through the gateway's docs-qa workflow.`,children:["Grounded on ",s.source.name,"’s documentation (llms.txt) · docs-qa"]})]})}function bc(){return new Date().toISOString()}function Lx(s){Hd();const{source:n}=s,r=f.useRef(s.fetchGateway);r.current=s.fetchGateway;const i=f.useMemo(()=>s.ask||Nx({fetchGateway:(q,te)=>r.current(q,te),source:n}),[s.ask,n.app,n.name]),l=f.useRef(id(n.app)),[u,m]=f.useState([]),d=f.useRef(u);d.current=u;const[h,x]=f.useState(""),[v,g]=f.useState([]),[w,L]=f.useState(!1),[E,$]=f.useState(""),T=f.useRef(null),[H,z]=f.useState(!1),[R,M]=f.useState({state:"loading",items:[]});f.useEffect(()=>()=>{var q;return(q=T.current)==null?void 0:q.abort()},[]);const A=f.useCallback(async()=>{M(q=>({...q,state:"loading"}));try{const q=await Cx((te,Y)=>r.current(te,Y),n.app);M({state:"ready",items:q})}catch(q){M({state:"error",items:[],error:String((q==null?void 0:q.message)||q)})}},[n.app]),V=f.useCallback(async q=>{var te;(te=T.current)==null||te.abort(),M(Y=>({...Y,state:"loading"}));try{const Y=await $x((U,X)=>r.current(U,X),q,n.name);l.current=q.sessionId,m(Y),$(""),z(!1),M(U=>({...U,state:"ready"}))}catch(Y){M(U=>({...U,state:"error",error:String((Y==null?void 0:Y.message)||Y)}))}},[n.name]),Q=f.useCallback(async q=>{try{const te=await r.current(ws(`sessions/${encodeURIComponent(q.sessionId)}/archive`),{method:"POST"});if(!te.ok)throw await Rp(te,"The conversation could not be archived");l.current===q.sessionId&&(l.current=id(n.app),m([])),M(Y=>({...Y,items:Y.items.filter(U=>U.sessionId!==q.sessionId)}))}catch(te){M(Y=>({...Y,state:"error",error:String((te==null?void 0:te.message)||te)}))}},[n.app]);f.useEffect(()=>{var q;s.connected||(q=T.current)==null||q.abort()},[s.connected]),f.useEffect(()=>()=>{for(const q of v)q.preview&&URL.revokeObjectURL(q.preview)},[]);const oe=f.useCallback(q=>{$(""),g(te=>[...te,...q.map(Y=>({id:Zo(),file:Y,preview:Tx.test(Y.type)&&typeof URL<"u"&&typeof URL.createObjectURL=="function"?URL.createObjectURL(Y):void 0}))])},[]),be=f.useCallback(async q=>{const te=String(q||"").trim();if(!te||w||!s.connected)return;const Y=v;x(""),g([]),$("");const U=Y.filter(he=>he.preview).map(he=>({kind:"image",src:he.preview,label:he.file.name})),X=Y.map(he=>({id:he.id,label:he.file.name,title:he.file.name,disabled:!0})),I={id:`u-${Zo()}`,role:"user",content:te,ts:bc(),...U.length?{media:U}:{},...X.length?{attachments:X}:{}},ee=`a-${Zo()}`,ae=[...d.current,I],k={id:ee,role:"assistant",title:n.name,content:"",ts:bc(),live:{callId:ee,reasoning:"",label:"answering"}};m([...ae,k]),L(!0);const C=new AbortController;T.current=C;const re=he=>m([...ae,he]);try{const he=await i(te,{signal:C.signal,sessionId:l.current,files:Y.map(ce=>ce.file),onText:ce=>{C.signal.aborted||re({...k,content:ce,live:{callId:ee,reasoning:"",label:"streaming"}})},onHistory:ce=>$(jx(ce))});C.signal.aborted||re({id:ee,role:"assistant",title:n.name,content:he,ts:bc()})}catch(he){const ce=C.signal.aborted;re({id:ee,role:"assistant",title:n.name,level:ce?"warn":"error",content:ce?"Stopped. Nothing more will be shown for this question.":String((he==null?void 0:he.message)||he||"The docs assistant failed."),ts:bc()})}finally{T.current===C&&(T.current=null),L(!1)}},[i,w,v,s.connected,n.name]),Ne=()=>{var q;(q=T.current)==null||q.abort(),l.current=id(n.app),m([]),g([]),x(""),$("")},je=e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`pc-docs-assistant__icon-btn${H?" is-active":""}`,"aria-label":"Past conversations","data-af-tip":"Past conversations","aria-pressed":H,disabled:!s.connected||w,onClick:()=>{const q=!H;z(q),q&&A()},children:e.jsx(Ue,{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&&!h&&!v.length&&!H,onClick:()=>{Ne(),z(!1)},children:e.jsx(Ue,{name:"compose",size:16})})]}),Ce=e.jsxs(e.Fragment,{children:[H?e.jsx("div",{className:"pc-docs-assistant pc-docs-assistant--history",children:e.jsx(Ex,{items:R.items,state:R.state,error:R.error,nowMs:Date.now(),activeSessionId:l.current,onOpen:q=>void V(q),onArchive:q=>void Q(q)})}):null,e.jsx("div",{hidden:H,style:{display:H?"none":"contents"},children:e.jsx(Ax,{source:n,messages:u,draft:h,onDraftChange:x,onSend:()=>void be(h),onStop:()=>{var q;return(q=T.current)==null?void 0:q.abort()},busy:w,blockedNotice:s.connected?void 0:"Connect to the gateway to use the docs assistant.",files:v.map(q=>({id:q.id,name:q.file.name})),onAddFiles:oe,onNotice:$,onRemoveFile:q=>g(te=>{const Y=te.find(U=>U.id===q);return Y!=null&&Y.preview&&URL.revokeObjectURL(Y.preview),te.filter(U=>U.id!==q)}),notice:E,suggestions:s.suggestions,onSuggestion:q=>void be(q),placeholder:s.placeholder})})]});return{headerActions:je,body:Ce}}function Mx(s){const{headerActions:n,body:r}=Lx(s);return e.jsx($d,{open:s.open,onClose:s.onClose,label:"Docs assistant",title:e.jsxs("span",{className:"pc-docs-assistant__title",children:[e.jsx(Ue,{name:"book",size:16}),"Docs assistant"]}),width:s.width||420,topOffset:s.topOffset,manageFocus:s.manageFocus===!0,className:`pc-docs-assistant-drawer${s.className?` ${s.className}`:""}`,headerActions:n,children:r})}function Rx(s){const n=s.trim();if(!n)throw new Error("AbstractContinuum was built without __APP_VERSION__ (see vite.config.ts define)");return n}const Px=Rx("0.7.5");function wc(s){return s?s.value!==void 0&&s.value!==null?!!s.value:s.enabled!==void 0?!!s.enabled:s.configured!==void 0?!!s.configured:s.path!==void 0?!!s.path:null:null}function Fo(s){if(!s)return"";const n=s.value!==void 0&&s.value!==null?s.value:s.id??s.path??"";return typeof n=="string"?n.trim():""}const dh="abstractcontinuum_gateway_csrf",zx="x-abstractcontinuum-csrf",Ix="x-abstract-csrf";function od(s){var i;const n=(s||"").trim(),r={};n&&(r.Authorization=`Bearer ${n}`);try{const l=(i=document.cookie.split(";").map(u=>u.trim()).find(u=>u.startsWith(`${dh}=`)))==null?void 0:i.slice(`${dh}=`.length);if(l){const u=decodeURIComponent(l);r[zx]=u,r[Ix]=u}}catch{}return r}function mh(s){const n={},r=(i,l)=>{const u=String(l||"").trim();u&&(n[i]=u)};return r("provider",s==null?void 0:s.provider),r("model",s==null?void 0:s.model),r("profile",s==null?void 0:s.profile),r("voice",s==null?void 0:s.voice),r("quality_preset",s==null?void 0:s.quality_preset),n}async function Dx(s){try{const n=await s.text();return n!=null&&n.trim()?n.trim():`${s.status}`}catch{return`${s.status}`}}class Ip extends Error{constructor(r,i,l){super(r);Ja(this,"status");Ja(this,"body");this.name="GatewayRequestError",this.status=i,this.body=l}}const ld=[15,30,60,120];class Ox{constructor(n){Ja(this,"_cfg");Ja(this,"_backoff_until",0);Ja(this,"_backoff_step",0);Ja(this,"fetch_gateway",(n,r)=>{const i=new Headers((r==null?void 0:r.headers)||{});for(const[l,u]of Object.entries(od(this._cfg.auth_token)))i.set(l,u);return fetch(Xu(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(Xu(this._cfg.base_url,r),{...i,headers:{...i==null?void 0:i.headers,...od(this._cfg.auth_token)}});if(l.ok)return this._backoff_step=0,this._backoff_until=0,l;const u=await Dx(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 x=ld[Math.min(this._backoff_step,ld.length-1)];this._backoff_until=Date.now()+x*1e3,this._backoff_step<ld.length-1&&(this._backoff_step+=1)}throw new Ip(`${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 h=await this._post_form("attachments_upload","api/gateway/attachments/upload",d),x=h==null?void 0:h.attachment;if(!x||typeof x!="object")throw new Error("attachments_upload: missing attachment");if(!String(x.$artifact||"").trim())throw new Error("attachments_upload: missing attachment.$artifact");return x}async audio_transcribe(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 h=String((r==null?void 0:r.request_id)||"").trim();h&&(m.request_id=h);const x=await this._post_json("audio_transcribe",`api/gateway/runs/${encodeURIComponent(i)}/audio/transcribe`,m);return{ok:!!(x!=null&&x.ok),run_id:String((x==null?void 0:x.run_id)||""),request_id:String((x==null?void 0:x.request_id)||""),text:String((x==null?void 0:x.text)||""),transcript_artifact:x==null?void 0:x.transcript_artifact}}async voice_tts(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,...mh(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 h=await this._post_json("voice_tts",`api/gateway/runs/${encodeURIComponent(i)}/voice/tts`,u);return{ok:!!(h!=null&&h.ok),run_id:String((h==null?void 0:h.run_id)||""),request_id:String((h==null?void 0:h.request_id)||""),audio_artifact:h==null?void 0:h.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:Xu(this._cfg.base_url,`api/gateway/runs/${encodeURIComponent(i)}/voice/tts/stream`),body:{text:String((r==null?void 0:r.text)||""),format:"wav",...mh(r)},headers:od(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",fh(n,"bug_report_create"))}async feature_report_create(n){return await this._post_json("feature_report_create","api/gateway/features/report",fh(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 h=(n==null?void 0:n.content)==null?"":String((n==null?void 0:n.content)??"");return h.trim()&&(u.content=h),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(x=>({kind:String((x==null?void 0:x.kind)||"").trim(),filename:String((x==null?void 0:x.filename)||"").trim()}))},d=String((n==null?void 0:n.task_type)||"").trim();d&&(m.task_type=d);const h=String((n==null?void 0:n.summary)||"").trim();return h&&(m.summary=h),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 h=String((n==null?void 0:n.provider)||"").trim();h&&(u.provider=h);const x=String((n==null?void 0:n.model)||"").trim();x&&(u.model=x);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 h=(n==null?void 0:n.draft_markdown)==null?"":String(n.draft_markdown??"");h.trim()&&(m.draft_markdown=h);const x=String((n==null?void 0:n.provider)||"").trim();x&&(m.provider=x);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 h=String((n==null?void 0:n.focus_type)||"").trim();return h&&(r.focus_type=h),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 h=String((n==null?void 0:n.target_reasoning_effort)||"").trim();return h&&l.set("target_reasoning_effort",h),(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(h=>({kind:String((h==null?void 0:h.kind)||"").trim(),filename:String((h==null?void 0:h.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 fh(s,n){const r=String((s==null?void 0:s.session_id)||"").trim();if(!r)throw new Error(`${n}: session_id is required`);const i=String((s==null?void 0:s.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((s==null?void 0:s[m])||"").trim();d&&(l[m]=d)}const u=s==null?void 0:s.context;return u&&typeof u=="object"&&(l.context=u),l}const hh={framework:null,gateway:null,gatewayNote:"checking…"};function Fx(s){if(s instanceof Ip){const r=s.message.replace(/^gateway_about failed:\s*/,"").trim();return`HTTP ${s.status}${r&&r!==String(s.status)?`: ${r}`:""}`}return(s instanceof Error?s.message:String(s))||"request failed"}async function qx(s){let n;try{n=await s.gateway_about()}catch(r){return el(null,Fx(r))}return el(n)}const ph=Kd("voice and camera")??"Voice and camera are not supported in this browser (getUserMedia unavailable).",Bx="Copy failed — select and copy";function _h(){var n;const s=globalThis.navigator;return typeof((n=s==null?void 0:s.mediaDevices)==null?void 0:n.getUserMedia)=="function"}function Ux(s){var l;const n=globalThis.document;if(!n||!n.body||typeof n.execCommand!="function")return!1;const r=n.createElement("textarea");r.value=s,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,s.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 Wx(s){var i;const n=String(s??""),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 Ux(n)}const Hx=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 Vx(s){const n=s.length,r=new Uint8Array(n+9+63>>6<<6);r.set(s),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,h)=>d>>>h|d<<32-h;for(let d=0;d<r.length;d+=64){for(let T=0;T<16;T++)u[T]=i.getUint32(d+T*4,!1);for(let T=16;T<64;T++){const H=m(u[T-15],7)^m(u[T-15],18)^u[T-15]>>>3,z=m(u[T-2],17)^m(u[T-2],19)^u[T-2]>>>10;u[T]=u[T-16]+H+u[T-7]+z>>>0}let[h,x,v,g,w,L,E,$]=[l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7]];for(let T=0;T<64;T++){const H=m(w,6)^m(w,11)^m(w,25),z=w&L^~w&E,R=$+H+z+Hx[T]+u[T]>>>0,M=m(h,2)^m(h,13)^m(h,22),A=h&x^h&v^x&v,V=M+A>>>0;$=E,E=L,L=w,w=g+R>>>0,g=v,v=x,x=h,h=R+V>>>0}l[0]=l[0]+h>>>0,l[1]=l[1]+x>>>0,l[2]=l[2]+v>>>0,l[3]=l[3]+g>>>0,l[4]=l[4]+w>>>0,l[5]=l[5]+L>>>0,l[6]=l[6]+E>>>0,l[7]=l[7]+$>>>0}return Array.from(l,d=>d.toString(16).padStart(8,"0")).join("")}async function Dp(s){var i;const n=new TextEncoder().encode(String(s??"")),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 Vx(n)}const Gx=/^[a-zA-Z0-9_-]+$/;function gh(s){return Gx.test(String(s||"").trim())}async function Kx(s){const n=String(s||""),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 Qd(s){const n=String(s||"").trim();if(!n)throw new Error("session_id is required");if(gh(n)){const i=`session_memory_${n}`;if(gh(i))return i}return`session_memory_sha_${(await Kx(n)).slice(0,32)}`}const tr=["bug","feature","improvement","task"];function sl(s){return String(s||"").trim().toLowerCase()}function Op(s){return tr.includes(sl(s))}function Fp(s){const n=sl(s);return Op(n)?n:"task"}function qp(s){return s.toUpperCase()}function Bp(s){return s==="bug"?"danger":s==="feature"?"ok":s==="improvement"?"info":s==="task"?"task":"muted"}function Up(s){return Op(s)?void 0:`"${s}" is not in the ruled type vocabulary (${tr.join(" / ")})`}function Wp(s){const n=String(s||"").trim();return n.replace(/^\[(bug|feature|improvement|task)\]\s*/i,"").trim()||n}function _a(s,n){const r=String(s||"");return r.length<=n?r:`${r.slice(0,Math.max(0,n-1))}…`}function Td(s=new Date){const n=d=>String(d).padStart(2,"0"),r=-s.getTimezoneOffset(),i=r>=0?"+":"-",l=Math.abs(r),u=n(Math.floor(l/60)),m=n(l%60);return`${s.getFullYear()}-${n(s.getMonth()+1)}-${n(s.getDate())} ${n(s.getHours())}:${n(s.getMinutes())}:${n(s.getSeconds())} ${i}${u}${m}`}function Jx(s){try{return JSON.parse(s)}catch{return null}}function yh(s,n){return s.scrollHeight-s.scrollTop-s.clientHeight<=n}function cd(s){const n=typeof s=="string"?s.trim():"";if(!n)return null;const r=n.replace(/(\.\d{3})\d+/,"$1"),i=Date.parse(r);return Number.isFinite(i)?i:null}function Ws(s){if(!Number.isFinite(s))return"";const n=Math.max(0,Math.floor(s/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 Ad(s){return Dp(String(s||""))}function tl(s){const n=String(s||"").trim().toLowerCase();return n==="completed"||n==="promoted"?"ok":n==="failed"?"danger":n==="running"?"info":n==="queued"||n==="awaiting_qa"?"warn":"muted"}function Qx(s,n){return s==="processing"?"queued,running,awaiting_qa":s==="failed"?"failed":s==="completed"&&n==="runs"?"completed,promoted":""}function qo(s,n){const r=s&&typeof s=="object"?s:{},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(),h=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:h||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:Yx(m)}}const ud=1200;function Yx(s){const n=String(s||"");return n?n.length<=ud?n:`${n.slice(0,ud)}
61
+ … [#TRUNCATION: ${ud} of ${n.length} chars; the full last_message is in the run directory]`:null}function Xx(s){const n=String(s||""),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=Jx(m);if(!d||typeof d!="object"){l+=1,i.push({idx:u,type:"raw",payload:null,raw:m});continue}const h=String(d.type||d.event||"event");i.push({idx:u,type:h,payload:d,raw:m})}return{total:r.length,bad:l,events:i,raw:n}}function Zx(s){if(!s)return null;let n=0,r=0,i=0,l=0,u=0;for(const d of s.events){const h=d.payload,x=h&&typeof h.usage=="object"?h.usage:null;x&&(Number.isFinite(Number(x.input_tokens))&&(n+=Number(x.input_tokens)),Number.isFinite(Number(x.cached_input_tokens))&&(r+=Number(x.cached_input_tokens)),Number.isFinite(Number(x.output_tokens))&&(i+=Number(x.output_tokens)));const v=h&&typeof h.item=="object"?h.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 al(s,n=Date.now()){const r=cd(s==null?void 0:s.created_at),i=cd(s==null?void 0:s.started_at),l=cd(s==null?void 0:s.finished_at),u=String((s==null?void 0:s.status)||"").trim().toLowerCase(),m=l??(u==="running"?n:null),d=l!=null,h=r!=null&&i!=null?Math.max(0,i-r):null,x=i!=null&&m!=null?Math.max(0,m-i):null,v=r!=null&&m!=null?Math.max(0,m-r):null,g=!d&&r!=null?Math.max(0,n-r):null;return{is_done:d,queue_delay_ms:h,run_ms:x,total_ms:v,age_ms:g}}function eb(s,n){const r=String(n.package_name).trim()||"{Package}",i=Wp(String(n.title||"").trim()||"{Title}"),l=String(n.summary||"").trim(),u=Fp(n.task_type),m=`# {ID}-${r}: [${qp(u)}] ${i}`.trim();let d=String(s||"");d=d.split("{Package}").join(r).split("{Title}").join(i);const h=d.split(/\r?\n/);let x=!1;for(let E=0;E<h.length;E+=1){const $=String(h[E]||"");if($.trim().startsWith("# ")){h[E]=m,x=!0;break}if($.trim())break}x||(h.unshift("",m),h.shift());const v=`> Created: ${String(n.created_at||"").trim()}`.trim();let g=!1;for(let E=0;E<Math.min(h.length,40);E+=1)if(String(h[E]||"").trim().toLowerCase().startsWith("> created:")){h[E]=v,g=!0;break}if(!g){const E=h.length>1&&!String(h[1]||"").trim()?2:1;h.splice(E,0,v,"")}const w=`> Type: ${u}`.trim();let L=!1;for(let E=0;E<Math.min(h.length,60);E+=1)if(String(h[E]||"").trim().toLowerCase().startsWith("> type:")){h[E]=w,L=!0;break}if(!L){let E=-1;for(let $=0;$<Math.min(h.length,60);$+=1)if(String(h[$]||"").trim().toLowerCase().startsWith("> created:")){E=$;break}if(E>=0){const $=E+1;$<h.length&&!String(h[$]||"").trim()?h.splice($,0,w):h.splice($,0,w,"")}else{const $=h.length>1&&!String(h[1]||"").trim()?2:1;h.splice($,0,w,"")}}if(l){for(let E=0;E<h.length;E+=1)if(String(h[E]||"").trim().toLowerCase()==="## summary"){let $=E+1;for(;$<h.length&&!String(h[$]||"").trim();)$+=1;($<h.length?String(h[$]||""):"").trim().toLowerCase().startsWith("one paragraph describing")?h[$]=l:h.splice(E+1,0,l,"");break}}return d=h.join(`
62
+ `),d.endsWith(`
63
+ `)||(d+=`
64
+ `),d}function Qa(s){return String(s||"").split(/\r?\n/).map(n=>n.trim()).filter(Boolean)}function tb(s){const n=String(s.package_name||"").trim()||"{Package}",r=Wp(String(s.title||"").trim()||"{Title}"),i=Fp(s.task_type),l=String(s.created_at||"").trim()||Td(),u=String(s.diagram||"").trim(),m=String(s.context||"").trim(),d=[];return d.push(`# {ID}-${n}: [${qp(i)}] ${r}`),d.push(""),d.push(`> Created: ${l}`),d.push(`> Type: ${i}`),d.push(""),d.push("## Summary"),d.push(s.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.
65
+ 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"),s.included.length?d.push(...s.included.map(h=>`- ${h}`)):d.push("- "),d.push(""),d.push("### Excluded"),s.excluded.length?d.push(...s.excluded.map(h=>`- ${h}`)):d.push("- "),d.push(""),d.push("## Implementation Plan"),s.plan.length?d.push(...s.plan.map((h,x)=>`${x+1}. ${h}`)):d.push("1. "),d.push(""),d.push("## Dependencies"),s.dependencies.length?d.push(...s.dependencies.map(h=>`- ${h}`)):d.push("- Related backlog items / ADRs"),d.push(""),d.push("## Acceptance Criteria"),s.acceptance.length?d.push(...s.acceptance.map(h=>`- [ ] ${h}`)):d.push("- [ ] Criterion 1 (clear, testable)"),d.push(""),d.push("## Testing (ADR-0019)"),d.push("- Level A:"),s.tests_a.length?d.push(...s.tests_a.map(h=>` - \`${h}\``)):d.push(" - `...`"),d.push("- Level B:"),s.tests_b.length?d.push(...s.tests_b.map(h=>` - \`${h}\``)):d.push(" - `...`"),d.push("- Level C (optional / opt-in):"),s.tests_c.length?d.push(...s.tests_c.map(h=>` - \`${h}\``)):d.push(" - n/a"),d.push(""),d.push("## Related"),d.push("- ADRs:"),d.push("- Code:"),d.push("- Reports:"),s.attachments.length&&(d.push("- Attachments:"),d.push(...s.attachments.map(h=>` - ${h}`))),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(`
66
+ `)}function nb(s,n){const r=n.map(h=>String(h||"").trim()).filter(Boolean);if(!r.length)return s;const i=String(s||"").split(/\r?\n/),l=i.map(h=>h.toLowerCase()),u=l.findIndex(h=>h.trim()==="## related");if(u<0)return`${String(s||"").trimEnd()}
67
+
68
+ ## Related
69
+ - Attachments:
70
+ ${r.map(x=>` - ${x}`).join(`
71
+ `)}
72
+ `;let m=-1;for(let h=u+1;h<i.length;h+=1){const x=l[h].trim();if(x.startsWith("## ")||x.startsWith("---"))break;if(x.startsWith("- attachments:")){m=h;break}}const d=["- Attachments:",...r.map(h=>` - ${h}`)];if(m>=0){let h=m+1;for(;h<i.length&&/^\s+-\s/.test(i[h]);)h+=1;i.splice(h,0,...r.map(x=>` - ${x}`))}else{let h=u+1;for(let x=u+1;x<i.length;x+=1){const v=l[x].trim();if(v.startsWith("## ")||v.startsWith("---")){h=x;break}h=x+1}i.splice(h,0,...d,"")}return i.join(`
73
+ `)}function sb(s,n){const r=sp(s);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 h=[];for(const x of i){const v=d.cells[x];if(!v)continue;const g=l.get(`${m.id}\0${d.id}\0${x}`);(g?g==="grant":!!v.assigned)&&h.push(x)}h.length&&(h.length===i.length?u.push({name:d.id}):u.push({name:d.id,phases:h}))}return u}function ab(s){var A,V;const{gateway:n,entity_name:r}=s,[i,l]=f.useState(null),[u,m]=f.useState(""),[d,h]=f.useState(!1),[x,v]=f.useState([]),[g,w]=f.useState(!1),[L,E]=f.useState(""),[$,T]=f.useState(""),H=f.useCallback(async()=>{h(!0),m("");try{l(await n.entity_skills(r))}catch(Q){l(null),m(String((Q==null?void 0:Q.message)||Q))}finally{h(!1)}},[n,r]);f.useEffect(()=>{v([]),T(""),E(""),H()},[H]);async function z(){if(!(i!=null&&i.matrix))return;const Q=sb(i.matrix,x);if(Q===null){E("Cannot serialize the selection: the matrix payload failed validation — refresh and retry.");return}w(!0),E("");try{const oe=await n.put_entity_skills(r,Q);l(oe),v([]),T("Selection saved — recorded as a host marker on the entity's stream."),setTimeout(()=>T(""),5e3)}catch(oe){E(String((oe==null?void 0:oe.message)||oe))}finally{w(!1)}}const R=Array.isArray((A=i==null?void 0:i.selection)==null?void 0:A.warnings)?i.selection.warnings.map(String):[],M=Array.isArray((V=i==null?void 0:i.resolved)==null?void 0:V.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 H(),disabled:d||g,title:"Reload the resolved view (discards pending edits)",children:d?"Loading…":"Refresh"}),e.jsx("button",{className:"btn",onClick:s.on_close,children:"Close"})]})]}),u?e.jsxs("div",{className:"page_error",children:["Skills unavailable: ",u]}):null,R.length?e.jsx("div",{className:"detail_warn",style:{marginTop:4},children:R.join(" · ")}):null,M.length?e.jsx("div",{className:"entity_skills_resolved",children:M.map(Q=>{const oe=String((Q==null?void 0:Q.name)||""),be=!!(Q!=null&&Q.active),Ne=!!(Q!=null&&Q.blocked),je=!!(Q!=null&&Q.requires_review),Ce=Q==null?void 0:Q.requires_unmet,q=Array.isArray(Ce)?Ce.map(String):Ce&&typeof Ce=="object"?Object.entries(Ce).map(([X,I])=>`${X}: ${String(I)}`):[],te=be?"ok":Ne?"danger":q.length||je?"warn":"muted",Y=be?"active":Ne?"blocked":q.length?"requires unmet":je?"requires review":"inactive",U=[...Array.isArray(Q==null?void 0:Q.reasons)?Q.reasons.map(String):[],...q].join("; ");return e.jsxs("span",{className:`chip mono ${te}`,title:U||void 0,children:[oe," · ",Y]},oe)})}):null,e.jsx(ey,{payload:i==null?void 0:i.matrix,patches:x,onPatchesChange:v,disabled:g||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 z(),disabled:g||!x.length,title:x.length?`Save ${x.length} pending change(s)`:"No pending changes",children:g?"Saving…":x.length?`Save ${x.length} change${x.length>1?"s":""}`:"Save"}),x.length?e.jsx("button",{className:"btn",onClick:()=>v([]),disabled:g,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 rb(s){const n=new Map;for(const r of s){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=al(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 ib(s){const{gateway:n,gateway_connected:r}=s,i=String(s.backlog_advisor_agent||"").trim()||"basic-agent",[l,u]=f.useState(null),[m,d]=f.useState([]),[h,x]=f.useState([]),[v,g]=f.useState(""),[w,L]=f.useState(null),[E,$]=f.useState(!1),[T,H]=f.useState(""),[z,R]=f.useState(!1),[M,A]=f.useState(""),[V,Q]=f.useState(null),oe=f.useRef(0);async function be(){if(!r||E)return;const k=++oe.current;$(!0),H("");try{const[C,re,he]=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!==oe.current)return;u(C),d([...Array.isArray(re==null?void 0:re.requests)?re.requests:[],...Array.isArray(he==null?void 0:he.requests)?he.requests:[]])}catch(C){k===oe.current&&H(String((C==null?void 0:C.message)||C||"Failed to load agents"))}finally{oe.current,$(!1)}try{const C=await n.list_entities();if(k!==oe.current)return;x(Array.isArray(C==null?void 0:C.entities)?C.entities:[]),g("")}catch(C){if(k!==oe.current)return;x([]),g(`#FALLBACK entity registry unavailable: ${String((C==null?void 0:C.message)||C)}`)}try{const C=await n.admin_executors();if(k!==oe.current)return;const re=Array.isArray(C)?C:Array.isArray(C==null?void 0:C.executors)?C.executors:[];L(re)}catch{k===oe.current&&L(C=>C===null?null:C)}try{const C=await n.admin_runtime_config();k===oe.current&&R((C==null?void 0:C.writable)===!0)}catch{k===oe.current&&R(!1)}}async function Ne(){oe.current+=1;try{const k=await n.list_entities();x(Array.isArray(k==null?void 0:k.entities)?k.entities:[]),g("")}catch(k){g(`#FALLBACK entity registry unavailable: ${String((k==null?void 0:k.message)||k)}`)}}async function je(){oe.current+=1;try{const k=await n.admin_executors(),C=Array.isArray(k)?k:Array.isArray(k==null?void 0:k.executors)?k.executors:[];L(C)}catch{}try{u(await n.backlog_exec_config())}catch{}}async function Ce(k){if(M)return;const C=`executor:${k}`;A(C),Q(null);try{await n.admin_runtime_config_update({executor:k}),await je()}catch(re){Q({key:C,text:String((re==null?void 0:re.message)||re||"Executor change refused")})}finally{A("")}}const[q,te]=f.useState(null);async function Y(k,C){if(M)return;const re=String(k.slug||k.name||"").trim();if(!re)return;const he=`entity:${re}`;A(he),Q(null);try{await n.entity_state(re,{state:C,reason:"by the operator via Continuum (Agents & Entities)"}),await Ne()}catch(ce){Q({key:he,text:String((ce==null?void 0:ce.message)||ce||"State change refused")})}finally{A("")}}f.useEffect(()=>{be()},[r]);const U=f.useMemo(()=>rb(m),[m]),X=!!(l!=null&&l.runner_alive),I=String((l==null?void 0:l.executor)||"").trim(),ee=!I||I==="none",ae=ee?"No execution agent":I;return e.jsx("div",{className:"page page_scroll",children:e.jsxs("div",{className:"page_inner page_pad constrained",children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsx("span",{className:"page_hint",children:"The workforce behind the pipeline — the executor is a pluggable seam; this console renders whatever the gateway reports."}),T?e.jsx("span",{className:"page_error mono",children:T}):null,e.jsx("div",{className:"page_toolbar_spacer"}),e.jsx("button",{className:`btn btn_icon ${E?"is_loading":""}`,onClick:()=>void be(),disabled:!r||E,title:"Refresh","aria-label":"Refresh",children:e.jsx(Ue,{name:"refresh",size:16})})]}),e.jsxs("div",{className:"agents_grid",children:[w!==null&&w.length?w.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(Ue,{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"}):z?e.jsx("button",{className:"btn",disabled:!!M||k.available===!1,title:k.available===!1?"Unavailable on the gateway host — the binary is not on its PATH":M&&M!==`executor:${k.id}`?"Another action is in flight":"Make this the gateway's default executor (admin, persisted gateway-side)",onClick:()=>void Ce(k.id),children:M===`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"})}),(V==null?void 0:V.key)===`executor:${k.id}`?e.jsx("div",{className:"detail_warn",children:V.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(Ue,{name:"terminal",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:ae}),e.jsx("div",{className:"entity_card_sub",children:ee?"enable one from Settings → Gateway administration":"execution agent (gateway-configured)"})]}),e.jsx("span",{className:`chip mono ${X?"ok":ee?"warn":"danger"}`,style:{marginLeft:"auto"},children:X?"available":ee?"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(Ue,{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=s.on_open_assistant)==null?void 0:k.call(s)},disabled:!s.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:[h.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&&!h.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,h.length?e.jsx("div",{className:"agents_grid",style:{marginTop:0},children:h.map(k=>{var O,we,$e,Oe,Re,it;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(Ue,{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 C=String(((O=k.state)==null?void 0:O.state)||"unknown").toLowerCase(),re=C==="awake"?"ok":C==="asleep"?"info":C==="paused"?"warn":"muted",ce=String(k.liveness||((we=k.state)==null?void 0:we.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(Ue,{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})]}),ce?e.jsx("span",{className:"chip mono danger",style:{marginLeft:"auto"},title:`The kill switch: served liveness=stopped (state: ${C}). Restore lives on the gateway console.`,children:"STOPPED"}):e.jsx("span",{className:`chip mono ${re}`,style:{marginLeft:"auto"},children:C})]}),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,($e=k.state)!=null&&$e.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 ",(Oe=k.files)!=null&&Oe.spark?"✓":"—"," · memory ",(Re=k.files)!=null&&Re.memory?"✓":"—"," · book ",(it=k.files)!=null&&it.book?"✓":"—"]})]}),e.jsxs("div",{className:"entity_card_actions",children:[!ce&&(C==="asleep"||C==="paused")?e.jsx("button",{className:"btn",disabled:!!M,title:M&&M!==`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 Y(k,"awake"),children:M===`entity:${k.slug||k.name}`?"Waking…":"Wake"}):null,!ce&&C==="awake"?e.jsx("button",{className:"btn",disabled:!!M,title:M&&M!==`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 Y(k,"asleep"),children:M===`entity:${k.slug||k.name}`?"Sending…":"Sleep"}):null,ce?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(Be=>Be===(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:q===(k.name||k.slug)?"Hide skills":"Skills"})]}),(V==null?void 0:V.key)===`entity:${k.slug||k.name}`?e.jsx("div",{className:"detail_warn",children:V.text}):null]},k.entity_id||k.slug)})}):null,q?e.jsx(ab,{gateway:n,entity_name:q,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"}),s.on_open_executions?e.jsx("button",{className:"btn cap_row_action",onClick:s.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"}),s.on_open_executions?e.jsx("button",{className:"btn cap_row_action",onClick:s.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"}),s.on_open_team?e.jsx("button",{className:"btn cap_row_action",onClick:s.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?Ws(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 Hs(s){const n=String(s||"").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 vh(s,n){const r=String(n||"").match(/^(\d{1,4})[-_]/);return!r||!s?null:`${s.toLowerCase()}-${r[1].padStart(4,"0")}`}function ob(s){return String(s||"").replace(/\\/g,"/").split("/").filter(Boolean).pop()||""}function lb(s){const r=String(s||"").replace(/\\/g,"/").match(/(?:^|\/)(proposed|planned|completed|deprecated|recurrent)\/([^/]+\.md)$/i);return r?{kind:r[1].toLowerCase(),filename:r[2]}:null}const cb=/\b([a-z][a-z0-9_.-]{3,60}-\d{4})\b/g,ub=6;function db(s){const n=[];for(const r of String(s||"").matchAll(cb)){const i=r[1];if(Hs(i)&&(n.includes(i)||n.push(i),n.length>=ub))break}return n}function Hp(s,n,r=24){const i=s.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 rl=["P0","P1","P2","P3"],Vp={P0:"P0 · critical",P1:"P1 · high",P2:"P2 · normal",P3:"P3 · low"},Gp=/^>\s*priority:\s*(p[0-3])\b/i,Kp=/^>\s*labels:\s*(.+)$/i;function Yd(s){return String(s||"").split(",").map(n=>n.trim().toLowerCase().replace(/\s+/g,"-")).filter(n=>!!n&&n.length<=40).slice(0,12)}function dd(s,n){const r=[];let i=!1;for(const l of s){const u=l.trim();if(/^#{1,6}\s/.test(u)){i=n.test(u);continue}i&&r.push(l)}return r}const mb=["one paragraph describing","criterion 1 (clear, testable)"];function xh(s){const n=s.trim().toLowerCase();return n?mb.some(r=>n.startsWith(r)):!0}function Oi(s){const n=String(s||"").split(/\r?\n/);let r=null,i=[];for(const h of n.slice(0,60)){const x=h.trim();if(/^##+\s/.test(x))break;const v=Gp.exec(x);v&&!r&&(r=v[1].toUpperCase());const g=Kp.exec(x);g&&!i.length&&(i=Yd(g[1]))}const l=[];for(const h of dd(n,/acceptance criteria/i)){const x=/^\s*[-*]\s*\[( |x|X)\]\s*(.+)$/.exec(h);if(!x)continue;const v=x[2].trim();xh(v)||l.push({text:v,checked:x[1].toLowerCase()==="x"})}const u=[];for(const h of dd(n,/testing/i))for(const x of h.matchAll(/`([^`]+)`/g)){const v=x[1].trim();!v||v==="..."||v.toLowerCase()==="n/a"||u.push(v)}const m=dd(n,/^#{1,6}\s*summary\b/i).map(h=>h.trim()).filter(Boolean),d=m.length>0&&!m.every(xh);return{priority:r,labels:i,acceptance:l,test_commands:u,has_summary:d}}function Xd(s,n){const r=String(s.task_type||"").trim().toLowerCase(),i=[{id:"type",label:`Work type is set (${tr.join(" / ")})`,ok:tr.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}: "${bh(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}: \`${bh(n.test_commands[0],60)}\``:"none found under ## Testing"}];return{ok:i.every(l=>l.ok),checks:i}}function bh(s,n){const r=String(s||"");return r.length<=n?r:`${r.slice(0,Math.max(0,n-1))}…`}function Ld(s){const n=s;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 Md(s,n){const i=[...String(s||"").split(/\r?\n/)];function l(u,m){const d=[];for(let x=0;x<Math.min(i.length,60);x+=1){const v=i[x].trim();if(/^##+\s/.test(v))break;u.test(v)&&d.push(x)}if(d.length){for(let x=d.length-1;x>=1;x-=1)i.splice(d[x],1);m?i[d[0]]=m:i.splice(d[0],1);return}if(!m)return;let h=-1;for(let x=0;x<Math.min(i.length,60);x+=1){const v=i[x].trim();if(v.startsWith("> ")&&(h=x),/^##\s/.test(v))break}if(h<0){const x=i.findIndex(v=>v.trim().startsWith("# "));if(x>=0)h=x;else{i.unshift(m);return}}i.splice(h+1,0,m)}return l(Gp,n.priority?`> Priority: ${n.priority}`:null),l(Kp,n.labels.length?`> Labels: ${n.labels.join(", ")}`:null),i.join(`
74
+ `)}const wh=[{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 Rd(s){const n=String(s||"").trim().toUpperCase();return rl.includes(n)?n:null}function Pd(s){return s.priority!==void 0||s.labels!==void 0}const fb="decision-gate";function hb(s){return Array.isArray(s)&&s.some(n=>String(n||"").trim().toLowerCase()===fb)}function Jp(s,n){return hb(s.labels!==void 0?s.labels:n==null?void 0:n.labels)}function Qp(s){return s.priority!==void 0||s.labels!==void 0}function zd(s,n){return s.priority!==void 0?s.priority:(n==null?void 0:n.priority)??null}function Id(s,n){return s.labels!==void 0?s.labels:(n==null?void 0:n.labels)??[]}const pb=new Set(["queued","running"]);function _b(s){const n=String(s||"").split("/").filter(Boolean);return n.length?n[n.length-1]:""}const gb=/^batch\((\d+)\)$/i;function jh(s){const n=gb.exec(String(s||"").trim());return n?Number(n[1]):null}function yb(s){const n=s.recent_limit??12,r=[],i=new Set;for(const v of s.active_items){const g=String(v.filename||"").trim();g&&i.add(g)}const l=(v,g,w)=>{const L=String(v.backlog_filename||"").trim()||_b(String(v.backlog_relpath||"")),E=jh(L),$=E!==null?"":L;return $&&w&&i.add($),{key:$&&w?`file:${$}`:`req:${v.request_id}`,column:g,title:E!==null?`Batch execution (${E} 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:E!==null?E:void 0}};for(const v of s.active_requests){const g=String(v.status||"").trim().toLowerCase();pb.has(g)?r.push(l(v,"in_progress",!0)):g==="awaiting_qa"&&r.push(l(v,"in_review",!0))}const u=[...s.terminal_requests].sort((v,g)=>{const w=String(v.finished_at||v.started_at||v.created_at||"");return String(g.finished_at||g.started_at||g.created_at||"").localeCompare(w)}),m=new Map;let d=0,h=0;for(const v of u){const g=String(v.status||"").trim().toLowerCase();if(g==="failed"){const w=String(v.backlog_filename||"").trim();w&&jh(w)===null&&m.set(w,(m.get(w)||0)+1),h<n&&(r.push(l(v,"failed",!1)),h+=1)}else(g==="promoted"||g==="completed")&&d<n&&(r.push(l(v,"done",!1)),d+=1)}for(const v of s.planned){const g=String(v.filename||"").trim();!g||i.has(g)||r.push({key:`file:${g}`,column:"ready",title:v.title||g,kind:"planned",filename:g,item_id:v.item_id,package:v.package,task_type:v.task_type,summary:v.summary,recent_failures:m.get(g)||void 0,priority:Pd(v)?Rd(v.priority):void 0,labels:Array.isArray(v.labels)?v.labels:void 0})}for(const v of s.proposed){const g=String(v.filename||"").trim();!g||i.has(g)||r.push({key:`file:${g}`,column:"triage",title:v.title||g,kind:"proposed",filename:g,item_id:v.item_id,package:v.package,task_type:v.task_type,summary:v.summary,priority:Pd(v)?Rd(v.priority):void 0,labels:Array.isArray(v.labels)?v.labels:void 0})}const x=new Map;for(const v of[...s.planned,...s.proposed])x.set(String(v.filename||"").trim(),v);for(const v of r){if(!v.filename||v.kind)continue;const g=x.get(v.filename);g&&(v.title=g.title||v.title,v.item_id=g.item_id,v.package=g.package,v.task_type=g.task_type,v.summary=g.summary)}return r}const vb=200;function xb(s,n){var v;const{live:r,done:i}=n,l=n.work||new Map;if(!r.size&&!i.length&&!l.size)return s;const u=new Set,m=new Set;for(const g of s){if(!g.filename||!g.package)continue;const w=vh(g.package,g.filename);w&&m.add(w)}const d=s.map(g=>{if(g.column!=="ready"||g.kind!=="planned"||!g.filename||!g.package)return g;const w=vh(g.package,g.filename);if(!w)return g;const L=r.get(w);return!L||!L.owner?g:(u.add(w),{...g,column:"in_progress",work_id:w,claim_owner:L.owner,claim_started_at:L.started_at})}),h=new Map;d.forEach((g,w)=>{g.filename&&h.set(g.filename,w)});for(const[g,w]of l){const L=w.card?h.get(ob(w.card)):void 0;if(m.has(g)||L!==void 0){if(L!==void 0){const T=d[L],H={...T,work_id:T.work_id||g,card_path:T.card_path||w.card},z=r.get(g);z!=null&&z.owner&&(u.add(g),H.claim_owner||(H.claim_owner=z.owner,H.claim_started_at=z.started_at)),d[L]=H}continue}if(w.status==="deprecated")continue;const E=r.get(g),$=w.status==="completed"?"done":w.status==="planned"?E!=null&&E.owner?"in_progress":"ready":"triage";E!=null&&E.owner&&u.add(g),d.push({key:`work:${g}`,column:$,title:w.title||g,work_id:g,package:(v=Hs(g))==null?void 0:v.package,summary:w.receipt,card_path:w.card,claim_owner:(E==null?void 0:E.owner)||(w.status==="completed"?w.owner:void 0),claim_started_at:E==null?void 0:E.started_at})}for(const[g,w]of r){if(u.has(g)||!w.owner)continue;const L=Hs(g);d.push({key:`claim:${g}`,column:"in_progress",title:typeof w.task=="string"&&w.task?w.task:g,work_id:L?g:void 0,package:L==null?void 0:L.package,claim_owner:w.owner,claim_started_at:w.started_at})}const x=new Set(d.filter(g=>g.column==="done").map(g=>g.work_id).filter(Boolean));for(const g of i.slice(0,vb)){if(x.has(g.item))continue;const w=Hs(g.item);d.push({key:`claim-done:${g.item}`,column:"done",title:g.item,work_id:w?g.item:void 0,package:w==null?void 0:w.package,claim_owner:g.owner,summary:g.receipt})}return d}function Ii(s){const n=String((s==null?void 0:s.message)??s??"");return/backlog folder not available|backlog browsing not configured/i.test(n)}function kh(s){return String((s==null?void 0:s.message)??s??"").trim().replace(/^[a-z_]+ failed: /,"")}function Zd(s,n,r){const[i,l]=f.useState({status:null,legacy:!1});return f.useEffect(()=>{if(!n)return;let u=!1;return(async()=>{try{const m=await s.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}},[s,n,r]),i}function bb(){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 em(s){const{gateway:n,surface:r,status:i,legacy:l,on_changed:u}=s,[m,d]=f.useState(!1),[h,x]=f.useState(""),[v,g]=f.useState(!1),[w,L]=f.useState(""),[E,$]=f.useState((i==null?void 0:i.writable)??null);f.useEffect(()=>{if((i==null?void 0:i.writable)!==void 0){$(!!i.writable);return}if(!l)return;let R=!1;return n.admin_runtime_config().then(M=>{R||$((M==null?void 0:M.writable)===!0)}).catch(()=>{R||$(!1)}),()=>{R=!0}},[n,i==null?void 0:i.writable,l]);async function T(R){if(!v){g(!0),L("");try{await n.admin_runtime_config_update({triage_repo_root:R}),d(!1),u==null||u()}catch(M){L(kh(M))}finally{g(!1)}}}const H=String((i==null?void 0:i.reason)||"").trim()||(s.error?kh(s.error):""),z=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,H||"the gateway did not say why."]}),E===!0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"callout_actions",style:{marginTop:"10px"},children:[z?e.jsx("button",{className:"btn primary",disabled:v,onClick:()=>void T(z),title:z,children:"Use the gateway's own folder"}):null,e.jsx("button",{className:"btn",disabled:v,onClick:()=>d(R=>!R),children:"Choose a folder…"})]}),z?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:z}),"; it is created with a starter overview and item template."]}):null,m?e.jsxs("form",{className:"field",style:{marginTop:"10px"},onSubmit:R=>{R.preventDefault(),h.trim()&&T(h.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:h,onChange:R=>x(String(R.target.value||"")),placeholder:"/path/to/your/project",autoFocus:!0}),e.jsx("button",{className:"btn primary",type:"submit",disabled:v||!h.trim(),children:v?"Saving…":"Use this folder"})]})]}):null,w?e.jsx("div",{className:"page_error mono",role:"alert",style:{marginTop:"8px"},children:w}):null]}):E===!1?e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:e.jsx(bb,{})}):null]})]})}function wb(s){const{status:n,on_create:r}=s,[i,l]=f.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:()=>{on(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 jb(s){return s.kind?[s.kind]:["completed","planned","proposed"]}function Yp(s){const{gateway:n,can_use_gateway:r,target:i,on_close:l,on_mutated:u,on_open_executions:m}=s,d=!!i,[h,x]=f.useState("spec"),[v,g]=f.useState(""),[w,L]=f.useState(""),[E,$]=f.useState(null),[T,H]=f.useState(!1),[z,R]=f.useState(""),[M,A]=f.useState(!1),[V,Q]=f.useState(""),[oe,be]=f.useState(!1),[Ne,je]=f.useState(""),[Ce,q]=f.useState(""),[te,Y]=f.useState(!1),[U,X]=f.useState([]),[I,ee]=f.useState(!1),[ae,k]=f.useState(null),[C,re]=f.useState(null),[he,ce]=f.useState(""),[O,we]=f.useState(!1),[$e,Oe]=f.useState(""),[Re,it]=f.useState({}),Be=f.useMemo(()=>Oi(v),[v]);f.useEffect(()=>{if(!d||!i)return;const W=ie=>{ie.key!=="Escape"||ie.defaultPrevented||kb(ie.target)||M||document.querySelector(".modal_backdrop")||(ie.preventDefault(),l())};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[d,i,l,M]),f.useEffect(()=>{!d||!i||(x(i.initial_tab||"spec"),A(!1),R(""),Oe(""),ce(""),it({}),ue(!1),k(null),re(null),$(null),ot(i),Ve(i))},[d,i==null?void 0:i.filename,i==null?void 0:i.kind,i==null?void 0:i.request_id]);async function ot(W){if(!W.filename){g(""),L("");return}H(!0);try{let ie=null,Se=null;for(const F of jb(W))try{const de=await n.backlog_content(F,W.filename);ie={kind:F,text:String((de==null?void 0:de.content)||"")};break}catch(de){Se=de}if(!ie)throw Se||new Error("Spec not found in any backlog kind");$(ie.kind),g(ie.text),L(await Ad(ie.text));const Je=Oi(ie.text);je(Je.priority||""),q(Je.labels.join(", "))}catch(ie){R(String((ie==null?void 0:ie.message)||ie||"Failed to load the spec"))}finally{H(!1)}}async function Ve(W){ee(!0);try{const[ie,Se]=await Promise.all([n.backlog_exec_requests({status:"queued,running,awaiting_qa",limit:200}),n.backlog_exec_requests({status:"promoted,completed,failed",limit:200})]),F=[...Array.isArray(ie==null?void 0:ie.requests)?ie.requests:[],...Array.isArray(Se==null?void 0:Se.requests)?Se.requests:[]].filter(ye=>W.filename&&String(ye.backlog_filename||"").trim()===W.filename||ye.request_id===W.request_id);F.sort((ye,xe)=>String(xe.created_at||"").localeCompare(String(ye.created_at||""))),X(F);const de=F.find(ye=>String(ye.status||"").toLowerCase()==="awaiting_qa")||null;if(k(de),de)try{const ye=await n.backlog_exec_request(de.request_id);re((ye==null?void 0:ye.payload)??null)}catch{re(null)}}catch{X([])}finally{ee(!1)}}async function ct(){if(!i||oe)return;const W=E||i.kind;if(W){be(!0),R("");try{const ie=await n.backlog_update({kind:W,filename:i.filename,content:V,expected_sha256:w||null}),Se=V.endsWith(`
75
+ `)?V:`${V}
76
+ `;g(Se),L(String((ie==null?void 0:ie.sha256)||"")),A(!1),await u()}catch(ie){R(String((ie==null?void 0:ie.message)||ie||"Save failed"))}finally{be(!1)}}}async function et(){if(!i||te)return;const W=E||i.kind;if(W){Y(!0),R("");try{const ie=Md(v,{priority:Ne||null,labels:Yd(Ce)}),Se=await n.backlog_update({kind:W,filename:i.filename,content:ie,expected_sha256:w||null});g(ie.endsWith(`
77
+ `)?ie:`${ie}
78
+ `),L(String((Se==null?void 0:Se.sha256)||"")),await u()}catch(ie){R(String((ie==null?void 0:ie.message)||ie||"Metadata save failed"))}finally{Y(!1)}}}const[fe,ue]=f.useState(!1);async function Ee(W){if(!(!ae||O)){if(W==="feedback"&&!he.trim()){Oe("Feedback is required.");return}we(!0),Oe("");try{W==="feedback"?await n.backlog_exec_feedback({request_id:ae.request_id,feedback:he}):W==="promote"?await n.backlog_exec_promote({request_id:ae.request_id,redeploy:!0}):await n.backlog_exec_deploy_uat({request_id:ae.request_id}),ce(""),ue(!1),i&&await Ve(i),await u()}catch(ie){Oe(String((ie==null?void 0:ie.message)||ie||"QA action failed"));try{const Se=await n.backlog_exec_request(ae.request_id);re((Se==null?void 0:Se.payload)??null)}catch{}}finally{we(!1)}}}if(!d||!i)return null;const se=Be.acceptance.filter((W,ie)=>!Re[`${ie}:${W.text}`]).length;return e.jsx("div",{className:"drawer_backdrop",onMouseDown:W=>{W.target===W.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:[E||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:()=>on(`docs/backlog/${E||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 ${h==="spec"?"active":""}`,onClick:()=>x("spec"),children:"Spec"}),e.jsxs("button",{className:`tab ${h==="runs"?"active":""}`,onClick:()=>x("runs"),children:["Runs ",U.length?`(${U.length})`:""]}),e.jsxs("button",{className:`tab ${h==="review"?"active":""}`,onClick:()=>x("review"),children:["Review",ae?" ●":""]})]}),e.jsxs("div",{className:"drawer_body work_drawer_body",children:[z?e.jsx("div",{className:"mono board_error",children:z}):null,h==="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:Ne,onChange:W=>je(W.target.value),disabled:te,title:"Priority",children:[e.jsx("option",{value:"",children:"priority: unset"}),rl.map(W=>e.jsx("option",{value:W,children:Vp[W]},W))]}),e.jsx("input",{value:Ce,onChange:W=>q(W.target.value),placeholder:"labels (comma-separated; sprints: sprint-29)",disabled:te}),e.jsx("button",{className:"btn",onClick:()=>void et(),disabled:te||!r||T,children:te?"Saving…":"Save metadata"}),M?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>A(!1),disabled:oe,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void ct(),disabled:oe,children:oe?"Saving…":"Save spec"})]}):e.jsx("button",{className:"btn",onClick:()=>{Q(v),A(!0)},disabled:T,children:"Edit spec"})]}):null,T?e.jsx("div",{className:"mono muted",children:"Loading…"}):M?e.jsx("textarea",{className:"mono work_spec_editor",value:V,onChange:W=>Q(W.target.value),rows:24}):v?e.jsxs(e.Fragment,{children:[e.jsx(Qn,{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,h==="runs"?e.jsxs(e.Fragment,{children:[I?e.jsx("div",{className:"mono muted",children:"Loading…"}):null,!I&&!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(W=>{const ie=String(W.status||"").toLowerCase(),Se=al(W);return e.jsxs("div",{className:"work_run_row",children:[e.jsx("span",{className:`chip mono ${tl(ie)}`,children:ie}),e.jsx("span",{className:"mono muted",children:_a(W.request_id,18)}),e.jsx("span",{className:"mono muted",children:W.created_at?new Date(W.created_at).toLocaleString():""}),e.jsx("span",{className:"mono muted",children:Se.run_ms!=null?`ran ${Ws(Se.run_ms)}`:""}),W.target_agent?e.jsx("span",{className:"chip mono muted",children:W.target_agent}):null,ie==="running"||ie==="queued"||ie==="awaiting_qa"?e.jsx("button",{className:"btn",onClick:()=>m(W.request_id),children:ie==="awaiting_qa"?"View logs":"Follow live"}):null]},W.request_id)})]}):null,h==="review"?ae?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."}),Be.acceptance.length?e.jsx("div",{className:"work_dod_list",children:Be.acceptance.map((W,ie)=>e.jsxs("label",{className:"work_dod_item",children:[e.jsx("input",{type:"checkbox",checked:!!Re[`${ie}:${W.text}`],onChange:Se=>it(Je=>({...Je,[`${ie}:${W.text}`]:Se.target.checked}))}),e.jsx("span",{children:W.text})]},`dod:${ie}:${W.text}`))}):e.jsx("div",{className:"mono muted",children:"This spec declares no acceptance criteria — review against the diff and logs."}),(()=>{const W=String((C==null?void 0:C.execution_mode)||"uat").toLowerCase(),ie=String((C==null?void 0:C.candidate_relpath)||"").trim(),Se=C==null?void 0:C.promotion_report,Je=!!(Se!=null&&Se.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: ",W,ie?` • candidate: ${ie}`:""]}),e.jsx("button",{className:"btn",onClick:()=>m(ae.request_id),title:"Open this run's logs and events in Executions",children:"View run logs"})]}),Je?e.jsxs("div",{className:"mono board_error",style:{marginTop:"6px"},children:["Promotion blocked: ",String((Se==null?void 0:Se.reason)||"conflicts")," — iterate on top of current prod or resolve manually."]}):null]})})(),Be.acceptance.length&&se>0?e.jsxs("div",{className:"mono work_drawer_warn",style:{marginTop:"8px"},children:[se," acceptance criteri",se===1?"on":"a"," unconfirmed — promoting anyway is an override."]}):null,e.jsx("textarea",{value:he,onChange:W=>ce(W.target.value),rows:3,placeholder:"QA feedback (what to change / fix)…",style:{width:"100%",marginTop:"10px"},disabled:O}),$e?e.jsx("div",{className:"mono board_error",children:$e}):null,e.jsxs("div",{className:"row",style:{gap:8,marginTop:"10px",flexWrap:"wrap",alignItems:"center"},children:[e.jsx("button",{className:"btn",onClick:()=>void Ee("deploy_uat"),disabled:O,children:"Restart UAT"}),fe?e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn danger",onClick:()=>void Ee("promote"),disabled:O,children:["Confirm: promote to prod",se>0?` (${se} unconfirmed)`:""," + redeploy"]}),e.jsx("button",{className:"btn",onClick:()=>ue(!1),disabled:O,children:"Cancel"})]}):e.jsx("button",{className:"btn primary",onClick:()=>ue(!0),disabled:O,children:Be.acceptance.length&&se>0?"Promote (override)…":"Approve → promote…"}),e.jsx("button",{className:"btn",onClick:()=>void Ee("feedback"),disabled:O,children:"Iterate (send feedback)"})]})]}):e.jsx("div",{className:"mono muted",children:"Nothing awaiting review for this item."}):null]})]})})}function kb(s){const n=s;return!n||typeof n.closest!="function"?!1:!!n.closest("input, textarea, select, [contenteditable=''], [contenteditable='true']")}function Dr(){return Zo()}async function Sb(s){const n=[],r=[];for(const i of s){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}]
79
+
80
+ \`\`\`
81
+ ${u}
82
+ \`\`\``)}catch{n.push(`[attached file: ${l}] (unreadable in browser)`)}}return{picked:r,text:n.join(`
83
+
84
+ `)}}function Nb(s){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:h,focus_type:x}=s,[v,g]=f.useState(!1),[w,L]=f.useState([]),[E,$]=f.useState(""),[T,H]=f.useState(!1),[z,R]=f.useState(""),[M,A]=f.useState(!1),[V,Q]=f.useState([]),oe=f.useRef(null),be=f.useRef(null),Ne=String(s.voice_session_id||"").trim()||"abstractcontinuum_backlog_advisor",[je,Ce]=f.useState(""),[q,te]=f.useState("");f.useEffect(()=>{(async()=>{try{const C=await Qd(Ne);Ce(C)}catch{Ce("")}})()},[Ne]);const Y=f.useMemo(()=>{if(!r)return{};const C=String(je||"").trim(),re=Ne;return{tts:async he=>{if(!C)throw new Error("Voice store not available (missing run_id).");const ce=await n.voice_tts(C,{text:he,request_id:Dr()}),O=ce==null?void 0:ce.audio_artifact,we=O&&typeof O=="object"&&!Array.isArray(O)?String(O.$artifact||"").trim():"";if(!we)throw new Error("TTS failed: missing audio artifact");return await(await n.download_run_artifact_content(C,we)).arrayBuffer()},transcribe:async(he,ce)=>{if(!C)throw new Error("Voice input unavailable (missing run_id).");const O=String(ce||he.type||"").toLowerCase(),we=O.includes("mp4")?"m4a":O.includes("ogg")?"ogg":O.includes("wav")?"wav":"webm",$e=new File([he],`recording.${we}`,{type:O||"audio/webm"}),Oe=await n.attachments_upload(re,$e,{filename:$e.name,content_type:$e.type}),Re=await n.audio_transcribe(C,{audio_artifact:Oe,request_id:Dr()});return String((Re==null?void 0:Re.text)||"").trim()}}},[r,n,je,Ne]),U=dp({...Y,on_error:te,on_transcript:C=>{const re=String(C||"").trim();re&&($(he=>{const ce=String(he||"");return ce.trim()?`${ce.trimEnd()}
85
+ ${re}`:re}),window.setTimeout(()=>{var he;return(he=oe.current)==null?void 0:he.focus()},0))}});f.useEffect(()=>{if(!v)return;const C=re=>{re.key==="Escape"&&(k(),g(!1))};return window.addEventListener("keydown",C),setTimeout(()=>{var re;return(re=oe.current)==null?void 0:re.focus()},0),()=>window.removeEventListener("keydown",C)},[v]);async function X(){if(T||!r)return;if(U.voice_ptt_busy){te("Wait for transcription to finish.");return}R(""),te("");const C=E.trim();if(!C)return;const re={id:Dr(),role:"user",content:C,ts:new Date().toISOString()},he=[...w,re];L(he),$(""),H(!0);try{const ce=await n.backlog_advisor({messages:he.map(Oe=>({role:Oe.role,content:Oe.content})),provider:l||null,model:u||null,thinking:m||null,agent:d||null,include_trace:M,focus_kind:h,focus_type:x}),O=M&&Array.isArray(ce==null?void 0:ce.tool_trace)?ce.tool_trace:[],we=String((ce==null?void 0:ce.run_id)||"").trim(),$e=String((ce==null?void 0:ce.reply)||"").trim();if(M&&O.length){const Oe={id:Dr(),role:"system",title:"Tool execution",level:"info",ts:new Date().toISOString(),content:JSON.stringify({run_id:we||null,tool_trace:O},null,2)};L(Re=>[...Re,Oe])}$e&&L(Oe=>[...Oe,{id:Dr(),role:"assistant",content:$e,ts:new Date().toISOString()}])}catch(ce){R(String((ce==null?void 0:ce.message)||ce||"Backlog advisor failed"))}finally{H(!1)}}async function I(C){var O;const re=Array.from(C||[]);if(!re.length)return;const{picked:he,text:ce}=await Sb(re);Q(we=>[...he,...we].slice(0,12)),$(we=>{const $e=String(we||"").trim();return $e?`${$e}
86
+
87
+ ${ce}`:ce});try{(O=oe.current)==null||O.focus()}catch{}}function ee(C){const re=String(C.id||C.ts||"").trim(),he=String(C.content||"").trim();!re||!he||(te(""),U.toggle_tts(re,he))}function ae(C){const re=String(C.id||C.ts||"").trim(),he=U.tts_playback;return!re||!he.key||he.key!==re?"idle":he.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:()=>{g(C=>{const re=!C;return re||k(),re})},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:C=>{C.target===C.currentTarget&&(k(),g(!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 ${M?"primary":""}`,onClick:()=>A(C=>!C),disabled:T,title:M?"Hide tool execution":"Show tool execution","aria-label":M?"Hide tool execution":"Show tool execution",children:[e.jsx(Ue,{name:"terminal",size:16}),i?null:M?"Tools on":"Tools"]}),e.jsx("button",{className:"btn",onClick:()=>L([]),disabled:T||!w.length,children:"Clear"}),e.jsx("button",{className:"btn",onClick:()=>{k(),g(!1)},children:"Close"})]})]}),e.jsxs("div",{className:"drawer_body",children:[e.jsx(zc,{messages:w,className:"drawer_chat_thread",messageProps:U.tts_supported&&r&&je.trim()?{onSpeakToggle:ee,getSpeakState:ae,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:be,type:"file",multiple:!0,style:{display:"none"},onChange:C=>{const re=Array.from(C.currentTarget.files||[]);C.currentTarget.value="",re.length&&I(re)}}),e.jsx(cl,{ref:oe,value:E,onChange:$,onSubmit:()=>void X(),placeholder:"Message to backlog advisor…",disabled:!r,busy:T||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||!je.trim()||T||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)":_h()?"Voice recording is not supported in this browser":ph,"aria-label":"Voice input",onPointerDown:C=>{var re,he;if(!(!r||!je.trim()||T||U.voice_ptt_busy||!U.voice_ptt_supported)){C.preventDefault();try{(he=(re=C.currentTarget)==null?void 0:re.setPointerCapture)==null||he.call(re,C.pointerId)}catch{}U.start_voice_ptt_recording()}},onPointerUp:C=>{C.preventDefault(),U.stop_voice_ptt_recording()},onPointerCancel:C=>{C.preventDefault(),U.stop_voice_ptt_recording()},children:[e.jsx(Ue,{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 C;return(C=be.current)==null?void 0:C.click()},disabled:T,title:"Attach a local file to your message","aria-label":"Attach file",children:[e.jsx(Ue,{name:"paperclip",size:16}),i?null:"Attach"]})]})}),V.length?e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["Last attached: ",V[0]]}):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,q?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:q}):null,_h()?null:e.jsx("div",{className:"muted","data-testid":"voice-https-hint",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:ph}),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 nr({open:s,title:n,children:r,actions:i,variant:l="default",onClose:u}){if(f.useEffect(()=>{if(!s)return;const d=h=>{h.key!=="Escape"||h.defaultPrevented||(h.preventDefault(),u())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s,u]),!s)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 Cb(s){const{readiness:n,server_refused:r,on_open_spec:i}=s;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 Xp(s){const{exec_cfg:n,with_setup:r}=s,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(`
88
+ `)}),e.jsx("button",{className:"btn",style:{marginTop:"4px"},onClick:()=>on(i.join(`
89
+ `)),children:"Copy setup"})]})]}):null]})}function Zp(s){const{value:n,onChange:r,disabled:i,inplace_warning:l,uat_note:u}=s;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 $b=["minimal","low","medium","high"];function e_(s){const{executors:n,value:r,onChange:i,disabled:l}=s;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 Eb(s){const{exec_cfg:n,model:r,set_model:i,effort:l,set_effort:u,disabled:m}=s;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"}),$b.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 t_(s){const{open:n,target:r,execute_mode:i,set_execute_mode:l,action_loading:u,action_error:m,exec_cfg:d,exec_cfg_loading:h,exec_cfg_error:x,on_confirm:v,on_close:g}=s,w=s.readiness??null,L=s.show_readiness===!0,[E,$]=Wt.useState(""),[T,H]=Wt.useState(""),[z,R]=Wt.useState(""),M=(r==null?void 0:r.filename)||"";Wt.useEffect(()=>{$(""),H(""),R("")},[M]);const A=E.trim()||T||z?{executor:z||void 0,target_model:E.trim()||void 0,target_reasoning_effort:T||void 0}:void 0;return e.jsxs(nr,{open:n,title:"Execute backlog item?",onClose:g,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:g,disabled:u,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>v(A),disabled:u||h||!r||(d==null?void 0:d.can_execute)!==!0,children:u?"Executing…":L&&!w?"Execute (readiness unknown)":w&&!w.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(e_,{executors:s.executors??null,value:z,onChange:R,disabled:u}),e.jsx(Eb,{exec_cfg:d,model:E,set_model:$,effort:T,set_effort:H,disabled:u}),L?e.jsx(Cb,{readiness:w,server_refused:s.server_refused,on_open_spec:s.on_open_spec}):null,e.jsx(Zp,{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."}),h?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:"Checking worker…"}):null,!h&&(d==null?void 0:d.can_execute)!==!0?e.jsx(Xp,{exec_cfg:d,with_setup:!0}):null,x?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:x}):null,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 Tb(s){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:h,exec_cfg_error:x,on_confirm:v,on_close:g}=s,[w,L]=Wt.useState("");return Wt.useEffect(()=>{n||L("")},[n]),e.jsxs(nr,{open:n,title:"Execute batch (single context)?",onClose:g,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:g,disabled:u,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>v(w||void 0),disabled:u||h||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(e_,{executors:s.executors??null,value:w,onChange:L,disabled:u}),e.jsx(Zp,{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(E=>e.jsxs("div",{children:["- docs/backlog/planned/",E.filename]},`batchitem:${E.filename}`))}):null,h?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:"Checking worker…"}):null,!h&&(d==null?void 0:d.can_execute)!==!0?e.jsx(Xp,{exec_cfg:d}):null,x?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:x}):null,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 Ab(s){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:h,merge_summary:x,set_merge_summary:v,merge_loading:g,merge_error:w,on_confirm:L,on_close:E}=s;return e.jsxs(nr,{open:n,title:"Merge planned items into master backlog?",onClose:E,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:E,disabled:g,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:L,disabled:g||r.length<2||!d.trim()||!i.trim(),children:g?"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:tr.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:$=>h($.target.value),placeholder:"Master backlog"})]}),e.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[e.jsx("label",{children:"Summary (optional)"}),e.jsx("textarea",{value:x,onChange:$=>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,w?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:w}):null]})}function tm(s){const n=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(s).matches,[r,i]=f.useState(n);return f.useEffect(()=>{var m;if(typeof window>"u"||typeof window.matchMedia!="function")return;const l=window.matchMedia(s),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)}},[s]),r}function n_(s,n){const[r,i]=f.useState(null);return f.useEffect(()=>{if(!n){i(null);return}let l=!1;return(async()=>{try{const u=await s.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 nm(s){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:h}=s,[x,v]=f.useState(null),[g,w]=f.useState(!1),[L,E]=f.useState(""),[$,T]=f.useState([]),[H,z]=f.useState(!1),[R,M]=f.useState(""),[A,V]=f.useState(null),[Q,oe]=f.useState(null),[be,Ne]=f.useState(!1),[je,Ce]=f.useState(""),[q,te]=f.useState(""),[Y,U]=f.useState(!1),[X,I]=f.useState(""),[ee,ae]=f.useState("events"),[k,C]=f.useState(""),[re,he]=f.useState(!1),[ce,O]=f.useState(""),[we,$e]=f.useState(!1),[Oe,Re]=f.useState(!0),it=f.useRef(null),Be=f.useRef(!0),ot=f.useRef(null),Ve=f.useRef(!1),ct=f.useRef(!1),et=1e6,fe=f.useMemo(()=>ee!=="events"?null:Xx(k),[k,ee]),ue=f.useMemo(()=>Zx(fe),[fe]),Ee=al(A);function se(){V(null),oe(null),Ce(""),C(""),O(""),$e(!1),ot.current=null}async function W(){if(!r)return null;if(g)return x;E(""),w(!0);try{const xe=await n.backlog_exec_config();return v(xe),xe}catch(xe){const ke=String((xe==null?void 0:xe.message)||xe||"Failed to load backlog exec config");return E(ke),v(null),null}finally{w(!1)}}async function ie(xe,ke,J){if(ct.current)return $;ct.current=!0,J!=null&&J.background||z(!0);const P=xe||i;try{const Z=Qx(P,ke||l),Pe=await n.backlog_exec_requests({status:Z,limit:200}),Fe=Array.isArray(Pe==null?void 0:Pe.requests)?Pe.requests:[];M(""),T(Fe);const Xe=String((A==null?void 0:A.status)||"").trim().toLowerCase(),dt=Xe==="failed"||Xe==="completed"||Xe==="promoted";if(P==="processing"&&(A!=null&&A.request_id)&&!dt&&!Fe.some(ft=>ft.request_id===A.request_id))try{const ft=await n.backlog_exec_request(A.request_id),Le=ft==null?void 0:ft.payload,st=String((Le==null?void 0:Le.status)||"").trim().toLowerCase();(st==="failed"||st==="completed"||st==="promoted")&&(h(st),oe(Le),V(qo(Le,A.request_id)))}catch{}if(A!=null&&A.request_id){const ft=Fe.find(Le=>Le.request_id===A.request_id)||null;ft&&V(ft)}return Fe}catch(Z){return M(String((Z==null?void 0:Z.message)||Z||"Failed to load backlog exec requests")),[]}finally{ct.current=!1,J!=null&&J.background||z(!1)}}async function Se(xe){if(r){V(xe),m&&d("detail"),oe(null),Ce(""),Ne(!0),I(""),te(""),C(""),O(""),$e(!1),ot.current=null;try{const ke=await n.backlog_exec_request(xe.request_id);oe((ke==null?void 0:ke.payload)??null)}catch(ke){Ce(String((ke==null?void 0:ke.message)||ke||"Failed to load request"))}finally{Ne(!1)}}}async function Je(xe){if(!r)return;const ke=String((A==null?void 0:A.request_id)||"").trim();if(!ke||Y)return;const J=String(q||"");if(!J.trim()){I("Feedback is required.");return}I(""),U(!0);try{const P=await n.backlog_exec_feedback({request_id:ke,feedback:J}),Z=(P==null?void 0:P.payload)??null;oe(Z),Z&&V(qo(Z,ke)),te(""),await xe()}catch(P){I(String((P==null?void 0:P.message)||P||"Failed to send feedback"))}finally{U(!1)}}async function F(xe){if(!r)return;const ke=String((A==null?void 0:A.request_id)||"").trim();if(ke&&!Y){I(""),U(!0);try{const J=await n.backlog_exec_promote({request_id:ke,redeploy:!0}),P=(J==null?void 0:J.payload)??null;oe(P),P&&V(qo(P,ke)),te(""),await xe()}catch(J){I(String((J==null?void 0:J.message)||J||"Failed to promote to prod"));try{const P=await n.backlog_exec_request(ke),Z=(P==null?void 0:P.payload)??null;oe(Z),Z&&V(qo(Z,ke))}catch{}}finally{U(!1)}}}async function de(xe){if(!r)return;const ke=String((A==null?void 0:A.request_id)||"").trim();if(ke&&!Y){I(""),U(!0);try{const J=await n.backlog_exec_deploy_uat({request_id:ke}),P=(J==null?void 0:J.payload)??null;oe(P),P&&V(qo(P,ke)),await xe()}catch(J){I(String((J==null?void 0:J.message)||J||"Failed to deploy to UAT"))}finally{U(!1)}}}async function ye(xe){if(!r)return;const ke=String((xe==null?void 0:xe.request_id)||(A==null?void 0:A.request_id)||"").trim();if(!ke)return;const J=(xe==null?void 0:xe.name)||ee,P=typeof(xe==null?void 0:xe.max_bytes)=="number"&&Number.isFinite(xe.max_bytes)?Number(xe.max_bytes):16e4;if(!Ve.current){Ve.current=!0,O(""),he(!0);try{const Z=`${ke}::${String(J)}`,Pe=ot.current,Fe=Pe!==null&&Pe.key===Z,Xe=await n.backlog_exec_log_tail({request_id:ke,name:String(J),max_bytes:P,...Fe?{after_bytes:Pe.offset}:{}}),dt=typeof(Xe==null?void 0:Xe.next_offset)=="number"&&Number.isFinite(Xe.next_offset),ft=String((Xe==null?void 0:Xe.content)||"");Fe&&dt&&(Xe==null?void 0:Xe.reset)!==!0?(ft&&C(Le=>{let st=Le+ft;if(st.length>et){const pt=st.length-et,Dt=st.indexOf(`
90
+ `,pt);st=Dt>=0?st.slice(Dt+1):st.slice(pt),$e(!0)}return st}),ot.current={key:Z,offset:Number(Xe.next_offset)}):(C(ft),$e(!!(Xe!=null&&Xe.truncated)),ot.current=dt?{key:Z,offset:Number(Xe.next_offset)}:null)}catch(Z){O(String((Z==null?void 0:Z.message)||Z||"Failed to load logs"))}finally{Ve.current=!1,he(!1)}}}return f.useEffect(()=>{r&&u&&W()},[u,r]),f.useEffect(()=>{if(!r||!u)return;const ke=setInterval(()=>{n.is_backing_off()||ie(i,void 0,{background:!0})},i==="processing"?2e3:5e3);return()=>clearInterval(ke)},[i,l,r,u,A==null?void 0:A.request_id]),f.useEffect(()=>{r&&u&&A!=null&&A.request_id&&ye({request_id:A.request_id,name:ee})},[A==null?void 0:A.request_id,ee,u,r]),f.useEffect(()=>{Be.current=!0},[A==null?void 0:A.request_id,ee]),f.useEffect(()=>{if(!it.current||!Be.current)return;const ke=window.requestAnimationFrame(()=>{const J=it.current;J&&(J.scrollTop=J.scrollHeight)});return()=>window.cancelAnimationFrame(ke)},[k,ee,A==null?void 0:A.request_id]),f.useEffect(()=>{if(!r||!u||!(A!=null&&A.request_id))return;const xe=String(A.status||"").trim().toLowerCase();if(xe==="completed"||xe==="promoted"||xe==="failed"||xe!=="running"&&Oe!==!0)return;const J=setInterval(()=>{n.is_backing_off()||ye({request_id:A.request_id,name:ee})},xe==="running"?1500:2500);return()=>clearInterval(J)},[A==null?void 0:A.request_id,A==null?void 0:A.status,ee,u,r,Oe]),{exec_cfg:x,exec_cfg_loading:g,exec_cfg_error:L,exec_requests:$,exec_loading:H,exec_error:R,exec_selected:A,set_exec_selected:V,exec_detail:Q,set_exec_detail:oe,exec_detail_loading:be,exec_detail_error:je,set_exec_detail_error:Ce,exec_qa_feedback:q,set_exec_qa_feedback:te,exec_qa_loading:Y,exec_qa_error:X,exec_log_name:ee,set_exec_log_name:ae,exec_log_text:k,exec_log_loading:re,exec_log_error:ce,exec_log_truncated:we,exec_log_auto:Oe,set_exec_log_auto:Re,exec_log_scroll_el_ref:it,exec_log_follow_ref:Be,parsed_exec_events:fe,event_stats:ue,time_stats:Ee,clear_exec_selection:se,load_exec_config:W,refresh_exec_list:ie,load_exec_request:Se,exec_send_feedback:Je,exec_promote_to_prod:F,exec_deploy_uat_now:de,load_exec_log_tail:ye}}const Sh=[{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 Lb(s){var en;const n=s.gateway,r=s.gateway_connected,i=String(s.maintenance_ai_provider||"").trim(),l=String(s.maintenance_ai_model||"").trim(),u=String(s.maintenance_ai_reasoning||"").trim(),m=String(s.backlog_advisor_agent||"").trim()||"basic-agent",d=s.default_execution_mode==="inplace"?"inplace":"uat",h=tm("(max-width: 767.98px)"),[x,v]=f.useState("planned"),[g,w]=f.useState([]),[L,E]=f.useState(!1),[$,T]=f.useState(""),[H,z]=f.useState(""),[R,M]=f.useState("all"),[A,V]=f.useState(""),[Q,oe]=f.useState(new Set),be=f.useRef(0),[Ne,je]=f.useState(null),[Ce,q]=f.useState([]),[te,Y]=f.useState(null),[U,X]=f.useState(d),[I,ee]=f.useState(!1),ae=n_(n,r),[k,C]=f.useState(""),[re,he]=f.useState(!1),[ce,O]=f.useState(d),[we,$e]=f.useState(!1),[Oe,Re]=f.useState(""),[it,Be]=f.useState(!1),[ot,Ve]=f.useState(!1),[ct,et]=f.useState("framework"),[fe,ue]=f.useState("task"),[Ee,se]=f.useState(""),[W,ie]=f.useState(""),[Se,Je]=f.useState(!1),[F,de]=f.useState(""),ye=nm({gateway:n,can_use_gateway:r,kind:"planned",completed_view:"tasks",is_exec_view:!1,is_compact_layout:h,set_compact_pane:()=>{},on_status_transfer:()=>{}});async function xe(){if(!r)return;const ge=++be.current;E(!0),T("");try{const Te=await n.backlog_list(x);if(ge!==be.current)return;w(Array.isArray(Te==null?void 0:Te.items)?Te.items:[])}catch(Te){if(ge!==be.current)return;w([]),T(String((Te==null?void 0:Te.message)||Te||"Failed to load backlog"))}finally{ge===be.current&&E(!1)}if(x==="planned")try{const Te=await n.backlog_exec_active_items();if(ge!==be.current)return;const Ye=new Set;for(const vt of Array.isArray(Te==null?void 0:Te.items)?Te.items:[]){const gt=String((vt==null?void 0:vt.filename)||"").trim();gt&&Ye.add(gt)}oe(Ye)}catch{ge===be.current&&oe(new Set)}else oe(new Set)}f.useEffect(()=>{q([]),V(""),xe()},[x,r]),f.useEffect(()=>{q(ge=>{const Te=new Set(g.map(vt=>String(vt.filename||"").trim())),Ye=ge.filter(vt=>Te.has(vt));return Ye.length===ge.length?ge:Ye})},[g]);const ke=f.useMemo(()=>{const ge=H.trim().toLowerCase(),Te=R.trim().toLowerCase();return g.filter(Ye=>{if(Te&&Te!=="all"&&sl(Ye.task_type)!==Te)return!1;if(!ge)return!0;const vt=Array.isArray(Ye.labels)?Ye.labels.join(" "):"";return`${Ye.item_id||""} ${Ye.package||""} ${Ye.title||""} ${Ye.task_type||""} ${Ye.summary||""} ${Ye.filename||""} ${vt} ${Ye.priority||""}`.toLowerCase().includes(ge)})},[g,H,R]),J=f.useMemo(()=>g.filter(ge=>Ce.includes(String(ge.filename||"").trim())),[g,Ce]),P=Ii($),[Z,Pe]=f.useState(0),Fe=Zd(n,r&&P,Z);function Xe(ge){je({filename:String(ge.filename||""),kind:x,title:ge.title||ge.filename,initial_tab:"spec"})}async function dt(ge,Te){V("");try{await n.backlog_move({from_kind:x,to_kind:Te,filename:String(ge.filename||"")}),await xe()}catch(Ye){V(String((Ye==null?void 0:Ye.message)||Ye||"Move failed"))}}async function ft(ge){const Te=String(ge.filename||"").trim();if(!Te)return;let Ye=null;try{const vt=await n.backlog_content("planned",Te);Ye=Xd({task_type:ge.task_type},Oi(String((vt==null?void 0:vt.content)||"")))}catch{Ye=null}C(""),X(d),Y({filename:Te,title:ge.title||Te,readiness:Ye}),ye.load_exec_config()}async function Le(ge){if(!(!te||I)){ee(!0),C("");try{const Te=ye.exec_cfg||await ye.load_exec_config();if(!Te||Te.can_execute!==!0){C((Te==null?void 0:Te.runner_error)||"Backlog exec is not available on this gateway.");return}const Ye=!!(te.readiness&&!te.readiness.ok);await n.backlog_execute({kind:"planned",filename:te.filename,execution_mode:U,executor:ge==null?void 0:ge.executor,target_model:ge==null?void 0:ge.target_model,target_reasoning_effort:ge==null?void 0:ge.target_reasoning_effort,dor:"check",override:Ye}),Y(null),await xe()}catch(Te){const Ye=Ld(Te);Ye?(Y(vt=>vt&&{...vt,readiness:Ye,server_refused:!0}),C("")):C(String((Te==null?void 0:Te.message)||Te||"Execute failed"))}finally{ee(!1)}}}async function st(ge){if(!(we||J.length<2)){Re(""),$e(!0);try{const Te=ye.exec_cfg||await ye.load_exec_config();if(!Te||Te.can_execute!==!0){Re((Te==null?void 0:Te.runner_error)||"Backlog exec is not available on this gateway.");return}await n.backlog_execute_batch({items:J.map(Ye=>({kind:"planned",filename:String(Ye.filename||"")})),execution_mode:ce,executor:ge,dor:"check",override:it}),he(!1),q([]),Be(!1),await xe()}catch(Te){const Ye=Ld(Te);if(Ye){const vt=Ye.checks.filter(gt=>!gt.ok);Be(!0),Re(`Definition of Ready refused by the gateway:
91
+ ${vt.map(gt=>`○ ${gt.label}${gt.evidence?` — ${gt.evidence}`:""}`).join(`
92
+ `)}
93
+ Execute batch again to override (recorded as dor_overridden).`)}else Re(String((Te==null?void 0:Te.message)||Te||"Execute batch failed"))}finally{$e(!1)}}}async function pt(){if(Se||J.length<2)return;const ge=Ee.trim();if(!ge){de("Title is required.");return}de(""),Je(!0);try{await n.backlog_merge({kind:"planned",items:J.map(Te=>({kind:"planned",filename:String(Te.filename||"")})),package:ct.trim()||"framework",task_type:fe,title:ge,summary:W.trim()||void 0}),Ve(!1),q([]),await xe()}catch(Te){de(String((Te==null?void 0:Te.message)||Te||"Merge failed"))}finally{Je(!1)}}function Dt(ge){const Te=String(ge||"").trim();q(Ye=>Ye.includes(Te)?Ye.filter(vt=>vt!==Te):[...Ye,Te])}function wt(ge){if(x==="planned"){const Te=Q.has(String(ge.filename||"").trim());return e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>void ft(ge),disabled:!r||Te,title:Te?"A live execution request already exists for this item":void 0,children:Te?"Processing…":"Execute"}),e.jsx("button",{className:"btn",title:"Move back to Triage (proposed)",onClick:()=>void dt(ge,"proposed"),disabled:!r,children:"→ Triage"}),e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void dt(ge,"trash"),disabled:!r,children:"Trash"})]})}return x==="proposed"?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",title:"Promote to Ready (planned)",onClick:()=>void dt(ge,"planned"),disabled:!r,children:"→ Ready"}),e.jsx("button",{className:"btn",title:"Deprecate",onClick:()=>void dt(ge,"deprecated"),disabled:!r,children:"Deprecate"}),e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void dt(ge,"trash"),disabled:!r,children:"Trash"})]}):x==="recurrent"?e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void dt(ge,"trash"),disabled:!r,children:"Trash"}):x==="deprecated"||x==="trash"?e.jsx("button",{className:"btn",title:"Restore to Triage (proposed)",onClick:()=>void dt(ge,"proposed"),disabled:!r,children:"Restore"}):null}return e.jsxs("div",{className:"page page_pad backlog_page",children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsx("div",{className:"seg seg_scroll",role:"group","aria-label":"Backlog kinds",children:Sh.map(ge=>e.jsx("button",{"aria-pressed":x===ge.id,className:`seg_btn ${x===ge.id?"active":""}`,onClick:()=>v(ge.id),children:ge.label},ge.id))}),r?null:e.jsx("span",{className:"page_hint mono",children:"Not connected — use the connection control (top right)."}),e.jsx("div",{className:"page_toolbar_spacer"}),e.jsxs("button",{className:`btn btn_icon ${L?"is_loading":""}`,onClick:()=>void xe(),disabled:!r||L,title:"Refresh","aria-label":"Refresh",children:[e.jsx(Ue,{name:"refresh",size:16}),L?"Refreshing":"Refresh"]})]}),P?e.jsx(em,{gateway:n,surface:"the backlog archive",status:Fe.status,legacy:Fe.legacy,error:$,on_changed:()=>{Pe(ge=>ge+1),xe()}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsx("input",{className:"board_search",value:H,onChange:ge=>z(ge.target.value),placeholder:"Search backlog (id/title/package/filename…)"}),e.jsxs("select",{value:R,onChange:ge=>M(ge.target.value),title:"Filter by type",children:[e.jsx("option",{value:"all",children:"all types"}),tr.map(ge=>e.jsx("option",{value:ge,children:ge},ge))]}),e.jsx("div",{className:"page_toolbar_spacer"}),x==="planned"&&Ce.length?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"chip mono info",children:[Ce.length," selected"]}),e.jsx("button",{className:"btn primary",disabled:Ce.length<2,onClick:()=>{Re(""),O(d),Be(!1),he(!0),ye.load_exec_config()},children:"Execute batch"}),e.jsx("button",{className:"btn",disabled:Ce.length<2,onClick:()=>{const ge=J.map(Te=>String(Te.package||"").trim()).filter(Boolean);et(ge.length&&ge.every(Te=>Te===ge[0])?ge[0]:"framework"),ue("task"),se(`Master backlog (${J.length} items)`),ie(""),de(""),Ve(!0)},children:"Merge → master"})]}):null,e.jsxs("span",{className:"mono muted backlog_count",style:{fontSize:"var(--font-size-sm)"},children:[ke.length,"/",g.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:(en=Sh.find(ge=>ge.id===x))==null?void 0:en.label}),e.jsxs("span",{className:"pane_count",children:[ke.length," item",ke.length===1?"":"s"]})]}),e.jsx("div",{className:"pane_body",style:{padding:0},children:ke.length?e.jsxs("table",{className:"data_table backlog_table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[x==="planned"?e.jsx("th",{className:"backlog_table_sel col_sel"}):null,e.jsx("th",{className:"col_id",children:"#"}),e.jsx("th",{className:"col_type",children:"type"}),e.jsx("th",{className:"col_package",children:"package"}),e.jsx("th",{children:"title"}),e.jsx("th",{className:"col_priority",children:"priority"}),e.jsx("th",{className:"col_labels",children:"labels"}),x!=="completed"?e.jsx("th",{className:"backlog_table_actions col_actions",children:"actions"}):null]})}),e.jsx("tbody",{children:ke.map(ge=>{const Te=String(ge.filename||"").trim(),Ye=sl(ge.task_type),vt=Pd(ge)?Rd(ge.priority):null,gt=Array.isArray(ge.labels)?ge.labels:[];return e.jsxs("tr",{className:"backlog_row",onClick:()=>Xe(ge),children:[x==="planned"?e.jsx("td",{className:"backlog_table_sel col_sel",onClick:jt=>jt.stopPropagation(),children:e.jsx("label",{className:"backlog_sel_hit",children:e.jsx("input",{type:"checkbox",checked:Ce.includes(Te),onChange:()=>Dt(Te),"aria-label":`Select ${Te}`})})}):null,e.jsx("td",{className:"mono muted col_id",children:ge.item_id||""}),e.jsx("td",{className:"col_type",children:Ye?e.jsx("span",{className:`chip mono ${Bp(Ye)}`,title:Up(Ye),children:Ye}):null}),e.jsx("td",{className:"mono muted col_package",title:ge.package||"",children:ge.package||""}),e.jsx("td",{className:"backlog_table_title",title:Te,children:ge.title||Te}),e.jsx("td",{className:"col_priority",children:vt?e.jsx("span",{className:`chip mono board_prio_${vt.toLowerCase()}`,children:vt}):null}),e.jsxs("td",{className:"col_labels",title:gt.join(", "),children:[gt.slice(0,2).map(jt=>e.jsx("span",{className:"chip mono info",style:{marginRight:4},children:jt},jt)),gt.length>2?e.jsxs("span",{className:"chip mono muted",children:["+",gt.length-2]}):null]}),x!=="completed"?e.jsx("td",{className:"backlog_table_actions col_actions",onClick:jt=>jt.stopPropagation(),children:e.jsx("div",{className:"entity_card_actions",children:wt(ge)})}):null]},`${x}:${Te}`)})})]}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",padding:"12px"},children:L?"Loading…":"No items."})})]})]}),e.jsx(t_,{open:!!te,target:te?{kind:"planned",filename:te.filename,title:te.title}:null,execute_mode:U,set_execute_mode:X,action_loading:I,action_error:k,exec_cfg:ye.exec_cfg,exec_cfg_loading:ye.exec_cfg_loading,exec_cfg_error:ye.exec_cfg_error,executors:ae,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 ge=te;Y(null),je({filename:ge.filename,kind:"planned",title:ge.title,initial_tab:"spec"})}:void 0,on_confirm:ge=>void Le(ge),on_close:()=>Y(null)}),e.jsx(Tb,{open:re,batch_selected_items:J,batch_execute_mode:ce,set_batch_execute_mode:O,batch_execute_loading:we,batch_execute_error:Oe,executors:ae,exec_cfg:ye.exec_cfg,exec_cfg_loading:ye.exec_cfg_loading,exec_cfg_error:ye.exec_cfg_error,on_confirm:ge=>void st(ge),on_close:()=>{he(!1),Re(""),Be(!1)}}),e.jsx(Ab,{open:ot,batch_selected_items:J,merge_package:ct,set_merge_package:et,merge_task_type:fe,set_merge_task_type:ue,merge_title:Ee,set_merge_title:se,merge_summary:W,set_merge_summary:ie,merge_loading:Se,merge_error:F,on_confirm:()=>void pt(),on_close:()=>{Ve(!1),de("")}}),e.jsx(Yp,{gateway:n,can_use_gateway:r,target:Ne,on_close:()=>je(null),on_mutated:async()=>{await xe()},on_open_executions:ge=>{var Te;return(Te=s.on_open_executions)==null?void 0:Te.call(s,ge)}}),e.jsx(Nb,{gateway:n,can_use_gateway:r,is_compact_layout:h,maint_provider:i,maint_model:l,maint_reasoning:u,advisor_agent:m,focus_kind:x,focus_type:R,voice_session_id:s.voice_session_id})]})}function Mb(s){const{open:n,gateway:r,can_use_gateway:i,maint_provider:l,maint_model:u,maint_reasoning:m,on_close:d,on_created:h}=s,[x,v]=f.useState(""),[g,w]=f.useState(!1),[L,E]=f.useState(""),[$,T]=f.useState("proposed"),[H,z]=f.useState("feature"),[R,M]=f.useState("framework"),[A,V]=f.useState(""),[Q,oe]=f.useState(""),[be,Ne]=f.useState(""),[je,Ce]=f.useState(""),[q,te]=f.useState(""),[Y,U]=f.useState(""),[X,I]=f.useState(!1),[ee,ae]=f.useState(""),[k,C]=f.useState(""),[re,he]=f.useState(""),[ce,O]=f.useState(""),[we,$e]=f.useState(""),[Oe,Re]=f.useState(""),[it,Be]=f.useState(""),[ot,Ve]=f.useState(""),[ct,et]=f.useState(""),[fe,ue]=f.useState(""),[Ee,se]=f.useState([]),[W,ie]=f.useState(!1),[Se,Je]=f.useState(""),[F,de]=f.useState([]),[ye,xe]=f.useState(""),[ke,J]=f.useState(!1);function P(){T("proposed"),z("feature"),M("framework"),V(""),oe(""),Ne(""),Ce(""),te(""),U(""),I(!1),ae(""),C(""),he(""),O(""),$e(""),Re(""),Be(""),Ve(""),et(""),ue(""),se([]),ie(!1),Je(""),de([]),xe(""),J(!1)}function Z(){d(),P()}async function Pe(){const Le=String(x||"").trim();if(Le)return Le;if(g)return"";E(""),w(!0);try{const st=await r.backlog_template(),pt=String((st==null?void 0:st.content)||"");return v(pt),pt}catch(st){return E(String((st==null?void 0:st.message)||st||"Failed to load backlog template")),""}finally{w(!1)}}async function Fe(Le){if(!i)return;const st=(Le==null?void 0:Le.force)===!0;if(!st&&q.trim())return;const pt=await Pe();if(!pt.trim())return;const Dt=String(R||"").trim().toLowerCase()||"{Package}",wt=Td(),en=eb(pt,{package_name:Dt,title:A,task_type:H,summary:Q,created_at:wt});te(ge=>st||!String(ge||"").trim()?en:ge)}f.useEffect(()=>{n&&i&&Fe()},[n,i]);function Xe(Le){if(q.trim()&&!globalThis.confirm("Overwrite the current draft markdown with a guided draft?"))return;const st=String(R||"").trim().toLowerCase()||"{Package}",pt=Td(),Dt=tb({package_name:st,title:A,task_type:H,summary:Q,diagram:ee,context:k,included:Qa(re),excluded:Qa(ce),plan:Qa(we),dependencies:Qa(Oe),acceptance:Qa(it),tests_a:Qa(ot),tests_b:Qa(ct),tests_c:Qa(fe),created_at:pt,attachments:[]});te(Dt)}async function dt(){var st;if(X)return;U(""),I(!0),Je("");let Le="";try{const pt=String(R||"").trim().toLowerCase(),Dt=Yd(je),wt=!!(be||Dt.length);let en=q||"";wt&&en.trim()&&(en=Md(en,{priority:be||null,labels:Dt}));const ge=await r.backlog_create({kind:$,package:pt,title:A,task_type:H,summary:Q||null,content:en||null}),Te=String((ge==null?void 0:ge.kind)||"").trim(),Ye=String((ge==null?void 0:ge.filename)||"").trim();if(wt&&!en.trim()&&Te&&Ye)try{const gt=await r.backlog_content(Te,Ye),jt=String((gt==null?void 0:gt.content)||""),lt=await Ad(jt),En=Md(jt,{priority:be||null,labels:Dt});await r.backlog_update({kind:Te,filename:Ye,content:En,expected_sha256:lt||null})}catch(gt){Le=[Le,`metadata lines not written: ${String((gt==null?void 0:gt.message)||gt)}`].filter(Boolean).join("; ")}const vt=[...Ee||[]];if(Te&&Ye&&vt.length){ie(!0);const gt=[];try{for(const jt of vt){const lt=await r.backlog_upload_attachment({kind:Te,filename:Ye,file:jt,overwrite:!1}),En=String(((st=lt==null?void 0:lt.stored)==null?void 0:st.relpath)||"").trim();En&&gt.push(En)}}catch(jt){Le=[Le,String((jt==null?void 0:jt.message)||jt||"Attachment upload failed")].filter(Boolean).join("; "),Je(Le)}finally{if(gt.length)try{const jt=await r.backlog_content(Te,Ye),lt=String((jt==null?void 0:jt.content)||""),En=await Ad(lt),js=nb(lt,gt);await r.backlog_update({kind:Te,filename:Ye,content:js,expected_sha256:En||null})}catch(jt){Le=[Le,`uploaded files not linked: ${String((jt==null?void 0:jt.message)||jt)}`].filter(Boolean).join("; ")}ie(!1)}}d(),P();try{await h(Te,Ye,Le)}catch{}}catch(pt){U(String((pt==null?void 0:pt.message)||pt||"Create failed"))}finally{I(!1)}}async function ft(){if(ke)return;U("");const Le=ye.trim();if(!Le)return;if(!A.trim()){U("Title is required before using AI assist.");return}const st=String(R||"").trim().toLowerCase();if(!st){U("Package is required before using AI assist.");return}const pt={id:Dr(),role:"user",content:Le,ts:new Date().toISOString()},Dt=[...F,pt];de(Dt),xe(""),J(!0);try{const wt=await r.backlog_assist({kind:$,package:st,title:A,summary:Q||null,draft_markdown:q||null,messages:Dt.map(Te=>({role:Te.role,content:Te.content})),provider:l||null,model:u||null,thinking:m||null}),en=String((wt==null?void 0:wt.reply)||"").trim(),ge=String((wt==null?void 0:wt.draft_markdown)||"").trim();en&&de(Te=>[...Te,{id:Dr(),role:"assistant",content:en,ts:new Date().toISOString()}]),ge&&te(ge)}catch(wt){U(String((wt==null?void 0:wt.message)||wt||"AI assist failed"))}finally{J(!1)}}return e.jsxs(nr,{open:n,title:"New backlog task",onClose:Z,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:Z,disabled:X||ke,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void dt(),disabled:X||!A.trim()||!R.trim(),children:X?"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:Le=>T(Le.target.value),children:[e.jsx("option",{value:"proposed",children:"proposed"}),e.jsx("option",{value:"planned",children:"planned"}),e.jsx("option",{value:"recurrent",children:"recurrent"})]})]})}),e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Type"}),e.jsx("select",{value:H,onChange:Le=>z(Le.target.value),children:tr.map(Le=>e.jsx("option",{value:Le,children:Le},Le))})]})}),e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Package"}),e.jsx("input",{value:R,onChange:Le=>M(Le.target.value),placeholder:"framework"})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Title"}),e.jsx("input",{value:A,onChange:Le=>V(Le.target.value),placeholder:"Short descriptive title"})]}),e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Priority"}),e.jsxs("select",{value:be,onChange:Le=>Ne(Le.target.value),children:[e.jsx("option",{value:"",children:"unset"}),rl.map(Le=>e.jsx("option",{value:Le,children:Vp[Le]},Le))]})]})}),e.jsx("div",{className:"col",style:{minWidth:320},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Labels (comma-separated; sprints: sprint-29)"}),e.jsx("input",{value:je,onChange:Le=>Ce(Le.target.value),placeholder:"ui, security, sprint-29",className:"mono"})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Summary (optional)"}),e.jsx("textarea",{value:Q,onChange:Le=>oe(Le.target.value),rows:3,placeholder:"One paragraph summary"})]}),e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Guided fields (optional)"}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Use this to generate a structured draft without editing markdown directly. One item per line for list fields."}),e.jsx("div",{style:{marginTop:"8px"},children:e.jsxs("details",{children:[e.jsx("summary",{className:"mono",style:{cursor:"pointer"},children:"Show guided fields"}),e.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[e.jsx("label",{children:"Diagram (ASCII)"}),e.jsx("textarea",{value:ee,onChange:Le=>ae(Le.target.value),rows:4,className:"mono",placeholder:"(optional) ascii diagram"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Context"}),e.jsx("textarea",{value:k,onChange:Le=>C(Le.target.value),rows:4,placeholder:"Why is this needed? Link to evidence (reports, discussions, etc.)."})]}),e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col",style:{minWidth:260},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Scope: Included (1 per line)"}),e.jsx("textarea",{value:re,onChange:Le=>he(Le.target.value),rows:4,className:"mono",placeholder:"..."})]})}),e.jsx("div",{className:"col",style:{minWidth:260},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Scope: Excluded (1 per line)"}),e.jsx("textarea",{value:ce,onChange:Le=>O(Le.target.value),rows:4,className:"mono",placeholder:"..."})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Implementation Plan (1 per line)"}),e.jsx("textarea",{value:we,onChange:Le=>$e(Le.target.value),rows:4,className:"mono",placeholder:"..."})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Dependencies (1 per line)"}),e.jsx("textarea",{value:Oe,onChange:Le=>Re(Le.target.value),rows:3,className:"mono",placeholder:"Related backlog items / ADRs / external libs…"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Acceptance Criteria (1 per line)"}),e.jsx("textarea",{value:it,onChange:Le=>Be(Le.target.value),rows:4,className:"mono",placeholder:"..."})]}),e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col",style:{minWidth:260},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Testing Level A (1 per line)"}),e.jsx("textarea",{value:ot,onChange:Le=>Ve(Le.target.value),rows:3,className:"mono",placeholder:"cd pkg && pytest -q ..."})]})}),e.jsx("div",{className:"col",style:{minWidth:260},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Testing Level B (1 per line)"}),e.jsx("textarea",{value:ct,onChange:Le=>et(Le.target.value),rows:3,className:"mono",placeholder:"run local gateway + manual verification..."})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Testing Level C (1 per line)"}),e.jsx("textarea",{value:fe,onChange:Le=>ue(Le.target.value),rows:2,className:"mono",placeholder:"(optional / opt-in)"})]}),e.jsx("div",{className:"row",style:{marginTop:"10px",justifyContent:"flex-end"},children:e.jsx("button",{className:"btn",onClick:()=>Xe(),disabled:X||ke,children:"Generate draft from guided fields"})})]})}),e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Attachments (optional)"}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Upload screenshots/diagrams to `docs/backlog/assets/<id>/` and link them under `## Related` after the task is created."}),e.jsx("div",{className:"field",style:{marginTop:"8px"},children:e.jsx("input",{type:"file",multiple:!0,onChange:Le=>{const st=Array.from(Le.target.files||[]);st.length&&(se(pt=>[...pt,...st]),Le.currentTarget.value="")}})}),Ee.length?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:Ee.map((Le,st)=>e.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between",marginTop:"4px"},children:[e.jsxs("span",{className:"mono muted",style:{paddingRight:"10px"},children:[Le.name," (",Math.round(Le.size/1024)," KB)"]}),e.jsx("button",{className:"btn",onClick:()=>se(pt=>pt.filter((Dt,wt)=>wt!==st)),disabled:X||W,children:"Remove"})]},`${Le.name}_${Le.size}_${st}`))}):null,W?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Uploading attachments…"}):null,Se?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Se}):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."}),g?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:()=>{q.trim()&&!globalThis.confirm("Reset the draft markdown to the backlog template?")||Fe({force:!0})},disabled:X||ke||g||!i,children:"Reset from template"})}),e.jsx("div",{className:"field",children:e.jsx("textarea",{value:q,onChange:Le=>te(Le.target.value),rows:10,className:"mono",placeholder:"(optional) full markdown draft"})}),e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"AI Assist (chat)"}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Use this to iteratively refine a backlog draft; assistant replies can also update the draft markdown."}),e.jsx(zc,{messages:F,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(cl,{value:ye,onChange:xe,onSubmit:()=>void ft(),placeholder:"Message to AI (e.g. refine acceptance criteria…)",disabled:!i||!A.trim(),busy:ke,rows:3,sendButtonClassName:"btn primary"})}),Y?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Y}):null]})}class s_ extends Wt.Component{constructor(){super(...arguments);Ja(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 a_(s){return`abstractcontinuum_list_open_${s}`}function r_(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function Dd(s,n=r_()){try{return(n==null?void 0:n.getItem(a_(s)))!=="0"}catch{return!0}}function i_(s,n,r=r_()){try{r==null||r.setItem(a_(s),n?"1":"0")}catch{}}function Pc(s){const[n,r]=f.useState(()=>Dd(s)),i=f.useCallback(()=>{r(l=>{const u=!l;return i_(s,u),u})},[s]);return[n,i]}function Rb(s){const[n,r]=f.useState({}),i=f.useCallback(u=>u in n?n[u]:Dd(`${s}_${u}`),[n,s]),l=f.useCallback(u=>{r(m=>{const d=!(u in m?m[u]:Dd(`${s}_${u}`));return i_(`${s}_${u}`,d),{...m,[u]:d}})},[s]);return[i,l]}function il(s){return e.jsxs("button",{type:"button",className:"list_disclosure","aria-expanded":s.open,"aria-controls":s.controls,onClick:s.on_toggle,title:s.open?`Hide ${s.title.toLowerCase()}`:`Show ${s.title.toLowerCase()}`,children:[e.jsx(Ue,{name:s.open?"chevronDown":"chevronRight",size:14}),e.jsx("span",{className:s.title_class||"pane_title",children:s.title}),s.count!==void 0?e.jsx("span",{className:s.count_class||"pane_count",children:s.count}):null]})}function ol(s){var n,r;try{if(!s||typeof window>"u"||!((n=window.matchMedia)!=null&&n.call(window,"(max-width: 767.98px)").matches))return;(r=s.scrollIntoView)==null||r.call(s,{block:"start",behavior:"smooth"})}catch{}}function sm(s){return!s||s.seat_key_present?"":`The team hub is not configured. ${String(s.setup||"").trim()||`No hub key for seat "${s.seat||"operator"}". Provision the seat, or start Continuum with --hub-token-file <path>.`}`}class am{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,h=new Error(`${n} failed: ${d}`);throw h.status=l.status,h}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,h=new Error(`upload failed: ${d}`);throw h.status=l.status,h}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 Pb=["commons"],zb=3e4,Ib=5*6e4,md={live:new Map,done:[],work:new Map},Nh=new Set(["proposed","planned","completed","deprecated"]);function Db(s,n){const r=n&&typeof n=="object"?String(n.item||""):"";if(r&&Hs(r))return r;const i=s.startsWith("claim:")?s.slice(6):"";return i&&Hs(i)?i:null}function Ob(s){const[n,r]=f.useState(md),i=f.useRef(new am),l=f.useRef(new Map),u=f.useRef(0),m=f.useRef(!1);return f.useEffect(()=>{let d=!0;const h=async()=>{if(!(m.current||Date.now()<u.current)){m.current=!0;try{const v=sm(await i.current.meta());if(v){d&&r(E=>E.not_configured===v?E:{...md,not_configured:v});return}const g=new Map,w=[],L=new Map;for(const E of Pb){let $=!1;try{const H=await i.current.work_rows(E);for(const z of H){const R=String(z.id||z.item||""),M=String(z.status||"").toLowerCase();!Hs(R)||!Nh.has(M)||L.set(R,{item:R,title:typeof z.title=="string"?z.title:void 0,status:M,owner:typeof z.owner=="string"?z.owner:void 0,receipt:typeof z.receipt=="string"?z.receipt:void 0,card:typeof z.card=="string"?z.card:void 0,updated_at:z.updated_at})}$=!0}catch{}const T=await i.current.store_keys(E);for(const H of T){const z=String(H.key||"");if(z.startsWith("work:")){if($)continue;const be=z.slice(5);if(!Hs(be))continue;const Ne=Number(H.version||0),je=`${E}\0${z}`,Ce=l.current.get(je);let q;if(Ce&&Ce.version===Ne)q=Ce.value;else{const Y=await i.current.store_get(E,z);q=Y==null?void 0:Y.value,l.current.set(je,{version:Ne,value:q})}const te=q&&typeof q=="object"?String(q.status||"").toLowerCase():"";if(!Nh.has(te))continue;L.set(be,{item:be,title:typeof q.title=="string"?q.title:void 0,status:te,owner:typeof q.owner=="string"?q.owner:void 0,receipt:typeof q.receipt=="string"?q.receipt:void 0,card:typeof q.card=="string"?q.card:void 0,updated_at:H.updated_at});continue}if(!z.startsWith("claim:"))continue;const R=Number(H.version||0),M=`${E}\0${z}`,A=l.current.get(M);let V;if(A&&A.version===R)V=A.value;else{const be=await i.current.store_get(E,z);V=be==null?void 0:be.value,l.current.set(M,{version:R,value:V})}if(!V||typeof V!="object"||typeof V.owner!="string"||!V.owner)continue;const Q=Db(z,V)||z.slice(6);if(!Q)continue;!!V.done||String(V.status||"").toLowerCase()==="done"?w.push({item:Q,owner:V.owner,receipt:typeof V.receipt=="string"?V.receipt:void 0,updated_at:H.updated_at}):g.has(Q)||g.set(Q,V)}}w.sort((E,$)=>($.updated_at||0)-(E.updated_at||0)),d&&r(E=>E.live.size===g.size&&[...g.keys()].every(T=>JSON.stringify(E.live.get(T))===JSON.stringify(g.get(T)))&&JSON.stringify(E.done)===JSON.stringify(w)&&E.work.size===L.size&&[...L.keys()].every(T=>JSON.stringify(E.work.get(T))===JSON.stringify(L.get(T)))&&!E.not_configured?E:{live:g,done:w,work:L})}catch{u.current=Date.now()+Ib,d&&r(v=>v.live.size||v.done.length||v.work.size?md:v)}finally{m.current=!1}}};h();const x=setInterval(()=>void h(),zb);return()=>{d=!1,clearInterval(x)}},[s]),n}const Fb=40,qb=4;function Bb(s){const{gateway:n,can_use_gateway:r,data_nonce:i}=s,[l,u]=f.useState([]),[m,d]=f.useState(!1),[h,x]=f.useState(""),[v,g]=f.useState(""),[w,L]=f.useState(null),[E,$]=f.useState(null),[T,H]=f.useState({}),z=f.useRef({}),R=f.useRef(!1),M=f.useCallback(async oe=>{if(r&&!R.current){R.current=!0,oe!=null&&oe.background||d(!0);try{const[be,Ne,je,Ce,q]=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=[],Y=[],U=(we,$e)=>we.status==="fulfilled"?we.value:(te.push($e),Y.push(we.reason),null),X=U(be,"proposed list"),I=U(Ne,"planned list"),ee=U(je,"live requests"),ae=U(Ce,"recent history"),k=U(q,"busy set");if(L(Y.find(we=>Ii(we))??null),!X&&!I&&!ee&&!ae){x("Failed to load the board (all sources failed)");return}x("");const C=Array.isArray(ee==null?void 0:ee.requests)?ee.requests:[];let re=Array.isArray(k==null?void 0:k.items)?k.items:[];k||(re=C.map(we=>({request_id:String(we.request_id||""),status:String(we.status||""),kind:"planned",filename:String(we.backlog_filename||"").trim(),relpath:String(we.backlog_relpath||"").trim()})).filter(we=>we.filename&&!/^batch\(\d+\)$/i.test(we.filename)));const he=Array.isArray(X==null?void 0:X.items)?X.items:[],ce=Array.isArray(I==null?void 0:I.items)?I.items:[];$(X&&I?he.length+ce.length:null);const O=yb({proposed:he,planned:ce,active_requests:C,terminal_requests:Array.isArray(ae==null?void 0:ae.requests)?ae.requests:[],active_items:re});u(O),g(te.length?`#FALLBACK partial board — failed: ${te.join(", ")}`:""),A(O,he,ce)}finally{R.current=!1,oe!=null&&oe.background||d(!1)}}},[n,r]);async function A(oe,be,Ne){const je=new Map;for(const Y of be)je.set(String(Y.filename||"").trim(),"proposed");for(const Y of Ne)je.set(String(Y.filename||"").trim(),"planned");const Ce=oe.filter(Y=>Y.filename&&!z.current[Y.filename]&&je.has(Y.filename)).filter(Y=>!Qp(Y)||Y.column==="ready").slice(0,Fb).map(Y=>({filename:Y.filename,kind:je.get(Y.filename)}));if(!Ce.length)return;const q=[...Ce],te=Array.from({length:Math.min(qb,q.length)},async()=>{for(;;){const Y=q.shift();if(!Y)return;try{const U=await n.backlog_content(Y.kind,Y.filename),X=Oi(String((U==null?void 0:U.content)||""));z.current={...z.current,[Y.filename]:X}}catch{}}});await Promise.all(te),H(z.current)}const V=f.useCallback(async(oe,be)=>{try{const Ne=await n.backlog_content(oe,be),je=Oi(String((Ne==null?void 0:Ne.content)||""));z.current={...z.current,[be]:je},H(z.current)}catch{}},[n]);return f.useEffect(()=>{M()},[M,i]),f.useEffect(()=>{if(!r)return;const oe=setInterval(()=>{n.is_backing_off()||M({background:!0})},1e4);return()=>clearInterval(oe)},[r,M,n]),{cards:l,loading:m,error:h,degraded:v,unconfigured:w!==null,unavailable:w,item_count:E,metadata:T,refresh:M,refresh_item_metadata:V}}function Ch(s,n){return s.length<=n?s:`${s.slice(0,n-1).trimEnd()}…`}const $h=new am;function Ub(s){if(!s)return"";const n=Math.max(0,Date.now()/1e3-s);return n<3600?`${Math.max(1,Math.round(n/60))}m`:n<172800?`${Math.round(n/3600)}h`:`${Math.round(n/86400)}d`}function Wb(s){const{card:n}=s,r=n.work_id||"",i=!!(r&&Hs(r)),[l,u]=f.useState({loading:i,error:"",claims:[],decisions:[],messages:[]});f.useEffect(()=>{let h=!0;if(i)return u(x=>({...x,loading:!0,error:""})),$h.meta().then(x=>{const v=sm(x);if(v)throw Object.assign(new Error(v),{not_configured:!0});return $h.work(r)}).then(x=>{h&&u({loading:!1,error:"",claims:Array.isArray(x==null?void 0:x.claims)?x.claims:[],decisions:Array.isArray(x==null?void 0:x.decisions)?x.decisions:[],messages:(Array.isArray(x==null?void 0:x.messages)?x.messages:[]).slice().sort((v,g)=>(g.created_at||0)-(v.created_at||0))})}).catch(x=>{h&&u({loading:!1,error:String((x==null?void 0:x.message)||x||"activity unavailable"),not_configured:!!(x!=null&&x.not_configured),claims:[],decisions:[],messages:[]})}),()=>{h=!1}},[r,i]);const m=l.messages[0],d=n.claim_started_at!==void 0&&n.claim_owner?Hp({owner:n.claim_owner,started_at:n.claim_started_at},Date.now()):null;return e.jsx("div",{className:"modal_backdrop",onClick:s.on_close,children:e.jsxs("div",{className:"modal_panel board_claim_panel board_activity_panel",onClick:h=>h.stopPropagation(),children:[e.jsxs("div",{className:"modal_head",children:[e.jsx("span",{className:"modal_title",children:n.title}),e.jsx("button",{className:"btn",onClick:s.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&&l.not_configured?e.jsx("div",{className:"muted team_note","data-hub-note":"not-configured",children:l.error}):null,l.error&&!l.not_configured?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(h=>e.jsxs("div",{className:"board_activity_msg",children:[e.jsxs("div",{className:"board_activity_msg_head mono",children:[e.jsx("span",{children:h.sender}),e.jsxs("span",{className:"muted",children:[h.channel," #",h.seq," · ",Ub(h.created_at)]}),s.on_open_team?e.jsx("button",{className:"team_row_expand",onClick:()=>s.on_open_team({channel:String(h.channel||""),message_id:String(h.id||""),seq:Number(h.seq)}),title:"Open this message in its Team channel",children:"open ↗"}):null]}),h.title?e.jsx("div",{className:"board_activity_msg_title",children:Ch(String(h.title),140)}):null,h.body?e.jsx("div",{className:"board_activity_msg_body muted",children:Ch(String(h.body),220)}):null]},h.id||h.seq))]}),e.jsx("div",{className:"entity_skills_actions",children:s.on_open_team?e.jsx("button",{className:"btn primary",onClick:()=>s.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 Hb(s){var Je;const{gateway:n,gateway_connected:r,data_nonce:i,on_mutated:l,on_open_executions:u}=s,m=s.default_execution_mode==="inplace"?"inplace":"uat",d=tm("(max-width: 767.98px)"),[h,x]=Rb("board_column"),v=n_(n,r),g=Bb({gateway:n,can_use_gateway:r,data_nonce:i}),[w,L]=f.useState(0),E=Zd(n,r,i+w),$=g.unconfigured||((Je=E.status)==null?void 0:Je.available)===!1,T=!$&&g.item_count===0&&!g.error,H=Ob(!0),z=f.useMemo(()=>xb(g.cards,H),[g.cards,H]),R=nm({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:()=>{}}),[M,A]=f.useState("");f.useEffect(()=>{var de;if(!s.query_preset)return;const F=Hs(s.query_preset);A(F?F.num.padStart(4,"0"):s.query_preset),(de=s.on_query_preset_consumed)==null||de.call(s)},[s.query_preset]);const[V,Q]=f.useState("all"),[oe,be]=f.useState("all"),[Ne,je]=f.useState(""),[Ce,q]=f.useState(!1),[te,Y]=f.useState(null),[U,X]=f.useState(null),[I,ee]=f.useState(null),[ae,k]=f.useState("uat"),[C,re]=f.useState(!1),[he,ce]=f.useState(""),[O,we]=f.useState(""),[$e,Oe]=f.useState(null),Re=f.useRef(null),it=z.some(F=>F.column==="in_progress"),[,Be]=f.useState(0);f.useEffect(()=>{if(!it)return;const F=setInterval(()=>Be(de=>(de+1)%3600),1e3);return()=>clearInterval(F)},[it]);const ot=f.useMemo(()=>{const F=new Set;for(const de of z)de.package&&F.add(de.package);return[...F].sort()},[z]),Ve=f.useMemo(()=>z.filter(F=>F.filename&&F.kind).length,[z]),ct=f.useMemo(()=>z.filter(F=>F.filename&&F.kind&&(Qp(F)||g.metadata[F.filename])).length,[z,g.metadata]),et=f.useMemo(()=>{const F=new Map;for(const de of z)if(de.filename)for(const ye of Id(de,g.metadata[de.filename]))F.set(ye,(F.get(ye)||0)+1);return[...F.entries()].sort((de,ye)=>ye[1]-de[1]).slice(0,12)},[z,g.metadata]),fe=f.useMemo(()=>{const F=M.trim().toLowerCase();return z.filter(de=>{if(V!=="all"&&(de.package||"")!==V||oe!=="all"&&String(de.task_type||"").toLowerCase()!==oe)return!1;const ye=de.filename?g.metadata[de.filename]:void 0,xe=Id(de,ye);return Ne&&!xe.includes(Ne)||Ce&&!xe.some(J=>{const P=J.toLowerCase();return P==="decision-gate"||P.startsWith("wave-")||P.startsWith("seat-")})?!1:F?`${de.item_id||""} ${de.title} ${de.filename||""} ${de.package||""} ${de.summary||""} ${de.exec_status||""} ${xe.join(" ")} ${zd(de,ye)||""}`.toLowerCase().includes(F):!0})},[z,g.metadata,M,V,oe,Ne,Ce]),ue=f.useMemo(()=>{var ye;const F=new Map;for(const xe of wh)F.set(xe.id,[]);for(const xe of fe)(ye=F.get(xe.column))==null||ye.push(xe);const de=xe=>{const ke=xe.filename?zd(xe,g.metadata[xe.filename]):null;return ke?rl.indexOf(ke):rl.length};for(const[xe,ke]of F)(xe==="triage"||xe==="ready")&&ke.sort((J,P)=>de(J)-de(P)||(P.item_id||0)-(J.item_id||0));return F},[fe,g.metadata]);async function Ee(F,de){if(!(!F.filename||!F.kind||F.kind==="completed")&&F.kind!==de){we("");try{await n.backlog_move({from_kind:F.kind,to_kind:de,filename:F.filename}),await g.refresh(),l()}catch(ye){we(String((ye==null?void 0:ye.message)||ye||"Move failed"))}}}async function se(F){if(!F.filename)return;let de=g.metadata[F.filename];if(!de)try{const xe=await n.backlog_content("planned",F.filename);de=Oi(String((xe==null?void 0:xe.content)||""))}catch{de=void 0}const ye=de?Xd({task_type:F.task_type},de):null;ce(""),k(m),ee({filename:F.filename,title:F.title,readiness:ye}),R.load_exec_config()}async function W(F){if(!(!I||C)){re(!0),ce("");try{const de=R.exec_cfg||await R.load_exec_config();if(!de||de.can_execute!==!0){ce((de==null?void 0:de.runner_error)||"Backlog exec is not available on this gateway.");return}const ye=!!(I.readiness&&!I.readiness.ok);await n.backlog_execute({kind:"planned",filename:I.filename,execution_mode:ae,executor:F==null?void 0:F.executor,target_model:F==null?void 0:F.target_model,target_reasoning_effort:F==null?void 0:F.target_reasoning_effort,dor:"check",override:ye}),ee(null),await g.refresh(),l()}catch(de){const ye=Ld(de);ye?(ee(xe=>xe&&{...xe,readiness:ye,server_refused:!0}),ce("")):ce(String((de==null?void 0:de.message)||de||"Execute failed"))}finally{re(!1)}}}function ie(F){if(!F.filename&&!F.request_id){const de=lb(F.card_path);if(de&&r){n.backlog_content(de.kind,de.filename).then(()=>{Y({filename:de.filename,kind:de.kind,title:F.title,work_id:F.work_id,has_live_request:!1,initial_tab:"spec"})}).catch(()=>X(F));return}X(F);return}Y({filename:F.filename||"",kind:F.kind||null,request_id:F.request_id,title:F.title,work_id:F.work_id,has_live_request:F.column==="in_progress"||F.column==="in_review",initial_tab:F.column==="in_review"?"review":F.column==="in_progress"?"runs":"spec"})}const Se={ready:"planned",triage:"proposed"};return e.jsxs("div",{className:"page board_page_root",children:[H.not_configured?e.jsxs("div",{className:"muted team_note board_hub_note",role:"status","data-hub-note":"not-configured",children:[H.not_configured," The board works without it; live claims appear once it is."]}):null,e.jsxs("div",{className:"board_toolbar",children:[e.jsx("input",{className:"board_search",value:M,onChange:F=>A(F.target.value),placeholder:"Search the board…"}),e.jsxs("select",{value:V,onChange:F=>Q(F.target.value),title:"Package",children:[e.jsx("option",{value:"all",children:"all packages"}),ot.map(F=>e.jsx("option",{value:F,children:F},F))]}),e.jsxs("select",{value:oe,onChange:F=>be(F.target.value),title:"Type",children:[e.jsx("option",{value:"all",children:"all types"}),tr.map(F=>e.jsx("option",{value:F,children:F},F))]}),e.jsx("button",{className:`chip mono board_facet ${Ce?"active":"muted"}`,onClick:()=>q(F=>!F),"aria-pressed":Ce,title:"Room supervision: only operator decision gates + wave items (labels decision-gate / wave-* / seat-*)",children:"Supervision"}),e.jsx("div",{className:"board_toolbar_spacer"}),g.degraded&&!$?e.jsx("span",{className:"mono board_warn",title:g.degraded,children:"partial board"}):null,g.error&&!$?e.jsx("span",{className:"mono board_error",children:g.error}):null,O?e.jsx("span",{className:"mono board_error",children:O}):null,e.jsx("button",{className:`btn btn_icon ${g.loading?"is_loading":""}`,onClick:()=>void g.refresh(),disabled:!r||g.loading,children:g.loading?"Refreshing…":"Refresh"})]}),$?e.jsx(em,{gateway:n,surface:"the board",status:E.status,legacy:E.legacy,error:g.unavailable,on_changed:()=>{L(F=>F+1),g.refresh()}}):null,T?e.jsx(wb,{status:E.status,on_create:s.on_new_task}):null,!$&&(et.length||Ve)?e.jsxs("div",{className:"board_facets",children:[e.jsx("span",{className:"mono muted board_facets_caption",children:"labels:"}),et.map(([F,de])=>e.jsxs("button",{className:`chip mono board_facet ${Ne===F?"active":"info"}`,onClick:()=>je(ye=>ye===F?"":F),title:`${de} scanned card(s) carry ${F} — click to filter (sprints are labels: sprint-N)`,children:[F," ",e.jsx("span",{className:"muted",children:de})]},F)),Ne?e.jsx("button",{className:"chip mono warn board_facet",onClick:()=>je(""),children:"clear ✕"}):null,ct<Ve?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 ",ct,"/",Ve]}):null]}):null,e.jsx("div",{className:"board_columns",style:$?{display:"none"}:void 0,children:wh.map(F=>{const de=ue.get(F.id)||[],ye=Se[F.id],xe=h(F.id);return e.jsxs("div",{className:`board_column board_column_${F.id} ${$e===F.id?"drag_over":""}${xe?"":" list_collapsed"}`,onDragOver:ke=>{!ye||!Re.current||(ke.preventDefault(),Oe(F.id))},onDragLeave:()=>Oe(ke=>ke===F.id?null:ke),onDrop:ke=>{ke.preventDefault(),Oe(null);const J=Re.current;Re.current=null,J&&ye&&Ee(J,ye)},children:[e.jsx("div",{className:"board_column_header",title:F.hint,children:e.jsx(il,{open:xe,on_toggle:()=>x(F.id),controls:`board_column_body_${F.id}`,title:F.label,count:de.length,title_class:"board_column_title",count_class:"board_column_count mono"})}),e.jsxs("div",{className:"board_column_body",id:`board_column_body_${F.id}`,hidden:!xe,children:[de.map(ke=>{const J=Jp(ke,ke.filename?g.metadata[ke.filename]:void 0);return e.jsx(Vb,{card:ke,metadata:ke.filename?g.metadata[ke.filename]:void 0,draggable:!J&&!!(ke.kind&&ke.filename&&(ke.column==="triage"||ke.column==="ready")),on_drag_start:()=>{Re.current=ke},on_drag_end:()=>{Re.current=null,Oe(null)},on_open:()=>ie(ke),on_promote:!J&&F.id==="triage"?()=>void Ee(ke,"planned"):void 0,on_demote:!J&&F.id==="ready"?()=>void Ee(ke,"proposed"):void 0,on_execute:!J&&F.id==="ready"?()=>void se(ke):void 0,on_follow:ke.exec_status==="running"||ke.exec_status==="queued"?()=>u(ke.request_id):void 0},ke.key)}),de.length?null:e.jsx("div",{className:"board_column_empty mono muted",children:"—"})]})]},F.id)})}),e.jsx(t_,{open:!!I,target:I?{kind:"planned",filename:I.filename,title:I.title}:null,execute_mode:ae,set_execute_mode:k,action_loading:C,action_error:he,exec_cfg:R.exec_cfg,exec_cfg_loading:R.exec_cfg_loading,exec_cfg_error:R.exec_cfg_error,executors:v,readiness:(I==null?void 0:I.readiness)??null,server_refused:(I==null?void 0:I.server_refused)===!0,show_readiness:!0,on_open_spec:I?()=>{const F=I;ee(null),Y({filename:F.filename,kind:"planned",title:F.title,initial_tab:"spec"})}:void 0,on_confirm:F=>void W(F),on_close:()=>ee(null)}),e.jsx(Yp,{gateway:n,can_use_gateway:r,target:te,on_close:()=>Y(null),on_mutated:async()=>{te!=null&&te.filename&&(te.kind==="proposed"||te.kind==="planned")&&await g.refresh_item_metadata(te.kind,te.filename),await g.refresh(),l()},on_open_executions:u}),U?e.jsx(Wb,{card:U,on_close:()=>X(null),on_open_team:s.on_open_team}):null]})}function Vb(s){const{card:n,metadata:r,draggable:i,on_drag_start:l,on_drag_end:u,on_open:m,on_promote:d,on_demote:h,on_execute:x,on_follow:v}=s,g=zd(n,r),w=Jp(n,r),L=!w&&r?Xd({task_type:n.task_type},r):null,E=sl(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":""} ${w?"gate":""}`,onClick:m,role:"button",tabIndex:0,onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.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(T=>!T.ok).map(T=>T.label).join("; ")}`}):null,e.jsx("span",{className:"board_card_title_text",children:n.title})]}),e.jsxs("div",{className:"board_card_chips",children:[w?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,E&&!w?e.jsx("span",{className:`chip mono ${Bp(E)}`,title:Up(E),children:E}):null,g?e.jsx("span",{className:`chip mono board_prio_${g.toLowerCase()}`,children:g}):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,Id(n,r).filter(T=>!w||T.toLowerCase()!=="decision-gate").slice(0,3).map(T=>e.jsx("span",{className:"chip mono info",children:T},T)),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:Ws($)}):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 T=Hp({owner:n.claim_owner,started_at:n.claim_started_at},Date.now());return e.jsxs("span",{className:`chip mono ${T!=null&&T.stale?"warn":"info"}`,title:`Live hub claim${n.work_id?` (claim:${n.work_id})`:""}${T!=null&&T.stale?" — stale: claimed long ago with no receipt yet; open to re-claim on the record per the ruled process":""}`,children:["⛏ ",n.claim_owner,T?` · ${T.label.replace("claimed ","")}`:""]})})():null]}),d||h||x||v?e.jsxs("div",{className:"board_card_actions",onClick:T=>T.stopPropagation(),children:[d?e.jsx("button",{className:"btn",onClick:d,title:"Move to Ready (planned)",children:"→ Ready"}):null,x?e.jsx("button",{className:"btn primary",onClick:x,children:"Execute"}):null,h?e.jsx("button",{className:"btn",onClick:h,title:"Move back to Triage (proposed)",children:"→ Triage"}):null,v?e.jsx("button",{className:"btn",onClick:v,children:"Follow live"}):null]}):null]})}function fd(s,n){const r=String(s||"").replace(/\r/g,"").trim();if(!r)return"";const l=(r.split(`
94
+ `,1)[0]||"").trim();return l.length<=n?l:`${l.slice(0,Math.max(0,n-1))}…`}function Gb(s){const n=String(s||"").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 o_(s){const n=String(s||"").trim();if(!n)return"";const r=n.match(/^(?:\/bin\/)?(?:zsh|bash)\s+-lc\s+([\s\S]+)$/);return r?Gb(String(r[1]||"").trim()):n}function Kb(s,n){const r=String(s||"").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 Jb(s,n){var x;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:[],h=String((r==null?void 0:r.message)||((x=r==null?void 0:r.error)==null?void 0:x.message)||"").trim();if(l==="command_execution"&&m)return o_(m)||m;if(l==="todo_list"&&d.length>0){const v=d.length,g=d.filter(H=>(H&&H.completed)===!0).length,w=d.find(H=>(H&&H.completed)!==!0),L=String((w==null?void 0:w.text)||"").trim(),E=v>1?` (+${v-1})`:"",$=v>0?` (${g}/${v})`:"",T=L?`todo: ${L}${E}`:`todo list (${v})`;return fd(`${T}${$}`,96)}return u?fd(u,96)||u:h?fd(h,96)||h:l||String(s||"").trim()||"event"}function Eh(s){const n=new Date(s),r=i=>String(i).padStart(2,"0");return`${r(n.getHours())}:${r(n.getMinutes())}`}function Qb(s){var i,l,u;const n=s&&typeof s=="object"?s:{},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 Eh(d)}if(typeof m=="string"){const d=m.trim();if(!d)continue;const h=Date.parse(d.replace(/(\.\d{3})\d+/,"$1"));if(Number.isFinite(h))return Eh(h)}}return null}function Yb(s){var T;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:h,exec_log_truncated:x,exec_log_auto:v,set_exec_log_auto:g,exec_log_scroll_el_ref:w,exec_log_follow_ref:L,parsed_exec_events:E,load_exec_log_tail:$}=s;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:H=>u(H.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(Di,{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:H=>g(()=>H)}),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(Ue,{name:"refresh",size:16}),i?null:d?"Loading…":"Refresh"]})]})]}),h?e.jsx("div",{className:"detail_warn",children:h}):null,!h&&x?e.jsx("div",{className:"detail_hint",children:"#TRUNCATION: log tail truncated"}):null,l==="events"&&E?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"exec_log_scroll",ref:w,onScroll:H=>{L.current=yh(H.currentTarget,12)},children:E.events.length===0?e.jsx("div",{className:"empty_note",children:"No events yet."}):E.events.map(H=>{var ee;const z=H.payload,R=z&&typeof z.item=="object"?z.item:null,M=R?String(R.type||"").trim():"",A=R?String(R.id||"").trim():"",V=z?String(z.thread_id||"").trim():"",Q=Kb(H.type,z),oe=Q==="error"?"danger":Q==="ok"?"ok":"info",be=Qb(z),Ne=Jb(H.type,z),je=String((z==null?void 0:z.message)||((ee=z==null?void 0:z.error)==null?void 0:ee.message)||"").trim(),Ce=R?String(R.text||"").trim():"",q=R?String(R.command||"").trim():"",te=R?String(R.status||"").trim():"",Y=R&&R.exit_code!=null?String(R.exit_code):"",U=R?String(R.aggregated_output||"").trim():"",X=R&&Array.isArray(R.items)?R.items:[],I=q?o_(q)||q:"";return e.jsxs("details",{className:`exec_event ${Q}`,children:[e.jsxs("summary",{className:"exec_event_summary",children:[be?e.jsx("span",{className:"exec_event_when mono muted",children:be}):null,be?e.jsx("span",{className:"exec_event_sep mono muted",children:"|"}):null,e.jsx("span",{className:"exec_event_main mono",title:Ne,children:Ne}),e.jsx("span",{className:`chip mono ${oe}`,children:M||H.type}),Y?e.jsxs("span",{className:"mono muted exec_event_right",children:["exit=",Y]}):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:H.type}),A?e.jsx("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:A}):null,V?e.jsxs("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["thread ",_a(V,18)]}):null]}),je?e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:je}):null,X&&X.length>0?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:X.map((ae,k)=>e.jsxs("div",{children:[(ae&&ae.completed)===!0?"✓":"○"," ",String((ae==null?void 0:ae.text)||"").trim()]},`${H.idx}-todo-${k}`))}):null,q?e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["command_execution ",te?`(${te})`:""," ",Y?`exit=${Y}`:""]}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"6px"},children:I})]}):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,Ce?e.jsx("div",{style:{marginTop:"8px"},children:e.jsx(Qn,{className:"md_doc",text:Ce})}):null]})]},`${H.idx}-${A}-${H.type}`)})}),e.jsxs("details",{style:{marginTop:"8px"},children:[e.jsxs("summary",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",cursor:"pointer"},children:["Raw JSONL",E.bad?` (${E.bad} unparsable line(s))`:""]}),e.jsx("pre",{className:"mono exec_raw_log",children:E.raw||""})]})]}):e.jsx("div",{className:"exec_log_scroll",ref:w,onScroll:H=>{L.current=yh(H.currentTarget,12)},children:e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)"},children:(()=>{var z;if(String(m||"").trim())return m;if(l==="last_message"){const R=String(((z=r==null?void 0:r.result)==null?void 0:z.last_message)||n.last_message||"").trim();if(R)return R;const M=String(n.status||"").trim().toLowerCase();return M==="queued"||M==="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)"})()})}),(T=r==null?void 0:r.result)!=null&&T.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 Xb(s){const{pipeline:n,is_compact_layout:r,on_back_to_list:i,on_send_feedback:l,on_promote:u,on_deploy_uat:m}=s,d=n.exec_selected;if(!d)return e.jsx("div",{className:"empty_note",children:"Select an exec request."});const{exec_detail:h,exec_detail_loading:x,exec_detail_error:v,exec_qa_feedback:g,set_exec_qa_feedback:w,exec_qa_loading:L,exec_qa_error:E,event_stats:$,time_stats:T,exec_log_name:H}=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 z=String(d.status||"").trim().toLowerCase();return e.jsx("span",{className:`chip mono ${tl(z)}`,children:z||"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:x,children:"Back"}):null,e.jsxs("button",{className:"btn btn_icon",onClick:()=>on(d.request_id),disabled:x,"aria-label":"Copy request id",title:"Copy request id",children:[e.jsx(Ue,{name:"copy",size:16}),r?null:"Copy request id"]}),d.backlog_relpath?e.jsxs("button",{className:"btn btn_icon",onClick:()=>on(d.backlog_relpath||""),disabled:x,"aria-label":"Copy backlog path",title:"Copy backlog path",children:[e.jsx(Ue,{name:"copy",size:16}),r?null:"Copy backlog path"]}):null,(()=>{var M;const R=(Array.isArray((M=h==null?void 0:h.backlog_queue)==null?void 0:M.items)?h.backlog_queue.items:[]).map(A=>String((A==null?void 0:A.relpath)||"").trim()).filter(Boolean);return R.length?e.jsxs("button",{className:"btn btn_icon",onClick:()=>on(R.join(`
95
+ `)),disabled:x,"aria-label":"Copy backlog paths",title:"Copy backlog paths",children:[e.jsx(Ue,{name:"copy",size:16}),r?null:"Copy backlog paths"]}):null})(),d.run_dir_relpath?e.jsxs("button",{className:"btn btn_icon",onClick:()=>on(d.run_dir_relpath||""),disabled:x,"aria-label":"Copy run dir",title:"Copy run dir",children:[e.jsx(Ue,{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:x?e.jsx("div",{className:"empty_note",children:"Loading…"}):e.jsxs(e.Fragment,{children:[e.jsx(Zb,{exec_selected:d,exec_detail:h,exec_qa_feedback:g,set_exec_qa_feedback:w,exec_qa_loading:L,exec_qa_error:E,on_send_feedback:l,on_promote:u,on_deploy_uat:m}),e.jsx(ew,{exec_selected:d,exec_detail:h}),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,T.age_ms!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"age"}),e.jsx("span",{className:"fact_value",children:Ws(T.age_ms)})]}):null,T.queue_delay_ms!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"queue delay"}),e.jsx("span",{className:"fact_value",children:Ws(T.queue_delay_ms)})]}):null,T.run_ms!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"run time"}),e.jsx("span",{className:"fact_value",children:Ws(T.run_ms)})]}):null,T.total_ms!=null&&T.is_done?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"total time"}),e.jsx("span",{className:"fact_value",children:Ws(T.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:H==="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(sw,{exec_detail:h}),e.jsx(tw,{exec_detail:h,exec_qa_loading:L,status:String(d.status||"")}),e.jsx(nw,{exec_detail:h}),e.jsx(aw,{exec_selected:d,exec_detail:h}),e.jsx("div",{className:"section_divider"}),e.jsx(Yb,{exec_selected:d,exec_detail:h,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:z=>n.set_exec_log_auto(z),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 Zb(s){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:h,on_deploy_uat:x}=s;if(String(n.status||"").trim().toLowerCase()!=="awaiting_qa")return null;const g=String((r==null?void 0:r.execution_mode)||"").trim().toLowerCase()||"uat",w=String((r==null?void 0:r.candidate_relpath)||"").trim(),L=String((r==null?void 0:r.candidate_patch_relpath)||"").trim(),E=String((r==null?void 0:r.candidate_manifest_relpath)||"").trim(),$=String((r==null?void 0:r.uat_current_relpath)||"").trim(),T=String((r==null?void 0:r.uat_lock_owner_request_id)||"").trim(),H=!!(r!=null&&r.uat_lock_acquired),z=!!(r!=null&&r.uat_pending),R=(r==null?void 0:r.uat_deploy)??null,M=String((r==null?void 0:r.uat_deploy_error)||"").trim(),A=r==null?void 0:r.attempt,V=(r==null?void 0:r.promotion_report)??null,Q=!!(V!=null&&V.blocked),oe=String((V==null?void 0:V.reason)||"").trim(),be=Array.isArray(V==null?void 0:V.conflicts)?(V==null?void 0:V.conflicts).slice(0,8):[],Ne=typeof(V==null?void 0:V.conflicts_total)=="number"?Number(V.conflicts_total):be.length;let je="",Ce="";const q=[];try{const te=R==null?void 0:R.processes;if(te&&typeof te=="object"&&!Array.isArray(te)){typeof te.status=="string"&&(je=String(te.status||"").trim()),typeof te.reason=="string"&&(Ce=String(te.reason||"").trim());for(const[Y,U]of Object.entries(te)){if(!U||typeof U!="object"||Array.isArray(U))continue;const X=U.probe;!X||typeof X!="object"||X.ok===!1&&q.push(String(Y))}}}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:g})]}),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,g==="uat"&&T?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"uat lock"}),e.jsxs("span",{className:"fact_value",children:[_a(T,18),H?" (owned)":z?" (pending)":""]})]}):null,w?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"candidate"}),e.jsx("span",{className:"fact_value mono",children:w})]}):null,E?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"manifest"}),e.jsx("span",{className:"fact_value mono",children:E})]}):null,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]}),g==="inplace"?e.jsx("div",{className:"detail_warn",children:"Inplace mode: prod may already be mutated. Approving only finalizes the request status."}):g==="uat"&&z&&T&&!H?e.jsxs("div",{className:"detail_warn",children:["UAT currently points to ",_a(T,16),". Click “Restart UAT” to switch the shared UAT stack to this request."]}):g==="uat"&&H?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."}),q.length?e.jsxs("div",{className:"detail_warn",children:["UAT may be unreachable: URL probe failed for ",q.slice(0,4).join(", "),q.length>4?"…":"",". Click “Restart UAT” and check process logs."]}):null]}):null,g==="uat"&&je==="skipped"&&Ce==="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,M?e.jsxs("div",{className:"detail_warn",children:["UAT deploy failed: ",M]}):null,Q&&oe==="conflicts"?e.jsxs("div",{className:"detail_warn",children:["Promotion blocked: prod diverged from the candidate base (",Ne," conflict",Ne===1?"":"s","). Use “Iterate” to re-run the request on top of current prod, or resolve conflicts manually.",be.length?e.jsx("ul",{style:{marginTop:"8px",paddingLeft:"18px"},children:be.map((te,Y)=>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:${Y}`))}):null]}):null,e.jsxs("div",{className:"row",style:{flexWrap:"wrap",gap:"6px",marginTop:"8px"},children:[L?e.jsxs("button",{className:"btn btn_icon",onClick:()=>on(L),disabled:u,children:[e.jsx(Ue,{name:"copy",size:16}),"Copy patch path"]}):null,E?e.jsxs("button",{className:"btn btn_icon",onClick:()=>on(E),disabled:u,children:[e.jsx(Ue,{name:"copy",size:16}),"Copy manifest path"]}):null,w?e.jsxs("button",{className:"btn btn_icon",onClick:()=>on(w),disabled:u,children:[e.jsx(Ue,{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:[g==="uat"?e.jsx("button",{className:"btn",onClick:x,disabled:u,children:"Restart UAT"}):null,e.jsx("button",{className:"btn primary",onClick:h,disabled:u,children:g==="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 ew(s){const{exec_selected:n,exec_detail:r}=s;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,h=typeof(u==null?void 0:u.deleted)=="number"?Number(u==null?void 0:u.deleted):null,x=String((u==null?void 0:u.manifest_sha256)||"").trim(),v=String((u==null?void 0:u.mode)||"").trim(),g=(m==null?void 0:m.redeploy)??null,w=String((g==null?void 0:g.status)||"").trim(),L=String((g==null?void 0:g.reason)||"").trim(),E=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,x?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"manifest sha256"}),e.jsxs("span",{className:"fact_value",children:[x.slice(0,16),"…"]})]}):null,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,h!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"deleted"}),e.jsxs("span",{className:"fact_value",children:[h," files"]})]}):null,w?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"redeploy"}),e.jsxs("span",{className:"fact_value",children:[w,L?` (${L})`:""]})]}):null,E?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"redeploy error"}),e.jsx("span",{className:"fact_value",style:{color:"var(--danger, rgb(248, 113, 113))"},children:E})]}):null]}),e.jsx("div",{className:"section_divider"})]})}function tw(s){const{exec_detail:n,exec_qa_loading:r}=s;if(String(s.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):"",h=String((i==null?void 0:i.manifest_sha256)||"").trim(),x=l&&typeof l.redeploy=="object"?l.redeploy:null,v=x?String(x.status||"").trim():"";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Promotion"}),e.jsxs("div",{className:"fact_grid",children:[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,h?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:()=>on(h),disabled:r,title:"Copy the full sha","aria-label":"Copy manifest sha256",children:e.jsx(Ue,{name:"copy",size:12})})]}),e.jsxs("span",{className:"fact_value mono",children:[h.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 nw(s){var i,l;const r=(Array.isArray((l=(i=s.exec_detail)==null?void 0:i.backlog_queue)==null?void 0:l.items)?s.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 sw(s){var h,x,v;const n=((h=s.exec_detail)==null?void 0:h.skills)||((v=(x=s.exec_detail)==null?void 0:x.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(g=>String(g))),d=u.filter(g=>{const w=String((g==null?void 0:g.status)||(g==null?void 0:g.state)||"").toLowerCase();return w&&w!=="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(g=>{const w=m.has(String(g)),L=l[String(g)];return e.jsxs("span",{className:`chip mono ${w?"ok":"warn"}`,title:w?L?`active · ${String(L).slice(0,12)}`:"active":"requested but not active — see verdict below",children:[g,w?"":" (held)"]},`skill:${g}`)})}),d.map((g,w)=>{const L=String((g==null?void 0:g.name)||(g==null?void 0:g.skill)||"skill"),E=String((g==null?void 0:g.reason)||(g==null?void 0:g.detail)||(g==null?void 0:g.status)||"held");return e.jsxs("div",{className:"detail_warn",children:[L,": ",E]},`verdict:${w}:${L}`)})]})}function aw(s){var r,i;const n=String(((i=(r=s.exec_detail)==null?void 0:r.result)==null?void 0:i.last_message)||s.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(Qn,{className:"md_doc",text:n})})]}):null}const rw=10;function iw(s){const{gateway:n,gateway_connected:r}=s,i=tm("(max-width: 767.98px)"),l=f.useRef(null),u=f.useRef(null),m=I=>{const ee=I==="detail"?u:l;requestAnimationFrame(()=>ol(ee.current))},[d,h]=Pc("exec_active"),[x,v]=Pc("exec_recent"),[g,w]=f.useState(null);async function L(){try{const I=await n.admin_executors(),ee=Array.isArray(I)?I:Array.isArray(I==null?void 0:I.executors)?I.executors:[];w(ee)}catch{w(null)}}f.useEffect(()=>{if(!r){w(null);return}L()},[n,r]);const E=nm({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:()=>{R()}}),[$,T]=f.useState([]),[H,z]=f.useState("");async function R(){if(r)try{const I=await n.backlog_exec_requests({status:"completed,promoted,failed",limit:50}),ee=Array.isArray(I==null?void 0:I.requests)?I.requests:[];ee.sort((ae,k)=>{const C=String(ae.finished_at||ae.started_at||ae.created_at||"");return String(k.finished_at||k.started_at||k.created_at||"").localeCompare(C)}),T(ee.slice(0,rw)),z("")}catch(I){z(String((I==null?void 0:I.message)||I||"Failed to load recent executions"))}}f.useEffect(()=>{if(!r)return;(async()=>{var k;const ee=await E.refresh_exec_list("processing");await R();const ae=String(s.focus_request_id||"").trim();if(ae){const C=ee.find(re=>re.request_id===ae);if(C)await E.load_exec_request(C);else try{const re=await n.backlog_exec_request(ae);re!=null&&re.payload&&await E.load_exec_request({request_id:ae,status:String(re.payload.status||"unknown")})}catch{}(k=s.on_focus_consumed)==null||k.call(s)}})();const I=setInterval(()=>{n.is_backing_off()||R()},15e3);return()=>clearInterval(I)},[r,s.focus_request_id]);const M=E.exec_requests.some(I=>String(I.status||"").toLowerCase()==="running"),[,A]=f.useState(0);f.useEffect(()=>{if(!M)return;const I=setInterval(()=>A(ee=>(ee+1)%3600),1e3);return()=>clearInterval(I)},[M]);const V=E.exec_requests,Q=f.useMemo(()=>{let I=0,ee=0,ae=0;for(const k of V){const C=String(k.status||"").trim().toLowerCase();C==="queued"?I+=1:C==="running"?ee+=1:C==="awaiting_qa"&&(ae+=1)}return{queued:I,running:ee,awaiting:ae}},[V]),oe=E.exec_cfg,be=!!(oe!=null&&oe.runner_alive),Ne=String((oe==null?void 0:oe.executor)||"").trim(),je=!Ne||Ne==="none",Ce=je?"execution agent":Ne,q=!!(oe!=null&&oe.can_execute),te=Ii(E.exec_error)||Ii(H),[Y,U]=f.useState(0),X=Zd(n,r&&te,Y);return e.jsxs("div",{className:"page page_pad exec_page",children:[e.jsxs("div",{className:"page_toolbar",children:[r&&oe?e.jsxs("span",{className:`chip mono ${q?"ok":"warn"}`,title:oe.codex_model?`${Ce}: ${oe.codex_model}${oe.codex_reasoning_effort?` (reasoning ${oe.codex_reasoning_effort})`:""}`:void 0,children:[je?"no execution agent":`${Ce} worker ${be?"on":"off"}`,!i&&oe.codex_model?` · ${oe.codex_model}`:""]}):null,r?null:e.jsx("span",{className:"page_hint",children:"Not connected — use the connection control (top right)."}),!te&&E.exec_error?e.jsx("span",{className:"page_error mono",children:E.exec_error}):null,e.jsx("div",{className:"page_toolbar_spacer"}),e.jsx("button",{className:`btn btn_icon ${E.exec_loading?"is_loading":""}`,onClick:()=>{E.refresh_exec_list("processing"),R(),E.load_exec_config(),L()},disabled:!r||E.exec_loading,title:"Refresh runs, worker config, and the executor registry","aria-label":"Refresh",children:e.jsx(Ue,{name:"refresh",size:16})})]}),r&&oe&&!q&&!te?e.jsxs("div",{className:"callout callout_warn",children:[e.jsx("div",{className:"callout_icon","aria-hidden":"true",children:e.jsx(Ue,{name:"warning",size:18})}),e.jsxs("div",{className:"callout_main",children:[e.jsxs("div",{className:"callout_title",children:[je?g!=null&&g.length?"No default executor selected":"No execution agent on this gateway":be?"The pipeline cannot execute":"The exec worker is not running",e.jsx("span",{className:"chip mono warn",children:je?"setup required":be?"cannot execute":"queued until it returns"})]}),e.jsx("p",{className:"callout_text",children:(()=>{if(!je)return oe.runner_error?`The worker reports: ${oe.runner_error} — new executions queue until it comes back.`:be?"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(!(g!=null&&g.length))return"The gateway serves the pipeline but has no executor configured — nothing can run until one is enabled on the gateway host.";const I=g.map(k=>k.display||k.id),ee=I.slice(0,4).join(", ")+(I.length>4?` +${I.length-4} more`:"");return g.some(k=>k.available!==!1)?`The gateway's registry serves ${g.length} executor${g.length===1?"":"s"} (${ee}), but no default is selected — pick one in Settings → Gateway administration (gateway admin).`:`The gateway's registry serves ${g.length} executor${g.length===1?"":"s"} (${ee}), but none is currently available — install an executor binary on the gateway host (PATH), then pick it in Settings.`})()}),(!(g!=null&&g.length)||!g.some(I=>I.available!==!1))&&(je||!be)?e.jsx("pre",{className:"mono setup_callout_pre",children:`abstractgateway config set backlog_exec_runner on # enables the exec worker
96
+ abstractgateway config set executor codex # canonical ids: codex | claude | cursor-agent | abstractcode
97
+ # the agent program must be installed on the gateway's computer (on its PATH)`}):null,e.jsx("div",{className:"callout_actions",children:s.on_open_settings?e.jsx("button",{className:"btn primary",onClick:s.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(em,{gateway:n,surface:"the execution pipeline",status:X.status,legacy:X.legacy,error:Ii(E.exec_error)?E.exec_error:H,on_changed:()=>{U(I=>I+1),E.refresh_exec_list("processing")}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"stat_strip",children:[e.jsxs("div",{className:`stat_card ${Q.running?"tone_info":""}`,children:[e.jsx("span",{className:"stat_value",children:Q.running}),e.jsx("span",{className:"stat_label",children:"running"})]}),e.jsxs("div",{className:`stat_card ${Q.awaiting?"tone_warn":""}`,children:[e.jsx("span",{className:"stat_value",children:Q.awaiting}),e.jsx("span",{className:"stat_label",children:"awaiting QA"})]}),e.jsxs("div",{className:"stat_card",children:[e.jsx("span",{className:"stat_value",children:Q.queued}),e.jsx("span",{className:"stat_label",children:"queued"})]}),e.jsxs("div",{className:`stat_card ${q?"tone_ok":"tone_danger"}`,children:[e.jsx("span",{className:"stat_value",children:q?"on":je?"none":"off"}),e.jsxs("span",{className:"stat_label",children:[Ce,je?"":" 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(il,{open:d,on_toggle:h,controls:"exec_active_list",title:"Active",count:V.length})}),e.jsx("div",{className:"pane_body pane_body_list",id:"exec_active_list",hidden:!d,children:V.length?V.map(I=>{var ce;const ee=String(I.status||"").trim().toLowerCase(),ae=al(I),k=((ce=E.exec_selected)==null?void 0:ce.request_id)===I.request_id,C=ee==="running"&&I.started_at?Math.max(0,Date.now()-Date.parse(I.started_at)):null,re=String(I.backlog_filename||I.backlog_relpath||"").trim(),he=I.target_agent||(I.target_model?`${String(I.executor_type||"agent").trim()||"agent"}:${I.target_model}`:"");return e.jsxs("button",{className:`run_card ${k?"selected":""} ${ee==="running"?"is_running":""}`,onClick:()=>void E.load_exec_request(I),children:[e.jsxs("div",{className:"run_card_head",children:[e.jsx("span",{className:"run_card_title",title:re,children:re||`request ${_a(I.request_id,12)}`}),e.jsx("span",{className:`chip mono ${tl(ee)}`,children:ee||"unknown"})]}),e.jsxs("div",{className:"run_card_meta",children:[e.jsx("span",{className:"run_card_time",children:C!==null?`running ${Ws(C)}`:ae.queue_delay_ms!=null?`queued ${Ws(ae.queue_delay_ms)}`:" "}),he?e.jsx("span",{className:"chip mono muted",children:he}):null,e.jsx("span",{className:"run_card_id mono",children:_a(I.request_id,14)})]})]},I.request_id)}):e.jsx("div",{className:"empty_note",children:"Nothing is executing right now. Execute a Ready item from the Board (or Backlog)."})})]}),e.jsxs("div",{className:`pane exec_pane_recent${x?"":" list_collapsed"}`,children:[e.jsx("div",{className:"pane_header",children:e.jsx(il,{open:x,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:!x,children:[H&&!te?e.jsx("div",{className:"page_error mono",style:{padding:"10px 12px"},children:H}):null,!H&&!$.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(I=>{var re;const ee=String(I.status||"").trim().toLowerCase(),ae=al(I),k=((re=E.exec_selected)==null?void 0:re.request_id)===I.request_id,C=_a(I.backlog_filename||I.backlog_relpath||"request",44);return e.jsxs("button",{className:`recent_row ${k?"selected":""}`,onClick:()=>void E.load_exec_request(I),title:String(I.backlog_filename||I.backlog_relpath||I.request_id),children:[e.jsx("span",{className:`chip mono ${tl(ee)}`,children:ee||"?"}),e.jsx("span",{className:"recent_row_name",children:C}),e.jsx("span",{className:"recent_row_time mono",children:ae.run_ms!=null?Ws(ae.run_ms):""})]},`recent:${I.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"}),E.exec_selected?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`chip mono ${tl(String(E.exec_selected.status||"").toLowerCase())}`,children:String(E.exec_selected.status||"?").toLowerCase()}),e.jsx("span",{className:"pane_count mono",children:_a(E.exec_selected.request_id,20)})]}):e.jsx("span",{className:"pane_count",children:"select a run"})]}),e.jsx("div",{className:"pane_body",children:e.jsx(Xb,{pipeline:E,is_compact_layout:i,on_back_to_list:()=>m("list"),on_send_feedback:()=>void E.exec_send_feedback(async()=>{await E.refresh_exec_list("processing")}),on_promote:()=>void E.exec_promote_to_prod(async()=>{await E.refresh_exec_list("processing"),await R()}),on_deploy_uat:()=>void E.exec_deploy_uat_now(async()=>{await E.refresh_exec_list("processing")})})})]})]})]})]})}function hd(s,n){const r=String(s||"");return r.length<=n?r:`${r.slice(0,Math.max(0,n-1))}…`}function ow(s){const n=String(s||"").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 Th(s){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[...s||[]].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 lw(s){const n=String(s||"").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 cw({gateway:s,gateway_connected:n}){const[r,i]=f.useState("prod"),[l,u]=f.useState(null),[m,d]=f.useState([]),[h,x]=f.useState(!1),[v,g]=f.useState(""),[w,L]=f.useState(!1),[E,$]=f.useState(null),[T,H]=f.useState([]),[z,R]=f.useState(!1),[M,A]=f.useState(""),[V,Q]=f.useState({}),[oe,be]=f.useState(!1),[Ne,je]=f.useState(null),[Ce,q]=f.useState(""),[te,Y]=f.useState(""),[U,X]=f.useState(!1),[I,ee]=f.useState("idle"),ae=f.useRef(null),k=f.useMemo(()=>Th(m.filter(fe=>!String((fe==null?void 0:fe.id)||"").trim().endsWith("_uat"))),[m]),C=f.useMemo(()=>Th(m.filter(fe=>String((fe==null?void 0:fe.id)||"").trim().endsWith("_uat"))),[m]),re=r==="uat"?C:k,he=f.useCallback(async()=>{if(n){x(!0),g("");try{const fe=await s.list_processes();u(!!(fe!=null&&fe.enabled));const ue=Array.isArray(fe==null?void 0:fe.processes)?fe.processes:[];d(ue)}catch(fe){g(String((fe==null?void 0:fe.message)||fe||"Failed to list processes"))}finally{x(!1)}}},[s,n]),ce=f.useCallback(async()=>{if(n){R(!0),A("");try{const fe=await s.list_process_env_vars();$(!!(fe!=null&&fe.enabled));const ue=Array.isArray(fe==null?void 0:fe.vars)?fe.vars:[];H(ue);const Ee=String((fe==null?void 0:fe.error)||"").trim();Ee&&A(Ee)}catch(fe){A(String((fe==null?void 0:fe.message)||fe||"Failed to list env vars"))}finally{R(!1)}}},[s,n]),O=f.useCallback(async()=>{if(!n)return;const fe=Ne;if(fe){X(!0);try{const ue=await s.process_log_tail(String(fe.id||""),{max_bytes:16e4}),Ee=String((ue==null?void 0:ue.content)||""),se=typeof(ue==null?void 0:ue.bytes)=="number"?Number(ue.bytes):0,W=!!(ue!=null&&ue.truncated),ie=String((ue==null?void 0:ue.log_relpath)||"");q(Ee),Y(`${se.toLocaleString()} bytes${W?" (tail)":""}${ie?` • ${ie}`:""}`)}catch(ue){q(""),Y(String((ue==null?void 0:ue.message)||ue||"Failed to read logs"))}finally{X(!1)}}},[s,n,Ne]),we=f.useCallback(async fe=>{je(fe),be(!0)},[]),$e=f.useCallback(()=>{be(!1),je(null),q(""),Y("")},[]);f.useEffect(()=>{n&&he()},[n,he]),f.useEffect(()=>{if(!n||r==="env"||!w)return;const fe=window.setInterval(()=>{s.is_backing_off()||he()},2e3);return()=>window.clearInterval(fe)},[n,r,w,he,s]),f.useEffect(()=>{n&&r==="env"&&ce()},[n,r,ce]),f.useEffect(()=>{if(n&&oe)return O(),ae.current&&window.clearInterval(ae.current),ae.current=window.setInterval(()=>{s.is_backing_off()||O()},1500),()=>{ae.current&&window.clearInterval(ae.current),ae.current=null}},[n,oe,O]);const Oe=f.useRef(!1),[Re,it]=f.useState(!1);async function Be(fe,ue){if(!Oe.current){Oe.current=!0,it(!0),g("");try{ue==="start"?await s.start_process(fe.id):ue==="stop"?await s.stop_process(fe.id):ue==="restart"?await s.restart_process(fe.id):ue==="redeploy"&&await s.redeploy_process(fe.id),await he()}catch(Ee){g(String((Ee==null?void 0:Ee.message)||Ee||`Failed to ${ue}`))}finally{Oe.current=!1,it(!1)}}}async function ot(fe){const ue=String(fe||"").trim();if(ue){A("");try{const Ee=String((V==null?void 0:V[ue])??""),se=await s.update_process_env_vars({set:{[ue]:Ee}});$(!!(se!=null&&se.enabled)),H(Array.isArray(se==null?void 0:se.vars)?se.vars:[]),Q(ie=>({...ie||{},[ue]:""}));const W=String((se==null?void 0:se.error)||"").trim();W&&A(W)}catch(Ee){A(String((Ee==null?void 0:Ee.message)||Ee||"Failed to set env var"))}}}async function Ve(fe){const ue=String(fe||"").trim();if(ue){A("");try{const Ee=await s.update_process_env_vars({unset:[ue]});$(!!(Ee!=null&&Ee.enabled)),H(Array.isArray(Ee==null?void 0:Ee.vars)?Ee.vars:[]),Q(W=>({...W||{},[ue]:""}));const se=String((Ee==null?void 0:Ee.error)||"").trim();se&&A(se)}catch(Ee){A(String((Ee==null?void 0:Ee.message)||Ee||"Failed to unset env var"))}}}const ct=l===null?"…":l?"enabled":"disabled",et=E===null?"…":E?"enabled":"disabled";return e.jsx("div",{className:"page page_scroll",children:e.jsxs("div",{className:"page_inner page_pad constrained",children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsxs("div",{className:"seg",role:"group","aria-label":"Service views",children:[e.jsx("button",{"aria-pressed":r==="prod",className:`seg_btn ${r==="prod"?"active":""}`,onClick:()=>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 ",ct]}):null,n&&r==="env"?e.jsxs("span",{className:`chip mono ${E===!1?"warn":"muted"}`,children:["env ",et]}):null,e.jsx("div",{className:"page_toolbar_spacer"}),r!=="env"?e.jsxs(e.Fragment,{children:[e.jsx(Di,{variant:"sm",label:"Auto-refresh",action:"auto-refresh",hint:"Refresh this list every few seconds.",checked:w,onChange:fe=>L(fe)}),e.jsxs("button",{className:`btn btn_icon ${h?"is_loading":""}`,onClick:()=>void he(),disabled:!n||h,children:[e.jsx(Ue,{name:"refresh",size:16}),h?"Refreshing…":"Refresh"]})]}):e.jsxs("button",{className:`btn btn_icon ${z?"is_loading":""}`,onClick:()=>void ce(),disabled:!n||z,children:[e.jsx(Ue,{name:"refresh",size:16}),z?"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"&&E===!1?e.jsxs("div",{className:"page_hint mono",children:["The process manager is off on this gateway. An admin turns it on in Settings → Gateway administration (or"," ",e.jsx("span",{className:"mono",children:"abstractgateway config set process_manager on"}),")."]}):null,r!=="env"&&v?e.jsx("div",{className:"page_error mono",children:v}):null,r==="env"&&M?e.jsx("div",{className:"page_error mono",children:M}):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:re.length})]}),e.jsxs("div",{className:"pane_body pane_body_list",children:[re.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."]}),re.map(fe=>{const ue=String(fe.id||"").trim(),Ee=String(fe.label||ue).trim()||ue,se=ow(String(fe.status||"")),ie=String(fe.status||"").trim().toLowerCase()==="running",Se=Array.isArray(fe==null?void 0:fe.actions)?fe.actions.map(dt=>String(dt||"").trim()):[],Je=Se.includes("start"),F=Se.includes("stop"),de=Se.includes("restart"),ye=Se.includes("redeploy"),xe=Se.includes("logs"),ke=typeof(fe==null?void 0:fe.pid)=="number"?Number(fe.pid):null,J=String((fe==null?void 0:fe.url)||"").trim(),P=String((fe==null?void 0:fe.description)||"").trim(),Z=String((fe==null?void 0:fe.last_error)||"").trim(),Pe=typeof(fe==null?void 0:fe.exit_code)=="number"?Number(fe.exit_code):null,Fe=[];ke&&Fe.push(`pid ${ke}`),Pe!==null&&Fe.push(`exit ${Pe}`);const Xe=Fe.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:Ee}),e.jsx("span",{className:`chip mono ${se.cls}`,children:se.label}),e.jsx("span",{className:"chip mono muted",children:ue}),Xe?e.jsx("span",{className:"entity_card_sub mono",children:Xe}):null]}),P?e.jsx("div",{className:"entity_card_sub mono",children:hd(P,220)}):null,J?e.jsx("div",{className:"entity_card_sub mono",children:ie?e.jsx("a",{href:J,target:"_blank",rel:"noreferrer",className:"mono",style:{opacity:.95},children:J}):e.jsx("span",{className:"mono",children:J})}):null,Z?e.jsx("div",{className:"page_error mono",children:hd(Z,360)}):null,e.jsxs("div",{className:"entity_card_actions",children:[Je?e.jsx("button",{className:"btn primary",onClick:()=>void Be(fe,"start"),disabled:h||Re,children:"Start"}):null,F?e.jsx("button",{className:"btn danger",onClick:()=>void Be(fe,"stop"),disabled:h||Re,children:"Stop"}):null,de?e.jsx("button",{className:"btn",onClick:()=>void Be(fe,"restart"),disabled:h||Re,children:"Restart"}):null,ye?e.jsx("button",{className:"btn",onClick:()=>void Be(fe,"redeploy"),disabled:h||Re,children:"Redeploy"}):null,xe?e.jsx("button",{className:"btn",onClick:()=>void we(fe),disabled:h,children:"Logs"}):null]})]},ue)})]})]}):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:T.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:[T.map(fe=>{const ue=String((fe==null?void 0:fe.key)||"").trim();if(!ue)return null;const Ee=String((fe==null?void 0:fe.label)||ue).trim()||ue,se=String((fe==null?void 0:fe.description)||"").trim(),W=String((fe==null?void 0:fe.source)||"").trim(),ie=!!(fe!=null&&fe.secret),Se=String((fe==null?void 0:fe.updated_at)||"").trim(),Je=lw(W),F=String((V==null?void 0:V[ue])??"");return e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"entity_card_title",children:Ee}),e.jsx("span",{className:`chip mono ${Je.cls}`,children:Je.label}),e.jsx("span",{className:"chip mono muted",children:ue})]}),se?e.jsx("div",{className:"entity_card_sub mono",children:hd(se,280)}):null,Se?e.jsxs("div",{className:"entity_card_sub mono",children:["updated ",Se]}):null,e.jsxs("div",{className:"entity_card_actions",children:[e.jsx("input",{className:"input",value:F,onChange:de=>Q(ye=>({...ye||{},[ue]:String(de.target.value||"")})),placeholder:ie?"••••••••":"value",type:ie?"password":"text",style:{flex:"1 1 320px",minWidth:"220px"},autoComplete:"off",spellCheck:!1}),e.jsx("button",{className:"btn primary",onClick:()=>void ot(ue),disabled:z,children:"Set"}),e.jsx("button",{className:"btn",onClick:()=>void Ve(ue),disabled:z,children:"Unset"})]})]},`env:${ue}`)}),T.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,oe&&Ne?e.jsxs(nr,{open:oe,title:`${String(Ne.label||Ne.id||"logs").trim()||"Logs"}`,onClose:$e,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 O(),disabled:U,children:[e.jsx(Ue,{name:"refresh",size:16}),U?"Refreshing…":"Refresh"]}),e.jsxs("button",{className:"btn btn_icon",onClick:()=>{Wx(Ce||"").then(fe=>{ee(fe?"copied":"failed"),window.setTimeout(()=>ee("idle"),2e3)})},disabled:!Ce,children:[e.jsx(Ue,{name:"copy",size:16}),I==="copied"?"Copied":I==="failed"?Bx:"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:Ce||"(no logs yet)"})]}):null]})})}function Ah(s){const n=String(s||"").trim();if(!n)return"";const r=Date.parse(n);return Number.isFinite(r)?new Date(r).toLocaleString():n}function Bo(s,n){const r=String(s||"");return r.length<=n?r:`${r.slice(0,Math.max(0,n-1))}…`}function pd(s){const n=String(s||"").split(/[,\n]/g).map(r=>r.trim()).filter(Boolean);return n.length<=1?n[0]||"":n}function uw(s){const n=s.gateway,[r,i]=Pc("inbox_email"),l=f.useRef(null),u=f.useRef(null),[m,d]=f.useState([]),[h,x]=f.useState(""),[v,g]=f.useState(""),[w,L]=f.useState(""),[E,$]=f.useState("7d"),[T,H]=f.useState("unread"),[z,R]=f.useState(25),[M,A]=f.useState(!1),[V,Q]=f.useState(!1),[oe,be]=f.useState(!1),[Ne,je]=f.useState(!1),[Ce,q]=f.useState(""),[te,Y]=f.useState(""),[U,X]=f.useState(""),[I,ee]=f.useState([]),[ae,k]=f.useState(""),[C,re]=f.useState(null),[he,ce]=f.useState(!1),[O,we]=f.useState(""),[$e,Oe]=f.useState(""),[Re,it]=f.useState(""),[Be,ot]=f.useState(""),[Ve,ct]=f.useState(""),et=s.enabled,fe=f.useMemo(()=>(Array.isArray(m)?m:[]).map(Z=>({account:String((Z==null?void 0:Z.account)||"").trim(),can_read:(Z==null?void 0:Z.can_read)!==!1,can_send:(Z==null?void 0:Z.can_send)!==!1,label:""})).filter(Z=>!!Z.account),[m]),ue=f.useMemo(()=>{const P=String(v||"").trim();return P&&fe.find(Z=>Z.account===P)||null},[fe,v]),Ee=!!(ue!=null&&ue.can_read),se=!!(ue!=null&&ue.can_send),W=f.useMemo(()=>fe.map(P=>{const Z=P.can_read?P.can_send?"":" (read-only)":" (send-only)";return{...P,label:`${P.account}${Z}`}}),[fe]);async function ie(){if(et){q(""),A(!0);try{const P=await n.email_list_accounts();d(Array.isArray(P==null?void 0:P.accounts)?P.accounts:[]),x(String((P==null?void 0:P.default_account)||"").trim())}catch(P){q(String((P==null?void 0:P.message)||P||"Failed to list email accounts")),d([]),x("")}finally{A(!1)}}}f.useEffect(()=>{ie()},[et]),f.useEffect(()=>{if(!et)return;const P=String(v||"").trim();if(P&&fe.some(Pe=>Pe.account===P))return;const Z=String(localStorage.getItem("abstractcontinuum_email_account")||"").trim();if(Z&&fe.some(Pe=>Pe.account===Z)){g(Z);return}if(h&&fe.some(Pe=>Pe.account===h)){g(h);return}fe.length&&g(fe[0].account)},[et,v,h,fe]),f.useEffect(()=>{const P=String(v||"").trim();P&&localStorage.setItem("abstractcontinuum_email_account",P)},[v]);async function Se(){if(!et)return;const P=String(v||"").trim();if(P){if(!Ee){q("Selected account is not allowed to read email."),ee([]),k(""),re(null);return}q(""),Q(!0);try{const Z=await n.email_list_messages({account:P,mailbox:String(w||"").trim()||void 0,since:String(E||"").trim()||void 0,status:T,limit:z}),Pe=Array.isArray(Z==null?void 0:Z.messages)?Z.messages:[];ee(Pe);const Fe=String(ae||"").trim();Fe&&!Pe.some(Xe=>String((Xe==null?void 0:Xe.uid)||"").trim()===Fe)&&(k(""),re(null))}catch(Z){q(String((Z==null?void 0:Z.message)||Z||"Failed to list emails")),ee([]),k(""),re(null)}finally{Q(!1)}}}f.useEffect(()=>{et&&String(v||"").trim()&&Se()},[et,v]);async function Je(P){if(!et)return;const Z=String(v||"").trim(),Pe=String(P||"").trim();if(!(!Z||!Pe)&&Ee){k(Pe),re(null),Y(""),be(!0);try{const Fe=await n.email_read_message(Pe,{account:Z,mailbox:String(w||"").trim()||void 0,max_body_chars:2e4});re(Fe)}catch(Fe){Y(String((Fe==null?void 0:Fe.message)||Fe||"Failed to read email"))}finally{be(!1)}}}function F(P){X(""),we(String((P==null?void 0:P.to)||"").trim()),Oe(""),it(""),ot(String((P==null?void 0:P.subject)||"").trim()),ct(String((P==null?void 0:P.body)||"")),ce(!0)}function de(){if(!C)return;const P=String((C==null?void 0:C.from)||"").trim(),Z=String((C==null?void 0:C.subject)||"").trim(),Pe=Z.toLowerCase().startsWith("re:")?Z:`Re: ${Z||"(no subject)"}`,Fe=String((C==null?void 0:C.body_text)||"").trim(),Xe=`
98
+
99
+ ---
100
+ On ${Ah((C==null?void 0:C.date)||"")}, ${P} wrote:
101
+
102
+ ${Fe}`;F({to:P,subject:Pe,body:Xe})}async function ye(){if(!et||Ne)return;const P=String(v||"").trim();if(P){if(!se){X("Selected account is not allowed to send email.");return}X(""),je(!0);try{const Z=pd(O);if(!Z)throw new Error("to is required");const Pe=String(Be||"").trim();if(!Pe)throw new Error("subject is required");const Fe=String(Ve||"").trim();if(!Fe)throw new Error("body is required");await n.email_send({account:P,to:Z,subject:Pe,body_text:Fe,cc:pd($e),bcc:pd(Re)}),ce(!1),we(""),Oe(""),it(""),ot(""),ct(""),await Se()}catch(Z){X(String((Z==null?void 0:Z.message)||Z||"Failed to send email"))}finally{je(!1)}}}const xe=f.useMemo(()=>{const P=String(ae||"").trim();return P&&I.find(Z=>String((Z==null?void 0:Z.uid)||"").trim()===P)||null},[I,ae]),ke=String((C==null?void 0:C.body_text)||"").trim()||String((C==null?void 0:C.body_html)||"").trim(),J=String((C==null?void 0:C.body_text)||"").trim()?"Body (text)":String((C==null?void 0:C.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 Z,Pe;(Pe=(Z=P.target)==null?void 0:Z.closest)!=null&&Pe.call(Z,".inbox_item")&&requestAnimationFrame(()=>ol(u.current))},children:[e.jsx("div",{className:"pane_header",children:e.jsx(il,{open:r,on_toggle:i,controls:"inbox_email_list",title:"Email",count:I.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=>g(String(P.target.value||"")),disabled:!et||M,children:W.length?W.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 ie(),disabled:!et||M,children:M?"Loading…":"Accounts"})]}),e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn",onClick:()=>void Se(),disabled:!et||V||!String(v||"").trim()||!Ee,children:V?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn primary",onClick:()=>F(),disabled:!et||!String(v||"").trim()||!se,children:"Compose"})]})]}),e.jsxs("div",{className:"row",style:{gap:"8px",alignItems:"center",flexWrap:"wrap"},children:[e.jsxs("div",{className:"field",style:{margin:0,minWidth:120,flex:"1 1 120px"},children:[e.jsx("label",{children:"Since"}),e.jsx("input",{value:E,onChange: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:T,onChange:P=>H(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(z),onChange:P=>R(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:w,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 Se(),disabled:!et||V||!String(v||"").trim()||!Ee,children:"Apply"})})]}),Ce?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:Ce}):null,e.jsx("div",{className:"inbox_list",children:I.length?I.map((P,Z)=>{const Pe=String((P==null?void 0:P.uid)||"").trim(),Fe=!!Pe&&Pe===String(ae||"").trim(),Xe=String((P==null?void 0:P.subject)||"").trim()||"(no subject)",dt=String((P==null?void 0:P.from)||"").trim(),ft=String((P==null?void 0:P.date)||"").trim(),Le=!!(P!=null&&P.seen);return e.jsxs("button",{className:`inbox_item ${Fe?"active":""}`,onClick:()=>void Je(Pe),children:[e.jsxs("div",{className:"inbox_item_title",children:[e.jsx("span",{className:`pill ${Le?"approved":"pending"}`,children:Le?"read":"unread"}),e.jsx("span",{className:"item_title_text",children:Bo(Xe,52)})]}),e.jsx("div",{className:"inbox_item_meta mono muted",children:Bo(dt,60)||"(from?)"}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[Bo(ft,36)||"(date?)"," • uid ",Bo(Pe,10)]})]},Pe||`idx:${Z}`)}):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:()=>ol(l.current),children:"← Back to the list"})}),ae?oe?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}):C?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((C==null?void 0:C.subject)||"").trim()||"(no subject)"}),e.jsx("span",{className:"pill muted",children:String((C==null?void 0:C.account)||"").trim()||v}),e.jsx("span",{className:"pill muted",children:String((C==null?void 0:C.mailbox)||"").trim()||"(mailbox?)"}),e.jsxs("span",{className:"pill muted",children:["uid ",Bo(String((C==null?void 0:C.uid)||ae),12)]})]}),e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn",onClick:()=>on(String((C==null?void 0:C.message_id)||"")),disabled:!String((C==null?void 0:C.message_id)||"").trim(),title:"Copy Message-ID",children:"Copy msg-id"}),e.jsx("button",{className:"btn",onClick:()=>on(String(ae||"")),disabled:!String(ae||"").trim(),title:"Copy UID",children:"Copy uid"}),e.jsx("button",{className:"btn primary",onClick:()=>de(),disabled:!se||!String((C==null?void 0:C.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((C==null?void 0:C.from)||"").trim()||"(from?)"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"To"}),e.jsx("div",{className:"mono",children:String((C==null?void 0:C.to)||"").trim()||"(to?)"})]}),String((C==null?void 0:C.cc)||"").trim()?e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Cc"}),e.jsx("div",{className:"mono",children:String((C==null?void 0:C.cc)||"").trim()})]}):null,e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Date"}),e.jsx("div",{className:"mono",children:Ah(String((C==null?void 0:C.date)||(xe==null?void 0:xe.date)||"").trim())||String((C==null?void 0:C.date)||(xe==null?void 0:xe.date)||"").trim()||"(date?)"})]}),Array.isArray(C==null?void 0:C.attachments)&&C.attachments.length?e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Attachments"}),e.jsx("div",{className:"mono",children:C.attachments.map((P,Z)=>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)||""}:${Z}`))})]}):null,e.jsx("div",{className:"section_divider"}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:J}),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:ke||"(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(nr,{open:he,title:`Compose (${String(v||"").trim()||"account"})`,onClose:()=>{Ne||ce(!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:()=>ce(!1),disabled:Ne,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void ye(),disabled:Ne,children:Ne?"Sending…":"Send"})]}),children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"To"}),e.jsx("input",{value:O,onChange:P=>we(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:$e,onChange:P=>Oe(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:Re,onChange:P=>it(String(P.target.value||"")),placeholder:"(optional)"})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Subject"}),e.jsx("input",{value:Be,onChange:P=>ot(String(P.target.value||"")),placeholder:"Subject"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Body (text)"}),e.jsx("textarea",{value:Ve,onChange:P=>ct(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 Lh(s){const n=String(s||"").trim();if(!n)return"";const r=n.split("/").filter(Boolean);return r.length?r[r.length-1]:""}function jc(s){const n=String(s||"").trim();if(!n)return"";const r=Date.parse(n);return Number.isFinite(r)?new Date(r).toLocaleString():n}function Li(s,n){const r=String(s||"");return r.length<=n?r:`${r.slice(0,Math.max(0,n-1))}…`}function dw(s){const n=s.gateway,r=!!s.enable_triage,[i,l]=Pc("inbox_reports"),u=f.useRef(null),m=f.useRef(null),[d,h]=f.useState(r?"messages":"email"),[x,v]=f.useState([]),[g,w]=f.useState([]),[L,E]=f.useState([]),[$,T]=f.useState(!1),[H,z]=f.useState(""),[R,M]=f.useState(null),[A,V]=f.useState(""),[Q,oe]=f.useState(!1),[be,Ne]=f.useState(""),[je,Ce]=f.useState("pending"),[q,te]=f.useState(null),[Y,U]=f.useState(""),[X,I]=f.useState(null),[ee,ae]=f.useState(""),[k,C]=f.useState(!1),[re,he]=f.useState(!1),[ce,O]=f.useState(""),[we,$e]=f.useState(""),Oe=!!we,[Re,it]=f.useState(""),[Be,ot]=f.useState(""),[Ve,ct]=f.useState(""),[et,fe]=f.useState(!1),ue=s.gateway_connected;f.useEffect(()=>{!r&&d!=="email"&&h("email")},[r,d]);const Ee=f.useMemo(()=>d==="bugs"?x:d==="features"?g:[],[d,x,g]);f.useEffect(()=>{d==="email"&&(z(""),T(!1))},[d]);async function se(){const J=await n.list_bug_reports();v(Array.isArray(J==null?void 0:J.items)?J.items:[])}async function W(){const J=await n.list_feature_requests();w(Array.isArray(J==null?void 0:J.items)?J.items:[])}async function ie(){const J=await n.list_triage_decisions({status:je||void 0,limit:500}),P=Array.isArray(J==null?void 0:J.decisions)?J.decisions:[];E(P),q&&!P.some(Z=>Z.decision_id===q.decision_id)&&(te(null),U(""),I(null),ae(""))}async function Se(){if(ue&&r&&d!=="email"){z(""),T(!0);try{d==="bugs"?await se():d==="features"?await W():await ie()}catch(J){z(String((J==null?void 0:J.message)||J||"Refresh failed"))}finally{T(!1)}}}f.useEffect(()=>{Se()},[d,ue,je,r]);async function Je(J){M(J),V(""),Ne(""),oe(!0);try{if(J.report_type==="bug"){const P=await n.get_bug_report_content(J.filename);V(String((P==null?void 0:P.content)||""))}else{const P=await n.get_feature_request_content(J.filename);V(String((P==null?void 0:P.content)||""))}}catch(P){Ne(String((P==null?void 0:P.message)||P||"Failed to load report"))}finally{oe(!1)}}async function F(J){te(J),U(""),I(null),ae("");const P=Lh(J.report_relpath);if(P)try{if(J.report_type==="bug"){const Z=await n.get_bug_report_content(P);U(String((Z==null?void 0:Z.content)||""))}else if(J.report_type==="feature"){const Z=await n.get_feature_request_content(P);U(String((Z==null?void 0:Z.content)||""))}}catch(Z){ae(String((Z==null?void 0:Z.message)||Z||"Failed to load report"))}}async function de(J){ae(""),I(null);const P=String(J.draft_relpath||"").trim();if(!P)return;const Z=Lh(P);if(Z)try{const Pe=await n.backlog_content("proposed",Z);I(Pe)}catch(Pe){ae(String((Pe==null?void 0:Pe.message)||Pe||"Failed to load draft (is repo root configured on gateway?)"))}}async function ye(J,P){if(q&&!k){ae(""),C(!0);try{const Z=await n.apply_triage_decision(q.decision_id,{action:J,defer_days:P??null});await ie();const Pe=String(je||"").trim().toLowerCase(),Fe=String((Z==null?void 0:Z.status)||"").trim().toLowerCase();if(!(!Pe||Pe===Fe))te(null),U(""),I(null);else if(te(Z),String(Z.draft_relpath||"").trim())try{await de(Z)}catch{}}catch(Z){ae(String((Z==null?void 0:Z.message)||Z||"Decision action failed"))}finally{C(!1)}}}async function xe(){if(!re){z(""),he(!0);try{const J=await n.triage_run({write_drafts:!1,enable_llm:!1});O(`Scanned ${(J==null?void 0:J.reports)??0} report(s); updated ${(J==null?void 0:J.updated_decisions)??0} decision(s).`),await ie()}catch(J){z(String((J==null?void 0:J.message)||J||"Triage failed"))}finally{he(!1)}}}f.useEffect(()=>{Oe&&(ct(""),ot(""),fe(!1),it(String(s.default_session_id||"").trim()))},[Oe,s.default_session_id]);async function ke(){var J,P;if(we&&!et){ct(""),fe(!0);try{const Z=String(Re||"").trim();if(!Z)throw new Error("session_id is required");const Pe=String(Be||"").trim();if(!Pe)throw new Error("description is required");const Fe={session_id:Z,description:Pe,active_run_id:String(s.default_active_run_id||"").trim()||void 0,workflow_id:String(s.default_workflow_id||"").trim()||void 0,client:"abstractcontinuum/web",client_version:"",user_agent:String(((J=globalThis==null?void 0:globalThis.navigator)==null?void 0:J.userAgent)||""),url:String(((P=globalThis==null?void 0:globalThis.location)==null?void 0:P.href)||"")};if(we==="bug"){const Xe=await n.bug_report_create(Fe),dt=String((Xe==null?void 0:Xe.filename)||"").trim();$e(""),h("bugs");const ft=await n.list_bug_reports(),Le=Array.isArray(ft==null?void 0:ft.items)?ft.items:[];v(Le);const st=Le.find(pt=>pt.filename===dt)||null;st&&await Je(st)}else{const Xe=await n.feature_report_create(Fe),dt=String((Xe==null?void 0:Xe.filename)||"").trim();$e(""),h("features");const ft=await n.list_feature_requests(),Le=Array.isArray(ft==null?void 0:ft.items)?ft.items:[];w(Le);const st=Le.find(pt=>pt.filename===dt)||null;st&&await Je(st)}}catch(Z){ct(String((Z==null?void 0:Z.message)||Z||"Failed to create report"))}finally{fe(!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:()=>h("messages"),children:"Messages"}),e.jsx("button",{"aria-pressed":d==="email",className:`seg_btn ${d==="email"?"active":""}`,onClick:()=>h("email"),children:"Email"}),e.jsx("button",{"aria-pressed":d==="bugs",className:`seg_btn ${d==="bugs"?"active":""}`,onClick:()=>h("bugs"),children:"Bugs"}),e.jsx("button",{"aria-pressed":d==="features",className:`seg_btn ${d==="features"?"active":""}`,onClick:()=>h("features"),children:"Features"})]}):e.jsx("button",{"aria-pressed":d==="email",className:`seg_btn ${d==="email"?"active":""}`,onClick:()=>h("email"),children:"Email"})}),r&&d!=="email"&&ce?e.jsx("span",{className:"page_hint mono",children:ce}):null,r&&d!=="email"&&H?e.jsx("span",{className:"page_error mono",children:H}):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:je,onChange:J=>Ce(String(J.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 Se(),disabled:!ue||$,children:$?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn primary",onClick:()=>void xe(),disabled:!ue||re,children:re?"Running…":"Run triage"})]}):d==="email"?null:e.jsx("button",{className:"btn",onClick:()=>void Se(),disabled:!ue||$,children:$?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn",onClick:()=>$e("bug"),disabled:!ue,children:"File bug"}),e.jsx("button",{className:"btn",onClick:()=>$e("feature"),disabled:!ue,children:"File feature"})]}):null]}),d==="email"?e.jsx(uw,{gateway:n,enabled:ue}):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:J=>{var P,Z;(Z=(P=J.target)==null?void 0:P.closest)!=null&&Z.call(P,".inbox_item")&&requestAnimationFrame(()=>ol(m.current))},children:[e.jsx("div",{className:"pane_header",children:e.jsx(il,{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:Ee.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(J=>{const P=(q==null?void 0:q.decision_id)===J.decision_id,Z=Array.isArray(J.missing_fields)?J.missing_fields.length:0;return e.jsxs("button",{className:`inbox_item ${P?"active":""}`,onClick:()=>void F(J),children:[e.jsxs("div",{className:"inbox_item_title",children:[e.jsx("span",{className:`pill ${String(J.status||"").toLowerCase()}`,children:String(J.status||"pending")}),e.jsx("span",{className:"mono",children:J.report_type}),e.jsx("span",{className:"mono muted",children:Li(J.decision_id,10)})]}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[Z?`${Z} missing`:"complete"," • ",jc(J.updated_at||J.created_at)||"(time?)"]}),e.jsx("div",{className:"inbox_item_meta mono",children:Li(J.report_relpath||"",46)})]},J.decision_id)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No decisions."})}):e.jsx(e.Fragment,{children:Ee.length?Ee.map(J=>{const P=(R==null?void 0:R.filename)===J.filename&&(R==null?void 0:R.report_type)===J.report_type,Z=String(J.triage_status||"").trim().toLowerCase();return e.jsxs("button",{className:`inbox_item ${P?"active":""}`,onClick:()=>void Je(J),children:[e.jsxs("div",{className:"inbox_item_title",children:[Z?e.jsx("span",{className:`pill ${Z}`,children:Z}):null,e.jsx("span",{className:"mono",children:Li(J.title||J.filename,46)})]}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[jc(J.created_at)||"(time?)"," • ",J.session_id?Li(J.session_id,12):"session?"]}),e.jsx("div",{className:"inbox_item_meta mono",children:J.filename})]},J.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:()=>ol(u.current),children:"← Back to the list"})}),d==="messages"?q?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:q.report_type}),e.jsx("span",{className:"chip mono muted",children:q.status}),e.jsx("span",{className:"chip mono muted",children:Li(q.decision_id,16)})]}),e.jsxs("div",{className:"inbox_detail_actions",children:[e.jsx("button",{className:"btn",onClick:()=>{on(q.report_relpath||"")},children:"Copy report path"}),q.draft_relpath?e.jsx("button",{className:"btn",onClick:()=>void de(q),children:"Load draft"}):null,e.jsx("button",{className:"btn primary",onClick:()=>void ye("approve"),disabled:k,children:"Approve"}),e.jsx("button",{className:"btn",onClick:()=>void ye("defer",1),disabled:k,children:"Defer 1d"}),e.jsx("button",{className:"btn",onClick:()=>void ye("defer",7),disabled:k,children:"Defer 7d"}),e.jsx("button",{className:"btn",onClick:()=>void ye("reject"),disabled:k,children:"Reject"})]})]}),e.jsxs("div",{className:"inbox_detail_meta mono muted",style:{fontSize:"var(--font-size-sm)"},children:[q.updated_at?`updated ${jc(q.updated_at)}`:null,q.created_at?`${q.updated_at?" • ":""}created ${jc(q.created_at)}`:null,q.defer_until?` • defer until ${q.defer_until}`:null]}),ee?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:ee}):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"}),q.missing_fields&&q.missing_fields.length?e.jsx("ul",{className:"inbox_list_ul mono",children:q.missing_fields.map(J=>e.jsx("li",{children:J},J))}):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"}),q.duplicates&&q.duplicates.length?e.jsx("ul",{className:"inbox_list_ul mono",children:q.duplicates.slice(0,20).map((J,P)=>{const Z=String((J==null?void 0:J.title)||(J==null?void 0:J.ref)||(J==null?void 0:J.kind)||"duplicate").trim(),Pe=typeof(J==null?void 0:J.score)=="number"&&Number.isFinite(J.score)?` (score ${J.score.toFixed(2)})`:"";return e.jsxs("li",{children:[Z,Pe]},`${Z}_${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"}),q.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:q.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)."})]})]}),X?e.jsxs("div",{className:"inbox_markdown",children:[e.jsx("div",{className:"section_title",children:"Draft content"}),e.jsx(Qn,{className:"md_doc",text:String(X.content||"")})]}):null,e.jsxs("div",{className:"inbox_markdown",children:[e.jsx("div",{className:"section_title",children:"Source report"}),Y?e.jsx(Qn,{className:"md_doc",text:Y}):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."}):R?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:R.report_type==="bug"?"Bug report":"Feature request"}),R.triage_status?e.jsx("span",{className:`pill ${R.triage_status}`,children:R.triage_status}):null,e.jsx("span",{className:"chip mono muted",children:R.filename}),R.session_id?e.jsx("span",{className:"chip mono muted",children:Li(R.session_id,16)}):null]}),e.jsx("div",{className:"inbox_detail_actions",children:e.jsx("button",{className:"btn",onClick:()=>{on(R.relpath||"")},children:"Copy path"})})]}),be?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:be}):null,Q?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading…"}):A?e.jsx(Qn,{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(nr,{open:Oe,title:we==="bug"?"File bug report":"File feature request",onClose:()=>$e(""),actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>$e(""),disabled:et,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void ke(),disabled:et,children:et?"Submitting…":"Submit"})]}),children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Session ID"}),e.jsx("input",{value:Re,onChange:J=>it(J.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:we==="bug"?"Bug description":"Feature description"}),e.jsx("textarea",{value:Be,onChange:J=>ot(J.target.value),placeholder:we==="bug"?"What is broken? What did you expect?":"What do you want to be able to do?",rows:6})]}),Ve?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:Ve}):null]})]})}const mw="api/continuum/settings";async function l_(s){const n=await fetch(mw,{...s,signal:AbortSignal.timeout(1e4),headers:s!=null&&s.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 fw(){return l_()}function hw(s,n){return l_({method:"PUT",body:JSON.stringify({[s]:n})})}const c_="abstractcontinuum_voice_override_v1",_d={enabled:!1};function Od(){try{const s=localStorage.getItem(c_);if(!s)return{..._d};const n=JSON.parse(s);return!n||typeof n!="object"?{..._d}:{enabled:!!n.enabled,provider:Us(n.provider),model:Us(n.model),profile:Us(n.profile),voice:Us(n.voice),quality_preset:Us(n.quality_preset)}}catch{return{..._d}}}const Fd="abstractcontinuum:voice_override_changed";function pw(s){try{localStorage.setItem(c_,JSON.stringify(s))}catch{}try{window.dispatchEvent(new CustomEvent(Fd))}catch{}}function u_(s){if(!s)return{};const n={},r=Us(s.quality_preset);if(r&&(n.quality_preset=r),!s.enabled)return n;for(const i of["provider","model","profile","voice"]){const l=Us(s[i]);l&&(n[i]=l)}return n}function Us(s){return String(s??"").trim()||void 0}function d_(s){const n=s&&typeof s=="object"?s.routes:null;if(!Array.isArray(n))return{};const r=x=>n.find(v=>v&&typeof v=="object"&&String(v.key||"").trim()===x&&!!v.configured),i=r("output.voice.tts")||r("output.voice");if(!i)return{};const l={},u=Us(i.provider),m=Us(i.model),d=i.options,h=d&&typeof d=="object"?Us(d.voice):void 0;return u&&(l.provider=u),m&&(l.model=m),h&&(l.voice=h),l}function _w(s){let n=String(s||"");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 Uo={loading:!1,error:"",providers:[],models_by_provider:{},profiles_by_provider:{},voices_by_provider:{},cloned_by_provider:{}};function gw(s){const n={};if(!Array.isArray(s))return n;for(const r of s){if(!r||typeof r!="object")continue;const i=r.voice_kinds;if(!(Array.isArray(i)&&i.some(h=>String(h).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 qd(s){if(!Array.isArray(s))return[];const n=[];for(const r of s)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 gd(s){const n={};if(s&&typeof s=="object"&&!Array.isArray(s))for(const[r,i]of Object.entries(s)){const l=qd(i);l.length&&(n[String(r)]=l)}return n}function yw(s){const{gateway:n,gateway_connected:r}=s,[i,l]=f.useState(()=>Od()),[u,m]=f.useState(Uo),[d,h]=f.useState(!1),[x,v]=f.useState(""),g=f.useRef(null),w=f.useCallback(R=>{l(M=>{const A={...M,...R};return pw(A),A})},[]);f.useEffect(()=>{if(!r){m(Uo);return}if(typeof(n==null?void 0:n.voice_voices)!="function"){m(Uo);return}let R=!0;m(A=>({...A,loading:!0,error:""}));let M;try{M=n.voice_voices()}catch(A){m({...Uo,error:String((A==null?void 0:A.message)||A||"voice catalog unavailable")});return}return M.then(A=>{if(!R)return;const V=[...new Set([...qd(A==null?void 0:A.providers),...qd(A==null?void 0:A.tts_providers)])];m({loading:!1,error:"",providers:V,models_by_provider:gd(A==null?void 0:A.tts_models_by_provider),profiles_by_provider:gd(A==null?void 0:A.tts_profiles_by_provider),voices_by_provider:gd(A==null?void 0:A.tts_voices_by_provider),cloned_by_provider:gw(A==null?void 0:A.items)})}).catch(A=>{R&&m({...Uo,error:String((A==null?void 0:A.message)||A||"voice catalog unavailable")})}),()=>{R=!1}},[n,r]);const L=i.provider||"",E=L&&u.models_by_provider[L]?u.models_by_provider[L]:[],$=L&&u.voices_by_provider[L]?u.voices_by_provider[L]:[],T=L&&u.profiles_by_provider[L]?u.profiles_by_provider[L]:[],H=[...L&&u.cloned_by_provider[L]?u.cloned_by_provider[L]:[],...u.cloned_by_provider["*"]||[]];async function z(){if(!(d||!r)){h(!0),v("");try{const R=await Qd("abstractcontinuum_team_voice");let M={};if(typeof n.capability_defaults=="function")try{M=d_(await n.capability_defaults())}catch{M={}}const A=await n.voice_tts(R,{text:"This is the voice AbstractContinuum will use to read your messages.",...M,...u_(i),timeout_s:30}),V=A==null?void 0:A.audio_artifact,Q=V&&typeof V=="object"?String(V.$artifact||"").trim():"";if(!Q)throw new Error("no audio returned");const oe=await n.download_run_artifact_content(R,Q),be=URL.createObjectURL(oe);if(g.current)try{g.current.pause()}catch{}const Ne=g.current;if(Ne){try{Ne.pause()}catch{}const Ce=Ne.src;Ce.startsWith("blob:")&&URL.revokeObjectURL(Ce)}const je=new Audio(be);g.current=je,je.onended=()=>{URL.revokeObjectURL(be),v("")};try{await je.play(),v("Playing…")}catch(Ce){v(String((Ce==null?void 0:Ce.name)||"").includes("NotAllowed")?"Synthesized OK — click Test again to play.":`Playback failed: ${String((Ce==null?void 0:Ce.message)||Ce).slice(0,80)}`),URL.revokeObjectURL(be)}}catch(R){v(`Test failed: ${String((R==null?void 0:R.message)||R||"synthesis error").slice(0,120)}`)}finally{h(!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(Di,{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:R=>w({enabled:R})}),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(kc,{value:L,options:u.providers,placeholder:"gateway default",onChange:R=>w({provider:R,model:"",voice:"",profile:""})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Model"}),e.jsx(kc,{value:i.model||"",options:E,placeholder:"default",onChange:R=>w({model:R})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Base voice"}),e.jsx(kc,{value:i.profile||"",options:T,placeholder:"default",onChange:R=>w({profile:R})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Cloned voice"}),e.jsx(kc,{value:i.voice||"",options:[...H,...$],placeholder:"none",onChange:R=>w({voice:R})})]})]}):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:R=>w({quality_preset:R.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 z(),children:d?"Synthesizing…":"Test voice"}),x?e.jsx("span",{className:"muted team_note",children:x}):null]})]}):e.jsx("div",{className:"muted team_note",children:"Connect to the gateway to configure and test message voice."})})]})}function kc(s){const n=Wt.useId();return e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"team_compose_control mono",list:n,value:s.value,placeholder:s.placeholder||"",onChange:r=>s.onChange(r.target.value.trim())}),s.options.length?e.jsx("datalist",{id:n,children:s.options.map(r=>e.jsx("option",{value:r},r))}):null]})}const vw=["minimal","low","medium","high","xhigh"];function xw(s){const{gateway:n,connected:r,model:i,value:l,onChange:u}=s,[m,d]=f.useState({state:"unknown",levels:[]}),[h,x]=f.useState(!1);if(f.useEffect(()=>{x(!1);const w=String(i||"").trim();if(!w||!r){d({state:"unknown",levels:[]});return}let L=!1;return d({state:"loading",levels:[]}),n.discovery_model_capabilities(w).then(E=>{if(L)return;const $=E!=null&&E.capabilities&&typeof E.capabilities=="object"?E.capabilities:{},T=$.thinking_support,H=Array.isArray($.reasoning_levels)?$.reasoning_levels.map(z=>String(z)):[];d(T===!0?{state:"supported",levels:H}:T===!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"&&!h||m.state==="loading",g=m.state==="supported"&&m.levels.length?m.levels:m.state==="unknown"&&h?[...vw]:[];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:w=>u(String(w.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"&&!h?"unknown — no served facts":"gateway default"}),g.map(w=>e.jsx("option",{value:w,children:w},w))]}),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:h,onChange:w=>{x(w.target.checked),w.target.checked||u("")}}),"set anyway (I know this model reasons)"]}):null]})}function bw(s){const[n,r]=f.useState(!1),[i,l]=f.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:s.busy}),e.jsx("button",{className:"btn primary",disabled:s.busy||!i.trim(),onClick:()=>{s.on_apply(i.trim()),r(!1)},children:"Apply"}),e.jsx("button",{className:"btn",disabled:s.busy,onClick:()=>r(!1),children:"Cancel"})]}):e.jsx("button",{className:"btn",disabled:s.busy,onClick:()=>{l(s.current),r(!0)},children:s.current?"Change…":"Set…"})}function ww(s){const n=String(s||"").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 jw(){var E;const[s,n]=f.useState(null),[r,i]=f.useState(""),[l,u]=f.useState(""),[m,d]=f.useState(!1),[h,x]=f.useState("");f.useEffect(()=>{let $=!1;return fw().then(T=>{var H;$||(n(T),u(String(((H=T.settings.hub_seat)==null?void 0:H.value)??"")))}).catch(T=>{$||i(String((T==null?void 0:T.message)||T))}),()=>{$=!0}},[]);async function v($){var T;d(!0),x("");try{const H=await hw("hub_seat",$);n(H),u(String(((T=H.settings.hub_seat)==null?void 0:T.value)??""))}catch(H){x(String((H==null?void 0:H.message)||H||"Save refused"))}finally{d(!1)}}const g=s==null?void 0:s.settings.hub_seat,w=String((g==null?void 0:g.value)??""),L=!!((E=s==null?void 0:s.writable)!=null&&E.includes("hub_seat"));return e.jsxs("div",{className:"pane","data-testid":"hub_seat_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Team (agora hub)"}),e.jsx("span",{className:"pane_subtitle",children:"server-side — this Continuum"})]}),e.jsx("div",{className:"pane_body",children:s?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:w}),ww(g==null?void 0:g.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()===w&&(g==null?void 0:g.source)==="setting",onClick:()=>void v(l.trim()),children:"Save"}),(g==null?void 0:g.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:s.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.",(g==null?void 0:g.source)==="flag"?" A launch flag sets the seat for this run; a saved value applies once Continuum restarts without it.":null]}),h?e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:h}):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 kw(s){var te,Y;const{gateway:n,gateway_connected:r,settings:i,set_settings:l}=s,u=(Y=(te=s.connection)==null?void 0:te.gateway)==null?void 0:Y.principal,[m,d]=f.useState({loaded:!1,process_manager:null,backlog_root:null,exec_pipeline:null,exec_detail:"",executor:""}),[h,x]=f.useState(null),[v,g]=f.useState(null),[w,L]=f.useState(!1),[E,$]=f.useState(null),[T,H]=f.useState([]),[z,R]=f.useState(""),[M,A]=f.useState(""),[V,Q]=f.useState(!1),[oe,be]=f.useState(0);async function Ne(U,X=""){if(!V){Q(!0),R(""),A("");try{const I=await n.admin_runtime_config_update(U);x(I),A(X),be(ee=>ee+1)}catch(I){R(String((I==null?void 0:I.message)||I||"Config update refused"))}finally{Q(!1)}}}f.useEffect(()=>{if(!r)return;let U=!1;return(async()=>{var I;const X={loaded:!0,process_manager:null,backlog_root:null,exec_pipeline:null,exec_detail:"",executor:""};try{const ee=await n.backlog_exec_config(),ae=!!(ee!=null&&ee.runner_enabled),k=!!(ee!=null&&ee.runner_alive),C=(ee==null?void 0:ee.can_execute)===!0;X.exec_pipeline=C?"on":ae||k?"degraded":"off",X.exec_detail=C?"":ae?k?"runner alive but cannot execute (executor missing?)":"runner enabled but not alive":"runner disabled",X.executor=String((ee==null?void 0:ee.executor)||"").trim()}catch{X.exec_pipeline=null}try{const ee=await n.admin_runtime_config();if(ee&&typeof ee=="object"){U||(x(ee),X.process_manager=wc(ee.process_manager),X.backlog_root=((I=ee.triage_repo_root)==null?void 0:I.available)!==void 0?!!ee.triage_repo_root.available:wc(ee.triage_repo_root),d(X));return}}catch{}try{const ee=await n.list_processes();X.process_manager=!!(ee!=null&&ee.enabled)}catch{X.process_manager=null}try{await n.backlog_template(),X.backlog_root=!0}catch(ee){X.backlog_root=Ii(ee)?!1:null}U||d(X)})(),(async()=>{try{const X=await n.admin_data_homes();U||($(Array.isArray(X==null?void 0:X.homes)?X.homes:[]),H(Array.isArray(X==null?void 0:X.warnings)?X.warnings:[]))}catch{U||$(null)}})(),(async()=>{try{const X=await n.list_bundles(),I=Array.isArray(X==null?void 0:X.items)?X.items:Array.isArray(X==null?void 0:X.bundles)?X.bundles:Array.isArray(X)?X:[],ee=[];for(const C of I){const re=String((C==null?void 0:C.bundle_id)||(C==null?void 0:C.id)||"").trim();if(!re)continue;const he=Array.isArray(C==null?void 0:C.entrypoints)?C.entrypoints:[];for(const ce of he){if((ce==null?void 0:ce.deprecated)===!0||!(Array.isArray(ce==null?void 0:ce.interfaces)?ce.interfaces:[]).some($e=>String($e||"").trim().length>0))continue;const we=String((ce==null?void 0:ce.name)||"").trim();ee.push({id:re,name:we?`${re} · ${we}`:re,description:String((ce==null?void 0:ce.description)||"").trim()||void 0})}}const ae=new Set,k=ee.filter(C=>ae.has(C.id)?!1:(ae.add(C.id),!0));k.sort((C,re)=>C.name.localeCompare(re.name)),U||g(k)}catch{U||g(null)}})(),()=>{U=!0}},[n,r,oe]);function je(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 Ce(U,X="on",I="off"){return U===null?e.jsx("span",{className:"chip mono muted",children:"unknown"}):e.jsx("span",{className:`chip mono ${U?"ok":"warn"}`,children:U?X:I})}function q(U){const X=String(U||"").trim();if(!X)return null;const I={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."]},[ee,ae,k]=I[X]||[X,"muted",""];return e.jsx("span",{className:`chip mono ${ae}`,title:k,"data-testid":"source_chip",children:ee})}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(X=>({...X,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($g,{disabled:!r,value:{provider:i.maintenance_ai_provider,model:i.maintenance_ai_model},onChange:U=>l(X=>({...X,maintenance_ai_provider:U.provider,maintenance_ai_model:U.model,maintenance_ai_reasoning:U.model===X.maintenance_ai_model?X.maintenance_ai_reasoning:""})),fetchProviders:async()=>{const U=await n.discovery_providers();return(Array.isArray(U==null?void 0:U.items)?U.items:[]).map(X=>({name:X.name,display_name:X.display_name}))},fetchModels:async U=>{const X=await n.discovery_provider_models(U);return Array.isArray(X==null?void 0:X.models)?X.models:[]},defaultHint:"Uses the gateway's configured default provider and model for maintenance calls."})]}),e.jsx(xw,{gateway:n,connected:r,model:i.maintenance_ai_model,value:i.maintenance_ai_reasoning,onChange:U=>l(X=>({...X,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(X=>({...X,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(),X=U===""||v.some(I=>I.id===U);return e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:X&&!w?U:"__custom__",onChange:I=>{const ee=I.target.value;ee==="__custom__"?L(!0):(L(!1),l(ae=>({...ae,backlog_advisor_agent:ee})))},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(I=>e.jsx("option",{value:I.id,title:I.description||void 0,children:I.name||I.id},I.id)),e.jsx("option",{value:"__custom__",children:"custom bundle id…"})]}),!X||w?e.jsx("input",{className:"mono",style:{marginTop:6},value:i.backlog_advisor_agent,onChange:I=>l(ee=>({...ee,backlog_advisor_agent:String(I.target.value||"")})),placeholder:"bundle id (e.g. docs-qa@0.1.0)"}):null]})})()]})]})]}),e.jsx(yw,{gateway:n,gateway_connected:r}),e.jsx(jw,{}),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,C,re,he,ce,O,we,$e,Oe;const U=(h==null?void 0:h.writable)===!0,X=Array.isArray(h==null?void 0:h.executors)?h.executors:[],I=U?null:h?h.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).",ee=h?wc(h.backlog_exec_runner)===!0:m.exec_pipeline==="on"||m.exec_pipeline==="degraded",ae=h?wc(h.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"}),Ce(m.backlog_root,"available","not available"),q((k=h==null?void 0:h.triage_repo_root)==null?void 0:k.source),e.jsxs("div",{className:"admin_row_action",children:[U&&((C=h==null?void 0:h.triage_repo_root)!=null&&C.default_path)&&Fo(h==null?void 0:h.triage_repo_root)!==h.triage_repo_root.default_path?e.jsx("button",{className:"btn",disabled:V,onClick:()=>{var Re;return void Ne({triage_repo_root:((Re=h==null?void 0:h.triage_repo_root)==null?void 0:Re.default_path)||null})},title:h.triage_repo_root.default_path,children:"Use the gateway's own folder"}):null,U?e.jsx(bw,{current:Fo(h==null?void 0:h.triage_repo_root),busy:V,on_apply:Re=>void Ne({triage_repo_root:Re})}):null]})]}),e.jsxs("div",{className:"admin_row_detail",children:[((re=h==null?void 0:h.triage_repo_root)==null?void 0:re.help)||"The folder whose docs/backlog holds the items the Board and Backlog pages show.",Fo(h==null?void 0:h.triage_repo_root)?e.jsxs(e.Fragment,{children:[" ","In use: ",e.jsx("code",{children:Fo(h==null?void 0:h.triage_repo_root)})]}):null,((he=h==null?void 0:h.triage_repo_root)==null?void 0:he.available)===!1&&h.triage_repo_root.reason?e.jsxs(e.Fragment,{children:[" — not available: ",h.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(Di,{label:"Exec runner",action:"exec-runner",checked:ee,unavailableReason:I,busy:V,onChange:Re=>void Ne({backlog_exec_runner:Re},Re?"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"}):ee&&m.exec_pipeline!=="on"?e.jsx("span",{className:"chip mono warn",title:m.exec_detail,children:"degraded"}):null,q((ce=h==null?void 0:h.backlog_exec_runner)==null?void 0:ce.source)]}),e.jsxs("div",{className:"admin_row_detail",children:[((O=h==null?void 0:h.backlog_exec_runner)==null?void 0:O.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"}),q((we=h==null?void 0:h.executor)==null?void 0:we.source),e.jsx("div",{className:"admin_row_action",children:U&&X.length?e.jsx("select",{value:Fo(h==null?void 0:h.executor),disabled:V,onChange:Re=>void Ne({executor:String(Re.target.value||"")}),title:"Pick the execution agent (validated by the gateway registry)",children:X.map(Re=>e.jsxs("option",{value:Re.id,disabled:Re.available===!1,children:[Re.display||Re.id,Re.available===!1?" (unavailable)":""]},Re.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(Di,{label:"Process manager",action:"process-manager",checked:ae,unavailableReason:I,busy:V,onChange:Re=>void Ne({process_manager:Re},Re?"Process manager is on.":"Process manager is off.")}),!h&&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,q(($e=h==null?void 0:h.process_manager)==null?void 0:$e.source)]}),e.jsx("div",{className:"admin_row_detail",children:((Oe=h==null?void 0:h.process_manager)==null?void 0:Oe.help)||"Powers the Services page. High trust: whoever reaches Services can redeploy."})]})]})})(),z?e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:z}):null,M&&!z?e.jsx("div",{className:"muted",role:"status","data-testid":"admin_notice",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:M}):null,e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:h?h.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.":h.writable===!1?"This gateway serves the admin config surface, but your principal is not authorized to change it (admin only).":"This gateway serves the admin config surface (write authority unknown — it predates the writable flag).":"This gateway does not serve its settings to Continuum (older build): update the gateway to change these from here."})]}):e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:"Connect to a gateway to see its posture (top-right control)."})})]}),e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Data and caches"}),e.jsx("span",{className:"pane_subtitle",children:E?`server-side — ${E.length} registered home${E.length===1?"":"s"}`:"server-side — read-only telemetry"})]}),e.jsx("div",{className:"pane_body",children:r?E===null?e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:"This gateway does not serve the data-homes registry yet (older build) — the table lights up on its next restart. Purge actions live on the gateway console either way; this card is read-only by design."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"table_scroll",children:e.jsxs("table",{className:"data_table mono",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"name"}),e.jsx("th",{children:"kind"}),e.jsx("th",{children:"owner"}),e.jsx("th",{children:"size"}),e.jsx("th",{children:"purge"})]})}),e.jsx("tbody",{children:[...E].sort((U,X)=>(X.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"}):je(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))})]})}),T.map((U,X)=>e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:U},`dhw:${X}`)),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 Sw=/^(```+|~~~+)\s*mermaid\s*$/i;function Nw(s){const n=String(s||"").split(`
103
+ `),r=[];let i=[],l=0;for(;l<n.length;){const u=n[l].match(Sw);if(!u){i.push(n[l]),l+=1;continue}const m=u[1];let d=-1;for(let h=l+1;h<n.length;h++){const x=n[h].trimEnd();if(x.startsWith(m[0].repeat(3))&&/^(`{3,}|~{3,})\s*$/.test(x)&&x[0]===m[0]){d=h;break}}if(d===-1){i.push(n[l]),l+=1;continue}i.length&&(r.push({kind:"md",text:i.join(`
104
+ `)}),i=[]),r.push({kind:"mermaid",text:n.slice(l+1,d).join(`
105
+ `)}),l=d+1}return i.length&&r.push({kind:"md",text:i.join(`
106
+ `)}),r}const Cw="modulepreload",$w=function(s,n){return new URL(s,n).href},Mh={},Ew=function(n,r,i){let l=Promise.resolve();if(r&&r.length>0){let m=function(v){return Promise.all(v.map(g=>Promise.resolve(g).then(w=>({status:"fulfilled",value:w}),w=>({status:"rejected",reason:w}))))};const d=document.getElementsByTagName("link"),h=document.querySelector("meta[property=csp-nonce]"),x=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));l=m(r.map(v=>{if(v=$w(v,i),v in Mh)return;Mh[v]=!0;const g=v.endsWith(".css"),w=g?'[rel="stylesheet"]':"";if(!!i)for(let $=d.length-1;$>=0;$--){const T=d[$];if(T.href===v&&(!g||T.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${v}"]${w}`))return;const E=document.createElement("link");if(E.rel=g?"stylesheet":Cw,g||(E.as="script"),E.crossOrigin="",E.href=v,x&&E.setAttribute("nonce",x),document.head.appendChild(E),g)return new Promise(($,T)=>{E.addEventListener("load",$),E.addEventListener("error",()=>T(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 yd=null;function Tw(){return yd||(yd=Ew(()=>import("./mermaid.core-DzIYYQn8.js").then(s=>s.bp),[],import.meta.url).then(s=>{const n=s.default||s;return n.initialize({startOnLoad:!1,securityLevel:"strict",theme:"dark"}),n})),yd}let Aw=0;function Lw(s){const n=f.useRef(null),[r,i]=f.useState("");return f.useEffect(()=>{let l=!0;return i(""),Tw().then(async u=>{const m=`af_mermaid_${Aw+=1}`,{svg:d}=await u.render(m,s.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}},[s.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:s.text})]}):e.jsx("div",{className:"team_mermaid",ref:n})}const m_=5e4,Mw="abstractcontinuum history_window.estimate_tokens (~4 chars per token)";function Rw(s){const n=String(s??"");return n?Math.max(1,Math.floor(n.length/4)):0}function Pw(s,n,r=m_){if(!Number.isInteger(r)||r<=0)throw new Error(`history window max_tokens must be a positive integer, got ${r}`);const i=s.map(h=>({item:h,tokens:n(h)}));let l=0,u=i.length,m=!1;for(let h=i.length-1;h>=0;h--){const x=i[h].tokens;if(l+x>r){u===i.length&&(m=!0,l+=x,u=h);break}l+=x,u=h}const d=i.slice(0,u);return{kept:i.slice(u).map(h=>h.item),report:{policy:"newest_whole_messages",max_tokens:r,token_estimator:Mw,total_messages:i.length,replayed_messages:i.length-u,replayed_tokens:l,dropped_messages:d.length,dropped_tokens:d.reduce((h,x)=>h+x.tokens,0),oversize_message_kept:m}}}const zw=400;function Iw(s){const n=new Map;for(const l of s)n.set(l.id,l);const r=l=>{let u=l,m=!1;const d=new Set([u.id]);for(let h=0;h<zw;h++){const x=String(u.reply_to||"");if(!x)break;const v=n.get(x);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[...s].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 Rh=[{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 f_(s,n,r){var l,u,m,d,h;if(s.retracted===!0)return n==="all"?!0:n==="unread"?!!((l=r.unread_seqs)!=null&&l.has(s.seq)||(u=r.unread_snapshot_seqs)!=null&&u.has(s.seq)):!1;const i=String(s.status||"").toLowerCase();switch(n){case"all":return!0;case"unread":return!!((m=r.unread_seqs)!=null&&m.has(s.seq)||(d=r.unread_snapshot_seqs)!=null&&d.has(s.seq));case"asks":return i==="open"||i==="blocked";case"fyi":return i==="fyi";case"resolved":return i==="resolved";case"to_me":return Array.isArray(s.to)&&s.to.includes(r.seat);case"vigilance":{const x=(i==="open"||i==="blocked")&&s.has_resolved_reply!==!0,v=s.critical===!0,g=Array.isArray(s.to)&&s.to.includes(r.seat),w=!!((h=r.escalated_seqs)!=null&&h.has(s.seq));return x||v||g||w}}}function Ph(s,n,r){return n==="all"?s:s.filter(i=>[i.root,...i.replies].some(l=>f_(l,n,r)))}function Dw(s,n,r){return f_(s,n,r)}function Ow(s){const n={},r={};for(const i of s){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 Fw(s){const n={};for(const r of s){const i=String(r.channel||""),l=Number(r.seq);!i||!Number.isFinite(l)||(n[i]||(n[i]=new Set)).add(l)}return n}function qw(s,n){const r={};for(const i of s){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 Bw(s){const n={};for(const r of s){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 Uw(s,n){const r=n?n.replace(/\/+$/,"")+"/":"",i=new Map,l=[];for(const u of s){const m=String(u.path||"");if(!m.startsWith(r))continue;const d=m.slice(r.length);if(!d)continue;const h=d.indexOf("/");if(h===-1)l.push(u);else{const x=d.slice(0,h);i.set(x,(i.get(x)||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 zh(s,n){const r=String(s||"");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 Ww(s){return s.is_reply?"reply":s.in_dm||s.kind==="ask"?"open":"fyi"}function Hw(s){const n=new Map;for(const i of s)i.id&&n.set(i.id,String(i.sender||""));const r=new Set;for(const i of s){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 Vw=/(?:^|[\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,Gw=4;function Kw(s){const n=[];for(const r of String(s||"").matchAll(Vw)){const i=r[1],l=r.index===void 0?-1:r.index,u=l>=0?String(s).slice(Math.max(0,l-12),l+1):"";if(!(u.includes("://")||/\/api\//.test(u))&&(n.includes(i)||n.push(i),n.length>=Gw))break}return n}function Jw(s,n,r){var l,u;const i=s.split("/").pop()||s;if(n!=null&&n.has(s))return{kind:"fs",path:s,rewritten:!1};for(let m=0;m<r.length;m++)if(String(((l=r[m])==null?void 0:l.filename)||"")===s)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]!==s}}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 Ih=/@([A-Za-z0-9][A-Za-z0-9_.-]*)/g;function vd(s){const n=[];for(const i of s.matchAll(Ih)){const l=i[1].toLowerCase();n.includes(l)||n.push(l)}return{title:s.replace(Ih," ").split(/\s+/).join(" ").trim().replace(/^[\s,;:-]+|[\s,;:-]+$/g,""),members:n}}function xd(s){const n=[];for(const r of String(s||"").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 bd(s,n){let r=s.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 Dh=400,Oh=/([.;:!?…]["')\]]*) +(\((?:\d{1,2}|[a-z])\)|\[\d{1,2}\]) (?=["'([{]?[A-Za-z0-9])/g,Fh=/([.;:!?…]["')\]]*) +(?=[A-Z][A-Z'-]+(?: [A-Z][A-Z'-]*)+)/g;function Qw(s){if(!s||s.length<Dh)return s;const n=s.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<Dh){r.push(u);continue}const m=u.split(/(`[^`\n]*`)/);let d=0;for(const h of m)h.startsWith("`")||(d+=(h.match(Oh)||[]).length+(h.match(Fh)||[]).length);if(d<2){r.push(u);continue}r.push(m.map(h=>h.startsWith("`")?h:h.replace(Oh,`$1
107
+
108
+ $2 `).replace(Fh,`$1
109
+
110
+ `)).join(""))}}return r.join("")}const Yw=/https?:\/\/[^\s<>()[\]{}"'`]+/g,Xw=/\.(png|jpe?g|gif|webp)$/i;function Zw(s,n){if(!n)return s;const r=n.replace(/\/+$/,"");if(!s.startsWith(r+"/"))return s;const l=s.slice(r.length).match(/^\/channels\/([^/]+)\/attachments\/([A-Za-z0-9_.-]+)$/);return l?`api/hub/channels/${l[1]}/attachments/${l[2]}`:s}function ej(s,n){if(!s||!/https?:\/\//.test(s))return s;const r=(n==null?void 0:n.hub_base)||"",i=(n==null?void 0:n.app_origin)||"",l=s.split(/(```[\s\S]*?(?:```|$))/),u=[];for(let m=0;m<l.length;m++){const d=l[m];if(d.startsWith("```")){u.push(d);continue}const h=d.split(/(`[^`\n]*`)/);for(let x=0;x<h.length;x++){const v=h[x];if(v.startsWith("`")){u.push(v);continue}u.push(v.replace(Yw,(g,w)=>{const L=v.slice(Math.max(0,w-2),w);if(L.endsWith("](")||L.endsWith("("))return g;const E=g.replace(/[.,;:!?]+$/,""),$=g.slice(E.length);let T="";try{T=new URL(E).pathname}catch{return g}const H=Zw(E,r),z=Xw.test(T),R=H!==E||i!==""&&H.startsWith(i+"/");return z&&R?`![image](${H})${$}`:`[${E}](${H})${$}`}))}}return u.join("")}const tj=/^api\/hub\/channels\/[^/]+\/attachments\/[A-Za-z0-9_-]+$/;function nj(s){const n=s.trim(),r=n.replace(/^\.\//,"").replace(/^\//,"");return r.startsWith("api/")?n.startsWith("/")||/\s/.test(r)||r.includes("..")?!0:!tj.test(r):!1}function Xo(s){if(!s||!s.includes("api/"))return s;const n=/(!?)\[([^\]]*)\]\(([^)]+)\)/g;return s.replace(n,(r,i,l,u)=>nj(String(u))?"`"+(String(l||"").trim()||String(u)).replace(/`/g,"")+" (blocked link)`":r)}function rm(s){let n=0;for(let r=0;r<s.length;r++)n=n*31+s.charCodeAt(r)>>>0;return n%360}function sj(s){var u,m,d,h;const n=Array.isArray(s.to)&&s.to.length?` to=[${s.to.join(",")}]`:"",r=(m=(u=s.data)==null?void 0:u.asks)!=null&&m.length?` asks=${s.data.asks.map(x=>`${x.id}:"${x.text}"`).join("; ")}`:"",i=(h=(d=s.data)==null?void 0:d.answers)!=null&&h.length?` answers=[${s.data.answers.join(",")}]`:"",l=s.reply_to?` reply_to=${s.reply_to}`:"";return`#${s.seq} [${s.sender}] (${s.status})${n}${l}${r}${i}
111
+ ${s.title?`title: ${s.title}
112
+ `:""}${String(s.body||"").trim()}`}function qh(s,n){const r=m_,l=[...s].sort((h,x)=>(h.seq||0)-(x.seq||0)).map(sj),{kept:u,report:m}=Pw(l,Rw,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(`
113
+ `)}
114
+
115
+ ${u.join(`
116
+
117
+ `)}`,report:m}}function Bh(s){const n=r=>`message${r===1?"":"s"}`;return s.dropped_messages<=0?`${s.replayed_messages} ${n(s.replayed_messages)}`:`${s.replayed_messages} of ${s.total_messages} ${n(s.total_messages)} (${s.dropped_messages} oldest dropped by the ${s.max_tokens.toLocaleString("en-US")}-token history window)`}function aj(s,n){let r=Number(s.up||0),i=Number(s.down||0),l=Number(s.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 rj(s,n){const r=Array.from(String(s??"")),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 h=Math.max(m,u),x=Math.min(m+d,r.length);x<=h||(h>u&&l.push({text:r.slice(u,h).join(""),hit:!1}),l.push({text:r.slice(h,x).join(""),hit:!0}),u=x)}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 Sc=[{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"}],ij=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function Ir(s,n){const r=s.toLowerCase().split(".").pop()||"",i=String(n||"").toLowerCase();if(r==="md"||r==="markdown"||i==="text/markdown")return"md";if(ij.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 oj({url:s,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:s,target:"_blank",rel:"noreferrer",download:!0,children:["Download ",n]})]}):e.jsx("img",{className:"team_fileview_img",src:s,alt:n,onError:()=>i(!0)})}function lj({view:s,onClose:n}){if(!s)return null;const r=s.url?e.jsxs("a",{className:"btn primary",href:s.url,target:"_blank",rel:"noreferrer",download:!0,children:["Download ",s.name]}):null;return e.jsxs(nr,{open:!0,title:s.name,onClose:n,variant:"default",children:[s.meta?e.jsx("div",{className:"muted team_note",style:{marginBottom:8},children:s.meta}):null,s.loading?e.jsx("div",{className:"muted team_note",children:"Loading…"}):s.error?e.jsxs("div",{className:"team_fileview_dl",children:[e.jsx("div",{className:"page_error mono",children:s.error}),r]}):s.mode==="md"?e.jsx("div",{className:"team_fileview_md",children:Nw(s.text||"").map((i,l)=>i.kind==="mermaid"?e.jsx(Lw,{text:i.text},l):e.jsx(Qn,{className:"md_doc",text:Xo(i.text)},l))}):s.mode==="text"?e.jsx("pre",{className:"team_fileview_text",children:s.text||""}):s.mode==="image"&&s.url?e.jsx(oj,{url:s.url,name:s.name},s.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",s.content_type?` (${s.content_type})`:"","."]}),r]})]})}const cj=Wt.memo(Qn),uj=["id","channel","seq","sender","kind","status","urgency","critical","downgraded","to","title","body","data","reply_to","created_at"];function Uh(s){let n='"';for(let r=0;r<s.length;r++){const i=s.charCodeAt(r),l=s[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 h_{constructor(n){this.value=n}}function Wh(s){if(!Number.isFinite(s))throw new Error("py_float_repr: non-finite");if(Object.is(s,-0))return"-0.0";if(s===0)return"0.0";const n=s<0,r=Math.abs(s),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 h;if(d<=-4||d>16){const x=u.length>1?`${u[0]}.${u.slice(1)}`:u[0],v=d-1,g=(v<0?"-":"+")+String(Math.abs(v)).padStart(2,"0");h=`${x}e${g}`}else d<=0?h="0."+"0".repeat(-d)+u:d>=u.length?h=u+"0".repeat(d-u.length)+".0":h=u.slice(0,d)+"."+u.slice(d);return(n?"-":"")+h}function Bd(s){if(s==null)return"null";if(typeof s=="boolean")return s?"true":"false";if(s instanceof h_){if(!Number.isFinite(s.value))throw new Error("canonical_json: non-finite number");return Wh(s.value)}if(typeof s=="number"){if(!Number.isFinite(s))throw new Error("canonical_json: non-finite number");return Number.isInteger(s)&&!Object.is(s,-0)?String(s):Wh(s)}if(typeof s=="string")return Uh(s);if(Array.isArray(s))return"["+s.map(Bd).join(",")+"]";if(typeof s=="object")return"{"+Object.keys(s).sort().map(r=>Uh(r)+":"+Bd(s[r])).join(",")+"}";throw new Error(`canonical_json: unsupported type ${typeof s}`)}async function dj(s){return Dp(s)}async function mj(s,n,r){const i={};for(const l of uj)l!=="channel"&&(i[l]=n[l]??null);return i.channel=r,typeof i.created_at=="number"&&(i.created_at=new h_(i.created_at)),await dj(s+`
118
+ `+Bd(i))}async function fj(s){const n=s.channel;let r="",i=0,l=0,u=null,m="";for(const h of s.turns){if(h.hash===null||h.hash===void 0){i>0&&u===null&&(u=h.seq),l+=1,r="";continue}const x=await mj(r,h,n);x!==h.hash&&u===null&&(u=h.seq),r=h.hash,m=x,i+=1}const d=u===null&&String(s.head||"")!==m;return{ok:u===null&&!d,broken_at:u,head_mismatch:d,computed_head:m,hashed:i,legacy:l}}const hj=5e3,pj=6,ha=200,_j=50,Nc=380,Hh=240,Vh=2,gj=12,Wo=8,Gh=16*1024*1024,yj=new Set(["image/png","image/jpeg","image/gif","image/webp"]),nl=256*1024;function vj(){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 Kh(){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 Cc(s){return s.length<=nl?s:s.slice(0,nl)+`
119
+
120
+ ---
121
+ #TRUNCATION: preview clamped at ${Hn(nl)} of ${Hn(s.length)} — download the file for the full content.`}function wd(s,n){try{return JSON.stringify(s)===JSON.stringify(n)}catch{return!1}}function jd(s,n){const r=Object.keys(s);if(r.length!==Object.keys(n).length)return!1;for(const i of r){const l=s[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 Hn(s){if(!Number.isFinite(s)||s<0)return"—";if(s<1024)return`${s} B`;const n=s/1024;return n<1024?`${Math.round(n)} KiB`:`${(s/(1024*1024)).toFixed(1)} MiB`}const p_="abstractcontinuum_team_drafts_v1";function xj(){try{const s=window.localStorage.getItem(p_),n=s?JSON.parse(s):{};return n&&typeof n=="object"?n:{}}catch{return{}}}function Ho(s){try{window.localStorage.setItem(p_,JSON.stringify(s))}catch{}}const $c="agora/0.4";function Vo(s){if(!s)return"";const n=Math.max(0,Math.floor(Date.now()/1e3-s));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 Go(s){if(!s)return"";try{return new Date(s*1e3).toLocaleString()}catch{return""}}function Jh(s){return{color:`hsl(${rm(s)}, 60%, 55%)`}}function Ya(s){const n=rm(s),r=n>=40&&n<=190?36:45;return{background:`hsl(${n}, 55%, ${r}%)`,color:"#fff"}}const zi=[{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."}],bj=[{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."}],Qh={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(zi.map(s=>[s.id,`${s.help} Every standing vote counts.`]))};function Ko(s){const n=zi.find(r=>r.id===s);return n?n.label:s==="general"?"General":s.charAt(0).toUpperCase()+s.slice(1)}function wj(s){if(!s)return"";try{return new Date(s*1e3).toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"})}catch{return""}}const jj=15e3;function kj(s){var Os,la,pn,Nr,yo,vo;const n=s.gateway,r=!!s.gateway_connected,i=f.useMemo(()=>new am,[]),l=f.useMemo(()=>{if(s.advisor)return s.advisor;if(!r||!n)return;const p=s.advisor_agent;return async(b,N)=>{const S=[...N.map(le=>({role:le.role,content:le.content})),{role:"user",content:b}],D=await n.backlog_advisor({messages:S,agent:p||null});return String((D==null?void 0:D.reply)||"").trim()||"(the model returned an empty reply)"}},[s.advisor,n,r,s.advisor_agent]),u=!!l,[m,d]=f.useState(""),[h,x]=f.useState(()=>Od()),[v,g]=f.useState(""),w=f.useRef(h);w.current=h;const L=f.useRef({});f.useEffect(()=>{if(!r||!n){d("");return}let p=!0;return(async()=>{try{const b=await Qd("abstractcontinuum_team_voice");p&&d(b)}catch{p&&d("")}})(),typeof n.capability_defaults=="function"&&Promise.resolve().then(()=>n.capability_defaults()).then(b=>{p&&(L.current=d_(b))}).catch(()=>{p&&(L.current={})}),()=>{p=!1}},[n,r]),f.useEffect(()=>{const p=()=>x(Od());return window.addEventListener(Fd,p),window.addEventListener("storage",p),()=>{window.removeEventListener(Fd,p),window.removeEventListener("storage",p)}},[]);const E=f.useMemo(()=>{const p=String(m||"").trim();if(!(!r||!n||!p))return b=>{const N=n.voice_stream_transport(p,{text:b,...L.current,...u_(w.current)});return Vy({path:N.path,body:N.body,headers:N.headers})}},[n,r,m]),$=dp({tts_stream:E,on_error:g});f.useEffect(()=>{if(!v)return;W(v);const p=setTimeout(()=>g(""),6e3);return()=>clearTimeout(p)},[v]);const[T,H]=f.useState(null),z=f.useRef(null);f.useEffect(()=>{z.current=T},[T]);const[R,M]=f.useState(""),[A,V]=f.useState(null),[Q,oe]=f.useState([]),[be,Ne]=f.useState({}),[je,Ce]=f.useState({}),[q,te]=f.useState({}),[Y,U]=f.useState({}),[X,I]=f.useState(null),[ee,ae]=f.useState(""),k=f.useRef(0),C=f.useRef(!1),re=f.useRef(!1);async function he(){if(!C.current&&!(Date.now()-k.current<3e4)){k.current=Date.now();try{const p=await i.desk();I(b=>b==="loading"?b:p),p.rows.length&&!re.current&&Gn(b=>b!==""?b:(re.current=!0,"desk"))}catch(p){((p==null?void 0:p.status)===403||(p==null?void 0:p.status)===404)&&(C.current=!0)}}}async function ce(){if(si){I(null),ae(si);return}I("loading"),ae("");try{const p=await i.desk();I(p),k.current=Date.now(),C.current=!1}catch(p){I(null),ae((p==null?void 0:p.status)===403?"The desk serves operators and reporting delegates only — this console's seat is neither.":(p==null?void 0:p.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((p==null?void 0:p.message)||p||"network error").slice(0,120)}) — transient; Refresh retries.`)}}const[O,we]=f.useState(""),[$e,Oe]=f.useState("channels"),[Re,it]=f.useState(!1),[Be,ot]=f.useState([]),[Ve,ct]=f.useState("all"),et=f.useRef(null),[fe,ue]=f.useState(null),Ee=f.useRef(""),[se,W]=f.useState(""),[ie,Se]=f.useState(!1),[Je,F]=f.useState({}),[de,ye]=f.useState({}),[xe,ke]=f.useState({}),J=f.useRef(new Set),P=f.useRef(0),[Z,Pe]=f.useState(""),[Fe,Xe]=f.useState(""),[dt,ft]=f.useState([]),[Le,st]=f.useState(!1),pt=f.useRef(null),[Dt,wt]=f.useState(!1),en=f.useRef(null);f.useEffect(()=>{const p=en.current;p&&(p.style.height="auto",p.style.height=`${Math.min(p.scrollHeight+2,160)}px`)},[Z,O]);const[ge,Te]=f.useState("fyi"),[Ye,vt]=f.useState(""),[gt,jt]=f.useState(""),[lt,En]=f.useState(null),[js,sr]=f.useState({}),[ks,as]=f.useState(""),tn=f.useRef(xj()),Vs=f.useRef(""),[Gs,Ss]=f.useState(!1),[qi,Ns]=f.useState(!1),[Ur,ht]=f.useState(""),[Gt,ar]=f.useState(null),[zt,rr]=f.useState(null),[Bi,ul]=f.useState({});function Ui(p,b){b.length&&ul(N=>{const S={...N},D=new Set(S[p]||[]);for(const le of b)D.add(le);return S[p]=D,S})}function Ot(p,b){const N=new Set(b.map(S=>String(S.agent_id||"")).filter(Boolean));N.size&&ul(S=>{const D=S[p];if(!D||![...D].some(ve=>N.has(ve)))return S;const le=new Set([...D].filter(ve=>!N.has(ve))),G={...S};return le.size?G[p]=le:delete G[p],G})}const Wr=f.useRef(0),[Hr,ir]=f.useState(""),[Ks,dl]=f.useState(null),[Vr,rs]=f.useState(""),[mn,Gr]=f.useState(!1),[fn,ml]=f.useState(""),[ga,fl]=f.useState([]);function ya(){i.delegations().then(p=>{dl(p),rs("")}).catch(p=>{dl([]);const b=String((p==null?void 0:p.message)||p);rs((p==null?void 0:p.status)===404||/allowlist/i.test(b)?"Delegation needs the updated console/hub — restart the stack to pick it up.":b)})}async function Kr(){if(!(!fn||!ga.length||mn)){Gr(!0),rs("");try{await i.set_delegation(fn,ga),ml(""),fl([]),ya()}catch(p){rs(String((p==null?void 0:p.message)||p||"delegation failed"))}finally{Gr(!1)}}}async function or(p){if(!mn){Gr(!0),rs("");try{await i.revoke_delegation(p),ya()}catch(b){rs(String((b==null?void 0:b.message)||b||"resign failed"))}finally{Gr(!1)}}}const[xn,Js]=f.useState(null),[Jr,Cs]=f.useState(null),[Kt,Xt]=f.useState(""),[$s,va]=f.useState(null),[Es,kt]=f.useState([]),[Jt,is]=f.useState(""),[Qr,Rn]=f.useState(""),[Yr,Wi]=f.useState(""),[lr,cr]=f.useState(!1),[os,Vn]=f.useState(""),[Tn,Ts]=f.useState({open:!1,name:"",is_private:!1}),[ln,hn]=f.useState(!1),[Ic,xa]=f.useState({}),[Et,Gn]=f.useState(""),[Pn,ba]=f.useState(null),[Xr,hl]=f.useState(""),[bn,wa]=f.useState("channel"),[ls,ur]=f.useState(""),[Hi,dr]=f.useState(null),[Zr,mr]=f.useState(""),[fr,Vi]=f.useState(""),[zn,cs]=f.useState(""),[Qs,ei]=f.useState(null),[ja,ka]=f.useState(""),[Ys,nn]=f.useState(""),[Sa,Qt]=f.useState(null),[As,Gi]=f.useState([]),[ti,hr]=f.useState(""),[Xs,Na]=f.useState(!1),[Ki,Ji]=f.useState(""),[pl,_l]=f.useState(""),ni=f.useRef(null),gl=f.useRef(0),Qi=f.useRef(!1),yl=f.useRef(0),[Yi,Xi]=f.useState(!1),[Zs,Zi]=f.useState("unknown"),[si,Dc]=f.useState(""),vl=f.useRef(""),wn=f.useRef([]),Ls=f.useRef([]),Ms=f.useRef(null),eo=f.useRef(!1),ai=f.useRef(null);vl.current=O,wn.current=Q,Ls.current=Be,f.useEffect(()=>{for(const p of Be){const b=Ta.current[p.id];b!==void 0&&p.ratings&&Number(p.ratings.mine||0)===b&&delete Ta.current[p.id]}},[Be]);const to=f.useRef(!1);async function Oc(p){var b;try{const N=await i.inbox(),S=Ow(N),D=Fw(N);Ce(We=>jd(We,D)?We:D);const le=qw(N,((b=z.current)==null?void 0:b.seat)||"");te(We=>jd(We,le)?We:le);const G=Bw(N);U(We=>jd(We,G)?We:G),he();const ve=p.slice(0,gj),ze=await Promise.allSettled(ve.map(We=>i.digest(We.name))),qe={};for(const We of p)qe[We.name]={unread:S[We.name]||0,open_questions:0};ze.forEach((We,Pt)=>{var Ht;const Nt=ve[Pt].name;if(We.status==="fulfilled"){const yt=(Ht=We.value)==null?void 0:Ht.counts;qe[Nt]={...qe[Nt],open_questions:Number((yt==null?void 0:yt.open_questions)||0)}}}),Ne(We=>wd(We,qe)?We:qe)}catch{}}async function Ca(p){if(eo.current){ai.current=p;return}eo.current=!0;let b=p;try{for(;b;)ai.current=null,await Oc(b),b=ai.current}finally{eo.current=!1}}async function pr(){const b=[...await i.channels()];return b.sort((N,S)=>(S.last_at||0)-(N.last_at||0)),oe(N=>wd(N,b)?N:b),wn.current=b,b}async function Yn(){try{let p;try{p=await i.meta()}catch(le){throw Zi("unreachable"),le}H({seat:p.seat,seat_key_present:p.seat_key_present});const b=sm(p);if(Dc(b),b){Zi("not_configured"),W("");return}Zi("ready");const N=await i.channels();M(String(p.hub_url||"")),i.healthz().then(le=>V(le)).catch(()=>V(null)),i.presence().then(le=>{const G=[...new Set(le.map(ve=>String(ve.agent_id||"")).filter(ve=>ve&&ve!==p.seat))].sort();kt(G)}).catch(()=>kt([]));const S=[...N];S.sort((le,G)=>(G.last_at||0)-(le.last_at||0)),oe(S);const D=S.filter(le=>!le.name.startsWith("dm:"));!O&&D.length&&we(D[0].name),W(""),Ca(S)}catch(p){W(String((p==null?void 0:p.message)||p||"Hub unreachable"))}}async function ea(p,b){var S,D,le;if(!p)return;const N=P.current;b!=null&&b.background||Se(!0);try{const G=Ls.current.length&&Ls.current[Ls.current.length-1].seq||0,ve=((S=wn.current.find(nt=>nt.name===p))==null?void 0:S.last_seq)||0;let ze=ve,qe=null;if(!(b!=null&&b.background))if(ve>0)qe=pr().catch(()=>null);else try{const nt=await pr();if(N!==P.current)return;ze=((D=nt.find(Ft=>Ft.name===p))==null?void 0:D.last_seq)||0}catch{}const We=Math.max(0,ze-ha),Pt=b!=null&&b.background&&G>0?Math.max(0,G-_j):We,Nt=await i.messages(p,{since:Pt,limit:ha});if(N!==P.current)return;const Ht=new Set(Ls.current.map(nt=>nt.id)),yt=Nt.some(nt=>!Ht.has(nt.id));if(b!=null&&b.background&&!yt&&G>0){const nt=Date.now();if(nt-yl.current>1e4){yl.current=nt;try{const Ft=await pr();if(N!==P.current)return;const Ct=((le=Ft.find(Ge=>Ge.name===p))==null?void 0:le.last_seq)||0;if(Ct>0&&Ct<G){const Ge=Math.max(0,Ct-ha),It=await i.messages(p,{since:Ge,limit:ha});if(N!==P.current)return;It.sort((_n,Mt)=>(_n.seq||0)-(Mt.seq||0)),ot(It),W("");return}}catch{}}}Nt.sort((nt,Ft)=>(nt.seq||0)-(Ft.seq||0)),ot(nt=>{if(b!=null&&b.background&&nt.length){if(!Nt.length)return nt;const Ft=new Set(nt.map($t=>$t.id)),Ct=Nt.filter($t=>!Ft.has($t.id)),Ge=new Map(Nt.map($t=>[$t.id,$t]));let It=0;const _n=nt.map($t=>{const ut=Ge.get($t.id);if(!ut)return $t;const Tt=JSON.stringify(ut.ratings??null)!==JSON.stringify($t.ratings??null)||(ut.has_resolved_reply??null)!==($t.has_resolved_reply??null)||JSON.stringify(ut.pending_asks??null)!==JSON.stringify($t.pending_asks??null)||!!ut.retracted!=!!$t.retracted;return Tt&&It++,Tt?ut:$t});if(!Ct.length&&!It)return nt;const Mt=[...It?_n:nt,...Ct];return Mt.length>ha*2?Mt.slice(Mt.length-ha*2):Mt}return Nt}),W(""),!(b!=null&&b.background)&&qe&&(async()=>{var nt;try{const Ft=await qe;if(N!==P.current||!Ft)return;const Ct=((nt=Ft.find(Ge=>Ge.name===p))==null?void 0:nt.last_seq)||0;if(Ct>0&&Ct!==ve){const Ge=Math.max(0,Ct-ha),It=await i.messages(p,{since:Ge,limit:ha});if(N!==P.current)return;It.sort((_n,Mt)=>(_n.seq||0)-(Mt.seq||0)),ot(_n=>wd(_n,It)?_n:It)}}catch{}})()}catch(G){if(N!==P.current)return;W(String((G==null?void 0:G.message)||G||"Failed to load messages"))}finally{!(b!=null&&b.background)&&N===P.current&&Se(!1)}}f.useEffect(()=>{Yn()},[]),f.useEffect(()=>{if(Zs!=="not_configured")return;const p=()=>{document.visibilityState!=="hidden"&&Yn()},b=setInterval(p,jj);return document.addEventListener("visibilitychange",p),()=>{clearInterval(b),document.removeEventListener("visibilitychange",p)}},[Zs]),f.useEffect(()=>{if(Zs!=="ready"&&Zs!=="unreachable")return;let p=null,b=!1,N=0,S=0;const D=()=>{if(!b){try{p=new WebSocket(i.ws_url())}catch{Xi(!1),N+=1,setTimeout(D,Math.min(15e3,1e3*Math.max(1,N)));return}p.onopen=()=>{Xi(!0),S=Date.now(),(!wn.current.length||!z.current)&&Yn()},p.onmessage=le=>{var G;try{const ve=JSON.parse(String(le.data||"{}"));if((ve==null?void 0:ve.type)!=="envelope")return;const ze=String(((G=ve.envelope)==null?void 0:G.channel)||"");ze&&ze===vl.current&&ea(ze,{background:!0}),ze&&!wn.current.some(qe=>qe.name===ze)&&pr(),Ms.current&&clearTimeout(Ms.current),Ms.current=setTimeout(()=>void Ca(wn.current),800)}catch{}},p.onclose=()=>{Xi(!1),b||(S&&Date.now()-S>=15e3?N=0:N+=1,S=0,setTimeout(D,Math.min(15e3,1e3*Math.max(1,N))))},p.onerror=()=>{try{p==null||p.close()}catch{}}}};return D(),()=>{b=!0,Ms.current&&clearTimeout(Ms.current);try{p==null||p.close()}catch{}}},[Zs==="ready"||Zs==="unreachable"]),f.useEffect(()=>{P.current+=1,F({}),ye({}),ke({}),J.current=new Set,ar(null),rr(null);try{$.stop_tts()}catch{}Wr.current=0,Ta.current={},Ra("recency"),ra(null),_i(""),ei(null),ka(""),nn(""),Qt(null),Js(null),Cs(null),va(null),Xt(""),Rn(""),xa({}),Gi([]),Ji(""),_l(""),Na(!1),hr(""),ot([]),ct(et.current||"all"),et.current=null,En(null),sr({}),as(""),ft([]),Vs.current&&Vs.current!==O&&(Z||Fe?tn.current[Vs.current]={text:Z,title:Fe,kind:ge}:delete tn.current[Vs.current],Ho(tn.current));const p=tn.current[O];if(Pe((p==null?void 0:p.text)||""),Xe((p==null?void 0:p.title)||""),Te((p==null?void 0:p.kind)||"fyi"),Vs.current=O,to.current=!0,ea(O),!O)return;Et==="files"&&_r(),Et==="members"&&ii();const b=setInterval(()=>{gl.current+=1,Qi.current||(Qi.current=!0,ea(O,{background:!0}).finally(()=>{Qi.current=!1})),gl.current%pj===0&&(pr().then(N=>Ca(N)).catch(()=>Ca(wn.current)),i.healthz().then(V).catch(()=>{}),i.meta().then(N=>H(N)).catch(()=>{}))},hj);return()=>clearInterval(b)},[O]);const xl=f.useRef({text:"",title:"",kind:"fyi",selected:""});xl.current={text:Z,title:Fe,kind:ge,selected:O},f.useEffect(()=>{if(!O)return;const p=setTimeout(()=>{Z||Fe?tn.current[O]={text:Z,title:Fe,kind:ge}:delete tn.current[O],Ho(tn.current)},300);return()=>clearTimeout(p)},[Z,Fe,ge,O]),f.useEffect(()=>{const p=()=>{const b=xl.current;b.selected&&(b.text||b.title?tn.current[b.selected]={text:b.text,title:b.title,kind:b.kind}:delete tn.current[b.selected],Ho(tn.current))};return window.addEventListener("pagehide",p),window.addEventListener("beforeunload",p),()=>{window.removeEventListener("pagehide",p),window.removeEventListener("beforeunload",p),p()}},[]),f.useEffect(()=>{const p=ni.current;if(!p||!Be.length)return;if(to.current){to.current=!1,p.scrollTop=p.scrollHeight;return}p.scrollHeight-p.scrollTop-p.clientHeight<240&&(p.scrollTop=p.scrollHeight)},[Be]),f.useEffect(()=>{if(Ve!=="unread"||!O){ue(null);return}const p=je[O];ue(new Set(p||[])),Ee.current=""},[Ve,O]),f.useEffect(()=>{if(Ve!=="unread"||!O||!fe||!fe.size)return;const p=Math.min(...fe),b=Be.length&&Be[0].seq||0;if(!p||!b||b<=p)return;const N=`${O}:${p}`;if(Ee.current===N)return;Ee.current=N;const S=P.current;i.messages(O,{since:Math.max(0,p-1),limit:ha}).then(D=>{S!==P.current||!D.length||ot(le=>{const G=new Set(le.map(ze=>ze.id)),ve=D.filter(ze=>!G.has(ze.id));return ve.length?[...le,...ve].sort((ze,qe)=>(ze.seq||0)-(qe.seq||0)):le})}).catch(()=>{S===P.current&&(ht("Couldn't load the older unread messages — the Unread list may be incomplete. Re-select Unread to retry."),setTimeout(()=>ht(""),6e3))})},[Ve,O,fe,Be]);function ri(p){J.current.has(p.id)||(J.current.add(p.id),i.read_message(p.channel,p.id).catch(()=>{}),i.ack(p.channel,p.seq).catch(()=>{}),Ce(b=>{const N=b[p.channel];if(!N||!N.has(p.seq))return b;const S=new Set(N);return S.delete(p.seq),{...b,[p.channel]:S}}),Ms.current&&clearTimeout(Ms.current),Ms.current=setTimeout(()=>void Ca(wn.current),500),p.critical&&(ht(`Read recorded for critical #${p.seq}.`),setTimeout(()=>ht(""),2500)))}function $a(p){const b=!Je[p.id];F(N=>({...N,[p.id]:b})),b&&ri(p)}function Fc(p){const b=window.getSelection();if(b&&!b.isCollapsed)return;const N=String(p.body||""),S=p.status==="reply"?Hh:Nc;N.length>S?$a(p):ri(p)}async function bl(){if(!O||Gt==="running")return;const p=P.current;ar("running");try{const b=await i.ledger(O),N=await fj(b);if(p!==P.current)return;ar(N)}catch(b){if(p!==P.current)return;ar({error:String((b==null?void 0:b.message)||b||"verification failed")})}}function ii(){{const p=P.current;rr("loading"),Js(null),ir(""),Cs(null),i.channel_info(O).then(b=>{p===P.current&&rr(b)}).catch(b=>{p===P.current&&rr({error:String((b==null?void 0:b.message)||b||"info failed")})}),i.members(O).then(b=>{p===P.current&&(Js(b),ir(""),Ot(O,b))}).catch(b=>{p===P.current&&(Js([]),ir(String((b==null?void 0:b.message)||b||"members unavailable")))}),i.list_blocks().then(b=>{p===P.current&&Cs(b)}).catch(()=>{p===P.current&&Cs([])}),i.retired_agents().then(b=>{p===P.current&&va(b)}).catch(()=>{p===P.current&&va([])})}}function ta(p){const b=Et===p?"":p;if(Gn(b),b==="files"&&_r(),b==="members"){let N=0;for(const S of Ls.current)String(S.sender||"")==="hub"&&(S.seq||0)>N&&(N=S.seq||0);Wr.current=N,ii(),ya()}b==="leaderboard"&&oi(bn),b==="desk"&&ce()}function oi(p){const b=P.current;ba(null),hl(""),ur(""),dr(null),cs(""),(p==="hub"?i.reputation_hub():i.reputation(O)).then(S=>{b===P.current&&ba(S)}).catch(S=>{if(b!==P.current)return;const D=Number((S==null?void 0:S.status)||0);hl(D===404||D===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 no(p){const b=ls===p?"":p;if(ur(b),dr(null),cs(""),!b||bn==="hub")return;const N=P.current;i.reputation_votes(O,b).then(S=>{N===P.current&&dr(S)}).catch(S=>{N===P.current&&(dr(null),cs(`votes list failed: ${String((S==null?void 0:S.message)||S||"fetch failed")}`))})}const[Rs,wl]=f.useState(""),[Ea,so]=f.useState("");f.useEffect(()=>{if(!Ea)return;const p=setTimeout(()=>so(""),6e3);return()=>clearTimeout(p)},[Ea]);async function jl(p){if(Ea!==p.id){so(p.id);return}so("");try{const b=Array.isArray(p.pending_asks)?p.pending_asks.filter(Boolean):[];await i.post_message(p.channel,{body:`Declined on the record by ${(T==null?void 0:T.seat)||"operator"} — closing without a substantive answer.`,status:"reply",reply_to:p.id,to:p.sender?[p.sender]:void 0,...b.length?{answers:b}:{}}),te(N=>{const S=N[p.channel];if(!(S!=null&&S.has(p.seq)))return N;const D=new Set(S);return D.delete(p.seq),{...N,[p.channel]:D}})}catch(b){W(String((b==null?void 0:b.message)||b||"decline failed"))}}const Ta=f.useRef({});function na(p){const b=p.ratings;return b?aj(b,Ta.current[p.id]):null}async function Aa(p,b){var D,le;const N=(T==null?void 0:T.seat)||"";if(!p||!N||Rs)return;const S=Ls.current.find(G=>G.id===p)||((D=br.current)==null?void 0:D.find(G=>G.id===p));if(S){wl(`${p}:${b}`),cs("");try{const G=((le=na(S))==null?void 0:le.mine)??0;G===b?await i.unrate_message(O,p):await i.rate_message(O,p,b),Ta.current[p]=G===b?0:b}catch(G){cs(String((G==null?void 0:G.message)||G||"rating failed"))}finally{wl("")}}}async function kl(p,b,N){if(!fr){Vi(`${p}:${b}:${N}`),cs("");try{await i.rate(O,p,b,N,Zr.trim()),mr("");const S=P.current,[D,le]=await Promise.all([i.reputation(O),i.reputation_votes(O,p)]);S===P.current&&(ba(D),dr(le))}catch(S){cs(String((S==null?void 0:S.message)||S||"vote failed"))}finally{Vi("")}}}function _r(){const p=P.current;ei(null),ka(""),nn(""),i.fs_list(O).then(b=>{p===P.current&&ei(b)}).catch(b=>{p===P.current&&ka(String((b==null?void 0:b.message)||b||"failed to list files"))})}async function qc(p){const b=P.current,N=Ir(p.path,"text/markdown"),S=`${p.updated_by||"?"} · ${Go(p.updated_at)} · v${p.version}`;Qt({name:p.path,mode:N==="image"?"text":N,meta:S,loading:!0});try{const D=await i.fs_read(O,p.path);if(b!==P.current)return;const le=Ir(p.path,D.mime);Qt({name:p.path,mode:le==="image"?"text":le,text:Cc(D.content),content_type:D.mime,meta:S,loading:!1})}catch(D){if(b!==P.current)return;Qt({name:p.path,mode:"text",meta:S,error:String((D==null?void 0:D.message)||D||"failed to read file")})}}const Ps=f.useRef(null);function sa(){const p=Ps.current,b=Ls.current;if(!p||!b.length)return;if(p.message_id?b.some(S=>S.id===p.message_id):!1){Ps.current=null,requestAnimationFrame(()=>{const S=document.getElementById(`hubmsg-${p.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(p.seq&&Number.isFinite(p.seq)){const S=P.current,D=p.seq;Ps.current={...p,seq:void 0},i.messages(O,{since:Math.max(0,D-3),limit:10}).then(le=>{S!==P.current||!le.length||ot(G=>{const ve=new Set(G.map(qe=>qe.id)),ze=le.filter(qe=>!ve.has(qe.id));return ze.length?[...G,...ze].sort((qe,We)=>(qe.seq||0)-(We.seq||0)):G})}).catch(()=>{})}}f.useEffect(()=>{var S;if(!s.focus)return;const{channel:p,message_id:b,seq:N}=s.focus;(S=s.on_focus_consumed)==null||S.call(s),p&&(Ps.current={message_id:b,seq:N},Oe("thread"),p===O?sa():we(p))},[s.focus]),f.useEffect(()=>{sa()},[Be]),f.useEffect(()=>{if(Et!=="members"||!O)return;let p=0,b="";for(const S of Be){if(S.channel&&S.channel!==O||String(S.sender||"")!=="hub")continue;const D=`${String(S.title||"")} ${String(S.body||"")}`;/\b(joined|left|kicked|banned|archived|reopened)\b/i.test(D)&&(S.seq||0)>p&&(p=S.seq||0,b=D)}if(!p||p<=Wr.current)return;const N=P.current;i.members(O).then(S=>{N===P.current&&(Wr.current=p,Js(S),ir(""),Ot(O,S))}).catch(()=>{}),/\b(kicked|banned)\b/i.test(b)&&i.list_blocks(O).then(S=>{N===P.current&&Cs(S)}).catch(()=>{})},[Be,Et,O]);const[ao,gr]=f.useState(null),li=f.useRef(0);f.useEffect(()=>{if(gr(null),li.current=0,!O)return;const p=P.current;i.fs_list(O).then(b=>{p===P.current&&gr(new Set(b.map(N=>String(N.path||"")).filter(Boolean)))}).catch(()=>{p===P.current&&gr(null)})},[O]),f.useEffect(()=>{const p=Be.reduce((N,S)=>{if(S.channel&&S.channel!==O)return N;const D=String(S.title||"");return(D.startsWith("fs:put")||D.startsWith("fs:delete"))&&(S.seq||0)>N?S.seq||0:N},0);if(!p||p<=li.current)return;const b=P.current;i.fs_list(O).then(N=>{b===P.current&&(li.current=p,gr(new Set(N.map(S=>String(S.path||"")).filter(Boolean))))}).catch(()=>{})},[Be,O]);async function Sl(p){const b=P.current,N=Ir(p,"text/markdown");Qt({name:p,mode:N==="image"?"text":N,loading:!0});try{const S=await i.fs_read(O,p);if(b!==P.current)return;const D=Ir(p,S.mime),le=S.updated_by?`${S.updated_by} · ${Go(S.updated_at)} · v${S.version??"?"}`:void 0;Qt({name:p,mode:D==="image"?"text":D,text:Cc(S.content),content_type:S.mime,meta:le,loading:!1})}catch(S){if(b!==P.current)return;Qt({name:p,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 ci(p,b){const N=P.current,S=i.attachment_url(p,b.id),D=Ir(b.filename,b.content_type);if(D==="image"){Qt({name:b.filename,mode:"image",url:S,content_type:b.content_type,size:b.size});return}if(D==="md"||D==="text"){if(b.size>nl){Qt({name:b.filename,mode:"download",url:S,content_type:b.content_type,size:b.size,error:`too large to preview inline (${Hn(b.size)} > ${Hn(nl)}) — download to view`});return}Qt({name:b.filename,mode:D,url:S,content_type:b.content_type,size:b.size,loading:!0});try{const le=await fetch(S);if(!le.ok)throw new Error(`fetch failed (${le.status})`);const G=await le.text();if(N!==P.current)return;Qt({name:b.filename,mode:D,url:S,content_type:b.content_type,size:b.size,text:Cc(G)})}catch(le){if(N!==P.current)return;Qt({name:b.filename,mode:"download",url:S,content_type:b.content_type,size:b.size,error:String((le==null?void 0:le.message)||le||"failed to load")})}return}Qt({name:b.filename,mode:"download",url:S,content_type:b.content_type,size:b.size})}async function ui(p,b,N="channel"){if(!Jt){is(`${N}:${b}:${p}`),Rn("");try{N==="hub"?b==="unblock"?await i.hub_unblock(p):await i.hub_block(p,b==="kick"?{seconds:3600,reason:"hub kick (Continuum Team page)"}:{reason:"hub ban (Continuum Team page)"}):b==="unblock"?await i.unblock(O,p):await i.block(O,p,b==="kick"?{seconds:3600,reason:"kicked by the operator (Continuum Team page)"}:{reason:"banned by the operator (Continuum Team page)"}),ht(`${N==="hub"?"hub ":""}${b} → ${p} applied.`),setTimeout(()=>ht(""),3e3);const S=P.current,D=await i.members(O).catch(()=>null);D&&S===P.current&&Js(D);const le=await i.list_blocks().catch(()=>null);le&&S===P.current&&Cs(le)}catch(S){Rn(String((S==null?void 0:S.message)||S||"moderation refused"))}finally{is("")}}}async function Bc(p){if(!Jt){is(`retire:${p}`),Rn("");try{await i.retire_agent(p,"decommissioned via Continuum Team page"),Xt(""),ht(`${p} retired (decommissioned — not banned).`),setTimeout(()=>ht(""),3500);const b=P.current,N=await i.members(O).catch(()=>null);N&&b===P.current&&Js(N);const S=await i.retired_agents().catch(()=>null);S&&b===P.current&&va(S)}catch(b){const N=b==null?void 0:b.status,S=String((b==null?void 0:b.message)||b||"");N===404||/not found|hub_route_not_allowed/i.test(S)?(ht("Agent retire ships with the next hub update — this control is wired and ready for it."),setTimeout(()=>ht(""),6e3)):Rn(S||"retire refused")}finally{is("")}}}async function Uc(p){if(!Jt){is(`unretire:${p}`),Rn("");try{await i.unretire_agent(p),Xt(""),ht(`${p} un-retired — it can rejoin channels explicitly.`),setTimeout(()=>ht(""),3500);const b=await i.retired_agents().catch(()=>null);b&&va(b)}catch(b){Rn(String((b==null?void 0:b.message)||b||"un-retire refused"))}finally{is("")}}}async function Wc(p){if(!Jt){is(`delete:${p}`),Rn("");try{await i.delete_agent(p),Xt(""),ht(`${p} deleted from the hub — off every roster and board; its id stays reserved.`),setTimeout(()=>ht(""),3500);const b=await i.retired_agents().catch(()=>null);b&&va(b)}catch(b){const N=String((b==null?void 0:b.message)||b);Rn((b==null?void 0:b.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)?`${p} is still active — retire it first, then delete.`:N||"delete refused")}finally{is("")}}}async function In(p){if(!ln){hn(!0),Rn("");try{let b={state:p},N;try{const S=await i.channel_meta(O);S&&typeof S.value=="object"&&S.value&&(b={...S.value,state:p}),typeof(S==null?void 0:S.version)=="number"&&(N=S.version)}catch{}await i.put_channel_meta(O,b,N),ht(p==="closed"?"Channel closed (member posts refused until reopened).":"Channel reopened."),setTimeout(()=>ht(""),3500),ii(),Yn()}catch(b){Rn(String((b==null?void 0:b.message)||b||"channel state change refused"))}finally{hn(!1)}}}const[yr,ro]=f.useState("");async function Nl(p){if(!ln){hn(!0),W("");try{await i.leave(p),ro(""),O===p&&we(""),await Yn(),ht("Direct message removed from your list."),setTimeout(()=>ht(""),3e3)}catch(b){W(String((b==null?void 0:b.message)||b||"leave refused"))}finally{hn(!1)}}}const[Cl,di]=f.useState("");async function io(p){if(!ln){hn(!0),W("");try{await i.archive(p),di(""),O===p&&we(""),await Yn(),ht(`Channel #${p} archived (history preserved).`),setTimeout(()=>ht(""),3500)}catch(b){const N=String((b==null?void 0:b.message)||b||"");(b==null?void 0:b.status)===404||/not found|hub_route_not_allowed/i.test(N)?(di(""),ht("Channel archive ships with the next hub update — this control is wired and ready for it."),setTimeout(()=>ht(""),6e3)):W(N||"archive refused")}finally{hn(!1)}}}async function $l(){const p=Tn.name.trim();if(!(!p||ln)){hn(!0),W("");try{await i.create_channel(p,Tn.is_private),Ts({open:!1,name:"",is_private:!1}),await Yn(),we(p),ht(`Channel #${p} created.`),setTimeout(()=>ht(""),3e3)}catch(b){W(String((b==null?void 0:b.message)||b||"channel create refused"))}finally{hn(!1)}}}async function El(p,b){if(!l)throw new Error("AI advisor is not available");return l(p,b)}async function La(p){if(!u)return;const b=p.root.id,N=P.current,S=p.replies.length+1;xa(D=>{var le;return{...D,[b]:{busy:!0,text:((le=D[b])==null?void 0:le.text)||"",error:"",count:S}}});try{const D=qh([p.root,...p.replies]),le=`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.
122
+
123
+ THREAD TRANSCRIPT:
124
+ ${D.text}`,G=await El(le,[]);if(N!==P.current)return;const ve=Bh(D.report);xa(ze=>({...ze,[b]:{busy:!1,text:G,error:"",count:S,window:ve}}))}catch(D){if(N!==P.current)return;xa(le=>({...le,[b]:{busy:!1,text:"",error:String((D==null?void 0:D.message)||D||"summary failed"),count:S}}))}}async function mi(p){const b=p.trim();if(!b||Xs||!u)return;const N=P.current;Gn("assistant"),Na(!0),Ji(""),Gi(S=>[...S,{role:"user",content:b}]);try{const S=qh(Be);_l(Bh(S.report));const D=`You are the operator's analyst for the agora hub channel #${O}. 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.
125
+
126
+ CHANNEL TRANSCRIPT (window):
127
+ ${S.text}
128
+
129
+ QUESTION: ${b}`,le=await El(D,As);if(N!==P.current)return;Gi(G=>[...G,{role:"assistant",content:le}])}catch(S){if(N!==P.current)return;Ji(String((S==null?void 0:S.message)||S||"assistant failed"))}finally{N===P.current&&Na(!1)}}const[zs,fi]=f.useState(""),[vr,xr]=f.useState("");async function Ma(p){if(!Gs){Ss(!0),W("");try{await i.retract_message(O,p.id),xr(""),ht(`#${p.seq} retracted — readers see a tombstone, the words are gone from every agent-facing read.`),setTimeout(()=>ht(""),4e3),await ea(O,{background:!0})}catch(b){const N=String((b==null?void 0:b.message)||b||"retract failed");W(/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{Ss(!1)}}}async function oo(p){if(!Gs){Ss(!0),W("");try{const b=zh(O,At);await i.post_message(O,{body:"Resolved.",status:"resolved",to:b?[b]:void 0,reply_to:p.id}),fi(""),ht(`Marked #${p.seq} resolved.`),setTimeout(()=>ht(""),3e3),await ea(O,{background:!0})}catch(b){W(String((b==null?void 0:b.message)||b||"Resolve failed"))}finally{Ss(!1)}}}async function lo(p){if(!p||!p.length||Le)return;const b=Array.from(p);if(dt.length+b.length>Wo){W(`At most ${Wo} attachments per message.`);return}const N=b.find(G=>G.size>Gh);if(N){W(`"${N.name}" is ${Hn(N.size)} — the limit is ${Hn(Gh)}.`);return}const S=P.current,D=O;st(!0),W("");let le=0;try{for(const G of b){const ve=await i.upload_attachment(D,G);if(S!==P.current||O!==D)return;ft(ze=>[...ze,ve]),le+=1}}catch(G){const ve=G==null?void 0:G.status,ze=String((G==null?void 0:G.message)||G||"");if(ve===404||/not found|hub_route_not_allowed/i.test(ze))ht("Attachments ship with the next hub update — the composer control is wired and ready for it."),setTimeout(()=>ht(""),6e3);else{const qe=b.length>1?` (${le} of ${b.length} attached before this)`:"";W(`${ze||"attachment upload failed"}${qe}`)}}finally{st(!1),pt.current&&(pt.current.value="")}}function hi(p){var N;En(p);const b=((N=p.data)==null?void 0:N.asks)||[];sr(b.length===1?{[b[0].id]:!0}:{}),as(""),Te("fyi")}function co(){En(null),sr({}),as("")}async function Tl(p){const{title:b,members:N}=vd(p);if(!N.length){W("/group: no @mentions found — usage: /group fix the voice outage @gateway @core");return}const S=b||`focused work with ${N.join(", ")}`;await us({title:S,members:N})}async function uo(p,b,N){const S=[],D=[];for(const le of N)try{const G=await fetch(i.attachment_url(p,le.id));if(!G.ok)throw new Error(`fetch ${G.status}`);const ve=await G.blob(),ze=new File([ve],le.filename||"attachment",{type:le.content_type||ve.type||"application/octet-stream"}),qe=await i.upload_attachment(b,ze);S.push({id:qe.id,filename:qe.filename||le.filename})}catch(G){D.push(`${le.filename||le.id.slice(0,8)} (${String((G==null?void 0:G.message)||G)})`)}return{migrated:S,att_failed:D}}async function mo(p,b,N){try{const S=await i.create_invite(p,b);return await i.send_dm(b,{title:`invite to ${p}${N?`: ${N}`:""}`.slice(0,120),body:`You are invited to '${p}'${N?` — ${N}`:""}. Join with join_channel(channel='${p}', 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 Al(p){var b,N;if(!(!O||!p)){cr(!0),Vn("");try{const S=zt&&typeof zt=="object"&&"meta"in zt?String(((b=zt.meta)==null?void 0:b.purpose)||""):"",D=!!((N=wn.current.find(G=>G.name===O))!=null&&N.private);let le=null;if(D)le=await mo(O,p,S||void 0);else try{await i.send_dm(p,{title:`join ${O}${S?`: ${S}`:""}`.slice(0,120),body:`You are invited to '${O}' (public)${S?` — ${S}`:""}. Join with join_channel(channel='${O}'), read the recent messages, and work the topic THERE.`})}catch(G){le=String((G==null?void 0:G.message)||G)}le?Vn(le.includes("outside the Team page allowlist")?"Invites need the updated console server — one stack restart activates them; nothing was sent.":`Invite failed: ${le}`):(Vn(`Invited @${p} — join pointer DM'd.`),Wi(""),Ui(O,[p]))}finally{cr(!1),setTimeout(()=>Vn(""),8e3)}}}async function Ll(p,b){var N;try{const S=vd(b).members;if(!S.length)return;const D=await i.members(p),le=new Set(D.map(We=>String(We.agent_id||""))),G=S.filter(We=>!le.has(We)&&Es.includes(We)&&We!==At);if(!G.length)return;const ve=!!((N=wn.current.find(We=>We.name===p))!=null&&N.private),ze=[],qe=[];for(const We of G)if(ve){const Pt=await mo(p,We);Pt?qe.push(`${We} (${Pt})`):ze.push(We)}else try{await i.send_dm(We,{title:`you were mentioned in #${p}`.slice(0,120),body:`You were mentioned in #${p} (public). Join with join_channel(channel='${p}') and read the recent messages.`}),ze.push(We)}catch(Pt){qe.push(`${We} (${String((Pt==null?void 0:Pt.message)||Pt)})`)}ze.length&&(Ui(p,ze),ht(`Posted — @${ze.join(", @")} ${ve?"invited":"nudged"} (mentioned, not yet member${ze.length===1?"":"s"}).`)),qe.length&&W(qe.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 ${qe.join("; ")}.`)}catch{}}async function us(p){var le,G;const{title:b,members:N}=p,S=[...dt],D=O;Ss(!0),W("");try{const ve=new Set(wn.current.map(yt=>yt.name)),ze=bd(b,ve);let qe=[],We=[],Pt=!1;try{const yt=await i.create_group({name:ze,members:N,purpose:b,opening_post:((le=p.opening_body)==null?void 0:le.trim())||b,private:!0});Pt=!0,qe=Array.isArray(yt==null?void 0:yt.invited)?yt.invited.map(String):N,We=Array.isArray(yt==null?void 0:yt.failed)?yt.failed.map(nt=>typeof nt=="string"?nt:`${(nt==null?void 0:nt.agent)||(nt==null?void 0:nt.member)||(nt==null?void 0:nt.peer)||"?"} (${String((nt==null?void 0:nt.error)||(nt==null?void 0:nt.detail)||"failed")})`):[]}catch(yt){const nt=String((yt==null?void 0:yt.message)||yt||"");if(!((yt==null?void 0:yt.status)===404||nt.includes("outside the Team page allowlist")||nt.includes("Not Found")))throw yt;try{await i.create_invite("__group-preflight__",N[0])}catch(Ct){if(String((Ct==null?void 0:Ct.message)||Ct).includes("outside the Team page allowlist")){W("/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(ze,!0),await i.put_channel_meta(ze,{purpose:b},0);for(const Ct of N)try{const Ge=await i.create_invite(ze,Ct);await i.send_dm(Ct,{title:`invite to ${ze}: ${b}`.slice(0,120),body:`You are invited to '${ze}' — focused room: ${b}. Join with join_channel(channel='${ze}', invite_token='${Ge}'), read the opening post, and work the topic THERE (not in commons).`}),qe.push(Ct)}catch(Ge){We.push(`${Ct} (${String((Ge==null?void 0:Ge.message)||Ge)})`)}}const{migrated:Nt,att_failed:Ht}=await uo(D,ze,S);Pt?Nt.length&&await i.post_message(ze,{body:"Attachments carried over from the create request.",status:"fyi",attachments:Nt}):await i.post_message(ze,{body:((G=p.opening_body)==null?void 0:G.trim())||b,title:b.slice(0,120),status:"open",attachments:Nt.length?Nt:void 0}),Ui(ze,qe),ht(`Room '${ze}' created — private, ${qe.length} invited${qe.length?`: ${qe.join(", ")}`:""}.`+(Nt.length?` ${Nt.length} attachment(s) carried over.`:"")+(We.length?` Invite FAILED for ${We.join("; ")}.`:"")),We.length&&W(`Some invites failed — ${We.join("; ")}. Mint them again from the room's Members drawer or re-run /group.`),Ht.length&&W(`Attachment carry-over failed for ${Ht.join("; ")} — the room and post were created; re-attach in the new room.`),Pe(""),Xe(""),jt(""),Te("fyi"),ft([]),delete tn.current[O],Ho(tn.current),await Yn(),we(ze),setTimeout(()=>ht(""),6e3)}catch(ve){W(`group creation failed: ${String((ve==null?void 0:ve.message)||ve)}`)}finally{Ss(!1)}}async function pi(){var le;const p=Z.trim(),b=dt.length>0,N=!lt&&!O.startsWith("dm:")&&ge==="group";if(!p&&!b&&!N||Gs||!O)return;if(N){const G=xd(gt);if(!G.length){W("Group needs at least one member — write their names like: @entity @assistant");return}const ve=Fe.trim()||(p?p.split(`
130
+ `)[0].slice(0,80):`focused work with ${G.join(", ")}`);await us({title:ve,members:G,opening_body:p});return}if(/^\/assistant(?=\s|$)/i.test(p)){if(!u){W("AI advisor is not configured — connect a gateway or inject an advisor.");return}const G=p.replace(/^\/assistant/i,"").trim();Pe(""),G?mi(G):Gn("assistant");return}if(/^\/group(?=\s|$)/i.test(p)){await Tl(p.replace(/^\/group/i,"").trim());return}if(/^\//.test(p)){W(`Unknown command "${p.split(/\s/)[0]}" — only /assistant and /group are supported. Remove the leading "/" to post this as a message.`);return}const S=Object.entries(js).filter(([,G])=>G).map(([G])=>G),D=O.startsWith("dm:");if(lt&&(((le=lt.data)==null?void 0:le.asks)||[]).length&&!S.length&&ks!=="void_reply"){as("void_reply");return}if(!lt&&!D&&ge==="ask"&&!Fe.trim()&&ks!=="untitled_open"){as("untitled_open");return}if(!lt&&!D&&ge==="dm"&&!Ye.trim()){W("Pick a recipient for the direct message.");return}Ss(!0),W("");try{if(!lt&&!D&&ge==="dm"){const G=Ye.trim(),ve=[...dt],ze=O;await i.send_dm(G,{body:p||(ve.length?`(${ve.length} attachment${ve.length===1?"":"s"})`:p),title:Fe.trim()||void 0});const qe=`dm:${[At,G].sort().join("--")}`;if(ve.length){const{migrated:We,att_failed:Pt}=await uo(ze,qe,ve);We.length&&await i.post_message(qe,{body:"",to:[G],attachments:We}),ht(`DM sent to ${G}${We.length?` with ${We.length} attachment(s)`:""}.`),Pt.length&&W(`Attachment carry-over failed for ${Pt.join("; ")} — the DM text was sent; re-attach inside the conversation.`)}else ht(`DM sent to ${G}.`);await Yn(),we(qe)}else{const G=dt.map(qe=>({id:qe.id,filename:qe.filename})),ve=D?zh(O,At):"";D&&!ve&&W(`#FALLBACK this dm's pair does not include seat '${At}' — sent unaddressed (no to-me wake; check the hub seat in Settings).`);const ze={body:p,title:Fe.trim()||void 0,status:Ww({is_reply:!!lt,in_dm:D,kind:ge}),to:ve?[ve]:void 0,reply_to:lt==null?void 0:lt.id,answers:lt&&S.length?S:void 0,attachments:G.length?G:void 0};try{await i.post_message(O,ze)}catch(qe){if(ve&&/address non-members/i.test(String((qe==null?void 0:qe.message)||qe)))await i.post_message(O,{...ze,to:void 0}),W(`#FALLBACK '${ve}' is no longer a member of this dm — message delivered unaddressed (their listener will not get a to-me wake).`);else throw qe}ht(D?"Sent.":"Posted."),await ea(O,{background:!0}),!D&&p&&Ll(O,p)}Pe(""),Xe(""),ft([]),En(null),sr({}),Te("fyi"),vt(""),as(""),delete tn.current[O],Ho(tn.current),setTimeout(()=>ht(""),3e3)}catch(G){W(String((G==null?void 0:G.message)||G||"Post failed"))}finally{Ss(!1)}}async function fo(p){if(!(!O||!p||qi||ie)){Ns(!0);try{await i.ack(O,p),ht(`Marked read to #${p}.`),setTimeout(()=>ht(""),3e3),Ca(wn.current)}catch(b){W(String((b==null?void 0:b.message)||b||"Ack failed"))}finally{Ns(!1)}}}const Dn=!!(T!=null&&T.seat_key_present)&&!(A!=null&&A.paused),At=(T==null?void 0:T.seat)||"",qt=O.startsWith("dm:"),ho=(()=>{if(!qt)return"";const p=O.slice(3);return At&&p.startsWith(`${At}--`)?p.slice(At.length+2):At&&p.endsWith(`--${At}`)?p.slice(0,p.length-At.length-2):p||O})(),Ml=f.useMemo(()=>Hw(Be),[Be]),ds=f.useMemo(()=>({seat:At,unread_seqs:je[O],unread_snapshot_seqs:Ve==="unread"&&fe||void 0,escalated_seqs:Y[O]}),[At,je,O,Ve,fe,Y]),xt=f.useMemo(()=>{if(lt)return null;const p=new Set(Q.map(N=>N.name)),b=Z.trimStart();if(/^\/group(\s|$)/i.test(b)){const{title:N,members:S}=vd(b.replace(/^\/group/i,"").trim()),D=N||(S.length?`focused work with ${S.join(", ")}`:"");return{name:D?bd(D,p):"group",members:S,source:"slash"}}if(ge==="group"&&!O.startsWith("dm:")){const N=xd(gt),S=Fe.trim()||(N.length?`focused work with ${N.join(", ")}`:"");return{name:S?bd(S,p):"group",members:N,source:"kind"}}return null},[Z,lt,Q,ge,gt,Fe,O]),Kn=f.useMemo(()=>Iw(Be),[Be]),ms=f.useMemo(()=>Ph(Kn,Ve,ds),[Kn,Ve,ds]),[fs,Ra]=f.useState("recency"),[aa,ra]=f.useState(null),br=f.useRef(null);f.useEffect(()=>{br.current=aa},[aa]);const[ia,_i]=f.useState("");function Hc(){const p=P.current;ra(null),_i(""),i.messages(O,{sort:"votes",limit:50}).then(b=>{p===P.current&&ra(b)}).catch(b=>{if(p!==P.current)return;const N=String((b==null?void 0:b.message)||b);_i((b==null?void 0:b.status)===400||(b==null?void 0:b.status)===404||/allowlist/i.test(N)?"Top-voted needs the next hub update (this hub predates sort=votes) — Recency still works.":N)})}function Vc(p){Ps.current={message_id:p.id,seq:p.seq},Ra("recency"),requestAnimationFrame(()=>sa())}const[po,wr]=f.useState(""),[hs,_o]=f.useState("all"),[jn,jr]=f.useState(""),[On,gi]=f.useState(null),[yi,ps]=f.useState(null),Xn=f.useRef(0);function Pa(p,b,N){if(!p&&!N)return;const S=++Xn.current;ps(null),gi({q:p,report:null,error:"",busy:!0}),i.search({q:p,channel:b==="channel"&&O?[O]:void 0,rated:N||void 0,sort:!p&&N?"votes":void 0}).then(D=>{S===Xn.current&&gi({q:p,report:D,error:"",busy:!1})}).catch(D=>{if(S!==Xn.current)return;const le=String((D==null?void 0:D.message)||D);gi({q:p,report:null,busy:!1,error:(D==null?void 0:D.status)===404||/allowlist/i.test(le)?"Search needs the next hub update (this hub predates search-grouped) — everything else still works.":le})})}function Is(p){Pa(p.trim(),hs,jn)}function vi(){Xn.current+=1,gi(null),ps(null),jr("")}function za(p,b){const N=(On==null?void 0:On.q)||"";if(!N&&!jn)return;const S=++Xn.current;ps({label:p,kind:b,hits:[],total:0,cursor:null,busy:!0,error:""}),i.search({q:N,kind:b,sort:"recent",limit:50,rated:jn||void 0,channel:hs==="channel"&&O?[O]:void 0}).then(D=>{if(S!==Xn.current)return;const le=Ia(D,b);ps({label:p,kind:b,hits:le.hits,total:le.total,cursor:D.next_cursor??null,busy:!1,error:""})}).catch(D=>{S===Xn.current&&ps({label:p,kind:b,hits:[],total:0,cursor:null,busy:!1,error:String((D==null?void 0:D.message)||D)})})}function Zn(){const p=yi,b=(On==null?void 0:On.q)||"";if(!p||!p.cursor||p.busy||!b&&!jn)return;const N=Xn.current;ps({...p,busy:!0}),i.search({q:b,kind:p.kind,sort:"recent",limit:50,cursor:p.cursor,rated:jn||void 0,channel:hs==="channel"&&O?[O]:void 0}).then(S=>{if(N!==Xn.current)return;const D=Ia(S,p.kind);ps(le=>le&&le.kind===p.kind?{...le,hits:[...le.hits,...D.hits],cursor:S.next_cursor??null,busy:!1}:le)}).catch(S=>{N===Xn.current&&ps(D=>D&&D.kind===p.kind?{...D,busy:!1,error:String((S==null?void 0:S.message)||S)}:D)})}function Ia(p,b){const N=Sc.find(D=>D.kind===b),S=N?p[N.id]:void 0;return S?{hits:S.hits||[],total:S.total||0}:{hits:[],total:0}}function _s(p){const b=String(p.channel||"");b&&(Ps.current={message_id:p.kind==="message"?p.ref:void 0,seq:p.seq??void 0},vi(),Ra("recency"),b===O?sa():we(b))}async function go(p){const b=String(p.channel||""),N=String(p.ref||"");if(!b||!N)return;const S=Ir(N,"text/markdown");Qt({name:N,mode:S==="image"?"text":S,meta:`#${b}`,loading:!0});try{const D=await i.fs_read(b,N),le=Ir(N,D.mime);Qt({name:N,mode:le==="image"?"text":le,text:Cc(D.content),content_type:D.mime,meta:`#${b} · ${D.updated_by||"?"} · v${D.version??"?"}`,loading:!1})}catch(D){Qt({name:N,mode:"text",meta:`#${b}`,error:String((D==null?void 0:D.message)||D||"failed to read file")})}}function Rl(p){const b=p.kind==="message"&&!!p.channel,N=p.kind==="file"&&!!p.channel,S=b||N,D=rj(String(p.snippet||""),p.highlights),le=p.ratings,G=String(p.channel||""),ve=G?G.startsWith("dm:")?G:`#${G}`:"";return e.jsxs("div",{className:`team_search_hit${S?" clickable":""}`,onClick:S?()=>N?void go(p):_s(p):void 0,role:S?"button":void 0,title:b?"Open this message in its thread":N?"Open this file":void 0,children:[e.jsxs("div",{className:"team_search_hit_head",children:[p.kind!=="message"?e.jsx("span",{className:"team_search_kind mono",children:p.kind}):null,ve?e.jsx("span",{className:"team_search_chan mono",children:ve}):null,p.sender?e.jsx("span",{className:"team_search_sender",style:{color:`hsl(${rm(String(p.sender))}, 60%, 55%)`},children:p.sender}):null,typeof p.seq=="number"&&p.seq>0?e.jsxs("span",{className:"muted mono",children:["#",p.seq]}):null,p.status==="open"||p.status==="blocked"?e.jsx("span",{className:"team_search_status mono",title:"This thread still carries an unresolved obligation",children:p.status}):null,typeof p.thread_hits=="number"&&p.thread_hits>1?e.jsxs("span",{className:"muted",title:"More matches in the same thread",children:[p.thread_hits," in thread"]}):null,le&&(le.up||le.down)?e.jsxs("span",{className:"team_search_tally mono",title:"Standing ±1 ratings on this message (read-only here — vote from the thread)",children:["▲",le.up," ▽",le.down]}):null,p.created_at?e.jsx("span",{className:"muted team_search_time",children:Go(p.created_at)}):null]}),String(p.title||"").trim()?e.jsx("div",{className:"team_search_title",children:p.title}):null,D.length?e.jsx("div",{className:"team_search_snippet",children:D.map((ze,qe)=>ze.hit?e.jsx("mark",{children:ze.text},qe):e.jsx(Wt.Fragment,{children:ze.text},qe))}):null,!b&&!N&&p.kind!=="agent"?e.jsx("div",{className:"team_search_ref mono muted",children:p.ref}):null]},`${p.kind}:${G}:${p.ref}`)}const Gc=f.useMemo(()=>{let p=0;for(const b of ms)for(const N of[b.root,...b.replies])p=Math.max(p,N.seq||0);return p},[ms]),oa=f.useMemo(()=>{const p={};for(const b of["asks","vigilance","fyi","resolved","to_me"])p[b]=Ph(Kn,b,ds).length;return p.unread=Be.filter(b=>{var N,S;return((N=ds.unread_seqs)==null?void 0:N.has(b.seq))||((S=ds.unread_snapshot_seqs)==null?void 0:S.has(b.seq))}).length,p},[Kn,Be,ds]);function kr(){var p,b;return zt==="loading"?e.jsx("span",{className:"muted team_note",children:"Loading channel info…"}):zt&&typeof zt=="object"&&"error"in zt?e.jsx("span",{className:"page_error mono",children:zt.error}):zt?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"team_info_row",children:[zt.state?e.jsx(Wn,{tone:zt.state==="open"?"success":"warning",size:"sm",children:zt.state}):null,(p=zt.channel)!=null&&p.private?e.jsx(Wn,{tone:"muted",size:"sm",children:"private"}):e.jsx(Wn,{tone:"muted",size:"sm",children:"public"}),zt.response_sla_minutes?e.jsxs(Wn,{tone:"muted",size:"sm",title:"Expected response SLA",children:["SLA ",Math.round(Number(zt.response_sla_minutes)/60),"h"]}):null,e.jsxs("span",{className:"muted team_note",children:[(xn??zt.members??[]).length," members"]})]}),(b=zt.meta)!=null&&b.purpose?e.jsx("div",{className:"team_info_purpose",children:zt.meta.purpose}):null,zt.charter?e.jsxs("div",{className:"team_info_charter",children:[e.jsx("div",{className:"muted team_note",style:{marginBottom:4},children:"Charter"}),e.jsx(Qn,{className:"md_doc",text:Xo(String(zt.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 ",xn?`(${xn.length})`:""]}),!qt&&xn!==null?e.jsxs("div",{className:"team_invite_row",children:[e.jsxs("select",{className:"team_compose_control team_invite_select",value:Yr,onChange:N=>Wi(N.target.value),disabled:!!lr,title:"Agents on the hub not yet in this channel",children:[e.jsx("option",{value:"",children:"invite: agent…"}),Es.filter(N=>!(xn||[]).some(S=>String(S.agent_id||"")===N)).filter(N=>!(Bi[O]||new Set).has(N)).map(N=>e.jsx("option",{value:N,children:N},N))]}),e.jsx("button",{className:"btn",disabled:!Yr||!!lr,title:"Mint a single-use invite token and DM it with the join pointer",onClick:()=>void Al(Yr),children:lr?"Inviting…":"Invite"})]}):null,os?e.jsx("div",{className:"muted team_note",children:os}):null,(()=>{const N=[...Bi[O]||[]].filter(S=>!(xn||[]).some(D=>String(D.agent_id||"")===S));return!N.length||xn===null?null:N.map(S=>e.jsxs("div",{className:"team_member_row team_member_invited",children:[e.jsx("span",{className:"team_avatar",style:Ya(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}`))})(),Hr?e.jsxs("div",{className:"muted team_note",children:["Members list unavailable (",Hr.slice(0,100),") — an empty list below means the FETCH failed, not an empty channel. Reopen the drawer to retry."]}):null,xn===null?e.jsx("span",{className:"muted team_note",children:"Loading members…"}):xn.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:Ya(S),"aria-hidden":"true",children:(S[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",title:String(N.about||""),children:S}),S!==At&&!qt?e.jsxs("span",{className:"team_member_actions",children:[e.jsx("button",{className:"team_row_expand",disabled:!!Jt,title:"Kick: 1-hour block from THIS channel (hub authorizes — owner/operator only)",onClick:()=>void ui(S,"kick"),children:Jt===`channel:kick:${S}`?"kicking…":"kick"}),e.jsx("button",{className:`team_row_expand ${Kt===`channel:ban:${S}`?"team_danger":""}`,disabled:!!Jt,title:"Ban: INDEFINITE block from this channel (two clicks — the first arms, the second confirms)",onClick:()=>{Kt===`channel:ban:${S}`?(Xt(""),ui(S,"ban")):Xt(`channel:ban:${S}`)},children:Jt===`channel:ban:${S}`?"banning…":Kt===`channel:ban:${S}`?"confirm ban":"ban"}),e.jsx("button",{className:`team_row_expand ${Kt===`hub:ban:${S}`?"team_danger":""}`,disabled:!!Jt,title:"Hub ban: INDEFINITE lockout from the ENTIRE hub — every channel, re-registration refused, live connection severed (operator-only). Two clicks to confirm.",onClick:()=>{Kt===`hub:ban:${S}`?(Xt(""),ui(S,"ban","hub")):Xt(`hub:ban:${S}`)},children:Jt===`hub:ban:${S}`?"hub-banning…":Kt===`hub:ban:${S}`?"confirm hub ban":"hub ban"}),e.jsx("button",{className:`team_row_expand ${Kt===`retire:${S}`?"team_danger":""}`,disabled:!!Jt,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:()=>{Kt===`retire:${S}`?(Xt(""),Bc(S)):Xt(`retire:${S}`)},children:Jt===`retire:${S}`?"retiring…":Kt===`retire:${S}`?"confirm retire":"retire"})]}):S===At?e.jsx("span",{className:"chip mono ok",style:{marginLeft:"auto"},children:"you"}):null]},S):null})]}),!qt&&Jr&&Jr.length?e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Blocked (",Jr.length,")"]}),Jr.map(N=>{const S=String(N.agent_id||N.agent||"");if(!S)return null;const D=String(N.scope||""),le=D==="hub",G=le?"hub":"channel",ve=N.expires_at?` · until ${new Date(Number(N.expires_at)*1e3).toLocaleString()}`:" · indefinite",ze=le?"hub-wide":`#${D}`;return e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Ya(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:[ze,ve]})]}),e.jsx("span",{className:"team_member_actions",children:e.jsx("button",{className:"team_row_expand",disabled:!!Jt,title:le?"Lift this HUB-WIDE block (the agent can re-register and rejoin)":"Lift this channel block (the agent can rejoin/post again)",onClick:()=>void ui(S,"unblock",G),children:Jt===`${G}:unblock:${S}`?"unblocking…":"unblock"})})]},`blocked:${D}:${S}`)})]}):null,!qt&&$s&&$s.length?e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Retired agents (",$s.length,")"]}),$s.map(N=>{const S=String(N.id||"");if(!S)return null;const D=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:Ya(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",D]})]}),e.jsxs("span",{className:"team_member_actions",children:[e.jsx("button",{className:`team_row_expand ${Kt===`unretire:${S}`?"team_danger":""}`,disabled:!!Jt,title:"Un-retire: restore this agent's access (it rejoins channels explicitly). Two clicks to confirm.",onClick:()=>{Kt===`unretire:${S}`?(Xt(""),Uc(S)):Xt(`unretire:${S}`)},children:Jt===`unretire:${S}`?"un-retiring…":Kt===`unretire:${S}`?"confirm un-retire":"un-retire"}),e.jsx("button",{className:`team_row_expand ${Kt===`delete:${S}`?"team_danger":""}`,disabled:!!Jt,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:()=>{Kt===`delete:${S}`?(Xt(""),Wc(S)):Xt(`delete:${S}`)},children:Jt===`delete:${S}`?"deleting…":Kt===`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:"ⓘ"})]}),Ks===null?e.jsx("span",{className:"muted team_note",children:Vr||"Loading delegations…"}):e.jsxs(e.Fragment,{children:[Ks.length===0?e.jsx("span",{className:"muted team_note",children:"No active delegate."}):null,Ks.map(N=>{const S=String(N.agent_id||""),D=Array.isArray(N.powers)?N.powers.map(String):[],le=Number(N.expires_at||N.expires||0);return e.jsxs("div",{className:"team_delegation_row",children:[e.jsx("span",{className:"team_avatar",style:Ya(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:[D.join(" + ")||"(no powers?)",le?` · until ${new Date(le*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:""]}),e.jsx("button",{className:`team_row_expand ${Kt===`resign:${S}`?"team_danger":""}`,disabled:mn,title:"Resign this delegate: the grant is revoked hub-wide, on the record (two clicks)",onClick:()=>{Kt===`resign:${S}`?(Xt(""),or(S)):Xt(`resign:${S}`)},children:mn?"resigning…":Kt===`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:fn,onChange:N=>ml(N.target.value),title:"Assign a delegate: any registered agent except operators and current delegates",children:[e.jsx("option",{value:"",children:"assign a delegate…"}),(xn??zt.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!==At&&!Ks.some(S=>String(S.agent_id)===N)).map(N=>e.jsx("option",{value:N,children:N},N))]}),fn?e.jsxs("div",{className:"team_delegation_powers_pick",children:[bj.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=>fl(D=>S.target.checked?[...D,N.id]:D.filter(le=>le!==N.id))}),N.id]},N.id)),e.jsx("button",{className:"btn",disabled:mn||!ga.length,title:ga.length?`Grant ${fn} the powers: ${ga.join(", ")} (7-day TTL, renewable; on the record)`:"Pick at least one power",onClick:()=>void Kr(),children:mn?"Assigning…":"Assign"})]}):null]}),Vr?e.jsx("div",{className:"page_error mono",children:Vr}):null]})]}),qt?null:e.jsx("div",{className:"team_chan_admin",children:kn?String(zt.state||"open")==="open"?e.jsx("button",{className:"btn",disabled:ln,title:"Close this channel — member posts refuse until reopened (owner-only; the hub authorizes)",onClick:()=>void In("closed"),children:ln?"Closing…":"Close channel"}):e.jsx("button",{className:"btn",disabled:ln,title:"Reopen this channel for member posts",onClick:()=>void In("open"),children:ln?"Reopening…":"Reopen channel"}):e.jsxs("span",{className:"muted team_note",children:["Close/reopen is owner-only on the hub (this channel's owner: ",sn||"unknown",")."]})}),Qr?e.jsx("div",{className:"page_error mono",children:Qr}):null]}):e.jsx("span",{className:"muted team_note",children:"Open a channel to see its members."})}function Da(p){var N;const b=((N=p.data)==null?void 0:N.attachments)||p.attachments||[];return b.length?e.jsx("div",{className:"team_attachments",children:b.map((S,D)=>{const le=`${S.id}:${D}`,G=i.attachment_url(p.channel,S.id);return yj.has(String(S.content_type||"").toLowerCase())?e.jsxs("button",{className:"team_attach_img_link",title:`${S.filename} · ${Hn(S.size)} — click to preview`,onClick:()=>void ci(p.channel,S),children:[e.jsx("img",{className:"team_attach_img",src:G,alt:S.filename,loading:"lazy",onError:ze=>{var Pt;const qe=ze.currentTarget;qe.style.display="none";const We=(Pt=qe.parentElement)==null?void 0:Pt.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(Ue,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:S.filename}),e.jsx("span",{className:"muted",children:Hn(S.size)})]})]},le):e.jsxs("button",{className:"team_attach_chip team_attach_dl",title:`${S.content_type} · ${Hn(S.size)} — click to preview`,onClick:()=>void ci(p.channel,S),children:[e.jsx(Ue,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:S.filename}),e.jsx("span",{className:"muted",children:Hn(S.size)})]},le)})}):null}function xi(p,b){var ve;const N=[],S=String(p.status||"").toLowerCase();(S==="open"||S==="blocked")&&(p.has_resolved_reply===!0||(p.id?Ml.has(p.id):!1))?N.push(e.jsx(Wn,{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(Wn,{tone:S==="blocked"?"error":"warning",size:"sm",children:S},"st")):S==="resolved"&&b&&N.push(e.jsx(Wn,{tone:"success",size:"sm",children:"resolved"},"st")),p.critical&&N.push(e.jsx(Wn,{tone:"error",size:"sm",title:"Critical: unpins only on explicit read — click the row to record the read",children:"critical"},"crit"));const le=((ve=p.data)==null?void 0:ve.answers)||[];S==="reply"&&le.length&&N.push(e.jsxs(Wn,{tone:"success",size:"sm",title:`This reply discharges ask(s) ${le.join(", ")} of its parent.`,children:["✓ answers ",le.join(",")]},"dis"));const G=p.to||[];for(const ze of G.slice(0,2))N.push(e.jsxs(Wn,{tone:"muted",size:"sm",children:["@",ze]},`to:${ze}`));return G.length>2&&N.push(e.jsxs(Wn,{tone:"muted",size:"sm",title:G.map(ze=>`@${ze}`).join(" "),children:["+",G.length-2]},"to+")),N}function Sr(p,b){return e.jsx(s_,{resetKey:`${p.retracted?1:0}:${(p.body||"").length}:${(p.title||"").length}`,fallback:e.jsx("div",{className:"team_row team_row_broken",id:`hubmsg-${p.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:Jh(p.sender),children:p.sender}),e.jsxs("span",{className:"team_row_meta mono",children:["#",p.seq," · ",Vo(p.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:(p.title?p.title+`
131
+ `:"")+String(p.body||"(no text)")})]})}),children:Oa(p,b)},p.id)}function Oa(p,b){var yt,nt,Ft,Ct;const N=!!Je[p.id],S=String(p.body||""),D=b.is_root?Nc:Hh,le=S.length>D,G=le&&!N,ve=((yt=p.data)==null?void 0:yt.asks)||[],ze=!!((nt=ds.unread_seqs)!=null&&nt.has(p.seq)),qe=Ve!=="all"&&Dw(p,Ve,ds),We=String(p.title||"").trim(),Pt=((Ft=S.trim().split(`
132
+ `)[0])==null?void 0:Ft.trim())||"",Nt=We&&(We===S.trim()||We===Pt),Ht=(lt==null?void 0:lt.id)===p.id;return e.jsxs("div",{className:`team_row ${p.sender===At?"own":""} ${qe?"hit":""} ${Ht?"replying":""} ${ze?"unread":""} ${p.retracted?"retracted":""}`,id:`hubmsg-${p.id}`,onClick:()=>Fc(p),title:le?void 0:p.critical?"Click to record the read (critical unpins on it)":void 0,children:[e.jsx("span",{className:"team_avatar",style:Ya(p.sender),"aria-hidden":"true",children:(p.sender[0]||"?").toUpperCase()}),e.jsxs("div",{className:"team_row_main",children:[e.jsxs("div",{className:"team_row_head",children:[(Ct=q[p.channel])!=null&&Ct.has(p.seq)?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"team_chip_debt",title:"Pinned by the hub until answered: this is an open ask or a directive addressed to you — reading is not answering; reply, Decline, or Resolve the thread to clear it",children:"needs reply"}),e.jsx("button",{className:`team_chip_decline ${Ea===p.id?"armed":""}`,title:Ea===p.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:Ge=>{Ge.stopPropagation(),jl(p)},children:Ea===p.id?"sure? declines on the record":"decline"})]}):ze?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"}):p.read===!1&&b.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:Jh(p.sender),children:p.sender}),xi(p,b.is_root),(()=>{const Ge=na(p);return!Ge||!Ge.up&&!Ge.down?null:e.jsxs("span",{className:`team_reaction_tally mono ${Ge.mine>0?"pos":Ge.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:[Ge.up?`▲${Ge.up}`:"",Ge.up&&Ge.down?" ":"",Ge.down?`▼${Ge.down}`:""]})})(),e.jsxs("span",{className:"team_row_meta mono",title:Go(p.created_at),children:["#",p.seq," · ",Vo(p.created_at)]})]}),We&&!Nt?e.jsx("div",{className:"team_row_title",children:We}):null,e.jsx("div",{className:`team_row_body ${G?b.is_root?"clamp_root":"clamp_reply":""}`,children:e.jsx(cj,{className:"md_doc",text:Xo(ej(Qw(S),{hub_base:R}))})}),Da(p),(()=>{var $t;const Ge=Kw(`${String(p.title||"")}
133
+ ${S}`),It=(($t=p.data)==null?void 0:$t.attachments)||p.attachments||[],_n=Ge.map(ut=>({mention:ut,res:Jw(ut,ao,It)})).filter(ut=>ut.res!==null).filter(ut=>{var Tt;return!(ut.res.kind==="attachment"&&String(((Tt=It[ut.res.attachment_index])==null?void 0:Tt.filename)||"")===ut.mention)}),Mt=s.on_open_board?db(`${String(p.title||"")}
134
+ ${S}`):[];return!_n.length&&!Mt.length?null:e.jsxs("div",{className:"team_fs_chips",children:[_n.map(({mention:ut,res:Tt})=>e.jsxs("button",{className:"team_attach_chip team_fs_chip",title:Tt.kind==="fs"?Tt.rewritten?`Opens ${Tt.path} (the mention's path moved — matched by name in #${O}'s files)`:`Open ${Tt.path} from #${O}'s virtual filesystem`:"Opens the file attached to this message (the path in the text belongs to the sender's workspace)",onClick:Cr=>{Cr.stopPropagation(),Tt.kind==="fs"?Sl(Tt.path):ci(p.channel,It[Tt.attachment_index])},children:[e.jsx(Kh,{}),e.jsx("span",{className:"team_attach_name",children:ut}),Tt.kind==="attachment"?e.jsx("span",{className:"team_fs_chip_note",children:"attached"}):Tt.rewritten?e.jsx("span",{className:"team_fs_chip_note",children:"moved"}):null]},ut)),Mt.map(ut=>e.jsxs("button",{className:"team_attach_chip team_fs_chip team_work_chip",title:`Work item ${ut} — open the Board filtered to it`,onClick:Tt=>{var Cr;Tt.stopPropagation(),(Cr=s.on_open_board)==null||Cr.call(s,ut)},children:[e.jsx("span",{className:"team_work_glyph","aria-hidden":!0,children:"⛭"}),e.jsx("span",{className:"team_attach_name mono",children:ut})]},`w:${ut}`))]})})(),ve.length?e.jsx("div",{className:"team_row_asks",children:ve.map(Ge=>e.jsxs("span",{className:"team_ask",title:Ge.text,children:["ask ",Ge.id,": ",Ge.text.length>90?Ge.text.slice(0,90)+"…":Ge.text]},Ge.id))}):null,le?e.jsx("button",{className:"team_row_expand",onClick:Ge=>{Ge.stopPropagation(),$a(p)},children:N?"collapse":"show more"}):null]}),Dn?e.jsxs("div",{className:"team_row_rail",children:[p.id&&p.sender!==At&&p.sender!=="hub"&&!p.retracted?(()=>{const Ge=na(p);return Ge?e.jsxs("span",{className:"team_vote_thumbs",children:[e.jsxs("button",{className:`btn btn_icon team_thumb ${Ge.mine>0?"up_on":""}`,title:Ge.mine>0?"Withdraw your +1 on this message":"+1 this message",disabled:!!Rs,onClick:It=>{It.stopPropagation(),Aa(p.id,1)},children:[e.jsx(Ue,{name:Ge.mine>0?"thumbsUpFilled":"thumbsUp",size:13}),Ge.up?e.jsx("span",{className:"team_thumb_count",children:Ge.up}):null]}),e.jsxs("button",{className:`btn btn_icon team_thumb ${Ge.mine<0?"down_on":""}`,title:Ge.mine<0?"Withdraw your −1 on this message":"−1 this message",disabled:!!Rs,onClick:It=>{It.stopPropagation(),Aa(p.id,-1)},children:[e.jsx(Ue,{name:Ge.mine<0?"thumbsDownFilled":"thumbsDown",size:13}),Ge.down?e.jsx("span",{className:"team_thumb_count",children:Ge.down}):null]})]}):null})():null,$.tts_supported&&p.id?(()=>{const Ge=$.tts_playback.key===p.id&&$.tts_playback.status==="playing",It=$.tts_playback.key===p.id&&$.tts_playback.status==="loading";return e.jsx("button",{className:`btn btn_icon ${Ge||It?"team_speak_on":""}`,title:Ge?"Pause":It?"Synthesizing…":h.enabled?"Read aloud (your voice override)":"Read aloud (gateway voice)","aria-label":Ge?"Pause reading":"Read this message aloud",onClick:_n=>{_n.stopPropagation();const Mt=_w(p.body||p.title||"");Mt?$.toggle_tts(p.id,Mt):W("Nothing readable to speak in this message (code/markup only).")},children:e.jsx(Ue,{name:Ge?"pause":It?"refresh":"speaker",size:13})})})():null,e.jsx("button",{className:"btn btn_icon",title:ve.length?"Reply and discharge this message's asks":"Reply in this trail (status=reply, linked to this message)",onClick:Ge=>{Ge.stopPropagation(),hi(p)},children:"↩ Reply"}),p.sender===At&&!p.retracted?e.jsx("button",{className:`btn btn_icon ${vr===p.id?"team_danger":""}`,title:vr===p.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:Ge=>{Ge.stopPropagation(),vr===p.id?Ma(p):xr(p.id)},children:vr===p.id?"⌫ confirm retract":"⌫ Retract"}):null,b.is_root&&(String(p.status||"").toLowerCase()==="open"||String(p.status||"").toLowerCase()==="blocked")?e.jsx("button",{className:`btn btn_icon ${zs===p.id?"team_danger":""}`,title:zs===p.id?"Click again to close this topic (posts a resolved reply)":"Mark this topic resolved — closes the thread on the hub (two clicks)",onClick:Ge=>{Ge.stopPropagation(),zs===p.id?oo(p):fi(p.id)},children:zs===p.id?"✓ confirm resolve":"✓ Resolve"}):null]}):null]},p.id)}function Ds(p){const b=p.replies.length,N=!!xe[p.root.id],S=!!de[p.root.id],D=N?[]:S||Ve!=="all"||b<=Vh+1?p.replies:p.replies.slice(b-Vh),le=N?b:b-D.length,G=Ic[p.root.id];return e.jsxs("div",{className:`team_thread_group ${b?"has_replies":""}`,children:[p.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,Sr(p.root,{is_root:!0}),le>0||b>0||String(p.root.body||"").length>Nc?e.jsxs("div",{className:"team_trail_bar",children:[b>0?e.jsx("button",{className:"team_replies_more",onClick:()=>ke(ve=>({...ve,[p.root.id]:!ve[p.root.id]})),children:N?`show ${b} repl${b===1?"y":"ies"}`:"fold thread"}):null,!N&&le>0?e.jsxs("button",{className:"team_replies_more",onClick:()=>ye(ve=>({...ve,[p.root.id]:!0})),children:["↓ ",le," earlier repl",le===1?"y":"ies"]}):null,!N&&u&&(b>0||String(p.root.body||"").length>Nc)?e.jsx("button",{className:"team_replies_more team_summarize",disabled:!!(G!=null&&G.busy),title:"LLM summary of this trail (root + replies) — read-only, never posts",onClick:()=>void La(p),children:G!=null&&G.busy?"✦ summarizing…":`✦ Summarize (${b+1})`}):null]}):null,!N&&b>0?e.jsx("div",{className:"team_replies",children:D.map(ve=>Sr(ve,{is_root:!1}))}):null,!N&&(G!=null&&G.text)?e.jsxs("div",{className:"team_summary",children:[e.jsxs("div",{className:"team_summary_head",children:[e.jsxs("span",{children:["AI summary — ",G.window||`${G.count} message${G.count===1?"":"s"}`]}),e.jsx("button",{className:"team_row_expand",onClick:()=>xa(ve=>({...ve,[p.root.id]:{busy:!1,text:"",error:"",count:0}})),children:"dismiss"})]}),e.jsx(Qn,{className:"md_doc",text:Xo(G.text)})]}):null,G!=null&&G.error?e.jsx("div",{className:"page_error mono",children:G.error}):null]},p.root.id)}const Rt=Be.length?Be[Be.length-1].seq:0,Lt=Math.max(Rt,((Os=Q.find(p=>p.name===O))==null?void 0:Os.last_seq)||0),gs=((la=Q.find(p=>p.name===O))==null?void 0:la.member_count)||0,sn=((pn=(xn||[]).find(p=>String(p.role||"")==="owner"))==null?void 0:pn.agent_id)||"",kn=!!At&&sn===At;return e.jsxs("div",{className:"page page_pad team_page",onDragOver:p=>{var b;Array.from(((b=p.dataTransfer)==null?void 0:b.types)||[]).includes("Files")&&(p.preventDefault(),Dn&&!Le&&wt(!0))},onDragLeave:p=>{p.currentTarget.contains(p.relatedTarget)||wt(!1)},onDrop:p=>{var b,N;(N=(b=p.dataTransfer)==null?void 0:b.files)!=null&&N.length&&(p.preventDefault(),wt(!1),!(!Dn||Le)&&lo(p.dataTransfer.files))},children:[Dt?e.jsx("div",{className:"team_drop_overlay",children:e.jsxs("div",{className:"team_drop_overlay_card",children:["Drop to attach to ",qt?ho:`#${O}`]})}):null,A!=null&&A.protocol&&A.protocol!==$c||A!=null&&A.paused||se||zn||Ur||T&&!T.seat_key_present?e.jsxs("div",{className:"team_statusstrip",children:[T&&!T.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!==$c?e.jsxs("span",{className:"chip mono warn",title:`The hub advertises ${A.protocol}; this page was written against ${$c}. Meaning may have shifted — rendering continues (protocol.md: warn, never refuse).`,children:["protocol ",A.protocol," ≠ ",$c]}):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,se?e.jsx("span",{className:"page_error mono",children:se}):null,zn?e.jsxs("span",{className:"page_error mono",children:["±1 failed: ",zn]}):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_${$e} ${Re?"team_tools_open":""}`,children:[e.jsxs("div",{className:"pane team_channels_pane",onClickCapture:p=>{var b,N;(N=(b=p.target)==null?void 0:b.closest)!=null&&N.call(b,".team_channel")&&Oe("thread")},children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Channels"}),e.jsx("span",{className:"pane_count",children:Q.filter(p=>!p.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:()=>Ts(p=>({...p,open:!p.open})),children:e.jsx(Ue,{name:"plus",size:14})})})]}),Tn.open?e.jsxs("div",{className:"team_new_channel",children:[e.jsx("input",{value:Tn.name,onChange:p=>Ts(b=>({...b,name:p.target.value})),placeholder:"channel-name (simple slug)",onKeyDown:p=>{p.key==="Enter"&&$l()}}),e.jsx(Di,{variant:"sm",label:"Private",hint:"Private channels need invites; public ones are joinable by any registered agent.",action:"new-channel-private",checked:Tn.is_private,onChange:p=>Ts(b=>({...b,is_private:p}))}),e.jsx("button",{className:"btn primary",disabled:!Tn.name.trim()||ln,onClick:()=>void $l(),children:ln?"Creating…":"Create"})]}):null,e.jsxs("div",{className:"pane_body pane_body_list",children:[Q.length?null:e.jsx("div",{className:"muted team_note team_rail_degraded",children:si?e.jsx("span",{"data-hub-note":"not-configured",children:si}):se?"Channels unavailable — the hub is unreachable. Retrying automatically; check that the hub is running if this persists.":"Loading channels…"}),Q.filter(p=>!p.name.startsWith("dm:")).map(p=>{const b=be[p.name],N=Cl===p.name;return e.jsxs("div",{className:`team_channel team_dm_row ${O===p.name?"selected":""}`,role:"button",tabIndex:0,onClick:()=>we(p.name),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&we(p.name)},children:[e.jsxs("span",{className:"team_channel_line",children:[e.jsxs("span",{className:`team_channel_name ${b!=null&&b.unread?"has_unread":""}`,children:["#",p.name]}),e.jsxs("span",{className:"team_channel_badges",children:[b!=null&&b.unread?e.jsx("span",{className:"team_badge unread",role:"button",tabIndex:0,title:`${b.unread>=100?"100 or more":b.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(),p.name!==O&&(et.current="unread"),we(p.name),ct("unread")},onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.stopPropagation(),p.name!==O&&(et.current="unread"),we(p.name),ct("unread"))},children:b.unread>=100?"99+":b.unread}):null,b!=null&&b.open_questions?e.jsx("span",{className:"team_badge asks",role:"button",tabIndex:0,title:`${b.open_questions} open question(s) in this room still awaiting answers (channel digest) — click to open with the Asks filter`,onClick:S=>{S.stopPropagation(),p.name!==O&&(et.current="asks"),we(p.name),ct("asks")},onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.stopPropagation(),p.name!==O&&(et.current="asks"),we(p.name),ct("asks"))},children:b.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:ln,onClick:S=>{S.stopPropagation(),N?io(p.name):di(p.name)},children:e.jsx(Ue,{name:N?"x":"trash",size:12})})]})]}),e.jsx("span",{className:"team_channel_meta mono",children:N?"archive? click ✕":`${p.member_count} seats · ${Vo(p.last_at)}`})]},p.name)}),(()=>{const p=Q.filter(b=>b.name.startsWith("dm:"));return p.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"team_rail_section",children:"Direct messages"}),p.map(b=>{const N=be[b.name],S=b.name.replace(/^dm:/,"").split("--").filter(le=>le!==At).join("")||b.name,D=yr===b.name;return e.jsxs("div",{className:`team_channel team_dm_row ${O===b.name?"selected":""}`,role:"button",tabIndex:0,onClick:()=>we(b.name),onKeyDown:le=>{(le.key==="Enter"||le.key===" ")&&we(b.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 ${D?"arming":""}`,title:D?"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":D?"Confirm remove direct message":"Remove direct message",disabled:ln,onClick:le=>{le.stopPropagation(),D?Nl(b.name):ro(b.name)},children:e.jsx(Ue,{name:D?"x":"trash",size:12})})]})]}),e.jsx("span",{className:"team_channel_meta mono",children:D?"remove? click ✕":Vo(b.last_at)})]},b.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:()=>{Oe("channels"),it(!1),Et&&Gn("")},"aria-label":"Back to channels",title:"Back to channels",children:"← Channels"}),e.jsx("button",{type:"button",className:"btn team_tools_btn",onClick:()=>it(p=>!p),"aria-expanded":Re,"aria-label":Re?"Hide thread tools":"Show thread tools (filters, search, panels)",title:"Filters, search, panels and actions",children:Re?"Less":"More"}),e.jsx("span",{className:"pane_title team_pane_title",children:O?qt?`@${ho} — direct`:`#${O}`:"Select a channel"}),O&&gs?e.jsxs("button",{className:"chip team_members_chip",onClick:()=>{Et!=="members"&&ta("members")},title:"View the channel members (opens the Members drawer, roster + moderation)",children:[gs," members"]}):null,ie?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 p=Ve==="all"?Lt:Gc;return e.jsx("button",{className:"btn",onClick:()=>void fo(p),disabled:!O||!Be.length||!p||qi||ie,title:Ve==="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:qi?"Marking…":`Mark read → #${p||"…"}`})})(),e.jsx("button",{className:"btn btn_icon",onClick:()=>{Yn(),ea(O)},title:"Refresh channels, badges, and the thread window (the page also polls every 5s)","aria-label":"Refresh",children:e.jsx(Ue,{name:"refresh",size:14})}),Gt&&Gt!=="running"&&typeof Gt=="object"&&"ok"in Gt?Gt.ok?e.jsxs(Wn,{tone:"success",size:"sm",title:`Hash chain recomputed client-side over ${Gt.hashed} hashed turns (${Gt.legacy} pre-ledger); served head matches.`,children:["transcript intact (",Gt.hashed,")"]}):e.jsxs(Wn,{tone:"error",size:"sm",title:Gt.broken_at!==null?`Recomputed chain diverges at seq ${Gt.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",Gt.broken_at!==null?` at #${Gt.broken_at}`:" (head mismatch)"]}):null,Gt&&typeof Gt=="object"&&"error"in Gt?e.jsx(Wn,{tone:"warning",size:"sm",title:Gt.error,children:"verify failed"}):null,e.jsx("button",{className:"btn btn_icon",onClick:()=>void bl(),disabled:!O||Gt==="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:Gt==="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:Rh.map(p=>{const b=Ve===p.id,N=oa[p.id];return e.jsxs("button",{className:`seg_btn ${b?"active":""}`,"aria-pressed":b,title:p.title,onClick:()=>ct(p.id),children:[p.label,typeof N=="number"&&N>0?e.jsx("span",{className:"team_filter_count",children:N}):null]},p.id)})}),e.jsxs("form",{className:"team_search_bar",onSubmit:p=>{p.preventDefault();const b=po.trim();if(!b&&!jn){jr("down"),Pa("",hs,"down");return}Is(b)},children:[e.jsx("input",{className:"team_search_input",type:"search",placeholder:"Search the hub…",value:po,onChange:p=>wr(p.target.value),onKeyDown:p=>{p.key==="Escape"&&(On&&vi(),wr(""))},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"}),On?e.jsx("button",{type:"button",className:"btn btn_icon team_search_close",onClick:vi,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 ${fs==="recency"?"active":""}`,"aria-pressed":fs==="recency",title:"Threads by last activity (default)",onClick:()=>Ra("recency"),children:"Recency"}),e.jsx("button",{className:`seg_btn ${fs==="votes"?"active":""}`,"aria-pressed":fs==="votes",title:"The channel's most-voted messages — whole channel, ranked by net standing ±1 (hub-served order)",onClick:()=>{Ra("votes"),Hc()},children:"Top voted"})]}),e.jsxs("span",{className:"team_filterbar_meta",children:[e.jsx("span",{className:`team_live_dot ${Yi?"on":""}`,title:Yi?"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:Yi?"● live":"◌ polling"})," · ",ms.length!==Kn.length?`${ms.length} of ${Kn.length} threads`:Kn.length?`${Kn.length} threads`:"",T!=null&&T.seat_key_present?e.jsxs("span",{title:"Posts are authored under this hub seat — your own identity, key held server-side.",children:[" · as ",T.seat]}):null]})]}),e.jsx("div",{className:"pane_body team_thread",ref:ni,children:On?(()=>{const p=On;if(p.error)return e.jsx("div",{className:"muted team_note",children:p.error});if(p.busy||!p.report)return e.jsx("div",{className:"muted team_note",children:p.q?`Searching “${p.q}”…`:"Browsing rated messages…"});const b=p.report;if(yi){const D=yi;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:()=>ps(null),children:"← All results"}),e.jsxs("span",{className:"muted",children:[D.label," matching “",p.q,"” — newest first",D.total?` · ${D.hits.length} of ${D.total}`:""]})]}),D.error?e.jsx("div",{className:"muted team_note",children:D.error}):null,D.hits.map(le=>Rl(le)),D.busy?e.jsx("div",{className:"muted team_note",children:"Loading…"}):null,!D.busy&&D.cursor?e.jsx("button",{className:"team_replies_more team_search_more",onClick:Zn,children:"Load more"}):null,!D.busy&&!D.hits.length&&!D.error?e.jsxs("div",{className:"muted team_note",children:["Nothing in ",D.label.toLowerCase()," matches “",p.q,"”."]}):null]})}const N=Sc.filter(D=>{var le;return!((((le=b[D.id])==null?void 0:le.total)??0)>0)}),S=N.length<Sc.length;return e.jsxs("div",{className:"team_search_results",children:[b.relaxed&&(!b.mode_used||b.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,b.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:b.notice}):null,e.jsxs("div",{className:"team_search_meta",children:[e.jsxs("span",{className:"muted",children:[p.q?`“${p.q}”`:`rated messages${jn?` (${jn==="down"?"↓ downvoted":"↑ upvoted"}, net-vote order)`:""}`," · ",b.channels_searched??0," channel",(b.channels_searched??0)===1?"":"s"," searched",b.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:[" ","· ",b.mode_used,typeof b.semantic_coverage=="number"?` (${Math.round(b.semantic_coverage*100)}% embedded)`:""]}):null]}),e.jsx("span",{className:"seg team_search_rated",role:"group","aria-label":"Rated filter",children:["up","down"].map(D=>e.jsx("button",{className:`seg_btn ${jn===D?"active":""}`,"aria-pressed":jn===D,title:D==="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 le=jn===D?"":D;jr(le),Pa(p.q,hs,le)},children:D==="up"?"▲ rated":"▼ rated"},D))}),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:hs==="channel",onChange:D=>{const le=D.target.checked?"channel":"all";_o(le),Pa(p.q,le,jn)}}),"this channel only"]})]}),Sc.map(D=>{const le=b[D.id],G=(le==null?void 0:le.shown)??0,ve=(le==null?void 0:le.total)??0,ze=(le==null?void 0:le.hits)??[];return!le||!ve&&!ze.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:D.label}),e.jsx("span",{className:"muted mono",children:G<ve?`showing ${G} of ${ve}`:`${ve}`}),G<ve&&D.kind?e.jsx("button",{className:"team_replies_more",onClick:()=>za(D.label,D.kind),title:`All ${ve} ${D.label.toLowerCase()} matches, newest first (paged)`,children:"view all →"}):null]}),ze.map(qe=>Rl(qe))]},D.id)}),S?N.length?e.jsxs("div",{className:"muted team_search_empties",children:["nothing in ",N.map(D=>D.label.toLowerCase()).join(", ")]}):null:e.jsx("div",{className:"muted team_note",children:p.q?`Nothing matches “${p.q}” in the channels this seat can read.`:"No rated messages match this lens."})]})})():fs==="votes"?ia?e.jsx("div",{className:"muted team_note",children:ia}):aa===null?e.jsx("div",{className:"muted team_note",children:"Loading the channel's top-voted messages…"}):aa.length?aa.map((p,b)=>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:["#",b+1]}),e.jsx("button",{className:"team_replies_more",onClick:()=>Vc(p),title:"Switch back to recency and scroll to this message in its thread",children:"view in thread"})]}),Sr(p,{is_root:!0})]},p.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 p=[];let b="";for(const N of ms){const S=N.replies.length?N.replies[N.replies.length-1]:N.root,D=wj(S.created_at);D&&D!==b&&(b=D,p.push(e.jsx("div",{className:"team_day_divider",children:e.jsx("span",{children:D})},`day:${D}:${N.root.id}`))),p.push(Ds(N))}return p})(),!ms.length&&O&&!ie?e.jsx("div",{className:"muted team_note",children:Kn.length?e.jsxs(e.Fragment,{children:["Nothing matches the ",e.jsx("strong",{children:((Nr=Rh.find(p=>p.id===Ve))==null?void 0:Nr.label)||Ve})," filter in this channel — the messages exist under All."," ",e.jsx("button",{className:"team_replies_more",onClick:()=>ct("all"),children:"Show all"})]}):"No messages in the window."}):null]})}),e.jsxs("div",{className:"team_composer",onKeyDown:p=>{p.key==="Escape"&&lt&&co()},children:[lt?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 p;(p=document.getElementById(`hubmsg-${lt.id}`))==null||p.scrollIntoView({block:"center"})},children:["↩ #",lt.seq," (",lt.sender,") —"," ",(String(lt.title||"").trim()||String(lt.body||"").trim()).slice(0,80)||"(no text)"]}),(((yo=lt.data)==null?void 0:yo.asks)||[]).length?e.jsx("span",{className:"team_reply_asks",children:(((vo=lt.data)==null?void 0:vo.asks)||[]).map(p=>e.jsxs("label",{title:p.text,children:[e.jsx("input",{type:"checkbox",checked:!!js[p.id],onChange:b=>sr(N=>({...N,[p.id]:b.target.checked}))}),e.jsxs("span",{className:"team_reply_ask_text",children:["ask ",p.id,": ",p.text.length>70?p.text.slice(0,70)+"…":p.text]})]},p.id))}):null,e.jsx("button",{className:"team_row_expand",onClick:co,children:"cancel (Esc)"})]}):null,ks==="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 ",lt?"Reply":"Post"," again to send as-is."]}):null,ks==="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,xt?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:xt.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:["#",xt.name]}),e.jsxs("span",{className:"team_group_invites",children:["invites: ",xt.members.map(p=>`@${p}`).join(" ")]})]}):e.jsx("span",{className:"muted",children:xt.source==="kind"?"Add members below — write their names like @entity @assistant":"/group needs @mentions — e.g. /group fix the voice outage @gateway @core"})}):null,!lt&&!qt&&(ge==="ask"||ge==="group")?e.jsx("input",{className:"team_ask_title",value:Fe,onChange:p=>Xe(p.target.value),placeholder:ge==="group"?"Group topic — names the room (e.g. fix the voice outage)":"Title — receivers triage asks by headline",disabled:!Dn}):null,!lt&&!qt&&ge==="group"?e.jsx("input",{className:"team_ask_title team_group_members",value:gt,onChange:p=>jt(p.target.value),placeholder:"Members — write their names: @entity @assistant @gateway",disabled:!Dn,list:"team_roster_options"}):null,!lt&&!qt&&ge==="group"&&Es.length?e.jsx("datalist",{id:"team_roster_options",children:Es.map(p=>e.jsx("option",{value:`@${p}`},p))}):null,dt.length?e.jsx("div",{className:"team_attach_pending",children:dt.map(p=>e.jsxs("span",{className:"team_attach_chip",title:`${p.content_type} · ${Hn(p.size)} — click to preview`,children:[e.jsxs("button",{className:"team_attach_open",onClick:()=>void ci(O,p),"aria-label":`Preview ${p.filename}`,children:[e.jsx(Ue,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:p.filename}),e.jsx("span",{className:"muted",children:Hn(p.size)})]}),e.jsx("button",{className:"team_attach_x","aria-label":`Remove ${p.filename}`,title:"Remove this attachment",onClick:()=>ft(b=>b.filter(N=>N.id!==p.id)),children:e.jsx(Ue,{name:"x",size:10})})]},p.id))}):null,e.jsxs("div",{className:"team_compose_row",children:[!lt&&!qt?e.jsxs("select",{className:"team_compose_control team_kind_select",value:ge,onChange:p=>{const b=p.target.value,N=b==="ask"?"ask":b==="dm"?"dm":b==="group"?"group":"fyi";Te(N),N!=="ask"&&N!=="group"&&Xe(""),N!=="group"&&jt("")},disabled:!Dn,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,!lt&&!qt&&ge==="dm"?Es.length?e.jsxs("select",{className:"team_compose_control team_dm_peer",value:Ye,onChange:p=>vt(p.target.value),disabled:!Dn,title:"Recipient — every agent on the hub you share a channel with, connected or not",children:[e.jsx("option",{value:"",children:"to: member…"}),Es.map(p=>e.jsx("option",{value:p,children:p},p))]}):e.jsx("input",{className:"team_compose_control team_dm_peer",value:Ye,onChange:p=>vt(p.target.value),placeholder:"to: agent id",disabled:!Dn,title:"Recipient agent id (roster unavailable — type it; #FALLBACK)"}):null,e.jsx("textarea",{ref:en,className:"team_compose_text",rows:2,value:Z,onChange:p=>Pe(p.target.value),placeholder:Dn?lt?`Reply to #${lt.seq} in #${O}…`:qt?`Message ${ho}…`:ge==="dm"?`Direct message${Ye.trim()?` to ${Ye.trim()}`:""}…`:u?`Message #${O||"…"} as ${(T==null?void 0:T.seat)||"operator"} — or /assistant <question>`:`Message #${O||"…"} as ${(T==null?void 0:T.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:!Dn,onKeyDown:p=>{p.key!=="Enter"||p.shiftKey||p.nativeEvent.isComposing||p.keyCode===229||(p.preventDefault(),!Gs&&(Z.trim()||dt.length)&&pi())}}),e.jsx("input",{ref:pt,type:"file",multiple:!0,style:{display:"none"},onChange:p=>void lo(p.target.files)}),e.jsx("button",{className:"btn team_attach_btn",disabled:!Dn||Le||dt.length>=Wo,title:dt.length>=Wo?`Attachment limit (${Wo}) reached`:"Attach a file or image (delivered to every recipient)","aria-label":"Attach a file",onClick:()=>{var p;return(p=pt.current)==null?void 0:p.click()},children:e.jsx(Ue,{name:"paperclip",size:14})}),e.jsxs("button",{className:"btn primary team_send",disabled:!Dn||Gs||!Z.trim()&&!dt.length&&!(ge==="group"&&!lt&&!qt&&xd(gt).length>0),onClick:()=>void pi(),"aria-label":Gs?"Sending":void 0,children:[e.jsx("span",{className:"team_send_icon","aria-hidden":"true",children:e.jsx(Ue,{name:"send",size:16})}),e.jsx("span",{className:"team_send_label",children:Gs?"Sending…":xt!=null&&xt.members.length||!lt&&!qt&&ge==="group"?"Create room":lt?"Reply":qt||ge==="dm"?"Send DM":ge==="ask"?"Ask":"Send"})]})]})]})]}),Et==="assistant"?e.jsxs("div",{className:"pane team_drawer team_ai_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Assistant"}),e.jsxs("span",{className:"pane_count",children:["#",O]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Gn(""),title:"Close",children:"✕"})})]}),e.jsxs("div",{className:"pane_body team_ai_thread",children:[As.length?null:e.jsxs("div",{className:"muted team_note",children:["Ask anything about #",O," — strategies used, deviations, who owes what, how a decision was reached. The model reads the current channel window (",Be.length," messages) and cites seqs. It never posts to the room."]}),As.map((p,b)=>e.jsxs("div",{className:`team_ai_turn ${p.role}`,children:[e.jsx("div",{className:"team_ai_role mono",children:p.role==="user"?"you":"analyst"}),e.jsx(Qn,{className:"md_doc",text:Xo(p.content)})]},b)),As.length&&pl?e.jsxs("div",{className:"muted team_note",children:["Last answer read ",pl,"."]}):null,Xs?e.jsx("div",{className:"muted team_note",children:"thinking…"}):null,Ki?e.jsx("div",{className:"page_error mono",children:Ki}):null]}),e.jsx("div",{className:"team_composer",children:e.jsx(cl,{value:ti,onChange:hr,onSubmit:()=>{const p=ti;hr(""),mi(p)},placeholder:u?`Ask about #${O}…`:"AI advisor is not configured for this shell.",disabled:!u,busy:Xs,rows:2,sendLabel:"Ask",busyLabel:"Asking…"})})]}):null,Et==="members"?e.jsxs("div",{className:"pane team_drawer team_members_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Members"}),e.jsxs("span",{className:"pane_count",children:["#",O]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Gn(""),title:"Close",children:"✕"})})]}),e.jsx("div",{className:"pane_body team_members_body",children:kr()})]}):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:["#",O]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Gn(""),title:"Close",children:"✕"})})]}),e.jsxs("div",{className:"team_fs_crumbs",children:[e.jsxs("button",{className:`team_fs_crumb ${Ys===""?"active":""}`,onClick:()=>nn(""),title:"Channel root",children:["#",O||"…"]}),Ys?Ys.split("/").map((p,b,N)=>{const S=N.slice(0,b+1).join("/");return e.jsxs(Wt.Fragment,{children:[e.jsx("span",{className:"team_fs_crumb_sep",children:"/"}),e.jsx("button",{className:`team_fs_crumb ${b===N.length-1?"active":""}`,onClick:()=>nn(S),children:p})]},S)}):null]}),e.jsx("div",{className:"pane_body pane_body_list",children:Qs===null&&!ja?e.jsx("div",{className:"muted team_note",children:"Loading files…"}):ja?e.jsx("div",{className:"page_error mono",children:ja}):Qs&&Qs.length?(()=>{const{dirs:p,leaves:b}=Uw(Qs,Ys);return!p.length&&!b.length?e.jsx("div",{className:"muted team_note",children:"Empty folder."}):e.jsxs(e.Fragment,{children:[p.map(N=>e.jsxs("button",{className:"team_file_row team_fs_dir",onClick:()=>nn(N.path),title:`${N.count} file(s) inside`,children:[e.jsx("span",{className:"team_fs_icon",children:e.jsx(vj,{})}),e.jsx("span",{className:"team_file_path",children:N.name}),e.jsx("span",{className:"team_file_meta mono",children:N.count})]},N.path)),b.map(N=>e.jsxs("button",{className:"team_file_row",onClick:()=>void qc(N),title:`${N.updated_by||"?"} · ${Go(N.updated_at)} · v${N.version} · ${Hn(N.size)}`,children:[e.jsx("span",{className:"team_fs_icon",children:e.jsx(Kh,{})}),e.jsxs("span",{className:"team_file_name_wrap",children:[e.jsx("span",{className:"team_file_path",children:N.path.slice(Ys?Ys.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:[Hn(N.size)," · ",Vo(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:bn==="hub"?"hub-wide":`#${O}`}),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 ${bn==="channel"?"active":""}`,onClick:()=>{wa("channel"),oi("channel")},disabled:!O,title:`This channel's board (#${O||"…"})`,children:"Channel"}),e.jsx("button",{className:`team_lb_scope_btn ${bn==="hub"?"active":""}`,onClick:()=>{wa("hub"),oi("hub")},title:"Hub-wide: the sum of every channel's scores",children:"Hub"})]}),e.jsx("button",{className:"btn btn_icon",onClick:()=>Gn(""),title:"Close",children:"✕"})]})]}),e.jsx("div",{className:"pane_body pane_body_list team_lb_body",children:Pn===null&&!Xr?e.jsx("div",{className:"muted team_note",children:"Loading leaderboard…"}):Xr?e.jsx("div",{className:"muted team_note",children:Xr}):!Pn||Pn.leaderboard.length===0?e.jsx("div",{className:"muted team_note",children:Array.isArray(Pn==null?void 0:Pn.categories)?`No reputation yet${bn==="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${bn==="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 p=Array.isArray(Pn.categories)||Pn.leaderboard.some(D=>D.breakdown!=null||typeof D.score=="number"),b=p?(S=Pn.categories)!=null&&S.length?Pn.categories:["general",...zi.map(D=>D.id)]:[],N=p&&b.length!==5?{gridTemplateColumns:`20px 22px minmax(70px, 1.5fr) minmax(40px, 0.7fr) repeat(${b.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"}),p?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"}),b.map(D=>e.jsx("span",{className:"team_lb_legend_axis",title:Qh[D]||`${Ko(D)} — reputation category.`,children:Ko(D)},D))]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"team_lb_legend_total",title:"Sum of all axis scores",children:"Total"}),zi.map(D=>e.jsx("span",{className:"team_lb_legend_axis",title:D.help,children:D.label},D.id)),e.jsx("span",{className:"team_lb_legend_axis",title:"Message ratings, collapsed per rater (agora-0122): each rater contributes ONE net sign across the agent's messages — flips cancel, farming doesn't count. ▲ raters up · ▼ raters down.",children:"Msgs"})]})]}),Pn.leaderboard.map((D,le)=>e.jsxs(Wt.Fragment,{children:[e.jsxs("div",{className:`team_lb_row ${ls===D.target?"open":""}`,style:N,onClick:()=>no(D.target),role:"button",tabIndex:0,onKeyDown:G=>{(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),no(D.target))},title:bn==="hub"?`${D.target}: rated in ${D.channels||0} channel(s) by ${D.raters} rater(s)`:p?`${D.target}: ${D.raters} rater(s) — click for attributed OPINION votes (general/thumbs live on the messages themselves)`:`${D.target}: ${D.raters} rater(s) — click for the votes behind the score`,children:[e.jsx("span",{className:`team_lb_rank ${le<3?`top${le+1}`:""}`,"aria-hidden":"true",children:le<3?"●":le+1}),e.jsx("span",{className:"team_avatar",style:Ya(D.target),"aria-hidden":"true",children:D.target.slice(0,1).toUpperCase()}),e.jsx("span",{className:"team_lb_agent",children:D.target}),p?e.jsxs(e.Fragment,{children:[(()=>{const G=Number(D.score||0),ve=D.votes;return e.jsxs("span",{className:`team_lb_total ${G>0?"pos":G<0?"neg":""}`,title:(()=>{const ze=Object.entries(D.breakdown||{}).filter(([,qe])=>qe&&Number(qe.score||0)!==0).map(([qe,We])=>`${Ko(qe)} ${Number(We.score)>0?"+":""}${Number(We.score)}`).join(" · ");return`${D.target}: score ${G>0?"+":""}${G} = ${ze||"no standing voices"} (categories sum; every standing vote counts — operator ruling dm#161)${ve?` — total: ${ve.up} up, ${ve.down} down`:""}`})(),children:[G>0?`+${G}`:G,ve&&(ve.up||ve.down)?e.jsxs("span",{className:"team_lb_rawvotes mono",children:[" ",e.jsxs("span",{className:"rv_up",children:[ve.up,"↑"]}),e.jsxs("span",{className:ve.down>0?"rv_down_hot":"rv_down",children:[ve.down,"↓"]})]}):null]})})(),b.map(G=>{var We;const ve=(We=D.breakdown)==null?void 0:We[G],ze=Number((ve==null?void 0:ve.score)||0),qe=!!(ve&&(ve.up||ve.down||ve.raters));return e.jsx("span",{className:`team_lb_axis ${ze>0?"pos":ze<0?"neg":""}`,title:qe?`${Ko(G)}: ${ze>0?"+":""}${ze} (▲${ve.up} ▼${ve.down} voices · ${ve.raters} engaged colleague${ve.raters===1?"":"s"}) — ${Qh[G]||"reputation category"}`:`${Ko(G)}: no standing input`,children:qe?ze>0?`+${ze}`:ze:"·"},G)})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`team_lb_total ${(D.total||0)>0?"pos":(D.total||0)<0?"neg":""}`,children:(D.total||0)>0?`+${D.total}`:D.total||0}),zi.map(G=>{var qe;const ve=(qe=D.axes)==null?void 0:qe[G.id],ze=(ve==null?void 0:ve.score)||0;return e.jsx("span",{className:`team_lb_axis ${ze>0?"pos":ze<0?"neg":""}`,title:ve?`${G.label}: ${ve.up} up, ${ve.down} down`:`${G.label}: no votes`,children:ve?ze>0?`+${ze}`:ze:"·"},G.id)}),(()=>{const G=D.messages,ve=G?G.up-G.down:0;return e.jsx("span",{className:`team_lb_axis ${ve>0?"pos":ve<0?"neg":""}`,title:G&&(G.up||G.down)?`Message ratings: ${G.up} rater(s) net-up, ${G.down} net-down (per-rater collapse — flips cancel)`:"Message ratings: none standing",children:G&&(G.up||G.down)?`▲${G.up}${G.down?` ▼${G.down}`:""}`:"·"})})()]})]}),ls===D.target&&bn==="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 ${At} — one live ±1 per axis; casting again revises, never stacks`,children:["rate as ",At||"operator",":"]}),zi.map(G=>e.jsxs("span",{className:"team_lb_cast_axis",title:G.help,children:[e.jsx("span",{className:"team_lb_cast_axis_name",children:G.label}),e.jsx("button",{className:"btn btn_icon team_lb_vote up",disabled:!!fr||D.target===At,onClick:ve=>{ve.stopPropagation(),kl(D.target,G.id,1)},title:`+1 ${G.label} for ${D.target}`,children:e.jsx(Ue,{name:"thumbsUp",size:12})}),e.jsx("button",{className:"btn btn_icon team_lb_vote down",disabled:!!fr||D.target===At,onClick:ve=>{ve.stopPropagation(),kl(D.target,G.id,-1)},title:`-1 ${G.label} for ${D.target}`,children:e.jsx(Ue,{name:"thumbsDown",size:12})})]},G.id))]}),e.jsx("input",{className:"team_lb_note",placeholder:"why — one line, on the record (optional, applies to your next vote)",value:Zr,maxLength:280,onChange:G=>mr(G.target.value),onClick:G=>G.stopPropagation()}),zn?e.jsx("div",{className:"team_lb_error",children:zn}):null,Hi===null?e.jsx("div",{className:"muted team_note",children:"Loading votes…"}):Hi.length===0?e.jsx("div",{className:"muted team_note",children:p?"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."}):Hi.map(G=>e.jsxs("div",{className:"team_lb_vote_row",children:[e.jsx("span",{className:"team_avatar team_avatar_sm",style:Ya(G.rater),"aria-hidden":"true",children:G.rater.slice(0,1).toUpperCase()}),e.jsx("span",{className:"team_lb_vote_rater",children:G.rater}),e.jsx("span",{className:"team_lb_vote_axis",children:G.axis}),e.jsx(Ue,{name:G.value>0?"thumbsUpFilled":"thumbsDownFilled",size:12,className:`team_lb_vote_val ${G.value>0?"pos":"neg"}`,title:G.value>0?"+1":"-1"}),e.jsx("span",{className:"team_lb_vote_note",title:G.note,children:G.note||e.jsx("span",{className:"muted",children:"no note"})})]},`${G.rater}:${G.axis}`))]}):null,ls===D.target&&bn==="hub"?e.jsx("div",{className:"team_lb_detail",children:e.jsx("div",{className:"muted team_note",children:p?"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]},D.target)),e.jsx("div",{className:"muted team_lb_footnote",children:p?"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 ce(),title:"Reload",children:"Refresh"}),e.jsx("button",{className:"btn btn_icon",onClick:()=>Gn(""),title:"Close",children:"✕"})]})]}),e.jsxs("div",{className:"pane_body pane_body_list",children:[X==="loading"?e.jsx("div",{className:"muted team_note",children:"Loading…"}):null,X===null&&ee?e.jsx("div",{className:"muted team_note",children:ee}):null,X!==null&&X!=="loading"?e.jsxs(e.Fragment,{children:[X.rows.length?null:e.jsx("div",{className:"muted team_note",children:"Nothing waits on you. Clear desk."}),X.rows.map((p,b)=>{const N=Number(p.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(p.kind)==="ask"?"warn":""}`,children:String(p.kind||"ask")}),e.jsx("span",{className:"mono muted",children:String(p.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(p.what||"")}),p.one_action?e.jsxs("div",{className:"team_desk_row_needed muted",children:["→ ",String(p.one_action)]}):null,p.channel?e.jsx("button",{className:"team_row_expand",onClick:()=>{Ps.current={message_id:p.id?String(p.id):void 0,seq:Number(p.seq)||void 0},String(p.channel)===O?sa():we(String(p.channel)),Gn("")},title:"Open the message that waits on you",children:"open ↗"}):null]},String(p.id||p.key||b))}),X.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:"}),X.satisfied.map((p,b)=>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(p.who_waits||"")})]}),e.jsx("div",{className:"team_desk_row_what muted",children:String(p.what||"")})]},String(p.key||b)))]}):null]}):null]})]}):null,e.jsxs("div",{className:"team_drawer_rail",children:[u?e.jsx("button",{className:`team_drawer_tab ${Et==="assistant"?"active":""}`,onClick:()=>ta("assistant"),disabled:!O,"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:()=>ta("members"),disabled:!O,"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:()=>ta("files"),disabled:!O,"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:()=>ta("leaderboard"),disabled:!O,"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 p=X!==null&&X!=="loading"?X:null,b=p?p.rows.length:0,N=p?p.satisfied.length:0;return e.jsxs("button",{className:`team_drawer_tab ${Et==="desk"?"active":""}`,onClick:()=>ta("desk"),"aria-pressed":Et==="desk","aria-label":b?`Open the operator desk — ${b} 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",b?e.jsx("span",{className:"team_desk_tab_badge",children:b>99?"99+":b}):null,!b&&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(lj,{view:Sa,onClose:()=>Qt(null)})]})}const Yh=[{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"}],Ud="abstractcontinuum_settings_v1";function Sj(){try{const s=window.localStorage.getItem(Ud)||"{}",n=JSON.parse(s);if(n&&(n.auth_token||n.gateway_url)){delete n.auth_token,delete n.gateway_url;try{window.localStorage.setItem(Ud,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 Nj={app:"continuum",name:"AbstractContinuum"},Cj=["How do I create a backlog task?","What does the Team page show?","How do managed processes work?"];function $j(){var fe;const[s,n]=f.useState("board"),r=mg("(max-width: 1023.98px)"),[i,l]=f.useState(!1),u=f.useRef(null),m=f.useRef(null),d=f.useRef(!1);f.useEffect(()=>{r||l(!1)},[r]),f.useEffect(()=>{var ue,Ee;if(r){if(i){const se=window.setTimeout(()=>{var ie;const W=(ie=m.current)==null?void 0:ie.querySelector(".shell_nav_item.active, .shell_nav_item");W==null||W.focus()},0);return()=>window.clearTimeout(se)}d.current&&(document.activeElement===document.body||!document.activeElement||(ue=m.current)!=null&&ue.contains(document.activeElement))&&((Ee=u.current)==null||Ee.focus())}},[i,r]),f.useEffect(()=>{d.current=i},[i]);function h(ue){n(ue),l(!1)}const[x,v]=f.useState(null),[g,w]=f.useState(null),[L,E]=f.useState(()=>Sj()),[$,T]=f.useState(!1),[H,z]=f.useState(!1),[R,M]=f.useState(0),[A,V]=f.useState(!1),[Q,oe]=f.useState(!1),[be,Ne]=f.useState(!1),[je,Ce]=Ry("continuum"),[q,te]=f.useState(0),[Y,U]=f.useState(null),[X,I]=f.useState("");f.useEffect(()=>{if(!Y)return;const ue=setTimeout(()=>U(null),8e3);return()=>clearTimeout(ue)},[Y]);const[ee,ae]=f.useState(!1);f.useEffect(()=>{var Se;const ue=((Se=document.querySelector('script[type="module"][src*="assets/"]'))==null?void 0:Se.getAttribute("src"))||"";if(!ue)return;let Ee=!1;async function se(){try{const Je=await fetch("./",{cache:"no-store",signal:AbortSignal.timeout(8e3)});if(!Je.ok)return;const de=(await Je.text()).match(/<script[^>]+type="module"[^>]+src="([^"]+)"/),ye=(de==null?void 0:de[1])||"";!Ee&&ye&&ue&&ye!==ue&&ae(!0)}catch{}}const W=()=>void se();window.addEventListener("focus",W);const ie=setInterval(()=>void se(),300*1e3);return se(),()=>{Ee=!0,window.removeEventListener("focus",W),clearInterval(ie)}},[]);function k(ue){I(String(ue||"")),n("executions")}f.useEffect(()=>{const ue=Ee=>{var se;Array.from(((se=Ee.dataTransfer)==null?void 0:se.types)||[]).includes("Files")&&Ee.preventDefault()};return window.addEventListener("dragover",ue),window.addEventListener("drop",ue),()=>{window.removeEventListener("dragover",ue),window.removeEventListener("drop",ue)}},[]);const[C,re]=f.useState(!1);f.useEffect(()=>{s==="team"&&re(!0)},[s]);function he(ue){var ie;const Ee=ue.target,se=(ie=Ee==null?void 0:Ee.closest)==null?void 0:ie.call(Ee,"a[href]");if(!se||se.target==="_blank"||se.hasAttribute("download"))return;const W=se.getAttribute("href")||"";W.startsWith("/")&&(ue.preventDefault(),window.open(W,"_blank","noopener"))}f.useEffect(()=>{try{window.localStorage.setItem(Ud,JSON.stringify(L))}catch{}},[L]);const ce=f.useMemo(()=>new Ox({base_url:""}),[]),O=ty({appName:"AbstractContinuum",connectionPath:Fi,onStatusChange:()=>M(ue=>ue+1)}),we=O.status,$e=f.useMemo(()=>jy("abstractcontinuum",Px),[]),[Oe,Re]=f.useState(hh),it=f.useRef(0);function Be(){const ue=++it.current;Re(hh),qx(ce).then(Ee=>{ue===it.current&&Re(Ee)})}const ot=f.useRef(0);f.useEffect(()=>{let ue=!1,Ee;return(async()=>{try{await ce.list_processes(),ue||(ot.current=0,T(!0))}catch{if(ue)return;ot.current+=1,ot.current>=2?T(!1):Ee=window.setTimeout(()=>{ue||M(se=>se+1)},2e3)}})(),()=>{ue=!0,Ee!==void 0&&window.clearTimeout(Ee)}},[ce,s,R]);const Ve=f.useRef($);f.useEffect(()=>{Ve.current&&!$&&(we!=null&&we.has_session)&&O.refresh(),Ve.current=$},[$,we==null?void 0:we.has_session]);async function ct(ue,Ee){const se=[...Ee.history.map(ie=>({role:ie.role,content:ie.content})),{role:"user",content:ue}],W=await ce.backlog_advisor({messages:se,agent:L.backlog_advisor_agent||null});return String((W==null?void 0:W.reply)||"").trim()||"(the advisor returned an empty reply)"}const et=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:Yh.map(ue=>e.jsxs("button",{className:`shell_nav_item ${s===ue.id?"active":""}`,onClick:()=>h(ue.id),title:ue.label,"aria-current":s===ue.id?"page":void 0,children:[e.jsx("span",{className:"shell_nav_icon",children:e.jsx(Ue,{name:ue.icon,size:16})}),e.jsx("span",{className:"shell_nav_label",children:ue.label})]},ue.id))})]});return e.jsxs("div",{className:"shell",onClickCapture:he,children:[r?null:e.jsx("aside",{className:"shell_sidebar",children:et}),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(ue=>!ue),children:e.jsx(Ue,{name:"list",size:18})}):null,e.jsx("div",{className:"shell_header_title",children:((fe=Yh.find(ue=>ue.id===s))==null?void 0:fe.label)||""}),e.jsx("div",{className:"shell_header_actions",children:e.jsx(qy,{docs:{open:Q,onToggle:()=>{oe(ue=>!ue),V(!1)},label:"Docs assistant"},assistant:{open:A,onToggle:()=>{V(ue=>!ue),oe(!1)}},appearance:{onOpen:()=>Ne(!0)},about:{identity:$e,versions:Oe,onOpen:Be},extraActions:e.jsxs("button",{className:"btn primary shell_newtask_btn",onClick:()=>z(!0),disabled:!$,"aria-label":"+ New task",title:"New task",children:["+",e.jsx("span",{className:"shell_newtask_label",children:" New task"})]}),connection:{phase:O.phase,signingOut:O.signingOut,onConnect:O.openModal,onDisconnect:()=>void O.signOut()}})})]}),!$&&s!=="settings"?e.jsxs("div",{className:"shell_banner",children:[e.jsx("span",{children:"Gateway unreachable or not signed in."}),e.jsx("button",{className:"btn",onClick:O.openModal,children:"Connect"})]}):null,O.signOutError?e.jsx("div",{className:"shell_banner",children:e.jsxs("span",{children:["Sign-out failed: ",O.signOutError," — the session may still be live."]})}):null,Y?e.jsxs("div",{className:`shell_banner ${Y.tone==="warn"?"":"shell_banner_ok"}`,children:[e.jsx("span",{children:Y.text}),e.jsx("button",{className:"btn",onClick:()=>U(null),children:"Dismiss"})]}):null,ee?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:[s==="board"?e.jsx(Hb,{gateway:ce,gateway_connected:$,data_nonce:q,on_mutated:()=>te(ue=>ue+1),on_open_executions:k,default_execution_mode:L.default_execution_mode,query_preset:x,on_query_preset_consumed:()=>v(null),on_open_team:ue=>{w(ue),n("team")},on_new_task:()=>z(!0)}):null,s==="executions"?e.jsx(iw,{gateway:ce,gateway_connected:$,focus_request_id:X,on_focus_consumed:()=>I(""),on_open_settings:()=>n("settings")}):null,s==="backlog"?e.jsx(Lb,{gateway:ce,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,s==="agents"?e.jsx(ib,{gateway:ce,gateway_connected:$,backlog_advisor_agent:L.backlog_advisor_agent,on_open_assistant:()=>V(!0),on_open_team:()=>n("team"),on_open_executions:()=>k()}):null,C?e.jsx("div",{style:{display:s==="team"?"contents":"none"},children:e.jsx(s_,{fallback:ue=>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(ue.message||ue)}),e.jsx("button",{className:"btn",onClick:()=>window.location.reload(),children:"Reload"})]})}),children:e.jsx(kj,{gateway:ce,gateway_connected:$,advisor:$?async(ue,Ee)=>{const se=[...Ee.map(ie=>({role:ie.role,content:ie.content})),{role:"user",content:ue}],W=await ce.backlog_advisor({messages:se,agent:L.backlog_advisor_agent||null});return String((W==null?void 0:W.reply)||"").trim()||"(the model returned an empty reply)"}:void 0,advisor_agent:L.backlog_advisor_agent,on_open_board:ue=>{v(ue||null),n("board")},focus:g,on_focus_consumed:()=>w(null)})})}):null,s==="inbox"?e.jsx(dw,{gateway:ce,gateway_connected:$,enable_triage:!0}):null,s==="services"?e.jsx(cw,{gateway:ce,gateway_connected:$}):null,s==="settings"?e.jsx(kw,{gateway:ce,gateway_connected:$,settings:L,set_settings:E,connection:we}):null]})]}),e.jsx(iy,{...O.modalProps}),r?e.jsx($d,{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:[et,e.jsx("button",{type:"button",className:"btn shell_nav_close",onClick:()=>l(!1),children:"Close menu"})]})}):null,e.jsx($d,{open:A,onClose:()=>V(!1),label:"Assistant",title:"Continuum assistant",children:e.jsx(cx,{ask:ct,assistantName:"Continuum advisor",blockedNotice:$?void 0:"Connect to the gateway to use the assistant."})}),e.jsx(Mx,{open:Q,onClose:()=>oe(!1),source:Nj,fetchGateway:ce.fetch_gateway,connected:$,placeholder:"Ask about AbstractContinuum…",suggestions:Cj,className:"continuum-docs-assistant"}),e.jsx(lp,{open:be,onClose:()=>Ne(!1),value:je,onChange:Ce}),e.jsx(Mb,{open:H,gateway:ce,can_use_gateway:$,maint_provider:L.maintenance_ai_provider,maint_model:L.maintenance_ai_model,maint_reasoning:L.maintenance_ai_reasoning,on_close:()=>z(!1),on_created:async(ue,Ee,se)=>{te(ie=>ie+1);const W=String(ue||"");n(W==="recurrent"?"backlog":"board"),U(se?{text:`Task created (${Ee}), but attachments failed: ${se}`,tone:"warn"}:{text:`Task created: ${Ee} (${W||"?"})${W==="recurrent"?" — recurrent items live on the Backlog page":""}`,tone:"ok"})}})]})}hg();const __=document.getElementById("root");if(!__)throw new Error("root element missing");og.createRoot(__).render(e.jsx(Wt.StrictMode,{children:e.jsx($j,{})}));export{Ew as _,Z_ as g};
135
+ //# sourceMappingURL=index-vNbbkx-g.js.map