pi-outpost 0.48.0 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +178 -0
- package/README.md +3 -0
- package/dist/contract/validate-structured-exchange.mjs +1 -1
- package/dist/pi-outpost.mjs +323 -97
- package/dist/pi-outpost.sea.mjs +2 -2
- package/dist/sea-prep.blob +2 -2
- package/dist/web/assets/{CodeEditor-DPHOc6pa.js → CodeEditor-cHm1xd4h.js} +2 -2
- package/dist/web/assets/{PdfViewer-R_n_5p2t.js → PdfViewer-CPxkOup9.js} +2 -2
- package/dist/web/assets/{abnfDiagram-WEYOIA3C-Do3Wh5PM.js → abnfDiagram-WEYOIA3C-Cpo-uXiO.js} +1 -1
- package/dist/web/assets/{architecture-WOLXFQ4H-Cy7-nVAk.js → architecture-WOLXFQ4H-BfK3PMUD.js} +1 -1
- package/dist/web/assets/{architectureDiagram-ZHVYKT53-Dfi29Stz.js → architectureDiagram-ZHVYKT53-kLCS_I4L.js} +1 -1
- package/dist/web/assets/{blockDiagram-RJAE7QA3-D9q44PU7.js → blockDiagram-RJAE7QA3-C6NgrXL5.js} +1 -1
- package/dist/web/assets/{c4Diagram-XDPPPE54-BpX5HzyP.js → c4Diagram-XDPPPE54-CVhvkODv.js} +1 -1
- package/dist/web/assets/channel-BqI7QxS3.js +1 -0
- package/dist/web/assets/{chunk-2E7WHVMD-BjkWWfrU.js → chunk-2E7WHVMD-BDpTVO_j.js} +1 -1
- package/dist/web/assets/{chunk-4EMNKR2T-p2pC-y9g.js → chunk-4EMNKR2T-Bf2vFmri.js} +1 -1
- package/dist/web/assets/{chunk-55XCU76K-BQg01A5g.js → chunk-55XCU76K-BVBNDBPq.js} +1 -1
- package/dist/web/assets/{chunk-7S6XSTFO-DsNcUgZc.js → chunk-7S6XSTFO-BxCPUAo6.js} +1 -1
- package/dist/web/assets/{chunk-AQDTSKZB-CZhSEpUg.js → chunk-AQDTSKZB-D926zGIX.js} +1 -1
- package/dist/web/assets/{chunk-DSNLSHJZ-CGVK9ZX7.js → chunk-DSNLSHJZ-DSbxZuYn.js} +3 -3
- package/dist/web/assets/{chunk-HAGFOTED-BChLRcG5.js → chunk-HAGFOTED-iybsmSvO.js} +1 -1
- package/dist/web/assets/{chunk-HNE4Q36P-DpN2La95.js → chunk-HNE4Q36P-BNO-r5as.js} +1 -1
- package/dist/web/assets/{chunk-NQOKRVIF-BU74KhFW.js → chunk-NQOKRVIF-BCDYvnQx.js} +1 -1
- package/dist/web/assets/{chunk-UHW7PFBP-CfF905Ls.js → chunk-UHW7PFBP-CtcE35zX.js} +1 -1
- package/dist/web/assets/{chunk-VQ5W62QI-Bulfmauj.js → chunk-VQ5W62QI-C-Wt_ErM.js} +1 -1
- package/dist/web/assets/{chunk-WQQL4CDK-CZl0mvTb.js → chunk-WQQL4CDK-B1xBf0mr.js} +1 -1
- package/dist/web/assets/{chunk-YZO67HFG-B8PUAUPP.js → chunk-YZO67HFG-BpQ4S2PJ.js} +1 -1
- package/dist/web/assets/{chunk-ZAUX2LTX-BOjtENw6.js → chunk-ZAUX2LTX-qfoMdC_H.js} +1 -1
- package/dist/web/assets/{chunk-ZCHMQSOR-sLh4j-hI.js → chunk-ZCHMQSOR-BivxIrRY.js} +1 -1
- package/dist/web/assets/{classDiagram-v2-4MYWR3UA-DPyHJ5Em.js → classDiagram-v2-4MYWR3UA-BYI7xjrb.js} +1 -1
- package/dist/web/assets/{conversationExport-CNLXCj3W.js → conversationExport-DrllhTso.js} +1 -1
- package/dist/web/assets/{cynefin-EF2NZ3EQ-MVu4cF-N.js → cynefin-EF2NZ3EQ-DJ-9M8oE.js} +1 -1
- package/dist/web/assets/{cynefinDiagram-WF24UDRP-DnTnDgff.js → cynefinDiagram-WF24UDRP-DOusz2FY.js} +1 -1
- package/dist/web/assets/{dagre-NK4GIZVX-CKNroz1z.js → dagre-NK4GIZVX-BTnSMJe8.js} +1 -1
- package/dist/web/assets/{diagram-CBK3MWTC-CwCd6_qV.js → diagram-CBK3MWTC-zdMJsfpH.js} +1 -1
- package/dist/web/assets/{diagram-I5XIIV2D-DYwP4m_v.js → diagram-I5XIIV2D-da1n7Zii.js} +1 -1
- package/dist/web/assets/{diagram-ODIL2UCW-CcRW28Q5.js → diagram-ODIL2UCW-CwK9VzT1.js} +1 -1
- package/dist/web/assets/{diagram-PFBEJUXE-DKEkhYqZ.js → diagram-PFBEJUXE-CbB2B9C6.js} +1 -1
- package/dist/web/assets/{diagram-RJA3I4VV-RbkVVAnC.js → diagram-RJA3I4VV-pvwTIUIZ.js} +1 -1
- package/dist/web/assets/{diagram-TYUNFSNR-CNwJFuSN.js → diagram-TYUNFSNR-DN5WIszR.js} +1 -1
- package/dist/web/assets/{dist-DiPZ0ZMo.js → dist-BE0nUFGq.js} +1 -1
- package/dist/web/assets/{dist-llboNNco.js → dist-BZrl9rJm.js} +1 -1
- package/dist/web/assets/{dist-CaVTvrEa.js → dist-CN0OXMj7.js} +1 -1
- package/dist/web/assets/{dist-BmreN7yT.js → dist-CguKBRMl.js} +1 -1
- package/dist/web/assets/{dist-Q4cIWyaP.js → dist-D1rpikNt.js} +1 -1
- package/dist/web/assets/{dist-DsDmmws4.js → dist-DDNDv3kw.js} +1 -1
- package/dist/web/assets/{dist-_f8zPwom.js → dist-Dm70hkr9.js} +1 -1
- package/dist/web/assets/{docxExport-Q_d-8cuv.js → docxExport-CVaLmrkL.js} +1 -1
- package/dist/web/assets/{ebnfDiagram-V4P3TTPT-Cqc1BzDn.js → ebnfDiagram-V4P3TTPT-DAUJvdbV.js} +1 -1
- package/dist/web/assets/{elk-QONTBCTQ-BfYqQVYA.js → elk-QONTBCTQ-CaoOyhyH.js} +1 -1
- package/dist/web/assets/{erDiagram-KYQIGQAA-Ch3md2ZT.js → erDiagram-KYQIGQAA-C0XlOeGn.js} +1 -1
- package/dist/web/assets/{eventmodeling-K75KTNOO-CEM1gSUP.js → eventmodeling-K75KTNOO-TGirSaz4.js} +1 -1
- package/dist/web/assets/flowDiagram-IUGLLWBU-Du-oaWuf.js +1 -0
- package/dist/web/assets/{ganttDiagram-R7GPNTJY-CBbUX-pJ.js → ganttDiagram-R7GPNTJY-DzIgrB3G.js} +1 -1
- package/dist/web/assets/{gitGraph-VSP46ZUC-b0QNbfLp.js → gitGraph-VSP46ZUC-Np_TOwYo.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PDYL7XHY-Dk1jb79y.js → gitGraphDiagram-PDYL7XHY-cxnJfQXZ.js} +1 -1
- package/dist/web/assets/{index-wRbvcbFv.js → index-DDBTGDBH.js} +7 -7
- package/dist/web/assets/{info-OHQRW6UA-qJGxsAec.js → info-OHQRW6UA-Cl1NlrzG.js} +1 -1
- package/dist/web/assets/{infoDiagram-MVDRKAX5-DD_Ft8m-.js → infoDiagram-MVDRKAX5-CyG9u95G.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-HPEHV2GE-CNsuC8b_.js → ishikawaDiagram-HPEHV2GE-0Jq8CstS.js} +1 -1
- package/dist/web/assets/{journeyDiagram-BOSHW7O7-DX-15hRC.js → journeyDiagram-BOSHW7O7-DRFwk-H0.js} +1 -1
- package/dist/web/assets/{kanban-definition-FNSA4HC5-IMoGW2uv.js → kanban-definition-FNSA4HC5-Cng1IGP2.js} +1 -1
- package/dist/web/assets/{line-CPpOZki1.js → line-Bb33sMEA.js} +1 -1
- package/dist/web/assets/{loadReferencedImage-CrHSXbBn.js → loadReferencedImage-DYg3cCFA.js} +1 -1
- package/dist/web/assets/{mermaid-parser.core-CeNpEp-C.js → mermaid-parser.core-CoS52w6v.js} +3 -3
- package/dist/web/assets/{mermaid.core-qPal8rWd.js → mermaid.core-uGk3xSaR.js} +4 -4
- package/dist/web/assets/{mermaidToImage-C-2lUq1m.js → mermaidToImage-CYbmysUI.js} +3 -3
- package/dist/web/assets/{mindmap-definition-6OY57UG3-ubhNaw2x.js → mindmap-definition-6OY57UG3-BfEELSQn.js} +1 -1
- package/dist/web/assets/{packet-JDAUHWVQ-DmgVbeMe.js → packet-JDAUHWVQ-Coi-LVlq.js} +1 -1
- package/dist/web/assets/{pdf-DVwdKFKt.js → pdf-Cwh2Qe7m.js} +1 -1
- package/dist/web/assets/{pegDiagram-ECIUJNBX-IKzVzakQ.js → pegDiagram-ECIUJNBX-D6615-y0.js} +1 -1
- package/dist/web/assets/{pie-XZMESJXO-BgEJcvid.js → pie-XZMESJXO-BNp3qjWK.js} +1 -1
- package/dist/web/assets/{pieDiagram-GNMPY74T-0wI5CThS.js → pieDiagram-GNMPY74T-CRkYdxki.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-D57K4MC3-CdYfHb7Q.js → quadrantDiagram-D57K4MC3-DQwsvypm.js} +1 -1
- package/dist/web/assets/{radar-ABXABTNO-hXh4gamL.js → radar-ABXABTNO-CfCgDKza.js} +1 -1
- package/dist/web/assets/{railroad-I3PHUGI6-BxY7w076.js → railroad-I3PHUGI6-FWpgyRNm.js} +1 -1
- package/dist/web/assets/{railroad-abnf-LNEFI6M7-B1NIZWRc.js → railroad-abnf-LNEFI6M7-DUx27Xr5.js} +1 -1
- package/dist/web/assets/{railroad-ebnf-DWYD2UWJ-BlTWd9xt.js → railroad-ebnf-DWYD2UWJ-Dlxh0tP5.js} +1 -1
- package/dist/web/assets/{railroad-peg-JR7BVNR7-MyQHmnUO.js → railroad-peg-JR7BVNR7-uVnJK6c5.js} +1 -1
- package/dist/web/assets/{railroadDiagram-Y72NRBL7-CRdIHZ7Q.js → railroadDiagram-Y72NRBL7-sg4iRfrf.js} +1 -1
- package/dist/web/assets/{requirementDiagram-EQYSW5RA-C7CbmfrH.js → requirementDiagram-EQYSW5RA-ymDU4EqE.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-SY24JHO5-aZQx61oF.js → sankeyDiagram-SY24JHO5-DQUX95aJ.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-BLEHNHQU-4G3YuHra.js → sequenceDiagram-BLEHNHQU-LRKjlEql.js} +1 -1
- package/dist/web/assets/{stateDiagram-v2-A6IESKWZ-DuqGYoAj.js → stateDiagram-v2-A6IESKWZ-wZPGtaAr.js} +1 -1
- package/dist/web/assets/{swimlanes-B3ENRKFQ-BxjyFKJ8.js → swimlanes-B3ENRKFQ-BijM_hgH.js} +1 -1
- package/dist/web/assets/swimlanesDiagram-AYQRV4AK-CBqd2kf3.js +8 -0
- package/dist/web/assets/{timeline-definition-JXYKGLGB-D1DZx-LG.js → timeline-definition-JXYKGLGB-ribPmxwQ.js} +1 -1
- package/dist/web/assets/{treeView-D4JQ5SDB-BmFVbU3o.js → treeView-D4JQ5SDB-CJozwK5D.js} +1 -1
- package/dist/web/assets/{treemap-SAJKECNS-V5kO4oMl.js → treemap-SAJKECNS-CMROax7j.js} +1 -1
- package/dist/web/assets/{usecaseDiagram-WPOLBNNX-BHJif-t9.js → usecaseDiagram-WPOLBNNX-BVrf-4S5.js} +1 -1
- package/dist/web/assets/{vennDiagram-Q3Y3IDCW-BloyeTsy.js → vennDiagram-Q3Y3IDCW-CYb7JAxc.js} +1 -1
- package/dist/web/assets/{wardley-7MLQ67FV-BsNgJPtK.js → wardley-7MLQ67FV-CYZm7ntN.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-IVAIDKWA-CLF0adYG.js → wardleyDiagram-IVAIDKWA-DVy66MTp.js} +1 -1
- package/dist/web/assets/{xychartDiagram-4URNHDU4-ChIFxs-q.js → xychartDiagram-4URNHDU4-DffcI3nN.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +3 -2
- package/dist/web/assets/channel-BBmCg8Cl.js +0 -1
- package/dist/web/assets/flowDiagram-IUGLLWBU-DLxpqk21.js +0 -1
- package/dist/web/assets/swimlanesDiagram-AYQRV4AK-D-JbNw8x.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-ttIAb4XJ.js","assets/rolldown-runtime-COiEfhsA.js","assets/mermaid.core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-ttIAb4XJ.js","assets/rolldown-runtime-COiEfhsA.js","assets/mermaid.core-uGk3xSaR.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-BWF7jMDv.js","assets/chunk-DSNLSHJZ-DSbxZuYn.js","assets/chunk-7S6XSTFO-BxCPUAo6.js","assets/dist-CumnGVmJ.js","assets/chunk-YZO67HFG-BpQ4S2PJ.js","assets/chunk-AQDTSKZB-D926zGIX.js","assets/chunk-DUW6YSOI-Dgx8z5s3.js","assets/chunk-UHW7PFBP-CtcE35zX.js","assets/chunk-HAGFOTED-iybsmSvO.js","assets/chunk-J5ZVWO5B-oDCd-gWO.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-ZAUX2LTX-qfoMdC_H.js","assets/chunk-WQQL4CDK-B1xBf0mr.js","assets/line-Bb33sMEA.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/chunk-HNE4Q36P-BNO-r5as.js","assets/mermaidToImage-CYbmysUI.js","assets/CodeEditor-cHm1xd4h.js","assets/dist-7keixpik.js","assets/docxExport-CVaLmrkL.js","assets/loadReferencedImage-DYg3cCFA.js","assets/conversationExport-DrllhTso.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{i as e,n as t,t as n}from"./rolldown-runtime-COiEfhsA.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var r=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},ee=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function te(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ne(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var re=/\/+/g;function ie(e,t){return typeof e==`object`&&e&&e.key!=null?ne(``+e.key):t.toString(36)}function O(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ae(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ae(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ie(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(re,`$&/`)+`/`),ae(o,r,i,``,function(e){return e})):o!=null&&(te(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(re,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ie(a,u),c+=ae(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+ie(a,u++),c+=ae(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ae(O(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function k(e,t,n){if(e==null)return e;var r=[],i=0;return ae(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function oe(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var se=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function ce(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,se)}catch(e){se(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function le(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else ce(le.bind(null,e))}var A={map:k,forEach:function(e,t,n){k(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return k(e,function(){t++}),t},toArray:function(e){return k(e,function(e){return e})||[]},only:function(e){if(!te(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=A,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=le,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!ee.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)ee.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=te,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:oe}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=ce,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),i=n(((e,t)=>{t.exports=r()})),a=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,D());else{var t=n(l);t!==null&&re(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function ee(){return g?!0:!(e.unstable_now()-T<w)}function E(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ee());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&re(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?D():S=!1}}}var D;if(typeof y==`function`)D=function(){y(E)};else if(typeof MessageChannel<`u`){var te=new MessageChannel,ne=te.port2;te.port1.onmessage=E,D=function(){ne.postMessage(null)}}else D=function(){_(E,0)};function re(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,re(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,D()))),r},e.unstable_shouldYield=ee,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),o=n(((e,t)=>{t.exports=a()})),s=n((e=>{var t=i();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var a={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},o=Symbol.for(`react.portal`),s=Symbol.for(`react.recoverable`),c=Symbol.for(`react.optimistic_key`);function l(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:r===c?c:``+r,children:e,containerInfo:t,implementation:n}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.browser=function(e){return{$$typeof:s,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return l(e,t,null,r)},e.flushSync=function(e){var t=u.T,n=a.p;try{if(u.T=null,a.p=2,e)return e()}finally{u.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=d(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??a.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=d(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else a.d.m(e)}},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return u.H.useFormState(e,t,n)},e.useFormStatus=function(){return u.H.useHostTransitionStatus()},e.version=`19.3.1`})),c=n(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=s()})),l=n((e=>{var t=o(),n=i(),r=c();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function u(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(l(e)!==e)throw Error(a(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return f(i),e;if(o===r)return f(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var s=!1,c=i.child;c;){if(c===n){s=!0,n=i,r=o;break}if(c===r){s=!0,r=i,n=o;break}c=c.sibling}if(!s){for(c=o.child;c;){if(c===n){s=!0,n=o,r=i;break}if(c===r){s=!0,r=o,n=i;break}c=c.sibling}if(!s)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}function h(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&h(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=g(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(a(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function ee(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var E=Object.assign,D=Symbol.for(`react.element`),te=Symbol.for(`react.transitional.element`),ne=Symbol.for(`react.portal`),re=Symbol.for(`react.fragment`),ie=Symbol.for(`react.strict_mode`),O=Symbol.for(`react.profiler`),ae=Symbol.for(`react.consumer`),k=Symbol.for(`react.context`),oe=Symbol.for(`react.forward_ref`),se=Symbol.for(`react.suspense`),ce=Symbol.for(`react.suspense_list`),le=Symbol.for(`react.memo`),A=Symbol.for(`react.lazy`),ue=Symbol.for(`react.activity`),de=Symbol.for(`react.legacy_hidden`),fe=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.for(`react.view_transition`),pe=Symbol.for(`react.recoverable`),me=Symbol.iterator;function he(e){return typeof e!=`object`||!e?null:(e=me&&e[me]||e[`@@iterator`],typeof e==`function`?e:null)}var ge=Symbol.for(`react.client.reference`);function _e(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ge?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case re:return`Fragment`;case O:return`Profiler`;case ie:return`StrictMode`;case se:return`Suspense`;case ce:return`SuspenseList`;case ue:return`Activity`;case j:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case ne:return`Portal`;case k:return e.displayName||`Context`;case ae:return(e._context.displayName||`Context`)+`.Consumer`;case oe:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case le:return t=e.displayName||null,t===null?_e(e.type)||`Memo`:t;case A:t=e._payload,e=e._init;try{return _e(e(t))}catch{}}return null}var ve=Array.isArray,ye=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,be=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,xe={pending:!1,data:null,method:null,action:null},Se=[],Ce=-1;function we(e){return{current:e}}function Te(e){0>Ce||(e.current=Se[Ce],Se[Ce]=null,Ce--)}function Ee(e,t){Ce++,Se[Ce]=e.current,e.current=t}var De=we(null),Oe=we(null),ke=we(null),Ae=we(null);function je(e,t){switch(Ee(ke,t),Ee(Oe,e),Ee(De,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?jp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=jp(t),e=Mp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Te(De),Ee(De,e)}function Me(){Te(De),Te(Oe),Te(ke)}function Ne(e){var t=e.memoizedState;t!==null&&(Oh._currentValue=t.memoizedState,Ee(Ae,e)),t=De.current;var n=Mp(t,e.type);t!==n&&(Ee(Oe,e),Ee(De,n))}function Pe(e){Oe.current===e&&(Te(De),Te(Oe)),Ae.current===e&&(Te(Ae),Oh._currentValue=xe)}var Fe,Ie;function Le(e){if(Fe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Fe=t&&t[1]||``,Ie=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+Fe+e+Ie}var Re=!1;function ze(e,t){if(!e||Re)return``;Re=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -17,7 +17,7 @@ Error generating stack: `+e.message+`
|
|
|
17
17
|
`),n=Me(t);if(n===-1)return;let r=t[n],i=/^(\s*)(flowchart|graph)([ \t]+(TD|TB|BT|LR|RL)\b)?(.*)$/i.exec(r);if(i!==null){let[,e,r,,a,o]=i,s=a===void 0?`TB`:je(a),c=Ae(s),l=[...t];return l[n]=`${e}${r} ${c}${o}`,{direction:s,turned:l.join(`
|
|
18
18
|
`)}}let a=/^(\s*)stateDiagram(-v2)?\s*$/i.exec(r);if(a!==null)return Pe(t,n,a[1])}function Pe(e,t,n){let r=0;for(let n=t+1;n<e.length;n+=1){let t=e[n],i=r===0?/^\s*direction\s+(TD|TB|BT|LR|RL)\s*$/i.exec(t):null;if(i!==null){let r=je(i[1]),a=[...e];return a[n]=t.replace(/(direction\s+)(TD|TB|BT|LR|RL)/i,`$1${Ae(r)}`),{direction:r,turned:a.join(`
|
|
19
19
|
`)}}r+=(t.match(/\{/g)?.length??0)-(t.match(/\}/g)?.length??0),r<0&&(r=0)}let i=[...e];return i.splice(t+1,0,`${n} direction LR`),{direction:`TB`,turned:i.join(`
|
|
20
|
-
`)}}var Fe=Promise.resolve();function Ie(e){let t=Fe.then(e,e);return Fe=t.then(()=>void 0,()=>void 0),t}var Le=`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,Re=`flex flex-wrap items-center gap-3 text-xs`,ze=null;async function Be(e){let t=await(ze??=he(()=>import(`./mermaid.core-
|
|
20
|
+
`)}}var Fe=Promise.resolve();function Ie(e){let t=Fe.then(e,e);return Fe=t.then(()=>void 0,()=>void 0),t}var Le=`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,Re=`flex flex-wrap items-center gap-3 text-xs`,ze=null;async function Be(e){let t=await(ze??=he(()=>import(`./mermaid.core-uGk3xSaR.js`).then(e=>e.t),__vite__mapDeps([2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])));return t.default.initialize({startOnLoad:!1,theme:e,look:`classic`,securityLevel:`strict`,suppressErrorRendering:!0}),t}function Ve(e){let t=/viewBox="\s*[\d.-]+[\s,]+[\d.-]+[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(e),n=t?Number(t[1]):NaN;return Number.isFinite(n)&&n>0?n:void 0}function He(e,t){if(typeof e!=`object`||!e||!(`props`in e))return null;let n=e.props;if(t!==void 0&&!RegExp(`\\blanguage-${t}\\b`).test(n.className??``))return null;let r=n.children;return typeof r==`string`?r:Array.isArray(r)&&r.every(e=>typeof e==`string`)?r.join(``):null}function Ue(e){let t=He(e,`mermaid`);return t===null?null:t.trim()}function We(e){let{children:t,...n}=e,r=Ue(t);if(r!==null)return(0,A.jsx)(Ge,{code:r});let i=He(t);return i===null?(0,A.jsx)(`pre`,{...n,children:t}):(0,A.jsxs)(`div`,{className:`code-block relative`,"data-testid":`code-block`,children:[(0,A.jsx)(`pre`,{...n,children:t}),(0,A.jsx)(ue,{iconOnly:!0,text:i.replace(/\n$/,``),className:`absolute right-1.5 top-1.5 rounded border border-zinc-300 bg-white/80 px-1.5 py-0.5 text-xs text-zinc-500 hover:text-zinc-800 dark:border-zinc-700 dark:bg-zinc-900/80 dark:text-zinc-400 dark:hover:text-zinc-100`})]})}function Ge({code:e}){let t=(0,d.useId)().replace(/[^a-zA-Z0-9]/g,``),n=m()===`light`?`default`:`dark`,[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(!1),[h,g]=(0,d.useState)(null),_=(0,d.useRef)(!1),v=(0,d.useRef)(0),y=(0,d.useRef)(0),b=()=>`mermaid-${t}-${++y.current}`,x=(0,d.useMemo)(()=>Ne(e),[e]),S=x===void 0?`landscape`:ke(x.direction),[C,w]=(0,d.useState)(void 0),T=r?.svg??null,ee=r!==null&&r.orientation!==S,E=(0,d.useRef)(null),D=(0,d.useRef)(e);D.current=e,(0,d.useEffect)(()=>(v.current+=1,i(null),w(void 0),u(!1),o(null),g(null),()=>{v.current+=1}),[e]);async function te(){if(!r||_.current)return;_.current=!0,p(!0),g(null);let e=v.current;try{let{renderDiagram:n}=await he(async()=>{let{renderDiagram:e}=await import(`./mermaidToImage-CYbmysUI.js`).then(e=>e.r);return{renderDiagram:e}},__vite__mapDeps([21,1])),i=await n(r.source,`mermaid-download-${t}`);if(e!==v.current)return;let a=URL.createObjectURL(new Blob([i.svg],{type:`image/svg+xml;charset=utf-8`}));try{let e=document.createElement(`a`);e.href=a,e.download=`diagram.svg`,e.click()}finally{URL.revokeObjectURL(a)}}catch(t){e===v.current&&g(t instanceof Error?t.message:String(t))}finally{_.current=!1,p(!1)}}return(0,d.useEffect)(()=>{let e=!1,t=setTimeout(()=>void Ie(async()=>{try{let t=(await Be(n)).default,r=D.current,a=Ne(r),s=a===void 0?`landscape`:ke(a.direction);if(C!==void 0&&a!==void 0){let n=C===s?r:a.turned,{svg:c}=await t.render(b(),n);e||(i({svg:c,orientation:C,source:n}),o(null));return}let c=await t.render(b(),r),l={svg:c.svg,orientation:s,source:r},u=Ve(c.svg);if(a!==void 0&&u!==void 0&&u>710){let e=await t.render(b(),a.turned),n=Ve(e.svg);if(n!==void 0){let t=s===`landscape`?De(u,n):De(n,u);t!==s&&(l={svg:e.svg,orientation:t,source:a.turned})}}e||(i(l),o(null))}catch(t){e||(i(null),o(t instanceof Error?t.message:String(t)))}}),300);return()=>{e=!0,clearTimeout(t)}},[e,t,n,C]),T?(0,A.jsxs)(`div`,{ref:E,className:`my-2 flex flex-col gap-2 rounded-lg border border-zinc-200 bg-zinc-50 p-3 dark:border-zinc-800 dark:bg-zinc-900`,children:[(0,A.jsxs)(`div`,{className:`${Re} order-3`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>c(!s),title:s?`Show diagram`:`Show code`,className:Le,children:s?`⚏ diagram`:`⌗ code`}),!s&&x!==void 0&&r!==null&&(0,A.jsx)(`button`,{type:`button`,"data-testid":`mermaid-orientation`,onClick:()=>w(e=>Ee(e??r.orientation)),title:r.orientation===`portrait`?`Turn it across the page — it is drawn down`:`Turn it down the page — it is drawn across`,"aria-label":`Turn the diagram ${Ee(r.orientation)}`,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,children:r.orientation===`portrait`?`↔ landscape`:`↕ portrait`}),!s&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>u(!0),"aria-label":`Show diagram at full size`,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,children:`⤢ enlarge`}),(0,A.jsx)(`button`,{type:`button`,className:Le,disabled:f,onClick:()=>void te(),title:`Save as .svg — insert it as a picture in a document`,children:f?`preparing SVG…`:`⤓ download SVG`}),(0,A.jsx)(ue,{text:e,className:Le}),h&&(0,A.jsxs)(`span`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:[`Could not download SVG: `,h]})]}),s?(0,A.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,A.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:T}}),ee&&!s&&(0,A.jsxs)(`div`,{className:`mt-1 text-center text-xs text-zinc-400 dark:text-zinc-600`,"data-testid":`mermaid-turned`,children:[`drawn `,r?.orientation,` to fit — the source asks for `,S]}),(0,A.jsx)(we,{label:`diagram`,testId:`mermaid-enlarged`,open:l,onClose:()=>u(!1),anchorRef:E,actions:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`button`,{type:`button`,className:Le,disabled:f,onClick:()=>void te(),children:f?`preparing SVG…`:`⤓ download SVG`}),h&&(0,A.jsxs)(`span`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:[`Could not download SVG: `,h]})]}),children:(0,A.jsx)(`div`,{style:{width:Ve(T)},className:`[&_svg]:!h-auto [&_svg]:!max-w-none [&_svg]:!w-full`,dangerouslySetInnerHTML:{__html:T}})})]}):(0,A.jsxs)(`pre`,{className:`my-2 overflow-x-auto rounded-lg border border-zinc-200 bg-zinc-50 p-3 font-mono text-xs text-zinc-500 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:[e,a&&(0,A.jsx)(`div`,{className:`mt-2 text-red-600 dark:text-red-400`,children:a})]})}function Ke({html:e,className:t=``,as:n=`div`}){return(0,A.jsx)(n,{className:`rendered-ansi overflow-x-auto font-mono text-xs leading-relaxed [&_span]:whitespace-pre-wrap ${t}`,dangerouslySetInnerHTML:{__html:e}})}function qe({lines:e,fill:t=!1}){return(0,A.jsx)(`div`,{className:`overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800 ${t?`max-h-full`:`max-h-72`}`,children:w(C(e)).map((e,t)=>e===null?(0,A.jsx)(`div`,{className:`bg-zinc-100 px-2 text-center text-zinc-400 dark:bg-zinc-800/60 dark:text-zinc-600`,children:`⋯`},t):(0,A.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,A.jsx)(`div`,{className:`whitespace-pre-wrap break-words border-r border-zinc-200 px-2 dark:border-zinc-800 ${e.changed?e.left===null?`bg-zinc-50 dark:bg-zinc-900/40`:`bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`text-zinc-500 dark:text-zinc-500`}`,children:e.left??` `}),(0,A.jsx)(`div`,{className:`whitespace-pre-wrap break-words px-2 ${e.changed?e.right===null?`bg-zinc-50 dark:bg-zinc-900/40`:`bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:`text-zinc-500 dark:text-zinc-500`}`,children:e.right??` `})]},t))})}function Je({lines:e}){return(0,A.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800`,children:T(e).map((e,t)=>e===null?(0,A.jsx)(`div`,{className:`bg-zinc-100 px-2 text-center text-zinc-400 dark:bg-zinc-800/60 dark:text-zinc-600`,children:`⋯`},t):(0,A.jsxs)(`div`,{className:e.type===`add`?`bg-emerald-50 px-2 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:e.type===`del`?`bg-red-50 px-2 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`px-2 text-zinc-500 dark:text-zinc-500`,children:[e.type===`add`?`+ `:e.type===`del`?`− `:` `,e.text]},t))})}function Ye({item:e,canEdit:t,onEdit:n}){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(null),o=t&&e.entryId!==void 0,s=r!==null;(0,d.useEffect)(()=>{s&&a.current?.focus()},[s]),(0,d.useEffect)(()=>{i(null)},[e.entryId,e.text]);function c(){let a=r?.trim();t&&e.entryId&&a&&(a===e.text||n(e.entryId,a,e.images),i(null))}return(0,A.jsxs)(`div`,{className:`group ml-auto flex max-w-[85%] items-start gap-1.5`,children:[o&&!s&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>i(e.text),title:`edit this prompt and ask again (branches the conversation)`,"aria-label":`Edit this prompt`,className:`mt-1.5 shrink-0 rounded px-1 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✎`}),(0,A.jsxs)(`div`,{className:`min-w-0 flex-1 rounded-xl bg-blue-100 px-4 py-2 text-[15px] text-blue-950 dark:bg-blue-950/60 dark:text-zinc-100`,children:[e.images&&e.images.length>0&&(0,A.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:e.images.map((e,t)=>(0,A.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-48 max-w-full rounded-lg object-contain`},t))}),s?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`textarea`,{ref:a,value:r,"aria-label":`Edit prompt`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),c()),e.key===`Escape`&&i(null)},rows:Math.min(10,Math.max(2,r.split(`
|
|
21
21
|
`).length)),className:`w-full resize-none rounded-md bg-white/70 px-2 py-1 text-[15px] outline-none ring-1 ring-blue-300 dark:bg-zinc-900/60 dark:ring-blue-900`}),(0,A.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2 text-xs`,children:[(0,A.jsx)(`span`,{className:`mr-auto text-blue-900/70 dark:text-zinc-400`,children:t?`asks again from here — the current answer moves to its own branch`:`waiting: the agent is running (or the connection dropped)`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>i(null),className:`rounded border border-blue-300 px-2 py-0.5 hover:bg-white/60 dark:border-zinc-700 dark:hover:bg-zinc-800`,children:`cancel`}),(0,A.jsx)(`button`,{type:`button`,onClick:c,disabled:!t||!r.trim()||r.trim()===e.text,className:`rounded border border-blue-400 bg-white/70 px-2 py-0.5 font-medium disabled:opacity-50 dark:border-blue-800 dark:bg-zinc-900/60`,children:`send`})]})]}):(0,A.jsx)(`div`,{className:`whitespace-pre-wrap`,children:e.text})]})]})}var Xe=`urn:structured-exchange:1`,Ze=[`graph`,`sequence`];function Qe(e){return $e(e)?[`graph`,`sequence`,`table`]:Ze}function $e(e){return e===`urn:structured-exchange:2`||e===`urn:structured-exchange:3`}function et(e){if(Array.isArray(e))return{cells:e};let t=e.heading;return typeof t==`string`?{cells:[],role:e.role,heading:t}:{cells:e.cells,role:e.role}}var tt={nodes:500,edges:2e3,participants:100,messages:1e3,columns:50,rows:5e3,removals:500,ref:200,localId:200,label:500,kind:100,kindsPerVocabulary:64,columnName:200,cell:1e3},nt=`urn:structured-exchange:2`,rt={profile:200,attributesPerItem:50,removeAttributesPerItem:50,attributeName:200,attributeString:1e3,attributeListItems:50,revision:200,locationsPerItem:10,uri:2e3,position:1e6,artifactsPerItem:20,artifactsPerDocument:50,artifactRel:100,artifactMediaType:100,artifactLabel:500,artifactDigest:71,relations:2e3,heading:500,headingDepth:6,viewpoints:20,viewpointConcern:500},it=8e6,at=`urn:structured-exchange:3`,ot=[Xe,nt,at];function st(e){return ot.find(t=>t===e)}var ct=4e6,lt=Math.max(ct,it);function ut(e){return $e(e)?it:ct}var dt=e=>new TextEncoder().encode(e).length;function ft(e){return e===`bytes`?lt:e===`relations`?rt.relations:tt[e]}function pt(e,t){let n=ft(e),r=t?.[e];return r===void 0||r>=n?{limit:n,level:`ceiling`}:{limit:r,level:`deployment`}}function mt(e,t,n){let r=dt(e),i=pt(`bytes`,t),a=n===void 0?1/0:ut(n),o=Math.min(i.limit,a),s=o===a&&a<i.limit?`ceiling`:i.level;if(!(r<=o))return{rule:`document-too-large`,path:``,message:`document is ${r} bytes, past the ${o}-byte ${s===`ceiling`?`contract ceiling`:`limit this deployment applies`}`,limit:o,observed:r,level:s}}var ht={graph:[`nodes`,`edges`],sequence:[`participants`,`messages`],table:[`columns`,`rows`,`relations`]};function gt(e,t){if(t===void 0)return[];let n=[];for(let r of ht[e.kind]??[]){let i=e.data[r];if(!Array.isArray(i))continue;let{limit:a,level:o}=pt(r,t);o===`deployment`&&i.length>a&&n.push({rule:`collection-past-deployment-limit`,path:`/data/${r}`,message:`${r} has ${i.length} entries, past the ${a} this deployment allows`,limit:a,observed:i.length,level:o})}return n}function _t(e,t){let n={};for(let t of ht[e.kind]??[]){let r=e.data[t];Array.isArray(r)&&(n[t]=r.length)}return{kind:e.kind,bytes:dt(t),counts:n}}var vt=6.6,yt=5.4;function bt(e,t,n){let r=e.flatMap(e=>e.split(/\r?\n/)).reduce((e,t)=>Math.max(e,t.length),0);return Math.min(Math.max(r*vt+22,t),n)}function xt(e,t,n,r){let i=t.map(e=>Tt(e).length).reduce((e,t)=>Math.max(e,t),0);return Math.max(bt(e,n,r),Math.min(i*yt+22,r))}function St(e,t,n=vt){let r=Math.max(Math.floor((t-22)/n+1e-6),4),i=[],a=e.split(/\r?\n/);if(a.length>1)return a.flatMap(e=>St(e,t,n)).slice(0,3);let o=``;for(let t of e.split(/\s+/)){let e=o===``?t:`${o} ${t}`;if(e.length<=r)o=e;else for(o!==``&&i.push(o),o=t;o.length>r&&i.length<3;)i.push(o.slice(0,r)),o=o.slice(r)}if(o!==``&&i.push(o),i.length===0)return[``];if(i.length<=3)return i;let s=i.slice(0,3);return s[2]=`${s[2].slice(0,Math.max(r-1,1))}…`,s}function Ct(e,t){return e*15+t*15+14}function wt(e,t){return e.flatMap(e=>St(Tt(e),t,yt))}function Tt(e){return`${e.field}: ${e.from===void 0?``:`${e.from} → `}${e.to}`}function Et(e,t){return`${e}: ${Dt(t)}`}function Dt(e){return Array.isArray(e)?e.map(e=>Dt(e)).join(`, `):e===null?`null`:typeof e==`object`&&e&&typeof e.ref==`string`?`<${e.ref}>`:String(e)}function Ot(e){let t=e.range===void 0?``:` lines ${e.range.startLine}–${e.range.endLine}`,n=e.revision===void 0?``:` at ${e.revision}`;return`${e.uri}${t}${n}`}function kt(e){let t=e.label===void 0?e.uri:`${e.label} (${e.uri})`,n=e.mediaType===void 0?``:`, ${e.mediaType}`;return`${e.rel}: ${t}${n} — ${e.sha256.slice(0,14)}…`}var At=864e5,jt=/^(\d{4})-(\d{2})-(\d{2})$/;function Mt(e){let t=jt.exec(e);if(t===null)return;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])],a=new Date(Date.UTC(n,r-1,i));if(a.setUTCFullYear(n,r-1,i),a.getUTCFullYear()===n&&a.getUTCMonth()===r-1&&a.getUTCDate()===i)return Math.round(a.getTime()/At)}function Nt(e){let t=new Date(e*At);return`${String(t.getUTCFullYear()).padStart(4,`0`)}-${String(t.getUTCMonth()+1).padStart(2,`0`)}-${String(t.getUTCDate()).padStart(2,`0`)}`}function Pt(e=new Date){return Math.round(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())/At)}function Ft(e){let t=Mt(e.type===`activity`?e.start:e.date),n=Mt(e.type===`activity`?e.end:e.date);return t===void 0||n===void 0?void 0:{start:t,end:n}}function It(e){let t=new Map;return e.rows.forEach((e,n)=>{e.type===`task`&&(t.has(e.id)||t.set(e.id,{id:e.id,type:`task`,row:n,days:Lt(e)}),e.items.forEach((e,r)=>{e.id===void 0||t.has(e.id)||t.set(e.id,{id:e.id,type:e.type,row:n,item:r,days:Ft(e)})}))}),t}function Lt(e){let t;for(let n of e.items){let e=Ft(n);e!==void 0&&(t=t===void 0?{...e}:{start:Math.min(t.start,e.start),end:Math.max(t.end,e.end)})}return t}function Rt(e){return e.type??`finish-to-start`}function zt(e){return{from:e.startsWith(`finish`)?`end`:`start`,to:e.endsWith(`finish`)?`end`:`start`}}function Bt(e,t){let n=t.get(e.from)?.days,r=t.get(e.to)?.days;if(n===void 0||r===void 0)return;let i=zt(Rt(e));return r[i.to]>=n[i.from]}function Vt(e){if(`date`in e){let t=Mt(e.date)??0;return{start:t,end:t}}return{start:Mt(e.start)??0,end:Mt(e.end)??0}}function Ht(e){if(e.previous===void 0)return;let t=Vt(e.type===`activity`?{start:e.start,end:e.end}:{date:e.date}),n=Vt(e.previous);return{start:t.start-n.start,end:t.end-n.end}}function Ut(e){if(e===0)return``;let t=e>0?`+`:`−`,n=Math.abs(e);return n<14?`${t}${n}d`:n<70?`${t}${Math.round(n/7)}w`:`${t}${Math.round(n/30.44)}mo`}function Wt(e){let t=Ht(e);return t===void 0?``:t.start===t.end?Ut(t.start):t.start===0?`end${Ut(t.end)}`:t.end===0?`start${Ut(t.start)}`:`${Ut(t.start)}, end${Ut(t.end)}`}function Gt(e,t){if(e.role!==void 0||t?.role!==void 0)return!0;let n=Ht(e);return n!==void 0&&(n.start!==0||n.end!==0)}function Kt(e){return e.role!==void 0||e.items.some(t=>Gt(t,e))}var qt={week:12,month:4,quarter:.75};function Jt(e,t){let n=e>=8?`week`:e>=1?`month`:`quarter`;if(t===void 0)return n;let r=[`week`,`month`,`quarter`];return r[Math.max(r.indexOf(n),r.indexOf(t))]}var Yt=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function Xt(e){return e.width>=24?e.label:e.width>=9?e.label.charAt(0):``}function Zt(e,t){return t===`month`?Xt(e):e.width>=e.label.length*6+4?e.label:``}function Qt(e){return((e+3)%7+7)%7}function $t(e){let t=e-Qt(e)+3,n=new Date(t*At).getUTCFullYear();return Math.floor((t-rn(n,0))/7)+1}function en(e){if(e.label!==void 0&&e.label!==``)return e.label;if(e.type===`milestone`&&e.kind!==void 0&&e.kind!==``)return e.kind}function tn(e){return e.length*vt}function nn(e,t){let n=new Date(e*At),r=n.getUTCFullYear(),i=n.getUTCMonth(),a=[];for(;;){i+=1,i===12&&(i=0,r+=1);let e=rn(r,i);if(e>t)return a;a.push({day:e,year:r,month:i})}}function rn(e,t){let n=new Date(0);return n.setUTCFullYear(e,t,1),Math.round(n.getTime()/At)}function an(e,t){let n=e=>e===`bar`||e===`ghost`;return n(e)&&t===`star`||e===`star`&&n(t)}function on(e,t){return e.x0<t.x1&&t.x0<e.x1}function sn(e,t){if(t<=0||e.width<=t)return;let n=e.items.filter(e=>e.change!==void 0);if(n.length>0){let e=Math.min(...n.flatMap(e=>e.ghost===void 0?[e.glyph.x]:[e.glyph.x,e.ghost.x]));return e<t*.9?void 0:Math.max(0,e-t/6)}if(`x`in e.today&&e.today.x>t*.8)return Math.max(0,e.today.x-t/3)}function cn(e,t,n={}){let r=Mt(e.time.start)??0,i=Mt(e.time.end)??r,a=n.pxPerDay??qt[e.time.scale]??4,o=(i-r+1)*a,s=e=>(e-r)*a,c=nn(r,i),l=new Date(r*At),u=[{day:r,year:l.getUTCFullYear(),month:l.getUTCMonth()},...c],d=u.map((e,t)=>{let n=t+1<u.length?u[t+1].day:i+1;return{label:Yt[e.month],x:s(e.day),width:(n-e.day)*a,year:e.year,month:e.month}}),f=[];u.forEach((e,t)=>{let n=d[t],r=f[f.length-1];r!==void 0&&r.label===String(e.year)?r.width+=n.width:f.push({label:String(e.year),x:n.x,width:n.width})});let p=Jt(a,n.unit),m=(e,t)=>e.map((n,r)=>{let o=r+1<e.length?e[r+1]:i+1;return{label:t(n),x:s(n),width:(o-n)*a}}),h=f,g;if(p===`week`){let e=[];for(let t=r-Qt(r)+7;t<=i;t+=7)e.push(t);g=m([r,...e],e=>`W${$t(e)}`),h=d.map(e=>({label:`${e.label} ${e.year}`,x:e.x,width:e.width}))}else if(p===`quarter`){let e=u.filter((e,t)=>t===0||e.month%3==0);g=e.map((t,n)=>{let r=n+1<e.length?e[n+1].day:i+1;return{label:`Q${Math.floor(t.month/3)+1}`,x:s(t.day),width:(r-t.day)*a}})}else g=d;let _=g.slice(1).map(e=>e.x),v=[],y=[],b=0,x=e.comparedTo!==void 0,S=(e,t)=>{if(!x)return;if(e.role===`added`||t.role===`added`)return`(new)`;let n=Wt(e);return n===``?void 0:`(${n})`},C=(e,t,n)=>{let r=S(e,t);return r===void 0?n:n===void 0?r:`${n} ${r}`},w=(e,t)=>{if(x)return e.role===`removed`||t.role===`removed`?`removed`:e.role===`added`||t.role===`added`?`added`:Wt(e)===``?void 0:`moved`},T=(e,t)=>{let n=[],r=[],i=[],c=e.map(e=>({...e,days:Ft(e.item)})).filter(e=>e.days!==void 0).sort((e,t)=>Number(e.item.type===`milestone`)-Number(t.item.type===`milestone`)||e.days.start-t.days.start||e.row-t.row||e.index-t.index);for(let{item:e,index:t,row:l,days:u,text:d,note:f,change:p}of c){let c=[],m;if(p===`moved`&&e.previous!==void 0){let t=Vt(e.previous);if(e.type===`activity`)m={x0:s(t.start),x1:s(t.end+1)};else{let e=s(t.start)+a/2;m={x0:e-7,x1:e+7,cx:e}}c.push({kind:`ghost`,x0:m.x0,x1:m.x1})}let h,g,_,v;if(e.type===`activity`){if(g=s(u.start),_=s(u.end+1),c.push({kind:`bar`,x0:g,x1:_}),d!==void 0){let e=tn(d);h=e+12<=_-g?{text:d,inside:!0,x:g+6,width:e}:ln(d,g,_,o),f!==void 0&&(h.note=f),c.push({kind:`label`,x0:h.x,x1:h.x+h.width})}}else v=s(u.start)+a/2,g=v-7,_=v+7,c.push({kind:`star`,x0:g,x1:_}),d!==void 0&&(h=ln(d,g,_,o),f!==void 0&&(h.note=f),c.push({kind:`label`,x0:h.x,x1:h.x+h.width}));let y=n.findIndex(e=>c.every(t=>e.every(e=>an(t.kind,e.kind)||!on(t,e))));y===-1&&(y=n.length,n.push([])),n[y].push(...c),r.push({row:l,item:t,type:e.type,lane:y,days:u,...e.kind?{kind:e.kind}:{},...p===void 0?{}:{change:p}}),i.push({label:h===void 0?void 0:{...h,...p===`removed`?{struck:!0}:{}},x0:g,x1:_,cx:v,ghost:m})}return r.forEach((e,n)=>{let r=i[n],a=t+4+e.lane*24+12,o=e.type===`activity`?{x:r.x0,y:a-6,width:r.x1-r.x0,height:12}:{x:r.x0,y:a-7,width:14,height:14},s=r.ghost;y.push({...e,glyph:o,...r.cx===void 0?{}:{center:{x:r.cx,y:a}},...r.label===void 0?{}:{label:{...r.label,y:a-8,height:16}},...s===void 0?{}:e.type===`activity`?{ghost:{x:s.x0,y:a-6,width:s.x1-s.x0,height:12}}:{ghost:{x:s.x0,y:a-7,width:14,height:14},ghostCenter:{x:s.cx,y:a}}})}),Math.max(1,n.length)},ee=e=>e*24+8,E=(e,t)=>{let n=T(e.items.map((n,r)=>({row:t,index:r,item:n,text:C(n,e,en(n)),note:S(n,e),change:w(n,e)})),b),r=ee(n);v.push({type:`task`,row:t,y:b,height:r,lanes:n,label:e.label,id:e.id}),b+=r},D,te=()=>{if(D!==void 0){if(D.tasks.length===0){let e=D.label?26:10;v.push({type:`separator`,row:D.row,y:b,height:e,...D.label?{label:D.label}:{}}),b+=e}else{let e=T(D.tasks.flatMap(({task:e,row:t})=>e.items.map((n,r)=>({row:t,index:r,item:n,text:C(n,e,en(n)??(n.type===`activity`?e.label:void 0)),note:S(n,e),change:w(n,e)}))),b),t=ee(e);v.push({type:`section`,row:D.row,y:b,height:t,lanes:e,...D.label?{label:D.label}:{},tasks:D.tasks.map(({task:e})=>e.id)}),b+=t}D=void 0}},ne=(()=>{let t=new Set;if(!(n.onlyChanged&&x))return;let r;return e.rows.forEach((e,n)=>{e.type===`separator`?r=n:Kt(e)&&(t.add(n),r!==void 0&&t.add(r))}),t})(),re=ne===void 0?0:e.rows.filter((e,t)=>e.type===`task`&&!ne.has(t)).length;e.rows.forEach((e,t)=>{if(ne===void 0||ne.has(t)){if(e.type===`separator`){if(n.compact){te(),D={row:t,...e.label?{label:e.label}:{},tasks:[]};return}let r=e.label?26:10;v.push({type:`separator`,row:t,y:b,height:r,...e.label?{label:e.label}:{}}),b+=r}else D===void 0?E(e,t):D.tasks.push({task:e,row:t})}}),te();let ie=[];for(let t of e.rows)if(t.type===`task`)for(let e of t.items)e.kind&&!ie.includes(e.kind)&&ie.push(e.kind);for(let t of[...e.periods??[],...e.references??[]])t.kind&&!ie.includes(t.kind)&&ie.push(t.kind);let O=[];(e.periods??[]).forEach((e,t)=>{let n=Math.max(Mt(e.start)??r,r),o=Math.min(Mt(e.end)??i,i);n>o||O.push({index:t,x:s(n),width:(o-n+1)*a,start:e.start,end:e.end,...e.label?{label:e.label}:{},...e.kind?{kind:e.kind}:{}})});let ae=(e.references??[]).flatMap((e,t)=>{let n=Mt(e.date);return n===void 0||n<r||n>i?[]:[{index:t,x:s(n)+a/2,label:e.label,date:e.date,...e.kind?{kind:e.kind}:{}}]}),k=[];if(t>=r&&t<=i){let e=s(t)+a/2;k.push({x0:e-26,x1:e+26})}let oe=[],se=[...O.filter(e=>e.label).map(e=>({of:`period`,index:e.index,text:e.label,x:e.x+3,room:e.width-6})),...ae.map(e=>{let t=tn(e.label)*(10/11);return{of:`reference`,index:e.index,text:e.label,x:Math.min(Math.max(2,e.x-t/2),o-t-2),room:o-4}})].sort((e,t)=>e.x-t.x);for(let e of se){let t=tn(e.text)*(10/11);if(t>e.room)continue;let n={x0:e.x-2,x1:e.x+t+2};k.some(e=>n.x0<e.x1&&e.x0<n.x1)||(k.push(n),oe.push({of:e.of,index:e.index,text:e.text,x:e.x,width:t}))}return{width:o,height:b,start:r,end:i,years:f,months:d,monthLines:c.map(e=>s(e.day)),unit:p,upper:h,lower:g,unitLines:_,rows:v,items:y,dependencies:un(e,v,y,s),today:t<r?{outside:`before`,day:t}:t>i?{outside:`after`,day:t}:{x:s(t)+a/2,day:t},kinds:ie,hiddenTasks:re,periods:O,references:ae,headerLabels:oe}}function ln(e,t,n,r){let i=tn(e),a=n+4;if(a+i<=r)return{text:e,inside:!1,x:a,width:i};let o=t-4-i;return o>=0?{text:e,inside:!1,x:o,width:i}:{text:e,inside:!1,x:Math.max(0,r-i),width:i}}function un(e,t,n,r){let i=It(e),a=new Map(n.map(e=>[`${e.row}:${e.item}`,e])),o=new Map(t.map(e=>[e.row,e])),s=(e,t)=>{let s=i.get(e);if(s?.days===void 0)return;if(s.item!==void 0){let e=a.get(`${s.row}:${s.item}`);if(e===void 0)return;let n=e.glyph.y+e.glyph.height/2;return e.center===void 0?{x:t===`start`?e.glyph.x:e.glyph.x+e.glyph.width,y:n}:{x:e.center.x+(t===`start`?-7:7),y:n}}let c=r(t===`start`?s.days.start:s.days.end+1),l=o.get(s.row);if(l!==void 0&&l.type===`task`)return{x:c,y:l.y+4+12};let u=n.filter(e=>e.row===s.row).sort((e,n)=>t===`start`?e.glyph.x-n.glyph.x:n.glyph.x+n.glyph.width-(e.glyph.x+e.glyph.width));if(u.length!==0)return{x:c,y:u[0].glyph.y+u[0].glyph.height/2}},c=[];return(e.dependencies??[]).forEach((e,t)=>{let n=Rt(e),r=zt(n),a=s(e.from,r.from),o=s(e.to,r.to),l=Bt(e,i);if(a===void 0||o===void 0||l===void 0)return;let u={x:a.x+(r.from===`end`?8:-8),y:a.y},d={x:o.x+(r.to===`start`?-8:8),y:o.y};if(a.y===o.y&&r.from===`end`&&r.to===`start`&&o.x>=a.x-14){c.push({index:t,from:e.from,to:e.to,type:n,satisfied:l,points:[a,o]});return}let f=o.y>a.y?o.y-12:(o.y,a.y,o.y+12);c.push({index:t,from:e.from,to:e.to,type:n,satisfied:l,points:[a,u,{x:u.x,y:f},{x:d.x,y:f},d,o]})}),c}function dn(e){let t=e.rows.reduce((e,t)=>Math.max(e,(t.label??``).length),0);return Math.min(Math.max(t*vt+24,120),280)}function fn(e,t){for(let n of e.rows){if(n.type!==`task`)continue;if(n.id===t)return`"${n.label}" (${t})`;let e=n.items.find(e=>e.id===t);if(e!==void 0){let n=en(e);return n===void 0?t:`"${n}" (${t})`}}return t}function pn(e,t,n){let r=n===!1?` — not satisfied by the dates`:``;return`${fn(e,t.to)} waits on ${fn(e,t.from)} (${Rt(t)})${r}`}function mn(e){let t=[];e.title!==void 0&&e.title!==``&&t.push(e.title),e.comparedTo!==void 0&&t.push(`Compared with ${e.comparedTo.label}${e.comparedTo.date===void 0?``:` (${e.comparedTo.date})`}`),t.push(`From ${e.time.start} to ${e.time.end}, by ${e.time.scale}`);for(let n of e.rows){if(t.push(``),n.type===`separator`){t.push(n.label?`— ${n.label} —`:`———`);continue}let e=n.role===void 0?``:n.role===`added`?` — new`:` — removed`;t.push(`${n.label} [${n.id}]${n.items.length===0?` — no items`:``}${e}`);for(let e of n.items){let n=e.type===`activity`?`${e.start} to ${e.end}`:e.date,r=e.label===void 0?``:`: ${e.label}`,i=e.kind===void 0?``:` [${e.kind}]`,a=e.id===void 0?``:` (${e.id})`,o=(()=>{if(e.role===`added`)return` — new`;if(e.role===`removed`)return` — removed`;let t=Wt(e);return t===``||e.previous===void 0?``:` — moved ${t}, was ${`date`in e.previous?e.previous.date:`${e.previous.start} to ${e.previous.end}`}`})();t.push(` ${e.type} ${n}${r}${i}${a}${o}`)}}let n=[...(e.periods??[]).map(e=>` period ${e.start} to ${e.end}${e.label?`: ${e.label}`:``}${e.kind?` [${e.kind}]`:``}`),...(e.references??[]).map(e=>` reference ${e.date}: ${e.label}${e.kind?` [${e.kind}]`:``}`)];n.length>0&&t.push(``,`Calendar`,...n);let r=e.dependencies??[];if(r.length>0){let n=It(e);t.push(``,`Dependencies`);for(let i of r)t.push(` ${pn(e,i,Bt(i,n))}`)}return t}function hn(e){let t=[],n=(e,n)=>{let r=Mt(e);return r===void 0&&t.push({rule:`invalid-date`,path:n,message:`"${e}" is not a day of the calendar`}),r},r=n(e.time.start,`/data/time/start`),i=n(e.time.end,`/data/time/end`),a=r!==void 0&&i!==void 0&&r<=i?{start:r,end:i}:void 0;r!==void 0&&i!==void 0&&r>i&&t.push({rule:`inverted-range`,path:`/data/time`,message:`the timeline starts on ${e.time.start}, after it ends on ${e.time.end}`});let o=`${e.time.start} to ${e.time.end}`,s=new Map,c=(e,n)=>{if(e===void 0)return;let r=s.get(e);r===void 0?s.set(e,n):t.push({rule:`duplicate-identifier`,path:`${n}/id`,message:`identifier "${e}" is already declared at ${r}`})},l=e.comparedTo!==void 0;e.comparedTo?.date!==void 0&&n(e.comparedTo.date,`/data/comparedTo/date`);let u=e=>t.push({rule:`comparison-without-reference`,path:e,message:"previous dates and change roles describe a comparison; declare `comparedTo` naming the plan they compare with"}),d=new Set;return e.rows.forEach((e,r)=>{if(e.type!==`task`)return;let i=`/data/rows/${r}`;c(e.id,i),e.role!==void 0&&!l&&u(`${i}/role`),e.items.forEach((r,s)=>{let f=`${i}/items/${s}`;if(c(r.id,f),r.kind!==void 0&&d.add(r.kind),r.role!==void 0&&!l&&u(`${f}/role`),r.previous!==void 0){l||u(`${f}/previous`),(r.role!==void 0||e.role!==void 0)&&t.push({rule:`contradictory-change`,path:`${f}/previous`,message:`an item that is ${r.role??`in a task that is ${e.role}`} has no previous dates; it is new or dropped, not moved`});let i=r.previous,s=r.type===`activity`?{first:n(i.start,`${f}/previous/start`),last:n(i.end,`${f}/previous/end`)}:(()=>{let e=n(i.date,`${f}/previous/date`);return{first:e,last:e}})();s.first!==void 0&&s.last!==void 0&&(s.first>s.last?t.push({rule:`inverted-range`,path:`${f}/previous`,message:`the previous dates start on ${i.start}, after they end on ${i.end}`}):a!==void 0&&(s.first<a.start||s.last>a.end)&&t.push({rule:`item-outside-range`,path:`${f}/previous`,message:`the previous dates fall outside the timeline's range ${o}; the range covers both plans, so widen \`time\``}))}r.role!==void 0&&e.role!==void 0&&r.role!==e.role&&t.push({rule:`contradictory-change`,path:`${f}/role`,message:`an item ${r.role} in a task that is ${e.role}`});let p,m;if(r.type===`activity`){if(p=n(r.start,`${f}/start`),m=n(r.end,`${f}/end`),p!==void 0&&m!==void 0&&p>m){t.push({rule:`inverted-range`,path:f,message:`the activity starts on ${r.start}, after it ends on ${r.end}`});return}}else p=m=n(r.date,`${f}/date`);a!==void 0&&p!==void 0&&m!==void 0&&(p<a.start||m>a.end)&&t.push({rule:`item-outside-range`,path:f,message:r.type===`activity`?`the activity runs ${r.start} to ${r.end}, outside the timeline's range ${o}; widen \`time\` or move the activity`:`the milestone falls on ${r.date}, outside the timeline's range ${o}; widen \`time\` or move the milestone`})})}),(e.periods??[]).forEach((e,r)=>{let i=`/data/periods/${r}`;e.kind!==void 0&&d.add(e.kind);let s=n(e.start,`${i}/start`),c=n(e.end,`${i}/end`);s!==void 0&&c!==void 0&&(s>c?t.push({rule:`inverted-range`,path:i,message:`the period starts on ${e.start}, after it ends on ${e.end}`}):a!==void 0&&(c<a.start||s>a.end)&&t.push({rule:`period-outside-range`,path:i,message:`the period ${e.start} to ${e.end} lies wholly outside the timeline's range ${o}, so nothing of it could be drawn`}))}),(e.references??[]).forEach((e,r)=>{let i=`/data/references/${r}`;e.kind!==void 0&&d.add(e.kind);let s=n(e.date,`${i}/date`);s!==void 0&&a!==void 0&&(s<a.start||s>a.end)&&t.push({rule:`item-outside-range`,path:i,message:`the reference date ${e.date} is outside the timeline's range ${o}; widen \`time\` or move it`})}),d.size>tt.kindsPerVocabulary&&t.push({rule:`too-many-kinds`,path:`/data/rows`,message:`${d.size} distinct item types, and no more than ${tt.kindsPerVocabulary} can be told apart in a rendering`,observed:d.size,limit:tt.kindsPerVocabulary}),t.push(..._n(e,It(e))),t.push(...gn(e)),t}function gn(e){let t=new Set;for(let n of e.rows)if(n.type===`task`){n.role===`removed`&&t.add(n.id);for(let e of n.items)e.id!==void 0&&(e.role===`removed`||n.role===`removed`)&&t.add(e.id)}let n=[];return(e.dependencies??[]).forEach((e,r)=>{for(let i of[`from`,`to`])t.has(e[i])&&n.push({rule:`dependency-on-removed`,path:`/data/dependencies/${r}/${i}`,message:`"${e[i]}" was dropped from the plan, so nothing can depend on it any more; remove the dependency`})}),n}function _n(e,t){let n=[],r=e.dependencies??[],i=[],a=new Map;r.forEach((r,o)=>{let s=`/data/dependencies/${o}`,c=!0;for(let i of[`from`,`to`]){let a=r[i],o=t.get(a);if(o===void 0)c=!1,n.push({rule:`unresolved-endpoint`,path:`${s}/${i}`,message:`"${a}" is not the identifier of any task or item this timeline declares`});else if(o.type===`task`&&o.days===void 0){c=!1;let t=e.rows[o.row];if(t.type===`task`&&t.items.length>0)continue;n.push({rule:`empty-task-endpoint`,path:`${s}/${i}`,message:`task "${a}" holds no item, so it has no start or finish for a dependency to link`})}}if(!c)return;let l=t.get(r.from),u=t.get(r.to),d=(e,t)=>e.type===`task`&&t.type!==`task`&&t.row===e.row;if(l.id===u.id||d(l,u)||d(u,l)){n.push({rule:`self-dependency`,path:s,message:l.id===u.id?`"${l.id}" cannot depend on itself`:`a task and one of its own items cannot depend on each other: the task's span is made of its items`});return}let f=JSON.stringify([r.from,r.to,Rt(r)]),p=a.get(f);p===void 0?(a.set(f,o),i.push({from:r.from,to:r.to,index:o})):n.push({rule:`duplicate-dependency`,path:s,message:`the same dependency is already declared at /data/dependencies/${p}`})});let o=vn(i);return o!==void 0&&n.push({rule:`dependency-cycle`,path:`/data/dependencies/${o.index}`,message:`dependencies form a cycle, which no dates can honour: ${o.ids.join(` → `)}`}),n}function vn(e){let t=new Map;for(let n of e){let e=t.get(n.from)??[];e.push({to:n.to,index:n.index}),t.set(n.from,e)}let n=new Map,r=[];for(let e of t.keys()){if(n.has(e))continue;let i=[{id:e,next:0}];for(n.set(e,`open`),r.push({id:e,index:-1});i.length>0;){let e=i[i.length-1],a=t.get(e.id)??[];if(e.next>=a.length){n.set(e.id,`done`),i.pop(),r.pop();continue}let o=a[e.next++],s=n.get(o.to);if(s===`open`){let e=r.findIndex(e=>e.id===o.to);return{ids:[...r.slice(e).map(e=>e.id),o.to],index:o.index}}s===void 0&&(n.set(o.to,`open`),i.push({id:o.to,next:0}),r.push({id:o.to,index:o.index}))}}}function yn(e){let t=e.data;return e.kind===`graph`?Array.isArray(t.nodes)&&Array.isArray(t.edges):e.kind===`sequence`?Array.isArray(t.participants)&&Array.isArray(t.messages):e.kind===`timeline`?typeof t.time==`object`&&t.time!==null&&Array.isArray(t.rows):Array.isArray(t.columns)&&Array.isArray(t.rows)}function bn(e){return e.kind===`graph`?e.data.nodes:e.kind===`sequence`?e.data.participants:[]}function xn(e){return e.kind===`graph`?e.data.edges:e.kind===`sequence`?e.data.messages:[]}function Sn(e){return e.kind===`graph`||e.kind===`sequence`?e.data.containers??[]:[]}function Cn(e){return e.kind===`graph`?`/data/nodes`:`/data/participants`}function wn(e){return e.kind===`graph`?`/data/edges`:`/data/messages`}function Tn(e){if(e.kind===`timeline`)return[];let t=e.data,n=[];for(let e of[`nodes`,`edges`,`participants`,`messages`,`rows`,`relations`]){let r=t[e];Array.isArray(r)&&r.forEach((t,r)=>{if(typeof t!=`object`||!t||Array.isArray(t))return;let i=t;n.push({at:`/data/${e}/${r}`,ref:typeof i.ref==`string`?i.ref:void 0,set:i.set,expect:i.expect,locations:i.locations})})}return n}function En(e){if(e.kind!==`table`)return[];let t=e.data.rows,n=[];return t.forEach((e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))return;let r=e;(r.ref!==void 0||r.set!==void 0)&&n.push({at:`/data/rows/${t}`,...typeof r.ref==`string`?{ref:r.ref}:{},...r.set===void 0?{}:{set:r.set}})}),n}function Dn(e){if(e.kind!==`table`)return[];let t=e.data.rows,n=[];return t.forEach((e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))return;let r=e.id;typeof r==`string`&&n.push({id:r,at:`/data/rows/${t}`})}),n}function On(e){if(e.kind!==`table`)return[];let t=e.data.relations;return Array.isArray(t)?t:[]}function kn(e,t){return e===`timeline`?`a timeline is maintained by presenting the revised timeline again, not proposed as a change, ${t}`:`a ${e} is a projection and cannot be proposed, ${t}`}function An(e){let t=[];if(!yn(e))return t.push({rule:`kind-data-mismatch`,path:`/data`,message:`data does not carry what kind "${e.kind}" declares`}),t;let n=Qe(e.schema).includes(e.kind);e.target!==void 0&&!n&&t.push({rule:`kind-not-proposable`,path:`/target`,message:kn(e.kind,`so it carries no target`)}),e.removals!==void 0&&(n?e.target===void 0&&t.push({rule:`removal-without-target`,path:`/removals`,message:`removals need a target: an artifact that does not exist yet has nothing to remove`}):t.push({rule:`kind-not-proposable`,path:`/removals`,message:kn(e.kind,`so it declares no removals`)}));let r=bn(e),i=Cn(e),a=new Map;r.forEach((e,n)=>{let r=a.get(e.id);r===void 0?a.set(e.id,n):t.push({rule:`duplicate-identifier`,path:`${i}/${n}/id`,message:`identifier "${e.id}" is already declared at ${i}/${r}`})});let o=new Map;Sn(e).forEach((e,n)=>{let r=o.get(e.id);r===void 0?o.set(e.id,n):t.push({rule:`duplicate-container-identifier`,path:`/data/containers/${n}/id`,message:`container "${e.id}" is already declared at /data/containers/${r}`})}),r.forEach((e,n)=>{for(let[r,a]of[[`container`,e.container],[`set/container`,e.set?.container]])a!==void 0&&!o.has(a)&&t.push({rule:`unresolved-container`,path:`${i}/${n}/${r}`,message:`"${a}" is not a container declared in /data/containers`})});let s=wn(e);xn(e).forEach((e,n)=>{for(let r of[`from`,`to`]){let o=e[r];a.has(o)||t.push({rule:`unresolved-endpoint`,path:`${s}/${n}/${r}`,message:`"${o}" is not an identifier declared in ${i}`})}});let c=new Map,l=(e,n,r)=>{if(n===void 0)return;let i=`${e}:${n}`,a=c.get(i);a===void 0?c.set(i,r):t.push({rule:`duplicate-reference`,path:r,message:`${e} "${n}" is already addressed at ${a}; a proposal states one intention per thing`})};r.forEach((e,t)=>l(`element`,e.ref,`${i}/${t}`)),xn(e).forEach((e,t)=>l(`relationship`,e.ref,`${s}/${t}`)),En(e).forEach(e=>l(`row`,e.ref,e.at)),(e.removals??[]).forEach((e,t)=>l(e.type,e.ref,`/removals/${t}`));let u=[...r.map((e,t)=>({at:`${i}/${t}`,ref:e.ref,set:e.set})),...xn(e).map((t,n)=>({at:`${wn(e)}/${n}`,ref:t.ref,set:t.set})),...En(e)];for(let r of u)r.set!==void 0&&(r.ref===void 0?t.push({rule:`change-without-reference`,path:`${r.at}/set`,message:`a change names a reference to change; without one this is a new thing, and its fields are its values`}):n?e.target===void 0&&t.push({rule:`change-without-target`,path:`${r.at}/set`,message:`a change needs a target: naming what is being changed is what makes this a proposal rather than a new artifact`}):t.push({rule:`kind-not-proposable`,path:`${r.at}/set`,message:kn(e.kind,`so nothing in it declares a change`)}));let d=e=>{let t=new Set;for(let n of e)n.kind!==void 0&&n.kind!==``&&t.add(n.kind);return t},f=[[e.kind===`sequence`?`participant`:`element`,i,d(r)],[e.kind===`sequence`?`message`:`relationship`,wn(e),d(xn(e))]];for(let[e,n,r]of f)r.size>tt.kindsPerVocabulary&&t.push({rule:`too-many-kinds`,path:n,message:`${r.size} distinct ${e} types, and no more than ${tt.kindsPerVocabulary} can be told apart in a rendering`,observed:r.size,limit:tt.kindsPerVocabulary});let p=e.viewpoints;if(Array.isArray(p)){if(e.kind!==`graph`)t.push({rule:`viewpoints-without-graph`,path:`/viewpoints`,message:`only a graph declares viewpoints; a ${e.kind} has no element and relationship kinds for one to retain`});else{let n=new Set(r.map(e=>e.kind).filter(e=>!!e)),i=new Set(xn(e).map(e=>e.kind).filter(e=>!!e)),a=new Map;p.forEach((e,r)=>{let o=`/viewpoints/${r}`,{id:s,elementKinds:c,relationshipKinds:l}=e,u=a.get(s);u===void 0?a.set(s,r):t.push({rule:`duplicate-viewpoint-identifier`,path:`${o}/id`,message:`viewpoint "${s}" is already declared at /viewpoints/${u}`}),c===void 0&&l===void 0&&t.push({rule:`empty-viewpoint`,path:o,message:`viewpoint "${s}" retains no kind, so it would show nothing it was not already showing; name elementKinds, relationshipKinds, or both`});let d=[[c,n,i,`elementKinds`,`element`,`relationship`],[l,i,n,`relationshipKinds`,`relationship`,`element`]];for(let[e,n,r,i,a,c]of d)e?.forEach((e,l)=>{n.has(e)||t.push({rule:`unresolved-viewpoint-kind`,path:`${o}/${i}/${l}`,message:`viewpoint "${s}" retains ${a} kind "${e}", and no ${a} of this document has it`+(r.has(e)?` (it is a ${c} kind here, which is a different vocabulary)`:``)})})})}}if(e.kind===`table`){let{columns:n,rows:r}=e.data;r.forEach((e,r)=>{let{cells:i,heading:a}=et(e);a===void 0&&i.length!==n.length&&t.push({rule:`row-column-mismatch`,path:`/data/rows/${r}`,message:`row has ${i.length} values but ${n.length} columns are declared`,observed:i.length,limit:n.length})})}e.kind===`timeline`&&t.push(...hn(e.data));for(let n of Tn(e)){n.expect!==void 0&&(e.target===void 0?t.push({rule:`expectation-without-target`,path:`${n.at}/expect`,message:`an expectation is checked by the authority a proposal targets; a document that targets nothing has nobody to check it`}):n.ref===void 0&&t.push({rule:`expectation-without-reference`,path:`${n.at}/expect`,message:`an expectation describes something that already exists, and this item carries no reference to one`}));let r=n.set?.removeAttributes;if(Array.isArray(r)){let e=n.set?.attributes??{},i=new Map;r.forEach((r,a)=>{if(typeof r!=`string`)return;let o=i.get(r);o===void 0?i.set(r,a):t.push({rule:`duplicate-attribute-removal`,path:`${n.at}/set/removeAttributes/${a}`,message:`"${r}" is already removed at ${n.at}/set/removeAttributes/${o}`}),Object.prototype.hasOwnProperty.call(e,r)&&t.push({rule:`attribute-set-and-removed`,path:`${n.at}/set/removeAttributes/${a}`,message:`"${r}" is both assigned and removed; a proposal states one intention per property`})})}Array.isArray(n.locations)&&n.locations.forEach((e,r)=>{if(typeof e!=`object`||!e)return;let i=e.range;i!==void 0&&(i.endLine<i.startLine||i.endLine===i.startLine&&i.endCharacter!==void 0&&i.startCharacter!==void 0&&i.endCharacter<i.startCharacter)&&t.push({rule:`location-range-reversed`,path:`${n.at}/locations/${r}/range`,message:`a range ends before it begins, so it selects nothing a reader could be taken to`})})}e.kind===`table`&&e.data.rows.forEach((e,n)=>{if(typeof e!=`object`||!e||Array.isArray(e))return;let r=e;r.role!==void 0&&r.set!==void 0&&t.push({rule:`role-with-change`,path:`/data/rows/${n}/role`,message:`a row states what it observed or what it asks for, not both: a declared role beside a change is a report and an instruction at once`})});let m=new Map;for(let n of Dn(e)){let e=m.get(n.id);e===void 0?m.set(n.id,n.at):t.push({rule:`duplicate-identifier`,path:`${n.at}/id`,message:`identifier "${n.id}" is already declared at ${e}`})}return On(e).forEach((e,n)=>{for(let r of[`from`,`to`]){let i=e[r];if(typeof i!=`object`||!i)continue;let a=i.id;typeof a==`string`&&(m.has(a)||t.push({rule:`unresolved-endpoint`,path:`/data/relations/${n}/${r}`,message:`"${a}" is not the identifier of any row this document declares`}))}}),t}function jn(e,t){let n=t(e);if(n.length>0)return{valid:!1,issues:n};let r=e,i=An(r);return i.length>0?{valid:!1,issues:i}:{valid:!0,envelope:r,issues:[]}}function Mn(e,t,n){let r=mt(e,n);if(r!==void 0)return{valid:!1,issues:[r]};let i;try{i=JSON.parse(e)}catch{return{valid:!1,issues:[{rule:`not-json`,path:``,message:`document is not parseable JSON`}]}}let a=jn(i,t);if(!a.valid)return a;let o=mt(e,n,a.envelope.schema);if(o!==void 0)return{valid:!1,issues:[o]};let s=gt(a.envelope,n);return s.length>0?{valid:!1,issues:s}:{valid:!0,envelope:a.envelope,measurement:_t(a.envelope,e),issues:[]}}function Nn(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e.schema;if(typeof t==`string`&&t.startsWith(`urn:structured-exchange:`))return t}function Pn(e,t,n){let r=mt(e,n);if(r!==void 0)return{status:`too-large`,issue:r};let i;try{i=JSON.parse(e)}catch{return{status:`not-a-document`,why:`unparseable`}}let a=Nn(i);if(a===void 0)return{status:`not-a-document`,why:`undeclared`};if(st(a)===void 0)return{status:`unsupported-version`,schema:a};let o=jn(i,t);if(!o.valid)return{status:`invalid`,issues:o.issues};let s=mt(e,n,o.envelope.schema);return s===void 0?{status:`valid`,envelope:o.envelope}:{status:`too-large`,issue:s}}function Fn(e){let t=e.replace(/\r\n/g,`
|
|
22
22
|
`).replace(/\s+$/,``),n=2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return`sx-${(n>>>0).toString(16).padStart(8,`0`)}-${t.length.toString(36)}`}async function In(e){try{return await navigator.clipboard.writeText(e),!0}catch{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.cssText=`position:fixed;top:0;left:0;opacity:0;pointer-events:none`,document.body.append(t);try{return t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}}function Ln(e,t,n){return e>=t&&e<=n}function Rn(e){return e===8205}function zn(e){return Ln(e,55296,56319)}function Bn(e){return Ln(e,127462,127487)}function Vn(e){return Ln(e,65024,65039)}function Hn(e){return Ln(e,768,879)||Ln(e,6832,6911)||Ln(e,7616,7679)||Ln(e,65056,65071)}function Un(e){return e>65535?2:1}function Wn(e,t){for(;t<e.length;){let n=e.codePointAt(t);if(Hn(n)||Vn(n))t+=Un(n);else break}return t}function Gn(e,t){let n=e.codePointAt(t),r=t+Un(n);for(r=Wn(e,r);r<e.length-1&&Rn(e.codePointAt(r));){let t=e.codePointAt(r+1);r+=1+Un(t),r=Wn(e,r)}return Bn(n)&&r<e.length&&Bn(e.codePointAt(r))&&(r+=Un(e.codePointAt(r))),r}function Kn(e){return zn(e)||Hn(e)||Vn(e)||Rn(e)}function qn(e,t){if(t===0)return!0;let n=0,r=0;for(;r<e.length;)if(r=Gn(e,r),n++,n>=t)return!0;return!1}function Jn(e,t){let n=0,r=0;for(;r<e.length;)if(r=Gn(e,r),n++,n>t)return!1;return!0}function Yn(e,t){if(t===0)return!0;let n=0;for(;n<e.length;){if(Kn(e.charCodeAt(n)))return qn(e,t);if(n++,n>=t)return!0}return!1}function Xn(e,t){let n=0;for(;n<e.length;){if(Kn(e.charCodeAt(n)))return Jn(e,t);if(n++,n>t)return!1}return!0}function Zn(e){return Array.isArray(e)}function Qn(e){return sr(typeof e,`bigint`)}function $n(e){return sr(typeof e,`boolean`)}function er(e){if(or(e)||!tr(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function tr(e){return sr(typeof e,`function`)}function nr(e){return sr(e,null)}function rr(e){return sr(typeof e,`object`)&&!nr(e)}function ir(e){return sr(typeof e,`string`)}function ar(e){return sr(typeof e,`symbol`)}function or(e){return sr(e,void 0)}function sr(e,t){return e===t}function cr(e,t){return Xn(e,t)}function lr(e,t){return Yn(e,t)}function ur(e){return e instanceof Boolean}function dr(e){return e instanceof Number}function fr(e){return e instanceof String}function pr(e){return globalThis.ArrayBuffer.isView(e)}function mr(e){return e instanceof globalThis.RegExp}function hr(e){return e instanceof globalThis.Date}var gr=[];function _r(e){gr=e.variables}var vr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`schema`in e&&`kind`in e&&`data`in e&&Object.getOwnPropertyNames(e).every((e,t)=>gr[0].test(e)||!1)&&e.schema===`urn:structured-exchange:1`&&(e.kind===`graph`||e.kind===`sequence`||e.kind===`table`)&&(e.target===void 0||!(`target`in e)||yr(e.target))&&(e.removals===void 0||!(`removals`in e)||Array.isArray(e.removals)&&e.removals.every((e,t)=>br(e))&&e.removals.length<=500)&&[typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`nodes`in e.data&&`edges`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>gr[2].test(e)||!1)&&Array.isArray(e.data.nodes)&&e.data.nodes.every((e,t)=>wr(e))&&e.data.nodes.length<=500&&e.data.nodes.length>=1&&Array.isArray(e.data.edges)&&e.data.edges.every((e,t)=>Er(e))&&e.data.edges.length<=2e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>Or(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`participants`in e.data&&`messages`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>gr[8].test(e)||!1)&&Array.isArray(e.data.participants)&&e.data.participants.every((e,t)=>wr(e))&&e.data.participants.length<=100&&e.data.participants.length>=1&&Array.isArray(e.data.messages)&&e.data.messages.every((e,t)=>kr(e))&&e.data.messages.length<=1e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>Or(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`columns`in e.data&&`rows`in e.data&&Object.getOwnPropertyNames(e.data).length===2&&Array.isArray(e.data.columns)&&e.data.columns.every((e,t)=>typeof e==`string`&&cr(e,200)&&lr(e,1))&&e.data.columns.length<=50&&e.data.columns.length>=1&&Array.isArray(e.data.rows)&&e.data.rows.every((e,t)=>[jr(e),typeof e==`object`&&!!e&&!Array.isArray(e)&&`cells`in e&&Object.getOwnPropertyNames(e).every((e,t)=>gr[11].test(e)||!1)&&jr(e.cells)&&(e.role===void 0||!(`role`in e)||e.role===`added`||e.role===`changed`||e.role===`context`||e.role===`removed`)].reduce((e,t,n)=>t===!0?++e:e,0)===1)&&e.data.rows.length<=5e3].reduce((e,t,n)=>t===!0?++e:e,0)===1),yr=(e=>typeof e==`string`&&cr(e,200)&&lr(e,1)),br=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`ref`in e&&Object.getOwnPropertyNames(e).every((e,t)=>gr[1].test(e)||!1)&&(e.type===`element`||e.type===`relationship`)&&yr(e.ref)&&(e.label===void 0||!(`label`in e)||xr(e.label))&&(e.kind===void 0||!(`kind`in e)||Sr(e.kind))&&(e.from===void 0||!(`from`in e)||Cr(e.from))&&(e.to===void 0||!(`to`in e)||Cr(e.to))),xr=(e=>typeof e==`string`&&cr(e,500)),Sr=(e=>typeof e==`string`&&cr(e,100)&&lr(e,1)),Cr=(e=>typeof e==`string`&&cr(e,200)&&lr(e,1)),wr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&Object.getOwnPropertyNames(e).every((e,t)=>gr[3].test(e)||!1)&&Cr(e.id)&&(e.ref===void 0||!(`ref`in e)||yr(e.ref))&&(e.label===void 0||!(`label`in e)||xr(e.label))&&(e.kind===void 0||!(`kind`in e)||Sr(e.kind))&&(e.set===void 0||!(`set`in e)||Tr(e.set))&&(e.container===void 0||!(`container`in e)||Cr(e.container))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),Tr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>gr[4].test(e)||!1)&&(e.label===void 0||!(`label`in e)||xr(e.label))&&(e.kind===void 0||!(`kind`in e)||Sr(e.kind))&&(e.container===void 0||!(`container`in e)||Cr(e.container))&&Object.getOwnPropertyNames(e).length>=1),Er=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>gr[5].test(e)||!1)&&Cr(e.from)&&Cr(e.to)&&(e.kind===void 0||!(`kind`in e)||Sr(e.kind))&&(e.ref===void 0||!(`ref`in e)||yr(e.ref))&&(e.label===void 0||!(`label`in e)||xr(e.label))&&(e.set===void 0||!(`set`in e)||Dr(e.set))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`kind`in e)),Dr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>gr[6].test(e)||!1)&&(e.kind===void 0||!(`kind`in e)||Sr(e.kind))&&(e.label===void 0||!(`label`in e)||xr(e.label))&&Object.getOwnPropertyNames(e).length>=1),Or=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&Object.getOwnPropertyNames(e).every((e,t)=>gr[7].test(e)||!1)&&Cr(e.id)&&xr(e.label)&&(e.kind===void 0||!(`kind`in e)||Sr(e.kind))),kr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>gr[9].test(e)||!1)&&Cr(e.from)&&Cr(e.to)&&(e.ref===void 0||!(`ref`in e)||yr(e.ref))&&(e.label===void 0||!(`label`in e)||xr(e.label))&&(e.set===void 0||!(`set`in e)||Ar(e.set))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),Ar=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>gr[10].test(e)||!1)&&(e.label===void 0||!(`label`in e)||xr(e.label))&&Object.getOwnPropertyNames(e).length>=1),jr=(e=>Array.isArray(e)&&e.every((e,t)=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||cr(e,1e3)))&&e.length<=50);function Mr(e){return vr(e)}_r({variables:[RegExp(`(^schema$|^kind$|^target$|^removals$|^data$)`,`u`),RegExp(`(^type$|^ref$|^label$|^kind$|^from$|^to$)`,`u`),RegExp(`(^nodes$|^edges$|^containers$)`,`u`),RegExp(`(^id$|^ref$|^label$|^kind$|^set$|^container$)`,`u`),RegExp(`(^label$|^kind$|^container$)`,`u`),RegExp(`(^from$|^to$|^kind$|^ref$|^label$|^set$)`,`u`),RegExp(`(^kind$|^label$)`,`u`),RegExp(`(^id$|^label$|^kind$)`,`u`),RegExp(`(^participants$|^messages$|^containers$)`,`u`),RegExp(`(^from$|^to$|^ref$|^label$|^set$)`,`u`),RegExp(`(^label$)`,`u`),RegExp(`(^cells$|^role$)`,`u`)]});function Nr(){throw Error(`Unreachable`)}function Pr(e){let t=new Set,n=e;for(;n&&n!==Object.prototype;){for(let e of Reflect.ownKeys(n))e!==`constructor`&&typeof e!=`symbol`&&t.add(e);n=Object.getPrototypeOf(n)}return[...t]}function Fr(e){return typeof e==`number`}var Ir;(function(e){e[e.Array=0]=`Array`,e[e.BigInt=1]=`BigInt`,e[e.Boolean=2]=`Boolean`,e[e.Date=3]=`Date`,e[e.Constructor=4]=`Constructor`,e[e.Function=5]=`Function`,e[e.Null=6]=`Null`,e[e.Number=7]=`Number`,e[e.Object=8]=`Object`,e[e.RegExp=9]=`RegExp`,e[e.String=10]=`String`,e[e.Symbol=11]=`Symbol`,e[e.TypeArray=12]=`TypeArray`,e[e.Undefined=13]=`Undefined`})(Ir||={});var Lr=BigInt(`14695981039346656037`),[Rr,zr]=[BigInt(`1099511628211`),BigInt(`18446744073709551616`)],Br=Array.from({length:256}).map((e,t)=>BigInt(t)),Vr=new Float64Array(1),Hr=new DataView(Vr.buffer),Ur=new Uint8Array(Vr.buffer);function Wr(e){Lr^=Br[e],Lr=Lr*Rr%zr}function Gr(e){Wr(Ir.Array);for(let t of e)oi(t)}function Kr(e){Wr(Ir.BigInt),Hr.setBigInt64(0,e);for(let e of Ur)Wr(e)}function qr(e){Wr(Ir.Boolean),Wr(+!!e)}function Jr(e){Wr(Ir.Constructor),oi(e.toString())}function Yr(e){Wr(Ir.Date),oi(e.getTime())}function Xr(e){Wr(Ir.Function),oi(e.toString())}function Zr(e){Wr(Ir.Null)}function Qr(e){Wr(Ir.Number),Hr.setFloat64(0,e,!0);for(let e of Ur)Wr(e)}function $r(e){Wr(Ir.Object);for(let t of Pr(e).sort())oi(t),oi(e[t])}function ei(e){Wr(Ir.RegExp),ni(e.toString())}var ti=new TextEncoder;function ni(e){Wr(Ir.String);for(let t of ti.encode(e))Wr(t)}function ri(e){Wr(Ir.Symbol),oi(e.toString())}function ii(e){Wr(Ir.TypeArray);let t=new Uint8Array(e.buffer);for(let e=0;e<t.length;e++)Wr(t[e])}function ai(e){return Wr(Ir.Undefined)}function oi(e){return pr(e)?ii(e):hr(e)?Yr(e):mr(e)?ei(e):ur(e)?qr(e.valueOf()):fr(e)?ni(e.valueOf()):dr(e)?Qr(e.valueOf()):Fr(e)?Qr(e):Zn(e)?Gr(e):$n(e)?qr(e):Qn(e)?Kr(e):er(e)?Jr(e):nr(e)?Zr(e):rr(e)?$r(e):ir(e)?ni(e):ar(e)?ri(e):or(e)?ai(e):tr(e)?Xr(e):Nr()}function si(e){return Lr=BigInt(`14695981039346656037`),oi(e),Lr}function ci(e){return si(e).toString(16).padStart(16,`0`)}var li=[];function ui(e){li=e.variables}var di=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`schema`in e&&`kind`in e&&`data`in e&&Object.getOwnPropertyNames(e).every((e,t)=>li[0].test(e)||!1)&&e.schema===`urn:structured-exchange:2`&&(e.kind===`graph`||e.kind===`sequence`||e.kind===`table`)&&(e.profile===void 0||!(`profile`in e)||typeof e.profile==`string`&&cr(e.profile,200)&&lr(e.profile,1))&&(e.target===void 0||!(`target`in e)||typeof e.target==`object`&&e.target!==null&&!Array.isArray(e.target)&&`ref`in e.target&&Object.getOwnPropertyNames(e.target).every((e,t)=>li[1].test(e)||!1)&&fi(e.target.ref)&&(e.target.revision===void 0||!(`revision`in e.target)||pi(e.target.revision)))&&(e.removals===void 0||!(`removals`in e)||Array.isArray(e.removals)&&e.removals.every((e,t)=>mi(e))&&e.removals.length<=500)&&(e.artifacts===void 0||!(`artifacts`in e)||Array.isArray(e.artifacts)&&e.artifacts.every((e,t)=>vi(e))&&e.artifacts.length<=50)&&(e.viewpoints===void 0||!(`viewpoints`in e)||Array.isArray(e.viewpoints)&&e.viewpoints.every((e,t)=>yi(e))&&e.viewpoints.length<=20)&&[typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`nodes`in e.data&&`edges`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>li[6].test(e)||!1)&&Array.isArray(e.data.nodes)&&e.data.nodes.every((e,t)=>bi(e))&&e.data.nodes.length<=500&&e.data.nodes.length>=1&&Array.isArray(e.data.edges)&&e.data.edges.every((e,t)=>Mi(e))&&e.data.edges.length<=2e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>Pi(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`participants`in e.data&&`messages`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>li[16].test(e)||!1)&&Array.isArray(e.data.participants)&&e.data.participants.every((e,t)=>bi(e))&&e.data.participants.length<=100&&e.data.participants.length>=1&&Array.isArray(e.data.messages)&&e.data.messages.every((e,t)=>Fi(e))&&e.data.messages.length<=1e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>Pi(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`columns`in e.data&&`rows`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>li[19].test(e)||!1)&&Array.isArray(e.data.columns)&&e.data.columns.every((e,t)=>typeof e==`string`&&cr(e,200)&&lr(e,1))&&e.data.columns.length<=50&&e.data.columns.length>=1&&Array.isArray(e.data.rows)&&e.data.rows.every((e,t)=>[Li(e),Ri(e),Vi(e)].reduce((e,t,n)=>t===!0?++e:e,0)===1)&&e.data.rows.length<=5e3&&(e.data.relations===void 0||!(`relations`in e.data)||Array.isArray(e.data.relations)&&e.data.relations.every((e,t)=>Hi(e))&&e.data.relations.length<=2e3)].reduce((e,t,n)=>t===!0?++e:e,0)===1),fi=(e=>typeof e==`string`&&cr(e,200)&&lr(e,1)),pi=(e=>typeof e==`string`&&cr(e,200)&&lr(e,1)),mi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`ref`in e&&Object.getOwnPropertyNames(e).every((e,t)=>li[2].test(e)||!1)&&(e.type===`element`||e.type===`relationship`||e.type===`row`)&&fi(e.ref)&&(e.label===void 0||!(`label`in e)||hi(e.label))&&(e.kind===void 0||!(`kind`in e)||gi(e.kind))&&(e.from===void 0||!(`from`in e)||_i(e.from))&&(e.to===void 0||!(`to`in e)||_i(e.to))),hi=(e=>typeof e==`string`&&cr(e,500)),gi=(e=>typeof e==`string`&&cr(e,100)&&lr(e,1)),_i=(e=>typeof e==`string`&&cr(e,200)&&lr(e,1)),vi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`rel`in e&&`uri`in e&&`sha256`in e&&Object.getOwnPropertyNames(e).every((e,t)=>li[3].test(e)||!1)&&typeof e.rel==`string`&&cr(e.rel,100)&&lr(e.rel,1)&&typeof e.uri==`string`&&cr(e.uri,2e3)&&lr(e.uri,1)&&typeof e.sha256==`string`&&li[4].test(e.sha256)&&(e.mediaType===void 0||!(`mediaType`in e)||typeof e.mediaType==`string`&&cr(e.mediaType,100)&&lr(e.mediaType,1))&&(e.label===void 0||!(`label`in e)||hi(e.label))),yi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&`concern`in e&&Object.getOwnPropertyNames(e).every((e,t)=>li[5].test(e)||!1)&&_i(e.id)&&typeof e.label==`string`&&cr(e.label,500)&&lr(e.label,1)&&typeof e.concern==`string`&&cr(e.concern,500)&&lr(e.concern,1)&&(e.elementKinds===void 0||!(`elementKinds`in e)||Array.isArray(e.elementKinds)&&e.elementKinds.every((e,t)=>gi(e))&&e.elementKinds.length<=64&&e.elementKinds.length>=1&&new Set(e.elementKinds.map(ci)).size===e.elementKinds.length)&&(e.relationshipKinds===void 0||!(`relationshipKinds`in e)||Array.isArray(e.relationshipKinds)&&e.relationshipKinds.every((e,t)=>gi(e))&&e.relationshipKinds.length<=64&&e.relationshipKinds.length>=1&&new Set(e.relationshipKinds.map(ci)).size===e.relationshipKinds.length)),bi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&Object.getOwnPropertyNames(e).every((e,t)=>li[7].test(e)||!1)&&_i(e.id)&&(e.ref===void 0||!(`ref`in e)||fi(e.ref))&&(e.label===void 0||!(`label`in e)||hi(e.label))&&(e.kind===void 0||!(`kind`in e)||gi(e.kind))&&(e.set===void 0||!(`set`in e)||xi(e.set))&&(e.container===void 0||!(`container`in e)||_i(e.container))&&(e.attributes===void 0||!(`attributes`in e)||Si(e.attributes))&&(e.expect===void 0||!(`expect`in e)||Di(e.expect))&&(e.locations===void 0||!(`locations`in e)||Oi(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||ji(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),xi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>li[8].test(e)||!1)&&(e.label===void 0||!(`label`in e)||hi(e.label))&&(e.kind===void 0||!(`kind`in e)||gi(e.kind))&&(e.container===void 0||!(`container`in e)||_i(e.container))&&(e.attributes===void 0||!(`attributes`in e)||Si(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||Ei(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Si=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((t,n)=>li[9].test(t)||Ci(e[t]))&&Object.getOwnPropertyNames(e).every((e,t)=>typeof e!=`string`||cr(e,200)&&lr(e,1))&&Object.getOwnPropertyNames(e).length<=50),Ci=(e=>[wi(e),Ti(e),Array.isArray(e)&&e.every((e,t)=>[wi(e),Ti(e)].reduce((e,t,n)=>t===!0?++e:e,0)===1)&&e.length<=50].reduce((e,t,n)=>t===!0?++e:e,0)===1),wi=(e=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||cr(e,1e3))),Ti=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`ref`in e&&Object.getOwnPropertyNames(e).length===1&&fi(e.ref)),Ei=(e=>Array.isArray(e)&&e.every((e,t)=>_i(e))&&e.length<=50),Di=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>li[10].test(e)||!1)&&(e.label===void 0||!(`label`in e)||hi(e.label))&&(e.kind===void 0||!(`kind`in e)||gi(e.kind))&&(e.container===void 0||!(`container`in e)||_i(e.container))&&(e.revision===void 0||!(`revision`in e)||pi(e.revision))&&(e.attributes===void 0||!(`attributes`in e)||Si(e.attributes))&&Object.getOwnPropertyNames(e).length>=1),Oi=(e=>Array.isArray(e)&&e.every((e,t)=>ki(e))&&e.length<=10),ki=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`uri`in e&&Object.getOwnPropertyNames(e).every((e,t)=>li[11].test(e)||!1)&&typeof e.uri==`string`&&cr(e.uri,2e3)&&lr(e.uri,1)&&(e.revision===void 0||!(`revision`in e)||pi(e.revision))&&(e.range===void 0||!(`range`in e)||typeof e.range==`object`&&e.range!==null&&!Array.isArray(e.range)&&`startLine`in e.range&&`endLine`in e.range&&Object.getOwnPropertyNames(e.range).every((e,t)=>li[12].test(e)||!1)&&Ai(e.range.startLine)&&(e.range.startCharacter===void 0||!(`startCharacter`in e.range)||Ai(e.range.startCharacter))&&Ai(e.range.endLine)&&(e.range.endCharacter===void 0||!(`endCharacter`in e.range)||Ai(e.range.endCharacter)))),Ai=(e=>Number.isInteger(e)&&(!(Number.isFinite(e)||typeof e==`bigint`)||e<=1e6&&e>=0)),ji=(e=>Array.isArray(e)&&e.every((e,t)=>vi(e))&&e.length<=20),Mi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>li[13].test(e)||!1)&&_i(e.from)&&_i(e.to)&&(e.kind===void 0||!(`kind`in e)||gi(e.kind))&&(e.ref===void 0||!(`ref`in e)||fi(e.ref))&&(e.label===void 0||!(`label`in e)||hi(e.label))&&(e.set===void 0||!(`set`in e)||Ni(e.set))&&(e.attributes===void 0||!(`attributes`in e)||Si(e.attributes))&&(e.expect===void 0||!(`expect`in e)||Di(e.expect))&&(e.locations===void 0||!(`locations`in e)||Oi(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||ji(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`kind`in e)),Ni=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>li[14].test(e)||!1)&&(e.kind===void 0||!(`kind`in e)||gi(e.kind))&&(e.label===void 0||!(`label`in e)||hi(e.label))&&(e.attributes===void 0||!(`attributes`in e)||Si(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||Ei(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Pi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&Object.getOwnPropertyNames(e).every((e,t)=>li[15].test(e)||!1)&&_i(e.id)&&hi(e.label)&&(e.kind===void 0||!(`kind`in e)||gi(e.kind))),Fi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>li[17].test(e)||!1)&&_i(e.from)&&_i(e.to)&&(e.ref===void 0||!(`ref`in e)||fi(e.ref))&&(e.label===void 0||!(`label`in e)||hi(e.label))&&(e.set===void 0||!(`set`in e)||Ii(e.set))&&(e.attributes===void 0||!(`attributes`in e)||Si(e.attributes))&&(e.expect===void 0||!(`expect`in e)||Di(e.expect))&&(e.locations===void 0||!(`locations`in e)||Oi(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||ji(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),Ii=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>li[18].test(e)||!1)&&(e.label===void 0||!(`label`in e)||hi(e.label))&&(e.attributes===void 0||!(`attributes`in e)||Si(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||Ei(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Li=(e=>Array.isArray(e)&&e.every((e,t)=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||cr(e,1e3)))&&e.length<=50),Ri=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`cells`in e&&Object.getOwnPropertyNames(e).every((e,t)=>li[20].test(e)||!1)&&Li(e.cells)&&(e.role===void 0||!(`role`in e)||zi(e.role))&&(e.id===void 0||!(`id`in e)||_i(e.id))&&(e.ref===void 0||!(`ref`in e)||fi(e.ref))&&(e.kind===void 0||!(`kind`in e)||gi(e.kind))&&(e.label===void 0||!(`label`in e)||hi(e.label))&&(e.set===void 0||!(`set`in e)||Bi(e.set))&&(e.attributes===void 0||!(`attributes`in e)||Si(e.attributes))&&(e.expect===void 0||!(`expect`in e)||Di(e.expect))&&(e.locations===void 0||!(`locations`in e)||Oi(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||ji(e.artifacts))),zi=(e=>e===`added`||e===`changed`||e===`context`||e===`removed`),Bi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>li[21].test(e)||!1)&&(e.label===void 0||!(`label`in e)||hi(e.label))&&(e.kind===void 0||!(`kind`in e)||gi(e.kind))&&(e.cells===void 0||!(`cells`in e)||Li(e.cells))&&(e.attributes===void 0||!(`attributes`in e)||Si(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||Ei(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Vi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`heading`in e&&Object.getOwnPropertyNames(e).every((e,t)=>li[22].test(e)||!1)&&typeof e.heading==`string`&&cr(e.heading,500)&&lr(e.heading,1)&&(e.depth===void 0||!(`depth`in e)||Number.isInteger(e.depth)&&(!(Number.isFinite(e.depth)||typeof e.depth==`bigint`)||e.depth<=6&&e.depth>=1))&&(e.role===void 0||!(`role`in e)||zi(e.role))&&(e.id===void 0||!(`id`in e)||_i(e.id))&&(e.ref===void 0||!(`ref`in e)||fi(e.ref))),Hi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&`kind`in e&&Object.getOwnPropertyNames(e).every((e,t)=>li[23].test(e)||!1)&&Ui(e.from)&&Ui(e.to)&&gi(e.kind)&&(e.ref===void 0||!(`ref`in e)||fi(e.ref))&&(e.label===void 0||!(`label`in e)||hi(e.label))&&(e.attributes===void 0||!(`attributes`in e)||Si(e.attributes))),Ui=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>li[24].test(e)||!1)&&(e.id===void 0||!(`id`in e)||_i(e.id))&&(e.ref===void 0||!(`ref`in e)||fi(e.ref))&&Object.getOwnPropertyNames(e).length>=1&&Object.getOwnPropertyNames(e).length<=1&&[!(typeof e==`object`&&e&&!Array.isArray(e))||`id`in e,!(typeof e==`object`&&e&&!Array.isArray(e))||`ref`in e].reduce((e,t,n)=>t===!0?++e:e,0)===1);function Wi(e){return di(e)}ui({variables:[RegExp(`(^schema$|^kind$|^profile$|^target$|^removals$|^artifacts$|^viewpoints$|^data$)`,`u`),RegExp(`(^ref$|^revision$)`,`u`),RegExp(`(^type$|^ref$|^label$|^kind$|^from$|^to$)`,`u`),RegExp(`(^rel$|^uri$|^sha256$|^mediaType$|^label$)`,`u`),RegExp(`^sha256:[0-9a-f]{64}$`,`u`),RegExp(`(^id$|^label$|^concern$|^elementKinds$|^relationshipKinds$)`,`u`),RegExp(`(^nodes$|^edges$|^containers$)`,`u`),RegExp(`(^id$|^ref$|^label$|^kind$|^set$|^container$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^kind$|^container$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(?!)`,`u`),RegExp(`(^label$|^kind$|^container$|^revision$|^attributes$)`,`u`),RegExp(`(^uri$|^revision$|^range$)`,`u`),RegExp(`(^startLine$|^startCharacter$|^endLine$|^endCharacter$)`,`u`),RegExp(`(^from$|^to$|^kind$|^ref$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^kind$|^label$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^id$|^label$|^kind$)`,`u`),RegExp(`(^participants$|^messages$|^containers$)`,`u`),RegExp(`(^from$|^to$|^ref$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^columns$|^rows$|^relations$)`,`u`),RegExp(`(^cells$|^role$|^id$|^ref$|^kind$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^kind$|^cells$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^heading$|^depth$|^role$|^id$|^ref$)`,`u`),RegExp(`(^from$|^to$|^kind$|^ref$|^label$|^attributes$)`,`u`),RegExp(`(^id$|^ref$)`,`u`)]});var Gi=[];function Ki(e){Gi=e.variables}var qi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`schema`in e&&`kind`in e&&`data`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[0].test(e)||!1)&&e.schema===`urn:structured-exchange:3`&&(e.kind===`graph`||e.kind===`sequence`||e.kind===`table`||e.kind===`timeline`)&&(e.profile===void 0||!(`profile`in e)||typeof e.profile==`string`&&cr(e.profile,200)&&lr(e.profile,1))&&(e.target===void 0||!(`target`in e)||typeof e.target==`object`&&e.target!==null&&!Array.isArray(e.target)&&`ref`in e.target&&Object.getOwnPropertyNames(e.target).every((e,t)=>Gi[1].test(e)||!1)&&Ji(e.target.ref)&&(e.target.revision===void 0||!(`revision`in e.target)||Yi(e.target.revision)))&&(e.removals===void 0||!(`removals`in e)||Array.isArray(e.removals)&&e.removals.every((e,t)=>Xi(e))&&e.removals.length<=500)&&(e.artifacts===void 0||!(`artifacts`in e)||Array.isArray(e.artifacts)&&e.artifacts.every((e,t)=>ea(e))&&e.artifacts.length<=50)&&(e.viewpoints===void 0||!(`viewpoints`in e)||Array.isArray(e.viewpoints)&&e.viewpoints.every((e,t)=>ta(e))&&e.viewpoints.length<=20)&&[typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`nodes`in e.data&&`edges`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>Gi[6].test(e)||!1)&&Array.isArray(e.data.nodes)&&e.data.nodes.every((e,t)=>na(e))&&e.data.nodes.length<=500&&e.data.nodes.length>=1&&Array.isArray(e.data.edges)&&e.data.edges.every((e,t)=>ma(e))&&e.data.edges.length<=2e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>ga(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`participants`in e.data&&`messages`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>Gi[16].test(e)||!1)&&Array.isArray(e.data.participants)&&e.data.participants.every((e,t)=>na(e))&&e.data.participants.length<=100&&e.data.participants.length>=1&&Array.isArray(e.data.messages)&&e.data.messages.every((e,t)=>_a(e))&&e.data.messages.length<=1e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>ga(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`columns`in e.data&&`rows`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>Gi[19].test(e)||!1)&&Array.isArray(e.data.columns)&&e.data.columns.every((e,t)=>typeof e==`string`&&cr(e,200)&&lr(e,1))&&e.data.columns.length<=50&&e.data.columns.length>=1&&Array.isArray(e.data.rows)&&e.data.rows.every((e,t)=>[ya(e),ba(e),Ca(e)].reduce((e,t,n)=>t===!0?++e:e,0)===1)&&e.data.rows.length<=5e3&&(e.data.relations===void 0||!(`relations`in e.data)||Array.isArray(e.data.relations)&&e.data.relations.every((e,t)=>wa(e))&&e.data.relations.length<=2e3),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`time`in e.data&&`rows`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>Gi[25].test(e)||!1)&&(e.data.title===void 0||!(`title`in e.data)||Zi(e.data.title))&&typeof e.data.time==`object`&&e.data.time!==null&&!Array.isArray(e.data.time)&&`start`in e.data.time&&`end`in e.data.time&&`scale`in e.data.time&&Object.getOwnPropertyNames(e.data.time).length===3&&Ea(e.data.time.start)&&Ea(e.data.time.end)&&(e.data.time.scale===`week`||e.data.time.scale===`month`||e.data.time.scale===`quarter`)&&Array.isArray(e.data.rows)&&e.data.rows.every((e,t)=>Da(e))&&e.data.rows.length<=500&&(e.data.dependencies===void 0||!(`dependencies`in e.data)||Array.isArray(e.data.dependencies)&&e.data.dependencies.every((e,t)=>Pa(e))&&e.data.dependencies.length<=2e3)&&(e.data.comparedTo===void 0||!(`comparedTo`in e.data)||typeof e.data.comparedTo==`object`&&e.data.comparedTo!==null&&!Array.isArray(e.data.comparedTo)&&`label`in e.data.comparedTo&&Object.getOwnPropertyNames(e.data.comparedTo).every((e,t)=>Gi[32].test(e)||!1)&&typeof e.data.comparedTo.label==`string`&&cr(e.data.comparedTo.label,500)&&lr(e.data.comparedTo.label,1)&&(e.data.comparedTo.date===void 0||!(`date`in e.data.comparedTo)||Ea(e.data.comparedTo.date)))&&(e.data.periods===void 0||!(`periods`in e.data)||Array.isArray(e.data.periods)&&e.data.periods.every((e,t)=>Fa(e))&&e.data.periods.length<=100)&&(e.data.references===void 0||!(`references`in e.data)||Array.isArray(e.data.references)&&e.data.references.every((e,t)=>Ia(e))&&e.data.references.length<=50)].reduce((e,t,n)=>t===!0?++e:e,0)===1),Ji=(e=>typeof e==`string`&&cr(e,200)&&lr(e,1)),Yi=(e=>typeof e==`string`&&cr(e,200)&&lr(e,1)),Xi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`ref`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[2].test(e)||!1)&&(e.type===`element`||e.type===`relationship`||e.type===`row`)&&Ji(e.ref)&&(e.label===void 0||!(`label`in e)||Zi(e.label))&&(e.kind===void 0||!(`kind`in e)||Qi(e.kind))&&(e.from===void 0||!(`from`in e)||$i(e.from))&&(e.to===void 0||!(`to`in e)||$i(e.to))),Zi=(e=>typeof e==`string`&&cr(e,500)),Qi=(e=>typeof e==`string`&&cr(e,100)&&lr(e,1)),$i=(e=>typeof e==`string`&&cr(e,200)&&lr(e,1)),ea=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`rel`in e&&`uri`in e&&`sha256`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[3].test(e)||!1)&&typeof e.rel==`string`&&cr(e.rel,100)&&lr(e.rel,1)&&typeof e.uri==`string`&&cr(e.uri,2e3)&&lr(e.uri,1)&&typeof e.sha256==`string`&&Gi[4].test(e.sha256)&&(e.mediaType===void 0||!(`mediaType`in e)||typeof e.mediaType==`string`&&cr(e.mediaType,100)&&lr(e.mediaType,1))&&(e.label===void 0||!(`label`in e)||Zi(e.label))),ta=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&`concern`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[5].test(e)||!1)&&$i(e.id)&&typeof e.label==`string`&&cr(e.label,500)&&lr(e.label,1)&&typeof e.concern==`string`&&cr(e.concern,500)&&lr(e.concern,1)&&(e.elementKinds===void 0||!(`elementKinds`in e)||Array.isArray(e.elementKinds)&&e.elementKinds.every((e,t)=>Qi(e))&&e.elementKinds.length<=64&&e.elementKinds.length>=1&&new Set(e.elementKinds.map(ci)).size===e.elementKinds.length)&&(e.relationshipKinds===void 0||!(`relationshipKinds`in e)||Array.isArray(e.relationshipKinds)&&e.relationshipKinds.every((e,t)=>Qi(e))&&e.relationshipKinds.length<=64&&e.relationshipKinds.length>=1&&new Set(e.relationshipKinds.map(ci)).size===e.relationshipKinds.length)),na=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[7].test(e)||!1)&&$i(e.id)&&(e.ref===void 0||!(`ref`in e)||Ji(e.ref))&&(e.label===void 0||!(`label`in e)||Zi(e.label))&&(e.kind===void 0||!(`kind`in e)||Qi(e.kind))&&(e.set===void 0||!(`set`in e)||ra(e.set))&&(e.container===void 0||!(`container`in e)||$i(e.container))&&(e.attributes===void 0||!(`attributes`in e)||ia(e.attributes))&&(e.expect===void 0||!(`expect`in e)||la(e.expect))&&(e.locations===void 0||!(`locations`in e)||ua(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||pa(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),ra=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[8].test(e)||!1)&&(e.label===void 0||!(`label`in e)||Zi(e.label))&&(e.kind===void 0||!(`kind`in e)||Qi(e.kind))&&(e.container===void 0||!(`container`in e)||$i(e.container))&&(e.attributes===void 0||!(`attributes`in e)||ia(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||ca(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),ia=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((t,n)=>Gi[9].test(t)||aa(e[t]))&&Object.getOwnPropertyNames(e).every((e,t)=>typeof e!=`string`||cr(e,200)&&lr(e,1))&&Object.getOwnPropertyNames(e).length<=50),aa=(e=>[oa(e),sa(e),Array.isArray(e)&&e.every((e,t)=>[oa(e),sa(e)].reduce((e,t,n)=>t===!0?++e:e,0)===1)&&e.length<=50].reduce((e,t,n)=>t===!0?++e:e,0)===1),oa=(e=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||cr(e,1e3))),sa=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`ref`in e&&Object.getOwnPropertyNames(e).length===1&&Ji(e.ref)),ca=(e=>Array.isArray(e)&&e.every((e,t)=>$i(e))&&e.length<=50),la=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[10].test(e)||!1)&&(e.label===void 0||!(`label`in e)||Zi(e.label))&&(e.kind===void 0||!(`kind`in e)||Qi(e.kind))&&(e.container===void 0||!(`container`in e)||$i(e.container))&&(e.revision===void 0||!(`revision`in e)||Yi(e.revision))&&(e.attributes===void 0||!(`attributes`in e)||ia(e.attributes))&&Object.getOwnPropertyNames(e).length>=1),ua=(e=>Array.isArray(e)&&e.every((e,t)=>da(e))&&e.length<=10),da=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`uri`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[11].test(e)||!1)&&typeof e.uri==`string`&&cr(e.uri,2e3)&&lr(e.uri,1)&&(e.revision===void 0||!(`revision`in e)||Yi(e.revision))&&(e.range===void 0||!(`range`in e)||typeof e.range==`object`&&e.range!==null&&!Array.isArray(e.range)&&`startLine`in e.range&&`endLine`in e.range&&Object.getOwnPropertyNames(e.range).every((e,t)=>Gi[12].test(e)||!1)&&fa(e.range.startLine)&&(e.range.startCharacter===void 0||!(`startCharacter`in e.range)||fa(e.range.startCharacter))&&fa(e.range.endLine)&&(e.range.endCharacter===void 0||!(`endCharacter`in e.range)||fa(e.range.endCharacter)))),fa=(e=>Number.isInteger(e)&&(!(Number.isFinite(e)||typeof e==`bigint`)||e<=1e6&&e>=0)),pa=(e=>Array.isArray(e)&&e.every((e,t)=>ea(e))&&e.length<=20),ma=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[13].test(e)||!1)&&$i(e.from)&&$i(e.to)&&(e.kind===void 0||!(`kind`in e)||Qi(e.kind))&&(e.ref===void 0||!(`ref`in e)||Ji(e.ref))&&(e.label===void 0||!(`label`in e)||Zi(e.label))&&(e.set===void 0||!(`set`in e)||ha(e.set))&&(e.attributes===void 0||!(`attributes`in e)||ia(e.attributes))&&(e.expect===void 0||!(`expect`in e)||la(e.expect))&&(e.locations===void 0||!(`locations`in e)||ua(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||pa(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`kind`in e)),ha=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[14].test(e)||!1)&&(e.kind===void 0||!(`kind`in e)||Qi(e.kind))&&(e.label===void 0||!(`label`in e)||Zi(e.label))&&(e.attributes===void 0||!(`attributes`in e)||ia(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||ca(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),ga=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[15].test(e)||!1)&&$i(e.id)&&Zi(e.label)&&(e.kind===void 0||!(`kind`in e)||Qi(e.kind))),_a=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[17].test(e)||!1)&&$i(e.from)&&$i(e.to)&&(e.ref===void 0||!(`ref`in e)||Ji(e.ref))&&(e.label===void 0||!(`label`in e)||Zi(e.label))&&(e.set===void 0||!(`set`in e)||va(e.set))&&(e.attributes===void 0||!(`attributes`in e)||ia(e.attributes))&&(e.expect===void 0||!(`expect`in e)||la(e.expect))&&(e.locations===void 0||!(`locations`in e)||ua(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||pa(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),va=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[18].test(e)||!1)&&(e.label===void 0||!(`label`in e)||Zi(e.label))&&(e.attributes===void 0||!(`attributes`in e)||ia(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||ca(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),ya=(e=>Array.isArray(e)&&e.every((e,t)=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||cr(e,1e3)))&&e.length<=50),ba=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`cells`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[20].test(e)||!1)&&ya(e.cells)&&(e.role===void 0||!(`role`in e)||xa(e.role))&&(e.id===void 0||!(`id`in e)||$i(e.id))&&(e.ref===void 0||!(`ref`in e)||Ji(e.ref))&&(e.kind===void 0||!(`kind`in e)||Qi(e.kind))&&(e.label===void 0||!(`label`in e)||Zi(e.label))&&(e.set===void 0||!(`set`in e)||Sa(e.set))&&(e.attributes===void 0||!(`attributes`in e)||ia(e.attributes))&&(e.expect===void 0||!(`expect`in e)||la(e.expect))&&(e.locations===void 0||!(`locations`in e)||ua(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||pa(e.artifacts))),xa=(e=>e===`added`||e===`changed`||e===`context`||e===`removed`),Sa=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[21].test(e)||!1)&&(e.label===void 0||!(`label`in e)||Zi(e.label))&&(e.kind===void 0||!(`kind`in e)||Qi(e.kind))&&(e.cells===void 0||!(`cells`in e)||ya(e.cells))&&(e.attributes===void 0||!(`attributes`in e)||ia(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||ca(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Ca=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`heading`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[22].test(e)||!1)&&typeof e.heading==`string`&&cr(e.heading,500)&&lr(e.heading,1)&&(e.depth===void 0||!(`depth`in e)||Number.isInteger(e.depth)&&(!(Number.isFinite(e.depth)||typeof e.depth==`bigint`)||e.depth<=6&&e.depth>=1))&&(e.role===void 0||!(`role`in e)||xa(e.role))&&(e.id===void 0||!(`id`in e)||$i(e.id))&&(e.ref===void 0||!(`ref`in e)||Ji(e.ref))),wa=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&`kind`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[23].test(e)||!1)&&Ta(e.from)&&Ta(e.to)&&Qi(e.kind)&&(e.ref===void 0||!(`ref`in e)||Ji(e.ref))&&(e.label===void 0||!(`label`in e)||Zi(e.label))&&(e.attributes===void 0||!(`attributes`in e)||ia(e.attributes))),Ta=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[24].test(e)||!1)&&(e.id===void 0||!(`id`in e)||$i(e.id))&&(e.ref===void 0||!(`ref`in e)||Ji(e.ref))&&Object.getOwnPropertyNames(e).length>=1&&Object.getOwnPropertyNames(e).length<=1&&[!(typeof e==`object`&&e&&!Array.isArray(e))||`id`in e,!(typeof e==`object`&&e&&!Array.isArray(e))||`ref`in e].reduce((e,t,n)=>t===!0?++e:e,0)===1),Ea=(e=>typeof e==`string`&&Gi[26].test(e)),Da=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&(e.type===`task`||e.type===`separator`)&&(typeof e!=`object`||!e||Array.isArray(e)||e.type===void 0||!(`type`in e)||e.type===`task`?Oa(e):!0)&&(typeof e!=`object`||!e||Array.isArray(e)||e.type===void 0||!(`type`in e)||e.type===`separator`?Na(e):!0)),Oa=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`id`in e&&`label`in e&&`items`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[27].test(e)||!1)&&e.type===`task`&&$i(e.id)&&Zi(e.label)&&Array.isArray(e.items)&&e.items.every((e,t)=>ka(e))&&e.items.length<=100&&(e.role===void 0||!(`role`in e)||ja(e.role))),ka=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&(e.type===`activity`||e.type===`milestone`)&&(typeof e!=`object`||!e||Array.isArray(e)||e.type===void 0||!(`type`in e)||e.type===`activity`?Aa(e):!0)&&(typeof e!=`object`||!e||Array.isArray(e)||e.type===void 0||!(`type`in e)||e.type===`milestone`?Ma(e):!0)),Aa=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`start`in e&&`end`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[28].test(e)||!1)&&e.type===`activity`&&Ea(e.start)&&Ea(e.end)&&(e.id===void 0||!(`id`in e)||$i(e.id))&&(e.label===void 0||!(`label`in e)||Zi(e.label))&&(e.kind===void 0||!(`kind`in e)||Qi(e.kind))&&(e.previous===void 0||!(`previous`in e)||typeof e.previous==`object`&&e.previous!==null&&!Array.isArray(e.previous)&&`start`in e.previous&&`end`in e.previous&&Object.getOwnPropertyNames(e.previous).length===2&&Ea(e.previous.start)&&Ea(e.previous.end))&&(e.role===void 0||!(`role`in e)||ja(e.role))),ja=(e=>e===`added`||e===`removed`),Ma=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`date`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[29].test(e)||!1)&&e.type===`milestone`&&Ea(e.date)&&(e.id===void 0||!(`id`in e)||$i(e.id))&&(e.label===void 0||!(`label`in e)||Zi(e.label))&&(e.kind===void 0||!(`kind`in e)||Qi(e.kind))&&(e.previous===void 0||!(`previous`in e)||typeof e.previous==`object`&&e.previous!==null&&!Array.isArray(e.previous)&&`date`in e.previous&&Object.getOwnPropertyNames(e.previous).length===1&&Ea(e.previous.date))&&(e.role===void 0||!(`role`in e)||ja(e.role))),Na=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[30].test(e)||!1)&&e.type===`separator`&&(e.label===void 0||!(`label`in e)||Zi(e.label))),Pa=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[31].test(e)||!1)&&$i(e.from)&&$i(e.to)&&(e.type===void 0||!(`type`in e)||e.type===`finish-to-start`||e.type===`start-to-start`||e.type===`finish-to-finish`||e.type===`start-to-finish`)),Fa=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`start`in e&&`end`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[33].test(e)||!1)&&Ea(e.start)&&Ea(e.end)&&(e.label===void 0||!(`label`in e)||Zi(e.label))&&(e.kind===void 0||!(`kind`in e)||Qi(e.kind))),Ia=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`date`in e&&`label`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Gi[34].test(e)||!1)&&Ea(e.date)&&typeof e.label==`string`&&cr(e.label,500)&&lr(e.label,1)&&(e.kind===void 0||!(`kind`in e)||Qi(e.kind)));function La(e){return qi(e)}Ki({variables:[RegExp(`(^schema$|^kind$|^profile$|^target$|^removals$|^artifacts$|^viewpoints$|^data$)`,`u`),RegExp(`(^ref$|^revision$)`,`u`),RegExp(`(^type$|^ref$|^label$|^kind$|^from$|^to$)`,`u`),RegExp(`(^rel$|^uri$|^sha256$|^mediaType$|^label$)`,`u`),RegExp(`^sha256:[0-9a-f]{64}$`,`u`),RegExp(`(^id$|^label$|^concern$|^elementKinds$|^relationshipKinds$)`,`u`),RegExp(`(^nodes$|^edges$|^containers$)`,`u`),RegExp(`(^id$|^ref$|^label$|^kind$|^set$|^container$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^kind$|^container$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(?!)`,`u`),RegExp(`(^label$|^kind$|^container$|^revision$|^attributes$)`,`u`),RegExp(`(^uri$|^revision$|^range$)`,`u`),RegExp(`(^startLine$|^startCharacter$|^endLine$|^endCharacter$)`,`u`),RegExp(`(^from$|^to$|^kind$|^ref$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^kind$|^label$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^id$|^label$|^kind$)`,`u`),RegExp(`(^participants$|^messages$|^containers$)`,`u`),RegExp(`(^from$|^to$|^ref$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^columns$|^rows$|^relations$)`,`u`),RegExp(`(^cells$|^role$|^id$|^ref$|^kind$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^kind$|^cells$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^heading$|^depth$|^role$|^id$|^ref$)`,`u`),RegExp(`(^from$|^to$|^kind$|^ref$|^label$|^attributes$)`,`u`),RegExp(`(^id$|^ref$)`,`u`),RegExp(`(^title$|^time$|^rows$|^dependencies$|^comparedTo$|^periods$|^references$)`,`u`),RegExp(`^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$`,`u`),RegExp(`(^type$|^id$|^label$|^items$|^role$)`,`u`),RegExp(`(^type$|^start$|^end$|^id$|^label$|^kind$|^previous$|^role$)`,`u`),RegExp(`(^type$|^date$|^id$|^label$|^kind$|^previous$|^role$)`,`u`),RegExp(`(^type$|^label$)`,`u`),RegExp(`(^from$|^to$|^type$)`,`u`),RegExp(`(^label$|^date$)`,`u`),RegExp(`(^start$|^end$|^label$|^kind$)`,`u`),RegExp(`(^date$|^label$|^kind$)`,`u`)]});var Ra={[Xe]:Mr,[nt]:Wi,[at]:La},za=e=>{let t=Nn(e),n=st(t);return n===void 0&&t!==void 0?[{rule:`unsupported-version`,path:`/schema`,message:`this build validates ${ot.join(` and `)}`}]:Ra[n??`urn:structured-exchange:1`](e)?[]:[{rule:`schema/invalid`,path:``,message:`does not conform to the published structured-exchange schema`}]},Ba=Object.defineProperty,Va=(e,t,n)=>t in e?Ba(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ha=(e,t)=>{for(var n in t)Ba(e,n,{get:t[n],enumerable:!0})},Ua=(e,t,n)=>Va(e,typeof t==`symbol`?t:t+``,n),Wa={};Ha(Wa,{Graph:()=>Ao,alg:()=>ro});var Ga=Object.defineProperty,Ka=(e,t)=>{for(var n in t)Ga(e,n,{get:t[n],enumerable:!0})},qa=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e&&e.multigraph,this._isCompound=`compound`in e&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=typeof e==`function`?e:()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),r=this.successors(e);if(r)for(let e of r)n.add(e);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),(t?.length??0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i,i):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=typeof e==`function`?e:()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=Xa(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=Za(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,Ja(this._preds[a],i),Ja(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Qa(this._isDirected,e):Xa(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!=`object`||!r?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?Qa(this._isDirected,e):Xa(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Qa(this._isDirected,e):Xa(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],Ya(this._preds[t],e),Ya(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function Ja(e,t){e[t]?e[t]++:e[t]=1}function Ya(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function Xa(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function Za(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function Qa(e,t){return Xa(e,t.v,t.w,t.name)}Ka({},{read:()=>no,write:()=>$a});function $a(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:eo(e),edges:to(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function eo(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function to(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function no(e){let t=new qa(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var ro={};Ka(ro,{CycleException:()=>yo,bellmanFord:()=>ao,components:()=>so,dijkstra:()=>uo,dijkstraAll:()=>po,findCycles:()=>ho,floydWarshall:()=>_o,isAcyclic:()=>xo,postorder:()=>To,preorder:()=>Eo,prim:()=>Do,shortestPaths:()=>Oo,tarjan:()=>mo,topsort:()=>bo});var io=()=>1;function ao(e,t,n,r){return oo(e,String(t),n||io,r||function(t){return e.outEdges(t)??[]})}function oo(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=i[e.v],r=i[e.w];if(!t||!r)return;let o=n(e);t.distance+o<r.distance&&(i[e.w]={distance:t.distance+o,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w,r=n===t.v?t.w:t.v;c({v:n,w:r})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function so(e){let t={},n=[],r;function i(n){var a,o;n in t||(t[n]=!0,r.push(n),(a=e.successors(n))==null||a.forEach(i),(o=e.predecessors(n))==null||o.forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var co=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){if(this.size()===0)throw Error(`Queue underflow`);this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},lo=()=>1;function uo(e,t,n,r){return fo(e,String(t),n||lo,r||function(t){return e.outEdges(t)??[]})}function fo(e,t,n,r){let i={},a=new co,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t];if(!r)return;let c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0;){o=a.removeMin();let e=i[o];if(!e||e.distance===1/0)break;s=e,r(o).forEach(c)}return i}function po(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=uo(e,i,t,n),r},{})}function mo(e){let t=0,n=[],r={},i=[];function a(o){var s;let c=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),(s=e.successors(o))==null||s.forEach(function(e){if(e in r){let t=r[e];t!=null&&t.onStack&&(c.lowlink=Math.min(c.lowlink,t.index))}else{a(e);let t=r[e];t&&(c.lowlink=Math.min(c.lowlink,t.lowlink))}}),c.lowlink===c.index){let e=[],t;do{t=n.pop();let i=r[t];i&&(i.onStack=!1),e.push(t)}while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function ho(e){return mo(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var go=()=>1;function _o(e,t,n){return vo(e,t||go,n||function(t){return e.outEdges(t)??[]})}function vo(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){let a={};r[e]=a,a[e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(a[t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let r=n.v===e?n.w:n.v,i=t(n);a[r]={distance:i,predecessor:e}})}),i.forEach(function(e){let t=r[e];t&&i.forEach(function(n){let a=r[n];a&&i.forEach(function(n){let r=a[e],i=t[n],o=a[n];if(r&&i&&o){let e=r.distance+i.distance;e<o.distance&&(o.distance=e,o.predecessor=i.predecessor)}})})}),r}var yo=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function bo(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new yo;a in t||(n[a]=!0,t[a]=!0,(o=e.predecessors(a))==null||o.forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new yo;return r}function xo(e){try{bo(e)}catch(e){if(e instanceof yo)return!1;throw e}return!0}function So(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=Co(e,t,n===`post`,o,a,r,i)}),i}function Co(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=Co(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function wo(e,t,n){return So(e,t,n,function(e,t){return e.push(t),e},[])}function To(e,t){return wo(e,t,`post`)}function Eo(e,t){return wo(e,t,`pre`)}function Do(e,t){var n;let r=new qa,i={},a=new co,o;function s(e){let n=e.v===o?e.w:e.v,r=a.priority(n);if(r!==void 0){let s=t(e);s<r&&(i[n]=o,a.decrease(n,s))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(e){a.add(e,1/0),r.setNode(e)});let c=e.nodes()[0];c!==void 0&&a.decrease(c,0);let l=!1;for(;a.size()>0;){if(o=a.removeMin(),o in i)r.setEdge(o,i[o]);else{if(l)throw Error(`Input graph is not connected: `+e);l=!0}(n=e.nodeEdges(o))==null||n.forEach(s)}return r}function Oo(e,t,n,r){return ko(e,t,n,r??(t=>e.outEdges(t)??[]))}function ko(e,t,n,r){if(n===void 0)return uo(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=a[o];if(s===void 0)continue;let c=r(s);for(let e=0;e<c.length;e++){let t=c[e];if(!t)continue;let r=t.v===s?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return ao(e,t,n,r)}return uo(e,t,n,r)}var Ao=qa;function jo(e,t,n,r){let i=r;for(;e.hasNode(i);)i=qo(r);return n.dummy=t,e.setNode(i,n),i}function Mo(e){let t=new Ao().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function No(e){let t=new Ao({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function Po(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function Fo(e){let t=Jo(Ho(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function Io(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=Vo(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function Lo(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=Vo(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function Ro(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),jo(e,`border`,i,t)}function zo(e,t=Bo){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var Bo=65535;function Vo(e,t){return t.length>Bo?e(...zo(t).map(t=>e(...t))):e(...t)}function Ho(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return Vo(Math.max,t)}function Uo(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function Wo(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function Go(e,t){return t()}var Ko=0;function qo(e){return e+(``+ ++Ko)}function Jo(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function Yo(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Xo(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function Zo(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var Qo=`\0`;function $o(e,t,n){if(!(e&&t&&n&&t.dummy===`edge`&&n.dummy===`edge`&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let r=!0;t.edgeObj.w===n.edgeObj.w&&(r=!1);let i=r?e[t.edgeObj.v]?.rank??NaN:e[t.edgeObj.w]?.rank??NaN,a=Object.entries(e).find(e=>e[1].edgeObj?.v===t.edgeObj.v&&e[1].edgeObj?.w===t.edgeObj.w&&e[1].rank===i),o=Object.entries(e).find(e=>e[1].edgeObj?.v===n.edgeObj.v&&e[1].edgeObj?.w===n.edgeObj.w&&e[1].rank===i);if(!a||!o)return 0;let s=a[1].order??NaN,c=o[1].order??NaN;return isNaN(s-c)?0:s-c}var es=`3.1.1`,ts=class{constructor(){Ua(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return ns(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&ns(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,rs)),n=n._prev;return`[`+e.join(`, `)+`]`}};function ns(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function rs(e,t){if(e!==`_next`&&e!==`_prev`)return t}var is=ts,as=()=>1;function os(e,t){if(e.nodeCount()<=1)return[];let n=ls(e,t||as);return ss(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function ss(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)cs(e,t,n,o);for(;o=i.dequeue();)cs(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(cs(e,t,n,o,!0)||[]);break}}}return r}function cs(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,us(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,us(t,n,o)}),e.removeNode(r.v),o}function ls(e,t){let n=new Ao,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=ds(i+r+3).map(()=>new is),o=r+1;return n.nodes().forEach(e=>{us(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function us(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function ds(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function fs(e,t){(e.graph().acyclicer===`greedy`?os(e,n(e)):ps(e,t??null)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,qo(`rev`))});function n(e){return t=>e.edge(t).weight}}function ps(e,t){let n=[],r={},i={};function a(t){Object.hasOwn(i,t)||(i[t]=!0,r[t]=!0,e.outEdges(t).forEach(e=>{Object.hasOwn(r,e.w)?n.push(e):a(e.w)}),delete r[t])}function o(a){var s;Object.hasOwn(i,a)||(i[a]=!0,r[a]=!0,(s=e.outEdges(a))==null||s.forEach(i=>{Object.hasOwn(r,i.w)||t.node(a)?.rank>t.node(i.w)?.rank&&hs(e,i.w,i)?n.push(i):o(i.w)}),delete r[a])}let s=a;return t&&typeof t.node==`function`&&(s=o),e.sources().forEach(s),e.nodes().forEach(s),n}function ms(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function hs(e,t,n){let r=new Set;function i(t){if(e.sources().includes(t))return!0;r.add(t);for(let a of e.inEdges(t)??[])if((a.v!==n.v||a.w!==n.w)&&!r.has(a.v)&&i(a.v))return!0;return!1}return i(t)}function gs(e){e.graph().dummyChains=[],e.edges().forEach(t=>_s(e,t))}function _s(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d=0;for(++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=jo(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function vs(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function ys(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=Vo(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function bs(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var xs=Ss;function Ss(e){let t=new Ao({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;Cs(t,e)<i&&(a=ws(t,e),a);)o=t.hasNode(a.v)?bs(e,a):-bs(e,a),Ts(t,e,o);return t}function Cs(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!bs(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function ws(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=bs(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function Ts(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:Es,postorder:Ds}=ro,Os=ks;ks.initLowLimValues=Ns,ks.initCutValues=As,ks.calcCutValue=Ms,ks.leaveEdge=Fs,ks.enterEdge=Is,ks.exchangeEdges=Ls;function ks(e){e=Mo(e),ys(e);let t=xs(e);Ns(t),As(t,e);let n,r;for(;n=Fs(t);)r=Is(t,e,n),Ls(t,e,n,r)}function As(e,t){let n=Ds(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>js(e,t,n))}function js(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=Ms(e,t,n)}function Ms(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,zs(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function Ns(e,t){arguments.length<2&&(t=e.nodes()[0]),Ps(e,{},1,t)}function Ps(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=Ps(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function Fs(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Is(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===Bs(e,e.node(t.v),s)&&c!==Bs(e,e.node(t.w),s)).reduce((e,n)=>bs(t,n)<bs(t,e)?n:e)}function Ls(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),Ns(e),As(e,t),Rs(e,t)}function Rs(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=Es(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function zs(e,t,n){return e.hasEdge(t,n)}function Bs(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Vs=Hs;function Hs(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:Gs(e);break;case`tight-tree`:Ws(e);break;case`longest-path`:Us(e);break;case`none`:break;default:Gs(e)}}var Us=ys;function Ws(e){ys(e),xs(e)}function Gs(e){Os(e)}var Ks=qs;function qs(e){let t=Ys(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=Js(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function Js(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function Ys(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children(Qo).forEach(r),t}function Xs(e){let t=jo(e,`root`,{},`_root`),n=Qs(e),r=Object.values(n),i=Vo(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=$s(e)+1;e.children(Qo).forEach(r=>{Zs(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function Zs(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=Ro(e,`_bt`),l=Ro(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{Zs(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function Qs(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children(Qo).forEach(e=>n(e,1)),t}function $s(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function ec(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var tc=nc;function nc(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),i&&Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)rc(e,`borderLeft`,`_bl`,n,i,t),rc(e,`borderRight`,`_br`,n,i,t)}}e.children(Qo).forEach(t)}function rc(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=jo(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function ic(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&oc(e)}function ac(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&cc(e),(t===`lr`||t===`rl`)&&(uc(e),oc(e))}function oc(e){e.nodes().forEach(t=>sc(e.node(t))),e.edges().forEach(t=>sc(e.edge(t)))}function sc(e){let t=e.width;e.width=e.height,e.height=t}function cc(e){e.nodes().forEach(t=>lc(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(lc),Object.hasOwn(r,`y`)&&lc(r)})}function lc(e){e.y=-e.y}function uc(e){e.nodes().forEach(t=>dc(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(dc),Object.hasOwn(r,`x`)&&dc(r)})}function dc(e){let t=e.x;e.x=e.y,e.y=t}function fc(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=Jo(Vo(Math.max,i)+1).map(()=>[]);function o(t){if(n[t])return;n[t]=!0;let r=e.node(t);a[r.rank].push(t);let i=e.successors(t);i&&[...i].sort((e,t)=>s(e,t)).forEach(o)}r.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(o);function s(n,r){return $o(t,e.node(n),e.node(r))}return a}function pc(e,t){let n=0;for(let r=1;r<t.length;++r)n+=mc(e,t[r-1],t[r]);return n}function mc(e,t,n){let r=Zo(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function hc(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function gc(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),_c(Object.values(n).filter(e=>!e.indegree))}function _c(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&vc(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>Yo(e,[`vs`,`i`,`barycenter`,`weight`]))}function vc(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function yc(e,t,n,r,i){let a={},o=null,s=null,c=i;typeof t==`boolean`?(c=t,a={}):t&&(a=t,o=n??null,s=r??null);let l=Uo(e,e=>Object.hasOwn(e,`barycenter`)),u=l.lhs,d=l.rhs.sort((e,t)=>t.i-e.i),f=[],p=0,m=0,h=0;u.sort(xc(s,o,!!c));for(let[e,t]of Object.entries(a)){let n=u.findIndex(t=>t.vs[0]===e);u.splice(n+1,0,t)}h=bc(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=bc(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function bc(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function xc(e,t,n){return(r,i)=>{if(r.barycenter<i.barycenter)return-1;if(r.barycenter>i.barycenter)return 1;if(e&&(typeof r.vs[0]==`string`||typeof i.vs[0]==`string`)){let n=$o(t,e.node(r.vs[0]),e.node(i.vs[0]));if(n!==0)return n}return n?i.i-r.i:r.i-i.i}}function Sc(e,t,n,r,i){var a,o;let s=null,c=i;typeof r==`boolean`?(c=r,s=null):r!==void 0&&(s=r);let l=e.children(t),u=e.node(t),d=u?u.borderLeft:void 0,f=u?u.borderRight:void 0,p={};d&&(l=l.filter(e=>e!==d&&e!==f));let m=hc(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=Sc(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&wc(t,r)}});let h=gc(m,n);Cc(h,p);let g={},_=!1;for(let t=0;t<h.length;t++)for(let n=t+1;n<h.length;n++)if(h[t]&&h[n]&&(a=h[t])!=null&&a.barycenter&&(o=h[n])!=null&&o.barycenter&&h[t]?.barycenter===h[n].barycenter){let r=h[t]?.vs[0]??``,i=h[n]?.vs[0]??``,a=e.node(r),o=e.node(i);if(a.dummy===`edge`&&o.dummy===`edge`&&a.edgeObj?.v===o.edgeObj?.v&&a.edgeObj?.w===o.edgeObj?.w){if(a.edgeLabel.reversed){g[i]=h[t],h.splice(t,1),t--;break}g[r]=h[n],h.splice(n,1),n--}else _=!0}let v=yc(h,g,s,e,c);if(d&&f){v.vs=[d,v.vs,f].flat(1);let t=e.predecessors(d);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(f),i=e.node(r[0]);Object.hasOwn(v,`barycenter`)||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+n.order+i.order)/(v.weight+2),v.weight+=2}}return Object.defineProperty(v,"result",{value:v,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(v,"usedBias",{value:_,enumerable:!1,configurable:!0,writable:!0}),v}function Cc(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function wc(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function Tc(e,t,n,r){r||=e.nodes();let i=Ec(e),a=new Ao({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function Ec(e){let t;for(;e.hasNode(t=qo(`_root`)););return t}function Dc(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function Oc(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,Oc);return}let r=Ho(e),i=kc(e,Jo(1,r+1),`inEdges`),a=kc(e,Jo(r-1,-1,-1),`outEdges`),o=fc(e,n);if(jc(e,o),t.disableOptimalOrderHeuristic)return;let s=1/0,c,l=t.constraints||[];for(let t=0,r=0;r<4;++t,++r){Ac(t%2?i:a,t%4>=2,l,n),o=Fo(e);let u=pc(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}jc(e,c)}function kc(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return Tc(e,t,n,r.get(t)||[])})}function Ac(e,t,n,r){let i=!0,a=new Ao;e.forEach(function(e){n.forEach(e=>a.setEdge(e.left,e.right));let o=e.graph().root,{result:s,usedBias:c}=Sc(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),Dc(e,a,s.vs)})}function jc(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function Mc(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=Pc(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&Fc(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function Nc(e,t){let n={};function r(t,r,i,a,o){Jo(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&Fc(n,t,i)})}})}function i(t,n){let i=-1,a=-1,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);if(t&&t.length){let s=t[0];if(s===void 0)return;a=e.node(s).order,r(n,o,c,i,a),o=c,i=a}}r(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(i),n}function Pc(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function Fc(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function Ic(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function Lc(e,t,n,r,i){let a={},o={},s={};return t.forEach(e=>{e.forEach((e,t)=>{a[e]=e,o[e]=e,s[e]=t})}),t.forEach(t=>{let c=-1,l=-1,u=!1,d=t,f=t.findIndex(t=>i?.includes(t)||Kc(t,e,i));f>0&&(d=[t[f],...t.slice(0,f),...t.slice(f+1)],u=!0),d.forEach(t=>{let d=r(t);if(d&&d.length){i!=null&&i.includes(t)&&(d=d.filter(t=>Kc(t,e,i)));let r=d.sort((e,t)=>{let n=s[e],r=s[t];return(n===void 0?0:n)-(r===void 0?0:r)}),f=(r.length-1)/2;for(let e=Math.floor(f),i=Math.ceil(f);e<=i;++e){let i=r[e];if(i===void 0)continue;let d=s[i];if(d!==void 0&&o[t]===t&&c<d&&s[i]!==l&&!Ic(n,t,i)){let e=a[i];e!==void 0&&(o[i]=t,o[t]=a[t]=e,c=d,u&&=(c=-1,l=s[i]??-1,!1))}}}})}),{root:a,align:o}}function Rc(e,t,n,r,i=!1){let a={},o=zc(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function zc(e,t,n,r){let i=new Ao,a=e.graph(),o=Wc(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function Bc(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=Gc(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function Vc(e,t){let n=Object.values(t),r=Vo(Math.min,n),i=Vo(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-Vo(Math.min,c);a!==`l`&&(l=i-Vo(Math.max,c)),l&&(e[o]=Xo(s,e=>e+l))})})}function Hc(e,t=void 0){let n=e.ul;return n?Xo(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function Uc(e,t){let n=Fo(e),r=Object.assign(Mc(e,n),Nc(e,n)),i={},a;return[`u`,`d`].forEach(o=>{a=o===`u`?n:Object.values(n).reverse(),[`l`,`r`].forEach(n=>{n===`r`&&(a=a.map(e=>Object.values(e).reverse()));let s=Lc(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=Rc(e,a,s.root,s.align,n===`r`);n===`r`&&(c=Xo(c,e=>-e)),i[o+n]=c})}),Vc(i,Bc(e,i)),Hc(i,e.graph().align)}function Wc(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2}return l&&(c+=n?l:-l),c}}function Gc(e,t){return e.node(t).width}function Kc(e,t,n){if(!n)return!1;let r=t.node(e)?.edgeObj;if(!r||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(r?.v),a=n.indexOf(r?.w);return i!==-1&&a!==-1&&i===(a+1)%n.length||i===(a-1)%n.length}function qc(e,t){e=No(e),Jc(e),Object.entries(Uc(e,t)).forEach(([t,n])=>e.node(t).x=n)}function Jc(e){let t=Fo(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);r.y=i===`top`?a+r.height/2:i===`bottom`?a+n-r.height/2:a+n/2}),a+=n+r})}var Yc=new WeakMap;function Xc(e,t={}){return Qc(e,Go,t),e}function Zc(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function Qc(e,t,n){let r=e.nodes().filter(t=>e.children(t).length),i={};r.forEach(r=>{let a=e.node(r);if(a&&a.rankdir){let o=new Ao({multigraph:!0,compound:!0});o.setGraph({rankdir:a.rankdir});let s=e.children(r);s.forEach(t=>{let n={...e.node(t)};o.setNode(t,n);let i=e.parent(t);i&&i!==r&&s.includes(i)&&o.setParent(t,i)});let c=new Set;e.edges().forEach(t=>{let n=Zc(e,t.v,r),i=Zc(e,t.w,r);if(n&&i&&n!==i){let r=`${n}\0${i}`;c.has(r)||(c.add(r),o.setEdge(n,i,{...e.edge(t)}))}}),Qc(o,t,n);let l=ll(o);$c(l,t,n,null),el(o,l);let u=1/0,d=1/0,f=-1/0,p=-1/0;o.nodes().forEach(e=>{if(e===r)return;let t=o.node(e);t&&typeof t.x==`number`&&typeof t.y==`number`&&typeof t.width==`number`&&typeof t.height==`number`&&(u=Math.min(u,t.x-t.width/2),f=Math.max(f,t.x+t.width/2),d=Math.min(d,t.y-t.height/2),p=Math.max(p,t.y+t.height/2))}),(!isFinite(u)||!isFinite(d)||!isFinite(f)||!isFinite(p))&&(u=d=0,f=p=0);let m=f-u,h=p-d;i[r]={minX:u,minY:d,maxX:f,maxY:p,width:m,height:h,offsetX:u,offsetY:d},a._dagreClusterSubgraph=o}});let a=[],o=t=>{let n=[],r=(e.children(t)||[]).filter(e=>e!==t);for(;r.length>0;){let t=r.shift();n.push(t),(e.children(t)||[]).filter(e=>e!==t).forEach(e=>r.push(e))}return n},s=new Map;r.forEach(t=>{let n=e.node(t);n&&n.rankdir&&i[t]&&s.set(t,(e.children(t)||[]).filter(e=>e!==t))});let c=new Set([...s.values()].flat()),l=new Map;s.forEach((e,t)=>{c.has(t)||l.set(t,o(t))});let u=new Set([...l.values()].flat()),d=e=>{for(let[t,n]of l)if(n.includes(e))return t;return e},f=[];e.edges().forEach(t=>{(u.has(t.v)||u.has(t.w))&&f.push({edge:t,label:e.edge(t)})});let p=new Map;u.forEach(t=>{let n=e.parent(t);p.set(t,typeof n==`string`?n:void 0)}),l.forEach((t,n)=>{let r=e.node(n),o=[];t.forEach(t=>{let n=e.node(t);n&&(o.push({id:t,node:n,parent:p.get(t)}),e.removeNode(t))});let s=f.filter(({edge:e})=>t.includes(e.v)||t.includes(e.w)),c=i[n];r&&(a.push({clusterId:n,subgraph:r._dagreClusterSubgraph,bounds:c,children:t,removedNodes:o,removedEdges:s}),r.width=c.width,r.height=c.height)});let m=new Set;f.forEach(({edge:t,label:n})=>{let r=d(t.v),i=d(t.w);if(r!==i&&e.hasNode(r)&&e.hasNode(i)){let t=`${r}\0${i}`;m.has(t)||(m.add(t),e.setEdge(r,i,{...n,width:0,height:0}))}});let h=ll(e),g=$c(h,t,n,Yc.get(e)??null);Yc.set(e,g),el(e,h),m.forEach(t=>{let n=t.indexOf(`\0`),r=t.slice(0,n),i=t.slice(n+1);e.hasEdge(r,i)&&e.removeEdge(r,i)}),a.forEach(({clusterId:t,subgraph:n,bounds:r,removedNodes:i,removedEdges:a})=>{let o=e.node(t),s=o?.x??0,c=o?.y??0,l=(r.minX+r.maxX)/2,u=(r.minY+r.maxY)/2;i.forEach(({id:t,node:n,parent:r})=>{e.setNode(t,n),r!==void 0&&e.setParent(t,r)}),a.forEach(({edge:t,label:n})=>{e.setEdge(t,n)}),n.nodes().forEach(r=>{if(r===t)return;let i=n.node(r),a=e.node(r);a&&i&&typeof i.x==`number`&&typeof i.y==`number`&&(a.x=s+(i.x-l),a.y=c+(i.y-u))}),delete o._dagreClusterSubgraph}),r.forEach(t=>{let n=e.node(t),r=i[t];if(n&&n.rankdir&&n._dagreClusterSubgraph&&r){let i=n._dagreClusterSubgraph,a=n.x??0,o=n.y??0,s=(r.minX+r.maxX)/2,c=(r.minY+r.maxY)/2;i.nodes().forEach(n=>{if(n===t)return;let r=i.node(n),l=e.node(n);if(l&&r&&typeof r.x==`number`&&typeof r.y==`number`){let e=r.x-s,t=r.y-c;l.x=a+e,l.y=o+t}}),delete n._dagreClusterSubgraph}})}function $c(e,t,n,r=null){var i,a;let o=n?.useDynamic!==!1,s=o&&(i=r?.graph)!=null?i:null,c=o&&(a=r?.rawNodes)!=null?a:null;t(` makeSpaceForEdgeLabels`,()=>ul(e)),t(` removeSelfEdges`,()=>yl(e)),t(` acyclic`,()=>fs(e,s)),t(` nestingGraph.run`,()=>Xs(e)),t(` rank`,()=>Vs(No(e))),t(` injectEdgeLabelProxies`,()=>dl(e)),t(` removeEmptyRanks`,()=>Lo(e)),t(` nestingGraph.cleanup`,()=>ec(e)),t(` normalizeRanks`,()=>Io(e)),t(` assignRankMinMax`,()=>fl(e)),t(` removeEdgeLabelProxies`,()=>pl(e)),t(` normalize.run`,()=>gs(e)),t(` parentDummyChains`,()=>Ks(e)),t(` addBorderSegments`,()=>tc(e)),t(` order`,()=>Oc(e,n,c)),t(` insertSelfEdges`,()=>bl(e)),t(` adjustCoordinateSystem`,()=>ic(e)),t(` position`,()=>qc(e,n.corePath)),t(` positionSelfEdges`,()=>xl(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>vl(e)),t(` normalize.undo`,()=>vs(e)),t(` fixupEdgeLabelCoords`,()=>gl(e)),t(` undoCoordinateSystem`,()=>ac(e)),t(` translateGraph`,()=>ml(e)),t(` assignNodeIntersects`,()=>hl(e)),t(` reversePoints`,()=>_l(e)),t(` acyclic.undo`,()=>ms(e)),{graph:e,rawNodes:l}}function el(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var tl=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],nl={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},rl=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],il=[`width`,`height`,`rank`],al={width:0,height:0},ol=[`minlen`,`weight`,`width`,`height`,`labeloffset`],sl={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},cl=[`labelpos`];function ll(e){let t=new Ao({multigraph:!0,compound:!0}),n=Cl(e.graph());return t.setGraph(Object.assign({},nl,Sl(n,tl),Yo(n,rl))),e.nodes().forEach(n=>{let r=Sl(Cl(e.node(n)),il);Object.keys(al).forEach(e=>{r[e]===void 0&&(r[e]=al[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=Cl(e.edge(n));t.setEdge(n,Object.assign({},sl,Sl(r,ol),Yo(r,cl)))}),t}function ul(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,(r.labelpos??`r`).toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function dl(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);jo(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function fl(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function pl(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function ml(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function hl(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(Po(r,a)),n.points.push(Po(i,o))})}function gl(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset}})}function _l(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function vl(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function yl(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function bl(e){Fo(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);typeof i.rank!=`number`&&(i.rank=0),i.order=r+n,(i.selfEdges||[]).forEach(t=>{jo(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,edgeLabel:t.label},`_se`),(!Array.isArray(t.label.points)||t.label.points.length!==7)&&(t.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function xl(e){e.nodes().forEach(t=>{let n=e.node(t),r=e=>typeof e==`number`&&isFinite(e);if(n.dummy===`selfedge`){let i=n,a=e.node(i.e.v),o=r(a?.x)?a.x:0,s=r(a?.y)?a.y:0,c=r(a?.width)?a.width:0,l=r(a?.height)?a.height:0,u=r(n.x)?n.x:o,d=r(n.y)?n.y:s,f=c/2,p=l/2;i.edgeLabel.points=[{x:u+f,y:d-p},{x:u+f,y:d-p},{x:u,y:d},{x:u-f,y:d+p},{x:u-f,y:d+p},{x:u,y:d},{x:u,y:d}],i.edgeLabel.x=u,i.edgeLabel.y=d,e.setEdge(i.e,i.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(e=>{if(!Array.isArray(e.label.points)||e.label.points.length!==7){let t=r(n.x)?n.x:0,i=r(n.y)?n.y:0,a=r(n.width)?n.width:0,o=r(n.height)?n.height:0,s=a/2,c=o/2;e.label.points=[{x:t+s,y:i-c},{x:t+s,y:i-c},{x:t,y:i},{x:t-s,y:i+c},{x:t-s,y:i+c},{x:t,y:i},{x:t,y:i}]}})})}function Sl(e,t){return Xo(Yo(e,t),Number)}function Cl(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}function wl(e){let t=Fo(e),n=new Ao({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{n.setNode(t,{label:t}),n.setParent(t,`layer`+e.node(t).rank)}),e.edges().forEach(e=>n.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{let r=`layer`+t;n.setNode(r,{rank:`same`}),e.reduce((e,t)=>(n.setEdge(e,t,{style:`invis`}),t))}),n}var Tl={graphlib:Wa,version:es,layout:Xc,debug:wl,util:{time:Wo,notime:Go}};function El(e,t){return t?e.ref===void 0?`added`:e.set===void 0?`context`:`changed`:`unchanged`}function Dl(e,t){if(t&&e.heading===void 0)return e.ref===void 0?`added`:e.set===void 0?`context`:`changed`}function Ol(e,t){return t?e.ref===void 0?`added`:e.set===void 0?`context`:`changed`:`unchanged`}function kl(e){let t=e.set;if(t===void 0)return[];let n=e;return Object.entries(t).filter(([e])=>e!==`attributes`&&e!==`removeAttributes`).map(([e,t])=>{let r=n[e];return{field:e,...typeof r==`string`?{from:r}:{},to:String(t)}})}var Al={added:`added`,changed:`changed`,context:`existing`,unchanged:``},jl={added:`added`,changed:`changed`,context:`existing`,removed:`removed`},Ml=[`added`,`changed`,`context`,`removed`];function Nl(e){return e.rows.some(e=>et(e).role!==void 0)}function Pl(e,t){if(t)return et(e).role??`context`}function Fl(e){if(e.length===0)return;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x+e.width)),i=Math.max(...e.map(e=>e.y+e.height));return{x:t-zl,y:n-zl-Bl,width:r-t+zl*2,height:i-n+zl*2+Bl}}var Il=64,Ll=24,Rl=12,zl=10,Bl=16,Vl=16,Hl=160,Ul=52;function Wl(e,t,n=`landscape`){let r=new Tl.graphlib.Graph({compound:!0,multigraph:!0});r.setGraph({rankdir:n===`portrait`?`TB`:`LR`,ranksep:Il,nodesep:Ll,marginx:Rl,marginy:Rl}),r.setDefaultEdgeLabel(()=>({}));for(let n of e.nodes)r.setNode(n.id,t(n));let i=e.containers??[],a=new Map;for(let t of e.nodes)t.container!==void 0&&i.some(e=>e.id===t.container)&&(r.setNode(t.container,{label:t.container}),r.setParent(t.id,t.container),a.set(t.container,[...a.get(t.container)??[],t.id]));e.edges.forEach((e,t)=>{e.from!==e.to&&r.hasNode(e.from)&&r.hasNode(e.to)&&r.setEdge(e.from,e.to,{},String(t))}),Tl.layout(r);let o=e.nodes.map(e=>{let n=r.node(e.id),{width:i,height:a}=t(e);return{id:e.id,x:(n?.x??Rl+i/2)-i/2,y:(n?.y??Rl+a/2)-a/2,width:i,height:a}}),s=[];e.edges.forEach((e,t)=>{if(e.from===e.to)return;let n=r.edge(e.from,e.to,String(t));n?.points!==void 0&&n.points.length>0&&s.push({index:t,points:n.points.map(e=>({x:e.x,y:e.y}))})});let c=[],l=o.reduce((e,t)=>Math.max(e,t.y+t.height),Rl)+Vl,u=new Map(o.map(e=>[e.id,e]));for(let e of i){let t=Fl((a.get(e.id)??[]).flatMap(e=>{let t=u.get(e);return t===void 0?[]:[t]}));t===void 0?(c.push({id:e.id,label:e.label,x:Rl,y:l,width:Hl,height:Ul}),l+=68):c.push({id:e.id,label:e.label,...t})}let d=[...o.map(e=>({x:e.x,y:e.y,width:e.width,height:e.height})),...c],f=Math.min(0,...d.map(e=>e.x))-Rl,p=Math.min(0,...d.map(e=>e.y))-Rl;if(f<0||p<0){for(let e of o)e.x-=f,e.y-=p;for(let e of c)e.x-=f,e.y-=p;for(let e of s)for(let t of e.points)t.x-=f,t.y-=p}let m=[...o.map(e=>({x:e.x,y:e.y,width:e.width,height:e.height})),...c].reduce((e,t)=>({width:Math.max(e.width,t.x+t.width),height:Math.max(e.height,t.y+t.height)}),{width:0,height:0});return{nodes:o,edges:s,containers:c,width:m.width+Rl,height:m.height+Rl}}var Gl={attributes:[],expectations:[],assignments:[],removedAttributes:[],locations:[],artifacts:[]};function Kl(e){if(typeof e!=`object`||!e)return Gl;let t=e,n=e=>typeof e==`object`&&e&&!Array.isArray(e)?Object.entries(e):[],r=t.set,i=r?.removeAttributes;return{attributes:n(t.attributes),expectations:n(t.expect?.attributes),assignments:n(r?.attributes),removedAttributes:Array.isArray(i)?i.filter(e=>typeof e==`string`):[],locations:Array.isArray(t.locations)?t.locations:[],artifacts:Array.isArray(t.artifacts)?t.artifacts:[]}}function ql(e){let t=e.target;if(typeof t==`string`)return{ref:t};if(typeof t!=`object`||!t)return;let n=t;if(typeof n.ref==`string`)return{ref:n.ref,...typeof n.revision==`string`?{revision:n.revision}:{}}}function Jl(e,t){let n=(e.removals??[]).map(e=>({type:e.type,ref:e.ref})),r=e.profile,i=e.artifacts,a={...typeof r==`string`?{profile:r}:{},...(()=>{let t=ql(e);return t===void 0?{}:{target:t}})(),artifacts:Array.isArray(i)?i:[]};if(e.kind===`table`){let r=e.data,i=Nl(r),o=r.rows.map(e=>{let n=Array.isArray(e)?{}:e,r=(Array.isArray(e)?void 0:e.role)??Dl({ref:typeof n.ref==`string`?n.ref:void 0,set:n.set,heading:typeof n.heading==`string`?n.heading:void 0},t)??Pl(e,i),{cells:a,heading:o}=et(e),s=Array.isArray(e)?{}:e;return{cells:a,...r===void 0?{}:{role:r},...o===void 0?{}:{heading:o},...typeof s.depth==`number`?{depth:s.depth}:{},...typeof s.id==`string`?{id:s.id}:{},...typeof s.ref==`string`?{ref:s.ref}:{},...typeof s.kind==`string`?{kind:s.kind}:{},changes:kl(s),...Kl(e)}}),s=new Map;for(let e of o){if(e.id===void 0)continue;let t=e.cells.find(e=>typeof e==`string`&&e!==``);s.set(e.id,(typeof t==`string`?t:void 0)??e.ref??e.id)}let c=r.relations,l=(Array.isArray(c)?c:[]).map(e=>{let t=e,n=e=>{let t=typeof e?.id==`string`?e.id:void 0,n=typeof e?.ref==`string`?e.ref:void 0;return{id:t,ref:n,label:(t===void 0?void 0:s.get(t))??n??t??``}},r=n(t.from),i=n(t.to);return{kind:t.kind??``,...typeof t.label==`string`?{label:t.label}:{},...r.id===void 0?{}:{fromRow:r.id},...i.id===void 0?{}:{toRow:i.id},...r.ref===void 0?{}:{fromRef:r.ref},...i.ref===void 0?{}:{toRef:i.ref},fromLabel:r.label,toLabel:i.label}});return{thingNoun:`column`,linkNoun:`row`,things:[],links:[],columns:r.columns,rows:o,containers:[],removals:n,traces:l,...a}}if(e.kind===`timeline`)return{thingNoun:`task`,linkNoun:`dependency`,things:[],links:[],containers:[],removals:n,traces:[],...a};let o=e.kind===`graph`,s=o?e.data.nodes:e.data.participants,c=o?e.data.edges:e.data.messages,l=new Map(s.map(e=>[e.id,Yl(e)]));return{thingNoun:o?`element`:`participant`,linkNoun:o?`relationship`:`message`,things:s.map(e=>({id:e.id,label:Yl(e),kind:e.kind,role:El(e,t),changes:kl(e),container:e.container,...Kl(e)})),links:c.map(e=>({from:e.from,to:e.to,fromLabel:l.get(e.from)??e.from,toLabel:l.get(e.to)??e.to,label:e.label,kind:`kind`in e?e.kind:void 0,role:Ol(e,t),changes:kl(e),isLoop:e.from===e.to,...Kl(e)})),containers:e.data.containers??[],removals:n,traces:[],...a}}function Yl(e){return e.label??e.ref??e.id}function Xl(e){if(e.kind===`graph`){let t=e.data,n=[`flowchart TD`],r=t.containers??[],i=new Set(r.map(e=>e.id)),a=e=>t.nodes.filter(t=>t.container===e);for(let e of r){n.push(` subgraph ${Zl(e.id)}["${$l(e.label)}"]`);for(let t of a(e.id))n.push(` ${Zl(t.id)}["${$l(Yl(t))}"]`);n.push(` end`)}for(let e of t.nodes)e.container!==void 0&&i.has(e.container)||n.push(` ${Zl(e.id)}["${$l(Yl(e))}"]`);for(let e of t.edges){let t=e.label??e.kind,r=t===void 0?`-->`:`-- "${$l(t)}" -->`;n.push(` ${Zl(e.from)} ${r} ${Zl(e.to)}`)}return n.join(`
|
|
23
23
|
`)}if(e.kind===`sequence`){let t=e.data,n=[`sequenceDiagram`],r=t.containers??[],i=new Set(r.map(e=>e.id)),a=(e,t)=>`${t}participant ${Zl(e.id)} as "${$l(Yl(e))}"`;for(let e of r){n.push(` box ${$l(e.label)}`);for(let r of t.participants.filter(t=>t.container===e.id))n.push(a(r,` `));n.push(` end`)}for(let e of t.participants)e.container!==void 0&&i.has(e.container)||n.push(a(e,` `));for(let e of t.messages)n.push(` ${Zl(e.from)}->>${Zl(e.to)}: ${$l(e.label??``)}`);return n.join(`
|
|
@@ -641,7 +641,7 @@ div.mxRubberband { position: absolute; overflow: hidden; border: 1px solid #29b6
|
|
|
641
641
|
`:``}${e}`};for(let e of t)e.kind===`path`?fR(n,e.data)||r(`@${e.data}`):e.kind===`text`&&r(`\`\`\`${e.name}\n${e.data}\n\`\`\``);return n}function hR(e){return{name:e,kind:`path`,data:e,mimeType:`text/plain`,source:`manual`}}function gR(e,t){return e.some(e=>e.kind===`path`&&e.data===t)?e:[...e,hR(t)]}function _R(e,t){return e.filter((e,n)=>n!==t)}function vR(e,t){if(!t)return!1;let n=e.composedPath();if(n.length>0)return n.includes(t);let r=e.target;return r!==null&&t.contains(r)}function yR(e){let t=(0,d.useRef)(null);return(0,d.useEffect)(()=>{function n(n){t.current&&!vR(n,t.current)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}var bR=100,xR=new Intl.Collator(void 0,{sensitivity:`base`,numeric:!0}),SR={extension:`ext`,prompt:`prompt`,skill:`skill`};function CR(e){return e===`directory`||e===`symlink-directory`}function wR(e,t){let n=e.slice(0,t),r=/(?:^|\s)@([^\s@]*)$/.exec(n);return r?{start:t-r[1].length-1,query:r[1]}:null}function TR({isStreaming:e,connected:t,commands:n,fileSearch:r,prefill:i,attachments:a,pendingUploads:o=[],onAttach:s,onMentionPaths:c,onRemoveAttachment:l,onSend:u,onAbort:f,onSearchFiles:p,onClearFileSearch:m,initialDraft:h,onDraftChange:g}){let[_,v]=(0,d.useState)(h??``);(0,d.useEffect)(()=>{g?.(_)},[_,g]);let[y,b]=(0,d.useState)(0),[x,S]=(0,d.useState)(0),[C,w]=(0,d.useState)(!1),T=(0,d.useRef)(null),ee=(0,d.useRef)(null),E=(0,d.useRef)(null),D=(0,d.useRef)(null),te=(0,d.useRef)(null);(0,d.useEffect)(()=>{i&&v(i.text)},[i?.nonce]),(0,d.useEffect)(()=>{te.current!==null&&(E.current?.focus(),E.current?.setSelectionRange(te.current,te.current),te.current=null)},[_]),(0,d.useLayoutEffect)(()=>{let e=E.current;if(!e)return;let t=-1,n=()=>{t=e.offsetWidth,e.style.overflowY=`hidden`,e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`,e.scrollHeight>e.clientHeight&&(e.style.overflowY=`auto`)};n();let r=typeof ResizeObserver>`u`?void 0:new ResizeObserver(()=>{e.offsetWidth!==t&&n()});return r?.observe(e,{box:`border-box`}),()=>r?.disconnect()},[_]);let ne=(0,d.useMemo)(()=>pR(_),[_]);(0,d.useEffect)(()=>{c(ne)},[ne.join(`
|
|
642
642
|
`)]);let re=(0,d.useMemo)(()=>{let e=/^\/(\S*)$/.exec(_);return e?e[1].toLowerCase():null},[_]),ie=(0,d.useMemo)(()=>re===null?[]:n.filter(e=>e.name.toLowerCase().includes(re)).sort((e,t)=>{let n=e.name.toLowerCase().startsWith(re);return n===t.name.toLowerCase().startsWith(re)?xR.compare(e.name,t.name):n?-1:1}).slice(0,bR),[re,n]),O=re===null?wR(_,y):null;(0,d.useEffect)(()=>{if(!O||O.query.length===0){m();return}let e=window.setTimeout(()=>p(O.query),150);return()=>clearTimeout(e)},[O?.query]);let ae=(0,d.useMemo)(()=>{if(ie.length>0)return{kind:`command`,items:ie};let e=O&&r?.query===O.query?r.results:[];return e.length>0?{kind:`file`,items:e}:null},[ie,O,r]),k=ae!==null&&!C,oe=re===null?O?`file:${O.query}`:null:`cmd:${re}`;(0,d.useEffect)(()=>{S(0)},[oe]),(0,d.useEffect)(()=>{w(!1)},[re===null?O?`file`:null:`command`]),(0,d.useEffect)(()=>{if(!k)return;let e=e=>{vR(e,T.current)||w(!0)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[k]),(0,d.useEffect)(()=>{ee.current?.querySelector(`[data-selected="true"]`)?.scrollIntoView({block:`nearest`})},[x]);let se=o.length>0,[ce,le]=(0,d.useState)(!1);(0,d.useEffect)(()=>{se||le(!1)},[se]);function ue(){if(se){le(!0);return}let e=mR(_,a),t=a.filter(e=>e.kind===`image`).map(e=>({data:e.data,mimeType:e.mimeType})),n=a.every(e=>e.kind===`path`);(_.trim()||!n&&e||t.length!==0)&&(u(e,t.length>0?t:void 0),v(``),m())}function de(e){let t=`/${e.name} `;v(t),te.current=t.length,b(t.length)}function fe(e){if(!O)return;let t=_.slice(0,O.start),n=_.slice(y),r=`@${e.path}${CR(e.type)?`/`:` `}`,i=`${t}${r}${n}`;v(i),m();let a=t.length+r.length;te.current=a,b(a)}function j(){if(ae){if(ae.kind===`command`){let e=ae.items[x];e&&de(e)}else{let e=ae.items[x];e&&fe(e)}}}function pe(e){if(k&&ae){if(e.key===`ArrowDown`){e.preventDefault(),S(e=>(e+1)%ae.items.length);return}if(e.key===`ArrowUp`){e.preventDefault(),S(e=>(e-1+ae.items.length)%ae.items.length);return}if(e.key===`Tab`||e.key===`Enter`){e.preventDefault(),j();return}if(e.key===`Escape`){e.preventDefault(),w(!0);return}}e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),ue())}function me(e){b(e.currentTarget.selectionStart??0)}function he(e){let t=Array.from(e.clipboardData.files);t.length>0&&(e.preventDefault(),s(t))}return(0,A.jsxs)(`div`,{ref:T,className:`relative`,children:[(a.length>0||se)&&(0,A.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[o.map(e=>(0,A.jsxs)(`span`,{"data-pending-upload":e.name,title:`${e.name} — copying into the workspace`,className:`flex items-center gap-1.5 rounded-md border border-dashed border-zinc-300 bg-zinc-50 py-1 pl-1.5 pr-2 text-xs text-zinc-500 dark:border-zinc-600 dark:bg-zinc-800/40 dark:text-zinc-400`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:`animate-pulse`,children:`⏳`}),(0,A.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,A.jsx)(`span`,{className:`sr-only`,children:`uploading`})]},e.id)),ce&&(0,A.jsx)(`span`,{role:`status`,className:`flex items-center py-1 text-xs text-amber-600 dark:text-amber-400`,children:`waiting for the attachment to finish uploading…`}),a.map((e,t)=>(0,A.jsxs)(`span`,{title:e.kind===`path`?`${e.name} — sent as a reference; the agent reads the file itself`:e.name,className:`flex items-center gap-1.5 rounded-md border border-zinc-200 bg-zinc-50 py-1 pl-1.5 pr-1 text-xs text-zinc-600 dark:border-zinc-700 dark:bg-zinc-800/60 dark:text-zinc-300`,children:[e.kind===`image`?(0,A.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:e.name,className:`h-8 w-8 rounded object-cover`}):(0,A.jsx)(`span`,{"aria-hidden":!0,className:e.kind===`path`?`font-mono font-bold text-blue-600 dark:text-blue-400`:``,children:e.kind===`path`?`@`:`📄`}),(0,A.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>l(t),title:`remove attachment`,className:`rounded px-1 text-zinc-400 hover:bg-zinc-200 hover:text-zinc-700 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✕`})]},`${e.name}:${t}`))]}),k&&ae&&(0,A.jsx)(`div`,{ref:ee,className:`absolute bottom-full left-0 z-20 mb-2 max-h-72 w-full max-w-xl overflow-y-auto rounded-lg border border-zinc-200 bg-white py-1 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:ae.kind===`command`?ae.items.map((e,t)=>(0,A.jsxs)(`button`,{type:`button`,"data-selected":t===x,onMouseEnter:()=>S(t),onClick:()=>de(e),className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm ${t===x?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,A.jsxs)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:[`/`,e.name]}),e.argumentHint&&(0,A.jsx)(`span`,{className:`font-mono text-xs text-zinc-500`,children:e.argumentHint}),e.description&&(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-zinc-500`,children:e.description}),(0,A.jsx)(`span`,{className:`ml-auto shrink-0 rounded bg-zinc-200 px-1 text-[10px] uppercase text-zinc-500 dark:bg-zinc-800`,children:SR[e.source]})]},e.name)):ae.items.map((e,t)=>(0,A.jsx)(`button`,{type:`button`,"data-selected":t===x,onMouseEnter:()=>S(t),onClick:()=>fe(e),className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm ${t===x?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:(0,A.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-zinc-800 dark:text-zinc-200`,children:[e.path,CR(e.type)?`/`:``]})},e.path))}),(0,A.jsxs)(`div`,{className:`flex items-end gap-2 rounded-xl border border-zinc-200 bg-zinc-50 p-2 focus-within:border-zinc-400 dark:border-zinc-800 dark:bg-zinc-900 dark:focus-within:border-zinc-600`,children:[(0,A.jsx)(`textarea`,{ref:E,value:_,onChange:e=>{v(e.target.value),b(e.target.selectionStart??e.target.value.length)},onKeyDown:pe,onClick:me,onKeyUp:me,onPaste:he,placeholder:t?e?`steer the agent… (Enter to send)`:`message pi… (/ for commands, @ for files, Enter to send, Shift+Enter for newline)`:`connecting…`,disabled:!t,rows:1,className:`max-h-[min(40vh,20rem)] flex-1 resize-none overflow-y-hidden bg-transparent px-2 py-1.5 text-[15px] outline-none placeholder:text-zinc-400 disabled:opacity-50 dark:placeholder:text-zinc-600`}),e&&(0,A.jsx)(`button`,{type:`button`,onClick:f,title:`stop`,"aria-label":`Stop the agent`,className:`rounded-lg bg-red-100 p-2 text-red-700 hover:bg-red-200 dark:bg-red-900/60 dark:text-red-200 dark:hover:bg-red-900`,children:(0,A.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,className:`h-4 w-4`,children:(0,A.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>D.current?.click(),disabled:!t,title:`attach files`,"aria-label":`Attach files`,className:`rounded-lg p-2 text-zinc-500 hover:bg-zinc-200 hover:text-zinc-700 disabled:opacity-30 dark:text-zinc-400 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:(0,A.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,A.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`})})}),(0,A.jsx)(`input`,{ref:D,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&s(Array.from(e.target.files)),e.target.value=``}}),(0,A.jsx)(`button`,{type:`button`,onClick:ue,disabled:!t||se||!_.trim()&&a.length===0,title:se?`waiting for an attachment to finish uploading`:e?`steer`:`send`,"aria-label":e?`Steer the agent`:`Send message`,className:`rounded-lg bg-zinc-900 p-2 text-zinc-100 hover:bg-zinc-800 disabled:opacity-30 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,children:e?(0,A.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:[(0,A.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,A.jsx)(`path`,{strokeLinecap:`round`,d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`}),(0,A.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]}):(0,A.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,A.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M6 12 3.27 3.13c6.6 1.9 12.83 4.9 18.43 8.87-5.6 3.97-11.83 6.97-18.43 8.87L6 12Zm0 0h7.5`})})})]})]})}var ER=`rounded-md border px-3 py-1.5 text-sm border-zinc-200 hover:bg-zinc-100 dark:border-zinc-800 dark:hover:bg-zinc-800`,DR=`rounded-md bg-zinc-900 px-3 py-1.5 text-sm text-zinc-100 hover:bg-zinc-800 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,OR=`w-full rounded-md border border-zinc-300 bg-white px-2 py-1.5 text-sm outline-none focus:border-zinc-500 dark:border-zinc-700 dark:bg-zinc-950 dark:focus:border-zinc-500`,kR=`mb-4 ${OR}`,AR=`1,3`,jR=` — `;function MR(e){let t=e.indexOf(`
|
|
643
643
|
`);return t===-1?{heading:e,body:``}:{heading:e.slice(0,t),body:e.slice(t+1).trim()}}function NR(e){let t=/^(\d+)\.\s+(\S[\s\S]*)$/.exec(e.trim());if(!t)return null;let n=t[2],r=n.indexOf(jR);return{index:Number(t[1]),label:r===-1?n:n.slice(0,r),description:r===-1?``:n.slice(r+3)}}function PR(e){if(e.method!==`input`||e.placeholder!==AR)return null;let{heading:t,body:n}=MR(e.title),r=[];for(let e of n.split(`
|
|
644
|
-
`)){let t=NR(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function FR({request:e,onRespond:t}){let[n,r]=(0,d.useState)(e.method===`editor`?e.prefill??``:``),[i,a]=(0,d.useState)([]),[o,s]=(0,d.useState)(!1),c=(e.method===`select`||e.method===`confirm`||e.method===`input`)&&e.timeout,[l,u]=(0,d.useState)(c?Math.ceil(c/1e3):null),f=PR(e),{heading:p,body:m}=MR(e.title);function h(){t({id:e.id,cancelled:!0})}function g(e){a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e].sort((e,t)=>e-t))}function _(){let r=n.trim();t({id:e.id,value:r.length>0?r:i.join(`,`)})}return(0,d.useEffect)(()=>{if(!o)return;let e=setTimeout(()=>s(!1),400);return()=>clearTimeout(e)},[o]),(0,d.useEffect)(()=>{if(l===null)return;if(l<=0){t({id:e.id,cancelled:!0});return}let n=setTimeout(()=>u(e=>e===null?null:e-1),1e3);return()=>clearTimeout(n)},[l,e.id,t]),(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:()=>s(!0),children:(0,A.jsxs)(`div`,{className:`w-full ${m?`max-w-2xl`:`max-w-md`} rounded-xl border bg-white p-4 shadow-2xl transition-shadow dark:bg-zinc-900 ${o?`border-zinc-400 ring-2 ring-zinc-400/60 dark:border-zinc-500 dark:ring-zinc-500/60`:`border-zinc-200 dark:border-zinc-700`}`,onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`mb-3 flex items-start gap-3`,children:[(0,A.jsx)(`h2`,{className:`flex-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:p}),(0,A.jsx)(`button`,{type:`button`,onClick:h,"aria-label":`Refuse to answer`,title:`Refuse to answer`,className:`-mr-1 -mt-1 rounded-md px-1.5 py-0.5 text-sm leading-none text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`✕`})]}),m&&!f&&(0,A.jsx)(`pre`,{className:`mb-3 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-zinc-50 p-2 font-mono text-xs text-zinc-600 dark:bg-zinc-950 dark:text-zinc-400`,children:m}),e.method===`select`&&(0,A.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>{let r=NR(n);return(0,A.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${ER}`,children:r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:r.label}),r.description&&(0,A.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:r.description})]}):n},n)})}),e.method===`confirm`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:ER,children:`No`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:DR,children:`Yes`})]})]}),f&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`mb-3 flex flex-col gap-1`,children:f.options.map(e=>(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:i.includes(e.index),onChange:()=>g(e.index),className:`mt-0.5`}),(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,A.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,A.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`…or type your own answer`,onKeyDown:e=>{e.key===`Enter`&&_(),e.key===`Escape`&&h()},className:`mb-1 ${OR}`}),(0,A.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:h,className:ER,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,onClick:_,className:DR,children:`OK`})]})]}),e.method===`input`&&!f&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`input`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),placeholder:e.placeholder,onKeyDown:r=>{r.key===`Enter`&&t({id:e.id,value:n}),r.key===`Escape`&&h()},className:kR}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:h,className:ER,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:DR,children:`OK`})]})]}),e.method===`editor`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`textarea`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&h()},className:`resize-none font-mono ${kR}`}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:h,className:ER,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:DR,children:`OK`})]})]}),l!==null&&(0,A.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,l,`s`]})]})})}var IR={info:`border-blue-300 bg-blue-50 text-blue-800 dark:border-blue-900 dark:bg-blue-950/60 dark:text-blue-200`,warning:`border-amber-300 bg-amber-50 text-amber-800 dark:border-amber-900 dark:bg-amber-950/60 dark:text-amber-200`,error:`border-red-300 bg-red-50 text-red-800 dark:border-red-900 dark:bg-red-950/60 dark:text-red-200`},LR=6e3;function RR({notification:e,onDismiss:t}){let n=(0,d.useRef)(t);return(0,d.useEffect)(()=>{n.current=t}),(0,d.useEffect)(()=>{let e=setTimeout(()=>n.current(),LR);return()=>clearTimeout(e)},[e.id]),(0,A.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-lg border px-3 py-2 text-sm shadow-lg ${IR[e.notifyType??`info`]}`,children:[(0,A.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Dismiss notification`,onClick:()=>n.current(),className:`-mr-1 shrink-0 rounded px-1 leading-5 opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100`,children:`×`})]})}function zR({notifications:e,onDismiss:t}){return e.length===0?null:(0,A.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,A.jsx)(RR,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var BR={30:`#3f3f46`,31:`#dc2626`,32:`#16a34a`,33:`#ca8a04`,34:`#2563eb`,35:`#9333ea`,36:`#0891b2`,37:`#71717a`,90:`#a1a1aa`,91:`#ef4444`,92:`#22c55e`,93:`#eab308`,94:`#3b82f6`,95:`#a855f7`,96:`#06b6d4`,97:`#d4d4d8`},VR=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function HR(e,t){let n={...e};for(let e=0;e<t.length;e++){let r=t[e];if(r===0)for(let e of Object.keys(n))delete n[e];else if(r===1)n.bold=!0;else if(r===2)n.dim=!0;else if(r===3)n.italic=!0;else if(r===4)n.underline=!0;else if(r===22)delete n.bold,delete n.dim;else if(r===23)delete n.italic;else if(r===24)delete n.underline;else if(r===39)delete n.color;else if(BR[r]!==void 0)n.color=BR[r];else if(r===38){if(t[e+1]===2){let[r,i,a]=[t[e+2],t[e+3],t[e+4]];[r,i,a].every(e=>Number.isFinite(e))&&(n.color=`rgb(${r} ${i} ${a})`),e+=4}else t[e+1]===5&&(e+=2)}}return n}function UR(e){let t=[],n={},r=0;VR.lastIndex=0;for(let i=VR.exec(e);i!==null;i=VR.exec(e)){i.index>r&&t.push({text:e.slice(r,i.index),...n}),r=i.index+i[0].length;let a=i[0];if(a.endsWith(`m`)){let e=a.slice(2,-1),t=e===``?[0]:e.split(/[;:]/).map(e=>e===``?0:Number(e));n=HR(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function WR(e){return e.replace(VR,``)}function GR({line:e}){let t=UR(e);return(0,A.jsx)(A.Fragment,{children:t.map((e,t)=>(0,A.jsx)(`span`,{style:{...e.color?{color:e.color}:{},...e.bold?{fontWeight:600}:{},...e.dim?{opacity:.7}:{},...e.italic?{fontStyle:`italic`}:{},...e.underline?{textDecoration:`underline`}:{}},children:e.text},t))})}function KR({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,A.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,A.jsx)(`div`,{className:`whitespace-pre-wrap rounded-md border border-zinc-200 bg-zinc-50 px-3 py-1.5 font-mono text-xs text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:t.lines.map((e,t)=>(0,A.jsx)(`div`,{children:(0,A.jsx)(GR,{line:e})},t))},e))})}var qR=null,JR=null;function YR(){return JR??=he(()=>import(`./CodeEditor-DPHOc6pa.js`).then(e=>e.t).then(e=>qR=e,e=>{throw JR=null,e}),__vite__mapDeps([22,1,23])),JR}var XR=(0,d.lazy)(()=>{if(qR!==null){let e=qR;return{then:t=>t({default:e.CodeEditor})}}return YR().then(e=>({default:e.CodeEditor}))});function ZR({text:e,path:t,serverUrl:n,token:r,workspace:i,template:a}){let[o,s]=(0,d.useState)(`idle`),[c,l]=(0,d.useState)(`plain`),[u,f]=(0,d.useState)(null),p=(0,d.useRef)(!1),m=(0,d.useRef)({plain:0,template:0});async function h(a){if(!(p.current||Date.now()-m.current[a]<750)){p.current=!0,m.current[a]=Date.now(),l(a),s(`working`),f(null);try{let{downloadDocx:o,downloadDocxInTemplate:c}=await he(async()=>{let{downloadDocx:e,downloadDocxInTemplate:t}=await import(`./docxExport-Q_d-8cuv.js`);return{downloadDocx:e,downloadDocxInTemplate:t}},__vite__mapDeps([24,21,1,25])),l=typeof e==`function`?e():e;await(a===`template`?c:o)(l,t,{serverUrl:n,token:r,workspace:i}),s(`idle`)}catch(e){s(`failed`),f(e instanceof Error?e.message:String(e))}finally{p.current=!1}}}let g=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 disabled:opacity-50 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,_=(e,t)=>o===`working`&&c===e?`… exporting`:o===`failed`&&c===e?`⚠ export failed`:t,v=(e,t)=>o===`failed`&&c===e?`Could not export: ${u??`unknown reason`}`:t;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>void h(`plain`),disabled:o===`working`,title:v(`plain`,`Download as a Word document`),"aria-label":`Download as a Word document`,className:g,children:_(`plain`,`⤓ word`)}),a!==void 0&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>void h(`template`),disabled:o===`working`,title:v(`template`,`Download as a Word document in the template ${a}`),"aria-label":`Download as a Word document in the template ${a}`,className:g,children:_(`template`,`⤓ word · template`)})]})}var QR=`pi-outpost:open`,$R=4,ez={css:`text/css`,js:`text/javascript`,mjs:`text/javascript`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,avif:`image/avif`,svg:`image/svg+xml`,ico:`image/x-icon`,bmp:`image/bmp`,woff:`font/woff`,woff2:`font/woff2`,ttf:`font/ttf`,otf:`font/otf`,mp4:`video/mp4`,webm:`video/webm`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`},tz=`(function () {
|
|
644
|
+
`)){let t=NR(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function FR({request:e,onRespond:t}){let[n,r]=(0,d.useState)(e.method===`editor`?e.prefill??``:``),[i,a]=(0,d.useState)([]),[o,s]=(0,d.useState)(!1),c=(e.method===`select`||e.method===`confirm`||e.method===`input`)&&e.timeout,[l,u]=(0,d.useState)(c?Math.ceil(c/1e3):null),f=PR(e),{heading:p,body:m}=MR(e.title);function h(){t({id:e.id,cancelled:!0})}function g(e){a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e].sort((e,t)=>e-t))}function _(){let r=n.trim();t({id:e.id,value:r.length>0?r:i.join(`,`)})}return(0,d.useEffect)(()=>{if(!o)return;let e=setTimeout(()=>s(!1),400);return()=>clearTimeout(e)},[o]),(0,d.useEffect)(()=>{if(l===null)return;if(l<=0){t({id:e.id,cancelled:!0});return}let n=setTimeout(()=>u(e=>e===null?null:e-1),1e3);return()=>clearTimeout(n)},[l,e.id,t]),(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:()=>s(!0),children:(0,A.jsxs)(`div`,{className:`w-full ${m?`max-w-2xl`:`max-w-md`} rounded-xl border bg-white p-4 shadow-2xl transition-shadow dark:bg-zinc-900 ${o?`border-zinc-400 ring-2 ring-zinc-400/60 dark:border-zinc-500 dark:ring-zinc-500/60`:`border-zinc-200 dark:border-zinc-700`}`,onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`mb-3 flex items-start gap-3`,children:[(0,A.jsx)(`h2`,{className:`flex-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:p}),(0,A.jsx)(`button`,{type:`button`,onClick:h,"aria-label":`Refuse to answer`,title:`Refuse to answer`,className:`-mr-1 -mt-1 rounded-md px-1.5 py-0.5 text-sm leading-none text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`✕`})]}),m&&!f&&(0,A.jsx)(`pre`,{className:`mb-3 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-zinc-50 p-2 font-mono text-xs text-zinc-600 dark:bg-zinc-950 dark:text-zinc-400`,children:m}),e.method===`select`&&(0,A.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>{let r=NR(n);return(0,A.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${ER}`,children:r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:r.label}),r.description&&(0,A.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:r.description})]}):n},n)})}),e.method===`confirm`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:ER,children:`No`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:DR,children:`Yes`})]})]}),f&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`mb-3 flex flex-col gap-1`,children:f.options.map(e=>(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:i.includes(e.index),onChange:()=>g(e.index),className:`mt-0.5`}),(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,A.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,A.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`…or type your own answer`,onKeyDown:e=>{e.key===`Enter`&&_(),e.key===`Escape`&&h()},className:`mb-1 ${OR}`}),(0,A.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:h,className:ER,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,onClick:_,className:DR,children:`OK`})]})]}),e.method===`input`&&!f&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`input`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),placeholder:e.placeholder,onKeyDown:r=>{r.key===`Enter`&&t({id:e.id,value:n}),r.key===`Escape`&&h()},className:kR}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:h,className:ER,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:DR,children:`OK`})]})]}),e.method===`editor`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`textarea`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&h()},className:`resize-none font-mono ${kR}`}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:h,className:ER,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:DR,children:`OK`})]})]}),l!==null&&(0,A.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,l,`s`]})]})})}var IR={info:`border-blue-300 bg-blue-50 text-blue-800 dark:border-blue-900 dark:bg-blue-950/60 dark:text-blue-200`,warning:`border-amber-300 bg-amber-50 text-amber-800 dark:border-amber-900 dark:bg-amber-950/60 dark:text-amber-200`,error:`border-red-300 bg-red-50 text-red-800 dark:border-red-900 dark:bg-red-950/60 dark:text-red-200`},LR=6e3;function RR({notification:e,onDismiss:t}){let n=(0,d.useRef)(t);return(0,d.useEffect)(()=>{n.current=t}),(0,d.useEffect)(()=>{let e=setTimeout(()=>n.current(),LR);return()=>clearTimeout(e)},[e.id]),(0,A.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-lg border px-3 py-2 text-sm shadow-lg ${IR[e.notifyType??`info`]}`,children:[(0,A.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Dismiss notification`,onClick:()=>n.current(),className:`-mr-1 shrink-0 rounded px-1 leading-5 opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100`,children:`×`})]})}function zR({notifications:e,onDismiss:t}){return e.length===0?null:(0,A.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,A.jsx)(RR,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var BR={30:`#3f3f46`,31:`#dc2626`,32:`#16a34a`,33:`#ca8a04`,34:`#2563eb`,35:`#9333ea`,36:`#0891b2`,37:`#71717a`,90:`#a1a1aa`,91:`#ef4444`,92:`#22c55e`,93:`#eab308`,94:`#3b82f6`,95:`#a855f7`,96:`#06b6d4`,97:`#d4d4d8`},VR=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function HR(e,t){let n={...e};for(let e=0;e<t.length;e++){let r=t[e];if(r===0)for(let e of Object.keys(n))delete n[e];else if(r===1)n.bold=!0;else if(r===2)n.dim=!0;else if(r===3)n.italic=!0;else if(r===4)n.underline=!0;else if(r===22)delete n.bold,delete n.dim;else if(r===23)delete n.italic;else if(r===24)delete n.underline;else if(r===39)delete n.color;else if(BR[r]!==void 0)n.color=BR[r];else if(r===38){if(t[e+1]===2){let[r,i,a]=[t[e+2],t[e+3],t[e+4]];[r,i,a].every(e=>Number.isFinite(e))&&(n.color=`rgb(${r} ${i} ${a})`),e+=4}else t[e+1]===5&&(e+=2)}}return n}function UR(e){let t=[],n={},r=0;VR.lastIndex=0;for(let i=VR.exec(e);i!==null;i=VR.exec(e)){i.index>r&&t.push({text:e.slice(r,i.index),...n}),r=i.index+i[0].length;let a=i[0];if(a.endsWith(`m`)){let e=a.slice(2,-1),t=e===``?[0]:e.split(/[;:]/).map(e=>e===``?0:Number(e));n=HR(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function WR(e){return e.replace(VR,``)}function GR({text:e}){let t=UR(e);return(0,A.jsx)(A.Fragment,{children:t.map((e,t)=>(0,A.jsx)(`span`,{style:{...e.color?{color:e.color}:{},...e.bold?{fontWeight:600}:{},...e.dim?{opacity:.7}:{},...e.italic?{fontStyle:`italic`}:{},...e.underline?{textDecoration:`underline`}:{}},children:e.text},t))})}function KR({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,A.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,A.jsx)(`div`,{className:`whitespace-pre-wrap rounded-md border border-zinc-200 bg-zinc-50 px-3 py-1.5 font-mono text-xs text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:t.lines.map((e,t)=>(0,A.jsx)(`div`,{children:(0,A.jsx)(GR,{text:e})},t))},e))})}var qR=null,JR=null;function YR(){return JR??=he(()=>import(`./CodeEditor-cHm1xd4h.js`).then(e=>e.t).then(e=>qR=e,e=>{throw JR=null,e}),__vite__mapDeps([22,1,23])),JR}var XR=(0,d.lazy)(()=>{if(qR!==null){let e=qR;return{then:t=>t({default:e.CodeEditor})}}return YR().then(e=>({default:e.CodeEditor}))});function ZR({text:e,path:t,serverUrl:n,token:r,workspace:i,template:a}){let[o,s]=(0,d.useState)(`idle`),[c,l]=(0,d.useState)(`plain`),[u,f]=(0,d.useState)(null),p=(0,d.useRef)(!1),m=(0,d.useRef)({plain:0,template:0});async function h(a){if(!(p.current||Date.now()-m.current[a]<750)){p.current=!0,m.current[a]=Date.now(),l(a),s(`working`),f(null);try{let{downloadDocx:o,downloadDocxInTemplate:c}=await he(async()=>{let{downloadDocx:e,downloadDocxInTemplate:t}=await import(`./docxExport-CVaLmrkL.js`);return{downloadDocx:e,downloadDocxInTemplate:t}},__vite__mapDeps([24,21,1,25])),l=typeof e==`function`?e():e;await(a===`template`?c:o)(l,t,{serverUrl:n,token:r,workspace:i}),s(`idle`)}catch(e){s(`failed`),f(e instanceof Error?e.message:String(e))}finally{p.current=!1}}}let g=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 disabled:opacity-50 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,_=(e,t)=>o===`working`&&c===e?`… exporting`:o===`failed`&&c===e?`⚠ export failed`:t,v=(e,t)=>o===`failed`&&c===e?`Could not export: ${u??`unknown reason`}`:t;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>void h(`plain`),disabled:o===`working`,title:v(`plain`,`Download as a Word document`),"aria-label":`Download as a Word document`,className:g,children:_(`plain`,`⤓ word`)}),a!==void 0&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>void h(`template`),disabled:o===`working`,title:v(`template`,`Download as a Word document in the template ${a}`),"aria-label":`Download as a Word document in the template ${a}`,className:g,children:_(`template`,`⤓ word · template`)})]})}var QR=`pi-outpost:open`,$R=4,ez={css:`text/css`,js:`text/javascript`,mjs:`text/javascript`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,avif:`image/avif`,svg:`image/svg+xml`,ico:`image/x-icon`,bmp:`image/bmp`,woff:`font/woff`,woff2:`font/woff2`,ttf:`font/ttf`,otf:`font/otf`,mp4:`video/mp4`,webm:`video/webm`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`},tz=`(function () {
|
|
645
645
|
document.addEventListener("click", function (event) {
|
|
646
646
|
var link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
|
|
647
647
|
if (!link || event.defaultPrevented) return;
|
|
@@ -668,7 +668,7 @@ div.mxRubberband { position: absolute; overflow: hidden; border: 1px solid #29b6
|
|
|
668
668
|
event.preventDefault();
|
|
669
669
|
parent.postMessage({ type: "${QR}", href: href }, "*");
|
|
670
670
|
}, true);
|
|
671
|
-
})();`;function nz(e){if(e==null)return!1;let t=e.trim();return t!==``&&!t.startsWith(`#`)&&!ne(t)}function rz(e,t){return ez[e.split(`.`).pop()?.toLowerCase()??``]??t}function iz(e,t){return new Promise((n,r)=>{let i=new FileReader;i.onload=()=>n(String(i.result).replace(/^data:[^;,]*/,`data:${t}`)),i.onerror=()=>r(i.error),i.readAsDataURL(e)})}async function az(e,t,n){let r=new DOMParser().parseFromString(e,`text/html`),i=new Map,a=e=>{let t=i.get(e);return t===void 0&&(t=n(e).catch(()=>void 0),i.set(e,t)),t},o=async e=>(await a(e))?.text(),s=async e=>{let t=await a(e);return t===void 0?void 0:iz(t,rz(e,t.type||`application/octet-stream`))},c=async(e,t,n=0)=>{let r=[...e.matchAll(/@import\s+(?:url\(\s*(['"]?)([^'")]+)\1\s*\)|(['"])([^'"]+)\3)[^;]*;/gi)];for(let i of r){let r=i[2]??i[4];if(!nz(r)||n>=$R)continue;let a=re(t,r),s=await o(a);s!==void 0&&(e=e.replace(i[0],await c(s,a,n+1)))}let i=/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi,a=new Map;for(let n of new Set([...e.matchAll(i)].map(e=>e[2]))){if(!nz(n))continue;let e=await s(re(t,n));e!==void 0&&a.set(n,e)}return e.replace(i,(e,t,n)=>a.has(n)?`url("${a.get(n)}")`:e)},l=Array.from(r.querySelectorAll(`style`));for(let e of Array.from(r.querySelectorAll(`link[href]`))){let n=(e.getAttribute(`rel`)??``).toLowerCase().split(/\s+/),i=e.getAttribute(`href`);if(!nz(i))continue;let a=re(t,i);if(n.includes(`stylesheet`)){let t=await o(a);if(t===void 0)continue;let n=r.createElement(`style`),i=e.getAttribute(`media`);i!==null&&n.setAttribute(`media`,i),n.textContent=await c(t,a),e.replaceWith(n)}else if(n.includes(`icon`)){let t=await s(a);t!==void 0&&e.setAttribute(`href`,t)}}for(let e of l)e.textContent=await c(e.textContent??``,t);for(let e of Array.from(r.querySelectorAll(`[style]`)))e.setAttribute(`style`,await c(e.getAttribute(`style`)??``,t));for(let e of Array.from(r.querySelectorAll(`script[src]`))){let n=e.getAttribute(`src`);if(!nz(n))continue;let r=await o(re(t,n));r!==void 0&&(e.removeAttribute(`src`),e.textContent=r.replace(/<\/script/gi,`<\\/script`))}for(let[e,n]of[[`img`,`src`],[`source`,`src`],[`video`,`src`],[`video`,`poster`],[`audio`,`src`],[`track`,`src`],[`input`,`src`],[`image`,`href`],[`image`,`xlink:href`],[`use`,`href`]])for(let i of Array.from(r.getElementsByTagName(e))){let e=i.getAttribute(n);if(!nz(e))continue;let r=await s(re(t,e));r!==void 0&&i.setAttribute(n,r)}for(let e of Array.from(r.querySelectorAll(`img[srcset], source[srcset]`))){let n=(e.getAttribute(`srcset`)??``).split(`,`).map(e=>e.trim()).filter(Boolean),r=[];for(let e of n){let[n,...i]=e.split(/\s+/),a=nz(n)?await s(re(t,n)):void 0;r.push([a??n,...i].join(` `))}e.setAttribute(`srcset`,r.join(`, `))}let u=r.createElement(`script`);return u.textContent=tz,r.head.prepend(u),`<!doctype html>\n${r.documentElement.outerHTML}`}var oz=`allow-scripts allow-popups allow-popups-to-escape-sandbox`;function sz({source:e,path:t,load:n,onOpen:r}){let i=(0,d.useRef)(null),[a,o]=(0,d.useState)(null);return(0,d.useEffect)(()=>{let r=!0;return az(e,t,n).then(e=>{r&&o(e)},()=>{r&&o(e)}),()=>{r=!1}},[e,t,n]),(0,d.useEffect)(()=>{function e(e){if(i.current===null||e.source!==i.current.contentWindow)return;let n=e.data;typeof n==`object`&&n&&n.type===`pi-outpost:open`&&typeof n.href==`string`&&r(re(t,n.href))}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[t,r]),a===null?(0,A.jsx)(`div`,{className:`p-4 text-sm text-zinc-500`,"data-testid":`html-page-loading`,children:`Loading…`}):(0,A.jsx)(`iframe`,{ref:i,title:t,"data-testid":`html-page`,sandbox:oz,srcDoc:a,className:`h-full min-h-[24rem] w-full border-0 bg-white`})}function cz({query:e,onQueryChange:t,matchCount:n,truncated:r=!1,currentIndex:i,searching:a=!1,onNext:o,onPrev:s,onClose:c,inputRef:l}){let u=(0,d.useRef)(null),f=l??u;(0,d.useEffect)(()=>{f.current?.focus(),f.current?.select()},[]);let p=n===0?a?`searching…`:`0/0`:`${i+1}/${n}${r?`+`:``}`;return(0,A.jsxs)(`div`,{role:`search`,"aria-label":`Find in file`,className:`flex items-center gap-2 border-b border-zinc-200 bg-zinc-50 px-3 py-1.5 text-xs dark:border-zinc-800 dark:bg-zinc-900`,children:[(0,A.jsx)(`input`,{ref:f,type:`text`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.shiftKey?s():o()):e.key===`Escape`&&(e.stopPropagation(),c())},placeholder:`Find in file`,"aria-label":`Find`,className:`min-w-0 flex-1 rounded border border-zinc-300 bg-white px-2 py-1 text-xs text-zinc-700 outline-none focus-visible:ring-1 focus-visible:ring-zinc-400 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-200`}),(0,A.jsx)(`span`,{className:`shrink-0 tabular-nums text-zinc-500 dark:text-zinc-400`,children:p}),(0,A.jsx)(`button`,{type:`button`,onClick:s,disabled:n===0,"aria-label":`Previous match`,title:`Previous match (Shift+Enter)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 disabled:opacity-40 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`‹`}),(0,A.jsx)(`button`,{type:`button`,onClick:o,disabled:n===0,"aria-label":`Next match`,title:`Next match (Enter)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 disabled:opacity-40 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`›`}),(0,A.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`Close find bar`,title:`Close (Esc)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`✕`})]})}var lz=3e3;function uz(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function dz(e,t,n=1/0){if(t===``)return[];let r=new RegExp(uz(t),`gi`),i=[],a;for(;(a=r.exec(e))!==null&&(i.push({start:a.index,end:a.index+a[0].length}),!(i.length>=n)););return i}function fz(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[],r=``;for(let e=t.nextNode();e!==null;e=t.nextNode()){let t=e.data.length;t!==0&&(n.push({node:e,start:r.length,end:r.length+t}),r+=e.data)}return{nodes:n,text:r}}function pz(e,t,n=lz){let r={matches:[],truncated:!1,clear:()=>{}};if(t===``)return r;let{nodes:i,text:a}=fz(e);if(a===``)return r;let o=dz(a,t,n+1),s=o.length>n,c=s?o.slice(0,n):o;if(c.length===0)return{matches:[],truncated:s,clear:()=>{}};let l=Array(c.length);for(let e=c.length-1;e>=0;e--){let{start:t,end:n}=c[e],r=[];for(let e of i){if(e.end<=t||e.start>=n)continue;let i=Math.max(0,t-e.start),a=Math.min(e.node.data.length,n-e.start);if(i>=a)continue;let o=e.node;a<o.data.length&&o.splitText(a);let s=i>0?o.splitText(i):o,c=document.createElement(`mark`);c.className=`find-match`,s.replaceWith(c),c.appendChild(s),r.push(c)}l[e]={marks:r}}return{matches:l,truncated:s,clear:()=>{for(let{marks:e}of l)for(let t of e)t.replaceWith(document.createTextNode(t.textContent??``));e.normalize()}}}var mz=(0,d.lazy)(()=>he(()=>import(`./PdfViewer-R_n_5p2t.js`),[])),hz=250,gz=`(min-width: 768px)`;function _z(){let[e,t]=(0,d.useState)(()=>window.matchMedia?.(gz).matches??!0);return(0,d.useEffect)(()=>{let e=window.matchMedia?.(gz);if(e===void 0)return;let n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function vz(e,t){let[n,r]=(0,d.useState)(e);return(0,d.useEffect)(()=>{let n=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(n)},[e,t]),n}function yz(e){let t=vu(e);return t.status===`valid`?t.envelope:void 0}var bz=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`;function xz(e){return/\.(md|markdown)$/i.test(e)}var Sz=O;function Cz(e){return/\.html?$/i.test(e)}function wz(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function Tz({file:e,writableRoot:t,isStreaming:n,onDirtyChange:r,gitState:i,initialShowGitDiff:a=!1,gitDiff:o,gitBaseline:s=null,onFetchGitDiff:c,onClearGitDiff:l,inRepository:u,onOpenGitHistory:f,onClose:p,onReload:m,onSave:h,serverUrl:g=``,token:_=null,workspace:v,docxTemplate:y,onImageLoad:b,onPdfLoad:x,rawRevision:C=0,onOpenNative:w}){let[T,ee]=(0,d.useState)(`rendered`),[D,te]=(0,d.useState)(null),[ne,O]=(0,d.useState)(a),[k,se]=(0,d.useState)(e.status===`loaded`&&e.justCreated?{draft:e.content,baseContent:e.content,baseMtimeMs:e.mtimeMs}:null),[ce,le]=(0,d.useState)(`idle`),de=(0,d.useRef)(null),fe=(0,d.useRef)(null),j=e.status===`loaded`?e:null,pe=j!==null&&xz(e.path),me=j!==null&&Cz(e.path),he=j!==null&&Sz(e.path),ge=ie(e.path),_e=ae(e.path),ve=(0,d.useMemo)(()=>j===null?void 0:vu(j.content),[j?.content]),ye=ve?.status===`valid`,be=ve?.status===`valid`||ve?.status===`invalid`,Se=be||pe||me||he,Ce=T===`source`,we=_z(),Te=wz(e.path,t)&&!_e,Ee=j!==null&&!ge&&!_e;(0,d.useEffect)(()=>{Ee&&YR().catch(()=>{})},[Ee]);let De=k!==null&&k.draft!==k.baseContent,[Oe,ke]=(0,d.useState)(!1),Ae=De||Oe,je=j?.pendingSave!==void 0,Me=k!==null&&j!==null&&j.mtimeMs!==k.baseMtimeMs,Ne=j?.saveError?.conflict===!0||Me,Pe=k?.draft??j?.content??``,Fe=vz(Pe,hz),Ie=(0,d.useMemo)(()=>j===null?void 0:vu(Fe),[Fe,j===null]),[Le,Re]=(0,d.useState)(()=>e.status===`loaded`?yz(e.content):void 0);(0,d.useEffect)(()=>{Ie?.status===`valid`&&Re(Ie.envelope)},[Ie]);let ze=Ie!==void 0&&Ie.status!==`valid`&&Le!==void 0,Be=Ie?.status===`invalid`?Fe===j?.content&&j.documentIssues!==void 0?j.documentIssues:Ie.issues:void 0,Ve=Ie?.status===`not-a-document`?Ie.why===`unparseable`?`This is not parseable JSON yet.`:"This no longer declares a structured-exchange `schema`.":Ie?.status===`unsupported-version`?`This declares ${Ie.schema}, which this version does not render.`:void 0,He=T===`split`&&Se&&!ne&&j!==null&&we,Ue=ne?void 0:He?be?Le:void 0:k===null&&!Ce&&ve?.status===`valid`?ve.envelope:void 0,Ge=(0,d.useRef)(null),Ke=k!==null,Je=j!==null&&k===null&&!He&&!ne&&(!pe||Ce)&&(!ye||Ce)&&(!me||Ce)&&(!he||Ce),Ye=ne||He?`none`:_e?`pdf`:k!==null||Je?`text`:j!==null&&!ge?`dom`:`none`,[Xe,Ze]=(0,d.useState)(!1),[Qe,$e]=(0,d.useState)(``),[et,tt]=(0,d.useState)(0),nt=(0,d.useRef)(null),rt=(0,d.useRef)(null),it=(0,d.useRef)(null),[at,ot]=(0,d.useState)({matchCount:0,currentIndex:-1,searching:!1}),[st,ct]=(0,d.useState)([]),[lt,ut]=(0,d.useState)(!1),dt=(0,d.useRef)(null),ft=(0,d.useRef)([]),pt=(0,d.useRef)(0),mt=(0,d.useRef)(``);function ht(e){pt.current=e;for(let[t,n]of ft.current.entries())for(let r of n.marks)r.isConnected&&r.classList.toggle(`find-match-current`,t===e);let t=ft.current[e]?.marks;t?.[0]?.isConnected&&t[0].scrollIntoView({block:`center`})}let gt=Xe?Qe:``,_t=(0,d.useMemo)(()=>Ye===`text`?dz(Pe,gt):[],[Ye,Pe,gt]);(0,d.useEffect)(()=>{Xe&&Ye===`none`&&Ze(!1)},[Xe,Ye]),(0,d.useEffect)(()=>{function e(){dt.current?.clear(),dt.current=null,ft.current=[],ct([]),ut(!1)}let t=rt.current;if(Ye!==`dom`||gt===``||t===null){e();return}dt.current?.clear();let n=pz(t,gt);dt.current=n,ft.current=n.matches,ct(n.matches),ut(n.truncated);let r=gt!==mt.current;mt.current=gt;let i=r?0:Math.min(pt.current,Math.max(n.matches.length-1,0));return tt(i),ht(i),e},[Ye,gt,T,Ce]);function vt(e,t){let n=e[t];n!==void 0&&de.current?.select(n.start,n.end)}(0,d.useEffect)(()=>{if(Ye!==`text`||!Xe)return;let e=dz(Pe,gt),t=gt!==mt.current;mt.current=gt;let n=t?0:Math.min(et,Math.max(e.length-1,0));tt(n),e.length>0&&vt(e,n)},[gt,Ye,Xe,Ke]),(0,d.useEffect)(()=>{de.current?.markMatches(Ye===`text`?_t:[],et)},[Ye,_t,et,Ke]);function yt(){Ze(!0)}function bt(){Ze(!1)}function xt(){if(Ye===`pdf`)it.current?.findNext();else if(Ye===`text`){if(_t.length===0)return;let e=(et+1)%_t.length;tt(e),vt(_t,e)}else{let e=ft.current.length;if(e===0)return;let t=(pt.current+1)%e;tt(t),ht(t)}}function St(){if(Ye===`pdf`)it.current?.findPrevious();else if(Ye===`text`){if(_t.length===0)return;let e=(et-1+_t.length)%_t.length;tt(e),vt(_t,e)}else{let e=ft.current.length;if(e===0)return;let t=(pt.current-1+e)%e;tt(t),ht(t)}}let Ct=Ye===`pdf`?{matchCount:at.matchCount,currentIndex:at.currentIndex,truncated:!1,searching:at.searching}:Ye===`text`?{matchCount:_t.length,currentIndex:_t.length>0?Math.min(et,_t.length-1):-1,truncated:!1,searching:!1}:{matchCount:st.length,currentIndex:st.length>0?Math.min(et,st.length-1):-1,truncated:lt,searching:!1},wt=k===null?null:(0,A.jsx)(d.Suspense,{fallback:(0,A.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading editor…`}),children:(0,A.jsx)(XR,{handle:de,path:e.path,value:k.draft,baseline:s,onChange:e=>se(t=>t===null?t:{...t,draft:e}),onSave:()=>{De&&!je&&!Ne&&Mt()}})},`editor`);function Tt(t){return j===null?null:(0,A.jsx)(d.Suspense,{fallback:(0,A.jsx)(`div`,{className:`p-4`,children:(0,A.jsx)(xe,{code:j.content,path:e.path})}),children:(0,A.jsx)(XR,{readOnly:!0,handle:t?de:void 0,path:e.path,value:j.content,baseline:s})},`source`)}let Et=(0,d.useCallback)(e=>fetch(oe(g,e,_,void 0,v)).then(e=>e.ok?e.blob():void 0,()=>void 0),[g,_,v]);function Dt(t){return(0,A.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,A.jsx)(Fy,{remarkPlugins:[SF,PF],rehypePlugins:[tD],components:{pre:We,a:({href:t,children:n,...r})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,A.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...r,children:n}):t.startsWith(`#`)?(0,A.jsx)(`a`,{href:t,...r,children:n}):(0,A.jsx)(`a`,{href:t,onClick:n=>{n.preventDefault(),m(re(e.path,t))},...r,children:n}),img:({src:t,alt:n,...r})=>{let i=typeof t==`string`&&t!==``&&!/^[a-z][a-z0-9+.-]*:/i.test(t)&&!t.startsWith(`//`)?oe(g,re(e.path,t),_,void 0,v):t;return(0,A.jsx)(`img`,{...r,src:i,alt:n??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:E(t)})})}function Ot(e){(T!==`split`||e===`split`||!De||window.confirm(`Discard unsaved changes?`))&&(e===T||!Oe||window.confirm(`Discard unsaved changes?`))&&(T===`split`&&e!==`split`&&se(null),te(null),ee(e))}function kt(){(!Ae||window.confirm(`Discard unsaved changes?`))&&p()}function At(){j&&(!Oe||window.confirm(`Discard unsaved changes?`))&&(Se&&T===`rendered`&&(te(`rendered`),ee(we?`split`:`source`)),se({draft:j.content,baseContent:j.content,baseMtimeMs:j.mtimeMs}))}function jt(){D===null?se(He&&j!==null?{draft:j.content,baseContent:j.content,baseMtimeMs:j.mtimeMs}:null):(se(null),ee(D),te(null))}function Mt(t=!1){j&&k!==null&&!je&&(fe.current=k.draft,h(e.path,k.draft,k.baseMtimeMs,t))}function Nt(){se(null),m(e.path)}function Pt(){let t=!ne;O(t),t?c(e.path):l()}return(0,d.useEffect)(()=>{k!==null&&j!==null&&fe.current!==null&&j.content===fe.current&&j.mtimeMs!==k.baseMtimeMs&&(fe.current=null,se({...k,baseContent:j.content,baseMtimeMs:j.mtimeMs}))},[j?.mtimeMs]),(0,d.useEffect)(()=>{function e(e){if(e.key===`Escape`)Xe?bt():kt();else if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`f`){if(Ye===`none`)return;e.preventDefault(),yt()}}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,d.useEffect)(()=>{He&&Te&&k===null&&j!==null&&se({draft:j.content,baseContent:j.content,baseMtimeMs:j.mtimeMs})},[He,Te,j?.mtimeMs]),(0,d.useEffect)(()=>{le(n?`streaming`:e=>e===`streaming`?`done`:e)},[n]),(0,d.useEffect)(()=>(r(Ae),()=>r(!1)),[Ae]),(0,d.useEffect)(()=>(a&&c(e.path),()=>l()),[]),(0,A.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[Se&&!ne&&(0,A.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,role:`group`,"aria-label":`How to show this document`,children:[[`rendered`,`⚏ rendered`,`Show the rendering`],[`split`,`⇹ split`,`Edit the file beside its rendering`],[`source`,`⌗ source`,`Show the file as written`]].map(([e,t,n])=>(0,A.jsx)(`button`,{type:`button`,onClick:()=>Ot(e),"aria-pressed":T===e,title:n,className:`rounded px-1.5 py-0.5 text-xs ${T===e?`bg-zinc-100 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-200`:`text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`}`,children:t},e))}),i!==void 0&&k===null&&(0,A.jsx)(`button`,{type:`button`,onClick:Pt,"aria-pressed":ne,title:ne?`Show file content`:`Show uncommitted changes (vs HEAD)`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs ${ne?`bg-amber-100 text-amber-800 dark:bg-amber-950/60 dark:text-amber-300`:`text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`}`,children:`± diff`}),u&&k===null&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>f(e.path),title:`Show this file's history`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:`⎇ history`}),(0,A.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:[e.path,Ae&&(0,A.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),he&&w&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>w(e.path),title:`Open with the application associated with .drawio files — draw.io desktop, where it is installed`,className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-600 hover:border-zinc-400 hover:text-zinc-900 dark:border-zinc-700 dark:text-zinc-300 dark:hover:border-zinc-500 dark:hover:text-zinc-100`,children:`↗ open in draw.io`}),j&&!ge&&!_e&&!he&&!ne&&!be&&(0,A.jsx)(ZR,{text:Pe,path:e.path,serverUrl:g,token:_,workspace:v,template:y}),Ue?.kind===`table`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(ZR,{text:()=>Ge.current?.markdown?.()??``,path:`${e.path.replace(/\.[^./]*$/,``)}.md`,serverUrl:g,token:_,workspace:v,template:y}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>Ge.current?.xlsx?.(),title:`Download as an Excel workbook`,"aria-label":`Download as an Excel workbook`,className:bz,children:`⤓ excel`})]}),(Ue?.kind===`graph`||Ue?.kind===`sequence`||Ue?.kind===`timeline`)&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>Ge.current?.svg?.(),title:`Download the figure as SVG`,"aria-label":`Download the figure as SVG`,className:bz,children:`⤓ svg`}),j&&k===null&&(0,A.jsx)(ue,{text:j.content}),j&&k===null&&!ne&&Te&&(0,A.jsx)(`button`,{type:`button`,onClick:At,className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500 dark:hover:text-zinc-200`,children:`✎ edit`}),j&&k===null&&!Te&&(0,A.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,title:`Outside the writable zone`,children:`🔒 read-only`}),k!==null&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>Mt(),disabled:!De||je||Ne,className:`shrink-0 rounded border border-emerald-300 px-2 py-0.5 text-xs text-emerald-700 hover:border-emerald-500 disabled:opacity-50 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600`,children:je?`saving…`:`save`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{(!De||window.confirm(`Discard unsaved changes?`))&&jt()},className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500`,children:De?`cancel`:`done`})]}),(0,A.jsx)(`button`,{type:`button`,onClick:kt,title:`Close (Esc)`,"aria-label":`Close file viewer`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),Xe&&Ye!==`none`&&(0,A.jsx)(cz,{inputRef:nt,query:Qe,onQueryChange:$e,matchCount:Ct.matchCount,currentIndex:Ct.currentIndex,truncated:Ct.truncated,searching:Ct.searching,onNext:xt,onPrev:St,onClose:bt}),Ne&&k!==null&&(0,A.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:[(0,A.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,A.jsx)(`button`,{type:`button`,onClick:Nt,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`reload (discard my edits)`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>Mt(!0),disabled:je,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 disabled:opacity-50 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`overwrite with my version`})]}),k!==null&&j?.saveError&&!j.saveError.conflict&&(0,A.jsx)(`div`,{className:`border-b border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:j.saveError.message}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[ne&&k===null&&(0,A.jsxs)(`div`,{className:`p-4`,children:[o?.path===e.path&&`error`in o&&(0,A.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:o.error}),o?.path===e.path&&`before`in o&&(0,A.jsx)(qe,{fill:!0,lines:S(o.before,o.after)}),o?.path!==e.path&&(0,A.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),_e&&k===null&&!ne&&(0,A.jsx)(Hf,{label:`This PDF`,children:(0,A.jsx)(d.Suspense,{fallback:(0,A.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),children:(0,A.jsx)(mz,{ref:it,path:e.path,serverUrl:g,token:_,workspace:v,revision:C,findQuery:Ye===`pdf`?gt:``,onFindStateChange:ot,...x?{onLoaded:x}:{}})})}),ge&&k===null&&!ne&&(0,A.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,A.jsx)(`img`,{src:oe(g,e.path,_,C,v),alt:e.path,onLoad:()=>b?.(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&k===null&&!ne&&!ge&&!_e&&(0,A.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!ge&&!_e&&(0,A.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),k!==null&&!He&&wt,j&&k===null&&!He&&!ne&&pe&&!Ce&&(0,A.jsx)(`div`,{ref:rt,children:Dt(j.content)}),j&&k===null&&!He&&!ne&&he&&!Ce&&(0,A.jsx)(`div`,{className:`h-full`,"data-testid":`file-drawio`,children:(0,A.jsx)(iI,{path:e.path,xml:j.content,variant:`viewer`,fallback:Tt(!1),onTouchUpDirtyChange:ke})}),j&&k===null&&!He&&!ne&&me&&!Ce&&(0,A.jsx)(`div`,{className:`h-full`,"data-testid":`file-html`,children:(0,A.jsx)(sz,{source:j.content,path:e.path,load:Et,onOpen:m})}),He&&(0,A.jsxs)(`div`,{className:`flex h-full min-h-0`,"data-testid":`file-split`,children:[(0,A.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto border-r border-zinc-200 dark:border-zinc-800`,children:wt??Tt(!1)}),(0,A.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto`,"data-testid":`file-split-rendering`,children:pe&&!be?(0,A.jsx)(`div`,{className:`prose-chat p-4 text-zinc-700 dark:text-zinc-300`,children:Dt(Fe)}):he&&!be?(0,A.jsx)(HF,{xml:Fe,serverUrl:g,title:e.path}):me&&!be?(0,A.jsx)(sz,{source:Fe,path:e.path,load:Et,onOpen:m}):(0,A.jsxs)(A.Fragment,{children:[ze&&(0,A.jsx)(`p`,{"data-testid":`file-split-stale`,className:`flex flex-wrap items-center gap-2 border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,children:(0,A.jsxs)(`span`,{children:[`Showing the document as it last stood.`,` `,Ve??`The text beside it does not satisfy the schema it declares.`]})}),Be!==void 0&&(0,A.jsxs)(`ul`,{"data-testid":`file-split-issues`,className:`space-y-0.5 border-b border-zinc-200 px-3 py-1.5 text-xs text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:[Be.slice(0,6).map((e,t)=>(0,A.jsxs)(`li`,{children:[(0,A.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),Be.length>6&&(0,A.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,Be.length-6,` more`]})]}),Le===void 0?(0,A.jsxs)(`p`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,"data-testid":`file-split-nothing`,children:[`Nothing to draw yet. `,Ve??`This document does not satisfy the schema it declares.`]}):(0,A.jsx)(Hf,{label:`This diagram`,children:(0,A.jsx)(`div`,{className:`p-4`,"data-testid":`file-structured-exchange`,children:(0,A.jsx)(zf,{envelope:Le,source:Pe,exportRef:Ge})})})]})})]}),j&&k===null&&!He&&!ne&&ye&&!Ce&&ve?.status===`valid`&&(0,A.jsx)(Hf,{label:`This diagram`,children:(0,A.jsx)(`div`,{className:`mx-auto max-w-5xl p-4`,"data-testid":`file-structured-exchange`,children:(0,A.jsx)(zf,{envelope:ve.envelope,source:j.content,exportRef:Ge})})}),j&&k===null&&!He&&!ne&&ve?.status===`invalid`&&(0,A.jsxs)(`div`,{"data-testid":`file-structured-exchange-invalid`,className:`mx-4 mt-4 rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,A.jsx)(`p`,{className:`font-medium`,children:`This declares a structured-exchange document and does not satisfy the schema.`}),(0,A.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:[(j.documentIssues??ve.issues).slice(0,8).map((e,t)=>(0,A.jsxs)(`li`,{children:[(0,A.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),(j.documentIssues??ve.issues).length>8&&(0,A.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,(j.documentIssues??ve.issues).length-8,` more`]})]})]}),j&&k===null&&!He&&!ne&&ve?.status===`unsupported-version`&&(0,A.jsxs)(`div`,{"data-testid":`file-structured-exchange-unsupported`,className:`mx-4 mt-4 rounded-lg border border-zinc-300 bg-zinc-50 px-3 py-2 text-sm text-zinc-600 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-400`,children:[`This document declares `,(0,A.jsx)(`span`,{className:`font-mono`,children:ve.schema}),`, which this version does not render. Shown as text.`]}),Je&&Tt(!0)]}),ce!==`idle`&&(0,A.jsxs)(`button`,{type:`button`,onClick:kt,"aria-live":`polite`,className:`flex items-center gap-2 border-t border-zinc-200 px-3 py-2 text-left text-sm hover:bg-zinc-50 dark:border-zinc-800 dark:hover:bg-zinc-900`,children:[ce===`streaming`?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,A.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,A.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,A.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function Ez(e){return e.split(`
|
|
671
|
+
})();`;function nz(e){if(e==null)return!1;let t=e.trim();return t!==``&&!t.startsWith(`#`)&&!ne(t)}function rz(e,t){return ez[e.split(`.`).pop()?.toLowerCase()??``]??t}function iz(e,t){return new Promise((n,r)=>{let i=new FileReader;i.onload=()=>n(String(i.result).replace(/^data:[^;,]*/,`data:${t}`)),i.onerror=()=>r(i.error),i.readAsDataURL(e)})}async function az(e,t,n){let r=new DOMParser().parseFromString(e,`text/html`),i=new Map,a=e=>{let t=i.get(e);return t===void 0&&(t=n(e).catch(()=>void 0),i.set(e,t)),t},o=async e=>(await a(e))?.text(),s=async e=>{let t=await a(e);return t===void 0?void 0:iz(t,rz(e,t.type||`application/octet-stream`))},c=async(e,t,n=0)=>{let r=[...e.matchAll(/@import\s+(?:url\(\s*(['"]?)([^'")]+)\1\s*\)|(['"])([^'"]+)\3)[^;]*;/gi)];for(let i of r){let r=i[2]??i[4];if(!nz(r)||n>=$R)continue;let a=re(t,r),s=await o(a);s!==void 0&&(e=e.replace(i[0],await c(s,a,n+1)))}let i=/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi,a=new Map;for(let n of new Set([...e.matchAll(i)].map(e=>e[2]))){if(!nz(n))continue;let e=await s(re(t,n));e!==void 0&&a.set(n,e)}return e.replace(i,(e,t,n)=>a.has(n)?`url("${a.get(n)}")`:e)},l=Array.from(r.querySelectorAll(`style`));for(let e of Array.from(r.querySelectorAll(`link[href]`))){let n=(e.getAttribute(`rel`)??``).toLowerCase().split(/\s+/),i=e.getAttribute(`href`);if(!nz(i))continue;let a=re(t,i);if(n.includes(`stylesheet`)){let t=await o(a);if(t===void 0)continue;let n=r.createElement(`style`),i=e.getAttribute(`media`);i!==null&&n.setAttribute(`media`,i),n.textContent=await c(t,a),e.replaceWith(n)}else if(n.includes(`icon`)){let t=await s(a);t!==void 0&&e.setAttribute(`href`,t)}}for(let e of l)e.textContent=await c(e.textContent??``,t);for(let e of Array.from(r.querySelectorAll(`[style]`)))e.setAttribute(`style`,await c(e.getAttribute(`style`)??``,t));for(let e of Array.from(r.querySelectorAll(`script[src]`))){let n=e.getAttribute(`src`);if(!nz(n))continue;let r=await o(re(t,n));r!==void 0&&(e.removeAttribute(`src`),e.textContent=r.replace(/<\/script/gi,`<\\/script`))}for(let[e,n]of[[`img`,`src`],[`source`,`src`],[`video`,`src`],[`video`,`poster`],[`audio`,`src`],[`track`,`src`],[`input`,`src`],[`image`,`href`],[`image`,`xlink:href`],[`use`,`href`]])for(let i of Array.from(r.getElementsByTagName(e))){let e=i.getAttribute(n);if(!nz(e))continue;let r=await s(re(t,e));r!==void 0&&i.setAttribute(n,r)}for(let e of Array.from(r.querySelectorAll(`img[srcset], source[srcset]`))){let n=(e.getAttribute(`srcset`)??``).split(`,`).map(e=>e.trim()).filter(Boolean),r=[];for(let e of n){let[n,...i]=e.split(/\s+/),a=nz(n)?await s(re(t,n)):void 0;r.push([a??n,...i].join(` `))}e.setAttribute(`srcset`,r.join(`, `))}let u=r.createElement(`script`);return u.textContent=tz,r.head.prepend(u),`<!doctype html>\n${r.documentElement.outerHTML}`}var oz=`allow-scripts allow-popups allow-popups-to-escape-sandbox`;function sz({source:e,path:t,load:n,onOpen:r}){let i=(0,d.useRef)(null),[a,o]=(0,d.useState)(null);return(0,d.useEffect)(()=>{let r=!0;return az(e,t,n).then(e=>{r&&o(e)},()=>{r&&o(e)}),()=>{r=!1}},[e,t,n]),(0,d.useEffect)(()=>{function e(e){if(i.current===null||e.source!==i.current.contentWindow)return;let n=e.data;typeof n==`object`&&n&&n.type===`pi-outpost:open`&&typeof n.href==`string`&&r(re(t,n.href))}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[t,r]),a===null?(0,A.jsx)(`div`,{className:`p-4 text-sm text-zinc-500`,"data-testid":`html-page-loading`,children:`Loading…`}):(0,A.jsx)(`iframe`,{ref:i,title:t,"data-testid":`html-page`,sandbox:oz,srcDoc:a,className:`h-full min-h-[24rem] w-full border-0 bg-white`})}function cz({query:e,onQueryChange:t,matchCount:n,truncated:r=!1,currentIndex:i,searching:a=!1,onNext:o,onPrev:s,onClose:c,inputRef:l}){let u=(0,d.useRef)(null),f=l??u;(0,d.useEffect)(()=>{f.current?.focus(),f.current?.select()},[]);let p=n===0?a?`searching…`:`0/0`:`${i+1}/${n}${r?`+`:``}`;return(0,A.jsxs)(`div`,{role:`search`,"aria-label":`Find in file`,className:`flex items-center gap-2 border-b border-zinc-200 bg-zinc-50 px-3 py-1.5 text-xs dark:border-zinc-800 dark:bg-zinc-900`,children:[(0,A.jsx)(`input`,{ref:f,type:`text`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.shiftKey?s():o()):e.key===`Escape`&&(e.stopPropagation(),c())},placeholder:`Find in file`,"aria-label":`Find`,className:`min-w-0 flex-1 rounded border border-zinc-300 bg-white px-2 py-1 text-xs text-zinc-700 outline-none focus-visible:ring-1 focus-visible:ring-zinc-400 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-200`}),(0,A.jsx)(`span`,{className:`shrink-0 tabular-nums text-zinc-500 dark:text-zinc-400`,children:p}),(0,A.jsx)(`button`,{type:`button`,onClick:s,disabled:n===0,"aria-label":`Previous match`,title:`Previous match (Shift+Enter)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 disabled:opacity-40 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`‹`}),(0,A.jsx)(`button`,{type:`button`,onClick:o,disabled:n===0,"aria-label":`Next match`,title:`Next match (Enter)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 disabled:opacity-40 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`›`}),(0,A.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`Close find bar`,title:`Close (Esc)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`✕`})]})}var lz=3e3;function uz(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function dz(e,t,n=1/0){if(t===``)return[];let r=new RegExp(uz(t),`gi`),i=[],a;for(;(a=r.exec(e))!==null&&(i.push({start:a.index,end:a.index+a[0].length}),!(i.length>=n)););return i}function fz(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[],r=``;for(let e=t.nextNode();e!==null;e=t.nextNode()){let t=e.data.length;t!==0&&(n.push({node:e,start:r.length,end:r.length+t}),r+=e.data)}return{nodes:n,text:r}}function pz(e,t,n=lz){let r={matches:[],truncated:!1,clear:()=>{}};if(t===``)return r;let{nodes:i,text:a}=fz(e);if(a===``)return r;let o=dz(a,t,n+1),s=o.length>n,c=s?o.slice(0,n):o;if(c.length===0)return{matches:[],truncated:s,clear:()=>{}};let l=Array(c.length);for(let e=c.length-1;e>=0;e--){let{start:t,end:n}=c[e],r=[];for(let e of i){if(e.end<=t||e.start>=n)continue;let i=Math.max(0,t-e.start),a=Math.min(e.node.data.length,n-e.start);if(i>=a)continue;let o=e.node;a<o.data.length&&o.splitText(a);let s=i>0?o.splitText(i):o,c=document.createElement(`mark`);c.className=`find-match`,s.replaceWith(c),c.appendChild(s),r.push(c)}l[e]={marks:r}}return{matches:l,truncated:s,clear:()=>{for(let{marks:e}of l)for(let t of e)t.replaceWith(document.createTextNode(t.textContent??``));e.normalize()}}}var mz=(0,d.lazy)(()=>he(()=>import(`./PdfViewer-CPxkOup9.js`),[])),hz=250,gz=`(min-width: 768px)`;function _z(){let[e,t]=(0,d.useState)(()=>window.matchMedia?.(gz).matches??!0);return(0,d.useEffect)(()=>{let e=window.matchMedia?.(gz);if(e===void 0)return;let n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function vz(e,t){let[n,r]=(0,d.useState)(e);return(0,d.useEffect)(()=>{let n=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(n)},[e,t]),n}function yz(e){let t=vu(e);return t.status===`valid`?t.envelope:void 0}var bz=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`;function xz(e){return/\.(md|markdown)$/i.test(e)}var Sz=O;function Cz(e){return/\.html?$/i.test(e)}function wz(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function Tz({file:e,writableRoot:t,isStreaming:n,onDirtyChange:r,gitState:i,initialShowGitDiff:a=!1,gitDiff:o,gitBaseline:s=null,onFetchGitDiff:c,onClearGitDiff:l,inRepository:u,onOpenGitHistory:f,onClose:p,onReload:m,onSave:h,serverUrl:g=``,token:_=null,workspace:v,docxTemplate:y,onImageLoad:b,onPdfLoad:x,rawRevision:C=0,onOpenNative:w}){let[T,ee]=(0,d.useState)(`rendered`),[D,te]=(0,d.useState)(null),[ne,O]=(0,d.useState)(a),[k,se]=(0,d.useState)(e.status===`loaded`&&e.justCreated?{draft:e.content,baseContent:e.content,baseMtimeMs:e.mtimeMs}:null),[ce,le]=(0,d.useState)(`idle`),de=(0,d.useRef)(null),fe=(0,d.useRef)(null),j=e.status===`loaded`?e:null,pe=j!==null&&xz(e.path),me=j!==null&&Cz(e.path),he=j!==null&&Sz(e.path),ge=ie(e.path),_e=ae(e.path),ve=(0,d.useMemo)(()=>j===null?void 0:vu(j.content),[j?.content]),ye=ve?.status===`valid`,be=ve?.status===`valid`||ve?.status===`invalid`,Se=be||pe||me||he,Ce=T===`source`,we=_z(),Te=wz(e.path,t)&&!_e,Ee=j!==null&&!ge&&!_e;(0,d.useEffect)(()=>{Ee&&YR().catch(()=>{})},[Ee]);let De=k!==null&&k.draft!==k.baseContent,[Oe,ke]=(0,d.useState)(!1),Ae=De||Oe,je=j?.pendingSave!==void 0,Me=k!==null&&j!==null&&j.mtimeMs!==k.baseMtimeMs,Ne=j?.saveError?.conflict===!0||Me,Pe=k?.draft??j?.content??``,Fe=vz(Pe,hz),Ie=(0,d.useMemo)(()=>j===null?void 0:vu(Fe),[Fe,j===null]),[Le,Re]=(0,d.useState)(()=>e.status===`loaded`?yz(e.content):void 0);(0,d.useEffect)(()=>{Ie?.status===`valid`&&Re(Ie.envelope)},[Ie]);let ze=Ie!==void 0&&Ie.status!==`valid`&&Le!==void 0,Be=Ie?.status===`invalid`?Fe===j?.content&&j.documentIssues!==void 0?j.documentIssues:Ie.issues:void 0,Ve=Ie?.status===`not-a-document`?Ie.why===`unparseable`?`This is not parseable JSON yet.`:"This no longer declares a structured-exchange `schema`.":Ie?.status===`unsupported-version`?`This declares ${Ie.schema}, which this version does not render.`:void 0,He=T===`split`&&Se&&!ne&&j!==null&&we,Ue=ne?void 0:He?be?Le:void 0:k===null&&!Ce&&ve?.status===`valid`?ve.envelope:void 0,Ge=(0,d.useRef)(null),Ke=k!==null,Je=j!==null&&k===null&&!He&&!ne&&(!pe||Ce)&&(!ye||Ce)&&(!me||Ce)&&(!he||Ce),Ye=ne||He?`none`:_e?`pdf`:k!==null||Je?`text`:j!==null&&!ge?`dom`:`none`,[Xe,Ze]=(0,d.useState)(!1),[Qe,$e]=(0,d.useState)(``),[et,tt]=(0,d.useState)(0),nt=(0,d.useRef)(null),rt=(0,d.useRef)(null),it=(0,d.useRef)(null),[at,ot]=(0,d.useState)({matchCount:0,currentIndex:-1,searching:!1}),[st,ct]=(0,d.useState)([]),[lt,ut]=(0,d.useState)(!1),dt=(0,d.useRef)(null),ft=(0,d.useRef)([]),pt=(0,d.useRef)(0),mt=(0,d.useRef)(``);function ht(e){pt.current=e;for(let[t,n]of ft.current.entries())for(let r of n.marks)r.isConnected&&r.classList.toggle(`find-match-current`,t===e);let t=ft.current[e]?.marks;t?.[0]?.isConnected&&t[0].scrollIntoView({block:`center`})}let gt=Xe?Qe:``,_t=(0,d.useMemo)(()=>Ye===`text`?dz(Pe,gt):[],[Ye,Pe,gt]);(0,d.useEffect)(()=>{Xe&&Ye===`none`&&Ze(!1)},[Xe,Ye]),(0,d.useEffect)(()=>{function e(){dt.current?.clear(),dt.current=null,ft.current=[],ct([]),ut(!1)}let t=rt.current;if(Ye!==`dom`||gt===``||t===null){e();return}dt.current?.clear();let n=pz(t,gt);dt.current=n,ft.current=n.matches,ct(n.matches),ut(n.truncated);let r=gt!==mt.current;mt.current=gt;let i=r?0:Math.min(pt.current,Math.max(n.matches.length-1,0));return tt(i),ht(i),e},[Ye,gt,T,Ce]);function vt(e,t){let n=e[t];n!==void 0&&de.current?.select(n.start,n.end)}(0,d.useEffect)(()=>{if(Ye!==`text`||!Xe)return;let e=dz(Pe,gt),t=gt!==mt.current;mt.current=gt;let n=t?0:Math.min(et,Math.max(e.length-1,0));tt(n),e.length>0&&vt(e,n)},[gt,Ye,Xe,Ke]),(0,d.useEffect)(()=>{de.current?.markMatches(Ye===`text`?_t:[],et)},[Ye,_t,et,Ke]);function yt(){Ze(!0)}function bt(){Ze(!1)}function xt(){if(Ye===`pdf`)it.current?.findNext();else if(Ye===`text`){if(_t.length===0)return;let e=(et+1)%_t.length;tt(e),vt(_t,e)}else{let e=ft.current.length;if(e===0)return;let t=(pt.current+1)%e;tt(t),ht(t)}}function St(){if(Ye===`pdf`)it.current?.findPrevious();else if(Ye===`text`){if(_t.length===0)return;let e=(et-1+_t.length)%_t.length;tt(e),vt(_t,e)}else{let e=ft.current.length;if(e===0)return;let t=(pt.current-1+e)%e;tt(t),ht(t)}}let Ct=Ye===`pdf`?{matchCount:at.matchCount,currentIndex:at.currentIndex,truncated:!1,searching:at.searching}:Ye===`text`?{matchCount:_t.length,currentIndex:_t.length>0?Math.min(et,_t.length-1):-1,truncated:!1,searching:!1}:{matchCount:st.length,currentIndex:st.length>0?Math.min(et,st.length-1):-1,truncated:lt,searching:!1},wt=k===null?null:(0,A.jsx)(d.Suspense,{fallback:(0,A.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading editor…`}),children:(0,A.jsx)(XR,{handle:de,path:e.path,value:k.draft,baseline:s,onChange:e=>se(t=>t===null?t:{...t,draft:e}),onSave:()=>{De&&!je&&!Ne&&Mt()}})},`editor`);function Tt(t){return j===null?null:(0,A.jsx)(d.Suspense,{fallback:(0,A.jsx)(`div`,{className:`p-4`,children:(0,A.jsx)(xe,{code:j.content,path:e.path})}),children:(0,A.jsx)(XR,{readOnly:!0,handle:t?de:void 0,path:e.path,value:j.content,baseline:s})},`source`)}let Et=(0,d.useCallback)(e=>fetch(oe(g,e,_,void 0,v)).then(e=>e.ok?e.blob():void 0,()=>void 0),[g,_,v]);function Dt(t){return(0,A.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,A.jsx)(Fy,{remarkPlugins:[SF,PF],rehypePlugins:[tD],components:{pre:We,a:({href:t,children:n,...r})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,A.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...r,children:n}):t.startsWith(`#`)?(0,A.jsx)(`a`,{href:t,...r,children:n}):(0,A.jsx)(`a`,{href:t,onClick:n=>{n.preventDefault(),m(re(e.path,t))},...r,children:n}),img:({src:t,alt:n,...r})=>{let i=typeof t==`string`&&t!==``&&!/^[a-z][a-z0-9+.-]*:/i.test(t)&&!t.startsWith(`//`)?oe(g,re(e.path,t),_,void 0,v):t;return(0,A.jsx)(`img`,{...r,src:i,alt:n??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:E(t)})})}function Ot(e){(T!==`split`||e===`split`||!De||window.confirm(`Discard unsaved changes?`))&&(e===T||!Oe||window.confirm(`Discard unsaved changes?`))&&(T===`split`&&e!==`split`&&se(null),te(null),ee(e))}function kt(){(!Ae||window.confirm(`Discard unsaved changes?`))&&p()}function At(){j&&(!Oe||window.confirm(`Discard unsaved changes?`))&&(Se&&T===`rendered`&&(te(`rendered`),ee(we?`split`:`source`)),se({draft:j.content,baseContent:j.content,baseMtimeMs:j.mtimeMs}))}function jt(){D===null?se(He&&j!==null?{draft:j.content,baseContent:j.content,baseMtimeMs:j.mtimeMs}:null):(se(null),ee(D),te(null))}function Mt(t=!1){j&&k!==null&&!je&&(fe.current=k.draft,h(e.path,k.draft,k.baseMtimeMs,t))}function Nt(){se(null),m(e.path)}function Pt(){let t=!ne;O(t),t?c(e.path):l()}return(0,d.useEffect)(()=>{k!==null&&j!==null&&fe.current!==null&&j.content===fe.current&&j.mtimeMs!==k.baseMtimeMs&&(fe.current=null,se({...k,baseContent:j.content,baseMtimeMs:j.mtimeMs}))},[j?.mtimeMs]),(0,d.useEffect)(()=>{function e(e){if(e.key===`Escape`)Xe?bt():kt();else if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`f`){if(Ye===`none`)return;e.preventDefault(),yt()}}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,d.useEffect)(()=>{He&&Te&&k===null&&j!==null&&se({draft:j.content,baseContent:j.content,baseMtimeMs:j.mtimeMs})},[He,Te,j?.mtimeMs]),(0,d.useEffect)(()=>{le(n?`streaming`:e=>e===`streaming`?`done`:e)},[n]),(0,d.useEffect)(()=>(r(Ae),()=>r(!1)),[Ae]),(0,d.useEffect)(()=>(a&&c(e.path),()=>l()),[]),(0,A.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[Se&&!ne&&(0,A.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,role:`group`,"aria-label":`How to show this document`,children:[[`rendered`,`⚏ rendered`,`Show the rendering`],[`split`,`⇹ split`,`Edit the file beside its rendering`],[`source`,`⌗ source`,`Show the file as written`]].map(([e,t,n])=>(0,A.jsx)(`button`,{type:`button`,onClick:()=>Ot(e),"aria-pressed":T===e,title:n,className:`rounded px-1.5 py-0.5 text-xs ${T===e?`bg-zinc-100 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-200`:`text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`}`,children:t},e))}),i!==void 0&&k===null&&(0,A.jsx)(`button`,{type:`button`,onClick:Pt,"aria-pressed":ne,title:ne?`Show file content`:`Show uncommitted changes (vs HEAD)`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs ${ne?`bg-amber-100 text-amber-800 dark:bg-amber-950/60 dark:text-amber-300`:`text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`}`,children:`± diff`}),u&&k===null&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>f(e.path),title:`Show this file's history`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:`⎇ history`}),(0,A.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:[e.path,Ae&&(0,A.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),he&&w&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>w(e.path),title:`Open with the application associated with .drawio files — draw.io desktop, where it is installed`,className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-600 hover:border-zinc-400 hover:text-zinc-900 dark:border-zinc-700 dark:text-zinc-300 dark:hover:border-zinc-500 dark:hover:text-zinc-100`,children:`↗ open in draw.io`}),j&&!ge&&!_e&&!he&&!ne&&!be&&(0,A.jsx)(ZR,{text:Pe,path:e.path,serverUrl:g,token:_,workspace:v,template:y}),Ue?.kind===`table`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(ZR,{text:()=>Ge.current?.markdown?.()??``,path:`${e.path.replace(/\.[^./]*$/,``)}.md`,serverUrl:g,token:_,workspace:v,template:y}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>Ge.current?.xlsx?.(),title:`Download as an Excel workbook`,"aria-label":`Download as an Excel workbook`,className:bz,children:`⤓ excel`})]}),(Ue?.kind===`graph`||Ue?.kind===`sequence`||Ue?.kind===`timeline`)&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>Ge.current?.svg?.(),title:`Download the figure as SVG`,"aria-label":`Download the figure as SVG`,className:bz,children:`⤓ svg`}),j&&k===null&&(0,A.jsx)(ue,{text:j.content}),j&&k===null&&!ne&&Te&&(0,A.jsx)(`button`,{type:`button`,onClick:At,className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500 dark:hover:text-zinc-200`,children:`✎ edit`}),j&&k===null&&!Te&&(0,A.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,title:`Outside the writable zone`,children:`🔒 read-only`}),k!==null&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>Mt(),disabled:!De||je||Ne,className:`shrink-0 rounded border border-emerald-300 px-2 py-0.5 text-xs text-emerald-700 hover:border-emerald-500 disabled:opacity-50 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600`,children:je?`saving…`:`save`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{(!De||window.confirm(`Discard unsaved changes?`))&&jt()},className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500`,children:De?`cancel`:`done`})]}),(0,A.jsx)(`button`,{type:`button`,onClick:kt,title:`Close (Esc)`,"aria-label":`Close file viewer`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),Xe&&Ye!==`none`&&(0,A.jsx)(cz,{inputRef:nt,query:Qe,onQueryChange:$e,matchCount:Ct.matchCount,currentIndex:Ct.currentIndex,truncated:Ct.truncated,searching:Ct.searching,onNext:xt,onPrev:St,onClose:bt}),Ne&&k!==null&&(0,A.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:[(0,A.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,A.jsx)(`button`,{type:`button`,onClick:Nt,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`reload (discard my edits)`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>Mt(!0),disabled:je,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 disabled:opacity-50 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`overwrite with my version`})]}),k!==null&&j?.saveError&&!j.saveError.conflict&&(0,A.jsx)(`div`,{className:`border-b border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:j.saveError.message}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[ne&&k===null&&(0,A.jsxs)(`div`,{className:`p-4`,children:[o?.path===e.path&&`error`in o&&(0,A.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:o.error}),o?.path===e.path&&`before`in o&&(0,A.jsx)(qe,{fill:!0,lines:S(o.before,o.after)}),o?.path!==e.path&&(0,A.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),_e&&k===null&&!ne&&(0,A.jsx)(Hf,{label:`This PDF`,children:(0,A.jsx)(d.Suspense,{fallback:(0,A.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),children:(0,A.jsx)(mz,{ref:it,path:e.path,serverUrl:g,token:_,workspace:v,revision:C,findQuery:Ye===`pdf`?gt:``,onFindStateChange:ot,...x?{onLoaded:x}:{}})})}),ge&&k===null&&!ne&&(0,A.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,A.jsx)(`img`,{src:oe(g,e.path,_,C,v),alt:e.path,onLoad:()=>b?.(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&k===null&&!ne&&!ge&&!_e&&(0,A.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!ge&&!_e&&(0,A.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),k!==null&&!He&&wt,j&&k===null&&!He&&!ne&&pe&&!Ce&&(0,A.jsx)(`div`,{ref:rt,children:Dt(j.content)}),j&&k===null&&!He&&!ne&&he&&!Ce&&(0,A.jsx)(`div`,{className:`h-full`,"data-testid":`file-drawio`,children:(0,A.jsx)(iI,{path:e.path,xml:j.content,variant:`viewer`,fallback:Tt(!1),onTouchUpDirtyChange:ke})}),j&&k===null&&!He&&!ne&&me&&!Ce&&(0,A.jsx)(`div`,{className:`h-full`,"data-testid":`file-html`,children:(0,A.jsx)(sz,{source:j.content,path:e.path,load:Et,onOpen:m})}),He&&(0,A.jsxs)(`div`,{className:`flex h-full min-h-0`,"data-testid":`file-split`,children:[(0,A.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto border-r border-zinc-200 dark:border-zinc-800`,children:wt??Tt(!1)}),(0,A.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto`,"data-testid":`file-split-rendering`,children:pe&&!be?(0,A.jsx)(`div`,{className:`prose-chat p-4 text-zinc-700 dark:text-zinc-300`,children:Dt(Fe)}):he&&!be?(0,A.jsx)(HF,{xml:Fe,serverUrl:g,title:e.path}):me&&!be?(0,A.jsx)(sz,{source:Fe,path:e.path,load:Et,onOpen:m}):(0,A.jsxs)(A.Fragment,{children:[ze&&(0,A.jsx)(`p`,{"data-testid":`file-split-stale`,className:`flex flex-wrap items-center gap-2 border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,children:(0,A.jsxs)(`span`,{children:[`Showing the document as it last stood.`,` `,Ve??`The text beside it does not satisfy the schema it declares.`]})}),Be!==void 0&&(0,A.jsxs)(`ul`,{"data-testid":`file-split-issues`,className:`space-y-0.5 border-b border-zinc-200 px-3 py-1.5 text-xs text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:[Be.slice(0,6).map((e,t)=>(0,A.jsxs)(`li`,{children:[(0,A.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),Be.length>6&&(0,A.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,Be.length-6,` more`]})]}),Le===void 0?(0,A.jsxs)(`p`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,"data-testid":`file-split-nothing`,children:[`Nothing to draw yet. `,Ve??`This document does not satisfy the schema it declares.`]}):(0,A.jsx)(Hf,{label:`This diagram`,children:(0,A.jsx)(`div`,{className:`p-4`,"data-testid":`file-structured-exchange`,children:(0,A.jsx)(zf,{envelope:Le,source:Pe,exportRef:Ge})})})]})})]}),j&&k===null&&!He&&!ne&&ye&&!Ce&&ve?.status===`valid`&&(0,A.jsx)(Hf,{label:`This diagram`,children:(0,A.jsx)(`div`,{className:`mx-auto max-w-5xl p-4`,"data-testid":`file-structured-exchange`,children:(0,A.jsx)(zf,{envelope:ve.envelope,source:j.content,exportRef:Ge})})}),j&&k===null&&!He&&!ne&&ve?.status===`invalid`&&(0,A.jsxs)(`div`,{"data-testid":`file-structured-exchange-invalid`,className:`mx-4 mt-4 rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,A.jsx)(`p`,{className:`font-medium`,children:`This declares a structured-exchange document and does not satisfy the schema.`}),(0,A.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:[(j.documentIssues??ve.issues).slice(0,8).map((e,t)=>(0,A.jsxs)(`li`,{children:[(0,A.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),(j.documentIssues??ve.issues).length>8&&(0,A.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,(j.documentIssues??ve.issues).length-8,` more`]})]})]}),j&&k===null&&!He&&!ne&&ve?.status===`unsupported-version`&&(0,A.jsxs)(`div`,{"data-testid":`file-structured-exchange-unsupported`,className:`mx-4 mt-4 rounded-lg border border-zinc-300 bg-zinc-50 px-3 py-2 text-sm text-zinc-600 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-400`,children:[`This document declares `,(0,A.jsx)(`span`,{className:`font-mono`,children:ve.schema}),`, which this version does not render. Shown as text.`]}),Je&&Tt(!0)]}),ce!==`idle`&&(0,A.jsxs)(`button`,{type:`button`,onClick:kt,"aria-live":`polite`,className:`flex items-center gap-2 border-t border-zinc-200 px-3 py-2 text-left text-sm hover:bg-zinc-50 dark:border-zinc-800 dark:hover:bg-zinc-900`,children:[ce===`streaming`?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,A.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,A.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,A.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function Ez(e){return e.split(`
|
|
672
672
|
`).map(e=>e.startsWith(`diff --git `)?{kind:`file`,text:e.slice(11)}:e.startsWith(`@@`)||e.startsWith(`+++`)||e.startsWith(`---`)||e.startsWith(`index `)?{kind:`hunk`,text:e}:e.startsWith(`+`)?{kind:`add`,text:e.slice(1)}:e.startsWith(`-`)?{kind:`del`,text:e.slice(1)}:{kind:`context`,text:e.startsWith(` `)?e.slice(1):e})}function Dz({show:e,onClose:t}){return(0,d.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),t())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]),(0,A.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,A.jsx)(`span`,{className:`font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,12)}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`commit diff`}),(0,A.jsx)(`button`,{type:`button`,onClick:t,title:`Close (Esc)`,"aria-label":`Close commit diff`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),e.truncated&&(0,A.jsx)(`div`,{className:`border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:`Patch truncated — showing the first 256 KiB.`}),(0,A.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed`,children:Ez(e.patch).map((e,t)=>(0,A.jsxs)(`div`,{className:e.kind===`file`?`mt-3 border-t border-zinc-200 pt-2 font-bold text-zinc-700 first:mt-0 first:border-t-0 first:pt-0 dark:border-zinc-800 dark:text-zinc-200`:e.kind===`hunk`?`text-sky-600 dark:text-sky-400`:e.kind===`add`?`bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:e.kind===`del`?`bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`text-zinc-500 dark:text-zinc-500`,children:[e.kind===`add`?`+ `:e.kind===`del`?`− `:``,e.text||` `]},t))})]})}var Oz=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],kz=`worktree`,Az={defaultWidth:288,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.files-sidebar-width.v1`},jz={defaultWidth:416,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.history-list-width.v1`},Mz={defaultWidth:288,minWidth:160,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.terminal-height.v1`};function Nz(e,t){return Number.isFinite(e)?Math.min(t.maxWidth,Math.max(t.minWidth,Math.round(e))):t.defaultWidth}function Pz(e,t){return e===null||e.trim()===``?t.defaultWidth:Nz(Number(e),t)}function Fz(e,t){try{return Pz((t??window.localStorage).getItem(e.storageKey),e)}catch{return e.defaultWidth}}function Iz(e,t,n){try{(n??window.localStorage).setItem(t.storageKey,String(Nz(e,t)))}catch{}}function Lz(e,t=`x`){let[n,r]=(0,d.useState)(()=>Fz(e)),i=(0,d.useRef)(n),a=(0,d.useRef)(null),o=(0,d.useCallback)(t=>{let n=Nz(t,e);return i.current=n,r(n),n},[e]),s=(0,d.useCallback)(()=>{a.current!==null&&(a.current=null,Iz(i.current,e))},[e]);return{width:n,separatorProps:{onPointerDown:e=>{e.isPrimary!==!1&&(e.button??0)===0&&(e.preventDefault(),e.currentTarget.setPointerCapture?.(e.pointerId),a.current={pointerId:e.pointerId,startX:t===`y`?e.clientY:e.clientX,startWidth:i.current})},onPointerMove:e=>{let n=a.current;n!==null&&n.pointerId===e.pointerId&&o(n.startWidth+(t===`y`?n.startX-e.clientY:e.clientX-n.startX))},onPointerUp:e=>{a.current?.pointerId===e.pointerId&&s()},onPointerCancel:e=>{let t=a.current;t!==null&&t.pointerId===e.pointerId&&(a.current=null,o(t.startWidth))},onLostPointerCapture:s,onKeyDown:n=>{let r=null;n.key===(t===`y`?`ArrowDown`:`ArrowLeft`)?r=i.current-e.keyboardStep:n.key===(t===`y`?`ArrowUp`:`ArrowRight`)?r=i.current+e.keyboardStep:n.key===`Home`&&(r=e.defaultWidth),r!==null&&(n.preventDefault(),Iz(o(r),e))}}}}function Rz({axis:e=`x`,label:t,width:n,config:r,separatorProps:i,className:a=``}){return(0,A.jsx)(`div`,{...i,role:`separator`,"aria-label":t,"aria-orientation":e===`y`?`horizontal`:`vertical`,"aria-valuemin":r.minWidth,"aria-valuemax":r.maxWidth,"aria-valuenow":n,tabIndex:0,title:t,className:`group absolute z-20 touch-none outline-none ${e===`y`?`inset-x-0 -top-1 h-2 cursor-row-resize`:`inset-y-0 -right-1 w-2 cursor-col-resize`} ${a}`,children:(0,A.jsx)(`span`,{className:`pointer-events-none absolute ${e===`y`?`inset-x-0 top-1/2 h-px`:`inset-y-0 left-1/2 w-px`} bg-transparent transition-colors group-hover:bg-blue-400 group-focus-visible:bg-blue-500 group-active:bg-blue-500 dark:group-hover:bg-blue-500`})})}var zz=`#10b981`,Bz=[`#8b5cf6`,`#f59e0b`,`#0ea5e9`,`#f43f5e`,`#14b8a6`,`#d946ef`];function Vz(e){return e===0?zz:Bz[(e-1)%Bz.length]}function Hz(e){return Bz[e%Bz.length]}function Uz(e){return e*14+7+1}function Wz(e){return e*14+2}function Gz({row:e,laneCount:t,colorOf:n=Vz}){let r=Wz(t),i=Uz(e.lane),a=e.highlight?zz:n(e.lane),o=e.dashed?`3 3`:void 0;return(0,A.jsxs)(`svg`,{width:r,height:36,viewBox:`0 0 ${r} 36`,"aria-hidden":!0,className:`shrink-0`,children:[e.through.map(e=>(0,A.jsx)(`line`,{x1:Uz(e),y1:0,x2:Uz(e),y2:36,stroke:n(e),strokeWidth:2,opacity:.55},e)),e.lineAbove&&(0,A.jsx)(`line`,{x1:i,y1:0,x2:i,y2:18,stroke:a,strokeWidth:2,strokeDasharray:o}),e.lineBelow&&(0,A.jsx)(`line`,{x1:i,y1:18,x2:i,y2:36,stroke:a,strokeWidth:2,strokeDasharray:o}),e.forkTo.map(e=>(0,A.jsx)(`path`,{d:`M ${i} 18 C ${i} 36, ${Uz(e)} 18, ${Uz(e)} 36`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`fork-${e}`)),(e.mergeFrom??[]).map(e=>(0,A.jsx)(`path`,{d:`M ${i} 18 C ${i} 0, ${Uz(e)} 18, ${Uz(e)} 0`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`merge-${e}`)),e.emphasis===`current`?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`circle`,{cx:i,cy:18,r:6,fill:`none`,stroke:a,strokeWidth:2}),(0,A.jsx)(`circle`,{cx:i,cy:18,r:2.5,fill:a})]}):(0,A.jsx)(`circle`,{cx:i,cy:18,r:4,fill:e.emphasis===`filled`?a:`var(--tree-off, #d4d4d8)`,stroke:a,strokeWidth:e.emphasis===`filled`?0:1.5})]})}function Kz(e,t){let n=[],r=t===void 0?[]:[t],i=r.length,a=t!==void 0,o=()=>{let e=r.indexOf(null);return e===-1?(r.push(null),i=Math.max(i,r.length),r.length-1):e};for(let s of e){let e=r.reduce((e,t,n)=>t===s.sha?[...e,n]:e,[]),c=e[0]??o();s.sha===t&&(a=!1);let l=(s.sha===t?e.length-1:e.length)===0,u=e.slice(1);for(let e of u)r[e]=null;i=Math.max(i,c+1);let[d,...f]=s.parents;r[c]=d??null;let p=f.map(e=>{let t=o();return r[t]=e,t});n.push({lane:c,through:r.reduce((e,t,n)=>t!==null&&n!==c&&!p.includes(n)&&!(a&&n===0)?[...e,n]:e,[]),forkTo:p,mergeFrom:u,tip:l})}return{lanes:n,laneCount:Math.max(i,1)}}function qz(e){let t=e.find(e=>e.head)?.sha,{lanes:n,laneCount:r}=Kz(e,t);return{rows:e.map((e,t)=>{let{lane:r,through:i,forkTo:a,mergeFrom:o,tip:s}=n[t];return{lane:r,through:i,forkTo:a,mergeFrom:o,entry:e,lineAbove:!s,lineBelow:e.parents.length>0,emphasis:e.head?`current`:`filled`}}),laneCount:r}}function Jz(e,t={}){let{lanes:n,laneCount:r}=Kz(e),i=e.map((e,t)=>{let{lane:r,through:i,forkTo:a,mergeFrom:o}=n[t];return{lane:r,through:i,forkTo:a,mergeFrom:o,rev:e.sha,path:e.path,entry:e,lineAbove:!0,lineBelow:e.parents.length>0,emphasis:`filled`}}),a=i[0];return i.unshift({rev:kz,path:a?.path??``,lane:a?.lane??0,through:a?.through??[],forkTo:[],mergeFrom:[],lineAbove:!1,lineBelow:i.length>0,emphasis:`current`,dashed:!t.dirty}),i[1]&&(i[1].lineAbove=!0),{rows:i,laneCount:r}}var Yz=20;function Xz(e){let t=(Date.now()-new Date(e).getTime())/1e3;return t<90?`now`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}function Zz(e){return e.rev===`worktree`?`working tree`:e.rev.slice(0,7)}function Qz(e,t){return e!==null&&t!==null&&e.rev===t.rev&&e.path===t.path}function $z(e){return{rev:e.rev,path:e.path}}function eB({history:e,diff:t,dirty:n,onFetchDiff:r,onClearDiff:i,onClose:a}){let[o,s]=(0,d.useState)({base:null,target:null}),{base:c,target:l}=o,[u,f]=(0,d.useState)(0),p=(0,d.useRef)([]),m=Lz(jz),{rows:h,laneCount:g}=(0,d.useMemo)(()=>Jz(e.entries,{dirty:n}),[e.entries,n]),_=(0,d.useRef)({onFetchDiff:r,onClose:a});_.current={onFetchDiff:r,onClose:a},(0,d.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),_.current.onClose())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[]),(0,d.useEffect)(()=>{c===null||l===null||Qz(c,l)||_.current.onFetchDiff(c,l)},[c,l]);let v=(0,d.useCallback)((e,t)=>{let n=$z(e);s(r=>{if(t===`base`)return{base:n,target:Qz(n,r.target)?r.base:r.target};if(t===`target`)return{base:Qz(n,r.base)?r.target:r.base,target:n};if(r.base===null&&r.target===null){let t=e.entry?.parents[0],r=t===void 0?void 0:h.find(e=>e.rev===t);return{base:r?$z(r):null,target:n}}return{base:Qz(n,r.base)?r.target:r.base,target:n}})},[h]),y=(0,d.useCallback)(()=>{s({base:null,target:null}),i()},[i]),b=(0,d.useCallback)(()=>s(e=>({base:e.target,target:e.base})),[]),x=(0,d.useCallback)(e=>{f(t=>{let n=Math.max(0,Math.min(h.length-1,t+e));return p.current[n]?.focus(),n})},[h.length]),S=e=>{let t=$z(e);return Qz(t,c)?`base`:Qz(t,l)?`target`:null},C=h.findIndex(e=>Qz($z(e),c)),w=h.findIndex(e=>Qz($z(e),l)),T=C>=0&&w>=0?{top:Math.min(C,w)*36+18,height:Math.abs(w-C)*36}:null;return(0,A.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:e.path}),c!==null&&l!==null&&(0,A.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-zinc-500 dark:text-zinc-400`,"aria-label":`Comparing ${Zz(c)} to ${Zz(l)}`,children:[(0,A.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:Zz(c)}),` → `,(0,A.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:Zz(l)})]}),c!==null&&l!==null&&(0,A.jsx)(`button`,{type:`button`,onClick:b,title:`Compare the other way round`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`⇄ swap`}),(c!==null||l!==null)&&(0,A.jsx)(`button`,{type:`button`,onClick:y,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`clear`}),(0,A.jsx)(`button`,{type:`button`,onClick:a,title:`Close (Esc)`,"aria-label":`Close file history`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,A.jsxs)(`div`,{role:`region`,"aria-label":`Commit history`,style:{"--history-list-width":`${m.width}px`},className:`relative flex max-h-[40%] w-full shrink-0 flex-col border-b border-zinc-200 md:max-h-none md:w-[var(--history-list-width)] md:border-b-0 md:border-r dark:border-zinc-800`,children:[(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),x(1)):e.key===`ArrowUp`&&(e.preventDefault(),x(-1))},children:[e.status===`loading`&&(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`Reading history…`}),e.status===`error`&&(0,A.jsx)(`div`,{className:`m-3 rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e.error}),e.status===`loaded`&&e.entries.length===0&&(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`No commits touch this file yet.`}),e.status===`loaded`&&e.entries.length>0&&(0,A.jsxs)(`div`,{className:`relative`,role:`group`,"aria-label":`Commits`,children:[T&&(0,A.jsx)(tB,{top:T.top,height:T.height,baseFirst:C<w}),h.map((e,t)=>(0,A.jsx)(iB,{ref:e=>{p.current[t]=e},row:e,laneCount:g,role:S(e),isFocused:t===u,onSelect:t=>v(e,t),onFocus:()=>f(t)},e.rev))]})]}),(0,A.jsx)(Rz,{label:`Resize History commit list`,width:m.width,config:jz,separatorProps:m.separatorProps,className:`hidden md:block`})]}),(0,A.jsx)(`div`,{role:`region`,"aria-label":`History diff`,className:`min-h-0 min-w-0 flex-1 overflow-auto p-3`,children:(0,A.jsx)(aB,{diff:t,base:c,target:l})})]})]})}function tB({top:e,height:t,baseFirst:n}){return(0,A.jsxs)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute left-0 z-10 motion-safe:transition-all motion-safe:duration-150 motion-safe:ease-out`,style:{top:e,height:t,width:Yz},children:[(0,A.jsx)(`div`,{className:`absolute inset-y-0 left-2 w-px bg-zinc-400 dark:bg-zinc-500`}),(0,A.jsx)(nB,{label:n?`base`:`target`,className:`top-0`}),(0,A.jsx)(nB,{label:n?`target`:`base`,className:`bottom-0`})]})}function nB({label:e,className:t}){return(0,A.jsx)(`div`,{className:`absolute left-2 flex h-px w-2.5 items-center bg-zinc-400 dark:bg-zinc-500 ${t}`,children:(0,A.jsx)(`span`,{className:`absolute -left-1 -top-1.5 rotate-180 text-[9px] leading-none text-zinc-500 [writing-mode:vertical-rl] dark:text-zinc-400`,children:e})})}var rB=`shrink-0 rounded px-1 py-0.5 text-[10px] text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 aria-disabled:cursor-default aria-disabled:opacity-30 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`;function iB({row:e,laneCount:t,role:n,isFocused:r,onSelect:i,onFocus:a,ref:o}){let s=e.entry,c=s?`${s.sha.slice(0,7)} ${s.subject}`:`Working tree`;return(0,A.jsxs)(`div`,{ref:o,role:`button`,tabIndex:r?0:-1,"aria-label":c,"aria-current":n===null?void 0:`true`,onFocus:a,onClick:()=>i(),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `?(e.preventDefault(),i()):e.key===`b`?i(`base`):e.key===`t`&&i(`target`))},style:{height:36,paddingLeft:Yz},className:`group flex cursor-pointer items-center gap-2 pr-2 focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${n===null?``:`bg-zinc-100 dark:bg-zinc-800/60`}`,children:[(0,A.jsx)(Gz,{row:e,laneCount:t}),s?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:s.sha.slice(0,7)}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-700 dark:text-zinc-300`,title:s.subject,children:s.subject}),(0,A.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-600`,children:[s.author,` · `,Xz(s.date)]}),(0,A.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums`,"aria-label":`${s.added} lines added, ${s.deleted} removed`,children:[(0,A.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-500`,children:[`+`,s.added]}),` `,(0,A.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,s.deleted]})]})]}):(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`working tree`}),(0,A.jsxs)(`span`,{className:`flex shrink-0 gap-0.5`,children:[(0,A.jsx)(`button`,{type:`button`,title:n===`target`?`Make this the base (swaps the two)`:`Compare from this version`,onClick:e=>{e.stopPropagation(),i(`base`)},className:rB,children:`base`}),(0,A.jsx)(`button`,{type:`button`,title:n===`base`?`Make this the target (swaps the two)`:`Compare to this version`,onClick:e=>{e.stopPropagation(),i(`target`)},className:rB,children:`target`})]})]})}function aB({diff:e,base:t,target:n}){return t===null&&n===null?(0,A.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Pick a commit to see what changed.`}):t===null||n===null?(0,A.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Now pick the version to compare it against.`}):e?.status===`error`?(0,A.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e.error}):e===null?(0,A.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Loading…`}):e.status===`loaded`&&e.beforeText===e.afterText?(0,A.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions are identical.`}):e.status===`loaded`&&x(e.beforeText,e.afterText)?(0,A.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions differ only in their line endings.`}):(0,A.jsx)(`div`,{className:e.status===`loading`?`opacity-40`:void 0,children:(0,A.jsx)(qe,{fill:!0,lines:S(e.beforeText,e.afterText)})})}var oB=`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 text-xs leading-none`,sB=`inline-flex h-7 min-w-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 text-xs leading-none`;function cB(e){let t=e.filter(e=>!e.sideOf).flatMap(t=>[t,...e.filter(e=>e.sideOf===t.root)]);return[...t,...e.filter(e=>!t.includes(e))]}var lB={stopped:`stopped`,starting:`starting…`,idle:`idle`,working:`working`,waiting:`waiting for you`,"ready-for-review":`ready for review`};function uB({activity:e}){switch(e){case`stopped`:return(0,A.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full border border-dashed border-zinc-400 dark:border-zinc-600`});case`starting`:return(0,A.jsx)(`svg`,{className:`h-2.5 w-2.5 shrink-0 animate-spin text-zinc-500 dark:text-zinc-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3.5`,strokeLinecap:`round`,children:(0,A.jsx)(`path`,{d:`M12 3a9 9 0 0 1 9 9`})});case`working`:return(0,A.jsxs)(`span`,{className:`relative flex h-2 w-2 shrink-0 items-center justify-center`,children:[(0,A.jsx)(`span`,{className:`absolute h-2 w-2 animate-ping rounded-full bg-blue-700 opacity-60 dark:bg-blue-400`}),(0,A.jsx)(`span`,{className:`relative h-2 w-2 rounded-full bg-blue-700 dark:bg-blue-400`})]});case`waiting`:return(0,A.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-amber-500`});case`ready-for-review`:return(0,A.jsx)(`span`,{className:`h-2 w-2 shrink-0 rotate-45 rounded-[1px] border-2 border-violet-600 bg-violet-100 dark:border-violet-400 dark:bg-violet-950`});default:return(0,A.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-zinc-400 dark:bg-zinc-600`})}}function dB({className:e}){return(0,A.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,A.jsx)(`path`,{d:`M12 6v7`}),(0,A.jsx)(`path`,{d:`M12 18h.01`})]})}function fB({className:e}){return(0,A.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,A.jsx)(`path`,{d:`M7 3h10v18H7z`}),(0,A.jsx)(`path`,{d:`m9.5 12 1.7 1.7 3.5-3.7`})]})}function pB(e){let{workspace:t,workspaces:n,locked:r}=e,[i,a]=(0,d.useState)(!1),o=(0,d.useRef)(null);if((0,d.useEffect)(()=>{if(!i)return;let e=e=>{vR(e,o.current)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]),r||!t)return null;let s=n.filter(e=>oL(e)!==oL(t)),c=n.filter(e=>!e.sideOf).length,l=n.filter(e=>e.needsAttention);return(0,A.jsxs)(`div`,{ref:o,className:`relative min-w-[4rem] max-w-[16rem]`,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-expanded":i,"aria-haspopup":`menu`,title:`Project: ${t.name} (${lB[t.activity]})`,className:`${sB} max-w-full gap-1.5 ${l.length>0?`border-amber-500 bg-amber-50 text-zinc-700 dark:bg-amber-950/40 dark:text-zinc-200`:`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`}`,children:[(0,A.jsx)(uB,{activity:t.activity}),(0,A.jsx)(`span`,{className:`truncate font-medium`,children:t.name}),l.length>0?(0,A.jsxs)(`span`,{className:`flex items-center gap-1 text-amber-600 dark:text-amber-500`,children:[(0,A.jsx)(dB,{className:`h-3 w-3`}),(0,A.jsx)(`span`,{className:`font-semibold`,children:l.length})]}):s.some(e=>e.activity===`working`)&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{className:`h-3 w-px bg-zinc-300 dark:bg-zinc-600`}),(0,A.jsx)(`span`,{className:`flex items-center gap-1`,children:s.map(e=>e.activity===`working`?(0,A.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5 items-center justify-center`,children:[(0,A.jsx)(`span`,{className:`absolute h-1.5 w-1.5 animate-ping rounded-full bg-blue-700 opacity-60 dark:bg-blue-400`}),(0,A.jsx)(`span`,{className:`relative h-1.5 w-1.5 rounded-full bg-blue-700 dark:bg-blue-400`})]},oL(e)):(0,A.jsx)(`span`,{className:`h-1 w-1 rounded-full bg-zinc-300 dark:bg-zinc-600`},oL(e)))})]}),(0,A.jsx)(`svg`,{className:`h-3 w-3 text-zinc-500`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,A.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),i&&(0,A.jsxs)(`div`,{role:`menu`,className:`absolute left-0 top-full z-40 mt-1 w-87 rounded-md border border-zinc-300 bg-white p-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[cB(n).map(n=>{let r=oL(n),i=r===oL(t),o=n.sideOf!==void 0;return(0,A.jsxs)(`div`,{"data-testid":o?`side-session-row`:`project-row`,className:`group flex items-center gap-2.5 rounded-md py-2 pr-2.5 ${o?`pl-7`:`pl-2.5`} ${i?`bg-zinc-100 dark:bg-zinc-800`:`hover:bg-zinc-50 dark:hover:bg-zinc-800/50`}`,children:[(0,A.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{a(!1),o?e.onSwitch(n.root,n.id):e.onSwitch(n.root)},className:`flex min-w-0 flex-1 items-center gap-2.5 text-left`,children:[(0,A.jsx)(uB,{activity:n.activity}),(0,A.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,A.jsx)(`span`,{className:`truncate text-[13px] ${i?`font-semibold text-zinc-900 dark:text-zinc-100`:`font-medium text-zinc-900 dark:text-zinc-100`}`,children:o?n.label??n.name:n.name}),!o&&(0,A.jsx)(`span`,{className:`truncate font-mono text-[11px] text-zinc-400 dark:text-zinc-500`,children:n.root})]})]}),(0,A.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[n.needsAttention?(0,A.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] font-medium ${n.activity===`ready-for-review`?`text-violet-700 dark:text-violet-400`:`text-amber-600 dark:text-amber-500`}`,children:[n.activity===`ready-for-review`?(0,A.jsx)(fB,{className:`h-3 w-3`}):(0,A.jsx)(dB,{className:`h-3 w-3`}),lB[n.activity]]}):(0,A.jsx)(`span`,{className:`text-[11px] ${n.activity===`working`?`text-blue-700 dark:text-blue-400`:`text-zinc-400 dark:text-zinc-500`}`,children:lB[n.activity]}),!o&&e.onOpenSide&&(0,A.jsx)(`button`,{type:`button`,title:`New side session on ${n.name}`,"aria-label":`New side session on ${n.name}`,onClick:t=>{t.stopPropagation(),a(!1),e.onOpenSide?.(n.root)},className:`flex h-5 w-5 items-center justify-center rounded border border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-800 dark:border-zinc-600 dark:text-zinc-400 dark:hover:border-zinc-500 dark:hover:text-zinc-100`,children:(0,A.jsxs)(`svg`,{className:`h-2.5 w-2.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,children:[(0,A.jsx)(`path`,{d:`M12 5v14`}),(0,A.jsx)(`path`,{d:`M5 12h14`})]})}),(o||c>1)&&(0,A.jsx)(`button`,{type:`button`,title:`Close ${o?n.label??n.name:n.name}`,"aria-label":`Close ${o?n.label??n.name:n.name}`,onClick:t=>{t.stopPropagation(),o?e.onClose(n.root,n.id):e.onClose(n.root)},className:`flex h-5 w-5 items-center justify-center rounded border border-transparent text-zinc-400 opacity-0 group-hover:border-zinc-300 group-hover:opacity-100 hover:text-zinc-700 dark:group-hover:border-zinc-600 dark:hover:text-zinc-200`,children:(0,A.jsxs)(`svg`,{className:`h-2.5 w-2.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,A.jsx)(`path`,{d:`M18 6 6 18`}),(0,A.jsx)(`path`,{d:`m6 6 12 12`})]})})]})]},r)}),(0,A.jsx)(`div`,{className:`my-1 h-px bg-zinc-200 dark:bg-zinc-700`}),(0,A.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{a(!1),e.onOpen()},className:`flex w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-left text-[13px] text-zinc-700 hover:bg-zinc-50 dark:text-zinc-300 dark:hover:bg-zinc-800/50`,children:[(0,A.jsxs)(`svg`,{className:`h-3.5 w-3.5 text-zinc-500`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,A.jsx)(`path`,{d:`M12 5v14`}),(0,A.jsx)(`path`,{d:`M5 12h14`})]}),`Open a project…`]})]})]})}function mB({label:e,browse:t,onBrowse:n,onSelect:r,onCancel:i}){let a=t?.path??`/`,o=t?.entries??[],s=t?.status===`loading`,[c,l]=(0,d.useState)(a);return(0,d.useEffect)(()=>{l(a)},[a]),(0,A.jsxs)(`div`,{className:`rounded-md border border-zinc-300 p-2 dark:border-zinc-700`,"data-testid":`server-path-picker`,children:[(0,A.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,A.jsx)(`span`,{className:`text-xs font-semibold text-zinc-600 dark:text-zinc-300`,children:e}),(0,A.jsx)(`button`,{type:`button`,onClick:i,className:`text-xs text-zinc-500 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200`,children:`Cancel`})]}),(0,A.jsxs)(`form`,{className:`mb-2 flex gap-1`,onSubmit:e=>{e.preventDefault();let t=c.trim();t&&n(t)},children:[(0,A.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),l(a))},spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":`Current directory`,"data-testid":`picker-path`,className:`min-w-0 flex-1 rounded border border-zinc-300 px-2 py-1 font-mono text-xs text-zinc-700 focus:border-zinc-500 focus:outline-none dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),(0,A.jsx)(`button`,{type:`submit`,disabled:c.trim()===``||c===a,className:`rounded border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-40 dark:border-zinc-700 dark:text-zinc-300`,children:`Go`})]}),t?.status===`error`&&(0,A.jsx)(`p`,{role:`alert`,className:`mb-2 text-xs text-red-600 dark:text-red-400`,children:t.error}),(0,A.jsxs)(`div`,{className:`mb-2 flex gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,disabled:!t?.parent,onClick:()=>t?.parent&&n(t.parent),className:`rounded border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-40 dark:border-zinc-700 dark:text-zinc-300`,children:`Up`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>r(a),className:`rounded bg-zinc-800 px-2 py-1 text-xs font-medium text-white hover:bg-zinc-700 dark:bg-zinc-200 dark:text-zinc-900`,children:`Use this directory`})]}),(0,A.jsxs)(`ul`,{className:`max-h-40 overflow-y-auto`,children:[s&&o.length===0&&(0,A.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400`,children:`Loading…`}),!s&&o.length===0&&t?.status!==`error`&&(0,A.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No subdirectories`}),o.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(`button`,{type:`button`,onClick:()=>n(e.path),className:`w-full truncate rounded px-2 py-1 text-left font-mono text-xs text-zinc-600 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800`,title:e.path,children:[e.name,e.name.endsWith(`:`)?`\\`:`/`]})},e.path))]})]})}function hB(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function gB(e){let{sandbox:t,applyState:n,blocked:r=!1,onCloseBrowser:i}=e,[a,o]=(0,d.useState)(!1),s=(0,d.useRef)(!1);if((0,d.useEffect)(()=>{r&&a&&(s.current=!1,o(!1))},[r,a]),(0,d.useEffect)(()=>{s.current&&n?.status!==`applying`&&(n?.status===`error`?s.current=!1:(s.current=!1,o(!1),i()))},[n,i]),!t)return(0,A.jsx)(`span`,{className:`${oB} border-dashed border-zinc-300 text-zinc-400 dark:border-zinc-700 dark:text-zinc-500`,title:`This server runs without a sandbox, so there is no root to move`,children:`No sandbox`});let c=t.locks?.root===!0,l=hB(t.root);return(0,A.jsxs)(`div`,{className:`relative min-w-[4rem] max-w-[14rem]`,children:[(0,A.jsxs)(`button`,{type:`button`,disabled:c,"aria-label":c?`Sandbox root: ${t.root} (locked)`:`Sandbox root: ${t.root}`,title:c?`${t.root} — locked by the server's configuration`:t.root,onClick:()=>{e.onOpened(),o(!0),e.onBrowse(t.root)},className:`${sB} max-w-full gap-1.5 ${c?`cursor-not-allowed border-zinc-200 text-zinc-400 dark:border-zinc-800 dark:text-zinc-500`:`border-zinc-300 text-zinc-600 hover:border-zinc-400 hover:text-zinc-800 dark:border-zinc-700 dark:text-zinc-300 dark:hover:border-zinc-500 dark:hover:text-zinc-100`}`,children:[(0,A.jsx)(`span`,{className:`truncate font-mono`,children:l}),c?(0,A.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`▾`})]}),a&&!r&&(0,A.jsxs)(`div`,{className:`absolute left-0 top-full z-20 mt-1 w-[380px] rounded-lg border border-zinc-200 bg-white p-2 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[n?.status===`error`&&(0,A.jsx)(`p`,{role:`alert`,className:`mb-2 text-xs text-red-600 dark:text-red-400`,children:n.message}),(0,A.jsx)(mB,{label:`Choose the sandbox root`,browse:e.browse,onBrowse:e.onBrowse,onSelect:t=>{s.current=!0,e.onSelect(t)},onCancel:()=>{s.current=!1,o(!1),i()}})]})]})}function _B(e){let t=(Date.now()-new Date(e).getTime())/1e3;return t<90?`now`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}function vB(e){return e.slice(e.lastIndexOf(`/`)+1)}function yB({status:e,selected:t,log:n,onFetchLog:r,onShowCommit:i}){let[a,o]=(0,d.useState)(!1),s=yR(()=>o(!1)),c=e?.repos??[],l=(t===null?null:JL(c,t))??(t===null&&c.length===1?c[0]:null),u=l&&(l.ahead>0||l.behind>0)?` ${l.ahead>0?`↑${l.ahead}`:``}${l.behind>0?`↓${l.behind}`:``}`:``,f=c.length>1&&l!==null&&l.repo!==``?`${vB(l.repo)} `:``,p=e===null?`…`:l?.branch??`—`,m=l!==null&&n?.repo===l.repo?n.entries:null,h=(0,d.useMemo)(()=>m===null?null:qz(m),[m]);return(0,d.useEffect)(()=>{a&&l!==null&&n?.repo!==l.repo&&r(l.repo)},[a,l?.repo,r]),(0,A.jsxs)(`div`,{className:`relative min-w-[4rem] max-w-[14rem] shrink-[2]`,ref:s,children:[(0,A.jsxs)(`button`,{type:`button`,disabled:l===null,onClick:()=>{l!==null&&(o(!a),a||r(l.repo))},title:l===null?`no repository selected`:`git history — ${l.repo===``?`this project`:l.repo}`,className:`${sB} max-w-full border-zinc-300 font-mono text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 disabled:cursor-default disabled:hover:border-zinc-300 disabled:hover:text-zinc-500 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200 dark:disabled:hover:border-zinc-800 dark:disabled:hover:text-zinc-400`,children:[(0,A.jsxs)(`span`,{className:`truncate`,children:[f,`⎇ `,p]}),u]}),a&&l!==null&&(0,A.jsxs)(`div`,{className:`absolute left-0 top-full z-20 mt-1 max-h-96 w-[26rem] max-w-[80vw] overflow-y-auto rounded-lg border border-zinc-200 bg-white py-1 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[m===null&&(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),m?.length===0&&(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no commits`}),h?.rows.map(e=>{let{entry:t}=e;return(0,A.jsxs)(`button`,{type:`button`,onClick:()=>{i(l.repo,t.sha),o(!1)},style:{height:36},className:`flex w-full items-center gap-2 pl-2 pr-3 text-left text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,A.jsx)(Gz,{row:e,laneCount:h.laneCount}),(0,A.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:t.sha.slice(0,7)}),t.refs.map(t=>{let n=t===l.branch?`#10b981`:Vz(e.lane);return(0,A.jsx)(`span`,{style:{borderColor:n,color:n},className:`max-w-[8rem] shrink-0 truncate rounded-full border px-1.5 font-mono text-[10px] leading-4 ${t===l.branch?`font-semibold`:``}`,children:t},t)}),t.tags.map(e=>(0,A.jsxs)(`span`,{title:`tag ${e}`,className:`max-w-[8rem] shrink-0 truncate rounded border border-zinc-300 px-1 font-mono text-[10px] leading-4 text-zinc-500 dark:border-zinc-600 dark:text-zinc-400`,children:[`◆ `,e]},`tag-${e}`)),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-700 dark:text-zinc-300`,title:t.subject,children:t.subject}),(0,A.jsxs)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:[t.author,` · `,_B(t.date)]})]},t.sha)})]})]})}var bB=[{name:`draw.io / diagrams.net`,website:`https://www.drawio.com/`,license:`Apache-2.0`,text:` Apache License
|
|
673
673
|
Version 2.0, January 2004
|
|
674
674
|
http://www.apache.org/licenses/
|
|
@@ -1262,8 +1262,8 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
1262
1262
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1263
1263
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1264
1264
|
SOFTWARE.
|
|
1265
|
-
`,SB=[[`draw.io / diagrams.net`,`Diagram viewer and editor`],[`React`,`User interface`],[`CodeMirror · xterm.js · node-pty`,`Code editor and terminal`],[`PDF.js · docx`,`Document tools`],[`Mermaid · KaTeX`,`Diagrams and mathematical notation`]],CB=[{name:`pi-outpost`,license:`MIT`,text:xB},...bB];function wB(){let[e,t]=(0,d.useState)(!1),n=(0,d.useRef)(null);return(0,d.useLayoutEffect)(()=>{n.current?.focus({preventScroll:!0});let e=n.current?.closest(`.overflow-y-auto`);e&&(e.scrollTop=0)},[e]),e?(0,A.jsxs)(`div`,{className:`text-zinc-700 dark:text-zinc-300`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:`mb-3 text-xs text-zinc-500 hover:underline dark:text-zinc-400`,children:`← Back to credits`}),(0,A.jsx)(`h3`,{ref:n,tabIndex:-1,className:`text-sm font-semibold outline-none`,children:`Third-party notices`}),(0,A.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`License texts and attributions for pi-outpost and the components acknowledged here.`}),CB.map(e=>(0,A.jsxs)(`section`,{className:`mt-5 border-t border-zinc-200 pt-3 dark:border-zinc-700`,children:[(0,A.jsxs)(`h4`,{className:`text-sm font-semibold`,children:[e.name,` `,(0,A.jsxs)(`span`,{className:`font-normal text-zinc-500 dark:text-zinc-400`,children:[`· `,e.license]})]}),(0,A.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed`,children:e.text})]},e.name))]}):(0,A.jsxs)(`div`,{className:`text-sm text-zinc-700 dark:text-zinc-300`,children:[(0,A.jsxs)(`section`,{className:`pb-5`,children:[(0,A.jsx)(`h3`,{ref:n,tabIndex:-1,className:`text-xl font-semibold tracking-tight outline-none`,children:`pi-outpost`}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Created by Laurent Francoise · MIT license`}),(0,A.jsxs)(`a`,{className:`mt-3 inline-flex items-center gap-2 text-xs underline underline-offset-4`,href:`https://laurentftech.github.io/pi-outpost/`,target:`_blank`,rel:`noopener noreferrer`,children:[`Project website `,(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`↗`})]})]}),(0,A.jsxs)(`section`,{className:`border-t border-zinc-200 pt-4 dark:border-zinc-700`,children:[(0,A.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Open-source acknowledgements`}),(0,A.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`Thanks to the authors and contributors of these projects.`}),(0,A.jsx)(`dl`,{className:`mt-3 space-y-3`,children:SB.map(([e,t])=>(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`dt`,{className:`text-xs font-medium`,children:e}),(0,A.jsx)(`dd`,{className:`mt-0.5 text-xs text-zinc-500 dark:text-zinc-400`,children:t})]},e))}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),className:`mt-4 flex w-full items-center justify-between rounded-md border border-zinc-300 px-3 py-2 text-xs hover:bg-zinc-100 dark:border-zinc-700 dark:hover:bg-zinc-800`,children:[`Third-party notices `,(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`→`})]})]})]})}function TB(e){if(e.installed===void 0)return`not installed`;if(e.restartNeeded)return`${e.installed} installed — restart to use it`;if(e.pinned!==void 0)return`${e.installed}, pinned`;let t=e.check;if(!t)return e.installed;switch(t.state){case`checking`:return`${e.installed}, checking…`;case`newer`:return`${e.installed} — ${t.latest} available`;case`current`:return`${e.installed}, up to date`;case`failed`:return`${e.installed}, not checked: ${t.reason}`;case`off`:return`${e.installed}, not checked: ${t.reason}`}}function EB({packages:e,update:t,locked:n,onCheck:r,onUpdate:i}){let[a,o]=(0,d.useState)(null);if(e===null||e.length===0)return null;let s=t?.status===`pending`?t.source:null;return(0,A.jsxs)(`div`,{className:`mt-3`,"data-testid":`pi-packages`,children:[(0,A.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,A.jsx)(`span`,{className:`text-xs font-medium text-zinc-600 dark:text-zinc-400`,children:`Packages`}),(0,A.jsx)(`button`,{type:`button`,onClick:r,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200`,children:`check for updates`})]}),(0,A.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let r=e.check?.state===`newer`&&!e.restartNeeded?e.check.latest:void 0;return(0,A.jsxs)(`li`,{"data-testid":`pi-package`,className:`rounded bg-zinc-50 px-2 py-1 text-xs dark:bg-zinc-800`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,A.jsx)(`span`,{className:`min-w-0 truncate font-mono text-zinc-700 dark:text-zinc-300`,title:e.source,children:e.name}),r&&!n&&a!==e.source&&(0,A.jsx)(`button`,{type:`button`,disabled:s!==null,onClick:()=>o(e.source),className:`shrink-0 rounded border border-zinc-300 px-1.5 py-0.5 text-zinc-700 hover:bg-zinc-100 disabled:opacity-50 dark:border-zinc-600 dark:text-zinc-200 dark:hover:bg-zinc-700`,children:s===e.source?`updating…`:`Update`})]}),(0,A.jsx)(`div`,{className:`line-clamp-2 text-zinc-500 dark:text-zinc-400`,"data-testid":`pi-package-status`,title:TB(e),children:TB(e)}),r&&a===e.source&&(0,A.jsxs)(`div`,{className:`mt-1 rounded border border-amber-300 bg-amber-50 p-2 text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,"data-testid":`pi-package-confirm`,children:[(0,A.jsxs)(`p`,{children:[`This replaces code that runs with the agent's privileges: `,e.name,` `,e.installed,` → `,r,`. It takes effect when pi-outpost restarts.`]}),(0,A.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>{o(null),i(e.source)},className:`rounded bg-amber-600 px-2 py-0.5 text-white hover:bg-amber-700`,children:[`Install `,r]}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(null),className:`rounded px-2 py-0.5 hover:bg-amber-100 dark:hover:bg-amber-900/40`,children:`Cancel`})]})]}),t&&t.status!==`pending`&&t.source===e.source&&(0,A.jsx)(`p`,{"data-testid":`pi-package-result`,className:`mt-1 ${t.status===`installed`?`text-emerald-700 dark:text-emerald-400`:`text-amber-700 dark:text-amber-400`}`,children:t.message})]},e.source)})})]})}function DB({reasons:e,canRestart:t,restarting:n,onRestart:r}){let[i,a]=(0,d.useState)(!1);return e.length===0?null:(0,A.jsxs)(`div`,{className:`mt-3 rounded border border-sky-200 bg-sky-50 p-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,"data-testid":`restart-needed`,children:[(0,A.jsxs)(`p`,{children:[`Installed and waiting on a restart to run: `,e.join(`, `),`.`]}),t?n?(0,A.jsx)(`p`,{className:`mt-1`,children:`Restarting pi-outpost…`}):i?(0,A.jsxs)(`div`,{className:`mt-1`,children:[(0,A.jsx)(`p`,{children:`pi-outpost stops and starts again in the same terminal. Every open window reconnects by itself, and conversations are kept.`}),(0,A.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>{a(!1),r()},className:`rounded bg-sky-700 px-2 py-0.5 text-white hover:bg-sky-800`,children:`Restart now`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:`rounded px-2 py-0.5 hover:bg-sky-100 dark:hover:bg-sky-900/50`,children:`Cancel`})]})]}):(0,A.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`mt-1 rounded border border-sky-300 px-2 py-0.5 hover:bg-sky-100 dark:border-sky-700 dark:hover:bg-sky-900/50`,children:`Restart pi-outpost`}):null]})}var OB=30,kB={display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`};function AB({skills:e,groups:t,enabled:n,onChange:r,disabled:i=!1,bound:a}){let[o,s]=(0,d.useState)(()=>e.length>40?new Set(e.filter(e=>n.has(e.relativePath)).map(e=>e.group)):new Set(t.map(e=>e.path))),[c,l]=(0,d.useState)(``),[u,f]=(0,d.useState)(!1),p=c.trim().toLocaleLowerCase(),m=p!==``||u,h=e=>(!u||n.has(e.relativePath))&&(!p||`${e.name} ${e.relativePath} ${e.description??``}`.toLocaleLowerCase().includes(p)),g=new Map;for(let t of e)g.set(t.group,[...g.get(t.group)??[],t]);let _=e.filter(e=>n.has(e.relativePath)).length,v=m?e.filter(h).length:e.length,y=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n.relativePath):i.delete(n.relativePath);r(i)},b=e=>{let t=new Set(n);t.has(e)?t.delete(e):t.add(e),r(t)},x=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,A.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,"aria-label":`Collection skills`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,A.jsxs)(`h3`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:[`Skills `,(0,A.jsxs)(`span`,{className:`font-normal text-zinc-500`,children:[`· `,_,` of `,e.length,` on`]})]}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,disabled:i||_===e.length,onClick:()=>y(e,!0),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All on`}),(0,A.jsx)(`button`,{type:`button`,disabled:i||_===0,onClick:()=>y(e,!1),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All off`})]})]}),a?(0,A.jsx)(`p`,{className:`mt-2 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:a.kind===`count`?`This repository holds more skills than the ${a.limit} listed here.`:`Folders deeper than ${a.limit} levels were not searched for skills.`}):null,e.length>0?(0,A.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(`input`,{type:`search`,"aria-label":`Search skills`,placeholder:`Search skills by name or folder`,value:c,onChange:e=>l(e.target.value),className:`min-w-0 flex-1 rounded-md border bg-transparent px-2.5 py-1 text-xs`}),(0,A.jsxs)(`button`,{type:`button`,"aria-pressed":u,onClick:()=>f(e=>!e),className:`rounded-md px-2.5 py-1 text-xs ${u?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:[`Only on (`,_,`)`]})]}):null,!m&&_>0&&_<=OB?(0,A.jsxs)(`div`,{role:`region`,"aria-label":`Skills that are on`,className:`mt-3 rounded-lg border border-emerald-200 bg-emerald-50/60 p-2 dark:border-emerald-900 dark:bg-emerald-950/30`,children:[(0,A.jsx)(`p`,{className:`px-1 text-[11px] font-medium text-emerald-800 dark:text-emerald-300`,children:`Turned on`}),(0,A.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.filter(e=>n.has(e.relativePath)).map(e=>(0,A.jsxs)(`li`,{className:`flex items-start justify-between gap-2 px-1`,children:[(0,A.jsxs)(`span`,{className:`min-w-0 text-xs`,children:[(0,A.jsx)(`span`,{className:`font-medium text-zinc-800 dark:text-zinc-100`,children:e.name}),` `,(0,A.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.group||`(repository root)`}),(0,A.jsx)(jB,{skill:e,checked:!0})]}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Turn off ${e.name} (${e.relativePath})`,disabled:i,onClick:()=>b(e.relativePath),className:`shrink-0 rounded border bg-white px-2 py-0.5 text-[11px] disabled:opacity-50 dark:bg-zinc-900`,children:`Turn off`})]},e.relativePath))})]}):null,e.length===0?(0,A.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`This repository holds no skills.`}):null,m&&v===0?(0,A.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:u&&!p?`No skill is on.`:`No skill matches.`}):null,(0,A.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>{let t=g.get(e.path)??[],r=m?t.filter(h):t;if(m&&r.length===0)return null;let a=r.filter(e=>n.has(e.relativePath)).length,s=m||o.has(e.path);return(0,A.jsxs)(`li`,{className:`rounded-lg border border-zinc-100 dark:border-zinc-800`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,A.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:()=>x(e.path),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-zinc-400`,children:s?`▾`:`▸`}),(0,A.jsx)(`span`,{className:`truncate font-mono text-xs font-medium text-zinc-700 dark:text-zinc-200`,children:e.label}),(0,A.jsxs)(`span`,{className:`shrink-0 text-[11px] text-zinc-500`,children:[a,`/`,r.length,` on`]})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,A.jsx)(`button`,{type:`button`,"aria-label":`All on in ${e.label}`,disabled:i||a===r.length,onClick:()=>y(r,!0),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All on`}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`All off in ${e.label}`,disabled:i||a===0,onClick:()=>y(r,!1),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All off`})]})]}),s?(0,A.jsx)(`ul`,{className:`space-y-1 border-t border-zinc-100 px-3 py-2 dark:border-zinc-800`,children:r.map(e=>{let t=n.has(e.relativePath);return(0,A.jsx)(`li`,{children:(0,A.jsxs)(`label`,{className:`flex items-start gap-2 rounded px-1 py-1 ${i?`opacity-60`:`cursor-pointer hover:bg-zinc-50 dark:hover:bg-zinc-800/60`}`,children:[(0,A.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":t,"aria-label":`${e.name} (${e.relativePath})`,checked:t,disabled:i,onChange:()=>b(e.relativePath),className:`mt-0.5`}),(0,A.jsxs)(`span`,{className:`min-w-0`,children:[(0,A.jsx)(`span`,{className:`block truncate text-sm text-zinc-800 dark:text-zinc-100`,children:e.name}),e.description?(0,A.jsx)(`span`,{title:e.description,style:kB,className:`text-[11px] text-zinc-500`,children:e.description}):null,(0,A.jsx)(jB,{skill:e,checked:t})]})]})},e.relativePath)})}):null]},e.path)})})]})}function jB({skill:e,checked:t}){return t===(e.state!==`off`)?e.state===`on-loaded`?(0,A.jsx)(`span`,{className:`block text-[11px] text-emerald-700 dark:text-emerald-400`,children:`Loaded`}):e.state===`on-not-loaded`?(0,A.jsxs)(`span`,{className:`block text-[11px] text-amber-700 dark:text-amber-400`,children:[`Not loaded — `,e.reason]}):e.state===`on-missing`?(0,A.jsxs)(`span`,{className:`block text-[11px] text-rose-700 dark:text-rose-400`,children:[`Missing — `,e.reason]}):null:(0,A.jsx)(`span`,{className:`block text-[11px] font-medium text-sky-700 dark:text-sky-300`,children:t?`Pending: on`:`Pending: off`})}function MB(e,t){return[...new Set(e.map(e=>e.group))].sort().map(e=>({path:e,label:e||t}))}function NB(e){return e.skills.filter(e=>e.state!==`off`).map(e=>e.relativePath)}function PB(e,t){let n=new Set(e),r=new Set(t);return n.size===r.size&&[...n].every(e=>r.has(e))}function FB(e,t){if(t.status===`loading`)return`Removing ${e}…`;if(t.status===`error`)return t.message??`Could not remove ${e}`;let n=t.result;return n?n.status===`removed`?`Removed ${e} and deleted ${n.path}.`:n.status===`removed-files-kept`?`Removed ${e}. ${n.reason??`Its files were kept`} (${n.path}).`:`Removed ${e}, but not every file could be deleted${n.reason?` — ${n.reason}`:``}. What remains is at ${n.path}.`:`Removed ${e}.`}var IB={unchecked:`Not checked`,checking:`Checking…`,current:`Up to date`,updateable:`Update available`,dirty:`Local changes`,detached:`Detached HEAD`,ahead:`Local branch ahead`,diverged:`Histories diverged`,"no-upstream":`No upstream`,locked:`Locked`,busy:`Workspace busy`,unavailable:`Unavailable`,failed:`Check failed`};function LB(e){if(!e)return[];let t=new Map(e.resources.map(e=>[e.id,e])),n=new Set(e.repositories.flatMap(e=>e.resourceIds)),r=e.repositories.map(e=>({id:e.id,name:e.name,path:e.path,repository:e,resources:e.resourceIds.flatMap(e=>t.get(e)?[t.get(e)]:[])})),i=e.resources.filter(e=>!n.has(e.id)),a=i.filter(e=>e.unavailableReason),o=i.filter(e=>!e.unavailableReason);return o.length&&r.push({id:`local`,name:`Local and built in`,reason:`Not backed by an updateable Git repository`,resources:o}),a.length&&r.push({id:`unavailable`,name:`Provenance unavailable`,reason:`The active runtime did not report enough filesystem provenance`,resources:a}),r}function RB(e){let t=e.length;for(;t>0&&(e[t-1]===`/`||e[t-1]===`\\`);)--t;return t===e.length?e:e.slice(0,t)}function zB(e){let t=RB(e),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<=0?`/`:t.slice(0,n)}function BB(e,t){let n=RB(t),r=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`)),i=r>=0?n.slice(r+1):n;return`${RB(e)}/${i||`agent-resources`}`}function VB({kind:e,resources:t,removalLocked:n=!1,onRemove:r}){return(0,A.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center justify-between text-sm font-semibold capitalize text-zinc-800 dark:text-zinc-200`,children:[(0,A.jsxs)(`span`,{children:[e,`s`]}),(0,A.jsx)(`span`,{className:`text-xs font-normal text-zinc-400`,children:t.length})]}),t.length===0?(0,A.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`None in this group`}):(0,A.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>(0,A.jsxs)(`li`,{className:`rounded-lg bg-zinc-50 px-3 py-2 dark:bg-zinc-800/70`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,A.jsx)(`p`,{className:`truncate text-sm font-medium text-zinc-700 dark:text-zinc-200`,children:e.name}),e.userRoot&&!n?(0,A.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.userRoot}`,onClick:()=>r(e),className:`text-xs text-zinc-500 hover:text-red-600`,children:`Remove`}):null]}),(0,A.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-400`,title:e.path,children:e.path??e.unavailableReason??`Path unavailable`})]},e.id))})]})}function HB({preview:e,busy:t,error:n,onApply:r,onCancel:i}){let[a,o]=(0,d.useState)(()=>new Set(e.roots.filter(e=>!e.locked).map(e=>`${e.kind}:${e.path}`))),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(()=>new Set),f=e.mode===`collection`,p=(0,d.useMemo)(()=>e.skills.map(e=>({...e,state:`off`})),[e.skills]),m=(0,d.useMemo)(()=>MB(e.skills,e.repositoryName),[e.skills,e.repositoryName]),h=e.roots.filter(e=>e.kind===`extension`&&a.has(`extension:${e.path}`)),g=h.length>0&&!s,_=t||!f&&a.size===0||g,v=()=>{let t=h.map(e=>e.path);f?r([],t,[...l]):r(e.roots.filter(e=>e.kind===`skill`&&a.has(`skill:${e.path}`)).map(e=>e.path),t)},y=e=>{c(!1),o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,A.jsxs)(`div`,{className:`space-y-3`,"data-testid":`resource-preview`,children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h3`,{className:`truncate text-xl font-semibold text-zinc-900 dark:text-zinc-100`,children:e.repositoryName}),(0,A.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-500`,title:e.repositoryPath,children:e.repositoryPath})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:i,className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,disabled:_,onClick:v,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:t?`Saving…`:`Save`})]})]}),g?(0,A.jsx)(`p`,{className:`text-xs text-amber-700`,children:`Confirm the extension warning below to save.`}):null,n?(0,A.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:n}):null,f?(0,A.jsx)(AB,{skills:p,groups:m,enabled:l,onChange:u,disabled:t,...e.bound?{bound:e.bound}:{}}):null,e.roots.map(e=>{let t=`${e.kind}:${e.path}`;return(0,A.jsxs)(`label`,{className:`flex items-start gap-2 rounded border p-2 ${e.locked?`opacity-50`:`cursor-pointer`}`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:a.has(t),disabled:e.locked,onChange:()=>y(t)}),(0,A.jsxs)(`span`,{children:[(0,A.jsxs)(`span`,{className:`block text-sm`,children:[e.name,` · `,e.kind]}),(0,A.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.path}),e.locked?(0,A.jsx)(`span`,{className:`block text-xs text-amber-700`,children:`Extension paths are locked`}):null]})]},t)}),h.length>0?(0,A.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),(0,A.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust the selected extension roots in this repository.`})]}):null]})}function UB(e){let t=(0,d.useRef)(null),n=(0,d.useRef)(e.onClose),r=(0,d.useRef)(!1),[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(`all`),[u,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(null),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(`skill`),[y,b]=(0,d.useState)(``),[x,S]=(0,d.useState)(!1),[C,w]=(0,d.useState)(``),[T,ee]=(0,d.useState)(``),[E,D]=(0,d.useState)(!1),[te,ne]=(0,d.useState)(``),[re,ie]=(0,d.useState)(null),[O,ae]=(0,d.useState)({}),[k,oe]=(0,d.useState)(null),[se,ce]=(0,d.useState)(null),le=(0,d.useMemo)(()=>LB(e.inventory),[e.inventory]),ue=(0,d.useMemo)(()=>{let e=o.trim().toLocaleLowerCase();return le.flatMap(t=>{let n=`repository`in t?t.repository.collection:void 0,r=n?t.resources.filter(e=>e.kind!==`skill`):t.resources,i=c===`all`?r:r.filter(e=>e.kind===c),a=n&&c!==`extension`?n.skills:[],o=i.length+a.length;if(o===0&&!(n&&c===`all`)||u&&(!(`repository`in t)||![`updateable`,`dirty`,`failed`,`unavailable`,`busy`].includes(t.repository.assessment.status)))return[];let s=`${t.name} ${`path`in t?t.path??``:``} ${i.map(e=>`${e.name} ${e.path??``}`).join(` `)} ${a.map(e=>`${e.name} ${e.relativePath}`).join(` `)}`.toLocaleLowerCase(),l=n?n.skills.filter(e=>e.state!==`off`).length:void 0;return!e||s.includes(e)?[{...t,resources:i,count:o,...l===void 0?{}:{onCount:l}}]:[]})},[le,u,c,o]),de=ue.find(e=>e.id===i)??ue[0]??null;if((0,d.useEffect)(()=>{n.current=e.onClose},[e.onClose]),(0,d.useEffect)(()=>{ae(t=>{let n={},r=!1;for(let[i,a]of Object.entries(t)){let t=e.inventory?.repositories.find(e=>e.id===i)?.collection;!t||PB(a,NB(t))?r=!0:n[i]=a}return r?n:t})},[e.inventory]),(0,d.useEffect)(()=>{e.open&&t.current?.focus()},[e.open]),(0,d.useEffect)(()=>{if(!e.open)return;let t=e=>{e.key===`Escape`&&n.current()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.open]),(0,d.useEffect)(()=>{let t=e.operations.clonePath;t?.status===`ready`&&t.path&&!E&&ee(t.path)},[E,e.operations.clonePath]),(0,d.useEffect)(()=>{e.operations.enrollment?.status===`ready`&&m(null)},[e.operations.enrollment]),(0,d.useEffect)(()=>{e.applyState?.status===`applying`?r.current=!0:r.current&&e.applyState===null&&(r.current=!1,m(null),g(null),S(!1))},[e.applyState]),!e.open)return null;let fe=de&&`repository`in de?de.repository:null,j=fe?e.operations.updates[fe.id]:void 0,pe=fe?.assessment,me=pe?.status===`updateable`&&pe.token&&pe.localRevision&&pe.upstreamRevision,he=()=>{let t=y.trim();t&&(_===`skill`?e.onUpdateConfig({userSkillPaths:[...new Set([...e.userSkillPaths,t])]}):e.onUpdateConfig({userExtensionPaths:[...new Set([...e.userExtensionPaths,t])]}))},ge=t=>{t.userRoot&&(t.kind===`skill`?e.onUpdateConfig({userSkillPaths:e.userSkillPaths.filter(e=>e!==t.userRoot)}):e.onUpdateConfig({userExtensionPaths:e.userExtensionPaths.filter(e=>e!==t.userRoot)}))},_e=(t,n=!1)=>{let r=t.assessment;r.token&&r.localRevision&&r.upstreamRevision&&e.onUpdate(t.id,r.token,r.localRevision,r.upstreamRevision,n)},ve=fe?.collection,ye=ve?NB(ve):[],be=new Set(fe&&O[fe.id]?O[fe.id]:ye),xe=ve?[...new Set([...be,...ye])].filter(e=>be.has(e)!==ye.includes(e)).length:0,Se=fe?e.operations.skills?.[fe.id]:void 0,Ce=e=>{if(!fe)return;let t=fe.id;ae(n=>{let r={...n};return PB(e,ye)?delete r[t]:r[t]=[...e],r})},we=()=>{if(!fe)return;let e=fe.id;ae(t=>{let n={...t};return delete n[e],n})},Te=()=>{if(!fe||!ve)return;let t=new Set(ve.skills.filter(e=>e.state!==`on-missing`).map(e=>e.relativePath));e.onSetSkills(fe.id,[...be].filter(e=>t.has(e)))},Ee=se?e.operations.removals?.[se.id]:void 0,De=Ee?.status===`error`||Ee?.result?.status===`removed-delete-failed`;return(0,A.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/45 p-4`,role:`presentation`,onMouseDown:t=>{t.currentTarget===t.target&&e.onClose()},children:[(0,A.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`agent-resources-title`,className:`flex h-[min(760px,92vh)] w-[min(1120px,96vw)] flex-col overflow-hidden rounded-2xl border border-zinc-200 bg-white shadow-2xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,A.jsxs)(`header`,{className:`flex items-center justify-between border-b border-zinc-200 px-5 py-4 dark:border-zinc-800`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{id:`agent-resources-title`,className:`text-lg font-semibold text-zinc-900 dark:text-zinc-100`,children:`Agent resources`}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Skills and extensions, grouped by repository`})]}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(),className:`rounded-md border px-3 py-1.5 text-xs disabled:opacity-50`,children:`Refresh all`}),(0,A.jsx)(`button`,{ref:t,type:`button`,"aria-label":`Close agent resources`,onClick:e.onClose,className:`rounded-md border px-2 py-1 text-sm`,children:`✕`})]})]}),(0,A.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[300px_1fr]`,children:[(0,A.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-r border-zinc-200 bg-zinc-50/80 p-3 dark:border-zinc-800 dark:bg-zinc-950/40`,children:[(0,A.jsx)(`input`,{"aria-label":`Search resources`,value:o,onChange:e=>s(e.target.value),placeholder:`Search repositories or resources`,className:`rounded-md border bg-white px-3 py-2 text-xs dark:bg-zinc-900`}),(0,A.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[[`all`,`skill`,`extension`].map(e=>(0,A.jsx)(`button`,{type:`button`,"aria-pressed":c===e,onClick:()=>l(e),className:`rounded px-2 py-1 text-[11px] ${c===e?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:e===`all`?`All`:`${e}s`},e)),(0,A.jsx)(`button`,{type:`button`,"aria-pressed":u,onClick:()=>f(e=>!e),className:`rounded px-2 py-1 text-[11px] ${u?`bg-amber-600 text-white`:`border`}`,children:`Needs attention`})]}),(0,A.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 space-y-1 overflow-y-auto`,children:[ue.map(e=>(0,A.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),className:`w-full rounded-lg px-3 py-2.5 text-left ${de?.id===e.id?`bg-white shadow-sm ring-1 ring-zinc-200 dark:bg-zinc-800 dark:ring-zinc-700`:`hover:bg-white/70 dark:hover:bg-zinc-900`}`,children:[(0,A.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-sm font-medium`,children:[(0,A.jsx)(`span`,{className:`truncate`,children:e.name}),(0,A.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400`,children:e.onCount===void 0?e.count??e.resources.length:`${e.onCount} on · ${e.count}`})]}),(0,A.jsx)(`span`,{className:`mt-1 block text-xs text-zinc-500`,children:`repository`in e?IB[e.repository.assessment.status]:e.reason})]},e.id)),ue.length===0?(0,A.jsx)(`p`,{className:`px-2 py-4 text-xs text-zinc-500`,children:`No matching resources`}):null]}),(0,A.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t pt-3`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>{S(!1),m(`local`),g(`local`),e.onBrowseServerPath(y||`/`)},className:`rounded-md border bg-white px-3 py-2 text-xs font-medium dark:bg-zinc-900`,children:`Add local folder…`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>m(`git`),className:`rounded-md bg-zinc-900 px-3 py-2 text-xs font-medium text-white dark:bg-zinc-100 dark:text-zinc-900`,children:`Add Git repository…`})]})]}),(0,A.jsxs)(`main`,{className:`min-w-0 overflow-y-auto p-6`,children:[se&&Ee?(0,A.jsxs)(`div`,{role:De?`alert`:`status`,className:`mb-4 flex items-start justify-between gap-3 rounded-lg border p-3 text-sm ${De?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[(0,A.jsx)(`p`,{className:`min-w-0 break-words`,children:FB(se.name,Ee)}),Ee.status===`loading`?null:(0,A.jsx)(`button`,{type:`button`,onClick:()=>ce(null),className:`shrink-0 text-xs underline`,children:`Dismiss`})]}):null,p===`local`?(0,A.jsxs)(`div`,{className:`max-w-xl space-y-4`,"data-testid":`add-local-folder`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add local folder`}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Choose an existing folder on the server and how the agent should load it.`})]}),(0,A.jsx)(`div`,{className:`flex gap-2`,children:[`skill`,`extension`].map(t=>(0,A.jsx)(`button`,{type:`button`,"aria-pressed":_===t,disabled:t===`extension`&&e.extensionLock,onClick:()=>{v(t),S(!1)},className:`rounded-md px-3 py-1.5 text-xs ${_===t?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:t===`skill`?`Skill folder`:`Extension folder`},t))}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(`input`,{"aria-label":`Local resource folder`,value:y,onChange:e=>{S(!1),b(e.target.value)},className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{g(`local`),e.onBrowseServerPath(y||`/`)},className:`rounded-md border px-3 text-xs`,children:`Browse…`})]}),h===`local`?(0,A.jsx)(mB,{label:`Choose a local resource folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{S(!1),b(t),g(null),e.onCloseServerBrowser()},onCancel:()=>{g(null),e.onCloseServerBrowser()}}):null,_===`extension`?(0,A.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),(0,A.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust every extension in this folder.`})]}):null,e.extensionLock?(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Extension paths are locked by this deployment.`}):null,e.applyState?.status===`error`?(0,A.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.applyState.message}):null,(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>{S(!1),m(null),g(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,disabled:!y.trim()||e.applyState?.status===`applying`||_===`extension`&&(!x||e.extensionLock),onClick:he,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.applyState?.status===`applying`?`Applying…`:`Add folder`})]})]}):p===`git`?(0,A.jsx)(`div`,{className:`max-w-2xl space-y-4`,"data-testid":`add-git-repository`,children:e.operations.preview?.status===`ready`&&e.operations.preview.preview?(0,A.jsx)(HB,{onCancel:()=>{m(null),g(null),e.onCloseServerBrowser()},preview:e.operations.preview.preview,busy:e.operations.enrollment?.status===`loading`,error:e.operations.enrollment?.status===`error`?e.operations.enrollment.message:void 0,onApply:(t,n,r)=>r?e.onEnrollRepository(e.operations.preview.preview.token,t,n,r):e.onEnrollRepository(e.operations.preview.preview.token,t,n)}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add Git repository`}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Clone it to a local folder, then choose what to turn on.`})]}),(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsx)(`span`,{className:`text-xs font-medium`,children:`Repository address`}),(0,A.jsx)(`input`,{"aria-label":`Repository address`,value:C,onChange:e=>w(e.target.value),onBlur:()=>{let t=C.trim();t&&(D(!1),ne(t),e.onSuggestClonePath(C))},placeholder:`https://github.com/team/resources.git`,className:`mt-1 w-full rounded-md border bg-transparent px-3 py-2 text-sm`})]}),(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsx)(`span`,{className:`text-xs font-medium`,children:`Local folder`}),(0,A.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,A.jsx)(`input`,{"aria-label":`Local clone folder`,value:T,onChange:e=>{D(!0),ee(e.target.value)},placeholder:`/path/to/resource-repositories/team-resources-ab12cd`,className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{g(`clone-parent`),e.onBrowseServerPath(zB(T))},className:`rounded-md border px-3 text-xs`,children:`Choose parent…`})]})]}),e.operations.clonePath?.status===`loading`?(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Suggesting a managed folder…`}):null,e.operations.clonePath?.status===`error`&&C.trim()===te?(0,A.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.clonePath.message}):null,h===`clone-parent`?(0,A.jsx)(mB,{label:`Choose the clone's parent folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{ee(BB(t,T)),g(null),e.onCloseServerBrowser()},onCancel:()=>{g(null),e.onCloseServerBrowser()}}):null,e.operations.preview?.status===`error`?(0,A.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.preview.message}):null,(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>{m(null),g(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,disabled:!C.trim()||!T.trim()||e.operations.preview?.status===`loading`,onClick:()=>e.onCloneRepository(C,T),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.operations.preview?.status===`loading`?`Cloning…`:`Clone and inspect`})]})]})}):de?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-xl font-semibold`,children:de.name}),fe?(0,A.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[11px]`,children:IB[fe.assessment.status]}):null]}),(0,A.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-zinc-500`,children:`repository`in de?de.path:de.reason}),pe?.branch?(0,A.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-400`,children:[pe.branch,pe.upstream?` → ${pe.upstream}`:``]}):null,fe?.removal&&!fe.removal.allowed?(0,A.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:fe.removal.reason}):null]}),fe?(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[fe.removal?.allowed?(0,A.jsx)(`button`,{type:`button`,disabled:e.operations.removals?.[fe.id]?.status===`loading`,onClick:()=>oe(fe),className:`rounded-md border border-red-200 px-3 py-1.5 text-xs text-red-700 disabled:opacity-50 dark:border-red-900 dark:text-red-400`,children:`Remove repository`}):null,(0,A.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(fe.id),className:`rounded-md border px-3 py-1.5 text-xs`,children:`Check`}),me||j?.status===`loading`?(0,A.jsx)(`button`,{type:`button`,disabled:j?.status===`loading`,onClick:()=>fe.containsExtensions?ie(fe):_e(fe),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:j?.status===`loading`?`Updating…`:`Update repository`}):null]}):null]}),pe?.reason?(0,A.jsxs)(`div`,{className:`mt-5 rounded-lg border p-3 text-sm ${pe.status===`dirty`?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[pe.reason,pe.status===`dirty`?(0,A.jsx)(`p`,{className:`mt-1 text-xs`,children:`Review and resolve these local changes in an external terminal, then check again. This updater never commits, stashes, discards, rebases, or merges them.`}):null]}):null,pe?.hasSubmodules?(0,A.jsx)(`p`,{className:`mt-3 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:`This repository declares submodules. Their working trees will not be initialized or updated.`}):null,j?.status===`ready`?(0,A.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-zinc-600`,children:j.result?.status===`updated`&&j.result.reloads.some(e=>e.status===`restart-required`)?`Repository updated. Its skills are reloaded; its extension code runs after pi-outpost restarts — restart it from Settings.`:j.result?.status===`updated`?`Repository updated and runtimes reloaded.`:j.result?.status===`updated-reload-failed`?`Repository updated on disk, but at least one runtime failed to reload.`:j.result?.reason}):null,j?.status===`error`?(0,A.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-red-600`,children:j.message}):null,ve&&fe&&c!==`extension`?(0,A.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[xe>0||Se?.status===`loading`?(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-sky-200 bg-sky-50 px-3 py-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,children:[(0,A.jsx)(`span`,{children:Se?.status===`loading`?`Applying…`:`${xe} pending change${xe===1?``:`s`} — applying replaces the session`}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,disabled:Se?.status===`loading`,onClick:we,className:`rounded border bg-white px-2.5 py-1 disabled:opacity-50 dark:bg-zinc-900`,children:`Discard`}),(0,A.jsx)(`button`,{type:`button`,disabled:Se?.status===`loading`||xe===0,onClick:Te,className:`rounded bg-zinc-900 px-2.5 py-1 font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:`Apply`})]})]}):null,Se?.status===`error`?(0,A.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:Se.message}):null,(0,A.jsx)(AB,{skills:ve.skills,groups:ve.groups,enabled:be,onChange:Ce,disabled:Se?.status===`loading`,...ve.bound?{bound:ve.bound}:{}},fe.id),de.resources.some(e=>e.kind===`extension`)?(0,A.jsx)(VB,{kind:`extension`,resources:de.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:ge}):null]}):(0,A.jsxs)(`div`,{className:`mt-6 grid grid-cols-2 gap-4`,children:[(0,A.jsx)(VB,{kind:`skill`,resources:de.resources.filter(e=>e.kind===`skill`),onRemove:ge}),(0,A.jsx)(VB,{kind:`extension`,resources:de.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:ge})]})]}):(0,A.jsx)(`p`,{className:`text-sm text-zinc-500`,children:`No resources are reported by this runtime.`})]})]})]}),re?(0,A.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,A.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`extension-update-title`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,A.jsx)(`h3`,{id:`extension-update-title`,className:`font-semibold`,children:`Update executable extensions?`}),(0,A.jsxs)(`p`,{className:`mt-2 text-sm text-zinc-600 dark:text-zinc-300`,children:[re.name,` contains extensions that run with the agent's privileges. Confirm updating `,re.assessment.localRevision?.slice(0,8),` to `,re.assessment.upstreamRevision?.slice(0,8),`.`]}),(0,A.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>ie(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{_e(re,!0),ie(null)},className:`rounded bg-amber-600 px-3 py-1.5 text-xs font-medium text-white`,children:`Confirm executable update`})]})]})}):null,k?(0,A.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,A.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`remove-repository-title`,"aria-describedby":`remove-repository-detail`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,A.jsxs)(`h3`,{id:`remove-repository-title`,className:`font-semibold`,children:[`Remove `,k.name,`?`]}),(0,A.jsx)(`p`,{id:`remove-repository-detail`,className:`mt-2 break-words text-sm text-zinc-600 dark:text-zinc-300`,children:k.removal?.deletesFiles?(0,A.jsxs)(A.Fragment,{children:[`This stops loading everything from `,k.name,` and deletes `,(0,A.jsx)(`span`,{className:`font-mono`,children:k.removal.path}),` from disk, with any local changes in it. This cannot be undone.`]}):(0,A.jsxs)(A.Fragment,{children:[`This stops loading everything from `,k.name,`. pi-outpost does not manage `,(0,A.jsx)(`span`,{className:`font-mono`,children:k.removal?.path??k.path}),`, so its files will be kept.`]})}),(0,A.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>oe(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{e.onRemoveRepository(k.id),ce({id:k.id,name:k.name}),oe(null)},className:`rounded bg-red-600 px-3 py-1.5 text-xs font-medium text-white`,children:k.removal?.deletesFiles?`Delete and remove`:`Remove repository`})]})]})}):null]})}var WB=`w-full rounded-md border border-zinc-300 bg-white px-3 py-2 text-sm text-zinc-800 placeholder:text-zinc-400 focus:border-zinc-400 focus:outline-none dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-100 dark:placeholder:text-zinc-600`,GB=`rounded-md border border-zinc-300 px-3 py-1.5 text-xs font-medium text-zinc-700 hover:bg-zinc-50 disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`;function KB({event:e}){switch(e.type){case`auth_url`:return(0,A.jsxs)(`div`,{"data-testid":`login-auth-url`,className:`space-y-1`,children:[(0,A.jsx)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:e.instructions??`Open this page to sign in:`}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`truncate text-sm text-sky-700 underline dark:text-sky-400`,children:e.url}),(0,A.jsx)(`button`,{type:`button`,className:GB,onClick:()=>void navigator.clipboard?.writeText(e.url),children:`Copy`})]})]});case`device_code`:return(0,A.jsxs)(`div`,{"data-testid":`login-device-code`,className:`space-y-1`,children:[(0,A.jsxs)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:[`Enter this code at`,` `,(0,A.jsx)(`a`,{href:e.verificationUri,target:`_blank`,rel:`noopener noreferrer`,className:`text-sky-700 underline dark:text-sky-400`,children:e.verificationUri}),`:`]}),(0,A.jsx)(`p`,{className:`select-all font-mono text-2xl tracking-widest text-zinc-900 dark:text-zinc-50`,children:e.userCode})]});case`info`:return(0,A.jsxs)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:[e.message,e.links?.map(e=>(0,A.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`ml-2 text-sky-700 underline dark:text-sky-400`,children:e.label??e.url},e.url))]});case`progress`:return(0,A.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:e.message})}}function qB({prompt:e,onAnswer:t}){let[n,r]=(0,d.useState)(``),i=e.type===`manual_code`&&/^http:\/\/(?:localhost|127\.0\.0\.1):1455\/auth\/callback\/?$/.test(e.placeholder??``);return e.type===`select`?(0,A.jsxs)(`div`,{"data-testid":`login-prompt`,className:`space-y-2`,children:[(0,A.jsx)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:e.message}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.options.map(e=>(0,A.jsx)(`button`,{type:`button`,className:GB,title:e.description,onClick:()=>t(e.id),children:e.label},e.id))})]}):(0,A.jsxs)(`div`,{"data-testid":`login-prompt`,className:`space-y-2`,children:[(0,A.jsxs)(`label`,{className:`block text-sm text-zinc-700 dark:text-zinc-200`,children:[e.type===`manual_code`?`${e.message} — or the whole address the browser was sent to`:e.message,(0,A.jsx)(`input`,{className:`${WB} mt-1`,type:e.type===`secret`?`password`:`text`,name:`provider-auth-response`,placeholder:e.placeholder,autoComplete:`off`,spellCheck:e.type!==`manual_code`,autoFocus:!0,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),n.trim()&&t(n.trim()))}})]}),i&&(0,A.jsx)(`p`,{className:`text-xs text-zinc-600 dark:text-zinc-300`,children:`If Pi Outpost runs on another computer, your browser may say it cannot connect to localhost. Copy the full address from that browser page and paste it above to finish signing in.`}),(0,A.jsx)(`button`,{type:`button`,className:GB,disabled:!n.trim(),onClick:()=>t(n.trim()),children:`Continue`})]})}function JB({login:e,providerName:t,onAnswer:n,onCancel:r,onDismiss:i}){return(0,A.jsxs)(`div`,{"data-testid":`login-flow`,className:`space-y-3 rounded-md border border-zinc-200 p-3 dark:border-zinc-700`,children:[(0,A.jsxs)(`p`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:[`Signing in to `,t]}),(0,A.jsxs)(`div`,{"aria-live":`polite`,"aria-atomic":`false`,children:[e.events.map((e,t)=>(0,A.jsx)(KB,{event:e},t)),e.prompt&&(0,A.jsx)(qB,{prompt:e.prompt.prompt,onAnswer:n},e.prompt.promptId),!e.done&&!e.prompt&&e.events.length===0&&(0,A.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`Starting…`}),e.done?(0,A.jsxs)(`div`,{"data-testid":`login-done`,"data-ok":e.done.ok?`true`:`false`,className:`space-y-2`,children:[(0,A.jsx)(`p`,{className:`text-sm ${e.done.ok?`text-emerald-700 dark:text-emerald-400`:`text-red-700 dark:text-red-400`}`,children:e.done.ok?`Signed in to ${t}.`:e.done.cancelled?`Sign-in cancelled.`:`Sign-in failed: ${e.done.message??`unknown error`}`}),(0,A.jsx)(`button`,{type:`button`,className:GB,onClick:i,children:`Close`})]}):(0,A.jsx)(`button`,{type:`button`,className:GB,onClick:r,children:`Cancel`})]})]})}function YB(e){return[...e].sort((e,t)=>e.localeCompare(t))}function XB(e,t){return e===`models_json_key`?`This key is managed in models.json. Remove it from that provider configuration.`:e===`environment`?`This key comes from ${t??`the server environment`}. Remove it from there.`:`This key is managed by ${t??e??`the provider runtime`}. Remove it from that source.`}function ZB(e,t){return e===`models_json_key`?`models.json`:t??e}function QB({credentials:e,login:t,onStartLogin:n,onAnswerLogin:r,onCancelLogin:i,onDismissLogin:a,onLogoutProvider:o,extensionPaths:s,configuredExtensionPaths:c,userExtensionPaths:l,extensionLock:u,piPackages:f=null,piPackageUpdate:p=null,canRestartServer:m=!1,serverRestarting:h=!1,onCheckPiPackages:g,onUpdatePiPackage:_,onRestartServer:v,onRestartSession:y,restartNeeded:b=[],tools:x,commands:S,sandbox:C,showRoots:w=!0,gitUnavailable:T,userSkillPaths:ee,serverBrowse:E,pickerBlocked:D=!1,onPickerOpened:te,applyState:ne,agentResources:re=null,agentResourceOperations:ie={clonePath:null,preview:null,enrollment:null,refresh:null,updates:{},skills:{},removals:{}},versions:O,onBrowseServerPath:ae,onCloseServerBrowser:k,onUpdateConfig:oe,onSuggestAgentResourceClonePath:se=()=>{},onCloneAgentResourceRepository:ce=()=>{},onEnrollAgentResourceRepository:le=()=>{},onSetAgentResourceSkills:ue=()=>{},onRemoveAgentResourceRepository:de=()=>{},onRefreshAgentResourceRepositories:fe=()=>{},onUpdateAgentResourceRepository:j=()=>{}}){let[pe,me]=(0,d.useState)(!1),[he,ge]=(0,d.useState)(!1),_e=(0,d.useRef)(new Map),[ve,ye]=(0,d.useState)(!1),be=(0,d.useRef)(null),[xe,Se]=(0,d.useState)(``),[Ce,we]=(0,d.useState)(``),[Te,Ee]=(0,d.useState)(!1),[De,Oe]=(0,d.useState)(!1),[ke,Ae]=(0,d.useState)(null),je=(e,r)=>{if(t&&!t.done){i?.(),a?.();let e=_e.current.get(t.provider);e&&(e.open=!1)}else n?.(e,r)};(0,d.useEffect)(()=>{D&&ke!==null&&Ae(null)},[D,ke]);let Me=yR(()=>{(pe||ke!==null)&&Be()}),Ne=x.filter(e=>e.active),Pe=x.filter(e=>!e.active),Fe=S.filter(e=>e.source===`skill`),Ie=[...x].sort((e,t)=>e.name.localeCompare(t.name)||Number(t.active)-Number(e.active)),Le=ne?.status===`applying`,Re=ne?.status===`error`?ne.message:null;(0,d.useEffect)(()=>{C&&(Se(C.root),we(C.writableRoot??``),Ee(C.allowWrite),Oe(C.allowBash))},[C]);let ze=(0,d.useRef)(!1);(0,d.useEffect)(()=>{ze.current&&ne===null&&Be(),ze.current=Le},[ne,Le]);function Be(){ge(!1),me(!1),Ae(null),k()}function Ve(e,t){te?.(),Ae(e),ae(t.trim()||`/`)}function He(e){ke===`root`?Se(e):ke===`writableRoot`&&we(e),Ae(null),k()}let Ue=C!==null&&(xe!==C.root||(Ce.trim()||void 0)!==(C.writableRoot||void 0)||Te!==C.allowWrite||De!==C.allowBash);function We(){C&&Ue&&oe({sandbox:{root:xe,allowWrite:Te,allowBash:De,writableRoot:Ce.trim()||void 0}})}let Ge=w&&C?.rootEditable!==!1,Ke=ke!==null&&!D&&(0,A.jsx)(mB,{label:ke===`root`?`Choose the sandbox root`:`Choose the writable root`,browse:E,onBrowse:ae,onSelect:He,onCancel:()=>{Ae(null),k()}});return(0,A.jsxs)(`div`,{className:`relative`,ref:Me,children:[(0,A.jsx)(`button`,{ref:be,type:`button`,onClick:()=>{ge(!1),pe?Be():me(!0)},title:`Settings`,"aria-label":`Settings`,className:`${oB} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`⚙`}),pe&&(0,A.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[80vh] w-[380px] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,A.jsxs)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:[he&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>ge(!1),className:`mb-2 text-xs text-zinc-600 hover:underline dark:text-zinc-400`,children:`← Back to settings`}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:he?`Credits`:`Settings`})]}),(0,A.jsx)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:he?(0,A.jsx)(wB,{}):(0,A.jsxs)(A.Fragment,{children:[T&&(0,A.jsxs)(`section`,{className:`mb-4`,"data-testid":`git-unavailable`,children:[(0,A.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Version control`}),T.reason===`no-repository`?(0,A.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`This project is not in a git repository.`}):(0,A.jsxs)(`div`,{className:`rounded border border-amber-300 bg-amber-50 px-2 py-1.5 dark:border-amber-900 dark:bg-amber-950/40`,children:[(0,A.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-300`,children:T.reason===`no-executable`?`Git is unavailable: its executable could not be run.`:`Git is unavailable: it refused this repository.`}),(0,A.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-amber-700 dark:text-amber-400`,children:T.message}),T.reason===`no-executable`&&(0,A.jsxs)(`p`,{className:`mt-1 text-xs text-amber-700 dark:text-amber-400`,children:[`Install git, add it to PATH, or name it with `,(0,A.jsx)(`span`,{className:`font-mono`,children:`gitPath`}),` in the configuration.`]})]})]}),e&&(0,A.jsxs)(`details`,{className:`mb-4`,"data-testid":`accounts-panel`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:[`Accounts · `,(0,A.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:[e.providers.filter(e=>e.configured).length,` providers configured`]})]}),(0,A.jsxs)(`div`,{className:`mt-2`,children:[(0,A.jsx)(`ul`,{className:`space-y-2`,children:e.providers.map(n=>(0,A.jsx)(`li`,{className:`rounded border border-zinc-200 p-2 dark:border-zinc-700`,children:(0,A.jsxs)(`details`,{ref:e=>{e?_e.current.set(n.id,e):_e.current.delete(n.id)},"data-testid":`account-${n.id}`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer`,children:[(0,A.jsx)(`span`,{className:`text-xs font-medium text-zinc-800 dark:text-zinc-200`,children:n.name}),(0,A.jsx)(`span`,{className:`ml-2 text-[11px] ${n.configured?`text-emerald-700 dark:text-emerald-400`:`text-zinc-500 dark:text-zinc-400`}`,children:n.configured?`${n.auth??`Authenticated`}${n.source?` · ${ZB(n.source,n.label)}`:``}`:`Not signed in`})]}),(0,A.jsxs)(`div`,{className:`mt-2`,children:[n.configured&&n.auth===`api_key`&&n.source!==`stored`&&(0,A.jsx)(`p`,{className:`mb-2 text-[11px] text-zinc-500 dark:text-zinc-400`,children:XB(n.source,n.label)}),!e.locked&&(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[n.methods?.includes(`oauth`)&&(0,A.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>je(n.id,`oauth`),children:`Sign in`}),n.methods?.includes(`api_key`)&&(0,A.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>je(n.id,`api_key`),children:`API key`}),n.configured&&n.source===`stored`&&(0,A.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>o?.(n.id),children:n.auth===`api_key`?`Remove API key`:`Sign out`})]}),t?.provider===n.id&&(0,A.jsx)(`div`,{className:`mt-2`,children:(0,A.jsx)(JB,{login:t,providerName:n.name,onAnswer:e=>r?.(e),onCancel:()=>i?.(),onDismiss:()=>a?.()})})]})]})},n.id))}),e.locked&&(0,A.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`Credentials are locked by this server.`})]})]}),(0,A.jsxs)(`section`,{className:`mb-4`,children:[(0,A.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Agent resources`}),x.length===0?(0,A.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`Tool inventory unavailable for this runtime`}):(0,A.jsxs)(`details`,{"data-testid":`tools-loaded`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[Ne.length,` tools active`,Pe.length?` · ${Pe.length} inactive`:``]}),(0,A.jsx)(`ul`,{className:`mt-2 space-y-1`,children:Ie.map(e=>(0,A.jsxs)(`li`,{className:`flex justify-between rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:[(0,A.jsx)(`span`,{children:e.name}),(0,A.jsx)(`span`,{children:e.active?`active`:`inactive`})]},e.name))})]}),Fe.length===0?(0,A.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skills loaded`}):(0,A.jsxs)(`details`,{className:`mt-2`,"data-testid":`skills-loaded`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[Fe.length,` skills loaded`]}),(0,A.jsx)(`ul`,{className:`mt-2 space-y-1`,children:YB(Fe.map(e=>e.name)).map(e=>(0,A.jsx)(`li`,{className:`rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:e},e))})]}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Manage agent resources`,onClick:()=>{me(!1),ye(!0)},className:`mt-3 w-full rounded-md border border-zinc-300 px-3 py-2 text-xs font-medium text-zinc-700 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`,children:`Manage resources…`})]}),(0,A.jsxs)(`section`,{className:`mb-4`,children:[(0,A.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),s===null?(0,A.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-unknown`,children:`Not reported by this runtime`}):s.length===0?(0,A.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,A.jsxs)(`details`,{"data-testid":`extensions-loaded`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[s.length,` `,s.length===1?`extension`:`extensions`,` loaded`]}),(0,A.jsx)(`ul`,{className:`mt-2 space-y-1`,children:YB(s).map(e=>(0,A.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),c.length>0&&(0,A.jsxs)(`details`,{className:`mt-2`,"data-testid":`extensions-configured`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[c.length,` configured by this deployment`]}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`Declared in the configuration file. They load either way, and nothing here can remove them.`}),(0,A.jsx)(`ul`,{className:`mt-1 space-y-1`,children:YB(c).map(e=>(0,A.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),u?(0,A.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-locked`,children:`Extension paths and repository updates that contain extensions are locked by this deployment.`}):null,(0,A.jsx)(EB,{packages:f,update:p,locked:u,onCheck:()=>g?.(),onUpdate:e=>_?.(e)}),(0,A.jsx)(DB,{reasons:b,canRestart:m,restarting:h,onRestart:()=>v?.()})]}),C&&(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:Ge?`Sandbox`:`Agent permissions`}),(0,A.jsxs)(`div`,{className:`space-y-3`,children:[!Ge&&(0,A.jsxs)(`p`,{"data-testid":`sandbox-project-root`,className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`This project is confined to its own folder,`,` `,(0,A.jsx)(`span`,{className:`break-all font-mono text-zinc-800 dark:text-zinc-200`,children:C.projectRoot??C.root}),`. Each open project is confined to its own. A change here applies to this project now, and to projects opened after.`]}),Ge&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,C.locks?.root?(0,A.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,A.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,A.jsx)(`input`,{type:`text`,value:xe,onChange:e=>Se(e.target.value),disabled:C.locks?.root,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:focus:border-zinc-500`}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Browse for sandbox root`,disabled:C.locks?.root,onClick:()=>Ve(`root`,xe),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),ke===`root`&&Ke,(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,C.locks?.writableRoot?(0,A.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,A.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,A.jsx)(`input`,{type:`text`,value:Ce,onChange:e=>we(e.target.value),disabled:C.locks?.writableRoot,placeholder:`Same as root`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Browse for writable root`,disabled:C.locks?.writableRoot,onClick:()=>Ve(`writableRoot`,Ce||xe),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),ke===`writableRoot`&&Ke]}),(0,A.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:Te,onChange:e=>Ee(e.target.checked),disabled:C.locks?.allowWrite,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,A.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,C.locks?.allowWrite?(0,A.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,A.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:De,onChange:e=>Oe(e.target.checked),disabled:C.locks?.allowBash,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,A.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,C.locks?.allowBash?(0,A.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]})]})]}),!C&&(0,A.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),(0,A.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[Re&&(0,A.jsx)(`p`,{role:`alert`,className:`rounded-md border border-red-300 bg-red-50 px-2 py-1 text-xs text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:Re}),(0,A.jsx)(`button`,{type:`button`,disabled:Le||Ue&&!xe.trim(),onClick:Ue?We:y,className:`w-full rounded-md bg-zinc-800 px-3 py-1.5 text-xs font-medium text-white hover:bg-zinc-700 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-zinc-200 dark:text-zinc-900 dark:hover:bg-zinc-300`,children:Le?`Restarting…`:Ue?`Apply & restart session`:`Restart session`}),(0,A.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:Ue?`Saved to the server's configuration file, then the session is rebuilt — the change survives a restart.`:`Start a fresh session to reload extensions and MCP connections. Settings are kept.`})]}),O&&(0,A.jsxs)(`section`,{className:`mt-4`,children:[(0,A.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,A.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,A.jsxs)(`p`,{children:[`pi-outpost: `,(0,A.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:O.piOutpost})]}),O.piSdk&&(0,A.jsxs)(`p`,{children:[`pi SDK: `,(0,A.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:O.piSdk})]}),O.agent&&(0,A.jsxs)(`p`,{children:[`agent: `,(0,A.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:O.agent})]})]})]}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>ge(!0),className:`mt-4 w-full border-t border-zinc-200 pt-3 text-left text-sm text-zinc-600 hover:text-zinc-900 dark:border-zinc-700 dark:text-zinc-400 dark:hover:text-zinc-100`,children:`Credits →`})]})})]}),(0,A.jsx)(UB,{open:ve,inventory:re,operations:ie,extensionLock:u,userSkillPaths:ee,userExtensionPaths:l,serverBrowse:E,applyState:ne,onClose:()=>{ye(!1),k(),be.current?.focus()},onBrowseServerPath:e=>{te?.(),ae(e)},onCloseServerBrowser:k,onUpdateConfig:oe,onSuggestClonePath:se,onCloneRepository:ce,onEnrollRepository:le,onSetSkills:ue,onRemoveRepository:de,onRefresh:fe,onUpdate:j})]})}function $B(e){let t=[],n=new Set,r=0,i=0;function a(e,o,s,c){let l=e.children,u=l.slice(1).map(e=>[e,r++]);u.length>0&&i++;let d=e.onPath&&!l.some(e=>e.onPath);if(t.push({node:e,lane:o,through:[...n].filter(e=>e!==o),forkTo:u.map(([,e])=>e),lineAbove:s,lineBelow:l.length>0,branchIndex:c,isCurrent:d,emphasis:d?`current`:e.onPath?`filled`:`hollow`,highlight:e.onPath}),l.length===0)n.delete(o);else{for(let[,e]of u)n.add(e);a(l[0],o,!0,u.length>0?1:void 0),u.forEach(([e,t],n)=>a(e,t,!0,n+2))}}return e.length>1&&i++,e.forEach((t,i)=>{let o=r++;n.add(o),a(t,o,!1,e.length>1?i+1:void 0)}),{rows:t,laneCount:r,branchPoints:i}}function eV(e){return e.flatMap(e=>[e,...eV(e.children)])}function tV({children:e,tone:t}){let n={current:`border-emerald-300 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-950/50 dark:text-emerald-300`,branch:`border-zinc-300 text-zinc-500 dark:border-zinc-700 dark:text-zinc-400`,label:`border-violet-300 bg-violet-50 text-violet-700 dark:border-violet-900 dark:bg-violet-950/50 dark:text-violet-300`}[t];return(0,A.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var nV=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`;function rV({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:o}=e,s=o.tipId??o.entryId;return(0,A.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${e.isCurrent?`bg-emerald-50/60 dark:bg-emerald-950/20`:``}`,style:{height:36},children:[(0,A.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>{r(s),a()},title:n?`unavailable while the agent is running`:o.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex h-full min-w-0 flex-1 items-center gap-2 pl-2 text-left text-sm disabled:opacity-50`,children:[(0,A.jsx)(Gz,{row:e,laneCount:t,colorOf:Hz}),(0,A.jsx)(`span`,{className:`min-w-0 truncate ${o.onPath?`text-zinc-800 dark:text-zinc-200`:`text-zinc-600 dark:text-zinc-400`}`,children:o.text||`(empty)`}),e.forkTo.length>0&&(0,A.jsxs)(tV,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,A.jsxs)(tV,{tone:`branch`,children:[`branch `,e.branchIndex,o.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,A.jsx)(tV,{tone:`current`,children:`current`}),o.label&&(0,A.jsx)(tV,{tone:`label`,children:o.label})]}),(0,A.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{r(o.entryId),a()},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:nV,children:`↺ redo`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{i(o.entryId),a()},title:`fork a new session from this point`,className:nV,children:`⑂ fork`})]})}function iV({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:i}){let[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(``),l=yR(()=>o(!1));(0,d.useEffect)(()=>{a&&e===null&&n()},[a,e]);let u=(0,d.useMemo)(()=>e&&e.length>0?$B(e):null,[e]),f=(0,d.useMemo)(()=>{if(!e||!s.trim())return null;let t=s.trim().toLowerCase();return eV(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,s]);return(0,A.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>{o(!a),a||(c(``),n())},title:`conversation tree: go back to an earlier point or fork`,className:`${oB} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`tree`}),a&&(0,A.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[70vh] w-[32rem] max-w-[90vw] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl [--tree-off:#e4e4e7] dark:border-zinc-700 dark:bg-zinc-900 dark:[--tree-off:#3f3f46]`,children:[e===null&&(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&u&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,A.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,A.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,A.jsxs)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:[u.rows.length,` turn`,u.rows.length===1?``:`s`,` · `,u.branchPoints,` branch point`,u.branchPoints===1?``:`s`]})]}),(0,A.jsx)(`input`,{type:`search`,value:s,onChange:e=>c(e.target.value),placeholder:`Search tree`,"aria-label":`Search conversation tree`,className:`mt-2 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,A.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Follow the colored lines — the current branch is highlighted. Click a turn to restore the conversation there · ↺ to send it again · ⑂ to fork a session`})]}),(0,A.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:f===null?u.rows.map(e=>(0,A.jsx)(rV,{row:e,laneCount:u.laneCount,isStreaming:t,onNavigate:r,onFork:i,onClose:()=>o(!1)},e.node.entryId)):f.length===0?(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):f.map(e=>(0,A.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,A.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.tipId??e.entryId),o(!1)},title:e.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left text-sm disabled:opacity-50`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,A.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,A.jsx)(tV,{tone:`current`,children:`on current branch`}),e.label&&(0,A.jsx)(tV,{tone:`label`,children:e.label})]}),(0,A.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.entryId),o(!1)},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:nV,children:`↺ redo`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{i(e.entryId),o(!1)},title:`fork a new session from this point`,className:nV,children:`⑂ fork`})]},e.entryId))})]})]})]})}var aV=200;function oV({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,d.useState)(e);return(0,A.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),onBlur:n,onKeyDown:e=>{e.key===`Enter`?t(r):e.key===`Escape`&&n()},placeholder:`Session name (empty to clear)`,"aria-label":`Session name`,className:`w-full rounded-md border border-zinc-400 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 dark:border-zinc-600 dark:placeholder:text-zinc-600`})}function sV({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:o,onCancelRename:s}){return n?(0,A.jsx)(`div`,{className:`px-3 py-2`,children:(0,A.jsx)(oV,{initial:e.name??``,onCommit:o,onCancel:s})}):(0,A.jsxs)(`div`,{className:`group flex items-start gap-1 hover:bg-zinc-100 dark:hover:bg-zinc-800 ${t?`bg-zinc-100 dark:bg-zinc-800/60`:``}`,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,A.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,A.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,A.jsxs)(`div`,{className:`mt-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:[new Date(e.modified).toLocaleString(),` · `,e.messageCount,` messages`,t?` · current`:``,!t&&e.liveIn?(0,A.jsxs)(`span`,{"data-testid":`session-live-in`,children:[` · open in `,e.liveIn]}):null]})]}),(0,A.jsx)(`button`,{type:`button`,onClick:a,title:`rename session`,"aria-label":`Rename session`,className:`mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✎`}),!t&&!e.liveIn&&(0,A.jsx)(`button`,{type:`button`,onClick:i,title:`delete session`,"aria-label":`Delete session`,className:`mr-2 mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-red-100 hover:text-red-600 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-red-950/60 dark:hover:text-red-400`,children:`✕`})]})}function cV({sessions:e,sessionSearch:t,sessionId:n,onSwitchSession:r,onDeleteSession:i,onListSessions:a,onRenameSession:o,onSearchSessions:s,onClearSessionSearch:c}){let[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(``),[m,h]=(0,d.useState)(null),g=yR(()=>u(!1)),_=f.trim(),v=_.length>=2;(0,d.useEffect)(()=>{if(!l)return;if(!v){c();return}let e=setTimeout(()=>s(_),aV);return()=>clearTimeout(e)},[l,_,v]);function y(){u(!1),h(null)}let b=v&&(t?.status!==`loaded`||t.query!==_),x=v?b?null:t?.results??null:e;return(0,A.jsxs)(`div`,{className:`relative`,ref:g,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>{l?y():(u(!0),p(``),h(null),c(),a())},className:`${oB} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`sessions`}),l&&(0,A.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-96 w-96 flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,A.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,A.jsx)(`input`,{type:`search`,value:f,onChange:e=>p(e.target.value),placeholder:`Search sessions`,"aria-label":`Search sessions`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,A.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Searches names and everything said in a session · ✎ to rename`})]}),(0,A.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[x===null&&(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),x?.length===0&&(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:v?`no matches`:`no saved sessions`}),x?.map(e=>(0,A.jsx)(sV,{session:e,isCurrent:e.id===n,renaming:m===e.path,onSwitch:()=>{r(e.path),y()},onDelete:()=>{window.confirm(`Delete this session?`)&&i(e.path)},onStartRename:()=>h(e.path),onRename:t=>{o(e.path,t),h(null),v&&s(f.trim())},onCancelRename:()=>h(null)},e.path))]})]})]})}function lV({filters:e,onFilterChange:t}){let[n,r]=(0,d.useState)(!1),i=yR(()=>r(!1)),a=qL(e),o=a>0?`Filter · ${a} hidden`:`Filter`;return(0,A.jsxs)(`div`,{className:`relative`,ref:i,onKeyDown:e=>{e.key===`Escape`&&n&&(e.stopPropagation(),r(!1))},children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>r(!n),"aria-haspopup":`menu`,"aria-expanded":n,title:`Choose what the conversation shows`,className:`${oB} ${a>0?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:o}),n&&(0,A.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-30 mt-1 w-48 rounded-md border border-zinc-200 bg-white py-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:HL.map(n=>(0,A.jsxs)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":e[n],onClick:()=>t(n,!e[n]),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-zinc-600 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:`w-3`,children:e[n]?`✓`:``}),(0,A.jsx)(`span`,{children:UL[n]})]},n))})]})}function uV({statuses:e,bar:t}){let n=Object.entries(e).map(([e,t])=>[e,WR(t)]).filter(([,e])=>e.trim()!==``),r=n.map(([e,t])=>`${e}\u0000${t}`).join(``),[i,a]=(0,d.useState)(!1),o=(0,d.useRef)(null),s=(0,d.useRef)(null),[c,l]=(0,d.useState)(!1),u=yR(()=>l(!1));if((0,d.useLayoutEffect)(()=>{o.current=null,a(!1),l(!1)},[r]),(0,d.useLayoutEffect)(()=>{let e=t;if(e===null)return;let n=()=>{o.current===null?(Array.from(s.current?.querySelectorAll(`[data-status-text]`)??[]).some(e=>e.scrollWidth>e.clientWidth+1)||e.scrollWidth>e.clientWidth+1)&&(o.current=e.clientWidth,a(!0)):e.clientWidth>o.current+64&&(o.current=null,a(!1),l(!1))};if(n(),typeof ResizeObserver>`u`)return;let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t,i,r]),n.length===0)return null;if(!i)return(0,A.jsx)(`div`,{ref:s,className:`flex shrink-0 items-center gap-1.5`,children:n.map(([e,t])=>(0,A.jsx)(`span`,{title:t,className:`${oB} max-w-[16rem] border-zinc-200 text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:(0,A.jsx)(`span`,{"data-status-text":!0,className:`truncate`,children:t})},e))});let f=`${n.length} ${n.length===1?`status`:`statuses`}`;return(0,A.jsxs)(`div`,{ref:u,className:`relative shrink-0`,onKeyDown:e=>{e.key===`Escape`&&c&&(e.stopPropagation(),l(!1))},children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>l(!c),"aria-expanded":c,title:n.map(([,e])=>e).join(`
|
|
1266
|
-
`),className:`${oB} border-zinc-200 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:[f,` ▾`]}),c&&(0,A.jsx)(`ul`,{"aria-label":`Extension statuses`,className:`absolute left-0 top-full z-20 mt-1 w-max max-w-[24rem] rounded-md border border-zinc-200 bg-white py-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:n.map(([e,t])=>(0,A.jsx)(`li`,{className:`break-words px-3 py-1.5 text-xs text-zinc-600 dark:text-zinc-300`,children:t},e))})]})}function dV({theme:e,preference:t=e,onToggle:n,onSetTheme:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useRef)(null),s=yR(()=>a(!1));(0,d.useEffect)(()=>{i&&s.current?.querySelector(`[aria-checked="true"]`)?.focus()},[i]);let c={light:`Light`,dark:`Dark`,system:`System`}[t];return(0,A.jsxs)(`div`,{ref:s,className:`relative`,onKeyDown:e=>{if(e.key===`Escape`&&(e.stopPropagation(),a(!1),o.current?.focus()),i&&[`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key)){e.preventDefault();let t=Array.from(s.current?.querySelectorAll(`[role="menuitemradio"]`)??[]),n=t.findIndex(e=>e.matches(`:focus`));t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus()}},children:[(0,A.jsx)(`button`,{ref:o,type:`button`,onClick:()=>a(e=>!e),title:`Theme: ${c}`,"aria-label":`Theme: ${c}`,"aria-haspopup":`menu`,"aria-expanded":i,className:`${oB} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:t===`system`?`◐`:e===`dark`?`☾`:`☀`}),i&&(0,A.jsx)(`div`,{role:`menu`,"aria-label":`Theme`,className:`absolute right-0 top-full z-40 mt-2 min-w-32 rounded-lg border border-zinc-300 bg-white p-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[`light`,`dark`,`system`].map(i=>(0,A.jsx)(`button`,{role:`menuitemradio`,"aria-checked":t===i,type:`button`,className:`block w-full rounded px-3 py-1.5 text-left text-xs text-zinc-700 hover:bg-zinc-100 focus:bg-zinc-100 dark:text-zinc-200 dark:hover:bg-zinc-800 dark:focus:bg-zinc-800`,onClick:()=>{r?r(i):i!==e&&n(),a(!1),o.current?.focus()},children:i===`light`?`Light`:i===`dark`?`Dark`:`System`},i))})]})}function fV(e){let{isStreaming:t,connected:n}=e,[r,i]=(0,d.useState)(null);return(0,A.jsxs)(`header`,{ref:i,className:`relative z-30 flex min-w-0 items-center gap-1.5 border-b border-zinc-200 px-4 py-2 dark:border-zinc-800`,children:[e.workspaceControl===`projects`&&(0,A.jsx)(pB,{workspace:e.workspace,workspaces:e.workspaces,locked:e.workspaceLocked,onSwitch:e.onSwitchWorkspace,onOpen:e.onOpenProject,onClose:e.onCloseProject,onOpenSide:e.onOpenSideSession}),e.workspaceControl===`root`&&e.rootControl&&(0,A.jsx)(gB,{sandbox:e.rootControl.sandbox,browse:e.rootControl.browse,applyState:e.rootControl.applyState,blocked:e.rootControl.blocked,onBrowse:e.rootControl.onBrowse,onCloseBrowser:e.rootControl.onCloseBrowser,onOpened:e.rootControl.onOpened,onSelect:e.rootControl.onSelect}),(0,A.jsxs)(`button`,{type:`button`,onClick:e.onToggleSidebar,title:e.sidebarOpen?`Hide files (panel opens on the left)`:`Show files`,"aria-pressed":e.sidebarOpen,className:`${oB} ${e.sidebarOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:[e.sidebarOpen?`◧`:`◨`,` files`]}),(0,A.jsxs)(`button`,{type:`button`,onClick:e.onToggleOutcome,"aria-pressed":e.outcomeOpen,title:`Review structured workspace Outcome`,className:`${oB} ${e.outcomeOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:e.workspace?.activity===`ready-for-review`?`border-amber-400 text-amber-700 dark:text-amber-300`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 dark:border-zinc-800 dark:text-zinc-400`}`,children:[`Outcome`,e.workspace?.activity===`ready-for-review`?` •`:``]}),e.gitAvailable&&(0,A.jsx)(yB,{status:e.gitStatus,selected:e.gitSelectedPath,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,A.jsx)(`span`,{title:e.title??void 0,className:`min-w-[2.25rem] shrink-[4] truncate whitespace-nowrap text-lg font-semibold leading-tight tracking-tight`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),(0,A.jsx)(uV,{statuses:e.statuses,bar:r}),(0,A.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,A.jsx)(lV,{filters:e.filters,onFilterChange:e.onFilterChange}),e.onExportConversation&&(0,A.jsx)(`button`,{type:`button`,onClick:e.onExportConversation,disabled:!!e.exportProgress,"aria-busy":!!e.exportProgress,title:`Save the whole conversation as one HTML file`,"aria-label":`Export the conversation as HTML`,className:`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 text-xs leading-none border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 disabled:cursor-progress disabled:opacity-60 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:e.exportProgress??`↓ html`}),e.onToggleTerminal&&(0,A.jsx)(`button`,{type:`button`,onClick:e.onToggleTerminal,title:e.terminalOpen?"Close Terminal (Ctrl+`)":"Open Terminal (Ctrl+`)","aria-pressed":e.terminalOpen,className:`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 text-xs leading-none ${e.terminalOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:`>_ terminal`}),e.showThemeToggle&&(0,A.jsx)(dV,{theme:e.theme,preference:e.themePreference,onSetTheme:e.onSetTheme,onToggle:e.onToggleTheme}),(0,A.jsx)(`button`,{type:`button`,onClick:e.onNewSession,title:`new session`,className:`${oB} border-emerald-300 text-emerald-700 hover:border-emerald-500 hover:text-emerald-600 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600 dark:hover:text-emerald-300`,children:`+ new`}),(0,A.jsx)(iV,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,A.jsx)(cV,{sessions:e.sessions,sessionSearch:e.sessionSearch,sessionId:e.sessionId,onSwitchSession:e.onSwitchSession,onDeleteSession:e.onDeleteSession,onListSessions:e.onListSessions,onRenameSession:e.onRenameSession,onSearchSessions:e.onSearchSessions,onClearSessionSearch:e.onClearSessionSearch}),(0,A.jsx)(QB,{credentials:e.credentials,login:e.login,onStartLogin:e.onStartLogin,onAnswerLogin:e.onAnswerLogin,onCancelLogin:e.onCancelLogin,onDismissLogin:e.onDismissLogin,onLogoutProvider:e.onLogoutProvider,extensionPaths:e.extensionPaths,configuredExtensionPaths:e.configuredExtensionPaths,userExtensionPaths:e.userExtensionPaths,extensionLock:e.extensionLock,piPackages:e.piPackages??null,piPackageUpdate:e.piPackageUpdate??null,canRestartServer:e.canRestartServer??!1,serverRestarting:e.serverRestarting??!1,...e.onCheckPiPackages?{onCheckPiPackages:e.onCheckPiPackages}:{},...e.onUpdatePiPackage?{onUpdatePiPackage:e.onUpdatePiPackage}:{},...e.onRestartServer?{onRestartServer:e.onRestartServer}:{},restartNeeded:e.restartNeeded??[],tools:e.tools??[],commands:e.commands??[],sandbox:e.sandbox,showRoots:!(e.workspaceControl===`projects`&&e.workspaces.filter(e=>!e.sideOf).length>1),gitUnavailable:e.gitUnavailable,userSkillPaths:e.userSkillPaths,serverBrowse:e.serverBrowse,applyState:e.settingsApply,agentResources:e.agentResources,agentResourceOperations:e.agentResourceOperations,versions:e.versions,onBrowseServerPath:e.onBrowseServerPath,onCloseServerBrowser:e.onCloseServerBrowser,pickerBlocked:e.settingsPickerBlocked,onPickerOpened:e.onSettingsPickerOpened,onRestartSession:e.onRestartSession,onUpdateConfig:e.onUpdateConfig,onSuggestAgentResourceClonePath:e.onSuggestAgentResourceClonePath,onCloneAgentResourceRepository:e.onCloneAgentResourceRepository,onEnrollAgentResourceRepository:e.onEnrollAgentResourceRepository,onSetAgentResourceSkills:e.onSetAgentResourceSkills,onRemoveAgentResourceRepository:e.onRemoveAgentResourceRepository,onRefreshAgentResourceRepositories:e.onRefreshAgentResourceRepositories,onUpdateAgentResourceRepository:e.onUpdateAgentResourceRepository}),(0,A.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function pV(e,t){let n=(0,d.useRef)(new Map);(0,d.useEffect)(()=>{if(typeof Notification>`u`)return;let r=e.filter(e=>e.needsAttention),i=r.filter(e=>oL(e)!==t);for(let e of[...n.current.keys()])r.some(t=>oL(t)===e)||n.current.delete(e);if(Notification.permission===`granted`&&(typeof document>`u`||document.visibilityState!==`visible`)){for(let e of i)if(n.current.get(oL(e))!==e.activity){n.current.set(oL(e),e.activity);try{let t=e.activity===`ready-for-review`;new Notification(t?`${e.name} is ready for review`:`${e.name} needs you`,{body:t?`Background work is ready for review.`:`The agent needs an answer to continue.`,tag:`pi-outpost:${oL(e)}`})}catch{}}}},[e,t])}var mV={"agent-directory":`read the agent directory (the provider keys)`,"beside-root":`read a file beside the root`,"write-beside-root":`write beside the root`,"signal-process":`signal another process of the server's user`,"server-environment":`inherit the server's environment`,"server-process-environment":`read the server's process environment (/proc)`,"unlisted-host":`reach a host not in sandbox.allowedHosts`,"direct-connection":`connect around the proxy`},hV=e=>e.map(e=>mV[e]??e),gV=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()};function _V(e,t){let n=t===`shell`?`The agent's shell`:`This terminal`;switch(e.state){case`checking`:return`${n} runs under ${e.runner||`a sandbox runner`}; its confinement is being checked.`;case`verified`:return[`${n} is confined by ${e.runner}, checked at ${gV(e.checkedAt)}. A command could not:`,...hV(e.refused).map(e=>`• ${e}`),...e.environmentReadable?[`The server's process environment is readable, and holds no secret.`]:[],...e.notChecked.length?[`Not checked:`,...e.notChecked.map(e=>`• ${mV[e.attempt]??e.attempt} — ${e.why}`)]:[]].join(`
|
|
1265
|
+
`,SB=[[`draw.io / diagrams.net`,`Diagram viewer and editor`],[`React`,`User interface`],[`CodeMirror · xterm.js · node-pty`,`Code editor and terminal`],[`PDF.js · docx`,`Document tools`],[`Mermaid · KaTeX`,`Diagrams and mathematical notation`]],CB=[{name:`pi-outpost`,license:`MIT`,text:xB},...bB];function wB(){let[e,t]=(0,d.useState)(!1),n=(0,d.useRef)(null);return(0,d.useLayoutEffect)(()=>{n.current?.focus({preventScroll:!0});let e=n.current?.closest(`.overflow-y-auto`);e&&(e.scrollTop=0)},[e]),e?(0,A.jsxs)(`div`,{className:`text-zinc-700 dark:text-zinc-300`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:`mb-3 text-xs text-zinc-500 hover:underline dark:text-zinc-400`,children:`← Back to credits`}),(0,A.jsx)(`h3`,{ref:n,tabIndex:-1,className:`text-sm font-semibold outline-none`,children:`Third-party notices`}),(0,A.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`License texts and attributions for pi-outpost and the components acknowledged here.`}),CB.map(e=>(0,A.jsxs)(`section`,{className:`mt-5 border-t border-zinc-200 pt-3 dark:border-zinc-700`,children:[(0,A.jsxs)(`h4`,{className:`text-sm font-semibold`,children:[e.name,` `,(0,A.jsxs)(`span`,{className:`font-normal text-zinc-500 dark:text-zinc-400`,children:[`· `,e.license]})]}),(0,A.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed`,children:e.text})]},e.name))]}):(0,A.jsxs)(`div`,{className:`text-sm text-zinc-700 dark:text-zinc-300`,children:[(0,A.jsxs)(`section`,{className:`pb-5`,children:[(0,A.jsx)(`h3`,{ref:n,tabIndex:-1,className:`text-xl font-semibold tracking-tight outline-none`,children:`pi-outpost`}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Created by Laurent Francoise · MIT license`}),(0,A.jsxs)(`a`,{className:`mt-3 inline-flex items-center gap-2 text-xs underline underline-offset-4`,href:`https://laurentftech.github.io/pi-outpost/`,target:`_blank`,rel:`noopener noreferrer`,children:[`Project website `,(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`↗`})]})]}),(0,A.jsxs)(`section`,{className:`border-t border-zinc-200 pt-4 dark:border-zinc-700`,children:[(0,A.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Open-source acknowledgements`}),(0,A.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`Thanks to the authors and contributors of these projects.`}),(0,A.jsx)(`dl`,{className:`mt-3 space-y-3`,children:SB.map(([e,t])=>(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`dt`,{className:`text-xs font-medium`,children:e}),(0,A.jsx)(`dd`,{className:`mt-0.5 text-xs text-zinc-500 dark:text-zinc-400`,children:t})]},e))}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),className:`mt-4 flex w-full items-center justify-between rounded-md border border-zinc-300 px-3 py-2 text-xs hover:bg-zinc-100 dark:border-zinc-700 dark:hover:bg-zinc-800`,children:[`Third-party notices `,(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`→`})]})]})]})}function TB(e){if(e.installed===void 0)return`not installed`;if(e.restartNeeded)return`${e.installed} installed — restart to use it`;if(e.pinned!==void 0)return`${e.installed}, pinned`;let t=e.check;if(!t)return e.installed;switch(t.state){case`checking`:return`${e.installed}, checking…`;case`newer`:return`${e.installed} — ${t.latest} available`;case`current`:return`${e.installed}, up to date`;case`failed`:return`${e.installed}, not checked: ${t.reason}`;case`off`:return`${e.installed}, not checked: ${t.reason}`}}function EB({packages:e,update:t,locked:n,onCheck:r,onUpdate:i}){let[a,o]=(0,d.useState)(null);if(e===null||e.length===0)return null;let s=t?.status===`pending`?t.source:null;return(0,A.jsxs)(`div`,{className:`mt-3`,"data-testid":`pi-packages`,children:[(0,A.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,A.jsx)(`span`,{className:`text-xs font-medium text-zinc-600 dark:text-zinc-400`,children:`Packages`}),(0,A.jsx)(`button`,{type:`button`,onClick:r,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200`,children:`check for updates`})]}),(0,A.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let r=e.check?.state===`newer`&&!e.restartNeeded?e.check.latest:void 0;return(0,A.jsxs)(`li`,{"data-testid":`pi-package`,className:`rounded bg-zinc-50 px-2 py-1 text-xs dark:bg-zinc-800`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,A.jsx)(`span`,{className:`min-w-0 truncate font-mono text-zinc-700 dark:text-zinc-300`,title:e.source,children:e.name}),r&&!n&&a!==e.source&&(0,A.jsx)(`button`,{type:`button`,disabled:s!==null,onClick:()=>o(e.source),className:`shrink-0 rounded border border-zinc-300 px-1.5 py-0.5 text-zinc-700 hover:bg-zinc-100 disabled:opacity-50 dark:border-zinc-600 dark:text-zinc-200 dark:hover:bg-zinc-700`,children:s===e.source?`updating…`:`Update`})]}),(0,A.jsx)(`div`,{className:`line-clamp-2 text-zinc-500 dark:text-zinc-400`,"data-testid":`pi-package-status`,title:TB(e),children:TB(e)}),r&&a===e.source&&(0,A.jsxs)(`div`,{className:`mt-1 rounded border border-amber-300 bg-amber-50 p-2 text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,"data-testid":`pi-package-confirm`,children:[(0,A.jsxs)(`p`,{children:[`This replaces code that runs with the agent's privileges: `,e.name,` `,e.installed,` → `,r,`. It takes effect when pi-outpost restarts.`]}),(0,A.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>{o(null),i(e.source)},className:`rounded bg-amber-600 px-2 py-0.5 text-white hover:bg-amber-700`,children:[`Install `,r]}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(null),className:`rounded px-2 py-0.5 hover:bg-amber-100 dark:hover:bg-amber-900/40`,children:`Cancel`})]})]}),t&&t.status!==`pending`&&t.source===e.source&&(0,A.jsx)(`p`,{"data-testid":`pi-package-result`,className:`mt-1 ${t.status===`installed`?`text-emerald-700 dark:text-emerald-400`:`text-amber-700 dark:text-amber-400`}`,children:t.message})]},e.source)})})]})}function DB({reasons:e,canRestart:t,restarting:n,onRestart:r}){let[i,a]=(0,d.useState)(!1);return e.length===0?null:(0,A.jsxs)(`div`,{className:`mt-3 rounded border border-sky-200 bg-sky-50 p-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,"data-testid":`restart-needed`,children:[(0,A.jsxs)(`p`,{children:[`Installed and waiting on a restart to run: `,e.join(`, `),`.`]}),t?n?(0,A.jsx)(`p`,{className:`mt-1`,children:`Restarting pi-outpost…`}):i?(0,A.jsxs)(`div`,{className:`mt-1`,children:[(0,A.jsx)(`p`,{children:`pi-outpost stops and starts again in the same terminal. Every open window reconnects by itself, and conversations are kept.`}),(0,A.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>{a(!1),r()},className:`rounded bg-sky-700 px-2 py-0.5 text-white hover:bg-sky-800`,children:`Restart now`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:`rounded px-2 py-0.5 hover:bg-sky-100 dark:hover:bg-sky-900/50`,children:`Cancel`})]})]}):(0,A.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`mt-1 rounded border border-sky-300 px-2 py-0.5 hover:bg-sky-100 dark:border-sky-700 dark:hover:bg-sky-900/50`,children:`Restart pi-outpost`}):null]})}var OB=30,kB={display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`};function AB({skills:e,groups:t,enabled:n,onChange:r,disabled:i=!1,bound:a}){let[o,s]=(0,d.useState)(()=>e.length>40?new Set(e.filter(e=>n.has(e.relativePath)).map(e=>e.group)):new Set(t.map(e=>e.path))),[c,l]=(0,d.useState)(``),[u,f]=(0,d.useState)(!1),p=c.trim().toLocaleLowerCase(),m=p!==``||u,h=e=>(!u||n.has(e.relativePath))&&(!p||`${e.name} ${e.relativePath} ${e.description??``}`.toLocaleLowerCase().includes(p)),g=new Map;for(let t of e)g.set(t.group,[...g.get(t.group)??[],t]);let _=e.filter(e=>n.has(e.relativePath)).length,v=m?e.filter(h).length:e.length,y=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n.relativePath):i.delete(n.relativePath);r(i)},b=e=>{let t=new Set(n);t.has(e)?t.delete(e):t.add(e),r(t)},x=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,A.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,"aria-label":`Collection skills`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,A.jsxs)(`h3`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:[`Skills `,(0,A.jsxs)(`span`,{className:`font-normal text-zinc-500`,children:[`· `,_,` of `,e.length,` on`]})]}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,disabled:i||_===e.length,onClick:()=>y(e,!0),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All on`}),(0,A.jsx)(`button`,{type:`button`,disabled:i||_===0,onClick:()=>y(e,!1),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All off`})]})]}),a?(0,A.jsx)(`p`,{className:`mt-2 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:a.kind===`count`?`This repository holds more skills than the ${a.limit} listed here.`:`Folders deeper than ${a.limit} levels were not searched for skills.`}):null,e.length>0?(0,A.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(`input`,{type:`search`,"aria-label":`Search skills`,placeholder:`Search skills by name or folder`,value:c,onChange:e=>l(e.target.value),className:`min-w-0 flex-1 rounded-md border bg-transparent px-2.5 py-1 text-xs`}),(0,A.jsxs)(`button`,{type:`button`,"aria-pressed":u,onClick:()=>f(e=>!e),className:`rounded-md px-2.5 py-1 text-xs ${u?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:[`Only on (`,_,`)`]})]}):null,!m&&_>0&&_<=OB?(0,A.jsxs)(`div`,{role:`region`,"aria-label":`Skills that are on`,className:`mt-3 rounded-lg border border-emerald-200 bg-emerald-50/60 p-2 dark:border-emerald-900 dark:bg-emerald-950/30`,children:[(0,A.jsx)(`p`,{className:`px-1 text-[11px] font-medium text-emerald-800 dark:text-emerald-300`,children:`Turned on`}),(0,A.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.filter(e=>n.has(e.relativePath)).map(e=>(0,A.jsxs)(`li`,{className:`flex items-start justify-between gap-2 px-1`,children:[(0,A.jsxs)(`span`,{className:`min-w-0 text-xs`,children:[(0,A.jsx)(`span`,{className:`font-medium text-zinc-800 dark:text-zinc-100`,children:e.name}),` `,(0,A.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.group||`(repository root)`}),(0,A.jsx)(jB,{skill:e,checked:!0})]}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Turn off ${e.name} (${e.relativePath})`,disabled:i,onClick:()=>b(e.relativePath),className:`shrink-0 rounded border bg-white px-2 py-0.5 text-[11px] disabled:opacity-50 dark:bg-zinc-900`,children:`Turn off`})]},e.relativePath))})]}):null,e.length===0?(0,A.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`This repository holds no skills.`}):null,m&&v===0?(0,A.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:u&&!p?`No skill is on.`:`No skill matches.`}):null,(0,A.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>{let t=g.get(e.path)??[],r=m?t.filter(h):t;if(m&&r.length===0)return null;let a=r.filter(e=>n.has(e.relativePath)).length,s=m||o.has(e.path);return(0,A.jsxs)(`li`,{className:`rounded-lg border border-zinc-100 dark:border-zinc-800`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,A.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:()=>x(e.path),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-zinc-400`,children:s?`▾`:`▸`}),(0,A.jsx)(`span`,{className:`truncate font-mono text-xs font-medium text-zinc-700 dark:text-zinc-200`,children:e.label}),(0,A.jsxs)(`span`,{className:`shrink-0 text-[11px] text-zinc-500`,children:[a,`/`,r.length,` on`]})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,A.jsx)(`button`,{type:`button`,"aria-label":`All on in ${e.label}`,disabled:i||a===r.length,onClick:()=>y(r,!0),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All on`}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`All off in ${e.label}`,disabled:i||a===0,onClick:()=>y(r,!1),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All off`})]})]}),s?(0,A.jsx)(`ul`,{className:`space-y-1 border-t border-zinc-100 px-3 py-2 dark:border-zinc-800`,children:r.map(e=>{let t=n.has(e.relativePath);return(0,A.jsx)(`li`,{children:(0,A.jsxs)(`label`,{className:`flex items-start gap-2 rounded px-1 py-1 ${i?`opacity-60`:`cursor-pointer hover:bg-zinc-50 dark:hover:bg-zinc-800/60`}`,children:[(0,A.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":t,"aria-label":`${e.name} (${e.relativePath})`,checked:t,disabled:i,onChange:()=>b(e.relativePath),className:`mt-0.5`}),(0,A.jsxs)(`span`,{className:`min-w-0`,children:[(0,A.jsx)(`span`,{className:`block truncate text-sm text-zinc-800 dark:text-zinc-100`,children:e.name}),e.description?(0,A.jsx)(`span`,{title:e.description,style:kB,className:`text-[11px] text-zinc-500`,children:e.description}):null,(0,A.jsx)(jB,{skill:e,checked:t})]})]})},e.relativePath)})}):null]},e.path)})})]})}function jB({skill:e,checked:t}){return t===(e.state!==`off`)?e.state===`on-loaded`?(0,A.jsx)(`span`,{className:`block text-[11px] text-emerald-700 dark:text-emerald-400`,children:`Loaded`}):e.state===`on-not-loaded`?(0,A.jsxs)(`span`,{className:`block text-[11px] text-amber-700 dark:text-amber-400`,children:[`Not loaded — `,e.reason]}):e.state===`on-missing`?(0,A.jsxs)(`span`,{className:`block text-[11px] text-rose-700 dark:text-rose-400`,children:[`Missing — `,e.reason]}):null:(0,A.jsx)(`span`,{className:`block text-[11px] font-medium text-sky-700 dark:text-sky-300`,children:t?`Pending: on`:`Pending: off`})}function MB(e,t){return[...new Set(e.map(e=>e.group))].sort().map(e=>({path:e,label:e||t}))}function NB(e){return e.skills.filter(e=>e.state!==`off`).map(e=>e.relativePath)}function PB(e,t){let n=new Set(e),r=new Set(t);return n.size===r.size&&[...n].every(e=>r.has(e))}function FB(e,t){if(t.status===`loading`)return`Removing ${e}…`;if(t.status===`error`)return t.message??`Could not remove ${e}`;let n=t.result;return n?n.status===`removed`?`Removed ${e} and deleted ${n.path}.`:n.status===`removed-files-kept`?`Removed ${e}. ${n.reason??`Its files were kept`} (${n.path}).`:`Removed ${e}, but not every file could be deleted${n.reason?` — ${n.reason}`:``}. What remains is at ${n.path}.`:`Removed ${e}.`}var IB={unchecked:`Not checked`,checking:`Checking…`,current:`Up to date`,updateable:`Update available`,dirty:`Local changes`,detached:`Detached HEAD`,ahead:`Local branch ahead`,diverged:`Histories diverged`,"no-upstream":`No upstream`,locked:`Locked`,busy:`Workspace busy`,unavailable:`Unavailable`,failed:`Check failed`};function LB(e){if(!e)return[];let t=new Map(e.resources.map(e=>[e.id,e])),n=new Set(e.repositories.flatMap(e=>e.resourceIds)),r=e.repositories.map(e=>({id:e.id,name:e.name,path:e.path,repository:e,resources:e.resourceIds.flatMap(e=>t.get(e)?[t.get(e)]:[])})),i=e.resources.filter(e=>!n.has(e.id)),a=i.filter(e=>e.unavailableReason),o=i.filter(e=>!e.unavailableReason);return o.length&&r.push({id:`local`,name:`Local and built in`,reason:`Not backed by an updateable Git repository`,resources:o}),a.length&&r.push({id:`unavailable`,name:`Provenance unavailable`,reason:`The active runtime did not report enough filesystem provenance`,resources:a}),r}function RB(e){let t=e.length;for(;t>0&&(e[t-1]===`/`||e[t-1]===`\\`);)--t;return t===e.length?e:e.slice(0,t)}function zB(e){let t=RB(e),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<=0?`/`:t.slice(0,n)}function BB(e,t){let n=RB(t),r=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`)),i=r>=0?n.slice(r+1):n;return`${RB(e)}/${i||`agent-resources`}`}function VB({kind:e,resources:t,removalLocked:n=!1,onRemove:r}){return(0,A.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center justify-between text-sm font-semibold capitalize text-zinc-800 dark:text-zinc-200`,children:[(0,A.jsxs)(`span`,{children:[e,`s`]}),(0,A.jsx)(`span`,{className:`text-xs font-normal text-zinc-400`,children:t.length})]}),t.length===0?(0,A.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`None in this group`}):(0,A.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>(0,A.jsxs)(`li`,{className:`rounded-lg bg-zinc-50 px-3 py-2 dark:bg-zinc-800/70`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,A.jsx)(`p`,{className:`truncate text-sm font-medium text-zinc-700 dark:text-zinc-200`,children:e.name}),e.userRoot&&!n?(0,A.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.userRoot}`,onClick:()=>r(e),className:`text-xs text-zinc-500 hover:text-red-600`,children:`Remove`}):null]}),(0,A.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-400`,title:e.path,children:e.path??e.unavailableReason??`Path unavailable`})]},e.id))})]})}function HB({preview:e,busy:t,error:n,onApply:r,onCancel:i}){let[a,o]=(0,d.useState)(()=>new Set(e.roots.filter(e=>!e.locked).map(e=>`${e.kind}:${e.path}`))),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(()=>new Set),f=e.mode===`collection`,p=(0,d.useMemo)(()=>e.skills.map(e=>({...e,state:`off`})),[e.skills]),m=(0,d.useMemo)(()=>MB(e.skills,e.repositoryName),[e.skills,e.repositoryName]),h=e.roots.filter(e=>e.kind===`extension`&&a.has(`extension:${e.path}`)),g=h.length>0&&!s,_=t||!f&&a.size===0||g,v=()=>{let t=h.map(e=>e.path);f?r([],t,[...l]):r(e.roots.filter(e=>e.kind===`skill`&&a.has(`skill:${e.path}`)).map(e=>e.path),t)},y=e=>{c(!1),o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,A.jsxs)(`div`,{className:`space-y-3`,"data-testid":`resource-preview`,children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h3`,{className:`truncate text-xl font-semibold text-zinc-900 dark:text-zinc-100`,children:e.repositoryName}),(0,A.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-500`,title:e.repositoryPath,children:e.repositoryPath})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:i,className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,disabled:_,onClick:v,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:t?`Saving…`:`Save`})]})]}),g?(0,A.jsx)(`p`,{className:`text-xs text-amber-700`,children:`Confirm the extension warning below to save.`}):null,n?(0,A.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:n}):null,f?(0,A.jsx)(AB,{skills:p,groups:m,enabled:l,onChange:u,disabled:t,...e.bound?{bound:e.bound}:{}}):null,e.roots.map(e=>{let t=`${e.kind}:${e.path}`;return(0,A.jsxs)(`label`,{className:`flex items-start gap-2 rounded border p-2 ${e.locked?`opacity-50`:`cursor-pointer`}`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:a.has(t),disabled:e.locked,onChange:()=>y(t)}),(0,A.jsxs)(`span`,{children:[(0,A.jsxs)(`span`,{className:`block text-sm`,children:[e.name,` · `,e.kind]}),(0,A.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.path}),e.locked?(0,A.jsx)(`span`,{className:`block text-xs text-amber-700`,children:`Extension paths are locked`}):null]})]},t)}),h.length>0?(0,A.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),(0,A.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust the selected extension roots in this repository.`})]}):null]})}function UB(e){let t=(0,d.useRef)(null),n=(0,d.useRef)(e.onClose),r=(0,d.useRef)(!1),[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(`all`),[u,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(null),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(`skill`),[y,b]=(0,d.useState)(``),[x,S]=(0,d.useState)(!1),[C,w]=(0,d.useState)(``),[T,ee]=(0,d.useState)(``),[E,D]=(0,d.useState)(!1),[te,ne]=(0,d.useState)(``),[re,ie]=(0,d.useState)(null),[O,ae]=(0,d.useState)({}),[k,oe]=(0,d.useState)(null),[se,ce]=(0,d.useState)(null),le=(0,d.useMemo)(()=>LB(e.inventory),[e.inventory]),ue=(0,d.useMemo)(()=>{let e=o.trim().toLocaleLowerCase();return le.flatMap(t=>{let n=`repository`in t?t.repository.collection:void 0,r=n?t.resources.filter(e=>e.kind!==`skill`):t.resources,i=c===`all`?r:r.filter(e=>e.kind===c),a=n&&c!==`extension`?n.skills:[],o=i.length+a.length;if(o===0&&!(n&&c===`all`)||u&&(!(`repository`in t)||![`updateable`,`dirty`,`failed`,`unavailable`,`busy`].includes(t.repository.assessment.status)))return[];let s=`${t.name} ${`path`in t?t.path??``:``} ${i.map(e=>`${e.name} ${e.path??``}`).join(` `)} ${a.map(e=>`${e.name} ${e.relativePath}`).join(` `)}`.toLocaleLowerCase(),l=n?n.skills.filter(e=>e.state!==`off`).length:void 0;return!e||s.includes(e)?[{...t,resources:i,count:o,...l===void 0?{}:{onCount:l}}]:[]})},[le,u,c,o]),de=ue.find(e=>e.id===i)??ue[0]??null;if((0,d.useEffect)(()=>{n.current=e.onClose},[e.onClose]),(0,d.useEffect)(()=>{ae(t=>{let n={},r=!1;for(let[i,a]of Object.entries(t)){let t=e.inventory?.repositories.find(e=>e.id===i)?.collection;!t||PB(a,NB(t))?r=!0:n[i]=a}return r?n:t})},[e.inventory]),(0,d.useEffect)(()=>{e.open&&t.current?.focus()},[e.open]),(0,d.useEffect)(()=>{if(!e.open)return;let t=e=>{e.key===`Escape`&&n.current()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.open]),(0,d.useEffect)(()=>{let t=e.operations.clonePath;t?.status===`ready`&&t.path&&!E&&ee(t.path)},[E,e.operations.clonePath]),(0,d.useEffect)(()=>{e.operations.enrollment?.status===`ready`&&m(null)},[e.operations.enrollment]),(0,d.useEffect)(()=>{e.applyState?.status===`applying`?r.current=!0:r.current&&e.applyState===null&&(r.current=!1,m(null),g(null),S(!1))},[e.applyState]),!e.open)return null;let fe=de&&`repository`in de?de.repository:null,j=fe?e.operations.updates[fe.id]:void 0,pe=fe?.assessment,me=pe?.status===`updateable`&&pe.token&&pe.localRevision&&pe.upstreamRevision,he=()=>{let t=y.trim();t&&(_===`skill`?e.onUpdateConfig({userSkillPaths:[...new Set([...e.userSkillPaths,t])]}):e.onUpdateConfig({userExtensionPaths:[...new Set([...e.userExtensionPaths,t])]}))},ge=t=>{t.userRoot&&(t.kind===`skill`?e.onUpdateConfig({userSkillPaths:e.userSkillPaths.filter(e=>e!==t.userRoot)}):e.onUpdateConfig({userExtensionPaths:e.userExtensionPaths.filter(e=>e!==t.userRoot)}))},_e=(t,n=!1)=>{let r=t.assessment;r.token&&r.localRevision&&r.upstreamRevision&&e.onUpdate(t.id,r.token,r.localRevision,r.upstreamRevision,n)},ve=fe?.collection,ye=ve?NB(ve):[],be=new Set(fe&&O[fe.id]?O[fe.id]:ye),xe=ve?[...new Set([...be,...ye])].filter(e=>be.has(e)!==ye.includes(e)).length:0,Se=fe?e.operations.skills?.[fe.id]:void 0,Ce=e=>{if(!fe)return;let t=fe.id;ae(n=>{let r={...n};return PB(e,ye)?delete r[t]:r[t]=[...e],r})},we=()=>{if(!fe)return;let e=fe.id;ae(t=>{let n={...t};return delete n[e],n})},Te=()=>{if(!fe||!ve)return;let t=new Set(ve.skills.filter(e=>e.state!==`on-missing`).map(e=>e.relativePath));e.onSetSkills(fe.id,[...be].filter(e=>t.has(e)))},Ee=se?e.operations.removals?.[se.id]:void 0,De=Ee?.status===`error`||Ee?.result?.status===`removed-delete-failed`;return(0,A.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/45 p-4`,role:`presentation`,onMouseDown:t=>{t.currentTarget===t.target&&e.onClose()},children:[(0,A.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`agent-resources-title`,className:`flex h-[min(760px,92vh)] w-[min(1120px,96vw)] flex-col overflow-hidden rounded-2xl border border-zinc-200 bg-white shadow-2xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,A.jsxs)(`header`,{className:`flex items-center justify-between border-b border-zinc-200 px-5 py-4 dark:border-zinc-800`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{id:`agent-resources-title`,className:`text-lg font-semibold text-zinc-900 dark:text-zinc-100`,children:`Agent resources`}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Skills and extensions, grouped by repository`})]}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(),className:`rounded-md border px-3 py-1.5 text-xs disabled:opacity-50`,children:`Refresh all`}),(0,A.jsx)(`button`,{ref:t,type:`button`,"aria-label":`Close agent resources`,onClick:e.onClose,className:`rounded-md border px-2 py-1 text-sm`,children:`✕`})]})]}),(0,A.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[300px_1fr]`,children:[(0,A.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-r border-zinc-200 bg-zinc-50/80 p-3 dark:border-zinc-800 dark:bg-zinc-950/40`,children:[(0,A.jsx)(`input`,{"aria-label":`Search resources`,value:o,onChange:e=>s(e.target.value),placeholder:`Search repositories or resources`,className:`rounded-md border bg-white px-3 py-2 text-xs dark:bg-zinc-900`}),(0,A.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[[`all`,`skill`,`extension`].map(e=>(0,A.jsx)(`button`,{type:`button`,"aria-pressed":c===e,onClick:()=>l(e),className:`rounded px-2 py-1 text-[11px] ${c===e?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:e===`all`?`All`:`${e}s`},e)),(0,A.jsx)(`button`,{type:`button`,"aria-pressed":u,onClick:()=>f(e=>!e),className:`rounded px-2 py-1 text-[11px] ${u?`bg-amber-600 text-white`:`border`}`,children:`Needs attention`})]}),(0,A.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 space-y-1 overflow-y-auto`,children:[ue.map(e=>(0,A.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),className:`w-full rounded-lg px-3 py-2.5 text-left ${de?.id===e.id?`bg-white shadow-sm ring-1 ring-zinc-200 dark:bg-zinc-800 dark:ring-zinc-700`:`hover:bg-white/70 dark:hover:bg-zinc-900`}`,children:[(0,A.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-sm font-medium`,children:[(0,A.jsx)(`span`,{className:`truncate`,children:e.name}),(0,A.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400`,children:e.onCount===void 0?e.count??e.resources.length:`${e.onCount} on · ${e.count}`})]}),(0,A.jsx)(`span`,{className:`mt-1 block text-xs text-zinc-500`,children:`repository`in e?IB[e.repository.assessment.status]:e.reason})]},e.id)),ue.length===0?(0,A.jsx)(`p`,{className:`px-2 py-4 text-xs text-zinc-500`,children:`No matching resources`}):null]}),(0,A.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t pt-3`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>{S(!1),m(`local`),g(`local`),e.onBrowseServerPath(y||`/`)},className:`rounded-md border bg-white px-3 py-2 text-xs font-medium dark:bg-zinc-900`,children:`Add local folder…`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>m(`git`),className:`rounded-md bg-zinc-900 px-3 py-2 text-xs font-medium text-white dark:bg-zinc-100 dark:text-zinc-900`,children:`Add Git repository…`})]})]}),(0,A.jsxs)(`main`,{className:`min-w-0 overflow-y-auto p-6`,children:[se&&Ee?(0,A.jsxs)(`div`,{role:De?`alert`:`status`,className:`mb-4 flex items-start justify-between gap-3 rounded-lg border p-3 text-sm ${De?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[(0,A.jsx)(`p`,{className:`min-w-0 break-words`,children:FB(se.name,Ee)}),Ee.status===`loading`?null:(0,A.jsx)(`button`,{type:`button`,onClick:()=>ce(null),className:`shrink-0 text-xs underline`,children:`Dismiss`})]}):null,p===`local`?(0,A.jsxs)(`div`,{className:`max-w-xl space-y-4`,"data-testid":`add-local-folder`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add local folder`}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Choose an existing folder on the server and how the agent should load it.`})]}),(0,A.jsx)(`div`,{className:`flex gap-2`,children:[`skill`,`extension`].map(t=>(0,A.jsx)(`button`,{type:`button`,"aria-pressed":_===t,disabled:t===`extension`&&e.extensionLock,onClick:()=>{v(t),S(!1)},className:`rounded-md px-3 py-1.5 text-xs ${_===t?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:t===`skill`?`Skill folder`:`Extension folder`},t))}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(`input`,{"aria-label":`Local resource folder`,value:y,onChange:e=>{S(!1),b(e.target.value)},className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{g(`local`),e.onBrowseServerPath(y||`/`)},className:`rounded-md border px-3 text-xs`,children:`Browse…`})]}),h===`local`?(0,A.jsx)(mB,{label:`Choose a local resource folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{S(!1),b(t),g(null),e.onCloseServerBrowser()},onCancel:()=>{g(null),e.onCloseServerBrowser()}}):null,_===`extension`?(0,A.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),(0,A.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust every extension in this folder.`})]}):null,e.extensionLock?(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Extension paths are locked by this deployment.`}):null,e.applyState?.status===`error`?(0,A.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.applyState.message}):null,(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>{S(!1),m(null),g(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,disabled:!y.trim()||e.applyState?.status===`applying`||_===`extension`&&(!x||e.extensionLock),onClick:he,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.applyState?.status===`applying`?`Applying…`:`Add folder`})]})]}):p===`git`?(0,A.jsx)(`div`,{className:`max-w-2xl space-y-4`,"data-testid":`add-git-repository`,children:e.operations.preview?.status===`ready`&&e.operations.preview.preview?(0,A.jsx)(HB,{onCancel:()=>{m(null),g(null),e.onCloseServerBrowser()},preview:e.operations.preview.preview,busy:e.operations.enrollment?.status===`loading`,error:e.operations.enrollment?.status===`error`?e.operations.enrollment.message:void 0,onApply:(t,n,r)=>r?e.onEnrollRepository(e.operations.preview.preview.token,t,n,r):e.onEnrollRepository(e.operations.preview.preview.token,t,n)}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add Git repository`}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Clone it to a local folder, then choose what to turn on.`})]}),(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsx)(`span`,{className:`text-xs font-medium`,children:`Repository address`}),(0,A.jsx)(`input`,{"aria-label":`Repository address`,value:C,onChange:e=>w(e.target.value),onBlur:()=>{let t=C.trim();t&&(D(!1),ne(t),e.onSuggestClonePath(C))},placeholder:`https://github.com/team/resources.git`,className:`mt-1 w-full rounded-md border bg-transparent px-3 py-2 text-sm`})]}),(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsx)(`span`,{className:`text-xs font-medium`,children:`Local folder`}),(0,A.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,A.jsx)(`input`,{"aria-label":`Local clone folder`,value:T,onChange:e=>{D(!0),ee(e.target.value)},placeholder:`/path/to/resource-repositories/team-resources-ab12cd`,className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{g(`clone-parent`),e.onBrowseServerPath(zB(T))},className:`rounded-md border px-3 text-xs`,children:`Choose parent…`})]})]}),e.operations.clonePath?.status===`loading`?(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Suggesting a managed folder…`}):null,e.operations.clonePath?.status===`error`&&C.trim()===te?(0,A.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.clonePath.message}):null,h===`clone-parent`?(0,A.jsx)(mB,{label:`Choose the clone's parent folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{ee(BB(t,T)),g(null),e.onCloseServerBrowser()},onCancel:()=>{g(null),e.onCloseServerBrowser()}}):null,e.operations.preview?.status===`error`?(0,A.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.preview.message}):null,(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>{m(null),g(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,disabled:!C.trim()||!T.trim()||e.operations.preview?.status===`loading`,onClick:()=>e.onCloneRepository(C,T),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.operations.preview?.status===`loading`?`Cloning…`:`Clone and inspect`})]})]})}):de?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-xl font-semibold`,children:de.name}),fe?(0,A.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[11px]`,children:IB[fe.assessment.status]}):null]}),(0,A.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-zinc-500`,children:`repository`in de?de.path:de.reason}),pe?.branch?(0,A.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-400`,children:[pe.branch,pe.upstream?` → ${pe.upstream}`:``]}):null,fe?.removal&&!fe.removal.allowed?(0,A.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:fe.removal.reason}):null]}),fe?(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[fe.removal?.allowed?(0,A.jsx)(`button`,{type:`button`,disabled:e.operations.removals?.[fe.id]?.status===`loading`,onClick:()=>oe(fe),className:`rounded-md border border-red-200 px-3 py-1.5 text-xs text-red-700 disabled:opacity-50 dark:border-red-900 dark:text-red-400`,children:`Remove repository`}):null,(0,A.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(fe.id),className:`rounded-md border px-3 py-1.5 text-xs`,children:`Check`}),me||j?.status===`loading`?(0,A.jsx)(`button`,{type:`button`,disabled:j?.status===`loading`,onClick:()=>fe.containsExtensions?ie(fe):_e(fe),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:j?.status===`loading`?`Updating…`:`Update repository`}):null]}):null]}),pe?.reason?(0,A.jsxs)(`div`,{className:`mt-5 rounded-lg border p-3 text-sm ${pe.status===`dirty`?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[pe.reason,pe.status===`dirty`?(0,A.jsx)(`p`,{className:`mt-1 text-xs`,children:`Review and resolve these local changes in an external terminal, then check again. This updater never commits, stashes, discards, rebases, or merges them.`}):null]}):null,pe?.hasSubmodules?(0,A.jsx)(`p`,{className:`mt-3 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:`This repository declares submodules. Their working trees will not be initialized or updated.`}):null,j?.status===`ready`?(0,A.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-zinc-600`,children:j.result?.status===`updated`&&j.result.reloads.some(e=>e.status===`restart-required`)?`Repository updated. Its skills are reloaded; its extension code runs after pi-outpost restarts — restart it from Settings.`:j.result?.status===`updated`?`Repository updated and runtimes reloaded.`:j.result?.status===`updated-reload-failed`?`Repository updated on disk, but at least one runtime failed to reload.`:j.result?.reason}):null,j?.status===`error`?(0,A.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-red-600`,children:j.message}):null,ve&&fe&&c!==`extension`?(0,A.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[xe>0||Se?.status===`loading`?(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-sky-200 bg-sky-50 px-3 py-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,children:[(0,A.jsx)(`span`,{children:Se?.status===`loading`?`Applying…`:`${xe} pending change${xe===1?``:`s`} — applying replaces the session`}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,disabled:Se?.status===`loading`,onClick:we,className:`rounded border bg-white px-2.5 py-1 disabled:opacity-50 dark:bg-zinc-900`,children:`Discard`}),(0,A.jsx)(`button`,{type:`button`,disabled:Se?.status===`loading`||xe===0,onClick:Te,className:`rounded bg-zinc-900 px-2.5 py-1 font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:`Apply`})]})]}):null,Se?.status===`error`?(0,A.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:Se.message}):null,(0,A.jsx)(AB,{skills:ve.skills,groups:ve.groups,enabled:be,onChange:Ce,disabled:Se?.status===`loading`,...ve.bound?{bound:ve.bound}:{}},fe.id),de.resources.some(e=>e.kind===`extension`)?(0,A.jsx)(VB,{kind:`extension`,resources:de.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:ge}):null]}):(0,A.jsxs)(`div`,{className:`mt-6 grid grid-cols-2 gap-4`,children:[(0,A.jsx)(VB,{kind:`skill`,resources:de.resources.filter(e=>e.kind===`skill`),onRemove:ge}),(0,A.jsx)(VB,{kind:`extension`,resources:de.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:ge})]})]}):(0,A.jsx)(`p`,{className:`text-sm text-zinc-500`,children:`No resources are reported by this runtime.`})]})]})]}),re?(0,A.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,A.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`extension-update-title`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,A.jsx)(`h3`,{id:`extension-update-title`,className:`font-semibold`,children:`Update executable extensions?`}),(0,A.jsxs)(`p`,{className:`mt-2 text-sm text-zinc-600 dark:text-zinc-300`,children:[re.name,` contains extensions that run with the agent's privileges. Confirm updating `,re.assessment.localRevision?.slice(0,8),` to `,re.assessment.upstreamRevision?.slice(0,8),`.`]}),(0,A.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>ie(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{_e(re,!0),ie(null)},className:`rounded bg-amber-600 px-3 py-1.5 text-xs font-medium text-white`,children:`Confirm executable update`})]})]})}):null,k?(0,A.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,A.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`remove-repository-title`,"aria-describedby":`remove-repository-detail`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,A.jsxs)(`h3`,{id:`remove-repository-title`,className:`font-semibold`,children:[`Remove `,k.name,`?`]}),(0,A.jsx)(`p`,{id:`remove-repository-detail`,className:`mt-2 break-words text-sm text-zinc-600 dark:text-zinc-300`,children:k.removal?.deletesFiles?(0,A.jsxs)(A.Fragment,{children:[`This stops loading everything from `,k.name,` and deletes `,(0,A.jsx)(`span`,{className:`font-mono`,children:k.removal.path}),` from disk, with any local changes in it. This cannot be undone.`]}):(0,A.jsxs)(A.Fragment,{children:[`This stops loading everything from `,k.name,`. pi-outpost does not manage `,(0,A.jsx)(`span`,{className:`font-mono`,children:k.removal?.path??k.path}),`, so its files will be kept.`]})}),(0,A.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>oe(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{e.onRemoveRepository(k.id),ce({id:k.id,name:k.name}),oe(null)},className:`rounded bg-red-600 px-3 py-1.5 text-xs font-medium text-white`,children:k.removal?.deletesFiles?`Delete and remove`:`Remove repository`})]})]})}):null]})}var WB=`w-full rounded-md border border-zinc-300 bg-white px-3 py-2 text-sm text-zinc-800 placeholder:text-zinc-400 focus:border-zinc-400 focus:outline-none dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-100 dark:placeholder:text-zinc-600`,GB=`rounded-md border border-zinc-300 px-3 py-1.5 text-xs font-medium text-zinc-700 hover:bg-zinc-50 disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`;function KB({event:e}){switch(e.type){case`auth_url`:return(0,A.jsxs)(`div`,{"data-testid":`login-auth-url`,className:`space-y-1`,children:[(0,A.jsx)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:e.instructions??`Open this page to sign in:`}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`truncate text-sm text-sky-700 underline dark:text-sky-400`,children:e.url}),(0,A.jsx)(`button`,{type:`button`,className:GB,onClick:()=>void navigator.clipboard?.writeText(e.url),children:`Copy`})]})]});case`device_code`:return(0,A.jsxs)(`div`,{"data-testid":`login-device-code`,className:`space-y-1`,children:[(0,A.jsxs)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:[`Enter this code at`,` `,(0,A.jsx)(`a`,{href:e.verificationUri,target:`_blank`,rel:`noopener noreferrer`,className:`text-sky-700 underline dark:text-sky-400`,children:e.verificationUri}),`:`]}),(0,A.jsx)(`p`,{className:`select-all font-mono text-2xl tracking-widest text-zinc-900 dark:text-zinc-50`,children:e.userCode})]});case`info`:return(0,A.jsxs)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:[e.message,e.links?.map(e=>(0,A.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`ml-2 text-sky-700 underline dark:text-sky-400`,children:e.label??e.url},e.url))]});case`progress`:return(0,A.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:e.message})}}function qB({prompt:e,onAnswer:t}){let[n,r]=(0,d.useState)(``),i=e.type===`manual_code`&&/^http:\/\/(?:localhost|127\.0\.0\.1):1455\/auth\/callback\/?$/.test(e.placeholder??``);return e.type===`select`?(0,A.jsxs)(`div`,{"data-testid":`login-prompt`,className:`space-y-2`,children:[(0,A.jsx)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:e.message}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.options.map(e=>(0,A.jsx)(`button`,{type:`button`,className:GB,title:e.description,onClick:()=>t(e.id),children:e.label},e.id))})]}):(0,A.jsxs)(`div`,{"data-testid":`login-prompt`,className:`space-y-2`,children:[(0,A.jsxs)(`label`,{className:`block text-sm text-zinc-700 dark:text-zinc-200`,children:[e.type===`manual_code`?`${e.message} — or the whole address the browser was sent to`:e.message,(0,A.jsx)(`input`,{className:`${WB} mt-1`,type:e.type===`secret`?`password`:`text`,name:`provider-auth-response`,placeholder:e.placeholder,autoComplete:`off`,spellCheck:e.type!==`manual_code`,autoFocus:!0,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),n.trim()&&t(n.trim()))}})]}),i&&(0,A.jsx)(`p`,{className:`text-xs text-zinc-600 dark:text-zinc-300`,children:`If Pi Outpost runs on another computer, your browser may say it cannot connect to localhost. Copy the full address from that browser page and paste it above to finish signing in.`}),(0,A.jsx)(`button`,{type:`button`,className:GB,disabled:!n.trim(),onClick:()=>t(n.trim()),children:`Continue`})]})}function JB({login:e,providerName:t,onAnswer:n,onCancel:r,onDismiss:i}){return(0,A.jsxs)(`div`,{"data-testid":`login-flow`,className:`space-y-3 rounded-md border border-zinc-200 p-3 dark:border-zinc-700`,children:[(0,A.jsxs)(`p`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:[`Signing in to `,t]}),(0,A.jsxs)(`div`,{"aria-live":`polite`,"aria-atomic":`false`,children:[e.events.map((e,t)=>(0,A.jsx)(KB,{event:e},t)),e.prompt&&(0,A.jsx)(qB,{prompt:e.prompt.prompt,onAnswer:n},e.prompt.promptId),!e.done&&!e.prompt&&e.events.length===0&&(0,A.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`Starting…`}),e.done?(0,A.jsxs)(`div`,{"data-testid":`login-done`,"data-ok":e.done.ok?`true`:`false`,className:`space-y-2`,children:[(0,A.jsx)(`p`,{className:`text-sm ${e.done.ok?`text-emerald-700 dark:text-emerald-400`:`text-red-700 dark:text-red-400`}`,children:e.done.ok?`Signed in to ${t}.`:e.done.cancelled?`Sign-in cancelled.`:`Sign-in failed: ${e.done.message??`unknown error`}`}),(0,A.jsx)(`button`,{type:`button`,className:GB,onClick:i,children:`Close`})]}):(0,A.jsx)(`button`,{type:`button`,className:GB,onClick:r,children:`Cancel`})]})]})}function YB(e){return[...e].sort((e,t)=>e.localeCompare(t))}function XB(e,t){return e===`models_json_key`?`This key is managed in models.json. Remove it from that provider configuration.`:e===`environment`?`This key comes from ${t??`the server environment`}. Remove it from there.`:`This key is managed by ${t??e??`the provider runtime`}. Remove it from that source.`}function ZB(e,t){return e===`models_json_key`?`models.json`:t??e}function QB({credentials:e,login:t,onStartLogin:n,onAnswerLogin:r,onCancelLogin:i,onDismissLogin:a,onLogoutProvider:o,extensionPaths:s,configuredExtensionPaths:c,userExtensionPaths:l,extensionLock:u,piPackages:f=null,piPackageUpdate:p=null,canRestartServer:m=!1,serverRestarting:h=!1,onCheckPiPackages:g,onUpdatePiPackage:_,onRestartServer:v,onRestartSession:y,restartNeeded:b=[],tools:x,commands:S,sandbox:C,showRoots:w=!0,gitUnavailable:T,userSkillPaths:ee,serverBrowse:E,pickerBlocked:D=!1,onPickerOpened:te,applyState:ne,agentResources:re=null,agentResourceOperations:ie={clonePath:null,preview:null,enrollment:null,refresh:null,updates:{},skills:{},removals:{}},versions:O,onBrowseServerPath:ae,onCloseServerBrowser:k,onUpdateConfig:oe,onSuggestAgentResourceClonePath:se=()=>{},onCloneAgentResourceRepository:ce=()=>{},onEnrollAgentResourceRepository:le=()=>{},onSetAgentResourceSkills:ue=()=>{},onRemoveAgentResourceRepository:de=()=>{},onRefreshAgentResourceRepositories:fe=()=>{},onUpdateAgentResourceRepository:j=()=>{}}){let[pe,me]=(0,d.useState)(!1),[he,ge]=(0,d.useState)(!1),_e=(0,d.useRef)(new Map),[ve,ye]=(0,d.useState)(!1),be=(0,d.useRef)(null),[xe,Se]=(0,d.useState)(``),[Ce,we]=(0,d.useState)(``),[Te,Ee]=(0,d.useState)(!1),[De,Oe]=(0,d.useState)(!1),[ke,Ae]=(0,d.useState)(null),je=(e,r)=>{if(t&&!t.done){i?.(),a?.();let e=_e.current.get(t.provider);e&&(e.open=!1)}else n?.(e,r)};(0,d.useEffect)(()=>{D&&ke!==null&&Ae(null)},[D,ke]);let Me=yR(()=>{(pe||ke!==null)&&Be()}),Ne=x.filter(e=>e.active),Pe=x.filter(e=>!e.active),Fe=S.filter(e=>e.source===`skill`),Ie=[...x].sort((e,t)=>e.name.localeCompare(t.name)||Number(t.active)-Number(e.active)),Le=ne?.status===`applying`,Re=ne?.status===`error`?ne.message:null;(0,d.useEffect)(()=>{C&&(Se(C.root),we(C.writableRoot??``),Ee(C.allowWrite),Oe(C.allowBash))},[C]);let ze=(0,d.useRef)(!1);(0,d.useEffect)(()=>{ze.current&&ne===null&&Be(),ze.current=Le},[ne,Le]);function Be(){ge(!1),me(!1),Ae(null),k()}function Ve(e,t){te?.(),Ae(e),ae(t.trim()||`/`)}function He(e){ke===`root`?Se(e):ke===`writableRoot`&&we(e),Ae(null),k()}let Ue=C!==null&&(xe!==C.root||(Ce.trim()||void 0)!==(C.writableRoot||void 0)||Te!==C.allowWrite||De!==C.allowBash);function We(){C&&Ue&&oe({sandbox:{root:xe,allowWrite:Te,allowBash:De,writableRoot:Ce.trim()||void 0}})}let Ge=w&&C?.rootEditable!==!1,Ke=ke!==null&&!D&&(0,A.jsx)(mB,{label:ke===`root`?`Choose the sandbox root`:`Choose the writable root`,browse:E,onBrowse:ae,onSelect:He,onCancel:()=>{Ae(null),k()}});return(0,A.jsxs)(`div`,{className:`relative`,ref:Me,children:[(0,A.jsx)(`button`,{ref:be,type:`button`,onClick:()=>{ge(!1),pe?Be():me(!0)},title:`Settings`,"aria-label":`Settings`,className:`${oB} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`⚙`}),pe&&(0,A.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[80vh] w-[380px] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,A.jsxs)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:[he&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>ge(!1),className:`mb-2 text-xs text-zinc-600 hover:underline dark:text-zinc-400`,children:`← Back to settings`}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:he?`Credits`:`Settings`})]}),(0,A.jsx)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:he?(0,A.jsx)(wB,{}):(0,A.jsxs)(A.Fragment,{children:[T&&(0,A.jsxs)(`section`,{className:`mb-4`,"data-testid":`git-unavailable`,children:[(0,A.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Version control`}),T.reason===`no-repository`?(0,A.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`This project is not in a git repository.`}):(0,A.jsxs)(`div`,{className:`rounded border border-amber-300 bg-amber-50 px-2 py-1.5 dark:border-amber-900 dark:bg-amber-950/40`,children:[(0,A.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-300`,children:T.reason===`no-executable`?`Git is unavailable: its executable could not be run.`:`Git is unavailable: it refused this repository.`}),(0,A.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-amber-700 dark:text-amber-400`,children:T.message}),T.reason===`no-executable`&&(0,A.jsxs)(`p`,{className:`mt-1 text-xs text-amber-700 dark:text-amber-400`,children:[`Install git, add it to PATH, or name it with `,(0,A.jsx)(`span`,{className:`font-mono`,children:`gitPath`}),` in the configuration.`]})]})]}),e&&(0,A.jsxs)(`details`,{className:`mb-4`,"data-testid":`accounts-panel`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:[`Accounts · `,(0,A.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:[e.providers.filter(e=>e.configured).length,` providers configured`]})]}),(0,A.jsxs)(`div`,{className:`mt-2`,children:[(0,A.jsx)(`ul`,{className:`space-y-2`,children:e.providers.map(n=>(0,A.jsx)(`li`,{className:`rounded border border-zinc-200 p-2 dark:border-zinc-700`,children:(0,A.jsxs)(`details`,{ref:e=>{e?_e.current.set(n.id,e):_e.current.delete(n.id)},"data-testid":`account-${n.id}`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer`,children:[(0,A.jsx)(`span`,{className:`text-xs font-medium text-zinc-800 dark:text-zinc-200`,children:n.name}),(0,A.jsx)(`span`,{className:`ml-2 text-[11px] ${n.configured?`text-emerald-700 dark:text-emerald-400`:`text-zinc-500 dark:text-zinc-400`}`,children:n.configured?`${n.auth??`Authenticated`}${n.source?` · ${ZB(n.source,n.label)}`:``}`:`Not signed in`})]}),(0,A.jsxs)(`div`,{className:`mt-2`,children:[n.configured&&n.auth===`api_key`&&n.source!==`stored`&&(0,A.jsx)(`p`,{className:`mb-2 text-[11px] text-zinc-500 dark:text-zinc-400`,children:XB(n.source,n.label)}),!e.locked&&(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[n.methods?.includes(`oauth`)&&(0,A.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>je(n.id,`oauth`),children:`Sign in`}),n.methods?.includes(`api_key`)&&(0,A.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>je(n.id,`api_key`),children:`API key`}),n.configured&&n.source===`stored`&&(0,A.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>o?.(n.id),children:n.auth===`api_key`?`Remove API key`:`Sign out`})]}),t?.provider===n.id&&(0,A.jsx)(`div`,{className:`mt-2`,children:(0,A.jsx)(JB,{login:t,providerName:n.name,onAnswer:e=>r?.(e),onCancel:()=>i?.(),onDismiss:()=>a?.()})})]})]})},n.id))}),e.locked&&(0,A.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`Credentials are locked by this server.`})]})]}),(0,A.jsxs)(`section`,{className:`mb-4`,children:[(0,A.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Agent resources`}),x.length===0?(0,A.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`Tool inventory unavailable for this runtime`}):(0,A.jsxs)(`details`,{"data-testid":`tools-loaded`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[Ne.length,` tools active`,Pe.length?` · ${Pe.length} inactive`:``]}),(0,A.jsx)(`ul`,{className:`mt-2 space-y-1`,children:Ie.map(e=>(0,A.jsxs)(`li`,{className:`flex justify-between rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:[(0,A.jsx)(`span`,{children:e.name}),(0,A.jsx)(`span`,{children:e.active?`active`:`inactive`})]},e.name))})]}),Fe.length===0?(0,A.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skills loaded`}):(0,A.jsxs)(`details`,{className:`mt-2`,"data-testid":`skills-loaded`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[Fe.length,` skills loaded`]}),(0,A.jsx)(`ul`,{className:`mt-2 space-y-1`,children:YB(Fe.map(e=>e.name)).map(e=>(0,A.jsx)(`li`,{className:`rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:e},e))})]}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Manage agent resources`,onClick:()=>{me(!1),ye(!0)},className:`mt-3 w-full rounded-md border border-zinc-300 px-3 py-2 text-xs font-medium text-zinc-700 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`,children:`Manage resources…`})]}),(0,A.jsxs)(`section`,{className:`mb-4`,children:[(0,A.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),s===null?(0,A.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-unknown`,children:`Not reported by this runtime`}):s.length===0?(0,A.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,A.jsxs)(`details`,{"data-testid":`extensions-loaded`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[s.length,` `,s.length===1?`extension`:`extensions`,` loaded`]}),(0,A.jsx)(`ul`,{className:`mt-2 space-y-1`,children:YB(s).map(e=>(0,A.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),c.length>0&&(0,A.jsxs)(`details`,{className:`mt-2`,"data-testid":`extensions-configured`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[c.length,` configured by this deployment`]}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`Declared in the configuration file. They load either way, and nothing here can remove them.`}),(0,A.jsx)(`ul`,{className:`mt-1 space-y-1`,children:YB(c).map(e=>(0,A.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),u?(0,A.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-locked`,children:`Extension paths and repository updates that contain extensions are locked by this deployment.`}):null,(0,A.jsx)(EB,{packages:f,update:p,locked:u,onCheck:()=>g?.(),onUpdate:e=>_?.(e)}),(0,A.jsx)(DB,{reasons:b,canRestart:m,restarting:h,onRestart:()=>v?.()})]}),C&&(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:Ge?`Sandbox`:`Agent permissions`}),(0,A.jsxs)(`div`,{className:`space-y-3`,children:[!Ge&&(0,A.jsxs)(`p`,{"data-testid":`sandbox-project-root`,className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`This project is confined to its own folder,`,` `,(0,A.jsx)(`span`,{className:`break-all font-mono text-zinc-800 dark:text-zinc-200`,children:C.projectRoot??C.root}),`. Each open project is confined to its own. A change here applies to this project now, and to projects opened after.`]}),Ge&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,C.locks?.root?(0,A.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,A.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,A.jsx)(`input`,{type:`text`,value:xe,onChange:e=>Se(e.target.value),disabled:C.locks?.root,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:focus:border-zinc-500`}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Browse for sandbox root`,disabled:C.locks?.root,onClick:()=>Ve(`root`,xe),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),ke===`root`&&Ke,(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,C.locks?.writableRoot?(0,A.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,A.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,A.jsx)(`input`,{type:`text`,value:Ce,onChange:e=>we(e.target.value),disabled:C.locks?.writableRoot,placeholder:`Same as root`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Browse for writable root`,disabled:C.locks?.writableRoot,onClick:()=>Ve(`writableRoot`,Ce||xe),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),ke===`writableRoot`&&Ke]}),(0,A.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:Te,onChange:e=>Ee(e.target.checked),disabled:C.locks?.allowWrite,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,A.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,C.locks?.allowWrite?(0,A.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,A.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:De,onChange:e=>Oe(e.target.checked),disabled:C.locks?.allowBash,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,A.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,C.locks?.allowBash?(0,A.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]})]})]}),!C&&(0,A.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),(0,A.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[Re&&(0,A.jsx)(`p`,{role:`alert`,className:`rounded-md border border-red-300 bg-red-50 px-2 py-1 text-xs text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:Re}),(0,A.jsx)(`button`,{type:`button`,disabled:Le||Ue&&!xe.trim(),onClick:Ue?We:y,className:`w-full rounded-md bg-zinc-800 px-3 py-1.5 text-xs font-medium text-white hover:bg-zinc-700 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-zinc-200 dark:text-zinc-900 dark:hover:bg-zinc-300`,children:Le?`Restarting…`:Ue?`Apply & restart session`:`Restart session`}),(0,A.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:Ue?`Saved to the server's configuration file, then the session is rebuilt — the change survives a restart.`:`Start a fresh session to reload extensions and MCP connections. Settings are kept.`})]}),O&&(0,A.jsxs)(`section`,{className:`mt-4`,children:[(0,A.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,A.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,A.jsxs)(`p`,{children:[`pi-outpost: `,(0,A.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:O.piOutpost})]}),O.piSdk&&(0,A.jsxs)(`p`,{children:[`pi SDK: `,(0,A.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:O.piSdk})]}),O.agent&&(0,A.jsxs)(`p`,{children:[`agent: `,(0,A.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:O.agent})]})]})]}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>ge(!0),className:`mt-4 w-full border-t border-zinc-200 pt-3 text-left text-sm text-zinc-600 hover:text-zinc-900 dark:border-zinc-700 dark:text-zinc-400 dark:hover:text-zinc-100`,children:`Credits →`})]})})]}),(0,A.jsx)(UB,{open:ve,inventory:re,operations:ie,extensionLock:u,userSkillPaths:ee,userExtensionPaths:l,serverBrowse:E,applyState:ne,onClose:()=>{ye(!1),k(),be.current?.focus()},onBrowseServerPath:e=>{te?.(),ae(e)},onCloseServerBrowser:k,onUpdateConfig:oe,onSuggestClonePath:se,onCloneRepository:ce,onEnrollRepository:le,onSetSkills:ue,onRemoveRepository:de,onRefresh:fe,onUpdate:j})]})}function $B(e){let t=[],n=new Set,r=0,i=0;function a(e,o,s,c){let l=e.children,u=l.slice(1).map(e=>[e,r++]);u.length>0&&i++;let d=e.onPath&&!l.some(e=>e.onPath);if(t.push({node:e,lane:o,through:[...n].filter(e=>e!==o),forkTo:u.map(([,e])=>e),lineAbove:s,lineBelow:l.length>0,branchIndex:c,isCurrent:d,emphasis:d?`current`:e.onPath?`filled`:`hollow`,highlight:e.onPath}),l.length===0)n.delete(o);else{for(let[,e]of u)n.add(e);a(l[0],o,!0,u.length>0?1:void 0),u.forEach(([e,t],n)=>a(e,t,!0,n+2))}}return e.length>1&&i++,e.forEach((t,i)=>{let o=r++;n.add(o),a(t,o,!1,e.length>1?i+1:void 0)}),{rows:t,laneCount:r,branchPoints:i}}function eV(e){return e.flatMap(e=>[e,...eV(e.children)])}function tV({children:e,tone:t}){let n={current:`border-emerald-300 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-950/50 dark:text-emerald-300`,branch:`border-zinc-300 text-zinc-500 dark:border-zinc-700 dark:text-zinc-400`,label:`border-violet-300 bg-violet-50 text-violet-700 dark:border-violet-900 dark:bg-violet-950/50 dark:text-violet-300`}[t];return(0,A.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var nV=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`;function rV({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:o}=e,s=o.tipId??o.entryId;return(0,A.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${e.isCurrent?`bg-emerald-50/60 dark:bg-emerald-950/20`:``}`,style:{height:36},children:[(0,A.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>{r(s),a()},title:n?`unavailable while the agent is running`:o.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex h-full min-w-0 flex-1 items-center gap-2 pl-2 text-left text-sm disabled:opacity-50`,children:[(0,A.jsx)(Gz,{row:e,laneCount:t,colorOf:Hz}),(0,A.jsx)(`span`,{className:`min-w-0 truncate ${o.onPath?`text-zinc-800 dark:text-zinc-200`:`text-zinc-600 dark:text-zinc-400`}`,children:o.text||`(empty)`}),e.forkTo.length>0&&(0,A.jsxs)(tV,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,A.jsxs)(tV,{tone:`branch`,children:[`branch `,e.branchIndex,o.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,A.jsx)(tV,{tone:`current`,children:`current`}),o.label&&(0,A.jsx)(tV,{tone:`label`,children:o.label})]}),(0,A.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{r(o.entryId),a()},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:nV,children:`↺ redo`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{i(o.entryId),a()},title:`fork a new session from this point`,className:nV,children:`⑂ fork`})]})}function iV({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:i}){let[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(``),l=yR(()=>o(!1));(0,d.useEffect)(()=>{a&&e===null&&n()},[a,e]);let u=(0,d.useMemo)(()=>e&&e.length>0?$B(e):null,[e]),f=(0,d.useMemo)(()=>{if(!e||!s.trim())return null;let t=s.trim().toLowerCase();return eV(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,s]);return(0,A.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>{o(!a),a||(c(``),n())},title:`conversation tree: go back to an earlier point or fork`,className:`${oB} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`tree`}),a&&(0,A.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[70vh] w-[32rem] max-w-[90vw] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl [--tree-off:#e4e4e7] dark:border-zinc-700 dark:bg-zinc-900 dark:[--tree-off:#3f3f46]`,children:[e===null&&(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&u&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,A.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,A.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,A.jsxs)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:[u.rows.length,` turn`,u.rows.length===1?``:`s`,` · `,u.branchPoints,` branch point`,u.branchPoints===1?``:`s`]})]}),(0,A.jsx)(`input`,{type:`search`,value:s,onChange:e=>c(e.target.value),placeholder:`Search tree`,"aria-label":`Search conversation tree`,className:`mt-2 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,A.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Follow the colored lines — the current branch is highlighted. Click a turn to restore the conversation there · ↺ to send it again · ⑂ to fork a session`})]}),(0,A.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:f===null?u.rows.map(e=>(0,A.jsx)(rV,{row:e,laneCount:u.laneCount,isStreaming:t,onNavigate:r,onFork:i,onClose:()=>o(!1)},e.node.entryId)):f.length===0?(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):f.map(e=>(0,A.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,A.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.tipId??e.entryId),o(!1)},title:e.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left text-sm disabled:opacity-50`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,A.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,A.jsx)(tV,{tone:`current`,children:`on current branch`}),e.label&&(0,A.jsx)(tV,{tone:`label`,children:e.label})]}),(0,A.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.entryId),o(!1)},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:nV,children:`↺ redo`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{i(e.entryId),o(!1)},title:`fork a new session from this point`,className:nV,children:`⑂ fork`})]},e.entryId))})]})]})]})}var aV=200;function oV({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,d.useState)(e);return(0,A.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),onBlur:n,onKeyDown:e=>{e.key===`Enter`?t(r):e.key===`Escape`&&n()},placeholder:`Session name (empty to clear)`,"aria-label":`Session name`,className:`w-full rounded-md border border-zinc-400 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 dark:border-zinc-600 dark:placeholder:text-zinc-600`})}function sV({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:o,onCancelRename:s}){return n?(0,A.jsx)(`div`,{className:`px-3 py-2`,children:(0,A.jsx)(oV,{initial:e.name??``,onCommit:o,onCancel:s})}):(0,A.jsxs)(`div`,{className:`group flex items-start gap-1 hover:bg-zinc-100 dark:hover:bg-zinc-800 ${t?`bg-zinc-100 dark:bg-zinc-800/60`:``}`,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,A.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,A.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,A.jsxs)(`div`,{className:`mt-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:[new Date(e.modified).toLocaleString(),` · `,e.messageCount,` messages`,t?` · current`:``,!t&&e.liveIn?(0,A.jsxs)(`span`,{"data-testid":`session-live-in`,children:[` · open in `,e.liveIn]}):null]})]}),(0,A.jsx)(`button`,{type:`button`,onClick:a,title:`rename session`,"aria-label":`Rename session`,className:`mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✎`}),!t&&!e.liveIn&&(0,A.jsx)(`button`,{type:`button`,onClick:i,title:`delete session`,"aria-label":`Delete session`,className:`mr-2 mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-red-100 hover:text-red-600 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-red-950/60 dark:hover:text-red-400`,children:`✕`})]})}function cV({sessions:e,sessionSearch:t,sessionId:n,onSwitchSession:r,onDeleteSession:i,onListSessions:a,onRenameSession:o,onSearchSessions:s,onClearSessionSearch:c}){let[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(``),[m,h]=(0,d.useState)(null),g=yR(()=>u(!1)),_=f.trim(),v=_.length>=2;(0,d.useEffect)(()=>{if(!l)return;if(!v){c();return}let e=setTimeout(()=>s(_),aV);return()=>clearTimeout(e)},[l,_,v]);function y(){u(!1),h(null)}let b=v&&(t?.status!==`loaded`||t.query!==_),x=v?b?null:t?.results??null:e;return(0,A.jsxs)(`div`,{className:`relative`,ref:g,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>{l?y():(u(!0),p(``),h(null),c(),a())},className:`${oB} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`sessions`}),l&&(0,A.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-96 w-96 flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,A.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,A.jsx)(`input`,{type:`search`,value:f,onChange:e=>p(e.target.value),placeholder:`Search sessions`,"aria-label":`Search sessions`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,A.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Searches names and everything said in a session · ✎ to rename`})]}),(0,A.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[x===null&&(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),x?.length===0&&(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:v?`no matches`:`no saved sessions`}),x?.map(e=>(0,A.jsx)(sV,{session:e,isCurrent:e.id===n,renaming:m===e.path,onSwitch:()=>{r(e.path),y()},onDelete:()=>{window.confirm(`Delete this session?`)&&i(e.path)},onStartRename:()=>h(e.path),onRename:t=>{o(e.path,t),h(null),v&&s(f.trim())},onCancelRename:()=>h(null)},e.path))]})]})]})}function lV({filters:e,onFilterChange:t}){let[n,r]=(0,d.useState)(!1),i=yR(()=>r(!1)),a=qL(e),o=a>0?`Filter · ${a} hidden`:`Filter`;return(0,A.jsxs)(`div`,{className:`relative`,ref:i,onKeyDown:e=>{e.key===`Escape`&&n&&(e.stopPropagation(),r(!1))},children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>r(!n),"aria-haspopup":`menu`,"aria-expanded":n,title:`Choose what the conversation shows`,className:`${oB} ${a>0?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:o}),n&&(0,A.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-30 mt-1 w-48 rounded-md border border-zinc-200 bg-white py-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:HL.map(n=>(0,A.jsxs)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":e[n],onClick:()=>t(n,!e[n]),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-zinc-600 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:`w-3`,children:e[n]?`✓`:``}),(0,A.jsx)(`span`,{children:UL[n]})]},n))})]})}function uV({statuses:e,bar:t}){let n=Object.entries(e).filter(([,e])=>WR(e).trim()!==``),r=n.map(([e,t])=>`${e}\u0000${t}`).join(``),[i,a]=(0,d.useState)(!1),o=(0,d.useRef)(null),s=(0,d.useRef)(null),[c,l]=(0,d.useState)(!1),u=yR(()=>l(!1));if((0,d.useLayoutEffect)(()=>{o.current=null,a(!1),l(!1)},[r]),(0,d.useLayoutEffect)(()=>{let e=t;if(e===null)return;let n=()=>{o.current===null?(Array.from(s.current?.querySelectorAll(`[data-status-text]`)??[]).some(e=>e.scrollWidth>e.clientWidth+1)||e.scrollWidth>e.clientWidth+1)&&(o.current=e.clientWidth,a(!0)):e.clientWidth>o.current+64&&(o.current=null,a(!1),l(!1))};if(n(),typeof ResizeObserver>`u`)return;let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t,i,r]),n.length===0)return null;if(!i)return(0,A.jsx)(`div`,{ref:s,className:`flex shrink-0 items-center gap-1.5`,children:n.map(([e,t])=>(0,A.jsx)(`span`,{title:WR(t),className:`${oB} max-w-[16rem] border-zinc-200 text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:(0,A.jsx)(`span`,{"data-status-text":!0,className:`truncate`,children:(0,A.jsx)(GR,{text:t})})},e))});let f=`${n.length} ${n.length===1?`status`:`statuses`}`;return(0,A.jsxs)(`div`,{ref:u,className:`relative shrink-0`,onKeyDown:e=>{e.key===`Escape`&&c&&(e.stopPropagation(),l(!1))},children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>l(!c),"aria-expanded":c,title:n.map(([,e])=>WR(e)).join(`
|
|
1266
|
+
`),className:`${oB} border-zinc-200 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:[f,` ▾`]}),c&&(0,A.jsx)(`ul`,{"aria-label":`Extension statuses`,className:`absolute left-0 top-full z-20 mt-1 w-max max-w-[24rem] rounded-md border border-zinc-200 bg-white py-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:n.map(([e,t])=>(0,A.jsx)(`li`,{className:`break-words px-3 py-1.5 text-xs text-zinc-600 dark:text-zinc-300`,children:(0,A.jsx)(GR,{text:t})},e))})]})}function dV({theme:e,preference:t=e,onToggle:n,onSetTheme:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useRef)(null),s=yR(()=>a(!1));(0,d.useEffect)(()=>{i&&s.current?.querySelector(`[aria-checked="true"]`)?.focus()},[i]);let c={light:`Light`,dark:`Dark`,system:`System`}[t];return(0,A.jsxs)(`div`,{ref:s,className:`relative`,onKeyDown:e=>{if(e.key===`Escape`&&(e.stopPropagation(),a(!1),o.current?.focus()),i&&[`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key)){e.preventDefault();let t=Array.from(s.current?.querySelectorAll(`[role="menuitemradio"]`)??[]),n=t.findIndex(e=>e.matches(`:focus`));t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus()}},children:[(0,A.jsx)(`button`,{ref:o,type:`button`,onClick:()=>a(e=>!e),title:`Theme: ${c}`,"aria-label":`Theme: ${c}`,"aria-haspopup":`menu`,"aria-expanded":i,className:`${oB} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:t===`system`?`◐`:e===`dark`?`☾`:`☀`}),i&&(0,A.jsx)(`div`,{role:`menu`,"aria-label":`Theme`,className:`absolute right-0 top-full z-40 mt-2 min-w-32 rounded-lg border border-zinc-300 bg-white p-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[`light`,`dark`,`system`].map(i=>(0,A.jsx)(`button`,{role:`menuitemradio`,"aria-checked":t===i,type:`button`,className:`block w-full rounded px-3 py-1.5 text-left text-xs text-zinc-700 hover:bg-zinc-100 focus:bg-zinc-100 dark:text-zinc-200 dark:hover:bg-zinc-800 dark:focus:bg-zinc-800`,onClick:()=>{r?r(i):i!==e&&n(),a(!1),o.current?.focus()},children:i===`light`?`Light`:i===`dark`?`Dark`:`System`},i))})]})}function fV(e){let{isStreaming:t,connected:n}=e,[r,i]=(0,d.useState)(null);return(0,A.jsxs)(`header`,{ref:i,className:`relative z-30 flex min-w-0 items-center gap-1.5 border-b border-zinc-200 px-4 py-2 dark:border-zinc-800`,children:[e.workspaceControl===`projects`&&(0,A.jsx)(pB,{workspace:e.workspace,workspaces:e.workspaces,locked:e.workspaceLocked,onSwitch:e.onSwitchWorkspace,onOpen:e.onOpenProject,onClose:e.onCloseProject,onOpenSide:e.onOpenSideSession}),e.workspaceControl===`root`&&e.rootControl&&(0,A.jsx)(gB,{sandbox:e.rootControl.sandbox,browse:e.rootControl.browse,applyState:e.rootControl.applyState,blocked:e.rootControl.blocked,onBrowse:e.rootControl.onBrowse,onCloseBrowser:e.rootControl.onCloseBrowser,onOpened:e.rootControl.onOpened,onSelect:e.rootControl.onSelect}),(0,A.jsxs)(`button`,{type:`button`,onClick:e.onToggleSidebar,title:e.sidebarOpen?`Hide files (panel opens on the left)`:`Show files`,"aria-pressed":e.sidebarOpen,className:`${oB} ${e.sidebarOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:[e.sidebarOpen?`◧`:`◨`,` files`]}),(0,A.jsxs)(`button`,{type:`button`,onClick:e.onToggleOutcome,"aria-pressed":e.outcomeOpen,title:`Review structured workspace Outcome`,className:`${oB} ${e.outcomeOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:e.workspace?.activity===`ready-for-review`?`border-amber-400 text-amber-700 dark:text-amber-300`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 dark:border-zinc-800 dark:text-zinc-400`}`,children:[`Outcome`,e.workspace?.activity===`ready-for-review`?` •`:``]}),e.gitAvailable&&(0,A.jsx)(yB,{status:e.gitStatus,selected:e.gitSelectedPath,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,A.jsx)(`span`,{title:e.title??void 0,className:`min-w-[2.25rem] shrink-[4] truncate whitespace-nowrap text-lg font-semibold leading-tight tracking-tight`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),(0,A.jsx)(uV,{statuses:e.statuses,bar:r}),(0,A.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,A.jsx)(lV,{filters:e.filters,onFilterChange:e.onFilterChange}),e.onExportConversation&&(0,A.jsx)(`button`,{type:`button`,onClick:e.onExportConversation,disabled:!!e.exportProgress,"aria-busy":!!e.exportProgress,title:`Save the whole conversation as one HTML file`,"aria-label":`Export the conversation as HTML`,className:`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 text-xs leading-none border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 disabled:cursor-progress disabled:opacity-60 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:e.exportProgress??`↓ html`}),e.onToggleTerminal&&(0,A.jsx)(`button`,{type:`button`,onClick:e.onToggleTerminal,title:e.terminalOpen?"Close Terminal (Ctrl+`)":"Open Terminal (Ctrl+`)","aria-pressed":e.terminalOpen,className:`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 text-xs leading-none ${e.terminalOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:`>_ terminal`}),e.showThemeToggle&&(0,A.jsx)(dV,{theme:e.theme,preference:e.themePreference,onSetTheme:e.onSetTheme,onToggle:e.onToggleTheme}),(0,A.jsx)(`button`,{type:`button`,onClick:e.onNewSession,title:`new session`,className:`${oB} border-emerald-300 text-emerald-700 hover:border-emerald-500 hover:text-emerald-600 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600 dark:hover:text-emerald-300`,children:`+ new`}),(0,A.jsx)(iV,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,A.jsx)(cV,{sessions:e.sessions,sessionSearch:e.sessionSearch,sessionId:e.sessionId,onSwitchSession:e.onSwitchSession,onDeleteSession:e.onDeleteSession,onListSessions:e.onListSessions,onRenameSession:e.onRenameSession,onSearchSessions:e.onSearchSessions,onClearSessionSearch:e.onClearSessionSearch}),(0,A.jsx)(QB,{credentials:e.credentials,login:e.login,onStartLogin:e.onStartLogin,onAnswerLogin:e.onAnswerLogin,onCancelLogin:e.onCancelLogin,onDismissLogin:e.onDismissLogin,onLogoutProvider:e.onLogoutProvider,extensionPaths:e.extensionPaths,configuredExtensionPaths:e.configuredExtensionPaths,userExtensionPaths:e.userExtensionPaths,extensionLock:e.extensionLock,piPackages:e.piPackages??null,piPackageUpdate:e.piPackageUpdate??null,canRestartServer:e.canRestartServer??!1,serverRestarting:e.serverRestarting??!1,...e.onCheckPiPackages?{onCheckPiPackages:e.onCheckPiPackages}:{},...e.onUpdatePiPackage?{onUpdatePiPackage:e.onUpdatePiPackage}:{},...e.onRestartServer?{onRestartServer:e.onRestartServer}:{},restartNeeded:e.restartNeeded??[],tools:e.tools??[],commands:e.commands??[],sandbox:e.sandbox,showRoots:!(e.workspaceControl===`projects`&&e.workspaces.filter(e=>!e.sideOf).length>1),gitUnavailable:e.gitUnavailable,userSkillPaths:e.userSkillPaths,serverBrowse:e.serverBrowse,applyState:e.settingsApply,agentResources:e.agentResources,agentResourceOperations:e.agentResourceOperations,versions:e.versions,onBrowseServerPath:e.onBrowseServerPath,onCloseServerBrowser:e.onCloseServerBrowser,pickerBlocked:e.settingsPickerBlocked,onPickerOpened:e.onSettingsPickerOpened,onRestartSession:e.onRestartSession,onUpdateConfig:e.onUpdateConfig,onSuggestAgentResourceClonePath:e.onSuggestAgentResourceClonePath,onCloneAgentResourceRepository:e.onCloneAgentResourceRepository,onEnrollAgentResourceRepository:e.onEnrollAgentResourceRepository,onSetAgentResourceSkills:e.onSetAgentResourceSkills,onRemoveAgentResourceRepository:e.onRemoveAgentResourceRepository,onRefreshAgentResourceRepositories:e.onRefreshAgentResourceRepositories,onUpdateAgentResourceRepository:e.onUpdateAgentResourceRepository}),(0,A.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function pV(e,t){let n=(0,d.useRef)(new Map);(0,d.useEffect)(()=>{if(typeof Notification>`u`)return;let r=e.filter(e=>e.needsAttention),i=r.filter(e=>oL(e)!==t);for(let e of[...n.current.keys()])r.some(t=>oL(t)===e)||n.current.delete(e);if(Notification.permission===`granted`&&(typeof document>`u`||document.visibilityState!==`visible`)){for(let e of i)if(n.current.get(oL(e))!==e.activity){n.current.set(oL(e),e.activity);try{let t=e.activity===`ready-for-review`;new Notification(t?`${e.name} is ready for review`:`${e.name} needs you`,{body:t?`Background work is ready for review.`:`The agent needs an answer to continue.`,tag:`pi-outpost:${oL(e)}`})}catch{}}}},[e,t])}var mV={"agent-directory":`read the agent directory (the provider keys)`,"beside-root":`read a file beside the root`,"write-beside-root":`write beside the root`,"signal-process":`signal another process of the server's user`,"server-environment":`inherit the server's environment`,"server-process-environment":`read the server's process environment (/proc)`,"unlisted-host":`reach a host not in sandbox.allowedHosts`,"direct-connection":`connect around the proxy`},hV=e=>e.map(e=>mV[e]??e),gV=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()};function _V(e,t){let n=t===`shell`?`The agent's shell`:`This terminal`;switch(e.state){case`checking`:return`${n} runs under ${e.runner||`a sandbox runner`}; its confinement is being checked.`;case`verified`:return[`${n} is confined by ${e.runner}, checked at ${gV(e.checkedAt)}. A command could not:`,...hV(e.refused).map(e=>`• ${e}`),...e.environmentReadable?[`The server's process environment is readable, and holds no secret.`]:[],...e.notChecked.length?[`Not checked:`,...e.notChecked.map(e=>`• ${mV[e.attempt]??e.attempt} — ${e.why}`)]:[]].join(`
|
|
1267
1267
|
`);case`partial`:return[`${n} is confined by ${e.runner}, checked at ${gV(e.checkedAt)}, except one thing: a command can read the server's process environment, which holds ${e.exposed.join(`, `)}.`,`Move these out of the server's environment — provider keys belong in the agent directory.`,`A command could not:`,...hV(e.refused).map(e=>`• ${e}`)].join(`
|
|
1268
1268
|
`);case`leaking`:return[`${n} is NOT confined as configured: under ${e.runner}, checked at ${gV(e.checkedAt)}, a command could:`,...hV(e.reached).map(e=>`• ${e}`),`The configuration is unchanged: fix the runner or its host, or stop using it.`].join(`
|
|
1269
1269
|
`);case`failed`:return`${n}'s confinement could not be checked (${e.runner}, ${gV(e.checkedAt)}): ${e.reason}`}}function vV({verdict:e,surface:t,root:n}){let r=n?` to ${n}`:``,i=e.state===`verified`?{icon:`🔒`,text:`confined${r}`,tone:`bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200`}:e.state===`partial`?{icon:`🔐`,text:`partly confined`,tone:`bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200`}:e.state===`leaking`?{icon:`🔓`,text:`not confined`,tone:`bg-red-100 text-red-800 dark:bg-red-900/50 dark:text-red-200`}:e.state===`failed`?{icon:`⚠`,text:`confinement unchecked`,tone:`bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200`}:{icon:`…`,text:`checking confinement`,tone:`bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-300`};return(0,A.jsxs)(`span`,{"data-testid":t===`shell`?`shell-confinement`:`terminal-confined`,"data-state":e.state,title:_V(e,t),className:`shrink-0 whitespace-nowrap rounded px-1.5 py-0.5 font-sans text-[11px] ${i.tone}`,children:[i.icon,` `,t===`shell`?`shell ${i.text}`:i.text]})}function yV(e){return!e||e.percent===null?`text-zinc-400 dark:text-zinc-600`:e.percent>=85?`text-red-500`:e.percent>=60?`text-amber-500 dark:text-amber-400`:`text-emerald-500`}function bV({usage:e,analysisOpen:t,onToggleAnalysis:n}){if(e.turns===0)return null;let r=e.turns-e.unpriced,i=[`${e.turns} turn${e.turns===1?``:`s`}`,`input ${e.input.toLocaleString()}`,`output ${e.output.toLocaleString()}`,`cache read ${e.cacheRead.toLocaleString()}`,`cache write ${e.cacheWrite.toLocaleString()}`,...e.unpriced>0&&r>0?[`${e.unpriced} unpriced`]:[]].join(` · `),a=(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`span`,{children:[pL(e.totalTokens),` tok`]}),r>0&&(0,A.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:[fL(e.cost),e.unpriced>0&&`*`]})]}),o=`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs text-zinc-500 dark:text-zinc-400`;return n?(0,A.jsx)(`button`,{type:`button`,onClick:n,title:`${i} — click for the session analysis`,"aria-haspopup":`dialog`,"aria-expanded":t??!1,className:`${o} ${t?`border-zinc-400 dark:border-zinc-600`:`border-zinc-300 hover:border-zinc-400 dark:border-zinc-800 dark:hover:border-zinc-600`}`,children:a}):(0,A.jsx)(`span`,{title:i,className:`${o} border-zinc-300 dark:border-zinc-800`,children:a})}function xV({usage:e}){let t=15.9155,n=2*Math.PI*t,r=e?.percent??0,i=Math.min(100,Math.max(0,r))/100*n;return(0,A.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 36 36`,className:`-rotate-90 shrink-0`,children:[(0,A.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,className:`text-zinc-200 dark:text-zinc-800`}),e&&e.percent!==null&&(0,A.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${i} ${n-i}`,className:yV(e)})]})}function SV({thinkingLevel:e,thinkingLevels:t,isStreaming:n,onSetThinking:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useRef)(null),s=e!==`off`,c=t&&t.length>0?t:Oz,l=c.indexOf(e),u=c.length>1;return(0,d.useEffect)(()=>{if(!i)return;function e(e){o.current&&!vR(e,o.current)&&a(!1)}function t(e){e.key===`Escape`&&a(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]),(0,A.jsxs)(`div`,{className:`relative`,ref:o,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),disabled:n,title:`thinking level`,"aria-haspopup":`true`,"aria-expanded":i,className:`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs disabled:opacity-50 ${s?`border-amber-300 text-amber-700 hover:border-amber-400 dark:border-amber-900 dark:text-amber-400 dark:hover:border-amber-700`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600`}`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none ${s?``:`opacity-40 grayscale`}`,children:`🧠`}),e]}),i&&(0,A.jsxs)(`div`,{className:`absolute bottom-full left-0 z-20 mb-1 w-48 rounded-lg border border-zinc-200 bg-white p-3 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,A.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between text-xs`,children:[(0,A.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`thinking`}),(0,A.jsx)(`span`,{className:`font-mono text-zinc-700 dark:text-zinc-200`,children:e})]}),u?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`input`,{type:`range`,min:0,max:c.length-1,step:1,value:l===-1?0:l,onChange:e=>r(c[Number(e.target.value)]),"aria-label":`Thinking level`,"aria-valuetext":e,className:`w-full accent-amber-500`}),(0,A.jsxs)(`div`,{className:`mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,children:[(0,A.jsx)(`span`,{children:c[0]}),(0,A.jsx)(`span`,{children:c[c.length-1]})]})]}):(0,A.jsxs)(`p`,{className:`text-[11px] text-zinc-500 dark:text-zinc-400`,children:[`this model accepts `,(0,A.jsx)(`span`,{className:`font-mono`,children:c[0]}),` only`]})]})]})}function CV(e){let{model:t,models:n,thinkingLevel:r,modelSupportsReasoning:i,isStreaming:a,contextUsage:o,sessionUsage:s,isCompacting:c}=e;return(0,A.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,A.jsxs)(`select`,{value:t,onChange:t=>{let r=n.find(e=>`${e.provider}/${e.id}`===t.target.value);r&&e.onSetModel(r.provider,r.id)},disabled:a,className:`max-w-64 rounded-md border border-zinc-300 bg-white px-2 py-1 font-mono text-xs text-zinc-700 outline-none hover:border-zinc-400 disabled:opacity-50 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-300 dark:hover:border-zinc-600`,children:[!n.some(e=>`${e.provider}/${e.id}`===t)&&(0,A.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,A.jsxs)(`option`,{value:`${e.provider}/${e.id}`,children:[e.provider,`/`,e.id]},`${e.provider}/${e.id}`))]}),i&&(0,A.jsx)(SV,{thinkingLevel:r,thinkingLevels:e.thinkingLevels,isStreaming:a,onSetThinking:e.onSetThinking}),e.shellConfinement&&(0,A.jsx)(`span`,{className:`ml-auto`,children:(0,A.jsx)(vV,{verdict:e.shellConfinement,surface:`shell`})}),(0,A.jsxs)(`button`,{type:`button`,onClick:e.onCompact,disabled:a||c,title:o?.tokens==null?`Click to compact the conversation context`:`${o.tokens.toLocaleString()} / ${o.contextWindow.toLocaleString()} tokens — click to compact`,className:`${e.shellConfinement?``:`ml-auto `}flex items-center gap-1.5 rounded-md border border-zinc-300 px-2 py-1 font-mono text-xs text-zinc-500 hover:border-zinc-400 disabled:opacity-50 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600`,children:[(0,A.jsx)(xV,{usage:o}),c?`compacting…`:o?.percent==null?`context`:`${Math.round(o.percent)}%`]}),(0,A.jsx)(bV,{usage:s,analysisOpen:e.analysisOpen,onToggleAnalysis:e.onToggleAnalysis})]})}var wV=`w-full rounded-md border border-zinc-300 bg-white px-3 py-2 text-sm text-zinc-800 placeholder:text-zinc-400 focus:border-zinc-400 focus:outline-none dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-100 dark:placeholder:text-zinc-600`,TV=`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`;function EV({title:e,credentials:t,onSetCredential:n,onStartLogin:r,login:i,onAnswerLogin:a,onCancelLogin:o,onDismissLogin:s,onDeclareProvider:c,errors:l}){let u=t.providers,[f,p]=(0,d.useState)(u.length>0?`known`:`custom`),[m,h]=(0,d.useState)(u[0]?.id??``),[g,_]=(0,d.useState)(``),[v,y]=(0,d.useState)(``),[b,x]=(0,d.useState)(``),[S,C]=(0,d.useState)(``),[w,T]=(0,d.useState)(!0),[ee,E]=(0,d.useState)(!0);function D(e){i?.provider===e?(i.done||o(),s()):(i&&(i.done||o(),s()),r(e,`oauth`))}let te=u.some(e=>e.configured)&&!t.usableModel;function ne(e){e.preventDefault(),!te&&(f===`known`?m&&g.trim()&&n(m,g.trim()):v.trim()&&b.trim()&&g.trim()&&S.trim()&&c({provider:v.trim(),baseUrl:b.trim(),apiKey:g.trim(),models:[S.trim()],compat:{supportsDeveloperRole:w,supportsReasoningEffort:ee}}))}return(0,A.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto p-6`,children:(0,A.jsxs)(`form`,{onSubmit:ne,className:`w-full max-w-md rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,A.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),te?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`h1`,{className:`mb-3 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model is available.`}),(0,A.jsxs)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:[`Credentials are configured, so this is not a missing key: `,(0,A.jsx)(`code`,{children:`allowedModels`}),` in your configuration leaves nothing to choose from. Widen it, or remove it, then restart.`]})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model provider is set up yet. Add one to start chatting.`}),(0,A.jsx)(`div`,{className:`mb-4 flex gap-1 rounded-lg bg-zinc-100 p-1 text-xs dark:bg-zinc-800`,children:[`known`,`custom`].map(e=>(0,A.jsx)(`button`,{type:`button`,onClick:()=>p(e),className:`flex-1 rounded-md px-2 py-1.5 ${f===e?`bg-white font-medium text-zinc-800 shadow-sm dark:bg-zinc-900 dark:text-zinc-100`:`text-zinc-500 dark:text-zinc-400`}`,children:e===`known`?`Provider API key`:`OpenAI-compatible endpoint`},e))}),t.signIn&&u.some(e=>e.methods?.includes(`oauth`))&&(0,A.jsxs)(`section`,{className:`mb-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,"data-testid":`onboarding-account-signin`,children:[(0,A.jsx)(`h2`,{className:`mb-2 text-xs font-medium text-zinc-700 dark:text-zinc-300`,children:`Sign in with an account`}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:u.filter(e=>e.methods?.includes(`oauth`)).map(e=>{let t=i?.provider===e.id;return(0,A.jsx)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":`onboarding-login-flow-${e.id}`,className:`rounded border px-3 py-2 text-xs ${t?`border-sky-500 bg-sky-50 text-sky-800 dark:bg-sky-950/40 dark:text-sky-200`:``}`,onClick:()=>D(e.id),children:e.name},e.id)})}),i&&(0,A.jsx)(`div`,{id:`onboarding-login-flow-${i.provider}`,className:`mt-3`,children:(0,A.jsx)(JB,{login:i,providerName:u.find(e=>e.id===i.provider)?.name??i.provider,onAnswer:a,onCancel:o,onDismiss:s})})]}),f===`known`?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`label`,{htmlFor:`onboarding-provider`,className:TV,children:`Provider`}),(0,A.jsx)(`select`,{id:`onboarding-provider`,value:m,onChange:e=>h(e.target.value),className:`${wV} mb-3`,children:u.map(e=>(0,A.jsxs)(`option`,{value:e.id,children:[e.name,e.configured?` (already configured)`:``]},e.id))})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`label`,{htmlFor:`onboarding-name`,className:TV,children:`Name`}),(0,A.jsx)(`input`,{id:`onboarding-name`,value:v,onChange:e=>y(e.target.value),placeholder:`corp`,className:`${wV} mb-3`}),(0,A.jsx)(`label`,{htmlFor:`onboarding-url`,className:TV,children:`Base URL`}),(0,A.jsx)(`input`,{id:`onboarding-url`,value:b,onChange:e=>x(e.target.value),placeholder:`https://llm.corp.example/v1`,className:`${wV} mb-3`}),(0,A.jsx)(`label`,{htmlFor:`onboarding-model`,className:TV,children:`Model id`}),(0,A.jsx)(`input`,{id:`onboarding-model`,value:S,onChange:e=>C(e.target.value),placeholder:`gpt-oss-120b`,className:`${wV} mb-3`})]}),(0,A.jsx)(`label`,{htmlFor:`onboarding-key`,className:TV,children:`API key`}),(0,A.jsx)(`input`,{id:`onboarding-key`,type:`password`,autoComplete:`off`,value:g,onChange:e=>_(e.target.value),placeholder:`sk-…`,className:wV}),f===`custom`&&(0,A.jsxs)(`fieldset`,{className:`mt-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,A.jsx)(`legend`,{className:`px-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Compatibility`}),(0,A.jsxs)(`label`,{className:`flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked),className:`mt-0.5`}),(0,A.jsxs)(`span`,{children:[`Server understands the `,(0,A.jsx)(`code`,{children:`developer`}),` role. Uncheck for vLLM, SGLang and most corporate gateways — the system prompt is then sent as a `,(0,A.jsx)(`code`,{children:`system`}),` message.`]})]}),(0,A.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:ee,onChange:e=>E(e.target.checked),className:`mt-0.5`}),(0,A.jsxs)(`span`,{children:[`Server accepts `,(0,A.jsx)(`code`,{children:`reasoning_effort`}),`. Uncheck if it rejects unknown fields.`]})]})]}),(0,A.jsx)(`button`,{type:`submit`,className:`mt-4 w-full rounded-md bg-zinc-800 px-3 py-2 text-sm font-medium text-white hover:bg-zinc-700 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,children:`Save and start`})]}),l.map((e,t)=>(0,A.jsx)(`p`,{className:`mt-3 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:e},t)),(0,A.jsxs)(`p`,{className:`mt-4 text-center text-xs text-zinc-400 dark:text-zinc-600`,children:[t.agentDir?`Stored in ${t.agentDir}. `:``,`Provider environment variables work too, as does `,(0,A.jsx)(`code`,{children:`pi-outpost login`}),`.`]})]})})}var DV=`application/x-pi-outpost-file`,OV=`application/x-pi-outpost-read-only-file`,kV=`mr-1 shrink-0 rounded px-1 text-xs text-zinc-400 hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 [@media(hover:hover)]:opacity-0`,AV={modified:{label:`M`,className:`text-amber-600 dark:text-amber-400`},added:{label:`A`,className:`text-emerald-600 dark:text-emerald-400`},untracked:{label:`U`,className:`text-emerald-600 dark:text-emerald-400`},deleted:{label:`D`,className:`text-red-600 dark:text-red-400`},conflicted:{label:`C`,className:`text-purple-600 dark:text-purple-400`}};function jV(e,t){return t?Object.keys(t).filter(t=>t.startsWith(`${e}/`)).length:0}function MV(e){return e===`directory`||e===`symlink-directory`}function NV(e,t){return t===void 0?!1:t===null||t!==``&&e!==t&&!e.startsWith(`${t}/`)}function PV({dir:e,depth:t,creation:n}){let[r,i]=(0,d.useState)(``),a=(0,d.useRef)(null),o=n.localError??n.serverError;return(0,d.useEffect)(()=>{a.current?.focus()},[]),(0,A.jsxs)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5`,children:[(0,A.jsx)(`input`,{ref:a,value:r,onChange:e=>i(e.target.value),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),n.submit(e,r)):t.key===`Escape`&&(t.preventDefault(),n.cancel())},onBlur:()=>{o===null&&n.cancel()},placeholder:`name, or name/ for a folder`,"aria-label":`New file or folder in ${e===``?`the workspace root`:e}`,spellCheck:!1,className:`w-full rounded border border-zinc-300 bg-white px-1 py-0.5 text-xs text-zinc-800 outline-none focus:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),o!==null&&(0,A.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:o})]})}function FV({path:e,name:t,depth:n,rename:r}){let[i,a]=(0,d.useState)(t),o=(0,d.useRef)(null),s=r.localError??r.serverError;return(0,d.useEffect)(()=>{o.current?.focus(),o.current?.select()},[]),(0,A.jsxs)(`div`,{style:{paddingLeft:n*12+16},className:`py-0.5`,children:[(0,A.jsx)(`input`,{ref:o,value:i,disabled:r.pending,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`&&!r.pending?(t.preventDefault(),r.submit(e,i)):t.key===`Escape`&&(t.preventDefault(),r.cancel())},onBlur:()=>{s===null&&r.cancel()},"aria-label":`Rename ${t}`,spellCheck:!1,className:`w-full rounded border border-zinc-300 bg-white px-1 py-0.5 text-xs text-zinc-800 outline-none focus:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),s!==null&&(0,A.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:s})]})}function IV({path:e,depth:t,...n}){let r=n.tree[e],i=n.creation?.openIn===e?(0,A.jsx)(PV,{dir:e,depth:t,creation:n.creation}):null;return r===void 0?i:r===`loading`?(0,A.jsxs)(A.Fragment,{children:[i,(0,A.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`loading…`})]}):`error`in r?(0,A.jsxs)(A.Fragment,{children:[i,(0,A.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-red-600 dark:text-red-400`,children:r.error})]}):r.length===0?(0,A.jsxs)(A.Fragment,{children:[i,i===null&&(0,A.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`empty`})]}):(0,A.jsxs)(A.Fragment,{children:[i,r.map(r=>(0,A.jsx)(LV,{parentPath:e,entry:r,depth:t,...n},r.name))]})}function LV({parentPath:e,entry:t,depth:n,...r}){let[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(!1),c=e?`${e}/${t.name}`:t.name,l=NV(c,r.writableRoot),u=r.fileOperation?.status===`pending`;if(MV(t.type)){let e=!l&&!u,d=e=>e.includes(OV)?r.onCopyFile===void 0?null:`copy`:r.onMoveFile===void 0?null:`move`;return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${o?`bg-blue-50 ring-1 ring-blue-400 dark:bg-blue-950/40`:``}`,onDragOver:t=>{if(!e||!Array.from(t.dataTransfer.types).includes(DV))return;let n=d(Array.from(t.dataTransfer.types));n!==null&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=n,s(!0))},onDragLeave:()=>s(!1),onDrop:t=>{if(!e)return;let n=t.dataTransfer.getData(DV),i=n?d(Array.from(t.dataTransfer.types)):null;i!==null&&(t.preventDefault(),t.stopPropagation(),s(!1),i===`copy`?r.onCopyFile?.(n,c):r.onMoveFile?.(n,c))},children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>{let e=!i;a(e),e&&r.tree[c]===void 0&&r.onExpand(c),r.onSelectDirectory?.(c)},style:{paddingLeft:n*12},className:`flex min-w-0 flex-1 items-center gap-1 rounded py-0.5 text-left`,children:[(0,A.jsx)(`span`,{className:`w-3 shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:i?`▾`:`▸`}),(0,A.jsx)(`span`,{title:t.name,className:`truncate ${l?`text-zinc-400 dark:text-zinc-600`:`text-zinc-700 dark:text-zinc-300`}`,children:t.name}),!i&&jV(c,r.gitFiles)>0&&(0,A.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-amber-100 px-1 font-mono text-[10px] font-bold text-amber-700 dark:bg-amber-950/60 dark:text-amber-400`,title:`${jV(c,r.gitFiles)} changed file(s) inside`,children:jV(c,r.gitFiles)})]}),r.onRevealNative&&(0,A.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>r.onRevealNative?.(c),title:`Show in the file manager`,"aria-label":`Show ${t.name} in the file manager`,className:kV,children:`⌂`}),r.creation&&!l&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>{a(!0),r.tree[c]===void 0&&r.onExpand(c),r.creation?.start(c)},title:`New file or folder here`,"aria-label":`New file or folder in ${t.name}`,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs text-zinc-400 hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 [@media(hover:hover)]:opacity-0`,children:`+`})]}),i&&(0,A.jsx)(IV,{path:c,depth:n+1,...r})]})}let f=c===r.openFilePath,p=r.gitFiles?.[c],m=r.attachedPaths?.includes(c)??!1,h=t.type===`file`,g=h||t.type===`symlink-file`,_=h&&!l,v=h&&(l?r.onCopyFile!==void 0:r.onMoveFile!==void 0);return r.rename?.path===c?(0,A.jsx)(FV,{path:c,name:t.name,depth:n,rename:r.rename}):(0,A.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${f?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,A.jsx)(`button`,{type:`button`,draggable:v&&!u,onDragStart:e=>{v&&!u&&(e.dataTransfer.effectAllowed=l?`copy`:`move`,e.dataTransfer.setData(DV,c),l&&e.dataTransfer.setData(OV,`copy`))},onClick:()=>r.onSelectFile(c),style:{paddingLeft:n*12+16},className:`flex min-w-0 flex-1 items-center py-0.5 text-left`,children:(0,A.jsx)(`span`,{title:t.name,className:`truncate ${l?`text-zinc-400 dark:text-zinc-600`:`text-zinc-600 dark:text-zinc-400`}`,children:t.name})}),g&&r.onOpenNative&&(0,A.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>r.onOpenNative?.(c),title:`Open with the associated application`,"aria-label":`Open ${t.name} with the associated application`,className:kV,children:`↗`}),r.onRevealNative&&(0,A.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>r.onRevealNative?.(c),title:`Show in the file manager`,"aria-label":`Show ${t.name} in the file manager`,className:kV,children:`⌂`}),_&&r.onRenameFile&&(0,A.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>r.rename?.start(c),title:`Rename file`,"aria-label":`Rename ${t.name}`,className:kV,children:`✎`}),_&&r.onDeleteFile&&(0,A.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(`Delete "${t.name}" permanently?`)&&r.onDeleteFile?.(c)},title:`Delete file`,"aria-label":`Delete ${t.name}`,className:`${kV} hover:text-red-600 dark:hover:text-red-400`,children:`×`}),r.onToggleAttachPath&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>r.onToggleAttachPath?.(c),title:m?`Remove this file from the prompt`:`Reference this file in the prompt`,"aria-label":`${m?`Remove`:`Reference`} ${t.name} in the prompt`,"aria-pressed":m,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:hover:bg-zinc-700 ${m?`font-bold text-blue-600 dark:text-blue-400`:`text-zinc-400 dark:text-zinc-600 [@media(hover:hover)]:opacity-0`}`,children:`@`}),p&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>(r.onSelectDiff??r.onSelectFile)(c),title:`Show uncommitted diff`,"aria-label":`Show diff of ${t.name}`,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs font-bold hover:bg-zinc-200 dark:hover:bg-zinc-700 ${AV[p].className}`,children:AV[p].label})]})}function RV(e){let t=e.trim();if(t===``)return{error:`A name is required`};let n=t.endsWith(`/`),r=n?t.slice(0,-1).trim():t;return r===``?{error:`A name is required`}:r.includes(`/`)||r.includes(`\\`)?{error:`That is a path, not a name`}:r===`.`||r===`..`?{error:`"${r}" is not a name`}:{kind:n?`directory`:`file`,name:r}}function zV(e){let t=RV(e);return`error`in t?t:t.kind===`directory`?{error:`That is a folder name`}:{name:t.name}}function BV(e){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),[f,p]=(0,d.useState)(null),m=e.onCreateFile!==void 0||e.onCreateDirectory!==void 0,h=e.createError&&a&&e.createError.path===VV(a.dir,a.name)?e.createError.message:null,g=e.created??null;(0,d.useEffect)(()=>{a!==null&&g!==null&&g===VV(a.dir,a.name)&&(n(null),o(null),i(null))},[a,g]);let _=e.fileOperation?.status===`error`&&e.fileOperation.operation===`rename_file`&&f===e.fileOperation.path?e.fileOperation.message:null;(0,d.useEffect)(()=>{let t=e.fileOperation;t?.status===`succeeded`&&t.operation===`rename_file`&&f===t.path&&(c(null),p(null),u(null))},[f,e.fileOperation]);let v=m?{openIn:t,localError:r,serverError:h,start:e=>{n(e),i(null),o(null)},cancel:()=>{n(null),i(null),o(null)},submit:(t,n)=>{let r=RV(n);if(`error`in r){i(r.error);return}i(null),o({dir:t,name:r.name});let a=VV(t,r.name);r.kind===`directory`?e.onCreateDirectory?.(a):e.onCreateFile?.(a)}}:void 0,y=e.onRenameFile?{path:s,pending:f!==null&&e.fileOperation?.status===`pending`&&e.fileOperation.operation===`rename_file`&&e.fileOperation.path===f,localError:l,serverError:_,start:e=>{c(e),p(null),u(null)},cancel:()=>{c(null),p(null),u(null)},submit:(t,n)=>{if(n.trim()===``){c(null),p(null),u(null);return}let r=zV(n);`error`in r?u(r.error):(u(null),p(t),e.onRenameFile?.(t,r.name))}}:void 0,b=!NV(``,e.writableRoot);return(0,A.jsxs)(`div`,{className:`text-sm`,children:[e.fileOperation?.status===`error`&&e.fileOperation.operation!==`rename_file`&&(0,A.jsx)(`p`,{role:`alert`,className:`mb-1 rounded bg-red-50 px-2 py-1 text-xs text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:e.fileOperation.message}),(v&&b||e.onRefresh)&&(0,A.jsxs)(`div`,{className:`mb-1 flex items-center`,children:[v&&b&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>v.start(``),"aria-label":`New file or folder in the workspace root`,className:`rounded px-1 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-600 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-400`,children:`+ new`}),e.onRefresh&&(0,A.jsx)(`button`,{type:`button`,onClick:e.onRefresh,title:`Refresh the file tree`,"aria-label":`Refresh the file tree`,className:`ml-auto rounded px-1 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-600 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-400`,children:`↻`})]}),(0,A.jsx)(IV,{path:``,depth:0,...e,...v?{creation:v}:{},...y?{rename:y}:{}})]})}function VV(e,t){return e===``?t:`${e}/${t}`}function HV({tree:e,openFile:t,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onSelectDirectory:o,onRefresh:s,onSelectFile:c,onSelectDiff:l,onToggleAttachPath:u,onCreateFile:f,onCreateDirectory:p,onOpenNative:m,onRevealNative:h,onRenameFile:g,onDeleteFile:_,onMoveFile:v,onCopyFile:y,fileOperation:b,createError:x,created:S}){let C=Lz(Az);return(0,d.useEffect)(()=>{e[``]===void 0&&a(``)},[]),(0,A.jsxs)(`aside`,{"aria-label":`Files`,style:{width:C.width},className:`relative flex shrink-0 flex-col border-r border-zinc-200 dark:border-zinc-800`,children:[(0,A.jsx)(`div`,{className:`border-b border-zinc-200 px-3 py-2 text-xs font-semibold uppercase text-zinc-400 dark:border-zinc-800 dark:text-zinc-600`,children:`Files`}),(0,A.jsx)(`div`,{className:`flex-1 overflow-auto p-2`,children:(0,A.jsx)(BV,{tree:e,openFilePath:t?.path,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onSelectDirectory:o,onRefresh:s,onSelectFile:c,onSelectDiff:l,onToggleAttachPath:u,onCreateFile:f,onCreateDirectory:p,onOpenNative:m,onRevealNative:h,onRenameFile:g,onDeleteFile:_,onMoveFile:v,onCopyFile:y,fileOperation:b,createError:x,created:S})}),(0,A.jsx)(Rz,{label:`Resize Files sidebar`,width:C.width,config:Az,separatorProps:C.separatorProps})]})}function UV({title:e,onSubmit:t}){let[n,r]=(0,d.useState)(``);return(0,A.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,A.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),n.trim()&&t(n.trim())},className:`w-full max-w-sm rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,A.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),(0,A.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`This server requires an access token.`}),(0,A.jsx)(`label`,{htmlFor:`pi-outpost-token`,className:`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`,children:`Access token`}),(0,A.jsx)(`input`,{id:`pi-outpost-token`,name:`token`,type:`password`,autoComplete:`off`,spellCheck:!1,value:n,onChange:e=>r(e.target.value),placeholder:`paste the token…`,className:`mb-3 w-full rounded-md border border-zinc-300 bg-white px-2 py-1.5 font-mono text-sm outline-none focus:border-zinc-500 dark:border-zinc-700 dark:bg-zinc-950 dark:focus:border-zinc-500`}),(0,A.jsx)(`button`,{type:`submit`,disabled:!n.trim(),className:`w-full rounded-md border border-emerald-300 px-2 py-1.5 text-sm text-emerald-700 hover:border-emerald-500 disabled:opacity-50 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600`,children:`Connect`}),(0,A.jsxs)(`p`,{className:`mt-3 text-center text-xs text-zinc-400 dark:text-zinc-600`,children:[`Ask the operator for the token, or open the link containing `,(0,A.jsx)(`code`,{children:`?token=…`})]})]})})}var WV={todo:{icon:`○`,label:`To do`,className:`text-zinc-500`},in_progress:{icon:`●`,label:`In progress`,className:`text-blue-600 dark:text-blue-400`},done:{icon:`✓`,label:`Done`,className:`text-emerald-600 dark:text-emerald-400`},blocked:{icon:`!`,label:`Blocked`,className:`text-red-600 dark:text-red-400`},needs_review:{icon:`?`,label:`Needs review`,className:`text-amber-600 dark:text-amber-400`}},GV=8;function KV(e){let t=e.uri.startsWith(`workspace:`)?e.uri.slice(10):/^[a-z][a-z0-9+.-]*:/i.test(e.uri)?null:e.uri;return t===null||t===``||/^(?:[\\/]|[a-z]:[\\/])/i.test(t)||t.replaceAll(`\\`,`/`).split(`/`).includes(`..`)?null:t}function qV({plan:e,open:t,onToggle:n,onOpenWorkspace:r,requestedTaskId:i,onTaskRequestHandled:a}){let o=(0,d.useId)(),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(null),[f,p]=(0,d.useState)(null);(0,d.useEffect)(()=>{i&&(e.tasks.some(e=>e.id===i)?(u(i),p(null)):(u(null),p(i)),a?.())},[e.tasks,i,a]),(0,d.useEffect)(()=>{l!==null&&!e.tasks.some(e=>e.id===l)&&u(null)},[e,l]),(0,d.useEffect)(()=>{if(!s)return;let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[s]);let m=(0,d.useMemo)(()=>{let t=new Map;for(let n of e.tasks)t.set(n.parentId,[...t.get(n.parentId)??[],n]);return t},[e.tasks]),h=(0,d.useMemo)(()=>new Map(e.tasks.map(e=>[e.id,e])),[e.tasks]),g=(0,d.useMemo)(()=>{let e=[],t=(n,r)=>{for(let i of m.get(n)??[])e.push({task:i,depth:r}),t(i.id,r+1)};return t(void 0,0),e.slice(0,GV)},[m]),_=l?h.get(l):void 0,v=e.tasks.filter(e=>e.status===`done`).length,y=(e,t=0)=>(m.get(e)??[]).flatMap(e=>{let n=WV[e.status];return[(0,A.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-level":t+1,"aria-selected":l===e.id,onClick:()=>u(e.id),"aria-current":e.status===`in_progress`?`step`:void 0,className:`flex w-full items-start gap-2 rounded px-2 py-1.5 text-left text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800 ${l===e.id?`bg-zinc-100 dark:bg-zinc-800`:``}`,style:{paddingLeft:`${.5+t*.85}rem`},children:[(0,A.jsx)(`span`,{className:`mt-px w-4 shrink-0 text-center font-semibold ${n.className}`,"aria-label":n.label,children:n.icon}),(0,A.jsx)(`span`,{className:e.status===`done`?`text-zinc-500 line-through`:`text-zinc-800 dark:text-zinc-200`,children:e.title})]},e.id),...y(e.id,t+1)]});return t?(0,A.jsxs)(`aside`,{"aria-label":`Work Plan`,className:`absolute inset-y-0 right-0 z-10 flex w-full flex-col border-l border-zinc-200 bg-white/95 shadow-lg backdrop-blur md:w-[23rem] dark:border-zinc-800 dark:bg-zinc-950/95`,children:[(0,A.jsxs)(`header`,{className:`border-b border-zinc-200 px-3 py-3 dark:border-zinc-800`,children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-zinc-500`,children:`Work Plan`}),(0,A.jsx)(`h2`,{className:`truncate text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:e.title})]}),(0,A.jsx)(`button`,{type:`button`,onClick:n,className:`rounded px-2 py-1 text-xs text-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-800`,"aria-label":`Close Work Plan`,children:`×`})]}),(0,A.jsxs)(`div`,{className:`mt-2 text-xs text-zinc-500`,children:[`Progress: `,v,` / `,e.tasks.length]}),(0,A.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-800`,"aria-hidden":!0,children:(0,A.jsx)(`div`,{className:`h-full bg-emerald-500`,style:{width:`${e.tasks.length===0?0:v/e.tasks.length*100}%`}})})]}),(0,A.jsx)(`div`,{role:`tree`,"aria-label":`Work Plan tasks`,className:`min-h-0 flex-1 overflow-y-auto p-2`,children:y(void 0)}),f&&(0,A.jsx)(`div`,{role:`status`,className:`border-t border-amber-200 bg-amber-50 p-3 text-xs text-amber-800 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-300`,children:`That Outcome task no longer exists in the current Work Plan.`}),_&&(0,A.jsxs)(`section`,{"aria-label":`Task details`,className:`max-h-[45%] overflow-y-auto border-t border-zinc-200 p-3 text-xs dark:border-zinc-800`,children:[(0,A.jsx)(`div`,{className:`font-semibold ${WV[_.status].className}`,children:WV[_.status].label}),(0,A.jsx)(`h3`,{className:`mt-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:_.title}),_.description&&(0,A.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-zinc-600 dark:text-zinc-300`,children:_.description}),_.statusReason&&(0,A.jsx)(`p`,{className:`mt-2 rounded bg-zinc-100 p-2 text-zinc-700 dark:bg-zinc-900 dark:text-zinc-300`,children:_.statusReason}),_.dependsOn.length>0&&(0,A.jsxs)(`div`,{className:`mt-3`,children:[(0,A.jsx)(`span`,{className:`font-semibold`,children:`Depends on:`}),` `,_.dependsOn.map(e=>h.get(e)?.title??e).join(`, `)]}),_.resources.length>0&&(0,A.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,A.jsx)(`div`,{className:`font-semibold`,children:`Resources`}),_.resources.map(e=>{let t=KV(e),n=e.label??e.uri;return t===null?/^https?:/i.test(e.uri)?(0,A.jsx)(`a`,{href:e.uri,target:`_blank`,rel:`noreferrer`,className:`block truncate text-blue-600 hover:underline dark:text-blue-400`,children:n},e.uri):(0,A.jsx)(`span`,{className:`block truncate text-zinc-500`,title:`No navigator is available for this resource`,children:n},e.uri):(0,A.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-blue-600 hover:underline dark:text-blue-400`,onClick:()=>r(t),children:n},e.uri)})]})]})]}):(0,A.jsxs)(`div`,{className:`absolute right-3 top-3 z-20`,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocusCapture:()=>c(!0),onBlurCapture:()=>c(!1),children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>{c(!1),n()},className:`rounded-md border border-zinc-300 bg-white px-2 py-1 text-xs shadow-sm dark:border-zinc-700 dark:bg-zinc-900`,"aria-label":`Open Work Plan`,"aria-describedby":o,children:[`Plan `,v,`/`,e.tasks.length]}),(0,A.jsx)(`div`,{id:o,role:`tooltip`,className:`absolute right-0 top-full w-72 pt-2 ${s?`block`:`hidden`}`,children:(0,A.jsxs)(`div`,{className:`rounded-md border border-zinc-200 bg-white p-2 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,A.jsx)(`ul`,{className:`space-y-1`,children:g.map(({task:e,depth:t})=>(0,A.jsxs)(`li`,{className:`flex min-w-0 items-start gap-1.5 text-xs`,style:{paddingLeft:`${t*.75}rem`},children:[(0,A.jsx)(`span`,{"aria-label":WV[e.status].label,className:`shrink-0 font-semibold ${WV[e.status].className}`,children:e.status===`done`?`☑`:`☐`}),(0,A.jsx)(`span`,{className:`truncate ${e.status===`done`?`text-zinc-500 line-through`:`text-zinc-800 dark:text-zinc-200`}`,children:e.title})]},e.id))}),e.tasks.length>g.length&&(0,A.jsxs)(`div`,{className:`mt-1 text-[11px] text-zinc-500`,children:[`+`,e.tasks.length-g.length,` more`]})]})})]})}var JV=Object.defineProperty,YV=Object.getOwnPropertyDescriptor,XV=(e,t)=>{for(var n in t)JV(e,n,{get:t[n],enumerable:!0})},ZV=(e,t,n,r)=>{for(var i=r>1?void 0:r?YV(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&JV(t,n,i),i},QV=(e,t)=>(n,r)=>t(n,r,e),$V=`Terminal input`,eH={get:()=>$V,set:e=>$V=e},tH=`Too much output to announce, navigate to rows manually to read`,nH={get:()=>tH,set:e=>tH=e};function rH(e){return e.replace(/\r?\n/g,`\r`)}function iH(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function aH(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function oH(e,t,n,r){e.stopPropagation(),e.clipboardData&&sH(e.clipboardData.getData(`text/plain`),t,n,r)}function sH(e,t,n,r){e=rH(e),e=iH(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function cH(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function lH(e,t,n,r,i){cH(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function uH(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function dH(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var fH=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},pH=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128||(c=(i&31)<<6|a&63,c<128)){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},mH=``,hH=` `,gH=class e{constructor(){this.fg=0,this.bg=0,this.extended=new _H}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},_H=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},vH=class e extends gH{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new _H,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?uH(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},yH=`di$target`,bH=`di$dependencies`,xH=new Map;function SH(e){return e[bH]||[]}function CH(e){if(xH.has(e))return xH.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);wH(t,e,r)};return t._id=e,xH.set(e,t),t}function wH(e,t,n){t[yH]===t?t[bH].push({id:e,index:n}):(t[bH]=[{id:e,index:n}],t[yH]=t)}var TH=CH(`BufferService`),EH=CH(`CoreMouseService`),DH=CH(`CoreService`),OH=CH(`CharsetService`),kH=CH(`InstantiationService`),AH=CH(`LogService`),jH=CH(`OptionsService`),MH=CH(`OscLinkService`),NH=CH(`UnicodeService`),PH=CH(`DecorationService`),FH=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new vH,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):IH(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};FH=ZV([QV(0,TH),QV(1,jH),QV(2,MH)],FH);function IH(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
@@ -1285,4 +1285,4 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
1285
1285
|
[Clipboard copy was refused by the browser.]`))),_.current=n,v.current=r,b.current.registerClear(e,()=>{n.clear()}),b.current.openTerminal?.(e,b.current.cwd,n.cols,n.rows,...t?[t]:[]);let i=null,a=0,o=()=>{let t=Date.now();t-a<1e3?i||=setTimeout(()=>{i=null,a=Date.now(),b.current.getTerminalCwd?.(e)},1e3-(t-a)):(a=t,b.current.getTerminalCwd?.(e))},s=n.onData(t=>{b.current.sendTerminalInput?.(e,t),(t.includes(`\r`)||t.includes(`
|
|
1286
1286
|
`))&&o()}),c=b.current.subscribeTerminal?.(e,{onData:t=>{n.write(t);let r=t.match(/\x1b\]7;file:\/\/[^/]*([^\x07\x1b]+)(?:\x07|\x1b\\)/);if(r&&r[1])try{let t=decodeURIComponent(r[1]);b.current.onCwdUpdate(e,t)}catch{}},onCwd:t=>{b.current.onCwdUpdate(e,t)},onExit:e=>{n.writeln(`\r\n\x1b[90m[Process completed (exit code ${e??0})]\x1b[0m`)},onError:e=>{n.writeln(`\r\n\x1b[31m[Terminal error: ${e}]\x1b[0m`)}})??(()=>{}),l=new ResizeObserver(()=>{if(g.current&&g.current.clientWidth>0&&g.current.clientHeight>0)try{r.fit(),n.cols>0&&n.rows>0&&b.current.resizeTerminal?.(e,n.cols,n.rows)}catch{}});return l.observe(g.current),()=>{s.dispose(),c(),l.disconnect(),n.dispose(),b.current.closeTerminal?.(e)}},[e]),(0,d.useEffect)(()=>{if(!a&&i&&r&&v.current&&_.current&&g.current){b.current.getTerminalCwd?.(e);let t=setTimeout(()=>{try{v.current?.fit(),_.current?.focus()}catch{}},50);return()=>clearTimeout(t)}},[i,r,e,a]),(0,A.jsx)(`div`,{ref:g,className:`h-full w-full p-2 bg-white dark:bg-zinc-950 overflow-hidden ${r?`block`:`hidden`}`})}function sX({shells:e,open:t,onClose:n,cwd:r,confinedRoot:i,confinement:a,unavailable:o,onSetWorkspaceRoot:s,openTerminal:c,sendTerminalInput:l,getTerminalCwd:u,resizeTerminal:f,closeTerminal:p,subscribeTerminal:m}){let[h,g]=(0,d.useState)(``),_=e?.some(e=>e.id===h)?h:``,[v,y]=(0,d.useState)(t);(0,d.useEffect)(()=>{t&&y(!0)},[t]);let[b,x]=(0,d.useState)([{id:`term-1`,title:`terminal 1`}]),[S,C]=(0,d.useState)(`term-1`),[w,T]=(0,d.useState)(null),[ee,E]=(0,d.useState)(``),[D,te]=(0,d.useState)({}),[ne,re]=(0,d.useState)(!1),ie=Lz(Mz,`y`),[O,ae]=(0,d.useState)(!1),k=(0,d.useRef)(new Map),oe=(0,d.useCallback)((e,t)=>{k.current.set(e,t)},[]),se=(0,d.useCallback)((e,t)=>{te(n=>({...n,[e]:t}))},[]),ce=(0,d.useCallback)(()=>{let e=b.length+1,t=`term-${crypto.randomUUID()}`,n={id:t,title:`terminal ${e}`,..._?{shellId:_}:{}};x(e=>[...e,n]),C(t)},[b.length,_]),le=(0,d.useCallback)((e,t)=>{t.stopPropagation(),b.length<=1?n():(x(t=>{let n=t.filter(t=>t.id!==e);if(S===e){let r=t.findIndex(t=>t.id===e),i=n[Math.max(0,r-1)]?.id??n[0]?.id;C(i)}return n}),k.current.delete(e),te(t=>{let n={...t};return delete n[e],n}))},[b.length,S,n]),ue=(e,t)=>{t.stopPropagation(),T(e.id),E(e.title)},de=()=>{if(w){let e=ee.trim();e&&x(t=>t.map(t=>t.id===w?{...t,title:e}:t)),T(null)}},fe=e=>{e.key===`Enter`?de():e.key===`Escape`&&T(null)},j=(0,d.useCallback)(()=>{let e=k.current.get(S);e&&e()},[S]),pe=D[S]||r||``;return v?(0,A.jsxs)(`div`,{style:{height:ne?`85vh`:ie.width,maxHeight:ne?`85vh`:`65vh`},className:`flex-col shrink-0 border-t border-zinc-200 dark:border-zinc-800 bg-zinc-100 dark:bg-zinc-900 ${t?`flex`:`hidden`} relative z-20`,children:[!ne&&(0,A.jsx)(Rz,{axis:`y`,label:`Resize Terminal panel`,width:ie.width,config:Mz,separatorProps:ie.separatorProps}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1 border-b border-zinc-200 dark:border-zinc-800 select-none bg-zinc-50 dark:bg-zinc-950 text-xs`,children:[(0,A.jsxs)(`div`,{className:`flex items-center space-x-1 overflow-x-auto min-w-0`,children:[(0,A.jsx)(`div`,{className:`flex items-center space-x-1`,children:b.map(e=>{let t=e.id===S,n=e.id===w;return(0,A.jsxs)(`div`,{onClick:()=>C(e.id),onDoubleClick:t=>ue(e,t),title:`Double-click to rename tab`,className:`flex items-center space-x-1 px-2.5 py-1 rounded text-xs cursor-pointer transition-colors ${t?`bg-zinc-200 dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100 font-medium shadow-sm`:`text-zinc-500 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 hover:bg-zinc-200/50 dark:hover:bg-zinc-800/50`}`,children:[n?(0,A.jsx)(`input`,{type:`text`,"data-testid":`terminal-tab-rename-input`,value:ee,autoFocus:!0,onChange:e=>E(e.target.value),onBlur:de,onKeyDown:fe,className:`bg-transparent border border-sky-500 rounded px-1 py-0 text-xs font-mono outline-none text-zinc-900 dark:text-zinc-100 w-24`}):(0,A.jsx)(`span`,{children:e.title}),b.length>1&&(0,A.jsx)(`span`,{onClick:t=>le(e.id,t),role:`button`,tabIndex:0,"aria-label":`Close terminal tab`,className:`ml-1 hover:text-red-500 rounded p-0.5 hover:bg-zinc-200 dark:hover:bg-zinc-700`,children:(0,A.jsx)(`svg`,{className:`w-3 h-3`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,A.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]},e.id)})}),e&&e.length>0&&(0,A.jsxs)(`select`,{"aria-label":`Shell for new terminal`,value:_,onChange:e=>g(e.target.value),disabled:!!o,className:`min-w-0 max-w-40 rounded border border-zinc-300 bg-zinc-50 text-xs text-zinc-800 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-200`,children:[(0,A.jsx)(`option`,{value:``,children:`Default shell`}),e.map(e=>(0,A.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),(0,A.jsx)(`button`,{onClick:ce,type:`button`,title:`New Terminal Tab`,className:`p-1 rounded text-zinc-500 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 hover:bg-zinc-200/60 dark:hover:bg-zinc-800/60`,children:(0,A.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,A.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 4v16m8-8H4`})})})]}),i&&!o&&(0,A.jsx)(vV,{verdict:a??{state:`checking`,runner:``},surface:`terminal`,root:aX(i)}),pe&&(0,A.jsx)(`div`,{className:`hidden md:flex items-center space-x-1.5 px-2 text-xs font-mono text-zinc-500 dark:text-zinc-400`,children:s&&(0,A.jsx)(`button`,{onClick:()=>{if(pe&&s){if((pe===`/`||pe===`\\`||/^[A-Za-z]:[\\/]?$/.test(pe))&&!window.confirm(`Open root filesystem "${pe}" as the workspace project?`))return;s(pe),ae(!0),setTimeout(()=>ae(!1),2e3)}},type:`button`,title:`Open "${pe}" as the workspace project and reposition the LLM agent`,className:`flex items-center space-x-1 px-1.5 py-0.5 rounded text-[11px] font-sans transition-colors ${O?`bg-emerald-500 text-white font-medium`:`bg-zinc-200/80 hover:bg-sky-500 hover:text-white dark:bg-zinc-800 dark:hover:bg-sky-600 dark:hover:text-white text-zinc-700 dark:text-zinc-300`}`,children:(0,A.jsx)(`span`,{children:O?`✓ Project opened`:`📁 ${aX(pe)} → open as project`})})}),(0,A.jsxs)(`div`,{className:`flex items-center space-x-1 text-zinc-500 dark:text-zinc-400`,children:[(0,A.jsx)(`button`,{onClick:j,type:`button`,title:`Clear Terminal Output`,className:`p-1 rounded hover:text-zinc-800 dark:hover:text-zinc-200 hover:bg-zinc-200/60 dark:hover:bg-zinc-800/60`,children:(0,A.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,A.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})})}),(0,A.jsx)(`button`,{onClick:()=>re(e=>!e),type:`button`,title:ne?`Restore Terminal Panel`:`Maximize Terminal Panel`,className:`p-1 rounded hover:text-zinc-800 dark:hover:text-zinc-200 hover:bg-zinc-200/60 dark:hover:bg-zinc-800/60`,children:ne?(0,A.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,A.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})}):(0,A.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,A.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M5 15l7-7 7 7`})})}),(0,A.jsx)(`button`,{onClick:n,type:`button`,title:"Minimize Terminal Panel (Ctrl+`)",className:`p-1 rounded hover:text-zinc-800 dark:hover:text-zinc-200 hover:bg-zinc-200/60 dark:hover:bg-zinc-800/60`,children:(0,A.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,A.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]})]}),(0,A.jsx)(`div`,{className:`flex-1 min-h-0 relative`,children:o?(0,A.jsxs)(`div`,{role:`status`,"data-testid":`terminal-unavailable`,className:`p-3 text-xs text-amber-700 dark:text-amber-300`,children:[(0,A.jsx)(`p`,{className:`font-medium`,children:`The terminal is unavailable.`}),(0,A.jsx)(`p`,{className:`mt-1 break-words font-mono`,children:o})]}):b.map(e=>(0,A.jsx)(oX,{id:e.id,shellId:e.shellId,cwd:r,isActive:e.id===S,isPanelOpen:t,renaming:w!==null,openTerminal:c,sendTerminalInput:l,getTerminalCwd:u,resizeTerminal:f,closeTerminal:p,subscribeTerminal:m,onCwdUpdate:se,registerClear:oe},e.id))})]}):null}var cX={todo:{label:`To do`,className:`text-zinc-500`},in_progress:{label:`In progress`,className:`text-blue-600 dark:text-blue-400`},done:{label:`Done`,className:`text-emerald-600 dark:text-emerald-400`},blocked:{label:`Blocked`,className:`text-red-600 dark:text-red-400`},needs_review:{label:`Needs review`,className:`text-amber-600 dark:text-amber-400`},passed:{label:`Passed`,className:`text-emerald-600 dark:text-emerald-400`},failed:{label:`Failed`,className:`text-red-600 dark:text-red-400`},inconclusive:{label:`Inconclusive`,className:`text-amber-600 dark:text-amber-400`},informational:{label:`Informational`,className:`text-zinc-500`},modified:{label:`Modified`,className:`text-blue-600 dark:text-blue-400`},added:{label:`Added`,className:`text-emerald-600 dark:text-emerald-400`},deleted:{label:`Deleted`,className:`text-red-600 dark:text-red-400`},untracked:{label:`Untracked`,className:`text-zinc-600 dark:text-zinc-300`},conflicted:{label:`Conflicted`,className:`text-red-600 dark:text-red-400`},unavailable:{label:`Unavailable`,className:`text-red-600 dark:text-red-400`},"not-recorded":{label:`Not recorded`,className:`text-zinc-500`}};function lX(e){return cX[e]??{label:e,className:`text-zinc-500`}}function uX({entry:e,onTarget:t}){let n=lX(e.status),r=(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`min-w-0 break-words text-sm font-medium text-zinc-900 dark:text-zinc-100`,children:e.title}),(0,A.jsx)(`span`,{className:`shrink-0 text-[11px] font-semibold uppercase tracking-wide ${n.className}`,children:n.label})]}),e.group&&(0,A.jsx)(`div`,{className:`mt-0.5 text-[11px] text-zinc-500`,children:e.group}),e.detail&&(0,A.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-zinc-600 dark:text-zinc-300`,children:e.detail}),e.reference&&(0,A.jsx)(`div`,{className:`mt-1 truncate text-xs text-zinc-500`,children:e.reference}),(0,A.jsx)(`div`,{className:`mt-1 text-[10px] uppercase tracking-wide text-zinc-400`,children:e.source})]}),i=`block w-full rounded-md border border-zinc-200 p-2 text-left hover:bg-zinc-50 dark:border-zinc-800 dark:hover:bg-zinc-900`;return e.target?.kind===`external-url`?(0,A.jsx)(`a`,{href:e.target.url,target:`_blank`,rel:`noreferrer`,className:i,children:r}):e.target?(0,A.jsx)(`button`,{type:`button`,onClick:()=>t(e.target),className:i,children:r}):(0,A.jsx)(`div`,{className:`rounded-md border border-zinc-200 p-2 dark:border-zinc-800`,children:r})}function dX({state:e,onClose:t,onRefresh:n,onTarget:r}){return(0,A.jsxs)(`aside`,{"aria-label":`Workspace Outcome`,className:`absolute inset-y-0 right-0 z-10 flex w-full flex-col border-l border-zinc-200 bg-white/95 shadow-lg backdrop-blur md:w-[26rem] dark:border-zinc-800 dark:bg-zinc-950/95`,children:[(0,A.jsxs)(`header`,{className:`flex items-start justify-between gap-2 border-b border-zinc-200 px-3 py-3 dark:border-zinc-800`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-zinc-500`,children:`Workspace review`}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:`Outcome`})]}),(0,A.jsxs)(`div`,{className:`flex gap-1`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:n,className:`rounded px-2 py-1 text-xs text-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:`Refresh`}),(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`rounded px-2 py-1 text-xs text-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-800`,"aria-label":`Close Outcome`,children:`×`})]})]}),(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:e===null||e.status===`loading`?(0,A.jsx)(`div`,{role:`status`,className:`text-sm text-zinc-500`,children:`Loading Outcome…`}):e.status===`error`?(0,A.jsx)(`div`,{role:`alert`,className:`rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/30 dark:text-red-300`,children:e.message}):(0,A.jsx)(`div`,{className:`space-y-4`,children:e.outcome.sections.map(e=>(0,A.jsxs)(`section`,{"aria-labelledby":`outcome-${e.id}`,className:`rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,A.jsx)(`h3`,{id:`outcome-${e.id}`,className:`text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:e.title}),e.availability===`partial`||e.availability===`unavailable`?(0,A.jsx)(`span`,{className:`text-[11px] font-semibold uppercase text-red-600 dark:text-red-400`,children:e.availability}):null]}),e.summary&&(0,A.jsx)(`p`,{className:`mt-1 text-xs text-zinc-600 dark:text-zinc-300`,children:e.summary}),e.entries.length>0&&(0,A.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.entries.map(e=>(0,A.jsx)(uX,{entry:e,onTarget:r},e.id))})]},e.id))})})]})}function fX(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`));return`${t.slice(0,4).join(``)}-${t.slice(4,6).join(``)}-${t.slice(6,8).join(``)}-${t.slice(8,10).join(``)}-${t.slice(10).join(``)}`}var pX=`pi-outpost:token`;function mX(){let e=null;try{let t=new URL(window.location.href);return e=t.searchParams.get(`token`),e&&(localStorage.setItem(pX,e),t.searchParams.delete(`token`),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)),localStorage.getItem(pX)}catch{return e}}function hX(){try{return localStorage.getItem(pX)}catch{return null}}function gX(e){try{localStorage.setItem(pX,e)}catch{}}var _X=class extends Error{kind;constructor(e,t){super(e),this.name=`HistoryError`,this.kind=t}};async function vX(e,t){let n=[];for(;;){let r=await e(n.length,50);if(r.items.length===0||(n.unshift(...r.items),t?.(n.length),r.remaining===0))return n}}function yX(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function bX(e,t){return e.base.rev===t.base.rev&&e.base.path===t.base.path&&e.target.rev===t.target.rev&&e.target.path===t.target.path}function xX(){return{clonePath:null,preview:null,enrollment:null,refresh:null,updates:{},skills:{},removals:{}}}var SX={login:null,connected:!1,workspace:null,workspaces:[],workspaceLocked:!1,embedWorkspaceControls:`settings`,switching:!1,agentStarting:!1,authRequired:!1,brandingReady:!1,branding:{},sessionId:``,sessionName:null,model:``,thinkingLevel:`off`,modelSupportsReasoning:!1,models:[],commands:[],extensionsBinding:!1,sessions:null,sessionSearch:null,tree:null,isStreaming:!1,items:[],olderHistory:null,pendingPrompt:null,workPlan:null,replyConformance:{},structuredAppearance:null,outpostUpdate:null,outpostChanges:null,piPackages:null,piPackageUpdate:null,serverRestarting:!1,restartNeeded:[],outcome:null,queue:{steering:[],followUp:[]},errors:[],contextUsage:null,isCompacting:!1,dialogQueue:[],notifications:[],statuses:{},widgets:{},editorPrefill:null,fileTree:{},directoryRequests:{},openFile:null,previewRevision:0,fileSearch:null,createError:null,created:null,fileOperation:null,extensionPaths:null,configuredExtensionPaths:[],userExtensionPaths:[],extensionLock:!1,tools:[],sandbox:null,terminal:null,userSkillPaths:[],serverBrowse:null,settingsApply:null,agentResources:null,agentResourceOperations:xX(),versions:null,gitAvailable:!1,gitUnavailable:null,credentials:null,gitStatus:null,gitDiff:null,gitBaseline:null,gitLog:null,gitShow:null,gitFileHistory:null,gitFileDiff:null};function CX(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.kind===`assistant`&&r.streaming){let i=[...e];return i[n]=t(r),i}}return[...e,t({kind:`assistant`,blocks:[],streaming:!0})]}function wX(e,t,n,r){for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.kind===`tool`&&i.toolCallId===t){let t=[...e];return t[n]={...i,...r},t}}return[...e,{kind:`tool`,toolCallId:t,toolName:n,args:{},output:``,running:!0,...r}]}function TX(e,t,n){for(let r=e.length-1;r>=0;r--){let i=e[r];if(i.kind===`tool`&&i.toolCallId===t){let t=[...e];return t[r]={...i,...n},t}}return e}function EX(e,t){if(t.type!==`hello`&&t.type!==`session_replaced`&&t.type!==`update_config_ack`&&t.type!==`workspace_switched`&&t.type!==`workspace_starting`)return e;let n=t.models.find(e=>`${e.provider}/${e.id}`===t.model);return{...e,replyConformance:{},structuredAppearance:t.type===`workspace_switched`||t.type===`workspace_starting`?null:e.structuredAppearance,agentStarting:t.agentStarting===!0,outpostUpdate:t.outpostUpdate??e.outpostUpdate,outpostChanges:t.outpostChanges??e.outpostChanges,piPackages:t.piPackages??e.piPackages,serverRestarting:!1,restartNeeded:t.restartNeeded??[],connected:!0,brandingReady:!0,workspace:t.workspace??null,workspaces:t.workspaces??[],workspaceLocked:t.workspaceLocked===!0,embedWorkspaceControls:t.embedWorkspaceControls??`settings`,switching:!1,branding:t.branding,sessionId:t.sessionId,sessionName:t.sessionName??null,model:t.model,thinkingLevel:t.thinkingLevel,thinkingLevels:t.thinkingLevels,modelSupportsReasoning:n?.reasoning??!1,models:t.models,commands:t.commands,extensionsBinding:t.extensionsBinding===!0,isStreaming:t.isStreaming,items:t.items,olderHistory:t.olderItems?{remaining:t.olderItems,have:0,loading:!1,error:null}:null,pendingPrompt:null,workPlan:t.workPlan??null,outcome:null,queue:{steering:[],followUp:[]},errors:[],contextUsage:t.contextUsage??null,isCompacting:!1,dialogQueue:[],notifications:[],statuses:{},widgets:{},extensionTitle:void 0,editorPrefill:null,tree:null,fileTree:{},directoryRequests:{},fileOperation:null,writableRoot:t.writableRoot,docxTemplate:t.docxTemplate,gitAvailable:t.gitAvailable===!0,gitUnavailable:t.gitUnavailable??null,credentials:t.credentials??null,extensionPaths:t.extensionPaths??null,configuredExtensionPaths:t.configuredExtensionPaths??[],userExtensionPaths:t.userExtensionPaths??[],extensionLock:t.extensionLock===!0,tools:t.tools??[],sandbox:t.sandbox??null,terminal:t.terminal??null,confinement:t.confinement??null,userSkillPaths:t.userSkillPaths??[],serverBrowse:null,settingsApply:null,versions:t.versions??null,agentResources:t.agentResources??null,agentResourceOperations:t.type===`hello`||t.type===`workspace_switched`||t.type===`workspace_starting`?xX():e.agentResourceOperations}}function DX(e,t){if(t.type===`connected`)return{...e,connected:!0,authRequired:!1};if(t.type===`workspace_switching`)return{...e,switching:!0};if(t.type===`pi_package_update_started`)return{...e,piPackageUpdate:{requestId:t.requestId,source:t.source,status:`pending`}};if(t.type===`auth_required`)return{...e,connected:!1,authRequired:!0};if(t.type===`auth_retrying`)return{...e,authRequired:!1};if(t.type===`login_started`)return{...e,login:{flowId:t.flowId,provider:t.provider,method:t.method,events:[],prompt:null,done:null}};if(t.type===`login_answered`)return e.login?{...e,login:{...e.login,prompt:null}}:e;if(t.type===`login_dismissed`)return{...e,login:null};if(t.type===`disconnected`&&e.login&&!e.login.done&&(e={...e,login:{...e.login,prompt:null,done:{ok:!1,message:`Connection lost — the sign-in was stopped. Start it again.`}}}),t.type===`disconnected`){let t=e.openFile,n=t?.status===`loaded`&&t.pendingSave!==void 0?{...t,pendingSave:void 0,saveError:{message:`Connection lost while saving — try again`,conflict:!1}}:e.openFile,r=e.outcome?.status===`loading`?{...e.outcome,status:`error`,message:`Connection lost while loading Outcome.`}:e.outcome;return{...e,connected:!1,openFile:n,outcome:r}}if(t.type===`branding_settled`)return{...e,brandingReady:!0};if(t.type===`branding_loaded`)return{...e,brandingReady:!0,branding:t.branding};if(t.type===`prompt_sent`)return{...e,pendingPrompt:{text:t.text,...t.images?.length?{images:t.images}:{}}};if(t.type===`pending_prompt_cancelled`)return!t.restoreText||!e.pendingPrompt?e:{...e,editorPrefill:{text:e.pendingPrompt.text,nonce:e.editorPrefill?e.editorPrefill.nonce+1:1}};if(t.type===`dismiss_notification`)return{...e,notifications:e.notifications.filter(e=>e.id!==t.id)};if(t.type===`dialog_answered`)return{...e,dialogQueue:e.dialogQueue.slice(1)};if(t.type===`dir_list_started`){let n=e.fileTree[t.path];return{...e,fileTree:{...e.fileTree,[t.path]:t.preserveEntries&&Array.isArray(n)?n:`loading`},directoryRequests:{...e.directoryRequests,[t.path]:t.requestId}}}if(t.type===`raw_preview_changed`)return e.openFile?.path===t.path?{...e,previewRevision:e.previewRevision+1}:e;if(t.type===`file_read_started`){let n=e.openFile;return t.preserveContent&&n?.status===`loaded`&&n.path===t.path?{...e,openFile:{...n,refreshRequestId:t.requestId}}:{...e,openFile:{status:`loading`,path:t.path,requestId:t.requestId}}}if(t.type===`file_save_started`){let n=e.openFile;return!e.connected||n?.status!==`loaded`||n.path!==t.path?e:{...e,openFile:{...n,pendingSave:{requestId:t.requestId,content:t.content},saveError:void 0}}}if(t.type===`close_file_preview`)return{...e,openFile:null};if(t.type===`file_search_started`)return{...e,fileSearch:{status:`loading`,query:t.query,requestId:t.requestId,results:[]}};if(t.type===`file_search_cleared`)return{...e,fileSearch:null};if(t.type===`file_create_started`)return{...e,createError:null,created:null};if(t.type===`file_operation_started`)return{...e,fileOperation:{status:`pending`,operation:t.operation,path:t.path,requestId:t.requestId}};if(t.type===`session_search_started`)return{...e,sessionSearch:{status:`loading`,query:t.query,requestId:t.requestId,results:[]}};if(t.type===`session_search_cleared`)return{...e,sessionSearch:null};if(t.type===`history_load_started`)return e.olderHistory?{...e,olderHistory:{...e.olderHistory,loading:!0,error:null}}:e;if(t.type===`history_loaded`)return e.olderHistory?{...e,items:[...t.items,...e.items],olderHistory:{remaining:t.remaining,have:e.olderHistory.have+t.items.length,loading:!1,error:null}}:e;if(t.type===`history_load_failed`)return e.olderHistory?{...e,olderHistory:{...e.olderHistory,loading:!1,error:t.message}}:e;if(t.type===`git_diff_started`||t.type===`git_diff_cleared`)return{...e,gitDiff:null};if(t.type===`git_baseline_started`){let n=e.gitBaseline?.path===t.path?e.gitBaseline.text:void 0;return{...e,gitBaseline:{path:t.path,requestId:t.requestId,...n===void 0?{}:{text:n}}}}if(t.type===`git_baseline_cleared`)return{...e,gitBaseline:null};if(t.type===`git_show_cleared`)return{...e,gitShow:null,gitLog:e.gitLog};if(t.type===`git_file_history_started`)return{...e,gitFileHistory:{path:t.path,status:`loading`,entries:[],requestId:t.requestId},gitFileDiff:null};if(t.type===`git_file_history_closed`)return{...e,gitFileHistory:null,gitFileDiff:null};if(t.type===`git_file_diff_started`)return{...e,gitFileDiff:{base:t.base,target:t.target,status:`loading`,beforeText:e.gitFileDiff?.beforeText??``,afterText:e.gitFileDiff?.afterText??``,requestId:t.requestId}};if(t.type===`git_file_diff_cleared`)return{...e,gitFileDiff:null};if(t.type===`server_browse_started`)return{...e,serverBrowse:{status:`loading`,path:e.serverBrowse?.path??t.path,parent:e.serverBrowse?.parent??null,entries:e.serverBrowse?.entries??[],requestId:t.requestId}};if(t.type===`server_browse_closed`)return{...e,serverBrowse:null};if(t.type===`settings_apply_started`)return{...e,settingsApply:{status:`applying`}};if(t.type===`resource_clone_path_started`)return{...e,agentResourceOperations:{...e.agentResourceOperations,clonePath:{requestId:t.requestId,status:`loading`}}};if(t.type===`resource_preview_started`)return{...e,agentResourceOperations:{...e.agentResourceOperations,preview:{requestId:t.requestId,status:`loading`}}};if(t.type===`resource_enrollment_started`)return{...e,agentResourceOperations:{...e.agentResourceOperations,enrollment:{requestId:t.requestId,status:`loading`}}};if(t.type===`resource_refresh_started`)return{...e,agentResourceOperations:{...e.agentResourceOperations,refresh:{requestId:t.requestId,status:`loading`,...t.repositoryId?{repositoryId:t.repositoryId}:{}}}};if(t.type===`resource_update_started`)return{...e,agentResourceOperations:{...e.agentResourceOperations,updates:{...e.agentResourceOperations.updates,[t.repositoryId]:{requestId:t.requestId,status:`loading`}}}};if(t.type===`resource_skills_started`){let n=e.agentResourceOperations;return{...e,agentResourceOperations:{...n,skills:{...n.skills,[t.repositoryId]:{requestId:t.requestId,status:`loading`}}}}}if(t.type===`resource_removal_started`){let n=e.agentResourceOperations;return{...e,agentResourceOperations:{...n,removals:{...n.removals,[t.repositoryId]:{requestId:t.requestId,status:`loading`}}}}}if(t.type===`outcome_started`)return{...e,outcome:{status:`loading`,requestId:t.requestId,workspaceRoot:t.workspaceRoot,sessionId:t.sessionId}};if(t.type===`outcome_failed`){let n=e.outcome;return n===null||n.status!==`loading`||n.requestId!==t.requestId?e:{...e,outcome:{...n,status:`error`,message:t.message}}}let n=t.message;if(n.type===`workspace_switched`&&e.agentStarting&&e.workspace&&n.workspace&&oL(n.workspace)===oL(e.workspace))return{...EX(e,n),openFile:e.openFile,gitDiff:e.gitDiff,gitBaseline:e.gitBaseline,fileTree:e.fileTree,directoryRequests:e.directoryRequests};switch(n.type){case`workspace_switched`:case`hello`:case`session_replaced`:case`update_config_ack`:case`workspace_starting`:return{...EX(e,n),openFile:null,gitDiff:null,gitBaseline:null,fileTree:{},directoryRequests:{}};case`workspace_activity`:return{...e,workspaces:n.workspaces,workspace:(e.workspace&&n.workspaces.find(t=>oL(t)===oL(e.workspace)))??e.workspace};case`agent_resource_clone_path`:{let t=e.agentResourceOperations.clonePath;return t?.requestId===n.requestId?{...e,agentResourceOperations:{...e.agentResourceOperations,clonePath:{...t,status:`ready`,path:n.path}}}:e}case`agent_resource_preview`:{let t=e.agentResourceOperations.preview;return t?.requestId===n.requestId?{...e,agentResourceOperations:{...e.agentResourceOperations,preview:{...t,status:`ready`,preview:n.preview}}}:e}case`agent_resource_enrolled`:{let t=e.agentResourceOperations.enrollment;return t?.requestId===n.requestId?{...e,agentResources:n.inventory,agentResourceOperations:{...e.agentResourceOperations,preview:null,enrollment:{...t,status:`ready`}}}:e}case`agent_resource_assessments`:{let t=e.agentResourceOperations.refresh;if(t?.requestId!==n.requestId||!e.agentResources)return e;let r=new Map(n.assessments.map(e=>[e.repositoryId,e]));return{...e,agentResources:{...e.agentResources,repositories:e.agentResources.repositories.map(e=>({...e,assessment:r.get(e.id)??e.assessment}))},agentResourceOperations:{...e.agentResourceOperations,refresh:{...t,status:`ready`}}}}case`agent_resource_inventory`:return{...e,agentResources:n.inventory};case`agent_resource_update_result`:{let t=n.result.repositoryId;if(!t)return e;let r=e.agentResourceOperations.updates[t];return r?.requestId===n.requestId?{...e,agentResources:n.inventory,agentResourceOperations:{...e.agentResourceOperations,updates:{...e.agentResourceOperations.updates,[t]:{...r,status:`ready`,result:n.result}}}}:e}case`agent_resource_skills_applied`:{let t=e.agentResourceOperations,r=t.skills[n.repositoryId];return r?.requestId===n.requestId?{...e,agentResources:n.inventory,agentResourceOperations:{...t,skills:{...t.skills,[n.repositoryId]:{...r,status:`ready`}}}}:e}case`agent_resource_removed`:{let t=e.agentResourceOperations,r=t.removals[n.repositoryId];return r?.requestId===n.requestId?{...e,agentResources:n.inventory,agentResourceOperations:{...t,removals:{...t.removals,[n.repositoryId]:{...r,status:`ready`,result:n.result}}}}:e}case`agent_resource_error`:{let t=e=>e?.requestId===n.requestId?{...e,status:`error`,message:n.message}:null,r=t(e.agentResourceOperations.clonePath),i=t(e.agentResourceOperations.preview),a=t(e.agentResourceOperations.enrollment),o=t(e.agentResourceOperations.refresh),s=e=>{let t=Object.entries(e).find(([,e])=>e.requestId===n.requestId);return t?{...e,[t[0]]:{...t[1],status:`error`,message:n.message}}:null},c=s(e.agentResourceOperations.updates),l=s(e.agentResourceOperations.skills),u=s(e.agentResourceOperations.removals);return!r&&!i&&!a&&!o&&!c&&!l&&!u?e:{...e,agentResourceOperations:{...e.agentResourceOperations,...r?{clonePath:r}:{},...i?{preview:i}:{},...a?{enrollment:a}:{},...o?{refresh:o}:{},...c?{updates:c}:{},...l?{skills:l}:{},...u?{removals:u}:{}}}}case`workspace_error`:return{...e,switching:!1,errors:[...e.errors,n.message]};case`sessions`:return{...e,sessions:n.sessions};case`session_search_results`:return e.sessionSearch?.requestId===n.requestId?{...e,sessionSearch:{...e.sessionSearch,status:`loaded`,results:n.sessions}}:e;case`tree`:return{...e,tree:n.roots};case`editor_prefill`:return{...e,editorPrefill:{text:n.text,nonce:e.editorPrefill?e.editorPrefill.nonce+1:1}};case`model_changed`:return{...e,model:n.model,modelSupportsReasoning:n.reasoning,thinkingLevels:n.thinkingLevels};case`login_event`:return e.login?.flowId===n.flowId?{...e,login:{...e.login,events:[...e.login.events,n.event]}}:e;case`login_prompt`:return e.login?.flowId===n.flowId?{...e,login:{...e.login,prompt:{promptId:n.promptId,prompt:n.prompt}}}:e;case`login_prompt_cancelled`:return e.login?.flowId!==n.flowId||e.login.prompt?.promptId!==n.promptId?e:{...e,login:{...e.login,prompt:null}};case`login_done`:return e.login?.flowId===n.flowId?{...e,login:{...e.login,prompt:null,done:{ok:n.ok,...n.cancelled?{cancelled:!0}:{},...n.message?{message:n.message}:{}}}}:e;case`credentials_changed`:{let t=n.models.find(e=>`${e.provider}/${e.id}`===n.model);return{...e,models:n.models,model:n.model,modelSupportsReasoning:t?.reasoning??!1,thinkingLevels:void 0,credentials:n.credentials}}case`extensions_bound`:return{...e,commands:n.commands,tools:n.tools??e.tools,extensionsBinding:!1};case`thinking_changed`:return{...e,thinkingLevel:n.level};case`work_plan_changed`:return{...e,workPlan:n.workPlan};case`workspace_outcome`:{let t=e.outcome;return t===null||t.requestId!==n.requestId||t.sessionId!==e.sessionId||n.outcome.sessionId!==e.sessionId||t.workspaceRoot!==null&&n.outcome.workspaceRoot!==t.workspaceRoot?e:{...e,outcome:{...t,status:`loaded`,outcome:n.outcome}}}case`workspace_outcome_error`:{let t=e.outcome;return t===null||t.status!==`loading`||t.requestId!==n.requestId?e:{...e,outcome:{...t,status:`error`,message:n.message}}}case`user`:return{...e,pendingPrompt:null,items:[...e.items,{kind:`user`,text:n.text,...n.images?{images:n.images}:{}}]};case`user_entries`:{let{entries:t}=n,r=e.items.flatMap((e,t)=>e.kind===`user`?[t]:[]),i=new Map;for(let n=r.length-1,a=t.length-1;n>=0&&a>=0;n--,a--){let o=e.items[r[n]];if(o.kind!==`user`||o.text!==t[a].text)break;i.set(r[n],t[a].entryId)}return{...e,items:e.items.map((e,t)=>{if(e.kind!==`user`)return e;let n=i.get(t);if(n===e.entryId)return e;if(n===void 0){let{entryId:t,...n}=e;return n}return{...e,entryId:n}})}}case`agent_start`:return{...e,isStreaming:!0,errors:[]};case`agent_end`:return{...e,isStreaming:!1,queue:{steering:[],followUp:[]},items:e.items.map(e=>e.kind===`tool`&&e.running?{...e,running:!1}:e.kind===`assistant`&&e.streaming?{...e,streaming:!1}:e)};case`assistant_start`:return{...e,items:[...e.items,{kind:`assistant`,blocks:[],streaming:!0}]};case`block_delta`:return{...e,items:CX(e.items,e=>{let t=[...e.blocks],r=t.findIndex(e=>e.contentIndex===n.contentIndex);return r>=0?t[r]={...t[r],text:t[r].text+n.delta}:t.push({type:n.block,text:n.delta,contentIndex:n.contentIndex}),{...e,blocks:t,streaming:!0}})};case`assistant_end`:return{...e,items:CX(e.items,()=>n.item)};case`custom_message`:return{...e,items:[...e.items,n.item]};case`tool_start`:return{...e,items:wX(e.items,n.toolCallId,n.toolName,{toolName:n.toolName,args:n.args,running:!0,callHtml:n.callHtml})};case`tool_update`:return{...e,items:wX(e.items,n.toolCallId,`tool`,{output:n.text,...n.outputHtml===void 0?{}:{outputHtml:n.outputHtml,outputHtmlCollapsed:n.outputHtmlCollapsed},...typeof n.progress==`number`?{progress:n.progress}:{}})};case`tool_end`:return{...e,items:wX(e.items,n.toolCallId,`tool`,{output:n.text,isError:n.isError,running:!1,outputHtml:n.outputHtml,outputHtmlCollapsed:n.outputHtmlCollapsed,structured:n.structured})};case`structured_conformance`:return{...e,items:TX(e.items,n.toolCallId,{structuredConformance:n.conformance})};case`structured_appearance`:return{...e,structuredAppearance:n.appearance};case`outpost_update`:return{...e,outpostUpdate:n.notice};case`outpost_changes`:return{...e,outpostChanges:n.changes};case`pi_packages`:return{...e,piPackages:n.packages};case`pi_package_update_result`:{let t=e.piPackageUpdate;return t?.requestId===n.requestId?{...e,piPackageUpdate:{requestId:n.requestId,source:t.source,status:n.outcome,message:n.message}}:e}case`restart_needed`:return{...e,restartNeeded:n.reasons};case`server_restarting`:return{...e,serverRestarting:!0,piPackageUpdate:null};case`reply_structured_conformance`:return{...e,replyConformance:{...e.replyConformance,[n.key]:n.conformance}};case`queue`:return{...e,queue:{steering:n.steering,followUp:n.followUp}};case`context_usage`:return{...e,contextUsage:n.usage};case`confinement`:return{...e,confinement:n.confinement};case`compaction_start`:return{...e,isCompacting:!0};case`compaction_end`:return{...e,isCompacting:!1,errors:n.errorMessage?[...e.errors,n.errorMessage]:e.errors};case`error`:return{...e,errors:[...e.errors,n.message],pendingPrompt:null,settingsApply:e.settingsApply?.status===`applying`?{status:`error`,message:n.message}:e.settingsApply};case`server_directory`:return e.serverBrowse?.requestId===n.requestId?{...e,serverBrowse:{status:`loaded`,path:n.path,parent:n.parent,entries:n.entries,requestId:n.requestId}}:e;case`server_directory_error`:return e.serverBrowse?.requestId===n.requestId?{...e,serverBrowse:{...e.serverBrowse,status:`error`,error:n.message}}:e;case`directory_listing`:return n.requestId.startsWith(`dir:`)&&e.directoryRequests[n.path]!==n.requestId?e:{...e,fileTree:{...e.fileTree,[n.path]:n.entries},...n.requestId.startsWith(`create:`)?{created:n.path,createError:null}:{}};case`file_content`:{let t=e.openFile,r=t?.status===`loading`&&t.requestId===n.requestId,i=t?.status===`loaded`&&t.refreshRequestId===n.requestId;return!r&&!i?e:{...e,openFile:{status:`loaded`,path:n.path,content:n.content,size:n.size,mtimeMs:n.mtimeMs,...n.documentIssues===void 0?{}:{documentIssues:n.documentIssues}}}}case`file_written`:{if(n.requestId.startsWith(`create:`))return{...e,createError:null,created:n.path,openFile:{status:`loaded`,path:n.path,content:``,size:n.size,mtimeMs:n.mtimeMs,justCreated:!0}};let t=e.openFile;return t?.status!==`loaded`||t.pendingSave?.requestId!==n.requestId?e:{...e,openFile:{status:`loaded`,path:t.path,content:t.pendingSave.content,size:n.size,mtimeMs:n.mtimeMs}}}case`file_operation_result`:{if(e.fileOperation?.status!==`pending`||e.fileOperation.requestId!==n.requestId)return e;let t=n.previousPath??n.path,r=n.operation===`delete_file`&&e.openFile?.path===n.path?null:e.openFile?.path===t?{...e.openFile,path:n.path}:e.openFile,i=e.gitFileHistory?.path===t||e.gitFileHistory?.path===n.path,a=e.gitDiff?.path===t||e.gitDiff?.path===n.path,o=e.gitBaseline?.path===t||e.gitBaseline?.path===n.path;return{...e,openFile:r,gitFileHistory:i?null:e.gitFileHistory,gitFileDiff:i?null:e.gitFileDiff,gitDiff:a?null:e.gitDiff,gitBaseline:o?null:e.gitBaseline,fileOperation:{status:`succeeded`,operation:n.operation,path:e.fileOperation.path,resultPath:n.path,requestId:n.requestId}}}case`file_browser_error`:if(n.requestId.startsWith(`dir:`))return e.directoryRequests[n.path]===n.requestId?{...e,fileTree:{...e.fileTree,[n.path]:{error:n.message}}}:e;if(n.requestId.startsWith(`create:`))return{...e,createError:{path:n.path,message:n.message}};if(n.requestId.startsWith(`write:`)){let t=e.openFile;return t?.status!==`loaded`||t.pendingSave?.requestId!==n.requestId?e:{...e,openFile:{...t,pendingSave:void 0,saveError:{message:n.message,conflict:n.reason===`conflict`}}}}return n.requestId.startsWith(`fileop:`)?e.fileOperation?.status!==`pending`||e.fileOperation.requestId!==n.requestId?e:{...e,fileOperation:{status:`error`,operation:e.fileOperation.operation,path:e.fileOperation.path,message:n.message,requestId:n.requestId}}:e.openFile?.status===`loading`&&e.openFile.requestId===n.requestId?{...e,openFile:{status:`error`,path:n.path,message:n.message}}:e.openFile?.status===`loaded`&&e.openFile.refreshRequestId===n.requestId?{...e,openFile:{...e.openFile,refreshRequestId:void 0}}:e;case`file_search_results`:return e.fileSearch?.requestId===n.requestId?{...e,fileSearch:{...e.fileSearch,status:`loaded`,results:n.results}}:e;case`git_status`:{let t={};for(let e of n.files)t[e.path]=e.status;let r=e.gitStatus;if(n.repo===void 0||r===null)return{...e,gitStatus:{repos:n.repos,files:t}};let i={};for(let[e,t]of Object.entries(r.files))JL(r.repos,e)?.repo!==n.repo&&(i[e]=t);let a=r.repos.map(e=>n.repos.find(t=>t.repo===e.repo)??e);return{...e,gitStatus:{repos:a,files:{...i,...t}}}}case`git_repositories_changed`:return{...e,gitAvailable:n.available,gitUnavailable:n.available?null:n.unavailable??null,gitStatus:n.available?e.gitStatus:null};case`git_diff`:return n.requestId.startsWith(`gitbase:`)?e.gitBaseline?.requestId===n.requestId?{...e,gitBaseline:{...e.gitBaseline,text:n.before}}:e:{...e,gitDiff:{path:n.path,before:n.before,after:n.after}};case`git_log`:return{...e,gitLog:{repo:n.repo,entries:n.entries}};case`git_show`:return{...e,gitShow:{sha:n.sha,patch:n.patch,truncated:n.truncated}};case`git_file_log`:return e.gitFileHistory?.requestId===n.requestId?{...e,gitFileHistory:{...e.gitFileHistory,status:`loaded`,entries:n.entries}}:e;case`git_file_diff`:return e.gitFileDiff===null||!bX(e.gitFileDiff,n)?e:{...e,gitFileDiff:{...e.gitFileDiff,status:`loaded`,beforeText:n.beforeText,afterText:n.afterText}};case`git_error`:return n.requestId.startsWith(`gitbase:`)?e.gitBaseline?.requestId===n.requestId?{...e,gitBaseline:null}:e:n.requestId.startsWith(`gitdiff:`)?{...e,gitDiff:e.openFile?{path:e.openFile.path,error:n.message}:null}:n.requestId===e.gitFileHistory?.requestId?{...e,gitFileHistory:{...e.gitFileHistory,status:`error`,error:n.message}}:n.requestId===e.gitFileDiff?.requestId?{...e,gitFileDiff:{...e.gitFileDiff,status:`error`,error:n.message}}:{...e,errors:[...e.errors,`git: ${n.message}`]};case`extension_ui_request`:switch(n.method){case`select`:case`confirm`:case`input`:case`editor`:return{...e,dialogQueue:[...e.dialogQueue,n]};case`notify`:return{...e,notifications:[...e.notifications,{id:n.id,message:n.message,notifyType:n.notifyType}]};case`setStatus`:{let t={...e.statuses};return n.statusText===void 0?delete t[n.statusKey]:t[n.statusKey]=n.statusText,{...e,statuses:t}}case`setWidget`:{let t={...e.widgets};return n.widgetLines===void 0?delete t[n.widgetKey]:t[n.widgetKey]={lines:n.widgetLines,placement:n.widgetPlacement??`aboveEditor`},{...e,widgets:t}}case`setTitle`:return{...e,extensionTitle:n.title};case`set_editor_text`:return{...e,editorPrefill:{text:n.text,nonce:e.editorPrefill?e.editorPrefill.nonce+1:1}};default:return e}default:return e}}function OX(e,t,n){let r=e?`${e.replace(/^http/,`ws`)}/ws`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/ws`,i=new URLSearchParams;t&&i.set(`token`,t),n&&i.set(`workspace`,n);let a=i.toString();return a?`${r}?${a}`:r}var kX=12e4,AX=3e4,jX=2e4,MX=45e3,NX=4401,PX=1e3;function FX(e=``,t,n=!1,r){let[i,a]=(0,d.useReducer)(DX,SX),o=(0,d.useRef)(null),[s,c]=(0,d.useState)(0),l=(0,d.useRef)(null),u=(0,d.useRef)(null);s===0&&l.current===null&&(l.current=t??(n?hX():mX()));let f=(0,d.useRef)(i.fileTree),p=(0,d.useRef)(i.openFile);(0,d.useEffect)(()=>{f.current=i.fileTree},[i.fileTree]),(0,d.useEffect)(()=>{p.current=i.openFile},[i.openFile]);let m=(0,d.useRef)(null);(0,d.useEffect)(()=>{m.current=i.gitDiff?.path??null},[i.gitDiff]);let h=(0,d.useRef)(new Map),g=(0,d.useRef)(new Map),_=(0,d.useRef)(new Map),v=(0,d.useRef)(new Map),y=(0,d.useRef)(i.sessionId);(0,d.useEffect)(()=>{y.current=i.sessionId},[i.sessionId]);let b=(0,d.useRef)(!1),x=(0,d.useRef)(i.olderHistory);(0,d.useEffect)(()=>{x.current=i.olderHistory},[i.olderHistory]);let S=(0,d.useRef)(i.writableRoot);(0,d.useEffect)(()=>{S.current=i.writableRoot},[i.writableRoot]);let C=(0,d.useRef)(!1),w=(0,d.useRef)(new Map),T=(0,d.useRef)(new Map),ee=i.workspace?oL(i.workspace):null,E=(0,d.useRef)({workspaceRoot:ee,sessionId:i.sessionId});(0,d.useEffect)(()=>{E.current={workspaceRoot:ee,sessionId:i.sessionId}},[ee,i.sessionId]);let D=(0,d.useCallback)(e=>{let t=o.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[]),te=(0,d.useRef)(!1),ne=(0,d.useRef)(null),re=(0,d.useRef)(!1),O=(0,d.useRef)(null),k=(0,d.useRef)(()=>{}),oe=(0,d.useCallback)(()=>{ne.current=null,O.current!==null&&(clearTimeout(O.current),O.current=null)},[]),se=(0,d.useCallback)(()=>{let e=o.current;if(!e||e.readyState!==WebSocket.OPEN)return;if(ne.current!==null){re.current=!0;return}let t=`outcome:${fX()}`;ne.current=t;let n=E.current;a({type:`outcome_started`,requestId:t,...n}),D({type:`get_outcome`,requestId:t}),O.current=setTimeout(()=>{ne.current===t&&(oe(),re.current=!1,a({type:`outcome_failed`,requestId:t,message:`The Outcome took too long to answer — try again.`}))},MX)},[D,oe]);k.current=se;let ce=(0,d.useCallback)(()=>{te.current&&k.current()},[]),le=(0,d.useCallback)(e=>{te.current=e,e?se():re.current=!1},[se]),A=(0,d.useCallback)((e,t=!1)=>{e===``&&(C.current=!0);let n=`dir:${fX()}`;a({type:`dir_list_started`,path:e,requestId:n,preserveEntries:t}),D({type:`list_directory`,path:e,requestId:n})},[D]),ue=(0,d.useRef)(!1),de=(0,d.useRef)(null),fe=(0,d.useRef)([]);(0,d.useEffect)(()=>{fe.current=i.gitStatus?.repos??[]},[i.gitStatus]);let j=(0,d.useRef)(new Set),pe=(0,d.useRef)(new Set),me=(0,d.useRef)(new Map),he=(0,d.useCallback)(e=>{if(!ue.current)return;let t=e??``;if(j.current.has(t)){pe.current.add(t);return}j.current.add(t);let n=`git:${fX()}`;me.current.set(n,t),D({type:`git_status`,...e===void 0?{}:{repo:e},requestId:n})},[D]),ge=(0,d.useCallback)(e=>{let t=me.current.get(e)??``;me.current.delete(e),j.current.delete(t),pe.current.delete(t)&&he(t===``?void 0:t)},[he]),_e=(0,d.useCallback)(e=>{f.current[e]!==void 0&&A(e,!0)},[A]),ve=(0,d.useCallback)(()=>{A(``,!0);for(let e of Object.keys(f.current))e!==``&&_e(e)},[_e,A]);(0,d.useEffect)(()=>{i.connected&&C.current&&f.current[``]===void 0&&A(``)},[i.connected,i.fileTree,A]),(0,d.useEffect)(()=>{i.connected&&te.current&&ne.current===null&&k.current()},[i.connected]);let ye=i.openFile?.path??null,be=ye===null?void 0:i.gitStatus?.files[ye],xe=i.gitBaseline!==null;(0,d.useEffect)(()=>{let e=be===`modified`||be===`added`||be===`conflicted`;if(!i.connected||ye===null||!e){xe&&a({type:`git_baseline_cleared`});return}let t=`gitbase:${fX()}`;a({type:`git_baseline_started`,path:ye,requestId:t}),D({type:`git_diff`,path:ye,requestId:t})},[i.connected,ye,be,i.gitStatus,D]),(0,d.useEffect)(()=>{let t=!1;return fetch(`${e}/branding`,{headers:l.current?{Authorization:`Bearer ${l.current}`}:{}}).then(e=>e.ok?e.json():null).then(e=>{t||a(e?{type:`branding_loaded`,branding:e}:{type:`branding_settled`})}).catch(()=>{t||a({type:`branding_settled`})}),()=>{t=!0}},[e,s]),(0,d.useEffect)(()=>{let t,n=!1;function i(){let s=new WebSocket(OX(e,l.current,r));o.current=s,s.onopen=()=>{o.current===s&&a({type:`connected`})},s.onmessage=e=>{if(o.current!==s)return;let t;try{t=JSON.parse(e.data)}catch{return}if(t.type===`hello`){for(let e of T.current.values())if(e.socket!==s){for(let t of w.current.get(e.message.terminalId)?.onData??[])t(`\r
|
|
1287
1287
|
[Connection restored; starting a new terminal session.]\r
|
|
1288
|
-
`);e.socket=s,s.send(JSON.stringify(e.message))}}if(t.type===`terminal_data`){let e=w.current.get(t.terminalId);if(e)for(let n of e.onData)n(t.data)}else if(t.type===`terminal_cwd`){let e=T.current.get(t.terminalId);e&&(e.message.cwd=t.cwd);let n=w.current.get(t.terminalId);if(n)for(let e of n.onCwd)e(t.cwd)}else if(t.type===`terminal_exit`){T.current.delete(t.terminalId);let e=w.current.get(t.terminalId);if(e)for(let n of e.onExit)n(t.exitCode)}else if(t.type===`terminal_error`){T.current.delete(t.terminalId);let e=w.current.get(t.terminalId);if(e)for(let n of e.onError)n(t.message)}else if(t.type===`history_items`){let e=v.current.get(t.requestId);e&&(v.current.delete(t.requestId),e.resolve({items:t.items,remaining:t.remaining}))}else if(t.type===`history_unavailable`){let e=v.current.get(t.requestId);e&&(v.current.delete(t.requestId),e.reject(new _X(t.reason,t.kind)))}else if((t.type===`file_content`||t.type===`file_written`||t.type===`file_browser_error`)&&g.current.has(t.requestId)){let e=g.current.get(t.requestId);g.current.delete(t.requestId),t.type===`file_browser_error`?e.reject(new GF(t.message,t.reason)):e.resolve(t.type===`file_content`?{content:t.content,mtimeMs:t.mtimeMs}:{mtimeMs:t.mtimeMs})}else if(t.type===`file_uploaded`){let e=h.current.get(t.requestId);e&&(h.current.delete(t.requestId),e.resolve(t.path))}else if(t.type===`file_browser_error`&&h.current.has(t.requestId)){let e=h.current.get(t.requestId);h.current.delete(t.requestId),e.reject(new eR(t.message,t.reason))}else if(t.type===`file_changed`){ce();for(let e of _.current.get(t.path)??[])e();_e(yX(t.path));let e=p.current;if(e?.status===`loaded`&&e.path===t.path){let e=`file:${fX()}`;a({type:`file_read_started`,path:t.path,requestId:e,preserveContent:!0}),D({type:`read_file`,path:t.path,requestId:e})}m.current===t.path&&D({type:`git_diff`,path:t.path,requestId:`gitdiff:${fX()}`}),he(JL(fe.current,t.path)?.repo)}else if(t.type===`directory_changed`){ce();for(let[e,n]of _.current)if(yX(e)===t.path)for(let e of n)e();_e(t.path);let e=p.current;if(e!==null&&yX(e.path)===t.path){if(ie(e.path)||ae(e.path))a({type:`raw_preview_changed`,path:e.path});else if(e.status===`loaded`){let t=`file:${fX()}`;a({type:`file_read_started`,path:e.path,requestId:t,preserveContent:!0}),D({type:`read_file`,path:e.path,requestId:t})}}let n=m.current;n!==null&&yX(n)===t.path&&D({type:`git_diff`,path:n,requestId:`gitdiff:${fX()}`}),he()}else{if((t.type===`hello`||t.type===`session_replaced`||t.type===`workspace_switched`||t.type===`workspace_starting`)&&(ue.current=t.gitAvailable===!0,t.type!==`session_replaced`&&he()),t.type===`agent_end`&&(he(),ce()),t.type===`git_repositories_changed`&&(ce(),ue.current=t.available,t.available&&he()),t.type===`git_changed`){ce(),he(t.repo===``?void 0:t.repo);let e=de.current;e!==null&&e.repo===t.repo&&D({type:`git_log`,repo:e.repo,...e.limit?{limit:e.limit}:{},requestId:`gitlog:${fX()}`})}if((t.type===`git_status`||t.type===`git_error`&&t.requestId.startsWith(`git:`))&&ge(t.requestId),t.type===`work_plan_changed`&&ce(),(t.type===`workspace_outcome`||t.type===`workspace_outcome_error`)&&ne.current===t.requestId&&(oe(),re.current&&(re.current=!1,queueMicrotask(()=>k.current()))),t.type===`hello`||t.type===`session_replaced`||t.type===`workspace_switched`||t.type===`workspace_starting`||t.type===`update_config_ack`){oe(),re.current=!1;let e=E.current,n=t.sessionId===e.sessionId,r=(t.workspace?oL(t.workspace):null)===e.workspaceRoot;te.current&&n&&r&&queueMicrotask(()=>k.current())}if(t.type===`file_operation_result`){let e=t.previousPath??t.path,n=p.current;t.operation===`delete_file`&&n?.path===t.path?p.current=null:n?.path===e&&(p.current={...n,path:t.path})}a({type:`server`,message:t}),t.type===`session_replaced`&&A(``)}},s.onclose=e=>{if(o.current===s){j.current.clear(),pe.current.clear(),me.current.clear(),oe(),re.current=!1;for(let e of h.current.values())e.reject(new eR(`The connection dropped before the upload finished`));h.current.clear();for(let e of g.current.values())e.reject(new GF(`The connection dropped before the server answered`));g.current.clear();for(let e of v.current.values())e.reject(new _X(`the connection dropped before the older messages arrived`,`failed`));v.current.clear(),e.code===NX?a({type:`auth_required`}):(a({type:`disconnected`}),n||(t=window.setTimeout(i,1500)))}}}return i(),()=>{n=!0,t!==void 0&&clearTimeout(t);let e=o.current;o.current=null,e?.close()}},[D,e,he,ge,_e,A,ce,oe,s,r]);let Se=(0,d.useCallback)((e,t)=>{let n=o.current;if(!n||n.readyState!==WebSocket.OPEN)return Promise.reject(new _X(`not connected to the server`,`failed`));let r=`history:${fX()}`;return new Promise((n,i)=>{let a=window.setTimeout(()=>{v.current.delete(r)&&i(new _X(`the older messages did not arrive`,`failed`))},jX),o=e=>t=>{clearTimeout(a),e(t)};v.current.set(r,{resolve:o(n),reject:o(i)}),D({type:`history_before`,sessionId:y.current,have:e,count:t,requestId:r})})},[D]),Ce=(0,d.useCallback)(async()=>{let e=x.current;if(!(!e||e.loading||b.current||e.remaining<=0)){b.current=!0,a({type:`history_load_started`});try{let t=await Se(e.have,50);a({type:`history_loaded`,items:t.items,remaining:t.remaining})}catch(e){if(e instanceof _X&&e.kind===`stale`){a({type:`history_load_failed`,message:``});return}a({type:`history_load_failed`,message:e instanceof Error?e.message:`the older messages could not be loaded`})}finally{b.current=!1}}},[Se]);return{state:i,fileIo:(0,d.useMemo)(()=>{function e(e,t){let n=o.current;if(!n||n.readyState!==WebSocket.OPEN)return Promise.reject(new GF(`not connected to the server`));let r=`${e}:${fX()}`;return new Promise((e,n)=>{let i=window.setTimeout(()=>{g.current.delete(r)&&n(new GF(`the server did not answer`))},AX);g.current.set(r,{resolve:t=>{clearTimeout(i),e(t)},reject:e=>{clearTimeout(i),n(e)}}),D(t(r))})}return{read:t=>e(`fileio-read`,e=>({type:`read_file`,path:t,requestId:e})),write:(t,n,r)=>e(`fileio-write`,e=>({type:`write_file`,path:t,content:n,expectedMtimeMs:r,requestId:e})),onChanged:(e,t)=>{let n=_.current.get(e)??new Set;return n.add(t),_.current.set(e,n),()=>{n.delete(t),n.size===0&&_.current.delete(e)}}}},[D]),setOutcomeActive:le,refreshOutcome:se,authToken:l.current,switchWorkspace:(e,t)=>{((t??e)!==ee||i.switching)&&(a({type:`workspace_switching`}),D({type:`switch_workspace`,root:e,...t!==void 0&&t!==e?{id:t}:{}}))},openProject:e=>{a({type:`workspace_switching`}),D({type:`open_project`,root:e})},closeProject:(e,t)=>D({type:`close_project`,root:e,...t!==void 0&&t!==e?{id:t}:{}}),checkPiPackages:()=>D({type:`check_pi_packages`}),updatePiPackage:e=>{let t=`pkg:${fX()}`;a({type:`pi_package_update_started`,requestId:t,source:e}),D({type:`update_pi_package`,source:e,requestId:t})},restartServer:()=>D({type:`restart_server`}),restartSession:()=>{a({type:`settings_apply_started`}),D({type:`restart_session`})},openSideSession:e=>{a({type:`workspace_switching`}),D({type:`open_side_session`,root:e})},submitToken:e=>{gX(e),l.current=e,a({type:`auth_retrying`}),c(e=>e+1)},prompt:(e,t)=>{a({type:`prompt_sent`,text:e,...t?.length?{images:t}:{}}),D({type:`prompt`,text:e,...t?.length?{images:t}:{}})},abort:()=>D({type:`abort`}),cancelPendingPrompt:e=>{a({type:`pending_prompt_cancelled`,restoreText:e}),D({type:`abort`})},setModel:(e,t)=>D({type:`set_model`,provider:e,id:t}),setThinking:e=>D({type:`set_thinking`,level:e}),newSession:()=>D({type:`new_session`}),switchSession:e=>D({type:`switch_session`,path:e}),deleteSession:e=>D({type:`delete_session`,path:e}),listSessions:()=>D({type:`list_sessions`}),renameSession:(e,t)=>D({type:`rename_session`,path:e,name:t}),searchSessions:e=>{let t=`sessions:${fX()}`;a({type:`session_search_started`,query:e,requestId:t}),D({type:`search_sessions`,query:e,requestId:t})},clearSessionSearch:()=>a({type:`session_search_cleared`}),listTree:()=>D({type:`list_tree`}),navigateTree:e=>D({type:`navigate_tree`,entryId:e}),forkSession:e=>D({type:`fork_session`,entryId:e}),editPrompt:(e,t,n)=>D({type:`edit_prompt`,entryId:e,text:t,...n?.length?{images:n}:{}}),compact:()=>D({type:`compact`}),fetchOlderItems:Se,loadOlderItems:Ce,respondToDialog:e=>{D({type:`extension_ui_response`,...e}),a({type:`dialog_answered`})},dismissNotification:e=>a({type:`dismiss_notification`,id:e}),listDirectory:e=>A(e),refreshFileTree:ve,readFile:(e,t)=>{let n=`file:${fX()}`;a({type:`file_read_started`,path:e,requestId:n}),D({type:`read_file`,path:e,requestId:n,...t===void 0?{}:{sha256:t}})},closeFilePreview:()=>a({type:`close_file_preview`}),writeFile:(e,t,n,r=!1)=>{let i=`write:${fX()}`;a({type:`file_save_started`,path:e,requestId:i,content:t}),D({type:`write_file`,path:e,content:t,expectedMtimeMs:n,...r?{force:r}:{},requestId:i})},createFile:e=>{a({type:`file_create_started`}),D({type:`create_file`,path:e,requestId:`create:${fX()}`})},uploadFile:(e,t)=>{let n=S.current;if(n===null)return Promise.reject(new eR(`the workspace is read-only`,`denied`));let r=o.current;if(!r||r.readyState!==WebSocket.OPEN)return Promise.reject(new eR(`not connected to the server`));let i=n?`${n}/${$L}`:$L,a=`upload:${fX()}`;return new Promise((n,r)=>{let o=window.setTimeout(()=>{h.current.delete(a)&&r(new eR(`the upload timed out`))},kX),s=e=>t=>{clearTimeout(o),e(t)};h.current.set(a,{resolve:s(n),reject:s(r)}),D({type:`upload_file`,destinationDirectory:i,name:e,contentBase64:t,requestId:a})})},createDirectory:e=>{a({type:`file_create_started`}),D({type:`create_directory`,path:e,requestId:`create:${fX()}`})},openNative:e=>{let t=`fileop:${fX()}`;a({type:`file_operation_started`,operation:`open_native`,path:e,requestId:t}),D({type:`open_native`,path:e,requestId:t})},revealNative:e=>{let t=Date.now();if(u.current?.path===e&&t-u.current.at<PX)return;u.current={path:e,at:t};let n=`fileop:${fX()}`;a({type:`file_operation_started`,operation:`reveal_native`,path:e,requestId:n}),D({type:`reveal_native`,path:e,requestId:n})},renameFile:(e,t)=>{let n=`fileop:${fX()}`;a({type:`file_operation_started`,operation:`rename_file`,path:e,requestId:n}),D({type:`rename_file`,path:e,name:t,requestId:n})},deleteFile:e=>{let t=`fileop:${fX()}`;a({type:`file_operation_started`,operation:`delete_file`,path:e,requestId:t}),D({type:`delete_file`,path:e,requestId:t})},moveFile:(e,t)=>{let n=`fileop:${fX()}`;a({type:`file_operation_started`,operation:`move_file`,path:e,requestId:n}),D({type:`move_file`,path:e,destinationDirectory:t,requestId:n})},copyFile:(e,t)=>{let n=`fileop:${fX()}`;a({type:`file_operation_started`,operation:`copy_file`,path:e,requestId:n}),D({type:`copy_file`,path:e,destinationDirectory:t,requestId:n})},searchFiles:e=>{let t=`search:${fX()}`;a({type:`file_search_started`,query:e,requestId:t}),D({type:`search_files`,query:e,requestId:t})},clearFileSearch:()=>a({type:`file_search_cleared`}),fetchGitStatus:()=>he(),fetchGitDiff:e=>{let t=`gitdiff:${fX()}`;a({type:`git_diff_started`,path:e,requestId:t}),D({type:`git_diff`,path:e,requestId:t})},clearGitDiff:()=>a({type:`git_diff_cleared`}),fetchGitLog:(e,t)=>{de.current={repo:e,limit:t},D({type:`git_log`,repo:e,...t?{limit:t}:{},requestId:`gitlog:${fX()}`})},fetchGitShow:(e,t)=>D({type:`git_show`,repo:e,sha:t,requestId:`gitshow:${fX()}`}),clearGitShow:()=>a({type:`git_show_cleared`}),fetchGitFileHistory:(e,t)=>{let n=`gitfilelog:${fX()}`;a({type:`git_file_history_started`,path:e,requestId:n}),D({type:`git_file_log`,path:e,...t?{limit:t}:{},requestId:n})},closeGitFileHistory:()=>a({type:`git_file_history_closed`}),fetchGitFileDiff:(e,t)=>{let n=`gitfilediff:${fX()}`;a({type:`git_file_diff_started`,base:e,target:t,requestId:n}),D({type:`git_file_diff`,base:e,target:t,requestId:n})},clearGitFileDiff:()=>a({type:`git_file_diff_cleared`}),setCredential:(e,t)=>D({type:`set_credential`,provider:e,apiKey:t}),startLogin:(e,t)=>{let n=fX();a({type:`login_started`,flowId:n,provider:e,method:t}),D({type:`start_login`,flowId:n,provider:e,method:t})},answerLogin:e=>{let t=i.login;t?.prompt&&(D({type:`login_answer`,flowId:t.flowId,promptId:t.prompt.promptId,value:e}),a({type:`login_answered`}))},cancelLogin:()=>{let e=i.login;e&&!e.done&&D({type:`cancel_login`,flowId:e.flowId})},dismissLogin:()=>a({type:`login_dismissed`}),logoutProvider:e=>D({type:`logout_provider`,provider:e}),declareProvider:e=>D({type:`declare_provider`,...e}),browseServerDirectory:e=>{let t=`serverdir:${fX()}`;a({type:`server_browse_started`,path:e,requestId:t}),D({type:`browse_server_directory`,path:e,requestId:t})},closeServerBrowser:()=>a({type:`server_browse_closed`}),suggestAgentResourceClonePath:e=>{let t=`resource-clone-path:${fX()}`;a({type:`resource_clone_path_started`,requestId:t}),D({type:`suggest_agent_resource_clone_path`,repositoryUrl:e,requestId:t})},cloneAgentResourceRepository:(e,t)=>{let n=`resource-preview:${fX()}`;a({type:`resource_preview_started`,requestId:n}),D({type:`clone_agent_resource_repository`,repositoryUrl:e,destinationPath:t,requestId:n})},enrollAgentResourceRepository:(e,t,n,r)=>{let i=`resource-enroll:${fX()}`;a({type:`resource_enrollment_started`,requestId:i}),D({type:`enroll_agent_resource_repository`,previewToken:e,skillRoots:t,extensionRoots:n,...r?{enabledSkills:r}:{},requestId:i})},setAgentResourceSkills:(e,t)=>{let n=`resource-skills:${fX()}`;a({type:`resource_skills_started`,requestId:n,repositoryId:e}),D({type:`set_agent_resource_skills`,repositoryId:e,enabledSkills:t,requestId:n})},removeAgentResourceRepository:e=>{let t=`resource-remove:${fX()}`;a({type:`resource_removal_started`,requestId:t,repositoryId:e}),D({type:`remove_agent_resource_repository`,repositoryId:e,requestId:t})},refreshAgentResourceRepositories:e=>{let t=`resource-refresh:${fX()}`;a({type:`resource_refresh_started`,requestId:t,...e?{repositoryId:e}:{}}),D({type:`refresh_agent_resource_repositories`,...e?{repositoryId:e}:{},requestId:t})},updateAgentResourceRepository:(e,t,n,r,i=!1)=>{let o=`resource-update:${fX()}`;a({type:`resource_update_started`,requestId:o,repositoryId:e}),D({type:`update_agent_resource_repository`,repositoryId:e,assessmentToken:t,localRevision:n,upstreamRevision:r,...i?{allowExecutableChanges:!0}:{},requestId:o})},updateConfig:e=>{a({type:`settings_apply_started`}),D({type:`update_config`,...e})},openTerminal:(e,t,n,r,i)=>{let a={type:`terminal_open`,terminalId:e,cwd:t,cols:n,rows:r,...i?{shellId:i}:{}};T.current.set(e,{message:a,socket:o.current?.readyState===WebSocket.OPEN?o.current:null}),D(a)},sendTerminalInput:(e,t)=>D({type:`terminal_input`,terminalId:e,data:t}),getTerminalCwd:e=>D({type:`terminal_get_cwd`,terminalId:e}),resizeTerminal:(e,t,n)=>{let r=T.current.get(e);r&&Object.assign(r.message,{cols:t,rows:n}),D({type:`terminal_resize`,terminalId:e,cols:t,rows:n})},closeTerminal:e=>{T.current.delete(e),D({type:`terminal_close`,terminalId:e}),w.current.delete(e)},subscribeTerminal:(e,t)=>{let n=w.current.get(e);return n||(n={onData:new Set,onCwd:new Set,onExit:new Set,onError:new Set},w.current.set(e,n)),t.onData&&n.onData.add(t.onData),t.onCwd&&n.onCwd.add(t.onCwd),t.onExit&&n.onExit.add(t.onExit),t.onError&&n.onError.add(t.onError),()=>{t.onData&&n?.onData.delete(t.onData),t.onCwd&&n?.onCwd.delete(t.onCwd),t.onExit&&n?.onExit.delete(t.onExit),t.onError&&n?.onError.delete(t.onError)}}}}var IX=120;function LX({label:e}){return(0,A.jsx)(`div`,{className:`flex justify-end px-4`,role:`status`,"aria-live":`polite`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,A.jsx)(`span`,{className:`inline-block h-4 w-4 animate-spin rounded-full border-[3px] border-zinc-300 border-t-blue-500 dark:border-zinc-600 dark:border-t-blue-400 motion-reduce:animate-pulse`}),(0,A.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:e})]})})}var RX=(0,d.forwardRef)(function({serverUrl:e=``,rootElement:t,initialTheme:n,token:r,workspace:i},a){let o=t!==void 0,s=t??document.documentElement,{state:c,authToken:l,submitToken:u,prompt:f,abort:m,cancelPendingPrompt:h,setModel:g,setThinking:_,newSession:v,switchSession:b,deleteSession:x,listSessions:S,renameSession:C,searchSessions:w,clearSessionSearch:T,listTree:ee,navigateTree:E,forkSession:D,editPrompt:te,compact:ne,loadOlderItems:re,fetchOlderItems:ie,respondToDialog:O,dismissNotification:ae,listDirectory:k,refreshFileTree:oe,readFile:ce,writeFile:le,createFile:ue,createDirectory:de,uploadFile:fe,openNative:j,revealNative:pe,renameFile:me,deleteFile:ge,moveFile:_e,copyFile:ve,closeFilePreview:ye,searchFiles:be,clearFileSearch:xe,fetchGitDiff:Se,clearGitDiff:Ce,fetchGitLog:we,fetchGitShow:Te,clearGitShow:Ee,fetchGitFileHistory:De,closeGitFileHistory:Oe,fetchGitFileDiff:ke,clearGitFileDiff:Ae,setCredential:je,startLogin:Me,answerLogin:Ne,cancelLogin:Pe,dismissLogin:Fe,logoutProvider:Ie,declareProvider:Le,updateConfig:Re,suggestAgentResourceClonePath:ze,cloneAgentResourceRepository:Be,enrollAgentResourceRepository:Ve,setAgentResourceSkills:He,removeAgentResourceRepository:Ue,refreshAgentResourceRepositories:We,updateAgentResourceRepository:Ge,browseServerDirectory:Ke,closeServerBrowser:qe,switchWorkspace:Je,openProject:Xe,closeProject:Ze,openSideSession:Qe,checkPiPackages:$e,updatePiPackage:et,restartServer:tt,restartSession:nt,openTerminal:rt,sendTerminalInput:it,getTerminalCwd:at,resizeTerminal:ot,closeTerminal:st,subscribeTerminal:ct,setOutcomeActive:lt,refreshOutcome:ut,fileIo:dt}=FX(e,r,o,i),ft=se(c.workspace);pV(c.workspaces,c.workspace?oL(c.workspace):null);let pt=c.workspace?oL(c.workspace):null;(0,d.useEffect)(()=>{_t([]),nn([]),yn.current&&(yn.current.scrollTop=0)},[pt]);let[mt,ht]=(0,d.useState)(!1),[gt,_t]=(0,d.useState)([]),[vt,yt]=(0,d.useState)([]),[bt,xt]=(0,d.useState)(!1),[St,Ct]=(0,d.useState)(null),[wt,Tt]=(0,d.useState)(null),Et=St===`project`,Dt=e=>Ct(e?`project`:null),Ot=c.embedWorkspaceControls===`projects`?`projects`:c.embedWorkspaceControls===`root`?`root`:`none`,kt=(0,d.useRef)({}),At=(0,d.useRef)([]),[jt,Mt]=(0,d.useState)(!1),Nt=(0,d.useRef)({readFile:ce,openNative:j});Nt.current={readFile:ce,openNative:j};let Pt=(0,d.useMemo)(()=>({serverUrl:e,fileIo:dt,onOpenFile:e=>{Mt(!1),Nt.current.readFile(e)},onOpenNative:e=>Nt.current.openNative(e)}),[e,dt]),[Ft,It]=(0,d.useState)(GL),Lt=(0,d.useCallback)((e,t)=>{KL(e,t),It(n=>({...n,[e]:t}))},[]),[Rt,zt]=(0,d.useState)(!1),[Bt,Vt]=(0,d.useState)(!0),[Ht,Ut]=(0,d.useState)(!1),Wt=c.terminal?.enabled??!1;(0,d.useEffect)(()=>{let e=e=>{Wt&&(e.ctrlKey||e.metaKey)&&e.key==="`"&&(e.preventDefault(),Ut(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Wt]);let[Gt,Kt]=(0,d.useState)(!1),[qt,Jt]=(0,d.useState)(null),Yt=(0,d.useCallback)(()=>Jt(null),[]);function Xt(){let e=!Rt;zt(e),e&&(Vt(!1),Kt(!1))}function Zt(){let e=!Bt;Vt(e),e&&(zt(!1),Kt(!1))}function Qt(){let e=!Gt;Kt(e),e&&(zt(!1),Vt(!1))}(0,d.useEffect)(()=>(lt(Gt),()=>lt(!1)),[Gt,lt,c.sessionId,pt]),(0,d.useEffect)(()=>{Kt(!1),Jt(null)},[pt]);let[$t,en]=(0,d.useState)([]),[tn,nn]=(0,d.useState)([]),rn=(0,d.useRef)(0),an=(0,d.useRef)(0),[on,sn]=(0,d.useState)(0);async function cn(e){let t=[...e],n=t.filter(rR).map(e=>({id:`${rn.current++}`,name:e.name}));n.length>0&&nn(e=>[...e,...n]),an.current===0&&en([]),an.current++;try{let{attachments:e,errors:n}=await dR(t,fe);e.length>0&&_t(t=>[...t,...e]),n.length>0&&en(e=>[...e,...n])}finally{if(an.current--,n.length>0){let e=new Set(n.map(e=>e.id));nn(t=>t.filter(t=>!e.has(t.id)))}}}(0,d.useEffect)(()=>{At.current=gt},[gt]);function ln(){ye()}let un=(0,d.useMemo)(()=>[...gt.filter(e=>e.kind===`path`).map(e=>e.data),...vt],[gt,vt]);function dn(e){let t=At.current.findIndex(t=>t.kind===`path`&&t.data===e);t>=0?fn(t):vt.includes(e)||_t(t=>gR(t,e))}function fn(e){_t(t=>_R(t,e))}function pn(e,t){f(e,t),_t([]),en([]),bt||ln()}function mn(e){e.preventDefault(),sn(0),e.dataTransfer.files.length>0&&cn(Array.from(e.dataTransfer.files))}let{theme:hn,preference:gn,toggle:_n,setTheme:vn}=y(c.branding.defaultTheme??`system`,c.branding.allowThemeToggle!==!1,s,n);(0,d.useImperativeHandle)(a,()=>({setTheme:vn}),[vn]);let yn=(0,d.useRef)(null),[bn,xn]=(0,d.useState)(null),Sn=(0,d.useCallback)(e=>{yn.current=e,xn(e)},[]),Cn=(0,d.useRef)(null),wn=(0,d.useRef)(!0),[Tn,En]=(0,d.useState)(!0),Dn=(0,d.useCallback)(e=>{e!==wn.current&&En(e),wn.current=e},[]),On=(0,d.useCallback)(()=>{let e=yn.current;e&&Dn(e.scrollHeight-e.scrollTop-e.clientHeight<IX)},[Dn]),kn=(0,d.useRef)(null),An=(0,d.useCallback)(()=>{let e=yn.current;e&&(e.scrollHeight-e.scrollTop-e.clientHeight<IX||(kn.current=e.scrollTop))},[]),jn=(0,d.useCallback)(()=>{let e=yn.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<IX,n=kn.current;if(n!==null){if(e.scrollTop<n)kn.current=null;else if(kn.current=t?null:e.scrollTop,!t)return}Dn(t)},[Dn]);function Mn(){kn.current=null}(0,d.useEffect)(()=>{let e=bn;if(!e)return;let t=()=>{kn.current=null,jn()};e.addEventListener(`scrollend`,t);let n;return typeof ResizeObserver<`u`&&(n=new ResizeObserver(()=>{wn.current?(An(),Cn.current?.scrollIntoView({behavior:`auto`})):jn()}),n.observe(e),e.firstElementChild&&n.observe(e.firstElementChild)),()=>{e.removeEventListener(`scrollend`,t),n?.disconnect()}},[bn,jn,An]);let Nn=(0,d.useCallback)(()=>{Dn(!0),An();let e=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1;Cn.current?.scrollIntoView({behavior:e?`auto`:`smooth`})},[Dn,An]);(0,d.useEffect)(()=>{wn.current?(An(),Cn.current?.scrollIntoView({behavior:`smooth`})):On()},[c.items,On,An]);let Pn=(0,d.useMemo)(()=>dL(c.items),[c.items]),Fn=(0,d.useMemo)(()=>Rt?xL(c.items):null,[Rt,c.items]),In=(0,d.useMemo)(()=>gI({readFile:(e,t)=>{Mt(!1),ce(e,t)},fetchGitFileHistory:e=>De(e),fetchGitDiff:e=>{Mt(!0),ce(e)},searchFiles:e=>be(e)}),[ce,De,be]),Ln=(0,d.useCallback)(()=>Lt(`tools`,!0),[Lt]),Rn=(0,d.useCallback)(e=>{let t=yn.current;if(t){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=r.top>=n.top&&r.bottom<=n.bottom,a=t.scrollHeight-t.scrollTop-t.clientHeight<IX;if(i&&a)return}Dn(!1)},[Dn]),[zn,Bn]=(0,d.useState)(null),[Vn,Hn]=(0,d.useState)(null),Un=(0,d.useMemo)(()=>{let e=c.sessions?.find(e=>e.id===c.sessionId);return c.sessionName?.trim()||e?.name?.trim()||e?.firstMessage?.trim()||c.sessionId},[c.sessionName,c.sessions,c.sessionId]),Wn=(0,d.useCallback)(async()=>{Hn(null),Bn(`preparing…`);try{let{exportConversation:t}=await he(async()=>{let{exportConversation:e}=await import(`./conversationExport-CNLXCj3W.js`);return{exportConversation:e}},__vite__mapDeps([26,21,1,25]));await t({items:c.items,olderItems:c.olderHistory?.remaining??0,...c.olderHistory?{fetchOlderItems:ie}:{},connection:{serverUrl:e,token:l,workspace:ft},meta:{...c.workspace?{project:c.workspace.name}:{},session:Un,model:c.model,exportedAt:new Date},onProgress:(e,t,n)=>Bn(e===`collecting`?`reading ${t}/${n}…`:`writing ${t}/${n}…`)})}catch(e){Hn(e instanceof Error?e.message:`the conversation could not be exported`)}finally{Bn(null)}},[c.items,c.olderHistory,c.workspace,c.model,Un,ie,e,l,ft]),{jumpToItem:Gn,highlightIndex:Kn}=BL({items:c.items,scrollerRef:yn,hideTools:!Ft.tools,onShowTools:Ln,onJump:Rn}),qn=(0,d.useRef)(null),Jn=(0,d.useRef)(c.olderHistory?.have??0),Yn=(0,d.useCallback)(()=>{let e=yn.current;e&&(qn.current={height:e.scrollHeight,top:e.scrollTop}),re()},[re]);return(0,d.useLayoutEffect)(()=>{let e=c.olderHistory?.have??0,t=Jn.current;Jn.current=e;let n=qn.current;if(qn.current=null,!n||e<=t)return;let r=yn.current;r&&(r.scrollTop=n.top+(r.scrollHeight-n.height))},[c.olderHistory?.have]),(0,d.useEffect)(()=>{if(!o){let e=c.extensionTitle??c.branding.title??`pi`;document.title=c.workspace?`${c.workspace.name} — ${e}`:e}c.branding.accentColor&&s.style.setProperty(`--accent`,c.branding.accentColor)},[c.branding,c.extensionTitle,c.workspace?.name,o,s]),o&&!c.brandingReady?null:c.authRequired?(0,A.jsx)(p.Provider,{value:hn,children:(0,A.jsx)(UV,{title:c.branding.title,onSubmit:u})}):c.credentials&&!c.credentials.usableModel?(0,A.jsx)(p.Provider,{value:hn,children:(0,A.jsx)(EV,{title:c.branding.title,credentials:c.credentials,onSetCredential:je,onStartLogin:Me,login:c.login,onAnswerLogin:Ne,onCancelLogin:Pe,onDismissLogin:Fe,onDeclareProvider:Le,errors:c.errors})}):(0,A.jsx)(p.Provider,{value:hn,children:(0,A.jsx)(Uf.Provider,{value:c.replyConformance,children:(0,A.jsx)(_f.Provider,{value:c.structuredAppearance,children:(0,A.jsxs)(UF.Provider,{value:Pt,children:[(0,A.jsxs)(`div`,{className:`relative flex h-full`,onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&sn(e=>e+1)},onDragLeave:()=>sn(e=>Math.max(0,e-1)),onDragOver:e=>e.preventDefault(),onDrop:mn,children:[on>0&&(0,A.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-40 flex items-center justify-center border-2 border-dashed bg-white/70 backdrop-blur-sm dark:bg-zinc-950/70`,style:{borderColor:`var(--accent, #3b82f6)`},children:(0,A.jsx)(`p`,{className:`text-lg font-medium text-zinc-700 dark:text-zinc-200`,children:`Drop files to attach (images, documents & text)`})}),mt&&(0,A.jsx)(HV,{tree:c.fileTree,openFile:c.openFile,writableRoot:c.writableRoot,gitFiles:c.gitStatus?.files,attachedPaths:un,onExpand:k,onSelectDirectory:Tt,onRefresh:oe,onSelectFile:e=>{Mt(!1),Tt(e),ce(e)},onSelectDiff:e=>{Mt(!0),Tt(e),ce(e)},onToggleAttachPath:dn,onCreateFile:e=>{Mt(!1),ue(e)},onCreateDirectory:de,onOpenNative:j,onRevealNative:pe,onRenameFile:me,onDeleteFile:ge,onMoveFile:_e,onCopyFile:ve,fileOperation:c.fileOperation,createError:c.createError,created:c.created}),(0,A.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[Et&&(0,A.jsx)(mB,{label:`Choose a project directory`,browse:c.serverBrowse,onBrowse:Ke,onSelect:e=>{Dt(!1),qe(),Xe(e)},onCancel:()=>{Dt(!1),qe()}}),!o&&c.outpostUpdate&&(0,A.jsx)(tL,{notice:c.outpostUpdate}),!o&&c.outpostChanges&&(0,A.jsx)(aL,{changes:c.outpostChanges}),(0,A.jsx)(fV,{workspace:c.workspace,workspaces:c.workspaces,workspaceLocked:c.workspaceLocked,workspaceControl:o?Ot:`projects`,rootControl:{sandbox:c.sandbox,browse:c.serverBrowse,applyState:c.settingsApply,blocked:St!==null&&St!==`root`,onBrowse:Ke,onCloseBrowser:()=>{Ct(null),qe()},onOpened:()=>Ct(`root`),onSelect:e=>Re({sandbox:{root:e,allowWrite:c.sandbox?.allowWrite??!1,allowBash:c.sandbox?.allowBash??!1,...c.sandbox?.writableRoot?{writableRoot:c.sandbox.writableRoot}:{}}})},onSwitchWorkspace:Je,onOpenProject:()=>{Dt(!0),Ke(``)},onCloseProject:Ze,onOpenSideSession:Qe,piPackages:c.piPackages,piPackageUpdate:c.piPackageUpdate,canRestartServer:!o,serverRestarting:c.serverRestarting,onCheckPiPackages:$e,onUpdatePiPackage:et,onRestartServer:tt,restartNeeded:c.restartNeeded,title:c.branding.title,credentials:c.credentials,login:c.login,onStartLogin:Me,onAnswerLogin:Ne,onCancelLogin:Pe,onDismissLogin:Fe,onLogoutProvider:Ie,sessions:c.sessions,sessionSearch:c.sessionSearch,sessionId:c.sessionId,tree:c.tree,isStreaming:c.isStreaming,connected:c.connected,theme:hn,showThemeToggle:c.branding.allowThemeToggle!==!1,statuses:c.statuses,sidebarOpen:mt,outcomeOpen:Gt,filters:Ft,onToggleSidebar:()=>ht(!mt),onToggleOutcome:Qt,onFilterChange:Lt,...c.items.length>0?{onExportConversation:()=>void Wn()}:{},exportProgress:zn,onToggleTheme:_n,themePreference:gn,onSetTheme:vn,onNewSession:v,onSwitchSession:b,onDeleteSession:x,onListSessions:S,onRenameSession:C,onSearchSessions:w,onClearSessionSearch:T,onListTree:ee,onNavigateTree:E,onForkSession:D,gitAvailable:c.gitAvailable,gitStatus:c.gitStatus,gitSelectedPath:wt,gitLog:c.gitLog,extensionPaths:c.extensionPaths,configuredExtensionPaths:c.configuredExtensionPaths,userExtensionPaths:c.userExtensionPaths,extensionLock:c.extensionLock,tools:c.tools,commands:c.commands,sandbox:c.sandbox,gitUnavailable:c.gitUnavailable,userSkillPaths:c.userSkillPaths,serverBrowse:c.serverBrowse,settingsApply:c.settingsApply,agentResources:c.agentResources,agentResourceOperations:c.agentResourceOperations,versions:c.versions,onBrowseServerPath:Ke,onCloseServerBrowser:qe,settingsPickerBlocked:St!==null&&St!==`settings`,onSettingsPickerOpened:()=>Ct(`settings`),onRestartSession:nt,onUpdateConfig:Re,onSuggestAgentResourceClonePath:ze,onCloneAgentResourceRepository:Be,onEnrollAgentResourceRepository:Ve,onSetAgentResourceSkills:He,onRemoveAgentResourceRepository:Ue,onRefreshAgentResourceRepositories:We,onUpdateAgentResourceRepository:Ge,onFetchGitLog:we,onShowCommit:Te,terminalOpen:Ht,onToggleTerminal:Wt?()=>Ut(e=>!e):void 0}),(0,A.jsxs)(`div`,{className:`relative z-0 flex min-h-0 flex-1 flex-col`,children:[c.workPlan&&(0,A.jsx)(qV,{plan:c.workPlan,open:Bt,onToggle:Zt,onOpenWorkspace:e=>{Mt(!1),ce(e)},requestedTaskId:qt,onTaskRequestHandled:Yt}),Gt&&(0,A.jsx)(dX,{state:c.outcome,onClose:()=>Kt(!1),onRefresh:ut,onTarget:e=>{e.kind===`work-plan-task`?(Jt(e.taskId),Kt(!1),zt(!1),Vt(!0)):e.kind===`workspace-file`?(Mt(!1),ce(e.path)):e.kind===`workspace-diff`&&(Mt(!0),ce(e.path))}}),c.openFile&&(0,A.jsx)(Tz,{file:c.openFile,writableRoot:c.writableRoot,docxTemplate:c.docxTemplate,isStreaming:c.isStreaming,onDirtyChange:xt,gitState:c.gitStatus?.files[c.openFile.path],initialShowGitDiff:jt,gitDiff:c.gitDiff,gitBaseline:c.gitBaseline?.path===c.openFile.path?c.gitBaseline.text??null:null,onFetchGitDiff:Se,onClearGitDiff:Ce,inRepository:JL(c.gitStatus?.repos??[],c.openFile.path)!==null,onOpenGitHistory:De,onClose:ln,onReload:ce,onSave:le,serverUrl:e,token:l,workspace:ft,onOpenNative:j,rawRevision:c.previewRevision},c.openFile.path),c.gitFileHistory&&(0,A.jsx)(eB,{history:c.gitFileHistory,diff:c.gitFileDiff,dirty:c.gitStatus?.files[c.gitFileHistory.path]!==void 0,onFetchDiff:ke,onClearDiff:Ae,onClose:Oe}),c.gitShow&&(0,A.jsx)(Dz,{show:c.gitShow,onClose:Ee}),Fn&&(0,A.jsx)(RL,{analysis:Fn,onJump:Gn,onClose:()=>zt(!1)}),(0,A.jsx)(`main`,{ref:Sn,onScroll:jn,onWheel:Mn,onTouchStart:Mn,onKeyDown:Mn,className:`flex-1 overflow-y-auto transition-opacity duration-150 ${c.switching?`opacity-40`:`opacity-100`} ${Rt?`md:pr-[26rem]`:c.workPlan&&Bt?`md:pr-[23rem]`:``}`,children:(0,A.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-3 px-4 py-6`,children:[c.items.length===0&&(0,A.jsxs)(`div`,{className:`mt-24 text-center text-zinc-500 dark:text-zinc-600`,children:[(0,A.jsx)(`div`,{className:`mb-2 text-4xl`,children:c.branding.title??`π`}),c.agentStarting?(0,A.jsx)(`p`,{className:`text-sm`,role:`status`,"data-testid":`agent-starting`,children:`Starting the agent… The project's files are ready.`}):(0,A.jsx)(`p`,{className:`text-sm`,children:c.branding.welcome??`Send a message to start the agent.`})]}),c.olderHistory&&(0,A.jsx)(lL,{older:c.olderHistory,onLoad:Yn}),c.items.map((t,n)=>{let r=`${c.sessionId}:${n}`,i=(e,t=r)=>(0,A.jsx)(`div`,{"data-item-index":n,className:`flex flex-col gap-3 rounded-lg transition-shadow ${Kn===n?`ring-2 ring-blue-400 dark:ring-blue-500`:``}`,children:e},t);return t.kind===`user`?i((0,A.jsx)(Ye,{item:t,canEdit:!t.readOnly&&!c.isStreaming&&c.connected,onEdit:te})):t.kind===`compaction`?i((0,A.jsx)(cL,{item:t})):t.kind===`tool`?Ft.tools?i((0,A.jsx)(ZI,{item:t,dispatch:In}),t.toolCallId?`${c.sessionId}:${t.toolCallId}`:r):null:t.kind===`custom`?i((0,A.jsx)(QI,{item:t})):(Ft.reasoning?t.blocks:t.blocks.filter(e=>e.type!==`thinking`)).length===0&&!t.errorMessage?(0,A.jsx)(`div`,{"data-item-index":n,className:`sr-only`,"aria-hidden":!0},r):i((0,A.jsx)(pI,{item:t,hideReasoning:!Ft.reasoning,serverUrl:e,token:l,workspace:ft,onOpenFile:e=>{Mt(!1),ce(e)}}))}),c.pendingPrompt&&(0,A.jsxs)(`div`,{className:`flex flex-col gap-3 opacity-60`,"data-pending-prompt":!0,children:[(0,A.jsx)(Ye,{item:{kind:`user`,...c.pendingPrompt},canEdit:!1,onEdit:()=>{}}),c.extensionsBinding?(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,"data-testid":`prompt-waiting-for-extensions`,children:[(0,A.jsx)(LX,{label:`waiting for extensions to start…`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>h(!kt.current[pt??``]),className:`text-xs text-zinc-500 underline hover:text-zinc-700 dark:hover:text-zinc-300`,children:`cancel`})]}):(0,A.jsx)(LX,{label:`sending…`})]}),c.isStreaming&&!c.pendingPrompt&&(0,A.jsx)(LX,{label:`working…`}),(c.queue.steering.length>0||c.queue.followUp.length>0)&&(0,A.jsxs)(`div`,{className:`rounded-lg border border-dashed border-zinc-300 px-3 py-2 text-xs text-zinc-500 dark:border-zinc-700`,children:[c.queue.steering.map((e,t)=>(0,A.jsxs)(`div`,{children:[`⏩ steering: `,e]},`s${t}`)),c.queue.followUp.map((e,t)=>(0,A.jsxs)(`div`,{children:[`⏭ follow-up: `,e]},`f${t}`))]}),$t.map((e,t)=>(0,A.jsx)(`div`,{className:`rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:e},`att${t}`)),Vn&&(0,A.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:Vn}),c.errors.map((e,t)=>(0,A.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e},t)),(0,A.jsx)(`div`,{ref:Cn})]})}),(0,A.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-4 z-0 flex justify-center ${Rt||Gt?`md:pr-[26rem]`:c.workPlan&&Bt?`md:pr-[23rem]`:``}`,children:!Tn&&(0,A.jsxs)(`button`,{type:`button`,onClick:Nn,"aria-label":`Scroll to the latest message`,className:`pointer-events-auto flex items-center gap-1.5 rounded-full border border-zinc-300 bg-white/95 px-3 py-1.5 text-xs text-zinc-600 shadow-lg backdrop-blur transition-colors hover:bg-zinc-50 motion-reduce:transition-none dark:border-zinc-700 dark:bg-zinc-900/95 dark:text-zinc-300 dark:hover:bg-zinc-800`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,children:`↓`}),`Latest`]})})]}),Wt&&(0,A.jsx)(sX,{open:Ht,onClose:()=>Ut(!1),cwd:c.workspace?.root,confinedRoot:c.terminal?.confined?c.sandbox?.root??c.workspace?.root:void 0,confinement:c.confinement?.terminal,unavailable:c.terminal?.unavailable,onSetWorkspaceRoot:e=>{Xe&&!o?Xe(e):c.sandbox?Re({sandbox:{root:e,allowWrite:c.sandbox.allowWrite,allowBash:c.sandbox.allowBash,...c.sandbox.writableRoot?{writableRoot:c.sandbox.writableRoot}:{}}}):Re({sandbox:{root:e,allowWrite:!0,allowBash:!0}})},shells:c.terminal?.shells,openTerminal:rt,sendTerminalInput:it,getTerminalCwd:at,resizeTerminal:ot,closeTerminal:st,subscribeTerminal:ct}),(0,A.jsx)(`footer`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,A.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,A.jsx)(KR,{widgets:c.widgets,placement:`aboveEditor`}),(0,A.jsx)(TR,{initialDraft:kt.current[pt??``]??``,onDraftChange:e=>{kt.current[pt??``]=e},isStreaming:c.isStreaming,connected:c.connected,commands:c.commands,fileSearch:c.fileSearch,prefill:c.editorPrefill,attachments:gt,pendingUploads:tn,onAttach:e=>void cn(e),onMentionPaths:yt,onRemoveAttachment:fn,onSend:pn,onAbort:m,onSearchFiles:be,onClearFileSearch:xe},pt??``),(0,A.jsx)(KR,{widgets:c.widgets,placement:`belowEditor`}),(0,A.jsx)(CV,{model:c.model,models:c.models,thinkingLevel:c.thinkingLevel,thinkingLevels:c.thinkingLevels,modelSupportsReasoning:c.modelSupportsReasoning,isStreaming:c.isStreaming,contextUsage:c.contextUsage,shellConfinement:c.confinement?.bash,sessionUsage:Pn,analysisOpen:Rt,onToggleAnalysis:Xt,isCompacting:c.isCompacting,onSetModel:g,onSetThinking:_,onCompact:ne})]})})]})]}),c.dialogQueue[0]&&(0,A.jsx)(FR,{request:c.dialogQueue[0],onRespond:O}),(0,A.jsx)(zR,{notifications:c.notifications,onDismiss:ae})]})})})})});(0,f.createRoot)(document.getElementById(`root`)).render((0,A.jsx)(d.StrictMode,{children:(0,A.jsx)(RX,{})}));export{re as A,Jf as C,le as D,he as E,i as M,ne as O,ep as S,Ie as T,k_ as _,PF as a,Fp as b,bM as c,hD as d,tD as f,qv as g,xy as h,sI as i,E as j,oe as k,tM as l,Ib as m,dz as n,SF as o,QE as p,pz as r,xM as s,vX as t,kD as u,Lp as v,bd as w,jp as x,Pp as y};
|
|
1288
|
+
`);e.socket=s,s.send(JSON.stringify(e.message))}}if(t.type===`terminal_data`){let e=w.current.get(t.terminalId);if(e)for(let n of e.onData)n(t.data)}else if(t.type===`terminal_cwd`){let e=T.current.get(t.terminalId);e&&(e.message.cwd=t.cwd);let n=w.current.get(t.terminalId);if(n)for(let e of n.onCwd)e(t.cwd)}else if(t.type===`terminal_exit`){T.current.delete(t.terminalId);let e=w.current.get(t.terminalId);if(e)for(let n of e.onExit)n(t.exitCode)}else if(t.type===`terminal_error`){T.current.delete(t.terminalId);let e=w.current.get(t.terminalId);if(e)for(let n of e.onError)n(t.message)}else if(t.type===`history_items`){let e=v.current.get(t.requestId);e&&(v.current.delete(t.requestId),e.resolve({items:t.items,remaining:t.remaining}))}else if(t.type===`history_unavailable`){let e=v.current.get(t.requestId);e&&(v.current.delete(t.requestId),e.reject(new _X(t.reason,t.kind)))}else if((t.type===`file_content`||t.type===`file_written`||t.type===`file_browser_error`)&&g.current.has(t.requestId)){let e=g.current.get(t.requestId);g.current.delete(t.requestId),t.type===`file_browser_error`?e.reject(new GF(t.message,t.reason)):e.resolve(t.type===`file_content`?{content:t.content,mtimeMs:t.mtimeMs}:{mtimeMs:t.mtimeMs})}else if(t.type===`file_uploaded`){let e=h.current.get(t.requestId);e&&(h.current.delete(t.requestId),e.resolve(t.path))}else if(t.type===`file_browser_error`&&h.current.has(t.requestId)){let e=h.current.get(t.requestId);h.current.delete(t.requestId),e.reject(new eR(t.message,t.reason))}else if(t.type===`file_changed`){ce();for(let e of _.current.get(t.path)??[])e();_e(yX(t.path));let e=p.current;if(e?.status===`loaded`&&e.path===t.path){let e=`file:${fX()}`;a({type:`file_read_started`,path:t.path,requestId:e,preserveContent:!0}),D({type:`read_file`,path:t.path,requestId:e})}m.current===t.path&&D({type:`git_diff`,path:t.path,requestId:`gitdiff:${fX()}`}),he(JL(fe.current,t.path)?.repo)}else if(t.type===`directory_changed`){ce();for(let[e,n]of _.current)if(yX(e)===t.path)for(let e of n)e();_e(t.path);let e=p.current;if(e!==null&&yX(e.path)===t.path){if(ie(e.path)||ae(e.path))a({type:`raw_preview_changed`,path:e.path});else if(e.status===`loaded`){let t=`file:${fX()}`;a({type:`file_read_started`,path:e.path,requestId:t,preserveContent:!0}),D({type:`read_file`,path:e.path,requestId:t})}}let n=m.current;n!==null&&yX(n)===t.path&&D({type:`git_diff`,path:n,requestId:`gitdiff:${fX()}`}),he()}else{if((t.type===`hello`||t.type===`session_replaced`||t.type===`workspace_switched`||t.type===`workspace_starting`)&&(ue.current=t.gitAvailable===!0,t.type!==`session_replaced`&&he()),t.type===`agent_end`&&(he(),ce()),t.type===`git_repositories_changed`&&(ce(),ue.current=t.available,t.available&&he()),t.type===`git_changed`){ce(),he(t.repo===``?void 0:t.repo);let e=de.current;e!==null&&e.repo===t.repo&&D({type:`git_log`,repo:e.repo,...e.limit?{limit:e.limit}:{},requestId:`gitlog:${fX()}`})}if((t.type===`git_status`||t.type===`git_error`&&t.requestId.startsWith(`git:`))&&ge(t.requestId),t.type===`work_plan_changed`&&ce(),(t.type===`workspace_outcome`||t.type===`workspace_outcome_error`)&&ne.current===t.requestId&&(oe(),re.current&&(re.current=!1,queueMicrotask(()=>k.current()))),t.type===`hello`||t.type===`session_replaced`||t.type===`workspace_switched`||t.type===`workspace_starting`||t.type===`update_config_ack`){oe(),re.current=!1;let e=E.current,n=t.sessionId===e.sessionId,r=(t.workspace?oL(t.workspace):null)===e.workspaceRoot;te.current&&n&&r&&queueMicrotask(()=>k.current())}if(t.type===`file_operation_result`){let e=t.previousPath??t.path,n=p.current;t.operation===`delete_file`&&n?.path===t.path?p.current=null:n?.path===e&&(p.current={...n,path:t.path})}a({type:`server`,message:t}),t.type===`session_replaced`&&A(``)}},s.onclose=e=>{if(o.current===s){j.current.clear(),pe.current.clear(),me.current.clear(),oe(),re.current=!1;for(let e of h.current.values())e.reject(new eR(`The connection dropped before the upload finished`));h.current.clear();for(let e of g.current.values())e.reject(new GF(`The connection dropped before the server answered`));g.current.clear();for(let e of v.current.values())e.reject(new _X(`the connection dropped before the older messages arrived`,`failed`));v.current.clear(),e.code===NX?a({type:`auth_required`}):(a({type:`disconnected`}),n||(t=window.setTimeout(i,1500)))}}}return i(),()=>{n=!0,t!==void 0&&clearTimeout(t);let e=o.current;o.current=null,e?.close()}},[D,e,he,ge,_e,A,ce,oe,s,r]);let Se=(0,d.useCallback)((e,t)=>{let n=o.current;if(!n||n.readyState!==WebSocket.OPEN)return Promise.reject(new _X(`not connected to the server`,`failed`));let r=`history:${fX()}`;return new Promise((n,i)=>{let a=window.setTimeout(()=>{v.current.delete(r)&&i(new _X(`the older messages did not arrive`,`failed`))},jX),o=e=>t=>{clearTimeout(a),e(t)};v.current.set(r,{resolve:o(n),reject:o(i)}),D({type:`history_before`,sessionId:y.current,have:e,count:t,requestId:r})})},[D]),Ce=(0,d.useCallback)(async()=>{let e=x.current;if(!(!e||e.loading||b.current||e.remaining<=0)){b.current=!0,a({type:`history_load_started`});try{let t=await Se(e.have,50);a({type:`history_loaded`,items:t.items,remaining:t.remaining})}catch(e){if(e instanceof _X&&e.kind===`stale`){a({type:`history_load_failed`,message:``});return}a({type:`history_load_failed`,message:e instanceof Error?e.message:`the older messages could not be loaded`})}finally{b.current=!1}}},[Se]);return{state:i,fileIo:(0,d.useMemo)(()=>{function e(e,t){let n=o.current;if(!n||n.readyState!==WebSocket.OPEN)return Promise.reject(new GF(`not connected to the server`));let r=`${e}:${fX()}`;return new Promise((e,n)=>{let i=window.setTimeout(()=>{g.current.delete(r)&&n(new GF(`the server did not answer`))},AX);g.current.set(r,{resolve:t=>{clearTimeout(i),e(t)},reject:e=>{clearTimeout(i),n(e)}}),D(t(r))})}return{read:t=>e(`fileio-read`,e=>({type:`read_file`,path:t,requestId:e})),write:(t,n,r)=>e(`fileio-write`,e=>({type:`write_file`,path:t,content:n,expectedMtimeMs:r,requestId:e})),onChanged:(e,t)=>{let n=_.current.get(e)??new Set;return n.add(t),_.current.set(e,n),()=>{n.delete(t),n.size===0&&_.current.delete(e)}}}},[D]),setOutcomeActive:le,refreshOutcome:se,authToken:l.current,switchWorkspace:(e,t)=>{((t??e)!==ee||i.switching)&&(a({type:`workspace_switching`}),D({type:`switch_workspace`,root:e,...t!==void 0&&t!==e?{id:t}:{}}))},openProject:e=>{a({type:`workspace_switching`}),D({type:`open_project`,root:e})},closeProject:(e,t)=>D({type:`close_project`,root:e,...t!==void 0&&t!==e?{id:t}:{}}),checkPiPackages:()=>D({type:`check_pi_packages`}),updatePiPackage:e=>{let t=`pkg:${fX()}`;a({type:`pi_package_update_started`,requestId:t,source:e}),D({type:`update_pi_package`,source:e,requestId:t})},restartServer:()=>D({type:`restart_server`}),restartSession:()=>{a({type:`settings_apply_started`}),D({type:`restart_session`})},openSideSession:e=>{a({type:`workspace_switching`}),D({type:`open_side_session`,root:e})},submitToken:e=>{gX(e),l.current=e,a({type:`auth_retrying`}),c(e=>e+1)},prompt:(e,t)=>{a({type:`prompt_sent`,text:e,...t?.length?{images:t}:{}}),D({type:`prompt`,text:e,...t?.length?{images:t}:{}})},abort:()=>D({type:`abort`}),cancelPendingPrompt:e=>{a({type:`pending_prompt_cancelled`,restoreText:e}),D({type:`abort`})},setModel:(e,t)=>D({type:`set_model`,provider:e,id:t}),setThinking:e=>D({type:`set_thinking`,level:e}),newSession:()=>D({type:`new_session`}),switchSession:e=>D({type:`switch_session`,path:e}),deleteSession:e=>D({type:`delete_session`,path:e}),listSessions:()=>D({type:`list_sessions`}),renameSession:(e,t)=>D({type:`rename_session`,path:e,name:t}),searchSessions:e=>{let t=`sessions:${fX()}`;a({type:`session_search_started`,query:e,requestId:t}),D({type:`search_sessions`,query:e,requestId:t})},clearSessionSearch:()=>a({type:`session_search_cleared`}),listTree:()=>D({type:`list_tree`}),navigateTree:e=>D({type:`navigate_tree`,entryId:e}),forkSession:e=>D({type:`fork_session`,entryId:e}),editPrompt:(e,t,n)=>D({type:`edit_prompt`,entryId:e,text:t,...n?.length?{images:n}:{}}),compact:()=>D({type:`compact`}),fetchOlderItems:Se,loadOlderItems:Ce,respondToDialog:e=>{D({type:`extension_ui_response`,...e}),a({type:`dialog_answered`})},dismissNotification:e=>a({type:`dismiss_notification`,id:e}),listDirectory:e=>A(e),refreshFileTree:ve,readFile:(e,t)=>{let n=`file:${fX()}`;a({type:`file_read_started`,path:e,requestId:n}),D({type:`read_file`,path:e,requestId:n,...t===void 0?{}:{sha256:t}})},closeFilePreview:()=>a({type:`close_file_preview`}),writeFile:(e,t,n,r=!1)=>{let i=`write:${fX()}`;a({type:`file_save_started`,path:e,requestId:i,content:t}),D({type:`write_file`,path:e,content:t,expectedMtimeMs:n,...r?{force:r}:{},requestId:i})},createFile:e=>{a({type:`file_create_started`}),D({type:`create_file`,path:e,requestId:`create:${fX()}`})},uploadFile:(e,t)=>{let n=S.current;if(n===null)return Promise.reject(new eR(`the workspace is read-only`,`denied`));let r=o.current;if(!r||r.readyState!==WebSocket.OPEN)return Promise.reject(new eR(`not connected to the server`));let i=n?`${n}/${$L}`:$L,a=`upload:${fX()}`;return new Promise((n,r)=>{let o=window.setTimeout(()=>{h.current.delete(a)&&r(new eR(`the upload timed out`))},kX),s=e=>t=>{clearTimeout(o),e(t)};h.current.set(a,{resolve:s(n),reject:s(r)}),D({type:`upload_file`,destinationDirectory:i,name:e,contentBase64:t,requestId:a})})},createDirectory:e=>{a({type:`file_create_started`}),D({type:`create_directory`,path:e,requestId:`create:${fX()}`})},openNative:e=>{let t=`fileop:${fX()}`;a({type:`file_operation_started`,operation:`open_native`,path:e,requestId:t}),D({type:`open_native`,path:e,requestId:t})},revealNative:e=>{let t=Date.now();if(u.current?.path===e&&t-u.current.at<PX)return;u.current={path:e,at:t};let n=`fileop:${fX()}`;a({type:`file_operation_started`,operation:`reveal_native`,path:e,requestId:n}),D({type:`reveal_native`,path:e,requestId:n})},renameFile:(e,t)=>{let n=`fileop:${fX()}`;a({type:`file_operation_started`,operation:`rename_file`,path:e,requestId:n}),D({type:`rename_file`,path:e,name:t,requestId:n})},deleteFile:e=>{let t=`fileop:${fX()}`;a({type:`file_operation_started`,operation:`delete_file`,path:e,requestId:t}),D({type:`delete_file`,path:e,requestId:t})},moveFile:(e,t)=>{let n=`fileop:${fX()}`;a({type:`file_operation_started`,operation:`move_file`,path:e,requestId:n}),D({type:`move_file`,path:e,destinationDirectory:t,requestId:n})},copyFile:(e,t)=>{let n=`fileop:${fX()}`;a({type:`file_operation_started`,operation:`copy_file`,path:e,requestId:n}),D({type:`copy_file`,path:e,destinationDirectory:t,requestId:n})},searchFiles:e=>{let t=`search:${fX()}`;a({type:`file_search_started`,query:e,requestId:t}),D({type:`search_files`,query:e,requestId:t})},clearFileSearch:()=>a({type:`file_search_cleared`}),fetchGitStatus:()=>he(),fetchGitDiff:e=>{let t=`gitdiff:${fX()}`;a({type:`git_diff_started`,path:e,requestId:t}),D({type:`git_diff`,path:e,requestId:t})},clearGitDiff:()=>a({type:`git_diff_cleared`}),fetchGitLog:(e,t)=>{de.current={repo:e,limit:t},D({type:`git_log`,repo:e,...t?{limit:t}:{},requestId:`gitlog:${fX()}`})},fetchGitShow:(e,t)=>D({type:`git_show`,repo:e,sha:t,requestId:`gitshow:${fX()}`}),clearGitShow:()=>a({type:`git_show_cleared`}),fetchGitFileHistory:(e,t)=>{let n=`gitfilelog:${fX()}`;a({type:`git_file_history_started`,path:e,requestId:n}),D({type:`git_file_log`,path:e,...t?{limit:t}:{},requestId:n})},closeGitFileHistory:()=>a({type:`git_file_history_closed`}),fetchGitFileDiff:(e,t)=>{let n=`gitfilediff:${fX()}`;a({type:`git_file_diff_started`,base:e,target:t,requestId:n}),D({type:`git_file_diff`,base:e,target:t,requestId:n})},clearGitFileDiff:()=>a({type:`git_file_diff_cleared`}),setCredential:(e,t)=>D({type:`set_credential`,provider:e,apiKey:t}),startLogin:(e,t)=>{let n=fX();a({type:`login_started`,flowId:n,provider:e,method:t}),D({type:`start_login`,flowId:n,provider:e,method:t})},answerLogin:e=>{let t=i.login;t?.prompt&&(D({type:`login_answer`,flowId:t.flowId,promptId:t.prompt.promptId,value:e}),a({type:`login_answered`}))},cancelLogin:()=>{let e=i.login;e&&!e.done&&D({type:`cancel_login`,flowId:e.flowId})},dismissLogin:()=>a({type:`login_dismissed`}),logoutProvider:e=>D({type:`logout_provider`,provider:e}),declareProvider:e=>D({type:`declare_provider`,...e}),browseServerDirectory:e=>{let t=`serverdir:${fX()}`;a({type:`server_browse_started`,path:e,requestId:t}),D({type:`browse_server_directory`,path:e,requestId:t})},closeServerBrowser:()=>a({type:`server_browse_closed`}),suggestAgentResourceClonePath:e=>{let t=`resource-clone-path:${fX()}`;a({type:`resource_clone_path_started`,requestId:t}),D({type:`suggest_agent_resource_clone_path`,repositoryUrl:e,requestId:t})},cloneAgentResourceRepository:(e,t)=>{let n=`resource-preview:${fX()}`;a({type:`resource_preview_started`,requestId:n}),D({type:`clone_agent_resource_repository`,repositoryUrl:e,destinationPath:t,requestId:n})},enrollAgentResourceRepository:(e,t,n,r)=>{let i=`resource-enroll:${fX()}`;a({type:`resource_enrollment_started`,requestId:i}),D({type:`enroll_agent_resource_repository`,previewToken:e,skillRoots:t,extensionRoots:n,...r?{enabledSkills:r}:{},requestId:i})},setAgentResourceSkills:(e,t)=>{let n=`resource-skills:${fX()}`;a({type:`resource_skills_started`,requestId:n,repositoryId:e}),D({type:`set_agent_resource_skills`,repositoryId:e,enabledSkills:t,requestId:n})},removeAgentResourceRepository:e=>{let t=`resource-remove:${fX()}`;a({type:`resource_removal_started`,requestId:t,repositoryId:e}),D({type:`remove_agent_resource_repository`,repositoryId:e,requestId:t})},refreshAgentResourceRepositories:e=>{let t=`resource-refresh:${fX()}`;a({type:`resource_refresh_started`,requestId:t,...e?{repositoryId:e}:{}}),D({type:`refresh_agent_resource_repositories`,...e?{repositoryId:e}:{},requestId:t})},updateAgentResourceRepository:(e,t,n,r,i=!1)=>{let o=`resource-update:${fX()}`;a({type:`resource_update_started`,requestId:o,repositoryId:e}),D({type:`update_agent_resource_repository`,repositoryId:e,assessmentToken:t,localRevision:n,upstreamRevision:r,...i?{allowExecutableChanges:!0}:{},requestId:o})},updateConfig:e=>{a({type:`settings_apply_started`}),D({type:`update_config`,...e})},openTerminal:(e,t,n,r,i)=>{let a={type:`terminal_open`,terminalId:e,cwd:t,cols:n,rows:r,...i?{shellId:i}:{}};T.current.set(e,{message:a,socket:o.current?.readyState===WebSocket.OPEN?o.current:null}),D(a)},sendTerminalInput:(e,t)=>D({type:`terminal_input`,terminalId:e,data:t}),getTerminalCwd:e=>D({type:`terminal_get_cwd`,terminalId:e}),resizeTerminal:(e,t,n)=>{let r=T.current.get(e);r&&Object.assign(r.message,{cols:t,rows:n}),D({type:`terminal_resize`,terminalId:e,cols:t,rows:n})},closeTerminal:e=>{T.current.delete(e),D({type:`terminal_close`,terminalId:e}),w.current.delete(e)},subscribeTerminal:(e,t)=>{let n=w.current.get(e);return n||(n={onData:new Set,onCwd:new Set,onExit:new Set,onError:new Set},w.current.set(e,n)),t.onData&&n.onData.add(t.onData),t.onCwd&&n.onCwd.add(t.onCwd),t.onExit&&n.onExit.add(t.onExit),t.onError&&n.onError.add(t.onError),()=>{t.onData&&n?.onData.delete(t.onData),t.onCwd&&n?.onCwd.delete(t.onCwd),t.onExit&&n?.onExit.delete(t.onExit),t.onError&&n?.onError.delete(t.onError)}}}}var IX=120;function LX({label:e}){return(0,A.jsx)(`div`,{className:`flex justify-end px-4`,role:`status`,"aria-live":`polite`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,A.jsx)(`span`,{className:`inline-block h-4 w-4 animate-spin rounded-full border-[3px] border-zinc-300 border-t-blue-500 dark:border-zinc-600 dark:border-t-blue-400 motion-reduce:animate-pulse`}),(0,A.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:e})]})})}var RX=(0,d.forwardRef)(function({serverUrl:e=``,rootElement:t,initialTheme:n,token:r,workspace:i},a){let o=t!==void 0,s=t??document.documentElement,{state:c,authToken:l,submitToken:u,prompt:f,abort:m,cancelPendingPrompt:h,setModel:g,setThinking:_,newSession:v,switchSession:b,deleteSession:x,listSessions:S,renameSession:C,searchSessions:w,clearSessionSearch:T,listTree:ee,navigateTree:E,forkSession:D,editPrompt:te,compact:ne,loadOlderItems:re,fetchOlderItems:ie,respondToDialog:O,dismissNotification:ae,listDirectory:k,refreshFileTree:oe,readFile:ce,writeFile:le,createFile:ue,createDirectory:de,uploadFile:fe,openNative:j,revealNative:pe,renameFile:me,deleteFile:ge,moveFile:_e,copyFile:ve,closeFilePreview:ye,searchFiles:be,clearFileSearch:xe,fetchGitDiff:Se,clearGitDiff:Ce,fetchGitLog:we,fetchGitShow:Te,clearGitShow:Ee,fetchGitFileHistory:De,closeGitFileHistory:Oe,fetchGitFileDiff:ke,clearGitFileDiff:Ae,setCredential:je,startLogin:Me,answerLogin:Ne,cancelLogin:Pe,dismissLogin:Fe,logoutProvider:Ie,declareProvider:Le,updateConfig:Re,suggestAgentResourceClonePath:ze,cloneAgentResourceRepository:Be,enrollAgentResourceRepository:Ve,setAgentResourceSkills:He,removeAgentResourceRepository:Ue,refreshAgentResourceRepositories:We,updateAgentResourceRepository:Ge,browseServerDirectory:Ke,closeServerBrowser:qe,switchWorkspace:Je,openProject:Xe,closeProject:Ze,openSideSession:Qe,checkPiPackages:$e,updatePiPackage:et,restartServer:tt,restartSession:nt,openTerminal:rt,sendTerminalInput:it,getTerminalCwd:at,resizeTerminal:ot,closeTerminal:st,subscribeTerminal:ct,setOutcomeActive:lt,refreshOutcome:ut,fileIo:dt}=FX(e,r,o,i),ft=se(c.workspace);pV(c.workspaces,c.workspace?oL(c.workspace):null);let pt=c.workspace?oL(c.workspace):null;(0,d.useEffect)(()=>{_t([]),nn([]),yn.current&&(yn.current.scrollTop=0)},[pt]);let[mt,ht]=(0,d.useState)(!1),[gt,_t]=(0,d.useState)([]),[vt,yt]=(0,d.useState)([]),[bt,xt]=(0,d.useState)(!1),[St,Ct]=(0,d.useState)(null),[wt,Tt]=(0,d.useState)(null),Et=St===`project`,Dt=e=>Ct(e?`project`:null),Ot=c.embedWorkspaceControls===`projects`?`projects`:c.embedWorkspaceControls===`root`?`root`:`none`,kt=(0,d.useRef)({}),At=(0,d.useRef)([]),[jt,Mt]=(0,d.useState)(!1),Nt=(0,d.useRef)({readFile:ce,openNative:j});Nt.current={readFile:ce,openNative:j};let Pt=(0,d.useMemo)(()=>({serverUrl:e,fileIo:dt,onOpenFile:e=>{Mt(!1),Nt.current.readFile(e)},onOpenNative:e=>Nt.current.openNative(e)}),[e,dt]),[Ft,It]=(0,d.useState)(GL),Lt=(0,d.useCallback)((e,t)=>{KL(e,t),It(n=>({...n,[e]:t}))},[]),[Rt,zt]=(0,d.useState)(!1),[Bt,Vt]=(0,d.useState)(!0),[Ht,Ut]=(0,d.useState)(!1),Wt=c.terminal?.enabled??!1;(0,d.useEffect)(()=>{let e=e=>{Wt&&(e.ctrlKey||e.metaKey)&&e.key==="`"&&(e.preventDefault(),Ut(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Wt]);let[Gt,Kt]=(0,d.useState)(!1),[qt,Jt]=(0,d.useState)(null),Yt=(0,d.useCallback)(()=>Jt(null),[]);function Xt(){let e=!Rt;zt(e),e&&(Vt(!1),Kt(!1))}function Zt(){let e=!Bt;Vt(e),e&&(zt(!1),Kt(!1))}function Qt(){let e=!Gt;Kt(e),e&&(zt(!1),Vt(!1))}(0,d.useEffect)(()=>(lt(Gt),()=>lt(!1)),[Gt,lt,c.sessionId,pt]),(0,d.useEffect)(()=>{Kt(!1),Jt(null)},[pt]);let[$t,en]=(0,d.useState)([]),[tn,nn]=(0,d.useState)([]),rn=(0,d.useRef)(0),an=(0,d.useRef)(0),[on,sn]=(0,d.useState)(0);async function cn(e){let t=[...e],n=t.filter(rR).map(e=>({id:`${rn.current++}`,name:e.name}));n.length>0&&nn(e=>[...e,...n]),an.current===0&&en([]),an.current++;try{let{attachments:e,errors:n}=await dR(t,fe);e.length>0&&_t(t=>[...t,...e]),n.length>0&&en(e=>[...e,...n])}finally{if(an.current--,n.length>0){let e=new Set(n.map(e=>e.id));nn(t=>t.filter(t=>!e.has(t.id)))}}}(0,d.useEffect)(()=>{At.current=gt},[gt]);function ln(){ye()}let un=(0,d.useMemo)(()=>[...gt.filter(e=>e.kind===`path`).map(e=>e.data),...vt],[gt,vt]);function dn(e){let t=At.current.findIndex(t=>t.kind===`path`&&t.data===e);t>=0?fn(t):vt.includes(e)||_t(t=>gR(t,e))}function fn(e){_t(t=>_R(t,e))}function pn(e,t){f(e,t),_t([]),en([]),bt||ln()}function mn(e){e.preventDefault(),sn(0),e.dataTransfer.files.length>0&&cn(Array.from(e.dataTransfer.files))}let{theme:hn,preference:gn,toggle:_n,setTheme:vn}=y(c.branding.defaultTheme??`system`,c.branding.allowThemeToggle!==!1,s,n);(0,d.useImperativeHandle)(a,()=>({setTheme:vn}),[vn]);let yn=(0,d.useRef)(null),[bn,xn]=(0,d.useState)(null),Sn=(0,d.useCallback)(e=>{yn.current=e,xn(e)},[]),Cn=(0,d.useRef)(null),wn=(0,d.useRef)(!0),[Tn,En]=(0,d.useState)(!0),Dn=(0,d.useCallback)(e=>{e!==wn.current&&En(e),wn.current=e},[]),On=(0,d.useCallback)(()=>{let e=yn.current;e&&Dn(e.scrollHeight-e.scrollTop-e.clientHeight<IX)},[Dn]),kn=(0,d.useRef)(null),An=(0,d.useCallback)(()=>{let e=yn.current;e&&(e.scrollHeight-e.scrollTop-e.clientHeight<IX||(kn.current=e.scrollTop))},[]),jn=(0,d.useCallback)(()=>{let e=yn.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<IX,n=kn.current;if(n!==null){if(e.scrollTop<n)kn.current=null;else if(kn.current=t?null:e.scrollTop,!t)return}Dn(t)},[Dn]);function Mn(){kn.current=null}(0,d.useEffect)(()=>{let e=bn;if(!e)return;let t=()=>{kn.current=null,jn()};e.addEventListener(`scrollend`,t);let n;return typeof ResizeObserver<`u`&&(n=new ResizeObserver(()=>{wn.current?(An(),Cn.current?.scrollIntoView({behavior:`auto`})):jn()}),n.observe(e),e.firstElementChild&&n.observe(e.firstElementChild)),()=>{e.removeEventListener(`scrollend`,t),n?.disconnect()}},[bn,jn,An]);let Nn=(0,d.useCallback)(()=>{Dn(!0),An();let e=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1;Cn.current?.scrollIntoView({behavior:e?`auto`:`smooth`})},[Dn,An]);(0,d.useEffect)(()=>{wn.current?(An(),Cn.current?.scrollIntoView({behavior:`smooth`})):On()},[c.items,On,An]);let Pn=(0,d.useMemo)(()=>dL(c.items),[c.items]),Fn=(0,d.useMemo)(()=>Rt?xL(c.items):null,[Rt,c.items]),In=(0,d.useMemo)(()=>gI({readFile:(e,t)=>{Mt(!1),ce(e,t)},fetchGitFileHistory:e=>De(e),fetchGitDiff:e=>{Mt(!0),ce(e)},searchFiles:e=>be(e)}),[ce,De,be]),Ln=(0,d.useCallback)(()=>Lt(`tools`,!0),[Lt]),Rn=(0,d.useCallback)(e=>{let t=yn.current;if(t){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=r.top>=n.top&&r.bottom<=n.bottom,a=t.scrollHeight-t.scrollTop-t.clientHeight<IX;if(i&&a)return}Dn(!1)},[Dn]),[zn,Bn]=(0,d.useState)(null),[Vn,Hn]=(0,d.useState)(null),Un=(0,d.useMemo)(()=>{let e=c.sessions?.find(e=>e.id===c.sessionId);return c.sessionName?.trim()||e?.name?.trim()||e?.firstMessage?.trim()||c.sessionId},[c.sessionName,c.sessions,c.sessionId]),Wn=(0,d.useCallback)(async()=>{Hn(null),Bn(`preparing…`);try{let{exportConversation:t}=await he(async()=>{let{exportConversation:e}=await import(`./conversationExport-DrllhTso.js`);return{exportConversation:e}},__vite__mapDeps([26,21,1,25]));await t({items:c.items,olderItems:c.olderHistory?.remaining??0,...c.olderHistory?{fetchOlderItems:ie}:{},connection:{serverUrl:e,token:l,workspace:ft},meta:{...c.workspace?{project:c.workspace.name}:{},session:Un,model:c.model,exportedAt:new Date},onProgress:(e,t,n)=>Bn(e===`collecting`?`reading ${t}/${n}…`:`writing ${t}/${n}…`)})}catch(e){Hn(e instanceof Error?e.message:`the conversation could not be exported`)}finally{Bn(null)}},[c.items,c.olderHistory,c.workspace,c.model,Un,ie,e,l,ft]),{jumpToItem:Gn,highlightIndex:Kn}=BL({items:c.items,scrollerRef:yn,hideTools:!Ft.tools,onShowTools:Ln,onJump:Rn}),qn=(0,d.useRef)(null),Jn=(0,d.useRef)(c.olderHistory?.have??0),Yn=(0,d.useCallback)(()=>{let e=yn.current;e&&(qn.current={height:e.scrollHeight,top:e.scrollTop}),re()},[re]);return(0,d.useLayoutEffect)(()=>{let e=c.olderHistory?.have??0,t=Jn.current;Jn.current=e;let n=qn.current;if(qn.current=null,!n||e<=t)return;let r=yn.current;r&&(r.scrollTop=n.top+(r.scrollHeight-n.height))},[c.olderHistory?.have]),(0,d.useEffect)(()=>{if(!o){let e=c.extensionTitle??c.branding.title??`pi`;document.title=c.workspace?`${c.workspace.name} — ${e}`:e}c.branding.accentColor&&s.style.setProperty(`--accent`,c.branding.accentColor)},[c.branding,c.extensionTitle,c.workspace?.name,o,s]),o&&!c.brandingReady?null:c.authRequired?(0,A.jsx)(p.Provider,{value:hn,children:(0,A.jsx)(UV,{title:c.branding.title,onSubmit:u})}):c.credentials&&!c.credentials.usableModel?(0,A.jsx)(p.Provider,{value:hn,children:(0,A.jsx)(EV,{title:c.branding.title,credentials:c.credentials,onSetCredential:je,onStartLogin:Me,login:c.login,onAnswerLogin:Ne,onCancelLogin:Pe,onDismissLogin:Fe,onDeclareProvider:Le,errors:c.errors})}):(0,A.jsx)(p.Provider,{value:hn,children:(0,A.jsx)(Uf.Provider,{value:c.replyConformance,children:(0,A.jsx)(_f.Provider,{value:c.structuredAppearance,children:(0,A.jsxs)(UF.Provider,{value:Pt,children:[(0,A.jsxs)(`div`,{className:`relative flex h-full`,onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&sn(e=>e+1)},onDragLeave:()=>sn(e=>Math.max(0,e-1)),onDragOver:e=>e.preventDefault(),onDrop:mn,children:[on>0&&(0,A.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-40 flex items-center justify-center border-2 border-dashed bg-white/70 backdrop-blur-sm dark:bg-zinc-950/70`,style:{borderColor:`var(--accent, #3b82f6)`},children:(0,A.jsx)(`p`,{className:`text-lg font-medium text-zinc-700 dark:text-zinc-200`,children:`Drop files to attach (images, documents & text)`})}),mt&&(0,A.jsx)(HV,{tree:c.fileTree,openFile:c.openFile,writableRoot:c.writableRoot,gitFiles:c.gitStatus?.files,attachedPaths:un,onExpand:k,onSelectDirectory:Tt,onRefresh:oe,onSelectFile:e=>{Mt(!1),Tt(e),ce(e)},onSelectDiff:e=>{Mt(!0),Tt(e),ce(e)},onToggleAttachPath:dn,onCreateFile:e=>{Mt(!1),ue(e)},onCreateDirectory:de,onOpenNative:j,onRevealNative:pe,onRenameFile:me,onDeleteFile:ge,onMoveFile:_e,onCopyFile:ve,fileOperation:c.fileOperation,createError:c.createError,created:c.created}),(0,A.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[Et&&(0,A.jsx)(mB,{label:`Choose a project directory`,browse:c.serverBrowse,onBrowse:Ke,onSelect:e=>{Dt(!1),qe(),Xe(e)},onCancel:()=>{Dt(!1),qe()}}),!o&&c.outpostUpdate&&(0,A.jsx)(tL,{notice:c.outpostUpdate}),!o&&c.outpostChanges&&(0,A.jsx)(aL,{changes:c.outpostChanges}),(0,A.jsx)(fV,{workspace:c.workspace,workspaces:c.workspaces,workspaceLocked:c.workspaceLocked,workspaceControl:o?Ot:`projects`,rootControl:{sandbox:c.sandbox,browse:c.serverBrowse,applyState:c.settingsApply,blocked:St!==null&&St!==`root`,onBrowse:Ke,onCloseBrowser:()=>{Ct(null),qe()},onOpened:()=>Ct(`root`),onSelect:e=>Re({sandbox:{root:e,allowWrite:c.sandbox?.allowWrite??!1,allowBash:c.sandbox?.allowBash??!1,...c.sandbox?.writableRoot?{writableRoot:c.sandbox.writableRoot}:{}}})},onSwitchWorkspace:Je,onOpenProject:()=>{Dt(!0),Ke(``)},onCloseProject:Ze,onOpenSideSession:Qe,piPackages:c.piPackages,piPackageUpdate:c.piPackageUpdate,canRestartServer:!o,serverRestarting:c.serverRestarting,onCheckPiPackages:$e,onUpdatePiPackage:et,onRestartServer:tt,restartNeeded:c.restartNeeded,title:c.branding.title,credentials:c.credentials,login:c.login,onStartLogin:Me,onAnswerLogin:Ne,onCancelLogin:Pe,onDismissLogin:Fe,onLogoutProvider:Ie,sessions:c.sessions,sessionSearch:c.sessionSearch,sessionId:c.sessionId,tree:c.tree,isStreaming:c.isStreaming,connected:c.connected,theme:hn,showThemeToggle:c.branding.allowThemeToggle!==!1,statuses:c.statuses,sidebarOpen:mt,outcomeOpen:Gt,filters:Ft,onToggleSidebar:()=>ht(!mt),onToggleOutcome:Qt,onFilterChange:Lt,...c.items.length>0?{onExportConversation:()=>void Wn()}:{},exportProgress:zn,onToggleTheme:_n,themePreference:gn,onSetTheme:vn,onNewSession:v,onSwitchSession:b,onDeleteSession:x,onListSessions:S,onRenameSession:C,onSearchSessions:w,onClearSessionSearch:T,onListTree:ee,onNavigateTree:E,onForkSession:D,gitAvailable:c.gitAvailable,gitStatus:c.gitStatus,gitSelectedPath:wt,gitLog:c.gitLog,extensionPaths:c.extensionPaths,configuredExtensionPaths:c.configuredExtensionPaths,userExtensionPaths:c.userExtensionPaths,extensionLock:c.extensionLock,tools:c.tools,commands:c.commands,sandbox:c.sandbox,gitUnavailable:c.gitUnavailable,userSkillPaths:c.userSkillPaths,serverBrowse:c.serverBrowse,settingsApply:c.settingsApply,agentResources:c.agentResources,agentResourceOperations:c.agentResourceOperations,versions:c.versions,onBrowseServerPath:Ke,onCloseServerBrowser:qe,settingsPickerBlocked:St!==null&&St!==`settings`,onSettingsPickerOpened:()=>Ct(`settings`),onRestartSession:nt,onUpdateConfig:Re,onSuggestAgentResourceClonePath:ze,onCloneAgentResourceRepository:Be,onEnrollAgentResourceRepository:Ve,onSetAgentResourceSkills:He,onRemoveAgentResourceRepository:Ue,onRefreshAgentResourceRepositories:We,onUpdateAgentResourceRepository:Ge,onFetchGitLog:we,onShowCommit:Te,terminalOpen:Ht,onToggleTerminal:Wt?()=>Ut(e=>!e):void 0}),(0,A.jsxs)(`div`,{className:`relative z-0 flex min-h-0 flex-1 flex-col`,children:[c.workPlan&&(0,A.jsx)(qV,{plan:c.workPlan,open:Bt,onToggle:Zt,onOpenWorkspace:e=>{Mt(!1),ce(e)},requestedTaskId:qt,onTaskRequestHandled:Yt}),Gt&&(0,A.jsx)(dX,{state:c.outcome,onClose:()=>Kt(!1),onRefresh:ut,onTarget:e=>{e.kind===`work-plan-task`?(Jt(e.taskId),Kt(!1),zt(!1),Vt(!0)):e.kind===`workspace-file`?(Mt(!1),ce(e.path)):e.kind===`workspace-diff`&&(Mt(!0),ce(e.path))}}),c.openFile&&(0,A.jsx)(Tz,{file:c.openFile,writableRoot:c.writableRoot,docxTemplate:c.docxTemplate,isStreaming:c.isStreaming,onDirtyChange:xt,gitState:c.gitStatus?.files[c.openFile.path],initialShowGitDiff:jt,gitDiff:c.gitDiff,gitBaseline:c.gitBaseline?.path===c.openFile.path?c.gitBaseline.text??null:null,onFetchGitDiff:Se,onClearGitDiff:Ce,inRepository:JL(c.gitStatus?.repos??[],c.openFile.path)!==null,onOpenGitHistory:De,onClose:ln,onReload:ce,onSave:le,serverUrl:e,token:l,workspace:ft,onOpenNative:j,rawRevision:c.previewRevision},c.openFile.path),c.gitFileHistory&&(0,A.jsx)(eB,{history:c.gitFileHistory,diff:c.gitFileDiff,dirty:c.gitStatus?.files[c.gitFileHistory.path]!==void 0,onFetchDiff:ke,onClearDiff:Ae,onClose:Oe}),c.gitShow&&(0,A.jsx)(Dz,{show:c.gitShow,onClose:Ee}),Fn&&(0,A.jsx)(RL,{analysis:Fn,onJump:Gn,onClose:()=>zt(!1)}),(0,A.jsx)(`main`,{ref:Sn,onScroll:jn,onWheel:Mn,onTouchStart:Mn,onKeyDown:Mn,className:`flex-1 overflow-y-auto transition-opacity duration-150 ${c.switching?`opacity-40`:`opacity-100`} ${Rt?`md:pr-[26rem]`:c.workPlan&&Bt?`md:pr-[23rem]`:``}`,children:(0,A.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-3 px-4 py-6`,children:[c.items.length===0&&(0,A.jsxs)(`div`,{className:`mt-24 text-center text-zinc-500 dark:text-zinc-600`,children:[(0,A.jsx)(`div`,{className:`mb-2 text-4xl`,children:c.branding.title??`π`}),c.agentStarting?(0,A.jsx)(`p`,{className:`text-sm`,role:`status`,"data-testid":`agent-starting`,children:`Starting the agent… The project's files are ready.`}):(0,A.jsx)(`p`,{className:`text-sm`,children:c.branding.welcome??`Send a message to start the agent.`})]}),c.olderHistory&&(0,A.jsx)(lL,{older:c.olderHistory,onLoad:Yn}),c.items.map((t,n)=>{let r=`${c.sessionId}:${n}`,i=(e,t=r)=>(0,A.jsx)(`div`,{"data-item-index":n,className:`flex flex-col gap-3 rounded-lg transition-shadow ${Kn===n?`ring-2 ring-blue-400 dark:ring-blue-500`:``}`,children:e},t);return t.kind===`user`?i((0,A.jsx)(Ye,{item:t,canEdit:!t.readOnly&&!c.isStreaming&&c.connected,onEdit:te})):t.kind===`compaction`?i((0,A.jsx)(cL,{item:t})):t.kind===`tool`?Ft.tools?i((0,A.jsx)(ZI,{item:t,dispatch:In}),t.toolCallId?`${c.sessionId}:${t.toolCallId}`:r):null:t.kind===`custom`?i((0,A.jsx)(QI,{item:t})):(Ft.reasoning?t.blocks:t.blocks.filter(e=>e.type!==`thinking`)).length===0&&!t.errorMessage?(0,A.jsx)(`div`,{"data-item-index":n,className:`sr-only`,"aria-hidden":!0},r):i((0,A.jsx)(pI,{item:t,hideReasoning:!Ft.reasoning,serverUrl:e,token:l,workspace:ft,onOpenFile:e=>{Mt(!1),ce(e)}}))}),c.pendingPrompt&&(0,A.jsxs)(`div`,{className:`flex flex-col gap-3 opacity-60`,"data-pending-prompt":!0,children:[(0,A.jsx)(Ye,{item:{kind:`user`,...c.pendingPrompt},canEdit:!1,onEdit:()=>{}}),c.extensionsBinding?(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,"data-testid":`prompt-waiting-for-extensions`,children:[(0,A.jsx)(LX,{label:`waiting for extensions to start…`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>h(!kt.current[pt??``]),className:`text-xs text-zinc-500 underline hover:text-zinc-700 dark:hover:text-zinc-300`,children:`cancel`})]}):(0,A.jsx)(LX,{label:`sending…`})]}),c.isStreaming&&!c.pendingPrompt&&(0,A.jsx)(LX,{label:`working…`}),(c.queue.steering.length>0||c.queue.followUp.length>0)&&(0,A.jsxs)(`div`,{className:`rounded-lg border border-dashed border-zinc-300 px-3 py-2 text-xs text-zinc-500 dark:border-zinc-700`,children:[c.queue.steering.map((e,t)=>(0,A.jsxs)(`div`,{children:[`⏩ steering: `,e]},`s${t}`)),c.queue.followUp.map((e,t)=>(0,A.jsxs)(`div`,{children:[`⏭ follow-up: `,e]},`f${t}`))]}),$t.map((e,t)=>(0,A.jsx)(`div`,{className:`rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:e},`att${t}`)),Vn&&(0,A.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:Vn}),c.errors.map((e,t)=>(0,A.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e},t)),(0,A.jsx)(`div`,{ref:Cn})]})}),(0,A.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-4 z-0 flex justify-center ${Rt||Gt?`md:pr-[26rem]`:c.workPlan&&Bt?`md:pr-[23rem]`:``}`,children:!Tn&&(0,A.jsxs)(`button`,{type:`button`,onClick:Nn,"aria-label":`Scroll to the latest message`,className:`pointer-events-auto flex items-center gap-1.5 rounded-full border border-zinc-300 bg-white/95 px-3 py-1.5 text-xs text-zinc-600 shadow-lg backdrop-blur transition-colors hover:bg-zinc-50 motion-reduce:transition-none dark:border-zinc-700 dark:bg-zinc-900/95 dark:text-zinc-300 dark:hover:bg-zinc-800`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,children:`↓`}),`Latest`]})})]}),Wt&&(0,A.jsx)(sX,{open:Ht,onClose:()=>Ut(!1),cwd:c.workspace?.root,confinedRoot:c.terminal?.confined?c.sandbox?.root??c.workspace?.root:void 0,confinement:c.confinement?.terminal,unavailable:c.terminal?.unavailable,onSetWorkspaceRoot:e=>{Xe&&!o?Xe(e):c.sandbox?Re({sandbox:{root:e,allowWrite:c.sandbox.allowWrite,allowBash:c.sandbox.allowBash,...c.sandbox.writableRoot?{writableRoot:c.sandbox.writableRoot}:{}}}):Re({sandbox:{root:e,allowWrite:!0,allowBash:!0}})},shells:c.terminal?.shells,openTerminal:rt,sendTerminalInput:it,getTerminalCwd:at,resizeTerminal:ot,closeTerminal:st,subscribeTerminal:ct}),(0,A.jsx)(`footer`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,A.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,A.jsx)(KR,{widgets:c.widgets,placement:`aboveEditor`}),(0,A.jsx)(TR,{initialDraft:kt.current[pt??``]??``,onDraftChange:e=>{kt.current[pt??``]=e},isStreaming:c.isStreaming,connected:c.connected,commands:c.commands,fileSearch:c.fileSearch,prefill:c.editorPrefill,attachments:gt,pendingUploads:tn,onAttach:e=>void cn(e),onMentionPaths:yt,onRemoveAttachment:fn,onSend:pn,onAbort:m,onSearchFiles:be,onClearFileSearch:xe},pt??``),(0,A.jsx)(KR,{widgets:c.widgets,placement:`belowEditor`}),(0,A.jsx)(CV,{model:c.model,models:c.models,thinkingLevel:c.thinkingLevel,thinkingLevels:c.thinkingLevels,modelSupportsReasoning:c.modelSupportsReasoning,isStreaming:c.isStreaming,contextUsage:c.contextUsage,shellConfinement:c.confinement?.bash,sessionUsage:Pn,analysisOpen:Rt,onToggleAnalysis:Xt,isCompacting:c.isCompacting,onSetModel:g,onSetThinking:_,onCompact:ne})]})})]})]}),c.dialogQueue[0]&&(0,A.jsx)(FR,{request:c.dialogQueue[0],onRespond:O}),(0,A.jsx)(zR,{notifications:c.notifications,onDismiss:ae})]})})})})});(0,f.createRoot)(document.getElementById(`root`)).render((0,A.jsx)(d.StrictMode,{children:(0,A.jsx)(RX,{})}));export{re as A,Jf as C,le as D,he as E,i as M,ne as O,ep as S,Ie as T,k_ as _,PF as a,Fp as b,bM as c,hD as d,tD as f,qv as g,xy as h,sI as i,E as j,oe as k,tM as l,Ib as m,dz as n,SF as o,QE as p,pz as r,xM as s,vX as t,kD as u,Lp as v,bd as w,jp as x,Pp as y};
|