pi-outpost 0.16.2 → 0.16.4

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 (93) hide show
  1. package/dist/pi-outpost.mjs +568 -368
  2. package/dist/pi-outpost.sea.mjs +2011 -1811
  3. package/dist/sea-prep.blob +0 -0
  4. package/dist/web/assets/{PdfViewer-DZETVqqX.js → PdfViewer-r8Lc1uQ2.js} +2 -2
  5. package/dist/web/assets/{abnfDiagram-VCTEODGH-DqQgwZ6R.js → abnfDiagram-VCTEODGH-BAApwSGI.js} +1 -1
  6. package/dist/web/assets/architecture-7GRP2DOG-DkG8lmjx.js +1 -0
  7. package/dist/web/assets/{architectureDiagram-5GKGNRK7-CgIcKdG7.js → architectureDiagram-5GKGNRK7-BL6O48hV.js} +1 -1
  8. package/dist/web/assets/{blockDiagram-OSKFZWR5-DjSvAryW.js → blockDiagram-OSKFZWR5-Bxzxa-oj.js} +1 -1
  9. package/dist/web/assets/{c4Diagram-7LVT6UL2-DvmNpV-m.js → c4Diagram-7LVT6UL2-a73ouBjs.js} +1 -1
  10. package/dist/web/assets/channel-B6KiOMuR.js +1 -0
  11. package/dist/web/assets/{chunk-3NF5O7KM-Cqs2Gmid.js → chunk-3NF5O7KM-DpB4AiXr.js} +1 -1
  12. package/dist/web/assets/{chunk-4HAMMTFA-DR9GC2ui.js → chunk-4HAMMTFA-BcIJbxBC.js} +1 -1
  13. package/dist/web/assets/{chunk-75Z2AOVW-DAW2Q_LD.js → chunk-75Z2AOVW-BCvq_eB1.js} +1 -1
  14. package/dist/web/assets/{chunk-DU6HZSFF-C2Df7Z4A.js → chunk-DU6HZSFF-CXOC2Mrj.js} +1 -1
  15. package/dist/web/assets/{chunk-F27PBJKO-BEvqws30.js → chunk-F27PBJKO-Cb-Y8zpb.js} +1 -1
  16. package/dist/web/assets/{chunk-GMAD6QVW-BHwcIZyM.js → chunk-GMAD6QVW-HnvoZP4x.js} +1 -1
  17. package/dist/web/assets/{chunk-GVQU2GXP-DoEZ7rBQ.js → chunk-GVQU2GXP-Cf4NoF8O.js} +1 -1
  18. package/dist/web/assets/{chunk-HLEWEB6X-MYkgNbPr.js → chunk-HLEWEB6X-41vjrMgF.js} +1 -1
  19. package/dist/web/assets/{chunk-L3NEJ4N5-BdgcxVIt.js → chunk-L3NEJ4N5-9aETjpyU.js} +1 -1
  20. package/dist/web/assets/{chunk-OSK3NFVY-CSc6-4Dx.js → chunk-OSK3NFVY-BhYwEFh2.js} +1 -1
  21. package/dist/web/assets/{chunk-P2QGCYS3-B_xE4daM.js → chunk-P2QGCYS3-C7cc0B5q.js} +1 -1
  22. package/dist/web/assets/{chunk-POPQ4Y6H-CowkRqD9.js → chunk-POPQ4Y6H-2GbDI_zs.js} +1 -1
  23. package/dist/web/assets/{chunk-PWAF6VOD-C42sJJXx.js → chunk-PWAF6VOD-BJ_YOj16.js} +1 -1
  24. package/dist/web/assets/{chunk-SVP7TREG-DMjqnbmR.js → chunk-SVP7TREG-BM7v74ta.js} +1 -1
  25. package/dist/web/assets/{chunk-ZLD2IHE6-hl56m55y.js → chunk-ZLD2IHE6-BDi-B33v.js} +1 -1
  26. package/dist/web/assets/classDiagram-CYGNFDIV-JtTZfcpF.js +1 -0
  27. package/dist/web/assets/classDiagram-v2-TLXNO2FR-JtTZfcpF.js +1 -0
  28. package/dist/web/assets/{cynefin-OW5HDTMX-D-SgR_Mf.js → cynefin-OW5HDTMX-BO3qW93K.js} +1 -1
  29. package/dist/web/assets/{cynefinDiagram-5FMLGOSQ-oHIoFAzQ.js → cynefinDiagram-5FMLGOSQ-BhFLBzCq.js} +1 -1
  30. package/dist/web/assets/{dagre-OS7QT2EB-R91tq3ur.js → dagre-OS7QT2EB-OESBLvy2.js} +1 -1
  31. package/dist/web/assets/{diagram-S7CK7UJ4-xn_61EVq.js → diagram-S7CK7UJ4-Df0nqbLB.js} +1 -1
  32. package/dist/web/assets/{diagram-UQ7AKVKN-CMAaeUbE.js → diagram-UQ7AKVKN-DW6F9z58.js} +1 -1
  33. package/dist/web/assets/{diagram-VSXAHHWV-DuWIwM_v.js → diagram-VSXAHHWV-CDaCF3yw.js} +1 -1
  34. package/dist/web/assets/{diagram-VX7I27RA-DcjAXEv9.js → diagram-VX7I27RA-HGDfbaYr.js} +1 -1
  35. package/dist/web/assets/{diagram-Z3DM3KII-MVvRpK9S.js → diagram-Z3DM3KII-bPOosa44.js} +1 -1
  36. package/dist/web/assets/{ebnfDiagram-PWID7BFC-DaV1dBr3.js → ebnfDiagram-PWID7BFC-BiPKXaRr.js} +1 -1
  37. package/dist/web/assets/{erDiagram-2YWLMYGG-CCeSx0tH.js → erDiagram-2YWLMYGG-CSSIrP47.js} +1 -1
  38. package/dist/web/assets/eventmodeling-NTZA5JFV-7G06wFCF.js +1 -0
  39. package/dist/web/assets/flowDiagram-T62WH6J4-_VRg0MTg.js +1 -0
  40. package/dist/web/assets/{ganttDiagram-EL5Y4UJY-B_v-nxD8.js → ganttDiagram-EL5Y4UJY-u1PGZvA4.js} +1 -1
  41. package/dist/web/assets/{gitGraph-4MIJSDKK-BiET3ax8.js → gitGraph-4MIJSDKK-BbGX188z.js} +1 -1
  42. package/dist/web/assets/{gitGraphDiagram-WWUBYQGX-CjjQZkw9.js → gitGraphDiagram-WWUBYQGX-tBOC1prU.js} +1 -1
  43. package/dist/web/assets/index-Chy8xSKl.css +2 -0
  44. package/dist/web/assets/{index-JrziMGG_.js → index-DMTkDXSj.js} +4 -4
  45. package/dist/web/assets/{info-A6RAGUB7-BV0CPlKG.js → info-A6RAGUB7-mjAg1yjH.js} +1 -1
  46. package/dist/web/assets/{infoDiagram-FKFFQAWI-DGxpwSIV.js → infoDiagram-FKFFQAWI-A-6Db4R1.js} +1 -1
  47. package/dist/web/assets/{ishikawaDiagram-5VMMS53U-PO1Jplmi.js → ishikawaDiagram-5VMMS53U-CFaW8CNU.js} +1 -1
  48. package/dist/web/assets/{journeyDiagram-EYS64GPL-CarBQBR0.js → journeyDiagram-EYS64GPL-CWSlMDHF.js} +1 -1
  49. package/dist/web/assets/{kanban-definition-UXKFOSKX-Cls5Y5p1.js → kanban-definition-UXKFOSKX-JKV2JzyF.js} +1 -1
  50. package/dist/web/assets/{line-D4GEUfvu.js → line-BYD6PQmT.js} +1 -1
  51. package/dist/web/assets/{mermaid-parser.core-BYLrlv9b.js → mermaid-parser.core-CuRTfO0d.js} +3 -3
  52. package/dist/web/assets/{mermaid.core-BFKSKkBv.js → mermaid.core-CptB1LAj.js} +4 -4
  53. package/dist/web/assets/{mindmap-definition-THT77NOG-DhSbf46Z.js → mindmap-definition-THT77NOG-BLGDChWB.js} +1 -1
  54. package/dist/web/assets/{packet-AYTQ26CC-DMIDG8qo.js → packet-AYTQ26CC-CLil_d8u.js} +1 -1
  55. package/dist/web/assets/{pdf-CChUuIoa.js → pdf-DEXSVb8p.js} +1 -1
  56. package/dist/web/assets/{pegDiagram-XKGWAZYB-BZnuKgnj.js → pegDiagram-XKGWAZYB-D044kEBz.js} +1 -1
  57. package/dist/web/assets/{pie-WAS4IAKB-DSmDorxL.js → pie-WAS4IAKB-CW0KLAUR.js} +1 -1
  58. package/dist/web/assets/{pieDiagram-E7YTZNPT-C2zh_4wY.js → pieDiagram-E7YTZNPT-BC4CLRsy.js} +1 -1
  59. package/dist/web/assets/{quadrantDiagram-AXDQQJYC-B_hgG0wU.js → quadrantDiagram-AXDQQJYC-CWM6xrUM.js} +1 -1
  60. package/dist/web/assets/{radar-RG4KPBEZ-oWqHl2RQ.js → radar-RG4KPBEZ-Ex2wOMBb.js} +1 -1
  61. package/dist/web/assets/{railroad-74A4TZTK-BTkZ6J0A.js → railroad-74A4TZTK-CM6-fLlN.js} +1 -1
  62. package/dist/web/assets/railroad-abnf-HS5TGJTU-53Nb8B5F.js +1 -0
  63. package/dist/web/assets/railroad-ebnf-LZEXJU2U-DawN7F7y.js +1 -0
  64. package/dist/web/assets/railroad-peg-WCYAUIDC-BYv7pt9w.js +1 -0
  65. package/dist/web/assets/{railroadDiagram-O6MQD6OU-ajkKNP_r.js → railroadDiagram-O6MQD6OU-CKmsTQsl.js} +1 -1
  66. package/dist/web/assets/{requirementDiagram-IS5BZ75X-BV3IDe8V.js → requirementDiagram-IS5BZ75X-BqqxU_oa.js} +1 -1
  67. package/dist/web/assets/{sankeyDiagram-P5KCCOFB-DofhV7Hm.js → sankeyDiagram-P5KCCOFB-CeMnool-.js} +1 -1
  68. package/dist/web/assets/{sequenceDiagram-WJ2MYXX4-B7vlL3Vm.js → sequenceDiagram-WJ2MYXX4-CfHuZqaq.js} +1 -1
  69. package/dist/web/assets/{stateDiagram-XQSTLZYL-B_4P_HRj.js → stateDiagram-XQSTLZYL-DYBptnll.js} +1 -1
  70. package/dist/web/assets/stateDiagram-v2-IH3M54BS-DjJTyf_R.js +1 -0
  71. package/dist/web/assets/{swimlanes-V6O3JKXN-CBo3i3Dk.js → swimlanes-V6O3JKXN-gDr_WVJX.js} +1 -1
  72. package/dist/web/assets/swimlanesDiagram-JKAHXJPX-hUEZE4Mm.js +8 -0
  73. package/dist/web/assets/{timeline-definition-24CTP7MA-Dhn2C-xD.js → timeline-definition-24CTP7MA-BN_IcKoA.js} +1 -1
  74. package/dist/web/assets/{treeView-Q6P3EWNA-BbLfWtW5.js → treeView-Q6P3EWNA-mZh2mABg.js} +1 -1
  75. package/dist/web/assets/{treemap-WGGIJYW6-BdAIXW47.js → treemap-WGGIJYW6-BQRUq1Wy.js} +1 -1
  76. package/dist/web/assets/{vennDiagram-4TSXK5OY-TulKHSnL.js → vennDiagram-4TSXK5OY-PuDkBJ9j.js} +1 -1
  77. package/dist/web/assets/{wardley-WFR3VGLG-EUsHfGbw.js → wardley-WFR3VGLG-cx5_a3mq.js} +1 -1
  78. package/dist/web/assets/{wardleyDiagram-VM6X3IG4-BNG7tFXA.js → wardleyDiagram-VM6X3IG4-yPKn6ltN.js} +1 -1
  79. package/dist/web/assets/{xychartDiagram-S5SC5T6Z-GMZfPBu8.js → xychartDiagram-S5SC5T6Z-CfOZB2xT.js} +1 -1
  80. package/dist/web/index.html +2 -2
  81. package/package.json +1 -1
  82. package/dist/web/assets/architecture-7GRP2DOG-BiIXUI05.js +0 -1
  83. package/dist/web/assets/channel-HbIvWZqO.js +0 -1
  84. package/dist/web/assets/classDiagram-CYGNFDIV-DuPh0Fxh.js +0 -1
  85. package/dist/web/assets/classDiagram-v2-TLXNO2FR-DuPh0Fxh.js +0 -1
  86. package/dist/web/assets/eventmodeling-NTZA5JFV-CMj3JxRr.js +0 -1
  87. package/dist/web/assets/flowDiagram-T62WH6J4-Bz_gnjwD.js +0 -1
  88. package/dist/web/assets/index-DZAiVvXH.css +0 -2
  89. package/dist/web/assets/railroad-abnf-HS5TGJTU-BXtqDQIg.js +0 -1
  90. package/dist/web/assets/railroad-ebnf-LZEXJU2U-CSWxGGNc.js +0 -1
  91. package/dist/web/assets/railroad-peg-WCYAUIDC-CyWffSFr.js +0 -1
  92. package/dist/web/assets/stateDiagram-v2-IH3M54BS-DgXcKErq.js +0 -1
  93. package/dist/web/assets/swimlanesDiagram-JKAHXJPX-GK0F0eOx.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-VbNX68N4.js","assets/rolldown-runtime-hePW80VL.js","assets/mermaid.core-BFKSKkBv.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-B6xuSHsQ.js","assets/chunk-DU6HZSFF-C2Df7Z4A.js","assets/chunk-75Z2AOVW-DAW2Q_LD.js","assets/dist-v5Q1xZ2K.js","assets/chunk-PWAF6VOD-C42sJJXx.js","assets/chunk-GMAD6QVW-BHwcIZyM.js","assets/chunk-P2QGCYS3-B_xE4daM.js","assets/chunk-4HAMMTFA-DR9GC2ui.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-GVQU2GXP-DoEZ7rBQ.js","assets/chunk-OSK3NFVY-CSc6-4Dx.js","assets/line-D4GEUfvu.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/graphlib-DS17s2tU.js","assets/chunk-L3NEJ4N5-BdgcxVIt.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-VbNX68N4.js","assets/rolldown-runtime-hePW80VL.js","assets/mermaid.core-CptB1LAj.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-B6xuSHsQ.js","assets/chunk-DU6HZSFF-CXOC2Mrj.js","assets/chunk-75Z2AOVW-BCvq_eB1.js","assets/dist-v5Q1xZ2K.js","assets/chunk-PWAF6VOD-BJ_YOj16.js","assets/chunk-GMAD6QVW-HnvoZP4x.js","assets/chunk-P2QGCYS3-C7cc0B5q.js","assets/chunk-4HAMMTFA-BcIJbxBC.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-GVQU2GXP-Cf4NoF8O.js","assets/chunk-OSK3NFVY-BhYwEFh2.js","assets/line-BYD6PQmT.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/graphlib-DS17s2tU.js","assets/chunk-L3NEJ4N5-9aETjpyU.js"])))=>i.map(i=>d[i]);
