pi-outpost 0.30.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/contract/validate-structured-exchange.mjs +1 -1
  2. package/dist/pi-outpost.mjs +4225 -1684
  3. package/dist/pi-outpost.sea.mjs +2 -2
  4. package/dist/sea-prep.blob +2 -2
  5. package/dist/skills/docx-from-template/SKILL.md +3 -2
  6. package/dist/web/assets/{PdfViewer-DM2j93gM.js → PdfViewer-DHIy06i5.js} +2 -2
  7. package/dist/web/assets/{abnfDiagram-VCTEODGH-DMqWwxhT.js → abnfDiagram-VCTEODGH-0IqI620v.js} +1 -1
  8. package/dist/web/assets/architecture-7GRP2DOG-BqTZwqCY.js +1 -0
  9. package/dist/web/assets/{architectureDiagram-5GKGNRK7-Cmw55DUJ.js → architectureDiagram-5GKGNRK7-BEGSAGSn.js} +1 -1
  10. package/dist/web/assets/{blockDiagram-OSKFZWR5-BlQMCvwy.js → blockDiagram-OSKFZWR5-sw0nzjYC.js} +1 -1
  11. package/dist/web/assets/{c4Diagram-7LVT6UL2-Chu7sQla.js → c4Diagram-7LVT6UL2-C6wQYxBC.js} +1 -1
  12. package/dist/web/assets/channel-CbMG5PZq.js +1 -0
  13. package/dist/web/assets/{chunk-3NF5O7KM-Bs9Gy119.js → chunk-3NF5O7KM-Dni31-nE.js} +1 -1
  14. package/dist/web/assets/{chunk-4HAMMTFA-IuCppxpD.js → chunk-4HAMMTFA-hiqoLVtf.js} +1 -1
  15. package/dist/web/assets/{chunk-75Z2AOVW-NtkdG7DW.js → chunk-75Z2AOVW-1k7HRGrm.js} +1 -1
  16. package/dist/web/assets/{chunk-DU6HZSFF-BtoTQPGb.js → chunk-DU6HZSFF-Dy05V--k.js} +1 -1
  17. package/dist/web/assets/{chunk-F27PBJKO-Cvnrd6Bh.js → chunk-F27PBJKO-C6rqX2gT.js} +1 -1
  18. package/dist/web/assets/{chunk-GMAD6QVW-DGB5J2r_.js → chunk-GMAD6QVW-Bi5Ne8OE.js} +1 -1
  19. package/dist/web/assets/{chunk-GVQU2GXP-C7GvltSz.js → chunk-GVQU2GXP-BtSmWzHA.js} +1 -1
  20. package/dist/web/assets/{chunk-HLEWEB6X-C1eFLusE.js → chunk-HLEWEB6X-yamDqy1M.js} +1 -1
  21. package/dist/web/assets/{chunk-L3NEJ4N5-DR-JHG39.js → chunk-L3NEJ4N5-CQSamtuJ.js} +1 -1
  22. package/dist/web/assets/{chunk-OSK3NFVY-CnEExzUX.js → chunk-OSK3NFVY-S95igUko.js} +1 -1
  23. package/dist/web/assets/{chunk-P2QGCYS3-C9zcRDKQ.js → chunk-P2QGCYS3-BPor-azX.js} +1 -1
  24. package/dist/web/assets/{chunk-POPQ4Y6H-CB9UGzF_.js → chunk-POPQ4Y6H-BrnPOTT-.js} +1 -1
  25. package/dist/web/assets/{chunk-PWAF6VOD-CIaq_ijT.js → chunk-PWAF6VOD-Dup_NAkl.js} +1 -1
  26. package/dist/web/assets/{chunk-SVP7TREG-mUYKwy6v.js → chunk-SVP7TREG-CYXVRfc0.js} +1 -1
  27. package/dist/web/assets/{chunk-ZLD2IHE6-BmP2ggTj.js → chunk-ZLD2IHE6-D0uZMMWb.js} +1 -1
  28. package/dist/web/assets/classDiagram-CYGNFDIV-2Yl201cv.js +1 -0
  29. package/dist/web/assets/classDiagram-v2-TLXNO2FR-2Yl201cv.js +1 -0
  30. package/dist/web/assets/{conversationExport-B1l3iRjL.js → conversationExport-CfUybHMU.js} +1 -1
  31. package/dist/web/assets/{cynefin-OW5HDTMX-DoaRfvqd.js → cynefin-OW5HDTMX-ua6bZIWp.js} +1 -1
  32. package/dist/web/assets/{cynefinDiagram-5FMLGOSQ-Dzfq9J56.js → cynefinDiagram-5FMLGOSQ-BKvXEDID.js} +1 -1
  33. package/dist/web/assets/{dagre-OS7QT2EB-Mo7Ax9Bi.js → dagre-OS7QT2EB-BRxaZdm2.js} +1 -1
  34. package/dist/web/assets/{diagram-S7CK7UJ4-Cvxa20rU.js → diagram-S7CK7UJ4-DTvEAe9r.js} +1 -1
  35. package/dist/web/assets/{diagram-UQ7AKVKN-DjpTGU_F.js → diagram-UQ7AKVKN-CVGEkml-.js} +1 -1
  36. package/dist/web/assets/{diagram-VSXAHHWV-ByLE1Zyl.js → diagram-VSXAHHWV-Dkh-RvzE.js} +1 -1
  37. package/dist/web/assets/{diagram-VX7I27RA-Cyc9OWNt.js → diagram-VX7I27RA-D5POkb-9.js} +1 -1
  38. package/dist/web/assets/{diagram-Z3DM3KII-DGTbhShH.js → diagram-Z3DM3KII-CC2Mxm4H.js} +1 -1
  39. package/dist/web/assets/{docxExport-CzFTex-m.js → docxExport-ErgwApAZ.js} +1 -1
  40. package/dist/web/assets/{ebnfDiagram-PWID7BFC-CbeKoL2f.js → ebnfDiagram-PWID7BFC-CbDy2vxX.js} +1 -1
  41. package/dist/web/assets/{erDiagram-2YWLMYGG-CGSNCHLB.js → erDiagram-2YWLMYGG-DUdStx-7.js} +1 -1
  42. package/dist/web/assets/eventmodeling-NTZA5JFV-Bw8wULv_.js +1 -0
  43. package/dist/web/assets/flowDiagram-T62WH6J4-Dp4v9IDN.js +1 -0
  44. package/dist/web/assets/{ganttDiagram-EL5Y4UJY-DYjbtkia.js → ganttDiagram-EL5Y4UJY-6dI1H52q.js} +1 -1
  45. package/dist/web/assets/{gitGraph-4MIJSDKK-BiGJUoQR.js → gitGraph-4MIJSDKK-UXnB0IFr.js} +1 -1
  46. package/dist/web/assets/{gitGraphDiagram-WWUBYQGX-t1f3R6K_.js → gitGraphDiagram-WWUBYQGX-B_wXPpx0.js} +1 -1
  47. package/dist/web/assets/{index-Druo6AJL.js → index-COu8CnNa.js} +5 -5
  48. package/dist/web/assets/{info-A6RAGUB7-B6YvVE9P.js → info-A6RAGUB7-C2WWyNzF.js} +1 -1
  49. package/dist/web/assets/{infoDiagram-FKFFQAWI-4xuNCmim.js → infoDiagram-FKFFQAWI-DY65_ndC.js} +1 -1
  50. package/dist/web/assets/{ishikawaDiagram-5VMMS53U-Dzt0UUHa.js → ishikawaDiagram-5VMMS53U-D-gYpOUM.js} +1 -1
  51. package/dist/web/assets/{journeyDiagram-EYS64GPL-DlSL8HYK.js → journeyDiagram-EYS64GPL-B0WqOtZ4.js} +1 -1
  52. package/dist/web/assets/{kanban-definition-UXKFOSKX-CwOJ0VUV.js → kanban-definition-UXKFOSKX-DIrVFtP3.js} +1 -1
  53. package/dist/web/assets/{line-DKQavTES.js → line-CuEhAU65.js} +1 -1
  54. package/dist/web/assets/{loadReferencedImage-B4thW94R.js → loadReferencedImage-DgHMXQNZ.js} +2 -2
  55. package/dist/web/assets/{mermaid-parser.core-hcRslV0v.js → mermaid-parser.core-CzCh9EE1.js} +3 -3
  56. package/dist/web/assets/{mermaid.core-He1v95E5.js → mermaid.core-BmGW_v8T.js} +4 -4
  57. package/dist/web/assets/{mindmap-definition-THT77NOG-Dm-RHh_K.js → mindmap-definition-THT77NOG-CBH0Z9AJ.js} +1 -1
  58. package/dist/web/assets/{packet-AYTQ26CC-CKXELtWR.js → packet-AYTQ26CC-BYG_KViO.js} +1 -1
  59. package/dist/web/assets/{pdf-DbJw3a4n.js → pdf-6mG9havR.js} +1 -1
  60. package/dist/web/assets/{pegDiagram-XKGWAZYB-BCOHJ5Ws.js → pegDiagram-XKGWAZYB-BNpTWHo8.js} +1 -1
  61. package/dist/web/assets/{pie-WAS4IAKB-aDbYwqRx.js → pie-WAS4IAKB-wBoUHr8R.js} +1 -1
  62. package/dist/web/assets/{pieDiagram-E7YTZNPT-zjpyyEad.js → pieDiagram-E7YTZNPT-CZ34Q1W-.js} +1 -1
  63. package/dist/web/assets/{quadrantDiagram-AXDQQJYC-9_TC3Drf.js → quadrantDiagram-AXDQQJYC-C5aFQsIe.js} +1 -1
  64. package/dist/web/assets/{radar-RG4KPBEZ-kuiXWdSp.js → radar-RG4KPBEZ-D4K5XP7X.js} +1 -1
  65. package/dist/web/assets/{railroad-74A4TZTK-CYVY-iQF.js → railroad-74A4TZTK-Haum25Us.js} +1 -1
  66. package/dist/web/assets/railroad-abnf-HS5TGJTU-D-kbOsoZ.js +1 -0
  67. package/dist/web/assets/railroad-ebnf-LZEXJU2U-CWtixpZf.js +1 -0
  68. package/dist/web/assets/railroad-peg-WCYAUIDC-BeY7arxf.js +1 -0
  69. package/dist/web/assets/{railroadDiagram-O6MQD6OU-Bb75_4nm.js → railroadDiagram-O6MQD6OU-B0ctRtRT.js} +1 -1
  70. package/dist/web/assets/{requirementDiagram-IS5BZ75X-CTuOhOSy.js → requirementDiagram-IS5BZ75X-BuOtNPGm.js} +1 -1
  71. package/dist/web/assets/{sankeyDiagram-P5KCCOFB-CGxEU0DK.js → sankeyDiagram-P5KCCOFB-CybICPpQ.js} +1 -1
  72. package/dist/web/assets/{sequenceDiagram-WJ2MYXX4-2aJPjQtr.js → sequenceDiagram-WJ2MYXX4-Dvo8sl8e.js} +1 -1
  73. package/dist/web/assets/{stateDiagram-XQSTLZYL-n954m6lj.js → stateDiagram-XQSTLZYL-BcM-hGJa.js} +1 -1
  74. package/dist/web/assets/stateDiagram-v2-IH3M54BS-hYgwFLzv.js +1 -0
  75. package/dist/web/assets/{swimlanes-V6O3JKXN-DHkryKCf.js → swimlanes-V6O3JKXN-mOOjKnlm.js} +1 -1
  76. package/dist/web/assets/swimlanesDiagram-JKAHXJPX-C_yinM3f.js +8 -0
  77. package/dist/web/assets/{timeline-definition-24CTP7MA-Bx-r-pvf.js → timeline-definition-24CTP7MA-DuwMztTy.js} +1 -1
  78. package/dist/web/assets/{treeView-Q6P3EWNA-BpuFDxVp.js → treeView-Q6P3EWNA-BT4vRttT.js} +1 -1
  79. package/dist/web/assets/{treemap-WGGIJYW6-DhAU0qeO.js → treemap-WGGIJYW6-Df6GHCE2.js} +1 -1
  80. package/dist/web/assets/{vennDiagram-4TSXK5OY-B7SsVK1T.js → vennDiagram-4TSXK5OY-BbcbGn7o.js} +1 -1
  81. package/dist/web/assets/{wardley-WFR3VGLG-T3ND9x3N.js → wardley-WFR3VGLG-L_G3ydHA.js} +1 -1
  82. package/dist/web/assets/{wardleyDiagram-VM6X3IG4-LN9cYkCA.js → wardleyDiagram-VM6X3IG4-CzB2tR_t.js} +1 -1
  83. package/dist/web/assets/{xychartDiagram-S5SC5T6Z-DBPV1r5l.js → xychartDiagram-S5SC5T6Z-CKHwJboP.js} +1 -1
  84. package/dist/web/index.html +1 -1
  85. package/package.json +1 -1
  86. package/dist/web/assets/architecture-7GRP2DOG-C-RUN5Nw.js +0 -1
  87. package/dist/web/assets/channel-CYhTbZyp.js +0 -1
  88. package/dist/web/assets/classDiagram-CYGNFDIV-L7PSV2RW.js +0 -1
  89. package/dist/web/assets/classDiagram-v2-TLXNO2FR-L7PSV2RW.js +0 -1
  90. package/dist/web/assets/eventmodeling-NTZA5JFV-St9tzXUX.js +0 -1
  91. package/dist/web/assets/flowDiagram-T62WH6J4-Dtx5xCra.js +0 -1
  92. package/dist/web/assets/railroad-abnf-HS5TGJTU-l0lEZJUk.js +0 -1
  93. package/dist/web/assets/railroad-ebnf-LZEXJU2U-BFnlL3ld.js +0 -1
  94. package/dist/web/assets/railroad-peg-WCYAUIDC-C6w5ibAf.js +0 -1
  95. package/dist/web/assets/stateDiagram-v2-IH3M54BS-DiskuHBZ.js +0 -1
  96. package/dist/web/assets/swimlanesDiagram-JKAHXJPX-C2Ro4zv7.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-BrZcom_y.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/mermaid.core-He1v95E5.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-oBChb5qS.js","assets/chunk-DU6HZSFF-BtoTQPGb.js","assets/chunk-75Z2AOVW-NtkdG7DW.js","assets/dist-B_J_HbC0.js","assets/chunk-PWAF6VOD-CIaq_ijT.js","assets/chunk-GMAD6QVW-DGB5J2r_.js","assets/chunk-P2QGCYS3-C9zcRDKQ.js","assets/chunk-4HAMMTFA-IuCppxpD.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-GVQU2GXP-C7GvltSz.js","assets/chunk-OSK3NFVY-CnEExzUX.js","assets/line-DKQavTES.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/graphlib-DS17s2tU.js","assets/chunk-L3NEJ4N5-DR-JHG39.js","assets/docxExport-CzFTex-m.js","assets/loadReferencedImage-B4thW94R.js","assets/conversationExport-B1l3iRjL.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-BrZcom_y.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/mermaid.core-BmGW_v8T.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-oBChb5qS.js","assets/chunk-DU6HZSFF-Dy05V--k.js","assets/chunk-75Z2AOVW-1k7HRGrm.js","assets/dist-B_J_HbC0.js","assets/chunk-PWAF6VOD-Dup_NAkl.js","assets/chunk-GMAD6QVW-Bi5Ne8OE.js","assets/chunk-P2QGCYS3-BPor-azX.js","assets/chunk-4HAMMTFA-hiqoLVtf.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-GVQU2GXP-BtSmWzHA.js","assets/chunk-OSK3NFVY-S95igUko.js","assets/line-CuEhAU65.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/graphlib-DS17s2tU.js","assets/chunk-L3NEJ4N5-CQSamtuJ.js","assets/docxExport-ErgwApAZ.js","assets/loadReferencedImage-DgHMXQNZ.js","assets/conversationExport-CfUybHMU.js"])))=>i.map(i=>d[i]);
2
2
  import{i as e,n as t,t as n}from"./rolldown-runtime-Dd_uD5pT.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.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.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`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function ee(){}var C={H:null,A:null,T:null,S:null},w=Object.prototype.hasOwnProperty;function T(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function te(e,t){return T(e.type,t,e.props)}function ne(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function re(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ie=/\/+/g;function ae(e,t){return typeof e==`object`&&e&&e.key!=null?re(``+e.key):t.toString(36)}function oe(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(ee,ee):(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 E(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,E(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ae(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(ie,`$&/`)+`/`),E(o,r,i,``,function(e){return e})):o!=null&&(ne(o)&&(o=te(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ie,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ae(a,u),c+=E(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+ae(a,u++),c+=E(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return E(oe(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 se(e,t,n){if(e==null)return e;var r=[],i=0;return E(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ce(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var D=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)},O={map:se,forEach:function(e,t,n){se(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return se(e,function(){t++}),t},toArray:function(e){return se(e,function(e){return e})||[]},only:function(e){if(!ne(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=O,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return C.H.useMemoCache(e)}},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=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!w.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 T(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)w.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 T(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=ne,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ce}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=C.T,n={};C.T=n;try{var r=e(),i=C.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(ee,D)}catch(e){D(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),C.T=t}},e.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},e.use=function(e){return C.H.use(e)},e.useActionState=function(e,t,n){return C.H.useActionState(e,t,n)},e.useCallback=function(e,t){return C.H.useCallback(e,t)},e.useContext=function(e){return C.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return C.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return C.H.useEffect(e,t)},e.useEffectEvent=function(e){return C.H.useEffectEvent(e)},e.useId=function(){return C.H.useId()},e.useImperativeHandle=function(e,t,n){return C.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return C.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return C.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return C.H.useMemo(e,t)},e.useOptimistic=function(e,t){return C.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return C.H.useReducer(e,t,n)},e.useRef=function(e){return C.H.useRef(e)},e.useState=function(e){return C.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return C.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return C.H.useTransition()},e.version=`19.2.8`})),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,ne());else{var t=n(l);t!==null&&ae(x,t.startTime-e)}}}var S=!1,ee=-1,C=5,w=-1;function T(){return g?!0:!(e.unstable_now()-w<C)}function te(){if(g=!1,S){var t=e.unstable_now();w=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(ee),ee=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&T());){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&&ae(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ne():S=!1}}}var ne;if(typeof y==`function`)ne=function(){y(te)};else if(typeof MessageChannel<`u`){var re=new MessageChannel,ie=re.port2;re.port1.onmessage=te,ne=function(){ie.postMessage(null)}}else ne=function(){_(te,0)};function ae(t,n){ee=_(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`):C=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(ee),ee=-1):h=!0,ae(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ne()))),r},e.unstable_shouldYield=T,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`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(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.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 s(e,t,null,r)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.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=l(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=l(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})}}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=l(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=l(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})}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 c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.8`})),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){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n: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}var h=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),ee=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),T=Symbol.for(`react.suspense_list`),te=Symbol.for(`react.memo`),ne=Symbol.for(`react.lazy`),re=Symbol.for(`react.activity`),ie=Symbol.for(`react.memo_cache_sentinel`),ae=Symbol.iterator;function oe(e){return typeof e!=`object`||!e?null:(e=ae&&e[ae]||e[`@@iterator`],typeof e==`function`?e:null)}var E=Symbol.for(`react.client.reference`);function se(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===E?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case w:return`Suspense`;case T:return`SuspenseList`;case re:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case ee:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case te:return t=e.displayName||null,t===null?se(e.type)||`Memo`:t;case ne:t=e._payload,e=e._init;try{return se(e(t))}catch{}}return null}var ce=Array.isArray,D=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,k={pending:!1,data:null,method:null,action:null},le=[],ue=-1;function de(e){return{current:e}}function fe(e){0>ue||(e.current=le[ue],le[ue]=null,ue--)}function A(e,t){ue++,le[ue]=e.current,e.current=t}var pe=de(null),me=de(null),he=de(null),ge=de(null);function _e(e,t){switch(A(he,t),A(me,e),A(pe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?uf(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=uf(t),e=df(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}fe(pe),A(pe,e)}function ve(){fe(pe),fe(me),fe(he)}function ye(e){e.memoizedState!==null&&A(ge,e);var t=pe.current,n=df(t,e.type);t!==n&&(A(me,e),A(pe,n))}function be(e){me.current===e&&(fe(pe),fe(me)),ge.current===e&&(fe(ge),bp._currentValue=k)}var xe,Se;function Ce(e){if(xe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);xe=t&&t[1]||``,Se=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+xe+e+Se}var we=!1;function Te(e,t){if(!e||we)return``;we=!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}e.call(n.prototype)}}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(`
@@ -13,11 +13,11 @@ Error generating stack: `+e.message+`
13
13
 
14
14
  `)?-1:i}function te(e){if(!e.includes(`\\(`)&&!e.includes(`\\[`)&&!e.includes(`\\)`)&&!e.includes(`\\]`))return e;let t=[],n=0;for(;n<e.length;){if(e.startsWith("```",n)){let r=e.indexOf("```",n+3);if(r===-1){t.push(e.slice(n));break}t.push(e.slice(n,r+3)),n=r+3;continue}if(e[n]==="`"){let r=e.indexOf("`",n+1);if(r!==-1&&!e.slice(n+1,r).includes(`
