pi-outpost 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pi-outpost.mjs +78 -78
- package/dist/pi-outpost.sea.mjs +78 -78
- package/dist/sea-prep.blob +0 -0
- package/dist/web/assets/{PdfViewer-CEAp6biY.js → PdfViewer-DLZN8MPh.js} +2 -2
- package/dist/web/assets/{abnfDiagram-N423BO3Z-BE4AMXSH.js → abnfDiagram-N423BO3Z-D8cHpBgq.js} +1 -1
- package/dist/web/assets/architecture-TIHT7OUA-Bbye2zvN.js +1 -0
- package/dist/web/assets/{architectureDiagram-T3A2C74G-tjG-eidb.js → architectureDiagram-T3A2C74G-DtsZcpid.js} +1 -1
- package/dist/web/assets/{blockDiagram-VBNYF7ZC-Bwzla1cD.js → blockDiagram-VBNYF7ZC-DG-Vee2I.js} +1 -1
- package/dist/web/assets/{c4Diagram-5PPSVZJV-BbNH9mqH.js → c4Diagram-5PPSVZJV-Cge6rtb_.js} +1 -1
- package/dist/web/assets/channel-DlNfTXiL.js +1 -0
- package/dist/web/assets/{chunk-2GRJ4B5K-BTjPaaWT.js → chunk-2GRJ4B5K-ky7RxMVL.js} +1 -1
- package/dist/web/assets/{chunk-3NCLNEKW-DfGGO5Az.js → chunk-3NCLNEKW-CkyESs3z.js} +1 -1
- package/dist/web/assets/{chunk-4I5QYGJK-Bajr_p-3.js → chunk-4I5QYGJK-CYlPMYIs.js} +1 -1
- package/dist/web/assets/{chunk-5RXB4S5H-CbDXtSwX.js → chunk-5RXB4S5H-BVOdrmAn.js} +1 -1
- package/dist/web/assets/{chunk-6Q2QTUOP-Cj5IB9-q.js → chunk-6Q2QTUOP-9AakjZbi.js} +1 -1
- package/dist/web/assets/{chunk-7Z6QIM7H-BIsTfYEd.js → chunk-7Z6QIM7H-C7bVXCbI.js} +1 -1
- package/dist/web/assets/{chunk-GF5L2VYU-CYLPBeKA.js → chunk-GF5L2VYU-DZPA6KQK.js} +1 -1
- package/dist/web/assets/{chunk-I66GZJ75-BjZt7BZl.js → chunk-I66GZJ75-VSO4Repf.js} +3 -3
- package/dist/web/assets/{chunk-J7OUQ5F2-B3gViRUp.js → chunk-J7OUQ5F2-D8dEppC4.js} +2 -2
- package/dist/web/assets/{chunk-JQJVKLGR-Dg177seh.js → chunk-JQJVKLGR-_IJrkM-o.js} +1 -1
- package/dist/web/assets/{chunk-KBJHAD2P-B_2jByMg.js → chunk-KBJHAD2P-Bo-QJ3Aq.js} +1 -1
- package/dist/web/assets/{chunk-NSK5VX7P-B5w-3_Ed.js → chunk-NSK5VX7P-CE77LZ3f.js} +1 -1
- package/dist/web/assets/{chunk-QR6OTTB3-DCJRxmQT.js → chunk-QR6OTTB3-_WMniCw7.js} +1 -1
- package/dist/web/assets/{chunk-UBXNYLIW-DBuIxFzr.js → chunk-UBXNYLIW-Bo4ZY-E5.js} +1 -1
- package/dist/web/assets/{chunk-W5SLKNZC-B-cGIOQF.js → chunk-W5SLKNZC-DE2NR4g3.js} +1 -1
- package/dist/web/assets/{chunk-WRU74C26-CLOxZV1w.js → chunk-WRU74C26-vZRte2zw.js} +1 -1
- package/dist/web/assets/classDiagram-JCYQIIEL-C2FqsfZm.js +1 -0
- package/dist/web/assets/classDiagram-v2-OCEON4UE-C2FqsfZm.js +1 -0
- package/dist/web/assets/{cynefin-VYW2F7L2-Bk96SN7L.js → cynefin-VYW2F7L2-CVQrkebh.js} +1 -1
- package/dist/web/assets/{cynefinDiagram-MW4NZA55-ooeswKGp.js → cynefinDiagram-MW4NZA55-BJEVaxY2.js} +1 -1
- package/dist/web/assets/{dagre-VZM6K2ZE-CSwH_rTA.js → dagre-VZM6K2ZE-Cg4yzfsn.js} +1 -1
- package/dist/web/assets/{diagram-7IWD3JNH-DVtrh_uV.js → diagram-7IWD3JNH-Bzhc3XNc.js} +1 -1
- package/dist/web/assets/{diagram-B4RE2ZJO-CYE5VmiD.js → diagram-B4RE2ZJO-cOBYJrqu.js} +1 -1
- package/dist/web/assets/{diagram-LBJQPF4R-BYOlHlmg.js → diagram-LBJQPF4R-DezvCa9m.js} +1 -1
- package/dist/web/assets/{diagram-Q27KOJAE-DJWxpvu9.js → diagram-Q27KOJAE-C8JzJOPz.js} +1 -1
- package/dist/web/assets/{diagram-UB23O5K3-B1g-vwj0.js → diagram-UB23O5K3-DcVfocW3.js} +1 -1
- package/dist/web/assets/{ebnfDiagram-BXEA7PRR-BX8Jv2Vd.js → ebnfDiagram-BXEA7PRR-1x68Vwg9.js} +1 -1
- package/dist/web/assets/{erDiagram-JOGREHBK-9hxklGu2.js → erDiagram-JOGREHBK-BQcP40bV.js} +1 -1
- package/dist/web/assets/eventmodeling-45OFAUF4-BDJFYTu6.js +1 -0
- package/dist/web/assets/flowDiagram-UKHOOZJN-KC9e-3Cq.js +1 -0
- package/dist/web/assets/{ganttDiagram-PKOTCBZU-D0kAnvoM.js → ganttDiagram-PKOTCBZU-mtDAHz0-.js} +1 -1
- package/dist/web/assets/{gitGraph-TEB2WS4Q-C9UMPCgj.js → gitGraph-TEB2WS4Q-FM2NyYE9.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-DS77QQ5N-6tPgqwE6.js → gitGraphDiagram-DS77QQ5N-BDfffmo3.js} +1 -1
- package/dist/web/assets/{index-De86t3J_.js → index-BiD5GZid.js} +8 -8
- package/dist/web/assets/{info-DKCQHKI2-BBV4qqmE.js → info-DKCQHKI2-B23QY2Bc.js} +1 -1
- package/dist/web/assets/{infoDiagram-6WML65LV-Bmhc86CN.js → infoDiagram-6WML65LV-_bzukZq-.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-WSZJBQD7-5wn4Yv2C.js → ishikawaDiagram-WSZJBQD7-BgAcJxsO.js} +1 -1
- package/dist/web/assets/{journeyDiagram-NVQOT4AX-DJLLpQlS.js → journeyDiagram-NVQOT4AX-DTnE9xwZ.js} +1 -1
- package/dist/web/assets/{kanban-definition-27J2QSJJ-7h9EMbUW.js → kanban-definition-27J2QSJJ-ClbSvAIG.js} +1 -1
- package/dist/web/assets/{line-Uu7s3CmK.js → line-D_QU9Cmq.js} +1 -1
- package/dist/web/assets/{mermaid-parser.core-DwpLoctN.js → mermaid-parser.core-BYcme6-K.js} +3 -3
- package/dist/web/assets/{mermaid.core-CRSZr8Y7.js → mermaid.core-BVGHn3kY.js} +3 -3
- package/dist/web/assets/{mindmap-definition-FAOFIHXS-DPic1KLK.js → mindmap-definition-FAOFIHXS-CvEfGwYt.js} +1 -1
- package/dist/web/assets/{packet-7NZHBO7P-CMRjleUu.js → packet-7NZHBO7P-C9jELtlO.js} +1 -1
- package/dist/web/assets/{pdf-DGJrgWix.js → pdf-DAk1L9of.js} +1 -1
- package/dist/web/assets/{pegDiagram-VL7TDLO6-CdECC4cs.js → pegDiagram-VL7TDLO6-CghIs6yt.js} +1 -1
- package/dist/web/assets/{pie-RZYD4A2V-C5X4oGn0.js → pie-RZYD4A2V-BrSou7Yh.js} +1 -1
- package/dist/web/assets/{pieDiagram-7S7Q4E2Y-Bvs4Q2O-.js → pieDiagram-7S7Q4E2Y-B5wcGLdh.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-CIZ2JOQS-FsUrYDg7.js → quadrantDiagram-CIZ2JOQS-qgPFvNxk.js} +1 -1
- package/dist/web/assets/{radar-I7S5WNFK-tvx7HrZO.js → radar-I7S5WNFK-SP4m6cq2.js} +1 -1
- package/dist/web/assets/{railroad-3IZDKUUU-DBks1QD-.js → railroad-3IZDKUUU-BsjoOneH.js} +1 -1
- package/dist/web/assets/railroad-abnf-AHOZXSZD-BVDgGfHK.js +1 -0
- package/dist/web/assets/railroad-ebnf-EBAXGLYW-Bb8EnDyP.js +1 -0
- package/dist/web/assets/railroad-peg-LSFZ7HO6-CwFMC2lj.js +1 -0
- package/dist/web/assets/{railroadDiagram-AXF67PYL-CBvFYCmN.js → railroadDiagram-AXF67PYL-t6xnVIcM.js} +1 -1
- package/dist/web/assets/{requirementDiagram-LRYGKXZP-C-rumttI.js → requirementDiagram-LRYGKXZP-CZkV6LhH.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-W5VNT64P-ClOK2cdj.js → sankeyDiagram-W5VNT64P-BpQAGTND.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-SI44F4Z6-B0pKllVj.js → sequenceDiagram-SI44F4Z6-C12jxyG4.js} +1 -1
- package/dist/web/assets/{stateDiagram-OKZ733FA-BoAWywzk.js → stateDiagram-OKZ733FA-BPjwRBUN.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-UEYNNEHI-DcBcxdoV.js +1 -0
- package/dist/web/assets/{swimlanes-SLNWSIFB-cdgjeXSf.js → swimlanes-SLNWSIFB-CDJ8S0lB.js} +1 -1
- package/dist/web/assets/swimlanesDiagram-ULZ7WXOC-DaR8FwWp.js +8 -0
- package/dist/web/assets/{timeline-definition-Z64GVDOM-ByMPGIEh.js → timeline-definition-Z64GVDOM-DxPzKILG.js} +1 -1
- package/dist/web/assets/{treeView-QDETBFTQ-zBqwQF47.js → treeView-QDETBFTQ-DAYvqyNi.js} +1 -1
- package/dist/web/assets/{treemap-6X3UGDF4-C2U9S2di.js → treemap-6X3UGDF4-CnqRm2UE.js} +1 -1
- package/dist/web/assets/{vennDiagram-T6HMQDX7-CyJfOcB0.js → vennDiagram-T6HMQDX7-CJlSyyPD.js} +1 -1
- package/dist/web/assets/{wardley-OPB4EBWU-CDxzQuvF.js → wardley-OPB4EBWU-BLz9JeoC.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-T6FBY63Y-IO8_CDTG.js → wardleyDiagram-T6FBY63Y-Dq_bL4Vh.js} +1 -1
- package/dist/web/assets/{xychartDiagram-ELKLHX3M-UUfxFEDc.js → xychartDiagram-ELKLHX3M-Ckxi00vc.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/web/assets/architecture-TIHT7OUA-DgTbwInB.js +0 -1
- package/dist/web/assets/channel-CXbqHDJA.js +0 -1
- package/dist/web/assets/classDiagram-JCYQIIEL-lv93WkUc.js +0 -1
- package/dist/web/assets/classDiagram-v2-OCEON4UE-lv93WkUc.js +0 -1
- package/dist/web/assets/eventmodeling-45OFAUF4-CSvMsqcO.js +0 -1
- package/dist/web/assets/flowDiagram-UKHOOZJN-CPmAOaGQ.js +0 -1
- package/dist/web/assets/railroad-abnf-AHOZXSZD-BnvB29Nv.js +0 -1
- package/dist/web/assets/railroad-ebnf-EBAXGLYW-BUSDQ0vn.js +0 -1
- package/dist/web/assets/railroad-peg-LSFZ7HO6-CZV0givf.js +0 -1
- package/dist/web/assets/stateDiagram-v2-UEYNNEHI-CHrsco-w.js +0 -1
- package/dist/web/assets/swimlanesDiagram-ULZ7WXOC-DPjAUQdL.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-BAwe9Wua.js","assets/rolldown-runtime-QTnfLwEv.js","assets/mermaid.core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-BAwe9Wua.js","assets/rolldown-runtime-QTnfLwEv.js","assets/mermaid.core-BVGHn3kY.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-_wZywoZs.js","assets/chunk-I66GZJ75-VSO4Repf.js","assets/chunk-NSK5VX7P-CE77LZ3f.js","assets/dist-D9sYb5Oa.js","assets/chunk-3NCLNEKW-CkyESs3z.js","assets/chunk-4I5QYGJK-CYlPMYIs.js","assets/chunk-WRU74C26-vZRte2zw.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-UBXNYLIW-Bo4ZY-E5.js","assets/chunk-W5SLKNZC-DE2NR4g3.js","assets/chunk-QR6OTTB3-_WMniCw7.js","assets/rough.esm-CSKSodPl.js","assets/chunk-7Z6QIM7H-C7bVXCbI.js","assets/line-D_QU9Cmq.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-J7OUQ5F2-D8dEppC4.js","assets/chunk-ZIRB5QZD-C6fEPe3t.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{n as e,r as t,t as n}from"./rolldown-runtime-QTnfLwEv.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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`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 te(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ne=/\/+/g;function re(e,t){return typeof e==`object`&&e&&e.key!=null?te(``+e.key):t.toString(36)}function ie(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 ae(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ae(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+re(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(ne,`$&/`)+`/`),ae(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(ne,`$&/`)+`/`)+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+re(a,u),c+=ae(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+re(a,u++),c+=ae(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ae(ie(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 oe(e,t,n){if(e==null)return e;var r=[],i=0;return ae(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function O(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:oe,forEach:function(e,t,n){oe(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return oe(e,function(){t++}),t},toArray:function(e){return oe(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:O}},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.7`})),i=n(((e,t)=>{t.exports=r()})),a=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,D());else{var t=n(l);t!==null&&re(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function 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&&re(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?D():S=!1}}}var D;if(typeof y==`function`)D=function(){y(ee)};else if(typeof MessageChannel<`u`){var te=new MessageChannel,ne=te.port2;te.port1.onmessage=ee,D=function(){ne.postMessage(null)}}else D=function(){_(ee,0)};function re(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,re(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,D()))),r},e.unstable_shouldYield=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.7`})),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`),te=Symbol.for(`react.activity`),ne=Symbol.for(`react.memo_cache_sentinel`),re=Symbol.iterator;function ie(e){return typeof e!=`object`||!e?null:(e=re&&e[re]||e[`@@iterator`],typeof e==`function`?e:null)}var ae=Symbol.for(`react.client.reference`);function oe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ae?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 te: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?oe(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}var O=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,se={pending:!1,data:null,method:null,action:null},ce=[],le=-1;function j(e){return{current:e}}function ue(e){0>le||(e.current=ce[le],ce[le]=null,le--)}function de(e,t){le++,ce[le]=e.current,e.current=t}var fe=j(null),pe=j(null),me=j(null),he=j(null);function ge(e,t){switch(de(me,t),de(pe,e),de(fe,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(fe),de(fe,e)}function _e(){ue(fe),ue(pe),ue(me)}function ve(e){e.memoizedState!==null&&de(he,e);var t=fe.current,n=Ud(t,e.type);t!==n&&(de(pe,e),de(fe,n))}function ye(e){pe.current===e&&(ue(fe),ue(pe)),he.current===e&&(ue(he),Qf._currentValue=se)}var be,xe;function Se(e){if(be===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);be=t&&t[1]||``,xe=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+be+e+xe}var Ce=!1;function we(e,t){if(!e||Ce)return``;Ce=!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 T(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=w(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=w(e,n+2,`$`,`\\(`);if(i!==-1){t.push(`$`,e.slice(n+2,i),`$`),n=i+1;continue}}if(e.startsWith(`$$`,n)){let r=w(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=w(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 E(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 ee(e){let t=E(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 D(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`//`)}function te(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 ne(e){return/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(e)}function re(e){return/\.pdf$/i.test(e)}function ie(e){return/\.(docx|xlsx|pptx)$/i.test(e)}function ae(e,t,n){let r=n?`&token=${encodeURIComponent(n)}`:``;return`${e}/files/raw?path=${encodeURIComponent(t)}${r}`}var oe=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),O=n(((e,t)=>{t.exports=oe()})),k=O();function A({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,k.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 se=`modulepreload`,ce=function(e){return`/`+e},le={},j=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,new URL(`../../../src/node/plugins/importAnalysisBuild.ts`,import.meta.url)).href}r=o(t.map(t=>{if(t=ce(t,n),t=s(t),t in le)return;le[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`:se,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)})},ue=null,de={javascript:()=>j(()=>import(`./javascript-w9aIBC1S.js`),[]),typescript:()=>j(()=>import(`./typescript-CTV1Js34.js`),[]),json:()=>j(()=>import(`./json-DS4EA3dC.js`),[]),xml:()=>j(()=>import(`./xml-DasnpDVC.js`),[]),css:()=>j(()=>import(`./css-D5l_8KUR.js`),[]),scss:()=>j(()=>import(`./scss-BNjRHcgO.js`),[]),bash:()=>j(()=>import(`./bash-LmRjUKlR.js`),[]),python:()=>j(()=>import(`./python-DwhXSSGr.js`),[]),go:()=>j(()=>import(`./go-B-PCS5zA.js`),[]),rust:()=>j(()=>import(`./rust-Dk33Kfe-.js`),[]),java:()=>j(()=>import(`./java-ChVphriW.js`),[]),c:()=>j(()=>import(`./c-CVYb4e6m.js`),[]),cpp:()=>j(()=>import(`./cpp-V0F2hNk9.js`),[]),csharp:()=>j(()=>import(`./csharp-GZmu99Fo.js`),[]),ruby:()=>j(()=>import(`./ruby-D6zc0cUO.js`),[]),php:()=>j(()=>import(`./php-5k5YNuRS.js`),[]),sql:()=>j(()=>import(`./sql-DWRKyvJ-.js`),[]),yaml:()=>j(()=>import(`./yaml-1XF8XcZB.js`),[]),ini:()=>j(()=>import(`./ini-B1CroMsf.js`),[]),dockerfile:()=>j(()=>import(`./dockerfile-C0zufGsU.js`),[]),markdown:()=>j(()=>import(`./markdown-C8bVcNXx.js`),[]),plaintext:()=>j(()=>import(`./plaintext-YB8mb-y7.js`),[])};async function fe(){return ue||=(async()=>{let{default:e}=await j(async()=>{let{default:e}=await import(`./core-BAwe9Wua.js`);return{default:e}},__vite__mapDeps([0,1]));return await Promise.all(Object.entries(de).map(async([t,n])=>{let r=await n();e.registerLanguage(t,r.default)})),e})(),ue}var pe={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 me(e){let t=e.split(`/`).pop()??e;if(/^dockerfile$/i.test(t))return`dockerfile`;let n=t.lastIndexOf(`.`);if(!(n<0))return pe[t.slice(n+1).toLowerCase()]}function he({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),fe().then(n=>{if(e)return;let a=me(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,k.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,children:e}):(0,k.jsx)(`pre`,{className:`hljs whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,dangerouslySetInnerHTML:{__html:n}})}var ge=c();function _e(e){let t=e?.getRootNode();if(t!==void 0)return t instanceof ShadowRoot?t:globalThis.document.body}function ve({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=_e(o?.current)??c.current,t?(0,ge.createPortal)((0,k.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`${e}, full size`,"data-testid":s,onClick:n,className:`fixed inset-0 z-[100] flex items-center justify-center overflow-auto bg-black/60 p-6`,children:(0,k.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`max-h-full w-auto max-w-[95vw] overflow-auto rounded-lg bg-white p-4 shadow-xl dark:bg-zinc-900`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-4`,children:[(0,k.jsx)(`span`,{className:`text-xs text-zinc-500`,children:e}),(0,k.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i,(0,k.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close`,className:`rounded px-2 py-0.5 text-xs text-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:`✕`})]})]}),(0,k.jsx)(`div`,{ref:a,className:`[&_svg]:!max-w-none`,children:r})]})}),c.current??globalThis.document.body):null}var ye=null,be=null;async function xe(e){let t=await(ye??=j(()=>import(`./mermaid.core-CRSZr8Y7.js`),__vite__mapDeps([2,3,4,1,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])));return be!==e&&(be=e,t.default.initialize({startOnLoad:!1,theme:e,securityLevel:`strict`,suppressErrorRendering:!0})),t}function Se(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 Ce({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 xe(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,k.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,k.jsx)(`div`,{className:`absolute left-2 top-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,k.jsx)(`button`,{type:`button`,onClick:()=>c(!s),title:s?`Show diagram`:`Show code`,className:`rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:s?`⚏ diagram`:`⌗ code`})}),(0,k.jsxs)(`div`,{className:`absolute right-2 top-2 z-10 flex items-center gap-2 opacity-0 transition-opacity group-hover:opacity-100`,children:[!s&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>u(!0),"aria-label":`Show diagram at full size`,className:`rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:`⤢ enlarge`}),(0,k.jsx)(A,{text:e})]}),s?(0,k.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,k.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:r}}),(0,k.jsx)(ve,{label:`diagram`,testId:`mermaid-enlarged`,open:l,onClose:()=>u(!1),anchorRef:f,children:(0,k.jsx)(`div`,{style:{width:Se(r)},className:`[&_svg]:!h-auto [&_svg]:!max-w-none [&_svg]:!w-full`,dangerouslySetInnerHTML:{__html:r}})})]}):(0,k.jsxs)(`pre`,{className:`my-2 overflow-x-auto rounded-lg border border-zinc-200 bg-zinc-50 p-3 font-mono text-xs text-zinc-500 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:[e,a&&(0,k.jsx)(`div`,{className:`mt-2 text-red-600 dark:text-red-400`,children:a})]})}function we({html:e,className:t=``,as:n=`div`}){return(0,k.jsx)(n,{className:`rendered-ansi overflow-x-auto font-mono text-xs leading-relaxed [&_span]:whitespace-pre-wrap ${t}`,dangerouslySetInnerHTML:{__html:e}})}function Te({lines:e,fill:t=!1}){return(0,k.jsx)(`div`,{className:`overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800 ${t?`max-h-full`:`max-h-72`}`,children:S(x(e)).map((e,t)=>e===null?(0,k.jsx)(`div`,{className:`bg-zinc-100 px-2 text-center text-zinc-400 dark:bg-zinc-800/60 dark:text-zinc-600`,children:`⋯`},t):(0,k.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,k.jsx)(`div`,{className:`whitespace-pre-wrap break-words border-r border-zinc-200 px-2 dark:border-zinc-800 ${e.changed?e.left===null?`bg-zinc-50 dark:bg-zinc-900/40`:`bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`text-zinc-500 dark:text-zinc-500`}`,children:e.left??` `}),(0,k.jsx)(`div`,{className:`whitespace-pre-wrap break-words px-2 ${e.changed?e.right===null?`bg-zinc-50 dark:bg-zinc-900/40`:`bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:`text-zinc-500 dark:text-zinc-500`}`,children:e.right??` `})]},t))})}function Ee({lines:e}){return(0,k.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800`,children:C(e).map((e,t)=>e===null?(0,k.jsx)(`div`,{className:`bg-zinc-100 px-2 text-center text-zinc-400 dark:bg-zinc-800/60 dark:text-zinc-600`,children:`⋯`},t):(0,k.jsxs)(`div`,{className:e.type===`add`?`bg-emerald-50 px-2 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:e.type===`del`?`bg-red-50 px-2 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`px-2 text-zinc-500 dark:text-zinc-500`,children:[e.type===`add`?`+ `:e.type===`del`?`− `:` `,e.text]},t))})}function De({item:e,canEdit:t,onEdit:n}){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(null),o=t&&e.entryId!==void 0,s=r!==null;(0,d.useEffect)(()=>{s&&a.current?.focus()},[s]),(0,d.useEffect)(()=>{i(null)},[e.entryId,e.text]);function c(){let a=r?.trim();if(!(!t||!e.entryId||!a)){if(a===e.text){i(null);return}n(e.entryId,a,e.images),i(null)}}return(0,k.jsxs)(`div`,{className:`group ml-auto flex max-w-[85%] items-start gap-1.5`,children:[o&&!s&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>i(e.text),title:`edit this prompt and ask again (branches the conversation)`,"aria-label":`Edit this prompt`,className:`mt-1.5 shrink-0 rounded px-1 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✎`}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1 rounded-xl bg-blue-100 px-4 py-2 text-[15px] text-blue-950 dark:bg-blue-950/60 dark:text-zinc-100`,children:[e.images&&e.images.length>0&&(0,k.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:e.images.map((e,t)=>(0,k.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-48 max-w-full rounded-lg object-contain`},t))}),s?(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`textarea`,{ref:a,value:r,"aria-label":`Edit prompt`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),c()),e.key===`Escape`&&i(null)},rows:Math.min(10,Math.max(2,r.split(`
|
|
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 ee(e){let t=E(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 D(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`//`)}function te(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 ne(e){return/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(e)}function re(e){return/\.pdf$/i.test(e)}function ie(e){return/\.(docx|xlsx|pptx)$/i.test(e)}function ae(e,t,n){let r=n?`&token=${encodeURIComponent(n)}`:``;return`${e}/files/raw?path=${encodeURIComponent(t)}${r}`}var oe=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),O=n(((e,t)=>{t.exports=oe()})),k=O();function A({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,k.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 se=`modulepreload`,ce=function(e){return`/`+e},le={},j=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,new URL(`../../../src/node/plugins/importAnalysisBuild.ts`,import.meta.url)).href}r=o(t.map(t=>{if(t=ce(t,n),t=s(t),t in le)return;le[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`:se,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)})},ue=null,de={javascript:()=>j(()=>import(`./javascript-w9aIBC1S.js`),[]),typescript:()=>j(()=>import(`./typescript-CTV1Js34.js`),[]),json:()=>j(()=>import(`./json-DS4EA3dC.js`),[]),xml:()=>j(()=>import(`./xml-DasnpDVC.js`),[]),css:()=>j(()=>import(`./css-D5l_8KUR.js`),[]),scss:()=>j(()=>import(`./scss-BNjRHcgO.js`),[]),bash:()=>j(()=>import(`./bash-LmRjUKlR.js`),[]),python:()=>j(()=>import(`./python-DwhXSSGr.js`),[]),go:()=>j(()=>import(`./go-B-PCS5zA.js`),[]),rust:()=>j(()=>import(`./rust-Dk33Kfe-.js`),[]),java:()=>j(()=>import(`./java-ChVphriW.js`),[]),c:()=>j(()=>import(`./c-CVYb4e6m.js`),[]),cpp:()=>j(()=>import(`./cpp-V0F2hNk9.js`),[]),csharp:()=>j(()=>import(`./csharp-GZmu99Fo.js`),[]),ruby:()=>j(()=>import(`./ruby-D6zc0cUO.js`),[]),php:()=>j(()=>import(`./php-5k5YNuRS.js`),[]),sql:()=>j(()=>import(`./sql-DWRKyvJ-.js`),[]),yaml:()=>j(()=>import(`./yaml-1XF8XcZB.js`),[]),ini:()=>j(()=>import(`./ini-B1CroMsf.js`),[]),dockerfile:()=>j(()=>import(`./dockerfile-C0zufGsU.js`),[]),markdown:()=>j(()=>import(`./markdown-C8bVcNXx.js`),[]),plaintext:()=>j(()=>import(`./plaintext-YB8mb-y7.js`),[])};async function fe(){return ue||=(async()=>{let{default:e}=await j(async()=>{let{default:e}=await import(`./core-BAwe9Wua.js`);return{default:e}},__vite__mapDeps([0,1]));return await Promise.all(Object.entries(de).map(async([t,n])=>{let r=await n();e.registerLanguage(t,r.default)})),e})(),ue}var pe={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 me(e){let t=e.split(`/`).pop()??e;if(/^dockerfile$/i.test(t))return`dockerfile`;let n=t.lastIndexOf(`.`);if(!(n<0))return pe[t.slice(n+1).toLowerCase()]}function he({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),fe().then(n=>{if(e)return;let a=me(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,k.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,children:e}):(0,k.jsx)(`pre`,{className:`hljs whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,dangerouslySetInnerHTML:{__html:n}})}var ge=c();function _e(e){let t=e?.getRootNode();if(t!==void 0)return t instanceof ShadowRoot?t:globalThis.document.body}function ve({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=_e(o?.current)??c.current,t?(0,ge.createPortal)((0,k.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`${e}, full size`,"data-testid":s,onClick:n,className:`fixed inset-0 z-[100] flex items-center justify-center overflow-auto bg-black/60 p-6`,children:(0,k.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`max-h-full w-auto max-w-[95vw] overflow-auto rounded-lg bg-white p-4 shadow-xl dark:bg-zinc-900`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-4`,children:[(0,k.jsx)(`span`,{className:`text-xs text-zinc-500`,children:e}),(0,k.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i,(0,k.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close`,className:`rounded px-2 py-0.5 text-xs text-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:`✕`})]})]}),(0,k.jsx)(`div`,{ref:a,className:`[&_svg]:!max-w-none`,children:r})]})}),c.current??globalThis.document.body):null}var ye=null,be=null;async function xe(e){let t=await(ye??=j(()=>import(`./mermaid.core-BVGHn3kY.js`),__vite__mapDeps([2,3,4,1,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])));return be!==e&&(be=e,t.default.initialize({startOnLoad:!1,theme:e,securityLevel:`strict`,suppressErrorRendering:!0})),t}function Se(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 Ce({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 xe(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,k.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,k.jsx)(`div`,{className:`absolute left-2 top-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,k.jsx)(`button`,{type:`button`,onClick:()=>c(!s),title:s?`Show diagram`:`Show code`,className:`rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:s?`⚏ diagram`:`⌗ code`})}),(0,k.jsxs)(`div`,{className:`absolute right-2 top-2 z-10 flex items-center gap-2 opacity-0 transition-opacity group-hover:opacity-100`,children:[!s&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>u(!0),"aria-label":`Show diagram at full size`,className:`rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:`⤢ enlarge`}),(0,k.jsx)(A,{text:e})]}),s?(0,k.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,k.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:r}}),(0,k.jsx)(ve,{label:`diagram`,testId:`mermaid-enlarged`,open:l,onClose:()=>u(!1),anchorRef:f,children:(0,k.jsx)(`div`,{style:{width:Se(r)},className:`[&_svg]:!h-auto [&_svg]:!max-w-none [&_svg]:!w-full`,dangerouslySetInnerHTML:{__html:r}})})]}):(0,k.jsxs)(`pre`,{className:`my-2 overflow-x-auto rounded-lg border border-zinc-200 bg-zinc-50 p-3 font-mono text-xs text-zinc-500 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:[e,a&&(0,k.jsx)(`div`,{className:`mt-2 text-red-600 dark:text-red-400`,children:a})]})}function we({html:e,className:t=``,as:n=`div`}){return(0,k.jsx)(n,{className:`rendered-ansi overflow-x-auto font-mono text-xs leading-relaxed [&_span]:whitespace-pre-wrap ${t}`,dangerouslySetInnerHTML:{__html:e}})}function Te({lines:e,fill:t=!1}){return(0,k.jsx)(`div`,{className:`overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800 ${t?`max-h-full`:`max-h-72`}`,children:S(x(e)).map((e,t)=>e===null?(0,k.jsx)(`div`,{className:`bg-zinc-100 px-2 text-center text-zinc-400 dark:bg-zinc-800/60 dark:text-zinc-600`,children:`⋯`},t):(0,k.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,k.jsx)(`div`,{className:`whitespace-pre-wrap break-words border-r border-zinc-200 px-2 dark:border-zinc-800 ${e.changed?e.left===null?`bg-zinc-50 dark:bg-zinc-900/40`:`bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`text-zinc-500 dark:text-zinc-500`}`,children:e.left??` `}),(0,k.jsx)(`div`,{className:`whitespace-pre-wrap break-words px-2 ${e.changed?e.right===null?`bg-zinc-50 dark:bg-zinc-900/40`:`bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:`text-zinc-500 dark:text-zinc-500`}`,children:e.right??` `})]},t))})}function Ee({lines:e}){return(0,k.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800`,children:C(e).map((e,t)=>e===null?(0,k.jsx)(`div`,{className:`bg-zinc-100 px-2 text-center text-zinc-400 dark:bg-zinc-800/60 dark:text-zinc-600`,children:`⋯`},t):(0,k.jsxs)(`div`,{className:e.type===`add`?`bg-emerald-50 px-2 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:e.type===`del`?`bg-red-50 px-2 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`px-2 text-zinc-500 dark:text-zinc-500`,children:[e.type===`add`?`+ `:e.type===`del`?`− `:` `,e.text]},t))})}function De({item:e,canEdit:t,onEdit:n}){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(null),o=t&&e.entryId!==void 0,s=r!==null;(0,d.useEffect)(()=>{s&&a.current?.focus()},[s]),(0,d.useEffect)(()=>{i(null)},[e.entryId,e.text]);function c(){let a=r?.trim();if(!(!t||!e.entryId||!a)){if(a===e.text){i(null);return}n(e.entryId,a,e.images),i(null)}}return(0,k.jsxs)(`div`,{className:`group ml-auto flex max-w-[85%] items-start gap-1.5`,children:[o&&!s&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>i(e.text),title:`edit this prompt and ask again (branches the conversation)`,"aria-label":`Edit this prompt`,className:`mt-1.5 shrink-0 rounded px-1 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✎`}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1 rounded-xl bg-blue-100 px-4 py-2 text-[15px] text-blue-950 dark:bg-blue-950/60 dark:text-zinc-100`,children:[e.images&&e.images.length>0&&(0,k.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:e.images.map((e,t)=>(0,k.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-48 max-w-full rounded-lg object-contain`},t))}),s?(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`textarea`,{ref:a,value:r,"aria-label":`Edit prompt`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),c()),e.key===`Escape`&&i(null)},rows:Math.min(10,Math.max(2,r.split(`
|
|
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,k.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2 text-xs`,children:[(0,k.jsx)(`span`,{className:`mr-auto text-blue-900/70 dark:text-zinc-400`,children:t?`asks again from here — the current answer moves to its own branch`:`waiting: the agent is running (or the connection dropped)`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>i(null),className:`rounded border border-blue-300 px-2 py-0.5 hover:bg-white/60 dark:border-zinc-700 dark:hover:bg-zinc-800`,children:`cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:c,disabled:!t||!r.trim()||r.trim()===e.text,className:`rounded border border-blue-400 bg-white/70 px-2 py-0.5 font-medium disabled:opacity-50 dark:border-blue-800 dark:bg-zinc-900/60`,children:`send`})]})]}):(0,k.jsx)(`div`,{className:`whitespace-pre-wrap`,children:e.text})]})]})}function Oe(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 ke(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var Ae=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,je=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Me={};function Ne(e,t){return((t||Me).jsx?je:Ae).test(e)}var Pe=/[ \t\n\f\r]/g;function Fe(e){return typeof e==`object`?e.type===`text`?Ie(e.value):!1:Ie(e)}function Ie(e){return e.replace(Pe,``)===``}var Le=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};Le.prototype.normal={},Le.prototype.property={},Le.prototype.space=void 0;function Re(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new Le(n,r,t)}function ze(e){return e.toLowerCase()}var Be=class{constructor(e,t){this.attribute=t,this.property=e}};Be.prototype.attribute=``,Be.prototype.booleanish=!1,Be.prototype.boolean=!1,Be.prototype.commaOrSpaceSeparated=!1,Be.prototype.commaSeparated=!1,Be.prototype.defined=!1,Be.prototype.mustUseProperty=!1,Be.prototype.number=!1,Be.prototype.overloadedBoolean=!1,Be.prototype.property=``,Be.prototype.spaceSeparated=!1,Be.prototype.space=void 0;var Ve=e({boolean:()=>M,booleanish:()=>Ue,commaOrSpaceSeparated:()=>qe,commaSeparated:()=>Ke,number:()=>N,overloadedBoolean:()=>We,spaceSeparated:()=>Ge}),He=0,M=Je(),Ue=Je(),We=Je(),N=Je(),Ge=Je(),Ke=Je(),qe=Je();function Je(){return 2**++He}var Ye=Object.keys(Ve),Xe=class extends Be{constructor(e,t,n,r){let i=-1;if(super(e,t),Ze(this,`space`,r),typeof n==`number`)for(;++i<Ye.length;){let e=Ye[i];Ze(this,Ye[i],(n&Ve[e])===Ve[e])}}};Xe.prototype.defined=!0;function Ze(e,t,n){n&&(e[t]=n)}function Qe(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Xe(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[ze(r)]=r,n[ze(a.attribute)]=r}return new Le(t,n,e.space)}var $e=Qe({properties:{ariaActiveDescendant:null,ariaAtomic:Ue,ariaAutoComplete:null,ariaBusy:Ue,ariaChecked:Ue,ariaColCount:N,ariaColIndex:N,ariaColSpan:N,ariaControls:Ge,ariaCurrent:null,ariaDescribedBy:Ge,ariaDetails:null,ariaDisabled:Ue,ariaDropEffect:Ge,ariaErrorMessage:null,ariaExpanded:Ue,ariaFlowTo:Ge,ariaGrabbed:Ue,ariaHasPopup:null,ariaHidden:Ue,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ge,ariaLevel:N,ariaLive:null,ariaModal:Ue,ariaMultiLine:Ue,ariaMultiSelectable:Ue,ariaOrientation:null,ariaOwns:Ge,ariaPlaceholder:null,ariaPosInSet:N,ariaPressed:Ue,ariaReadOnly:Ue,ariaRelevant:null,ariaRequired:Ue,ariaRoleDescription:Ge,ariaRowCount:N,ariaRowIndex:N,ariaRowSpan:N,ariaSelected:Ue,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 et(e,t){return t in e?e[t]:t}function tt(e,t){return et(e,t.toLowerCase())}var nt=Qe({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:Ke,acceptCharset:Ge,accessKey:Ge,action:null,allow:null,allowFullScreen:M,allowPaymentRequest:M,allowUserMedia:M,alpha:M,alt:null,as:null,async:M,autoCapitalize:null,autoComplete:Ge,autoFocus:M,autoPlay:M,blocking:Ge,capture:null,charSet:null,checked:M,cite:null,className:Ge,closedBy:null,colorSpace:null,cols:N,colSpan:N,command:null,commandFor:null,content:null,contentEditable:Ue,controls:M,controlsList:Ge,coords:N|Ke,crossOrigin:null,data:null,dateTime:null,decoding:null,default:M,defer:M,dir:null,dirName:null,disabled:M,download:We,draggable:Ue,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:M,formTarget:null,headers:Ge,height:N,hidden:We,high:N,href:null,hrefLang:null,htmlFor:Ge,httpEquiv:Ge,id:null,imageSizes:null,imageSrcSet:null,inert:M,inputMode:null,integrity:null,is:null,isMap:M,itemId:null,itemProp:Ge,itemRef:Ge,itemScope:M,itemType:Ge,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:M,low:N,manifest:null,max:null,maxLength:N,media:null,method:null,min:null,minLength:N,multiple:M,muted:M,name:null,nonce:null,noModule:M,noValidate:M,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:M,optimum:N,pattern:null,ping:Ge,placeholder:null,playsInline:M,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:M,referrerPolicy:null,rel:Ge,required:M,reversed:M,rows:N,rowSpan:N,sandbox:Ge,scope:null,scoped:M,seamless:M,selected:M,shadowRootClonable:M,shadowRootCustomElementRegistry:M,shadowRootDelegatesFocus:M,shadowRootMode:null,shadowRootSerializable:M,shape:null,size:N,sizes:null,slot:null,span:N,spellCheck:Ue,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:M,useMap:null,value:Ue,width:N,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ge,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:M,declare:M,event:null,face:null,frame:null,frameBorder:null,hSpace:N,leftMargin:N,link:null,longDesc:null,lowSrc:null,marginHeight:N,marginWidth:N,noResize:M,noHref:M,noShade:M,noWrap:M,object:null,profile:null,prompt:null,rev:null,rightMargin:N,rules:null,scheme:null,scrolling:Ue,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:M,disablePictureInPicture:M,disableRemotePlayback:M,exportParts:Ke,part:Ge,prefix:null,property:null,results:N,security:null,unselectable:null},space:`html`,transform:tt}),rt=Qe({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:qe,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:Ge,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:M,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:Ke,g2:Ke,glyphName:Ke,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:qe,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:Ge,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:N,pointsAtY:N,pointsAtZ:N,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:qe,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:qe,rev:qe,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:qe,requiredFeatures:qe,requiredFonts:qe,requiredFormats:qe,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:qe,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:qe,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:qe,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:et}),it=Qe({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()}}),at=Qe({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:tt}),ot=Qe({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),st={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`},ct=/[A-Z]/g,lt=/-[a-z]/g,ut=/^data[-\w.:]+$/i;function dt(e,t){let n=ze(t),r=t,i=Be;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&ut.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(lt,pt);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!lt.test(e)){let n=e.replace(ct,ft);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Xe}return new i(r,t)}function ft(e){return`-`+e.toLowerCase()}function pt(e){return e.charAt(1).toUpperCase()}var mt=Re([$e,nt,it,at,ot],`html`),ht=Re([$e,rt,it,at,ot],`svg`);function gt(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function _t(e){return e.join(` `).trim()}var vt=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})),yt=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(vt());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}})),bt=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))}})),xt=n(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(yt()),r=bt();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})),St=wt(`end`),Ct=wt(`start`);function wt(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 Tt(e){let t=Ct(e),n=St(e);if(t&&n)return{start:t,end:n}}function Et(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Ot(e.position):`start`in e||`end`in e?Ot(e):`line`in e||`column`in e?Dt(e):``}function Dt(e){return kt(e&&e.line)+`:`+kt(e&&e.column)}function Ot(e){return Dt(e&&e.start)+`-`+Dt(e&&e.end)}function kt(e){return e&&typeof e==`number`?e:1}var At=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=Et(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}};At.prototype.file=``,At.prototype.name=``,At.prototype.reason=``,At.prototype.message=``,At.prototype.stack=``,At.prototype.column=void 0,At.prototype.line=void 0,At.prototype.ancestors=void 0,At.prototype.cause=void 0,At.prototype.fatal=void 0,At.prototype.place=void 0,At.prototype.ruleId=void 0,At.prototype.source=void 0;var jt=t(xt(),1),Mt={}.hasOwnProperty,Nt=new Map,Pt=/[A-Z]/g,Ft=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),It=new Set([`td`,`th`]);function Lt(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=Jt(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`?ht:mt,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Rt(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Rt(e,t,n){if(t.type===`element`)return zt(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return Bt(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Ht(e,t,n);if(t.type===`mdxjsEsm`)return Vt(e,t);if(t.type===`root`)return Ut(e,t,n);if(t.type===`text`)return Wt(e,t)}function zt(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=ht,e.schema=i),e.ancestors.push(t);let a=en(e,t.tagName,!1),o=Yt(e,t),s=Zt(e,t);return Ft.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!Fe(e):!0})),Gt(e,o,a,t),Kt(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Bt(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)}tn(e,t.position)}function Vt(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);tn(e,t.position)}function Ht(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=ht,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:en(e,t.name,!0),o=Xt(e,t),s=Zt(e,t);return Gt(e,o,a,t),Kt(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Ut(e,t,n){let r={};return Kt(r,Zt(e,t)),e.create(t,e.Fragment,r,n)}function Wt(e,t){return t.value}function Gt(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Kt(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 Jt(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=Ct(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 Yt(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&Mt.call(t.properties,i)){let a=Qt(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&It.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 Xt(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 tn(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 tn(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function Zt(e,t){let n=[],r=-1,i=e.passKeys?new Map:Nt;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=Rt(e,a,o);s!==void 0&&n.push(s)}return n}function Qt(e,t,n){let r=dt(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?ke(n):_t(n)),r.property===`style`){let t=typeof n==`object`?n:$t(e,String(n));return e.stylePropertyNameCase===`css`&&(t=nn(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?st[r.property]||r.property:r.attribute,n]}}function $t(e,t){try{return(0,jt.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new At("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=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-parse-style-attribute`,r}}function en(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=Ne(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=Ne(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return Mt.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);tn(e)}function tn(e,t){let n=new At("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=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-handle-mdx-estrees-without-createevaluater`,n}function nn(e){let t={},n;for(n in e)Mt.call(e,n)&&(t[rn(n)]=e[n]);return t}function rn(e){let t=e.replace(Pt,an);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function an(e){return`-`+e.toLowerCase()}var on={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`]},sn={};function cn(e,t){let n=t||sn;return ln(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function ln(e,t,n){if(dn(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 un(e.children,t,n)}return Array.isArray(e)?un(e,t,n):``}function un(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=ln(e[i],t,n);return r.join(``)}function dn(e){return!!(e&&typeof e==`object`)}var fn=document.createElement(`i`);function pn(e){let t=`&`+e+`;`;fn.innerHTML=t;let n=fn.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function mn(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 hn(e,t){return e.length>0?(mn(e,e.length,0,t),e):t}var gn={}.hasOwnProperty;function _n(e){let t={},n=-1;for(;++n<e.length;)vn(t,e[n]);return t}function vn(e,t){let n;for(n in t){let r=(gn.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){gn.call(r,a)||(r[a]=[]);let e=i[a];yn(r[a],Array.isArray(e)?e:e?[e]:[])}}}function yn(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);mn(e,0,0,r)}function bn(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 xn(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var Sn=Nn(/[A-Za-z]/),Cn=Nn(/[\dA-Za-z]/),wn=Nn(/[#-'*+\--9=?A-Z^-~]/);function Tn(e){return e!==null&&(e<32||e===127)}var En=Nn(/\d/),Dn=Nn(/[\dA-Fa-f]/),On=Nn(/[!-/:-@[-`{-~]/);function P(e){return e!==null&&e<-2}function kn(e){return e!==null&&(e<0||e===32)}function An(e){return e===-2||e===-1||e===32}var jn=Nn(/\p{P}|\p{S}/u),Mn=Nn(/\s/);function Nn(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Pn(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&Cn(e.charCodeAt(n+1))&&Cn(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 Fn(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return An(r)?(e.enter(n),s(r)):t(r)}function s(r){return An(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var In={tokenize:Ln};function Ln(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`),Fn(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 Rn={tokenize:Bn},zn={tokenize:Vn};function Bn(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 mn(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(zn,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(zn,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++;mn(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 Vn(e,t,n){return Fn(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Hn(e){if(e===null||kn(e)||Mn(e))return 1;if(jn(e))return 2}function Un(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 Wn={name:`attention`,resolveAll:Gn,tokenize:Kn};function Gn(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=hn(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=hn(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=hn(l,Un(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=hn(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=hn(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,mn(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 Kn(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Hn(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=Hn(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 Jn={name:`autolink`,tokenize:Yn};function Yn(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 Sn(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||Cn(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||Cn(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||Tn(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):wn(t)?(e.consume(t),l):n(t)}function u(e){return Cn(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||Cn(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Xn={partial:!0,tokenize:Zn};function Zn(e,t,n){return r;function r(t){return An(t)?Fn(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||P(e)?t(e):n(e)}}var Qn={continuation:{tokenize:er},exit:tr,name:`blockQuote`,tokenize:$n};function $n(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 An(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function er(e,t,n){let r=this;return i;function i(t){return An(t)?Fn(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Qn,t,n)(r)}}function tr(e){e.exit(`blockQuote`)}var nr={name:`characterEscape`,tokenize:rr};function rr(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 On(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var ir={name:`characterReference`,tokenize:ar};function ar(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=Cn,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=Dn,u):(e.enter(`characterReferenceValue`),a=7,o=En,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===Cn&&!pn(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 or={partial:!0,tokenize:lr},sr={concrete:!0,name:`codeFenced`,tokenize:cr};function cr(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`),An(t)?Fn(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||P(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(or,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)):An(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),Fn(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&&An(t)?Fn(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||P(t)?e.check(or,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`),An(t)?Fn(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`),An(t)?Fn(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||P(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function lr(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 ur={name:`codeIndented`,tokenize:fr},dr={partial:!0,tokenize:pr};function fr(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),Fn(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(dr,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 pr(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):Fn(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 mr={name:`codeText`,previous:gr,resolve:hr,tokenize:_r};function hr(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 gr(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function _r(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 vr=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&&yr(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),yr(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),yr(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);yr(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);yr(this.left,t.reverse())}}};function yr(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 br(e){let t={},n=-1,r,i,a,o,s,c,l,u=new vr(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,xr(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 mn(e,0,1/0,u.slice(0)),!l}function xr(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 Sr={resolve:wr,tokenize:Tr},Cr={partial:!0,tokenize:Er};function wr(e){return br(e),e}function Tr(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(Cr,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 Er(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Fn(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 Dr(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||Tn(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||kn(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||Tn(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 Or(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||=!An(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function kr(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`),Fn(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 Ar(e,t){let n;return r;function r(i){return P(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):An(i)?Fn(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var jr={name:`definition`,tokenize:Nr},Mr={partial:!0,tokenize:Pr};function Nr(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Or.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=xn(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 kn(t)?Ar(e,l)(t):l(t)}function l(t){return Dr(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Mr,d,d)(t)}function d(t){return An(t)?Fn(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 Pr(e,t,n){return r;function r(t){return kn(t)?Ar(e,i)(t):n(t)}function i(t){return kr(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return An(t)?Fn(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||P(e)?t(e):n(e)}}var Fr={name:`hardBreakEscape`,tokenize:Ir};function Ir(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 Lr={name:`headingAtx`,resolve:Rr,tokenize:zr};function Rr(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`},mn(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function zr(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||kn(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)):An(n)?Fn(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||kn(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Br=`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(`.`),Vr=[`pre`,`script`,`style`,`textarea`],Hr={concrete:!0,name:`htmlFlow`,resolveTo:Gr,tokenize:Kr},Ur={partial:!0,tokenize:Jr},Wr={partial:!0,tokenize:qr};function Gr(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 Kr(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):Sn(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):Sn(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 Sn(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||kn(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Vr.includes(l)?(i=1,r.interrupt?t(s):D(s)):Br.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||Cn(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 An(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||Sn(t)?(e.consume(t),b):An(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||Cn(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):An(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):An(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||kn(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||An(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):An(t)?(e.consume(t),ee):n(t)}function D(t){return t===45&&i===2?(e.consume(t),ie):t===60&&i===1?(e.consume(t),ae):t===62&&i===4?(e.consume(t),A):t===63&&i===3?(e.consume(t),k):t===93&&i===5?(e.consume(t),O):P(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Ur,se,te)(t)):t===null||P(t)?(e.exit(`htmlFlowData`),te(t)):(e.consume(t),D)}function te(t){return e.check(Wr,ne,se)(t)}function ne(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),re}function re(t){return t===null||P(t)?te(t):(e.enter(`htmlFlowData`),D(t))}function ie(t){return t===45?(e.consume(t),k):D(t)}function ae(t){return t===47?(e.consume(t),o=``,oe):D(t)}function oe(t){if(t===62){let n=o.toLowerCase();return Vr.includes(n)?(e.consume(t),A):D(t)}return Sn(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),oe):D(t)}function O(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`),se(t)):(e.consume(t),A)}function se(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 Jr(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Xn,t,n)}}var Yr={name:`htmlText`,tokenize:Xr};function Xr(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):Sn(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):Sn(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,ae(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?ie(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,ae(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?ie(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?ie(t):P(t)?(o=v,ae(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):P(t)?(o=y,ae(t)):(e.consume(t),y)}function b(e){return e===62?ie(e):y(e)}function x(t){return Sn(t)?(e.consume(t),S):n(t)}function S(t){return t===45||Cn(t)?(e.consume(t),S):C(t)}function C(t){return P(t)?(o=C,ae(t)):An(t)?(e.consume(t),C):ie(t)}function w(t){return t===45||Cn(t)?(e.consume(t),w):t===47||t===62||kn(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),ie):t===58||t===95||Sn(t)?(e.consume(t),E):P(t)?(o=T,ae(t)):An(t)?(e.consume(t),T):ie(t)}function E(t){return t===45||t===46||t===58||t===95||Cn(t)?(e.consume(t),E):ee(t)}function ee(t){return t===61?(e.consume(t),D):P(t)?(o=ee,ae(t)):An(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,te):P(t)?(o=D,ae(t)):An(t)?(e.consume(t),D):(e.consume(t),ne)}function te(t){return t===i?(e.consume(t),i=void 0,re):t===null?n(t):P(t)?(o=te,ae(t)):(e.consume(t),te)}function ne(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||kn(t)?T(t):(e.consume(t),ne)}function re(e){return e===47||e===62||kn(e)?T(e):n(e)}function ie(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function ae(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),oe}function oe(t){return An(t)?Fn(e,O,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):O(t)}function O(t){return e.enter(`htmlTextData`),o(t)}}var Zr={name:`labelEnd`,resolveAll:ti,resolveTo:ni,tokenize:ri},Qr={tokenize:ii},$r={tokenize:ai},ei={tokenize:oi};function ti(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&&mn(e,0,e.length,n),e}function ni(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=hn(s,e.slice(a+1,a+r+3)),s=hn(s,[[`enter`,u,t]]),s=hn(s,Un(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=hn(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=hn(s,e.slice(o+1)),s=hn(s,[[`exit`,c,t]]),mn(e,a,e.length,s),e}function ri(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(xn(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(Qr,u,o?u:d)(t):t===91?e.attempt($r,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(ei,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function ii(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 kn(t)?Ar(e,a)(t):a(t)}function a(t){return t===41?u(t):Dr(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return kn(t)?Ar(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?kr(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return kn(t)?Ar(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 ai(e,t,n){let r=this;return i;function i(t){return Or.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(xn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function oi(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 si={name:`labelStartImage`,resolveAll:Zr.resolveAll,tokenize:ci};function ci(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 li={name:`labelStartLink`,resolveAll:Zr.resolveAll,tokenize:ui};function ui(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 di={name:`lineEnding`,tokenize:fi};function fi(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Fn(e,t,`linePrefix`)}}var pi={name:`thematicBreak`,tokenize:mi};function mi(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`),An(t)?Fn(e,s,`whitespace`)(t):s(t))}}var hi={continuation:{tokenize:yi},exit:xi,name:`list`,tokenize:vi},gi={partial:!0,tokenize:Si},_i={partial:!0,tokenize:bi};function vi(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:En(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(pi,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 En(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(Xn,r.interrupt?n:u,e.attempt(gi,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return An(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 yi(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Xn,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Fn(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!An(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(_i,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Fn(e,e.attempt(hi,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function bi(e,t,n){let r=this;return Fn(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 xi(e){e.exit(this.containerState.type)}function Si(e,t,n){let r=this;return Fn(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!An(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var Ci={name:`setextUnderline`,resolveTo:wi,tokenize:Ti};function wi(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 Ti(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`),An(t)?Fn(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||P(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var Ei={tokenize:Di};function Di(e){let t=this,n=e.attempt(Xn,r,e.attempt(this.parser.constructs.flowInitial,i,Fn(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Sr,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 Oi={resolveAll:Mi()},ki=ji(`string`),Ai=ji(`text`);function ji(e){return{resolveAll:Mi(e===`text`?Ni: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 Mi(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 Ni(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 Pi=e({attentionMarkers:()=>Hi,contentInitial:()=>Ii,disable:()=>Ui,document:()=>Fi,flow:()=>Ri,flowInitial:()=>Li,insideSpan:()=>Vi,string:()=>zi,text:()=>Bi}),Fi={42:hi,43:hi,45:hi,48:hi,49:hi,50:hi,51:hi,52:hi,53:hi,54:hi,55:hi,56:hi,57:hi,62:Qn},Ii={91:jr},Li={[-2]:ur,[-1]:ur,32:ur},Ri={35:Lr,42:pi,45:[Ci,pi],60:Hr,61:Ci,95:pi,96:sr,126:sr},zi={38:ir,92:nr},Bi={[-5]:di,[-4]:di,[-3]:di,33:si,38:ir,42:Wn,60:[Jn,Yr],91:li,92:[Fr,nr],93:Zr,95:Wn,96:mr},Vi={null:[Wn,Oi]},Hi={null:[42,95]},Ui={null:[]};function Wi(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=hn(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Un(a,l.events,l),l.events):[]}function f(e,t){return Ki(p(e),t)}function p(e){return Gi(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&&mn(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 Gi(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 Ki(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
|
|
@@ -315,9 +315,9 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
315
315
|
`)}}function wC(e){return`n${[...e].map(e=>e.charCodeAt(0).toString(36)).join(``)}`}var TC={"#":`#35;`,'"':`#quot;`,";":`#59;`,"<":`#60;`,">":`#62;`};function EC(e){return e.replace(/[#";<>]/g,e=>TC[e]).replace(/[\r\n\t\f\v\u0000-\u001f\u2028\u2029]+/g,` `)}var DC=`#ffffff`,OC=`#27272a`,kC=`#71717a`,AC={added:{fill:`#ecfdf5`,stroke:`#059669`,text:`#065f46`},changed:{fill:`#fffbeb`,stroke:`#d97706`,text:`#92400e`},context:{fill:`#fafafa`,stroke:`#d4d4d8`,text:`#71717a`},unchanged:{fill:`#ffffff`,stroke:`#a1a1aa`,text:OC}},jC={added:`#059669`,changed:`#d97706`,context:`#d4d4d8`,unchanged:`#a1a1aa`},MC=[`added`,`changed`,`context`,`unchanged`],NC=[{fill:`#eff6ff`,stroke:`#2563eb`},{fill:`#f5f3ff`,stroke:`#7c3aed`},{fill:`#ecfeff`,stroke:`#0891b2`},{fill:`#fff1f2`,stroke:`#e11d48`},{fill:`#f7fee7`,stroke:`#65a30d`},{fill:`#fff7ed`,stroke:`#ea580c`},{fill:`#f0fdfa`,stroke:`#0d9488`},{fill:`#fdf4ff`,stroke:`#c026d3`},{fill:`#fefce8`,stroke:`#ca8a04`},{fill:`#f8fafc`,stroke:`#475569`},{fill:`#eef2ff`,stroke:`#4f46e5`},{fill:`#fef2f2`,stroke:`#b91c1c`},{fill:`#f0fdf4`,stroke:`#16a34a`},{fill:`#fdf2f8`,stroke:`#db2777`},{fill:`#f5f5f4`,stroke:`#78716c`},{fill:`#f0f9ff`,stroke:`#0369a1`}],PC=[void 0,`7 3`,`2 3`,`9 3 2 3`],FC=NC.length*PC.length;function IC(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t}NC.length;function LC(e){let t=new Map,n=new Set;for(let r of e){let e=IC(r)%FC;for(let t=0;t<FC&&n.has(e);t++)e=(e+1)%FC;n.add(e);let i=NC[e%NC.length];t.set(r,{...i,dash:PC[Math.floor(e/NC.length)%PC.length]})}return t}function RC(e){let t=[];for(let n of e)n.kind!==void 0&&n.kind!==``&&!t.includes(n.kind)&&t.push(n.kind);return t}function zC(e,t){return`${e}:${t}`}var BC=17,VC=18,HC=92,UC=860;function WC(e){return Math.min(e,UC)}function GC(e){return 21+(e.length+9)*5.6+VC}function KC(e,t){let n=WC(t),r=1,i=0;for(let t of e.entries){let e=GC(t.label);i>0&&HC+i+e>n-20&&(r+=1,i=0),i+=e}return r}function qC(e){let t=e.flatMap(e=>e.entries).reduce((e,t)=>Math.max(e,GC(t.label)),0);return t===0?0:Math.min(HC+t+32,UC)}function JC(e,t){let n=e.filter(e=>e.entries.length>0);return n.length===0?0:n.reduce((e,n)=>e+KC(n,t),0)*BC+12}function YC({groups:e,x:t,y:n,width:r,onToggle:i}){let a=e.filter(e=>e.entries.length>0);if(a.length===0)return null;let o=WC(r),s=0;return(0,k.jsx)(`g`,{"data-testid":`diagram-legend`,children:a.map(e=>{let r=s,a=0,c=e.entries.map(r=>{let c=GC(r.label);a>0&&HC+a+c>o-20&&(s+=1,a=0);let l=t+HC+a,u=n+s*BC;return a+=c,(0,k.jsxs)(`g`,{"data-legend-entry":r.key??r.label,"data-faded":r.faded===!0?`true`:void 0,"data-hidden":r.hidden===!0?`true`:void 0,onClick:r.toggles===!0&&r.key!==void 0&&i!==void 0?()=>i(r.key):void 0,style:r.toggles===!0?{cursor:`pointer`}:void 0,opacity:r.hidden===!0?.45:r.faded===!0?.62:1,children:[r.toggles===!0&&(0,k.jsx)(`rect`,{x:l-3,y:u-3,width:GC(r.label)-8,height:16,fill:`transparent`}),e.sample===`line`?(0,k.jsx)(`line`,{x1:l,y1:u+5,x2:l+16,y2:u+5,stroke:r.stroke,strokeWidth:1.6,strokeDasharray:r.dashed}):(0,k.jsx)(`rect`,{x:l,y:u,width:16,height:10,rx:2,fill:r.fill,stroke:r.stroke,strokeWidth:1.2,strokeDasharray:r.dashed}),(0,k.jsx)(`text`,{x:l+21,y:u+9,fontSize:9,fill:kC,fontFamily:`system-ui, sans-serif`,children:r.hidden===!0?`${r.label} (hidden)`:r.label})]},r.label)}),l=(0,k.jsx)(`text`,{"data-testid":`legend-group`,x:t,y:n+r*BC+9,fontSize:9,fontWeight:600,fill:kC,fontFamily:`system-ui, sans-serif`,children:e.title},`${e.title}-title`);return s+=1,(0,k.jsxs)(`g`,{children:[l,c]},e.title)})})}var XC=6.6,ZC=5.4,QC=22,$C=15,ew=14,tw=3;function nw(e,t,n){let r=e.flatMap(e=>e.split(/\r?\n/)).reduce((e,t)=>Math.max(e,t.length),0);return Math.min(Math.max(r*XC+QC,t),n)}function rw(e,t,n,r){let i=t.map(e=>sw(e).length).reduce((e,t)=>Math.max(e,t),0);return Math.max(nw(e,n,r),Math.min(i*ZC+QC,r))}function iw(e,t,n=XC){let r=Math.max(Math.floor((t-QC)/n+1e-6),4),i=[],a=e.split(/\r?\n/);if(a.length>1)return a.flatMap(e=>iw(e,t,n)).slice(0,tw);let o=``;for(let t of e.split(/\s+/)){let e=o===``?t:`${o} ${t}`;if(e.length<=r){o=e;continue}for(o!==``&&i.push(o),o=t;o.length>r&&i.length<tw;)i.push(o.slice(0,r)),o=o.slice(r)}if(o!==``&&i.push(o),i.length===0)return[``];if(i.length<=tw)return i;let s=i.slice(0,tw);return s[tw-1]=`${s[tw-1].slice(0,Math.max(r-1,1))}…`,s}function aw(e,t){return e*$C+t*$C+ew}function ow(e,t){return e.flatMap(e=>iw(sw(e),t,ZC))}function sw(e){return`${e.field}: ${e.from===void 0?``:`${e.from} → `}${e.to}`}function cw(e,t){let n=[SC(e)];t!==`unchanged`&&n.push(`(${uC[t]})`),e.ref!==void 0&&n.push(`[${e.ref}]`);for(let t of lC(e))n.push(sw(t));return n.join(` `)}function lw({x:e,y:t,width:n,height:r,role:i,label:a,tint:o,changes:s,title:c,anchor:l=`start`,hover:u,elementId:d}){let f=AC[i],p={fill:o?.fill??f.fill,stroke:i===`unchanged`?o?.stroke??f.stroke:f.stroke,text:f.text===kC?kC:OC},m=i===`added`||i===`changed`?2:1.2,h=i===`context`?.62:1,g=iw(a,n),_=ow(s,n),v=g.length+_.length,y=t+r/2-(v-1)*$C/2+4,b=l===`middle`?e+n/2:e+8;return(0,k.jsxs)(`g`,{"data-element-role":i,"data-element-id":d,...u,children:[(0,k.jsx)(`title`,{children:c}),(0,k.jsx)(`rect`,{x:e,y:t,width:n,height:r,rx:5,fill:p.fill,stroke:p.stroke,strokeWidth:m,strokeDasharray:o?.dash,opacity:h}),(0,k.jsxs)(`text`,{x:b,textAnchor:l,fontSize:11,fill:p.text,fontFamily:`system-ui, sans-serif`,children:[g.map((e,t)=>(0,k.jsx)(`tspan`,{x:b,y:y+t*$C,children:e},t)),_.map((e,t)=>(0,k.jsx)(`tspan`,{"data-testid":`field-changes`,x:b,y:y+(g.length+t)*$C,fontSize:9,fontWeight:600,children:e},`change-${t}`))]})]})}function uw(e,t){return`${e}-${t.replace(`#`,``)}`}function dw({prefix:e,paints:t}){return(0,k.jsx)(`defs`,{children:t.map(t=>(0,k.jsx)(`marker`,{id:uw(e,t),viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`6.5`,markerHeight:`6.5`,orient:`auto`,children:(0,k.jsx)(`path`,{d:`M0,0 L10,5 L0,10 z`,fill:t})},t))})}function fw(e,t){let n=t.cx-e.cx,r=t.cy-e.cy;if(n===0&&r===0)return{x:e.cx,y:e.cy};let i=Math.min(n===0?1/0:e.w/2/Math.abs(n),r===0?1/0:e.h/2/Math.abs(r));return{x:e.cx+n*i,y:e.cy+r*i}}function pw(){let[e,t]=(0,d.useState)(void 0);return{hover:e=>({onPointerEnter:n=>t({text:e,x:n.clientX,y:n.clientY}),onPointerMove:n=>t({text:e,x:n.clientX,y:n.clientY}),onPointerLeave:()=>t(void 0)}),Tooltip:()=>e===void 0?null:(0,k.jsx)(`div`,{"data-testid":`diagram-tooltip`,role:`tooltip`,style:{position:`fixed`,left:e.x+14,top:e.y+14,zIndex:120},className:`pointer-events-none max-w-sm rounded bg-zinc-900 px-2 py-1 text-xs text-white shadow-lg dark:bg-zinc-100 dark:text-zinc-900`,children:e.text})}}function mw(e,t){if(e.length<3)return e.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `);let n=[`M ${e[0].x} ${e[0].y}`];for(let r=1;r<e.length-1;r++){let i=e[r-1],a=e[r],o=e[r+1],s=Math.hypot(a.x-i.x,a.y-i.y),c=Math.hypot(o.x-a.x,o.y-a.y);if(s===0||c===0)continue;let l=((a.x-i.x)*(o.y-a.y)-(a.y-i.y)*(o.x-a.x))/(s*c);if(Math.abs(l)<.02)continue;let u=Math.min(t,s/2,c/2),d={x:a.x-(a.x-i.x)/s*u,y:a.y-(a.y-i.y)/s*u},f={x:a.x+(o.x-a.x)/c*u,y:a.y+(o.y-a.y)/c*u};n.push(`L ${d.x} ${d.y}`,`Q ${a.x} ${a.y} ${f.x} ${f.y}`)}let r=e[e.length-1];return n.push(`L ${r.x} ${r.y}`),n.join(` `)}function hw(e,t,n,r,i){if(e===t){let t=26+r*12,n=e.cx-e.w/4,i=e.cx+e.w/4,a=e.y;return{d:`M ${n} ${a} C ${n} ${a-t}, ${i} ${a-t}, ${i} ${a}`,labelAt:{x:e.cx,y:a-t*.75},span:t*2}}let a=fw(e,t),o=fw(t,e),s=Math.hypot(o.x-a.x,o.y-a.y),c=(n??[]).slice(1,-1),l=i===void 0?c:c.map((e,t)=>{let n=c.length===1?.5:t/(c.length-1);return{x:e.x+i.from.dx*(1-n)+i.to.dx*n,y:e.y+i.from.dy*(1-n)+i.to.dy*n}});if(l.length>0&&r===0){let e=l[Math.floor((l.length-1)/2)];return{d:mw([a,...l,o],12),labelAt:e,span:s}}let u=r===0?0:Math.ceil(r/2)*22*(r%2==1?1:-1),d=(a.x+o.x)/2,f=(a.y+o.y)/2;if(u===0)return{d:`M ${a.x} ${a.y} L ${o.x} ${o.y}`,labelAt:{x:d,y:f},span:s};let p=s===0?0:-(o.y-a.y)/s,m=s===0?0:(o.x-a.x)/s,h=d+p*u*2,g=f+m*u*2;return{d:`M ${a.x} ${a.y} Q ${h} ${g} ${o.x} ${o.y}`,labelAt:{x:d+p*u,y:f+m*u},span:s}}function gw(e){let t=(e.match(/-?\d+(?:\.\d+)?/g)??[]).map(Number);if(t.length<2)return;let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let e=0;e+1<t.length;e+=2)n=Math.min(n,t[e]),i=Math.max(i,t[e]),r=Math.min(r,t[e+1]),a=Math.max(a,t[e+1]);return{minX:n,minY:r,maxX:i,maxY:a}}function _w(e,t,n,r){let i=t=>{let n=e.participants.find(e=>e.id===t);return n===void 0?t:SC(n)},a=t.label===void 0||t.label===``?``:`: ${t.label}`;return[`${n+1}.`,`${i(t.from)} → ${i(t.to)}${a}`,t.from===t.to?`(to itself)`:``,r===`unchanged`?``:`[${uC[r]}]`,lC(t).map(sw).join(`, `)].filter(e=>e!==``).join(` `)}function vw(e,t,n){let r=t=>{let n=e.nodes.find(e=>e.id===t);return n===void 0?t:SC(n)},i=t.label??t.kind;return[`${r(t.from)} → ${r(t.to)}`,i===void 0?``:`(${i})`,n===`unchanged`?``:`[${uC[n]}]`,lC(t).map(sw).join(`, `)].filter(e=>e!==``).join(` `)}function yw({data:e,isProposal:t,nudges:n,setNudges:r,hidden:i,setHidden:a}){let o=(0,d.useRef)(null),[s,c]=(0,d.useState)(void 0),[l,u]=(0,d.useState)(!1),{hover:f,Tooltip:p}=pw(),m=(0,d.useRef)(void 0);(0,d.useEffect)(()=>()=>m.current?.(),[]);let h=(0,d.useCallback)(e=>{let t=rw([SC(e)],lC(e),120,260);return{width:t,height:aw(iw(SC(e),t).length,ow(lC(e),t).length)}},[]),g=(0,d.useMemo)(()=>{let t=e.nodes.filter(e=>e.kind===void 0||!i.has(zC(`element`,e.kind))),n=new Set(t.map(e=>e.id));return{nodes:t,edges:e.edges.filter(e=>(e.kind===void 0||!i.has(zC(`relationship`,e.kind)))&&n.has(e.from)&&n.has(e.to)),containers:e.containers}},[e,i]),_=(0,d.useMemo)(()=>bC(g,h),[g,h]),v=(0,d.useMemo)(()=>new Map(_.nodes.map(e=>[e.id,e])),[_]),y=e=>{let t=v.get(e);if(t===void 0)return;let r=n.get(e),i=t.x+(r?.dx??0),a=t.y+(r?.dy??0);return{x:i,y:a,cx:i+t.width/2,cy:a+t.height/2,w:t.width,h:t.height}},b=(0,d.useMemo)(()=>_.containers.map(e=>{let t=dC(g.nodes.filter(t=>t.container===e.id).flatMap(e=>{let t=y(e.id);return t===void 0?[]:[{x:t.x,y:t.y,width:t.w,height:t.h}]}));return t===void 0?e:{...e,...t}}),[_.containers,g,n]),x=(0,d.useMemo)(()=>LC(RC(e.nodes)),[e.nodes]),S=(0,d.useMemo)(()=>LC(RC(e.edges)),[e.edges]),C=(0,d.useMemo)(()=>{let n=e=>t=>{let n=(e===`element`?x:S).get(t);return{label:t,fill:n.fill,stroke:n.stroke,dashed:n.dash,toggles:!0,key:zC(e,t),hidden:i.has(zC(e,t))}},r=[{title:`elements`,sample:`box`,entries:RC(e.nodes).map(n(`element`))},{title:`relationships`,sample:`line`,entries:RC(e.edges).map(n(`relationship`))}];if(t){let e=new Set([...g.nodes.map(e=>sC(e,!0)),...g.edges.map(e=>cC(e,!0))]);r.push({title:`changes`,sample:`box`,entries:MC.filter(t=>t!==`unchanged`&&e.has(t)).map(e=>({label:uC[e],fill:DC,stroke:AC[e].stroke,faded:e===`context`}))})}return r},[e,g,t,x,S,i]),w=(0,d.useMemo)(()=>{let e=new Map,t=new Map;for(let n of g.edges){let r=`${n.from}\u0000${n.to}`,i=t.get(r)??0;e.set(n,i),t.set(r,i+1)}return e},[g]),T=(0,d.useMemo)(()=>{let e=new Map(_.edges.map(e=>[e.index,e.points])),t=new Map;return g.edges.forEach((n,r)=>{let i=e.get(r);i!==void 0&&t.set(n,i)}),t},[_,g]),E={dx:0,dy:0},ee=g.edges.map(e=>{let t=y(e.from),r=y(e.to);if(t===void 0||r===void 0)return;let i=n.has(e.from)||n.has(e.to);return hw(t,e.from===e.to?t:r,T.get(e),w.get(e)??0,i?{from:n.get(e.from)??E,to:n.get(e.to)??E}:void 0)}),D=_.nodes.map(e=>y(e.id)),te=ee.flatMap(e=>{let t=e===void 0?void 0:gw(e.d);return t===void 0?[]:[t]}),ne=Math.min(0,...D.map(e=>e.x-12),...te.map(e=>e.minX-12)),re=Math.min(0,...D.map(e=>e.y-12),...te.map(e=>e.minY-14)),ie=Math.max(_.width,...D.map(e=>e.x+e.w+12),...te.map(e=>e.maxX+12)),ae=Math.max(_.height,...D.map(e=>e.y+e.h+12),...te.map(e=>e.maxY+12)),oe=ie-ne,O=ae-re,A=e=>{let n=cC(e,t),r=e.kind===void 0?void 0:S.get(e.kind);return{role:n,stroke:r?.stroke??jC.unchanged,dash:r?.dash,halo:n===`added`||n===`changed`?jC[n]:void 0,width:n===`context`?1:n===`unchanged`?1.5:1.8,opacity:n===`context`?.6:1}},se=[...new Set(g.edges.map(e=>A(e).stroke))],ce=ae+4,le=Math.max(oe,qC(C)),j=O+JC(C,le),ue=e=>{if(e.button!==0)return;let t=e.target;if(t.closest(`[data-draggable="node"]`)!==null||t.closest(`[data-legend-entry]`)!==null)return;let n=o.current?.parentElement??null;for(;n!==null&&n.scrollWidth<=n.clientWidth&&n.scrollHeight<=n.clientHeight;)n=n.parentElement;if(n===null)return;e.preventDefault();let r=e.clientX,i=e.clientY,a=n.scrollLeft,s=n.scrollTop,c=e.currentTarget;c.setPointerCapture?.(e.pointerId),u(!0);let l=e=>{n.scrollLeft=a-(e.clientX-r),n.scrollTop=s-(e.clientY-i)},d=()=>{m.current=void 0,c.releasePointerCapture?.(e.pointerId),c.removeEventListener(`pointermove`,l),c.removeEventListener(`pointerup`,d),c.removeEventListener(`pointercancel`,d),u(!1)};m.current?.(),m.current=d,c.addEventListener(`pointermove`,l),c.addEventListener(`pointerup`,d),c.addEventListener(`pointercancel`,d)},de=e=>t=>{if(t.button!==0)return;t.preventDefault();let i=o.current,a=i===null?1:(i.getBoundingClientRect().width||le)/le,s=t.clientX,l=t.clientY,u=n.get(e)??{dx:0,dy:0},d=t.currentTarget;d.setPointerCapture?.(t.pointerId),c(e);let f=t=>{let i=new Map(n);i.set(e,{dx:u.dx+(t.clientX-s)/a,dy:u.dy+(t.clientY-l)/a}),r(i)},p=()=>{m.current=void 0,d.releasePointerCapture?.(t.pointerId),d.removeEventListener(`pointermove`,f),d.removeEventListener(`pointerup`,p),d.removeEventListener(`pointercancel`,p),c(void 0)};m.current?.(),m.current=p,d.addEventListener(`pointermove`,f),d.addEventListener(`pointerup`,p),d.addEventListener(`pointercancel`,p)};return(0,k.jsxs)(k.Fragment,{children:[n.size>0&&(0,k.jsx)(`button`,{type:`button`,className:`mb-1 text-xs underline text-neutral-500 hover:text-neutral-800 dark:hover:text-neutral-200`,onClick:()=>r(new Map),children:`reset layout`}),(0,k.jsx)(p,{}),(0,k.jsxs)(`svg`,{ref:o,role:`img`,"aria-label":g.nodes.length===e.nodes.length?`Graph of ${e.nodes.length} elements and ${e.edges.length} relationships`:`Graph of ${e.nodes.length} elements and ${e.edges.length} relationships, filtered to ${g.nodes.length} elements and ${g.edges.length} relationships`,viewBox:`${ne} ${re} ${le} ${j}`,width:le,height:j,xmlns:`http://www.w3.org/2000/svg`,onPointerDown:ue,style:{cursor:l?`grabbing`:`grab`,touchAction:`none`},children:[(0,k.jsx)(`rect`,{x:ne,y:re,width:le,height:j,fill:DC}),(0,k.jsx)(dw,{prefix:`se-arrow`,paints:se}),b.map(e=>(0,k.jsxs)(`g`,{"data-container":e.id,children:[(0,k.jsx)(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:8,fill:`none`,stroke:kC,strokeOpacity:.55,strokeDasharray:`5 3`}),(0,k.jsx)(`text`,{x:e.x+8,y:e.y+12,fontSize:10,fill:kC,children:e.label})]},`container-${e.id}`)),g.edges.map((t,n)=>{let r=y(t.from),i=y(t.to);if(r===void 0||i===void 0)return null;let a=A(t),o=a.role,s=a.stroke,c=lC(t),l=t.label??t.kind,u=ee[n],d=e=>e.length*5.2+8<=u.span;return(0,k.jsxs)(`g`,{"data-relationship-role":o,"data-relationship-shape":t.from===t.to?`loop`:`open`,...f(vw(e,t,o)),children:[(0,k.jsx)(`title`,{children:vw(e,t,o)}),(0,k.jsx)(`path`,{"data-edge":`hit`,d:u.d,fill:`none`,stroke:`transparent`,strokeWidth:14,pointerEvents:`stroke`}),a.halo!==void 0&&(0,k.jsx)(`path`,{"data-edge":`role`,pointerEvents:`none`,d:u.d,fill:`none`,stroke:a.halo,strokeWidth:a.width+4,strokeLinecap:`round`,opacity:.3}),(0,k.jsx)(`path`,{"data-edge":`line`,pointerEvents:`none`,d:u.d,fill:`none`,stroke:s,strokeWidth:a.width,strokeDasharray:a.dash,opacity:a.opacity,markerEnd:`url(#${uw(`se-arrow`,s)})`}),l!==void 0&&d(l)&&(0,k.jsx)(`text`,{x:u.labelAt.x,y:u.labelAt.y-5,textAnchor:`middle`,fontSize:9,fill:s,fontFamily:`system-ui, sans-serif`,stroke:DC,strokeWidth:3,paintOrder:`stroke`,children:l}),c.length>0&&d(c.map(sw).join(`, `))&&(0,k.jsx)(`text`,{"data-testid":`relationship-change`,x:u.labelAt.x,y:u.labelAt.y+10,textAnchor:`middle`,fontSize:9,fontWeight:600,fill:s,fontFamily:`system-ui, sans-serif`,stroke:DC,strokeWidth:3,paintOrder:`stroke`,children:c.map(sw).join(`, `)})]},`edge-${n}`)}),g.nodes.map(e=>{let n=y(e.id);if(n===void 0)return null;let r=sC(e,t);return(0,k.jsx)(`g`,{"data-draggable":`node`,onPointerDown:de(e.id),style:{cursor:s===e.id?`grabbing`:`grab`},children:(0,k.jsx)(lw,{x:n.x,y:n.y,width:n.w,height:n.h,role:r,label:SC(e),tint:e.kind===void 0?void 0:x.get(e.kind),changes:lC(e),title:cw(e,r),hover:f(cw(e,r)),elementId:e.id})},e.id)}),i.size>0&&(0,k.jsx)(`text`,{"data-testid":`diagram-filter-note`,x:ne+12,y:ce+JC(C,le)-4,fontSize:9,fontWeight:600,fill:`#92400e`,fontFamily:`system-ui, sans-serif`,children:`Filtered view: ${g.nodes.length} of ${e.nodes.length} elements and ${g.edges.length} of ${e.edges.length} relationships shown.`+(t?` Hidden types are still part of the proposal.`:``)}),(0,k.jsx)(YC,{groups:C,x:ne+12,y:ce,width:le,onToggle:e=>{let t=new Set(i);t.delete(e)||t.add(e),a(t)}})]})]})}var bw=40,xw=22,Sw=26;function Cw({data:e,isProposal:t}){let n=(0,d.useMemo)(()=>{let t=e.containers??[];if(t.length===0)return e.participants;let n=new Set(t.map(e=>e.id)),r=new Set,i=[];for(let t of e.participants){if(r.has(t.id))continue;let a=t.container;if(a===void 0||!n.has(a)){i.push(t),r.add(t.id);continue}for(let t of e.participants)t.container!==a||r.has(t.id)||(i.push(t),r.add(t.id))}return i},[e.participants,e.containers]),r=(0,d.useMemo)(()=>{let t=e.containers??[],r=[];return n.forEach((e,n)=>{let i=t.find(t=>t.id===e.container);if(i===void 0)return;let a=r.at(-1);a!==void 0&&a.container.id===i.id&&a.to===n-1?a.to=n:r.push({container:i,from:n,to:n})}),r},[n,e.containers]),i=(e.containers??[]).length>0?xw:0,a=(0,d.useMemo)(()=>new Map(n.map((e,t)=>[e.id,t])),[n]),o=(0,d.useMemo)(()=>Math.max(...e.participants.map(e=>rw([SC(e)],lC(e),110,240)),nw(e.messages.map(e=>e.label??``),110,240)*.8),[e.participants,e.messages]),s=o-14,c=(0,d.useMemo)(()=>e.participants.reduce((e,t)=>Math.max(e,aw(iw(SC(t),s).length,ow(lC(t),s).length)),aw(1,0))+8,[e.participants,s]),l=e=>(a.get(e)??0)*o+o/2,u=Math.max(e.participants.length*o,240),f=i+c+(e.messages.length+1)*bw,p=(0,d.useMemo)(()=>LC(RC(e.participants)),[e.participants]),m=(0,d.useMemo)(()=>{let n=[{title:`participants`,sample:`box`,entries:RC(e.participants).map(e=>{let t=p.get(e);return{label:e,fill:t.fill,stroke:t.stroke,dashed:t.dash,key:zC(`element`,e)}})}];if(t){let t=new Set([...e.participants.map(e=>sC(e,!0)),...e.messages.map(e=>cC(e,!0))]);n.push({title:`changes`,sample:`box`,entries:MC.filter(e=>e!==`unchanged`&&t.has(e)).map(e=>({label:uC[e],fill:DC,stroke:AC[e].stroke,faded:e===`context`}))})}return n},[e,t,p]),{hover:h,Tooltip:g}=pw(),_=f+4,v=Math.max(u,qC(m)),y=f+JC(m,v);return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`svg`,{role:`img`,"aria-label":`Sequence of ${e.participants.length} participants and ${e.messages.length} messages`,viewBox:`0 0 ${v} ${y}`,width:v,height:y,xmlns:`http://www.w3.org/2000/svg`,children:[(0,k.jsx)(`rect`,{x:0,y:0,width:v,height:y,fill:DC}),(0,k.jsx)(dw,{prefix:`se-msg`,paints:MC.map(e=>jC[e])}),r.map(e=>{let t=e.from*o+(o-s)/2,n=e.to*o+(o+s)/2;return(0,k.jsxs)(`g`,{"data-container":e.container.id,children:[(0,k.jsx)(`rect`,{x:t,y:2,width:n-t,height:xw-6,rx:5,fill:`none`,stroke:kC,strokeOpacity:.55,strokeDasharray:`5 3`}),(0,k.jsx)(`text`,{x:(t+n)/2,y:xw-9,fontSize:10,textAnchor:`middle`,fill:kC,children:e.container.label})]},`band-${e.container.id}-${e.from}`)}),n.map(e=>(0,k.jsx)(`line`,{x1:l(e.id),y1:i+c,x2:l(e.id),y2:f-6,stroke:`#d4d4d8`,strokeDasharray:`3 3`,strokeWidth:1},`life-${e.id}`)),n.map(e=>{let n=sC(e,t);return(0,k.jsx)(lw,{x:l(e.id)-s/2,y:i+4,width:s,height:c-8,role:n,label:SC(e),tint:e.kind===void 0?void 0:p.get(e.kind),changes:lC(e),title:cw(e,n),hover:h(cw(e,n)),anchor:`middle`,elementId:e.id},e.id)}),e.messages.map((n,r)=>{let a=cC(n,t),o=_w(e,n,r,a),s=jC[a],u=i+c+(r+1)*bw,d=l(n.from),f=l(n.to),p=n.from===n.to,m=lC(n),g=p?d+Sw+6:(d+f)/2;return(0,k.jsxs)(`g`,{"data-relationship-role":a,"data-message-index":r,"data-message-from":n.from,"data-message-to":n.to,...h(o),children:[(0,k.jsx)(`title`,{children:o}),p?(0,k.jsx)(`path`,{d:`M ${d} ${u} h ${Sw} v ${bw/2} h -${Sw}`,fill:`none`,stroke:s,strokeWidth:1.4,markerEnd:`url(#${uw(`se-msg`,jC[a])})`}):(0,k.jsx)(`line`,{x1:d,y1:u,x2:f,y2:u,stroke:s,strokeWidth:1.4,markerEnd:`url(#${uw(`se-msg`,jC[a])})`}),(0,k.jsx)(`text`,{x:g,y:u-5,textAnchor:p?`start`:`middle`,fontSize:10,fill:OC,fontFamily:`system-ui, sans-serif`,stroke:DC,strokeWidth:3,paintOrder:`stroke`,children:n.label}),m.length>0&&(0,k.jsx)(`text`,{"data-testid":`relationship-change`,x:g,y:u+11,textAnchor:p?`start`:`middle`,fontSize:9,fontWeight:600,fill:s,fontFamily:`system-ui, sans-serif`,stroke:DC,strokeWidth:3,paintOrder:`stroke`,children:m.map(sw).join(`, `)}),(0,k.jsx)(`text`,{x:4,y:u+3,fontSize:9,fill:kC,fontFamily:`system-ui, sans-serif`,children:r+1})]},r)}),(0,k.jsx)(YC,{groups:m,x:12,y:_,width:v})]}),(0,k.jsx)(g,{})]})}function ww({data:e}){return(0,k.jsx)(`div`,{className:`overflow-x-auto`,children:(0,k.jsxs)(`table`,{className:`w-full border-collapse text-xs`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsx)(`tr`,{children:e.columns.map((e,t)=>(0,k.jsx)(`th`,{className:`border-b border-zinc-300 px-2 py-1 text-left font-medium dark:border-zinc-700`,children:e},t))})}),(0,k.jsx)(`tbody`,{children:e.rows.map((e,t)=>(0,k.jsx)(`tr`,{children:e.map((e,t)=>(0,k.jsx)(`td`,{className:`border-b border-zinc-200 px-2 py-1 dark:border-zinc-800`,children:e===null?(0,k.jsx)(`span`,{className:`opacity-40`,children:`—`}):String(e)},t))},t))})]})})}function Tw(e,t){if(e===void 0)return JSON.stringify(t,null,2);try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Ew(e,t){let n=xC(e,t),r=[];if(n.columns!==void 0&&n.rows!==void 0){r.push(n.columns.join(` | `));for(let e of n.rows)r.push(e.map(e=>e===null?``:String(e)).join(` | `))}else{if(r.push([`${n.things.length} ${n.thingNoun}s`,`${n.links.length} ${n.linkNoun}s`,...n.containers.length>0?[`${n.containers.length} containers`]:[]].join(`, `)),r.push(``),n.containers.length>0){for(let e of n.containers){let t=n.things.filter(t=>t.container===e.id);r.push(`${e.label}: ${t.length===0?`no members`:t.map(e=>e.label).join(`, `)}`)}r.push(``)}let e=new Map(n.containers.map(e=>[e.id,e.label]));for(let t of n.things){let n=t.container===void 0?void 0:e.get(t.container);r.push([t.label,t.kind===void 0?``:` [${t.kind}]`,n===void 0?``:` in ${n}`,t.role===`unchanged`?``:` (${uC[t.role]})`,t.changes.length===0?``:` — ${t.changes.map(sw).join(`, `)}`].join(``))}n.links.length>0&&r.push(``),n.links.forEach((e,t)=>{let i=[e.kind,e.label].filter(e=>e!==void 0&&e!==``),a=i.length===0?`→`:`—${i.join(`: `)}→`;r.push([n.linkNoun===`message`?`${t+1}. `:``,`${e.fromLabel} ${a} ${e.toLabel}`,e.isLoop?` (to itself)`:``,e.role===`unchanged`?``:` (${uC[e.role]})`,e.changes.length===0?``:` — ${e.changes.map(sw).join(`, `)}`].join(``))})}if(n.removals.length>0){r.push(``);for(let e of n.removals)r.push(`removed ${e.type}: ${e.ref}`)}return r.join(`
|
|
316
316
|
`)}function Dw(e,t){let n=e=>{if(e===void 0)return;let n=t.data,r=[...n.nodes??[],...n.participants??[]].find(t=>t.id===e||t.ref===e);return r===void 0?e:SC(r)},r=t.data,i=[...r.nodes??[],...r.participants??[],...r.edges??[],...r.messages??[]].find(t=>`ref`in t&&t.ref===e.ref),a=e.from!==void 0||e.to!==void 0?`${n(e.from)??`?`} → ${n(e.to)??`?`}`:i!==void 0&&`from`in i?`${n(i.from)} → ${n(i.to)}`:void 0,o=e.label??(i===void 0?void 0:i.label),s=e.kind??(i===void 0?void 0:i.kind),c=[o,s===void 0?void 0:`[${s}]`,a].filter(e=>e!==void 0&&e!==``);return c.length===0?e.ref:`${c.join(` `)} (${e.ref})`}var Ow=`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200`;function kw({item:e}){let t=oC(e.structured),[n,r]=(0,d.useState)(!1),[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(!1),[u,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(null),h=(0,d.useRef)(null),g=(0,d.useRef)(null),[_,v]=(0,d.useState)(new Map),[y,b]=(0,d.useState)(new Set),x=(0,d.useMemo)(()=>t?CC(t):void 0,[t]);if(t===void 0)return null;let S=t.target!==void 0,C=t.removals??[],w=t.kind===`graph`?(0,k.jsx)(yw,{data:t.data,isProposal:S,nudges:_,setNudges:v,hidden:y,setHidden:b}):t.kind===`sequence`?(0,k.jsx)(Cw,{data:t.data,isProposal:S}):(0,k.jsx)(ww,{data:t.data}),T=`${t.kind}-${t.target??`diagram`}.svg`.replace(/[^\w.-]+/g,`-`);function E(e){let t=e.cloneNode(!0);for(let e of[t,...t.querySelectorAll(`[style]`)])e.style.removeProperty(`cursor`),e.style.removeProperty(`touch-action`),e.getAttribute(`style`)===``&&e.removeAttribute(`style`);return t}function ee(){let e=(g.current??h.current)?.querySelector(`svg`);return e?new XMLSerializer().serializeToString(E(e)):void 0}function D(){let e=ee();if(e===void 0)return;let t=URL.createObjectURL(new Blob([e],{type:`image/svg+xml`})),n=document.createElement(`a`);n.href=t,n.download=T,n.click(),URL.revokeObjectURL(t),m(`SVG downloaded`),window.setTimeout(()=>m(null),2500)}async function te(){let e=ee();if(e!==void 0){try{await navigator.clipboard.writeText(e),m(`SVG markup copied`)}catch{m(`could not copy`)}window.setTimeout(()=>m(null),2500)}}return(0,k.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[S&&(0,k.jsxs)(`p`,{className:`text-xs text-zinc-500`,"data-testid":`structured-proposal-note`,children:[`Proposed changes to `,(0,k.jsx)(`span`,{className:`font-mono`,children:t.target}),`. Anything not mentioned is left as it is; anything shown without a change is here for context.`]}),y.size>0&&(0,k.jsxs)(`p`,{"data-testid":`structured-filtered`,className:`flex flex-wrap items-center gap-2 rounded border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,k.jsxs)(`span`,{children:[`Filtered view — `,[...y].map(e=>e.replace(/^(element|relationship):/,``)).join(`, `),` hidden.`,` `,S?`The full proposal still applies.`:``]}),(0,k.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>b(new Set),children:`show everything`})]}),(0,k.jsx)(`div`,{ref:h,className:`overflow-x-auto`,children:w}),(0,k.jsx)(ve,{label:`${t.kind} view`,open:n,onClose:()=>r(!1),containerRef:g,anchorRef:h,actions:t.kind!==`table`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,onClick:D,className:Ow,children:`⤓ download SVG`}),(0,k.jsx)(`button`,{type:`button`,onClick:te,className:Ow,children:`copy markup`}),p!==null&&(0,k.jsx)(`span`,{className:`text-xs text-zinc-500`,children:p})]}),children:w}),C.length>0&&(0,k.jsx)(`ul`,{className:`space-y-1`,"data-testid":`structured-removals`,children:C.map((e,n)=>(0,k.jsxs)(`li`,{"data-relationship-role":`removed`,className:`rounded border border-red-300 bg-red-50 px-2 py-1 text-xs text-red-800 dark:border-red-800 dark:bg-red-950/40 dark:text-red-200`,children:[(0,k.jsx)(`span`,{className:`line-through`,children:Dw(e,t)}),Dw(e,t)===e.ref&&(0,k.jsx)(`span`,{className:`ml-2 not-italic opacity-70`,"data-testid":`removal-undescribed`,children:`— the proposal does not say what this is`}),(0,k.jsx)(`span`,{className:`ml-2 font-mono opacity-60`,children:e.type})]},n))}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:[(0,k.jsx)(`button`,{type:`button`,className:`text-zinc-500 underline`,"aria-label":`Show ${t.kind} view at full size`,onClick:()=>r(!0),children:`⤢ enlarge`}),t.kind!==`table`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`text-zinc-500 underline`,title:`Save as .svg — insert it as a picture in a document`,onClick:D,children:`⤓ download SVG`}),(0,k.jsx)(`button`,{type:`button`,className:`text-zinc-500 underline`,title:`Copy the SVG markup, for somewhere that takes it directly`,onClick:()=>void te(),children:`copy markup`})]}),(0,k.jsxs)(`button`,{type:`button`,className:`text-zinc-500 underline`,onClick:()=>a(e=>!e),children:[i?`hide`:`show`,` text equivalent`]}),x!==void 0&&(0,k.jsxs)(`button`,{type:`button`,className:`text-zinc-500 underline`,onClick:()=>s(e=>!e),children:[o?`hide`:`show`,` derived diagram syntax`]}),(0,k.jsxs)(`button`,{type:`button`,className:`text-zinc-500 underline`,onClick:()=>f(e=>!e),children:[u?`hide`:`show`,` envelope`]}),(0,k.jsxs)(`button`,{type:`button`,className:`text-zinc-500 underline`,onClick:()=>l(e=>!e),children:[c?`hide`:`show`,` original output`]}),p!==null&&(0,k.jsx)(`span`,{role:`status`,className:`text-emerald-600 dark:text-emerald-400`,children:p})]}),i&&(0,k.jsx)(`pre`,{"data-testid":`structured-text-equivalent`,className:`overflow-x-auto rounded bg-zinc-100 p-2 text-xs dark:bg-zinc-800`,children:Ew(t,S)}),o&&x!==void 0&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`p`,{className:`mb-1 text-[11px] text-zinc-500`,children:`Derived from the structured data above. It is an export, not the source.`}),(0,k.jsx)(`pre`,{"data-testid":`structured-derived-export`,className:`overflow-x-auto rounded bg-zinc-100 p-2 text-xs dark:bg-zinc-800`,children:x})]}),u&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`p`,{className:`mb-1 text-[11px] text-zinc-500`,children:`The validated document this view is drawn from. It is not sent to the model.`}),(0,k.jsx)(`pre`,{"data-testid":`structured-envelope`,className:`max-h-80 overflow-auto rounded bg-zinc-100 p-2 text-xs dark:bg-zinc-800`,children:Tw(e.structured,t)})]}),c&&(0,k.jsx)(`pre`,{"data-testid":`structured-raw-output`,className:`overflow-x-auto rounded bg-zinc-100 p-2 text-xs dark:bg-zinc-800`,children:e.output})]})}var Aw=[ev,{id:`structured-exchange`,match:e=>oC(e.structured)!==void 0,stable:!1,showsRawReveal:!0,startsExpanded:!0,Expanded:kw},nv,iv,mv,xv,av,ov,$_];function jw(e){for(let t of Aw){let n=!1;try{n=t.match(e)}catch{n=!1}if(n)return t}return $_}function Mw(e,t){let n=jw(e);if(t===void 0||t===n.id)return n;let r=Aw.find(e=>e.id===t);if(r===void 0||r.id===$_.id||n.extensionOwned===!0)return n;let i=!1;try{i=r.match(e)}catch{i=!1}return i?r:n}function Nw(e){if(typeof e!=`object`||!e)return``;let t=e,n=[`command`,`path`,`file_path`,`pattern`,`query`].find(e=>typeof t[e]==`string`);if(n)return t[n];let r=JSON.stringify(t);return r===`{}`?``:r}function Pw({item:e,dispatch:t=K_}){let n=(0,d.useRef)(void 0),r=Mw(e,n.current);n.current=r.id;let i=r.startsExpanded===!0,[a,o]=(0,d.useState)(i);(0,d.useEffect)(()=>{o(i)},[i]);let[s,c]=(0,d.useState)(!1),l=Nw(e.args),u=r.Collapsed,f=!a&&u!==void 0&&(r.hasCollapsed?.(e)??!0);return(0,k.jsxs)(`div`,{className:`rounded-lg border text-sm ${e.isError?`border-red-300 bg-red-50 dark:border-red-900/60 dark:bg-red-950/20`:`border-zinc-200 bg-zinc-50 dark:border-zinc-800 dark:bg-zinc-900/60`}`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>o(!a),className:`flex w-full items-center gap-2 px-3 py-2 text-left`,children:[(0,k.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.running?`animate-pulse motion-reduce:animate-none bg-amber-400`:e.isError?`bg-red-500`:`bg-emerald-500`}`}),e.callHtml?(0,k.jsx)(we,{as:`span`,html:e.callHtml,className:`min-w-0 flex-1 text-zinc-700 dark:text-zinc-300`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`font-mono font-medium text-zinc-700 dark:text-zinc-300`,children:e.toolName}),l&&(0,k.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-500`,children:l})]}),(0,k.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-600`,children:a?`▾`:`▸`})]}),f&&u!==void 0&&(0,k.jsx)(`div`,{className:`border-t border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:(0,k.jsx)(u,{item:e,dispatch:t})}),a&&(0,k.jsxs)(`div`,{className:`border-t border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsx)(r.Expanded,{item:e,dispatch:t}),r.showsRawReveal===!0&&(0,k.jsxs)(`div`,{className:`mt-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>c(!s),className:`text-xs text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-400`,children:s?`hide raw output`:`raw output`}),s&&(0,k.jsx)(`div`,{className:`mt-1`,children:(0,k.jsx)(Q_,{item:e})})]})]})]})}function Fw({item:e}){let[t,n]=(0,d.useState)(!1),r=e.details!==void 0,i=!!e.contentHtml,a=e.contentHtmlCollapsed??e.contentHtml,o=r||i&&!!e.contentHtmlCollapsed;return(0,k.jsxs)(`div`,{className:`rounded-lg border border-violet-200 bg-violet-50 px-3 py-2 text-sm dark:border-violet-900/60 dark:bg-violet-950/30`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`span`,{className:`font-mono text-xs font-bold text-violet-700 dark:text-violet-300`,children:[`[`,e.customType,`]`]}),o&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>n(!t),title:`Show details`,className:`ml-auto text-xs text-violet-500 hover:text-violet-700 dark:text-violet-500 dark:hover:text-violet-300`,children:t?`▾`:`▸`})]}),i&&a?(0,k.jsx)(we,{html:t||!e.contentHtmlCollapsed?e.contentHtml??a:a,className:`mt-1 text-violet-950 dark:text-violet-100`}):(0,k.jsx)(`div`,{className:`prose-chat mt-1 text-violet-950 dark:text-violet-100`,children:(0,k.jsx)(fs,{remarkPlugins:[E_,R_],rehypePlugins:[Em],children:T(e.text)})}),t&&r&&(0,k.jsx)(`pre`,{className:`mt-2 max-h-96 overflow-auto border-t border-violet-200 pt-2 font-mono text-xs text-violet-600 dark:border-violet-900/60 dark:text-violet-400`,children:JSON.stringify(e.details,null,2)})]})}var Iw={cost:0,unpriced:0,turns:0,input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0};function Lw(e){let t={...Iw};for(let n of e){if(n.kind!==`assistant`||!n.usage)continue;let e=n.usage;t.turns+=1,t.input+=e.input,t.output+=e.output,t.cacheRead+=e.cacheRead,t.cacheWrite+=e.cacheWrite,t.totalTokens+=e.totalTokens,e.cost===void 0?t.unpriced+=1:t.cost+=e.cost}return t}function Rw(e){let t=e>0&&e<.01?4:2;return`$${e.toFixed(t)}`}function zw(e){return e<1e3?String(e):e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1)}M`}var Bw=80,Vw=new WeakMap;function Hw(e){let t=typeof e==`object`&&!!e;if(t){let t=Vw.get(e);if(t!==void 0)return t}let n=0;try{n=JSON.stringify(e)?.length??0}catch{n=0}return t&&Vw.set(e,n),n}function Uw(e){let t=e.replace(/\s+/g,` `).trim();return t.length>Bw?`${t.slice(0,Bw-1)}…`:t}function Ww(e,t){return{index:e,title:t,turns:0,toolCalls:0,failedToolCalls:0,input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,unpriced:0}}function Gw(e,t){e.turns+=1,e.input+=t.input,e.output+=t.output,e.cacheRead+=t.cacheRead,e.cacheWrite+=t.cacheWrite,e.totalTokens+=t.totalTokens,t.cost===void 0?e.unpriced+=1:e.cost=(e.cost??0)+t.cost}function Kw(e){if(e.length===0)return 0;let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==1?t[n]:(t[n-1]+t[n])/2}function qw(e){let t=[],n=[],r=[],i=new Map,a=Ww(-1,``),o=a;e.forEach((e,a)=>{if(e.kind===`user`){o=Ww(a,Uw(e.text)),r.push(o);return}if(e.kind===`assistant`){if(!e.usage)return;t.push({index:a,number:t.length+1,requestIndex:o.index,usage:e.usage}),Gw(o,e.usage);return}if(e.kind!==`tool`)return;let s={index:a,toolCallId:e.toolCallId,name:e.toolName,inputSize:Hw(e.args),outputSize:e.output.length,isError:e.isError===!0,running:e.running===!0,requestIndex:o.index};n.push(s),o.toolCalls+=1,s.isError&&(o.failedToolCalls+=1);let c=i.get(s.name)??{name:s.name,calls:0,failures:0,inputSize:0,outputSize:0};c.calls+=1,s.isError&&(c.failures+=1),c.inputSize+=s.inputSize,c.outputSize+=s.outputSize,i.set(s.name,c)}),(a.turns>0||a.toolCalls>0)&&r.unshift(a);let s=Lw(e),c=t.map(e=>e.usage.cost).filter(e=>e!==void 0),l=n.filter(e=>e.isError).length;return{turns:t,requests:r,toolCalls:n,tools:[...i.values()],totals:s,pricedTurns:c.length,averageTurnCost:c.length===0?0:s.cost/c.length,medianTurnCost:Kw(c),totalToolCalls:n.length,failedToolCalls:l,toolCallsPerTurn:t.length===0?0:n.length/t.length}}function Jw(e,t){let n=[...e];return t===`input`?n.sort((e,t)=>t.inputSize-e.inputSize):t===`failure`?n.sort((e,t)=>Number(t.isError)-Number(e.isError)||t.outputSize-e.outputSize):n.sort((e,t)=>t.outputSize-e.outputSize)}function Yw(e){return e.filter(e=>e.index>=0).sort((e,t)=>t.totalTokens-e.totalTokens||(t.cost??0)-(e.cost??0))}function Xw(e){return e<1e3?`${e} B`:e<1e6?`${Math.round(e/1e3)} kB`:`${(e/1e6).toFixed(1)} MB`}var Zw=768,Qw=26,$w=132,eT=12,tT=96,nT=$w-8,rT=[{key:`input`,label:`input`,className:`text-emerald-500`,value:e=>e.usage.input},{key:`output`,label:`output`,className:`text-blue-500`,value:e=>e.usage.output},{key:`cacheRead`,label:`cache read`,className:`text-violet-500`,value:e=>e.usage.cacheRead},{key:`cacheWrite`,label:`cache write`,className:`text-amber-500`,value:e=>e.usage.cacheWrite}],iT=[{key:`cost`,label:`cost`,className:`text-rose-500`,value:e=>e.usage.cost??0}];function aT({title:e,children:t}){return(0,k.jsxs)(`section`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:[(0,k.jsx)(`h3`,{className:`mb-2 font-mono text-[11px] uppercase tracking-wide text-zinc-400 dark:text-zinc-500`,children:e}),t]})}function oT({children:e}){return(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:e})}function sT({label:e,value:t,hint:n}){return(0,k.jsxs)(`div`,{className:`rounded-md border border-zinc-200 px-2 py-1.5 dark:border-zinc-800`,children:[(0,k.jsx)(`div`,{"aria-label":`${e}: ${t}`,className:`font-mono text-sm text-zinc-700 dark:text-zinc-200`,children:t}),(0,k.jsx)(`div`,{className:`text-[11px] text-zinc-500 dark:text-zinc-400`,children:e}),n&&(0,k.jsx)(`div`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,children:n})]})}function cT({turns:e,series:t,format:n,onJump:r,describe:i}){let a=Math.max(1,...e.flatMap(e=>t.map(t=>t.value(e)))),o=Math.max(e.length*Qw,Qw),s=e=>Qw/2+e*Qw,c=e=>eT+tT*(1-e/a);return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`mb-1 flex flex-wrap gap-x-3 gap-y-1`,children:t.map(e=>(0,k.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-zinc-500 dark:text-zinc-400`,children:[(0,k.jsx)(`span`,{className:`inline-block h-0.5 w-3 bg-current ${e.className}`}),e.label]},e.key))}),(0,k.jsxs)(`div`,{className:`flex`,children:[(0,k.jsxs)(`div`,{"aria-hidden":!0,className:`flex w-12 shrink-0 flex-col justify-between py-2 pr-1 text-right font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,style:{height:$w},children:[(0,k.jsx)(`span`,{children:n(a)}),(0,k.jsx)(`span`,{children:`0`})]}),(0,k.jsx)(`div`,{className:`min-w-0 flex-1 overflow-x-auto`,children:(0,k.jsxs)(`svg`,{width:o,height:$w,role:`group`,"aria-label":`Per-turn chart`,children:[(0,k.jsx)(`line`,{x1:0,x2:o,y1:108,y2:108,stroke:`currentColor`,className:`text-zinc-200 dark:text-zinc-800`}),t.map(t=>(0,k.jsx)(`polyline`,{fill:`none`,stroke:`currentColor`,strokeWidth:1.5,className:t.className,points:e.map((e,n)=>`${s(n)},${c(t.value(e))}`).join(` `)},t.key)),e.map((n,a)=>(0,k.jsxs)(`g`,{children:[t.map(e=>(0,k.jsx)(`circle`,{cx:s(a),cy:c(e.value(n)),r:2,fill:`currentColor`,className:e.className},e.key)),(0,k.jsx)(`rect`,{x:s(a)-Qw/2,y:0,width:Qw,height:$w,fill:`transparent`,role:`button`,tabIndex:0,"aria-label":`Turn ${n.number}: ${i(n)} — jump to it`,className:`cursor-pointer outline-none focus-visible:fill-zinc-500/10`,onClick:()=>r(n.index),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(n.index))},children:(0,k.jsx)(`title`,{children:`turn ${n.number} · ${i(n)}`})}),(e.length<=12||n.number%5==0)&&(0,k.jsx)(`text`,{x:s(a),y:nT,textAnchor:`middle`,className:`fill-zinc-400 text-[9px] dark:fill-zinc-600`,children:n.number})]},n.index))]})})]})]})}function lT({onJump:e,label:t,children:n}){return(0,k.jsx)(`button`,{type:`button`,onClick:e,"aria-label":t,className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1 text-left text-xs hover:bg-zinc-100 dark:hover:bg-zinc-900`,children:n})}function uT({analysis:e,onJump:t,onClose:n}){let[r,i]=(0,d.useState)(`output`),{totals:a}=e;function o(e){t(e),window.innerWidth<Zw&&n()}let s=e.turns.length===0&&e.toolCalls.length===0,c=Jw(e.toolCalls,r),l=Yw(e.requests);return(0,k.jsxs)(`aside`,{"aria-label":`Session analysis`,className:`absolute inset-y-0 right-0 z-10 w-full overflow-y-auto border-l border-zinc-200 bg-white shadow-xl md:w-[26rem] dark:border-zinc-800 dark:bg-zinc-950`,children:[(0,k.jsxs)(`header`,{className:`sticky top-0 flex items-center gap-2 border-b border-zinc-200 bg-white px-4 py-2 dark:border-zinc-800 dark:bg-zinc-950`,children:[(0,k.jsx)(`h2`,{className:`font-mono text-xs text-zinc-600 dark:text-zinc-300`,children:`session analysis`}),(0,k.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close session analysis`,className:`ml-auto rounded-md px-2 py-1 text-sm text-zinc-500 hover:bg-zinc-100 dark:text-zinc-400 dark:hover:bg-zinc-900`,children:`×`})]}),s?(0,k.jsx)(`div`,{className:`px-4 py-6`,children:(0,k.jsx)(oT,{children:`Nothing to analyse yet — no turn has reported figures and no tool has been called.`})}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(aT,{title:`tokens`,children:(0,k.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,k.jsx)(sT,{label:`total`,value:zw(a.totalTokens)}),(0,k.jsx)(sT,{label:`fresh input`,value:zw(a.input)}),(0,k.jsx)(sT,{label:`output`,value:zw(a.output)}),(0,k.jsx)(sT,{label:`cache read`,value:zw(a.cacheRead)}),(0,k.jsx)(sT,{label:`cache write`,value:zw(a.cacheWrite)}),(0,k.jsx)(sT,{label:`turns`,value:String(e.turns.length)})]})}),(0,k.jsx)(aT,{title:`cost`,children:e.pricedTurns===0?(0,k.jsx)(oT,{children:`No turn was priced — this provider reports tokens only.`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,k.jsx)(sT,{label:`total`,value:Rw(a.cost)}),(0,k.jsx)(sT,{label:`average turn`,value:Rw(e.averageTurnCost)}),(0,k.jsx)(sT,{label:`median turn`,value:Rw(e.medianTurnCost)})]}),(0,k.jsxs)(`p`,{className:`mt-1 text-[11px] text-zinc-400 dark:text-zinc-500`,children:[`over `,e.pricedTurns,` priced turn`,e.pricedTurns===1?``:`s`,a.unpriced>0&&`, ${a.unpriced} unpriced`]})]})}),(0,k.jsx)(aT,{title:`tool calls`,children:e.totalToolCalls===0?(0,k.jsx)(oT,{children:`No tool call recorded in this session.`}):(0,k.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,k.jsx)(sT,{label:`calls`,value:String(e.totalToolCalls)}),(0,k.jsx)(sT,{label:`per turn`,value:e.toolCallsPerTurn.toFixed(1)}),(0,k.jsx)(sT,{label:`failed`,value:String(e.failedToolCalls)})]})}),(0,k.jsx)(aT,{title:`tokens per turn`,children:e.turns.length===0?(0,k.jsx)(oT,{children:`No turn has reported figures yet.`}):(0,k.jsx)(cT,{turns:e.turns,series:rT,format:zw,onJump:o,describe:e=>`${zw(e.usage.totalTokens)} tokens (input ${e.usage.input}, output ${e.usage.output}, cache read ${e.usage.cacheRead}, cache write ${e.usage.cacheWrite})`})}),(0,k.jsx)(aT,{title:`cost per turn`,children:e.pricedTurns===0?(0,k.jsx)(oT,{children:`No turn was priced, so there is no cost to plot.`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(cT,{turns:e.turns.filter(e=>e.usage.cost!==void 0),series:iT,format:Rw,onJump:o,describe:e=>Rw(e.usage.cost??0)}),a.unpriced>0&&(0,k.jsxs)(`p`,{className:`mt-1 text-[10px] text-zinc-400 dark:text-zinc-500`,children:[a.unpriced,` unpriced turn`,a.unpriced===1?``:`s`,` left out — they carry no price to plot`]})]})}),(0,k.jsx)(aT,{title:`costliest tool calls`,children:c.length===0?(0,k.jsx)(oT,{children:`No tool call recorded in this session.`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,k.jsx)(`label`,{htmlFor:`tool-ranking`,className:`text-[11px] text-zinc-500 dark:text-zinc-400`,children:`rank by`}),(0,k.jsxs)(`select`,{id:`tool-ranking`,value:r,onChange:e=>i(e.target.value),className:`rounded-md border border-zinc-300 bg-white px-1.5 py-0.5 font-mono text-[11px] text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-300`,children:[(0,k.jsx)(`option`,{value:`output`,children:`output size`}),(0,k.jsx)(`option`,{value:`input`,children:`input size`}),(0,k.jsx)(`option`,{value:`failure`,children:`failure`})]})]}),(0,k.jsx)(`p`,{className:`mb-1 text-[10px] text-zinc-400 dark:text-zinc-500`,children:`measured content size, not tokens — a tool call carries no price`}),c.slice(0,10).map(e=>(0,k.jsxs)(lT,{onJump:()=>o(e.index),label:`Jump to the ${e.name} call, output ${Xw(e.outputSize)}`,children:[(0,k.jsx)(`span`,{className:`font-mono text-zinc-600 dark:text-zinc-300`,children:e.name}),e.isError&&(0,k.jsx)(`span`,{className:`text-red-500`,children:`failed`}),e.running&&(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`running`}),(0,k.jsxs)(`span`,{className:`ml-auto font-mono text-zinc-500 dark:text-zinc-400`,children:[`in `,Xw(e.inputSize),` · out `,Xw(e.outputSize)]})]},e.toolCallId||`${e.index}`))]})}),(0,k.jsx)(aT,{title:`tools`,children:e.tools.length===0?(0,k.jsx)(oT,{children:`No tool has been called yet.`}):(0,k.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{className:`text-left text-[10px] uppercase text-zinc-400 dark:text-zinc-500`,children:[(0,k.jsx)(`th`,{className:`font-normal`,children:`tool`}),(0,k.jsx)(`th`,{className:`font-normal`,children:`calls`}),(0,k.jsx)(`th`,{className:`font-normal`,children:`failed`}),(0,k.jsx)(`th`,{className:`text-right font-normal`,children:`in / out`})]})}),(0,k.jsx)(`tbody`,{className:`font-mono text-zinc-600 dark:text-zinc-300`,children:[...e.tools].sort((e,t)=>t.outputSize-e.outputSize).map(e=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`td`,{children:e.name}),(0,k.jsx)(`td`,{children:e.calls}),(0,k.jsx)(`td`,{className:e.failures>0?`text-red-500`:``,children:e.failures}),(0,k.jsxs)(`td`,{className:`text-right`,children:[Xw(e.inputSize),` / `,Xw(e.outputSize)]})]},e.name))})]})}),(0,k.jsx)(aT,{title:`costliest requests`,children:l.length===0?(0,k.jsx)(oT,{children:`No request has consumed anything yet.`}):l.slice(0,10).map(e=>(0,k.jsxs)(lT,{onJump:()=>o(e.index),label:`Jump to the request "${e.title}"`,children:[(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-600 dark:text-zinc-300`,children:e.title}),(0,k.jsxs)(`span`,{className:`shrink-0 font-mono text-zinc-500 dark:text-zinc-400`,children:[zw(e.totalTokens),` tok`,e.cost!==void 0&&` · ${Rw(e.cost)}`]}),(0,k.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-500`,children:[e.turns,`t / `,e.toolCalls,`c`,e.failedToolCalls>0&&` · ${e.failedToolCalls}✗`]})]},e.index))})]})]})}var dT=2e3;function fT({items:e,scrollerRef:t,hideTools:n,onShowTools:r,stickToBottom:i}){let[a,o]=(0,d.useState)(null),s=(0,d.useRef)(null),[c,l]=(0,d.useState)(0),u=(0,d.useRef)(null);(0,d.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]);let f=(0,d.useCallback)(t=>{let i=e[t];i&&(i.kind===`tool`&&n&&r(),s.current=t,l(e=>e+1))},[e,n,r]);return(0,d.useEffect)(()=>{let e=s.current;if(e===null)return;s.current=null;let n=t.current?.querySelector(`[data-item-index="${e}"]`);n&&(i.current=!1,n.scrollIntoView?.({behavior:`smooth`,block:`center`}),o(e),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>o(null),dT))},[c,n,t,i]),{jumpToItem:f,highlightIndex:a}}var pT=`uploads`,mT=class extends Error{reason;constructor(e,t){super(e),this.name=`UploadError`,this.reason=t}};function hT(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result.split(`,`,2)[1]??``),r.onerror=()=>n(r.error),r.readAsDataURL(e)})}function gT(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function _T(e){return e.type.startsWith(`image/`)?`image`:e.type===`application/pdf`||re(e.name)||ie(e.name)?`extraction-tool`:e.size<=524288?`inline-text`:bT(e)&&e.size<=26214400?`extraction-tool`:`unsupported`}function vT(e){let t=_T(e);return t===`extraction-tool`?!0:t===`image`&&e.size>7340032}var yT=new Set([`application/json`,`application/xml`,`application/javascript`,`application/x-yaml`,`application/yaml`,`application/sql`]);function bT(e){return e.type.startsWith(`text/`)||yT.has(e.type)}function xT(e){return bT(e)?`${e.name}: file too large to upload (max 25 MB)`:`${e.name}: unsupported file type${e.type?` (${e.type})`:``}`}function ST(e,t){return t instanceof mT?t.reason===`denied`?`${e.name}: cannot upload — the workspace is read-only`:t.reason===`too-large`?`${e.name}: file too large to upload (max 25 MB)`:t.reason===`invalid`?`${e.name}: ${t.message}`:`${e.name}: upload failed — ${t.message}`:`${e.name}: upload failed`}async function CT(e){let t;try{t=await e.text()}catch{return{attachments:[],errors:[`${e.name}: could not be read`]}}return t.includes(`\0`)?{attachments:[],errors:[`${e.name}: unsupported binary file`]}:{attachments:[{name:e.name,kind:`text`,data:t,mimeType:e.type||`text/plain`,source:`manual`}],errors:[]}}async function wT(e){try{let t=await hT(e);return{attachments:[{name:e.name,kind:`image`,data:t,mimeType:e.type,source:`manual`}],errors:[]}}catch{return{attachments:[],errors:[`${e.name}: could not be read`]}}}async function TT(e,t){if(e.size>26214400)return{attachments:[],errors:[`${e.name}: file too large to upload (max 25 MB)`]};let n;try{n=await hT(e)}catch{return{attachments:[],errors:[`${e.name}: could not be read`]}}try{return{attachments:[FT(await t(e.name,n))],errors:[]}}catch(t){return{attachments:[],errors:[ST(e,t)]}}}async function ET(e,t){let n=await Promise.all([...e].map(e=>{let n=_T(e);return n===`unsupported`?Promise.resolve({attachments:[],errors:[xT(e)]}):n===`inline-text`?CT(e):n===`image`&&e.size<=7340032?wT(e):TT(e,t)}));return{attachments:n.flatMap(e=>e.attachments),errors:n.flatMap(e=>e.errors)}}function DT(e){return{...FT(e),source:`preview`,previewPath:e}}function OT(e){return DT(e)}function kT(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`(^|\\s)@${n}[,.;:!?)\\]]*(\\s|$)`).test(e)}var AT=new Set([`,`,`.`,`;`,`:`,`!`,`?`,`)`,`]`]);function jT(e){let t=e.length;for(;t>0&&AT.has(e[t-1]);)t--;return e.slice(0,t)}function MT(e){return[...e.matchAll(/(?:^|\s)@([^\s@]+)/g)].map(([,e])=>jT(e)).filter(e=>e.length>0)}function NT(e,t){let n=e.trim(),r=e=>{n+=`${n?`
|
|
317
317
|
|
|
318
|
-
`:``}${e}`};for(let e of t)e.kind===`path`?kT(n,e.data)||r(`@${e.data}`):e.kind===`text`&&r(`\`\`\`${e.name}\n${e.data}\n\`\`\``);return n}async function PT(e,t){try{let n=await fetch(t);if(!n.ok)return`${e}: unable to read preview image for attachment`;let r=n.headers.get(`Content-Type`)?.split(`;`,1)[0]??``;if(!r.startsWith(`image/`))return`${e}: preview is not a supported image attachment`;let i=new Uint8Array(await n.arrayBuffer());return i.byteLength>7340032?`${e}: image too large (max 7 MB)`:{name:e,kind:`image`,data:gT(i),mimeType:r,source:`preview`,previewPath:e}}catch{return`${e}: unable to read preview image for attachment`}}function FT(e){return{name:e,kind:`path`,data:e,mimeType:`text/plain`,source:`manual`}}function IT(e,t){return e.some(e=>e.kind===`path`&&e.data===t)?e:[...e,FT(t)]}function LT(e,t){return[...e.filter(e=>e.source!==`preview`),t]}function RT(e,t){return e.filter((e,n)=>n!==t)}
|
|
319
|
-
`)]);let te=(0,d.useMemo)(()=>{let e=/^\/(\S*)$/.exec(h);return e?e[1].toLowerCase():null},[h]),ne=(0,d.useMemo)(()=>te===null?[]:n.filter(e=>e.name.toLowerCase().startsWith(te)).sort((e,t)=>
|
|
320
|
-
`).length)),className:`flex-1 resize-none bg-transparent px-2 py-1.5 text-[15px] outline-none placeholder:text-zinc-400 disabled:opacity-50 dark:placeholder:text-zinc-600`}),e&&(0,k.jsx)(`button`,{type:`button`,onClick:f,title:`stop`,"aria-label":`Stop the agent`,className:`rounded-lg bg-red-100 p-2 text-red-700 hover:bg-red-200 dark:bg-red-900/60 dark:text-red-200 dark:hover:bg-red-900`,children:(0,k.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,className:`h-4 w-4`,children:(0,k.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>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,k.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`})})}),(0,k.jsx)(`input`,{ref:E,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&s(Array.from(e.target.files)),e.target.value=``}}),(0,k.jsx)(`button`,{type:`button`,onClick: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,k.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:[(0,k.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,k.jsx)(`path`,{strokeLinecap:`round`,d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`}),(0,k.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]}):(0,k.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M6 12 3.27 3.13c6.6 1.9 12.83 4.9 18.43 8.87-5.6 3.97-11.83 6.97-18.43 8.87L6 12Zm0 0h7.5`})})})]})]})}var
|
|
321
|
-
`);return t===-1?{heading:e,body:``}:{heading:e.slice(0,t),body:e.slice(t+1).trim()}}function
|
|
322
|
-
`)){let t=QT(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function eE({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=$T(e),{heading:u,body:f}=ZT(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,k.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:p,children:(0,k.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,k.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:u}),f&&!l&&(0,k.jsx)(`pre`,{className:`mb-3 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-zinc-50 p-2 font-mono text-xs text-zinc-600 dark:bg-zinc-950 dark:text-zinc-400`,children:f}),e.method===`select`&&(0,k.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>{let r=QT(n);return(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${GT}`,children:r?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:r.label}),r.description&&(0,k.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:r.description})]}):n},n)})}),e.method===`confirm`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:GT,children:`No`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:KT,children:`Yes`})]})]}),l&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`mb-3 flex flex-col gap-1`,children:l.options.map(e=>(0,k.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:i.includes(e.index),onChange:()=>m(e.index),className:`mt-0.5`}),(0,k.jsxs)(`span`,{children:[(0,k.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,k.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,k.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`…or type your own answer`,onKeyDown:e=>{e.key===`Enter`&&h(),e.key===`Escape`&&p()},className:`mb-1 ${qT}`}),(0,k.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:p,className:GT,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:h,className:KT,children:`OK`})]})]}),e.method===`input`&&!l&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`input`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),placeholder:e.placeholder,onKeyDown:r=>{r.key===`Enter`&&t({id:e.id,value:n}),r.key===`Escape`&&p()},className:JT}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:p,className:GT,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:KT,children:`OK`})]})]}),e.method===`editor`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`textarea`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&p()},className:`resize-none font-mono ${JT}`}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:p,className:GT,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:KT,children:`OK`})]})]}),s!==null&&(0,k.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,s,`s`]})]})})}var tE={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 nE({notification:e,onDismiss:t}){return(0,d.useEffect)(()=>{let e=setTimeout(t,6e3);return()=>clearTimeout(e)},[t]),(0,k.jsx)(`div`,{className:`rounded-lg border px-3 py-2 text-sm shadow-lg ${tE[e.notifyType??`info`]}`,children:e.message})}function rE({notifications:e,onDismiss:t}){return e.length===0?null:(0,k.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,k.jsx)(nE,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var iE={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`},aE=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function oE(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(iE[r]!==void 0)n.color=iE[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 sE(e){let t=[],n={},r=0;aE.lastIndex=0;for(let i=aE.exec(e);i!==null;i=aE.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=oE(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function cE(e){return e.replace(aE,``)}function lE({line:e}){return(0,k.jsx)(k.Fragment,{children:sE(e).map((e,t)=>(0,k.jsx)(`span`,{style:{...e.color?{color:e.color}:{},...e.bold?{fontWeight:600}:{},...e.dim?{opacity:.7}:{},...e.italic?{fontStyle:`italic`}:{},...e.underline?{textDecoration:`underline`}:{}},children:e.text},t))})}function uE({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,k.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,k.jsx)(`div`,{className:`whitespace-pre-wrap rounded-md border border-zinc-200 bg-zinc-50 px-3 py-1.5 font-mono text-xs text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:t.lines.map((e,t)=>(0,k.jsx)(`div`,{children:(0,k.jsx)(lE,{line:e})},t))},e))})}var dE=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,k.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,k.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}},fE=(0,d.lazy)(()=>j(()=>import(`./PdfViewer-CEAp6biY.js`),[]));function pE(e){return/\.(md|markdown)$/i.test(e)}function mE(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function hE({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}){let[y,x]=(0,d.useState)(!1),[S,C]=(0,d.useState)(a),[w,E]=(0,d.useState)(e.status===`loaded`&&e.justCreated?{draft:e.content,baseContent:e.content,baseMtimeMs:e.mtimeMs}:null),[ee,D]=(0,d.useState)(`idle`),ie=(0,d.useRef)(null),oe=(0,d.useRef)(null),O=e.status===`loaded`?e:null,se=O!==null&&pE(e.path),ce=ne(e.path),le=re(e.path),j=mE(e.path,t)&&!le,ue=w!==null&&w.draft!==w.baseContent,de=O?.pendingSave!==void 0,fe=w!==null&&O!==null&&O.mtimeMs!==w.baseMtimeMs,pe=O?.saveError?.conflict===!0||fe;function me(){ue&&!window.confirm(`Discard unsaved changes?`)||f()}function ge(){O&&E({draft:O.content,baseContent:O.content,baseMtimeMs:O.mtimeMs})}function _e(t=!1){!O||w===null||de||(oe.current=w.draft,m(e.path,w.draft,w.baseMtimeMs,t))}function ve(){E(null),p(e.path)}function ye(){let t=!S;C(t),t?s(e.path):c()}return(0,d.useEffect)(()=>{if(w!==null&&O!==null&&oe.current!==null&&O.content===oe.current&&O.mtimeMs!==w.baseMtimeMs){let e=oe.current;oe.current=null,w.draft===e?E(null):E({...w,baseContent:O.content,baseMtimeMs:O.mtimeMs})}},[O?.mtimeMs]),(0,d.useEffect)(()=>{function e(e){e.key===`Escape`&&me()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,d.useEffect)(()=>{D(n?`streaming`:e=>e===`streaming`?`done`:e)},[n]),(0,d.useEffect)(()=>(r(ue),()=>r(!1)),[ue]),(0,d.useEffect)(()=>(a&&s(e.path),()=>c()),[]),(0,k.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[se&&w===null&&!S&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>x(!y),title:y?`Show rendered`:`Show source`,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:y?`⚏ rendered`:`⌗ source`}),i!==void 0&&w===null&&(0,k.jsx)(`button`,{type:`button`,onClick:ye,"aria-pressed":S,title:S?`Show file content`:`Show uncommitted changes (vs HEAD)`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs ${S?`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&&w===null&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>u(e.path),title:`Show this file's history`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:`⎇ history`}),(0,k.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:[e.path,ue&&(0,k.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),O&&w===null&&(0,k.jsx)(A,{text:O.content}),O&&w===null&&!S&&j&&(0,k.jsx)(`button`,{type:`button`,onClick:ge,className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500 dark:hover:text-zinc-200`,children:`✎ edit`}),O&&w===null&&!j&&(0,k.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,title:`Outside the writable zone`,children:`🔒 read-only`}),w!==null&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>_e(),disabled:!ue||de||pe,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:de?`saving…`:`save`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>ue?window.confirm(`Discard unsaved changes?`)&&E(null):E(null),className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500`,children:`cancel`})]}),(0,k.jsx)(`button`,{type:`button`,onClick:me,title:`Close (Esc)`,"aria-label":`Close file viewer`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),pe&&w!==null&&(0,k.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:[(0,k.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,k.jsx)(`button`,{type:`button`,onClick:ve,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`reload (discard my edits)`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>_e(!0),disabled:de,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`})]}),w!==null&&O?.saveError&&!O.saveError.conflict&&(0,k.jsx)(`div`,{className:`border-b border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:O.saveError.message}),(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[S&&w===null&&(0,k.jsxs)(`div`,{className:`p-4`,children:[o?.path===e.path&&`error`in o&&(0,k.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:o.error}),o?.path===e.path&&`before`in o&&(0,k.jsx)(Te,{fill:!0,lines:b(o.before,o.after)}),o?.path!==e.path&&(0,k.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),le&&w===null&&!S&&(0,k.jsx)(dE,{label:`This PDF`,children:(0,k.jsx)(d.Suspense,{fallback:(0,k.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),children:(0,k.jsx)(fE,{path:e.path,serverUrl:h,token:g,...v?{onLoaded:v}:{}})})}),ce&&w===null&&!S&&(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,k.jsx)(`img`,{src:ae(h,e.path,g),alt:e.path,onLoad:()=>_(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&w===null&&!S&&!ce&&!le&&(0,k.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!ce&&!le&&(0,k.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),w!==null&&(0,k.jsx)(`textarea`,{ref:ie,value:w.draft,onChange:e=>E({...w,draft:e.target.value}),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),ue&&!de&&!pe&&_e())},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`}),O&&w===null&&!S&&se&&!y&&(0,k.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,k.jsx)(fs,{remarkPlugins:[E_,R_],rehypePlugins:[Em],components:{a:({href:t,children:n,...r})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,k.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...r,children:n}):t.startsWith(`#`)?(0,k.jsx)(`a`,{href:t,...r,children:n}):(0,k.jsx)(`a`,{href:t,onClick:n=>{n.preventDefault(),p(te(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(`//`)?ae(h,te(e.path,t),g):t;return(0,k.jsx)(`img`,{...r,src:i,alt:n??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:T(O.content)})}),O&&w===null&&!S&&(!se||y)&&(0,k.jsx)(`div`,{className:`p-4`,children:(0,k.jsx)(he,{code:O.content,path:e.path})})]}),ee!==`idle`&&(0,k.jsxs)(`button`,{type:`button`,onClick:me,"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:[ee===`streaming`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,k.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,k.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,k.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function gE(e){return e.split(`
|
|
323
|
-
`).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 _E({show:e,onClose:t}){return(0,d.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),t())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]),(0,k.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsx)(`span`,{className:`font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,12)}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`commit diff`}),(0,k.jsx)(`button`,{type:`button`,onClick:t,title:`Close (Esc)`,"aria-label":`Close commit diff`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),e.truncated&&(0,k.jsx)(`div`,{className:`border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:`Patch truncated — showing the first 256 KiB.`}),(0,k.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed`,children:gE(e.patch).map((e,t)=>(0,k.jsxs)(`div`,{className:e.kind===`file`?`mt-3 border-t border-zinc-200 pt-2 font-bold text-zinc-700 first:mt-0 first:border-t-0 first:pt-0 dark:border-zinc-800 dark:text-zinc-200`:e.kind===`hunk`?`text-sky-600 dark:text-sky-400`:e.kind===`add`?`bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:e.kind===`del`?`bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`text-zinc-500 dark:text-zinc-500`,children:[e.kind===`add`?`+ `:e.kind===`del`?`− `:``,e.text||` `]},t))})]})}var vE=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],yE=`worktree`,bE={defaultWidth:288,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.files-sidebar-width.v1`},xE={defaultWidth:416,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.history-list-width.v1`};function SE(e,t){return Number.isFinite(e)?Math.min(t.maxWidth,Math.max(t.minWidth,Math.round(e))):t.defaultWidth}function CE(e,t){return e===null||e.trim()===``?t.defaultWidth:SE(Number(e),t)}function wE(e,t){try{return CE((t??window.localStorage).getItem(e.storageKey),e)}catch{return e.defaultWidth}}function TE(e,t,n){try{(n??window.localStorage).setItem(t.storageKey,String(SE(e,t)))}catch{}}function EE(e){let[t,n]=(0,d.useState)(()=>wE(e)),r=(0,d.useRef)(t),i=(0,d.useRef)(null),a=(0,d.useCallback)(t=>{let i=SE(t,e);return r.current=i,n(i),i},[e]),o=(0,d.useCallback)(()=>{i.current!==null&&(i.current=null,TE(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(),TE(a(n),e))}}}}function DE({label:e,width:t,config:n,separatorProps:r,className:i=``}){return(0,k.jsx)(`div`,{...r,role:`separator`,"aria-label":e,"aria-orientation":`vertical`,"aria-valuemin":n.minWidth,"aria-valuemax":n.maxWidth,"aria-valuenow":t,tabIndex:0,title:e,className:`group absolute inset-y-0 -right-1 z-20 w-2 cursor-col-resize touch-none outline-none ${i}`,children:(0,k.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 left-1/2 w-px bg-transparent transition-colors group-hover:bg-blue-400 group-focus-visible:bg-blue-500 group-active:bg-blue-500 dark:group-hover:bg-blue-500`})})}var OE=`#10b981`,kE=[`#8b5cf6`,`#f59e0b`,`#0ea5e9`,`#f43f5e`,`#14b8a6`,`#d946ef`];function AE(e){return e===0?OE:kE[(e-1)%kE.length]}function jE(e){return kE[e%kE.length]}function ME(e){return e*14+14/2+1}function NE(e){return e*14+2}function PE({row:e,laneCount:t,colorOf:n=AE}){let r=NE(t),i=ME(e.lane),a=e.highlight?OE:n(e.lane),o=e.dashed?`3 3`:void 0;return(0,k.jsxs)(`svg`,{width:r,height:36,viewBox:`0 0 ${r} 36`,"aria-hidden":!0,className:`shrink-0`,children:[e.through.map(e=>(0,k.jsx)(`line`,{x1:ME(e),y1:0,x2:ME(e),y2:36,stroke:n(e),strokeWidth:2,opacity:.55},e)),e.lineAbove&&(0,k.jsx)(`line`,{x1:i,y1:0,x2:i,y2:18,stroke:a,strokeWidth:2,strokeDasharray:o}),e.lineBelow&&(0,k.jsx)(`line`,{x1:i,y1:18,x2:i,y2:36,stroke:a,strokeWidth:2,strokeDasharray:o}),e.forkTo.map(e=>(0,k.jsx)(`path`,{d:`M ${i} 18 C ${i} 36, ${ME(e)} 18, ${ME(e)} 36`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`fork-${e}`)),(e.mergeFrom??[]).map(e=>(0,k.jsx)(`path`,{d:`M ${i} 18 C ${i} 0, ${ME(e)} 18, ${ME(e)} 0`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`merge-${e}`)),e.emphasis===`current`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`circle`,{cx:i,cy:18,r:6,fill:`none`,stroke:a,strokeWidth:2}),(0,k.jsx)(`circle`,{cx:i,cy:18,r:2.5,fill:a})]}):(0,k.jsx)(`circle`,{cx:i,cy:18,r:4,fill:e.emphasis===`filled`?a:`var(--tree-off, #d4d4d8)`,stroke:a,strokeWidth:e.emphasis===`filled`?0:1.5})]})}function FE(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:yE,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 IE=20;function LE(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 RE(e){return e.rev===`worktree`?`working tree`:e.rev.slice(0,7)}function zE(e,t){return e!==null&&t!==null&&e.rev===t.rev&&e.path===t.path}function BE(e){return{rev:e.rev,path:e.path}}function VE({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=EE(xE),{rows:h,laneCount:g}=(0,d.useMemo)(()=>FE(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||zE(c,l)||_.current.onFetchDiff(c,l)},[c,l]);let v=(0,d.useCallback)((e,t)=>{let n=BE(e);s(r=>{if(t===`base`)return{base:n,target:zE(n,r.target)?r.base:r.target};if(t===`target`)return{base:zE(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?BE(r):null,target:n}}return{base:zE(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=BE(e);return zE(t,c)?`base`:zE(t,l)?`target`:null},C=h.findIndex(e=>zE(BE(e),c)),w=h.findIndex(e=>zE(BE(e),l)),T=C>=0&&w>=0?{top:Math.min(C,w)*36+36/2,height:Math.abs(w-C)*36}:null;return(0,k.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:e.path}),c!==null&&l!==null&&(0,k.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-zinc-500 dark:text-zinc-400`,"aria-label":`Comparing ${RE(c)} to ${RE(l)}`,children:[(0,k.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:RE(c)}),` → `,(0,k.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:RE(l)})]}),c!==null&&l!==null&&(0,k.jsx)(`button`,{type:`button`,onClick:b,title:`Compare the other way round`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`⇄ swap`}),(c!==null||l!==null)&&(0,k.jsx)(`button`,{type:`button`,onClick:y,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`clear`}),(0,k.jsx)(`button`,{type:`button`,onClick:a,title:`Close (Esc)`,"aria-label":`Close file history`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,k.jsxs)(`div`,{role:`region`,"aria-label":`Commit history`,style:{"--history-list-width":`${m.width}px`},className:`relative flex max-h-[40%] w-full shrink-0 flex-col border-b border-zinc-200 md:max-h-none md:w-[var(--history-list-width)] md:border-b-0 md:border-r dark:border-zinc-800`,children:[(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),x(1)):e.key===`ArrowUp`&&(e.preventDefault(),x(-1))},children:[e.status===`loading`&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`Reading history…`}),e.status===`error`&&(0,k.jsx)(`div`,{className:`m-3 rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e.error}),e.status===`loaded`&&e.entries.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`No commits touch this file yet.`}),e.status===`loaded`&&e.entries.length>0&&(0,k.jsxs)(`div`,{className:`relative`,role:`group`,"aria-label":`Commits`,children:[T&&(0,k.jsx)(HE,{top:T.top,height:T.height,baseFirst:C<w}),h.map((e,t)=>(0,k.jsx)(GE,{ref:e=>{p.current[t]=e},row:e,laneCount:g,role:S(e),isFocused:t===u,onSelect:t=>v(e,t),onFocus:()=>f(t)},e.rev))]})]}),(0,k.jsx)(DE,{label:`Resize History commit list`,width:m.width,config:xE,separatorProps:m.separatorProps,className:`hidden md:block`})]}),(0,k.jsx)(`div`,{role:`region`,"aria-label":`History diff`,className:`min-h-0 min-w-0 flex-1 overflow-auto p-3`,children:(0,k.jsx)(KE,{diff:t,base:c,target:l})})]})]})}function HE({top:e,height:t,baseFirst:n}){return(0,k.jsxs)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute left-0 z-10 motion-safe:transition-all motion-safe:duration-150 motion-safe:ease-out`,style:{top:e,height:t,width:IE},children:[(0,k.jsx)(`div`,{className:`absolute inset-y-0 left-2 w-px bg-zinc-400 dark:bg-zinc-500`}),(0,k.jsx)(UE,{label:n?`base`:`target`,className:`top-0`}),(0,k.jsx)(UE,{label:n?`target`:`base`,className:`bottom-0`})]})}function UE({label:e,className:t}){return(0,k.jsx)(`div`,{className:`absolute left-2 flex h-px w-2.5 items-center bg-zinc-400 dark:bg-zinc-500 ${t}`,children:(0,k.jsx)(`span`,{className:`absolute -left-1 -top-1.5 rotate-180 text-[9px] leading-none text-zinc-500 [writing-mode:vertical-rl] dark:text-zinc-400`,children:e})})}var WE=`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 GE({row:e,laneCount:t,role:n,isFocused:r,onSelect:i,onFocus:a,ref:o}){let s=e.entry,c=s?`${s.sha.slice(0,7)} ${s.subject}`:`Working tree`;return(0,k.jsxs)(`div`,{ref:o,role:`button`,tabIndex:r?0:-1,"aria-label":c,"aria-current":n===null?void 0:`true`,onFocus:a,onClick:()=>i(),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `?(e.preventDefault(),i()):e.key===`b`?i(`base`):e.key===`t`&&i(`target`))},style:{height:36,paddingLeft:IE},className:`group flex cursor-pointer items-center gap-2 pr-2 focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${n===null?``:`bg-zinc-100 dark:bg-zinc-800/60`}`,children:[(0,k.jsx)(PE,{row:e,laneCount:t}),s?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:s.sha.slice(0,7)}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-700 dark:text-zinc-300`,title:s.subject,children:s.subject}),(0,k.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-600`,children:[s.author,` · `,LE(s.date)]}),(0,k.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums`,"aria-label":`${s.added} lines added, ${s.deleted} removed`,children:[(0,k.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-500`,children:[`+`,s.added]}),` `,(0,k.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,s.deleted]})]})]}):(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`working tree`}),(0,k.jsxs)(`span`,{className:`flex shrink-0 gap-0.5`,children:[(0,k.jsx)(`button`,{type:`button`,title:n===`target`?`Make this the base (swaps the two)`:`Compare from this version`,onClick:e=>{e.stopPropagation(),i(`base`)},className:WE,children:`base`}),(0,k.jsx)(`button`,{type:`button`,title:n===`base`?`Make this the target (swaps the two)`:`Compare to this version`,onClick:e=>{e.stopPropagation(),i(`target`)},className:WE,children:`target`})]})]})}function KE({diff:e,base:t,target:n}){return t===null&&n===null?(0,k.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Pick a commit to see what changed.`}):t===null||n===null?(0,k.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Now pick the version to compare it against.`}):e?.status===`error`?(0,k.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e.error}):e===null?(0,k.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Loading…`}):e.status===`loaded`&&e.beforeText===e.afterText?(0,k.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions are identical.`}):(0,k.jsx)(`div`,{className:e.status===`loading`?`opacity-40`:void 0,children:(0,k.jsx)(Te,{fill:!0,lines:b(e.beforeText,e.afterText)})})}function qE(e){let t=(0,d.useRef)(null);return(0,d.useEffect)(()=>{function n(n){t.current&&!t.current.contains(n.target)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}function JE(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 YE({status:e,log:t,onFetchLog:n,onShowCommit:r}){let[i,a]=(0,d.useState)(!1),o=qE(()=>a(!1)),s=e&&(e.ahead>0||e.behind>0)?` ${e.ahead>0?`↑${e.ahead}`:``}${e.behind>0?`↓${e.behind}`:``}`:``;return(0,k.jsxs)(`div`,{className:`relative`,ref:o,children:[(0,k.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,k.jsxs)(`div`,{className:`absolute left-0 top-full z-20 mt-1 max-h-96 w-[26rem] max-w-[80vw] overflow-y-auto rounded-lg border border-zinc-200 bg-white py-1 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[t===null&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),t?.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no commits`}),t?.map(e=>(0,k.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,k.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,7)}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-700 dark:text-zinc-300`,title:e.subject,children:e.subject}),(0,k.jsxs)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:[e.author,` · `,JE(e.date)]})]},e.sha))]})]})}function XE(e){let t=(0,d.useRef)(null);return(0,d.useEffect)(()=>{function n(n){t.current&&!t.current.contains(n.target)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}function ZE({extensionPaths:e,sandbox:t,versions:n,onUpdateConfig:r}){let[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(``),[u,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(!1),_=XE(()=>a(!1));(0,d.useEffect)(()=>{t&&(s(t.root),l(t.writableRoot??``),f(t.allowWrite),m(t.allowBash))},[t]);function v(){a(!1),g(!1)}function y(){t&&(g(!0),r({root:o,allowWrite:u,allowBash:p,writableRoot:c.trim()||void 0}),v())}return(0,k.jsxs)(`div`,{className:`relative`,ref:_,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>a(!i),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:`⚙`}),i&&(0,k.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[80vh] w-[380px] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,k.jsx)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Settings`})}),(0,k.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:[(0,k.jsxs)(`section`,{className:`mb-4`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),e.length===0?(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,k.jsx)(`ul`,{className:`space-y-1`,children:e.map((e,t)=>(0,k.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))})]}),t&&(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Sandbox`}),(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsxs)(`label`,{className:`block`,children:[(0,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,t.locks?.root?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,k.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),disabled:t.locks?.root,className:`mt-1 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:focus:border-zinc-500`})]}),(0,k.jsxs)(`label`,{className:`block`,children:[(0,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,t.locks?.writableRoot?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,k.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),disabled:t.locks?.writableRoot,placeholder:`Same as root`,className:`mt-1 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`})]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>f(e.target.checked),disabled:t.locks?.allowWrite,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,t.locks?.allowWrite?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked),disabled:t.locks?.allowBash,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,t.locks?.allowBash?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,k.jsx)(`button`,{type:`button`,disabled:h||!o.trim(),onClick:y,className:`w-full rounded-md bg-zinc-800 px-3 py-1.5 text-xs font-medium text-white hover:bg-zinc-700 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-zinc-200 dark:text-zinc-900 dark:hover:bg-zinc-300`,children:h?`Applying…`:`Apply & restart session`}),(0,k.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:`File browser paths update immediately. Agent tools (read/write/bash) use the new sandbox after a server restart.`})]})]}),!t&&(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),n&&(0,k.jsxs)(`section`,{className:`mt-4`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,k.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,k.jsxs)(`p`,{children:[`pi-outpost: `,(0,k.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:n.piOutpost})]}),n.piSdk&&(0,k.jsxs)(`p`,{children:[`pi SDK: `,(0,k.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:n.piSdk})]}),n.agent&&(0,k.jsxs)(`p`,{children:[`agent: `,(0,k.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:n.agent})]})]})]})]})]})]})}function QE(e){let t=(0,d.useRef)(null);return(0,d.useEffect)(()=>{function n(n){t.current&&!t.current.contains(n.target)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}function $E(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 eD(e){return e.flatMap(e=>[e,...eD(e.children)])}function tD({children:e,tone:t}){let n={current:`border-emerald-300 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-950/50 dark:text-emerald-300`,branch:`border-zinc-300 text-zinc-500 dark:border-zinc-700 dark:text-zinc-400`,label:`border-violet-300 bg-violet-50 text-violet-700 dark:border-violet-900 dark:bg-violet-950/50 dark:text-violet-300`}[t];return(0,k.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var nD=`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 rD({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:o}=e,s=o.tipId??o.entryId;return(0,k.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${e.isCurrent?`bg-emerald-50/60 dark:bg-emerald-950/20`:``}`,style:{height:36},children:[(0,k.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>{r(s),a()},title:n?`unavailable while the agent is running`:o.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex h-full min-w-0 flex-1 items-center gap-2 pl-2 text-left text-sm disabled:opacity-50`,children:[(0,k.jsx)(PE,{row:e,laneCount:t,colorOf:jE}),(0,k.jsx)(`span`,{className:`min-w-0 truncate ${o.onPath?`text-zinc-800 dark:text-zinc-200`:`text-zinc-600 dark:text-zinc-400`}`,children:o.text||`(empty)`}),e.forkTo.length>0&&(0,k.jsxs)(tD,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,k.jsxs)(tD,{tone:`branch`,children:[`branch `,e.branchIndex,o.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,k.jsx)(tD,{tone:`current`,children:`current`}),o.label&&(0,k.jsx)(tD,{tone:`label`,children:o.label})]}),(0,k.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{r(o.entryId),a()},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:nD,children:`↺ redo`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{i(o.entryId),a()},title:`fork a new session from this point`,className:nD,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=QE(()=>o(!1));(0,d.useEffect)(()=>{a&&e===null&&n()},[a,e]);let u=(0,d.useMemo)(()=>e&&e.length>0?$E(e):null,[e]),f=(0,d.useMemo)(()=>{if(!e||!s.trim())return null;let t=s.trim().toLowerCase();return eD(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,s]);return(0,k.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>{o(!a),a||(c(``),n())},title:`conversation tree: go back to an earlier point or fork`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`tree`}),a&&(0,k.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[70vh] w-[32rem] max-w-[90vw] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl [--tree-off:#e4e4e7] dark:border-zinc-700 dark:bg-zinc-900 dark:[--tree-off:#3f3f46]`,children:[e===null&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&u&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,k.jsxs)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:[u.rows.length,` turn`,u.rows.length===1?``:`s`,` · `,u.branchPoints,` branch point`,u.branchPoints===1?``:`s`]})]}),(0,k.jsx)(`input`,{type:`search`,value:s,onChange:e=>c(e.target.value),placeholder:`Search tree`,"aria-label":`Search conversation tree`,className:`mt-2 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,k.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Follow the colored lines — the current branch is highlighted. Click a turn to restore the conversation there · ↺ to send it again · ⑂ to fork a session`})]}),(0,k.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:f===null?u.rows.map(e=>(0,k.jsx)(rD,{row:e,laneCount:u.laneCount,isStreaming:t,onNavigate:r,onFork:i,onClose:()=>o(!1)},e.node.entryId)):f.length===0?(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):f.map(e=>(0,k.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,k.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.tipId??e.entryId),o(!1)},title:e.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left text-sm disabled:opacity-50`,children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,k.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,k.jsx)(tD,{tone:`current`,children:`on current branch`}),e.label&&(0,k.jsx)(tD,{tone:`label`,children:e.label})]}),(0,k.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.entryId),o(!1)},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:nD,children:`↺ redo`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{i(e.entryId),o(!1)},title:`fork a new session from this point`,className:nD,children:`⑂ fork`})]},e.entryId))})]})]})]})}function aD(e){let t=(0,d.useRef)(null);return(0,d.useEffect)(()=>{function n(n){t.current&&!t.current.contains(n.target)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}var oD=200;function sD({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,d.useState)(e);return(0,k.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),onBlur:n,onKeyDown:e=>{e.key===`Enter`?t(r):e.key===`Escape`&&n()},placeholder:`Session name (empty to clear)`,"aria-label":`Session name`,className:`w-full rounded-md border border-zinc-400 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 dark:border-zinc-600 dark:placeholder:text-zinc-600`})}function cD({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:o,onCancelRename:s}){return n?(0,k.jsx)(`div`,{className:`px-3 py-2`,children:(0,k.jsx)(sD,{initial:e.name??``,onCommit:o,onCancel:s})}):(0,k.jsxs)(`div`,{className:`group flex items-start gap-1 hover:bg-zinc-100 dark:hover:bg-zinc-800 ${t?`bg-zinc-100 dark:bg-zinc-800/60`:``}`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,k.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,k.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,k.jsxs)(`div`,{className:`mt-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:[new Date(e.modified).toLocaleString(),` · `,e.messageCount,` messages`,t?` · current`:``]})]}),(0,k.jsx)(`button`,{type:`button`,onClick:a,title:`rename session`,"aria-label":`Rename session`,className:`mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✎`}),!t&&(0,k.jsx)(`button`,{type:`button`,onClick:i,title:`delete session`,"aria-label":`Delete session`,className:`mr-2 mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-red-100 hover:text-red-600 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-red-950/60 dark:hover:text-red-400`,children:`✕`})]})}function lD({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=aD(()=>u(!1)),_=f.trim(),v=_.length>=2;(0,d.useEffect)(()=>{if(!l)return;if(!v){c();return}let e=setTimeout(()=>s(_),oD);return()=>clearTimeout(e)},[l,_,v]);function y(){u(!1),h(null)}let b=v&&!(t?.status===`loaded`&&t.query===_),x=v?b?null:t?.results??null:e;return(0,k.jsxs)(`div`,{className:`relative`,ref:g,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>{if(l){y();return}u(!0),p(``),h(null),c(),a()},className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`sessions`}),l&&(0,k.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-96 w-96 flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,k.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsx)(`input`,{type:`search`,value:f,onChange:e=>p(e.target.value),placeholder:`Search sessions`,"aria-label":`Search sessions`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,k.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Searches names and everything said in a session · ✎ to rename`})]}),(0,k.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[x===null&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),x?.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:v?`no matches`:`no saved sessions`}),x?.map(e=>(0,k.jsx)(cD,{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 uD({theme:e,onToggle:t}){return(0,k.jsx)(`button`,{type:`button`,onClick:t,title:e===`dark`?`Switch to light theme`:`Switch to dark theme`,"aria-label":e===`dark`?`Switch to light theme`:`Switch to dark theme`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:e===`dark`?`☀`:`☾`})}function dD(e){let{isStreaming:t,connected:n}=e;return(0,k.jsxs)(`header`,{className:`relative z-30 flex items-center gap-3 border-b border-zinc-200 px-4 py-2.5 dark:border-zinc-800`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:e.onToggleSidebar,title:e.sidebarOpen?`Hide files (panel opens on the left)`:`Show files`,"aria-pressed":e.sidebarOpen,className:`rounded-md border px-2 py-1 text-xs ${e.sidebarOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:[e.sidebarOpen?`◧`:`◨`,` files`]}),e.gitAvailable&&(0,k.jsx)(YE,{status:e.gitStatus,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,k.jsx)(`span`,{className:`text-lg font-semibold tracking-tight`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),Object.entries(e.statuses).map(([e,t])=>(0,k.jsx)(`span`,{className:`rounded-md border border-zinc-200 px-2 py-1 text-xs text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:cE(t)},e)),(0,k.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,k.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,k.jsx)(uD,{theme:e.theme,onToggle:e.onToggleTheme}),(0,k.jsx)(`button`,{type:`button`,onClick:e.onNewSession,title:`new session`,className:`rounded-md border border-emerald-300 px-2 py-1 text-xs text-emerald-700 hover:border-emerald-500 hover:text-emerald-600 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600 dark:hover:text-emerald-300`,children:`+ new`}),(0,k.jsx)(iD,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,k.jsx)(lD,{sessions:e.sessions,sessionSearch:e.sessionSearch,sessionId:e.sessionId,onSwitchSession:e.onSwitchSession,onDeleteSession:e.onDeleteSession,onListSessions:e.onListSessions,onRenameSession:e.onRenameSession,onSearchSessions:e.onSearchSessions,onClearSessionSearch:e.onClearSessionSearch}),(0,k.jsx)(ZE,{extensionPaths:e.extensionPaths,sandbox:e.sandbox,versions:e.versions,onUpdateConfig:e.onUpdateConfig}),(0,k.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function fD(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 pD({usage:e,analysisOpen:t,onToggleAnalysis:n}){if(e.turns===0)return null;let r=e.turns-e.unpriced,i=[`${e.turns} turn${e.turns===1?``:`s`}`,`input ${e.input.toLocaleString()}`,`output ${e.output.toLocaleString()}`,`cache read ${e.cacheRead.toLocaleString()}`,`cache write ${e.cacheWrite.toLocaleString()}`,...e.unpriced>0&&r>0?[`${e.unpriced} unpriced`]:[]].join(` · `),a=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{children:[zw(e.totalTokens),` tok`]}),r>0&&(0,k.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:[Rw(e.cost),e.unpriced>0&&`*`]})]}),o=`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs text-zinc-500 dark:text-zinc-400`;return n?(0,k.jsx)(`button`,{type:`button`,onClick:n,title:`${i} — click for the session analysis`,"aria-haspopup":`dialog`,"aria-expanded":t??!1,className:`${o} ${t?`border-zinc-400 dark:border-zinc-600`:`border-zinc-300 hover:border-zinc-400 dark:border-zinc-800 dark:hover:border-zinc-600`}`,children:a}):(0,k.jsx)(`span`,{title:i,className:`${o} border-zinc-300 dark:border-zinc-800`,children:a})}function mD({usage:e}){let t=15.9155,n=2*Math.PI*t,r=e?.percent??0,i=Math.min(100,Math.max(0,r))/100*n;return(0,k.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 36 36`,className:`-rotate-90 shrink-0`,children:[(0,k.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,className:`text-zinc-200 dark:text-zinc-800`}),e&&e.percent!==null&&(0,k.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${i} ${n-i}`,className:fD(e)})]})}function hD({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,vE.indexOf(e));return(0,d.useEffect)(()=>{if(!r)return;function e(e){a.current&&!a.current.contains(e.target)&&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,k.jsxs)(`div`,{className:`relative`,ref:a,children:[(0,k.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,k.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none ${o?``:`opacity-40 grayscale`}`,children:`🧠`}),e]}),r&&(0,k.jsxs)(`div`,{className:`absolute bottom-full left-0 z-20 mb-1 w-48 rounded-lg border border-zinc-200 bg-white p-3 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between text-xs`,children:[(0,k.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`thinking`}),(0,k.jsx)(`span`,{className:`font-mono text-zinc-700 dark:text-zinc-200`,children:e})]}),(0,k.jsx)(`input`,{type:`range`,min:0,max:vE.length-1,step:1,value:s,onChange:e=>n(vE[Number(e.target.value)]),"aria-label":`Thinking level`,"aria-valuetext":e,className:`w-full accent-amber-500`}),(0,k.jsxs)(`div`,{className:`mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,children:[(0,k.jsx)(`span`,{children:vE[0]}),(0,k.jsx)(`span`,{children:vE[vE.length-1]})]})]})]})}function gD(e){let{model:t,models:n,thinkingLevel:r,modelSupportsReasoning:i,isStreaming:a,contextUsage:o,sessionUsage:s,isCompacting:c}=e;return(0,k.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,k.jsxs)(`select`,{value:t,onChange:t=>{let r=n.find(e=>`${e.provider}/${e.id}`===t.target.value);r&&e.onSetModel(r.provider,r.id)},disabled:a,className:`max-w-64 rounded-md border border-zinc-300 bg-white px-2 py-1 font-mono text-xs text-zinc-700 outline-none hover:border-zinc-400 disabled:opacity-50 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-300 dark:hover:border-zinc-600`,children:[!n.some(e=>`${e.provider}/${e.id}`===t)&&(0,k.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,k.jsxs)(`option`,{value:`${e.provider}/${e.id}`,children:[e.provider,`/`,e.id]},`${e.provider}/${e.id}`))]}),i&&(0,k.jsx)(hD,{thinkingLevel:r,isStreaming:a,onSetThinking:e.onSetThinking}),(0,k.jsxs)(`button`,{type:`button`,onClick:e.onCompact,disabled:a||c,title:o?.tokens==null?`Click to compact the conversation context`:`${o.tokens.toLocaleString()} / ${o.contextWindow.toLocaleString()} tokens — click to compact`,className:`ml-auto flex items-center gap-1.5 rounded-md border border-zinc-300 px-2 py-1 font-mono text-xs text-zinc-500 hover:border-zinc-400 disabled:opacity-50 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600`,children:[(0,k.jsx)(mD,{usage:o}),c?`compacting…`:o?.percent==null?`context`:`${Math.round(o.percent)}%`]}),(0,k.jsx)(pD,{usage:s,analysisOpen:e.analysisOpen,onToggleAnalysis:e.onToggleAnalysis})]})}var _D=`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`,vD=`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`;function yD({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,k.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto p-6`,children:(0,k.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,k.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),C?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`h1`,{className:`mb-3 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model is available.`}),(0,k.jsxs)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:[`Credentials are configured, so this is not a missing key: `,(0,k.jsx)(`code`,{children:`allowedModels`}),` in your configuration leaves nothing to choose from. Widen it, or remove it, then restart.`]})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model provider is set up yet. Add one to start chatting.`}),(0,k.jsx)(`div`,{className:`mb-4 flex gap-1 rounded-lg bg-zinc-100 p-1 text-xs dark:bg-zinc-800`,children:[`known`,`custom`].map(e=>(0,k.jsx)(`button`,{type:`button`,onClick:()=>s(e),className:`flex-1 rounded-md px-2 py-1.5 ${o===e?`bg-white font-medium text-zinc-800 shadow-sm dark:bg-zinc-900 dark:text-zinc-100`:`text-zinc-500 dark:text-zinc-400`}`,children:e===`known`?`Provider API key`:`OpenAI-compatible endpoint`},e))}),o===`known`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`label`,{htmlFor:`onboarding-provider`,className:vD,children:`Provider`}),(0,k.jsx)(`select`,{id:`onboarding-provider`,value:c,onChange:e=>l(e.target.value),className:`${_D} mb-3`,children:a.map(e=>(0,k.jsxs)(`option`,{value:e.id,children:[e.name,e.configured?` (already configured)`:``]},e.id))})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`label`,{htmlFor:`onboarding-name`,className:vD,children:`Name`}),(0,k.jsx)(`input`,{id:`onboarding-name`,value:p,onChange:e=>m(e.target.value),placeholder:`corp`,className:`${_D} mb-3`}),(0,k.jsx)(`label`,{htmlFor:`onboarding-url`,className:vD,children:`Base URL`}),(0,k.jsx)(`input`,{id:`onboarding-url`,value:h,onChange:e=>g(e.target.value),placeholder:`https://llm.corp.example/v1`,className:`${_D} mb-3`}),(0,k.jsx)(`label`,{htmlFor:`onboarding-model`,className:vD,children:`Model id`}),(0,k.jsx)(`input`,{id:`onboarding-model`,value:_,onChange:e=>v(e.target.value),placeholder:`gpt-oss-120b`,className:`${_D} mb-3`})]}),(0,k.jsx)(`label`,{htmlFor:`onboarding-key`,className:vD,children:`API key`}),(0,k.jsx)(`input`,{id:`onboarding-key`,type:`password`,autoComplete:`off`,value:u,onChange:e=>f(e.target.value),placeholder:`sk-…`,className:_D}),o===`custom`&&(0,k.jsxs)(`fieldset`,{className:`mt-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,k.jsx)(`legend`,{className:`px-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Compatibility`}),(0,k.jsxs)(`label`,{className:`flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5`}),(0,k.jsxs)(`span`,{children:[`Server understands the `,(0,k.jsx)(`code`,{children:`developer`}),` role. Uncheck for vLLM, SGLang and most corporate gateways — the system prompt is then sent as a `,(0,k.jsx)(`code`,{children:`system`}),` message.`]})]}),(0,k.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`mt-0.5`}),(0,k.jsxs)(`span`,{children:[`Server accepts `,(0,k.jsx)(`code`,{children:`reasoning_effort`}),`. Uncheck if it rejects unknown fields.`]})]})]}),(0,k.jsx)(`button`,{type:`submit`,className:`mt-4 w-full rounded-md bg-zinc-800 px-3 py-2 text-sm font-medium text-white hover:bg-zinc-700 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,children:`Save and start`})]}),i.map((e,t)=>(0,k.jsx)(`p`,{className:`mt-3 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:e},t)),(0,k.jsxs)(`p`,{className:`mt-4 text-center text-xs text-zinc-400 dark:text-zinc-600`,children:[t.agentDir?`Stored in ${t.agentDir}. `:``,`Provider environment variables work too, as does `,(0,k.jsx)(`code`,{children:`pi-outpost login`}),`.`]})]})})}var bD=`application/x-pi-outpost-file`,xD=`application/x-pi-outpost-read-only-file`,SD=`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`,CD={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 wD(e,t){return t?Object.keys(t).filter(t=>t.startsWith(`${e}/`)).length:0}function TD(e){return e===`directory`||e===`symlink-directory`}function ED(e,t){return t===void 0?!1:t===null?!0:t===``?!1:e!==t&&!e.startsWith(`${t}/`)}function DD({dir:e,depth:t,creation:n}){let[r,i]=(0,d.useState)(``),a=(0,d.useRef)(null),o=n.localError??n.serverError;return(0,d.useEffect)(()=>{a.current?.focus()},[]),(0,k.jsxs)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5`,children:[(0,k.jsx)(`input`,{ref:a,value:r,onChange:e=>i(e.target.value),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),n.submit(e,r)):t.key===`Escape`&&(t.preventDefault(),n.cancel())},onBlur:()=>{o===null&&n.cancel()},placeholder:`name, or name/ for a folder`,"aria-label":`New file or folder in ${e===``?`the workspace root`:e}`,spellCheck:!1,className:`w-full rounded border border-zinc-300 bg-white px-1 py-0.5 text-xs text-zinc-800 outline-none focus:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),o!==null&&(0,k.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:o})]})}function OD({path:e,name:t,depth:n,rename:r}){let[i,a]=(0,d.useState)(t),o=(0,d.useRef)(null),s=r.localError??r.serverError;return(0,d.useEffect)(()=>{o.current?.focus(),o.current?.select()},[]),(0,k.jsxs)(`div`,{style:{paddingLeft:n*12+16},className:`py-0.5`,children:[(0,k.jsx)(`input`,{ref:o,value:i,disabled:r.pending,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`&&!r.pending?(t.preventDefault(),r.submit(e,i)):t.key===`Escape`&&(t.preventDefault(),r.cancel())},onBlur:()=>{s===null&&r.cancel()},"aria-label":`Rename ${t}`,spellCheck:!1,className:`w-full rounded border border-zinc-300 bg-white px-1 py-0.5 text-xs text-zinc-800 outline-none focus:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),s!==null&&(0,k.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:s})]})}function kD({path:e,depth:t,...n}){let r=n.tree[e],i=n.creation?.openIn===e?(0,k.jsx)(DD,{dir:e,depth:t,creation:n.creation}):null;return r===void 0?i:r===`loading`?(0,k.jsxs)(k.Fragment,{children:[i,(0,k.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`loading…`})]}):`error`in r?(0,k.jsxs)(k.Fragment,{children:[i,(0,k.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-red-600 dark:text-red-400`,children:r.error})]}):r.length===0?(0,k.jsxs)(k.Fragment,{children:[i,i===null&&(0,k.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`empty`})]}):(0,k.jsxs)(k.Fragment,{children:[i,r.map(r=>(0,k.jsx)(AD,{parentPath:e,entry:r,depth:t,...n},r.name))]})}function AD({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=ED(c,r.writableRoot),u=r.fileOperation?.status===`pending`;if(TD(t.type)){let e=!l&&!u,d=e=>e.includes(xD)?r.onCopyFile===void 0?null:`copy`:r.onMoveFile===void 0?null:`move`;return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${o?`bg-blue-50 ring-1 ring-blue-400 dark:bg-blue-950/40`:``}`,onDragOver:t=>{if(!e||!Array.from(t.dataTransfer.types).includes(bD))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(bD),i=n?d(Array.from(t.dataTransfer.types)):null;i!==null&&(t.preventDefault(),t.stopPropagation(),s(!1),i===`copy`?r.onCopyFile?.(n,c):r.onMoveFile?.(n,c))},children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>{let e=!i;a(e),e&&r.tree[c]===void 0&&r.onExpand(c)},style:{paddingLeft:n*12},className:`flex min-w-0 flex-1 items-center gap-1 rounded py-0.5 text-left`,children:[(0,k.jsx)(`span`,{className:`w-3 shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:i?`▾`:`▸`}),(0,k.jsx)(`span`,{title:t.name,className:`truncate ${l?`text-zinc-400 dark:text-zinc-600`:`text-zinc-700 dark:text-zinc-300`}`,children:t.name}),!i&&wD(c,r.gitFiles)>0&&(0,k.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-amber-100 px-1 font-mono text-[10px] font-bold text-amber-700 dark:bg-amber-950/60 dark:text-amber-400`,title:`${wD(c,r.gitFiles)} changed file(s) inside`,children:wD(c,r.gitFiles)})]}),r.creation&&!l&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>{a(!0),r.tree[c]===void 0&&r.onExpand(c),r.creation?.start(c)},title:`New file or folder here`,"aria-label":`New file or folder in ${t.name}`,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs text-zinc-400 hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 [@media(hover:hover)]:opacity-0`,children:`+`})]}),i&&(0,k.jsx)(kD,{path:c,depth:n+1,...r})]})}let f=c===r.openFilePath,p=r.gitFiles?.[c],m=r.attachedPaths?.includes(c)??!1,h=t.type===`file`,g=h||t.type===`symlink-file`,_=h&&!l,v=h&&(l?r.onCopyFile!==void 0:r.onMoveFile!==void 0);return r.rename?.path===c?(0,k.jsx)(OD,{path:c,name:t.name,depth:n,rename:r.rename}):(0,k.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${f?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,k.jsx)(`button`,{type:`button`,draggable:v&&!u,onDragStart:e=>{!v||u||(e.dataTransfer.effectAllowed=l?`copy`:`move`,e.dataTransfer.setData(bD,c),l&&e.dataTransfer.setData(xD,`copy`))},onClick:()=>r.onSelectFile(c),style:{paddingLeft:n*12+16},className:`flex min-w-0 flex-1 items-center py-0.5 text-left`,children:(0,k.jsx)(`span`,{title:t.name,className:`truncate ${l?`text-zinc-400 dark:text-zinc-600`:`text-zinc-600 dark:text-zinc-400`}`,children:t.name})}),g&&r.onOpenNative&&(0,k.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>r.onOpenNative?.(c),title:`Open with the associated application`,"aria-label":`Open ${t.name} with the associated application`,className:SD,children:`↗`}),_&&r.onRenameFile&&(0,k.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>r.rename?.start(c),title:`Rename file`,"aria-label":`Rename ${t.name}`,className:SD,children:`✎`}),_&&r.onDeleteFile&&(0,k.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(`Delete "${t.name}" permanently?`)&&r.onDeleteFile?.(c)},title:`Delete file`,"aria-label":`Delete ${t.name}`,className:`${SD} hover:text-red-600 dark:hover:text-red-400`,children:`×`}),r.onToggleAttachPath&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>r.onToggleAttachPath?.(c),title:m?`Remove this file from the prompt`:`Reference this file in the prompt`,"aria-label":`${m?`Remove`:`Reference`} ${t.name} in the prompt`,"aria-pressed":m,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:hover:bg-zinc-700 ${m?`font-bold text-blue-600 dark:text-blue-400`:`text-zinc-400 dark:text-zinc-600 [@media(hover:hover)]:opacity-0`}`,children:`@`}),p&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>(r.onSelectDiff??r.onSelectFile)(c),title:`Show uncommitted diff`,"aria-label":`Show diff of ${t.name}`,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs font-bold hover:bg-zinc-200 dark:hover:bg-zinc-700 ${CD[p].className}`,children:CD[p].label})]})}function jD(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 MD(e){let t=jD(e);return`error`in t?t:t.kind===`directory`?{error:`That is a folder name`}:{name:t.name}}function ND(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===PD(a.dir,a.name)?e.createError.message:null,g=e.created??null;(0,d.useEffect)(()=>{a===null||g===null||g===PD(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=jD(n);if(`error`in r){i(r.error);return}i(null),o({dir:t,name:r.name});let a=PD(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=MD(n);if(`error`in r){u(r.error);return}u(null),p(t),e.onRenameFile?.(t,r.name)}}:void 0,b=!ED(``,e.writableRoot);return(0,k.jsxs)(`div`,{className:`text-sm`,children:[e.fileOperation?.status===`error`&&e.fileOperation.operation!==`rename_file`&&(0,k.jsx)(`p`,{role:`alert`,className:`mb-1 rounded bg-red-50 px-2 py-1 text-xs text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:e.fileOperation.message}),v&&b&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>v.start(``),"aria-label":`New file or folder in the workspace root`,className:`mb-1 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`}),(0,k.jsx)(kD,{path:``,depth:0,...e,...v?{creation:v}:{},...y?{rename:y}:{}})]})}function PD(e,t){return e===``?t:`${e}/${t}`}function FD({tree:e,openFile:t,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onSelectFile:o,onSelectDiff:s,onToggleAttachPath:c,onCreateFile:l,onCreateDirectory:u,onOpenNative:f,onRenameFile:p,onDeleteFile:m,onMoveFile:h,onCopyFile:g,fileOperation:_,createError:v,created:y}){let b=EE(bE);return(0,d.useEffect)(()=>{e[``]===void 0&&a(``)},[]),(0,k.jsxs)(`aside`,{"aria-label":`Files`,style:{width:b.width},className:`relative flex shrink-0 flex-col border-r border-zinc-200 dark:border-zinc-800`,children:[(0,k.jsx)(`div`,{className:`border-b border-zinc-200 px-3 py-2 text-xs font-semibold uppercase text-zinc-400 dark:border-zinc-800 dark:text-zinc-600`,children:`Files`}),(0,k.jsx)(`div`,{className:`flex-1 overflow-auto p-2`,children:(0,k.jsx)(ND,{tree:e,openFilePath:t?.path,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onSelectFile:o,onSelectDiff:s,onToggleAttachPath:c,onCreateFile:l,onCreateDirectory:u,onOpenNative:f,onRenameFile:p,onDeleteFile:m,onMoveFile:h,onCopyFile:g,fileOperation:_,createError:v,created:y})}),(0,k.jsx)(DE,{label:`Resize Files sidebar`,width:b.width,config:bE,separatorProps:b.separatorProps})]})}function ID({title:e,onSubmit:t}){let[n,r]=(0,d.useState)(``);return(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,k.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),n.trim()&&t(n.trim())},className:`w-full max-w-sm rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,k.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),(0,k.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`This server requires an access token.`}),(0,k.jsx)(`label`,{htmlFor:`pi-outpost-token`,className:`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`,children:`Access token`}),(0,k.jsx)(`input`,{id:`pi-outpost-token`,name:`token`,type:`password`,autoComplete:`off`,spellCheck:!1,value:n,onChange:e=>r(e.target.value),placeholder:`paste the token…`,className:`mb-3 w-full rounded-md border border-zinc-300 bg-white px-2 py-1.5 font-mono text-sm outline-none focus:border-zinc-500 dark:border-zinc-700 dark:bg-zinc-950 dark:focus:border-zinc-500`}),(0,k.jsx)(`button`,{type:`submit`,disabled:!n.trim(),className:`w-full rounded-md border border-emerald-300 px-2 py-1.5 text-sm text-emerald-700 hover:border-emerald-500 disabled:opacity-50 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600`,children:`Connect`}),(0,k.jsxs)(`p`,{className:`mt-3 text-center text-xs text-zinc-400 dark:text-zinc-600`,children:[`Ask the operator for the token, or open the link containing `,(0,k.jsx)(`code`,{children:`?token=…`})]})]})})}var LD=`pi-outpost:token`;function RD(){let e=null;try{let t=new URL(window.location.href);return e=t.searchParams.get(`token`),e&&(localStorage.setItem(LD,e),t.searchParams.delete(`token`),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)),localStorage.getItem(LD)}catch{return e}}function zD(){try{return localStorage.getItem(LD)}catch{return null}}function BD(e){try{localStorage.setItem(LD,e)}catch{}}function VD(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 HD={connected:!1,authRequired:!1,brandingReady:!1,branding:{},sessionId:``,model:``,thinkingLevel:`off`,modelSupportsReasoning:!1,models:[],commands:[],sessions:null,sessionSearch:null,tree:null,isStreaming:!1,items:[],queue:{steering:[],followUp:[]},errors:[],contextUsage:null,isCompacting:!1,dialogQueue:[],notifications:[],statuses:{},widgets:{},editorPrefill:null,fileTree:{},openFile:null,fileSearch:null,createError:null,created:null,fileOperation:null,extensionPaths:[],sandbox:null,versions:null,gitAvailable:!1,credentials:null,gitStatus:null,gitDiff:null,gitLog:null,gitShow:null,gitFileHistory:null,gitFileDiff:null};function UD(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 WD(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 GD(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,queue:{steering:[],followUp:[]},errors:[],contextUsage:t.contextUsage??null,isCompacting:!1,dialogQueue:[],notifications:[],statuses:{},widgets:{},extensionTitle:void 0,editorPrefill:null,tree:null,fileTree:{},fileOperation:null,writableRoot:t.writableRoot,gitAvailable:t.gitAvailable===!0,credentials:t.credentials??null,extensionPaths:t.extensionPaths??[],sandbox:t.sandbox??null,versions:t.versions??null}}function KD(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===`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`)return{...e,fileTree:{...e.fileTree,[t.path]:`loading`}};if(t.type===`file_read_started`)return{...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};let n=t.message;switch(n.type){case`hello`:case`session_replaced`:case`update_config_ack`:return GD(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`user`:return{...e,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:UD(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:UD(e.items,()=>n.item)};case`custom_message`:return{...e,items:[...e.items,n.item]};case`tool_start`:return{...e,items:WD(e.items,n.toolCallId,n.toolName,{toolName:n.toolName,args:n.args,running:!0,callHtml:n.callHtml})};case`tool_update`:return{...e,items:WD(e.items,n.toolCallId,`tool`,{output:n.text})};case`tool_end`:return{...e,items:WD(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]};case`directory_listing`:return{...e,fileTree:{...e.fileTree,[n.path]:n.entries},...n.requestId.startsWith(`create:`)?{created:n.path,createError:null}:{}};case`file_content`:return e.openFile?.status!==`loading`||e.openFile.requestId!==n.requestId?e:{...e,openFile:{status:`loaded`,path:n.path,content:n.content,size:n.size,mtimeMs:n.mtimeMs}};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,fileTree:{...e.fileTree,[n.path]:{error:n.message}}};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:{...e,openFile:{status:`error`,path:n.path,message:n.message}};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||!VD(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 qD(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 JD=12e4,YD=4401;function XD(e=``,t,n=!1){let[r,i]=(0,d.useReducer)(KD,HD),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?zD():RD()));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.useRef)(!1),_=(0,d.useRef)(!1),v=(0,d.useRef)(!1),y=(0,d.useCallback)(()=>{if(g.current){if(_.current){v.current=!0;return}_.current=!0,h({type:`git_status`,requestId:`git:${crypto.randomUUID()}`})}},[h]),b=(0,d.useCallback)(()=>{_.current=!1,v.current&&(v.current=!1,y())},[y]);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(qD(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 mT(t.message,t.reason));return}if(t.type===`file_changed`){let e=t.path.lastIndexOf(`/`),n=e<0?``:t.path.slice(0,e);console.log(`[file_changed] path=`,t.path,`parentPath=`,n,`fileTree keys=`,Object.keys(l.current).join(`,`)),l.current[n]===void 0?console.log(`[file_changed] parent NOT in fileTree, skipping refresh`):(console.log(`[file_changed] parent found in fileTree, refreshing`),i({type:`dir_list_started`,path:n}),h({type:`list_directory`,path:n,requestId:`dir:${crypto.randomUUID()}`}));let r=u.current;if(r?.status===`loaded`&&r.path===t.path){let e=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:t.path,requestId:e}),h({type:`read_file`,path:t.path,requestId:e})}f.current===t.path&&h({type:`git_diff`,path:t.path,requestId:`gitdiff:${crypto.randomUUID()}`}),y();return}if((t.type===`hello`||t.type===`session_replaced`)&&(g.current=t.gitAvailable===!0,t.type===`hello`&&y()),t.type===`agent_end`&&y(),(t.type===`git_status`||t.type===`git_error`&&t.requestId.startsWith(`git:`))&&b(),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})}if(i({type:`server`,message:t}),t.type===`session_replaced`){let e=`dir:${crypto.randomUUID()}`;i({type:`dir_list_started`,path:``}),h({type:`list_directory`,path:``,requestId:e})}},o.onclose=e=>{if(a.current===o){_.current=!1,v.current=!1;for(let e of p.current.values())e.reject(new mT(`The connection dropped before the upload finished`));if(p.current.clear(),e.code===YD){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,y,b,o]),{state:r,authToken:c.current,submitToken:e=>{BD(e),c.current=e,i({type:`auth_retrying`}),s(e=>e+1)},prompt:(e,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=>{i({type:`dir_list_started`,path:e}),h({type:`list_directory`,path:e,requestId:`dir:${crypto.randomUUID()}`})},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 mT(`the workspace is read-only`,`denied`));let r=a.current;if(!r||r.readyState!==WebSocket.OPEN)return Promise.reject(new mT(`not connected to the server`));let i=n?`${n}/${pT}`:pT,o=`upload:${crypto.randomUUID()}`;return new Promise((n,r)=>{let a=window.setTimeout(()=>{p.current.delete(o)&&r(new mT(`the upload timed out`))},JD),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:y,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}),updateConfig:e=>h({type:`update_config`,sandbox:e})}}var ZD=(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:te,dismissNotification:oe,listDirectory:O,readFile:A,writeFile:se,createFile:ce,createDirectory:le,uploadFile:j,openNative:ue,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:Oe,declareProvider:ke,updateConfig:Ae}=XD(e,r,a),[je,Me]=(0,d.useState)(!1),[Ne,Pe]=(0,d.useState)([]),[Fe,Ie]=(0,d.useState)([]),[Le,Re]=(0,d.useState)(null),[ze,Be]=(0,d.useState)(null),[Ve,He]=(0,d.useState)(null),[M,Ue]=(0,d.useState)(!1),We=(0,d.useRef)([]),N=(0,d.useRef)(null),Ge=(0,d.useRef)(null),[Ke,qe]=(0,d.useState)(!1),[Je,Ye]=(0,d.useState)(()=>{try{return localStorage.getItem(`pi-outpost:hide-tools`)===`1`}catch{return!1}});function Xe(){Ye(e=>{try{localStorage.setItem(`pi-outpost:hide-tools`,e?`0`:`1`)}catch{}return!e})}let[Ze,Qe]=(0,d.useState)(!1),[$e,et]=(0,d.useState)([]),[tt,nt]=(0,d.useState)([]),rt=(0,d.useRef)(0),it=(0,d.useRef)(0),[at,ot]=(0,d.useState)(0);async function st(e){let t=[...e],n=t.filter(vT).map(e=>({id:`${rt.current++}`,name:e.name}));n.length>0&&nt(e=>[...e,...n]),it.current===0&&et([]),it.current++;try{let{attachments:e,errors:n}=await ET(t,j);e.length>0&&Pe(t=>[...t,...e]),n.length>0&&et(e=>[...e,...n])}finally{if(it.current--,n.length>0){let e=new Set(n.map(e=>e.id));nt(t=>t.filter(t=>!e.has(t.id)))}}}(0,d.useEffect)(()=>{We.current=Ne},[Ne]),(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`&&ie(n);if(N.current!==n&&(N.current=n,Ge.current=null,Pe(e=>e.filter(e=>e.source!==`preview`)),Re(null),Be(null),He(null)),Ge.current===n)return;let a=!1;async function o(){let t=ne(n)?ze===n?await PT(n,ae(e,n,c)):null:re(n)?Ve===n?OT(n):null:i||r?DT(n):null;if(!(a||t===null||N.current!==n||Ge.current===n)){if(typeof t==`string`){Re(t);return}Re(null),Pe(e=>LT(e,t))}}return o(),()=>{a=!0}},[s.openFile,e,c,ze,Ve]);function ct(){N.current=null,Ge.current=null,he()}let lt=(0,d.useMemo)(()=>[...Ne.filter(e=>e.kind===`path`).map(e=>e.data),...Fe],[Ne,Fe]);function ut(e){let t=We.current.findIndex(t=>t.kind===`path`&&t.data===e);t>=0?dt(t):Fe.includes(e)||Pe(t=>IT(t,e))}function dt(e){let t=We.current[e];t?.source===`preview`&&(Ge.current=t.previewPath??N.current,Re(null)),Pe(t=>RT(t,e))}function ft(e,t){u(e,t),Pe([]),et([]),Re(null),M||ct()}function pt(e){e.preventDefault(),ot(0),e.dataTransfer.files.length>0&&st(Array.from(e.dataTransfer.files))}let{theme:mt,toggle:ht,setTheme:gt}=y(s.branding.defaultTheme??`system`,s.branding.allowThemeToggle!==!1,o,n);(0,d.useImperativeHandle)(i,()=>({setTheme:gt}),[gt]);let _t=(0,d.useRef)(null),vt=(0,d.useRef)(null),yt=(0,d.useRef)(!0);function bt(){let e=_t.current;e&&(yt.current=e.scrollHeight-e.scrollTop-e.clientHeight<120)}(0,d.useEffect)(()=>{yt.current&&vt.current?.scrollIntoView({behavior:`smooth`})},[s.items]);let xt=(0,d.useMemo)(()=>Lw(s.items),[s.items]),St=(0,d.useMemo)(()=>Ze?qw(s.items):null,[Ze,s.items]),Ct=(0,d.useMemo)(()=>G_({readFile:e=>{qe(!1),A(e)},fetchGitFileHistory:e=>Ce(e),fetchGitDiff:e=>{qe(!0),A(e)},searchFiles:e=>ge(e)}),[A,Ce,ge]),wt=(0,d.useCallback)(()=>Ye(!1),[]),{jumpToItem:Tt,highlightIndex:Et}=fT({items:s.items,scrollerRef:_t,hideTools:Je,onShowTools:wt,stickToBottom:yt});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,k.jsx)(p.Provider,{value:mt,children:(0,k.jsx)(ID,{title:s.branding.title,onSubmit:l})}):s.credentials&&!s.credentials.usableModel?(0,k.jsx)(p.Provider,{value:mt,children:(0,k.jsx)(yD,{title:s.branding.title,credentials:s.credentials,onSetCredential:Oe,onDeclareProvider:ke,errors:s.errors})}):(0,k.jsxs)(p.Provider,{value:mt,children:[(0,k.jsxs)(`div`,{className:`relative flex h-full`,onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&ot(e=>e+1)},onDragLeave:()=>ot(e=>Math.max(0,e-1)),onDragOver:e=>e.preventDefault(),onDrop:pt,children:[at>0&&(0,k.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-40 flex items-center justify-center border-2 border-dashed bg-white/70 backdrop-blur-sm dark:bg-zinc-950/70`,style:{borderColor:`var(--accent, #3b82f6)`},children:(0,k.jsx)(`p`,{className:`text-lg font-medium text-zinc-700 dark:text-zinc-200`,children:`Drop files to attach (images, documents & text)`})}),je&&(0,k.jsx)(FD,{tree:s.fileTree,openFile:s.openFile,writableRoot:s.writableRoot,gitFiles:s.gitStatus?.files,attachedPaths:lt,onExpand:O,onSelectFile:e=>{qe(!1),A(e)},onSelectDiff:e=>{qe(!0),A(e)},onToggleAttachPath:ut,onCreateFile:e=>{qe(!1),ce(e)},onCreateDirectory:le,onOpenNative:ue,onRenameFile:de,onDeleteFile:fe,onMoveFile:pe,onCopyFile:me,fileOperation:s.fileOperation,createError:s.createError,created:s.created}),(0,k.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[(0,k.jsx)(dD,{title:s.branding.title,sessions:s.sessions,sessionSearch:s.sessionSearch,sessionId:s.sessionId,tree:s.tree,isStreaming:s.isStreaming,connected:s.connected,theme:mt,showThemeToggle:s.branding.allowThemeToggle!==!1,statuses:s.statuses,sidebarOpen:je,hideTools:Je,onToggleSidebar:()=>Me(!je),onToggleHideTools:Xe,onToggleTheme:ht,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,sandbox:s.sandbox,versions:s.versions,onUpdateConfig:Ae,onFetchGitLog:be,onShowCommit:xe}),(0,k.jsxs)(`div`,{className:`relative z-0 flex min-h-0 flex-1 flex-col`,children:[s.openFile&&(0,k.jsx)(hE,{file:s.openFile,writableRoot:s.writableRoot,isStreaming:s.isStreaming,onDirtyChange:Ue,gitState:s.gitStatus?.files[s.openFile.path],initialShowGitDiff:Ke,gitDiff:s.gitDiff,onFetchGitDiff:ve,onClearGitDiff:ye,gitAvailable:s.gitAvailable,onOpenGitHistory:Ce,onClose:ct,onReload:A,onSave:se,serverUrl:e,token:c,onImageLoad:Be,onPdfLoad:He},s.openFile.path),s.gitFileHistory&&(0,k.jsx)(VE,{history:s.gitFileHistory,diff:s.gitFileDiff,dirty:s.gitStatus?.files[s.gitFileHistory.path]!==void 0,onFetchDiff:Te,onClearDiff:Ee,onClose:we}),s.gitShow&&(0,k.jsx)(_E,{show:s.gitShow,onClose:Se}),St&&(0,k.jsx)(uT,{analysis:St,onJump:Tt,onClose:()=>Qe(!1)}),(0,k.jsx)(`main`,{ref:_t,onScroll:bt,className:`flex-1 overflow-y-auto ${Ze?`md:pr-[26rem]`:``}`,children:(0,k.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-3 px-4 py-6`,children:[s.items.length===0&&(0,k.jsxs)(`div`,{className:`mt-24 text-center text-zinc-500 dark:text-zinc-600`,children:[(0,k.jsx)(`div`,{className:`mb-2 text-4xl`,children:s.branding.title??`π`}),(0,k.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,k.jsx)(`div`,{"data-item-index":n,className:`flex flex-col gap-3 rounded-lg transition-shadow ${Et===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,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(De,{item:t,canEdit:!s.isStreaming&&s.connected,onEdit:ee}),e&&(0,k.jsx)(`div`,{className:`flex justify-end px-4`,children:(0,k.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,k.jsx)(`span`,{className:`inline-block h-4 w-4 animate-spin rounded-full border-[3px] border-zinc-300 border-t-blue-500 dark:border-zinc-600 dark:border-t-blue-400 motion-reduce:animate-pulse`}),(0,k.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`working…`})]})})]}))}return t.kind===`tool`?Je?null:i((0,k.jsx)(Pw,{item:t,dispatch:Ct}),t.toolCallId?`${s.sessionId}:${t.toolCallId}`:r):t.kind===`custom`?i((0,k.jsx)(Fw,{item:t})):t.blocks.length===0&&!t.errorMessage?(0,k.jsx)(`div`,{"data-item-index":n,className:`sr-only`,"aria-hidden":!0},r):i((0,k.jsx)(H_,{item:t,serverUrl:e,token:c,onOpenFile:e=>{qe(!1),A(e)}}))}),(s.queue.steering.length>0||s.queue.followUp.length>0)&&(0,k.jsxs)(`div`,{className:`rounded-lg border border-dashed border-zinc-300 px-3 py-2 text-xs text-zinc-500 dark:border-zinc-700`,children:[s.queue.steering.map((e,t)=>(0,k.jsxs)(`div`,{children:[`⏩ steering: `,e]},`s${t}`)),s.queue.followUp.map((e,t)=>(0,k.jsxs)(`div`,{children:[`⏭ follow-up: `,e]},`f${t}`))]}),$e.map((e,t)=>(0,k.jsx)(`div`,{className:`rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:e},`att${t}`)),Le&&(0,k.jsx)(`div`,{className:`rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:Le}),s.errors.map((e,t)=>(0,k.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e},t)),(0,k.jsx)(`div`,{ref:vt})]})})]}),(0,k.jsx)(`footer`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,k.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,k.jsx)(uE,{widgets:s.widgets,placement:`aboveEditor`}),(0,k.jsx)(WT,{isStreaming:s.isStreaming,connected:s.connected,commands:s.commands,fileSearch:s.fileSearch,prefill:s.editorPrefill,attachments:Ne,pendingUploads:tt,onAttach:e=>void st(e),onMentionPaths:Ie,onRemoveAttachment:dt,onSend:ft,onAbort:f,onSearchFiles:ge,onClearFileSearch:_e}),(0,k.jsx)(uE,{widgets:s.widgets,placement:`belowEditor`}),(0,k.jsx)(gD,{model:s.model,models:s.models,thinkingLevel:s.thinkingLevel,modelSupportsReasoning:s.modelSupportsReasoning,isStreaming:s.isStreaming,contextUsage:s.contextUsage,sessionUsage:xt,analysisOpen:Ze,onToggleAnalysis:()=>Qe(e=>!e),isCompacting:s.isCompacting,onSetModel:m,onSetThinking:h,onCompact:D})]})})]})]}),s.dialogQueue[0]&&(0,k.jsx)(eE,{request:s.dialogQueue[0],onRespond:te}),(0,k.jsx)(rE,{notifications:s.notifications,onDismiss:oe})]})});(0,f.createRoot)(document.getElementById(`root`)).render((0,k.jsx)(d.StrictMode,{children:(0,k.jsx)(ZD,{})}));export{i as a,ae as i,j as n,O as r,pc as t};
|
|
318
|
+
`:``}${e}`};for(let e of t)e.kind===`path`?kT(n,e.data)||r(`@${e.data}`):e.kind===`text`&&r(`\`\`\`${e.name}\n${e.data}\n\`\`\``);return n}async function PT(e,t){try{let n=await fetch(t);if(!n.ok)return`${e}: unable to read preview image for attachment`;let r=n.headers.get(`Content-Type`)?.split(`;`,1)[0]??``;if(!r.startsWith(`image/`))return`${e}: preview is not a supported image attachment`;let i=new Uint8Array(await n.arrayBuffer());return i.byteLength>7340032?`${e}: image too large (max 7 MB)`:{name:e,kind:`image`,data:gT(i),mimeType:r,source:`preview`,previewPath:e}}catch{return`${e}: unable to read preview image for attachment`}}function FT(e){return{name:e,kind:`path`,data:e,mimeType:`text/plain`,source:`manual`}}function IT(e,t){return e.some(e=>e.kind===`path`&&e.data===t)?e:[...e,FT(t)]}function LT(e,t){return[...e.filter(e=>e.source!==`preview`),t]}function RT(e,t){return e.filter((e,n)=>n!==t)}function zT(e,t){if(!t)return!1;let n=e.composedPath();if(n.length>0)return n.includes(t);let r=e.target;return r!==null&&t.contains(r)}function BT(e){let t=(0,d.useRef)(null);return(0,d.useEffect)(()=>{function n(n){t.current&&!zT(n,t.current)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}var VT=100,HT=new Intl.Collator(void 0,{sensitivity:`base`,numeric:!0}),UT={extension:`ext`,prompt:`prompt`,skill:`skill`};function WT(e){return e===`directory`||e===`symlink-directory`}function GT(e,t){let n=e.slice(0,t),r=/(?:^|\s)@([^\s@]*)$/.exec(n);return r?{start:t-r[1].length-1,query:r[1]}:null}function KT({isStreaming:e,connected:t,commands:n,fileSearch:r,prefill:i,attachments:a,pendingUploads:o=[],onAttach:s,onMentionPaths:c,onRemoveAttachment:l,onSend:u,onAbort:f,onSearchFiles:p,onClearFileSearch:m}){let[h,g]=(0,d.useState)(``),[_,v]=(0,d.useState)(0),[y,b]=(0,d.useState)(0),[x,S]=(0,d.useState)(!1),C=(0,d.useRef)(null),w=(0,d.useRef)(null),T=(0,d.useRef)(null),E=(0,d.useRef)(null),ee=(0,d.useRef)(null);(0,d.useEffect)(()=>{i&&g(i.text)},[i?.nonce]),(0,d.useEffect)(()=>{ee.current!==null&&(T.current?.focus(),T.current?.setSelectionRange(ee.current,ee.current),ee.current=null)},[h]);let D=(0,d.useMemo)(()=>MT(h),[h]);(0,d.useEffect)(()=>{c(D)},[D.join(`
|
|
319
|
+
`)]);let te=(0,d.useMemo)(()=>{let e=/^\/(\S*)$/.exec(h);return e?e[1].toLowerCase():null},[h]),ne=(0,d.useMemo)(()=>te===null?[]:n.filter(e=>e.name.toLowerCase().startsWith(te)).sort((e,t)=>HT.compare(e.name,t.name)).slice(0,VT),[te,n]),re=te===null?GT(h,_):null;(0,d.useEffect)(()=>{if(!re||re.query.length===0){m();return}let e=window.setTimeout(()=>p(re.query),150);return()=>clearTimeout(e)},[re?.query]);let ie=(0,d.useMemo)(()=>{if(ne.length>0)return{kind:`command`,items:ne};let e=re&&r?.query===re.query?r.results:[];return e.length>0?{kind:`file`,items:e}:null},[ne,re,r]),ae=ie!==null&&!x;(0,d.useEffect)(()=>{b(0)},[te===null?re?`file:${re.query}`:null:`cmd:${te}`]),(0,d.useEffect)(()=>{S(!1)},[te===null?re?`file`:null:`command`]),(0,d.useEffect)(()=>{if(!ae)return;let e=e=>{zT(e,C.current)||S(!0)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[ae]),(0,d.useEffect)(()=>{w.current?.querySelector(`[data-selected="true"]`)?.scrollIntoView({block:`nearest`})},[y]);let oe=o.length>0,[O,A]=(0,d.useState)(!1);(0,d.useEffect)(()=>{oe||A(!1)},[oe]);function se(){if(oe){A(!0);return}let e=NT(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(!re)return;let t=h.slice(0,re.start),n=h.slice(_),r=`@${e.path}${WT(e.type)?`/`:` `}`,i=`${t}${r}${n}`;g(i),m();let a=t.length+r.length;ee.current=a,v(a)}function j(){if(ie)if(ie.kind===`command`){let e=ie.items[y];e&&ce(e)}else{let e=ie.items[y];e&&le(e)}}function ue(e){if(ae&&ie){if(e.key===`ArrowDown`){e.preventDefault(),b(e=>(e+1)%ie.items.length);return}if(e.key===`ArrowUp`){e.preventDefault(),b(e=>(e-1+ie.items.length)%ie.items.length);return}if(e.key===`Tab`||e.key===`Enter`){e.preventDefault(),j();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,k.jsxs)(`div`,{ref:C,className:`relative`,children:[(a.length>0||oe)&&(0,k.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[o.map(e=>(0,k.jsxs)(`span`,{"data-pending-upload":e.name,title:`${e.name} — copying into the workspace`,className:`flex items-center gap-1.5 rounded-md border border-dashed border-zinc-300 bg-zinc-50 py-1 pl-1.5 pr-2 text-xs text-zinc-500 dark:border-zinc-600 dark:bg-zinc-800/40 dark:text-zinc-400`,children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`animate-pulse`,children:`⏳`}),(0,k.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,k.jsx)(`span`,{className:`sr-only`,children:`uploading`})]},e.id)),O&&(0,k.jsx)(`span`,{role:`status`,className:`flex items-center py-1 text-xs text-amber-600 dark:text-amber-400`,children:`waiting for the attachment to finish uploading…`}),a.map((e,t)=>(0,k.jsxs)(`span`,{title:e.kind===`path`?`${e.name} — sent as a reference; the agent reads the file itself`:e.name,className:`flex items-center gap-1.5 rounded-md border border-zinc-200 bg-zinc-50 py-1 pl-1.5 pr-1 text-xs text-zinc-600 dark:border-zinc-700 dark:bg-zinc-800/60 dark:text-zinc-300`,children:[e.kind===`image`?(0,k.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:e.name,className:`h-8 w-8 rounded object-cover`}):(0,k.jsx)(`span`,{"aria-hidden":!0,className:e.kind===`path`?`font-mono font-bold text-blue-600 dark:text-blue-400`:``,children:e.kind===`path`?`@`:`📄`}),(0,k.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>l(t),title:`remove attachment`,className:`rounded px-1 text-zinc-400 hover:bg-zinc-200 hover:text-zinc-700 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✕`})]},`${e.name}:${t}`))]}),ae&&ie&&(0,k.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:ie.kind===`command`?ie.items.map((e,t)=>(0,k.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,k.jsxs)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:[`/`,e.name]}),e.argumentHint&&(0,k.jsx)(`span`,{className:`font-mono text-xs text-zinc-500`,children:e.argumentHint}),e.description&&(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-zinc-500`,children:e.description}),(0,k.jsx)(`span`,{className:`ml-auto shrink-0 rounded bg-zinc-200 px-1 text-[10px] uppercase text-zinc-500 dark:bg-zinc-800`,children:UT[e.source]})]},e.name)):ie.items.map((e,t)=>(0,k.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,k.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-zinc-800 dark:text-zinc-200`,children:[e.path,WT(e.type)?`/`:``]})},e.path))}),(0,k.jsxs)(`div`,{className:`flex items-end gap-2 rounded-xl border border-zinc-200 bg-zinc-50 p-2 focus-within:border-zinc-400 dark:border-zinc-800 dark:bg-zinc-900 dark:focus-within:border-zinc-600`,children:[(0,k.jsx)(`textarea`,{ref:T,value:h,onChange:e=>{g(e.target.value),v(e.target.selectionStart??e.target.value.length)},onKeyDown:ue,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(`
|
|
320
|
+
`).length)),className:`flex-1 resize-none bg-transparent px-2 py-1.5 text-[15px] outline-none placeholder:text-zinc-400 disabled:opacity-50 dark:placeholder:text-zinc-600`}),e&&(0,k.jsx)(`button`,{type:`button`,onClick:f,title:`stop`,"aria-label":`Stop the agent`,className:`rounded-lg bg-red-100 p-2 text-red-700 hover:bg-red-200 dark:bg-red-900/60 dark:text-red-200 dark:hover:bg-red-900`,children:(0,k.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,className:`h-4 w-4`,children:(0,k.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>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,k.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`})})}),(0,k.jsx)(`input`,{ref:E,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&s(Array.from(e.target.files)),e.target.value=``}}),(0,k.jsx)(`button`,{type:`button`,onClick: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,k.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:[(0,k.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,k.jsx)(`path`,{strokeLinecap:`round`,d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`}),(0,k.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]}):(0,k.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M6 12 3.27 3.13c6.6 1.9 12.83 4.9 18.43 8.87-5.6 3.97-11.83 6.97-18.43 8.87L6 12Zm0 0h7.5`})})})]})]})}var qT=`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`,JT=`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`,YT=`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`,XT=`mb-4 ${YT}`,ZT=`1,3`,QT=` — `;function $T(e){let t=e.indexOf(`
|
|
321
|
+
`);return t===-1?{heading:e,body:``}:{heading:e.slice(0,t),body:e.slice(t+1).trim()}}function eE(e){let t=/^(\d+)\.\s+(\S[\s\S]*)$/.exec(e.trim());if(!t)return null;let n=t[2],r=n.indexOf(QT);return{index:Number(t[1]),label:r===-1?n:n.slice(0,r),description:r===-1?``:n.slice(r+3)}}function tE(e){if(e.method!==`input`||e.placeholder!==ZT)return null;let{heading:t,body:n}=$T(e.title),r=[];for(let e of n.split(`
|
|
322
|
+
`)){let t=eE(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function nE({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=tE(e),{heading:u,body:f}=$T(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,k.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:p,children:(0,k.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,k.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:u}),f&&!l&&(0,k.jsx)(`pre`,{className:`mb-3 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-zinc-50 p-2 font-mono text-xs text-zinc-600 dark:bg-zinc-950 dark:text-zinc-400`,children:f}),e.method===`select`&&(0,k.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>{let r=eE(n);return(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${qT}`,children:r?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:r.label}),r.description&&(0,k.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:r.description})]}):n},n)})}),e.method===`confirm`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:qT,children:`No`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:JT,children:`Yes`})]})]}),l&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`mb-3 flex flex-col gap-1`,children:l.options.map(e=>(0,k.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:i.includes(e.index),onChange:()=>m(e.index),className:`mt-0.5`}),(0,k.jsxs)(`span`,{children:[(0,k.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,k.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,k.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`…or type your own answer`,onKeyDown:e=>{e.key===`Enter`&&h(),e.key===`Escape`&&p()},className:`mb-1 ${YT}`}),(0,k.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:p,className:qT,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:h,className:JT,children:`OK`})]})]}),e.method===`input`&&!l&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`input`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),placeholder:e.placeholder,onKeyDown:r=>{r.key===`Enter`&&t({id:e.id,value:n}),r.key===`Escape`&&p()},className:XT}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:p,className:qT,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:JT,children:`OK`})]})]}),e.method===`editor`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`textarea`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&p()},className:`resize-none font-mono ${XT}`}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:p,className:qT,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:JT,children:`OK`})]})]}),s!==null&&(0,k.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,s,`s`]})]})})}var rE={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 iE({notification:e,onDismiss:t}){return(0,d.useEffect)(()=>{let e=setTimeout(t,6e3);return()=>clearTimeout(e)},[t]),(0,k.jsx)(`div`,{className:`rounded-lg border px-3 py-2 text-sm shadow-lg ${rE[e.notifyType??`info`]}`,children:e.message})}function aE({notifications:e,onDismiss:t}){return e.length===0?null:(0,k.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,k.jsx)(iE,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var oE={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`},sE=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function cE(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(oE[r]!==void 0)n.color=oE[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;sE.lastIndex=0;for(let i=sE.exec(e);i!==null;i=sE.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=cE(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function uE(e){return e.replace(sE,``)}function dE({line:e}){return(0,k.jsx)(k.Fragment,{children:lE(e).map((e,t)=>(0,k.jsx)(`span`,{style:{...e.color?{color:e.color}:{},...e.bold?{fontWeight:600}:{},...e.dim?{opacity:.7}:{},...e.italic?{fontStyle:`italic`}:{},...e.underline?{textDecoration:`underline`}:{}},children:e.text},t))})}function fE({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,k.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,k.jsx)(`div`,{className:`whitespace-pre-wrap rounded-md border border-zinc-200 bg-zinc-50 px-3 py-1.5 font-mono text-xs text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:t.lines.map((e,t)=>(0,k.jsx)(`div`,{children:(0,k.jsx)(dE,{line:e})},t))},e))})}var pE=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,k.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,k.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}},mE=(0,d.lazy)(()=>j(()=>import(`./PdfViewer-DLZN8MPh.js`),[]));function hE(e){return/\.(md|markdown)$/i.test(e)}function gE(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function _E({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}){let[y,x]=(0,d.useState)(!1),[S,C]=(0,d.useState)(a),[w,E]=(0,d.useState)(e.status===`loaded`&&e.justCreated?{draft:e.content,baseContent:e.content,baseMtimeMs:e.mtimeMs}:null),[ee,D]=(0,d.useState)(`idle`),ie=(0,d.useRef)(null),oe=(0,d.useRef)(null),O=e.status===`loaded`?e:null,se=O!==null&&hE(e.path),ce=ne(e.path),le=re(e.path),j=gE(e.path,t)&&!le,ue=w!==null&&w.draft!==w.baseContent,de=O?.pendingSave!==void 0,fe=w!==null&&O!==null&&O.mtimeMs!==w.baseMtimeMs,pe=O?.saveError?.conflict===!0||fe;function me(){ue&&!window.confirm(`Discard unsaved changes?`)||f()}function ge(){O&&E({draft:O.content,baseContent:O.content,baseMtimeMs:O.mtimeMs})}function _e(t=!1){!O||w===null||de||(oe.current=w.draft,m(e.path,w.draft,w.baseMtimeMs,t))}function ve(){E(null),p(e.path)}function ye(){let t=!S;C(t),t?s(e.path):c()}return(0,d.useEffect)(()=>{if(w!==null&&O!==null&&oe.current!==null&&O.content===oe.current&&O.mtimeMs!==w.baseMtimeMs){let e=oe.current;oe.current=null,w.draft===e?E(null):E({...w,baseContent:O.content,baseMtimeMs:O.mtimeMs})}},[O?.mtimeMs]),(0,d.useEffect)(()=>{function e(e){e.key===`Escape`&&me()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,d.useEffect)(()=>{D(n?`streaming`:e=>e===`streaming`?`done`:e)},[n]),(0,d.useEffect)(()=>(r(ue),()=>r(!1)),[ue]),(0,d.useEffect)(()=>(a&&s(e.path),()=>c()),[]),(0,k.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[se&&w===null&&!S&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>x(!y),title:y?`Show rendered`:`Show source`,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:y?`⚏ rendered`:`⌗ source`}),i!==void 0&&w===null&&(0,k.jsx)(`button`,{type:`button`,onClick:ye,"aria-pressed":S,title:S?`Show file content`:`Show uncommitted changes (vs HEAD)`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs ${S?`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&&w===null&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>u(e.path),title:`Show this file's history`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:`⎇ history`}),(0,k.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:[e.path,ue&&(0,k.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),O&&w===null&&(0,k.jsx)(A,{text:O.content}),O&&w===null&&!S&&j&&(0,k.jsx)(`button`,{type:`button`,onClick:ge,className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500 dark:hover:text-zinc-200`,children:`✎ edit`}),O&&w===null&&!j&&(0,k.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,title:`Outside the writable zone`,children:`🔒 read-only`}),w!==null&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>_e(),disabled:!ue||de||pe,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:de?`saving…`:`save`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>ue?window.confirm(`Discard unsaved changes?`)&&E(null):E(null),className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500`,children:`cancel`})]}),(0,k.jsx)(`button`,{type:`button`,onClick:me,title:`Close (Esc)`,"aria-label":`Close file viewer`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),pe&&w!==null&&(0,k.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:[(0,k.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,k.jsx)(`button`,{type:`button`,onClick:ve,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`reload (discard my edits)`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>_e(!0),disabled:de,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`})]}),w!==null&&O?.saveError&&!O.saveError.conflict&&(0,k.jsx)(`div`,{className:`border-b border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:O.saveError.message}),(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[S&&w===null&&(0,k.jsxs)(`div`,{className:`p-4`,children:[o?.path===e.path&&`error`in o&&(0,k.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:o.error}),o?.path===e.path&&`before`in o&&(0,k.jsx)(Te,{fill:!0,lines:b(o.before,o.after)}),o?.path!==e.path&&(0,k.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),le&&w===null&&!S&&(0,k.jsx)(pE,{label:`This PDF`,children:(0,k.jsx)(d.Suspense,{fallback:(0,k.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),children:(0,k.jsx)(mE,{path:e.path,serverUrl:h,token:g,...v?{onLoaded:v}:{}})})}),ce&&w===null&&!S&&(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,k.jsx)(`img`,{src:ae(h,e.path,g),alt:e.path,onLoad:()=>_(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&w===null&&!S&&!ce&&!le&&(0,k.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!ce&&!le&&(0,k.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),w!==null&&(0,k.jsx)(`textarea`,{ref:ie,value:w.draft,onChange:e=>E({...w,draft:e.target.value}),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),ue&&!de&&!pe&&_e())},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`}),O&&w===null&&!S&&se&&!y&&(0,k.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,k.jsx)(fs,{remarkPlugins:[E_,R_],rehypePlugins:[Em],components:{a:({href:t,children:n,...r})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,k.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...r,children:n}):t.startsWith(`#`)?(0,k.jsx)(`a`,{href:t,...r,children:n}):(0,k.jsx)(`a`,{href:t,onClick:n=>{n.preventDefault(),p(te(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(`//`)?ae(h,te(e.path,t),g):t;return(0,k.jsx)(`img`,{...r,src:i,alt:n??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:T(O.content)})}),O&&w===null&&!S&&(!se||y)&&(0,k.jsx)(`div`,{className:`p-4`,children:(0,k.jsx)(he,{code:O.content,path:e.path})})]}),ee!==`idle`&&(0,k.jsxs)(`button`,{type:`button`,onClick:me,"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:[ee===`streaming`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,k.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,k.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,k.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function vE(e){return e.split(`
|
|
323
|
+
`).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 yE({show:e,onClose:t}){return(0,d.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),t())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]),(0,k.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsx)(`span`,{className:`font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,12)}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`commit diff`}),(0,k.jsx)(`button`,{type:`button`,onClick:t,title:`Close (Esc)`,"aria-label":`Close commit diff`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),e.truncated&&(0,k.jsx)(`div`,{className:`border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:`Patch truncated — showing the first 256 KiB.`}),(0,k.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed`,children:vE(e.patch).map((e,t)=>(0,k.jsxs)(`div`,{className:e.kind===`file`?`mt-3 border-t border-zinc-200 pt-2 font-bold text-zinc-700 first:mt-0 first:border-t-0 first:pt-0 dark:border-zinc-800 dark:text-zinc-200`:e.kind===`hunk`?`text-sky-600 dark:text-sky-400`:e.kind===`add`?`bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:e.kind===`del`?`bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`text-zinc-500 dark:text-zinc-500`,children:[e.kind===`add`?`+ `:e.kind===`del`?`− `:``,e.text||` `]},t))})]})}var bE=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],xE=`worktree`,SE={defaultWidth:288,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.files-sidebar-width.v1`},CE={defaultWidth:416,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.history-list-width.v1`};function wE(e,t){return Number.isFinite(e)?Math.min(t.maxWidth,Math.max(t.minWidth,Math.round(e))):t.defaultWidth}function TE(e,t){return e===null||e.trim()===``?t.defaultWidth:wE(Number(e),t)}function EE(e,t){try{return TE((t??window.localStorage).getItem(e.storageKey),e)}catch{return e.defaultWidth}}function DE(e,t,n){try{(n??window.localStorage).setItem(t.storageKey,String(wE(e,t)))}catch{}}function OE(e){let[t,n]=(0,d.useState)(()=>EE(e)),r=(0,d.useRef)(t),i=(0,d.useRef)(null),a=(0,d.useCallback)(t=>{let i=wE(t,e);return r.current=i,n(i),i},[e]),o=(0,d.useCallback)(()=>{i.current!==null&&(i.current=null,DE(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(),DE(a(n),e))}}}}function kE({label:e,width:t,config:n,separatorProps:r,className:i=``}){return(0,k.jsx)(`div`,{...r,role:`separator`,"aria-label":e,"aria-orientation":`vertical`,"aria-valuemin":n.minWidth,"aria-valuemax":n.maxWidth,"aria-valuenow":t,tabIndex:0,title:e,className:`group absolute inset-y-0 -right-1 z-20 w-2 cursor-col-resize touch-none outline-none ${i}`,children:(0,k.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 left-1/2 w-px bg-transparent transition-colors group-hover:bg-blue-400 group-focus-visible:bg-blue-500 group-active:bg-blue-500 dark:group-hover:bg-blue-500`})})}var AE=`#10b981`,jE=[`#8b5cf6`,`#f59e0b`,`#0ea5e9`,`#f43f5e`,`#14b8a6`,`#d946ef`];function ME(e){return e===0?AE:jE[(e-1)%jE.length]}function NE(e){return jE[e%jE.length]}function PE(e){return e*14+14/2+1}function FE(e){return e*14+2}function IE({row:e,laneCount:t,colorOf:n=ME}){let r=FE(t),i=PE(e.lane),a=e.highlight?AE:n(e.lane),o=e.dashed?`3 3`:void 0;return(0,k.jsxs)(`svg`,{width:r,height:36,viewBox:`0 0 ${r} 36`,"aria-hidden":!0,className:`shrink-0`,children:[e.through.map(e=>(0,k.jsx)(`line`,{x1:PE(e),y1:0,x2:PE(e),y2:36,stroke:n(e),strokeWidth:2,opacity:.55},e)),e.lineAbove&&(0,k.jsx)(`line`,{x1:i,y1:0,x2:i,y2:18,stroke:a,strokeWidth:2,strokeDasharray:o}),e.lineBelow&&(0,k.jsx)(`line`,{x1:i,y1:18,x2:i,y2:36,stroke:a,strokeWidth:2,strokeDasharray:o}),e.forkTo.map(e=>(0,k.jsx)(`path`,{d:`M ${i} 18 C ${i} 36, ${PE(e)} 18, ${PE(e)} 36`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`fork-${e}`)),(e.mergeFrom??[]).map(e=>(0,k.jsx)(`path`,{d:`M ${i} 18 C ${i} 0, ${PE(e)} 18, ${PE(e)} 0`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`merge-${e}`)),e.emphasis===`current`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`circle`,{cx:i,cy:18,r:6,fill:`none`,stroke:a,strokeWidth:2}),(0,k.jsx)(`circle`,{cx:i,cy:18,r:2.5,fill:a})]}):(0,k.jsx)(`circle`,{cx:i,cy:18,r:4,fill:e.emphasis===`filled`?a:`var(--tree-off, #d4d4d8)`,stroke:a,strokeWidth:e.emphasis===`filled`?0:1.5})]})}function LE(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:xE,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 RE=20;function zE(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 BE(e){return e.rev===`worktree`?`working tree`:e.rev.slice(0,7)}function VE(e,t){return e!==null&&t!==null&&e.rev===t.rev&&e.path===t.path}function HE(e){return{rev:e.rev,path:e.path}}function UE({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=OE(CE),{rows:h,laneCount:g}=(0,d.useMemo)(()=>LE(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||VE(c,l)||_.current.onFetchDiff(c,l)},[c,l]);let v=(0,d.useCallback)((e,t)=>{let n=HE(e);s(r=>{if(t===`base`)return{base:n,target:VE(n,r.target)?r.base:r.target};if(t===`target`)return{base:VE(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?HE(r):null,target:n}}return{base:VE(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=HE(e);return VE(t,c)?`base`:VE(t,l)?`target`:null},C=h.findIndex(e=>VE(HE(e),c)),w=h.findIndex(e=>VE(HE(e),l)),T=C>=0&&w>=0?{top:Math.min(C,w)*36+36/2,height:Math.abs(w-C)*36}:null;return(0,k.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:e.path}),c!==null&&l!==null&&(0,k.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-zinc-500 dark:text-zinc-400`,"aria-label":`Comparing ${BE(c)} to ${BE(l)}`,children:[(0,k.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:BE(c)}),` → `,(0,k.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:BE(l)})]}),c!==null&&l!==null&&(0,k.jsx)(`button`,{type:`button`,onClick:b,title:`Compare the other way round`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`⇄ swap`}),(c!==null||l!==null)&&(0,k.jsx)(`button`,{type:`button`,onClick:y,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`clear`}),(0,k.jsx)(`button`,{type:`button`,onClick:a,title:`Close (Esc)`,"aria-label":`Close file history`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,k.jsxs)(`div`,{role:`region`,"aria-label":`Commit history`,style:{"--history-list-width":`${m.width}px`},className:`relative flex max-h-[40%] w-full shrink-0 flex-col border-b border-zinc-200 md:max-h-none md:w-[var(--history-list-width)] md:border-b-0 md:border-r dark:border-zinc-800`,children:[(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),x(1)):e.key===`ArrowUp`&&(e.preventDefault(),x(-1))},children:[e.status===`loading`&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`Reading history…`}),e.status===`error`&&(0,k.jsx)(`div`,{className:`m-3 rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e.error}),e.status===`loaded`&&e.entries.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`No commits touch this file yet.`}),e.status===`loaded`&&e.entries.length>0&&(0,k.jsxs)(`div`,{className:`relative`,role:`group`,"aria-label":`Commits`,children:[T&&(0,k.jsx)(WE,{top:T.top,height:T.height,baseFirst:C<w}),h.map((e,t)=>(0,k.jsx)(qE,{ref:e=>{p.current[t]=e},row:e,laneCount:g,role:S(e),isFocused:t===u,onSelect:t=>v(e,t),onFocus:()=>f(t)},e.rev))]})]}),(0,k.jsx)(kE,{label:`Resize History commit list`,width:m.width,config:CE,separatorProps:m.separatorProps,className:`hidden md:block`})]}),(0,k.jsx)(`div`,{role:`region`,"aria-label":`History diff`,className:`min-h-0 min-w-0 flex-1 overflow-auto p-3`,children:(0,k.jsx)(JE,{diff:t,base:c,target:l})})]})]})}function WE({top:e,height:t,baseFirst:n}){return(0,k.jsxs)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute left-0 z-10 motion-safe:transition-all motion-safe:duration-150 motion-safe:ease-out`,style:{top:e,height:t,width:RE},children:[(0,k.jsx)(`div`,{className:`absolute inset-y-0 left-2 w-px bg-zinc-400 dark:bg-zinc-500`}),(0,k.jsx)(GE,{label:n?`base`:`target`,className:`top-0`}),(0,k.jsx)(GE,{label:n?`target`:`base`,className:`bottom-0`})]})}function GE({label:e,className:t}){return(0,k.jsx)(`div`,{className:`absolute left-2 flex h-px w-2.5 items-center bg-zinc-400 dark:bg-zinc-500 ${t}`,children:(0,k.jsx)(`span`,{className:`absolute -left-1 -top-1.5 rotate-180 text-[9px] leading-none text-zinc-500 [writing-mode:vertical-rl] dark:text-zinc-400`,children:e})})}var KE=`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 qE({row:e,laneCount:t,role:n,isFocused:r,onSelect:i,onFocus:a,ref:o}){let s=e.entry,c=s?`${s.sha.slice(0,7)} ${s.subject}`:`Working tree`;return(0,k.jsxs)(`div`,{ref:o,role:`button`,tabIndex:r?0:-1,"aria-label":c,"aria-current":n===null?void 0:`true`,onFocus:a,onClick:()=>i(),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `?(e.preventDefault(),i()):e.key===`b`?i(`base`):e.key===`t`&&i(`target`))},style:{height:36,paddingLeft:RE},className:`group flex cursor-pointer items-center gap-2 pr-2 focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${n===null?``:`bg-zinc-100 dark:bg-zinc-800/60`}`,children:[(0,k.jsx)(IE,{row:e,laneCount:t}),s?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:s.sha.slice(0,7)}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-700 dark:text-zinc-300`,title:s.subject,children:s.subject}),(0,k.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-600`,children:[s.author,` · `,zE(s.date)]}),(0,k.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums`,"aria-label":`${s.added} lines added, ${s.deleted} removed`,children:[(0,k.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-500`,children:[`+`,s.added]}),` `,(0,k.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,s.deleted]})]})]}):(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`working tree`}),(0,k.jsxs)(`span`,{className:`flex shrink-0 gap-0.5`,children:[(0,k.jsx)(`button`,{type:`button`,title:n===`target`?`Make this the base (swaps the two)`:`Compare from this version`,onClick:e=>{e.stopPropagation(),i(`base`)},className:KE,children:`base`}),(0,k.jsx)(`button`,{type:`button`,title:n===`base`?`Make this the target (swaps the two)`:`Compare to this version`,onClick:e=>{e.stopPropagation(),i(`target`)},className:KE,children:`target`})]})]})}function JE({diff:e,base:t,target:n}){return t===null&&n===null?(0,k.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Pick a commit to see what changed.`}):t===null||n===null?(0,k.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Now pick the version to compare it against.`}):e?.status===`error`?(0,k.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e.error}):e===null?(0,k.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Loading…`}):e.status===`loaded`&&e.beforeText===e.afterText?(0,k.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions are identical.`}):(0,k.jsx)(`div`,{className:e.status===`loading`?`opacity-40`:void 0,children:(0,k.jsx)(Te,{fill:!0,lines:b(e.beforeText,e.afterText)})})}function YE(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 XE({status:e,log:t,onFetchLog:n,onShowCommit:r}){let[i,a]=(0,d.useState)(!1),o=BT(()=>a(!1)),s=e&&(e.ahead>0||e.behind>0)?` ${e.ahead>0?`↑${e.ahead}`:``}${e.behind>0?`↓${e.behind}`:``}`:``;return(0,k.jsxs)(`div`,{className:`relative`,ref:o,children:[(0,k.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,k.jsxs)(`div`,{className:`absolute left-0 top-full z-20 mt-1 max-h-96 w-[26rem] max-w-[80vw] overflow-y-auto rounded-lg border border-zinc-200 bg-white py-1 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[t===null&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),t?.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no commits`}),t?.map(e=>(0,k.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,k.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,7)}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-700 dark:text-zinc-300`,title:e.subject,children:e.subject}),(0,k.jsxs)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:[e.author,` · `,YE(e.date)]})]},e.sha))]})]})}function ZE({extensionPaths:e,sandbox:t,versions:n,onUpdateConfig:r}){let[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(``),[u,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(!1),_=BT(()=>a(!1));(0,d.useEffect)(()=>{t&&(s(t.root),l(t.writableRoot??``),f(t.allowWrite),m(t.allowBash))},[t]);function v(){a(!1),g(!1)}function y(){t&&(g(!0),r({root:o,allowWrite:u,allowBash:p,writableRoot:c.trim()||void 0}),v())}return(0,k.jsxs)(`div`,{className:`relative`,ref:_,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>a(!i),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:`⚙`}),i&&(0,k.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[80vh] w-[380px] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,k.jsx)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Settings`})}),(0,k.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:[(0,k.jsxs)(`section`,{className:`mb-4`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),e.length===0?(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,k.jsx)(`ul`,{className:`space-y-1`,children:e.map((e,t)=>(0,k.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))})]}),t&&(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Sandbox`}),(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsxs)(`label`,{className:`block`,children:[(0,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,t.locks?.root?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,k.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),disabled:t.locks?.root,className:`mt-1 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:focus:border-zinc-500`})]}),(0,k.jsxs)(`label`,{className:`block`,children:[(0,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,t.locks?.writableRoot?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,k.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),disabled:t.locks?.writableRoot,placeholder:`Same as root`,className:`mt-1 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`})]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>f(e.target.checked),disabled:t.locks?.allowWrite,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,t.locks?.allowWrite?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked),disabled:t.locks?.allowBash,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,t.locks?.allowBash?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,k.jsx)(`button`,{type:`button`,disabled:h||!o.trim(),onClick:y,className:`w-full rounded-md bg-zinc-800 px-3 py-1.5 text-xs font-medium text-white hover:bg-zinc-700 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-zinc-200 dark:text-zinc-900 dark:hover:bg-zinc-300`,children:h?`Applying…`:`Apply & restart session`}),(0,k.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:`File browser paths update immediately. Agent tools (read/write/bash) use the new sandbox after a server restart.`})]})]}),!t&&(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),n&&(0,k.jsxs)(`section`,{className:`mt-4`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,k.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,k.jsxs)(`p`,{children:[`pi-outpost: `,(0,k.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:n.piOutpost})]}),n.piSdk&&(0,k.jsxs)(`p`,{children:[`pi SDK: `,(0,k.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:n.piSdk})]}),n.agent&&(0,k.jsxs)(`p`,{children:[`agent: `,(0,k.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:n.agent})]})]})]})]})]})]})}function QE(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 $E(e){return e.flatMap(e=>[e,...$E(e.children)])}function eD({children:e,tone:t}){let n={current:`border-emerald-300 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-950/50 dark:text-emerald-300`,branch:`border-zinc-300 text-zinc-500 dark:border-zinc-700 dark:text-zinc-400`,label:`border-violet-300 bg-violet-50 text-violet-700 dark:border-violet-900 dark:bg-violet-950/50 dark:text-violet-300`}[t];return(0,k.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var tD=`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 nD({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:o}=e,s=o.tipId??o.entryId;return(0,k.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${e.isCurrent?`bg-emerald-50/60 dark:bg-emerald-950/20`:``}`,style:{height:36},children:[(0,k.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>{r(s),a()},title:n?`unavailable while the agent is running`:o.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex h-full min-w-0 flex-1 items-center gap-2 pl-2 text-left text-sm disabled:opacity-50`,children:[(0,k.jsx)(IE,{row:e,laneCount:t,colorOf:NE}),(0,k.jsx)(`span`,{className:`min-w-0 truncate ${o.onPath?`text-zinc-800 dark:text-zinc-200`:`text-zinc-600 dark:text-zinc-400`}`,children:o.text||`(empty)`}),e.forkTo.length>0&&(0,k.jsxs)(eD,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,k.jsxs)(eD,{tone:`branch`,children:[`branch `,e.branchIndex,o.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,k.jsx)(eD,{tone:`current`,children:`current`}),o.label&&(0,k.jsx)(eD,{tone:`label`,children:o.label})]}),(0,k.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{r(o.entryId),a()},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:tD,children:`↺ redo`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{i(o.entryId),a()},title:`fork a new session from this point`,className:tD,children:`⑂ fork`})]})}function rD({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:i}){let[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(``),l=BT(()=>o(!1));(0,d.useEffect)(()=>{a&&e===null&&n()},[a,e]);let u=(0,d.useMemo)(()=>e&&e.length>0?QE(e):null,[e]),f=(0,d.useMemo)(()=>{if(!e||!s.trim())return null;let t=s.trim().toLowerCase();return $E(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,s]);return(0,k.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>{o(!a),a||(c(``),n())},title:`conversation tree: go back to an earlier point or fork`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`tree`}),a&&(0,k.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[70vh] w-[32rem] max-w-[90vw] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl [--tree-off:#e4e4e7] dark:border-zinc-700 dark:bg-zinc-900 dark:[--tree-off:#3f3f46]`,children:[e===null&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&u&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,k.jsxs)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:[u.rows.length,` turn`,u.rows.length===1?``:`s`,` · `,u.branchPoints,` branch point`,u.branchPoints===1?``:`s`]})]}),(0,k.jsx)(`input`,{type:`search`,value:s,onChange:e=>c(e.target.value),placeholder:`Search tree`,"aria-label":`Search conversation tree`,className:`mt-2 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,k.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Follow the colored lines — the current branch is highlighted. Click a turn to restore the conversation there · ↺ to send it again · ⑂ to fork a session`})]}),(0,k.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:f===null?u.rows.map(e=>(0,k.jsx)(nD,{row:e,laneCount:u.laneCount,isStreaming:t,onNavigate:r,onFork:i,onClose:()=>o(!1)},e.node.entryId)):f.length===0?(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):f.map(e=>(0,k.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,k.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.tipId??e.entryId),o(!1)},title:e.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left text-sm disabled:opacity-50`,children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,k.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,k.jsx)(eD,{tone:`current`,children:`on current branch`}),e.label&&(0,k.jsx)(eD,{tone:`label`,children:e.label})]}),(0,k.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.entryId),o(!1)},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:tD,children:`↺ redo`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{i(e.entryId),o(!1)},title:`fork a new session from this point`,className:tD,children:`⑂ fork`})]},e.entryId))})]})]})]})}var iD=200;function aD({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,d.useState)(e);return(0,k.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),onBlur:n,onKeyDown:e=>{e.key===`Enter`?t(r):e.key===`Escape`&&n()},placeholder:`Session name (empty to clear)`,"aria-label":`Session name`,className:`w-full rounded-md border border-zinc-400 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 dark:border-zinc-600 dark:placeholder:text-zinc-600`})}function oD({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:o,onCancelRename:s}){return n?(0,k.jsx)(`div`,{className:`px-3 py-2`,children:(0,k.jsx)(aD,{initial:e.name??``,onCommit:o,onCancel:s})}):(0,k.jsxs)(`div`,{className:`group flex items-start gap-1 hover:bg-zinc-100 dark:hover:bg-zinc-800 ${t?`bg-zinc-100 dark:bg-zinc-800/60`:``}`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,k.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,k.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,k.jsxs)(`div`,{className:`mt-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:[new Date(e.modified).toLocaleString(),` · `,e.messageCount,` messages`,t?` · current`:``]})]}),(0,k.jsx)(`button`,{type:`button`,onClick:a,title:`rename session`,"aria-label":`Rename session`,className:`mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✎`}),!t&&(0,k.jsx)(`button`,{type:`button`,onClick:i,title:`delete session`,"aria-label":`Delete session`,className:`mr-2 mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-red-100 hover:text-red-600 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-red-950/60 dark:hover:text-red-400`,children:`✕`})]})}function sD({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=BT(()=>u(!1)),_=f.trim(),v=_.length>=2;(0,d.useEffect)(()=>{if(!l)return;if(!v){c();return}let e=setTimeout(()=>s(_),iD);return()=>clearTimeout(e)},[l,_,v]);function y(){u(!1),h(null)}let b=v&&!(t?.status===`loaded`&&t.query===_),x=v?b?null:t?.results??null:e;return(0,k.jsxs)(`div`,{className:`relative`,ref:g,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>{if(l){y();return}u(!0),p(``),h(null),c(),a()},className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`sessions`}),l&&(0,k.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-96 w-96 flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,k.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsx)(`input`,{type:`search`,value:f,onChange:e=>p(e.target.value),placeholder:`Search sessions`,"aria-label":`Search sessions`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,k.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Searches names and everything said in a session · ✎ to rename`})]}),(0,k.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[x===null&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),x?.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:v?`no matches`:`no saved sessions`}),x?.map(e=>(0,k.jsx)(oD,{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 cD({theme:e,onToggle:t}){return(0,k.jsx)(`button`,{type:`button`,onClick:t,title:e===`dark`?`Switch to light theme`:`Switch to dark theme`,"aria-label":e===`dark`?`Switch to light theme`:`Switch to dark theme`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:e===`dark`?`☀`:`☾`})}function lD(e){let{isStreaming:t,connected:n}=e;return(0,k.jsxs)(`header`,{className:`relative z-30 flex items-center gap-3 border-b border-zinc-200 px-4 py-2.5 dark:border-zinc-800`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:e.onToggleSidebar,title:e.sidebarOpen?`Hide files (panel opens on the left)`:`Show files`,"aria-pressed":e.sidebarOpen,className:`rounded-md border px-2 py-1 text-xs ${e.sidebarOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:[e.sidebarOpen?`◧`:`◨`,` files`]}),e.gitAvailable&&(0,k.jsx)(XE,{status:e.gitStatus,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,k.jsx)(`span`,{className:`text-lg font-semibold tracking-tight`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),Object.entries(e.statuses).map(([e,t])=>(0,k.jsx)(`span`,{className:`rounded-md border border-zinc-200 px-2 py-1 text-xs text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:uE(t)},e)),(0,k.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,k.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,k.jsx)(cD,{theme:e.theme,onToggle:e.onToggleTheme}),(0,k.jsx)(`button`,{type:`button`,onClick:e.onNewSession,title:`new session`,className:`rounded-md border border-emerald-300 px-2 py-1 text-xs text-emerald-700 hover:border-emerald-500 hover:text-emerald-600 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600 dark:hover:text-emerald-300`,children:`+ new`}),(0,k.jsx)(rD,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,k.jsx)(sD,{sessions:e.sessions,sessionSearch:e.sessionSearch,sessionId:e.sessionId,onSwitchSession:e.onSwitchSession,onDeleteSession:e.onDeleteSession,onListSessions:e.onListSessions,onRenameSession:e.onRenameSession,onSearchSessions:e.onSearchSessions,onClearSessionSearch:e.onClearSessionSearch}),(0,k.jsx)(ZE,{extensionPaths:e.extensionPaths,sandbox:e.sandbox,versions:e.versions,onUpdateConfig:e.onUpdateConfig}),(0,k.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 dD({usage:e,analysisOpen:t,onToggleAnalysis:n}){if(e.turns===0)return null;let r=e.turns-e.unpriced,i=[`${e.turns} turn${e.turns===1?``:`s`}`,`input ${e.input.toLocaleString()}`,`output ${e.output.toLocaleString()}`,`cache read ${e.cacheRead.toLocaleString()}`,`cache write ${e.cacheWrite.toLocaleString()}`,...e.unpriced>0&&r>0?[`${e.unpriced} unpriced`]:[]].join(` · `),a=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{children:[zw(e.totalTokens),` tok`]}),r>0&&(0,k.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:[Rw(e.cost),e.unpriced>0&&`*`]})]}),o=`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs text-zinc-500 dark:text-zinc-400`;return n?(0,k.jsx)(`button`,{type:`button`,onClick:n,title:`${i} — click for the session analysis`,"aria-haspopup":`dialog`,"aria-expanded":t??!1,className:`${o} ${t?`border-zinc-400 dark:border-zinc-600`:`border-zinc-300 hover:border-zinc-400 dark:border-zinc-800 dark:hover:border-zinc-600`}`,children:a}):(0,k.jsx)(`span`,{title:i,className:`${o} border-zinc-300 dark:border-zinc-800`,children:a})}function fD({usage:e}){let t=15.9155,n=2*Math.PI*t,r=e?.percent??0,i=Math.min(100,Math.max(0,r))/100*n;return(0,k.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 36 36`,className:`-rotate-90 shrink-0`,children:[(0,k.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,className:`text-zinc-200 dark:text-zinc-800`}),e&&e.percent!==null&&(0,k.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${i} ${n-i}`,className:uD(e)})]})}function pD({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,bE.indexOf(e));return(0,d.useEffect)(()=>{if(!r)return;function e(e){a.current&&!zT(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,k.jsxs)(`div`,{className:`relative`,ref:a,children:[(0,k.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,k.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none ${o?``:`opacity-40 grayscale`}`,children:`🧠`}),e]}),r&&(0,k.jsxs)(`div`,{className:`absolute bottom-full left-0 z-20 mb-1 w-48 rounded-lg border border-zinc-200 bg-white p-3 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between text-xs`,children:[(0,k.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`thinking`}),(0,k.jsx)(`span`,{className:`font-mono text-zinc-700 dark:text-zinc-200`,children:e})]}),(0,k.jsx)(`input`,{type:`range`,min:0,max:bE.length-1,step:1,value:s,onChange:e=>n(bE[Number(e.target.value)]),"aria-label":`Thinking level`,"aria-valuetext":e,className:`w-full accent-amber-500`}),(0,k.jsxs)(`div`,{className:`mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,children:[(0,k.jsx)(`span`,{children:bE[0]}),(0,k.jsx)(`span`,{children:bE[bE.length-1]})]})]})]})}function mD(e){let{model:t,models:n,thinkingLevel:r,modelSupportsReasoning:i,isStreaming:a,contextUsage:o,sessionUsage:s,isCompacting:c}=e;return(0,k.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,k.jsxs)(`select`,{value:t,onChange:t=>{let r=n.find(e=>`${e.provider}/${e.id}`===t.target.value);r&&e.onSetModel(r.provider,r.id)},disabled:a,className:`max-w-64 rounded-md border border-zinc-300 bg-white px-2 py-1 font-mono text-xs text-zinc-700 outline-none hover:border-zinc-400 disabled:opacity-50 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-300 dark:hover:border-zinc-600`,children:[!n.some(e=>`${e.provider}/${e.id}`===t)&&(0,k.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,k.jsxs)(`option`,{value:`${e.provider}/${e.id}`,children:[e.provider,`/`,e.id]},`${e.provider}/${e.id}`))]}),i&&(0,k.jsx)(pD,{thinkingLevel:r,isStreaming:a,onSetThinking:e.onSetThinking}),(0,k.jsxs)(`button`,{type:`button`,onClick:e.onCompact,disabled:a||c,title:o?.tokens==null?`Click to compact the conversation context`:`${o.tokens.toLocaleString()} / ${o.contextWindow.toLocaleString()} tokens — click to compact`,className:`ml-auto flex items-center gap-1.5 rounded-md border border-zinc-300 px-2 py-1 font-mono text-xs text-zinc-500 hover:border-zinc-400 disabled:opacity-50 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600`,children:[(0,k.jsx)(fD,{usage:o}),c?`compacting…`:o?.percent==null?`context`:`${Math.round(o.percent)}%`]}),(0,k.jsx)(dD,{usage:s,analysisOpen:e.analysisOpen,onToggleAnalysis:e.onToggleAnalysis})]})}var hD=`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`,gD=`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`;function _D({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,k.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto p-6`,children:(0,k.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,k.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),C?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`h1`,{className:`mb-3 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model is available.`}),(0,k.jsxs)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:[`Credentials are configured, so this is not a missing key: `,(0,k.jsx)(`code`,{children:`allowedModels`}),` in your configuration leaves nothing to choose from. Widen it, or remove it, then restart.`]})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model provider is set up yet. Add one to start chatting.`}),(0,k.jsx)(`div`,{className:`mb-4 flex gap-1 rounded-lg bg-zinc-100 p-1 text-xs dark:bg-zinc-800`,children:[`known`,`custom`].map(e=>(0,k.jsx)(`button`,{type:`button`,onClick:()=>s(e),className:`flex-1 rounded-md px-2 py-1.5 ${o===e?`bg-white font-medium text-zinc-800 shadow-sm dark:bg-zinc-900 dark:text-zinc-100`:`text-zinc-500 dark:text-zinc-400`}`,children:e===`known`?`Provider API key`:`OpenAI-compatible endpoint`},e))}),o===`known`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`label`,{htmlFor:`onboarding-provider`,className:gD,children:`Provider`}),(0,k.jsx)(`select`,{id:`onboarding-provider`,value:c,onChange:e=>l(e.target.value),className:`${hD} mb-3`,children:a.map(e=>(0,k.jsxs)(`option`,{value:e.id,children:[e.name,e.configured?` (already configured)`:``]},e.id))})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`label`,{htmlFor:`onboarding-name`,className:gD,children:`Name`}),(0,k.jsx)(`input`,{id:`onboarding-name`,value:p,onChange:e=>m(e.target.value),placeholder:`corp`,className:`${hD} mb-3`}),(0,k.jsx)(`label`,{htmlFor:`onboarding-url`,className:gD,children:`Base URL`}),(0,k.jsx)(`input`,{id:`onboarding-url`,value:h,onChange:e=>g(e.target.value),placeholder:`https://llm.corp.example/v1`,className:`${hD} mb-3`}),(0,k.jsx)(`label`,{htmlFor:`onboarding-model`,className:gD,children:`Model id`}),(0,k.jsx)(`input`,{id:`onboarding-model`,value:_,onChange:e=>v(e.target.value),placeholder:`gpt-oss-120b`,className:`${hD} mb-3`})]}),(0,k.jsx)(`label`,{htmlFor:`onboarding-key`,className:gD,children:`API key`}),(0,k.jsx)(`input`,{id:`onboarding-key`,type:`password`,autoComplete:`off`,value:u,onChange:e=>f(e.target.value),placeholder:`sk-…`,className:hD}),o===`custom`&&(0,k.jsxs)(`fieldset`,{className:`mt-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,k.jsx)(`legend`,{className:`px-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Compatibility`}),(0,k.jsxs)(`label`,{className:`flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5`}),(0,k.jsxs)(`span`,{children:[`Server understands the `,(0,k.jsx)(`code`,{children:`developer`}),` role. Uncheck for vLLM, SGLang and most corporate gateways — the system prompt is then sent as a `,(0,k.jsx)(`code`,{children:`system`}),` message.`]})]}),(0,k.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`mt-0.5`}),(0,k.jsxs)(`span`,{children:[`Server accepts `,(0,k.jsx)(`code`,{children:`reasoning_effort`}),`. Uncheck if it rejects unknown fields.`]})]})]}),(0,k.jsx)(`button`,{type:`submit`,className:`mt-4 w-full rounded-md bg-zinc-800 px-3 py-2 text-sm font-medium text-white hover:bg-zinc-700 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,children:`Save and start`})]}),i.map((e,t)=>(0,k.jsx)(`p`,{className:`mt-3 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:e},t)),(0,k.jsxs)(`p`,{className:`mt-4 text-center text-xs text-zinc-400 dark:text-zinc-600`,children:[t.agentDir?`Stored in ${t.agentDir}. `:``,`Provider environment variables work too, as does `,(0,k.jsx)(`code`,{children:`pi-outpost login`}),`.`]})]})})}var vD=`application/x-pi-outpost-file`,yD=`application/x-pi-outpost-read-only-file`,bD=`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`,xD={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 SD(e,t){return t?Object.keys(t).filter(t=>t.startsWith(`${e}/`)).length:0}function CD(e){return e===`directory`||e===`symlink-directory`}function wD(e,t){return t===void 0?!1:t===null?!0:t===``?!1:e!==t&&!e.startsWith(`${t}/`)}function TD({dir:e,depth:t,creation:n}){let[r,i]=(0,d.useState)(``),a=(0,d.useRef)(null),o=n.localError??n.serverError;return(0,d.useEffect)(()=>{a.current?.focus()},[]),(0,k.jsxs)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5`,children:[(0,k.jsx)(`input`,{ref:a,value:r,onChange:e=>i(e.target.value),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),n.submit(e,r)):t.key===`Escape`&&(t.preventDefault(),n.cancel())},onBlur:()=>{o===null&&n.cancel()},placeholder:`name, or name/ for a folder`,"aria-label":`New file or folder in ${e===``?`the workspace root`:e}`,spellCheck:!1,className:`w-full rounded border border-zinc-300 bg-white px-1 py-0.5 text-xs text-zinc-800 outline-none focus:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),o!==null&&(0,k.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:o})]})}function ED({path:e,name:t,depth:n,rename:r}){let[i,a]=(0,d.useState)(t),o=(0,d.useRef)(null),s=r.localError??r.serverError;return(0,d.useEffect)(()=>{o.current?.focus(),o.current?.select()},[]),(0,k.jsxs)(`div`,{style:{paddingLeft:n*12+16},className:`py-0.5`,children:[(0,k.jsx)(`input`,{ref:o,value:i,disabled:r.pending,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`&&!r.pending?(t.preventDefault(),r.submit(e,i)):t.key===`Escape`&&(t.preventDefault(),r.cancel())},onBlur:()=>{s===null&&r.cancel()},"aria-label":`Rename ${t}`,spellCheck:!1,className:`w-full rounded border border-zinc-300 bg-white px-1 py-0.5 text-xs text-zinc-800 outline-none focus:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),s!==null&&(0,k.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:s})]})}function DD({path:e,depth:t,...n}){let r=n.tree[e],i=n.creation?.openIn===e?(0,k.jsx)(TD,{dir:e,depth:t,creation:n.creation}):null;return r===void 0?i:r===`loading`?(0,k.jsxs)(k.Fragment,{children:[i,(0,k.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`loading…`})]}):`error`in r?(0,k.jsxs)(k.Fragment,{children:[i,(0,k.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-red-600 dark:text-red-400`,children:r.error})]}):r.length===0?(0,k.jsxs)(k.Fragment,{children:[i,i===null&&(0,k.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`empty`})]}):(0,k.jsxs)(k.Fragment,{children:[i,r.map(r=>(0,k.jsx)(OD,{parentPath:e,entry:r,depth:t,...n},r.name))]})}function OD({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=wD(c,r.writableRoot),u=r.fileOperation?.status===`pending`;if(CD(t.type)){let e=!l&&!u,d=e=>e.includes(yD)?r.onCopyFile===void 0?null:`copy`:r.onMoveFile===void 0?null:`move`;return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${o?`bg-blue-50 ring-1 ring-blue-400 dark:bg-blue-950/40`:``}`,onDragOver:t=>{if(!e||!Array.from(t.dataTransfer.types).includes(vD))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(vD),i=n?d(Array.from(t.dataTransfer.types)):null;i!==null&&(t.preventDefault(),t.stopPropagation(),s(!1),i===`copy`?r.onCopyFile?.(n,c):r.onMoveFile?.(n,c))},children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>{let e=!i;a(e),e&&r.tree[c]===void 0&&r.onExpand(c)},style:{paddingLeft:n*12},className:`flex min-w-0 flex-1 items-center gap-1 rounded py-0.5 text-left`,children:[(0,k.jsx)(`span`,{className:`w-3 shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:i?`▾`:`▸`}),(0,k.jsx)(`span`,{title:t.name,className:`truncate ${l?`text-zinc-400 dark:text-zinc-600`:`text-zinc-700 dark:text-zinc-300`}`,children:t.name}),!i&&SD(c,r.gitFiles)>0&&(0,k.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-amber-100 px-1 font-mono text-[10px] font-bold text-amber-700 dark:bg-amber-950/60 dark:text-amber-400`,title:`${SD(c,r.gitFiles)} changed file(s) inside`,children:SD(c,r.gitFiles)})]}),r.creation&&!l&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>{a(!0),r.tree[c]===void 0&&r.onExpand(c),r.creation?.start(c)},title:`New file or folder here`,"aria-label":`New file or folder in ${t.name}`,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs text-zinc-400 hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 [@media(hover:hover)]:opacity-0`,children:`+`})]}),i&&(0,k.jsx)(DD,{path:c,depth:n+1,...r})]})}let f=c===r.openFilePath,p=r.gitFiles?.[c],m=r.attachedPaths?.includes(c)??!1,h=t.type===`file`,g=h||t.type===`symlink-file`,_=h&&!l,v=h&&(l?r.onCopyFile!==void 0:r.onMoveFile!==void 0);return r.rename?.path===c?(0,k.jsx)(ED,{path:c,name:t.name,depth:n,rename:r.rename}):(0,k.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${f?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,k.jsx)(`button`,{type:`button`,draggable:v&&!u,onDragStart:e=>{!v||u||(e.dataTransfer.effectAllowed=l?`copy`:`move`,e.dataTransfer.setData(vD,c),l&&e.dataTransfer.setData(yD,`copy`))},onClick:()=>r.onSelectFile(c),style:{paddingLeft:n*12+16},className:`flex min-w-0 flex-1 items-center py-0.5 text-left`,children:(0,k.jsx)(`span`,{title:t.name,className:`truncate ${l?`text-zinc-400 dark:text-zinc-600`:`text-zinc-600 dark:text-zinc-400`}`,children:t.name})}),g&&r.onOpenNative&&(0,k.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>r.onOpenNative?.(c),title:`Open with the associated application`,"aria-label":`Open ${t.name} with the associated application`,className:bD,children:`↗`}),_&&r.onRenameFile&&(0,k.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>r.rename?.start(c),title:`Rename file`,"aria-label":`Rename ${t.name}`,className:bD,children:`✎`}),_&&r.onDeleteFile&&(0,k.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(`Delete "${t.name}" permanently?`)&&r.onDeleteFile?.(c)},title:`Delete file`,"aria-label":`Delete ${t.name}`,className:`${bD} hover:text-red-600 dark:hover:text-red-400`,children:`×`}),r.onToggleAttachPath&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>r.onToggleAttachPath?.(c),title:m?`Remove this file from the prompt`:`Reference this file in the prompt`,"aria-label":`${m?`Remove`:`Reference`} ${t.name} in the prompt`,"aria-pressed":m,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:hover:bg-zinc-700 ${m?`font-bold text-blue-600 dark:text-blue-400`:`text-zinc-400 dark:text-zinc-600 [@media(hover:hover)]:opacity-0`}`,children:`@`}),p&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>(r.onSelectDiff??r.onSelectFile)(c),title:`Show uncommitted diff`,"aria-label":`Show diff of ${t.name}`,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs font-bold hover:bg-zinc-200 dark:hover:bg-zinc-700 ${xD[p].className}`,children:xD[p].label})]})}function kD(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 AD(e){let t=kD(e);return`error`in t?t:t.kind===`directory`?{error:`That is a folder name`}:{name:t.name}}function jD(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===MD(a.dir,a.name)?e.createError.message:null,g=e.created??null;(0,d.useEffect)(()=>{a===null||g===null||g===MD(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=kD(n);if(`error`in r){i(r.error);return}i(null),o({dir:t,name:r.name});let a=MD(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=AD(n);if(`error`in r){u(r.error);return}u(null),p(t),e.onRenameFile?.(t,r.name)}}:void 0,b=!wD(``,e.writableRoot);return(0,k.jsxs)(`div`,{className:`text-sm`,children:[e.fileOperation?.status===`error`&&e.fileOperation.operation!==`rename_file`&&(0,k.jsx)(`p`,{role:`alert`,className:`mb-1 rounded bg-red-50 px-2 py-1 text-xs text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:e.fileOperation.message}),v&&b&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>v.start(``),"aria-label":`New file or folder in the workspace root`,className:`mb-1 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`}),(0,k.jsx)(DD,{path:``,depth:0,...e,...v?{creation:v}:{},...y?{rename:y}:{}})]})}function MD(e,t){return e===``?t:`${e}/${t}`}function ND({tree:e,openFile:t,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onSelectFile:o,onSelectDiff:s,onToggleAttachPath:c,onCreateFile:l,onCreateDirectory:u,onOpenNative:f,onRenameFile:p,onDeleteFile:m,onMoveFile:h,onCopyFile:g,fileOperation:_,createError:v,created:y}){let b=OE(SE);return(0,d.useEffect)(()=>{e[``]===void 0&&a(``)},[]),(0,k.jsxs)(`aside`,{"aria-label":`Files`,style:{width:b.width},className:`relative flex shrink-0 flex-col border-r border-zinc-200 dark:border-zinc-800`,children:[(0,k.jsx)(`div`,{className:`border-b border-zinc-200 px-3 py-2 text-xs font-semibold uppercase text-zinc-400 dark:border-zinc-800 dark:text-zinc-600`,children:`Files`}),(0,k.jsx)(`div`,{className:`flex-1 overflow-auto p-2`,children:(0,k.jsx)(jD,{tree:e,openFilePath:t?.path,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onSelectFile:o,onSelectDiff:s,onToggleAttachPath:c,onCreateFile:l,onCreateDirectory:u,onOpenNative:f,onRenameFile:p,onDeleteFile:m,onMoveFile:h,onCopyFile:g,fileOperation:_,createError:v,created:y})}),(0,k.jsx)(kE,{label:`Resize Files sidebar`,width:b.width,config:SE,separatorProps:b.separatorProps})]})}function PD({title:e,onSubmit:t}){let[n,r]=(0,d.useState)(``);return(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,k.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),n.trim()&&t(n.trim())},className:`w-full max-w-sm rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,k.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),(0,k.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`This server requires an access token.`}),(0,k.jsx)(`label`,{htmlFor:`pi-outpost-token`,className:`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`,children:`Access token`}),(0,k.jsx)(`input`,{id:`pi-outpost-token`,name:`token`,type:`password`,autoComplete:`off`,spellCheck:!1,value:n,onChange:e=>r(e.target.value),placeholder:`paste the token…`,className:`mb-3 w-full rounded-md border border-zinc-300 bg-white px-2 py-1.5 font-mono text-sm outline-none focus:border-zinc-500 dark:border-zinc-700 dark:bg-zinc-950 dark:focus:border-zinc-500`}),(0,k.jsx)(`button`,{type:`submit`,disabled:!n.trim(),className:`w-full rounded-md border border-emerald-300 px-2 py-1.5 text-sm text-emerald-700 hover:border-emerald-500 disabled:opacity-50 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600`,children:`Connect`}),(0,k.jsxs)(`p`,{className:`mt-3 text-center text-xs text-zinc-400 dark:text-zinc-600`,children:[`Ask the operator for the token, or open the link containing `,(0,k.jsx)(`code`,{children:`?token=…`})]})]})})}var FD=`pi-outpost:token`;function ID(){let e=null;try{let t=new URL(window.location.href);return e=t.searchParams.get(`token`),e&&(localStorage.setItem(FD,e),t.searchParams.delete(`token`),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)),localStorage.getItem(FD)}catch{return e}}function LD(){try{return localStorage.getItem(FD)}catch{return null}}function RD(e){try{localStorage.setItem(FD,e)}catch{}}function zD(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 BD={connected:!1,authRequired:!1,brandingReady:!1,branding:{},sessionId:``,model:``,thinkingLevel:`off`,modelSupportsReasoning:!1,models:[],commands:[],sessions:null,sessionSearch:null,tree:null,isStreaming:!1,items:[],queue:{steering:[],followUp:[]},errors:[],contextUsage:null,isCompacting:!1,dialogQueue:[],notifications:[],statuses:{},widgets:{},editorPrefill:null,fileTree:{},openFile:null,fileSearch:null,createError:null,created:null,fileOperation:null,extensionPaths:[],sandbox:null,versions:null,gitAvailable:!1,credentials:null,gitStatus:null,gitDiff:null,gitLog:null,gitShow:null,gitFileHistory:null,gitFileDiff:null};function VD(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 HD(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 UD(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,queue:{steering:[],followUp:[]},errors:[],contextUsage:t.contextUsage??null,isCompacting:!1,dialogQueue:[],notifications:[],statuses:{},widgets:{},extensionTitle:void 0,editorPrefill:null,tree:null,fileTree:{},fileOperation:null,writableRoot:t.writableRoot,gitAvailable:t.gitAvailable===!0,credentials:t.credentials??null,extensionPaths:t.extensionPaths??[],sandbox:t.sandbox??null,versions:t.versions??null}}function WD(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===`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`)return{...e,fileTree:{...e.fileTree,[t.path]:`loading`}};if(t.type===`file_read_started`)return{...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};let n=t.message;switch(n.type){case`hello`:case`session_replaced`:case`update_config_ack`:return UD(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`user`:return{...e,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:VD(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:VD(e.items,()=>n.item)};case`custom_message`:return{...e,items:[...e.items,n.item]};case`tool_start`:return{...e,items:HD(e.items,n.toolCallId,n.toolName,{toolName:n.toolName,args:n.args,running:!0,callHtml:n.callHtml})};case`tool_update`:return{...e,items:HD(e.items,n.toolCallId,`tool`,{output:n.text})};case`tool_end`:return{...e,items:HD(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]};case`directory_listing`:return{...e,fileTree:{...e.fileTree,[n.path]:n.entries},...n.requestId.startsWith(`create:`)?{created:n.path,createError:null}:{}};case`file_content`:return e.openFile?.status!==`loading`||e.openFile.requestId!==n.requestId?e:{...e,openFile:{status:`loaded`,path:n.path,content:n.content,size:n.size,mtimeMs:n.mtimeMs}};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,fileTree:{...e.fileTree,[n.path]:{error:n.message}}};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:{...e,openFile:{status:`error`,path:n.path,message:n.message}};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||!zD(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 GD(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 KD=12e4,qD=4401;function JD(e=``,t,n=!1){let[r,i]=(0,d.useReducer)(WD,BD),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?LD():ID()));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.useRef)(!1),_=(0,d.useRef)(!1),v=(0,d.useRef)(!1),y=(0,d.useCallback)(()=>{if(g.current){if(_.current){v.current=!0;return}_.current=!0,h({type:`git_status`,requestId:`git:${crypto.randomUUID()}`})}},[h]),b=(0,d.useCallback)(()=>{_.current=!1,v.current&&(v.current=!1,y())},[y]);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(GD(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 mT(t.message,t.reason));return}if(t.type===`file_changed`){let e=t.path.lastIndexOf(`/`),n=e<0?``:t.path.slice(0,e);console.log(`[file_changed] path=`,t.path,`parentPath=`,n,`fileTree keys=`,Object.keys(l.current).join(`,`)),l.current[n]===void 0?console.log(`[file_changed] parent NOT in fileTree, skipping refresh`):(console.log(`[file_changed] parent found in fileTree, refreshing`),i({type:`dir_list_started`,path:n}),h({type:`list_directory`,path:n,requestId:`dir:${crypto.randomUUID()}`}));let r=u.current;if(r?.status===`loaded`&&r.path===t.path){let e=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:t.path,requestId:e}),h({type:`read_file`,path:t.path,requestId:e})}f.current===t.path&&h({type:`git_diff`,path:t.path,requestId:`gitdiff:${crypto.randomUUID()}`}),y();return}if((t.type===`hello`||t.type===`session_replaced`)&&(g.current=t.gitAvailable===!0,t.type===`hello`&&y()),t.type===`agent_end`&&y(),(t.type===`git_status`||t.type===`git_error`&&t.requestId.startsWith(`git:`))&&b(),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})}if(i({type:`server`,message:t}),t.type===`session_replaced`){let e=`dir:${crypto.randomUUID()}`;i({type:`dir_list_started`,path:``}),h({type:`list_directory`,path:``,requestId:e})}},o.onclose=e=>{if(a.current===o){_.current=!1,v.current=!1;for(let e of p.current.values())e.reject(new mT(`The connection dropped before the upload finished`));if(p.current.clear(),e.code===qD){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,y,b,o]),{state:r,authToken:c.current,submitToken:e=>{RD(e),c.current=e,i({type:`auth_retrying`}),s(e=>e+1)},prompt:(e,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=>{i({type:`dir_list_started`,path:e}),h({type:`list_directory`,path:e,requestId:`dir:${crypto.randomUUID()}`})},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 mT(`the workspace is read-only`,`denied`));let r=a.current;if(!r||r.readyState!==WebSocket.OPEN)return Promise.reject(new mT(`not connected to the server`));let i=n?`${n}/${pT}`:pT,o=`upload:${crypto.randomUUID()}`;return new Promise((n,r)=>{let a=window.setTimeout(()=>{p.current.delete(o)&&r(new mT(`the upload timed out`))},KD),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:y,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}),updateConfig:e=>h({type:`update_config`,sandbox:e})}}var YD=(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:te,dismissNotification:oe,listDirectory:O,readFile:A,writeFile:se,createFile:ce,createDirectory:le,uploadFile:j,openNative:ue,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:Oe,declareProvider:ke,updateConfig:Ae}=JD(e,r,a),[je,Me]=(0,d.useState)(!1),[Ne,Pe]=(0,d.useState)([]),[Fe,Ie]=(0,d.useState)([]),[Le,Re]=(0,d.useState)(null),[ze,Be]=(0,d.useState)(null),[Ve,He]=(0,d.useState)(null),[M,Ue]=(0,d.useState)(!1),We=(0,d.useRef)([]),N=(0,d.useRef)(null),Ge=(0,d.useRef)(null),[Ke,qe]=(0,d.useState)(!1),[Je,Ye]=(0,d.useState)(()=>{try{return localStorage.getItem(`pi-outpost:hide-tools`)===`1`}catch{return!1}});function Xe(){Ye(e=>{try{localStorage.setItem(`pi-outpost:hide-tools`,e?`0`:`1`)}catch{}return!e})}let[Ze,Qe]=(0,d.useState)(!1),[$e,et]=(0,d.useState)([]),[tt,nt]=(0,d.useState)([]),rt=(0,d.useRef)(0),it=(0,d.useRef)(0),[at,ot]=(0,d.useState)(0);async function st(e){let t=[...e],n=t.filter(vT).map(e=>({id:`${rt.current++}`,name:e.name}));n.length>0&&nt(e=>[...e,...n]),it.current===0&&et([]),it.current++;try{let{attachments:e,errors:n}=await ET(t,j);e.length>0&&Pe(t=>[...t,...e]),n.length>0&&et(e=>[...e,...n])}finally{if(it.current--,n.length>0){let e=new Set(n.map(e=>e.id));nt(t=>t.filter(t=>!e.has(t.id)))}}}(0,d.useEffect)(()=>{We.current=Ne},[Ne]),(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`&&ie(n);if(N.current!==n&&(N.current=n,Ge.current=null,Pe(e=>e.filter(e=>e.source!==`preview`)),Re(null),Be(null),He(null)),Ge.current===n)return;let a=!1;async function o(){let t=ne(n)?ze===n?await PT(n,ae(e,n,c)):null:re(n)?Ve===n?OT(n):null:i||r?DT(n):null;if(!(a||t===null||N.current!==n||Ge.current===n)){if(typeof t==`string`){Re(t);return}Re(null),Pe(e=>LT(e,t))}}return o(),()=>{a=!0}},[s.openFile,e,c,ze,Ve]);function ct(){N.current=null,Ge.current=null,he()}let lt=(0,d.useMemo)(()=>[...Ne.filter(e=>e.kind===`path`).map(e=>e.data),...Fe],[Ne,Fe]);function ut(e){let t=We.current.findIndex(t=>t.kind===`path`&&t.data===e);t>=0?dt(t):Fe.includes(e)||Pe(t=>IT(t,e))}function dt(e){let t=We.current[e];t?.source===`preview`&&(Ge.current=t.previewPath??N.current,Re(null)),Pe(t=>RT(t,e))}function ft(e,t){u(e,t),Pe([]),et([]),Re(null),M||ct()}function pt(e){e.preventDefault(),ot(0),e.dataTransfer.files.length>0&&st(Array.from(e.dataTransfer.files))}let{theme:mt,toggle:ht,setTheme:gt}=y(s.branding.defaultTheme??`system`,s.branding.allowThemeToggle!==!1,o,n);(0,d.useImperativeHandle)(i,()=>({setTheme:gt}),[gt]);let _t=(0,d.useRef)(null),vt=(0,d.useRef)(null),yt=(0,d.useRef)(!0);function bt(){let e=_t.current;e&&(yt.current=e.scrollHeight-e.scrollTop-e.clientHeight<120)}(0,d.useEffect)(()=>{yt.current&&vt.current?.scrollIntoView({behavior:`smooth`})},[s.items]);let xt=(0,d.useMemo)(()=>Lw(s.items),[s.items]),St=(0,d.useMemo)(()=>Ze?qw(s.items):null,[Ze,s.items]),Ct=(0,d.useMemo)(()=>G_({readFile:e=>{qe(!1),A(e)},fetchGitFileHistory:e=>Ce(e),fetchGitDiff:e=>{qe(!0),A(e)},searchFiles:e=>ge(e)}),[A,Ce,ge]),wt=(0,d.useCallback)(()=>Ye(!1),[]),{jumpToItem:Tt,highlightIndex:Et}=fT({items:s.items,scrollerRef:_t,hideTools:Je,onShowTools:wt,stickToBottom:yt});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,k.jsx)(p.Provider,{value:mt,children:(0,k.jsx)(PD,{title:s.branding.title,onSubmit:l})}):s.credentials&&!s.credentials.usableModel?(0,k.jsx)(p.Provider,{value:mt,children:(0,k.jsx)(_D,{title:s.branding.title,credentials:s.credentials,onSetCredential:Oe,onDeclareProvider:ke,errors:s.errors})}):(0,k.jsxs)(p.Provider,{value:mt,children:[(0,k.jsxs)(`div`,{className:`relative flex h-full`,onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&ot(e=>e+1)},onDragLeave:()=>ot(e=>Math.max(0,e-1)),onDragOver:e=>e.preventDefault(),onDrop:pt,children:[at>0&&(0,k.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-40 flex items-center justify-center border-2 border-dashed bg-white/70 backdrop-blur-sm dark:bg-zinc-950/70`,style:{borderColor:`var(--accent, #3b82f6)`},children:(0,k.jsx)(`p`,{className:`text-lg font-medium text-zinc-700 dark:text-zinc-200`,children:`Drop files to attach (images, documents & text)`})}),je&&(0,k.jsx)(ND,{tree:s.fileTree,openFile:s.openFile,writableRoot:s.writableRoot,gitFiles:s.gitStatus?.files,attachedPaths:lt,onExpand:O,onSelectFile:e=>{qe(!1),A(e)},onSelectDiff:e=>{qe(!0),A(e)},onToggleAttachPath:ut,onCreateFile:e=>{qe(!1),ce(e)},onCreateDirectory:le,onOpenNative:ue,onRenameFile:de,onDeleteFile:fe,onMoveFile:pe,onCopyFile:me,fileOperation:s.fileOperation,createError:s.createError,created:s.created}),(0,k.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[(0,k.jsx)(lD,{title:s.branding.title,sessions:s.sessions,sessionSearch:s.sessionSearch,sessionId:s.sessionId,tree:s.tree,isStreaming:s.isStreaming,connected:s.connected,theme:mt,showThemeToggle:s.branding.allowThemeToggle!==!1,statuses:s.statuses,sidebarOpen:je,hideTools:Je,onToggleSidebar:()=>Me(!je),onToggleHideTools:Xe,onToggleTheme:ht,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,sandbox:s.sandbox,versions:s.versions,onUpdateConfig:Ae,onFetchGitLog:be,onShowCommit:xe}),(0,k.jsxs)(`div`,{className:`relative z-0 flex min-h-0 flex-1 flex-col`,children:[s.openFile&&(0,k.jsx)(_E,{file:s.openFile,writableRoot:s.writableRoot,isStreaming:s.isStreaming,onDirtyChange:Ue,gitState:s.gitStatus?.files[s.openFile.path],initialShowGitDiff:Ke,gitDiff:s.gitDiff,onFetchGitDiff:ve,onClearGitDiff:ye,gitAvailable:s.gitAvailable,onOpenGitHistory:Ce,onClose:ct,onReload:A,onSave:se,serverUrl:e,token:c,onImageLoad:Be,onPdfLoad:He},s.openFile.path),s.gitFileHistory&&(0,k.jsx)(UE,{history:s.gitFileHistory,diff:s.gitFileDiff,dirty:s.gitStatus?.files[s.gitFileHistory.path]!==void 0,onFetchDiff:Te,onClearDiff:Ee,onClose:we}),s.gitShow&&(0,k.jsx)(yE,{show:s.gitShow,onClose:Se}),St&&(0,k.jsx)(uT,{analysis:St,onJump:Tt,onClose:()=>Qe(!1)}),(0,k.jsx)(`main`,{ref:_t,onScroll:bt,className:`flex-1 overflow-y-auto ${Ze?`md:pr-[26rem]`:``}`,children:(0,k.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-3 px-4 py-6`,children:[s.items.length===0&&(0,k.jsxs)(`div`,{className:`mt-24 text-center text-zinc-500 dark:text-zinc-600`,children:[(0,k.jsx)(`div`,{className:`mb-2 text-4xl`,children:s.branding.title??`π`}),(0,k.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,k.jsx)(`div`,{"data-item-index":n,className:`flex flex-col gap-3 rounded-lg transition-shadow ${Et===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,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(De,{item:t,canEdit:!s.isStreaming&&s.connected,onEdit:ee}),e&&(0,k.jsx)(`div`,{className:`flex justify-end px-4`,children:(0,k.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,k.jsx)(`span`,{className:`inline-block h-4 w-4 animate-spin rounded-full border-[3px] border-zinc-300 border-t-blue-500 dark:border-zinc-600 dark:border-t-blue-400 motion-reduce:animate-pulse`}),(0,k.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`working…`})]})})]}))}return t.kind===`tool`?Je?null:i((0,k.jsx)(Pw,{item:t,dispatch:Ct}),t.toolCallId?`${s.sessionId}:${t.toolCallId}`:r):t.kind===`custom`?i((0,k.jsx)(Fw,{item:t})):t.blocks.length===0&&!t.errorMessage?(0,k.jsx)(`div`,{"data-item-index":n,className:`sr-only`,"aria-hidden":!0},r):i((0,k.jsx)(H_,{item:t,serverUrl:e,token:c,onOpenFile:e=>{qe(!1),A(e)}}))}),(s.queue.steering.length>0||s.queue.followUp.length>0)&&(0,k.jsxs)(`div`,{className:`rounded-lg border border-dashed border-zinc-300 px-3 py-2 text-xs text-zinc-500 dark:border-zinc-700`,children:[s.queue.steering.map((e,t)=>(0,k.jsxs)(`div`,{children:[`⏩ steering: `,e]},`s${t}`)),s.queue.followUp.map((e,t)=>(0,k.jsxs)(`div`,{children:[`⏭ follow-up: `,e]},`f${t}`))]}),$e.map((e,t)=>(0,k.jsx)(`div`,{className:`rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:e},`att${t}`)),Le&&(0,k.jsx)(`div`,{className:`rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:Le}),s.errors.map((e,t)=>(0,k.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e},t)),(0,k.jsx)(`div`,{ref:vt})]})})]}),(0,k.jsx)(`footer`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,k.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,k.jsx)(fE,{widgets:s.widgets,placement:`aboveEditor`}),(0,k.jsx)(KT,{isStreaming:s.isStreaming,connected:s.connected,commands:s.commands,fileSearch:s.fileSearch,prefill:s.editorPrefill,attachments:Ne,pendingUploads:tt,onAttach:e=>void st(e),onMentionPaths:Ie,onRemoveAttachment:dt,onSend:ft,onAbort:f,onSearchFiles:ge,onClearFileSearch:_e}),(0,k.jsx)(fE,{widgets:s.widgets,placement:`belowEditor`}),(0,k.jsx)(mD,{model:s.model,models:s.models,thinkingLevel:s.thinkingLevel,modelSupportsReasoning:s.modelSupportsReasoning,isStreaming:s.isStreaming,contextUsage:s.contextUsage,sessionUsage:xt,analysisOpen:Ze,onToggleAnalysis:()=>Qe(e=>!e),isCompacting:s.isCompacting,onSetModel:m,onSetThinking:h,onCompact:D})]})})]})]}),s.dialogQueue[0]&&(0,k.jsx)(nE,{request:s.dialogQueue[0],onRespond:te}),(0,k.jsx)(aE,{notifications:s.notifications,onDismiss:oe})]})});(0,f.createRoot)(document.getElementById(`root`)).render((0,k.jsx)(d.StrictMode,{children:(0,k.jsx)(YD,{})}));export{i as a,ae as i,j as n,O as r,pc as t};
|