2
2
  import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.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 C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function ee(e,t){return E(e.type,t,e.props)}function D(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function O(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var te=/\/+/g;function ne(e,t){return typeof e==`object`&&e&&e.key!=null?O(``+e.key):t.toString(36)}function re(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(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 ie(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,ie(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ne(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(te,`$&/`)+`/`),ie(o,r,i,``,function(e){return e})):o!=null&&(D(o)&&(o=ee(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(te,`$&/`)+`/`)+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+ne(a,u),c+=ie(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+ne(a,u++),c+=ie(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ie(re(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 ae(e,t,n){if(e==null)return e;var r=[],i=0;return ie(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function oe(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 k=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)},A={map:ae,forEach:function(e,t,n){ae(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ae(e,function(){t++}),t},toArray:function(e){return ae(e,function(e){return e})||[]},only:function(e){if(!D(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=A,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=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.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)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=D,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:oe}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,k)}catch(e){k(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.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,D());else{var t=n(l);t!==null&&ne(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function ee(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){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&&ne(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?D():S=!1}}}var D;if(typeof y==`function`)D=function(){y(ee)};else if(typeof MessageChannel<`u`){var O=new MessageChannel,te=O.port2;O.port1.onmessage=ee,D=function(){te.postMessage(null)}}else D=function(){_(ee,0)};function ne(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ne(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,D()))),r},e.unstable_shouldYield=E,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`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),ee=Symbol.for(`react.memo`),D=Symbol.for(`react.lazy`),O=Symbol.for(`react.activity`),te=Symbol.for(`react.memo_cache_sentinel`),ne=Symbol.iterator;function re(e){return typeof e!=`object`||!e?null:(e=ne&&e[ne]||e[`@@iterator`],typeof e==`function`?e:null)}var ie=Symbol.for(`react.client.reference`);function ae(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ie?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 T:return`Suspense`;case E:return`SuspenseList`;case O:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ee:return t=e.displayName||null,t===null?ae(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return ae(e(t))}catch{}}return null}var oe=Array.isArray,k=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j={pending:!1,data:null,method:null,action:null},se=[],ce=-1;function le(e){return{current:e}}function ue(e){0>ce||(e.current=se[ce],se[ce]=null,ce--)}function M(e,t){ce++,se[ce]=e.current,e.current=t}var de=le(null),fe=le(null),pe=le(null),me=le(null);function he(e,t){switch(M(pe,t),M(fe,e),M(de,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Hd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Hd(t),e=Ud(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ue(de),M(de,e)}function ge(){ue(de),ue(fe),ue(pe)}function _e(e){e.memoizedState!==null&&M(me,e);var t=de.current,n=Ud(t,e.type);t!==n&&(M(fe,e),M(de,n))}function ve(e){fe.current===e&&(ue(de),ue(fe)),me.current===e&&(ue(me),$f._currentValue=j)}var ye,be;function xe(e){if(ye===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ye=t&&t[1]||``,be=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+ye+e+be}var Se=!1;function Ce(e,t){if(!e||Se)return``;Se=!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,7 +13,7 @@ Error generating stack: `+e.message+`
13
13
 
14
14
  `)?-1:i}function ee(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=E(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=E(e,n+2,`$`,`\\(`);if(i!==-1){t.push(`$`,e.slice(n+2,i),`$`),n=i+1;continue}}if(e.startsWith(`$$`,n)){let r=E(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=E(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 D(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 O(e){let t=D(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 te(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`//`)}function ne(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 re(e){return/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(e)}function ie(e){return/\.pdf$/i.test(e)}function ae(e){return/\.(docx|xlsx|pptx)$/i.test(e)}function oe(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 k=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})),A=n(((e,t)=>{t.exports=k()})),j=A();function se({text:e,className:t}){let[n,r]=(0,d.useState)(!1);async function i(){try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)}catch{}}return(0,j.jsx)(`button`,{type:`button`,onClick:i,title:n?`Copied!`:`Copy`,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?`✓ copied`:`⧉ copy`})}var ce=`modulepreload`,le=function(e){return`/`+e},ue={},M=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=le(t,n),t=s(t),t in ue)return;ue[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`:ce,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)})},de=null,fe={javascript:()=>M(()=>import(`./javascript-8AmHuH5O.js`),[]),typescript:()=>M(()=>import(`./typescript-CxkPLmSc.js`),[]),json:()=>M(()=>import(`./json-PmyKWHmm.js`),[]),xml:()=>M(()=>import(`./xml-COl5yFSC.js`),[]),css:()=>M(()=>import(`./css-D8M8GYaw.js`),[]),scss:()=>M(()=>import(`./scss-gOyOKiXd.js`),[]),bash:()=>M(()=>import(`./bash-LmRjUKlR.js`),[]),python:()=>M(()=>import(`./python-gHmu6VPG.js`),[]),go:()=>M(()=>import(`./go-CYstVVJV.js`),[]),rust:()=>M(()=>import(`./rust-BIKPVoi6.js`),[]),java:()=>M(()=>import(`./java-Dde-Wnb4.js`),[]),c:()=>M(()=>import(`./c-DBVbJFpC.js`),[]),cpp:()=>M(()=>import(`./cpp-N2d8M7Nc.js`),[]),csharp:()=>M(()=>import(`./csharp-yYt0Ikks.js`),[]),ruby:()=>M(()=>import(`./ruby-BGpZ3p4_.js`),[]),php:()=>M(()=>import(`./php-DuZl5e-L.js`),[]),sql:()=>M(()=>import(`./sql-DWRKyvJ-.js`),[]),yaml:()=>M(()=>import(`./yaml-DjOhhVLG.js`),[]),ini:()=>M(()=>import(`./ini-B1CroMsf.js`),[]),dockerfile:()=>M(()=>import(`./dockerfile-C0zufGsU.js`),[]),markdown:()=>M(()=>import(`./markdown-D6FrnlqJ.js`),[]),plaintext:()=>M(()=>import(`./plaintext-YB8mb-y7.js`),[])};async function pe(){return de||=(async()=>{let{default:e}=await M(async()=>{let{default:e}=await import(`./core-VbNX68N4.js`);return{default:e}},__vite__mapDeps([0,1]));return await Promise.all(Object.entries(fe).map(async([t,n])=>{let r=await n();e.registerLanguage(t,r.default)})),e})(),de}var me={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 he(e){let t=e.split(`/`).pop()??e;if(/^dockerfile$/i.test(t))return`dockerfile`;let n=t.lastIndexOf(`.`);if(!(n<0))return me[t.slice(n+1).toLowerCase()]}function ge({code:e,path:t}){let[n,r]=(0,d.useState)(null),i=(0,d.useRef)(e);return i.current=e,(0,d.useEffect)(()=>{let e=!1;return r(null),pe().then(n=>{if(e)return;let a=he(t),o=a&&n.getLanguage(a)?n.highlight(i.current,{language:a}):n.highlightAuto(i.current);r(o.value)}),()=>{e=!0}},[e,t]),n===null?(0,j.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,children:e}):(0,j.jsx)(`pre`,{className:`hljs whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,dangerouslySetInnerHTML:{__html:n}})}var _e=c();function ve(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 ye({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=ve(o?.current)??c.current,t?(0,_e.createPortal)((0,j.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,j.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,j.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-4`,children:[(0,j.jsx)(`span`,{className:`text-xs text-zinc-500`,children:e}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i,(0,j.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,j.jsx)(`div`,{ref:a,className:`[&_svg]:!max-w-none`,children:r})]})}),c.current??globalThis.document.body):null}var be=null,xe=null;async function Se(e){let t=await(be??=M(()=>import(`./mermaid.core-BFKSKkBv.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 xe!==e&&(xe=e,t.default.initialize({startOnLoad:!1,theme:e,securityLevel:`strict`,suppressErrorRendering:!0})),t}function Ce(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 we(e){return typeof e==`object`&&e&&`props`in e&&typeof e.props.className==`string`&&/language-mermaid\b/.test(e.props.className)?String(e.props.children??``).trim():null}function Te(e){let{children:t,...n}=e,r=we(t);return r===null?(0,j.jsx)(`pre`,{...n,children:t}):(0,j.jsx)(Ee,{code:r})}function Ee({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.useRef)(null),p=(0,d.useRef)(e);return p.current=e,(0,d.useEffect)(()=>{let e=!1,r=setTimeout(async()=>{try{let{svg:r}=await(await Se(n)).default.render(`mermaid-${t}`,p.current);e||(i(r),o(null))}catch(t){e||o(t instanceof Error?t.message:String(t))}},300);return()=>{e=!0,clearTimeout(r)}},[e,t,n]),r?(0,j.jsxs)(`div`,{ref:f,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,j.jsx)(`div`,{className:`absolute left-2 top-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,j.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,j.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&&(0,j.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,j.jsx)(se,{text:e})]}),s?(0,j.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,j.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:r}}),(0,j.jsx)(ye,{label:`diagram`,testId:`mermaid-enlarged`,open:l,onClose:()=>u(!1),anchorRef:f,children:(0,j.jsx)(`div`,{style:{width:Ce(r)},className:`[&_svg]:!h-auto [&_svg]:!max-w-none [&_svg]:!w-full`,dangerouslySetInnerHTML:{__html:r}})})]}):(0,j.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,j.jsx)(`div`,{className:`mt-2 text-red-600 dark:text-red-400`,children:a})]})}function De({html:e,className:t=``,as:n=`div`}){return(0,j.jsx)(n,{className:`rendered-ansi overflow-x-auto font-mono text-xs leading-relaxed [&_span]:whitespace-pre-wrap ${t}`,dangerouslySetInnerHTML:{__html:e}})}function Oe({lines:e,fill:t=!1}){return(0,j.jsx)(`div`,{className:`overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800 ${t?`max-h-full`:`max-h-72`}`,children:w(C(e)).map((e,t)=>e===null?(0,j.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,j.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,j.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,j.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 ke({lines:e}){return(0,j.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800`,children:T(e).map((e,t)=>e===null?(0,j.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,j.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 Ae({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,j.jsxs)(`div`,{className:`group ml-auto flex max-w-[85%] items-start gap-1.5`,children:[o&&!s&&(0,j.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,j.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,j.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:e.images.map((e,t)=>(0,j.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-48 max-w-full rounded-lg object-contain`},t))}),s?(0,j.jsxs)(`div`,{children:[(0,j.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(`
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 O(e){let t=D(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 te(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`//`)}function ne(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 re(e){return/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(e)}function ie(e){return/\.pdf$/i.test(e)}function ae(e){return/\.(docx|xlsx|pptx)$/i.test(e)}function oe(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 k=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})),A=n(((e,t)=>{t.exports=k()})),j=A();function se({text:e,className:t}){let[n,r]=(0,d.useState)(!1);async function i(){try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)}catch{}}return(0,j.jsx)(`button`,{type:`button`,onClick:i,title:n?`Copied!`:`Copy`,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?`✓ copied`:`⧉ copy`})}var ce=`modulepreload`,le=function(e){return`/`+e},ue={},M=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=le(t,n),t=s(t),t in ue)return;ue[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`:ce,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)})},de=null,fe={javascript:()=>M(()=>import(`./javascript-8AmHuH5O.js`),[]),typescript:()=>M(()=>import(`./typescript-CxkPLmSc.js`),[]),json:()=>M(()=>import(`./json-PmyKWHmm.js`),[]),xml:()=>M(()=>import(`./xml-COl5yFSC.js`),[]),css:()=>M(()=>import(`./css-D8M8GYaw.js`),[]),scss:()=>M(()=>import(`./scss-gOyOKiXd.js`),[]),bash:()=>M(()=>import(`./bash-LmRjUKlR.js`),[]),python:()=>M(()=>import(`./python-gHmu6VPG.js`),[]),go:()=>M(()=>import(`./go-CYstVVJV.js`),[]),rust:()=>M(()=>import(`./rust-BIKPVoi6.js`),[]),java:()=>M(()=>import(`./java-Dde-Wnb4.js`),[]),c:()=>M(()=>import(`./c-DBVbJFpC.js`),[]),cpp:()=>M(()=>import(`./cpp-N2d8M7Nc.js`),[]),csharp:()=>M(()=>import(`./csharp-yYt0Ikks.js`),[]),ruby:()=>M(()=>import(`./ruby-BGpZ3p4_.js`),[]),php:()=>M(()=>import(`./php-DuZl5e-L.js`),[]),sql:()=>M(()=>import(`./sql-DWRKyvJ-.js`),[]),yaml:()=>M(()=>import(`./yaml-DjOhhVLG.js`),[]),ini:()=>M(()=>import(`./ini-B1CroMsf.js`),[]),dockerfile:()=>M(()=>import(`./dockerfile-C0zufGsU.js`),[]),markdown:()=>M(()=>import(`./markdown-D6FrnlqJ.js`),[]),plaintext:()=>M(()=>import(`./plaintext-YB8mb-y7.js`),[])};async function pe(){return de||=(async()=>{let{default:e}=await M(async()=>{let{default:e}=await import(`./core-VbNX68N4.js`);return{default:e}},__vite__mapDeps([0,1]));return await Promise.all(Object.entries(fe).map(async([t,n])=>{let r=await n();e.registerLanguage(t,r.default)})),e})(),de}var me={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 he(e){let t=e.split(`/`).pop()??e;if(/^dockerfile$/i.test(t))return`dockerfile`;let n=t.lastIndexOf(`.`);if(!(n<0))return me[t.slice(n+1).toLowerCase()]}function ge({code:e,path:t}){let[n,r]=(0,d.useState)(null),i=(0,d.useRef)(e);return i.current=e,(0,d.useEffect)(()=>{let e=!1;return r(null),pe().then(n=>{if(e)return;let a=he(t),o=a&&n.getLanguage(a)?n.highlight(i.current,{language:a}):n.highlightAuto(i.current);r(o.value)}),()=>{e=!0}},[e,t]),n===null?(0,j.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,children:e}):(0,j.jsx)(`pre`,{className:`hljs whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,dangerouslySetInnerHTML:{__html:n}})}var _e=c();function ve(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 ye({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=ve(o?.current)??c.current,t?(0,_e.createPortal)((0,j.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,j.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,j.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-4`,children:[(0,j.jsx)(`span`,{className:`text-xs text-zinc-500`,children:e}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i,(0,j.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,j.jsx)(`div`,{ref:a,className:`[&_svg]:!max-w-none`,children:r})]})}),c.current??globalThis.document.body):null}var be=null,xe=null;async function Se(e){let t=await(be??=M(()=>import(`./mermaid.core-CptB1LAj.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 xe!==e&&(xe=e,t.default.initialize({startOnLoad:!1,theme:e,securityLevel:`strict`,suppressErrorRendering:!0})),t}function Ce(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 we(e){return typeof e==`object`&&e&&`props`in e&&typeof e.props.className==`string`&&/language-mermaid\b/.test(e.props.className)?String(e.props.children??``).trim():null}function Te(e){let{children:t,...n}=e,r=we(t);return r===null?(0,j.jsx)(`pre`,{...n,children:t}):(0,j.jsx)(Ee,{code:r})}function Ee({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.useRef)(null),p=(0,d.useRef)(e);return p.current=e,(0,d.useEffect)(()=>{let e=!1,r=setTimeout(async()=>{try{let{svg:r}=await(await Se(n)).default.render(`mermaid-${t}`,p.current);e||(i(r),o(null))}catch(t){e||o(t instanceof Error?t.message:String(t))}},300);return()=>{e=!0,clearTimeout(r)}},[e,t,n]),r?(0,j.jsxs)(`div`,{ref:f,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,j.jsx)(`div`,{className:`absolute left-2 top-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,j.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,j.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&&(0,j.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,j.jsx)(se,{text:e})]}),s?(0,j.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,j.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:r}}),(0,j.jsx)(ye,{label:`diagram`,testId:`mermaid-enlarged`,open:l,onClose:()=>u(!1),anchorRef:f,children:(0,j.jsx)(`div`,{style:{width:Ce(r)},className:`[&_svg]:!h-auto [&_svg]:!max-w-none [&_svg]:!w-full`,dangerouslySetInnerHTML:{__html:r}})})]}):(0,j.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,j.jsx)(`div`,{className:`mt-2 text-red-600 dark:text-red-400`,children:a})]})}function De({html:e,className:t=``,as:n=`div`}){return(0,j.jsx)(n,{className:`rendered-ansi overflow-x-auto font-mono text-xs leading-relaxed [&_span]:whitespace-pre-wrap ${t}`,dangerouslySetInnerHTML:{__html:e}})}function Oe({lines:e,fill:t=!1}){return(0,j.jsx)(`div`,{className:`overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800 ${t?`max-h-full`:`max-h-72`}`,children:w(C(e)).map((e,t)=>e===null?(0,j.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,j.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,j.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,j.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 ke({lines:e}){return(0,j.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800`,children:T(e).map((e,t)=>e===null?(0,j.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,j.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 Ae({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,j.jsxs)(`div`,{className:`group ml-auto flex max-w-[85%] items-start gap-1.5`,children:[o&&!s&&(0,j.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,j.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,j.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:e.images.map((e,t)=>(0,j.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-48 max-w-full rounded-lg object-contain`},t))}),s?(0,j.jsxs)(`div`,{children:[(0,j.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(`
17
17
  `).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,j.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2 text-xs`,children:[(0,j.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,j.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,j.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,j.jsx)(`div`,{className:`whitespace-pre-wrap`,children:e.text})]})]})}function je(e){let t=[],n=String(e||``),r=n.indexOf(`,`),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);let e=n.slice(i,r).trim();(e||!a)&&t.push(e),i=r+1,r=n.indexOf(`,`,i)}return t}function Me(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var Ne=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Pe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Fe={};function Ie(e,t){return((t||Fe).jsx?Pe:Ne).test(e)}var Le=/[ \t\n\f\r]/g;function Re(e){return typeof e==`object`?e.type===`text`&&ze(e.value):ze(e)}function ze(e){return e.replace(Le,``)===``}var Be=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};Be.prototype.normal={},Be.prototype.property={},Be.prototype.space=void 0;function Ve(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new Be(n,r,t)}function He(e){return e.toLowerCase()}var Ue=class{constructor(e,t){this.attribute=t,this.property=e}};Ue.prototype.attribute=``,Ue.prototype.booleanish=!1,Ue.prototype.boolean=!1,Ue.prototype.commaOrSpaceSeparated=!1,Ue.prototype.commaSeparated=!1,Ue.prototype.defined=!1,Ue.prototype.mustUseProperty=!1,Ue.prototype.number=!1,Ue.prototype.overloadedBoolean=!1,Ue.prototype.property=``,Ue.prototype.spaceSeparated=!1,Ue.prototype.space=void 0;var We=e({boolean:()=>Ke,booleanish:()=>qe,commaOrSpaceSeparated:()=>Ze,commaSeparated:()=>Xe,number:()=>N,overloadedBoolean:()=>Je,spaceSeparated:()=>Ye}),Ge=0,Ke=Qe(),qe=Qe(),Je=Qe(),N=Qe(),Ye=Qe(),Xe=Qe(),Ze=Qe();function Qe(){return 2**++Ge}var $e=Object.keys(We),et=class extends Ue{constructor(e,t,n,r){let i=-1;if(super(e,t),tt(this,`space`,r),typeof n==`number`)for(;++i<$e.length;){let e=$e[i];tt(this,$e[i],(n&We[e])===We[e])}}};et.prototype.defined=!0;function tt(e,t,n){n&&(e[t]=n)}function nt(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new et(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[He(r)]=r,n[He(a.attribute)]=r}return new Be(t,n,e.space)}var rt=nt({properties:{ariaActiveDescendant:null,ariaAtomic:qe,ariaAutoComplete:null,ariaBusy:qe,ariaChecked:qe,ariaColCount:N,ariaColIndex:N,ariaColSpan:N,ariaControls:Ye,ariaCurrent:null,ariaDescribedBy:Ye,ariaDetails:null,ariaDisabled:qe,ariaDropEffect:Ye,ariaErrorMessage:null,ariaExpanded:qe,ariaFlowTo:Ye,ariaGrabbed:qe,ariaHasPopup:null,ariaHidden:qe,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ye,ariaLevel:N,ariaLive:null,ariaModal:qe,ariaMultiLine:qe,ariaMultiSelectable:qe,ariaOrientation:null,ariaOwns:Ye,ariaPlaceholder:null,ariaPosInSet:N,ariaPressed:qe,ariaReadOnly:qe,ariaRelevant:null,ariaRequired:qe,ariaRoleDescription:Ye,ariaRowCount:N,ariaRowIndex:N,ariaRowSpan:N,ariaSelected:qe,ariaSetSize:N,ariaSort:null,ariaValueMax:N,ariaValueMin:N,ariaValueNow:N,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function it(e,t){return t in e?e[t]:t}function at(e,t){return it(e,t.toLowerCase())}var ot=nt({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:Xe,acceptCharset:Ye,accessKey:Ye,action:null,allow:null,allowFullScreen:Ke,allowPaymentRequest:Ke,allowUserMedia:Ke,alpha:Ke,alt:null,as:null,async:Ke,autoCapitalize:null,autoComplete:Ye,autoFocus:Ke,autoPlay:Ke,blocking:Ye,capture:null,charSet:null,checked:Ke,cite:null,className:Ye,closedBy:null,colorSpace:null,cols:N,colSpan:N,command:null,commandFor:null,content:null,contentEditable:qe,controls:Ke,controlsList:Ye,coords:N|Xe,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ke,defer:Ke,dir:null,dirName:null,disabled:Ke,download:Je,draggable:qe,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ke,formTarget:null,headers:Ye,height:N,hidden:Je,high:N,href:null,hrefLang:null,htmlFor:Ye,httpEquiv:Ye,id:null,imageSizes:null,imageSrcSet:null,inert:Ke,inputMode:null,integrity:null,is:null,isMap:Ke,itemId:null,itemProp:Ye,itemRef:Ye,itemScope:Ke,itemType:Ye,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ke,low:N,manifest:null,max:null,maxLength:N,media:null,method:null,min:null,minLength:N,multiple:Ke,muted:Ke,name:null,nonce:null,noModule:Ke,noValidate:Ke,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ke,optimum:N,pattern:null,ping:Ye,placeholder:null,playsInline:Ke,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ke,referrerPolicy:null,rel:Ye,required:Ke,reversed:Ke,rows:N,rowSpan:N,sandbox:Ye,scope:null,scoped:Ke,seamless:Ke,selected:Ke,shadowRootClonable:Ke,shadowRootCustomElementRegistry:Ke,shadowRootDelegatesFocus:Ke,shadowRootMode:null,shadowRootSerializable:Ke,shape:null,size:N,sizes:null,slot:null,span:N,spellCheck:qe,src:null,srcDoc:null,srcLang:null,srcSet:null,start:N,step:null,style:null,tabIndex:N,target:null,title:null,translate:null,type:null,typeMustMatch:Ke,useMap:null,value:qe,width:N,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ye,axis:null,background:null,bgColor:null,border:N,borderColor:null,bottomMargin:N,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ke,declare:Ke,event:null,face:null,frame:null,frameBorder:null,hSpace:N,leftMargin:N,link:null,longDesc:null,lowSrc:null,marginHeight:N,marginWidth:N,noResize:Ke,noHref:Ke,noShade:Ke,noWrap:Ke,object:null,profile:null,prompt:null,rev:null,rightMargin:N,rules:null,scheme:null,scrolling:qe,standby:null,summary:null,text:null,topMargin:N,valueType:null,version:null,vAlign:null,vLink:null,vSpace:N,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Ke,disablePictureInPicture:Ke,disableRemotePlayback:Ke,exportParts:Xe,part:Ye,prefix:null,property:null,results:N,security:null,unselectable:null},space:`html`,transform:at}),st=nt({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:Ze,accentHeight:N,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:N,amplitude:N,arabicForm:null,ascent:N,attributeName:null,attributeType:null,azimuth:N,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:N,by:null,calcMode:null,capHeight:N,className:Ye,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:N,diffuseConstant:N,direction:null,display:null,dur:null,divisor:N,dominantBaseline:null,download:Ke,dx:null,dy:null,edgeMode:null,editable:null,elevation:N,enableBackground:null,end:null,event:null,exponent:N,externalResourcesRequired:null,fill:null,fillOpacity:N,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Xe,g2:Xe,glyphName:Xe,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:N,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:N,horizOriginX:N,horizOriginY:N,id:null,ideographic:N,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:N,k:N,k1:N,k2:N,k3:N,k4:N,kernelMatrix:Ze,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:N,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:N,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:N,overlineThickness:N,paintOrder:null,panose1:null,path:null,pathLength:N,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ye,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:N,pointsAtY:N,pointsAtZ:N,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ze,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ze,rev:Ze,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ze,requiredFeatures:Ze,requiredFonts:Ze,requiredFormats:Ze,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:N,specularExponent:N,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:N,strikethroughThickness:N,string:null,stroke:null,strokeDashArray:Ze,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:N,strokeOpacity:N,strokeWidth:null,style:null,surfaceScale:N,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ze,tabIndex:N,tableValues:null,target:null,targetX:N,targetY:N,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ze,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:N,underlineThickness:N,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:N,values:null,vAlphabetic:N,vMathematical:N,vectorEffect:null,vHanging:N,vIdeographic:N,version:null,vertAdvY:N,vertOriginX:N,vertOriginY:N,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:N,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:it}),ct=nt({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),lt=nt({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:at}),ut=nt({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),dt={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},ft=/[A-Z]/g,pt=/-[a-z]/g,mt=/^data[-\w.:]+$/i;function ht(e,t){let n=He(t),r=t,i=Ue;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&mt.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(pt,_t);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!pt.test(e)){let n=e.replace(ft,gt);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=et}return new i(r,t)}function gt(e){return`-`+e.toLowerCase()}function _t(e){return e.charAt(1).toUpperCase()}var vt=Ve([rt,ot,ct,lt,ut],`html`),yt=Ve([rt,st,ct,lt,ut],`svg`);function bt(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function xt(e){return e.join(` `).trim()}var St=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
18
18
  `);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),Ct=n((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(St());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),wt=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),Tt=n(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Ct()),r=wt();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),Et=Ot(`end`),Dt=Ot(`start`);function Ot(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function kt(e){let t=Dt(e),n=Et(e);if(t&&n)return{start:t,end:n}}function At(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Mt(e.position):`start`in e||`end`in e?Mt(e):`line`in e||`column`in e?jt(e):``}function jt(e){return Nt(e&&e.line)+`:`+Nt(e&&e.column)}function Mt(e){return jt(e&&e.start)+`-`+jt(e&&e.end)}function Nt(e){return e&&typeof e==`number`?e:1}var Pt=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=At(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Pt.prototype.file=``,Pt.prototype.name=``,Pt.prototype.reason=``,Pt.prototype.message=``,Pt.prototype.stack=``,Pt.prototype.column=void 0,Pt.prototype.line=void 0,Pt.prototype.ancestors=void 0,Pt.prototype.cause=void 0,Pt.prototype.fatal=void 0,Pt.prototype.place=void 0,Pt.prototype.ruleId=void 0,Pt.prototype.source=void 0;var Ft=t(Tt(),1),It={}.hasOwnProperty,Lt=new Map,Rt=/[A-Z]/g,zt=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Bt=new Set([`td`,`th`]),Vt=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function Ht(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=$t(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=Qt(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?yt:vt,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Ut(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Ut(e,t,n){if(t.type===`element`)return Wt(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return Gt(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return qt(e,t,n);if(t.type===`mdxjsEsm`)return Kt(e,t);if(t.type===`root`)return Jt(e,t,n);if(t.type===`text`)return Yt(e,t)}function Wt(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=yt,e.schema=i),e.ancestors.push(t);let a=on(e,t.tagName,!1),o=en(e,t),s=nn(e,t);return zt.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!Re(e)})),Xt(e,o,a,t),Zt(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Gt(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}sn(e,t.position)}function Kt(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);sn(e,t.position)}function qt(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=yt,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:on(e,t.name,!0),o=tn(e,t),s=nn(e,t);return Xt(e,o,a,t),Zt(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Jt(e,t,n){let r={};return Zt(r,nn(e,t)),e.create(t,e.Fragment,r,n)}function Yt(e,t){return t.value}function Xt(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Zt(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Qt(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function $t(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=Dt(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function en(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&It.call(t.properties,i)){let a=rn(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Bt.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function tn(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else sn(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else sn(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function nn(e,t){let n=[],r=-1,i=e.passKeys?new Map:Lt;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=Ut(e,a,o);s!==void 0&&n.push(s)}return n}function rn(e,t,n){let r=ht(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Me(n):xt(n)),r.property===`style`){let t=typeof n==`object`?n:an(e,String(n));return e.stylePropertyNameCase===`css`&&(t=cn(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?dt[r.property]||r.property:r.attribute,n]}}function an(e,t){try{return(0,Ft.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new Pt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=Vt+`#cannot-parse-style-attribute`,r}}function on(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=Ie(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=Ie(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return It.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);sn(e)}function sn(e,t){let n=new Pt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=Vt+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function cn(e){let t={},n;for(n in e)It.call(e,n)&&(t[ln(n)]=e[n]);return t}function ln(e){let t=e.replace(Rt,un);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function un(e){return`-`+e.toLowerCase()}var dn={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},fn={};function pn(e,t){let n=t||fn;return mn(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function mn(e,t,n){if(gn(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return hn(e.children,t,n)}return Array.isArray(e)?hn(e,t,n):``}function hn(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=mn(e[i],t,n);return r.join(``)}function gn(e){return!!(e&&typeof e==`object`)}var _n=document.createElement(`i`);function vn(e){let t=`&`+e+`;`;_n.innerHTML=t;let n=_n.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function yn(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function bn(e,t){return e.length>0?(yn(e,e.length,0,t),e):t}var xn={}.hasOwnProperty;function Sn(e){let t={},n=-1;for(;++n<e.length;)Cn(t,e[n]);return t}function Cn(e,t){let n;for(n in t){let r=(xn.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){xn.call(r,a)||(r[a]=[]);let e=i[a];wn(r[a],Array.isArray(e)?e:e?[e]:[])}}}function wn(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);yn(e,0,0,r)}function Tn(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function En(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var Dn=Rn(/[A-Za-z]/),On=Rn(/[\dA-Za-z]/),kn=Rn(/[#-'*+\--9=?A-Z^-~]/);function An(e){return e!==null&&(e<32||e===127)}var jn=Rn(/\d/),Mn=Rn(/[\dA-Fa-f]/),Nn=Rn(/[!-/:-@[-`{-~]/);function P(e){return e!==null&&e<-2}function Pn(e){return e!==null&&(e<0||e===32)}function Fn(e){return e===-2||e===-1||e===32}var In=Rn(/\p{P}|\p{S}/u),Ln=Rn(/\s/);function Rn(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function zn(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&On(e.charCodeAt(n+1))&&On(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function Bn(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Fn(r)?(e.enter(n),s(r)):t(r)}function s(r){return Fn(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var Vn={tokenize:Hn};function Hn(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Bn(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return P(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Un={tokenize:Gn},Wn={tokenize:Kn};function Gn(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return yn(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Wn,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Wn,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return P(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;yn(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Kn(e,t,n){return Bn(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function qn(e){if(e===null||Pn(e)||Ln(e))return 1;if(In(e))return 2}function Jn(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var Yn={name:`attention`,resolveAll:Xn,tokenize:Zn};function Xn(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Qn(d,-c),Qn(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=bn(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=bn(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=bn(l,Jn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=bn(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=bn(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,yn(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function Zn(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=qn(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=qn(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Qn(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var $n={name:`autolink`,tokenize:er};function er(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return Dn(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||On(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||On(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||An(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):kn(t)?(e.consume(t),l):n(t)}function u(e){return On(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||On(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var tr={partial:!0,tokenize:nr};function nr(e,t,n){return r;function r(t){return Fn(t)?Bn(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||P(e)?t(e):n(e)}}var rr={continuation:{tokenize:ar},exit:or,name:`blockQuote`,tokenize:ir};function ir(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Fn(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function ar(e,t,n){let r=this;return i;function i(t){return Fn(t)?Bn(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(rr,t,n)(r)}}function or(e){e.exit(`blockQuote`)}var sr={name:`characterEscape`,tokenize:cr};function cr(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return Nn(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var lr={name:`characterReference`,tokenize:ur};function ur(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=On,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=Mn,u):(e.enter(`characterReferenceValue`),a=7,o=jn,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===On&&!vn(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var dr={partial:!0,tokenize:mr},fr={concrete:!0,name:`codeFenced`,tokenize:pr};function pr(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Fn(t)?Bn(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||P(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(dr,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||P(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Fn(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),Bn(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||P(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||P(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Fn(t)?Bn(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||P(t)?e.check(dr,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||P(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Fn(t)?Bn(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Fn(t)?Bn(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||P(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function mr(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var hr={name:`codeIndented`,tokenize:_r},gr={partial:!0,tokenize:vr};function _r(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),Bn(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):P(t)?e.attempt(gr,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||P(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function vr(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):P(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):Bn(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):P(e)?i(e):n(e)}}var yr={name:`codeText`,previous:xr,resolve:br,tokenize:Sr};function br(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function xr(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function Sr(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):P(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||P(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var Cr=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&wr(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),wr(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),wr(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);wr(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);wr(this.left,t.reverse())}}}};function wr(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Tr(e){let t={},n=-1,r,i,a,o,s,c,l,u=new Cr(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,Er(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return yn(e,0,1/0,u.slice(0)),!l}function Er(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var Dr={resolve:kr,tokenize:Ar},Or={partial:!0,tokenize:jr};function kr(e){return Tr(e),e}function Ar(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):P(t)?e.check(Or,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function jr(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Bn(e,a,`linePrefix`)}function a(i){if(i===null||P(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Mr(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||An(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||P(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||Pn(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||An(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function Nr(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):P(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||P(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!Fn(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Pr(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):P(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Bn(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||P(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Fr(e,t){let n;return r;function r(i){return P(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Fn(i)?Bn(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Ir={name:`definition`,tokenize:Rr},Lr={partial:!0,tokenize:zr};function Rr(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Nr.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=En(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return Pn(t)?Fr(e,l)(t):l(t)}function l(t){return Mr(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Lr,d,d)(t)}function d(t){return Fn(t)?Bn(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||P(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function zr(e,t,n){return r;function r(t){return Pn(t)?Fr(e,i)(t):n(t)}function i(t){return Pr(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Fn(t)?Bn(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||P(e)?t(e):n(e)}}var Br={name:`hardBreakEscape`,tokenize:Vr};function Vr(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return P(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Hr={name:`headingAtx`,resolve:Ur,tokenize:Wr};function Ur(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},yn(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Wr(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||Pn(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||P(n)?(e.exit(`atxHeading`),t(n)):Fn(n)?Bn(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||Pn(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Gr=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Kr=[`pre`,`script`,`style`,`textarea`],qr={concrete:!0,name:`htmlFlow`,resolveTo:Xr,tokenize:Zr},Jr={partial:!0,tokenize:$r},Yr={partial:!0,tokenize:Qr};function Xr(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Zr(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:k):Dn(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):Dn(a)?(e.consume(a),i=4,r.interrupt?t:k):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:k):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:D:m):n(i)}function h(t){return Dn(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||Pn(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Kr.includes(l)?(i=1,r.interrupt?t(s):D(s)):Gr.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):D(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||On(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:D):n(i)}function v(t){return Fn(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||Dn(t)?(e.consume(t),b):Fn(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||On(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Fn(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Fn(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||P(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||Pn(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Fn(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),ee):n(t)}function ee(t){return t===null||P(t)?D(t):Fn(t)?(e.consume(t),ee):n(t)}function D(t){return t===45&&i===2?(e.consume(t),re):t===60&&i===1?(e.consume(t),ie):t===62&&i===4?(e.consume(t),A):t===63&&i===3?(e.consume(t),k):t===93&&i===5?(e.consume(t),oe):P(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Jr,j,O)(t)):t===null||P(t)?(e.exit(`htmlFlowData`),O(t)):(e.consume(t),D)}function O(t){return e.check(Yr,te,j)(t)}function te(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ne}function ne(t){return t===null||P(t)?O(t):(e.enter(`htmlFlowData`),D(t))}function re(t){return t===45?(e.consume(t),k):D(t)}function ie(t){return t===47?(e.consume(t),o=``,ae):D(t)}function ae(t){if(t===62){let n=o.toLowerCase();return Kr.includes(n)?(e.consume(t),A):D(t)}return Dn(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ae):D(t)}function oe(t){return t===93?(e.consume(t),k):D(t)}function k(t){return t===62?(e.consume(t),A):t===45&&i===2?(e.consume(t),k):D(t)}function A(t){return t===null||P(t)?(e.exit(`htmlFlowData`),j(t)):(e.consume(t),A)}function j(n){return e.exit(`htmlFlow`),t(n)}}function Qr(e,t,n){let r=this;return i;function i(t){return P(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function $r(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(tr,t,n)}}var ei={name:`htmlText`,tokenize:ti};function ti(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):Dn(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):Dn(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):P(t)?(o=d,ie(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?re(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):P(t)?(o=h,ie(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?re(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?re(t):P(t)?(o=v,ie(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):P(t)?(o=y,ie(t)):(e.consume(t),y)}function b(e){return e===62?re(e):y(e)}function x(t){return Dn(t)?(e.consume(t),S):n(t)}function S(t){return t===45||On(t)?(e.consume(t),S):C(t)}function C(t){return P(t)?(o=C,ie(t)):Fn(t)?(e.consume(t),C):re(t)}function w(t){return t===45||On(t)?(e.consume(t),w):t===47||t===62||Pn(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),re):t===58||t===95||Dn(t)?(e.consume(t),E):P(t)?(o=T,ie(t)):Fn(t)?(e.consume(t),T):re(t)}function E(t){return t===45||t===46||t===58||t===95||On(t)?(e.consume(t),E):ee(t)}function ee(t){return t===61?(e.consume(t),D):P(t)?(o=ee,ie(t)):Fn(t)?(e.consume(t),ee):T(t)}function D(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,O):P(t)?(o=D,ie(t)):Fn(t)?(e.consume(t),D):(e.consume(t),te)}function O(t){return t===i?(e.consume(t),i=void 0,ne):t===null?n(t):P(t)?(o=O,ie(t)):(e.consume(t),O)}function te(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||Pn(t)?T(t):(e.consume(t),te)}function ne(e){return e===47||e===62||Pn(e)?T(e):n(e)}function re(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function ie(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ae}function ae(t){return Fn(t)?Bn(e,oe,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):oe(t)}function oe(t){return e.enter(`htmlTextData`),o(t)}}var ni={name:`labelEnd`,resolveAll:oi,resolveTo:si,tokenize:ci},ri={tokenize:li},ii={tokenize:ui},ai={tokenize:di};function oi(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&yn(e,0,e.length,n),e}function si(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=bn(s,e.slice(a+1,a+r+3)),s=bn(s,[[`enter`,u,t]]),s=bn(s,Jn(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=bn(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=bn(s,e.slice(o+1)),s=bn(s,[[`exit`,c,t]]),yn(e,a,e.length,s),e}function ci(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(En(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(ri,u,o?u:d)(t):t===91?e.attempt(ii,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(ai,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function li(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return Pn(t)?Fr(e,a)(t):a(t)}function a(t){return t===41?u(t):Mr(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return Pn(t)?Fr(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Pr(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return Pn(t)?Fr(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function ui(e,t,n){let r=this;return i;function i(t){return Nr.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(En(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function di(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var fi={name:`labelStartImage`,resolveAll:ni.resolveAll,tokenize:pi};function pi(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var mi={name:`labelStartLink`,resolveAll:ni.resolveAll,tokenize:hi};function hi(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var gi={name:`lineEnding`,tokenize:_i};function _i(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Bn(e,t,`linePrefix`)}}var vi={name:`thematicBreak`,tokenize:yi};function yi(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||P(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Fn(t)?Bn(e,s,`whitespace`)(t):s(t))}}var bi={continuation:{tokenize:wi},exit:Ei,name:`list`,tokenize:Ci},xi={partial:!0,tokenize:Di},Si={partial:!0,tokenize:Ti};function Ci(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:jn(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(vi,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return jn(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(tr,r.interrupt?n:u,e.attempt(xi,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Fn(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function wi(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(tr,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Bn(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Fn(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Si,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Bn(e,e.attempt(bi,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function Ti(e,t,n){let r=this;return Bn(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function Ei(e){e.exit(this.containerState.type)}function Di(e,t,n){let r=this;return Bn(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Fn(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var Oi={name:`setextUnderline`,resolveTo:ki,tokenize:Ai};function ki(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function Ai(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Fn(t)?Bn(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||P(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var ji={tokenize:Mi};function Mi(e){let t=this,n=e.attempt(tr,r,e.attempt(this.parser.constructs.flowInitial,i,Bn(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Dr,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var Ni={resolveAll:Li()},Pi=Ii(`string`),Fi=Ii(`text`);function Ii(e){return{resolveAll:Li(e===`text`?Ri:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function Li(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function Ri(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var zi=e({attentionMarkers:()=>qi,contentInitial:()=>Vi,disable:()=>Ji,document:()=>Bi,flow:()=>Ui,flowInitial:()=>Hi,insideSpan:()=>Ki,string:()=>Wi,text:()=>Gi}),Bi={42:bi,43:bi,45:bi,48:bi,49:bi,50:bi,51:bi,52:bi,53:bi,54:bi,55:bi,56:bi,57:bi,62:rr},Vi={91:Ir},Hi={[-2]:hr,[-1]:hr,32:hr},Ui={35:Hr,42:vi,45:[Oi,vi],60:qr,61:Oi,95:vi,96:fr,126:fr},Wi={38:lr,92:sr},Gi={[-5]:gi,[-4]:gi,[-3]:gi,33:fi,38:lr,42:Yn,60:[$n,ei],91:mi,92:[Br,sr],93:ni,95:Yn,96:yr},Ki={null:[Yn,Ni]},qi={null:[42,95]},Ji={null:[]};function Yi(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=bn(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Jn(a,l.events,l),l.events):[]}function f(e,t){return Zi(p(e),t)}function p(e){return Xi(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){P(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&yn(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Xi(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Zi(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
19
19
  `;break;case-3:o=`\r
@@ -320,5 +320,5 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
320
320
  `)]);let O=(0,d.useMemo)(()=>{let e=/^\/(\S*)$/.exec(h);return e?e[1].toLowerCase():null},[h]),te=(0,d.useMemo)(()=>O===null?[]:n.filter(e=>e.name.toLowerCase().startsWith(O)).sort((e,t)=>hE.compare(e.name,t.name)).slice(0,mE),[O,n]),ne=O===null?vE(h,_):null;(0,d.useEffect)(()=>{if(!ne||ne.query.length===0){m();return}let e=window.setTimeout(()=>p(ne.query),150);return()=>clearTimeout(e)},[ne?.query]);let re=(0,d.useMemo)(()=>{if(te.length>0)return{kind:`command`,items:te};let e=ne&&r?.query===ne.query?r.results:[];return e.length>0?{kind:`file`,items:e}:null},[te,ne,r]),ie=re!==null&&!x,ae=O===null?ne?`file:${ne.query}`:null:`cmd:${O}`;(0,d.useEffect)(()=>{b(0)},[ae]),(0,d.useEffect)(()=>{S(!1)},[O===null?ne?`file`:null:`command`]),(0,d.useEffect)(()=>{if(!ie)return;let e=e=>{fE(e,C.current)||S(!0)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[ie]),(0,d.useEffect)(()=>{w.current?.querySelector(`[data-selected="true"]`)?.scrollIntoView({block:`nearest`})},[y]);let oe=o.length>0,[k,A]=(0,d.useState)(!1);(0,d.useEffect)(()=>{oe||A(!1)},[oe]);function se(){if(oe){A(!0);return}let e=oE(h,a),t=a.filter(e=>e.kind===`image`).map(e=>({data:e.data,mimeType:e.mimeType})),n=a.every(e=>e.kind===`path`);!h.trim()&&(n||!e)&&t.length===0||(u(e,t.length>0?t:void 0),g(``),m())}function ce(e){let t=`/${e.name} `;g(t),ee.current=t.length,v(t.length)}function le(e){if(!ne)return;let t=h.slice(0,ne.start),n=h.slice(_),r=`@${e.path}${_E(e.type)?`/`:` `}`,i=`${t}${r}${n}`;g(i),m();let a=t.length+r.length;ee.current=a,v(a)}function ue(){if(re){if(re.kind===`command`){let e=re.items[y];e&&ce(e)}else{let e=re.items[y];e&&le(e)}}}function M(e){if(ie&&re){if(e.key===`ArrowDown`){e.preventDefault(),b(e=>(e+1)%re.items.length);return}if(e.key===`ArrowUp`){e.preventDefault(),b(e=>(e-1+re.items.length)%re.items.length);return}if(e.key===`Tab`||e.key===`Enter`){e.preventDefault(),ue();return}if(e.key===`Escape`){e.preventDefault(),S(!0);return}}e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),se())}function de(e){v(e.currentTarget.selectionStart??0)}function fe(e){let t=Array.from(e.clipboardData.files);t.length>0&&(e.preventDefault(),s(t))}return(0,j.jsxs)(`div`,{ref:C,className:`relative`,children:[(a.length>0||oe)&&(0,j.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[o.map(e=>(0,j.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,j.jsx)(`span`,{"aria-hidden":!0,className:`animate-pulse`,children:`⏳`}),(0,j.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,j.jsx)(`span`,{className:`sr-only`,children:`uploading`})]},e.id)),k&&(0,j.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,j.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,j.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:e.name,className:`h-8 w-8 rounded object-cover`}):(0,j.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,j.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,j.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}`))]}),ie&&re&&(0,j.jsx)(`div`,{ref:w,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:re.kind===`command`?re.items.map((e,t)=>(0,j.jsxs)(`button`,{type:`button`,"data-selected":t===y,onMouseEnter:()=>b(t),onClick:()=>ce(e),className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm ${t===y?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,j.jsxs)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:[`/`,e.name]}),e.argumentHint&&(0,j.jsx)(`span`,{className:`font-mono text-xs text-zinc-500`,children:e.argumentHint}),e.description&&(0,j.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-zinc-500`,children:e.description}),(0,j.jsx)(`span`,{className:`ml-auto shrink-0 rounded bg-zinc-200 px-1 text-[10px] uppercase text-zinc-500 dark:bg-zinc-800`,children:gE[e.source]})]},e.name)):re.items.map((e,t)=>(0,j.jsx)(`button`,{type:`button`,"data-selected":t===y,onMouseEnter:()=>b(t),onClick:()=>le(e),className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm ${t===y?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:(0,j.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-zinc-800 dark:text-zinc-200`,children:[e.path,_E(e.type)?`/`:``]})},e.path))}),(0,j.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,j.jsx)(`textarea`,{ref:T,value:h,onChange:e=>{g(e.target.value),v(e.target.selectionStart??e.target.value.length)},onKeyDown:M,onClick:de,onKeyUp:de,onPaste:fe,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,h.split(`
321
321
  `).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,j.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,j.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,className:`h-4 w-4`,children:(0,j.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>E.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,j.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,j.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,j.jsx)(`input`,{ref:E,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&s(Array.from(e.target.files)),e.target.value=``}}),(0,j.jsx)(`button`,{type:`button`,onClick:se,disabled:!t||oe||!h.trim()&&a.length===0,title:oe?`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,j.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:[(0,j.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,j.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,j.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]}):(0,j.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,j.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 bE=`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`,xE=`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`,SE=`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`,CE=`mb-4 ${SE}`,wE=`1,3`,TE=` — `;function EE(e){let t=e.indexOf(`
322
322
  `);return t===-1?{heading:e,body:``}:{heading:e.slice(0,t),body:e.slice(t+1).trim()}}function DE(e){let t=/^(\d+)\.\s+(\S[\s\S]*)$/.exec(e.trim());if(!t)return null;let n=t[2],r=n.indexOf(TE);return{index:Number(t[1]),label:r===-1?n:n.slice(0,r),description:r===-1?``:n.slice(r+3)}}function OE(e){if(e.method!==`input`||e.placeholder!==wE)return null;let{heading:t,body:n}=EE(e.title),r=[];for(let e of n.split(`
323
- `)){let t=DE(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function kE({request:e,onRespond:t}){let[n,r]=(0,d.useState)(e.method===`editor`?e.prefill??``:``),[i,a]=(0,d.useState)([]),o=(e.method===`select`||e.method===`confirm`||e.method===`input`)&&e.timeout,[s,c]=(0,d.useState)(o?Math.ceil(o/1e3):null),l=OE(e),{heading:u,body:f}=EE(e.title);function p(){t({id:e.id,cancelled:!0})}function m(e){a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e].sort((e,t)=>e-t))}function h(){let r=n.trim();t({id:e.id,value:r.length>0?r:i.join(`,`)})}return(0,d.useEffect)(()=>{if(s===null)return;if(s<=0){t({id:e.id,cancelled:!0});return}let n=setTimeout(()=>c(e=>e===null?null:e-1),1e3);return()=>clearTimeout(n)},[s,e.id,t]),(0,j.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:p,children:(0,j.jsxs)(`div`,{className:`w-full ${f?`max-w-2xl`:`max-w-md`} rounded-xl border border-zinc-200 bg-white p-4 shadow-2xl dark:border-zinc-700 dark:bg-zinc-900`,onClick:e=>e.stopPropagation(),children:[(0,j.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:u}),f&&!l&&(0,j.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:f}),e.method===`select`&&(0,j.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>{let r=DE(n);return(0,j.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${bE}`,children:r?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:r.label}),r.description&&(0,j.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,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,j.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:bE,children:`No`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:xE,children:`Yes`})]})]}),l&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`mb-3 flex flex-col gap-1`,children:l.options.map(e=>(0,j.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,j.jsx)(`input`,{type:`checkbox`,checked:i.includes(e.index),onChange:()=>m(e.index),className:`mt-0.5`}),(0,j.jsxs)(`span`,{children:[(0,j.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,j.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,j.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`…or type your own answer`,onKeyDown:e=>{e.key===`Enter`&&h(),e.key===`Escape`&&p()},className:`mb-1 ${SE}`}),(0,j.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,j.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:p,className:bE,children:`Cancel`}),(0,j.jsx)(`button`,{type:`button`,onClick:h,className:xE,children:`OK`})]})]}),e.method===`input`&&!l&&(0,j.jsxs)(j.Fragment,{children:[(0,j.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`&&p()},className:CE}),(0,j.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:p,className:bE,children:`Cancel`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:xE,children:`OK`})]})]}),e.method===`editor`&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`textarea`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&p()},className:`resize-none font-mono ${CE}`}),(0,j.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:p,className:bE,children:`Cancel`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:xE,children:`OK`})]})]}),s!==null&&(0,j.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,s,`s`]})]})})}var AE={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`};function jE({notification:e,onDismiss:t}){return(0,d.useEffect)(()=>{let e=setTimeout(t,6e3);return()=>clearTimeout(e)},[t]),(0,j.jsx)(`div`,{className:`rounded-lg border px-3 py-2 text-sm shadow-lg ${AE[e.notifyType??`info`]}`,children:e.message})}function ME({notifications:e,onDismiss:t}){return e.length===0?null:(0,j.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,j.jsx)(jE,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var NE={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`},PE=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function FE(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(NE[r]!==void 0)n.color=NE[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 IE(e){let t=[],n={},r=0;PE.lastIndex=0;for(let i=PE.exec(e);i!==null;i=PE.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=FE(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function LE(e){return e.replace(PE,``)}function RE({line:e}){let t=IE(e);return(0,j.jsx)(j.Fragment,{children:t.map((e,t)=>(0,j.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 zE({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,j.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,j.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,j.jsx)(`div`,{children:(0,j.jsx)(RE,{line:e})},t))},e))})}var BE=class extends d.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){console.error(`[pi-outpost] viewer crashed:`,e,t.componentStack)}render(){return this.state.failed?(0,j.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,j.jsxs)(`p`,{className:`max-w-md text-center text-sm text-zinc-600 dark:text-zinc-400`,children:[this.props.label??`This file`,` could not be displayed. Close and reopen it to try again.`]})}):this.props.children}},VE=(0,d.lazy)(()=>M(()=>import(`./PdfViewer-DZETVqqX.js`),[])),HE=250,UE=`(min-width: 768px)`;function WE(){let[e,t]=(0,d.useState)(()=>window.matchMedia?.(UE).matches??!0);return(0,d.useEffect)(()=>{let e=window.matchMedia?.(UE);if(e===void 0)return;let n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function GE(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 KE(e){let t=nw(e);return t.status===`valid`?t.envelope:void 0}function qE(e){return/\.(md|markdown)$/i.test(e)}function JE(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function YE({file:e,writableRoot:t,isStreaming:n,onDirtyChange:r,gitState:i,initialShowGitDiff:a=!1,gitDiff:o,onFetchGitDiff:s,onClearGitDiff:c,gitAvailable:l,onOpenGitHistory:u,onClose:f,onReload:p,onSave:m,serverUrl:h=``,token:g=null,onImageLoad:_,onPdfLoad:v,rawRevision:y=0}){let[b,x]=(0,d.useState)(`rendered`),[C,w]=(0,d.useState)(a),[T,E]=(0,d.useState)(e.status===`loaded`&&e.justCreated?{draft:e.content,baseContent:e.content,baseMtimeMs:e.mtimeMs}:null),[D,O]=(0,d.useState)(`idle`),te=(0,d.useRef)(null),ae=(0,d.useRef)(null),k=e.status===`loaded`?e:null,A=k!==null&&qE(e.path),ce=re(e.path),le=ie(e.path),ue=(0,d.useMemo)(()=>k===null?void 0:nw(k.content),[k?.content]),M=ue?.status===`valid`,de=ue?.status===`valid`||ue?.status===`invalid`,fe=de||A,pe=b===`source`,me=WE(),he=JE(e.path,t)&&!le,_e=T!==null&&T.draft!==T.baseContent,ve=k?.pendingSave!==void 0,ye=T!==null&&k!==null&&k.mtimeMs!==T.baseMtimeMs,be=k?.saveError?.conflict===!0||ye,xe=T?.draft??k?.content??``,Se=GE(xe,HE),Ce=(0,d.useMemo)(()=>k===null?void 0:nw(Se),[Se,k===null]),[we,Ee]=(0,d.useState)(()=>e.status===`loaded`?KE(e.content):void 0);(0,d.useEffect)(()=>{Ce?.status===`valid`&&Ee(Ce.envelope)},[Ce]);let De=Ce!==void 0&&Ce.status!==`valid`&&we!==void 0,ke=Ce?.status===`invalid`?Se===k?.content&&k.documentIssues!==void 0?k.documentIssues:Ce.issues:void 0,Ae=Ce?.status===`not-a-document`?Ce.why===`unparseable`?`This is not parseable JSON yet.`:"This no longer declares a structured-exchange `schema`.":Ce?.status===`unsupported-version`?`This declares ${Ce.schema}, which this version does not render.`:void 0,je=b===`split`&&fe&&!C&&k!==null&&me,Me=T===null?null:(0,j.jsx)(`textarea`,{ref:te,value:T.draft,onChange:e=>E({...T,draft:e.target.value}),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),_e&&!ve&&!be&&Le())},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 Ne(t){return(0,j.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,j.jsx)(_s,{remarkPlugins:[D_,z_],rehypePlugins:[Dm],components:{pre:Te,a:({href:t,children:n,...r})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,j.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...r,children:n}):t.startsWith(`#`)?(0,j.jsx)(`a`,{href:t,...r,children:n}):(0,j.jsx)(`a`,{href:t,onClick:n=>{n.preventDefault(),p(ne(e.path,t))},...r,children:n}),img:({src:t,alt:n,...r})=>{let i=typeof t==`string`&&t!==``&&!/^[a-z][a-z0-9+.-]*:/i.test(t)&&!t.startsWith(`//`)?oe(h,ne(e.path,t),g):t;return(0,j.jsx)(`img`,{...r,src:i,alt:n??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:ee(t)})})}function Pe(e){b===`split`&&e!==`split`&&_e&&!window.confirm(`Discard unsaved changes?`)||(b===`split`&&e!==`split`&&E(null),x(e))}function Fe(){_e&&!window.confirm(`Discard unsaved changes?`)||f()}function Ie(){k&&E({draft:k.content,baseContent:k.content,baseMtimeMs:k.mtimeMs})}function Le(t=!1){!k||T===null||ve||(ae.current=T.draft,m(e.path,T.draft,T.baseMtimeMs,t))}function Re(){E(null),p(e.path)}function ze(){let t=!C;w(t),t?s(e.path):c()}return(0,d.useEffect)(()=>{if(T!==null&&k!==null&&ae.current!==null&&k.content===ae.current&&k.mtimeMs!==T.baseMtimeMs){let e=ae.current;ae.current=null,T.draft===e?E(null):E({...T,baseContent:k.content,baseMtimeMs:k.mtimeMs})}},[k?.mtimeMs]),(0,d.useEffect)(()=>{function e(e){e.key===`Escape`&&Fe()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,d.useEffect)(()=>{je&&he&&T===null&&k!==null&&E({draft:k.content,baseContent:k.content,baseMtimeMs:k.mtimeMs})},[je,he,k?.mtimeMs]),(0,d.useEffect)(()=>{O(n?`streaming`:e=>e===`streaming`?`done`:e)},[n]),(0,d.useEffect)(()=>(r(_e),()=>r(!1)),[_e]),(0,d.useEffect)(()=>(a&&s(e.path),()=>c()),[]),(0,j.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[fe&&!C&&(0,j.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,j.jsx)(`button`,{type:`button`,onClick:()=>Pe(e),"aria-pressed":b===e,title:n,className:`rounded px-1.5 py-0.5 text-xs ${b===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,j.jsx)(`button`,{type:`button`,onClick:ze,"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,j.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,j.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,_e&&(0,j.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),k&&T===null&&(0,j.jsx)(se,{text:k.content}),k&&T===null&&!C&&he&&(0,j.jsx)(`button`,{type:`button`,onClick:Ie,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`}),k&&T===null&&!he&&(0,j.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,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{type:`button`,onClick:()=>Le(),disabled:!_e||ve||be,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:ve?`saving…`:`save`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>{_e&&!window.confirm(`Discard unsaved changes?`)||E(je&&k!==null?{draft:k.content,baseContent:k.content,baseMtimeMs:k.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,j.jsx)(`button`,{type:`button`,onClick:Fe,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:`✕`})]}),be&&T!==null&&(0,j.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,j.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,j.jsx)(`button`,{type:`button`,onClick:Re,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,j.jsx)(`button`,{type:`button`,onClick:()=>Le(!0),disabled:ve,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&&k?.saveError&&!k.saveError.conflict&&(0,j.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:k.saveError.message}),(0,j.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[C&&T===null&&(0,j.jsxs)(`div`,{className:`p-4`,children:[o?.path===e.path&&`error`in o&&(0,j.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,j.jsx)(Oe,{fill:!0,lines:S(o.before,o.after)}),o?.path!==e.path&&(0,j.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),le&&T===null&&!C&&(0,j.jsx)(BE,{label:`This PDF`,children:(0,j.jsx)(d.Suspense,{fallback:(0,j.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),children:(0,j.jsx)(VE,{path:e.path,serverUrl:h,token:g,revision:y,...v?{onLoaded:v}:{}})})}),ce&&T===null&&!C&&(0,j.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,j.jsx)(`img`,{src:oe(h,e.path,g,y),alt:e.path,onLoad:()=>_(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&T===null&&!C&&!ce&&!le&&(0,j.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!ce&&!le&&(0,j.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),T!==null&&!je&&Me,k&&T===null&&!je&&!C&&A&&!pe&&Ne(k.content),je&&(0,j.jsxs)(`div`,{className:`flex h-full min-h-0`,"data-testid":`file-split`,children:[(0,j.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto border-r border-zinc-200 dark:border-zinc-800`,children:Me??(0,j.jsx)(`div`,{className:`p-4`,children:(0,j.jsx)(ge,{code:k.content,path:e.path})})}),(0,j.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto`,"data-testid":`file-split-rendering`,children:A&&!de?(0,j.jsx)(`div`,{className:`prose-chat p-4 text-zinc-700 dark:text-zinc-300`,children:Ne(Se)}):(0,j.jsxs)(j.Fragment,{children:[De&&(0,j.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,j.jsxs)(`span`,{children:[`Showing the document as it last stood.`,` `,Ae??`The text beside it does not satisfy the schema it declares.`]})}),ke!==void 0&&(0,j.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:[ke.slice(0,6).map((e,t)=>(0,j.jsxs)(`li`,{children:[(0,j.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),ke.length>6&&(0,j.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,ke.length-6,` more`]})]}),we===void 0?(0,j.jsxs)(`p`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,"data-testid":`file-split-nothing`,children:[`Nothing to draw yet. `,Ae??`This document does not satisfy the schema it declares.`]}):(0,j.jsx)(BE,{label:`This diagram`,children:(0,j.jsx)(`div`,{className:`p-4`,"data-testid":`file-structured-exchange`,children:(0,j.jsx)($w,{envelope:we,source:xe})})})]})})]}),k&&T===null&&!je&&!C&&M&&!pe&&ue?.status===`valid`&&(0,j.jsx)(BE,{label:`This diagram`,children:(0,j.jsx)(`div`,{className:`mx-auto max-w-5xl p-4`,"data-testid":`file-structured-exchange`,children:(0,j.jsx)($w,{envelope:ue.envelope,source:k.content})})}),k&&T===null&&!je&&!C&&ue?.status===`invalid`&&(0,j.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,j.jsx)(`p`,{className:`font-medium`,children:`This declares a structured-exchange document and does not satisfy the schema.`}),(0,j.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:[(k.documentIssues??ue.issues).slice(0,8).map((e,t)=>(0,j.jsxs)(`li`,{children:[(0,j.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),(k.documentIssues??ue.issues).length>8&&(0,j.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,(k.documentIssues??ue.issues).length-8,` more`]})]})]}),k&&T===null&&!je&&!C&&ue?.status===`unsupported-version`&&(0,j.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,j.jsx)(`span`,{className:`font-mono`,children:ue.schema}),`, which this version does not render. Shown as text.`]}),k&&T===null&&!je&&!C&&(!A||pe)&&(!M||pe)&&(0,j.jsx)(`div`,{className:`p-4`,children:(0,j.jsx)(ge,{code:k.content,path:e.path})})]}),D!==`idle`&&(0,j.jsxs)(`button`,{type:`button`,onClick:Fe,"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:[D===`streaming`?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,j.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,j.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,j.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function XE(e){return e.split(`
324
- `).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 ZE({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,j.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,j.jsx)(`span`,{className:`font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,12)}),(0,j.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`commit diff`}),(0,j.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,j.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,j.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed`,children:XE(e.patch).map((e,t)=>(0,j.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 QE=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],$E=`worktree`,eD={defaultWidth:288,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.files-sidebar-width.v1`},tD={defaultWidth:416,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.history-list-width.v1`};function nD(e,t){return Number.isFinite(e)?Math.min(t.maxWidth,Math.max(t.minWidth,Math.round(e))):t.defaultWidth}function rD(e,t){return e===null||e.trim()===``?t.defaultWidth:nD(Number(e),t)}function iD(e,t){try{return rD((t??window.localStorage).getItem(e.storageKey),e)}catch{return e.defaultWidth}}function aD(e,t,n){try{(n??window.localStorage).setItem(t.storageKey,String(nD(e,t)))}catch{}}function oD(e){let[t,n]=(0,d.useState)(()=>iD(e)),r=(0,d.useRef)(t),i=(0,d.useRef)(null),a=(0,d.useCallback)(t=>{let i=nD(t,e);return r.current=i,n(i),i},[e]),o=(0,d.useCallback)(()=>{i.current!==null&&(i.current=null,aD(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(),aD(a(n),e))}}}}function sD({label:e,width:t,config:n,separatorProps:r,className:i=``}){return(0,j.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,j.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 cD=`#10b981`,lD=[`#8b5cf6`,`#f59e0b`,`#0ea5e9`,`#f43f5e`,`#14b8a6`,`#d946ef`];function uD(e){return e===0?cD:lD[(e-1)%lD.length]}function dD(e){return lD[e%lD.length]}function fD(e){return e*14+7+1}function pD(e){return e*14+2}function mD({row:e,laneCount:t,colorOf:n=uD}){let r=pD(t),i=fD(e.lane),a=e.highlight?cD:n(e.lane),o=e.dashed?`3 3`:void 0;return(0,j.jsxs)(`svg`,{width:r,height:36,viewBox:`0 0 ${r} 36`,"aria-hidden":!0,className:`shrink-0`,children:[e.through.map(e=>(0,j.jsx)(`line`,{x1:fD(e),y1:0,x2:fD(e),y2:36,stroke:n(e),strokeWidth:2,opacity:.55},e)),e.lineAbove&&(0,j.jsx)(`line`,{x1:i,y1:0,x2:i,y2:18,stroke:a,strokeWidth:2,strokeDasharray:o}),e.lineBelow&&(0,j.jsx)(`line`,{x1:i,y1:18,x2:i,y2:36,stroke:a,strokeWidth:2,strokeDasharray:o}),e.forkTo.map(e=>(0,j.jsx)(`path`,{d:`M ${i} 18 C ${i} 36, ${fD(e)} 18, ${fD(e)} 36`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`fork-${e}`)),(e.mergeFrom??[]).map(e=>(0,j.jsx)(`path`,{d:`M ${i} 18 C ${i} 0, ${fD(e)} 18, ${fD(e)} 0`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`merge-${e}`)),e.emphasis===`current`?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`circle`,{cx:i,cy:18,r:6,fill:`none`,stroke:a,strokeWidth:2}),(0,j.jsx)(`circle`,{cx:i,cy:18,r:2.5,fill:a})]}):(0,j.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 hD(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:$E,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 gD=20;function _D(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 vD(e){return e.rev===`worktree`?`working tree`:e.rev.slice(0,7)}function yD(e,t){return e!==null&&t!==null&&e.rev===t.rev&&e.path===t.path}function bD(e){return{rev:e.rev,path:e.path}}function xD({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=oD(tD),{rows:h,laneCount:g}=(0,d.useMemo)(()=>hD(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||yD(c,l)||_.current.onFetchDiff(c,l)},[c,l]);let v=(0,d.useCallback)((e,t)=>{let n=bD(e);s(r=>{if(t===`base`)return{base:n,target:yD(n,r.target)?r.base:r.target};if(t===`target`)return{base:yD(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?bD(r):null,target:n}}return{base:yD(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=bD(e);return yD(t,c)?`base`:yD(t,l)?`target`:null},C=h.findIndex(e=>yD(bD(e),c)),w=h.findIndex(e=>yD(bD(e),l)),T=C>=0&&w>=0?{top:Math.min(C,w)*36+18,height:Math.abs(w-C)*36}:null;return(0,j.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,j.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,j.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-zinc-500 dark:text-zinc-400`,"aria-label":`Comparing ${vD(c)} to ${vD(l)}`,children:[(0,j.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:vD(c)}),` → `,(0,j.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:vD(l)})]}),c!==null&&l!==null&&(0,j.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,j.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,j.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,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,j.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,j.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,j.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`Reading history…`}),e.status===`error`&&(0,j.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,j.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,j.jsxs)(`div`,{className:`relative`,role:`group`,"aria-label":`Commits`,children:[T&&(0,j.jsx)(SD,{top:T.top,height:T.height,baseFirst:C<w}),h.map((e,t)=>(0,j.jsx)(TD,{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,j.jsx)(sD,{label:`Resize History commit list`,width:m.width,config:tD,separatorProps:m.separatorProps,className:`hidden md:block`})]}),(0,j.jsx)(`div`,{role:`region`,"aria-label":`History diff`,className:`min-h-0 min-w-0 flex-1 overflow-auto p-3`,children:(0,j.jsx)(ED,{diff:t,base:c,target:l})})]})]})}function SD({top:e,height:t,baseFirst:n}){return(0,j.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:gD},children:[(0,j.jsx)(`div`,{className:`absolute inset-y-0 left-2 w-px bg-zinc-400 dark:bg-zinc-500`}),(0,j.jsx)(CD,{label:n?`base`:`target`,className:`top-0`}),(0,j.jsx)(CD,{label:n?`target`:`base`,className:`bottom-0`})]})}function CD({label:e,className:t}){return(0,j.jsx)(`div`,{className:`absolute left-2 flex h-px w-2.5 items-center bg-zinc-400 dark:bg-zinc-500 ${t}`,children:(0,j.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 wD=`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 TD({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,j.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:gD},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,j.jsx)(mD,{row:e,laneCount:t}),s?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:s.sha.slice(0,7)}),(0,j.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,j.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-600`,children:[s.author,` · `,_D(s.date)]}),(0,j.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums`,"aria-label":`${s.added} lines added, ${s.deleted} removed`,children:[(0,j.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-500`,children:[`+`,s.added]}),` `,(0,j.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,s.deleted]})]})]}):(0,j.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`working tree`}),(0,j.jsxs)(`span`,{className:`flex shrink-0 gap-0.5`,children:[(0,j.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:wD,children:`base`}),(0,j.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:wD,children:`target`})]})]})}function ED({diff:e,base:t,target:n}){return t===null&&n===null?(0,j.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,j.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,j.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,j.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Loading…`}):e.status===`loaded`&&e.beforeText===e.afterText?(0,j.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,j.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions differ only in their line endings.`}):(0,j.jsx)(`div`,{className:e.status===`loading`?`opacity-40`:void 0,children:(0,j.jsx)(Oe,{fill:!0,lines:S(e.beforeText,e.afterText)})})}function DD(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 OD({status:e,log:t,onFetchLog:n,onShowCommit:r}){let[i,a]=(0,d.useState)(!1),o=pE(()=>a(!1)),s=e&&(e.ahead>0||e.behind>0)?` ${e.ahead>0?`↑${e.ahead}`:``}${e.behind>0?`↓${e.behind}`:``}`:``;return(0,j.jsxs)(`div`,{className:`relative`,ref:o,children:[(0,j.jsxs)(`button`,{type:`button`,onClick:()=>{a(!i),i||n()},title:`git history`,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 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:[`⎇ `,e?.branch??`…`,s]}),i&&(0,j.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:[t===null&&(0,j.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),t?.length===0&&(0,j.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no commits`}),t?.map(e=>(0,j.jsxs)(`button`,{type:`button`,onClick:()=>{r(e.sha),a(!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,j.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,7)}),(0,j.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-700 dark:text-zinc-300`,title:e.subject,children:e.subject}),(0,j.jsxs)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:[e.author,` · `,DD(e.date)]})]},e.sha))]})]})}function kD({label:e,browse:t,onBrowse:n,onSelect:r,onCancel:i}){let a=t?.path??`/`,o=t?.entries??[],s=t?.status===`loading`;return(0,j.jsxs)(`div`,{className:`rounded-md border border-zinc-300 p-2 dark:border-zinc-700`,"data-testid":`server-path-picker`,children:[(0,j.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,j.jsx)(`span`,{className:`text-xs font-semibold text-zinc-600 dark:text-zinc-300`,children:e}),(0,j.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,j.jsx)(`p`,{className:`mb-2 break-all font-mono text-[11px] text-zinc-500 dark:text-zinc-400`,"data-testid":`picker-path`,children:a}),t?.status===`error`&&(0,j.jsx)(`p`,{role:`alert`,className:`mb-2 text-xs text-red-600 dark:text-red-400`,children:t.error}),(0,j.jsxs)(`div`,{className:`mb-2 flex gap-2`,children:[(0,j.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,j.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,j.jsxs)(`ul`,{className:`max-h-40 overflow-y-auto`,children:[s&&o.length===0&&(0,j.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400`,children:`Loading…`}),!s&&o.length===0&&t?.status!==`error`&&(0,j.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No subdirectories`}),o.map(e=>(0,j.jsx)(`li`,{children:(0,j.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 AD({extensionPaths:e,tools:t,commands:n,sandbox:r,userSkillPaths:i,serverBrowse:a,applyState:o,versions:s,onBrowseServerPath:c,onCloseServerBrowser:l,onUpdateConfig:u}){let[f,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(``),[g,_]=(0,d.useState)(``),[v,y]=(0,d.useState)(!1),[b,x]=(0,d.useState)(!1),[S,C]=(0,d.useState)(i),[w,T]=(0,d.useState)(null),E=pE(()=>ie()),ee=t.filter(e=>e.active),D=t.filter(e=>!e.active),O=n.filter(e=>e.source===`skill`),te=o?.status===`applying`,ne=o?.status===`error`?o.message:null;(0,d.useEffect)(()=>{r&&(h(r.root),_(r.writableRoot??``),y(r.allowWrite),x(r.allowBash))},[r]),(0,d.useEffect)(()=>{C(i)},[i]);let re=(0,d.useRef)(!1);(0,d.useEffect)(()=>{re.current&&o===null&&ie(),re.current=te},[o,te]);function ie(){p(!1),T(null),l()}function ae(e,t){T(e),c(t.trim()||`/`)}function oe(e){w===`root`?h(e):w===`writableRoot`?_(e):w===`skill`&&!S.includes(e)&&C([...S,e]),T(null),l()}function k(){let e=r?{root:m,allowWrite:v,allowBash:b,writableRoot:g.trim()||void 0}:void 0;u({...e?{sandbox:e}:{},userSkillPaths:S})}let A=w!==null&&(0,j.jsx)(kD,{label:w===`skill`?`Choose a skills directory`:w===`root`?`Choose the sandbox root`:`Choose the writable root`,browse:a,onBrowse:c,onSelect:oe,onCancel:()=>{T(null),l()}});return(0,j.jsxs)(`div`,{className:`relative`,ref:E,children:[(0,j.jsx)(`button`,{type:`button`,onClick:()=>p(!f),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:`⚙`}),f&&(0,j.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,j.jsx)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,j.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Settings`})}),(0,j.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:[(0,j.jsxs)(`section`,{className:`mb-4`,children:[(0,j.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Agent resources`}),t.length===0?(0,j.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`Tool inventory unavailable for this runtime`}):(0,j.jsxs)(`details`,{children:[(0,j.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[ee.length,` tools active`,D.length?` · ${D.length} inactive`:``]}),(0,j.jsx)(`ul`,{className:`mt-2 space-y-1`,children:t.map(e=>(0,j.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,j.jsx)(`span`,{children:e.name}),(0,j.jsx)(`span`,{children:e.active?`active`:`inactive`})]},e.name))})]}),O.length===0?(0,j.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skills loaded`}):(0,j.jsxs)(`details`,{className:`mt-2`,children:[(0,j.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[O.length,` skills loaded`]}),(0,j.jsx)(`ul`,{className:`mt-2 space-y-1`,children:O.map(e=>(0,j.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.name},e.name))})]}),(0,j.jsxs)(`div`,{className:`mt-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsx)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:`User skill paths`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>ae(`skill`,S[S.length-1]??`/`),className:`rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-600 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-300`,children:`Add directory…`})]}),S.length===0?(0,j.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skill directories added`}):(0,j.jsx)(`ul`,{className:`mt-1 space-y-1`,children:S.map(e=>(0,j.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded bg-zinc-50 px-2 py-1 dark:bg-zinc-800`,children:[(0,j.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-600 dark:text-zinc-400`,title:e,children:e}),(0,j.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:()=>C(S.filter(t=>t!==e)),className:`shrink-0 text-xs text-zinc-500 hover:text-red-600 dark:text-zinc-400 dark:hover:text-red-400`,children:`Remove`})]},e))}),w===`skill`&&(0,j.jsx)(`div`,{className:`mt-2`,children:A})]})]}),(0,j.jsxs)(`section`,{className:`mb-4`,children:[(0,j.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),e.length===0?(0,j.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,j.jsx)(`ul`,{className:`space-y-1`,children:e.map((e,t)=>(0,j.jsx)(`li`,{className:`rounded bg-zinc-50 px-2 py-1 text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},t))})]}),r&&(0,j.jsxs)(`section`,{children:[(0,j.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Sandbox`}),(0,j.jsxs)(`div`,{className:`space-y-3`,children:[(0,j.jsxs)(`label`,{className:`block`,children:[(0,j.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,r.locks?.root?(0,j.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,j.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,j.jsx)(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),disabled:r.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,j.jsx)(`button`,{type:`button`,"aria-label":`Browse for sandbox root`,disabled:r.locks?.root,onClick:()=>ae(`root`,m),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…`})]})]}),w===`root`&&A,(0,j.jsxs)(`label`,{className:`block`,children:[(0,j.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,r.locks?.writableRoot?(0,j.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,j.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,j.jsx)(`input`,{type:`text`,value:g,onChange:e=>_(e.target.value),disabled:r.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,j.jsx)(`button`,{type:`button`,"aria-label":`Browse for writable root`,disabled:r.locks?.writableRoot,onClick:()=>ae(`writableRoot`,g||m),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…`})]})]}),w===`writableRoot`&&A,(0,j.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:v,onChange:e=>y(e.target.checked),disabled:r.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,j.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,r.locks?.allowWrite?(0,j.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,j.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked),disabled:r.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,j.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,r.locks?.allowBash?(0,j.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]})]})]}),!r&&(0,j.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),(0,j.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[ne&&(0,j.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:ne}),(0,j.jsx)(`button`,{type:`button`,disabled:te||r!==null&&!m.trim(),onClick:k,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:te?`Applying…`:`Apply & restart session`}),(0,j.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.`})]}),s&&(0,j.jsxs)(`section`,{className:`mt-4`,children:[(0,j.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,j.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,j.jsxs)(`p`,{children:[`pi-outpost: `,(0,j.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:s.piOutpost})]}),s.piSdk&&(0,j.jsxs)(`p`,{children:[`pi SDK: `,(0,j.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:s.piSdk})]}),s.agent&&(0,j.jsxs)(`p`,{children:[`agent: `,(0,j.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:s.agent})]})]})]})]})]})]})}function jD(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 MD(e){return e.flatMap(e=>[e,...MD(e.children)])}function ND({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,j.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var PD=`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 FD({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:o}=e,s=o.tipId??o.entryId;return(0,j.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,j.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,j.jsx)(mD,{row:e,laneCount:t,colorOf:dD}),(0,j.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,j.jsxs)(ND,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,j.jsxs)(ND,{tone:`branch`,children:[`branch `,e.branchIndex,o.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,j.jsx)(ND,{tone:`current`,children:`current`}),o.label&&(0,j.jsx)(ND,{tone:`label`,children:o.label})]}),(0,j.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:PD,children:`↺ redo`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>{i(o.entryId),a()},title:`fork a new session from this point`,className:PD,children:`⑂ fork`})]})}function ID({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:i}){let[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(``),l=pE(()=>o(!1));(0,d.useEffect)(()=>{a&&e===null&&n()},[a,e]);let u=(0,d.useMemo)(()=>e&&e.length>0?jD(e):null,[e]),f=(0,d.useMemo)(()=>{if(!e||!s.trim())return null;let t=s.trim().toLowerCase();return MD(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,s]);return(0,j.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,j.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,j.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,j.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,j.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&u&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,j.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,j.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,j.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,j.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,j.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,j.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:f===null?u.rows.map(e=>(0,j.jsx)(FD,{row:e,laneCount:u.laneCount,isStreaming:t,onNavigate:r,onFork:i,onClose:()=>o(!1)},e.node.entryId)):f.length===0?(0,j.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):f.map(e=>(0,j.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,j.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,j.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,j.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,j.jsx)(ND,{tone:`current`,children:`on current branch`}),e.label&&(0,j.jsx)(ND,{tone:`label`,children:e.label})]}),(0,j.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:PD,children:`↺ redo`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>{i(e.entryId),o(!1)},title:`fork a new session from this point`,className:PD,children:`⑂ fork`})]},e.entryId))})]})]})]})}var LD=200;function RD({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,d.useState)(e);return(0,j.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 zD({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:o,onCancelRename:s}){return n?(0,j.jsx)(`div`,{className:`px-3 py-2`,children:(0,j.jsx)(RD,{initial:e.name??``,onCommit:o,onCancel:s})}):(0,j.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,j.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,j.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,j.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,j.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`:``]})]}),(0,j.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&&(0,j.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 BD({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=pE(()=>u(!1)),_=f.trim(),v=_.length>=2;(0,d.useEffect)(()=>{if(!l)return;if(!v){c();return}let e=setTimeout(()=>s(_),LD);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,j.jsxs)(`div`,{className:`relative`,ref:g,children:[(0,j.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,j.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,j.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,j.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,j.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,j.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[x===null&&(0,j.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),x?.length===0&&(0,j.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:v?`no matches`:`no saved sessions`}),x?.map(e=>(0,j.jsx)(zD,{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 VD({theme:e,onToggle:t}){return(0,j.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 HD(e){let{isStreaming:t,connected:n}=e;return(0,j.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:[(0,j.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`]}),e.gitAvailable&&(0,j.jsx)(OD,{status:e.gitStatus,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,j.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,j.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:LE(t)},e)),(0,j.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:e.onToggleHideTools,title:e.hideTools?`Show tool cards in the conversation`:`Hide tool cards (long sessions read better without them)`,"aria-pressed":e.hideTools,className:`rounded-md border px-2 py-1 text-xs ${e.hideTools?`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:`⚒ tools`}),e.showThemeToggle&&(0,j.jsx)(VD,{theme:e.theme,onToggle:e.onToggleTheme}),(0,j.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,j.jsx)(ID,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,j.jsx)(BD,{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,j.jsx)(AD,{extensionPaths:e.extensionPaths,tools:e.tools??[],commands:e.commands??[],sandbox:e.sandbox,userSkillPaths:e.userSkillPaths,serverBrowse:e.serverBrowse,applyState:e.settingsApply,versions:e.versions,onBrowseServerPath:e.onBrowseServerPath,onCloseServerBrowser:e.onCloseServerBrowser,onUpdateConfig:e.onUpdateConfig}),(0,j.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function UD(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 WD({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,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`span`,{children:[uT(e.totalTokens),` tok`]}),r>0&&(0,j.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:[lT(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,j.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,j.jsx)(`span`,{title:i,className:`${o} border-zinc-300 dark:border-zinc-800`,children:a})}function GD({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,j.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 36 36`,className:`-rotate-90 shrink-0`,children:[(0,j.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,j.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${i} ${n-i}`,className:UD(e)})]})}function KD({thinkingLevel:e,isStreaming:t,onSetThinking:n}){let[r,i]=(0,d.useState)(!1),a=(0,d.useRef)(null),o=e!==`off`,s=Math.max(0,QE.indexOf(e));return(0,d.useEffect)(()=>{if(!r)return;function e(e){a.current&&!fE(e,a.current)&&i(!1)}function t(e){e.key===`Escape`&&i(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]),(0,j.jsxs)(`div`,{className:`relative`,ref:a,children:[(0,j.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),disabled:t,title:`thinking level`,"aria-haspopup":`true`,"aria-expanded":r,className:`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs disabled:opacity-50 ${o?`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,j.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none ${o?``:`opacity-40 grayscale`}`,children:`🧠`}),e]}),r&&(0,j.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,j.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between text-xs`,children:[(0,j.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`thinking`}),(0,j.jsx)(`span`,{className:`font-mono text-zinc-700 dark:text-zinc-200`,children:e})]}),(0,j.jsx)(`input`,{type:`range`,min:0,max:QE.length-1,step:1,value:s,onChange:e=>n(QE[Number(e.target.value)]),"aria-label":`Thinking level`,"aria-valuetext":e,className:`w-full accent-amber-500`}),(0,j.jsxs)(`div`,{className:`mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,children:[(0,j.jsx)(`span`,{children:QE[0]}),(0,j.jsx)(`span`,{children:QE[QE.length-1]})]})]})]})}function qD(e){let{model:t,models:n,thinkingLevel:r,modelSupportsReasoning:i,isStreaming:a,contextUsage:o,sessionUsage:s,isCompacting:c}=e;return(0,j.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,j.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,j.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,j.jsxs)(`option`,{value:`${e.provider}/${e.id}`,children:[e.provider,`/`,e.id]},`${e.provider}/${e.id}`))]}),i&&(0,j.jsx)(KD,{thinkingLevel:r,isStreaming:a,onSetThinking:e.onSetThinking}),(0,j.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,j.jsx)(GD,{usage:o}),c?`compacting…`:o?.percent==null?`context`:`${Math.round(o.percent)}%`]}),(0,j.jsx)(WD,{usage:s,analysisOpen:e.analysisOpen,onToggleAnalysis:e.onToggleAnalysis})]})}var JD=`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`,YD=`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`;function XD({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),C=a.some(e=>e.configured)&&!t.usableModel;function w(e){if(e.preventDefault(),!C){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,j.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto p-6`,children:(0,j.jsxs)(`form`,{onSubmit:w,className:`w-full max-w-md rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,j.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),C?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`h1`,{className:`mb-3 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model is available.`}),(0,j.jsxs)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:[`Credentials are configured, so this is not a missing key: `,(0,j.jsx)(`code`,{children:`allowedModels`}),` in your configuration leaves nothing to choose from. Widen it, or remove it, then restart.`]})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.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,j.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,j.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,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`label`,{htmlFor:`onboarding-provider`,className:YD,children:`Provider`}),(0,j.jsx)(`select`,{id:`onboarding-provider`,value:c,onChange:e=>l(e.target.value),className:`${JD} mb-3`,children:a.map(e=>(0,j.jsxs)(`option`,{value:e.id,children:[e.name,e.configured?` (already configured)`:``]},e.id))})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`label`,{htmlFor:`onboarding-name`,className:YD,children:`Name`}),(0,j.jsx)(`input`,{id:`onboarding-name`,value:p,onChange:e=>m(e.target.value),placeholder:`corp`,className:`${JD} mb-3`}),(0,j.jsx)(`label`,{htmlFor:`onboarding-url`,className:YD,children:`Base URL`}),(0,j.jsx)(`input`,{id:`onboarding-url`,value:h,onChange:e=>g(e.target.value),placeholder:`https://llm.corp.example/v1`,className:`${JD} mb-3`}),(0,j.jsx)(`label`,{htmlFor:`onboarding-model`,className:YD,children:`Model id`}),(0,j.jsx)(`input`,{id:`onboarding-model`,value:_,onChange:e=>v(e.target.value),placeholder:`gpt-oss-120b`,className:`${JD} mb-3`})]}),(0,j.jsx)(`label`,{htmlFor:`onboarding-key`,className:YD,children:`API key`}),(0,j.jsx)(`input`,{id:`onboarding-key`,type:`password`,autoComplete:`off`,value:u,onChange:e=>f(e.target.value),placeholder:`sk-…`,className:JD}),o===`custom`&&(0,j.jsxs)(`fieldset`,{className:`mt-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,j.jsx)(`legend`,{className:`px-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Compatibility`}),(0,j.jsxs)(`label`,{className:`flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5`}),(0,j.jsxs)(`span`,{children:[`Server understands the `,(0,j.jsx)(`code`,{children:`developer`}),` role. Uncheck for vLLM, SGLang and most corporate gateways — the system prompt is then sent as a `,(0,j.jsx)(`code`,{children:`system`}),` message.`]})]}),(0,j.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`mt-0.5`}),(0,j.jsxs)(`span`,{children:[`Server accepts `,(0,j.jsx)(`code`,{children:`reasoning_effort`}),`. Uncheck if it rejects unknown fields.`]})]})]}),(0,j.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,j.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,j.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,j.jsx)(`code`,{children:`pi-outpost login`}),`.`]})]})})}var ZD=`application/x-pi-outpost-file`,QD=`application/x-pi-outpost-read-only-file`,$D=`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`,eO={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 tO(e,t){return t?Object.keys(t).filter(t=>t.startsWith(`${e}/`)).length:0}function nO(e){return e===`directory`||e===`symlink-directory`}function rO(e,t){return t===void 0?!1:t===null||t!==``&&e!==t&&!e.startsWith(`${t}/`)}function iO({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,j.jsxs)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5`,children:[(0,j.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,j.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:o})]})}function aO({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,j.jsxs)(`div`,{style:{paddingLeft:n*12+16},className:`py-0.5`,children:[(0,j.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,j.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:s})]})}function oO({path:e,depth:t,...n}){let r=n.tree[e],i=n.creation?.openIn===e?(0,j.jsx)(iO,{dir:e,depth:t,creation:n.creation}):null;return r===void 0?i:r===`loading`?(0,j.jsxs)(j.Fragment,{children:[i,(0,j.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,j.jsxs)(j.Fragment,{children:[i,(0,j.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,j.jsxs)(j.Fragment,{children:[i,i===null&&(0,j.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`empty`})]}):(0,j.jsxs)(j.Fragment,{children:[i,r.map(r=>(0,j.jsx)(sO,{parentPath:e,entry:r,depth:t,...n},r.name))]})}function sO({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=rO(c,r.writableRoot),u=r.fileOperation?.status===`pending`;if(nO(t.type)){let e=!l&&!u,d=e=>e.includes(QD)?r.onCopyFile===void 0?null:`copy`:r.onMoveFile===void 0?null:`move`;return(0,j.jsxs)(`div`,{children:[(0,j.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(ZD))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(ZD),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,j.jsxs)(`button`,{type:`button`,onClick:()=>{let e=!i;a(e),e&&r.tree[c]===void 0&&r.onExpand(c)},style:{paddingLeft:n*12},className:`flex min-w-0 flex-1 items-center gap-1 rounded py-0.5 text-left`,children:[(0,j.jsx)(`span`,{className:`w-3 shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:i?`▾`:`▸`}),(0,j.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&&tO(c,r.gitFiles)>0&&(0,j.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:`${tO(c,r.gitFiles)} changed file(s) inside`,children:tO(c,r.gitFiles)})]}),r.creation&&!l&&(0,j.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,j.jsx)(oO,{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,j.jsx)(aO,{path:c,name:t.name,depth:n,rename:r.rename}):(0,j.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,j.jsx)(`button`,{type:`button`,draggable:v&&!u,onDragStart:e=>{!v||u||(e.dataTransfer.effectAllowed=l?`copy`:`move`,e.dataTransfer.setData(ZD,c),l&&e.dataTransfer.setData(QD,`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,j.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,j.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:$D,children:`↗`}),_&&r.onRenameFile&&(0,j.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>r.rename?.start(c),title:`Rename file`,"aria-label":`Rename ${t.name}`,className:$D,children:`✎`}),_&&r.onDeleteFile&&(0,j.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:`${$D} hover:text-red-600 dark:hover:text-red-400`,children:`×`}),r.onToggleAttachPath&&(0,j.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,j.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 ${eO[p].className}`,children:eO[p].label})]})}function cO(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 lO(e){let t=cO(e);return`error`in t?t:t.kind===`directory`?{error:`That is a folder name`}:{name:t.name}}function uO(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===dO(a.dir,a.name)?e.createError.message:null,g=e.created??null;(0,d.useEffect)(()=>{a!==null&&g!==null&&g===dO(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=cO(n);if(`error`in r){i(r.error);return}i(null),o({dir:t,name:r.name});let a=dO(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=lO(n);if(`error`in r){u(r.error);return}u(null),p(t),e.onRenameFile?.(t,r.name)}}:void 0,b=!rO(``,e.writableRoot);return(0,j.jsxs)(`div`,{className:`text-sm`,children:[e.fileOperation?.status===`error`&&e.fileOperation.operation!==`rename_file`&&(0,j.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,j.jsxs)(`div`,{className:`mb-1 flex items-center`,children:[v&&b&&(0,j.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,j.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,j.jsx)(oO,{path:``,depth:0,...e,...v?{creation:v}:{},...y?{rename:y}:{}})]})}function dO(e,t){return e===``?t:`${e}/${t}`}function fO({tree:e,openFile:t,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onRefresh:o,onSelectFile:s,onSelectDiff:c,onToggleAttachPath:l,onCreateFile:u,onCreateDirectory:f,onOpenNative:p,onRenameFile:m,onDeleteFile:h,onMoveFile:g,onCopyFile:_,fileOperation:v,createError:y,created:b}){let x=oD(eD);return(0,d.useEffect)(()=>{e[``]===void 0&&a(``)},[]),(0,j.jsxs)(`aside`,{"aria-label":`Files`,style:{width:x.width},className:`relative flex shrink-0 flex-col border-r border-zinc-200 dark:border-zinc-800`,children:[(0,j.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,j.jsx)(`div`,{className:`flex-1 overflow-auto p-2`,children:(0,j.jsx)(uO,{tree:e,openFilePath:t?.path,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onRefresh:o,onSelectFile:s,onSelectDiff:c,onToggleAttachPath:l,onCreateFile:u,onCreateDirectory:f,onOpenNative:p,onRenameFile:m,onDeleteFile:h,onMoveFile:g,onCopyFile:_,fileOperation:v,createError:y,created:b})}),(0,j.jsx)(sD,{label:`Resize Files sidebar`,width:x.width,config:eD,separatorProps:x.separatorProps})]})}function pO({title:e,onSubmit:t}){let[n,r]=(0,d.useState)(``);return(0,j.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,j.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,j.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),(0,j.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`This server requires an access token.`}),(0,j.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,j.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,j.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,j.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,j.jsx)(`code`,{children:`?token=…`})]})]})})}var mO={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`}},hO=8;function gO(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 _O({plan:e,open:t,onToggle:n,onOpenWorkspace:r}){let i=(0,d.useId)(),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(null);(0,d.useEffect)(()=>{s!==null&&!e.tasks.some(e=>e.id===s)&&c(null)},[e,s]),(0,d.useEffect)(()=>{if(!a)return;let e=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]);let l=(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]),u=(0,d.useMemo)(()=>new Map(e.tasks.map(e=>[e.id,e])),[e.tasks]),f=(0,d.useMemo)(()=>{let e=[],t=(n,r)=>{for(let i of l.get(n)??[])e.push({task:i,depth:r}),t(i.id,r+1)};return t(void 0,0),e.slice(0,hO)},[l]),p=s?u.get(s):void 0,m=e.tasks.filter(e=>e.status===`done`).length,h=(e,t=0)=>(l.get(e)??[]).flatMap(e=>{let n=mO[e.status];return[(0,j.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-level":t+1,"aria-selected":s===e.id,onClick:()=>c(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 ${s===e.id?`bg-zinc-100 dark:bg-zinc-800`:``}`,style:{paddingLeft:`${.5+t*.85}rem`},children:[(0,j.jsx)(`span`,{className:`mt-px w-4 shrink-0 text-center font-semibold ${n.className}`,"aria-label":n.label,children:n.icon}),(0,j.jsx)(`span`,{className:e.status===`done`?`text-zinc-500 line-through`:`text-zinc-800 dark:text-zinc-200`,children:e.title})]},e.id),...h(e.id,t+1)]});return t?(0,j.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,j.jsxs)(`header`,{className:`border-b border-zinc-200 px-3 py-3 dark:border-zinc-800`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-zinc-500`,children:`Work Plan`}),(0,j.jsx)(`h2`,{className:`truncate text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:e.title})]}),(0,j.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,j.jsxs)(`div`,{className:`mt-2 text-xs text-zinc-500`,children:[`Progress: `,m,` / `,e.tasks.length]}),(0,j.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-800`,"aria-hidden":!0,children:(0,j.jsx)(`div`,{className:`h-full bg-emerald-500`,style:{width:`${e.tasks.length===0?0:m/e.tasks.length*100}%`}})})]}),(0,j.jsx)(`div`,{role:`tree`,"aria-label":`Work Plan tasks`,className:`min-h-0 flex-1 overflow-y-auto p-2`,children:h(void 0)}),p&&(0,j.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,j.jsx)(`div`,{className:`font-semibold ${mO[p.status].className}`,children:mO[p.status].label}),(0,j.jsx)(`h3`,{className:`mt-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:p.title}),p.description&&(0,j.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-zinc-600 dark:text-zinc-300`,children:p.description}),p.statusReason&&(0,j.jsx)(`p`,{className:`mt-2 rounded bg-zinc-100 p-2 text-zinc-700 dark:bg-zinc-900 dark:text-zinc-300`,children:p.statusReason}),p.dependsOn.length>0&&(0,j.jsxs)(`div`,{className:`mt-3`,children:[(0,j.jsx)(`span`,{className:`font-semibold`,children:`Depends on:`}),` `,p.dependsOn.map(e=>u.get(e)?.title??e).join(`, `)]}),p.resources.length>0&&(0,j.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,j.jsx)(`div`,{className:`font-semibold`,children:`Resources`}),p.resources.map(e=>{let t=gO(e),n=e.label??e.uri;return t===null?/^https?:/i.test(e.uri)?(0,j.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,j.jsx)(`span`,{className:`block truncate text-zinc-500`,title:`No navigator is available for this resource`,children:n},e.uri):(0,j.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,j.jsxs)(`div`,{className:`absolute right-3 top-3 z-20`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocusCapture:()=>o(!0),onBlurCapture:()=>o(!1),children:[(0,j.jsxs)(`button`,{type:`button`,onClick:()=>{o(!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":i,children:[`Plan `,m,`/`,e.tasks.length]}),(0,j.jsx)(`div`,{id:i,role:`tooltip`,className:`absolute right-0 top-full w-72 pt-2 ${a?`block`:`hidden`}`,children:(0,j.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,j.jsx)(`ul`,{className:`space-y-1`,children:f.map(({task:e,depth:t})=>(0,j.jsxs)(`li`,{className:`flex min-w-0 items-start gap-1.5 text-xs`,style:{paddingLeft:`${t*.75}rem`},children:[(0,j.jsx)(`span`,{"aria-label":mO[e.status].label,className:`shrink-0 font-semibold ${mO[e.status].className}`,children:e.status===`done`?`☑`:`☐`}),(0,j.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>f.length&&(0,j.jsxs)(`div`,{className:`mt-1 text-[11px] text-zinc-500`,children:[`+`,e.tasks.length-f.length,` more`]})]})})]})}var vO=`pi-outpost:token`;function yO(){let e=null;try{let t=new URL(window.location.href);return e=t.searchParams.get(`token`),e&&(localStorage.setItem(vO,e),t.searchParams.delete(`token`),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)),localStorage.getItem(vO)}catch{return e}}function bO(){try{return localStorage.getItem(vO)}catch{return null}}function xO(e){try{localStorage.setItem(vO,e)}catch{}}function SO(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function CO(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}var wO={connected:!1,authRequired:!1,brandingReady:!1,branding:{},sessionId:``,model:``,thinkingLevel:`off`,modelSupportsReasoning:!1,models:[],commands:[],sessions:null,sessionSearch:null,tree:null,isStreaming:!1,items:[],pendingPrompt:null,workPlan: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:[],tools:[],sandbox:null,userSkillPaths:[],serverBrowse:null,settingsApply:null,versions:null,gitAvailable:!1,credentials:null,gitStatus:null,gitDiff:null,gitLog:null,gitShow:null,gitFileHistory:null,gitFileDiff:null};function TO(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 EO(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 DO(e,t){if(t.type!==`hello`&&t.type!==`session_replaced`&&t.type!==`update_config_ack`)return e;let n=t.models.find(e=>`${e.provider}/${e.id}`===t.model);return{...e,connected:!0,brandingReady:!0,branding:t.branding,sessionId:t.sessionId,model:t.model,thinkingLevel:t.thinkingLevel,modelSupportsReasoning:n?.reasoning??!1,models:t.models,commands:t.commands,isStreaming:t.isStreaming,items:t.items,pendingPrompt:null,workPlan:t.workPlan??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,gitAvailable:t.gitAvailable===!0,credentials:t.credentials??null,extensionPaths:t.extensionPaths??[],tools:t.tools??[],sandbox:t.sandbox??null,userSkillPaths:t.userSkillPaths??[],serverBrowse:null,settingsApply:null,versions:t.versions??null}}function OO(e,t){if(t.type===`connected`)return{...e,connected:!0,authRequired:!1};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;return{...e,connected:!1,openFile:n}}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===`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`}};let n=t.message;switch(n.type){case`hello`:case`session_replaced`:case`update_config_ack`:return DO(e,n);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};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,credentials:n.credentials}}case`thinking_changed`:return{...e,thinkingLevel:n.level};case`work_plan_changed`:return{...e,workPlan:n.workPlan};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:TO(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:TO(e.items,()=>n.item)};case`custom_message`:return{...e,items:[...e.items,n.item]};case`tool_start`:return{...e,items:EO(e.items,n.toolCallId,n.toolName,{toolName:n.toolName,args:n.args,running:!0,callHtml:n.callHtml})};case`tool_update`:return{...e,items:EO(e.items,n.toolCallId,`tool`,{output:n.text})};case`tool_end`:return{...e,items:EO(e.items,n.toolCallId,`tool`,{output:n.text,isError:n.isError,running:!1,outputHtml:n.outputHtml,outputHtmlCollapsed:n.outputHtmlCollapsed,structured:n.structured})};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;return{...e,gitStatus:{branch:n.branch,ahead:n.ahead,behind:n.behind,files:t}}}case`git_diff`:return{...e,gitDiff:{path:n.path,before:n.before,after:n.after}};case`git_log`:return{...e,gitLog: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||!CO(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 kO(e,t){let n=e?`${e.replace(/^http/,`ws`)}/ws`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/ws`;return t?`${n}?token=${encodeURIComponent(t)}`:n}var AO=12e4,jO=4401;function MO(e=``,t,n=!1){let[r,i]=(0,d.useReducer)(OO,wO),a=(0,d.useRef)(null),[o,s]=(0,d.useState)(0),c=(0,d.useRef)(null);o===0&&c.current===null&&(c.current=t??(n?bO():yO()));let l=(0,d.useRef)(r.fileTree),u=(0,d.useRef)(r.openFile);(0,d.useEffect)(()=>{l.current=r.fileTree},[r.fileTree]),(0,d.useEffect)(()=>{u.current=r.openFile},[r.openFile]);let f=(0,d.useRef)(null);(0,d.useEffect)(()=>{f.current=r.gitDiff?.path??null},[r.gitDiff]);let p=(0,d.useRef)(new Map),m=(0,d.useRef)(r.writableRoot);(0,d.useEffect)(()=>{m.current=r.writableRoot},[r.writableRoot]);let h=(0,d.useCallback)(e=>{let t=a.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[]),g=(0,d.useCallback)((e,t=!1)=>{let n=`dir:${crypto.randomUUID()}`;i({type:`dir_list_started`,path:e,requestId:n,preserveEntries:t}),h({type:`list_directory`,path:e,requestId:n})},[h]),_=(0,d.useRef)(!1),v=(0,d.useRef)(!1),y=(0,d.useRef)(!1),b=(0,d.useCallback)(()=>{if(_.current){if(v.current){y.current=!0;return}v.current=!0,h({type:`git_status`,requestId:`git:${crypto.randomUUID()}`})}},[h]),x=(0,d.useCallback)(()=>{v.current=!1,y.current&&(y.current=!1,b())},[b]),S=(0,d.useCallback)(e=>{l.current[e]!==void 0&&g(e,!0)},[g]),C=(0,d.useCallback)(()=>{for(let e of Object.keys(l.current))S(e)},[S]);return(0,d.useEffect)(()=>{let t=!1;return fetch(`${e}/branding`,{headers:c.current?{Authorization:`Bearer ${c.current}`}:{}}).then(e=>e.ok?e.json():null).then(e=>{t||i(e?{type:`branding_loaded`,branding:e}:{type:`branding_settled`})}).catch(()=>{t||i({type:`branding_settled`})}),()=>{t=!0}},[e,o]),(0,d.useEffect)(()=>{let t,n=!1;function r(){let o=new WebSocket(kO(e,c.current));a.current=o,o.onopen=()=>{a.current===o&&i({type:`connected`})},o.onmessage=e=>{if(a.current!==o)return;let t;try{t=JSON.parse(e.data)}catch{return}if(t.type===`file_uploaded`){let e=p.current.get(t.requestId);e&&(p.current.delete(t.requestId),e.resolve(t.path));return}if(t.type===`file_browser_error`&&p.current.has(t.requestId)){let e=p.current.get(t.requestId);p.current.delete(t.requestId),e.reject(new UT(t.message,t.reason));return}if(t.type===`file_changed`){S(SO(t.path));let e=u.current;if(e?.status===`loaded`&&e.path===t.path){let e=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:t.path,requestId:e,preserveContent:!0}),h({type:`read_file`,path:t.path,requestId:e})}f.current===t.path&&h({type:`git_diff`,path:t.path,requestId:`gitdiff:${crypto.randomUUID()}`}),b();return}if(t.type===`directory_changed`){S(t.path);let e=u.current;if(e!==null&&SO(e.path)===t.path){if(re(e.path)||ie(e.path))i({type:`raw_preview_changed`,path:e.path});else if(e.status===`loaded`){let t=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:e.path,requestId:t,preserveContent:!0}),h({type:`read_file`,path:e.path,requestId:t})}}let n=f.current;n!==null&&SO(n)===t.path&&h({type:`git_diff`,path:n,requestId:`gitdiff:${crypto.randomUUID()}`}),b();return}if((t.type===`hello`||t.type===`session_replaced`)&&(_.current=t.gitAvailable===!0,t.type===`hello`&&b()),t.type===`agent_end`&&b(),(t.type===`git_status`||t.type===`git_error`&&t.requestId.startsWith(`git:`))&&x(),t.type===`file_operation_result`){let e=t.previousPath??t.path,n=u.current;t.operation===`delete_file`&&n?.path===t.path?u.current=null:n?.path===e&&(u.current={...n,path:t.path})}i({type:`server`,message:t}),t.type===`session_replaced`&&g(``)},o.onclose=e=>{if(a.current===o){v.current=!1,y.current=!1;for(let e of p.current.values())e.reject(new UT(`The connection dropped before the upload finished`));if(p.current.clear(),e.code===jO){i({type:`auth_required`});return}i({type:`disconnected`}),n||(t=window.setTimeout(r,1500))}}}return r(),()=>{n=!0,t!==void 0&&clearTimeout(t);let e=a.current;a.current=null,e?.close()}},[h,e,b,x,S,g,o]),{state:r,authToken:c.current,submitToken:e=>{xO(e),c.current=e,i({type:`auth_retrying`}),s(e=>e+1)},prompt:(e,t)=>{i({type:`prompt_sent`,text:e,...t?.length?{images:t}:{}}),h({type:`prompt`,text:e,...t?.length?{images:t}:{}})},abort:()=>h({type:`abort`}),setModel:(e,t)=>h({type:`set_model`,provider:e,id:t}),setThinking:e=>h({type:`set_thinking`,level:e}),newSession:()=>h({type:`new_session`}),switchSession:e=>h({type:`switch_session`,path:e}),deleteSession:e=>h({type:`delete_session`,path:e}),listSessions:()=>h({type:`list_sessions`}),renameSession:(e,t)=>h({type:`rename_session`,path:e,name:t}),searchSessions:e=>{let t=`sessions:${crypto.randomUUID()}`;i({type:`session_search_started`,query:e,requestId:t}),h({type:`search_sessions`,query:e,requestId:t})},clearSessionSearch:()=>i({type:`session_search_cleared`}),listTree:()=>h({type:`list_tree`}),navigateTree:e=>h({type:`navigate_tree`,entryId:e}),forkSession:e=>h({type:`fork_session`,entryId:e}),editPrompt:(e,t,n)=>h({type:`edit_prompt`,entryId:e,text:t,...n?.length?{images:n}:{}}),compact:()=>h({type:`compact`}),respondToDialog:e=>{h({type:`extension_ui_response`,...e}),i({type:`dialog_answered`})},dismissNotification:e=>i({type:`dismiss_notification`,id:e}),listDirectory:e=>g(e),refreshFileTree:C,readFile:e=>{let t=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:e,requestId:t}),h({type:`read_file`,path:e,requestId:t})},closeFilePreview:()=>i({type:`close_file_preview`}),writeFile:(e,t,n,r=!1)=>{let a=`write:${crypto.randomUUID()}`;i({type:`file_save_started`,path:e,requestId:a,content:t}),h({type:`write_file`,path:e,content:t,expectedMtimeMs:n,...r?{force:r}:{},requestId:a})},createFile:e=>{i({type:`file_create_started`}),h({type:`create_file`,path:e,requestId:`create:${crypto.randomUUID()}`})},uploadFile:(e,t)=>{let n=m.current;if(n===null)return Promise.reject(new UT(`the workspace is read-only`,`denied`));let r=a.current;if(!r||r.readyState!==WebSocket.OPEN)return Promise.reject(new UT(`not connected to the server`));let i=n?`${n}/${HT}`:HT,o=`upload:${crypto.randomUUID()}`;return new Promise((n,r)=>{let a=window.setTimeout(()=>{p.current.delete(o)&&r(new UT(`the upload timed out`))},AO),s=e=>t=>{clearTimeout(a),e(t)};p.current.set(o,{resolve:s(n),reject:s(r)}),h({type:`upload_file`,destinationDirectory:i,name:e,contentBase64:t,requestId:o})})},createDirectory:e=>{i({type:`file_create_started`}),h({type:`create_directory`,path:e,requestId:`create:${crypto.randomUUID()}`})},openNative:e=>{let t=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`open_native`,path:e,requestId:t}),h({type:`open_native`,path:e,requestId:t})},renameFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`rename_file`,path:e,requestId:n}),h({type:`rename_file`,path:e,name:t,requestId:n})},deleteFile:e=>{let t=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`delete_file`,path:e,requestId:t}),h({type:`delete_file`,path:e,requestId:t})},moveFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`move_file`,path:e,requestId:n}),h({type:`move_file`,path:e,destinationDirectory:t,requestId:n})},copyFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`copy_file`,path:e,requestId:n}),h({type:`copy_file`,path:e,destinationDirectory:t,requestId:n})},searchFiles:e=>{let t=`search:${crypto.randomUUID()}`;i({type:`file_search_started`,query:e,requestId:t}),h({type:`search_files`,query:e,requestId:t})},clearFileSearch:()=>i({type:`file_search_cleared`}),fetchGitStatus:b,fetchGitDiff:e=>{let t=`gitdiff:${crypto.randomUUID()}`;i({type:`git_diff_started`,path:e,requestId:t}),h({type:`git_diff`,path:e,requestId:t})},clearGitDiff:()=>i({type:`git_diff_cleared`}),fetchGitLog:e=>h({type:`git_log`,...e?{limit:e}:{},requestId:`gitlog:${crypto.randomUUID()}`}),fetchGitShow:e=>h({type:`git_show`,sha:e,requestId:`gitshow:${crypto.randomUUID()}`}),clearGitShow:()=>i({type:`git_show_cleared`}),fetchGitFileHistory:(e,t)=>{let n=`gitfilelog:${crypto.randomUUID()}`;i({type:`git_file_history_started`,path:e,requestId:n}),h({type:`git_file_log`,path:e,...t?{limit:t}:{},requestId:n})},closeGitFileHistory:()=>i({type:`git_file_history_closed`}),fetchGitFileDiff:(e,t)=>{let n=`gitfilediff:${crypto.randomUUID()}`;i({type:`git_file_diff_started`,base:e,target:t,requestId:n}),h({type:`git_file_diff`,base:e,target:t,requestId:n})},clearGitFileDiff:()=>i({type:`git_file_diff_cleared`}),setCredential:(e,t)=>h({type:`set_credential`,provider:e,apiKey:t}),declareProvider:e=>h({type:`declare_provider`,...e}),browseServerDirectory:e=>{let t=`serverdir:${crypto.randomUUID()}`;i({type:`server_browse_started`,path:e,requestId:t}),h({type:`browse_server_directory`,path:e,requestId:t})},closeServerBrowser:()=>i({type:`server_browse_closed`}),updateConfig:e=>{i({type:`settings_apply_started`}),h({type:`update_config`,...e})}}}var NO=(0,d.forwardRef)(function({serverUrl:e=``,rootElement:t,initialTheme:n,token:r},i){let a=t!==void 0,o=t??document.documentElement,{state:s,authToken:c,submitToken:l,prompt:u,abort:f,setModel:m,setThinking:h,newSession:g,switchSession:_,deleteSession:v,listSessions:b,renameSession:x,searchSessions:S,clearSessionSearch:C,listTree:w,navigateTree:T,forkSession:E,editPrompt:ee,compact:D,respondToDialog:O,dismissNotification:te,listDirectory:ne,refreshFileTree:k,readFile:A,writeFile:se,createFile:ce,createDirectory:le,uploadFile:ue,openNative:M,renameFile:de,deleteFile:fe,moveFile:pe,copyFile:me,closeFilePreview:he,searchFiles:ge,clearFileSearch:_e,fetchGitDiff:ve,clearGitDiff:ye,fetchGitLog:be,fetchGitShow:xe,clearGitShow:Se,fetchGitFileHistory:Ce,closeGitFileHistory:we,fetchGitFileDiff:Te,clearGitFileDiff:Ee,setCredential:De,declareProvider:Oe,updateConfig:ke,browseServerDirectory:je,closeServerBrowser:Me}=MO(e,r,a),[Ne,Pe]=(0,d.useState)(!1),[Fe,Ie]=(0,d.useState)([]),[Le,Re]=(0,d.useState)([]),[ze,Be]=(0,d.useState)(null),[Ve,He]=(0,d.useState)(null),[Ue,We]=(0,d.useState)(null),[Ge,Ke]=(0,d.useState)(!1),qe=(0,d.useRef)([]),Je=(0,d.useRef)(null),N=(0,d.useRef)(null),[Ye,Xe]=(0,d.useState)(!1),[Ze,Qe]=(0,d.useState)(()=>{try{return localStorage.getItem(`pi-outpost:hide-tools`)===`1`}catch{return!1}});function $e(){Qe(e=>{try{localStorage.setItem(`pi-outpost:hide-tools`,e?`0`:`1`)}catch{}return!e})}let[et,tt]=(0,d.useState)(!1),[nt,rt]=(0,d.useState)(!0);function it(){let e=!et;tt(e),e&&rt(!1)}function at(){let e=!nt;rt(e),e&&tt(!1)}let[ot,st]=(0,d.useState)([]),[ct,lt]=(0,d.useState)([]),ut=(0,d.useRef)(0),dt=(0,d.useRef)(0),[ft,pt]=(0,d.useState)(0);async function mt(e){let t=[...e],n=t.filter(qT).map(e=>({id:`${ut.current++}`,name:e.name}));n.length>0&&lt(e=>[...e,...n]),dt.current===0&&st([]),dt.current++;try{let{attachments:e,errors:n}=await tE(t,ue);e.length>0&&Ie(t=>[...t,...e]),n.length>0&&st(e=>[...e,...n])}finally{if(dt.current--,n.length>0){let e=new Set(n.map(e=>e.id));lt(t=>t.filter(t=>!e.has(t.id)))}}}(0,d.useEffect)(()=>{qe.current=Fe},[Fe]),(0,d.useEffect)(()=>{let t=s.openFile;if(!t)return;let n=t.path,r=t.status===`loaded`,i=t.status===`error`&&t.message===`Binary file — preview not supported`&&ae(n);if(Je.current!==n&&(Je.current=n,N.current=null,Ie(e=>e.filter(e=>e.source!==`preview`)),Be(null),He(null),We(null)),N.current===n)return;(re(n)||ie(n))&&Ie(e=>e.filter(e=>e.source!==`preview`));let a=!1;async function o(){let t=re(n)?Ve===n?await sE(n,oe(e,n,c,s.previewRevision)):null:ie(n)?Ue?.path===n&&Ue.revision===s.previewRevision?rE(n):null:i||r?nE(n):null;if(!(a||t===null||Je.current!==n||N.current===n)){if(typeof t==`string`){Be(t);return}Be(null),Ie(e=>uE(e,t))}}return o(),()=>{a=!0}},[s.openFile,s.previewRevision,e,c,Ve,Ue]);function ht(){Je.current=null,N.current=null,he()}let gt=(0,d.useMemo)(()=>[...Fe.filter(e=>e.kind===`path`).map(e=>e.data),...Le],[Fe,Le]);function _t(e){let t=qe.current.findIndex(t=>t.kind===`path`&&t.data===e);t>=0?vt(t):Le.includes(e)||Ie(t=>lE(t,e))}function vt(e){let t=qe.current[e];t?.source===`preview`&&(N.current=t.previewPath??Je.current,Be(null)),Ie(t=>dE(t,e))}function yt(e,t){u(e,t),Ie([]),st([]),Be(null),Ge||ht()}function bt(e){e.preventDefault(),pt(0),e.dataTransfer.files.length>0&&mt(Array.from(e.dataTransfer.files))}let{theme:xt,toggle:St,setTheme:Ct}=y(s.branding.defaultTheme??`system`,s.branding.allowThemeToggle!==!1,o,n);(0,d.useImperativeHandle)(i,()=>({setTheme:Ct}),[Ct]);let wt=(0,d.useRef)(null),Tt=(0,d.useRef)(null),Et=(0,d.useRef)(!0);function Dt(){let e=wt.current;e&&(Et.current=e.scrollHeight-e.scrollTop-e.clientHeight<120)}(0,d.useEffect)(()=>{Et.current&&Tt.current?.scrollIntoView({behavior:`smooth`})},[s.items]);let Ot=(0,d.useMemo)(()=>cT(s.items),[s.items]),kt=(0,d.useMemo)(()=>et?vT(s.items):null,[et,s.items]),At=(0,d.useMemo)(()=>W_({readFile:e=>{Xe(!1),A(e)},fetchGitFileHistory:e=>Ce(e),fetchGitDiff:e=>{Xe(!0),A(e)},searchFiles:e=>ge(e)}),[A,Ce,ge]),jt=(0,d.useCallback)(()=>Qe(!1),[]),{jumpToItem:Mt,highlightIndex:Nt}=LT({items:s.items,scrollerRef:wt,hideTools:Ze,onShowTools:jt,stickToBottom:Et});return(0,d.useEffect)(()=>{a||(document.title=s.extensionTitle??s.branding.title??`pi`),s.branding.accentColor&&o.style.setProperty(`--accent`,s.branding.accentColor)},[s.branding,s.extensionTitle,a,o]),a&&!s.brandingReady?null:s.authRequired?(0,j.jsx)(p.Provider,{value:xt,children:(0,j.jsx)(pO,{title:s.branding.title,onSubmit:l})}):s.credentials&&!s.credentials.usableModel?(0,j.jsx)(p.Provider,{value:xt,children:(0,j.jsx)(XD,{title:s.branding.title,credentials:s.credentials,onSetCredential:De,onDeclareProvider:Oe,errors:s.errors})}):(0,j.jsxs)(p.Provider,{value:xt,children:[(0,j.jsxs)(`div`,{className:`relative flex h-full`,onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&pt(e=>e+1)},onDragLeave:()=>pt(e=>Math.max(0,e-1)),onDragOver:e=>e.preventDefault(),onDrop:bt,children:[ft>0&&(0,j.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,j.jsx)(`p`,{className:`text-lg font-medium text-zinc-700 dark:text-zinc-200`,children:`Drop files to attach (images, documents & text)`})}),Ne&&(0,j.jsx)(fO,{tree:s.fileTree,openFile:s.openFile,writableRoot:s.writableRoot,gitFiles:s.gitStatus?.files,attachedPaths:gt,onExpand:ne,onRefresh:k,onSelectFile:e=>{Xe(!1),A(e)},onSelectDiff:e=>{Xe(!0),A(e)},onToggleAttachPath:_t,onCreateFile:e=>{Xe(!1),ce(e)},onCreateDirectory:le,onOpenNative:M,onRenameFile:de,onDeleteFile:fe,onMoveFile:pe,onCopyFile:me,fileOperation:s.fileOperation,createError:s.createError,created:s.created}),(0,j.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[(0,j.jsx)(HD,{title:s.branding.title,sessions:s.sessions,sessionSearch:s.sessionSearch,sessionId:s.sessionId,tree:s.tree,isStreaming:s.isStreaming,connected:s.connected,theme:xt,showThemeToggle:s.branding.allowThemeToggle!==!1,statuses:s.statuses,sidebarOpen:Ne,hideTools:Ze,onToggleSidebar:()=>Pe(!Ne),onToggleHideTools:$e,onToggleTheme:St,onNewSession:g,onSwitchSession:_,onDeleteSession:v,onListSessions:b,onRenameSession:x,onSearchSessions:S,onClearSessionSearch:C,onListTree:w,onNavigateTree:T,onForkSession:E,gitAvailable:s.gitAvailable,gitStatus:s.gitStatus,gitLog:s.gitLog,extensionPaths:s.extensionPaths,tools:s.tools,commands:s.commands,sandbox:s.sandbox,userSkillPaths:s.userSkillPaths,serverBrowse:s.serverBrowse,settingsApply:s.settingsApply,versions:s.versions,onBrowseServerPath:je,onCloseServerBrowser:Me,onUpdateConfig:ke,onFetchGitLog:be,onShowCommit:xe}),(0,j.jsxs)(`div`,{className:`relative z-0 flex min-h-0 flex-1 flex-col`,children:[s.workPlan&&(0,j.jsx)(_O,{plan:s.workPlan,open:nt,onToggle:at,onOpenWorkspace:e=>{Xe(!1),A(e)}}),s.openFile&&(0,j.jsx)(YE,{file:s.openFile,writableRoot:s.writableRoot,isStreaming:s.isStreaming,onDirtyChange:Ke,gitState:s.gitStatus?.files[s.openFile.path],initialShowGitDiff:Ye,gitDiff:s.gitDiff,onFetchGitDiff:ve,onClearGitDiff:ye,gitAvailable:s.gitAvailable,onOpenGitHistory:Ce,onClose:ht,onReload:A,onSave:se,serverUrl:e,token:c,onImageLoad:He,onPdfLoad:e=>We({path:e,revision:s.previewRevision}),rawRevision:s.previewRevision},s.openFile.path),s.gitFileHistory&&(0,j.jsx)(xD,{history:s.gitFileHistory,diff:s.gitFileDiff,dirty:s.gitStatus?.files[s.gitFileHistory.path]!==void 0,onFetchDiff:Te,onClearDiff:Ee,onClose:we}),s.gitShow&&(0,j.jsx)(ZE,{show:s.gitShow,onClose:Se}),kt&&(0,j.jsx)(FT,{analysis:kt,onJump:Mt,onClose:()=>tt(!1)}),(0,j.jsx)(`main`,{ref:wt,onScroll:Dt,className:`flex-1 overflow-y-auto ${et?`md:pr-[26rem]`:s.workPlan&&nt?`md:pr-[23rem]`:``}`,children:(0,j.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-3 px-4 py-6`,children:[s.items.length===0&&(0,j.jsxs)(`div`,{className:`mt-24 text-center text-zinc-500 dark:text-zinc-600`,children:[(0,j.jsx)(`div`,{className:`mb-2 text-4xl`,children:s.branding.title??`π`}),(0,j.jsx)(`p`,{className:`text-sm`,children:s.branding.welcome??`Send a message to start the agent.`})]}),s.items.map((t,n)=>{let r=`${s.sessionId}:${n}`,i=(e,t=r)=>(0,j.jsx)(`div`,{"data-item-index":n,className:`flex flex-col gap-3 rounded-lg transition-shadow ${Nt===n?`ring-2 ring-blue-400 dark:ring-blue-500`:``}`,children:e},t);if(t.kind===`user`){let e=n===s.items.length-1&&s.isStreaming;return i((0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(Ae,{item:t,canEdit:!s.isStreaming&&s.connected,onEdit:ee}),e&&(0,j.jsx)(`div`,{className:`flex justify-end px-4`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,j.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,j.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`working…`})]})})]}))}return t.kind===`tool`?Ze?null:i((0,j.jsx)(aT,{item:t,dispatch:At}),t.toolCallId?`${s.sessionId}:${t.toolCallId}`:r):t.kind===`custom`?i((0,j.jsx)(oT,{item:t})):t.blocks.length===0&&!t.errorMessage?(0,j.jsx)(`div`,{"data-item-index":n,className:`sr-only`,"aria-hidden":!0},r):i((0,j.jsx)(V_,{item:t,serverUrl:e,token:c,onOpenFile:e=>{Xe(!1),A(e)}}))}),s.pendingPrompt&&(0,j.jsxs)(`div`,{className:`flex flex-col gap-3 opacity-60`,"data-pending-prompt":!0,children:[(0,j.jsx)(Ae,{item:{kind:`user`,...s.pendingPrompt},canEdit:!1,onEdit:()=>{}}),(0,j.jsx)(`div`,{className:`flex justify-end px-4`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,j.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,j.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`sending…`})]})})]}),(s.queue.steering.length>0||s.queue.followUp.length>0)&&(0,j.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:[s.queue.steering.map((e,t)=>(0,j.jsxs)(`div`,{children:[`⏩ steering: `,e]},`s${t}`)),s.queue.followUp.map((e,t)=>(0,j.jsxs)(`div`,{children:[`⏭ follow-up: `,e]},`f${t}`))]}),ot.map((e,t)=>(0,j.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}`)),ze&&(0,j.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:ze}),s.errors.map((e,t)=>(0,j.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,j.jsx)(`div`,{ref:Tt})]})})]}),(0,j.jsx)(`footer`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,j.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,j.jsx)(zE,{widgets:s.widgets,placement:`aboveEditor`}),(0,j.jsx)(yE,{isStreaming:s.isStreaming,connected:s.connected,commands:s.commands,fileSearch:s.fileSearch,prefill:s.editorPrefill,attachments:Fe,pendingUploads:ct,onAttach:e=>void mt(e),onMentionPaths:Re,onRemoveAttachment:vt,onSend:yt,onAbort:f,onSearchFiles:ge,onClearFileSearch:_e}),(0,j.jsx)(zE,{widgets:s.widgets,placement:`belowEditor`}),(0,j.jsx)(qD,{model:s.model,models:s.models,thinkingLevel:s.thinkingLevel,modelSupportsReasoning:s.modelSupportsReasoning,isStreaming:s.isStreaming,contextUsage:s.contextUsage,sessionUsage:Ot,analysisOpen:et,onToggleAnalysis:it,isCompacting:s.isCompacting,onSetModel:m,onSetThinking:h,onCompact:D})]})})]})]}),s.dialogQueue[0]&&(0,j.jsx)(kE,{request:s.dialogQueue[0],onRespond:O}),(0,j.jsx)(ME,{notifications:s.notifications,onDismiss:te})]})});(0,f.createRoot)(document.getElementById(`root`)).render((0,j.jsx)(d.StrictMode,{children:(0,j.jsx)(NO,{})}));export{i,A as n,oe as r,M as t};
323
+ `)){let t=DE(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function kE({request:e,onRespond:t}){let[n,r]=(0,d.useState)(e.method===`editor`?e.prefill??``:``),[i,a]=(0,d.useState)([]),o=(e.method===`select`||e.method===`confirm`||e.method===`input`)&&e.timeout,[s,c]=(0,d.useState)(o?Math.ceil(o/1e3):null),l=OE(e),{heading:u,body:f}=EE(e.title);function p(){t({id:e.id,cancelled:!0})}function m(e){a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e].sort((e,t)=>e-t))}function h(){let r=n.trim();t({id:e.id,value:r.length>0?r:i.join(`,`)})}return(0,d.useEffect)(()=>{if(s===null)return;if(s<=0){t({id:e.id,cancelled:!0});return}let n=setTimeout(()=>c(e=>e===null?null:e-1),1e3);return()=>clearTimeout(n)},[s,e.id,t]),(0,j.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:p,children:(0,j.jsxs)(`div`,{className:`w-full ${f?`max-w-2xl`:`max-w-md`} rounded-xl border border-zinc-200 bg-white p-4 shadow-2xl dark:border-zinc-700 dark:bg-zinc-900`,onClick:e=>e.stopPropagation(),children:[(0,j.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:u}),f&&!l&&(0,j.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:f}),e.method===`select`&&(0,j.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>{let r=DE(n);return(0,j.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${bE}`,children:r?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:r.label}),r.description&&(0,j.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,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,j.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:bE,children:`No`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:xE,children:`Yes`})]})]}),l&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`mb-3 flex flex-col gap-1`,children:l.options.map(e=>(0,j.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,j.jsx)(`input`,{type:`checkbox`,checked:i.includes(e.index),onChange:()=>m(e.index),className:`mt-0.5`}),(0,j.jsxs)(`span`,{children:[(0,j.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,j.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,j.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`…or type your own answer`,onKeyDown:e=>{e.key===`Enter`&&h(),e.key===`Escape`&&p()},className:`mb-1 ${SE}`}),(0,j.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,j.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:p,className:bE,children:`Cancel`}),(0,j.jsx)(`button`,{type:`button`,onClick:h,className:xE,children:`OK`})]})]}),e.method===`input`&&!l&&(0,j.jsxs)(j.Fragment,{children:[(0,j.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`&&p()},className:CE}),(0,j.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:p,className:bE,children:`Cancel`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:xE,children:`OK`})]})]}),e.method===`editor`&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`textarea`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&p()},className:`resize-none font-mono ${CE}`}),(0,j.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:p,className:bE,children:`Cancel`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:xE,children:`OK`})]})]}),s!==null&&(0,j.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,s,`s`]})]})})}var AE={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`},jE=6e3;function ME({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(),jE);return()=>clearTimeout(e)},[e.id]),(0,j.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-lg border px-3 py-2 text-sm shadow-lg ${AE[e.notifyType??`info`]}`,children:[(0,j.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,j.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 NE({notifications:e,onDismiss:t}){return e.length===0?null:(0,j.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,j.jsx)(ME,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var PE={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`},FE=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function IE(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(PE[r]!==void 0)n.color=PE[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 LE(e){let t=[],n={},r=0;FE.lastIndex=0;for(let i=FE.exec(e);i!==null;i=FE.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=IE(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function RE(e){return e.replace(FE,``)}function zE({line:e}){let t=LE(e);return(0,j.jsx)(j.Fragment,{children:t.map((e,t)=>(0,j.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 BE({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,j.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,j.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,j.jsx)(`div`,{children:(0,j.jsx)(zE,{line:e})},t))},e))})}var VE=class extends d.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){console.error(`[pi-outpost] viewer crashed:`,e,t.componentStack)}render(){return this.state.failed?(0,j.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,j.jsxs)(`p`,{className:`max-w-md text-center text-sm text-zinc-600 dark:text-zinc-400`,children:[this.props.label??`This file`,` could not be displayed. Close and reopen it to try again.`]})}):this.props.children}},HE=(0,d.lazy)(()=>M(()=>import(`./PdfViewer-r8Lc1uQ2.js`),[])),UE=250,WE=`(min-width: 768px)`;function GE(){let[e,t]=(0,d.useState)(()=>window.matchMedia?.(WE).matches??!0);return(0,d.useEffect)(()=>{let e=window.matchMedia?.(WE);if(e===void 0)return;let n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function KE(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 qE(e){let t=nw(e);return t.status===`valid`?t.envelope:void 0}function JE(e){return/\.(md|markdown)$/i.test(e)}function YE(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function XE({file:e,writableRoot:t,isStreaming:n,onDirtyChange:r,gitState:i,initialShowGitDiff:a=!1,gitDiff:o,onFetchGitDiff:s,onClearGitDiff:c,gitAvailable:l,onOpenGitHistory:u,onClose:f,onReload:p,onSave:m,serverUrl:h=``,token:g=null,onImageLoad:_,onPdfLoad:v,rawRevision:y=0}){let[b,x]=(0,d.useState)(`rendered`),[C,w]=(0,d.useState)(a),[T,E]=(0,d.useState)(e.status===`loaded`&&e.justCreated?{draft:e.content,baseContent:e.content,baseMtimeMs:e.mtimeMs}:null),[D,O]=(0,d.useState)(`idle`),te=(0,d.useRef)(null),ae=(0,d.useRef)(null),k=e.status===`loaded`?e:null,A=k!==null&&JE(e.path),ce=re(e.path),le=ie(e.path),ue=(0,d.useMemo)(()=>k===null?void 0:nw(k.content),[k?.content]),M=ue?.status===`valid`,de=ue?.status===`valid`||ue?.status===`invalid`,fe=de||A,pe=b===`source`,me=GE(),he=YE(e.path,t)&&!le,_e=T!==null&&T.draft!==T.baseContent,ve=k?.pendingSave!==void 0,ye=T!==null&&k!==null&&k.mtimeMs!==T.baseMtimeMs,be=k?.saveError?.conflict===!0||ye,xe=T?.draft??k?.content??``,Se=KE(xe,UE),Ce=(0,d.useMemo)(()=>k===null?void 0:nw(Se),[Se,k===null]),[we,Ee]=(0,d.useState)(()=>e.status===`loaded`?qE(e.content):void 0);(0,d.useEffect)(()=>{Ce?.status===`valid`&&Ee(Ce.envelope)},[Ce]);let De=Ce!==void 0&&Ce.status!==`valid`&&we!==void 0,ke=Ce?.status===`invalid`?Se===k?.content&&k.documentIssues!==void 0?k.documentIssues:Ce.issues:void 0,Ae=Ce?.status===`not-a-document`?Ce.why===`unparseable`?`This is not parseable JSON yet.`:"This no longer declares a structured-exchange `schema`.":Ce?.status===`unsupported-version`?`This declares ${Ce.schema}, which this version does not render.`:void 0,je=b===`split`&&fe&&!C&&k!==null&&me,Me=T===null?null:(0,j.jsx)(`textarea`,{ref:te,value:T.draft,onChange:e=>E({...T,draft:e.target.value}),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),_e&&!ve&&!be&&Le())},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 Ne(t){return(0,j.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,j.jsx)(_s,{remarkPlugins:[D_,z_],rehypePlugins:[Dm],components:{pre:Te,a:({href:t,children:n,...r})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,j.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...r,children:n}):t.startsWith(`#`)?(0,j.jsx)(`a`,{href:t,...r,children:n}):(0,j.jsx)(`a`,{href:t,onClick:n=>{n.preventDefault(),p(ne(e.path,t))},...r,children:n}),img:({src:t,alt:n,...r})=>{let i=typeof t==`string`&&t!==``&&!/^[a-z][a-z0-9+.-]*:/i.test(t)&&!t.startsWith(`//`)?oe(h,ne(e.path,t),g):t;return(0,j.jsx)(`img`,{...r,src:i,alt:n??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:ee(t)})})}function Pe(e){b===`split`&&e!==`split`&&_e&&!window.confirm(`Discard unsaved changes?`)||(b===`split`&&e!==`split`&&E(null),x(e))}function Fe(){_e&&!window.confirm(`Discard unsaved changes?`)||f()}function Ie(){k&&E({draft:k.content,baseContent:k.content,baseMtimeMs:k.mtimeMs})}function Le(t=!1){!k||T===null||ve||(ae.current=T.draft,m(e.path,T.draft,T.baseMtimeMs,t))}function Re(){E(null),p(e.path)}function ze(){let t=!C;w(t),t?s(e.path):c()}return(0,d.useEffect)(()=>{if(T!==null&&k!==null&&ae.current!==null&&k.content===ae.current&&k.mtimeMs!==T.baseMtimeMs){let e=ae.current;ae.current=null,T.draft===e?E(null):E({...T,baseContent:k.content,baseMtimeMs:k.mtimeMs})}},[k?.mtimeMs]),(0,d.useEffect)(()=>{function e(e){e.key===`Escape`&&Fe()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,d.useEffect)(()=>{je&&he&&T===null&&k!==null&&E({draft:k.content,baseContent:k.content,baseMtimeMs:k.mtimeMs})},[je,he,k?.mtimeMs]),(0,d.useEffect)(()=>{O(n?`streaming`:e=>e===`streaming`?`done`:e)},[n]),(0,d.useEffect)(()=>(r(_e),()=>r(!1)),[_e]),(0,d.useEffect)(()=>(a&&s(e.path),()=>c()),[]),(0,j.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[fe&&!C&&(0,j.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,j.jsx)(`button`,{type:`button`,onClick:()=>Pe(e),"aria-pressed":b===e,title:n,className:`rounded px-1.5 py-0.5 text-xs ${b===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,j.jsx)(`button`,{type:`button`,onClick:ze,"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,j.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,j.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,_e&&(0,j.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),k&&T===null&&(0,j.jsx)(se,{text:k.content}),k&&T===null&&!C&&he&&(0,j.jsx)(`button`,{type:`button`,onClick:Ie,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`}),k&&T===null&&!he&&(0,j.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,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{type:`button`,onClick:()=>Le(),disabled:!_e||ve||be,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:ve?`saving…`:`save`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>{_e&&!window.confirm(`Discard unsaved changes?`)||E(je&&k!==null?{draft:k.content,baseContent:k.content,baseMtimeMs:k.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,j.jsx)(`button`,{type:`button`,onClick:Fe,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:`✕`})]}),be&&T!==null&&(0,j.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,j.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,j.jsx)(`button`,{type:`button`,onClick:Re,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,j.jsx)(`button`,{type:`button`,onClick:()=>Le(!0),disabled:ve,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&&k?.saveError&&!k.saveError.conflict&&(0,j.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:k.saveError.message}),(0,j.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[C&&T===null&&(0,j.jsxs)(`div`,{className:`p-4`,children:[o?.path===e.path&&`error`in o&&(0,j.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,j.jsx)(Oe,{fill:!0,lines:S(o.before,o.after)}),o?.path!==e.path&&(0,j.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),le&&T===null&&!C&&(0,j.jsx)(VE,{label:`This PDF`,children:(0,j.jsx)(d.Suspense,{fallback:(0,j.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),children:(0,j.jsx)(HE,{path:e.path,serverUrl:h,token:g,revision:y,...v?{onLoaded:v}:{}})})}),ce&&T===null&&!C&&(0,j.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,j.jsx)(`img`,{src:oe(h,e.path,g,y),alt:e.path,onLoad:()=>_(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&T===null&&!C&&!ce&&!le&&(0,j.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!ce&&!le&&(0,j.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),T!==null&&!je&&Me,k&&T===null&&!je&&!C&&A&&!pe&&Ne(k.content),je&&(0,j.jsxs)(`div`,{className:`flex h-full min-h-0`,"data-testid":`file-split`,children:[(0,j.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto border-r border-zinc-200 dark:border-zinc-800`,children:Me??(0,j.jsx)(`div`,{className:`p-4`,children:(0,j.jsx)(ge,{code:k.content,path:e.path})})}),(0,j.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto`,"data-testid":`file-split-rendering`,children:A&&!de?(0,j.jsx)(`div`,{className:`prose-chat p-4 text-zinc-700 dark:text-zinc-300`,children:Ne(Se)}):(0,j.jsxs)(j.Fragment,{children:[De&&(0,j.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,j.jsxs)(`span`,{children:[`Showing the document as it last stood.`,` `,Ae??`The text beside it does not satisfy the schema it declares.`]})}),ke!==void 0&&(0,j.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:[ke.slice(0,6).map((e,t)=>(0,j.jsxs)(`li`,{children:[(0,j.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),ke.length>6&&(0,j.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,ke.length-6,` more`]})]}),we===void 0?(0,j.jsxs)(`p`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,"data-testid":`file-split-nothing`,children:[`Nothing to draw yet. `,Ae??`This document does not satisfy the schema it declares.`]}):(0,j.jsx)(VE,{label:`This diagram`,children:(0,j.jsx)(`div`,{className:`p-4`,"data-testid":`file-structured-exchange`,children:(0,j.jsx)($w,{envelope:we,source:xe})})})]})})]}),k&&T===null&&!je&&!C&&M&&!pe&&ue?.status===`valid`&&(0,j.jsx)(VE,{label:`This diagram`,children:(0,j.jsx)(`div`,{className:`mx-auto max-w-5xl p-4`,"data-testid":`file-structured-exchange`,children:(0,j.jsx)($w,{envelope:ue.envelope,source:k.content})})}),k&&T===null&&!je&&!C&&ue?.status===`invalid`&&(0,j.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,j.jsx)(`p`,{className:`font-medium`,children:`This declares a structured-exchange document and does not satisfy the schema.`}),(0,j.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:[(k.documentIssues??ue.issues).slice(0,8).map((e,t)=>(0,j.jsxs)(`li`,{children:[(0,j.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),(k.documentIssues??ue.issues).length>8&&(0,j.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,(k.documentIssues??ue.issues).length-8,` more`]})]})]}),k&&T===null&&!je&&!C&&ue?.status===`unsupported-version`&&(0,j.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,j.jsx)(`span`,{className:`font-mono`,children:ue.schema}),`, which this version does not render. Shown as text.`]}),k&&T===null&&!je&&!C&&(!A||pe)&&(!M||pe)&&(0,j.jsx)(`div`,{className:`p-4`,children:(0,j.jsx)(ge,{code:k.content,path:e.path})})]}),D!==`idle`&&(0,j.jsxs)(`button`,{type:`button`,onClick:Fe,"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:[D===`streaming`?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,j.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,j.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,j.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function ZE(e){return e.split(`
324
+ `).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 QE({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,j.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,j.jsx)(`span`,{className:`font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,12)}),(0,j.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`commit diff`}),(0,j.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,j.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,j.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed`,children:ZE(e.patch).map((e,t)=>(0,j.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 $E=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],eD=`worktree`,tD={defaultWidth:288,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.files-sidebar-width.v1`},nD={defaultWidth:416,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.history-list-width.v1`};function rD(e,t){return Number.isFinite(e)?Math.min(t.maxWidth,Math.max(t.minWidth,Math.round(e))):t.defaultWidth}function iD(e,t){return e===null||e.trim()===``?t.defaultWidth:rD(Number(e),t)}function aD(e,t){try{return iD((t??window.localStorage).getItem(e.storageKey),e)}catch{return e.defaultWidth}}function oD(e,t,n){try{(n??window.localStorage).setItem(t.storageKey,String(rD(e,t)))}catch{}}function sD(e){let[t,n]=(0,d.useState)(()=>aD(e)),r=(0,d.useRef)(t),i=(0,d.useRef)(null),a=(0,d.useCallback)(t=>{let i=rD(t,e);return r.current=i,n(i),i},[e]),o=(0,d.useCallback)(()=>{i.current!==null&&(i.current=null,oD(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(),oD(a(n),e))}}}}function cD({label:e,width:t,config:n,separatorProps:r,className:i=``}){return(0,j.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,j.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 lD=`#10b981`,uD=[`#8b5cf6`,`#f59e0b`,`#0ea5e9`,`#f43f5e`,`#14b8a6`,`#d946ef`];function dD(e){return e===0?lD:uD[(e-1)%uD.length]}function fD(e){return uD[e%uD.length]}function pD(e){return e*14+7+1}function mD(e){return e*14+2}function hD({row:e,laneCount:t,colorOf:n=dD}){let r=mD(t),i=pD(e.lane),a=e.highlight?lD:n(e.lane),o=e.dashed?`3 3`:void 0;return(0,j.jsxs)(`svg`,{width:r,height:36,viewBox:`0 0 ${r} 36`,"aria-hidden":!0,className:`shrink-0`,children:[e.through.map(e=>(0,j.jsx)(`line`,{x1:pD(e),y1:0,x2:pD(e),y2:36,stroke:n(e),strokeWidth:2,opacity:.55},e)),e.lineAbove&&(0,j.jsx)(`line`,{x1:i,y1:0,x2:i,y2:18,stroke:a,strokeWidth:2,strokeDasharray:o}),e.lineBelow&&(0,j.jsx)(`line`,{x1:i,y1:18,x2:i,y2:36,stroke:a,strokeWidth:2,strokeDasharray:o}),e.forkTo.map(e=>(0,j.jsx)(`path`,{d:`M ${i} 18 C ${i} 36, ${pD(e)} 18, ${pD(e)} 36`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`fork-${e}`)),(e.mergeFrom??[]).map(e=>(0,j.jsx)(`path`,{d:`M ${i} 18 C ${i} 0, ${pD(e)} 18, ${pD(e)} 0`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`merge-${e}`)),e.emphasis===`current`?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`circle`,{cx:i,cy:18,r:6,fill:`none`,stroke:a,strokeWidth:2}),(0,j.jsx)(`circle`,{cx:i,cy:18,r:2.5,fill:a})]}):(0,j.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 gD(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:eD,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 _D=20;function vD(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 yD(e){return e.rev===`worktree`?`working tree`:e.rev.slice(0,7)}function bD(e,t){return e!==null&&t!==null&&e.rev===t.rev&&e.path===t.path}function xD(e){return{rev:e.rev,path:e.path}}function SD({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=sD(nD),{rows:h,laneCount:g}=(0,d.useMemo)(()=>gD(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||bD(c,l)||_.current.onFetchDiff(c,l)},[c,l]);let v=(0,d.useCallback)((e,t)=>{let n=xD(e);s(r=>{if(t===`base`)return{base:n,target:bD(n,r.target)?r.base:r.target};if(t===`target`)return{base:bD(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?xD(r):null,target:n}}return{base:bD(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=xD(e);return bD(t,c)?`base`:bD(t,l)?`target`:null},C=h.findIndex(e=>bD(xD(e),c)),w=h.findIndex(e=>bD(xD(e),l)),T=C>=0&&w>=0?{top:Math.min(C,w)*36+18,height:Math.abs(w-C)*36}:null;return(0,j.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,j.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,j.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-zinc-500 dark:text-zinc-400`,"aria-label":`Comparing ${yD(c)} to ${yD(l)}`,children:[(0,j.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:yD(c)}),` → `,(0,j.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:yD(l)})]}),c!==null&&l!==null&&(0,j.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,j.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,j.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,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,j.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,j.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,j.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`Reading history…`}),e.status===`error`&&(0,j.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,j.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,j.jsxs)(`div`,{className:`relative`,role:`group`,"aria-label":`Commits`,children:[T&&(0,j.jsx)(CD,{top:T.top,height:T.height,baseFirst:C<w}),h.map((e,t)=>(0,j.jsx)(ED,{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,j.jsx)(cD,{label:`Resize History commit list`,width:m.width,config:nD,separatorProps:m.separatorProps,className:`hidden md:block`})]}),(0,j.jsx)(`div`,{role:`region`,"aria-label":`History diff`,className:`min-h-0 min-w-0 flex-1 overflow-auto p-3`,children:(0,j.jsx)(DD,{diff:t,base:c,target:l})})]})]})}function CD({top:e,height:t,baseFirst:n}){return(0,j.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:_D},children:[(0,j.jsx)(`div`,{className:`absolute inset-y-0 left-2 w-px bg-zinc-400 dark:bg-zinc-500`}),(0,j.jsx)(wD,{label:n?`base`:`target`,className:`top-0`}),(0,j.jsx)(wD,{label:n?`target`:`base`,className:`bottom-0`})]})}function wD({label:e,className:t}){return(0,j.jsx)(`div`,{className:`absolute left-2 flex h-px w-2.5 items-center bg-zinc-400 dark:bg-zinc-500 ${t}`,children:(0,j.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 TD=`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 ED({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,j.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:_D},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,j.jsx)(hD,{row:e,laneCount:t}),s?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:s.sha.slice(0,7)}),(0,j.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,j.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-600`,children:[s.author,` · `,vD(s.date)]}),(0,j.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums`,"aria-label":`${s.added} lines added, ${s.deleted} removed`,children:[(0,j.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-500`,children:[`+`,s.added]}),` `,(0,j.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,s.deleted]})]})]}):(0,j.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`working tree`}),(0,j.jsxs)(`span`,{className:`flex shrink-0 gap-0.5`,children:[(0,j.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:TD,children:`base`}),(0,j.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:TD,children:`target`})]})]})}function DD({diff:e,base:t,target:n}){return t===null&&n===null?(0,j.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,j.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,j.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,j.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Loading…`}):e.status===`loaded`&&e.beforeText===e.afterText?(0,j.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,j.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions differ only in their line endings.`}):(0,j.jsx)(`div`,{className:e.status===`loading`?`opacity-40`:void 0,children:(0,j.jsx)(Oe,{fill:!0,lines:S(e.beforeText,e.afterText)})})}function OD(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 kD({status:e,log:t,onFetchLog:n,onShowCommit:r}){let[i,a]=(0,d.useState)(!1),o=pE(()=>a(!1)),s=e&&(e.ahead>0||e.behind>0)?` ${e.ahead>0?`↑${e.ahead}`:``}${e.behind>0?`↓${e.behind}`:``}`:``;return(0,j.jsxs)(`div`,{className:`relative`,ref:o,children:[(0,j.jsxs)(`button`,{type:`button`,onClick:()=>{a(!i),i||n()},title:`git history`,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 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:[`⎇ `,e?.branch??`…`,s]}),i&&(0,j.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:[t===null&&(0,j.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),t?.length===0&&(0,j.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no commits`}),t?.map(e=>(0,j.jsxs)(`button`,{type:`button`,onClick:()=>{r(e.sha),a(!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,j.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,7)}),(0,j.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-700 dark:text-zinc-300`,title:e.subject,children:e.subject}),(0,j.jsxs)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:[e.author,` · `,OD(e.date)]})]},e.sha))]})]})}function AD({label:e,browse:t,onBrowse:n,onSelect:r,onCancel:i}){let a=t?.path??`/`,o=t?.entries??[],s=t?.status===`loading`;return(0,j.jsxs)(`div`,{className:`rounded-md border border-zinc-300 p-2 dark:border-zinc-700`,"data-testid":`server-path-picker`,children:[(0,j.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,j.jsx)(`span`,{className:`text-xs font-semibold text-zinc-600 dark:text-zinc-300`,children:e}),(0,j.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,j.jsx)(`p`,{className:`mb-2 break-all font-mono text-[11px] text-zinc-500 dark:text-zinc-400`,"data-testid":`picker-path`,children:a}),t?.status===`error`&&(0,j.jsx)(`p`,{role:`alert`,className:`mb-2 text-xs text-red-600 dark:text-red-400`,children:t.error}),(0,j.jsxs)(`div`,{className:`mb-2 flex gap-2`,children:[(0,j.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,j.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,j.jsxs)(`ul`,{className:`max-h-40 overflow-y-auto`,children:[s&&o.length===0&&(0,j.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400`,children:`Loading…`}),!s&&o.length===0&&t?.status!==`error`&&(0,j.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No subdirectories`}),o.map(e=>(0,j.jsx)(`li`,{children:(0,j.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 jD({extensionPaths:e,tools:t,commands:n,sandbox:r,userSkillPaths:i,serverBrowse:a,applyState:o,versions:s,onBrowseServerPath:c,onCloseServerBrowser:l,onUpdateConfig:u}){let[f,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(``),[g,_]=(0,d.useState)(``),[v,y]=(0,d.useState)(!1),[b,x]=(0,d.useState)(!1),[S,C]=(0,d.useState)(i),[w,T]=(0,d.useState)(null),E=pE(()=>ie()),ee=t.filter(e=>e.active),D=t.filter(e=>!e.active),O=n.filter(e=>e.source===`skill`),te=o?.status===`applying`,ne=o?.status===`error`?o.message:null;(0,d.useEffect)(()=>{r&&(h(r.root),_(r.writableRoot??``),y(r.allowWrite),x(r.allowBash))},[r]),(0,d.useEffect)(()=>{C(i)},[i]);let re=(0,d.useRef)(!1);(0,d.useEffect)(()=>{re.current&&o===null&&ie(),re.current=te},[o,te]);function ie(){p(!1),T(null),l()}function ae(e,t){T(e),c(t.trim()||`/`)}function oe(e){w===`root`?h(e):w===`writableRoot`?_(e):w===`skill`&&!S.includes(e)&&C([...S,e]),T(null),l()}function k(){let e=r?{root:m,allowWrite:v,allowBash:b,writableRoot:g.trim()||void 0}:void 0;u({...e?{sandbox:e}:{},userSkillPaths:S})}let A=w!==null&&(0,j.jsx)(AD,{label:w===`skill`?`Choose a skills directory`:w===`root`?`Choose the sandbox root`:`Choose the writable root`,browse:a,onBrowse:c,onSelect:oe,onCancel:()=>{T(null),l()}});return(0,j.jsxs)(`div`,{className:`relative`,ref:E,children:[(0,j.jsx)(`button`,{type:`button`,onClick:()=>p(!f),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:`⚙`}),f&&(0,j.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,j.jsx)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,j.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Settings`})}),(0,j.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:[(0,j.jsxs)(`section`,{className:`mb-4`,children:[(0,j.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Agent resources`}),t.length===0?(0,j.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`Tool inventory unavailable for this runtime`}):(0,j.jsxs)(`details`,{children:[(0,j.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[ee.length,` tools active`,D.length?` · ${D.length} inactive`:``]}),(0,j.jsx)(`ul`,{className:`mt-2 space-y-1`,children:t.map(e=>(0,j.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,j.jsx)(`span`,{children:e.name}),(0,j.jsx)(`span`,{children:e.active?`active`:`inactive`})]},e.name))})]}),O.length===0?(0,j.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skills loaded`}):(0,j.jsxs)(`details`,{className:`mt-2`,children:[(0,j.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[O.length,` skills loaded`]}),(0,j.jsx)(`ul`,{className:`mt-2 space-y-1`,children:O.map(e=>(0,j.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.name},e.name))})]}),(0,j.jsxs)(`div`,{className:`mt-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsx)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:`User skill paths`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>ae(`skill`,S[S.length-1]??`/`),className:`rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-600 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-300`,children:`Add directory…`})]}),S.length===0?(0,j.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skill directories added`}):(0,j.jsx)(`ul`,{className:`mt-1 space-y-1`,children:S.map(e=>(0,j.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded bg-zinc-50 px-2 py-1 dark:bg-zinc-800`,children:[(0,j.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-600 dark:text-zinc-400`,title:e,children:e}),(0,j.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:()=>C(S.filter(t=>t!==e)),className:`shrink-0 text-xs text-zinc-500 hover:text-red-600 dark:text-zinc-400 dark:hover:text-red-400`,children:`Remove`})]},e))}),w===`skill`&&(0,j.jsx)(`div`,{className:`mt-2`,children:A})]})]}),(0,j.jsxs)(`section`,{className:`mb-4`,children:[(0,j.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),e.length===0?(0,j.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,j.jsx)(`ul`,{className:`space-y-1`,children:e.map((e,t)=>(0,j.jsx)(`li`,{className:`rounded bg-zinc-50 px-2 py-1 text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},t))})]}),r&&(0,j.jsxs)(`section`,{children:[(0,j.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Sandbox`}),(0,j.jsxs)(`div`,{className:`space-y-3`,children:[(0,j.jsxs)(`label`,{className:`block`,children:[(0,j.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,r.locks?.root?(0,j.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,j.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,j.jsx)(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),disabled:r.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,j.jsx)(`button`,{type:`button`,"aria-label":`Browse for sandbox root`,disabled:r.locks?.root,onClick:()=>ae(`root`,m),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…`})]})]}),w===`root`&&A,(0,j.jsxs)(`label`,{className:`block`,children:[(0,j.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,r.locks?.writableRoot?(0,j.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,j.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,j.jsx)(`input`,{type:`text`,value:g,onChange:e=>_(e.target.value),disabled:r.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,j.jsx)(`button`,{type:`button`,"aria-label":`Browse for writable root`,disabled:r.locks?.writableRoot,onClick:()=>ae(`writableRoot`,g||m),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…`})]})]}),w===`writableRoot`&&A,(0,j.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:v,onChange:e=>y(e.target.checked),disabled:r.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,j.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,r.locks?.allowWrite?(0,j.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,j.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked),disabled:r.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,j.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,r.locks?.allowBash?(0,j.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]})]})]}),!r&&(0,j.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),(0,j.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[ne&&(0,j.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:ne}),(0,j.jsx)(`button`,{type:`button`,disabled:te||r!==null&&!m.trim(),onClick:k,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:te?`Applying…`:`Apply & restart session`}),(0,j.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.`})]}),s&&(0,j.jsxs)(`section`,{className:`mt-4`,children:[(0,j.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,j.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,j.jsxs)(`p`,{children:[`pi-outpost: `,(0,j.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:s.piOutpost})]}),s.piSdk&&(0,j.jsxs)(`p`,{children:[`pi SDK: `,(0,j.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:s.piSdk})]}),s.agent&&(0,j.jsxs)(`p`,{children:[`agent: `,(0,j.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:s.agent})]})]})]})]})]})]})}function MD(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 ND(e){return e.flatMap(e=>[e,...ND(e.children)])}function PD({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,j.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var FD=`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 ID({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:o}=e,s=o.tipId??o.entryId;return(0,j.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,j.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,j.jsx)(hD,{row:e,laneCount:t,colorOf:fD}),(0,j.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,j.jsxs)(PD,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,j.jsxs)(PD,{tone:`branch`,children:[`branch `,e.branchIndex,o.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,j.jsx)(PD,{tone:`current`,children:`current`}),o.label&&(0,j.jsx)(PD,{tone:`label`,children:o.label})]}),(0,j.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:FD,children:`↺ redo`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>{i(o.entryId),a()},title:`fork a new session from this point`,className:FD,children:`⑂ fork`})]})}function LD({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:i}){let[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(``),l=pE(()=>o(!1));(0,d.useEffect)(()=>{a&&e===null&&n()},[a,e]);let u=(0,d.useMemo)(()=>e&&e.length>0?MD(e):null,[e]),f=(0,d.useMemo)(()=>{if(!e||!s.trim())return null;let t=s.trim().toLowerCase();return ND(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,s]);return(0,j.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,j.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,j.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,j.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,j.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&u&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,j.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,j.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,j.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,j.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,j.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,j.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:f===null?u.rows.map(e=>(0,j.jsx)(ID,{row:e,laneCount:u.laneCount,isStreaming:t,onNavigate:r,onFork:i,onClose:()=>o(!1)},e.node.entryId)):f.length===0?(0,j.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):f.map(e=>(0,j.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,j.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,j.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,j.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,j.jsx)(PD,{tone:`current`,children:`on current branch`}),e.label&&(0,j.jsx)(PD,{tone:`label`,children:e.label})]}),(0,j.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:FD,children:`↺ redo`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>{i(e.entryId),o(!1)},title:`fork a new session from this point`,className:FD,children:`⑂ fork`})]},e.entryId))})]})]})]})}var RD=200;function zD({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,d.useState)(e);return(0,j.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 BD({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:o,onCancelRename:s}){return n?(0,j.jsx)(`div`,{className:`px-3 py-2`,children:(0,j.jsx)(zD,{initial:e.name??``,onCommit:o,onCancel:s})}):(0,j.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,j.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,j.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,j.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,j.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`:``]})]}),(0,j.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&&(0,j.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 VD({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=pE(()=>u(!1)),_=f.trim(),v=_.length>=2;(0,d.useEffect)(()=>{if(!l)return;if(!v){c();return}let e=setTimeout(()=>s(_),RD);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,j.jsxs)(`div`,{className:`relative`,ref:g,children:[(0,j.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,j.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,j.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,j.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,j.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,j.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[x===null&&(0,j.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),x?.length===0&&(0,j.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:v?`no matches`:`no saved sessions`}),x?.map(e=>(0,j.jsx)(BD,{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 HD({theme:e,onToggle:t}){return(0,j.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 UD(e){let{isStreaming:t,connected:n}=e;return(0,j.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:[(0,j.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`]}),e.gitAvailable&&(0,j.jsx)(kD,{status:e.gitStatus,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,j.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,j.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:RE(t)},e)),(0,j.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:e.onToggleHideTools,title:e.hideTools?`Show tool cards in the conversation`:`Hide tool cards (long sessions read better without them)`,"aria-pressed":e.hideTools,className:`rounded-md border px-2 py-1 text-xs ${e.hideTools?`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:`⚒ tools`}),e.showThemeToggle&&(0,j.jsx)(HD,{theme:e.theme,onToggle:e.onToggleTheme}),(0,j.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,j.jsx)(LD,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,j.jsx)(VD,{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,j.jsx)(jD,{extensionPaths:e.extensionPaths,tools:e.tools??[],commands:e.commands??[],sandbox:e.sandbox,userSkillPaths:e.userSkillPaths,serverBrowse:e.serverBrowse,applyState:e.settingsApply,versions:e.versions,onBrowseServerPath:e.onBrowseServerPath,onCloseServerBrowser:e.onCloseServerBrowser,onUpdateConfig:e.onUpdateConfig}),(0,j.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function WD(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 GD({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,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`span`,{children:[uT(e.totalTokens),` tok`]}),r>0&&(0,j.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:[lT(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,j.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,j.jsx)(`span`,{title:i,className:`${o} border-zinc-300 dark:border-zinc-800`,children:a})}function KD({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,j.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 36 36`,className:`-rotate-90 shrink-0`,children:[(0,j.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,j.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${i} ${n-i}`,className:WD(e)})]})}function qD({thinkingLevel:e,isStreaming:t,onSetThinking:n}){let[r,i]=(0,d.useState)(!1),a=(0,d.useRef)(null),o=e!==`off`,s=Math.max(0,$E.indexOf(e));return(0,d.useEffect)(()=>{if(!r)return;function e(e){a.current&&!fE(e,a.current)&&i(!1)}function t(e){e.key===`Escape`&&i(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]),(0,j.jsxs)(`div`,{className:`relative`,ref:a,children:[(0,j.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),disabled:t,title:`thinking level`,"aria-haspopup":`true`,"aria-expanded":r,className:`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs disabled:opacity-50 ${o?`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,j.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none ${o?``:`opacity-40 grayscale`}`,children:`🧠`}),e]}),r&&(0,j.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,j.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between text-xs`,children:[(0,j.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`thinking`}),(0,j.jsx)(`span`,{className:`font-mono text-zinc-700 dark:text-zinc-200`,children:e})]}),(0,j.jsx)(`input`,{type:`range`,min:0,max:$E.length-1,step:1,value:s,onChange:e=>n($E[Number(e.target.value)]),"aria-label":`Thinking level`,"aria-valuetext":e,className:`w-full accent-amber-500`}),(0,j.jsxs)(`div`,{className:`mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,children:[(0,j.jsx)(`span`,{children:$E[0]}),(0,j.jsx)(`span`,{children:$E[$E.length-1]})]})]})]})}function JD(e){let{model:t,models:n,thinkingLevel:r,modelSupportsReasoning:i,isStreaming:a,contextUsage:o,sessionUsage:s,isCompacting:c}=e;return(0,j.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,j.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,j.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,j.jsxs)(`option`,{value:`${e.provider}/${e.id}`,children:[e.provider,`/`,e.id]},`${e.provider}/${e.id}`))]}),i&&(0,j.jsx)(qD,{thinkingLevel:r,isStreaming:a,onSetThinking:e.onSetThinking}),(0,j.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,j.jsx)(KD,{usage:o}),c?`compacting…`:o?.percent==null?`context`:`${Math.round(o.percent)}%`]}),(0,j.jsx)(GD,{usage:s,analysisOpen:e.analysisOpen,onToggleAnalysis:e.onToggleAnalysis})]})}var YD=`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`,XD=`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`;function ZD({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),C=a.some(e=>e.configured)&&!t.usableModel;function w(e){if(e.preventDefault(),!C){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,j.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto p-6`,children:(0,j.jsxs)(`form`,{onSubmit:w,className:`w-full max-w-md rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,j.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),C?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`h1`,{className:`mb-3 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model is available.`}),(0,j.jsxs)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:[`Credentials are configured, so this is not a missing key: `,(0,j.jsx)(`code`,{children:`allowedModels`}),` in your configuration leaves nothing to choose from. Widen it, or remove it, then restart.`]})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.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,j.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,j.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,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`label`,{htmlFor:`onboarding-provider`,className:XD,children:`Provider`}),(0,j.jsx)(`select`,{id:`onboarding-provider`,value:c,onChange:e=>l(e.target.value),className:`${YD} mb-3`,children:a.map(e=>(0,j.jsxs)(`option`,{value:e.id,children:[e.name,e.configured?` (already configured)`:``]},e.id))})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`label`,{htmlFor:`onboarding-name`,className:XD,children:`Name`}),(0,j.jsx)(`input`,{id:`onboarding-name`,value:p,onChange:e=>m(e.target.value),placeholder:`corp`,className:`${YD} mb-3`}),(0,j.jsx)(`label`,{htmlFor:`onboarding-url`,className:XD,children:`Base URL`}),(0,j.jsx)(`input`,{id:`onboarding-url`,value:h,onChange:e=>g(e.target.value),placeholder:`https://llm.corp.example/v1`,className:`${YD} mb-3`}),(0,j.jsx)(`label`,{htmlFor:`onboarding-model`,className:XD,children:`Model id`}),(0,j.jsx)(`input`,{id:`onboarding-model`,value:_,onChange:e=>v(e.target.value),placeholder:`gpt-oss-120b`,className:`${YD} mb-3`})]}),(0,j.jsx)(`label`,{htmlFor:`onboarding-key`,className:XD,children:`API key`}),(0,j.jsx)(`input`,{id:`onboarding-key`,type:`password`,autoComplete:`off`,value:u,onChange:e=>f(e.target.value),placeholder:`sk-…`,className:YD}),o===`custom`&&(0,j.jsxs)(`fieldset`,{className:`mt-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,j.jsx)(`legend`,{className:`px-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Compatibility`}),(0,j.jsxs)(`label`,{className:`flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5`}),(0,j.jsxs)(`span`,{children:[`Server understands the `,(0,j.jsx)(`code`,{children:`developer`}),` role. Uncheck for vLLM, SGLang and most corporate gateways — the system prompt is then sent as a `,(0,j.jsx)(`code`,{children:`system`}),` message.`]})]}),(0,j.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`mt-0.5`}),(0,j.jsxs)(`span`,{children:[`Server accepts `,(0,j.jsx)(`code`,{children:`reasoning_effort`}),`. Uncheck if it rejects unknown fields.`]})]})]}),(0,j.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,j.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,j.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,j.jsx)(`code`,{children:`pi-outpost login`}),`.`]})]})})}var QD=`application/x-pi-outpost-file`,$D=`application/x-pi-outpost-read-only-file`,eO=`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`,tO={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 nO(e,t){return t?Object.keys(t).filter(t=>t.startsWith(`${e}/`)).length:0}function rO(e){return e===`directory`||e===`symlink-directory`}function iO(e,t){return t===void 0?!1:t===null||t!==``&&e!==t&&!e.startsWith(`${t}/`)}function aO({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,j.jsxs)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5`,children:[(0,j.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,j.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:o})]})}function oO({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,j.jsxs)(`div`,{style:{paddingLeft:n*12+16},className:`py-0.5`,children:[(0,j.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,j.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:s})]})}function sO({path:e,depth:t,...n}){let r=n.tree[e],i=n.creation?.openIn===e?(0,j.jsx)(aO,{dir:e,depth:t,creation:n.creation}):null;return r===void 0?i:r===`loading`?(0,j.jsxs)(j.Fragment,{children:[i,(0,j.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,j.jsxs)(j.Fragment,{children:[i,(0,j.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,j.jsxs)(j.Fragment,{children:[i,i===null&&(0,j.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`empty`})]}):(0,j.jsxs)(j.Fragment,{children:[i,r.map(r=>(0,j.jsx)(cO,{parentPath:e,entry:r,depth:t,...n},r.name))]})}function cO({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=iO(c,r.writableRoot),u=r.fileOperation?.status===`pending`;if(rO(t.type)){let e=!l&&!u,d=e=>e.includes($D)?r.onCopyFile===void 0?null:`copy`:r.onMoveFile===void 0?null:`move`;return(0,j.jsxs)(`div`,{children:[(0,j.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(QD))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(QD),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,j.jsxs)(`button`,{type:`button`,onClick:()=>{let e=!i;a(e),e&&r.tree[c]===void 0&&r.onExpand(c)},style:{paddingLeft:n*12},className:`flex min-w-0 flex-1 items-center gap-1 rounded py-0.5 text-left`,children:[(0,j.jsx)(`span`,{className:`w-3 shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:i?`▾`:`▸`}),(0,j.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&&nO(c,r.gitFiles)>0&&(0,j.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:`${nO(c,r.gitFiles)} changed file(s) inside`,children:nO(c,r.gitFiles)})]}),r.creation&&!l&&(0,j.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,j.jsx)(sO,{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,j.jsx)(oO,{path:c,name:t.name,depth:n,rename:r.rename}):(0,j.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,j.jsx)(`button`,{type:`button`,draggable:v&&!u,onDragStart:e=>{!v||u||(e.dataTransfer.effectAllowed=l?`copy`:`move`,e.dataTransfer.setData(QD,c),l&&e.dataTransfer.setData($D,`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,j.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,j.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:eO,children:`↗`}),_&&r.onRenameFile&&(0,j.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>r.rename?.start(c),title:`Rename file`,"aria-label":`Rename ${t.name}`,className:eO,children:`✎`}),_&&r.onDeleteFile&&(0,j.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:`${eO} hover:text-red-600 dark:hover:text-red-400`,children:`×`}),r.onToggleAttachPath&&(0,j.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,j.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 ${tO[p].className}`,children:tO[p].label})]})}function lO(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 uO(e){let t=lO(e);return`error`in t?t:t.kind===`directory`?{error:`That is a folder name`}:{name:t.name}}function dO(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===fO(a.dir,a.name)?e.createError.message:null,g=e.created??null;(0,d.useEffect)(()=>{a!==null&&g!==null&&g===fO(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=lO(n);if(`error`in r){i(r.error);return}i(null),o({dir:t,name:r.name});let a=fO(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=uO(n);if(`error`in r){u(r.error);return}u(null),p(t),e.onRenameFile?.(t,r.name)}}:void 0,b=!iO(``,e.writableRoot);return(0,j.jsxs)(`div`,{className:`text-sm`,children:[e.fileOperation?.status===`error`&&e.fileOperation.operation!==`rename_file`&&(0,j.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,j.jsxs)(`div`,{className:`mb-1 flex items-center`,children:[v&&b&&(0,j.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,j.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,j.jsx)(sO,{path:``,depth:0,...e,...v?{creation:v}:{},...y?{rename:y}:{}})]})}function fO(e,t){return e===``?t:`${e}/${t}`}function pO({tree:e,openFile:t,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onRefresh:o,onSelectFile:s,onSelectDiff:c,onToggleAttachPath:l,onCreateFile:u,onCreateDirectory:f,onOpenNative:p,onRenameFile:m,onDeleteFile:h,onMoveFile:g,onCopyFile:_,fileOperation:v,createError:y,created:b}){let x=sD(tD);return(0,d.useEffect)(()=>{e[``]===void 0&&a(``)},[]),(0,j.jsxs)(`aside`,{"aria-label":`Files`,style:{width:x.width},className:`relative flex shrink-0 flex-col border-r border-zinc-200 dark:border-zinc-800`,children:[(0,j.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,j.jsx)(`div`,{className:`flex-1 overflow-auto p-2`,children:(0,j.jsx)(dO,{tree:e,openFilePath:t?.path,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onRefresh:o,onSelectFile:s,onSelectDiff:c,onToggleAttachPath:l,onCreateFile:u,onCreateDirectory:f,onOpenNative:p,onRenameFile:m,onDeleteFile:h,onMoveFile:g,onCopyFile:_,fileOperation:v,createError:y,created:b})}),(0,j.jsx)(cD,{label:`Resize Files sidebar`,width:x.width,config:tD,separatorProps:x.separatorProps})]})}function mO({title:e,onSubmit:t}){let[n,r]=(0,d.useState)(``);return(0,j.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,j.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,j.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),(0,j.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`This server requires an access token.`}),(0,j.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,j.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,j.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,j.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,j.jsx)(`code`,{children:`?token=…`})]})]})})}var hO={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`}},gO=8;function _O(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 vO({plan:e,open:t,onToggle:n,onOpenWorkspace:r}){let i=(0,d.useId)(),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(null);(0,d.useEffect)(()=>{s!==null&&!e.tasks.some(e=>e.id===s)&&c(null)},[e,s]),(0,d.useEffect)(()=>{if(!a)return;let e=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]);let l=(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]),u=(0,d.useMemo)(()=>new Map(e.tasks.map(e=>[e.id,e])),[e.tasks]),f=(0,d.useMemo)(()=>{let e=[],t=(n,r)=>{for(let i of l.get(n)??[])e.push({task:i,depth:r}),t(i.id,r+1)};return t(void 0,0),e.slice(0,gO)},[l]),p=s?u.get(s):void 0,m=e.tasks.filter(e=>e.status===`done`).length,h=(e,t=0)=>(l.get(e)??[]).flatMap(e=>{let n=hO[e.status];return[(0,j.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-level":t+1,"aria-selected":s===e.id,onClick:()=>c(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 ${s===e.id?`bg-zinc-100 dark:bg-zinc-800`:``}`,style:{paddingLeft:`${.5+t*.85}rem`},children:[(0,j.jsx)(`span`,{className:`mt-px w-4 shrink-0 text-center font-semibold ${n.className}`,"aria-label":n.label,children:n.icon}),(0,j.jsx)(`span`,{className:e.status===`done`?`text-zinc-500 line-through`:`text-zinc-800 dark:text-zinc-200`,children:e.title})]},e.id),...h(e.id,t+1)]});return t?(0,j.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,j.jsxs)(`header`,{className:`border-b border-zinc-200 px-3 py-3 dark:border-zinc-800`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-zinc-500`,children:`Work Plan`}),(0,j.jsx)(`h2`,{className:`truncate text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:e.title})]}),(0,j.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,j.jsxs)(`div`,{className:`mt-2 text-xs text-zinc-500`,children:[`Progress: `,m,` / `,e.tasks.length]}),(0,j.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-800`,"aria-hidden":!0,children:(0,j.jsx)(`div`,{className:`h-full bg-emerald-500`,style:{width:`${e.tasks.length===0?0:m/e.tasks.length*100}%`}})})]}),(0,j.jsx)(`div`,{role:`tree`,"aria-label":`Work Plan tasks`,className:`min-h-0 flex-1 overflow-y-auto p-2`,children:h(void 0)}),p&&(0,j.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,j.jsx)(`div`,{className:`font-semibold ${hO[p.status].className}`,children:hO[p.status].label}),(0,j.jsx)(`h3`,{className:`mt-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:p.title}),p.description&&(0,j.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-zinc-600 dark:text-zinc-300`,children:p.description}),p.statusReason&&(0,j.jsx)(`p`,{className:`mt-2 rounded bg-zinc-100 p-2 text-zinc-700 dark:bg-zinc-900 dark:text-zinc-300`,children:p.statusReason}),p.dependsOn.length>0&&(0,j.jsxs)(`div`,{className:`mt-3`,children:[(0,j.jsx)(`span`,{className:`font-semibold`,children:`Depends on:`}),` `,p.dependsOn.map(e=>u.get(e)?.title??e).join(`, `)]}),p.resources.length>0&&(0,j.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,j.jsx)(`div`,{className:`font-semibold`,children:`Resources`}),p.resources.map(e=>{let t=_O(e),n=e.label??e.uri;return t===null?/^https?:/i.test(e.uri)?(0,j.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,j.jsx)(`span`,{className:`block truncate text-zinc-500`,title:`No navigator is available for this resource`,children:n},e.uri):(0,j.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,j.jsxs)(`div`,{className:`absolute right-3 top-3 z-20`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocusCapture:()=>o(!0),onBlurCapture:()=>o(!1),children:[(0,j.jsxs)(`button`,{type:`button`,onClick:()=>{o(!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":i,children:[`Plan `,m,`/`,e.tasks.length]}),(0,j.jsx)(`div`,{id:i,role:`tooltip`,className:`absolute right-0 top-full w-72 pt-2 ${a?`block`:`hidden`}`,children:(0,j.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,j.jsx)(`ul`,{className:`space-y-1`,children:f.map(({task:e,depth:t})=>(0,j.jsxs)(`li`,{className:`flex min-w-0 items-start gap-1.5 text-xs`,style:{paddingLeft:`${t*.75}rem`},children:[(0,j.jsx)(`span`,{"aria-label":hO[e.status].label,className:`shrink-0 font-semibold ${hO[e.status].className}`,children:e.status===`done`?`☑`:`☐`}),(0,j.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>f.length&&(0,j.jsxs)(`div`,{className:`mt-1 text-[11px] text-zinc-500`,children:[`+`,e.tasks.length-f.length,` more`]})]})})]})}var yO=`pi-outpost:token`;function bO(){let e=null;try{let t=new URL(window.location.href);return e=t.searchParams.get(`token`),e&&(localStorage.setItem(yO,e),t.searchParams.delete(`token`),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)),localStorage.getItem(yO)}catch{return e}}function xO(){try{return localStorage.getItem(yO)}catch{return null}}function SO(e){try{localStorage.setItem(yO,e)}catch{}}function CO(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function wO(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}var TO={connected:!1,authRequired:!1,brandingReady:!1,branding:{},sessionId:``,model:``,thinkingLevel:`off`,modelSupportsReasoning:!1,models:[],commands:[],sessions:null,sessionSearch:null,tree:null,isStreaming:!1,items:[],pendingPrompt:null,workPlan: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:[],tools:[],sandbox:null,userSkillPaths:[],serverBrowse:null,settingsApply:null,versions:null,gitAvailable:!1,credentials:null,gitStatus:null,gitDiff:null,gitLog:null,gitShow:null,gitFileHistory:null,gitFileDiff:null};function EO(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 DO(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 OO(e,t){if(t.type!==`hello`&&t.type!==`session_replaced`&&t.type!==`update_config_ack`)return e;let n=t.models.find(e=>`${e.provider}/${e.id}`===t.model);return{...e,connected:!0,brandingReady:!0,branding:t.branding,sessionId:t.sessionId,model:t.model,thinkingLevel:t.thinkingLevel,modelSupportsReasoning:n?.reasoning??!1,models:t.models,commands:t.commands,isStreaming:t.isStreaming,items:t.items,pendingPrompt:null,workPlan:t.workPlan??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,gitAvailable:t.gitAvailable===!0,credentials:t.credentials??null,extensionPaths:t.extensionPaths??[],tools:t.tools??[],sandbox:t.sandbox??null,userSkillPaths:t.userSkillPaths??[],serverBrowse:null,settingsApply:null,versions:t.versions??null}}function kO(e,t){if(t.type===`connected`)return{...e,connected:!0,authRequired:!1};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;return{...e,connected:!1,openFile:n}}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===`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`}};let n=t.message;switch(n.type){case`hello`:case`session_replaced`:case`update_config_ack`:return OO(e,n);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};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,credentials:n.credentials}}case`thinking_changed`:return{...e,thinkingLevel:n.level};case`work_plan_changed`:return{...e,workPlan:n.workPlan};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:EO(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:EO(e.items,()=>n.item)};case`custom_message`:return{...e,items:[...e.items,n.item]};case`tool_start`:return{...e,items:DO(e.items,n.toolCallId,n.toolName,{toolName:n.toolName,args:n.args,running:!0,callHtml:n.callHtml})};case`tool_update`:return{...e,items:DO(e.items,n.toolCallId,`tool`,{output:n.text})};case`tool_end`:return{...e,items:DO(e.items,n.toolCallId,`tool`,{output:n.text,isError:n.isError,running:!1,outputHtml:n.outputHtml,outputHtmlCollapsed:n.outputHtmlCollapsed,structured:n.structured})};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;return{...e,gitStatus:{branch:n.branch,ahead:n.ahead,behind:n.behind,files:t}}}case`git_diff`:return{...e,gitDiff:{path:n.path,before:n.before,after:n.after}};case`git_log`:return{...e,gitLog: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||!wO(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 AO(e,t){let n=e?`${e.replace(/^http/,`ws`)}/ws`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/ws`;return t?`${n}?token=${encodeURIComponent(t)}`:n}var jO=12e4,MO=4401;function NO(e=``,t,n=!1){let[r,i]=(0,d.useReducer)(kO,TO),a=(0,d.useRef)(null),[o,s]=(0,d.useState)(0),c=(0,d.useRef)(null);o===0&&c.current===null&&(c.current=t??(n?xO():bO()));let l=(0,d.useRef)(r.fileTree),u=(0,d.useRef)(r.openFile);(0,d.useEffect)(()=>{l.current=r.fileTree},[r.fileTree]),(0,d.useEffect)(()=>{u.current=r.openFile},[r.openFile]);let f=(0,d.useRef)(null);(0,d.useEffect)(()=>{f.current=r.gitDiff?.path??null},[r.gitDiff]);let p=(0,d.useRef)(new Map),m=(0,d.useRef)(r.writableRoot);(0,d.useEffect)(()=>{m.current=r.writableRoot},[r.writableRoot]);let h=(0,d.useCallback)(e=>{let t=a.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[]),g=(0,d.useCallback)((e,t=!1)=>{let n=`dir:${crypto.randomUUID()}`;i({type:`dir_list_started`,path:e,requestId:n,preserveEntries:t}),h({type:`list_directory`,path:e,requestId:n})},[h]),_=(0,d.useRef)(!1),v=(0,d.useRef)(!1),y=(0,d.useRef)(!1),b=(0,d.useCallback)(()=>{if(_.current){if(v.current){y.current=!0;return}v.current=!0,h({type:`git_status`,requestId:`git:${crypto.randomUUID()}`})}},[h]),x=(0,d.useCallback)(()=>{v.current=!1,y.current&&(y.current=!1,b())},[b]),S=(0,d.useCallback)(e=>{l.current[e]!==void 0&&g(e,!0)},[g]),C=(0,d.useCallback)(()=>{for(let e of Object.keys(l.current))S(e)},[S]);return(0,d.useEffect)(()=>{let t=!1;return fetch(`${e}/branding`,{headers:c.current?{Authorization:`Bearer ${c.current}`}:{}}).then(e=>e.ok?e.json():null).then(e=>{t||i(e?{type:`branding_loaded`,branding:e}:{type:`branding_settled`})}).catch(()=>{t||i({type:`branding_settled`})}),()=>{t=!0}},[e,o]),(0,d.useEffect)(()=>{let t,n=!1;function r(){let o=new WebSocket(AO(e,c.current));a.current=o,o.onopen=()=>{a.current===o&&i({type:`connected`})},o.onmessage=e=>{if(a.current!==o)return;let t;try{t=JSON.parse(e.data)}catch{return}if(t.type===`file_uploaded`){let e=p.current.get(t.requestId);e&&(p.current.delete(t.requestId),e.resolve(t.path));return}if(t.type===`file_browser_error`&&p.current.has(t.requestId)){let e=p.current.get(t.requestId);p.current.delete(t.requestId),e.reject(new UT(t.message,t.reason));return}if(t.type===`file_changed`){S(CO(t.path));let e=u.current;if(e?.status===`loaded`&&e.path===t.path){let e=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:t.path,requestId:e,preserveContent:!0}),h({type:`read_file`,path:t.path,requestId:e})}f.current===t.path&&h({type:`git_diff`,path:t.path,requestId:`gitdiff:${crypto.randomUUID()}`}),b();return}if(t.type===`directory_changed`){S(t.path);let e=u.current;if(e!==null&&CO(e.path)===t.path){if(re(e.path)||ie(e.path))i({type:`raw_preview_changed`,path:e.path});else if(e.status===`loaded`){let t=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:e.path,requestId:t,preserveContent:!0}),h({type:`read_file`,path:e.path,requestId:t})}}let n=f.current;n!==null&&CO(n)===t.path&&h({type:`git_diff`,path:n,requestId:`gitdiff:${crypto.randomUUID()}`}),b();return}if((t.type===`hello`||t.type===`session_replaced`)&&(_.current=t.gitAvailable===!0,t.type===`hello`&&b()),t.type===`agent_end`&&b(),(t.type===`git_status`||t.type===`git_error`&&t.requestId.startsWith(`git:`))&&x(),t.type===`file_operation_result`){let e=t.previousPath??t.path,n=u.current;t.operation===`delete_file`&&n?.path===t.path?u.current=null:n?.path===e&&(u.current={...n,path:t.path})}i({type:`server`,message:t}),t.type===`session_replaced`&&g(``)},o.onclose=e=>{if(a.current===o){v.current=!1,y.current=!1;for(let e of p.current.values())e.reject(new UT(`The connection dropped before the upload finished`));if(p.current.clear(),e.code===MO){i({type:`auth_required`});return}i({type:`disconnected`}),n||(t=window.setTimeout(r,1500))}}}return r(),()=>{n=!0,t!==void 0&&clearTimeout(t);let e=a.current;a.current=null,e?.close()}},[h,e,b,x,S,g,o]),{state:r,authToken:c.current,submitToken:e=>{SO(e),c.current=e,i({type:`auth_retrying`}),s(e=>e+1)},prompt:(e,t)=>{i({type:`prompt_sent`,text:e,...t?.length?{images:t}:{}}),h({type:`prompt`,text:e,...t?.length?{images:t}:{}})},abort:()=>h({type:`abort`}),setModel:(e,t)=>h({type:`set_model`,provider:e,id:t}),setThinking:e=>h({type:`set_thinking`,level:e}),newSession:()=>h({type:`new_session`}),switchSession:e=>h({type:`switch_session`,path:e}),deleteSession:e=>h({type:`delete_session`,path:e}),listSessions:()=>h({type:`list_sessions`}),renameSession:(e,t)=>h({type:`rename_session`,path:e,name:t}),searchSessions:e=>{let t=`sessions:${crypto.randomUUID()}`;i({type:`session_search_started`,query:e,requestId:t}),h({type:`search_sessions`,query:e,requestId:t})},clearSessionSearch:()=>i({type:`session_search_cleared`}),listTree:()=>h({type:`list_tree`}),navigateTree:e=>h({type:`navigate_tree`,entryId:e}),forkSession:e=>h({type:`fork_session`,entryId:e}),editPrompt:(e,t,n)=>h({type:`edit_prompt`,entryId:e,text:t,...n?.length?{images:n}:{}}),compact:()=>h({type:`compact`}),respondToDialog:e=>{h({type:`extension_ui_response`,...e}),i({type:`dialog_answered`})},dismissNotification:e=>i({type:`dismiss_notification`,id:e}),listDirectory:e=>g(e),refreshFileTree:C,readFile:e=>{let t=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:e,requestId:t}),h({type:`read_file`,path:e,requestId:t})},closeFilePreview:()=>i({type:`close_file_preview`}),writeFile:(e,t,n,r=!1)=>{let a=`write:${crypto.randomUUID()}`;i({type:`file_save_started`,path:e,requestId:a,content:t}),h({type:`write_file`,path:e,content:t,expectedMtimeMs:n,...r?{force:r}:{},requestId:a})},createFile:e=>{i({type:`file_create_started`}),h({type:`create_file`,path:e,requestId:`create:${crypto.randomUUID()}`})},uploadFile:(e,t)=>{let n=m.current;if(n===null)return Promise.reject(new UT(`the workspace is read-only`,`denied`));let r=a.current;if(!r||r.readyState!==WebSocket.OPEN)return Promise.reject(new UT(`not connected to the server`));let i=n?`${n}/${HT}`:HT,o=`upload:${crypto.randomUUID()}`;return new Promise((n,r)=>{let a=window.setTimeout(()=>{p.current.delete(o)&&r(new UT(`the upload timed out`))},jO),s=e=>t=>{clearTimeout(a),e(t)};p.current.set(o,{resolve:s(n),reject:s(r)}),h({type:`upload_file`,destinationDirectory:i,name:e,contentBase64:t,requestId:o})})},createDirectory:e=>{i({type:`file_create_started`}),h({type:`create_directory`,path:e,requestId:`create:${crypto.randomUUID()}`})},openNative:e=>{let t=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`open_native`,path:e,requestId:t}),h({type:`open_native`,path:e,requestId:t})},renameFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`rename_file`,path:e,requestId:n}),h({type:`rename_file`,path:e,name:t,requestId:n})},deleteFile:e=>{let t=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`delete_file`,path:e,requestId:t}),h({type:`delete_file`,path:e,requestId:t})},moveFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`move_file`,path:e,requestId:n}),h({type:`move_file`,path:e,destinationDirectory:t,requestId:n})},copyFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`copy_file`,path:e,requestId:n}),h({type:`copy_file`,path:e,destinationDirectory:t,requestId:n})},searchFiles:e=>{let t=`search:${crypto.randomUUID()}`;i({type:`file_search_started`,query:e,requestId:t}),h({type:`search_files`,query:e,requestId:t})},clearFileSearch:()=>i({type:`file_search_cleared`}),fetchGitStatus:b,fetchGitDiff:e=>{let t=`gitdiff:${crypto.randomUUID()}`;i({type:`git_diff_started`,path:e,requestId:t}),h({type:`git_diff`,path:e,requestId:t})},clearGitDiff:()=>i({type:`git_diff_cleared`}),fetchGitLog:e=>h({type:`git_log`,...e?{limit:e}:{},requestId:`gitlog:${crypto.randomUUID()}`}),fetchGitShow:e=>h({type:`git_show`,sha:e,requestId:`gitshow:${crypto.randomUUID()}`}),clearGitShow:()=>i({type:`git_show_cleared`}),fetchGitFileHistory:(e,t)=>{let n=`gitfilelog:${crypto.randomUUID()}`;i({type:`git_file_history_started`,path:e,requestId:n}),h({type:`git_file_log`,path:e,...t?{limit:t}:{},requestId:n})},closeGitFileHistory:()=>i({type:`git_file_history_closed`}),fetchGitFileDiff:(e,t)=>{let n=`gitfilediff:${crypto.randomUUID()}`;i({type:`git_file_diff_started`,base:e,target:t,requestId:n}),h({type:`git_file_diff`,base:e,target:t,requestId:n})},clearGitFileDiff:()=>i({type:`git_file_diff_cleared`}),setCredential:(e,t)=>h({type:`set_credential`,provider:e,apiKey:t}),declareProvider:e=>h({type:`declare_provider`,...e}),browseServerDirectory:e=>{let t=`serverdir:${crypto.randomUUID()}`;i({type:`server_browse_started`,path:e,requestId:t}),h({type:`browse_server_directory`,path:e,requestId:t})},closeServerBrowser:()=>i({type:`server_browse_closed`}),updateConfig:e=>{i({type:`settings_apply_started`}),h({type:`update_config`,...e})}}}var PO=(0,d.forwardRef)(function({serverUrl:e=``,rootElement:t,initialTheme:n,token:r},i){let a=t!==void 0,o=t??document.documentElement,{state:s,authToken:c,submitToken:l,prompt:u,abort:f,setModel:m,setThinking:h,newSession:g,switchSession:_,deleteSession:v,listSessions:b,renameSession:x,searchSessions:S,clearSessionSearch:C,listTree:w,navigateTree:T,forkSession:E,editPrompt:ee,compact:D,respondToDialog:O,dismissNotification:te,listDirectory:ne,refreshFileTree:k,readFile:A,writeFile:se,createFile:ce,createDirectory:le,uploadFile:ue,openNative:M,renameFile:de,deleteFile:fe,moveFile:pe,copyFile:me,closeFilePreview:he,searchFiles:ge,clearFileSearch:_e,fetchGitDiff:ve,clearGitDiff:ye,fetchGitLog:be,fetchGitShow:xe,clearGitShow:Se,fetchGitFileHistory:Ce,closeGitFileHistory:we,fetchGitFileDiff:Te,clearGitFileDiff:Ee,setCredential:De,declareProvider:Oe,updateConfig:ke,browseServerDirectory:je,closeServerBrowser:Me}=NO(e,r,a),[Ne,Pe]=(0,d.useState)(!1),[Fe,Ie]=(0,d.useState)([]),[Le,Re]=(0,d.useState)([]),[ze,Be]=(0,d.useState)(null),[Ve,He]=(0,d.useState)(null),[Ue,We]=(0,d.useState)(null),[Ge,Ke]=(0,d.useState)(!1),qe=(0,d.useRef)([]),Je=(0,d.useRef)(null),N=(0,d.useRef)(null),[Ye,Xe]=(0,d.useState)(!1),[Ze,Qe]=(0,d.useState)(()=>{try{return localStorage.getItem(`pi-outpost:hide-tools`)===`1`}catch{return!1}});function $e(){Qe(e=>{try{localStorage.setItem(`pi-outpost:hide-tools`,e?`0`:`1`)}catch{}return!e})}let[et,tt]=(0,d.useState)(!1),[nt,rt]=(0,d.useState)(!0);function it(){let e=!et;tt(e),e&&rt(!1)}function at(){let e=!nt;rt(e),e&&tt(!1)}let[ot,st]=(0,d.useState)([]),[ct,lt]=(0,d.useState)([]),ut=(0,d.useRef)(0),dt=(0,d.useRef)(0),[ft,pt]=(0,d.useState)(0);async function mt(e){let t=[...e],n=t.filter(qT).map(e=>({id:`${ut.current++}`,name:e.name}));n.length>0&&lt(e=>[...e,...n]),dt.current===0&&st([]),dt.current++;try{let{attachments:e,errors:n}=await tE(t,ue);e.length>0&&Ie(t=>[...t,...e]),n.length>0&&st(e=>[...e,...n])}finally{if(dt.current--,n.length>0){let e=new Set(n.map(e=>e.id));lt(t=>t.filter(t=>!e.has(t.id)))}}}(0,d.useEffect)(()=>{qe.current=Fe},[Fe]),(0,d.useEffect)(()=>{let t=s.openFile;if(!t)return;let n=t.path,r=t.status===`loaded`,i=t.status===`error`&&t.message===`Binary file — preview not supported`&&ae(n);if(Je.current!==n&&(Je.current=n,N.current=null,Ie(e=>e.filter(e=>e.source!==`preview`)),Be(null),He(null),We(null)),N.current===n)return;(re(n)||ie(n))&&Ie(e=>e.filter(e=>e.source!==`preview`));let a=!1;async function o(){let t=re(n)?Ve===n?await sE(n,oe(e,n,c,s.previewRevision)):null:ie(n)?Ue?.path===n&&Ue.revision===s.previewRevision?rE(n):null:i||r?nE(n):null;if(!(a||t===null||Je.current!==n||N.current===n)){if(typeof t==`string`){Be(t);return}Be(null),Ie(e=>uE(e,t))}}return o(),()=>{a=!0}},[s.openFile,s.previewRevision,e,c,Ve,Ue]);function ht(){Je.current=null,N.current=null,he()}let gt=(0,d.useMemo)(()=>[...Fe.filter(e=>e.kind===`path`).map(e=>e.data),...Le],[Fe,Le]);function _t(e){let t=qe.current.findIndex(t=>t.kind===`path`&&t.data===e);t>=0?vt(t):Le.includes(e)||Ie(t=>lE(t,e))}function vt(e){let t=qe.current[e];t?.source===`preview`&&(N.current=t.previewPath??Je.current,Be(null)),Ie(t=>dE(t,e))}function yt(e,t){u(e,t),Ie([]),st([]),Be(null),Ge||ht()}function bt(e){e.preventDefault(),pt(0),e.dataTransfer.files.length>0&&mt(Array.from(e.dataTransfer.files))}let{theme:xt,toggle:St,setTheme:Ct}=y(s.branding.defaultTheme??`system`,s.branding.allowThemeToggle!==!1,o,n);(0,d.useImperativeHandle)(i,()=>({setTheme:Ct}),[Ct]);let wt=(0,d.useRef)(null),Tt=(0,d.useRef)(null),Et=(0,d.useRef)(!0);function Dt(){let e=wt.current;e&&(Et.current=e.scrollHeight-e.scrollTop-e.clientHeight<120)}(0,d.useEffect)(()=>{Et.current&&Tt.current?.scrollIntoView({behavior:`smooth`})},[s.items]);let Ot=(0,d.useMemo)(()=>cT(s.items),[s.items]),kt=(0,d.useMemo)(()=>et?vT(s.items):null,[et,s.items]),At=(0,d.useMemo)(()=>W_({readFile:e=>{Xe(!1),A(e)},fetchGitFileHistory:e=>Ce(e),fetchGitDiff:e=>{Xe(!0),A(e)},searchFiles:e=>ge(e)}),[A,Ce,ge]),jt=(0,d.useCallback)(()=>Qe(!1),[]),{jumpToItem:Mt,highlightIndex:Nt}=LT({items:s.items,scrollerRef:wt,hideTools:Ze,onShowTools:jt,stickToBottom:Et});return(0,d.useEffect)(()=>{a||(document.title=s.extensionTitle??s.branding.title??`pi`),s.branding.accentColor&&o.style.setProperty(`--accent`,s.branding.accentColor)},[s.branding,s.extensionTitle,a,o]),a&&!s.brandingReady?null:s.authRequired?(0,j.jsx)(p.Provider,{value:xt,children:(0,j.jsx)(mO,{title:s.branding.title,onSubmit:l})}):s.credentials&&!s.credentials.usableModel?(0,j.jsx)(p.Provider,{value:xt,children:(0,j.jsx)(ZD,{title:s.branding.title,credentials:s.credentials,onSetCredential:De,onDeclareProvider:Oe,errors:s.errors})}):(0,j.jsxs)(p.Provider,{value:xt,children:[(0,j.jsxs)(`div`,{className:`relative flex h-full`,onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&pt(e=>e+1)},onDragLeave:()=>pt(e=>Math.max(0,e-1)),onDragOver:e=>e.preventDefault(),onDrop:bt,children:[ft>0&&(0,j.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,j.jsx)(`p`,{className:`text-lg font-medium text-zinc-700 dark:text-zinc-200`,children:`Drop files to attach (images, documents & text)`})}),Ne&&(0,j.jsx)(pO,{tree:s.fileTree,openFile:s.openFile,writableRoot:s.writableRoot,gitFiles:s.gitStatus?.files,attachedPaths:gt,onExpand:ne,onRefresh:k,onSelectFile:e=>{Xe(!1),A(e)},onSelectDiff:e=>{Xe(!0),A(e)},onToggleAttachPath:_t,onCreateFile:e=>{Xe(!1),ce(e)},onCreateDirectory:le,onOpenNative:M,onRenameFile:de,onDeleteFile:fe,onMoveFile:pe,onCopyFile:me,fileOperation:s.fileOperation,createError:s.createError,created:s.created}),(0,j.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[(0,j.jsx)(UD,{title:s.branding.title,sessions:s.sessions,sessionSearch:s.sessionSearch,sessionId:s.sessionId,tree:s.tree,isStreaming:s.isStreaming,connected:s.connected,theme:xt,showThemeToggle:s.branding.allowThemeToggle!==!1,statuses:s.statuses,sidebarOpen:Ne,hideTools:Ze,onToggleSidebar:()=>Pe(!Ne),onToggleHideTools:$e,onToggleTheme:St,onNewSession:g,onSwitchSession:_,onDeleteSession:v,onListSessions:b,onRenameSession:x,onSearchSessions:S,onClearSessionSearch:C,onListTree:w,onNavigateTree:T,onForkSession:E,gitAvailable:s.gitAvailable,gitStatus:s.gitStatus,gitLog:s.gitLog,extensionPaths:s.extensionPaths,tools:s.tools,commands:s.commands,sandbox:s.sandbox,userSkillPaths:s.userSkillPaths,serverBrowse:s.serverBrowse,settingsApply:s.settingsApply,versions:s.versions,onBrowseServerPath:je,onCloseServerBrowser:Me,onUpdateConfig:ke,onFetchGitLog:be,onShowCommit:xe}),(0,j.jsxs)(`div`,{className:`relative z-0 flex min-h-0 flex-1 flex-col`,children:[s.workPlan&&(0,j.jsx)(vO,{plan:s.workPlan,open:nt,onToggle:at,onOpenWorkspace:e=>{Xe(!1),A(e)}}),s.openFile&&(0,j.jsx)(XE,{file:s.openFile,writableRoot:s.writableRoot,isStreaming:s.isStreaming,onDirtyChange:Ke,gitState:s.gitStatus?.files[s.openFile.path],initialShowGitDiff:Ye,gitDiff:s.gitDiff,onFetchGitDiff:ve,onClearGitDiff:ye,gitAvailable:s.gitAvailable,onOpenGitHistory:Ce,onClose:ht,onReload:A,onSave:se,serverUrl:e,token:c,onImageLoad:He,onPdfLoad:e=>We({path:e,revision:s.previewRevision}),rawRevision:s.previewRevision},s.openFile.path),s.gitFileHistory&&(0,j.jsx)(SD,{history:s.gitFileHistory,diff:s.gitFileDiff,dirty:s.gitStatus?.files[s.gitFileHistory.path]!==void 0,onFetchDiff:Te,onClearDiff:Ee,onClose:we}),s.gitShow&&(0,j.jsx)(QE,{show:s.gitShow,onClose:Se}),kt&&(0,j.jsx)(FT,{analysis:kt,onJump:Mt,onClose:()=>tt(!1)}),(0,j.jsx)(`main`,{ref:wt,onScroll:Dt,className:`flex-1 overflow-y-auto ${et?`md:pr-[26rem]`:s.workPlan&&nt?`md:pr-[23rem]`:``}`,children:(0,j.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-3 px-4 py-6`,children:[s.items.length===0&&(0,j.jsxs)(`div`,{className:`mt-24 text-center text-zinc-500 dark:text-zinc-600`,children:[(0,j.jsx)(`div`,{className:`mb-2 text-4xl`,children:s.branding.title??`π`}),(0,j.jsx)(`p`,{className:`text-sm`,children:s.branding.welcome??`Send a message to start the agent.`})]}),s.items.map((t,n)=>{let r=`${s.sessionId}:${n}`,i=(e,t=r)=>(0,j.jsx)(`div`,{"data-item-index":n,className:`flex flex-col gap-3 rounded-lg transition-shadow ${Nt===n?`ring-2 ring-blue-400 dark:ring-blue-500`:``}`,children:e},t);if(t.kind===`user`){let e=n===s.items.length-1&&s.isStreaming;return i((0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(Ae,{item:t,canEdit:!s.isStreaming&&s.connected,onEdit:ee}),e&&(0,j.jsx)(`div`,{className:`flex justify-end px-4`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,j.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,j.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`working…`})]})})]}))}return t.kind===`tool`?Ze?null:i((0,j.jsx)(aT,{item:t,dispatch:At}),t.toolCallId?`${s.sessionId}:${t.toolCallId}`:r):t.kind===`custom`?i((0,j.jsx)(oT,{item:t})):t.blocks.length===0&&!t.errorMessage?(0,j.jsx)(`div`,{"data-item-index":n,className:`sr-only`,"aria-hidden":!0},r):i((0,j.jsx)(V_,{item:t,serverUrl:e,token:c,onOpenFile:e=>{Xe(!1),A(e)}}))}),s.pendingPrompt&&(0,j.jsxs)(`div`,{className:`flex flex-col gap-3 opacity-60`,"data-pending-prompt":!0,children:[(0,j.jsx)(Ae,{item:{kind:`user`,...s.pendingPrompt},canEdit:!1,onEdit:()=>{}}),(0,j.jsx)(`div`,{className:`flex justify-end px-4`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,j.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,j.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`sending…`})]})})]}),(s.queue.steering.length>0||s.queue.followUp.length>0)&&(0,j.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:[s.queue.steering.map((e,t)=>(0,j.jsxs)(`div`,{children:[`⏩ steering: `,e]},`s${t}`)),s.queue.followUp.map((e,t)=>(0,j.jsxs)(`div`,{children:[`⏭ follow-up: `,e]},`f${t}`))]}),ot.map((e,t)=>(0,j.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}`)),ze&&(0,j.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:ze}),s.errors.map((e,t)=>(0,j.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,j.jsx)(`div`,{ref:Tt})]})})]}),(0,j.jsx)(`footer`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,j.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,j.jsx)(BE,{widgets:s.widgets,placement:`aboveEditor`}),(0,j.jsx)(yE,{isStreaming:s.isStreaming,connected:s.connected,commands:s.commands,fileSearch:s.fileSearch,prefill:s.editorPrefill,attachments:Fe,pendingUploads:ct,onAttach:e=>void mt(e),onMentionPaths:Re,onRemoveAttachment:vt,onSend:yt,onAbort:f,onSearchFiles:ge,onClearFileSearch:_e}),(0,j.jsx)(BE,{widgets:s.widgets,placement:`belowEditor`}),(0,j.jsx)(JD,{model:s.model,models:s.models,thinkingLevel:s.thinkingLevel,modelSupportsReasoning:s.modelSupportsReasoning,isStreaming:s.isStreaming,contextUsage:s.contextUsage,sessionUsage:Ot,analysisOpen:et,onToggleAnalysis:it,isCompacting:s.isCompacting,onSetModel:m,onSetThinking:h,onCompact:D})]})})]})]}),s.dialogQueue[0]&&(0,j.jsx)(kE,{request:s.dialogQueue[0],onRespond:O}),(0,j.jsx)(NE,{notifications:s.notifications,onDismiss:te})]})});(0,f.createRoot)(document.getElementById(`root`)).render((0,j.jsx)(d.StrictMode,{children:(0,j.jsx)(PO,{})}));export{i,A as n,oe as r,M as t};