15
15
  `)){t.push(e.slice(n,r+1)),n=r+1;continue}}if(e.startsWith(`\\[`,n)){let r=e.indexOf(`\\]`,n+2);if(r!==-1){t.push(`$$`,e.slice(n+2,r),`$$`),n=r+2;continue}let i=T(e,n+2,`$$`,`\\[`);if(i!==-1){t.push(`$$`,e.slice(n+2,i),`$$`),n=i+2;continue}}if(e.startsWith(`\\(`,n)){let r=e.indexOf(`\\)`,n+2);if(r!==-1){t.push(`$`,e.slice(n+2,r),`$`),n=r+2;continue}let i=T(e,n+2,`$`,`\\(`);if(i!==-1){t.push(`$`,e.slice(n+2,i),`$`),n=i+1;continue}}if(e.startsWith(`$$`,n)){let r=T(e,n+2,`\\]`,`\\[`),i=e.indexOf(`$$`,n+2);if(r!==-1&&(i===-1||r<i)){t.push(`$$`,e.slice(n+2,r),`$$`),n=r+2;continue}}if(e[n]===`$`){let r=T(e,n+1,`\\)`,`\\(`),i=e.indexOf(`$`,n+1);if(r!==-1&&(i===-1||r<i)){t.push(`$`,e.slice(n+1,r),`$`),n=r+2;continue}}t.push(e[n]),n++}return t.join(``)}function ne(e){let t=`
16
- … [truncated,`,n=e.includes(t)?e.split(t)[0]:e;try{return JSON.parse(n)}catch{}let r=0,i=-1,a=-1;for(let e=0;e<n.length;e++)if(n[e]===`{`&&r++,n[e]===`}`&&(r--,a=e,r===0)){i=e;break}if(i>0)try{return JSON.parse(n.slice(0,i+1))}catch{return}if(a>0)try{return JSON.parse(n.slice(0,a+1))}catch{return}}function re(e){let t=ne(e);if(typeof t==`string`)return t;if(typeof t!=`object`||!t)return;let n=t.__pi_render;if(n?.text!==void 0&&n.text!==null)return String(n.text)}function ie(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`//`)}function ae(e,t){let n=t.split(/[?#]/)[0],r=n.startsWith(`/`)?n.split(`/`):[...e.split(`/`).slice(0,-1),...n.split(`/`)],i=[];for(let e of r)e!==``&&e!==`.`&&(e===`..`?i.pop():i.push(e));return i.join(`/`)}function oe(e){return/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(e)}function E(e){return/\.pdf$/i.test(e)}function se(e){return/\.(docx|xlsx|pptx)$/i.test(e)}function ce(e,t,n,r){let i=n?`&token=${encodeURIComponent(n)}`:``,a=r===void 0?``:`&v=${encodeURIComponent(String(r))}`;return`${e}/files/raw?path=${encodeURIComponent(t)}${i}${a}`}var D=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),O=n(((e,t)=>{t.exports=D()})),k=O();function le({text:e,className:t,iconOnly:n=!1}){let[r,i]=(0,d.useState)(!1);async function a(){try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)}catch{}}return(0,k.jsx)(`button`,{type:`button`,onClick:a,title:r?`Copied!`:n?`Copy code`:`Copy`,"aria-label":n?r?`Copied`:`Copy code`:void 0,className:t??`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:n?r?`✓`:`⧉`:r?`✓ copied`:`⧉ copy`})}var ue=`modulepreload`,de=function(e){return`/`+e},fe={},A=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=de(t,n),t=s(t),t in fe)return;fe[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:ue,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},pe=null,me={javascript:()=>A(()=>import(`./javascript-8AmHuH5O.js`),[]),typescript:()=>A(()=>import(`./typescript-CxkPLmSc.js`),[]),json:()=>A(()=>import(`./json-PmyKWHmm.js`),[]),xml:()=>A(()=>import(`./xml-COl5yFSC.js`),[]),css:()=>A(()=>import(`./css-D8M8GYaw.js`),[]),scss:()=>A(()=>import(`./scss-gOyOKiXd.js`),[]),bash:()=>A(()=>import(`./bash-LmRjUKlR.js`),[]),python:()=>A(()=>import(`./python-gHmu6VPG.js`),[]),go:()=>A(()=>import(`./go-CYstVVJV.js`),[]),rust:()=>A(()=>import(`./rust-BIKPVoi6.js`),[]),java:()=>A(()=>import(`./java-Dde-Wnb4.js`),[]),c:()=>A(()=>import(`./c-DBVbJFpC.js`),[]),cpp:()=>A(()=>import(`./cpp-N2d8M7Nc.js`),[]),csharp:()=>A(()=>import(`./csharp-yYt0Ikks.js`),[]),ruby:()=>A(()=>import(`./ruby-BGpZ3p4_.js`),[]),php:()=>A(()=>import(`./php-DuZl5e-L.js`),[]),sql:()=>A(()=>import(`./sql-DWRKyvJ-.js`),[]),yaml:()=>A(()=>import(`./yaml-DjOhhVLG.js`),[]),ini:()=>A(()=>import(`./ini-B1CroMsf.js`),[]),dockerfile:()=>A(()=>import(`./dockerfile-C0zufGsU.js`),[]),markdown:()=>A(()=>import(`./markdown-D6FrnlqJ.js`),[]),plaintext:()=>A(()=>import(`./plaintext-YB8mb-y7.js`),[])};async function he(){return pe||=(async()=>{let{default:e}=await A(async()=>{let{default:e}=await import(`./core-BrZcom_y.js`);return{default:e}},__vite__mapDeps([0,1]));return await Promise.all(Object.entries(me).map(async([t,n])=>{let r=await n();e.registerLanguage(t,r.default)})),e})(),pe}var ge={ts:`typescript`,tsx:`typescript`,mts:`typescript`,cts:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,html:`xml`,htm:`xml`,xml:`xml`,svg:`xml`,css:`css`,scss:`scss`,sh:`bash`,bash:`bash`,zsh:`bash`,py:`python`,go:`go`,rs:`rust`,java:`java`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,hpp:`cpp`,cs:`csharp`,rb:`ruby`,php:`php`,sql:`sql`,yaml:`yaml`,yml:`yaml`,ini:`ini`,toml:`ini`,dockerfile:`dockerfile`,md:`markdown`,markdown:`markdown`};function _e(e){let t=e.split(`/`).pop()??e;if(/^dockerfile$/i.test(t))return`dockerfile`;let n=t.lastIndexOf(`.`);if(!(n<0))return ge[t.slice(n+1).toLowerCase()]}var ve=(0,d.memo)(function({code:e,path:t,onRendered:n}){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(e);a.current=e;let o=(0,d.useRef)(n);return o.current=n,(0,d.useEffect)(()=>{let e=!1;return i(null),he().then(n=>{if(e)return;let r=_e(t),s=r&&n.getLanguage(r)?n.highlight(a.current,{language:r}):n.highlightAuto(a.current);i(s.value),o.current?.()}),()=>{e=!0}},[e,t]),r===null?(0,k.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,children:e}):(0,k.jsx)(`pre`,{className:`hljs whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,dangerouslySetInnerHTML:{__html:r}})}),ye=c();function be(e){if(e==null)return;if(!(e.getRootNode()instanceof ShadowRoot))return globalThis.document.body;let t=e;for(;t.parentElement!==null;)t=t.parentElement;return t}function xe({label:e,open:t,onClose:n,children:r,actions:i,containerRef:a,anchorRef:o,testId:s=`structured-enlarged`}){(0,d.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,n]);let c=(0,d.useRef)(void 0);return c.current=be(o?.current)??c.current,t?(0,ye.createPortal)((0,k.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`${e}, full size`,"data-testid":s,onClick:n,className:`fixed inset-0 z-[100] flex items-center justify-center overflow-auto bg-black/60 p-6`,children:(0,k.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`max-h-full w-auto max-w-[95vw] overflow-auto rounded-lg bg-white p-4 shadow-xl dark:bg-zinc-900`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-4`,children:[(0,k.jsx)(`span`,{className:`text-xs text-zinc-500`,children:e}),(0,k.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i,(0,k.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close`,className:`rounded px-2 py-0.5 text-xs text-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:`✕`})]})]}),(0,k.jsx)(`div`,{ref:a,className:`[&_svg]:!max-w-none`,children:r})]})}),c.current??globalThis.document.body):null}var Se=.8;function Ce(e){return e===`landscape`?`portrait`:`landscape`}function we(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||e<=710?`landscape`:t<=e*Se?`portrait`:`landscape`}var Te=[`LR`,`RL`];function Ee(e){return Te.includes(e)?`landscape`:`portrait`}function De(e){switch(e){case`LR`:return`TB`;case`TB`:return`LR`;case`RL`:return`BT`;case`BT`:return`RL`}}function Oe(e){let t=e.toUpperCase();return t===`TD`?`TB`:t===`TB`||t===`BT`||t===`LR`||t===`RL`?t:void 0}function ke(e){let t=0;if(e[0]?.trim()===`---`){let n=e.findIndex((e,t)=>t>0&&e.trim()===`---`);if(n===-1)return-1;t=n+1}for(;t<e.length;t+=1){let n=e[t].trim();if(!(n===``||n.startsWith(`%%`)))return t}return-1}function Ae(e){let t=e.split(`
16
+ … [truncated,`,n=e.includes(t)?e.split(t)[0]:e;try{return JSON.parse(n)}catch{}let r=0,i=-1,a=-1;for(let e=0;e<n.length;e++)if(n[e]===`{`&&r++,n[e]===`}`&&(r--,a=e,r===0)){i=e;break}if(i>0)try{return JSON.parse(n.slice(0,i+1))}catch{return}if(a>0)try{return JSON.parse(n.slice(0,a+1))}catch{return}}function re(e){let t=ne(e);if(typeof t==`string`)return t;if(typeof t!=`object`||!t)return;let n=t.__pi_render;if(n?.text!==void 0&&n.text!==null)return String(n.text)}function ie(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`//`)}function ae(e,t){let n=t.split(/[?#]/)[0],r=n.startsWith(`/`)?n.split(`/`):[...e.split(`/`).slice(0,-1),...n.split(`/`)],i=[];for(let e of r)e!==``&&e!==`.`&&(e===`..`?i.pop():i.push(e));return i.join(`/`)}function oe(e){return/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(e)}function E(e){return/\.pdf$/i.test(e)}function se(e){return/\.(docx|xlsx|pptx|msg|eml|emlx)$/i.test(e)}function ce(e,t,n,r){let i=n?`&token=${encodeURIComponent(n)}`:``,a=r===void 0?``:`&v=${encodeURIComponent(String(r))}`;return`${e}/files/raw?path=${encodeURIComponent(t)}${i}${a}`}var D=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),O=n(((e,t)=>{t.exports=D()})),k=O();function le({text:e,className:t,iconOnly:n=!1}){let[r,i]=(0,d.useState)(!1);async function a(){try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)}catch{}}return(0,k.jsx)(`button`,{type:`button`,onClick:a,title:r?`Copied!`:n?`Copy code`:`Copy`,"aria-label":n?r?`Copied`:`Copy code`:void 0,className:t??`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:n?r?`✓`:`⧉`:r?`✓ copied`:`⧉ copy`})}var ue=`modulepreload`,de=function(e){return`/`+e},fe={},A=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=de(t,n),t=s(t),t in fe)return;fe[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:ue,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},pe=null,me={javascript:()=>A(()=>import(`./javascript-8AmHuH5O.js`),[]),typescript:()=>A(()=>import(`./typescript-CxkPLmSc.js`),[]),json:()=>A(()=>import(`./json-PmyKWHmm.js`),[]),xml:()=>A(()=>import(`./xml-COl5yFSC.js`),[]),css:()=>A(()=>import(`./css-D8M8GYaw.js`),[]),scss:()=>A(()=>import(`./scss-gOyOKiXd.js`),[]),bash:()=>A(()=>import(`./bash-LmRjUKlR.js`),[]),python:()=>A(()=>import(`./python-gHmu6VPG.js`),[]),go:()=>A(()=>import(`./go-CYstVVJV.js`),[]),rust:()=>A(()=>import(`./rust-BIKPVoi6.js`),[]),java:()=>A(()=>import(`./java-Dde-Wnb4.js`),[]),c:()=>A(()=>import(`./c-DBVbJFpC.js`),[]),cpp:()=>A(()=>import(`./cpp-N2d8M7Nc.js`),[]),csharp:()=>A(()=>import(`./csharp-yYt0Ikks.js`),[]),ruby:()=>A(()=>import(`./ruby-BGpZ3p4_.js`),[]),php:()=>A(()=>import(`./php-DuZl5e-L.js`),[]),sql:()=>A(()=>import(`./sql-DWRKyvJ-.js`),[]),yaml:()=>A(()=>import(`./yaml-DjOhhVLG.js`),[]),ini:()=>A(()=>import(`./ini-B1CroMsf.js`),[]),dockerfile:()=>A(()=>import(`./dockerfile-C0zufGsU.js`),[]),markdown:()=>A(()=>import(`./markdown-D6FrnlqJ.js`),[]),plaintext:()=>A(()=>import(`./plaintext-YB8mb-y7.js`),[])};async function he(){return pe||=(async()=>{let{default:e}=await A(async()=>{let{default:e}=await import(`./core-BrZcom_y.js`);return{default:e}},__vite__mapDeps([0,1]));return await Promise.all(Object.entries(me).map(async([t,n])=>{let r=await n();e.registerLanguage(t,r.default)})),e})(),pe}var ge={ts:`typescript`,tsx:`typescript`,mts:`typescript`,cts:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,html:`xml`,htm:`xml`,xml:`xml`,svg:`xml`,css:`css`,scss:`scss`,sh:`bash`,bash:`bash`,zsh:`bash`,py:`python`,go:`go`,rs:`rust`,java:`java`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,hpp:`cpp`,cs:`csharp`,rb:`ruby`,php:`php`,sql:`sql`,yaml:`yaml`,yml:`yaml`,ini:`ini`,toml:`ini`,dockerfile:`dockerfile`,md:`markdown`,markdown:`markdown`};function _e(e){let t=e.split(`/`).pop()??e;if(/^dockerfile$/i.test(t))return`dockerfile`;let n=t.lastIndexOf(`.`);if(!(n<0))return ge[t.slice(n+1).toLowerCase()]}var ve=(0,d.memo)(function({code:e,path:t,onRendered:n}){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(e);a.current=e;let o=(0,d.useRef)(n);return o.current=n,(0,d.useEffect)(()=>{let e=!1;return i(null),he().then(n=>{if(e)return;let r=_e(t),s=r&&n.getLanguage(r)?n.highlight(a.current,{language:r}):n.highlightAuto(a.current);i(s.value),o.current?.()}),()=>{e=!0}},[e,t]),r===null?(0,k.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,children:e}):(0,k.jsx)(`pre`,{className:`hljs whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,dangerouslySetInnerHTML:{__html:r}})}),ye=c();function be(e){if(e==null)return;if(!(e.getRootNode()instanceof ShadowRoot))return globalThis.document.body;let t=e;for(;t.parentElement!==null;)t=t.parentElement;return t}function xe({label:e,open:t,onClose:n,children:r,actions:i,containerRef:a,anchorRef:o,testId:s=`structured-enlarged`}){(0,d.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,n]);let c=(0,d.useRef)(void 0);return c.current=be(o?.current)??c.current,t?(0,ye.createPortal)((0,k.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`${e}, full size`,"data-testid":s,onClick:n,className:`fixed inset-0 z-[100] flex items-center justify-center overflow-auto bg-black/60 p-6`,children:(0,k.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`max-h-full w-auto max-w-[95vw] overflow-auto rounded-lg bg-white p-4 shadow-xl dark:bg-zinc-900`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-4`,children:[(0,k.jsx)(`span`,{className:`text-xs text-zinc-500`,children:e}),(0,k.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i,(0,k.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close`,className:`rounded px-2 py-0.5 text-xs text-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:`✕`})]})]}),(0,k.jsx)(`div`,{ref:a,className:`[&_svg]:!max-w-none`,children:r})]})}),c.current??globalThis.document.body):null}var Se=.8;function Ce(e){return e===`landscape`?`portrait`:`landscape`}function we(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||e<=710?`landscape`:t<=e*Se?`portrait`:`landscape`}var Te=[`LR`,`RL`];function Ee(e){return Te.includes(e)?`landscape`:`portrait`}function De(e){switch(e){case`LR`:return`TB`;case`TB`:return`LR`;case`RL`:return`BT`;case`BT`:return`RL`}}function Oe(e){let t=e.toUpperCase();return t===`TD`?`TB`:t===`TB`||t===`BT`||t===`LR`||t===`RL`?t:void 0}function ke(e){let t=0;if(e[0]?.trim()===`---`){let n=e.findIndex((e,t)=>t>0&&e.trim()===`---`);if(n===-1)return-1;t=n+1}for(;t<e.length;t+=1){let n=e[t].trim();if(!(n===``||n.startsWith(`%%`)))return t}return-1}function Ae(e){let t=e.split(`
17
17
  `),n=ke(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`:Oe(a),c=De(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 je(t,n,a[1])}function je(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=Oe(i[1]),a=[...e];return a[n]=t.replace(/(direction\s+)(TD|TB|BT|LR|RL)/i,`$1${De(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 Me=Promise.resolve();function Ne(e){let t=Me.then(e,e);return Me=t.then(()=>void 0,()=>void 0),t}var Pe=null;async function Fe(e){let t=await(Pe??=A(()=>import(`./mermaid.core-He1v95E5.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])));return t.default.initialize({startOnLoad:!1,theme:e,securityLevel:`strict`,suppressErrorRendering:!0}),t}function Ie(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 Le(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 Re(e){let t=Le(e,`mermaid`);return t===null?null:t.trim()}function ze(e){let{children:t,...n}=e,r=Re(t);if(r!==null)return(0,k.jsx)(Be,{code:r});let i=Le(t);return i===null?(0,k.jsx)(`pre`,{...n,children:t}):(0,k.jsxs)(`div`,{className:`code-block relative`,"data-testid":`code-block`,children:[(0,k.jsx)(`pre`,{...n,children:t}),(0,k.jsx)(le,{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 Be({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=(0,d.useMemo)(()=>Ae(e),[e]),p=f===void 0?`landscape`:Ee(f.direction),[h,g]=(0,d.useState)(void 0),_=r?.svg??null,v=r!==null&&r.orientation!==p,y=(0,d.useRef)(null),b=(0,d.useRef)(e);return b.current=e,(0,d.useEffect)(()=>{let e=!1,r=setTimeout(()=>void Ne(async()=>{try{let r=(await Fe(n)).default,a=b.current,s=Ae(a),c=s===void 0?`landscape`:Ee(s.direction);if(h!==void 0&&s!==void 0){let n=h===c?a:s.turned,{svg:l}=await r.render(`mermaid-${t}`,n);e||(i({svg:l,orientation:h}),o(null));return}let l=await r.render(`mermaid-${t}`,a),u={svg:l.svg,orientation:c},d=Ie(l.svg);if(s!==void 0&&d!==void 0&&d>710){let e=await r.render(`mermaid-${t}-turned`,s.turned),n=Ie(e.svg);if(n!==void 0){let t=c===`landscape`?we(d,n):we(n,d);t!==c&&(u={svg:e.svg,orientation:t})}}e||(i(u),o(null))}catch(t){e||o(t instanceof Error?t.message:String(t))}}),300);return()=>{e=!0,clearTimeout(r)}},[e,t,n,h]),_?(0,k.jsxs)(`div`,{ref:y,className:`group relative my-2 rounded-lg border border-zinc-200 bg-zinc-50 p-3 dark:border-zinc-800 dark:bg-zinc-900`,children:[(0,k.jsx)(`div`,{className:`absolute left-2 top-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,k.jsx)(`button`,{type:`button`,onClick:()=>c(!s),title:s?`Show diagram`:`Show code`,className:`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:s?`⚏ diagram`:`⌗ code`})}),(0,k.jsxs)(`div`,{className:`absolute right-2 top-2 z-10 flex items-center gap-2 opacity-0 transition-opacity group-hover:opacity-100`,children:[!s&&f!==void 0&&r!==null&&(0,k.jsx)(`button`,{type:`button`,"data-testid":`mermaid-orientation`,onClick:()=>g(e=>Ce(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 ${Ce(r.orientation)}`,className:`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:r.orientation===`portrait`?`↔ landscape`:`↕ portrait`}),!s&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>u(!0),"aria-label":`Show diagram at full size`,className:`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:`⤢ enlarge`}),(0,k.jsx)(le,{text:e})]}),s?(0,k.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,k.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:_}}),v&&!s&&(0,k.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 `,p]}),(0,k.jsx)(xe,{label:`diagram`,testId:`mermaid-enlarged`,open:l,onClose:()=>u(!1),anchorRef:y,children:(0,k.jsx)(`div`,{style:{width:Ie(_)},className:`[&_svg]:!h-auto [&_svg]:!max-w-none [&_svg]:!w-full`,dangerouslySetInnerHTML:{__html:_}})})]}):(0,k.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,k.jsx)(`div`,{className:`mt-2 text-red-600 dark:text-red-400`,children:a})]})}function Ve({html:e,className:t=``,as:n=`div`}){return(0,k.jsx)(n,{className:`rendered-ansi overflow-x-auto font-mono text-xs leading-relaxed [&_span]:whitespace-pre-wrap ${t}`,dangerouslySetInnerHTML:{__html:e}})}function He({lines:e,fill:t=!1}){return(0,k.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:C(ee(e)).map((e,t)=>e===null?(0,k.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,k.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,k.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,k.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 Ue({lines:e}){return(0,k.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800`,children:w(e).map((e,t)=>e===null?(0,k.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,k.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 We({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();if(!(!t||!e.entryId||!a)){if(a===e.text){i(null);return}n(e.entryId,a,e.images),i(null)}}return(0,k.jsxs)(`div`,{className:`group ml-auto flex max-w-[85%] items-start gap-1.5`,children:[o&&!s&&(0,k.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,k.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,k.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:e.images.map((e,t)=>(0,k.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-48 max-w-full rounded-lg object-contain`},t))}),s?(0,k.jsxs)(`div`,{children:[(0,k.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(`
20
+ `)}}var Me=Promise.resolve();function Ne(e){let t=Me.then(e,e);return Me=t.then(()=>void 0,()=>void 0),t}var Pe=null;async function Fe(e){let t=await(Pe??=A(()=>import(`./mermaid.core-BmGW_v8T.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])));return t.default.initialize({startOnLoad:!1,theme:e,securityLevel:`strict`,suppressErrorRendering:!0}),t}function Ie(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 Le(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 Re(e){let t=Le(e,`mermaid`);return t===null?null:t.trim()}function ze(e){let{children:t,...n}=e,r=Re(t);if(r!==null)return(0,k.jsx)(Be,{code:r});let i=Le(t);return i===null?(0,k.jsx)(`pre`,{...n,children:t}):(0,k.jsxs)(`div`,{className:`code-block relative`,"data-testid":`code-block`,children:[(0,k.jsx)(`pre`,{...n,children:t}),(0,k.jsx)(le,{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 Be({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=(0,d.useMemo)(()=>Ae(e),[e]),p=f===void 0?`landscape`:Ee(f.direction),[h,g]=(0,d.useState)(void 0),_=r?.svg??null,v=r!==null&&r.orientation!==p,y=(0,d.useRef)(null),b=(0,d.useRef)(e);return b.current=e,(0,d.useEffect)(()=>{let e=!1,r=setTimeout(()=>void Ne(async()=>{try{let r=(await Fe(n)).default,a=b.current,s=Ae(a),c=s===void 0?`landscape`:Ee(s.direction);if(h!==void 0&&s!==void 0){let n=h===c?a:s.turned,{svg:l}=await r.render(`mermaid-${t}`,n);e||(i({svg:l,orientation:h}),o(null));return}let l=await r.render(`mermaid-${t}`,a),u={svg:l.svg,orientation:c},d=Ie(l.svg);if(s!==void 0&&d!==void 0&&d>710){let e=await r.render(`mermaid-${t}-turned`,s.turned),n=Ie(e.svg);if(n!==void 0){let t=c===`landscape`?we(d,n):we(n,d);t!==c&&(u={svg:e.svg,orientation:t})}}e||(i(u),o(null))}catch(t){e||o(t instanceof Error?t.message:String(t))}}),300);return()=>{e=!0,clearTimeout(r)}},[e,t,n,h]),_?(0,k.jsxs)(`div`,{ref:y,className:`group relative my-2 rounded-lg border border-zinc-200 bg-zinc-50 p-3 dark:border-zinc-800 dark:bg-zinc-900`,children:[(0,k.jsx)(`div`,{className:`absolute left-2 top-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,k.jsx)(`button`,{type:`button`,onClick:()=>c(!s),title:s?`Show diagram`:`Show code`,className:`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:s?`⚏ diagram`:`⌗ code`})}),(0,k.jsxs)(`div`,{className:`absolute right-2 top-2 z-10 flex items-center gap-2 opacity-0 transition-opacity group-hover:opacity-100`,children:[!s&&f!==void 0&&r!==null&&(0,k.jsx)(`button`,{type:`button`,"data-testid":`mermaid-orientation`,onClick:()=>g(e=>Ce(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 ${Ce(r.orientation)}`,className:`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:r.orientation===`portrait`?`↔ landscape`:`↕ portrait`}),!s&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>u(!0),"aria-label":`Show diagram at full size`,className:`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:`⤢ enlarge`}),(0,k.jsx)(le,{text:e})]}),s?(0,k.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,k.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:_}}),v&&!s&&(0,k.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 `,p]}),(0,k.jsx)(xe,{label:`diagram`,testId:`mermaid-enlarged`,open:l,onClose:()=>u(!1),anchorRef:y,children:(0,k.jsx)(`div`,{style:{width:Ie(_)},className:`[&_svg]:!h-auto [&_svg]:!max-w-none [&_svg]:!w-full`,dangerouslySetInnerHTML:{__html:_}})})]}):(0,k.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,k.jsx)(`div`,{className:`mt-2 text-red-600 dark:text-red-400`,children:a})]})}function Ve({html:e,className:t=``,as:n=`div`}){return(0,k.jsx)(n,{className:`rendered-ansi overflow-x-auto font-mono text-xs leading-relaxed [&_span]:whitespace-pre-wrap ${t}`,dangerouslySetInnerHTML:{__html:e}})}function He({lines:e,fill:t=!1}){return(0,k.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:C(ee(e)).map((e,t)=>e===null?(0,k.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,k.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,k.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,k.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 Ue({lines:e}){return(0,k.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800`,children:w(e).map((e,t)=>e===null?(0,k.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,k.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 We({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();if(!(!t||!e.entryId||!a)){if(a===e.text){i(null);return}n(e.entryId,a,e.images),i(null)}}return(0,k.jsxs)(`div`,{className:`group ml-auto flex max-w-[85%] items-start gap-1.5`,children:[o&&!s&&(0,k.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,k.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,k.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:e.images.map((e,t)=>(0,k.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-48 max-w-full rounded-lg object-contain`},t))}),s?(0,k.jsxs)(`div`,{children:[(0,k.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,k.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2 text-xs`,children:[(0,k.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,k.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,k.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,k.jsx)(`div`,{className:`whitespace-pre-wrap`,children:e.text})]})]})}var Ge=`urn:structured-exchange:1`,Ke=[`graph`,`sequence`];function qe(e){return e===`urn:structured-exchange:2`?[`graph`,`sequence`,`table`]:Ke}function Je(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 Ye={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},Xe=`urn:structured-exchange:2`,Ze={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},Qe=8e6,$e=[Ge,Xe];function et(e){return $e.find(t=>t===e)}var tt=4e6,nt=Math.max(tt,Qe);function rt(e){return e===`urn:structured-exchange:2`?Qe:tt}var it=e=>new TextEncoder().encode(e).length;function at(e){return e===`bytes`?nt:e===`relations`?Ze.relations:Ye[e]}function ot(e,t){let n=at(e),r=t?.[e];return r===void 0||r>=n?{limit:n,level:`ceiling`}:{limit:r,level:`deployment`}}function st(e,t,n){let r=it(e),i=ot(`bytes`,t),a=n===void 0?1/0:rt(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 ct={graph:[`nodes`,`edges`],sequence:[`participants`,`messages`],table:[`columns`,`rows`,`relations`]};function lt(e,t){if(t===void 0)return[];let n=[];for(let r of ct[e.kind]??[]){let i=e.data[r];if(!Array.isArray(i))continue;let{limit:a,level:o}=ot(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 ut(e,t){let n={};for(let t of ct[e.kind]??[]){let r=e.data[t];Array.isArray(r)&&(n[t]=r.length)}return{kind:e.kind,bytes:it(t),counts:n}}function dt(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):Array.isArray(t.columns)&&Array.isArray(t.rows)}function ft(e){return e.kind===`graph`?e.data.nodes:e.kind===`sequence`?e.data.participants:[]}function pt(e){return e.kind===`graph`?e.data.edges:e.kind===`sequence`?e.data.messages:[]}function mt(e){return e.kind===`graph`||e.kind===`sequence`?e.data.containers??[]:[]}function ht(e){return e.kind===`graph`?`/data/nodes`:`/data/participants`}function gt(e){return e.kind===`graph`?`/data/edges`:`/data/messages`}function _t(e){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 vt(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 yt(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 bt(e){if(e.kind!==`table`)return[];let t=e.data.relations;return Array.isArray(t)?t:[]}function xt(e){let t=[];if(!dt(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:`a ${e.kind} is a projection and cannot be proposed, 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:`a ${e.kind} is a projection and cannot be proposed, so it declares no removals`}));let r=ft(e),i=ht(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;mt(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=gt(e);pt(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}`)),pt(e).forEach((e,t)=>l(`relationship`,e.ref,`${s}/${t}`)),vt(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})),...pt(e).map((t,n)=>({at:`${gt(e)}/${n}`,ref:t.ref,set:t.set})),...vt(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:`a ${e.kind} is a projection and cannot be proposed, 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`,gt(e),d(pt(e))]];for(let[e,n,r]of f)r.size>Ye.kindsPerVocabulary&&t.push({rule:`too-many-kinds`,path:n,message:`${r.size} distinct ${e} types, and no more than ${Ye.kindsPerVocabulary} can be told apart in a rendering`,observed:r.size,limit:Ye.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(pt(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}=Je(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})})}for(let n of _t(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 yt(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 bt(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 St(e,t){let n=t(e);if(n.length>0)return{valid:!1,issues:n};let r=e,i=xt(r);return i.length>0?{valid:!1,issues:i}:{valid:!0,envelope:r,issues:[]}}function Ct(e,t,n){let r=st(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=St(i,t);if(!a.valid)return a;let o=st(e,n,a.envelope.schema);if(o!==void 0)return{valid:!1,issues:[o]};let s=lt(a.envelope,n);return s.length>0?{valid:!1,issues:s}:{valid:!0,envelope:a.envelope,measurement:ut(a.envelope,e),issues:[]}}function wt(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 Tt(e,t,n){let r=st(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=wt(i);if(a===void 0)return{status:`not-a-document`,why:`undeclared`};if(et(a)===void 0)return{status:`unsupported-version`,schema:a};let o=St(i,t);if(!o.valid)return{status:`invalid`,issues:o.issues};let s=st(e,n,o.envelope.schema);return s===void 0?{status:`valid`,envelope:o.envelope}:{status:`too-large`,issue:s}}function Et(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)}`}function Dt(e,t,n){return e>=t&&e<=n}function Ot(e){return e===8205}function kt(e){return Dt(e,55296,56319)}function At(e){return Dt(e,127462,127487)}function jt(e){return Dt(e,65024,65039)}function Mt(e){return Dt(e,768,879)||Dt(e,6832,6911)||Dt(e,7616,7679)||Dt(e,65056,65071)}function Nt(e){return e>65535?2:1}function Pt(e,t){for(;t<e.length;){let n=e.codePointAt(t);if(Mt(n)||jt(n))t+=Nt(n);else break}return t}function Ft(e,t){let n=e.codePointAt(t),r=t+Nt(n);for(r=Pt(e,r);r<e.length-1&&Ot(e.codePointAt(r));){let t=e.codePointAt(r+1);r+=1+Nt(t),r=Pt(e,r)}return At(n)&&r<e.length&&At(e.codePointAt(r))&&(r+=Nt(e.codePointAt(r))),r}function It(e){return kt(e)||Mt(e)||jt(e)||Ot(e)}function Lt(e,t){if(t===0)return!0;let n=0,r=0;for(;r<e.length;)if(r=Ft(e,r),n++,n>=t)return!0;return!1}function Rt(e,t){let n=0,r=0;for(;r<e.length;)if(r=Ft(e,r),n++,n>t)return!1;return!0}function zt(e,t){if(t===0)return!0;let n=0;for(;n<e.length;){if(It(e.charCodeAt(n)))return Lt(e,t);if(n++,n>=t)return!0}return!1}function Bt(e,t){let n=0;for(;n<e.length;){if(It(e.charCodeAt(n)))return Rt(e,t);if(n++,n>t)return!1}return!0}function Vt(e){return Array.isArray(e)}function Ht(e){return Zt(typeof e,`bigint`)}function Ut(e){return Zt(typeof e,`boolean`)}function Wt(e){if(Xt(e)||!Gt(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function Gt(e){return Zt(typeof e,`function`)}function Kt(e){return Zt(e,null)}function qt(e){return Zt(typeof e,`object`)&&!Kt(e)}function Jt(e){return Zt(typeof e,`string`)}function Yt(e){return Zt(typeof e,`symbol`)}function Xt(e){return Zt(e,void 0)}function Zt(e,t){return e===t}function Qt(e,t){return Bt(e,t)}function $t(e,t){return zt(e,t)}function en(e){return e instanceof Boolean}function tn(e){return e instanceof Number}function nn(e){return e instanceof String}function rn(e){return globalThis.ArrayBuffer.isView(e)}function an(e){return e instanceof globalThis.RegExp}function on(e){return e instanceof globalThis.Date}var sn=[];function cn(e){sn=e.variables}var ln=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`schema`in e&&`kind`in e&&`data`in e&&Object.getOwnPropertyNames(e).every((e,t)=>sn[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)||un(e.target))&&(e.removals===void 0||!(`removals`in e)||Array.isArray(e.removals)&&e.removals.every((e,t)=>dn(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)=>sn[2].test(e)||!1)&&Array.isArray(e.data.nodes)&&e.data.nodes.every((e,t)=>hn(e))&&e.data.nodes.length<=500&&e.data.nodes.length>=1&&Array.isArray(e.data.edges)&&e.data.edges.every((e,t)=>_n(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)=>yn(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)=>sn[8].test(e)||!1)&&Array.isArray(e.data.participants)&&e.data.participants.every((e,t)=>hn(e))&&e.data.participants.length<=100&&e.data.participants.length>=1&&Array.isArray(e.data.messages)&&e.data.messages.every((e,t)=>bn(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)=>yn(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`&&Qt(e,200)&&$t(e,1))&&e.data.columns.length<=50&&e.data.columns.length>=1&&Array.isArray(e.data.rows)&&e.data.rows.every((e,t)=>[Sn(e),typeof e==`object`&&!!e&&!Array.isArray(e)&&`cells`in e&&Object.getOwnPropertyNames(e).every((e,t)=>sn[11].test(e)||!1)&&Sn(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),un=(e=>typeof e==`string`&&Qt(e,200)&&$t(e,1)),dn=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`ref`in e&&Object.getOwnPropertyNames(e).every((e,t)=>sn[1].test(e)||!1)&&(e.type===`element`||e.type===`relationship`)&&un(e.ref)&&(e.label===void 0||!(`label`in e)||fn(e.label))&&(e.kind===void 0||!(`kind`in e)||pn(e.kind))&&(e.from===void 0||!(`from`in e)||mn(e.from))&&(e.to===void 0||!(`to`in e)||mn(e.to))),fn=(e=>typeof e==`string`&&Qt(e,500)),pn=(e=>typeof e==`string`&&Qt(e,100)&&$t(e,1)),mn=(e=>typeof e==`string`&&Qt(e,200)&&$t(e,1)),hn=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&Object.getOwnPropertyNames(e).every((e,t)=>sn[3].test(e)||!1)&&mn(e.id)&&(e.ref===void 0||!(`ref`in e)||un(e.ref))&&(e.label===void 0||!(`label`in e)||fn(e.label))&&(e.kind===void 0||!(`kind`in e)||pn(e.kind))&&(e.set===void 0||!(`set`in e)||gn(e.set))&&(e.container===void 0||!(`container`in e)||mn(e.container))&&(!(typeof e==`object`&&e&&!Array.isArray(e))||`ref`in e||!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),gn=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>sn[4].test(e)||!1)&&(e.label===void 0||!(`label`in e)||fn(e.label))&&(e.kind===void 0||!(`kind`in e)||pn(e.kind))&&(e.container===void 0||!(`container`in e)||mn(e.container))&&Object.getOwnPropertyNames(e).length>=1),_n=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>sn[5].test(e)||!1)&&mn(e.from)&&mn(e.to)&&(e.kind===void 0||!(`kind`in e)||pn(e.kind))&&(e.ref===void 0||!(`ref`in e)||un(e.ref))&&(e.label===void 0||!(`label`in e)||fn(e.label))&&(e.set===void 0||!(`set`in e)||vn(e.set))&&(!(typeof e==`object`&&e&&!Array.isArray(e))||`ref`in e||!(typeof e==`object`&&e&&!Array.isArray(e))||`kind`in e)),vn=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>sn[6].test(e)||!1)&&(e.kind===void 0||!(`kind`in e)||pn(e.kind))&&(e.label===void 0||!(`label`in e)||fn(e.label))&&Object.getOwnPropertyNames(e).length>=1),yn=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&Object.getOwnPropertyNames(e).every((e,t)=>sn[7].test(e)||!1)&&mn(e.id)&&fn(e.label)&&(e.kind===void 0||!(`kind`in e)||pn(e.kind))),bn=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>sn[9].test(e)||!1)&&mn(e.from)&&mn(e.to)&&(e.ref===void 0||!(`ref`in e)||un(e.ref))&&(e.label===void 0||!(`label`in e)||fn(e.label))&&(e.set===void 0||!(`set`in e)||xn(e.set))&&(!(typeof e==`object`&&e&&!Array.isArray(e))||`ref`in e||!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),xn=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>sn[10].test(e)||!1)&&(e.label===void 0||!(`label`in e)||fn(e.label))&&Object.getOwnPropertyNames(e).length>=1),Sn=(e=>Array.isArray(e)&&e.every((e,t)=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||Qt(e,1e3)))&&e.length<=50);function Cn(e){return ln(e)}cn({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 wn(){throw Error(`Unreachable`)}function Tn(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 En(e){return typeof e==`number`}var Dn;(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`})(Dn||={});var On=BigInt(`14695981039346656037`),[kn,An]=[BigInt(`1099511628211`),BigInt(`18446744073709551616`)],jn=Array.from({length:256}).map((e,t)=>BigInt(t)),Mn=new Float64Array(1),Nn=new DataView(Mn.buffer),Pn=new Uint8Array(Mn.buffer);function Fn(e){On^=jn[e],On=On*kn%An}function In(e){Fn(Dn.Array);for(let t of e)Zn(t)}function Ln(e){Fn(Dn.BigInt),Nn.setBigInt64(0,e);for(let e of Pn)Fn(e)}function Rn(e){Fn(Dn.Boolean),Fn(+!!e)}function zn(e){Fn(Dn.Constructor),Zn(e.toString())}function Bn(e){Fn(Dn.Date),Zn(e.getTime())}function Vn(e){Fn(Dn.Function),Zn(e.toString())}function Hn(e){Fn(Dn.Null)}function Un(e){Fn(Dn.Number),Nn.setFloat64(0,e,!0);for(let e of Pn)Fn(e)}function Wn(e){Fn(Dn.Object);for(let t of Tn(e).sort())Zn(t),Zn(e[t])}function Gn(e){Fn(Dn.RegExp),qn(e.toString())}var Kn=new TextEncoder;function qn(e){Fn(Dn.String);for(let t of Kn.encode(e))Fn(t)}function Jn(e){Fn(Dn.Symbol),Zn(e.toString())}function Yn(e){Fn(Dn.TypeArray);let t=new Uint8Array(e.buffer);for(let e=0;e<t.length;e++)Fn(t[e])}function Xn(e){return Fn(Dn.Undefined)}function Zn(e){return rn(e)?Yn(e):on(e)?Bn(e):an(e)?Gn(e):en(e)?Rn(e.valueOf()):nn(e)?qn(e.valueOf()):tn(e)?Un(e.valueOf()):En(e)?Un(e):Vt(e)?In(e):Ut(e)?Rn(e):Ht(e)?Ln(e):Wt(e)?zn(e):Kt(e)?Hn(e):qt(e)?Wn(e):Jt(e)?qn(e):Yt(e)?Jn(e):Xt(e)?Xn(e):Gt(e)?Vn(e):wn()}function Qn(e){return On=BigInt(`14695981039346656037`),Zn(e),On}function $n(e){return Qn(e).toString(16).padStart(16,`0`)}var er=[];function tr(e){er=e.variables}var nr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`schema`in e&&`kind`in e&&`data`in e&&Object.getOwnPropertyNames(e).every((e,t)=>er[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`&&Qt(e.profile,200)&&$t(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)=>er[1].test(e)||!1)&&rr(e.target.ref)&&(e.target.revision===void 0||!(`revision`in e.target)||ir(e.target.revision)))&&(e.removals===void 0||!(`removals`in e)||Array.isArray(e.removals)&&e.removals.every((e,t)=>ar(e))&&e.removals.length<=500)&&(e.artifacts===void 0||!(`artifacts`in e)||Array.isArray(e.artifacts)&&e.artifacts.every((e,t)=>lr(e))&&e.artifacts.length<=50)&&(e.viewpoints===void 0||!(`viewpoints`in e)||Array.isArray(e.viewpoints)&&e.viewpoints.every((e,t)=>ur(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)=>er[6].test(e)||!1)&&Array.isArray(e.data.nodes)&&e.data.nodes.every((e,t)=>dr(e))&&e.data.nodes.length<=500&&e.data.nodes.length>=1&&Array.isArray(e.data.edges)&&e.data.edges.every((e,t)=>Cr(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)=>Tr(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)=>er[16].test(e)||!1)&&Array.isArray(e.data.participants)&&e.data.participants.every((e,t)=>dr(e))&&e.data.participants.length<=100&&e.data.participants.length>=1&&Array.isArray(e.data.messages)&&e.data.messages.every((e,t)=>Er(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)=>Tr(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)=>er[19].test(e)||!1)&&Array.isArray(e.data.columns)&&e.data.columns.every((e,t)=>typeof e==`string`&&Qt(e,200)&&$t(e,1))&&e.data.columns.length<=50&&e.data.columns.length>=1&&Array.isArray(e.data.rows)&&e.data.rows.every((e,t)=>[Or(e),kr(e),Mr(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)=>Nr(e))&&e.data.relations.length<=2e3)].reduce((e,t,n)=>t===!0?++e:e,0)===1),rr=(e=>typeof e==`string`&&Qt(e,200)&&$t(e,1)),ir=(e=>typeof e==`string`&&Qt(e,200)&&$t(e,1)),ar=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`ref`in e&&Object.getOwnPropertyNames(e).every((e,t)=>er[2].test(e)||!1)&&(e.type===`element`||e.type===`relationship`||e.type===`row`)&&rr(e.ref)&&(e.label===void 0||!(`label`in e)||or(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))),or=(e=>typeof e==`string`&&Qt(e,500)),sr=(e=>typeof e==`string`&&Qt(e,100)&&$t(e,1)),cr=(e=>typeof e==`string`&&Qt(e,200)&&$t(e,1)),lr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`rel`in e&&`uri`in e&&`sha256`in e&&Object.getOwnPropertyNames(e).every((e,t)=>er[3].test(e)||!1)&&typeof e.rel==`string`&&Qt(e.rel,100)&&$t(e.rel,1)&&typeof e.uri==`string`&&Qt(e.uri,2e3)&&$t(e.uri,1)&&typeof e.sha256==`string`&&er[4].test(e.sha256)&&(e.mediaType===void 0||!(`mediaType`in e)||typeof e.mediaType==`string`&&Qt(e.mediaType,100)&&$t(e.mediaType,1))&&(e.label===void 0||!(`label`in e)||or(e.label))),ur=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&`concern`in e&&Object.getOwnPropertyNames(e).every((e,t)=>er[5].test(e)||!1)&&cr(e.id)&&typeof e.label==`string`&&Qt(e.label,500)&&$t(e.label,1)&&typeof e.concern==`string`&&Qt(e.concern,500)&&$t(e.concern,1)&&(e.elementKinds===void 0||!(`elementKinds`in e)||Array.isArray(e.elementKinds)&&e.elementKinds.every((e,t)=>sr(e))&&e.elementKinds.length<=64&&e.elementKinds.length>=1&&new Set(e.elementKinds.map($n)).size===e.elementKinds.length)&&(e.relationshipKinds===void 0||!(`relationshipKinds`in e)||Array.isArray(e.relationshipKinds)&&e.relationshipKinds.every((e,t)=>sr(e))&&e.relationshipKinds.length<=64&&e.relationshipKinds.length>=1&&new Set(e.relationshipKinds.map($n)).size===e.relationshipKinds.length)),dr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&Object.getOwnPropertyNames(e).every((e,t)=>er[7].test(e)||!1)&&cr(e.id)&&(e.ref===void 0||!(`ref`in e)||rr(e.ref))&&(e.label===void 0||!(`label`in e)||or(e.label))&&(e.kind===void 0||!(`kind`in e)||sr(e.kind))&&(e.set===void 0||!(`set`in e)||fr(e.set))&&(e.container===void 0||!(`container`in e)||cr(e.container))&&(e.attributes===void 0||!(`attributes`in e)||pr(e.attributes))&&(e.expect===void 0||!(`expect`in e)||vr(e.expect))&&(e.locations===void 0||!(`locations`in e)||yr(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||Sr(e.artifacts))&&(!(typeof e==`object`&&e&&!Array.isArray(e))||`ref`in e||!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),fr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>er[8].test(e)||!1)&&(e.label===void 0||!(`label`in e)||or(e.label))&&(e.kind===void 0||!(`kind`in e)||sr(e.kind))&&(e.container===void 0||!(`container`in e)||cr(e.container))&&(e.attributes===void 0||!(`attributes`in e)||pr(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||_r(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),pr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((t,n)=>er[9].test(t)||mr(e[t]))&&Object.getOwnPropertyNames(e).every((e,t)=>typeof e!=`string`||Qt(e,200)&&$t(e,1))&&Object.getOwnPropertyNames(e).length<=50),mr=(e=>[hr(e),gr(e),Array.isArray(e)&&e.every((e,t)=>[hr(e),gr(e)].reduce((e,t,n)=>t===!0?++e:e,0)===1)&&e.length<=50].reduce((e,t,n)=>t===!0?++e:e,0)===1),hr=(e=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||Qt(e,1e3))),gr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`ref`in e&&Object.getOwnPropertyNames(e).length===1&&rr(e.ref)),_r=(e=>Array.isArray(e)&&e.every((e,t)=>cr(e))&&e.length<=50),vr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>er[10].test(e)||!1)&&(e.label===void 0||!(`label`in e)||or(e.label))&&(e.kind===void 0||!(`kind`in e)||sr(e.kind))&&(e.container===void 0||!(`container`in e)||cr(e.container))&&(e.revision===void 0||!(`revision`in e)||ir(e.revision))&&(e.attributes===void 0||!(`attributes`in e)||pr(e.attributes))&&Object.getOwnPropertyNames(e).length>=1),yr=(e=>Array.isArray(e)&&e.every((e,t)=>br(e))&&e.length<=10),br=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`uri`in e&&Object.getOwnPropertyNames(e).every((e,t)=>er[11].test(e)||!1)&&typeof e.uri==`string`&&Qt(e.uri,2e3)&&$t(e.uri,1)&&(e.revision===void 0||!(`revision`in e)||ir(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)=>er[12].test(e)||!1)&&xr(e.range.startLine)&&(e.range.startCharacter===void 0||!(`startCharacter`in e.range)||xr(e.range.startCharacter))&&xr(e.range.endLine)&&(e.range.endCharacter===void 0||!(`endCharacter`in e.range)||xr(e.range.endCharacter)))),xr=(e=>Number.isInteger(e)&&(!(Number.isFinite(e)||typeof e==`bigint`)||e<=1e6&&e>=0)),Sr=(e=>Array.isArray(e)&&e.every((e,t)=>lr(e))&&e.length<=20),Cr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>er[13].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)||rr(e.ref))&&(e.label===void 0||!(`label`in e)||or(e.label))&&(e.set===void 0||!(`set`in e)||wr(e.set))&&(e.attributes===void 0||!(`attributes`in e)||pr(e.attributes))&&(e.expect===void 0||!(`expect`in e)||vr(e.expect))&&(e.locations===void 0||!(`locations`in e)||yr(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||Sr(e.artifacts))&&(!(typeof e==`object`&&e&&!Array.isArray(e))||`ref`in e||!(typeof e==`object`&&e&&!Array.isArray(e))||`kind`in e)),wr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>er[14].test(e)||!1)&&(e.kind===void 0||!(`kind`in e)||sr(e.kind))&&(e.label===void 0||!(`label`in e)||or(e.label))&&(e.attributes===void 0||!(`attributes`in e)||pr(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||_r(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Tr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&Object.getOwnPropertyNames(e).every((e,t)=>er[15].test(e)||!1)&&cr(e.id)&&or(e.label)&&(e.kind===void 0||!(`kind`in e)||sr(e.kind))),Er=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>er[17].test(e)||!1)&&cr(e.from)&&cr(e.to)&&(e.ref===void 0||!(`ref`in e)||rr(e.ref))&&(e.label===void 0||!(`label`in e)||or(e.label))&&(e.set===void 0||!(`set`in e)||Dr(e.set))&&(e.attributes===void 0||!(`attributes`in e)||pr(e.attributes))&&(e.expect===void 0||!(`expect`in e)||vr(e.expect))&&(e.locations===void 0||!(`locations`in e)||yr(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||Sr(e.artifacts))&&(!(typeof e==`object`&&e&&!Array.isArray(e))||`ref`in e||!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),Dr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>er[18].test(e)||!1)&&(e.label===void 0||!(`label`in e)||or(e.label))&&(e.attributes===void 0||!(`attributes`in e)||pr(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||_r(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Or=(e=>Array.isArray(e)&&e.every((e,t)=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||Qt(e,1e3)))&&e.length<=50),kr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`cells`in e&&Object.getOwnPropertyNames(e).every((e,t)=>er[20].test(e)||!1)&&Or(e.cells)&&(e.role===void 0||!(`role`in e)||Ar(e.role))&&(e.id===void 0||!(`id`in e)||cr(e.id))&&(e.ref===void 0||!(`ref`in e)||rr(e.ref))&&(e.kind===void 0||!(`kind`in e)||sr(e.kind))&&(e.label===void 0||!(`label`in e)||or(e.label))&&(e.set===void 0||!(`set`in e)||jr(e.set))&&(e.attributes===void 0||!(`attributes`in e)||pr(e.attributes))&&(e.expect===void 0||!(`expect`in e)||vr(e.expect))&&(e.locations===void 0||!(`locations`in e)||yr(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||Sr(e.artifacts))),Ar=(e=>e===`added`||e===`changed`||e===`context`||e===`removed`),jr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>er[21].test(e)||!1)&&(e.label===void 0||!(`label`in e)||or(e.label))&&(e.kind===void 0||!(`kind`in e)||sr(e.kind))&&(e.cells===void 0||!(`cells`in e)||Or(e.cells))&&(e.attributes===void 0||!(`attributes`in e)||pr(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||_r(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Mr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`heading`in e&&Object.getOwnPropertyNames(e).every((e,t)=>er[22].test(e)||!1)&&typeof e.heading==`string`&&Qt(e.heading,500)&&$t(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)||Ar(e.role))&&(e.id===void 0||!(`id`in e)||cr(e.id))&&(e.ref===void 0||!(`ref`in e)||rr(e.ref))),Nr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&`kind`in e&&Object.getOwnPropertyNames(e).every((e,t)=>er[23].test(e)||!1)&&Pr(e.from)&&Pr(e.to)&&sr(e.kind)&&(e.ref===void 0||!(`ref`in e)||rr(e.ref))&&(e.label===void 0||!(`label`in e)||or(e.label))&&(e.attributes===void 0||!(`attributes`in e)||pr(e.attributes))),Pr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>er[24].test(e)||!1)&&(e.id===void 0||!(`id`in e)||cr(e.id))&&(e.ref===void 0||!(`ref`in e)||rr(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 Fr(e){return nr(e)}tr({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 Ir={[Ge]:Cn,[Xe]:Fr},Lr=e=>{let t=wt(e),n=et(t);return n===void 0&&t!==void 0?[{rule:`unsupported-version`,path:`/schema`,message:`this build validates ${$e.join(` and `)}`}]:Ir[n??`urn:structured-exchange:1`](e)?[]:[{rule:`schema/invalid`,path:``,message:`does not conform to the published structured-exchange schema`}]},Rr=Object.defineProperty,zr=(e,t,n)=>t in e?Rr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Br=(e,t)=>{for(var n in t)Rr(e,n,{get:t[n],enumerable:!0})},Vr=(e,t,n)=>zr(e,typeof t==`symbol`?t:t+``,n),Hr={};Br(Hr,{Graph:()=>Di,alg:()=>ti});var Ur=Object.defineProperty,Wr=(e,t)=>{for(var n in t)Ur(e,n,{get:t[n],enumerable:!0})},Gr=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=Jr(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=Yr(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,Kr(this._preds[a],i),Kr(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?Xr(this._isDirected,e):Jr(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?Xr(this._isDirected,e):Jr(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Xr(this._isDirected,e):Jr(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],qr(this._preds[t],e),qr(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 Kr(e,t){e[t]?e[t]++:e[t]=1}function qr(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function Jr(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 Yr(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 Xr(e,t){return Jr(e,t.v,t.w,t.name)}Wr({},{read:()=>ei,write:()=>Zr});function Zr(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Qr(e),edges:$r(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Qr(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 $r(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 ei(e){let t=new Gr(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 ti={};Wr(ti,{CycleException:()=>gi,bellmanFord:()=>ri,components:()=>ai,dijkstra:()=>ci,dijkstraAll:()=>ui,findCycles:()=>fi,floydWarshall:()=>mi,isAcyclic:()=>vi,postorder:()=>Si,preorder:()=>Ci,prim:()=>wi,shortestPaths:()=>Ti,tarjan:()=>di,topsort:()=>_i});var ni=()=>1;function ri(e,t,n,r){return ii(e,String(t),n||ni,r||function(t){return e.outEdges(t)??[]})}function ii(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 ai(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 oi=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}},si=()=>1;function ci(e,t,n,r){return li(e,String(t),n||si,r||function(t){return e.outEdges(t)??[]})}function li(e,t,n,r){let i={},a=new oi,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 ui(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=ci(e,i,t,n),r},{})}function di(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 fi(e){return di(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var pi=()=>1;function mi(e,t,n){return hi(e,t||pi,n||function(t){return e.outEdges(t)??[]})}function hi(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 gi=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function _i(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new gi;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 gi;return r}function vi(e){try{_i(e)}catch(e){if(e instanceof gi)return!1;throw e}return!0}function yi(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=bi(e,t,n===`post`,o,a,r,i)}),i}function bi(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=bi(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function xi(e,t,n){return yi(e,t,n,function(e,t){return e.push(t),e},[])}function Si(e,t){return xi(e,t,`post`)}function Ci(e,t){return xi(e,t,`pre`)}function wi(e,t){var n;let r=new Gr,i={},a=new oi,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 Ti(e,t,n,r){return Ei(e,t,n,r??(t=>e.outEdges(t)??[]))}function Ei(e,t,n,r){if(n===void 0)return ci(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 ri(e,t,n,r)}return ci(e,t,n,r)}var Di=Gr;function Oi(e,t,n,r){let i=r;for(;e.hasNode(i);)i=Wi(r);return n.dummy=t,e.setNode(i,n),i}function ki(e){let t=new Di().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 Ai(e){let t=new Di({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 ji(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 Mi(e){let t=Gi(zi(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 Ni(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=Ri(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function Pi(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=Ri(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 Fi(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),Oi(e,`border`,i,t)}function Ii(e,t=Li){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var Li=65535;function Ri(e,t){return t.length>Li?e(...Ii(t).map(t=>e(...t))):e(...t)}function zi(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return Ri(Math.max,t)}function Bi(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function Vi(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function Hi(e,t){return t()}var Ui=0;function Wi(e){return e+(``+ ++Ui)}function Gi(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 Ki(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function qi(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 Ji(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var Yi=`\0`;function Xi(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 Zi=`3.1.1`,Qi=class{constructor(){Vr(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return $i(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&$i(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,ea)),n=n._prev;return`[`+e.join(`, `)+`]`}};function $i(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function ea(e,t){if(e!==`_next`&&e!==`_prev`)return t}var ta=Qi,na=()=>1;function ra(e,t){if(e.nodeCount()<=1)return[];let n=oa(e,t||na);return ia(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function ia(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)aa(e,t,n,o);for(;o=i.dequeue();)aa(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(aa(e,t,n,o,!0)||[]);break}}}return r}function aa(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,sa(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,sa(t,n,o)}),e.removeNode(r.v),o}function oa(e,t){let n=new Di,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=ca(i+r+3).map(()=>new ta),o=r+1;return n.nodes().forEach(e=>{sa(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function sa(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 ca(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function la(e,t){(e.graph().acyclicer===`greedy`?ra(e,n(e)):ua(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,Wi(`rev`))});function n(e){return t=>e.edge(t).weight}}function ua(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&&fa(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 da(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 fa(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 pa(e){e.graph().dummyChains=[],e.edges().forEach(t=>ma(e,t))}function ma(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;for(d=0,++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=Oi(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 ha(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 ga(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=Ri(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function _a(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var va=ya;function ya(e){let t=new Di({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(;ba(t,e)<i&&(a=xa(t,e),a);)o=t.hasNode(a.v)?_a(e,a):-_a(e,a),Sa(t,e,o);return t}function ba(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)&&!_a(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function xa(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=_a(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function Sa(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:Ca,postorder:wa}=ti,Ta=Ea;Ea.initLowLimValues=Aa,Ea.initCutValues=Da,Ea.calcCutValue=ka,Ea.leaveEdge=Ma,Ea.enterEdge=Na,Ea.exchangeEdges=Pa;function Ea(e){e=ki(e),ga(e);let t=va(e);Aa(t),Da(t,e);let n,r;for(;n=Ma(t);)r=Na(t,e,n),Pa(t,e,n,r)}function Da(e,t){let n=wa(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>Oa(e,t,n))}function Oa(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=ka(e,t,n)}function ka(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,Ia(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function Aa(e,t){arguments.length<2&&(t=e.nodes()[0]),ja(e,{},1,t)}function ja(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=ja(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function Ma(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Na(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===La(e,e.node(t.v),s)&&c!==La(e,e.node(t.w),s)).reduce((e,n)=>_a(t,n)<_a(t,e)?n:e)}function Pa(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),Aa(e),Da(e,t),Fa(e,t)}function Fa(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=Ca(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 Ia(e,t,n){return e.hasEdge(t,n)}function La(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Ra=za;function za(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:Ha(e);break;case`tight-tree`:Va(e);break;case`longest-path`:Ba(e);break;case`none`:break;default:Ha(e)}}var Ba=ga;function Va(e){ga(e),va(e)}function Ha(e){Ta(e)}var Ua=Wa;function Wa(e){let t=Ka(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=Ga(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 Ga(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 Ka(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(Yi).forEach(r),t}function qa(e){let t=Oi(e,`root`,{},`_root`),n=Ya(e),r=Object.values(n),i=Ri(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=Xa(e)+1;e.children(Yi).forEach(r=>{Ja(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function Ja(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=Fi(e,`_bt`),l=Fi(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{Ja(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 Ya(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(Yi).forEach(e=>n(e,1)),t}function Xa(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Za(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var Qa=$a;function $a(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)eo(e,`borderLeft`,`_bl`,n,i,t),eo(e,`borderRight`,`_br`,n,i,t)}}e.children(Yi).forEach(t)}function eo(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=Oi(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function to(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&ro(e)}function no(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&ao(e),(t===`lr`||t===`rl`)&&(so(e),ro(e))}function ro(e){e.nodes().forEach(t=>io(e.node(t))),e.edges().forEach(t=>io(e.edge(t)))}function io(e){let t=e.width;e.width=e.height,e.height=t}function ao(e){e.nodes().forEach(t=>oo(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(oo),Object.hasOwn(r,`y`)&&oo(r)})}function oo(e){e.y=-e.y}function so(e){e.nodes().forEach(t=>co(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(co),Object.hasOwn(r,`x`)&&co(r)})}function co(e){let t=e.x;e.x=e.y,e.y=t}function lo(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=Gi(Ri(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 Xi(t,e.node(n),e.node(r))}return a}function uo(e,t){let n=0;for(let r=1;r<t.length;++r)n+=fo(e,t[r-1],t[r]);return n}function fo(e,t,n){let r=Ji(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 po(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 mo(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))}),ho(Object.values(n).filter(e=>!e.indegree))}function ho(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&go(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=>Ki(e,[`vs`,`i`,`barycenter`,`weight`]))}function go(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 _o(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=Bi(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(yo(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=vo(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=vo(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function vo(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 yo(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=Xi(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 bo(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=po(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=bo(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&So(t,r)}});let h=mo(m,n);xo(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=_o(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 xo(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function So(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 Co(e,t,n,r){r||=e.nodes();let i=wo(e),a=new Di({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 wo(e){let t;for(;e.hasNode(t=Wi(`_root`)););return t}function To(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 Eo(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,Eo);return}let r=zi(e),i=Do(e,Gi(1,r+1),`inEdges`),a=Do(e,Gi(r-1,-1,-1),`outEdges`),o=lo(e,n);if(ko(e,o),t.disableOptimalOrderHeuristic)return;let s=1/0,c,l=t.constraints||[];for(let t=0,r=0;r<4;++t,++r){Oo(t%2?i:a,t%4>=2,l,n),o=Mi(e);let u=uo(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}ko(e,c)}function Do(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 Co(e,t,n,r.get(t)||[])})}function Oo(e,t,n,r){let i=!0,a=new Di;e.forEach(function(e){n.forEach(e=>a.setEdge(e.left,e.right));let o=e.graph().root,{result:s,usedBias:c}=bo(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),To(e,a,s.vs)})}function ko(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function Ao(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=Mo(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)&&No(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function jo(e,t){let n={};function r(t,r,i,a,o){Gi(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)&&No(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 Mo(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function No(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 Po(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 Fo(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)||Wo(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=>Wo(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&&!Po(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 Io(e,t,n,r,i=!1){let a={},o=Lo(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 Lo(e,t,n,r){let i=new Di,a=e.graph(),o=Ho(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 Ro(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=Uo(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 zo(e,t){let n=Object.values(t),r=Ri(Math.min,n),i=Ri(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-Ri(Math.min,c);a!==`l`&&(l=i-Ri(Math.max,c)),l&&(e[o]=qi(s,e=>e+l))})})}function Bo(e,t=void 0){let n=e.ul;return n?qi(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 Vo(e,t){let n=Mi(e),r=Object.assign(Ao(e,n),jo(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=Fo(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=Io(e,a,s.root,s.align,n===`r`);n===`r`&&(c=qi(c,e=>-e)),i[o+n]=c})}),zo(i,Ro(e,i)),Bo(i,e.graph().align)}function Ho(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;break}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;break}return l&&(c+=n?l:-l),c}}function Uo(e,t){return e.node(t).width}function Wo(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 Go(e,t){e=Ai(e),Ko(e),Object.entries(Vo(e,t)).forEach(([t,n])=>e.node(t).x=n)}function Ko(e){let t=Mi(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 qo=new WeakMap;function Jo(e,t={}){return Xo(e,Hi,t),e}function Yo(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function Xo(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 Di({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=Yo(e,t.v,r),i=Yo(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)}))}}),Xo(o,t,n);let l=ss(o);Zo(l,t,n,null),Qo(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=ss(e),g=Zo(h,t,n,qo.get(e)??null);qo.set(e,g),Qo(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 Zo(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`,()=>cs(e)),t(` removeSelfEdges`,()=>_s(e)),t(` acyclic`,()=>la(e,s)),t(` nestingGraph.run`,()=>qa(e)),t(` rank`,()=>Ra(Ai(e))),t(` injectEdgeLabelProxies`,()=>ls(e)),t(` removeEmptyRanks`,()=>Pi(e)),t(` nestingGraph.cleanup`,()=>Za(e)),t(` normalizeRanks`,()=>Ni(e)),t(` assignRankMinMax`,()=>us(e)),t(` removeEdgeLabelProxies`,()=>ds(e)),t(` normalize.run`,()=>pa(e)),t(` parentDummyChains`,()=>Ua(e)),t(` addBorderSegments`,()=>Qa(e)),t(` order`,()=>Eo(e,n,c)),t(` insertSelfEdges`,()=>vs(e)),t(` adjustCoordinateSystem`,()=>to(e)),t(` position`,()=>Go(e,n.corePath)),t(` positionSelfEdges`,()=>ys(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>gs(e)),t(` normalize.undo`,()=>ha(e)),t(` fixupEdgeLabelCoords`,()=>ms(e)),t(` undoCoordinateSystem`,()=>no(e)),t(` translateGraph`,()=>fs(e)),t(` assignNodeIntersects`,()=>ps(e)),t(` reversePoints`,()=>hs(e)),t(` acyclic.undo`,()=>da(e)),{graph:e,rawNodes:l}}function Qo(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 $o=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],es={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},ts=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],ns=[`width`,`height`,`rank`],rs={width:0,height:0},is=[`minlen`,`weight`,`width`,`height`,`labeloffset`],as={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},os=[`labelpos`];function ss(e){let t=new Di({multigraph:!0,compound:!0}),n=xs(e.graph());return t.setGraph(Object.assign({},es,bs(n,$o),Ki(n,ts))),e.nodes().forEach(n=>{let r=bs(xs(e.node(n)),ns);Object.keys(rs).forEach(e=>{r[e]===void 0&&(r[e]=rs[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=xs(e.edge(n));t.setEdge(n,Object.assign({},as,bs(r,is),Ki(r,os)))}),t}function cs(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 ls(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);Oi(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function us(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 ds(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 fs(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 ps(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(ji(r,a)),n.points.push(ji(i,o))})}function ms(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;break}})}function hs(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function gs(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 _s(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 vs(e){Mi(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=>{Oi(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 ys(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 bs(e,t){return qi(Ki(e,t),Number)}function xs(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}function Ss(e){let t=Mi(e),n=new Di({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 Cs={graphlib:Hr,version:Zi,layout:Jo,debug:Ss,util:{time:Vi,notime:Hi}},ws=6.6,Ts=5.4;function Es(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*ws+22,t),n)}function Ds(e,t,n,r){let i=t.map(e=>js(e).length).reduce((e,t)=>Math.max(e,t),0);return Math.max(Es(e,n,r),Math.min(i*Ts+22,r))}function Os(e,t,n=ws){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=>Os(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;continue}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 ks(e,t){return e*15+t*15+14}function As(e,t){return e.flatMap(e=>Os(js(e),t,Ts))}function js(e){return`${e.field}: ${e.from===void 0?``:`${e.from} → `}${e.to}`}function Ms(e,t){return`${e}: ${Ns(t)}`}function Ns(e){return Array.isArray(e)?e.map(e=>Ns(e)).join(`, `):e===null?`null`:typeof e==`object`&&e&&typeof e.ref==`string`?`<${e.ref}>`:String(e)}function Ps(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 Fs(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)}…`}function Is(e,t){return t?e.ref===void 0?`added`:e.set===void 0?`context`:`changed`:`unchanged`}function Ls(e,t){if(t&&e.heading===void 0)return e.ref===void 0?`added`:e.set===void 0?`context`:`changed`}function Rs(e,t){return t?e.ref===void 0?`added`:e.set===void 0?`context`:`changed`:`unchanged`}function zs(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 Bs={added:`added`,changed:`changed`,context:`existing`,unchanged:``},Vs={added:`added`,changed:`changed`,context:`existing`,removed:`removed`},Hs=[`added`,`changed`,`context`,`removed`];function Us(e){return e.rows.some(e=>Je(e).role!==void 0)}function Ws(e,t){if(t)return Je(e).role??`context`}function Gs(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-Ys,y:n-Ys-Xs,width:r-t+Ys*2,height:i-n+Ys*2+Xs}}var Ks=64,qs=24,Js=12,Ys=10,Xs=16,Zs=16,Qs=160,$s=52;function ec(e,t,n=`landscape`){let r=new Cs.graphlib.Graph({compound:!0,multigraph:!0});r.setGraph({rankdir:n===`portrait`?`TB`:`LR`,ranksep:Ks,nodesep:qs,marginx:Js,marginy:Js}),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))}),Cs.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??Js+i/2)-i/2,y:(n?.y??Js+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),Js)+Zs,u=new Map(o.map(e=>[e.id,e]));for(let e of i){let t=Gs((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:Js,y:l,width:Qs,height:$s}),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))-Js,p=Math.min(0,...d.map(e=>e.y))-Js;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+Js,height:m.height+Js}}var tc={attributes:[],expectations:[],assignments:[],removedAttributes:[],locations:[],artifacts:[]};function nc(e){if(typeof e!=`object`||!e)return tc;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 rc(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 ic(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=rc(e);return t===void 0?{}:{target:t}})(),artifacts:Array.isArray(i)?i:[]};if(e.kind===`table`){let r=e.data,i=Us(r),o=r.rows.map(e=>{let n=Array.isArray(e)?{}:e,r=(Array.isArray(e)?void 0:e.role)??Ls({ref:typeof n.ref==`string`?n.ref:void 0,set:n.set,heading:typeof n.heading==`string`?n.heading:void 0},t)??Ws(e,i),{cells:a,heading:o}=Je(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:zs(s),...nc(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}}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,ac(e)]));return{thingNoun:o?`element`:`participant`,linkNoun:o?`relationship`:`message`,things:s.map(e=>({id:e.id,label:ac(e),kind:e.kind,role:Is(e,t),changes:zs(e),container:e.container,...nc(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:Rs(e,t),changes:zs(e),isLoop:e.from===e.to,...nc(e)})),containers:e.data.containers??[],removals:n,traces:[],...a}}function ac(e){return e.label??e.ref??e.id}function oc(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 ${sc(e.id)}["${lc(e.label)}"]`);for(let t of a(e.id))n.push(` ${sc(t.id)}["${lc(ac(t))}"]`);n.push(` end`)}for(let e of t.nodes)e.container!==void 0&&i.has(e.container)||n.push(` ${sc(e.id)}["${lc(ac(e))}"]`);for(let e of t.edges){let t=e.label??e.kind,r=t===void 0?`-->`:`-- "${lc(t)}" -->`;n.push(` ${sc(e.from)} ${r} ${sc(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 ${sc(e.id)} as "${lc(ac(e))}"`;for(let e of r){n.push(` box ${lc(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(` ${sc(e.from)}->>${sc(e.to)}: ${lc(e.label??``)}`);return n.join(`
@@ -330,7 +330,7 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
330
330
  `)]);let ae=(0,d.useMemo)(()=>{let e=/^\/(\S*)$/.exec(_);return e?e[1].toLowerCase():null},[_]),oe=(0,d.useMemo)(()=>ae===null?[]:n.filter(e=>e.name.toLowerCase().includes(ae)).sort((e,t)=>{let n=e.name.toLowerCase().startsWith(ae);return n===t.name.toLowerCase().startsWith(ae)?XP.compare(e.name,t.name):n?-1:1}).slice(0,YP),[ae,n]),E=ae===null?$P(_,y):null;(0,d.useEffect)(()=>{if(!E||E.query.length===0){m();return}let e=window.setTimeout(()=>p(E.query),150);return()=>clearTimeout(e)},[E?.query]);let se=(0,d.useMemo)(()=>{if(oe.length>0)return{kind:`command`,items:oe};let e=E&&r?.query===E.query?r.results:[];return e.length>0?{kind:`file`,items:e}:null},[oe,E,r]),ce=se!==null&&!ee,D=ae===null?E?`file:${E.query}`:null:`cmd:${ae}`;(0,d.useEffect)(()=>{S(0)},[D]),(0,d.useEffect)(()=>{C(!1)},[ae===null?E?`file`:null:`command`]),(0,d.useEffect)(()=>{if(!ce)return;let e=e=>{qP(e,w.current)||C(!0)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[ce]),(0,d.useEffect)(()=>{T.current?.querySelector(`[data-selected="true"]`)?.scrollIntoView({block:`nearest`})},[x]);let O=o.length>0,[le,ue]=(0,d.useState)(!1);(0,d.useEffect)(()=>{O||ue(!1)},[O]);function de(){if(O){ue(!0);return}let e=VP(_,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 fe(e){let t=`/${e.name} `;v(t),re.current=t.length,b(t.length)}function A(e){if(!E)return;let t=_.slice(0,E.start),n=_.slice(y),r=`@${e.path}${QP(e.type)?`/`:` `}`,i=`${t}${r}${n}`;v(i),m();let a=t.length+r.length;re.current=a,b(a)}function pe(){if(se){if(se.kind===`command`){let e=se.items[x];e&&fe(e)}else{let e=se.items[x];e&&A(e)}}}function me(e){if(ce&&se){if(e.key===`ArrowDown`){e.preventDefault(),S(e=>(e+1)%se.items.length);return}if(e.key===`ArrowUp`){e.preventDefault(),S(e=>(e-1+se.items.length)%se.items.length);return}if(e.key===`Tab`||e.key===`Enter`){e.preventDefault(),pe();return}if(e.key===`Escape`){e.preventDefault(),C(!0);return}}e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),de())}function he(e){b(e.currentTarget.selectionStart??0)}function ge(e){let t=Array.from(e.clipboardData.files);t.length>0&&(e.preventDefault(),s(t))}return(0,k.jsxs)(`div`,{ref:w,className:`relative`,children:[(a.length>0||O)&&(0,k.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[o.map(e=>(0,k.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,k.jsx)(`span`,{"aria-hidden":!0,className:`animate-pulse`,children:`⏳`}),(0,k.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,k.jsx)(`span`,{className:`sr-only`,children:`uploading`})]},e.id)),le&&(0,k.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,k.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,k.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:e.name,className:`h-8 w-8 rounded object-cover`}):(0,k.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,k.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,k.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}`))]}),ce&&se&&(0,k.jsx)(`div`,{ref:T,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:se.kind===`command`?se.items.map((e,t)=>(0,k.jsxs)(`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,k.jsxs)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:[`/`,e.name]}),e.argumentHint&&(0,k.jsx)(`span`,{className:`font-mono text-xs text-zinc-500`,children:e.argumentHint}),e.description&&(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-zinc-500`,children:e.description}),(0,k.jsx)(`span`,{className:`ml-auto shrink-0 rounded bg-zinc-200 px-1 text-[10px] uppercase text-zinc-500 dark:bg-zinc-800`,children:ZP[e.source]})]},e.name)):se.items.map((e,t)=>(0,k.jsx)(`button`,{type:`button`,"data-selected":t===x,onMouseEnter:()=>S(t),onClick:()=>A(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,k.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-zinc-800 dark:text-zinc-200`,children:[e.path,QP(e.type)?`/`:``]})},e.path))}),(0,k.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,k.jsx)(`textarea`,{ref:te,value:_,onChange:e=>{v(e.target.value),b(e.target.selectionStart??e.target.value.length)},onKeyDown:me,onClick:he,onKeyUp:he,onPaste:ge,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:Math.min(6,Math.max(1,_.split(`
331
331
  `).length)),className:`flex-1 resize-none 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,k.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,k.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,className:`h-4 w-4`,children:(0,k.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>ne.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,k.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,k.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,k.jsx)(`input`,{ref:ne,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&s(Array.from(e.target.files)),e.target.value=``}}),(0,k.jsx)(`button`,{type:`button`,onClick:de,disabled:!t||O||!_.trim()&&a.length===0,title:O?`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,k.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:[(0,k.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,k.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,k.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]}):(0,k.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,k.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 tF=`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`,nF=`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`,rF=`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`,iF=`mb-4 ${rF}`,aF=`1,3`,oF=` — `;function sF(e){let t=e.indexOf(`
332
332
  `);return t===-1?{heading:e,body:``}:{heading:e.slice(0,t),body:e.slice(t+1).trim()}}function cF(e){let t=/^(\d+)\.\s+(\S[\s\S]*)$/.exec(e.trim());if(!t)return null;let n=t[2],r=n.indexOf(oF);return{index:Number(t[1]),label:r===-1?n:n.slice(0,r),description:r===-1?``:n.slice(r+3)}}function lF(e){if(e.method!==`input`||e.placeholder!==aF)return null;let{heading:t,body:n}=sF(e.title),r=[];for(let e of n.split(`
333
- `)){let t=cF(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function uF({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=lF(e),{heading:p,body:m}=sF(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,k.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:()=>s(!0),children:(0,k.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,k.jsxs)(`div`,{className:`mb-3 flex items-start gap-3`,children:[(0,k.jsx)(`h2`,{className:`flex-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:p}),(0,k.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,k.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,k.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>{let r=cF(n);return(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${tF}`,children:r?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:r.label}),r.description&&(0,k.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,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:tF,children:`No`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:nF,children:`Yes`})]})]}),f&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`mb-3 flex flex-col gap-1`,children:f.options.map(e=>(0,k.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,k.jsx)(`input`,{type:`checkbox`,checked:i.includes(e.index),onChange:()=>g(e.index),className:`mt-0.5`}),(0,k.jsxs)(`span`,{children:[(0,k.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,k.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,k.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 ${rF}`}),(0,k.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:h,className:tF,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:_,className:nF,children:`OK`})]})]}),e.method===`input`&&!f&&(0,k.jsxs)(k.Fragment,{children:[(0,k.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:iF}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:h,className:tF,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:nF,children:`OK`})]})]}),e.method===`editor`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.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 ${iF}`}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:h,className:tF,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:nF,children:`OK`})]})]}),l!==null&&(0,k.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,l,`s`]})]})})}var dF={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`},fF=6e3;function pF({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(),fF);return()=>clearTimeout(e)},[e.id]),(0,k.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-lg border px-3 py-2 text-sm shadow-lg ${dF[e.notifyType??`info`]}`,children:[(0,k.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,k.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 mF({notifications:e,onDismiss:t}){return e.length===0?null:(0,k.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,k.jsx)(pF,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var hF={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`},gF=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function _F(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(hF[r]!==void 0)n.color=hF[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 vF(e){let t=[],n={},r=0;gF.lastIndex=0;for(let i=gF.exec(e);i!==null;i=gF.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=_F(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function yF(e){return e.replace(gF,``)}function bF({line:e}){let t=vF(e);return(0,k.jsx)(k.Fragment,{children:t.map((e,t)=>(0,k.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 xF({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,k.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,k.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,k.jsx)(`div`,{children:(0,k.jsx)(bF,{line:e})},t))},e))})}function SF({text:e,path:t,serverUrl:n,token:r,template:i}){let[a,o]=(0,d.useState)(`idle`),[s,c]=(0,d.useState)(`plain`),[l,u]=(0,d.useState)(null),f=(0,d.useRef)(!1),p=(0,d.useRef)({plain:0,template:0});async function m(i){if(!(f.current||Date.now()-p.current[i]<750)){f.current=!0,p.current[i]=Date.now(),c(i),o(`working`),u(null);try{let{downloadDocx:a,downloadDocxInTemplate:s}=await A(async()=>{let{downloadDocx:e,downloadDocxInTemplate:t}=await import(`./docxExport-CzFTex-m.js`);return{downloadDocx:e,downloadDocxInTemplate:t}},__vite__mapDeps([20,1,21]));await(i===`template`?s:a)(e,t,{serverUrl:n,token:r}),o(`idle`)}catch(e){o(`failed`),u(e instanceof Error?e.message:String(e))}finally{f.current=!1}}}let h=`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`,g=(e,t)=>a===`working`&&s===e?`… exporting`:a===`failed`&&s===e?`⚠ export failed`:t,_=(e,t)=>a===`failed`&&s===e?`Could not export: ${l??`unknown reason`}`:t;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>void m(`plain`),disabled:a===`working`,title:_(`plain`,`Download as a Word document`),"aria-label":`Download as a Word document`,className:h,children:g(`plain`,`⤓ word`)}),i!==void 0&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>void m(`template`),disabled:a===`working`,title:_(`template`,`Download as a Word document in the template ${i}`),"aria-label":`Download as a Word document in the template ${i}`,className:h,children:g(`template`,`⤓ word · template`)})]})}function CF({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,k.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,k.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,k.jsx)(`span`,{className:`shrink-0 tabular-nums text-zinc-500 dark:text-zinc-400`,children:p}),(0,k.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,k.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,k.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 wF=3e3;function TF(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function EF(e,t,n=1/0){if(t===``)return[];let r=new RegExp(TF(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 DF(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 OF(e,t,n=wF){let r={matches:[],truncated:!1,clear:()=>{}};if(t===``)return r;let{nodes:i,text:a}=DF(e);if(a===``)return r;let o=EF(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 kF=(0,d.lazy)(()=>A(()=>import(`./PdfViewer-DM2j93gM.js`),[])),AF=250,jF=`(min-width: 768px)`;function MF(){let[e,t]=(0,d.useState)(()=>window.matchMedia?.(jF).matches??!0);return(0,d.useEffect)(()=>{let e=window.matchMedia?.(jF);if(e===void 0)return;let n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function NF(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 PF(e){let t=Oc(e);return t.status===`valid`?t.envelope:void 0}function FF(e){return/\.(md|markdown)$/i.test(e)}function IF(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function LF({file:e,writableRoot:t,isStreaming:n,onDirtyChange:r,gitState:i,initialShowGitDiff:a=!1,gitDiff:o,onFetchGitDiff:s,onClearGitDiff:c,inRepository:l,onOpenGitHistory:u,onClose:f,onReload:p,onSave:m,serverUrl:h=``,token:g=null,docxTemplate:_,onImageLoad:v,onPdfLoad:y,rawRevision:b=0}){let[x,ee]=(0,d.useState)(`rendered`),[C,w]=(0,d.useState)(a),[T,ne]=(0,d.useState)(e.status===`loaded`&&e.justCreated?{draft:e.content,baseContent:e.content,baseMtimeMs:e.mtimeMs}:null),[re,ie]=(0,d.useState)(`idle`),se=(0,d.useRef)(null),D=(0,d.useRef)(null),O=e.status===`loaded`?e:null,ue=O!==null&&FF(e.path),de=oe(e.path),fe=E(e.path),A=(0,d.useMemo)(()=>O===null?void 0:Oc(O.content),[O?.content]),pe=A?.status===`valid`,me=A?.status===`valid`||A?.status===`invalid`,he=me||ue,ge=x===`source`,_e=MF(),ye=IF(e.path,t)&&!fe,be=T!==null&&T.draft!==T.baseContent,xe=O?.pendingSave!==void 0,Se=T!==null&&O!==null&&O.mtimeMs!==T.baseMtimeMs,Ce=O?.saveError?.conflict===!0||Se,we=T?.draft??O?.content??``,Te=NF(we,AF),Ee=(0,d.useMemo)(()=>O===null?void 0:Oc(Te),[Te,O===null]),[De,Oe]=(0,d.useState)(()=>e.status===`loaded`?PF(e.content):void 0);(0,d.useEffect)(()=>{Ee?.status===`valid`&&Oe(Ee.envelope)},[Ee]);let ke=Ee!==void 0&&Ee.status!==`valid`&&De!==void 0,Ae=Ee?.status===`invalid`?Te===O?.content&&O.documentIssues!==void 0?O.documentIssues:Ee.issues:void 0,je=Ee?.status===`not-a-document`?Ee.why===`unparseable`?`This is not parseable JSON yet.`:"This no longer declares a structured-exchange `schema`.":Ee?.status===`unsupported-version`?`This declares ${Ee.schema}, which this version does not render.`:void 0,Me=x===`split`&&he&&!C&&O!==null&&_e,Ne=C||Me?`none`:fe?`pdf`:T===null?O!==null&&!de?`dom`:`none`:`edit`,[Pe,Fe]=(0,d.useState)(!1),[Ie,Le]=(0,d.useState)(``),[Re,Be]=(0,d.useState)(0),Ve=(0,d.useRef)(null),Ue=(0,d.useRef)(null),We=(0,d.useRef)(null),[Ge,Ke]=(0,d.useState)({matchCount:0,currentIndex:-1,searching:!1}),[qe,Je]=(0,d.useState)([]),[Ye,Xe]=(0,d.useState)(!1),Ze=(0,d.useRef)(null),Qe=(0,d.useRef)([]),$e=(0,d.useRef)(0),et=(0,d.useRef)(``);function tt(e){$e.current=e;for(let[t,n]of Qe.current.entries())for(let r of n.marks)r.isConnected&&r.classList.toggle(`find-match-current`,t===e);let t=Qe.current[e]?.marks;t?.[0]?.isConnected&&t[0].scrollIntoView({block:`center`})}let nt=Pe?Ie:``,rt=(0,d.useMemo)(()=>Ne===`edit`?EF(we,nt):[],[Ne,we,nt]);(0,d.useEffect)(()=>{Pe&&Ne===`none`&&Fe(!1)},[Pe,Ne]);let[it,at]=(0,d.useState)(0),ot=(0,d.useCallback)(()=>at(e=>e+1),[]);(0,d.useEffect)(()=>{function e(){Ze.current?.clear(),Ze.current=null,Qe.current=[],Je([]),Xe(!1)}let t=Ue.current;if(Ne!==`dom`||nt===``||t===null){e();return}Ze.current?.clear();let n=OF(t,nt);Ze.current=n,Qe.current=n.matches,Je(n.matches),Xe(n.truncated);let r=nt!==et.current;et.current=nt;let i=r?0:Math.min($e.current,Math.max(n.matches.length-1,0));return Be(i),tt(i),e},[Ne,nt,x,ge,it]);function st(e,t){let n=e[t],r=se.current;n!==void 0&&r!==null&&(r.focus(),r.setSelectionRange(n.start,n.end),Ve.current?.focus())}(0,d.useEffect)(()=>{if(Ne!==`edit`||!Pe)return;let e=EF(we,nt);Be(0),e.length>0&&st(e,0)},[nt,Ne,Pe]);function ct(){Fe(!0)}function lt(){Fe(!1)}function ut(){if(Ne===`pdf`)We.current?.findNext();else if(Ne===`edit`){if(rt.length===0)return;let e=(Re+1)%rt.length;Be(e),st(rt,e)}else{let e=Qe.current.length;if(e===0)return;let t=($e.current+1)%e;Be(t),tt(t)}}function dt(){if(Ne===`pdf`)We.current?.findPrevious();else if(Ne===`edit`){if(rt.length===0)return;let e=(Re-1+rt.length)%rt.length;Be(e),st(rt,e)}else{let e=Qe.current.length;if(e===0)return;let t=($e.current-1+e)%e;Be(t),tt(t)}}let ft=Ne===`pdf`?{matchCount:Ge.matchCount,currentIndex:Ge.currentIndex,truncated:!1,searching:Ge.searching}:Ne===`edit`?{matchCount:rt.length,currentIndex:rt.length>0?Math.min(Re,rt.length-1):-1,truncated:!1,searching:!1}:{matchCount:qe.length,currentIndex:qe.length>0?Math.min(Re,qe.length-1):-1,truncated:Ye,searching:!1},pt=T===null?null:(0,k.jsx)(`textarea`,{ref:se,value:T.draft,onChange:e=>ne({...T,draft:e.target.value}),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),be&&!xe&&!Ce&&vt())},spellCheck:!1,className:`h-full w-full resize-none bg-transparent p-4 font-mono text-[13px] leading-relaxed text-zinc-800 outline-none ring-inset focus-visible:ring-1 focus-visible:ring-zinc-300 dark:text-zinc-200 dark:focus-visible:ring-zinc-700`});function mt(t){return(0,k.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,k.jsx)(Hg,{remarkPlugins:[CM,FM],rehypePlugins:[iw],components:{pre:ze,a:({href:t,children:n,...r})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,k.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...r,children:n}):t.startsWith(`#`)?(0,k.jsx)(`a`,{href:t,...r,children:n}):(0,k.jsx)(`a`,{href:t,onClick:n=>{n.preventDefault(),p(ae(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(`//`)?ce(h,ae(e.path,t),g):t;return(0,k.jsx)(`img`,{...r,src:i,alt:n??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:te(t)})})}function ht(e){x===`split`&&e!==`split`&&be&&!window.confirm(`Discard unsaved changes?`)||(x===`split`&&e!==`split`&&ne(null),ee(e))}function gt(){be&&!window.confirm(`Discard unsaved changes?`)||f()}function _t(){O&&ne({draft:O.content,baseContent:O.content,baseMtimeMs:O.mtimeMs})}function vt(t=!1){!O||T===null||xe||(D.current=T.draft,m(e.path,T.draft,T.baseMtimeMs,t))}function yt(){ne(null),p(e.path)}function bt(){let t=!C;w(t),t?s(e.path):c()}return(0,d.useEffect)(()=>{if(T!==null&&O!==null&&D.current!==null&&O.content===D.current&&O.mtimeMs!==T.baseMtimeMs){let e=D.current;D.current=null,T.draft===e?ne(null):ne({...T,baseContent:O.content,baseMtimeMs:O.mtimeMs})}},[O?.mtimeMs]),(0,d.useEffect)(()=>{function e(e){if(e.key===`Escape`){Pe?lt():gt();return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`f`){if(Ne===`none`)return;e.preventDefault(),ct()}}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,d.useEffect)(()=>{Me&&ye&&T===null&&O!==null&&ne({draft:O.content,baseContent:O.content,baseMtimeMs:O.mtimeMs})},[Me,ye,O?.mtimeMs]),(0,d.useEffect)(()=>{ie(n?`streaming`:e=>e===`streaming`?`done`:e)},[n]),(0,d.useEffect)(()=>(r(be),()=>r(!1)),[be]),(0,d.useEffect)(()=>(a&&s(e.path),()=>c()),[]),(0,k.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[he&&!C&&(0,k.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,k.jsx)(`button`,{type:`button`,onClick:()=>ht(e),"aria-pressed":x===e,title:n,className:`rounded px-1.5 py-0.5 text-xs ${x===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&&T===null&&(0,k.jsx)(`button`,{type:`button`,onClick:bt,"aria-pressed":C,title:C?`Show file content`:`Show uncommitted changes (vs HEAD)`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs ${C?`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`}),l&&T===null&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>u(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,k.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,be&&(0,k.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),O&&!de&&!fe&&!C&&(0,k.jsx)(SF,{text:we,path:e.path,serverUrl:h,token:g,template:_}),O&&T===null&&(0,k.jsx)(le,{text:O.content}),O&&T===null&&!C&&ye&&(0,k.jsx)(`button`,{type:`button`,onClick:_t,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`}),O&&T===null&&!ye&&(0,k.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,title:`Outside the writable zone`,children:`🔒 read-only`}),T!==null&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>vt(),disabled:!be||xe||Ce,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:xe?`saving…`:`save`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{be&&!window.confirm(`Discard unsaved changes?`)||ne(Me&&O!==null?{draft:O.content,baseContent:O.content,baseMtimeMs:O.mtimeMs}:null)},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:`cancel`})]}),(0,k.jsx)(`button`,{type:`button`,onClick:gt,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:`✕`})]}),Pe&&Ne!==`none`&&(0,k.jsx)(CF,{inputRef:Ve,query:Ie,onQueryChange:Le,matchCount:ft.matchCount,currentIndex:ft.currentIndex,truncated:ft.truncated,searching:ft.searching,onNext:ut,onPrev:dt,onClose:lt}),Ce&&T!==null&&(0,k.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,k.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,k.jsx)(`button`,{type:`button`,onClick:yt,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,k.jsx)(`button`,{type:`button`,onClick:()=>vt(!0),disabled:xe,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`})]}),T!==null&&O?.saveError&&!O.saveError.conflict&&(0,k.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:O.saveError.message}),(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[C&&T===null&&(0,k.jsxs)(`div`,{className:`p-4`,children:[o?.path===e.path&&`error`in o&&(0,k.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,k.jsx)(He,{fill:!0,lines:S(o.before,o.after)}),o?.path!==e.path&&(0,k.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),fe&&T===null&&!C&&(0,k.jsx)(Zl,{label:`This PDF`,children:(0,k.jsx)(d.Suspense,{fallback:(0,k.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),children:(0,k.jsx)(kF,{ref:We,path:e.path,serverUrl:h,token:g,revision:b,findQuery:Ne===`pdf`?nt:``,onFindStateChange:Ke,...y?{onLoaded:y}:{}})})}),de&&T===null&&!C&&(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,k.jsx)(`img`,{src:ce(h,e.path,g,b),alt:e.path,onLoad:()=>v(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&T===null&&!C&&!de&&!fe&&(0,k.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!de&&!fe&&(0,k.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),T!==null&&!Me&&pt,O&&T===null&&!Me&&!C&&ue&&!ge&&(0,k.jsx)(`div`,{ref:Ue,children:mt(O.content)}),Me&&(0,k.jsxs)(`div`,{className:`flex h-full min-h-0`,"data-testid":`file-split`,children:[(0,k.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto border-r border-zinc-200 dark:border-zinc-800`,children:pt??(0,k.jsx)(`div`,{className:`p-4`,children:(0,k.jsx)(ve,{code:O.content,path:e.path})})}),(0,k.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto`,"data-testid":`file-split-rendering`,children:ue&&!me?(0,k.jsx)(`div`,{className:`prose-chat p-4 text-zinc-700 dark:text-zinc-300`,children:mt(Te)}):(0,k.jsxs)(k.Fragment,{children:[ke&&(0,k.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,k.jsxs)(`span`,{children:[`Showing the document as it last stood.`,` `,je??`The text beside it does not satisfy the schema it declares.`]})}),Ae!==void 0&&(0,k.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:[Ae.slice(0,6).map((e,t)=>(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),Ae.length>6&&(0,k.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,Ae.length-6,` more`]})]}),De===void 0?(0,k.jsxs)(`p`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,"data-testid":`file-split-nothing`,children:[`Nothing to draw yet. `,je??`This document does not satisfy the schema it declares.`]}):(0,k.jsx)(Zl,{label:`This diagram`,children:(0,k.jsx)(`div`,{className:`p-4`,"data-testid":`file-structured-exchange`,children:(0,k.jsx)(Jl,{envelope:De,source:we})})})]})})]}),O&&T===null&&!Me&&!C&&pe&&!ge&&A?.status===`valid`&&(0,k.jsx)(Zl,{label:`This diagram`,children:(0,k.jsx)(`div`,{className:`mx-auto max-w-5xl p-4`,"data-testid":`file-structured-exchange`,children:(0,k.jsx)(Jl,{envelope:A.envelope,source:O.content})})}),O&&T===null&&!Me&&!C&&A?.status===`invalid`&&(0,k.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,k.jsx)(`p`,{className:`font-medium`,children:`This declares a structured-exchange document and does not satisfy the schema.`}),(0,k.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:[(O.documentIssues??A.issues).slice(0,8).map((e,t)=>(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),(O.documentIssues??A.issues).length>8&&(0,k.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,(O.documentIssues??A.issues).length-8,` more`]})]})]}),O&&T===null&&!Me&&!C&&A?.status===`unsupported-version`&&(0,k.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,k.jsx)(`span`,{className:`font-mono`,children:A.schema}),`, which this version does not render. Shown as text.`]}),O&&T===null&&!Me&&!C&&(!ue||ge)&&(!pe||ge)&&(0,k.jsx)(`div`,{ref:Ue,className:`p-4`,children:(0,k.jsx)(ve,{code:O.content,path:e.path,onRendered:ot})})]}),re!==`idle`&&(0,k.jsxs)(`button`,{type:`button`,onClick:gt,"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:[re===`streaming`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,k.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,k.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,k.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function RF(e){return e.split(`
333
+ `)){let t=cF(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function uF({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=lF(e),{heading:p,body:m}=sF(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,k.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:()=>s(!0),children:(0,k.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,k.jsxs)(`div`,{className:`mb-3 flex items-start gap-3`,children:[(0,k.jsx)(`h2`,{className:`flex-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:p}),(0,k.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,k.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,k.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>{let r=cF(n);return(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${tF}`,children:r?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:r.label}),r.description&&(0,k.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,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:tF,children:`No`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:nF,children:`Yes`})]})]}),f&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`mb-3 flex flex-col gap-1`,children:f.options.map(e=>(0,k.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,k.jsx)(`input`,{type:`checkbox`,checked:i.includes(e.index),onChange:()=>g(e.index),className:`mt-0.5`}),(0,k.jsxs)(`span`,{children:[(0,k.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,k.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,k.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 ${rF}`}),(0,k.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:h,className:tF,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:_,className:nF,children:`OK`})]})]}),e.method===`input`&&!f&&(0,k.jsxs)(k.Fragment,{children:[(0,k.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:iF}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:h,className:tF,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:nF,children:`OK`})]})]}),e.method===`editor`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.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 ${iF}`}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:h,className:tF,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:nF,children:`OK`})]})]}),l!==null&&(0,k.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,l,`s`]})]})})}var dF={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`},fF=6e3;function pF({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(),fF);return()=>clearTimeout(e)},[e.id]),(0,k.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-lg border px-3 py-2 text-sm shadow-lg ${dF[e.notifyType??`info`]}`,children:[(0,k.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,k.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 mF({notifications:e,onDismiss:t}){return e.length===0?null:(0,k.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,k.jsx)(pF,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var hF={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`},gF=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function _F(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(hF[r]!==void 0)n.color=hF[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 vF(e){let t=[],n={},r=0;gF.lastIndex=0;for(let i=gF.exec(e);i!==null;i=gF.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=_F(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function yF(e){return e.replace(gF,``)}function bF({line:e}){let t=vF(e);return(0,k.jsx)(k.Fragment,{children:t.map((e,t)=>(0,k.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 xF({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,k.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,k.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,k.jsx)(`div`,{children:(0,k.jsx)(bF,{line:e})},t))},e))})}function SF({text:e,path:t,serverUrl:n,token:r,template:i}){let[a,o]=(0,d.useState)(`idle`),[s,c]=(0,d.useState)(`plain`),[l,u]=(0,d.useState)(null),f=(0,d.useRef)(!1),p=(0,d.useRef)({plain:0,template:0});async function m(i){if(!(f.current||Date.now()-p.current[i]<750)){f.current=!0,p.current[i]=Date.now(),c(i),o(`working`),u(null);try{let{downloadDocx:a,downloadDocxInTemplate:s}=await A(async()=>{let{downloadDocx:e,downloadDocxInTemplate:t}=await import(`./docxExport-ErgwApAZ.js`);return{downloadDocx:e,downloadDocxInTemplate:t}},__vite__mapDeps([20,1,21]));await(i===`template`?s:a)(e,t,{serverUrl:n,token:r}),o(`idle`)}catch(e){o(`failed`),u(e instanceof Error?e.message:String(e))}finally{f.current=!1}}}let h=`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`,g=(e,t)=>a===`working`&&s===e?`… exporting`:a===`failed`&&s===e?`⚠ export failed`:t,_=(e,t)=>a===`failed`&&s===e?`Could not export: ${l??`unknown reason`}`:t;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>void m(`plain`),disabled:a===`working`,title:_(`plain`,`Download as a Word document`),"aria-label":`Download as a Word document`,className:h,children:g(`plain`,`⤓ word`)}),i!==void 0&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>void m(`template`),disabled:a===`working`,title:_(`template`,`Download as a Word document in the template ${i}`),"aria-label":`Download as a Word document in the template ${i}`,className:h,children:g(`template`,`⤓ word · template`)})]})}function CF({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,k.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,k.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,k.jsx)(`span`,{className:`shrink-0 tabular-nums text-zinc-500 dark:text-zinc-400`,children:p}),(0,k.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,k.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,k.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 wF=3e3;function TF(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function EF(e,t,n=1/0){if(t===``)return[];let r=new RegExp(TF(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 DF(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 OF(e,t,n=wF){let r={matches:[],truncated:!1,clear:()=>{}};if(t===``)return r;let{nodes:i,text:a}=DF(e);if(a===``)return r;let o=EF(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 kF=(0,d.lazy)(()=>A(()=>import(`./PdfViewer-DHIy06i5.js`),[])),AF=250,jF=`(min-width: 768px)`;function MF(){let[e,t]=(0,d.useState)(()=>window.matchMedia?.(jF).matches??!0);return(0,d.useEffect)(()=>{let e=window.matchMedia?.(jF);if(e===void 0)return;let n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function NF(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 PF(e){let t=Oc(e);return t.status===`valid`?t.envelope:void 0}function FF(e){return/\.(md|markdown)$/i.test(e)}function IF(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function LF({file:e,writableRoot:t,isStreaming:n,onDirtyChange:r,gitState:i,initialShowGitDiff:a=!1,gitDiff:o,onFetchGitDiff:s,onClearGitDiff:c,inRepository:l,onOpenGitHistory:u,onClose:f,onReload:p,onSave:m,serverUrl:h=``,token:g=null,docxTemplate:_,onImageLoad:v,onPdfLoad:y,rawRevision:b=0}){let[x,ee]=(0,d.useState)(`rendered`),[C,w]=(0,d.useState)(a),[T,ne]=(0,d.useState)(e.status===`loaded`&&e.justCreated?{draft:e.content,baseContent:e.content,baseMtimeMs:e.mtimeMs}:null),[re,ie]=(0,d.useState)(`idle`),se=(0,d.useRef)(null),D=(0,d.useRef)(null),O=e.status===`loaded`?e:null,ue=O!==null&&FF(e.path),de=oe(e.path),fe=E(e.path),A=(0,d.useMemo)(()=>O===null?void 0:Oc(O.content),[O?.content]),pe=A?.status===`valid`,me=A?.status===`valid`||A?.status===`invalid`,he=me||ue,ge=x===`source`,_e=MF(),ye=IF(e.path,t)&&!fe,be=T!==null&&T.draft!==T.baseContent,xe=O?.pendingSave!==void 0,Se=T!==null&&O!==null&&O.mtimeMs!==T.baseMtimeMs,Ce=O?.saveError?.conflict===!0||Se,we=T?.draft??O?.content??``,Te=NF(we,AF),Ee=(0,d.useMemo)(()=>O===null?void 0:Oc(Te),[Te,O===null]),[De,Oe]=(0,d.useState)(()=>e.status===`loaded`?PF(e.content):void 0);(0,d.useEffect)(()=>{Ee?.status===`valid`&&Oe(Ee.envelope)},[Ee]);let ke=Ee!==void 0&&Ee.status!==`valid`&&De!==void 0,Ae=Ee?.status===`invalid`?Te===O?.content&&O.documentIssues!==void 0?O.documentIssues:Ee.issues:void 0,je=Ee?.status===`not-a-document`?Ee.why===`unparseable`?`This is not parseable JSON yet.`:"This no longer declares a structured-exchange `schema`.":Ee?.status===`unsupported-version`?`This declares ${Ee.schema}, which this version does not render.`:void 0,Me=x===`split`&&he&&!C&&O!==null&&_e,Ne=C||Me?`none`:fe?`pdf`:T===null?O!==null&&!de?`dom`:`none`:`edit`,[Pe,Fe]=(0,d.useState)(!1),[Ie,Le]=(0,d.useState)(``),[Re,Be]=(0,d.useState)(0),Ve=(0,d.useRef)(null),Ue=(0,d.useRef)(null),We=(0,d.useRef)(null),[Ge,Ke]=(0,d.useState)({matchCount:0,currentIndex:-1,searching:!1}),[qe,Je]=(0,d.useState)([]),[Ye,Xe]=(0,d.useState)(!1),Ze=(0,d.useRef)(null),Qe=(0,d.useRef)([]),$e=(0,d.useRef)(0),et=(0,d.useRef)(``);function tt(e){$e.current=e;for(let[t,n]of Qe.current.entries())for(let r of n.marks)r.isConnected&&r.classList.toggle(`find-match-current`,t===e);let t=Qe.current[e]?.marks;t?.[0]?.isConnected&&t[0].scrollIntoView({block:`center`})}let nt=Pe?Ie:``,rt=(0,d.useMemo)(()=>Ne===`edit`?EF(we,nt):[],[Ne,we,nt]);(0,d.useEffect)(()=>{Pe&&Ne===`none`&&Fe(!1)},[Pe,Ne]);let[it,at]=(0,d.useState)(0),ot=(0,d.useCallback)(()=>at(e=>e+1),[]);(0,d.useEffect)(()=>{function e(){Ze.current?.clear(),Ze.current=null,Qe.current=[],Je([]),Xe(!1)}let t=Ue.current;if(Ne!==`dom`||nt===``||t===null){e();return}Ze.current?.clear();let n=OF(t,nt);Ze.current=n,Qe.current=n.matches,Je(n.matches),Xe(n.truncated);let r=nt!==et.current;et.current=nt;let i=r?0:Math.min($e.current,Math.max(n.matches.length-1,0));return Be(i),tt(i),e},[Ne,nt,x,ge,it]);function st(e,t){let n=e[t],r=se.current;n!==void 0&&r!==null&&(r.focus(),r.setSelectionRange(n.start,n.end),Ve.current?.focus())}(0,d.useEffect)(()=>{if(Ne!==`edit`||!Pe)return;let e=EF(we,nt);Be(0),e.length>0&&st(e,0)},[nt,Ne,Pe]);function ct(){Fe(!0)}function lt(){Fe(!1)}function ut(){if(Ne===`pdf`)We.current?.findNext();else if(Ne===`edit`){if(rt.length===0)return;let e=(Re+1)%rt.length;Be(e),st(rt,e)}else{let e=Qe.current.length;if(e===0)return;let t=($e.current+1)%e;Be(t),tt(t)}}function dt(){if(Ne===`pdf`)We.current?.findPrevious();else if(Ne===`edit`){if(rt.length===0)return;let e=(Re-1+rt.length)%rt.length;Be(e),st(rt,e)}else{let e=Qe.current.length;if(e===0)return;let t=($e.current-1+e)%e;Be(t),tt(t)}}let ft=Ne===`pdf`?{matchCount:Ge.matchCount,currentIndex:Ge.currentIndex,truncated:!1,searching:Ge.searching}:Ne===`edit`?{matchCount:rt.length,currentIndex:rt.length>0?Math.min(Re,rt.length-1):-1,truncated:!1,searching:!1}:{matchCount:qe.length,currentIndex:qe.length>0?Math.min(Re,qe.length-1):-1,truncated:Ye,searching:!1},pt=T===null?null:(0,k.jsx)(`textarea`,{ref:se,value:T.draft,onChange:e=>ne({...T,draft:e.target.value}),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),be&&!xe&&!Ce&&vt())},spellCheck:!1,className:`h-full w-full resize-none bg-transparent p-4 font-mono text-[13px] leading-relaxed text-zinc-800 outline-none ring-inset focus-visible:ring-1 focus-visible:ring-zinc-300 dark:text-zinc-200 dark:focus-visible:ring-zinc-700`});function mt(t){return(0,k.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,k.jsx)(Hg,{remarkPlugins:[CM,FM],rehypePlugins:[iw],components:{pre:ze,a:({href:t,children:n,...r})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,k.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...r,children:n}):t.startsWith(`#`)?(0,k.jsx)(`a`,{href:t,...r,children:n}):(0,k.jsx)(`a`,{href:t,onClick:n=>{n.preventDefault(),p(ae(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(`//`)?ce(h,ae(e.path,t),g):t;return(0,k.jsx)(`img`,{...r,src:i,alt:n??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:te(t)})})}function ht(e){x===`split`&&e!==`split`&&be&&!window.confirm(`Discard unsaved changes?`)||(x===`split`&&e!==`split`&&ne(null),ee(e))}function gt(){be&&!window.confirm(`Discard unsaved changes?`)||f()}function _t(){O&&ne({draft:O.content,baseContent:O.content,baseMtimeMs:O.mtimeMs})}function vt(t=!1){!O||T===null||xe||(D.current=T.draft,m(e.path,T.draft,T.baseMtimeMs,t))}function yt(){ne(null),p(e.path)}function bt(){let t=!C;w(t),t?s(e.path):c()}return(0,d.useEffect)(()=>{if(T!==null&&O!==null&&D.current!==null&&O.content===D.current&&O.mtimeMs!==T.baseMtimeMs){let e=D.current;D.current=null,T.draft===e?ne(null):ne({...T,baseContent:O.content,baseMtimeMs:O.mtimeMs})}},[O?.mtimeMs]),(0,d.useEffect)(()=>{function e(e){if(e.key===`Escape`){Pe?lt():gt();return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`f`){if(Ne===`none`)return;e.preventDefault(),ct()}}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,d.useEffect)(()=>{Me&&ye&&T===null&&O!==null&&ne({draft:O.content,baseContent:O.content,baseMtimeMs:O.mtimeMs})},[Me,ye,O?.mtimeMs]),(0,d.useEffect)(()=>{ie(n?`streaming`:e=>e===`streaming`?`done`:e)},[n]),(0,d.useEffect)(()=>(r(be),()=>r(!1)),[be]),(0,d.useEffect)(()=>(a&&s(e.path),()=>c()),[]),(0,k.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[he&&!C&&(0,k.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,k.jsx)(`button`,{type:`button`,onClick:()=>ht(e),"aria-pressed":x===e,title:n,className:`rounded px-1.5 py-0.5 text-xs ${x===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&&T===null&&(0,k.jsx)(`button`,{type:`button`,onClick:bt,"aria-pressed":C,title:C?`Show file content`:`Show uncommitted changes (vs HEAD)`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs ${C?`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`}),l&&T===null&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>u(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,k.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,be&&(0,k.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),O&&!de&&!fe&&!C&&(0,k.jsx)(SF,{text:we,path:e.path,serverUrl:h,token:g,template:_}),O&&T===null&&(0,k.jsx)(le,{text:O.content}),O&&T===null&&!C&&ye&&(0,k.jsx)(`button`,{type:`button`,onClick:_t,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`}),O&&T===null&&!ye&&(0,k.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,title:`Outside the writable zone`,children:`🔒 read-only`}),T!==null&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>vt(),disabled:!be||xe||Ce,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:xe?`saving…`:`save`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{be&&!window.confirm(`Discard unsaved changes?`)||ne(Me&&O!==null?{draft:O.content,baseContent:O.content,baseMtimeMs:O.mtimeMs}:null)},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:`cancel`})]}),(0,k.jsx)(`button`,{type:`button`,onClick:gt,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:`✕`})]}),Pe&&Ne!==`none`&&(0,k.jsx)(CF,{inputRef:Ve,query:Ie,onQueryChange:Le,matchCount:ft.matchCount,currentIndex:ft.currentIndex,truncated:ft.truncated,searching:ft.searching,onNext:ut,onPrev:dt,onClose:lt}),Ce&&T!==null&&(0,k.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,k.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,k.jsx)(`button`,{type:`button`,onClick:yt,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,k.jsx)(`button`,{type:`button`,onClick:()=>vt(!0),disabled:xe,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`})]}),T!==null&&O?.saveError&&!O.saveError.conflict&&(0,k.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:O.saveError.message}),(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[C&&T===null&&(0,k.jsxs)(`div`,{className:`p-4`,children:[o?.path===e.path&&`error`in o&&(0,k.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,k.jsx)(He,{fill:!0,lines:S(o.before,o.after)}),o?.path!==e.path&&(0,k.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),fe&&T===null&&!C&&(0,k.jsx)(Zl,{label:`This PDF`,children:(0,k.jsx)(d.Suspense,{fallback:(0,k.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),children:(0,k.jsx)(kF,{ref:We,path:e.path,serverUrl:h,token:g,revision:b,findQuery:Ne===`pdf`?nt:``,onFindStateChange:Ke,...y?{onLoaded:y}:{}})})}),de&&T===null&&!C&&(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,k.jsx)(`img`,{src:ce(h,e.path,g,b),alt:e.path,onLoad:()=>v(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&T===null&&!C&&!de&&!fe&&(0,k.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!de&&!fe&&(0,k.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),T!==null&&!Me&&pt,O&&T===null&&!Me&&!C&&ue&&!ge&&(0,k.jsx)(`div`,{ref:Ue,children:mt(O.content)}),Me&&(0,k.jsxs)(`div`,{className:`flex h-full min-h-0`,"data-testid":`file-split`,children:[(0,k.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto border-r border-zinc-200 dark:border-zinc-800`,children:pt??(0,k.jsx)(`div`,{className:`p-4`,children:(0,k.jsx)(ve,{code:O.content,path:e.path})})}),(0,k.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto`,"data-testid":`file-split-rendering`,children:ue&&!me?(0,k.jsx)(`div`,{className:`prose-chat p-4 text-zinc-700 dark:text-zinc-300`,children:mt(Te)}):(0,k.jsxs)(k.Fragment,{children:[ke&&(0,k.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,k.jsxs)(`span`,{children:[`Showing the document as it last stood.`,` `,je??`The text beside it does not satisfy the schema it declares.`]})}),Ae!==void 0&&(0,k.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:[Ae.slice(0,6).map((e,t)=>(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),Ae.length>6&&(0,k.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,Ae.length-6,` more`]})]}),De===void 0?(0,k.jsxs)(`p`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,"data-testid":`file-split-nothing`,children:[`Nothing to draw yet. `,je??`This document does not satisfy the schema it declares.`]}):(0,k.jsx)(Zl,{label:`This diagram`,children:(0,k.jsx)(`div`,{className:`p-4`,"data-testid":`file-structured-exchange`,children:(0,k.jsx)(Jl,{envelope:De,source:we})})})]})})]}),O&&T===null&&!Me&&!C&&pe&&!ge&&A?.status===`valid`&&(0,k.jsx)(Zl,{label:`This diagram`,children:(0,k.jsx)(`div`,{className:`mx-auto max-w-5xl p-4`,"data-testid":`file-structured-exchange`,children:(0,k.jsx)(Jl,{envelope:A.envelope,source:O.content})})}),O&&T===null&&!Me&&!C&&A?.status===`invalid`&&(0,k.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,k.jsx)(`p`,{className:`font-medium`,children:`This declares a structured-exchange document and does not satisfy the schema.`}),(0,k.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:[(O.documentIssues??A.issues).slice(0,8).map((e,t)=>(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),(O.documentIssues??A.issues).length>8&&(0,k.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,(O.documentIssues??A.issues).length-8,` more`]})]})]}),O&&T===null&&!Me&&!C&&A?.status===`unsupported-version`&&(0,k.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,k.jsx)(`span`,{className:`font-mono`,children:A.schema}),`, which this version does not render. Shown as text.`]}),O&&T===null&&!Me&&!C&&(!ue||ge)&&(!pe||ge)&&(0,k.jsx)(`div`,{ref:Ue,className:`p-4`,children:(0,k.jsx)(ve,{code:O.content,path:e.path,onRendered:ot})})]}),re!==`idle`&&(0,k.jsxs)(`button`,{type:`button`,onClick:gt,"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:[re===`streaming`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,k.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,k.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,k.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function RF(e){return e.split(`
334
334
  `).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 zF({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,k.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsx)(`span`,{className:`font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,12)}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`commit diff`}),(0,k.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,k.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,k.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed`,children:RF(e.patch).map((e,t)=>(0,k.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 BF=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],VF=`worktree`,HF={defaultWidth:288,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.files-sidebar-width.v1`},UF={defaultWidth:416,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.history-list-width.v1`};function WF(e,t){return Number.isFinite(e)?Math.min(t.maxWidth,Math.max(t.minWidth,Math.round(e))):t.defaultWidth}function GF(e,t){return e===null||e.trim()===``?t.defaultWidth:WF(Number(e),t)}function KF(e,t){try{return GF((t??window.localStorage).getItem(e.storageKey),e)}catch{return e.defaultWidth}}function qF(e,t,n){try{(n??window.localStorage).setItem(t.storageKey,String(WF(e,t)))}catch{}}function JF(e){let[t,n]=(0,d.useState)(()=>KF(e)),r=(0,d.useRef)(t),i=(0,d.useRef)(null),a=(0,d.useCallback)(t=>{let i=WF(t,e);return r.current=i,n(i),i},[e]),o=(0,d.useCallback)(()=>{i.current!==null&&(i.current=null,qF(r.current,e))},[e]);return{width:t,separatorProps:{onPointerDown:e=>{e.isPrimary!==!1&&(e.button??0)===0&&(e.preventDefault(),e.currentTarget.setPointerCapture?.(e.pointerId),i.current={pointerId:e.pointerId,startX:e.clientX,startWidth:r.current})},onPointerMove:e=>{let t=i.current;t!==null&&t.pointerId===e.pointerId&&a(t.startWidth+e.clientX-t.startX)},onPointerUp:e=>{i.current?.pointerId===e.pointerId&&o()},onPointerCancel:e=>{let t=i.current;t!==null&&t.pointerId===e.pointerId&&(i.current=null,a(t.startWidth))},onLostPointerCapture:o,onKeyDown:t=>{let n=null;t.key===`ArrowLeft`?n=r.current-e.keyboardStep:t.key===`ArrowRight`?n=r.current+e.keyboardStep:t.key===`Home`&&(n=e.defaultWidth),n!==null&&(t.preventDefault(),qF(a(n),e))}}}}function YF({label:e,width:t,config:n,separatorProps:r,className:i=``}){return(0,k.jsx)(`div`,{...r,role:`separator`,"aria-label":e,"aria-orientation":`vertical`,"aria-valuemin":n.minWidth,"aria-valuemax":n.maxWidth,"aria-valuenow":t,tabIndex:0,title:e,className:`group absolute inset-y-0 -right-1 z-20 w-2 cursor-col-resize touch-none outline-none ${i}`,children:(0,k.jsx)(`span`,{className:`pointer-events-none absolute 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 XF=`#10b981`,ZF=[`#8b5cf6`,`#f59e0b`,`#0ea5e9`,`#f43f5e`,`#14b8a6`,`#d946ef`];function QF(e){return e===0?XF:ZF[(e-1)%ZF.length]}function $F(e){return ZF[e%ZF.length]}function eI(e){return e*14+7+1}function tI(e){return e*14+2}function nI({row:e,laneCount:t,colorOf:n=QF}){let r=tI(t),i=eI(e.lane),a=e.highlight?XF:n(e.lane),o=e.dashed?`3 3`:void 0;return(0,k.jsxs)(`svg`,{width:r,height:36,viewBox:`0 0 ${r} 36`,"aria-hidden":!0,className:`shrink-0`,children:[e.through.map(e=>(0,k.jsx)(`line`,{x1:eI(e),y1:0,x2:eI(e),y2:36,stroke:n(e),strokeWidth:2,opacity:.55},e)),e.lineAbove&&(0,k.jsx)(`line`,{x1:i,y1:0,x2:i,y2:18,stroke:a,strokeWidth:2,strokeDasharray:o}),e.lineBelow&&(0,k.jsx)(`line`,{x1:i,y1:18,x2:i,y2:36,stroke:a,strokeWidth:2,strokeDasharray:o}),e.forkTo.map(e=>(0,k.jsx)(`path`,{d:`M ${i} 18 C ${i} 36, ${eI(e)} 18, ${eI(e)} 36`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`fork-${e}`)),(e.mergeFrom??[]).map(e=>(0,k.jsx)(`path`,{d:`M ${i} 18 C ${i} 0, ${eI(e)} 18, ${eI(e)} 0`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`merge-${e}`)),e.emphasis===`current`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`circle`,{cx:i,cy:18,r:6,fill:`none`,stroke:a,strokeWidth:2}),(0,k.jsx)(`circle`,{cx:i,cy:18,r:2.5,fill:a})]}):(0,k.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 rI(e,t={}){let n=[],r=[],i=0,a=()=>{let e=r.indexOf(null);return e===-1?(r.push(null),i=Math.max(i,r.length),r.length-1):e};for(let t of e){let e=r.reduce((e,n,r)=>n===t.sha?[...e,r]:e,[]),o=e[0]??a(),s=e.slice(1);for(let e of s)r[e]=null;i=Math.max(i,o+1);let[c,...l]=t.parents;r[o]=c??null;let u=l.map(e=>{let t=a();return r[t]=e,t});n.push({rev:t.sha,path:t.path,entry:t,lane:o,through:r.reduce((e,t,n)=>t!==null&&n!==o&&!u.includes(n)?[...e,n]:e,[]),forkTo:u,mergeFrom:s,lineAbove:!0,lineBelow:t.parents.length>0,emphasis:`filled`})}let o=n[0];return n.unshift({rev:VF,path:o?.path??``,lane:o?.lane??0,through:o?.through??[],forkTo:[],mergeFrom:[],lineAbove:!1,lineBelow:n.length>0,emphasis:`current`,dashed:!t.dirty}),n[1]&&(n[1].lineAbove=!0),{rows:n,laneCount:Math.max(i,1)}}var iI=20;function aI(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 oI(e){return e.rev===`worktree`?`working tree`:e.rev.slice(0,7)}function sI(e,t){return e!==null&&t!==null&&e.rev===t.rev&&e.path===t.path}function cI(e){return{rev:e.rev,path:e.path}}function lI({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=JF(UF),{rows:h,laneCount:g}=(0,d.useMemo)(()=>rI(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||sI(c,l)||_.current.onFetchDiff(c,l)},[c,l]);let v=(0,d.useCallback)((e,t)=>{let n=cI(e);s(r=>{if(t===`base`)return{base:n,target:sI(n,r.target)?r.base:r.target};if(t===`target`)return{base:sI(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?cI(r):null,target:n}}return{base:sI(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=cI(e);return sI(t,c)?`base`:sI(t,l)?`target`:null},ee=h.findIndex(e=>sI(cI(e),c)),C=h.findIndex(e=>sI(cI(e),l)),w=ee>=0&&C>=0?{top:Math.min(ee,C)*36+18,height:Math.abs(C-ee)*36}:null;return(0,k.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.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,k.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-zinc-500 dark:text-zinc-400`,"aria-label":`Comparing ${oI(c)} to ${oI(l)}`,children:[(0,k.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:oI(c)}),` → `,(0,k.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:oI(l)})]}),c!==null&&l!==null&&(0,k.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,k.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,k.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,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,k.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,k.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,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`Reading history…`}),e.status===`error`&&(0,k.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,k.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,k.jsxs)(`div`,{className:`relative`,role:`group`,"aria-label":`Commits`,children:[w&&(0,k.jsx)(uI,{top:w.top,height:w.height,baseFirst:ee<C}),h.map((e,t)=>(0,k.jsx)(pI,{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,k.jsx)(YF,{label:`Resize History commit list`,width:m.width,config:UF,separatorProps:m.separatorProps,className:`hidden md:block`})]}),(0,k.jsx)(`div`,{role:`region`,"aria-label":`History diff`,className:`min-h-0 min-w-0 flex-1 overflow-auto p-3`,children:(0,k.jsx)(mI,{diff:t,base:c,target:l})})]})]})}function uI({top:e,height:t,baseFirst:n}){return(0,k.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:iI},children:[(0,k.jsx)(`div`,{className:`absolute inset-y-0 left-2 w-px bg-zinc-400 dark:bg-zinc-500`}),(0,k.jsx)(dI,{label:n?`base`:`target`,className:`top-0`}),(0,k.jsx)(dI,{label:n?`target`:`base`,className:`bottom-0`})]})}function dI({label:e,className:t}){return(0,k.jsx)(`div`,{className:`absolute left-2 flex h-px w-2.5 items-center bg-zinc-400 dark:bg-zinc-500 ${t}`,children:(0,k.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 fI=`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 pI({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,k.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:iI},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,k.jsx)(nI,{row:e,laneCount:t}),s?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:s.sha.slice(0,7)}),(0,k.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,k.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-600`,children:[s.author,` · `,aI(s.date)]}),(0,k.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums`,"aria-label":`${s.added} lines added, ${s.deleted} removed`,children:[(0,k.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-500`,children:[`+`,s.added]}),` `,(0,k.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,s.deleted]})]})]}):(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`working tree`}),(0,k.jsxs)(`span`,{className:`flex shrink-0 gap-0.5`,children:[(0,k.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:fI,children:`base`}),(0,k.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:fI,children:`target`})]})]})}function mI({diff:e,base:t,target:n}){return t===null&&n===null?(0,k.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,k.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,k.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,k.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Loading…`}):e.status===`loaded`&&e.beforeText===e.afterText?(0,k.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,k.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions differ only in their line endings.`}):(0,k.jsx)(`div`,{className:e.status===`loading`?`opacity-40`:void 0,children:(0,k.jsx)(He,{fill:!0,lines:S(e.beforeText,e.afterText)})})}function hI(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 gI={stopped:`stopped`,starting:`starting…`,idle:`idle`,working:`working`,waiting:`waiting for you`,"ready-for-review":`ready for review`};function _I({activity:e}){switch(e){case`stopped`:return(0,k.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,k.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,k.jsx)(`path`,{d:`M12 3a9 9 0 0 1 9 9`})});case`working`:return(0,k.jsxs)(`span`,{className:`relative flex h-2 w-2 shrink-0 items-center justify-center`,children:[(0,k.jsx)(`span`,{className:`absolute h-2 w-2 animate-ping rounded-full bg-blue-700 opacity-60 dark:bg-blue-400`}),(0,k.jsx)(`span`,{className:`relative h-2 w-2 rounded-full bg-blue-700 dark:bg-blue-400`})]});case`waiting`:return(0,k.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-amber-500`});case`ready-for-review`:return(0,k.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,k.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-zinc-400 dark:bg-zinc-600`})}}function vI({className:e}){return(0,k.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,k.jsx)(`path`,{d:`M12 6v7`}),(0,k.jsx)(`path`,{d:`M12 18h.01`})]})}function yI({className:e}){return(0,k.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,k.jsx)(`path`,{d:`M7 3h10v18H7z`}),(0,k.jsx)(`path`,{d:`m9.5 12 1.7 1.7 3.5-3.7`})]})}function bI(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=>{qP(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=>AN(e)!==AN(t)),c=n.filter(e=>!e.sideOf).length,l=n.filter(e=>e.needsAttention);return(0,k.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-expanded":i,"aria-haspopup":`menu`,title:`Project: ${t.name} (${gI[t.activity]})`,className:`flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs ${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,k.jsx)(_I,{activity:t.activity}),(0,k.jsx)(`span`,{className:`font-medium`,children:t.name}),l.length>0?(0,k.jsxs)(`span`,{className:`flex items-center gap-1 text-amber-600 dark:text-amber-500`,children:[(0,k.jsx)(vI,{className:`h-3 w-3`}),(0,k.jsx)(`span`,{className:`font-semibold`,children:l.length})]}):s.some(e=>e.activity===`working`)&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`h-3 w-px bg-zinc-300 dark:bg-zinc-600`}),(0,k.jsx)(`span`,{className:`flex items-center gap-1`,children:s.map(e=>e.activity===`working`?(0,k.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5 items-center justify-center`,children:[(0,k.jsx)(`span`,{className:`absolute h-1.5 w-1.5 animate-ping rounded-full bg-blue-700 opacity-60 dark:bg-blue-400`}),(0,k.jsx)(`span`,{className:`relative h-1.5 w-1.5 rounded-full bg-blue-700 dark:bg-blue-400`})]},AN(e)):(0,k.jsx)(`span`,{className:`h-1 w-1 rounded-full bg-zinc-300 dark:bg-zinc-600`},AN(e)))})]}),(0,k.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,k.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),i&&(0,k.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:[hI(n).map(n=>{let r=AN(n),i=r===AN(t),o=n.sideOf!==void 0;return(0,k.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,k.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{a(!1),i||(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,k.jsx)(_I,{activity:n.activity}),(0,k.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,k.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,k.jsx)(`span`,{className:`truncate font-mono text-[11px] text-zinc-400 dark:text-zinc-500`,children:n.root})]})]}),(0,k.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[n.needsAttention?(0,k.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,k.jsx)(yI,{className:`h-3 w-3`}):(0,k.jsx)(vI,{className:`h-3 w-3`}),gI[n.activity]]}):(0,k.jsx)(`span`,{className:`text-[11px] ${n.activity===`working`?`text-blue-700 dark:text-blue-400`:`text-zinc-400 dark:text-zinc-500`}`,children:gI[n.activity]}),!o&&e.onOpenSide&&(0,k.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,k.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,k.jsx)(`path`,{d:`M12 5v14`}),(0,k.jsx)(`path`,{d:`M5 12h14`})]})}),(o||c>1)&&(0,k.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,k.jsxs)(`svg`,{className:`h-2.5 w-2.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,k.jsx)(`path`,{d:`M18 6 6 18`}),(0,k.jsx)(`path`,{d:`m6 6 12 12`})]})})]})]},r)}),(0,k.jsx)(`div`,{className:`my-1 h-px bg-zinc-200 dark:bg-zinc-700`}),(0,k.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,k.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,k.jsx)(`path`,{d:`M12 5v14`}),(0,k.jsx)(`path`,{d:`M5 12h14`})]}),`Open a project…`]})]})]})}function xI({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,k.jsxs)(`div`,{className:`rounded-md border border-zinc-300 p-2 dark:border-zinc-700`,"data-testid":`server-path-picker`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-xs font-semibold text-zinc-600 dark:text-zinc-300`,children:e}),(0,k.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,k.jsxs)(`form`,{className:`mb-2 flex gap-1`,onSubmit:e=>{e.preventDefault();let t=c.trim();t&&n(t)},children:[(0,k.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,k.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,k.jsx)(`p`,{role:`alert`,className:`mb-2 text-xs text-red-600 dark:text-red-400`,children:t.error}),(0,k.jsxs)(`div`,{className:`mb-2 flex gap-2`,children:[(0,k.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,k.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,k.jsxs)(`ul`,{className:`max-h-40 overflow-y-auto`,children:[s&&o.length===0&&(0,k.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400`,children:`Loading…`}),!s&&o.length===0&&t?.status!==`error`&&(0,k.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No subdirectories`}),o.map(e=>(0,k.jsx)(`li`,{children:(0,k.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 SI(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function CI(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)(()=>{if(s.current&&n?.status!==`applying`){if(n?.status===`error`){s.current=!1;return}s.current=!1,o(!1),i()}},[n,i]),!t)return(0,k.jsx)(`span`,{className:`rounded-md border border-dashed border-zinc-300 px-2 py-1 text-xs 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=SI(t.root);return(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.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:`flex max-w-[14rem] items-center gap-1.5 rounded-md border px-2 py-1 text-xs ${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,k.jsx)(`span`,{className:`truncate font-mono`,children:l}),c?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):(0,k.jsx)(`span`,{"aria-hidden":`true`,children:`▾`})]}),a&&!r&&(0,k.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,k.jsx)(`p`,{role:`alert`,className:`mb-2 text-xs text-red-600 dark:text-red-400`,children:n.message}),(0,k.jsx)(xI,{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 wI(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 TI(e){return e.slice(e.lastIndexOf(`/`)+1)}function EI({status:e,selected:t,log:n,onFetchLog:r,onShowCommit:i}){let[a,o]=(0,d.useState)(!1),s=JP(()=>o(!1)),c=e?.repos??[],l=(t===null?null:vP(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!==``?`${TI(l.repo)} `:``,p=e===null?`…`:l?.branch??`—`,m=l!==null&&n?.repo===l.repo?n.entries:null;return(0,d.useEffect)(()=>{a&&l!==null&&n?.repo!==l.repo&&r(l.repo)},[a,l?.repo,r]),(0,k.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,k.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:`rounded-md border border-zinc-300 px-2 py-1 font-mono text-xs 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:[f,`⎇ `,p,u]}),a&&l!==null&&(0,k.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,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),m?.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no commits`}),m?.map(e=>(0,k.jsxs)(`button`,{type:`button`,onClick:()=>{i(l.repo,e.sha),o(!1)},className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,k.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,7)}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-700 dark:text-zinc-300`,title:e.subject,children:e.subject}),(0,k.jsxs)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:[e.author,` · `,wI(e.date)]})]},e.sha))]})]})}function DI(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 OI({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,k.jsxs)(`div`,{className:`mt-3`,"data-testid":`pi-packages`,children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,k.jsx)(`span`,{className:`text-xs font-medium text-zinc-600 dark:text-zinc-400`,children:`Packages`}),(0,k.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,k.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,k.jsxs)(`li`,{"data-testid":`pi-package`,className:`rounded bg-zinc-50 px-2 py-1 text-xs dark:bg-zinc-800`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.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,k.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,k.jsx)(`div`,{className:`line-clamp-2 text-zinc-500 dark:text-zinc-400`,"data-testid":`pi-package-status`,title:DI(e),children:DI(e)}),r&&a===e.source&&(0,k.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,k.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,k.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,k.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,k.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,k.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 kI({reasons:e,canRestart:t,restarting:n,onRestart:r}){let[i,a]=(0,d.useState)(!1);return e.length===0?null:(0,k.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,k.jsxs)(`p`,{children:[`Installed and waiting on a restart to run: `,e.join(`, `),`.`]}),t?n?(0,k.jsx)(`p`,{className:`mt-1`,children:`Restarting pi-outpost…`}):i?(0,k.jsxs)(`div`,{className:`mt-1`,children:[(0,k.jsx)(`p`,{children:`pi-outpost stops and starts again in the same terminal. Every open window reconnects by itself, and conversations are kept.`}),(0,k.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,k.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,k.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,k.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 AI=30,jI={display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`};function MI({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,k.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,"aria-label":`Collection skills`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,k.jsxs)(`h3`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:[`Skills `,(0,k.jsxs)(`span`,{className:`font-normal text-zinc-500`,children:[`· `,_,` of `,e.length,` on`]})]}),(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.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,k.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,k.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,k.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,k.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,k.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&&_<=AI?(0,k.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,k.jsx)(`p`,{className:`px-1 text-[11px] font-medium text-emerald-800 dark:text-emerald-300`,children:`Turned on`}),(0,k.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.filter(e=>n.has(e.relativePath)).map(e=>(0,k.jsxs)(`li`,{className:`flex items-start justify-between gap-2 px-1`,children:[(0,k.jsxs)(`span`,{className:`min-w-0 text-xs`,children:[(0,k.jsx)(`span`,{className:`font-medium text-zinc-800 dark:text-zinc-100`,children:e.name}),` `,(0,k.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.group||`(repository root)`}),(0,k.jsx)(NI,{skill:e,checked:!0})]}),(0,k.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,k.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`This repository holds no skills.`}):null,m&&v===0?(0,k.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:u&&!p?`No skill is on.`:`No skill matches.`}):null,(0,k.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,k.jsxs)(`li`,{className:`rounded-lg border border-zinc-100 dark:border-zinc-800`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,k.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,k.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-zinc-400`,children:s?`▾`:`▸`}),(0,k.jsx)(`span`,{className:`truncate font-mono text-xs font-medium text-zinc-700 dark:text-zinc-200`,children:e.label}),(0,k.jsxs)(`span`,{className:`shrink-0 text-[11px] text-zinc-500`,children:[a,`/`,r.length,` on`]})]}),(0,k.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,k.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,k.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,k.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,k.jsx)(`li`,{children:(0,k.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,k.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,k.jsxs)(`span`,{className:`min-w-0`,children:[(0,k.jsx)(`span`,{className:`block truncate text-sm text-zinc-800 dark:text-zinc-100`,children:e.name}),e.description?(0,k.jsx)(`span`,{title:e.description,style:jI,className:`text-[11px] text-zinc-500`,children:e.description}):null,(0,k.jsx)(NI,{skill:e,checked:t})]})]})},e.relativePath)})}):null]},e.path)})})]})}function NI({skill:e,checked:t}){return t===(e.state!==`off`)?e.state===`on-loaded`?(0,k.jsx)(`span`,{className:`block text-[11px] text-emerald-700 dark:text-emerald-400`,children:`Loaded`}):e.state===`on-not-loaded`?(0,k.jsxs)(`span`,{className:`block text-[11px] text-amber-700 dark:text-amber-400`,children:[`Not loaded — `,e.reason]}):e.state===`on-missing`?(0,k.jsxs)(`span`,{className:`block text-[11px] text-rose-700 dark:text-rose-400`,children:[`Missing — `,e.reason]}):null:(0,k.jsx)(`span`,{className:`block text-[11px] font-medium text-sky-700 dark:text-sky-300`,children:t?`Pending: on`:`Pending: off`})}function PI(e,t){return[...new Set(e.map(e=>e.group))].sort().map(e=>({path:e,label:e||t}))}function FI(e){return e.skills.filter(e=>e.state!==`off`).map(e=>e.relativePath)}function II(e,t){let n=new Set(e),r=new Set(t);return n.size===r.size&&[...n].every(e=>r.has(e))}function LI(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 RI={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 zI(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 BI(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 VI(e){let t=BI(e),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<=0?`/`:t.slice(0,n)}function HI(e,t){let n=BI(t),r=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`)),i=r>=0?n.slice(r+1):n;return`${BI(e)}/${i||`agent-resources`}`}function UI({kind:e,resources:t,removalLocked:n=!1,onRemove:r}){return(0,k.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,children:[(0,k.jsxs)(`h3`,{className:`flex items-center justify-between text-sm font-semibold capitalize text-zinc-800 dark:text-zinc-200`,children:[(0,k.jsxs)(`span`,{children:[e,`s`]}),(0,k.jsx)(`span`,{className:`text-xs font-normal text-zinc-400`,children:t.length})]}),t.length===0?(0,k.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`None in this group`}):(0,k.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>(0,k.jsxs)(`li`,{className:`rounded-lg bg-zinc-50 px-3 py-2 dark:bg-zinc-800/70`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.jsx)(`p`,{className:`truncate text-sm font-medium text-zinc-700 dark:text-zinc-200`,children:e.name}),e.userRoot&&!n?(0,k.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,k.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 WI({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)(()=>PI(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,k.jsxs)(`div`,{className:`space-y-3`,"data-testid":`resource-preview`,children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`h3`,{className:`truncate text-xl font-semibold text-zinc-900 dark:text-zinc-100`,children:e.repositoryName}),(0,k.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-500`,title:e.repositoryPath,children:e.repositoryPath})]}),(0,k.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:i,className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,k.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,k.jsx)(`p`,{className:`text-xs text-amber-700`,children:`Confirm the extension warning below to save.`}):null,n?(0,k.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:n}):null,f?(0,k.jsx)(MI,{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,k.jsxs)(`label`,{className:`flex items-start gap-2 rounded border p-2 ${e.locked?`opacity-50`:`cursor-pointer`}`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:a.has(t),disabled:e.locked,onChange:()=>y(t)}),(0,k.jsxs)(`span`,{children:[(0,k.jsxs)(`span`,{className:`block text-sm`,children:[e.name,` · `,e.kind]}),(0,k.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.path}),e.locked?(0,k.jsx)(`span`,{className:`block text-xs text-amber-700`,children:`Extension paths are locked`}):null]})]},t)}),h.length>0?(0,k.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),(0,k.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust the selected extension roots in this repository.`})]}):null]})}function GI(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),[ee,C]=(0,d.useState)(``),[w,T]=(0,d.useState)(``),[te,ne]=(0,d.useState)(!1),[re,ie]=(0,d.useState)(``),[ae,oe]=(0,d.useState)(null),[E,se]=(0,d.useState)({}),[ce,D]=(0,d.useState)(null),[O,le]=(0,d.useState)(null),ue=(0,d.useMemo)(()=>zI(e.inventory),[e.inventory]),de=(0,d.useMemo)(()=>{let e=o.trim().toLocaleLowerCase();return ue.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}}]:[]})},[ue,u,c,o]),fe=de.find(e=>e.id===i)??de[0]??null;if((0,d.useEffect)(()=>{n.current=e.onClose},[e.onClose]),(0,d.useEffect)(()=>{se(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||II(a,FI(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&&!te&&T(t.path)},[te,e.operations.clonePath]),(0,d.useEffect)(()=>{e.operations.enrollment?.status===`ready`&&m(null)},[e.operations.enrollment]),(0,d.useEffect)(()=>{if(e.applyState?.status===`applying`){r.current=!0;return}r.current&&e.applyState===null&&(r.current=!1,m(null),g(null),S(!1))},[e.applyState]),!e.open)return null;let A=fe&&`repository`in fe?fe.repository:null,pe=A?e.operations.updates[A.id]:void 0,me=A?.assessment,he=me?.status===`updateable`&&me.token&&me.localRevision&&me.upstreamRevision,ge=()=>{let t=y.trim();t&&(_===`skill`?e.onUpdateConfig({userSkillPaths:[...new Set([...e.userSkillPaths,t])]}):e.onUpdateConfig({userExtensionPaths:[...new Set([...e.userExtensionPaths,t])]}))},_e=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)}))},ve=(t,n=!1)=>{let r=t.assessment;!r.token||!r.localRevision||!r.upstreamRevision||e.onUpdate(t.id,r.token,r.localRevision,r.upstreamRevision,n)},ye=A?.collection,be=ye?FI(ye):[],xe=new Set(A&&E[A.id]?E[A.id]:be),Se=ye?[...new Set([...xe,...be])].filter(e=>xe.has(e)!==be.includes(e)).length:0,Ce=A?e.operations.skills?.[A.id]:void 0,we=e=>{if(!A)return;let t=A.id;se(n=>{let r={...n};return II(e,be)?delete r[t]:r[t]=[...e],r})},Te=()=>{if(!A)return;let e=A.id;se(t=>{let n={...t};return delete n[e],n})},Ee=()=>{if(!A||!ye)return;let t=new Set(ye.skills.filter(e=>e.state!==`on-missing`).map(e=>e.relativePath));e.onSetSkills(A.id,[...xe].filter(e=>t.has(e)))},De=O?e.operations.removals?.[O.id]:void 0,Oe=De?.status===`error`||De?.result?.status===`removed-delete-failed`;return(0,k.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,k.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,k.jsxs)(`header`,{className:`flex items-center justify-between border-b border-zinc-200 px-5 py-4 dark:border-zinc-800`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h2`,{id:`agent-resources-title`,className:`text-lg font-semibold text-zinc-900 dark:text-zinc-100`,children:`Agent resources`}),(0,k.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Skills and extensions, grouped by repository`})]}),(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.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,k.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,k.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[300px_1fr]`,children:[(0,k.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,k.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,k.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[[`all`,`skill`,`extension`].map(e=>(0,k.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,k.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,k.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 space-y-1 overflow-y-auto`,children:[de.map(e=>(0,k.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),className:`w-full rounded-lg px-3 py-2.5 text-left ${fe?.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,k.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-sm font-medium`,children:[(0,k.jsx)(`span`,{className:`truncate`,children:e.name}),(0,k.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,k.jsx)(`span`,{className:`mt-1 block text-xs text-zinc-500`,children:`repository`in e?RI[e.repository.assessment.status]:e.reason})]},e.id)),de.length===0?(0,k.jsx)(`p`,{className:`px-2 py-4 text-xs text-zinc-500`,children:`No matching resources`}):null]}),(0,k.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t pt-3`,children:[(0,k.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,k.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,k.jsxs)(`main`,{className:`min-w-0 overflow-y-auto p-6`,children:[O&&De?(0,k.jsxs)(`div`,{role:Oe?`alert`:`status`,className:`mb-4 flex items-start justify-between gap-3 rounded-lg border p-3 text-sm ${Oe?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[(0,k.jsx)(`p`,{className:`min-w-0 break-words`,children:LI(O.name,De)}),De.status===`loading`?null:(0,k.jsx)(`button`,{type:`button`,onClick:()=>le(null),className:`shrink-0 text-xs underline`,children:`Dismiss`})]}):null,p===`local`?(0,k.jsxs)(`div`,{className:`max-w-xl space-y-4`,"data-testid":`add-local-folder`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add local folder`}),(0,k.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Choose an existing folder on the server and how the agent should load it.`})]}),(0,k.jsx)(`div`,{className:`flex gap-2`,children:[`skill`,`extension`].map(t=>(0,k.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,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.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,k.jsx)(`button`,{type:`button`,onClick:()=>{g(`local`),e.onBrowseServerPath(y||`/`)},className:`rounded-md border px-3 text-xs`,children:`Browse…`})]}),h===`local`?(0,k.jsx)(xI,{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,k.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),(0,k.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust every extension in this folder.`})]}):null,e.extensionLock?(0,k.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Extension paths are locked by this deployment.`}):null,e.applyState?.status===`error`?(0,k.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.applyState.message}):null,(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.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,k.jsx)(`button`,{type:`button`,disabled:!y.trim()||e.applyState?.status===`applying`||_===`extension`&&(!x||e.extensionLock),onClick:ge,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,k.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,k.jsx)(WI,{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,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add Git repository`}),(0,k.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Clone it to a local folder, then choose what to turn on.`})]}),(0,k.jsxs)(`label`,{className:`block`,children:[(0,k.jsx)(`span`,{className:`text-xs font-medium`,children:`Repository address`}),(0,k.jsx)(`input`,{"aria-label":`Repository address`,value:ee,onChange:e=>C(e.target.value),onBlur:()=>{let t=ee.trim();t&&(ne(!1),ie(t),e.onSuggestClonePath(ee))},placeholder:`https://github.com/team/resources.git`,className:`mt-1 w-full rounded-md border bg-transparent px-3 py-2 text-sm`})]}),(0,k.jsxs)(`label`,{className:`block`,children:[(0,k.jsx)(`span`,{className:`text-xs font-medium`,children:`Local folder`}),(0,k.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,k.jsx)(`input`,{"aria-label":`Local clone folder`,value:w,onChange:e=>{ne(!0),T(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,k.jsx)(`button`,{type:`button`,onClick:()=>{g(`clone-parent`),e.onBrowseServerPath(VI(w))},className:`rounded-md border px-3 text-xs`,children:`Choose parent…`})]})]}),e.operations.clonePath?.status===`loading`?(0,k.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Suggesting a managed folder…`}):null,e.operations.clonePath?.status===`error`&&ee.trim()===re?(0,k.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.clonePath.message}):null,h===`clone-parent`?(0,k.jsx)(xI,{label:`Choose the clone's parent folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{T(HI(t,w)),g(null),e.onCloseServerBrowser()},onCancel:()=>{g(null),e.onCloseServerBrowser()}}):null,e.operations.preview?.status===`error`?(0,k.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.preview.message}):null,(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.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,k.jsx)(`button`,{type:`button`,disabled:!ee.trim()||!w.trim()||e.operations.preview?.status===`loading`,onClick:()=>e.onCloneRepository(ee,w),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`})]})]})}):fe?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`h3`,{className:`text-xl font-semibold`,children:fe.name}),A?(0,k.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[11px]`,children:RI[A.assessment.status]}):null]}),(0,k.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-zinc-500`,children:`repository`in fe?fe.path:fe.reason}),me?.branch?(0,k.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-400`,children:[me.branch,me.upstream?` → ${me.upstream}`:``]}):null,A?.removal&&!A.removal.allowed?(0,k.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:A.removal.reason}):null]}),A?(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[A.removal?.allowed?(0,k.jsx)(`button`,{type:`button`,disabled:e.operations.removals?.[A.id]?.status===`loading`,onClick:()=>D(A),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,k.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(A.id),className:`rounded-md border px-3 py-1.5 text-xs`,children:`Check`}),he||pe?.status===`loading`?(0,k.jsx)(`button`,{type:`button`,disabled:pe?.status===`loading`,onClick:()=>A.containsExtensions?oe(A):ve(A),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:pe?.status===`loading`?`Updating…`:`Update repository`}):null]}):null]}),me?.reason?(0,k.jsxs)(`div`,{className:`mt-5 rounded-lg border p-3 text-sm ${me.status===`dirty`?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[me.reason,me.status===`dirty`?(0,k.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,me?.hasSubmodules?(0,k.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,pe?.status===`ready`?(0,k.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-zinc-600`,children:pe.result?.status===`updated`&&pe.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.`:pe.result?.status===`updated`?`Repository updated and runtimes reloaded.`:pe.result?.status===`updated-reload-failed`?`Repository updated on disk, but at least one runtime failed to reload.`:pe.result?.reason}):null,pe?.status===`error`?(0,k.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-red-600`,children:pe.message}):null,ye&&A&&c!==`extension`?(0,k.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[Se>0||Ce?.status===`loading`?(0,k.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,k.jsx)(`span`,{children:Ce?.status===`loading`?`Applying…`:`${Se} pending change${Se===1?``:`s`} — applying replaces the session`}),(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,disabled:Ce?.status===`loading`,onClick:Te,className:`rounded border bg-white px-2.5 py-1 disabled:opacity-50 dark:bg-zinc-900`,children:`Discard`}),(0,k.jsx)(`button`,{type:`button`,disabled:Ce?.status===`loading`||Se===0,onClick:Ee,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,Ce?.status===`error`?(0,k.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:Ce.message}):null,(0,k.jsx)(MI,{skills:ye.skills,groups:ye.groups,enabled:xe,onChange:we,disabled:Ce?.status===`loading`,...ye.bound?{bound:ye.bound}:{}},A.id),fe.resources.some(e=>e.kind===`extension`)?(0,k.jsx)(UI,{kind:`extension`,resources:fe.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:_e}):null]}):(0,k.jsxs)(`div`,{className:`mt-6 grid grid-cols-2 gap-4`,children:[(0,k.jsx)(UI,{kind:`skill`,resources:fe.resources.filter(e=>e.kind===`skill`),onRemove:_e}),(0,k.jsx)(UI,{kind:`extension`,resources:fe.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:_e})]})]}):(0,k.jsx)(`p`,{className:`text-sm text-zinc-500`,children:`No resources are reported by this runtime.`})]})]})]}),ae?(0,k.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,k.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,k.jsx)(`h3`,{id:`extension-update-title`,className:`font-semibold`,children:`Update executable extensions?`}),(0,k.jsxs)(`p`,{className:`mt-2 text-sm text-zinc-600 dark:text-zinc-300`,children:[ae.name,` contains extensions that run with the agent's privileges. Confirm updating `,ae.assessment.localRevision?.slice(0,8),` to `,ae.assessment.upstreamRevision?.slice(0,8),`.`]}),(0,k.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>oe(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{ve(ae,!0),oe(null)},className:`rounded bg-amber-600 px-3 py-1.5 text-xs font-medium text-white`,children:`Confirm executable update`})]})]})}):null,ce?(0,k.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,k.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,k.jsxs)(`h3`,{id:`remove-repository-title`,className:`font-semibold`,children:[`Remove `,ce.name,`?`]}),(0,k.jsx)(`p`,{id:`remove-repository-detail`,className:`mt-2 break-words text-sm text-zinc-600 dark:text-zinc-300`,children:ce.removal?.deletesFiles?(0,k.jsxs)(k.Fragment,{children:[`This stops loading everything from `,ce.name,` and deletes `,(0,k.jsx)(`span`,{className:`font-mono`,children:ce.removal.path}),` from disk, with any local changes in it. This cannot be undone.`]}):(0,k.jsxs)(k.Fragment,{children:[`This stops loading everything from `,ce.name,`. pi-outpost does not manage `,(0,k.jsx)(`span`,{className:`font-mono`,children:ce.removal?.path??ce.path}),`, so its files will be kept.`]})}),(0,k.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>D(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{e.onRemoveRepository(ce.id),le({id:ce.id,name:ce.name}),D(null)},className:`rounded bg-red-600 px-3 py-1.5 text-xs font-medium text-white`,children:ce.removal?.deletesFiles?`Delete and remove`:`Remove repository`})]})]})}):null]})}function KI(e){return[...e].sort((e,t)=>e.localeCompare(t))}function qI({extensionPaths:e,configuredExtensionPaths:t,userExtensionPaths:n,extensionLock:r,piPackages:i=null,piPackageUpdate:a=null,canRestartServer:o=!1,serverRestarting:s=!1,onCheckPiPackages:c,onUpdatePiPackage:l,onRestartServer:u,restartNeeded:f=[],tools:p,commands:m,sandbox:h,showRoots:g=!0,gitUnavailable:_,userSkillPaths:v,serverBrowse:y,pickerBlocked:b=!1,onPickerOpened:x,applyState:S,agentResources:ee=null,agentResourceOperations:C={clonePath:null,preview:null,enrollment:null,refresh:null,updates:{},skills:{},removals:{}},versions:w,onBrowseServerPath:T,onCloseServerBrowser:te,onUpdateConfig:ne,onSuggestAgentResourceClonePath:re=()=>{},onCloneAgentResourceRepository:ie=()=>{},onEnrollAgentResourceRepository:ae=()=>{},onSetAgentResourceSkills:oe=()=>{},onRemoveAgentResourceRepository:E=()=>{},onRefreshAgentResourceRepositories:se=()=>{},onUpdateAgentResourceRepository:ce=()=>{}}){let[D,O]=(0,d.useState)(!1),[le,ue]=(0,d.useState)(!1),de=(0,d.useRef)(null),[fe,A]=(0,d.useState)(``),[pe,me]=(0,d.useState)(``),[he,ge]=(0,d.useState)(!1),[_e,ve]=(0,d.useState)(!1),[ye,be]=(0,d.useState)(null);(0,d.useEffect)(()=>{b&&ye!==null&&be(null)},[b,ye]);let xe=JP(()=>{(D||ye!==null)&&ke()}),Se=p.filter(e=>e.active),Ce=p.filter(e=>!e.active),we=m.filter(e=>e.source===`skill`),Te=[...p].sort((e,t)=>e.name.localeCompare(t.name)||Number(t.active)-Number(e.active)),Ee=S?.status===`applying`,De=S?.status===`error`?S.message:null;(0,d.useEffect)(()=>{h&&(A(h.root),me(h.writableRoot??``),ge(h.allowWrite),ve(h.allowBash))},[h]);let Oe=(0,d.useRef)(!1);(0,d.useEffect)(()=>{Oe.current&&S===null&&ke(),Oe.current=Ee},[S,Ee]);function ke(){O(!1),be(null),te()}function Ae(e,t){x?.(),be(e),T(t.trim()||`/`)}function je(e){ye===`root`?A(e):ye===`writableRoot`&&me(e),be(null),te()}let Me=h!==null&&(fe!==h.root||(pe.trim()||void 0)!==(h.writableRoot||void 0)||he!==h.allowWrite||_e!==h.allowBash);function Ne(){!h||!Me||ne({sandbox:{root:fe,allowWrite:he,allowBash:_e,writableRoot:pe.trim()||void 0}})}let Pe=g&&h?.rootEditable!==!1,Fe=ye!==null&&!b&&(0,k.jsx)(xI,{label:ye===`root`?`Choose the sandbox root`:`Choose the writable root`,browse:y,onBrowse:T,onSelect:je,onCancel:()=>{be(null),te()}});return(0,k.jsxs)(`div`,{className:`relative`,ref:xe,children:[(0,k.jsx)(`button`,{ref:de,type:`button`,onClick:()=>O(!D),title:`Settings`,"aria-label":`Settings`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs 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:`⚙`}),D&&(0,k.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,k.jsx)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Settings`})}),(0,k.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:[_&&(0,k.jsxs)(`section`,{className:`mb-4`,"data-testid":`git-unavailable`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Version control`}),_.reason===`no-repository`?(0,k.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`This project is not in a git repository.`}):(0,k.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,k.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-300`,children:_.reason===`no-executable`?`Git is unavailable: its executable could not be run.`:`Git is unavailable: it refused this repository.`}),(0,k.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-amber-700 dark:text-amber-400`,children:_.message}),_.reason===`no-executable`&&(0,k.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,k.jsx)(`span`,{className:`font-mono`,children:`gitPath`}),` in the configuration.`]})]})]}),(0,k.jsxs)(`section`,{className:`mb-4`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Agent resources`}),p.length===0?(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`Tool inventory unavailable for this runtime`}):(0,k.jsxs)(`details`,{"data-testid":`tools-loaded`,children:[(0,k.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[Se.length,` tools active`,Ce.length?` · ${Ce.length} inactive`:``]}),(0,k.jsx)(`ul`,{className:`mt-2 space-y-1`,children:Te.map(e=>(0,k.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,k.jsx)(`span`,{children:e.name}),(0,k.jsx)(`span`,{children:e.active?`active`:`inactive`})]},e.name))})]}),we.length===0?(0,k.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skills loaded`}):(0,k.jsxs)(`details`,{className:`mt-2`,"data-testid":`skills-loaded`,children:[(0,k.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[we.length,` skills loaded`]}),(0,k.jsx)(`ul`,{className:`mt-2 space-y-1`,children:KI(we.map(e=>e.name)).map(e=>(0,k.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,k.jsx)(`button`,{type:`button`,"aria-label":`Manage agent resources`,onClick:()=>{O(!1),ue(!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,k.jsxs)(`section`,{className:`mb-4`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),e===null?(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-unknown`,children:`Not reported by this runtime`}):e.length===0?(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,k.jsxs)(`details`,{"data-testid":`extensions-loaded`,children:[(0,k.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[e.length,` `,e.length===1?`extension`:`extensions`,` loaded`]}),(0,k.jsx)(`ul`,{className:`mt-2 space-y-1`,children:KI(e).map(e=>(0,k.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))})]}),t.length>0&&(0,k.jsxs)(`details`,{className:`mt-2`,"data-testid":`extensions-configured`,children:[(0,k.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[t.length,` configured by this deployment`]}),(0,k.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,k.jsx)(`ul`,{className:`mt-1 space-y-1`,children:KI(t).map(e=>(0,k.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))})]}),r?(0,k.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,k.jsx)(OI,{packages:i,update:a,locked:r,onCheck:()=>c?.(),onUpdate:e=>l?.(e)}),(0,k.jsx)(kI,{reasons:f,canRestart:o,restarting:s,onRestart:()=>u?.()})]}),h&&(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:Pe?`Sandbox`:`Agent permissions`}),(0,k.jsxs)(`div`,{className:`space-y-3`,children:[!Pe&&(0,k.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,k.jsx)(`span`,{className:`break-all font-mono text-zinc-800 dark:text-zinc-200`,children:h.projectRoot??h.root}),`. Each open project is confined to its own. A change here applies to this project now, and to projects opened after.`]}),Pe&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`label`,{className:`block`,children:[(0,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,h.locks?.root?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,k.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,k.jsx)(`input`,{type:`text`,value:fe,onChange:e=>A(e.target.value),disabled:h.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,k.jsx)(`button`,{type:`button`,"aria-label":`Browse for sandbox root`,disabled:h.locks?.root,onClick:()=>Ae(`root`,fe),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…`})]})]}),ye===`root`&&Fe,(0,k.jsxs)(`label`,{className:`block`,children:[(0,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,h.locks?.writableRoot?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,k.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,k.jsx)(`input`,{type:`text`,value:pe,onChange:e=>me(e.target.value),disabled:h.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,k.jsx)(`button`,{type:`button`,"aria-label":`Browse for writable root`,disabled:h.locks?.writableRoot,onClick:()=>Ae(`writableRoot`,pe||fe),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…`})]})]}),ye===`writableRoot`&&Fe]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:he,onChange:e=>ge(e.target.checked),disabled:h.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,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,h.locks?.allowWrite?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:_e,onChange:e=>ve(e.target.checked),disabled:h.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,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,h.locks?.allowBash?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]})]})]}),!h&&(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),h&&(0,k.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[De&&(0,k.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:De}),(0,k.jsx)(`button`,{type:`button`,disabled:Ee||!Me||h!==null&&!fe.trim(),onClick:Ne,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:Ee?`Applying…`:`Apply & restart session`}),(0,k.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Saved to the server's configuration file, then the session is rebuilt — the change survives a restart.`})]}),w&&(0,k.jsxs)(`section`,{className:`mt-4`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,k.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,k.jsxs)(`p`,{children:[`pi-outpost: `,(0,k.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:w.piOutpost})]}),w.piSdk&&(0,k.jsxs)(`p`,{children:[`pi SDK: `,(0,k.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:w.piSdk})]}),w.agent&&(0,k.jsxs)(`p`,{children:[`agent: `,(0,k.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:w.agent})]})]})]})]})]}),(0,k.jsx)(GI,{open:le,inventory:ee,operations:C,extensionLock:r,userSkillPaths:v,userExtensionPaths:n,serverBrowse:y,applyState:S,onClose:()=>{ue(!1),te(),de.current?.focus()},onBrowseServerPath:e=>{x?.(),T(e)},onCloseServerBrowser:te,onUpdateConfig:ne,onSuggestClonePath:re,onCloneRepository:ie,onEnrollRepository:ae,onSetSkills:oe,onRemoveRepository:E,onRefresh:se,onUpdate:ce})]})}function JI(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);return}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 YI(e){return e.flatMap(e=>[e,...YI(e.children)])}function XI({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,k.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var ZI=`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 QI({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:o}=e,s=o.tipId??o.entryId;return(0,k.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,k.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,k.jsx)(nI,{row:e,laneCount:t,colorOf:$F}),(0,k.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,k.jsxs)(XI,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,k.jsxs)(XI,{tone:`branch`,children:[`branch `,e.branchIndex,o.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,k.jsx)(XI,{tone:`current`,children:`current`}),o.label&&(0,k.jsx)(XI,{tone:`label`,children:o.label})]}),(0,k.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:ZI,children:`↺ redo`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{i(o.entryId),a()},title:`fork a new session from this point`,className:ZI,children:`⑂ fork`})]})}function $I({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:i}){let[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(``),l=JP(()=>o(!1));(0,d.useEffect)(()=>{a&&e===null&&n()},[a,e]);let u=(0,d.useMemo)(()=>e&&e.length>0?JI(e):null,[e]),f=(0,d.useMemo)(()=>{if(!e||!s.trim())return null;let t=s.trim().toLowerCase();return YI(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,s]);return(0,k.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>{o(!a),a||(c(``),n())},title:`conversation tree: go back to an earlier point or fork`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs 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,k.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,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&u&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,k.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,k.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,k.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,k.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:f===null?u.rows.map(e=>(0,k.jsx)(QI,{row:e,laneCount:u.laneCount,isStreaming:t,onNavigate:r,onFork:i,onClose:()=>o(!1)},e.node.entryId)):f.length===0?(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):f.map(e=>(0,k.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,k.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,k.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,k.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,k.jsx)(XI,{tone:`current`,children:`on current branch`}),e.label&&(0,k.jsx)(XI,{tone:`label`,children:e.label})]}),(0,k.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:ZI,children:`↺ redo`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{i(e.entryId),o(!1)},title:`fork a new session from this point`,className:ZI,children:`⑂ fork`})]},e.entryId))})]})]})]})}var eL=200;function tL({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,d.useState)(e);return(0,k.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 nL({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:o,onCancelRename:s}){return n?(0,k.jsx)(`div`,{className:`px-3 py-2`,children:(0,k.jsx)(tL,{initial:e.name??``,onCommit:o,onCancel:s})}):(0,k.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,k.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,k.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,k.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,k.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,k.jsxs)(`span`,{"data-testid":`session-live-in`,children:[` · open in `,e.liveIn]}):null]})]}),(0,k.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,k.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 rL({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=JP(()=>u(!1)),_=f.trim(),v=_.length>=2;(0,d.useEffect)(()=>{if(!l)return;if(!v){c();return}let e=setTimeout(()=>s(_),eL);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,k.jsxs)(`div`,{className:`relative`,ref:g,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>{if(l){y();return}u(!0),p(``),h(null),c(),a()},className:`rounded-md border border-zinc-300 px-2 py-1 text-xs 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,k.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,k.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.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,k.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,k.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[x===null&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),x?.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:v?`no matches`:`no saved sessions`}),x?.map(e=>(0,k.jsx)(nL,{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 iL({filters:e,onFilterChange:t}){let[n,r]=(0,d.useState)(!1),i=JP(()=>r(!1)),a=_P(e),o=a>0?`Filter · ${a} hidden`:`Filter`;return(0,k.jsxs)(`div`,{className:`relative`,ref:i,onKeyDown:e=>{e.key===`Escape`&&n&&(e.stopPropagation(),r(!1))},children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>r(!n),"aria-haspopup":`menu`,"aria-expanded":n,title:`Choose what the conversation shows`,className:`rounded-md border px-2 py-1 text-xs ${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,k.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:fP.map(n=>(0,k.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,k.jsx)(`span`,{"aria-hidden":!0,className:`w-3`,children:e[n]?`✓`:``}),(0,k.jsx)(`span`,{children:pP[n]})]},n))})]})}function aL({theme:e,onToggle:t}){return(0,k.jsx)(`button`,{type:`button`,onClick:t,title:e===`dark`?`Switch to light theme`:`Switch to dark theme`,"aria-label":e===`dark`?`Switch to light theme`:`Switch to dark theme`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs 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===`dark`?`☀`:`☾`})}function oL(e){let{isStreaming:t,connected:n}=e;return(0,k.jsxs)(`header`,{className:`relative z-30 flex items-center gap-3 border-b border-zinc-200 px-4 py-2.5 dark:border-zinc-800`,children:[e.workspaceControl===`projects`&&(0,k.jsx)(bI,{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,k.jsx)(CI,{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,k.jsxs)(`button`,{type:`button`,onClick:e.onToggleSidebar,title:e.sidebarOpen?`Hide files (panel opens on the left)`:`Show files`,"aria-pressed":e.sidebarOpen,className:`rounded-md border px-2 py-1 text-xs ${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,k.jsxs)(`button`,{type:`button`,onClick:e.onToggleOutcome,"aria-pressed":e.outcomeOpen,title:`Review structured workspace Outcome`,className:`rounded-md border px-2 py-1 text-xs ${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,k.jsx)(EI,{status:e.gitStatus,selected:e.gitSelectedPath,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,k.jsx)(`span`,{className:`text-lg font-semibold tracking-tight`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),Object.entries(e.statuses).map(([e,t])=>(0,k.jsx)(`span`,{className:`rounded-md border border-zinc-200 px-2 py-1 text-xs text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:yF(t)},e)),(0,k.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,k.jsx)(iL,{filters:e.filters,onFilterChange:e.onFilterChange}),e.onExportConversation&&(0,k.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:`rounded-md border border-zinc-300 px-2 py-1 text-xs 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,k.jsx)(`button`,{type:`button`,onClick:e.onToggleTerminal,title:e.terminalOpen?"Close Terminal (Ctrl+`)":"Open Terminal (Ctrl+`)","aria-pressed":e.terminalOpen,className:`rounded-md border px-2 py-1 text-xs ${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,k.jsx)(aL,{theme:e.theme,onToggle:e.onToggleTheme}),(0,k.jsx)(`button`,{type:`button`,onClick:e.onNewSession,title:`new session`,className:`rounded-md border border-emerald-300 px-2 py-1 text-xs 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,k.jsx)($I,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,k.jsx)(rL,{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,k.jsx)(qI,{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,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,k.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function sL(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=>AN(e)!==t);for(let e of[...n.current.keys()])r.some(t=>AN(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(AN(e))!==e.activity){n.current.set(AN(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:${AN(e)}`})}catch{}}}},[e,t])}function cL(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 lL({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,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{children:[LN(e.totalTokens),` tok`]}),r>0&&(0,k.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:[IN(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,k.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,k.jsx)(`span`,{title:i,className:`${o} border-zinc-300 dark:border-zinc-800`,children:a})}function uL({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,k.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 36 36`,className:`-rotate-90 shrink-0`,children:[(0,k.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,k.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${i} ${n-i}`,className:cL(e)})]})}function dL({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:BF,l=c.indexOf(e),u=c.length>1;return(0,d.useEffect)(()=>{if(!i)return;function e(e){o.current&&!qP(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,k.jsxs)(`div`,{className:`relative`,ref:o,children:[(0,k.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,k.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none ${s?``:`opacity-40 grayscale`}`,children:`🧠`}),e]}),i&&(0,k.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,k.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between text-xs`,children:[(0,k.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`thinking`}),(0,k.jsx)(`span`,{className:`font-mono text-zinc-700 dark:text-zinc-200`,children:e})]}),u?(0,k.jsxs)(k.Fragment,{children:[(0,k.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,k.jsxs)(`div`,{className:`mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,children:[(0,k.jsx)(`span`,{children:c[0]}),(0,k.jsx)(`span`,{children:c[c.length-1]})]})]}):(0,k.jsxs)(`p`,{className:`text-[11px] text-zinc-500 dark:text-zinc-400`,children:[`this model accepts `,(0,k.jsx)(`span`,{className:`font-mono`,children:c[0]}),` only`]})]})]})}function fL(e){let{model:t,models:n,thinkingLevel:r,modelSupportsReasoning:i,isStreaming:a,contextUsage:o,sessionUsage:s,isCompacting:c}=e;return(0,k.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,k.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,k.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,k.jsxs)(`option`,{value:`${e.provider}/${e.id}`,children:[e.provider,`/`,e.id]},`${e.provider}/${e.id}`))]}),i&&(0,k.jsx)(dL,{thinkingLevel:r,thinkingLevels:e.thinkingLevels,isStreaming:a,onSetThinking:e.onSetThinking}),(0,k.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:`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,k.jsx)(uL,{usage:o}),c?`compacting…`:o?.percent==null?`context`:`${Math.round(o.percent)}%`]}),(0,k.jsx)(lL,{usage:s,analysisOpen:e.analysisOpen,onToggleAnalysis:e.onToggleAnalysis})]})}var pL=`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`,mL=`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`;function hL({title:e,credentials:t,onSetCredential:n,onDeclareProvider:r,errors:i}){let a=t.providers,[o,s]=(0,d.useState)(a.length>0?`known`:`custom`),[c,l]=(0,d.useState)(a[0]?.id??``),[u,f]=(0,d.useState)(``),[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(``),[_,v]=(0,d.useState)(``),[y,b]=(0,d.useState)(!0),[x,S]=(0,d.useState)(!0),ee=a.some(e=>e.configured)&&!t.usableModel;function C(e){if(e.preventDefault(),!ee){if(o===`known`){c&&u.trim()&&n(c,u.trim());return}!p.trim()||!h.trim()||!u.trim()||!_.trim()||r({provider:p.trim(),baseUrl:h.trim(),apiKey:u.trim(),models:[_.trim()],compat:{supportsDeveloperRole:y,supportsReasoningEffort:x}})}}return(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto p-6`,children:(0,k.jsxs)(`form`,{onSubmit:C,className:`w-full max-w-md rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,k.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),ee?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`h1`,{className:`mb-3 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model is available.`}),(0,k.jsxs)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:[`Credentials are configured, so this is not a missing key: `,(0,k.jsx)(`code`,{children:`allowedModels`}),` in your configuration leaves nothing to choose from. Widen it, or remove it, then restart.`]})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.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,k.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,k.jsx)(`button`,{type:`button`,onClick:()=>s(e),className:`flex-1 rounded-md px-2 py-1.5 ${o===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))}),o===`known`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`label`,{htmlFor:`onboarding-provider`,className:mL,children:`Provider`}),(0,k.jsx)(`select`,{id:`onboarding-provider`,value:c,onChange:e=>l(e.target.value),className:`${pL} mb-3`,children:a.map(e=>(0,k.jsxs)(`option`,{value:e.id,children:[e.name,e.configured?` (already configured)`:``]},e.id))})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`label`,{htmlFor:`onboarding-name`,className:mL,children:`Name`}),(0,k.jsx)(`input`,{id:`onboarding-name`,value:p,onChange:e=>m(e.target.value),placeholder:`corp`,className:`${pL} mb-3`}),(0,k.jsx)(`label`,{htmlFor:`onboarding-url`,className:mL,children:`Base URL`}),(0,k.jsx)(`input`,{id:`onboarding-url`,value:h,onChange:e=>g(e.target.value),placeholder:`https://llm.corp.example/v1`,className:`${pL} mb-3`}),(0,k.jsx)(`label`,{htmlFor:`onboarding-model`,className:mL,children:`Model id`}),(0,k.jsx)(`input`,{id:`onboarding-model`,value:_,onChange:e=>v(e.target.value),placeholder:`gpt-oss-120b`,className:`${pL} mb-3`})]}),(0,k.jsx)(`label`,{htmlFor:`onboarding-key`,className:mL,children:`API key`}),(0,k.jsx)(`input`,{id:`onboarding-key`,type:`password`,autoComplete:`off`,value:u,onChange:e=>f(e.target.value),placeholder:`sk-…`,className:pL}),o===`custom`&&(0,k.jsxs)(`fieldset`,{className:`mt-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,k.jsx)(`legend`,{className:`px-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Compatibility`}),(0,k.jsxs)(`label`,{className:`flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5`}),(0,k.jsxs)(`span`,{children:[`Server understands the `,(0,k.jsx)(`code`,{children:`developer`}),` role. Uncheck for vLLM, SGLang and most corporate gateways — the system prompt is then sent as a `,(0,k.jsx)(`code`,{children:`system`}),` message.`]})]}),(0,k.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`mt-0.5`}),(0,k.jsxs)(`span`,{children:[`Server accepts `,(0,k.jsx)(`code`,{children:`reasoning_effort`}),`. Uncheck if it rejects unknown fields.`]})]})]}),(0,k.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`})]}),i.map((e,t)=>(0,k.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,k.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,k.jsx)(`code`,{children:`pi-outpost login`}),`.`]})]})})}var gL=`application/x-pi-outpost-file`,_L=`application/x-pi-outpost-read-only-file`,vL=`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`,yL={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 bL(e,t){return t?Object.keys(t).filter(t=>t.startsWith(`${e}/`)).length:0}function xL(e){return e===`directory`||e===`symlink-directory`}function SL(e,t){return t===void 0?!1:t===null||t!==``&&e!==t&&!e.startsWith(`${t}/`)}function CL({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,k.jsxs)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5`,children:[(0,k.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,k.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:o})]})}function wL({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,k.jsxs)(`div`,{style:{paddingLeft:n*12+16},className:`py-0.5`,children:[(0,k.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,k.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:s})]})}function TL({path:e,depth:t,...n}){let r=n.tree[e],i=n.creation?.openIn===e?(0,k.jsx)(CL,{dir:e,depth:t,creation:n.creation}):null;return r===void 0?i:r===`loading`?(0,k.jsxs)(k.Fragment,{children:[i,(0,k.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,k.jsxs)(k.Fragment,{children:[i,(0,k.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,k.jsxs)(k.Fragment,{children:[i,i===null&&(0,k.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`empty`})]}):(0,k.jsxs)(k.Fragment,{children:[i,r.map(r=>(0,k.jsx)(EL,{parentPath:e,entry:r,depth:t,...n},r.name))]})}function EL({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=SL(c,r.writableRoot),u=r.fileOperation?.status===`pending`;if(xL(t.type)){let e=!l&&!u,d=e=>e.includes(_L)?r.onCopyFile===void 0?null:`copy`:r.onMoveFile===void 0?null:`move`;return(0,k.jsxs)(`div`,{children:[(0,k.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(gL))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(gL),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,k.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,k.jsx)(`span`,{className:`w-3 shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:i?`▾`:`▸`}),(0,k.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&&bL(c,r.gitFiles)>0&&(0,k.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:`${bL(c,r.gitFiles)} changed file(s) inside`,children:bL(c,r.gitFiles)})]}),r.onRevealNative&&(0,k.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:vL,children:`⌂`}),r.creation&&!l&&(0,k.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,k.jsx)(TL,{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,k.jsx)(wL,{path:c,name:t.name,depth:n,rename:r.rename}):(0,k.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,k.jsx)(`button`,{type:`button`,draggable:v&&!u,onDragStart:e=>{!v||u||(e.dataTransfer.effectAllowed=l?`copy`:`move`,e.dataTransfer.setData(gL,c),l&&e.dataTransfer.setData(_L,`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,k.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,k.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:vL,children:`↗`}),r.onRevealNative&&(0,k.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:vL,children:`⌂`}),_&&r.onRenameFile&&(0,k.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>r.rename?.start(c),title:`Rename file`,"aria-label":`Rename ${t.name}`,className:vL,children:`✎`}),_&&r.onDeleteFile&&(0,k.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:`${vL} hover:text-red-600 dark:hover:text-red-400`,children:`×`}),r.onToggleAttachPath&&(0,k.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,k.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 ${yL[p].className}`,children:yL[p].label})]})}function DL(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 OL(e){let t=DL(e);return`error`in t?t:t.kind===`directory`?{error:`That is a folder name`}:{name:t.name}}function kL(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===AL(a.dir,a.name)?e.createError.message:null,g=e.created??null;(0,d.useEffect)(()=>{a!==null&&g!==null&&g===AL(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=DL(n);if(`error`in r){i(r.error);return}i(null),o({dir:t,name:r.name});let a=AL(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=OL(n);if(`error`in r){u(r.error);return}u(null),p(t),e.onRenameFile?.(t,r.name)}}:void 0,b=!SL(``,e.writableRoot);return(0,k.jsxs)(`div`,{className:`text-sm`,children:[e.fileOperation?.status===`error`&&e.fileOperation.operation!==`rename_file`&&(0,k.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,k.jsxs)(`div`,{className:`mb-1 flex items-center`,children:[v&&b&&(0,k.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,k.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,k.jsx)(TL,{path:``,depth:0,...e,...v?{creation:v}:{},...y?{rename:y}:{}})]})}function AL(e,t){return e===``?t:`${e}/${t}`}function jL({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 ee=JF(HF);return(0,d.useEffect)(()=>{e[``]===void 0&&a(``)},[]),(0,k.jsxs)(`aside`,{"aria-label":`Files`,style:{width:ee.width},className:`relative flex shrink-0 flex-col border-r border-zinc-200 dark:border-zinc-800`,children:[(0,k.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,k.jsx)(`div`,{className:`flex-1 overflow-auto p-2`,children:(0,k.jsx)(kL,{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,k.jsx)(YF,{label:`Resize Files sidebar`,width:ee.width,config:HF,separatorProps:ee.separatorProps})]})}function ML({title:e,onSubmit:t}){let[n,r]=(0,d.useState)(``);return(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,k.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,k.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),(0,k.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`This server requires an access token.`}),(0,k.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,k.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,k.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,k.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,k.jsx)(`code`,{children:`?token=…`})]})]})})}var NL={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`}},PL=8;function FL(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 IL({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,PL)},[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=NL[e.status];return[(0,k.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,k.jsx)(`span`,{className:`mt-px w-4 shrink-0 text-center font-semibold ${n.className}`,"aria-label":n.label,children:n.icon}),(0,k.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,k.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,k.jsxs)(`header`,{className:`border-b border-zinc-200 px-3 py-3 dark:border-zinc-800`,children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-zinc-500`,children:`Work Plan`}),(0,k.jsx)(`h2`,{className:`truncate text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:e.title})]}),(0,k.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,k.jsxs)(`div`,{className:`mt-2 text-xs text-zinc-500`,children:[`Progress: `,v,` / `,e.tasks.length]}),(0,k.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-800`,"aria-hidden":!0,children:(0,k.jsx)(`div`,{className:`h-full bg-emerald-500`,style:{width:`${e.tasks.length===0?0:v/e.tasks.length*100}%`}})})]}),(0,k.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,k.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,k.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,k.jsx)(`div`,{className:`font-semibold ${NL[_.status].className}`,children:NL[_.status].label}),(0,k.jsx)(`h3`,{className:`mt-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:_.title}),_.description&&(0,k.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-zinc-600 dark:text-zinc-300`,children:_.description}),_.statusReason&&(0,k.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,k.jsxs)(`div`,{className:`mt-3`,children:[(0,k.jsx)(`span`,{className:`font-semibold`,children:`Depends on:`}),` `,_.dependsOn.map(e=>h.get(e)?.title??e).join(`, `)]}),_.resources.length>0&&(0,k.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,k.jsx)(`div`,{className:`font-semibold`,children:`Resources`}),_.resources.map(e=>{let t=FL(e),n=e.label??e.uri;return t===null?/^https?:/i.test(e.uri)?(0,k.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,k.jsx)(`span`,{className:`block truncate text-zinc-500`,title:`No navigator is available for this resource`,children:n},e.uri):(0,k.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,k.jsxs)(`div`,{className:`absolute right-3 top-3 z-20`,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocusCapture:()=>c(!0),onBlurCapture:()=>c(!1),children:[(0,k.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,k.jsx)(`div`,{id:o,role:`tooltip`,className:`absolute right-0 top-full w-72 pt-2 ${s?`block`:`hidden`}`,children:(0,k.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,k.jsx)(`ul`,{className:`space-y-1`,children:g.map(({task:e,depth:t})=>(0,k.jsxs)(`li`,{className:`flex min-w-0 items-start gap-1.5 text-xs`,style:{paddingLeft:`${t*.75}rem`},children:[(0,k.jsx)(`span`,{"aria-label":NL[e.status].label,className:`shrink-0 font-semibold ${NL[e.status].className}`,children:e.status===`done`?`☑`:`☐`}),(0,k.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,k.jsxs)(`div`,{className:`mt-1 text-[11px] text-zinc-500`,children:[`+`,e.tasks.length-g.length,` more`]})]})})]})}var LL=Object.defineProperty,RL=Object.getOwnPropertyDescriptor,zL=(e,t)=>{for(var n in t)LL(e,n,{get:t[n],enumerable:!0})},BL=(e,t,n,r)=>{for(var i=r>1?void 0:r?RL(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&&LL(t,n,i),i},VL=(e,t)=>(n,r)=>t(n,r,e),HL=`Terminal input`,UL={get:()=>HL,set:e=>HL=e},WL=`Too much output to announce, navigate to rows manually to read`,GL={get:()=>WL,set:e=>WL=e};function KL(e){return e.replace(/\r?\n/g,`\r`)}function qL(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function JL(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function YL(e,t,n,r){e.stopPropagation(),e.clipboardData&&XL(e.clipboardData.getData(`text/plain`),t,n,r)}function XL(e,t,n,r){e=KL(e),e=qL(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ZL(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 QL(e,t,n,r,i){ZL(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function $L(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function eR(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 tR=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);continue}i!==65279&&(t[r++]=i)}return r}},nR=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){d--;continue}if(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}},rR=``,iR=` `,aR=class e{constructor(){this.fg=0,this.bg=0,this.extended=new oR}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}},oR=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}},sR=class e extends aR{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new oR,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?$L(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()]}},cR=`di$target`,lR=`di$dependencies`,uR=new Map;function dR(e){return e[lR]||[]}function fR(e){if(uR.has(e))return uR.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);pR(t,e,r)};return t._id=e,uR.set(e,t),t}function pR(e,t,n){t[cR]===t?t[lR].push({id:e,index:n}):(t[lR]=[{id:e,index:n}],t[cR]=t)}var mR=fR(`BufferService`),hR=fR(`CoreMouseService`),gR=fR(`CoreService`),_R=fR(`CharsetService`),vR=fR(`InstantiationService`),yR=fR(`LogService`),bR=fR(`OptionsService`),xR=fR(`OscLinkService`),SR=fR(`UnicodeService`),CR=fR(`DecorationService`),wR=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 sR,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):TR(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)}};wR=BL([VL(0,mR),VL(1,bR),VL(2,xR)],wR);function TR(e,t){if(confirm(`Do you want to navigate to ${t}?
335
335
 
336
336
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var ER=fR(`CharSizeService`),DR=fR(`CoreBrowserService`),OR=fR(`MouseService`),kR=fR(`RenderService`),AR=fR(`SelectionService`),jR=fR(`CharacterJoinerService`),MR=fR(`ThemeService`),NR=fR(`LinkProviderService`),PR=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?BR.isErrorNoTelemetry(e)?new BR(e.message+`
@@ -347,4 +347,4 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
347
347
  `))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(qB(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ez(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<bG+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
348
348
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===bG+1&&(this._liveRegion.textContent+=GL.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};xG=BL([VL(1,vR),VL(2,DR),VL(3,kR)],xG);var SG=class extends rz{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ez(()=>{QR(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(qB(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(qB(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(qB(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(qB(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&CG(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,QR(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};SG=BL([VL(1,OR),VL(2,kR),VL(3,mR),VL(4,NR)],SG);function CG(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var wG=class extends lG{constructor(e={}){super(e),this._linkifier=this._register(new iz),this.browser=IH,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new iz),this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Q),this.onKey=this._onKey.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Q),this.onBell=this._onBell.event,this._onFocus=this._register(new Q),this._onBlur=this._register(new Q),this._onA11yCharEmitter=this._register(new Q),this._onA11yTabEmitter=this._register(new Q),this._onWillOpen=this._register(new Q),this._setup(),this._decorationService=this._instantiationService.createInstance(gG),this._instantiationService.setService(CR,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(jH),this._instantiationService.setService(NR,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(wR)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(dz.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(dz.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(dz.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(dz.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(ez(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=$V.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${qW(r)}${GV.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=QV.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=QV.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(xG,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(qB(this.element,`copy`,e=>{this.hasSelection()&&JL(e,this._selectionService)}));let e=e=>YL(e,this.textarea,this.coreService,this.optionsService);this._register(qB(this.textarea,`paste`,e)),this._register(qB(this.element,`paste`,e)),BH?this._register(qB(this.element,`mousedown`,e=>{e.button===2&&QL(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(qB(this.element,`contextmenu`,e=>{QL(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),JH&&this._register(qB(this.element,`auxclick`,e=>{e.button===1&&ZL(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(qB(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(qB(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(qB(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(qB(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(qB(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(qB(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(qB(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(qB(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,UL.get()),YH||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(kH,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(DR,this._coreBrowserService),this._register(qB(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(qB(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(TH,this._document,this._helperContainer),this._instantiationService.setService(ER,this._charSizeService),this._themeService=this._instantiationService.createInstance(NU),this._instantiationService.setService(MR,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(oH),this._instantiationService.setService(jR,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(tU,this.rows,this.screenElement)),this._instantiationService.setService(kR,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(KV,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(PH),this._instantiationService.setService(OR,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(SG,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(LV,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(CU,this.element,this.screenElement,r)),this._instantiationService.setService(AR,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(dz.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(RV,this.screenElement)),this._register(qB(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(xG,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(UV,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(UV,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(wH,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(qB(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(qB(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){XL(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=dG(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===$.ETX||n.key===$.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(TG(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(UU));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function TG(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var EG=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},DG=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new sR)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},OG=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new DG(t)}getNullCell(){return new sR}},kG=class extends rz{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Q),this.onBufferChange=this._onBufferChange.event,this._normal=new OG(this._core.buffers.normal,`normal`),this._alternate=new OG(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},AG=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},jG=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},MG=[`cols`,`rows`],NG=0,PG=class extends rz{constructor(e){super(),this._core=this._register(new wG(e)),this._addonManager=this._register(new EG),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(MG.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new AG(this._core),this._parser}get unicode(){return this._checkProposedApi(),new jG(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new kG(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
349
349
  `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return UL.get()},set promptLabel(e){UL.set(e)},get tooMuchOutput(){return GL.get()},set tooMuchOutput(e){GL.set(e)}}}_verifyIntegers(...e){for(NG of e)if(NG===1/0||isNaN(NG)||NG%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(NG of e)if(NG&&(NG===1/0||isNaN(NG)||NG%1!=0||NG<0))throw Error(`This API only accepts positive integers`)}},FG=2,IG=1,LG=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(FG,Math.floor(u/e.css.cell.width)),rows:Math.max(IG,Math.floor(l/e.css.cell.height))}}},RG=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=BG.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function zG(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var BG=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!zG(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),!(!n.isWrapped||o.indexOf(` `)!==-1)););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},VG=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function HG(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var UG=class{constructor(e=HG,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||VG;this._linkProvider=this._terminal.registerLinkProvider(new RG(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},WG={background:`#09090b`,foreground:`#f4f4f5`,cursor:`#38bdf8`,cursorAccent:`#09090b`,selectionBackground:`rgba(56, 189, 248, 0.3)`,black:`#27272a`,red:`#f87171`,green:`#4ade80`,yellow:`#facc15`,blue:`#60a5fa`,magenta:`#c084fc`,cyan:`#38bdf8`,white:`#f4f4f5`,brightBlack:`#52525b`,brightRed:`#ef4444`,brightGreen:`#22c55e`,brightYellow:`#eab308`,brightBlue:`#3b82f6`,brightMagenta:`#a855f7`,brightCyan:`#06b6d4`,brightWhite:`#ffffff`},GG={background:`#ffffff`,foreground:`#18181b`,cursor:`#0284c7`,cursorAccent:`#ffffff`,selectionBackground:`rgba(2, 132, 199, 0.2)`,black:`#18181b`,red:`#dc2626`,green:`#16a34a`,yellow:`#ca8a04`,blue:`#2563eb`,magenta:`#9333ea`,cyan:`#0891b2`,white:`#e4e4e7`,brightBlack:`#71717a`,brightRed:`#b91c1c`,brightGreen:`#15803d`,brightYellow:`#a16207`,brightBlue:`#1d4ed8`,brightMagenta:`#7e22ce`,brightCyan:`#0e7490`,brightWhite:`#27272a`};function KG(e){if(!e)return``;let t=e.split(/[\\/]/).filter(Boolean);return t.length<=3?e:`…/`+t.slice(-3).join(`/`)}function qG({id:e,cwd:t,isActive:n,isPanelOpen:r,renaming:i,openTerminal:a,sendTerminalInput:o,getTerminalCwd:s,resizeTerminal:c,closeTerminal:l,subscribeTerminal:u,onCwdUpdate:f,registerClear:m}){let h=(0,d.useRef)(null),g=(0,d.useRef)(null),_=(0,d.useRef)(null),v=(0,d.useContext)(p)===`dark`,y=(0,d.useRef)({cwd:t,openTerminal:a,sendTerminalInput:o,getTerminalCwd:s,resizeTerminal:c,closeTerminal:l,subscribeTerminal:u,onCwdUpdate:f,registerClear:m});return y.current={cwd:t,openTerminal:a,sendTerminalInput:o,getTerminalCwd:s,resizeTerminal:c,closeTerminal:l,subscribeTerminal:u,onCwdUpdate:f,registerClear:m},(0,d.useEffect)(()=>{g.current&&(g.current.options.theme=v?WG:GG)},[v]),(0,d.useEffect)(()=>{if(!h.current)return;let t=new PG({cursorBlink:!0,cursorStyle:`block`,fontSize:13,fontFamily:`'JetBrains Mono', 'Fira Code', ui-monospace, Menlo, Monaco, 'Courier New', monospace`,lineHeight:1.2,theme:v?WG:GG}),n=new LG;t.loadAddon(n),t.loadAddon(new UG),t.open(h.current),n.fit(),g.current=t,_.current=n,y.current.registerClear(e,()=>{t.clear()}),y.current.openTerminal?.(e,y.current.cwd,t.cols,t.rows);let r=null,i=0,a=()=>{let t=Date.now();if(t-i<1e3){r||=setTimeout(()=>{r=null,i=Date.now(),y.current.getTerminalCwd?.(e)},1e3-(t-i));return}i=t,y.current.getTerminalCwd?.(e)},o=t.onData(t=>{y.current.sendTerminalInput?.(e,t),(t.includes(`\r`)||t.includes(`
350
- `))&&a()}),s=y.current.subscribeTerminal?.(e,{onData:n=>{t.write(n);let r=n.match(/\x1b\]7;file:\/\/[^/]*([^\x07\x1b]+)(?:\x07|\x1b\\)/);if(r&&r[1])try{let t=decodeURIComponent(r[1]);y.current.onCwdUpdate(e,t)}catch{}},onCwd:t=>{y.current.onCwdUpdate(e,t)},onExit:e=>{t.writeln(`\r\n\x1b[90m[Process completed (exit code ${e??0})]\x1b[0m`)},onError:e=>{t.writeln(`\r\n\x1b[31m[Terminal error: ${e}]\x1b[0m`)}})??(()=>{}),c=new ResizeObserver(()=>{if(h.current&&h.current.clientWidth>0&&h.current.clientHeight>0)try{n.fit(),t.cols>0&&t.rows>0&&y.current.resizeTerminal?.(e,t.cols,t.rows)}catch{}});return c.observe(h.current),()=>{o.dispose(),s(),c.disconnect(),t.dispose(),y.current.closeTerminal?.(e)}},[e]),(0,d.useEffect)(()=>{if(!i&&r&&n&&_.current&&g.current&&h.current){y.current.getTerminalCwd?.(e);let t=setTimeout(()=>{try{_.current?.fit(),g.current?.focus()}catch{}},50);return()=>clearTimeout(t)}},[r,n,e,i]),(0,k.jsx)(`div`,{ref:h,className:`h-full w-full p-2 bg-white dark:bg-zinc-950 overflow-hidden ${n?`block`:`hidden`}`})}function JG({open:e,onClose:t,cwd:n,onSetWorkspaceRoot:r,openTerminal:i,sendTerminalInput:a,getTerminalCwd:o,resizeTerminal:s,closeTerminal:c,subscribeTerminal:l}){let[u,f]=(0,d.useState)(e);(0,d.useEffect)(()=>{e&&f(!0)},[e]);let[p,m]=(0,d.useState)([{id:`term-1`,title:`terminal 1`}]),[h,g]=(0,d.useState)(`term-1`),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(``),[x,S]=(0,d.useState)({}),[ee,C]=(0,d.useState)(!1),[w,T]=(0,d.useState)(!1),te=(0,d.useRef)(new Map),ne=(0,d.useCallback)((e,t)=>{te.current.set(e,t)},[]),re=(0,d.useCallback)((e,t)=>{S(n=>({...n,[e]:t}))},[]),ie=(0,d.useCallback)(()=>{let e=p.length+1,t=`term-${Date.now()}-${e}`,n={id:t,title:`terminal ${e}`};m(e=>[...e,n]),g(t)},[p.length]),ae=(0,d.useCallback)((e,n)=>{if(n.stopPropagation(),p.length<=1){t();return}m(t=>{let n=t.filter(t=>t.id!==e);if(h===e){let r=t.findIndex(t=>t.id===e),i=n[Math.max(0,r-1)]?.id??n[0]?.id;g(i)}return n}),te.current.delete(e),S(t=>{let n={...t};return delete n[e],n})},[p.length,h,t]),oe=(e,t)=>{t.stopPropagation(),v(e.id),b(e.title)},E=()=>{if(_){let e=y.trim();e&&m(t=>t.map(t=>t.id===_?{...t,title:e}:t)),v(null)}},se=e=>{e.key===`Enter`?E():e.key===`Escape`&&v(null)},ce=(0,d.useCallback)(()=>{let e=te.current.get(h);e&&e()},[h]),D=x[h]||n||``;return u?(0,k.jsxs)(`div`,{className:`flex-col border-t border-zinc-200 dark:border-zinc-800 bg-zinc-100 dark:bg-zinc-900 transition-all duration-150 ${e?`flex`:`hidden`} ${ee?`h-[85vh]`:`h-72`} relative z-20`,children:[(0,k.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,k.jsxs)(`div`,{className:`flex items-center space-x-1 overflow-x-auto min-w-0`,children:[(0,k.jsx)(`div`,{className:`flex items-center space-x-1`,children:p.map(e=>{let t=e.id===h,n=e.id===_;return(0,k.jsxs)(`div`,{onClick:()=>g(e.id),onDoubleClick:t=>oe(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,k.jsx)(`input`,{type:`text`,"data-testid":`terminal-tab-rename-input`,value:y,autoFocus:!0,onChange:e=>b(e.target.value),onBlur:E,onKeyDown:se,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,k.jsx)(`span`,{children:e.title}),p.length>1&&(0,k.jsx)(`span`,{onClick:t=>ae(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,k.jsx)(`svg`,{className:`w-3 h-3`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]},e.id)})}),(0,k.jsx)(`button`,{onClick:ie,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,k.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 4v16m8-8H4`})})})]}),D&&(0,k.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:r&&(0,k.jsx)(`button`,{onClick:()=>{if(D&&r){if((D===`/`||D===`\\`||/^[A-Za-z]:[\\/]?$/.test(D))&&!window.confirm(`Open root filesystem "${D}" as the workspace project?`))return;r(D),T(!0),setTimeout(()=>T(!1),2e3)}},type:`button`,title:`Open "${D}" 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 ${w?`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,k.jsx)(`span`,{children:w?`✓ Project opened`:`📁 ${KG(D)} → open as project`})})}),(0,k.jsxs)(`div`,{className:`flex items-center space-x-1 text-zinc-500 dark:text-zinc-400`,children:[(0,k.jsx)(`button`,{onClick:ce,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,k.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,k.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,k.jsx)(`button`,{onClick:()=>C(e=>!e),type:`button`,title:ee?`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:ee?(0,k.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})}):(0,k.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M5 15l7-7 7 7`})})}),(0,k.jsx)(`button`,{onClick:t,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,k.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]})]}),(0,k.jsx)(`div`,{className:`flex-1 min-h-0 relative`,children:p.map(t=>(0,k.jsx)(qG,{id:t.id,cwd:n,isActive:t.id===h,isPanelOpen:e,renaming:_!==null,openTerminal:i,sendTerminalInput:a,getTerminalCwd:o,resizeTerminal:s,closeTerminal:c,subscribeTerminal:l,onCwdUpdate:re,registerClear:ne},t.id))})]}):null}var YG={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 XG(e){return YG[e]??{label:e,className:`text-zinc-500`}}function ZG({entry:e,onTarget:t}){let n=XG(e.status),r=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,k.jsx)(`span`,{className:`min-w-0 break-words text-sm font-medium text-zinc-900 dark:text-zinc-100`,children:e.title}),(0,k.jsx)(`span`,{className:`shrink-0 text-[11px] font-semibold uppercase tracking-wide ${n.className}`,children:n.label})]}),e.group&&(0,k.jsx)(`div`,{className:`mt-0.5 text-[11px] text-zinc-500`,children:e.group}),e.detail&&(0,k.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-zinc-600 dark:text-zinc-300`,children:e.detail}),e.reference&&(0,k.jsx)(`div`,{className:`mt-1 truncate text-xs text-zinc-500`,children:e.reference}),(0,k.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,k.jsx)(`a`,{href:e.target.url,target:`_blank`,rel:`noreferrer`,className:i,children:r}):e.target?(0,k.jsx)(`button`,{type:`button`,onClick:()=>t(e.target),className:i,children:r}):(0,k.jsx)(`div`,{className:`rounded-md border border-zinc-200 p-2 dark:border-zinc-800`,children:r})}function QG({state:e,onClose:t,onRefresh:n,onTarget:r}){return(0,k.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,k.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,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-zinc-500`,children:`Workspace review`}),(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:`Outcome`})]}),(0,k.jsxs)(`div`,{className:`flex gap-1`,children:[(0,k.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,k.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,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:e===null||e.status===`loading`?(0,k.jsx)(`div`,{role:`status`,className:`text-sm text-zinc-500`,children:`Loading Outcome…`}):e.status===`error`?(0,k.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,k.jsx)(`div`,{className:`space-y-4`,children:e.outcome.sections.map(e=>(0,k.jsxs)(`section`,{"aria-labelledby":`outcome-${e.id}`,className:`rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.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,k.jsx)(`span`,{className:`text-[11px] font-semibold uppercase text-red-600 dark:text-red-400`,children:e.availability}):null]}),e.summary&&(0,k.jsx)(`p`,{className:`mt-1 text-xs text-zinc-600 dark:text-zinc-300`,children:e.summary}),e.entries.length>0&&(0,k.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.entries.map(e=>(0,k.jsx)(ZG,{entry:e,onTarget:r},e.id))})]},e.id))})})]})}var $G=`pi-outpost:token`;function eK(){let e=null;try{let t=new URL(window.location.href);return e=t.searchParams.get(`token`),e&&(localStorage.setItem($G,e),t.searchParams.delete(`token`),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)),localStorage.getItem($G)}catch{return e}}function tK(){try{return localStorage.getItem($G)}catch{return null}}function nK(e){try{localStorage.setItem($G,e)}catch{}}var rK=class extends Error{kind;constructor(e,t){super(e),this.name=`HistoryError`,this.kind=t}};async function iK(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 aK(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function oK(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 sK(){return{clonePath:null,preview:null,enrollment:null,refresh:null,updates:{},skills:{},removals:{}}}var cK={connected:!1,workspace:null,workspaces:[],workspaceLocked:!1,embedWorkspaceControls:`settings`,switching:!1,authRequired:!1,brandingReady:!1,branding:{},sessionId:``,sessionName:null,model:``,thinkingLevel:`off`,modelSupportsReasoning:!1,models:[],commands:[],sessions:null,sessionSearch:null,tree:null,isStreaming:!1,items:[],olderHistory:null,pendingPrompt:null,workPlan:null,replyConformance:{},outpostUpdate: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:sK(),versions:null,gitAvailable:!1,gitUnavailable:null,credentials:null,gitStatus:null,gitDiff:null,gitLog:null,gitShow:null,gitFileHistory:null,gitFileDiff:null};function lK(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 uK(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 dK(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 fK(e,t){if(t.type!==`hello`&&t.type!==`session_replaced`&&t.type!==`update_config_ack`&&t.type!==`workspace_switched`)return e;let n=t.models.find(e=>`${e.provider}/${e.id}`===t.model);return{...e,replyConformance:{},outpostUpdate:t.outpostUpdate??e.outpostUpdate,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,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,userSkillPaths:t.userSkillPaths??[],serverBrowse:null,settingsApply:null,versions:t.versions??null,agentResources:t.agentResources??null,agentResourceOperations:t.type===`hello`||t.type===`workspace_switched`?sK():e.agentResourceOperations}}function pK(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===`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===`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_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;switch(n.type){case`hello`:case`session_replaced`:case`update_config_ack`:case`workspace_switched`:return{...fK(e,n),openFile:null,gitDiff:null,fileTree:{},directoryRequests:{}};case`workspace_activity`:return{...e,workspaces:n.workspaces,workspace:(e.workspace&&n.workspaces.find(t=>AN(t)===AN(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`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};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:lK(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:lK(e.items,()=>n.item)};case`custom_message`:return{...e,items:[...e.items,n.item]};case`tool_start`:return{...e,items:uK(e.items,n.toolCallId,n.toolName,{toolName:n.toolName,args:n.args,running:!0,callHtml:n.callHtml})};case`tool_update`:return{...e,items:uK(e.items,n.toolCallId,`tool`,{output:n.text,...typeof n.progress==`number`?{progress:n.progress}:{}})};case`tool_end`:return{...e,items:uK(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:dK(e.items,n.toolCallId,{structuredConformance:n.conformance})};case`outpost_update`:return{...e,outpostUpdate:n.notice};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`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;return{...e,openFile:r,gitFileHistory:i?null:e.gitFileHistory,gitFileDiff:i?null:e.gitFileDiff,gitDiff:a?null:e.gitDiff,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))vP(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{...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||!oK(e.gitFileDiff,n)?e:{...e,gitFileDiff:{...e.gitFileDiff,status:`loaded`,beforeText:n.beforeText,afterText:n.afterText}};case`git_error`:return 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 mK(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 hK=12e4,gK=2e4,_K=45e3,vK=4401,yK=1e3;function bK(e=``,t,n=!1,r){let[i,a]=(0,d.useReducer)(pK,cK),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?tK():eK()));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)(i.sessionId);(0,d.useEffect)(()=>{_.current=i.sessionId},[i.sessionId]);let v=(0,d.useRef)(!1),y=(0,d.useRef)(i.olderHistory);(0,d.useEffect)(()=>{y.current=i.olderHistory},[i.olderHistory]);let b=(0,d.useRef)(i.writableRoot);(0,d.useEffect)(()=>{b.current=i.writableRoot},[i.writableRoot]);let x=(0,d.useRef)(!1),S=(0,d.useRef)(new Map),ee=i.workspace?AN(i.workspace):null,C=(0,d.useRef)({workspaceRoot:ee,sessionId:i.sessionId});(0,d.useEffect)(()=>{C.current={workspaceRoot:ee,sessionId:i.sessionId}},[ee,i.sessionId]);let w=(0,d.useCallback)(e=>{let t=o.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[]),T=(0,d.useRef)(!1),te=(0,d.useRef)(null),ne=(0,d.useRef)(!1),re=(0,d.useRef)(null),ie=(0,d.useRef)(()=>{}),ae=(0,d.useCallback)(()=>{te.current=null,re.current!==null&&(clearTimeout(re.current),re.current=null)},[]),se=(0,d.useCallback)(()=>{let e=o.current;if(!e||e.readyState!==WebSocket.OPEN)return;if(te.current!==null){ne.current=!0;return}let t=`outcome:${crypto.randomUUID()}`;te.current=t;let n=C.current;a({type:`outcome_started`,requestId:t,...n}),w({type:`get_outcome`,requestId:t}),re.current=setTimeout(()=>{te.current===t&&(ae(),ne.current=!1,a({type:`outcome_failed`,requestId:t,message:`The Outcome took too long to answer — try again.`}))},_K)},[w,ae]);ie.current=se;let ce=(0,d.useCallback)(()=>{T.current&&ie.current()},[]),D=(0,d.useCallback)(e=>{T.current=e,e?se():ne.current=!1},[se]),O=(0,d.useCallback)((e,t=!1)=>{e===``&&(x.current=!0);let n=`dir:${crypto.randomUUID()}`;a({type:`dir_list_started`,path:e,requestId:n,preserveEntries:t}),w({type:`list_directory`,path:e,requestId:n})},[w]),k=(0,d.useRef)(!1),le=(0,d.useRef)([]);(0,d.useEffect)(()=>{le.current=i.gitStatus?.repos??[]},[i.gitStatus]);let ue=(0,d.useRef)(new Set),de=(0,d.useRef)(new Set),fe=(0,d.useRef)(new Map),A=(0,d.useCallback)(e=>{if(!k.current)return;let t=e??``;if(ue.current.has(t)){de.current.add(t);return}ue.current.add(t);let n=`git:${crypto.randomUUID()}`;fe.current.set(n,t),w({type:`git_status`,...e===void 0?{}:{repo:e},requestId:n})},[w]),pe=(0,d.useCallback)(e=>{let t=fe.current.get(e)??``;fe.current.delete(e),ue.current.delete(t),de.current.delete(t)&&A(t===``?void 0:t)},[A]),me=(0,d.useCallback)(e=>{f.current[e]!==void 0&&O(e,!0)},[O]),he=(0,d.useCallback)(()=>{O(``,!0);for(let e of Object.keys(f.current))e!==``&&me(e)},[me,O]);(0,d.useEffect)(()=>{!i.connected||!x.current||f.current[``]===void 0&&O(``)},[i.connected,i.fileTree,O]),(0,d.useEffect)(()=>{!i.connected||!T.current||te.current===null&&ie.current()},[i.connected]),(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(mK(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===`terminal_data`){let e=S.current.get(t.terminalId);if(e)for(let n of e.onData)n(t.data);return}if(t.type===`terminal_cwd`){let e=S.current.get(t.terminalId);if(e)for(let n of e.onCwd)n(t.cwd);return}if(t.type===`terminal_exit`){let e=S.current.get(t.terminalId);if(e)for(let n of e.onExit)n(t.exitCode);return}if(t.type===`terminal_error`){let e=S.current.get(t.terminalId);if(e)for(let n of e.onError)n(t.message);return}if(t.type===`history_items`){let e=g.current.get(t.requestId);e&&(g.current.delete(t.requestId),e.resolve({items:t.items,remaining:t.remaining}));return}if(t.type===`history_unavailable`){let e=g.current.get(t.requestId);e&&(g.current.delete(t.requestId),e.reject(new rK(t.reason,t.kind)));return}if(t.type===`file_uploaded`){let e=h.current.get(t.requestId);e&&(h.current.delete(t.requestId),e.resolve(t.path));return}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 wP(t.message,t.reason));return}if(t.type===`file_changed`){ce(),me(aK(t.path));let e=p.current;if(e?.status===`loaded`&&e.path===t.path){let e=`file:${crypto.randomUUID()}`;a({type:`file_read_started`,path:t.path,requestId:e,preserveContent:!0}),w({type:`read_file`,path:t.path,requestId:e})}m.current===t.path&&w({type:`git_diff`,path:t.path,requestId:`gitdiff:${crypto.randomUUID()}`}),A(vP(le.current,t.path)?.repo);return}if(t.type===`directory_changed`){ce(),me(t.path);let e=p.current;if(e!==null&&aK(e.path)===t.path){if(oe(e.path)||E(e.path))a({type:`raw_preview_changed`,path:e.path});else if(e.status===`loaded`){let t=`file:${crypto.randomUUID()}`;a({type:`file_read_started`,path:e.path,requestId:t,preserveContent:!0}),w({type:`read_file`,path:e.path,requestId:t})}}let n=m.current;n!==null&&aK(n)===t.path&&w({type:`git_diff`,path:n,requestId:`gitdiff:${crypto.randomUUID()}`}),A();return}if((t.type===`hello`||t.type===`session_replaced`)&&(k.current=t.gitAvailable===!0,t.type===`hello`&&A()),t.type===`agent_end`&&(A(),ce()),t.type===`git_repositories_changed`&&(ce(),k.current=t.available,t.available&&A()),(t.type===`git_status`||t.type===`git_error`&&t.requestId.startsWith(`git:`))&&pe(t.requestId),t.type===`work_plan_changed`&&ce(),(t.type===`workspace_outcome`||t.type===`workspace_outcome_error`)&&te.current===t.requestId&&(ae(),ne.current&&(ne.current=!1,queueMicrotask(()=>ie.current()))),t.type===`hello`||t.type===`session_replaced`||t.type===`workspace_switched`||t.type===`update_config_ack`){ae(),ne.current=!1;let e=C.current,n=t.sessionId===e.sessionId,r=(t.workspace?AN(t.workspace):null)===e.workspaceRoot;T.current&&n&&r&&queueMicrotask(()=>ie.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`&&O(``)},s.onclose=e=>{if(o.current===s){ue.current.clear(),de.current.clear(),fe.current.clear(),ae(),ne.current=!1;for(let e of h.current.values())e.reject(new wP(`The connection dropped before the upload finished`));h.current.clear();for(let e of g.current.values())e.reject(new rK(`the connection dropped before the older messages arrived`,`failed`));if(g.current.clear(),e.code===vK){a({type:`auth_required`});return}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()}},[w,e,A,pe,me,O,ce,ae,s,r]);let ge=(0,d.useCallback)((e,t)=>{let n=o.current;if(!n||n.readyState!==WebSocket.OPEN)return Promise.reject(new rK(`not connected to the server`,`failed`));let r=`history:${crypto.randomUUID()}`;return new Promise((n,i)=>{let a=window.setTimeout(()=>{g.current.delete(r)&&i(new rK(`the older messages did not arrive`,`failed`))},gK),o=e=>t=>{clearTimeout(a),e(t)};g.current.set(r,{resolve:o(n),reject:o(i)}),w({type:`history_before`,sessionId:_.current,have:e,count:t,requestId:r})})},[w]),_e=(0,d.useCallback)(async()=>{let e=y.current;if(!(!e||e.loading||v.current||e.remaining<=0)){v.current=!0,a({type:`history_load_started`});try{let t=await ge(e.have,50);a({type:`history_loaded`,items:t.items,remaining:t.remaining})}catch(e){if(e instanceof rK&&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{v.current=!1}}},[ge]);return{state:i,setOutcomeActive:D,refreshOutcome:se,authToken:l.current,switchWorkspace:(e,t)=>{(t??e)!==ee&&(a({type:`workspace_switching`}),w({type:`switch_workspace`,root:e,...t!==void 0&&t!==e?{id:t}:{}}))},openProject:e=>{a({type:`workspace_switching`}),w({type:`open_project`,root:e})},closeProject:(e,t)=>w({type:`close_project`,root:e,...t!==void 0&&t!==e?{id:t}:{}}),checkPiPackages:()=>w({type:`check_pi_packages`}),updatePiPackage:e=>{let t=`pkg:${crypto.randomUUID()}`;a({type:`pi_package_update_started`,requestId:t,source:e}),w({type:`update_pi_package`,source:e,requestId:t})},restartServer:()=>w({type:`restart_server`}),openSideSession:e=>{a({type:`workspace_switching`}),w({type:`open_side_session`,root:e})},submitToken:e=>{nK(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}:{}}),w({type:`prompt`,text:e,...t?.length?{images:t}:{}})},abort:()=>w({type:`abort`}),setModel:(e,t)=>w({type:`set_model`,provider:e,id:t}),setThinking:e=>w({type:`set_thinking`,level:e}),newSession:()=>w({type:`new_session`}),switchSession:e=>w({type:`switch_session`,path:e}),deleteSession:e=>w({type:`delete_session`,path:e}),listSessions:()=>w({type:`list_sessions`}),renameSession:(e,t)=>w({type:`rename_session`,path:e,name:t}),searchSessions:e=>{let t=`sessions:${crypto.randomUUID()}`;a({type:`session_search_started`,query:e,requestId:t}),w({type:`search_sessions`,query:e,requestId:t})},clearSessionSearch:()=>a({type:`session_search_cleared`}),listTree:()=>w({type:`list_tree`}),navigateTree:e=>w({type:`navigate_tree`,entryId:e}),forkSession:e=>w({type:`fork_session`,entryId:e}),editPrompt:(e,t,n)=>w({type:`edit_prompt`,entryId:e,text:t,...n?.length?{images:n}:{}}),compact:()=>w({type:`compact`}),fetchOlderItems:ge,loadOlderItems:_e,respondToDialog:e=>{w({type:`extension_ui_response`,...e}),a({type:`dialog_answered`})},dismissNotification:e=>a({type:`dismiss_notification`,id:e}),listDirectory:e=>O(e),refreshFileTree:he,readFile:(e,t)=>{let n=`file:${crypto.randomUUID()}`;a({type:`file_read_started`,path:e,requestId:n}),w({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:${crypto.randomUUID()}`;a({type:`file_save_started`,path:e,requestId:i,content:t}),w({type:`write_file`,path:e,content:t,expectedMtimeMs:n,...r?{force:r}:{},requestId:i})},createFile:e=>{a({type:`file_create_started`}),w({type:`create_file`,path:e,requestId:`create:${crypto.randomUUID()}`})},uploadFile:(e,t)=>{let n=b.current;if(n===null)return Promise.reject(new wP(`the workspace is read-only`,`denied`));let r=o.current;if(!r||r.readyState!==WebSocket.OPEN)return Promise.reject(new wP(`not connected to the server`));let i=n?`${n}/${CP}`:CP,a=`upload:${crypto.randomUUID()}`;return new Promise((n,r)=>{let o=window.setTimeout(()=>{h.current.delete(a)&&r(new wP(`the upload timed out`))},hK),s=e=>t=>{clearTimeout(o),e(t)};h.current.set(a,{resolve:s(n),reject:s(r)}),w({type:`upload_file`,destinationDirectory:i,name:e,contentBase64:t,requestId:a})})},createDirectory:e=>{a({type:`file_create_started`}),w({type:`create_directory`,path:e,requestId:`create:${crypto.randomUUID()}`})},openNative:e=>{let t=`fileop:${crypto.randomUUID()}`;a({type:`file_operation_started`,operation:`open_native`,path:e,requestId:t}),w({type:`open_native`,path:e,requestId:t})},revealNative:e=>{let t=Date.now();if(u.current?.path===e&&t-u.current.at<yK)return;u.current={path:e,at:t};let n=`fileop:${crypto.randomUUID()}`;a({type:`file_operation_started`,operation:`reveal_native`,path:e,requestId:n}),w({type:`reveal_native`,path:e,requestId:n})},renameFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;a({type:`file_operation_started`,operation:`rename_file`,path:e,requestId:n}),w({type:`rename_file`,path:e,name:t,requestId:n})},deleteFile:e=>{let t=`fileop:${crypto.randomUUID()}`;a({type:`file_operation_started`,operation:`delete_file`,path:e,requestId:t}),w({type:`delete_file`,path:e,requestId:t})},moveFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;a({type:`file_operation_started`,operation:`move_file`,path:e,requestId:n}),w({type:`move_file`,path:e,destinationDirectory:t,requestId:n})},copyFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;a({type:`file_operation_started`,operation:`copy_file`,path:e,requestId:n}),w({type:`copy_file`,path:e,destinationDirectory:t,requestId:n})},searchFiles:e=>{let t=`search:${crypto.randomUUID()}`;a({type:`file_search_started`,query:e,requestId:t}),w({type:`search_files`,query:e,requestId:t})},clearFileSearch:()=>a({type:`file_search_cleared`}),fetchGitStatus:()=>A(),fetchGitDiff:e=>{let t=`gitdiff:${crypto.randomUUID()}`;a({type:`git_diff_started`,path:e,requestId:t}),w({type:`git_diff`,path:e,requestId:t})},clearGitDiff:()=>a({type:`git_diff_cleared`}),fetchGitLog:(e,t)=>w({type:`git_log`,repo:e,...t?{limit:t}:{},requestId:`gitlog:${crypto.randomUUID()}`}),fetchGitShow:(e,t)=>w({type:`git_show`,repo:e,sha:t,requestId:`gitshow:${crypto.randomUUID()}`}),clearGitShow:()=>a({type:`git_show_cleared`}),fetchGitFileHistory:(e,t)=>{let n=`gitfilelog:${crypto.randomUUID()}`;a({type:`git_file_history_started`,path:e,requestId:n}),w({type:`git_file_log`,path:e,...t?{limit:t}:{},requestId:n})},closeGitFileHistory:()=>a({type:`git_file_history_closed`}),fetchGitFileDiff:(e,t)=>{let n=`gitfilediff:${crypto.randomUUID()}`;a({type:`git_file_diff_started`,base:e,target:t,requestId:n}),w({type:`git_file_diff`,base:e,target:t,requestId:n})},clearGitFileDiff:()=>a({type:`git_file_diff_cleared`}),setCredential:(e,t)=>w({type:`set_credential`,provider:e,apiKey:t}),declareProvider:e=>w({type:`declare_provider`,...e}),browseServerDirectory:e=>{let t=`serverdir:${crypto.randomUUID()}`;a({type:`server_browse_started`,path:e,requestId:t}),w({type:`browse_server_directory`,path:e,requestId:t})},closeServerBrowser:()=>a({type:`server_browse_closed`}),suggestAgentResourceClonePath:e=>{let t=`resource-clone-path:${crypto.randomUUID()}`;a({type:`resource_clone_path_started`,requestId:t}),w({type:`suggest_agent_resource_clone_path`,repositoryUrl:e,requestId:t})},cloneAgentResourceRepository:(e,t)=>{let n=`resource-preview:${crypto.randomUUID()}`;a({type:`resource_preview_started`,requestId:n}),w({type:`clone_agent_resource_repository`,repositoryUrl:e,destinationPath:t,requestId:n})},enrollAgentResourceRepository:(e,t,n,r)=>{let i=`resource-enroll:${crypto.randomUUID()}`;a({type:`resource_enrollment_started`,requestId:i}),w({type:`enroll_agent_resource_repository`,previewToken:e,skillRoots:t,extensionRoots:n,...r?{enabledSkills:r}:{},requestId:i})},setAgentResourceSkills:(e,t)=>{let n=`resource-skills:${crypto.randomUUID()}`;a({type:`resource_skills_started`,requestId:n,repositoryId:e}),w({type:`set_agent_resource_skills`,repositoryId:e,enabledSkills:t,requestId:n})},removeAgentResourceRepository:e=>{let t=`resource-remove:${crypto.randomUUID()}`;a({type:`resource_removal_started`,requestId:t,repositoryId:e}),w({type:`remove_agent_resource_repository`,repositoryId:e,requestId:t})},refreshAgentResourceRepositories:e=>{let t=`resource-refresh:${crypto.randomUUID()}`;a({type:`resource_refresh_started`,requestId:t,...e?{repositoryId:e}:{}}),w({type:`refresh_agent_resource_repositories`,...e?{repositoryId:e}:{},requestId:t})},updateAgentResourceRepository:(e,t,n,r,i=!1)=>{let o=`resource-update:${crypto.randomUUID()}`;a({type:`resource_update_started`,requestId:o,repositoryId:e}),w({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`}),w({type:`update_config`,...e})},openTerminal:(e,t,n,r)=>w({type:`terminal_open`,terminalId:e,cwd:t,cols:n,rows:r}),sendTerminalInput:(e,t)=>w({type:`terminal_input`,terminalId:e,data:t}),getTerminalCwd:e=>w({type:`terminal_get_cwd`,terminalId:e}),resizeTerminal:(e,t,n)=>w({type:`terminal_resize`,terminalId:e,cols:t,rows:n}),closeTerminal:e=>{w({type:`terminal_close`,terminalId:e}),S.current.delete(e)},subscribeTerminal:(e,t)=>{let n=S.current.get(e);return n||(n={onData:new Set,onCwd:new Set,onExit:new Set,onError:new Set},S.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 xK=120;function SK({label:e}){return(0,k.jsx)(`div`,{className:`flex justify-end px-4`,role:`status`,"aria-live":`polite`,children:(0,k.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,k.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,k.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:e})]})})}var CK=(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,setModel:h,setThinking:g,newSession:_,switchSession:v,deleteSession:b,listSessions:x,renameSession:S,searchSessions:ee,clearSessionSearch:C,listTree:w,navigateTree:T,forkSession:te,editPrompt:ne,compact:re,loadOlderItems:ie,fetchOlderItems:ae,respondToDialog:D,dismissNotification:O,listDirectory:le,refreshFileTree:ue,readFile:de,writeFile:fe,createFile:pe,createDirectory:me,uploadFile:he,openNative:ge,revealNative:_e,renameFile:ve,deleteFile:ye,moveFile:be,copyFile:xe,closeFilePreview:Se,searchFiles:Ce,clearFileSearch:we,fetchGitDiff:Te,clearGitDiff:Ee,fetchGitLog:De,fetchGitShow:Oe,clearGitShow:ke,fetchGitFileHistory:Ae,closeGitFileHistory:je,fetchGitFileDiff:Me,clearGitFileDiff:Ne,setCredential:Pe,declareProvider:Fe,updateConfig:Ie,suggestAgentResourceClonePath:Le,cloneAgentResourceRepository:Re,enrollAgentResourceRepository:ze,setAgentResourceSkills:Be,removeAgentResourceRepository:Ve,refreshAgentResourceRepositories:He,updateAgentResourceRepository:Ue,browseServerDirectory:Ge,closeServerBrowser:Ke,switchWorkspace:qe,openProject:Je,closeProject:Ye,openSideSession:Xe,checkPiPackages:Ze,updatePiPackage:Qe,restartServer:$e,openTerminal:et,sendTerminalInput:tt,getTerminalCwd:nt,resizeTerminal:rt,closeTerminal:it,subscribeTerminal:at,setOutcomeActive:ot,refreshOutcome:st}=bK(e,r,o,i);sL(c.workspaces,c.workspace?AN(c.workspace):null);let ct=c.workspace?AN(c.workspace):null;(0,d.useEffect)(()=>{ft([]),rn([]),yn.current&&(yn.current.scrollTop=0)},[ct]);let[lt,ut]=(0,d.useState)(!1),[dt,ft]=(0,d.useState)([]),[pt,mt]=(0,d.useState)([]),[ht,gt]=(0,d.useState)(null),[_t,vt]=(0,d.useState)(null),[yt,bt]=(0,d.useState)(null),[xt,St]=(0,d.useState)(!1),[Ct,wt]=(0,d.useState)(null),[Tt,Et]=(0,d.useState)(null),Dt=Ct===`project`,Ot=e=>wt(e?`project`:null),kt=c.embedWorkspaceControls===`projects`?`projects`:c.embedWorkspaceControls===`root`?`root`:`none`,At=(0,d.useRef)({}),jt=(0,d.useRef)([]),Mt=(0,d.useRef)(null),Nt=(0,d.useRef)(null),[Pt,Ft]=(0,d.useState)(!1),[It,Lt]=(0,d.useState)(hP),Rt=(0,d.useCallback)((e,t)=>{gP(e,t),Lt(n=>({...n,[e]:t}))},[]),[zt,Bt]=(0,d.useState)(!1),[Vt,Ht]=(0,d.useState)(!0),[Ut,Wt]=(0,d.useState)(!1),Gt=c.terminal?.enabled??!1;(0,d.useEffect)(()=>{let e=e=>{Gt&&(e.ctrlKey||e.metaKey)&&e.key==="`"&&(e.preventDefault(),Wt(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Gt]);let[Kt,qt]=(0,d.useState)(!1),[Jt,Yt]=(0,d.useState)(null),Xt=(0,d.useCallback)(()=>Yt(null),[]);function Zt(){let e=!zt;Bt(e),e&&(Ht(!1),qt(!1))}function Qt(){let e=!Vt;Ht(e),e&&(Bt(!1),qt(!1))}function $t(){let e=!Kt;qt(e),e&&(Bt(!1),Ht(!1))}(0,d.useEffect)(()=>(ot(Kt),()=>ot(!1)),[Kt,ot,c.sessionId,ct]),(0,d.useEffect)(()=>{qt(!1),Yt(null)},[ct]);let[en,tn]=(0,d.useState)([]),[nn,rn]=(0,d.useState)([]),an=(0,d.useRef)(0),on=(0,d.useRef)(0),[sn,cn]=(0,d.useState)(0);async function ln(e){let t=[...e],n=t.filter(OP).map(e=>({id:`${an.current++}`,name:e.name}));n.length>0&&rn(e=>[...e,...n]),on.current===0&&tn([]),on.current++;try{let{attachments:e,errors:n}=await IP(t,he);e.length>0&&ft(t=>[...t,...e]),n.length>0&&tn(e=>[...e,...n])}finally{if(on.current--,n.length>0){let e=new Set(n.map(e=>e.id));rn(t=>t.filter(t=>!e.has(t.id)))}}}(0,d.useEffect)(()=>{jt.current=dt},[dt]),(0,d.useEffect)(()=>{let t=c.openFile;if(!t)return;let n=t.path,r=t.status===`loaded`,i=t.status===`error`&&t.message===`Binary file — preview not supported`&&se(n);if(Mt.current!==n&&(Mt.current=n,Nt.current=null,ft(e=>e.filter(e=>e.source!==`preview`)),gt(null),vt(null),bt(null)),Nt.current===n)return;(oe(n)||E(n))&&ft(e=>e.filter(e=>e.source!==`preview`));let a=!1;async function o(){let t=oe(n)?_t===n?await HP(n,ce(e,n,l,c.previewRevision)):null:E(n)?yt?.path===n&&yt.revision===c.previewRevision?RP(n):null:i||r?LP(n):null;if(!(a||t===null||Mt.current!==n||Nt.current===n)){if(typeof t==`string`){gt(t);return}gt(null),ft(e=>GP(e,t))}}return o(),()=>{a=!0}},[c.openFile,c.previewRevision,e,l,_t,yt]);function un(){Mt.current=null,Nt.current=null,Se()}let dn=(0,d.useMemo)(()=>[...dt.filter(e=>e.kind===`path`).map(e=>e.data),...pt],[dt,pt]);function fn(e){let t=jt.current.findIndex(t=>t.kind===`path`&&t.data===e);t>=0?pn(t):pt.includes(e)||ft(t=>WP(t,e))}function pn(e){let t=jt.current[e];t?.source===`preview`&&(Nt.current=t.previewPath??Mt.current,gt(null)),ft(t=>KP(t,e))}function mn(e,t){f(e,t),ft([]),tn([]),gt(null),xt||un()}function hn(e){e.preventDefault(),cn(0),e.dataTransfer.files.length>0&&ln(Array.from(e.dataTransfer.files))}let{theme: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<xK)},[Dn]),kn=(0,d.useRef)(null),An=(0,d.useCallback)(()=>{let e=yn.current;e&&(e.scrollHeight-e.scrollTop-e.clientHeight<xK||(kn.current=e.scrollTop))},[]),jn=(0,d.useCallback)(()=>{let e=yn.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<xK,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(()=>{if(wn.current){An(),Cn.current?.scrollIntoView({behavior:`auto`});return}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)(()=>{if(wn.current){An(),Cn.current?.scrollIntoView({behavior:`smooth`});return}On()},[c.items,On,An]);let Pn=(0,d.useMemo)(()=>FN(c.items),[c.items]),Fn=(0,d.useMemo)(()=>zt?GN(c.items):null,[zt,c.items]),In=(0,d.useMemo)(()=>GM({readFile:(e,t)=>{Ft(!1),de(e,t)},fetchGitFileHistory:e=>Ae(e),fetchGitDiff:e=>{Ft(!0),de(e)},searchFiles:e=>Ce(e)}),[de,Ae,Ce]),Ln=(0,d.useCallback)(()=>Rt(`tools`,!0),[Rt]),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<xK;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 A(async()=>{let{exportConversation:e}=await import(`./conversationExport-B1l3iRjL.js`);return{exportConversation:e}},__vite__mapDeps([22,21]));await t({items:c.items,olderItems:c.olderHistory?.remaining??0,...c.olderHistory?{fetchOlderItems:ae}:{},connection:{serverUrl:e,token:l},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,ae,e,l]),{jumpToItem:Gn,highlightIndex:Kn}=uP({items:c.items,scrollerRef:yn,hideTools:!It.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}),ie()},[ie]);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,k.jsx)(p.Provider,{value:gn,children:(0,k.jsx)(ML,{title:c.branding.title,onSubmit:u})}):c.credentials&&!c.credentials.usableModel?(0,k.jsx)(p.Provider,{value:gn,children:(0,k.jsx)(hL,{title:c.branding.title,credentials:c.credentials,onSetCredential:Pe,onDeclareProvider:Fe,errors:c.errors})}):(0,k.jsx)(p.Provider,{value:gn,children:(0,k.jsxs)(Ql.Provider,{value:c.replyConformance,children:[(0,k.jsxs)(`div`,{className:`relative flex h-full`,onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&cn(e=>e+1)},onDragLeave:()=>cn(e=>Math.max(0,e-1)),onDragOver:e=>e.preventDefault(),onDrop:hn,children:[sn>0&&(0,k.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,k.jsx)(`p`,{className:`text-lg font-medium text-zinc-700 dark:text-zinc-200`,children:`Drop files to attach (images, documents & text)`})}),lt&&(0,k.jsx)(jL,{tree:c.fileTree,openFile:c.openFile,writableRoot:c.writableRoot,gitFiles:c.gitStatus?.files,attachedPaths:dn,onExpand:le,onSelectDirectory:Et,onRefresh:ue,onSelectFile:e=>{Ft(!1),Et(e),de(e)},onSelectDiff:e=>{Ft(!0),Et(e),de(e)},onToggleAttachPath:fn,onCreateFile:e=>{Ft(!1),pe(e)},onCreateDirectory:me,onOpenNative:ge,onRevealNative:_e,onRenameFile:ve,onDeleteFile:ye,onMoveFile:be,onCopyFile:xe,fileOperation:c.fileOperation,createError:c.createError,created:c.created}),(0,k.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[Dt&&(0,k.jsx)(xI,{label:`Choose a project directory`,browse:c.serverBrowse,onBrowse:Ge,onSelect:e=>{Ot(!1),Ke(),Je(e)},onCancel:()=>{Ot(!1),Ke()}}),!o&&c.outpostUpdate&&(0,k.jsx)(kN,{notice:c.outpostUpdate}),(0,k.jsx)(oL,{workspace:c.workspace,workspaces:c.workspaces,workspaceLocked:c.workspaceLocked,workspaceControl:o?kt:`projects`,rootControl:{sandbox:c.sandbox,browse:c.serverBrowse,applyState:c.settingsApply,blocked:Ct!==null&&Ct!==`root`,onBrowse:Ge,onCloseBrowser:()=>{wt(null),Ke()},onOpened:()=>wt(`root`),onSelect:e=>Ie({sandbox:{root:e,allowWrite:c.sandbox?.allowWrite??!1,allowBash:c.sandbox?.allowBash??!1,...c.sandbox?.writableRoot?{writableRoot:c.sandbox.writableRoot}:{}}})},onSwitchWorkspace:qe,onOpenProject:()=>{Ot(!0),Ge(``)},onCloseProject:Ye,onOpenSideSession:Xe,piPackages:c.piPackages,piPackageUpdate:c.piPackageUpdate,canRestartServer:!o,serverRestarting:c.serverRestarting,onCheckPiPackages:Ze,onUpdatePiPackage:Qe,onRestartServer:$e,restartNeeded:c.restartNeeded,title:c.branding.title,sessions:c.sessions,sessionSearch:c.sessionSearch,sessionId:c.sessionId,tree:c.tree,isStreaming:c.isStreaming,connected:c.connected,theme:gn,showThemeToggle:c.branding.allowThemeToggle!==!1,statuses:c.statuses,sidebarOpen:lt,outcomeOpen:Kt,filters:It,onToggleSidebar:()=>ut(!lt),onToggleOutcome:$t,onFilterChange:Rt,...c.items.length>0?{onExportConversation:()=>void Wn()}:{},exportProgress:zn,onToggleTheme:_n,onNewSession:_,onSwitchSession:v,onDeleteSession:b,onListSessions:x,onRenameSession:S,onSearchSessions:ee,onClearSessionSearch:C,onListTree:w,onNavigateTree:T,onForkSession:te,gitAvailable:c.gitAvailable,gitStatus:c.gitStatus,gitSelectedPath:Tt,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:Ge,onCloseServerBrowser:Ke,settingsPickerBlocked:Ct!==null&&Ct!==`settings`,onSettingsPickerOpened:()=>wt(`settings`),onUpdateConfig:Ie,onSuggestAgentResourceClonePath:Le,onCloneAgentResourceRepository:Re,onEnrollAgentResourceRepository:ze,onSetAgentResourceSkills:Be,onRemoveAgentResourceRepository:Ve,onRefreshAgentResourceRepositories:He,onUpdateAgentResourceRepository:Ue,onFetchGitLog:De,onShowCommit:Oe,terminalOpen:Ut,onToggleTerminal:Gt?()=>Wt(e=>!e):void 0}),(0,k.jsxs)(`div`,{className:`relative z-0 flex min-h-0 flex-1 flex-col`,children:[c.workPlan&&(0,k.jsx)(IL,{plan:c.workPlan,open:Vt,onToggle:Qt,onOpenWorkspace:e=>{Ft(!1),de(e)},requestedTaskId:Jt,onTaskRequestHandled:Xt}),Kt&&(0,k.jsx)(QG,{state:c.outcome,onClose:()=>qt(!1),onRefresh:st,onTarget:e=>{e.kind===`work-plan-task`?(Yt(e.taskId),qt(!1),Bt(!1),Ht(!0)):e.kind===`workspace-file`?(Ft(!1),de(e.path)):e.kind===`workspace-diff`&&(Ft(!0),de(e.path))}}),c.openFile&&(0,k.jsx)(LF,{file:c.openFile,writableRoot:c.writableRoot,docxTemplate:c.docxTemplate,isStreaming:c.isStreaming,onDirtyChange:St,gitState:c.gitStatus?.files[c.openFile.path],initialShowGitDiff:Pt,gitDiff:c.gitDiff,onFetchGitDiff:Te,onClearGitDiff:Ee,inRepository:vP(c.gitStatus?.repos??[],c.openFile.path)!==null,onOpenGitHistory:Ae,onClose:un,onReload:de,onSave:fe,serverUrl:e,token:l,onImageLoad:vt,onPdfLoad:e=>bt({path:e,revision:c.previewRevision}),rawRevision:c.previewRevision},c.openFile.path),c.gitFileHistory&&(0,k.jsx)(lI,{history:c.gitFileHistory,diff:c.gitFileDiff,dirty:c.gitStatus?.files[c.gitFileHistory.path]!==void 0,onFetchDiff:Me,onClearDiff:Ne,onClose:je}),c.gitShow&&(0,k.jsx)(zF,{show:c.gitShow,onClose:ke}),Fn&&(0,k.jsx)(cP,{analysis:Fn,onJump:Gn,onClose:()=>Bt(!1)}),(0,k.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`} ${zt?`md:pr-[26rem]`:c.workPlan&&Vt?`md:pr-[23rem]`:``}`,children:(0,k.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-3 px-4 py-6`,children:[c.items.length===0&&(0,k.jsxs)(`div`,{className:`mt-24 text-center text-zinc-500 dark:text-zinc-600`,children:[(0,k.jsx)(`div`,{className:`mb-2 text-4xl`,children:c.branding.title??`π`}),(0,k.jsx)(`p`,{className:`text-sm`,children:c.branding.welcome??`Send a message to start the agent.`})]}),c.olderHistory&&(0,k.jsx)(NN,{older:c.olderHistory,onLoad:Yn}),c.items.map((t,n)=>{let r=`${c.sessionId}:${n}`,i=(e,t=r)=>(0,k.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,k.jsx)(We,{item:t,canEdit:!t.readOnly&&!c.isStreaming&&c.connected,onEdit:ne})):t.kind===`compaction`?i((0,k.jsx)(MN,{item:t})):t.kind===`tool`?It.tools?i((0,k.jsx)(TN,{item:t,dispatch:In}),t.toolCallId?`${c.sessionId}:${t.toolCallId}`:r):null:t.kind===`custom`?i((0,k.jsx)(EN,{item:t})):(It.reasoning?t.blocks:t.blocks.filter(e=>e.type!==`thinking`)).length===0&&!t.errorMessage?(0,k.jsx)(`div`,{"data-item-index":n,className:`sr-only`,"aria-hidden":!0},r):i((0,k.jsx)(HM,{item:t,hideReasoning:!It.reasoning,serverUrl:e,token:l,onOpenFile:e=>{Ft(!1),de(e)}}))}),c.pendingPrompt&&(0,k.jsxs)(`div`,{className:`flex flex-col gap-3 opacity-60`,"data-pending-prompt":!0,children:[(0,k.jsx)(We,{item:{kind:`user`,...c.pendingPrompt},canEdit:!1,onEdit:()=>{}}),(0,k.jsx)(SK,{label:`sending…`})]}),c.isStreaming&&!c.pendingPrompt&&(0,k.jsx)(SK,{label:`working…`}),(c.queue.steering.length>0||c.queue.followUp.length>0)&&(0,k.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,k.jsxs)(`div`,{children:[`⏩ steering: `,e]},`s${t}`)),c.queue.followUp.map((e,t)=>(0,k.jsxs)(`div`,{children:[`⏭ follow-up: `,e]},`f${t}`))]}),en.map((e,t)=>(0,k.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}`)),ht&&(0,k.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:ht}),Vn&&(0,k.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,k.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,k.jsx)(`div`,{ref:Cn})]})}),(0,k.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-4 z-0 flex justify-center ${zt||Kt?`md:pr-[26rem]`:c.workPlan&&Vt?`md:pr-[23rem]`:``}`,children:!Tn&&(0,k.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,k.jsx)(`span`,{"aria-hidden":!0,children:`↓`}),`Latest`]})})]}),Gt&&(0,k.jsx)(JG,{open:Ut,onClose:()=>Wt(!1),cwd:c.workspace?.root,onSetWorkspaceRoot:e=>{Je&&!o?Je(e):c.sandbox?Ie({sandbox:{root:e,allowWrite:c.sandbox.allowWrite,allowBash:c.sandbox.allowBash,...c.sandbox.writableRoot?{writableRoot:c.sandbox.writableRoot}:{}}}):Ie({sandbox:{root:e,allowWrite:!0,allowBash:!0}})},openTerminal:et,sendTerminalInput:tt,getTerminalCwd:nt,resizeTerminal:rt,closeTerminal:it,subscribeTerminal:at}),(0,k.jsx)(`footer`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,k.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,k.jsx)(xF,{widgets:c.widgets,placement:`aboveEditor`}),(0,k.jsx)(eF,{initialDraft:At.current[ct??``]??``,onDraftChange:e=>{At.current[ct??``]=e},isStreaming:c.isStreaming,connected:c.connected,commands:c.commands,fileSearch:c.fileSearch,prefill:c.editorPrefill,attachments:dt,pendingUploads:nn,onAttach:e=>void ln(e),onMentionPaths:mt,onRemoveAttachment:pn,onSend:mn,onAbort:m,onSearchFiles:Ce,onClearFileSearch:we},ct??``),(0,k.jsx)(xF,{widgets:c.widgets,placement:`belowEditor`}),(0,k.jsx)(fL,{model:c.model,models:c.models,thinkingLevel:c.thinkingLevel,thinkingLevels:c.thinkingLevels,modelSupportsReasoning:c.modelSupportsReasoning,isStreaming:c.isStreaming,contextUsage:c.contextUsage,sessionUsage:Pn,analysisOpen:zt,onToggleAnalysis:Zt,isCompacting:c.isCompacting,onSetModel:h,onSetThinking:g,onCompact:re})]})})]})]}),c.dialogQueue[0]&&(0,k.jsx)(uF,{request:c.dialogQueue[0],onRespond:D}),(0,k.jsx)(mF,{notifications:c.notifications,onDismiss:O})]})})});(0,f.createRoot)(document.getElementById(`root`)).render((0,k.jsx)(d.StrictMode,{children:(0,k.jsx)(CK,{})}));export{i as A,Ne as C,ce as D,ie as E,ae as O,xl as S,O as T,Uu as _,FM as a,lu as b,Ck as c,vw as d,iw as f,Ku as g,Rm as h,RM as i,te as k,ik as l,eg as m,EF as n,CM as o,Og as p,OF as r,wk as s,iK as t,Mw as u,Wu as v,A as w,ru as x,Bu as y};
350
+ `))&&a()}),s=y.current.subscribeTerminal?.(e,{onData:n=>{t.write(n);let r=n.match(/\x1b\]7;file:\/\/[^/]*([^\x07\x1b]+)(?:\x07|\x1b\\)/);if(r&&r[1])try{let t=decodeURIComponent(r[1]);y.current.onCwdUpdate(e,t)}catch{}},onCwd:t=>{y.current.onCwdUpdate(e,t)},onExit:e=>{t.writeln(`\r\n\x1b[90m[Process completed (exit code ${e??0})]\x1b[0m`)},onError:e=>{t.writeln(`\r\n\x1b[31m[Terminal error: ${e}]\x1b[0m`)}})??(()=>{}),c=new ResizeObserver(()=>{if(h.current&&h.current.clientWidth>0&&h.current.clientHeight>0)try{n.fit(),t.cols>0&&t.rows>0&&y.current.resizeTerminal?.(e,t.cols,t.rows)}catch{}});return c.observe(h.current),()=>{o.dispose(),s(),c.disconnect(),t.dispose(),y.current.closeTerminal?.(e)}},[e]),(0,d.useEffect)(()=>{if(!i&&r&&n&&_.current&&g.current&&h.current){y.current.getTerminalCwd?.(e);let t=setTimeout(()=>{try{_.current?.fit(),g.current?.focus()}catch{}},50);return()=>clearTimeout(t)}},[r,n,e,i]),(0,k.jsx)(`div`,{ref:h,className:`h-full w-full p-2 bg-white dark:bg-zinc-950 overflow-hidden ${n?`block`:`hidden`}`})}function JG({open:e,onClose:t,cwd:n,onSetWorkspaceRoot:r,openTerminal:i,sendTerminalInput:a,getTerminalCwd:o,resizeTerminal:s,closeTerminal:c,subscribeTerminal:l}){let[u,f]=(0,d.useState)(e);(0,d.useEffect)(()=>{e&&f(!0)},[e]);let[p,m]=(0,d.useState)([{id:`term-1`,title:`terminal 1`}]),[h,g]=(0,d.useState)(`term-1`),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(``),[x,S]=(0,d.useState)({}),[ee,C]=(0,d.useState)(!1),[w,T]=(0,d.useState)(!1),te=(0,d.useRef)(new Map),ne=(0,d.useCallback)((e,t)=>{te.current.set(e,t)},[]),re=(0,d.useCallback)((e,t)=>{S(n=>({...n,[e]:t}))},[]),ie=(0,d.useCallback)(()=>{let e=p.length+1,t=`term-${Date.now()}-${e}`,n={id:t,title:`terminal ${e}`};m(e=>[...e,n]),g(t)},[p.length]),ae=(0,d.useCallback)((e,n)=>{if(n.stopPropagation(),p.length<=1){t();return}m(t=>{let n=t.filter(t=>t.id!==e);if(h===e){let r=t.findIndex(t=>t.id===e),i=n[Math.max(0,r-1)]?.id??n[0]?.id;g(i)}return n}),te.current.delete(e),S(t=>{let n={...t};return delete n[e],n})},[p.length,h,t]),oe=(e,t)=>{t.stopPropagation(),v(e.id),b(e.title)},E=()=>{if(_){let e=y.trim();e&&m(t=>t.map(t=>t.id===_?{...t,title:e}:t)),v(null)}},se=e=>{e.key===`Enter`?E():e.key===`Escape`&&v(null)},ce=(0,d.useCallback)(()=>{let e=te.current.get(h);e&&e()},[h]),D=x[h]||n||``;return u?(0,k.jsxs)(`div`,{className:`flex-col border-t border-zinc-200 dark:border-zinc-800 bg-zinc-100 dark:bg-zinc-900 transition-all duration-150 ${e?`flex`:`hidden`} ${ee?`h-[85vh]`:`h-72`} relative z-20`,children:[(0,k.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,k.jsxs)(`div`,{className:`flex items-center space-x-1 overflow-x-auto min-w-0`,children:[(0,k.jsx)(`div`,{className:`flex items-center space-x-1`,children:p.map(e=>{let t=e.id===h,n=e.id===_;return(0,k.jsxs)(`div`,{onClick:()=>g(e.id),onDoubleClick:t=>oe(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,k.jsx)(`input`,{type:`text`,"data-testid":`terminal-tab-rename-input`,value:y,autoFocus:!0,onChange:e=>b(e.target.value),onBlur:E,onKeyDown:se,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,k.jsx)(`span`,{children:e.title}),p.length>1&&(0,k.jsx)(`span`,{onClick:t=>ae(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,k.jsx)(`svg`,{className:`w-3 h-3`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]},e.id)})}),(0,k.jsx)(`button`,{onClick:ie,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,k.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 4v16m8-8H4`})})})]}),D&&(0,k.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:r&&(0,k.jsx)(`button`,{onClick:()=>{if(D&&r){if((D===`/`||D===`\\`||/^[A-Za-z]:[\\/]?$/.test(D))&&!window.confirm(`Open root filesystem "${D}" as the workspace project?`))return;r(D),T(!0),setTimeout(()=>T(!1),2e3)}},type:`button`,title:`Open "${D}" 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 ${w?`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,k.jsx)(`span`,{children:w?`✓ Project opened`:`📁 ${KG(D)} → open as project`})})}),(0,k.jsxs)(`div`,{className:`flex items-center space-x-1 text-zinc-500 dark:text-zinc-400`,children:[(0,k.jsx)(`button`,{onClick:ce,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,k.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,k.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,k.jsx)(`button`,{onClick:()=>C(e=>!e),type:`button`,title:ee?`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:ee?(0,k.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})}):(0,k.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M5 15l7-7 7 7`})})}),(0,k.jsx)(`button`,{onClick:t,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,k.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]})]}),(0,k.jsx)(`div`,{className:`flex-1 min-h-0 relative`,children:p.map(t=>(0,k.jsx)(qG,{id:t.id,cwd:n,isActive:t.id===h,isPanelOpen:e,renaming:_!==null,openTerminal:i,sendTerminalInput:a,getTerminalCwd:o,resizeTerminal:s,closeTerminal:c,subscribeTerminal:l,onCwdUpdate:re,registerClear:ne},t.id))})]}):null}var YG={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 XG(e){return YG[e]??{label:e,className:`text-zinc-500`}}function ZG({entry:e,onTarget:t}){let n=XG(e.status),r=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,k.jsx)(`span`,{className:`min-w-0 break-words text-sm font-medium text-zinc-900 dark:text-zinc-100`,children:e.title}),(0,k.jsx)(`span`,{className:`shrink-0 text-[11px] font-semibold uppercase tracking-wide ${n.className}`,children:n.label})]}),e.group&&(0,k.jsx)(`div`,{className:`mt-0.5 text-[11px] text-zinc-500`,children:e.group}),e.detail&&(0,k.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-zinc-600 dark:text-zinc-300`,children:e.detail}),e.reference&&(0,k.jsx)(`div`,{className:`mt-1 truncate text-xs text-zinc-500`,children:e.reference}),(0,k.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,k.jsx)(`a`,{href:e.target.url,target:`_blank`,rel:`noreferrer`,className:i,children:r}):e.target?(0,k.jsx)(`button`,{type:`button`,onClick:()=>t(e.target),className:i,children:r}):(0,k.jsx)(`div`,{className:`rounded-md border border-zinc-200 p-2 dark:border-zinc-800`,children:r})}function QG({state:e,onClose:t,onRefresh:n,onTarget:r}){return(0,k.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,k.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,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-zinc-500`,children:`Workspace review`}),(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:`Outcome`})]}),(0,k.jsxs)(`div`,{className:`flex gap-1`,children:[(0,k.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,k.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,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:e===null||e.status===`loading`?(0,k.jsx)(`div`,{role:`status`,className:`text-sm text-zinc-500`,children:`Loading Outcome…`}):e.status===`error`?(0,k.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,k.jsx)(`div`,{className:`space-y-4`,children:e.outcome.sections.map(e=>(0,k.jsxs)(`section`,{"aria-labelledby":`outcome-${e.id}`,className:`rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.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,k.jsx)(`span`,{className:`text-[11px] font-semibold uppercase text-red-600 dark:text-red-400`,children:e.availability}):null]}),e.summary&&(0,k.jsx)(`p`,{className:`mt-1 text-xs text-zinc-600 dark:text-zinc-300`,children:e.summary}),e.entries.length>0&&(0,k.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.entries.map(e=>(0,k.jsx)(ZG,{entry:e,onTarget:r},e.id))})]},e.id))})})]})}var $G=`pi-outpost:token`;function eK(){let e=null;try{let t=new URL(window.location.href);return e=t.searchParams.get(`token`),e&&(localStorage.setItem($G,e),t.searchParams.delete(`token`),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)),localStorage.getItem($G)}catch{return e}}function tK(){try{return localStorage.getItem($G)}catch{return null}}function nK(e){try{localStorage.setItem($G,e)}catch{}}var rK=class extends Error{kind;constructor(e,t){super(e),this.name=`HistoryError`,this.kind=t}};async function iK(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 aK(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function oK(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 sK(){return{clonePath:null,preview:null,enrollment:null,refresh:null,updates:{},skills:{},removals:{}}}var cK={connected:!1,workspace:null,workspaces:[],workspaceLocked:!1,embedWorkspaceControls:`settings`,switching:!1,authRequired:!1,brandingReady:!1,branding:{},sessionId:``,sessionName:null,model:``,thinkingLevel:`off`,modelSupportsReasoning:!1,models:[],commands:[],sessions:null,sessionSearch:null,tree:null,isStreaming:!1,items:[],olderHistory:null,pendingPrompt:null,workPlan:null,replyConformance:{},outpostUpdate: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:sK(),versions:null,gitAvailable:!1,gitUnavailable:null,credentials:null,gitStatus:null,gitDiff:null,gitLog:null,gitShow:null,gitFileHistory:null,gitFileDiff:null};function lK(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 uK(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 dK(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 fK(e,t){if(t.type!==`hello`&&t.type!==`session_replaced`&&t.type!==`update_config_ack`&&t.type!==`workspace_switched`)return e;let n=t.models.find(e=>`${e.provider}/${e.id}`===t.model);return{...e,replyConformance:{},outpostUpdate:t.outpostUpdate??e.outpostUpdate,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,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,userSkillPaths:t.userSkillPaths??[],serverBrowse:null,settingsApply:null,versions:t.versions??null,agentResources:t.agentResources??null,agentResourceOperations:t.type===`hello`||t.type===`workspace_switched`?sK():e.agentResourceOperations}}function pK(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===`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===`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_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;switch(n.type){case`hello`:case`session_replaced`:case`update_config_ack`:case`workspace_switched`:return{...fK(e,n),openFile:null,gitDiff:null,fileTree:{},directoryRequests:{}};case`workspace_activity`:return{...e,workspaces:n.workspaces,workspace:(e.workspace&&n.workspaces.find(t=>AN(t)===AN(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`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};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:lK(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:lK(e.items,()=>n.item)};case`custom_message`:return{...e,items:[...e.items,n.item]};case`tool_start`:return{...e,items:uK(e.items,n.toolCallId,n.toolName,{toolName:n.toolName,args:n.args,running:!0,callHtml:n.callHtml})};case`tool_update`:return{...e,items:uK(e.items,n.toolCallId,`tool`,{output:n.text,...typeof n.progress==`number`?{progress:n.progress}:{}})};case`tool_end`:return{...e,items:uK(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:dK(e.items,n.toolCallId,{structuredConformance:n.conformance})};case`outpost_update`:return{...e,outpostUpdate:n.notice};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`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;return{...e,openFile:r,gitFileHistory:i?null:e.gitFileHistory,gitFileDiff:i?null:e.gitFileDiff,gitDiff:a?null:e.gitDiff,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))vP(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{...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||!oK(e.gitFileDiff,n)?e:{...e,gitFileDiff:{...e.gitFileDiff,status:`loaded`,beforeText:n.beforeText,afterText:n.afterText}};case`git_error`:return 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 mK(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 hK=12e4,gK=2e4,_K=45e3,vK=4401,yK=1e3;function bK(e=``,t,n=!1,r){let[i,a]=(0,d.useReducer)(pK,cK),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?tK():eK()));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)(i.sessionId);(0,d.useEffect)(()=>{_.current=i.sessionId},[i.sessionId]);let v=(0,d.useRef)(!1),y=(0,d.useRef)(i.olderHistory);(0,d.useEffect)(()=>{y.current=i.olderHistory},[i.olderHistory]);let b=(0,d.useRef)(i.writableRoot);(0,d.useEffect)(()=>{b.current=i.writableRoot},[i.writableRoot]);let x=(0,d.useRef)(!1),S=(0,d.useRef)(new Map),ee=i.workspace?AN(i.workspace):null,C=(0,d.useRef)({workspaceRoot:ee,sessionId:i.sessionId});(0,d.useEffect)(()=>{C.current={workspaceRoot:ee,sessionId:i.sessionId}},[ee,i.sessionId]);let w=(0,d.useCallback)(e=>{let t=o.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[]),T=(0,d.useRef)(!1),te=(0,d.useRef)(null),ne=(0,d.useRef)(!1),re=(0,d.useRef)(null),ie=(0,d.useRef)(()=>{}),ae=(0,d.useCallback)(()=>{te.current=null,re.current!==null&&(clearTimeout(re.current),re.current=null)},[]),se=(0,d.useCallback)(()=>{let e=o.current;if(!e||e.readyState!==WebSocket.OPEN)return;if(te.current!==null){ne.current=!0;return}let t=`outcome:${crypto.randomUUID()}`;te.current=t;let n=C.current;a({type:`outcome_started`,requestId:t,...n}),w({type:`get_outcome`,requestId:t}),re.current=setTimeout(()=>{te.current===t&&(ae(),ne.current=!1,a({type:`outcome_failed`,requestId:t,message:`The Outcome took too long to answer — try again.`}))},_K)},[w,ae]);ie.current=se;let ce=(0,d.useCallback)(()=>{T.current&&ie.current()},[]),D=(0,d.useCallback)(e=>{T.current=e,e?se():ne.current=!1},[se]),O=(0,d.useCallback)((e,t=!1)=>{e===``&&(x.current=!0);let n=`dir:${crypto.randomUUID()}`;a({type:`dir_list_started`,path:e,requestId:n,preserveEntries:t}),w({type:`list_directory`,path:e,requestId:n})},[w]),k=(0,d.useRef)(!1),le=(0,d.useRef)([]);(0,d.useEffect)(()=>{le.current=i.gitStatus?.repos??[]},[i.gitStatus]);let ue=(0,d.useRef)(new Set),de=(0,d.useRef)(new Set),fe=(0,d.useRef)(new Map),A=(0,d.useCallback)(e=>{if(!k.current)return;let t=e??``;if(ue.current.has(t)){de.current.add(t);return}ue.current.add(t);let n=`git:${crypto.randomUUID()}`;fe.current.set(n,t),w({type:`git_status`,...e===void 0?{}:{repo:e},requestId:n})},[w]),pe=(0,d.useCallback)(e=>{let t=fe.current.get(e)??``;fe.current.delete(e),ue.current.delete(t),de.current.delete(t)&&A(t===``?void 0:t)},[A]),me=(0,d.useCallback)(e=>{f.current[e]!==void 0&&O(e,!0)},[O]),he=(0,d.useCallback)(()=>{O(``,!0);for(let e of Object.keys(f.current))e!==``&&me(e)},[me,O]);(0,d.useEffect)(()=>{!i.connected||!x.current||f.current[``]===void 0&&O(``)},[i.connected,i.fileTree,O]),(0,d.useEffect)(()=>{!i.connected||!T.current||te.current===null&&ie.current()},[i.connected]),(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(mK(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===`terminal_data`){let e=S.current.get(t.terminalId);if(e)for(let n of e.onData)n(t.data);return}if(t.type===`terminal_cwd`){let e=S.current.get(t.terminalId);if(e)for(let n of e.onCwd)n(t.cwd);return}if(t.type===`terminal_exit`){let e=S.current.get(t.terminalId);if(e)for(let n of e.onExit)n(t.exitCode);return}if(t.type===`terminal_error`){let e=S.current.get(t.terminalId);if(e)for(let n of e.onError)n(t.message);return}if(t.type===`history_items`){let e=g.current.get(t.requestId);e&&(g.current.delete(t.requestId),e.resolve({items:t.items,remaining:t.remaining}));return}if(t.type===`history_unavailable`){let e=g.current.get(t.requestId);e&&(g.current.delete(t.requestId),e.reject(new rK(t.reason,t.kind)));return}if(t.type===`file_uploaded`){let e=h.current.get(t.requestId);e&&(h.current.delete(t.requestId),e.resolve(t.path));return}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 wP(t.message,t.reason));return}if(t.type===`file_changed`){ce(),me(aK(t.path));let e=p.current;if(e?.status===`loaded`&&e.path===t.path){let e=`file:${crypto.randomUUID()}`;a({type:`file_read_started`,path:t.path,requestId:e,preserveContent:!0}),w({type:`read_file`,path:t.path,requestId:e})}m.current===t.path&&w({type:`git_diff`,path:t.path,requestId:`gitdiff:${crypto.randomUUID()}`}),A(vP(le.current,t.path)?.repo);return}if(t.type===`directory_changed`){ce(),me(t.path);let e=p.current;if(e!==null&&aK(e.path)===t.path){if(oe(e.path)||E(e.path))a({type:`raw_preview_changed`,path:e.path});else if(e.status===`loaded`){let t=`file:${crypto.randomUUID()}`;a({type:`file_read_started`,path:e.path,requestId:t,preserveContent:!0}),w({type:`read_file`,path:e.path,requestId:t})}}let n=m.current;n!==null&&aK(n)===t.path&&w({type:`git_diff`,path:n,requestId:`gitdiff:${crypto.randomUUID()}`}),A();return}if((t.type===`hello`||t.type===`session_replaced`)&&(k.current=t.gitAvailable===!0,t.type===`hello`&&A()),t.type===`agent_end`&&(A(),ce()),t.type===`git_repositories_changed`&&(ce(),k.current=t.available,t.available&&A()),(t.type===`git_status`||t.type===`git_error`&&t.requestId.startsWith(`git:`))&&pe(t.requestId),t.type===`work_plan_changed`&&ce(),(t.type===`workspace_outcome`||t.type===`workspace_outcome_error`)&&te.current===t.requestId&&(ae(),ne.current&&(ne.current=!1,queueMicrotask(()=>ie.current()))),t.type===`hello`||t.type===`session_replaced`||t.type===`workspace_switched`||t.type===`update_config_ack`){ae(),ne.current=!1;let e=C.current,n=t.sessionId===e.sessionId,r=(t.workspace?AN(t.workspace):null)===e.workspaceRoot;T.current&&n&&r&&queueMicrotask(()=>ie.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`&&O(``)},s.onclose=e=>{if(o.current===s){ue.current.clear(),de.current.clear(),fe.current.clear(),ae(),ne.current=!1;for(let e of h.current.values())e.reject(new wP(`The connection dropped before the upload finished`));h.current.clear();for(let e of g.current.values())e.reject(new rK(`the connection dropped before the older messages arrived`,`failed`));if(g.current.clear(),e.code===vK){a({type:`auth_required`});return}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()}},[w,e,A,pe,me,O,ce,ae,s,r]);let ge=(0,d.useCallback)((e,t)=>{let n=o.current;if(!n||n.readyState!==WebSocket.OPEN)return Promise.reject(new rK(`not connected to the server`,`failed`));let r=`history:${crypto.randomUUID()}`;return new Promise((n,i)=>{let a=window.setTimeout(()=>{g.current.delete(r)&&i(new rK(`the older messages did not arrive`,`failed`))},gK),o=e=>t=>{clearTimeout(a),e(t)};g.current.set(r,{resolve:o(n),reject:o(i)}),w({type:`history_before`,sessionId:_.current,have:e,count:t,requestId:r})})},[w]),_e=(0,d.useCallback)(async()=>{let e=y.current;if(!(!e||e.loading||v.current||e.remaining<=0)){v.current=!0,a({type:`history_load_started`});try{let t=await ge(e.have,50);a({type:`history_loaded`,items:t.items,remaining:t.remaining})}catch(e){if(e instanceof rK&&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{v.current=!1}}},[ge]);return{state:i,setOutcomeActive:D,refreshOutcome:se,authToken:l.current,switchWorkspace:(e,t)=>{(t??e)!==ee&&(a({type:`workspace_switching`}),w({type:`switch_workspace`,root:e,...t!==void 0&&t!==e?{id:t}:{}}))},openProject:e=>{a({type:`workspace_switching`}),w({type:`open_project`,root:e})},closeProject:(e,t)=>w({type:`close_project`,root:e,...t!==void 0&&t!==e?{id:t}:{}}),checkPiPackages:()=>w({type:`check_pi_packages`}),updatePiPackage:e=>{let t=`pkg:${crypto.randomUUID()}`;a({type:`pi_package_update_started`,requestId:t,source:e}),w({type:`update_pi_package`,source:e,requestId:t})},restartServer:()=>w({type:`restart_server`}),openSideSession:e=>{a({type:`workspace_switching`}),w({type:`open_side_session`,root:e})},submitToken:e=>{nK(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}:{}}),w({type:`prompt`,text:e,...t?.length?{images:t}:{}})},abort:()=>w({type:`abort`}),setModel:(e,t)=>w({type:`set_model`,provider:e,id:t}),setThinking:e=>w({type:`set_thinking`,level:e}),newSession:()=>w({type:`new_session`}),switchSession:e=>w({type:`switch_session`,path:e}),deleteSession:e=>w({type:`delete_session`,path:e}),listSessions:()=>w({type:`list_sessions`}),renameSession:(e,t)=>w({type:`rename_session`,path:e,name:t}),searchSessions:e=>{let t=`sessions:${crypto.randomUUID()}`;a({type:`session_search_started`,query:e,requestId:t}),w({type:`search_sessions`,query:e,requestId:t})},clearSessionSearch:()=>a({type:`session_search_cleared`}),listTree:()=>w({type:`list_tree`}),navigateTree:e=>w({type:`navigate_tree`,entryId:e}),forkSession:e=>w({type:`fork_session`,entryId:e}),editPrompt:(e,t,n)=>w({type:`edit_prompt`,entryId:e,text:t,...n?.length?{images:n}:{}}),compact:()=>w({type:`compact`}),fetchOlderItems:ge,loadOlderItems:_e,respondToDialog:e=>{w({type:`extension_ui_response`,...e}),a({type:`dialog_answered`})},dismissNotification:e=>a({type:`dismiss_notification`,id:e}),listDirectory:e=>O(e),refreshFileTree:he,readFile:(e,t)=>{let n=`file:${crypto.randomUUID()}`;a({type:`file_read_started`,path:e,requestId:n}),w({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:${crypto.randomUUID()}`;a({type:`file_save_started`,path:e,requestId:i,content:t}),w({type:`write_file`,path:e,content:t,expectedMtimeMs:n,...r?{force:r}:{},requestId:i})},createFile:e=>{a({type:`file_create_started`}),w({type:`create_file`,path:e,requestId:`create:${crypto.randomUUID()}`})},uploadFile:(e,t)=>{let n=b.current;if(n===null)return Promise.reject(new wP(`the workspace is read-only`,`denied`));let r=o.current;if(!r||r.readyState!==WebSocket.OPEN)return Promise.reject(new wP(`not connected to the server`));let i=n?`${n}/${CP}`:CP,a=`upload:${crypto.randomUUID()}`;return new Promise((n,r)=>{let o=window.setTimeout(()=>{h.current.delete(a)&&r(new wP(`the upload timed out`))},hK),s=e=>t=>{clearTimeout(o),e(t)};h.current.set(a,{resolve:s(n),reject:s(r)}),w({type:`upload_file`,destinationDirectory:i,name:e,contentBase64:t,requestId:a})})},createDirectory:e=>{a({type:`file_create_started`}),w({type:`create_directory`,path:e,requestId:`create:${crypto.randomUUID()}`})},openNative:e=>{let t=`fileop:${crypto.randomUUID()}`;a({type:`file_operation_started`,operation:`open_native`,path:e,requestId:t}),w({type:`open_native`,path:e,requestId:t})},revealNative:e=>{let t=Date.now();if(u.current?.path===e&&t-u.current.at<yK)return;u.current={path:e,at:t};let n=`fileop:${crypto.randomUUID()}`;a({type:`file_operation_started`,operation:`reveal_native`,path:e,requestId:n}),w({type:`reveal_native`,path:e,requestId:n})},renameFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;a({type:`file_operation_started`,operation:`rename_file`,path:e,requestId:n}),w({type:`rename_file`,path:e,name:t,requestId:n})},deleteFile:e=>{let t=`fileop:${crypto.randomUUID()}`;a({type:`file_operation_started`,operation:`delete_file`,path:e,requestId:t}),w({type:`delete_file`,path:e,requestId:t})},moveFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;a({type:`file_operation_started`,operation:`move_file`,path:e,requestId:n}),w({type:`move_file`,path:e,destinationDirectory:t,requestId:n})},copyFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;a({type:`file_operation_started`,operation:`copy_file`,path:e,requestId:n}),w({type:`copy_file`,path:e,destinationDirectory:t,requestId:n})},searchFiles:e=>{let t=`search:${crypto.randomUUID()}`;a({type:`file_search_started`,query:e,requestId:t}),w({type:`search_files`,query:e,requestId:t})},clearFileSearch:()=>a({type:`file_search_cleared`}),fetchGitStatus:()=>A(),fetchGitDiff:e=>{let t=`gitdiff:${crypto.randomUUID()}`;a({type:`git_diff_started`,path:e,requestId:t}),w({type:`git_diff`,path:e,requestId:t})},clearGitDiff:()=>a({type:`git_diff_cleared`}),fetchGitLog:(e,t)=>w({type:`git_log`,repo:e,...t?{limit:t}:{},requestId:`gitlog:${crypto.randomUUID()}`}),fetchGitShow:(e,t)=>w({type:`git_show`,repo:e,sha:t,requestId:`gitshow:${crypto.randomUUID()}`}),clearGitShow:()=>a({type:`git_show_cleared`}),fetchGitFileHistory:(e,t)=>{let n=`gitfilelog:${crypto.randomUUID()}`;a({type:`git_file_history_started`,path:e,requestId:n}),w({type:`git_file_log`,path:e,...t?{limit:t}:{},requestId:n})},closeGitFileHistory:()=>a({type:`git_file_history_closed`}),fetchGitFileDiff:(e,t)=>{let n=`gitfilediff:${crypto.randomUUID()}`;a({type:`git_file_diff_started`,base:e,target:t,requestId:n}),w({type:`git_file_diff`,base:e,target:t,requestId:n})},clearGitFileDiff:()=>a({type:`git_file_diff_cleared`}),setCredential:(e,t)=>w({type:`set_credential`,provider:e,apiKey:t}),declareProvider:e=>w({type:`declare_provider`,...e}),browseServerDirectory:e=>{let t=`serverdir:${crypto.randomUUID()}`;a({type:`server_browse_started`,path:e,requestId:t}),w({type:`browse_server_directory`,path:e,requestId:t})},closeServerBrowser:()=>a({type:`server_browse_closed`}),suggestAgentResourceClonePath:e=>{let t=`resource-clone-path:${crypto.randomUUID()}`;a({type:`resource_clone_path_started`,requestId:t}),w({type:`suggest_agent_resource_clone_path`,repositoryUrl:e,requestId:t})},cloneAgentResourceRepository:(e,t)=>{let n=`resource-preview:${crypto.randomUUID()}`;a({type:`resource_preview_started`,requestId:n}),w({type:`clone_agent_resource_repository`,repositoryUrl:e,destinationPath:t,requestId:n})},enrollAgentResourceRepository:(e,t,n,r)=>{let i=`resource-enroll:${crypto.randomUUID()}`;a({type:`resource_enrollment_started`,requestId:i}),w({type:`enroll_agent_resource_repository`,previewToken:e,skillRoots:t,extensionRoots:n,...r?{enabledSkills:r}:{},requestId:i})},setAgentResourceSkills:(e,t)=>{let n=`resource-skills:${crypto.randomUUID()}`;a({type:`resource_skills_started`,requestId:n,repositoryId:e}),w({type:`set_agent_resource_skills`,repositoryId:e,enabledSkills:t,requestId:n})},removeAgentResourceRepository:e=>{let t=`resource-remove:${crypto.randomUUID()}`;a({type:`resource_removal_started`,requestId:t,repositoryId:e}),w({type:`remove_agent_resource_repository`,repositoryId:e,requestId:t})},refreshAgentResourceRepositories:e=>{let t=`resource-refresh:${crypto.randomUUID()}`;a({type:`resource_refresh_started`,requestId:t,...e?{repositoryId:e}:{}}),w({type:`refresh_agent_resource_repositories`,...e?{repositoryId:e}:{},requestId:t})},updateAgentResourceRepository:(e,t,n,r,i=!1)=>{let o=`resource-update:${crypto.randomUUID()}`;a({type:`resource_update_started`,requestId:o,repositoryId:e}),w({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`}),w({type:`update_config`,...e})},openTerminal:(e,t,n,r)=>w({type:`terminal_open`,terminalId:e,cwd:t,cols:n,rows:r}),sendTerminalInput:(e,t)=>w({type:`terminal_input`,terminalId:e,data:t}),getTerminalCwd:e=>w({type:`terminal_get_cwd`,terminalId:e}),resizeTerminal:(e,t,n)=>w({type:`terminal_resize`,terminalId:e,cols:t,rows:n}),closeTerminal:e=>{w({type:`terminal_close`,terminalId:e}),S.current.delete(e)},subscribeTerminal:(e,t)=>{let n=S.current.get(e);return n||(n={onData:new Set,onCwd:new Set,onExit:new Set,onError:new Set},S.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 xK=120;function SK({label:e}){return(0,k.jsx)(`div`,{className:`flex justify-end px-4`,role:`status`,"aria-live":`polite`,children:(0,k.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,k.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,k.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:e})]})})}var CK=(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,setModel:h,setThinking:g,newSession:_,switchSession:v,deleteSession:b,listSessions:x,renameSession:S,searchSessions:ee,clearSessionSearch:C,listTree:w,navigateTree:T,forkSession:te,editPrompt:ne,compact:re,loadOlderItems:ie,fetchOlderItems:ae,respondToDialog:D,dismissNotification:O,listDirectory:le,refreshFileTree:ue,readFile:de,writeFile:fe,createFile:pe,createDirectory:me,uploadFile:he,openNative:ge,revealNative:_e,renameFile:ve,deleteFile:ye,moveFile:be,copyFile:xe,closeFilePreview:Se,searchFiles:Ce,clearFileSearch:we,fetchGitDiff:Te,clearGitDiff:Ee,fetchGitLog:De,fetchGitShow:Oe,clearGitShow:ke,fetchGitFileHistory:Ae,closeGitFileHistory:je,fetchGitFileDiff:Me,clearGitFileDiff:Ne,setCredential:Pe,declareProvider:Fe,updateConfig:Ie,suggestAgentResourceClonePath:Le,cloneAgentResourceRepository:Re,enrollAgentResourceRepository:ze,setAgentResourceSkills:Be,removeAgentResourceRepository:Ve,refreshAgentResourceRepositories:He,updateAgentResourceRepository:Ue,browseServerDirectory:Ge,closeServerBrowser:Ke,switchWorkspace:qe,openProject:Je,closeProject:Ye,openSideSession:Xe,checkPiPackages:Ze,updatePiPackage:Qe,restartServer:$e,openTerminal:et,sendTerminalInput:tt,getTerminalCwd:nt,resizeTerminal:rt,closeTerminal:it,subscribeTerminal:at,setOutcomeActive:ot,refreshOutcome:st}=bK(e,r,o,i);sL(c.workspaces,c.workspace?AN(c.workspace):null);let ct=c.workspace?AN(c.workspace):null;(0,d.useEffect)(()=>{ft([]),rn([]),yn.current&&(yn.current.scrollTop=0)},[ct]);let[lt,ut]=(0,d.useState)(!1),[dt,ft]=(0,d.useState)([]),[pt,mt]=(0,d.useState)([]),[ht,gt]=(0,d.useState)(null),[_t,vt]=(0,d.useState)(null),[yt,bt]=(0,d.useState)(null),[xt,St]=(0,d.useState)(!1),[Ct,wt]=(0,d.useState)(null),[Tt,Et]=(0,d.useState)(null),Dt=Ct===`project`,Ot=e=>wt(e?`project`:null),kt=c.embedWorkspaceControls===`projects`?`projects`:c.embedWorkspaceControls===`root`?`root`:`none`,At=(0,d.useRef)({}),jt=(0,d.useRef)([]),Mt=(0,d.useRef)(null),Nt=(0,d.useRef)(null),[Pt,Ft]=(0,d.useState)(!1),[It,Lt]=(0,d.useState)(hP),Rt=(0,d.useCallback)((e,t)=>{gP(e,t),Lt(n=>({...n,[e]:t}))},[]),[zt,Bt]=(0,d.useState)(!1),[Vt,Ht]=(0,d.useState)(!0),[Ut,Wt]=(0,d.useState)(!1),Gt=c.terminal?.enabled??!1;(0,d.useEffect)(()=>{let e=e=>{Gt&&(e.ctrlKey||e.metaKey)&&e.key==="`"&&(e.preventDefault(),Wt(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Gt]);let[Kt,qt]=(0,d.useState)(!1),[Jt,Yt]=(0,d.useState)(null),Xt=(0,d.useCallback)(()=>Yt(null),[]);function Zt(){let e=!zt;Bt(e),e&&(Ht(!1),qt(!1))}function Qt(){let e=!Vt;Ht(e),e&&(Bt(!1),qt(!1))}function $t(){let e=!Kt;qt(e),e&&(Bt(!1),Ht(!1))}(0,d.useEffect)(()=>(ot(Kt),()=>ot(!1)),[Kt,ot,c.sessionId,ct]),(0,d.useEffect)(()=>{qt(!1),Yt(null)},[ct]);let[en,tn]=(0,d.useState)([]),[nn,rn]=(0,d.useState)([]),an=(0,d.useRef)(0),on=(0,d.useRef)(0),[sn,cn]=(0,d.useState)(0);async function ln(e){let t=[...e],n=t.filter(OP).map(e=>({id:`${an.current++}`,name:e.name}));n.length>0&&rn(e=>[...e,...n]),on.current===0&&tn([]),on.current++;try{let{attachments:e,errors:n}=await IP(t,he);e.length>0&&ft(t=>[...t,...e]),n.length>0&&tn(e=>[...e,...n])}finally{if(on.current--,n.length>0){let e=new Set(n.map(e=>e.id));rn(t=>t.filter(t=>!e.has(t.id)))}}}(0,d.useEffect)(()=>{jt.current=dt},[dt]),(0,d.useEffect)(()=>{let t=c.openFile;if(!t)return;let n=t.path,r=t.status===`loaded`,i=t.status===`error`&&t.message===`Binary file — preview not supported`&&se(n);if(Mt.current!==n&&(Mt.current=n,Nt.current=null,ft(e=>e.filter(e=>e.source!==`preview`)),gt(null),vt(null),bt(null)),Nt.current===n)return;(oe(n)||E(n))&&ft(e=>e.filter(e=>e.source!==`preview`));let a=!1;async function o(){let t=oe(n)?_t===n?await HP(n,ce(e,n,l,c.previewRevision)):null:E(n)?yt?.path===n&&yt.revision===c.previewRevision?RP(n):null:i||r?LP(n):null;if(!(a||t===null||Mt.current!==n||Nt.current===n)){if(typeof t==`string`){gt(t);return}gt(null),ft(e=>GP(e,t))}}return o(),()=>{a=!0}},[c.openFile,c.previewRevision,e,l,_t,yt]);function un(){Mt.current=null,Nt.current=null,Se()}let dn=(0,d.useMemo)(()=>[...dt.filter(e=>e.kind===`path`).map(e=>e.data),...pt],[dt,pt]);function fn(e){let t=jt.current.findIndex(t=>t.kind===`path`&&t.data===e);t>=0?pn(t):pt.includes(e)||ft(t=>WP(t,e))}function pn(e){let t=jt.current[e];t?.source===`preview`&&(Nt.current=t.previewPath??Mt.current,gt(null)),ft(t=>KP(t,e))}function mn(e,t){f(e,t),ft([]),tn([]),gt(null),xt||un()}function hn(e){e.preventDefault(),cn(0),e.dataTransfer.files.length>0&&ln(Array.from(e.dataTransfer.files))}let{theme: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<xK)},[Dn]),kn=(0,d.useRef)(null),An=(0,d.useCallback)(()=>{let e=yn.current;e&&(e.scrollHeight-e.scrollTop-e.clientHeight<xK||(kn.current=e.scrollTop))},[]),jn=(0,d.useCallback)(()=>{let e=yn.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<xK,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(()=>{if(wn.current){An(),Cn.current?.scrollIntoView({behavior:`auto`});return}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)(()=>{if(wn.current){An(),Cn.current?.scrollIntoView({behavior:`smooth`});return}On()},[c.items,On,An]);let Pn=(0,d.useMemo)(()=>FN(c.items),[c.items]),Fn=(0,d.useMemo)(()=>zt?GN(c.items):null,[zt,c.items]),In=(0,d.useMemo)(()=>GM({readFile:(e,t)=>{Ft(!1),de(e,t)},fetchGitFileHistory:e=>Ae(e),fetchGitDiff:e=>{Ft(!0),de(e)},searchFiles:e=>Ce(e)}),[de,Ae,Ce]),Ln=(0,d.useCallback)(()=>Rt(`tools`,!0),[Rt]),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<xK;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 A(async()=>{let{exportConversation:e}=await import(`./conversationExport-CfUybHMU.js`);return{exportConversation:e}},__vite__mapDeps([22,21]));await t({items:c.items,olderItems:c.olderHistory?.remaining??0,...c.olderHistory?{fetchOlderItems:ae}:{},connection:{serverUrl:e,token:l},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,ae,e,l]),{jumpToItem:Gn,highlightIndex:Kn}=uP({items:c.items,scrollerRef:yn,hideTools:!It.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}),ie()},[ie]);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,k.jsx)(p.Provider,{value:gn,children:(0,k.jsx)(ML,{title:c.branding.title,onSubmit:u})}):c.credentials&&!c.credentials.usableModel?(0,k.jsx)(p.Provider,{value:gn,children:(0,k.jsx)(hL,{title:c.branding.title,credentials:c.credentials,onSetCredential:Pe,onDeclareProvider:Fe,errors:c.errors})}):(0,k.jsx)(p.Provider,{value:gn,children:(0,k.jsxs)(Ql.Provider,{value:c.replyConformance,children:[(0,k.jsxs)(`div`,{className:`relative flex h-full`,onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&cn(e=>e+1)},onDragLeave:()=>cn(e=>Math.max(0,e-1)),onDragOver:e=>e.preventDefault(),onDrop:hn,children:[sn>0&&(0,k.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,k.jsx)(`p`,{className:`text-lg font-medium text-zinc-700 dark:text-zinc-200`,children:`Drop files to attach (images, documents & text)`})}),lt&&(0,k.jsx)(jL,{tree:c.fileTree,openFile:c.openFile,writableRoot:c.writableRoot,gitFiles:c.gitStatus?.files,attachedPaths:dn,onExpand:le,onSelectDirectory:Et,onRefresh:ue,onSelectFile:e=>{Ft(!1),Et(e),de(e)},onSelectDiff:e=>{Ft(!0),Et(e),de(e)},onToggleAttachPath:fn,onCreateFile:e=>{Ft(!1),pe(e)},onCreateDirectory:me,onOpenNative:ge,onRevealNative:_e,onRenameFile:ve,onDeleteFile:ye,onMoveFile:be,onCopyFile:xe,fileOperation:c.fileOperation,createError:c.createError,created:c.created}),(0,k.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[Dt&&(0,k.jsx)(xI,{label:`Choose a project directory`,browse:c.serverBrowse,onBrowse:Ge,onSelect:e=>{Ot(!1),Ke(),Je(e)},onCancel:()=>{Ot(!1),Ke()}}),!o&&c.outpostUpdate&&(0,k.jsx)(kN,{notice:c.outpostUpdate}),(0,k.jsx)(oL,{workspace:c.workspace,workspaces:c.workspaces,workspaceLocked:c.workspaceLocked,workspaceControl:o?kt:`projects`,rootControl:{sandbox:c.sandbox,browse:c.serverBrowse,applyState:c.settingsApply,blocked:Ct!==null&&Ct!==`root`,onBrowse:Ge,onCloseBrowser:()=>{wt(null),Ke()},onOpened:()=>wt(`root`),onSelect:e=>Ie({sandbox:{root:e,allowWrite:c.sandbox?.allowWrite??!1,allowBash:c.sandbox?.allowBash??!1,...c.sandbox?.writableRoot?{writableRoot:c.sandbox.writableRoot}:{}}})},onSwitchWorkspace:qe,onOpenProject:()=>{Ot(!0),Ge(``)},onCloseProject:Ye,onOpenSideSession:Xe,piPackages:c.piPackages,piPackageUpdate:c.piPackageUpdate,canRestartServer:!o,serverRestarting:c.serverRestarting,onCheckPiPackages:Ze,onUpdatePiPackage:Qe,onRestartServer:$e,restartNeeded:c.restartNeeded,title:c.branding.title,sessions:c.sessions,sessionSearch:c.sessionSearch,sessionId:c.sessionId,tree:c.tree,isStreaming:c.isStreaming,connected:c.connected,theme:gn,showThemeToggle:c.branding.allowThemeToggle!==!1,statuses:c.statuses,sidebarOpen:lt,outcomeOpen:Kt,filters:It,onToggleSidebar:()=>ut(!lt),onToggleOutcome:$t,onFilterChange:Rt,...c.items.length>0?{onExportConversation:()=>void Wn()}:{},exportProgress:zn,onToggleTheme:_n,onNewSession:_,onSwitchSession:v,onDeleteSession:b,onListSessions:x,onRenameSession:S,onSearchSessions:ee,onClearSessionSearch:C,onListTree:w,onNavigateTree:T,onForkSession:te,gitAvailable:c.gitAvailable,gitStatus:c.gitStatus,gitSelectedPath:Tt,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:Ge,onCloseServerBrowser:Ke,settingsPickerBlocked:Ct!==null&&Ct!==`settings`,onSettingsPickerOpened:()=>wt(`settings`),onUpdateConfig:Ie,onSuggestAgentResourceClonePath:Le,onCloneAgentResourceRepository:Re,onEnrollAgentResourceRepository:ze,onSetAgentResourceSkills:Be,onRemoveAgentResourceRepository:Ve,onRefreshAgentResourceRepositories:He,onUpdateAgentResourceRepository:Ue,onFetchGitLog:De,onShowCommit:Oe,terminalOpen:Ut,onToggleTerminal:Gt?()=>Wt(e=>!e):void 0}),(0,k.jsxs)(`div`,{className:`relative z-0 flex min-h-0 flex-1 flex-col`,children:[c.workPlan&&(0,k.jsx)(IL,{plan:c.workPlan,open:Vt,onToggle:Qt,onOpenWorkspace:e=>{Ft(!1),de(e)},requestedTaskId:Jt,onTaskRequestHandled:Xt}),Kt&&(0,k.jsx)(QG,{state:c.outcome,onClose:()=>qt(!1),onRefresh:st,onTarget:e=>{e.kind===`work-plan-task`?(Yt(e.taskId),qt(!1),Bt(!1),Ht(!0)):e.kind===`workspace-file`?(Ft(!1),de(e.path)):e.kind===`workspace-diff`&&(Ft(!0),de(e.path))}}),c.openFile&&(0,k.jsx)(LF,{file:c.openFile,writableRoot:c.writableRoot,docxTemplate:c.docxTemplate,isStreaming:c.isStreaming,onDirtyChange:St,gitState:c.gitStatus?.files[c.openFile.path],initialShowGitDiff:Pt,gitDiff:c.gitDiff,onFetchGitDiff:Te,onClearGitDiff:Ee,inRepository:vP(c.gitStatus?.repos??[],c.openFile.path)!==null,onOpenGitHistory:Ae,onClose:un,onReload:de,onSave:fe,serverUrl:e,token:l,onImageLoad:vt,onPdfLoad:e=>bt({path:e,revision:c.previewRevision}),rawRevision:c.previewRevision},c.openFile.path),c.gitFileHistory&&(0,k.jsx)(lI,{history:c.gitFileHistory,diff:c.gitFileDiff,dirty:c.gitStatus?.files[c.gitFileHistory.path]!==void 0,onFetchDiff:Me,onClearDiff:Ne,onClose:je}),c.gitShow&&(0,k.jsx)(zF,{show:c.gitShow,onClose:ke}),Fn&&(0,k.jsx)(cP,{analysis:Fn,onJump:Gn,onClose:()=>Bt(!1)}),(0,k.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`} ${zt?`md:pr-[26rem]`:c.workPlan&&Vt?`md:pr-[23rem]`:``}`,children:(0,k.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-3 px-4 py-6`,children:[c.items.length===0&&(0,k.jsxs)(`div`,{className:`mt-24 text-center text-zinc-500 dark:text-zinc-600`,children:[(0,k.jsx)(`div`,{className:`mb-2 text-4xl`,children:c.branding.title??`π`}),(0,k.jsx)(`p`,{className:`text-sm`,children:c.branding.welcome??`Send a message to start the agent.`})]}),c.olderHistory&&(0,k.jsx)(NN,{older:c.olderHistory,onLoad:Yn}),c.items.map((t,n)=>{let r=`${c.sessionId}:${n}`,i=(e,t=r)=>(0,k.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,k.jsx)(We,{item:t,canEdit:!t.readOnly&&!c.isStreaming&&c.connected,onEdit:ne})):t.kind===`compaction`?i((0,k.jsx)(MN,{item:t})):t.kind===`tool`?It.tools?i((0,k.jsx)(TN,{item:t,dispatch:In}),t.toolCallId?`${c.sessionId}:${t.toolCallId}`:r):null:t.kind===`custom`?i((0,k.jsx)(EN,{item:t})):(It.reasoning?t.blocks:t.blocks.filter(e=>e.type!==`thinking`)).length===0&&!t.errorMessage?(0,k.jsx)(`div`,{"data-item-index":n,className:`sr-only`,"aria-hidden":!0},r):i((0,k.jsx)(HM,{item:t,hideReasoning:!It.reasoning,serverUrl:e,token:l,onOpenFile:e=>{Ft(!1),de(e)}}))}),c.pendingPrompt&&(0,k.jsxs)(`div`,{className:`flex flex-col gap-3 opacity-60`,"data-pending-prompt":!0,children:[(0,k.jsx)(We,{item:{kind:`user`,...c.pendingPrompt},canEdit:!1,onEdit:()=>{}}),(0,k.jsx)(SK,{label:`sending…`})]}),c.isStreaming&&!c.pendingPrompt&&(0,k.jsx)(SK,{label:`working…`}),(c.queue.steering.length>0||c.queue.followUp.length>0)&&(0,k.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,k.jsxs)(`div`,{children:[`⏩ steering: `,e]},`s${t}`)),c.queue.followUp.map((e,t)=>(0,k.jsxs)(`div`,{children:[`⏭ follow-up: `,e]},`f${t}`))]}),en.map((e,t)=>(0,k.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}`)),ht&&(0,k.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:ht}),Vn&&(0,k.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,k.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,k.jsx)(`div`,{ref:Cn})]})}),(0,k.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-4 z-0 flex justify-center ${zt||Kt?`md:pr-[26rem]`:c.workPlan&&Vt?`md:pr-[23rem]`:``}`,children:!Tn&&(0,k.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,k.jsx)(`span`,{"aria-hidden":!0,children:`↓`}),`Latest`]})})]}),Gt&&(0,k.jsx)(JG,{open:Ut,onClose:()=>Wt(!1),cwd:c.workspace?.root,onSetWorkspaceRoot:e=>{Je&&!o?Je(e):c.sandbox?Ie({sandbox:{root:e,allowWrite:c.sandbox.allowWrite,allowBash:c.sandbox.allowBash,...c.sandbox.writableRoot?{writableRoot:c.sandbox.writableRoot}:{}}}):Ie({sandbox:{root:e,allowWrite:!0,allowBash:!0}})},openTerminal:et,sendTerminalInput:tt,getTerminalCwd:nt,resizeTerminal:rt,closeTerminal:it,subscribeTerminal:at}),(0,k.jsx)(`footer`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,k.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,k.jsx)(xF,{widgets:c.widgets,placement:`aboveEditor`}),(0,k.jsx)(eF,{initialDraft:At.current[ct??``]??``,onDraftChange:e=>{At.current[ct??``]=e},isStreaming:c.isStreaming,connected:c.connected,commands:c.commands,fileSearch:c.fileSearch,prefill:c.editorPrefill,attachments:dt,pendingUploads:nn,onAttach:e=>void ln(e),onMentionPaths:mt,onRemoveAttachment:pn,onSend:mn,onAbort:m,onSearchFiles:Ce,onClearFileSearch:we},ct??``),(0,k.jsx)(xF,{widgets:c.widgets,placement:`belowEditor`}),(0,k.jsx)(fL,{model:c.model,models:c.models,thinkingLevel:c.thinkingLevel,thinkingLevels:c.thinkingLevels,modelSupportsReasoning:c.modelSupportsReasoning,isStreaming:c.isStreaming,contextUsage:c.contextUsage,sessionUsage:Pn,analysisOpen:zt,onToggleAnalysis:Zt,isCompacting:c.isCompacting,onSetModel:h,onSetThinking:g,onCompact:re})]})})]})]}),c.dialogQueue[0]&&(0,k.jsx)(uF,{request:c.dialogQueue[0],onRespond:D}),(0,k.jsx)(mF,{notifications:c.notifications,onDismiss:O})]})})});(0,f.createRoot)(document.getElementById(`root`)).render((0,k.jsx)(d.StrictMode,{children:(0,k.jsx)(CK,{})}));export{i as A,Ne as C,ce as D,ie as E,ae as O,xl as S,O as T,Uu as _,FM as a,lu as b,Ck as c,vw as d,iw as f,Ku as g,Rm as h,RM as i,te as k,ik as l,eg as m,EF as n,CM as o,Og as p,OF as r,wk as s,iK as t,Mw as u,Wu as v,A as w,ru as x,Bu as y};