claude-code-session-manager 0.119.1 → 0.120.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentLibrary-BpW0pGgk.js → AgentLibrary-LBg3mVL8.js} +1 -1
- package/dist/assets/{Button-DZX5guWb.js → Button-C4BN5ISR.js} +1 -1
- package/dist/assets/{DataModel-WG4pG_4z.js → DataModel-CHhjk61s.js} +1 -1
- package/dist/assets/{History-D58whvn_.js → History-CL-T6Lv3.js} +1 -1
- package/dist/assets/{Hooks-DCI9ezg4.js → Hooks-ByWVgXIf.js} +1 -1
- package/dist/assets/{Library-YqMi-vsA.js → Library-QvYVAEmY.js} +1 -1
- package/dist/assets/{ListDetail-ap4W5z_Z.js → ListDetail-FvNe6fo5.js} +1 -1
- package/dist/assets/{McpServers-CT0pBTF8.js → McpServers-C7EmPm8B.js} +1 -1
- package/dist/assets/{Memory-BODDUBy4.js → Memory-nyLR4Yw4.js} +1 -1
- package/dist/assets/{Panel-CeOfUS9B.js → Panel-thElCbLX.js} +1 -1
- package/dist/assets/{Permissions-DyOqpLQx.js → Permissions-FQ9GM6Ca.js} +1 -1
- package/dist/assets/{Plugins-DBXzKjL2.js → Plugins-D9KE7XTI.js} +2 -2
- package/dist/assets/{ProvenanceBadge-C47IX1Q6.js → ProvenanceBadge-lAViG8yV.js} +1 -1
- package/dist/assets/{RemoteMachines-CtkAJvkZ.js → RemoteMachines-AWpARk7N.js} +1 -1
- package/dist/assets/{SaveBar-YMtzcCzP.js → SaveBar-c15EEGB_.js} +1 -1
- package/dist/assets/{Scheduler-BNiYg0YD.js → Scheduler-FvduP1FG.js} +5 -5
- package/dist/assets/{ScopeSwitcher-Dgi8CiDi.js → ScopeSwitcher-BLep1rtB.js} +1 -1
- package/dist/assets/Settings-D1kTUIDB.js +4 -0
- package/dist/assets/{SkillReferenceGraph-CaFsccNI.js → SkillReferenceGraph-_40_f0t3.js} +1 -1
- package/dist/assets/{Skills-BeCMBQ3l.js → Skills-DaTkSOuU.js} +1 -1
- package/dist/assets/{SystemPrompt-C3WmcPEF.js → SystemPrompt-DxNf-soM.js} +1 -1
- package/dist/assets/{TagLibrary-DP4GH7Dr.js → TagLibrary-L6KpBV-x.js} +1 -1
- package/dist/assets/{TiptapBody-CXCMvRr_.js → TiptapBody-C_XjtJ82.js} +1 -1
- package/dist/assets/{Toggle-TY-Wa8hv.js → Toggle-H0rERKNI.js} +1 -1
- package/dist/assets/{ViewTabs-CaacRnp6.js → ViewTabs-ZUWphDat.js} +1 -1
- package/dist/assets/{historyTotals-C28IlVVQ.js → historyTotals-BxFKOztb.js} +1 -1
- package/dist/assets/{index-DdEMkmbi.js → index-B5wj0DEX.js} +8 -8
- package/dist/assets/{index-DAMBm3UN.css → index-Dd7UQabV.css} +1 -1
- package/dist/assets/{settingsSchema-7Yg6dNNB.js → settingsSchema-BRcYkXJN.js} +1 -1
- package/dist/assets/{skillFrontmatter-Dcuys1km.js → skillFrontmatter-DFGp4DST.js} +1 -1
- package/dist/assets/{useAgentsDirWatch-B0H4M-TT.js → useAgentsDirWatch-VvrgalfC.js} +1 -1
- package/dist/assets/{useRemotePeers-Zp9jchCS.js → useRemotePeers-mvXKNEE3.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +11 -8
- package/src/main/crashDiagnostics.cjs +18 -13
- package/src/main/health.cjs +129 -4
- package/src/main/index.cjs +57 -18
- package/src/main/ipcSchemas.cjs +3 -3
- package/src/main/lib/activeSessions.cjs +51 -34
- package/src/main/lib/claude/agentModelResolve.cjs +5 -3
- package/src/main/lib/claude/personaToolScope.cjs +68 -0
- package/src/main/lib/epic/archivedTranscript.cjs +91 -0
- package/src/main/lib/epic/archivedTranscriptMigration.cjs +84 -0
- package/src/main/lib/epic/delegationReadiness.cjs +2 -0
- package/src/main/lib/epic/epicSettle.cjs +21 -5
- package/src/main/lib/epic/epicValidationHook.cjs +7 -0
- package/src/main/lib/git/depHealth.cjs +161 -0
- package/src/main/lib/git/worktreeDeps.cjs +158 -5
- package/src/main/lib/machineProfile.cjs +2 -0
- package/src/main/lib/mcpToolCatalog.cjs +3 -1
- package/src/main/lib/opsRetentionSettings.cjs +183 -0
- package/src/main/lib/prd/prdWorktreeReach.cjs +2 -2
- package/src/main/lib/prd/workTypeLibrary.cjs +7 -3
- package/src/main/lib/process/procGroupRss.cjs +61 -0
- package/src/main/lib/scheduler/queueHistory.cjs +68 -9
- package/src/main/lib/scheduler/runLogRetention.cjs +129 -43
- package/src/main/lib/scheduler/schedulerBatch.cjs +7 -3
- package/src/main/lib/scheduler/staleTmpSweep.cjs +117 -0
- package/src/main/lib/telemetry/auditLog.cjs +51 -6
- package/src/main/lib/telemetry/crashTelemetry.cjs +49 -1
- package/src/main/lib/telemetry/opsErrorLog.cjs +30 -10
- package/src/main/lib/telemetry/telemetryClient.cjs +5 -2
- package/src/main/scheduler/prdParser.cjs +50 -0
- package/src/main/scheduler/prdPaths.cjs +61 -16
- package/src/main/scheduler/reviewLadder.cjs +24 -1
- package/src/main/scheduler.cjs +214 -37
- package/src/main/templates/PRD_AUTHORING.md +2 -2
- package/src/preload/api.d.ts +28 -3
- package/src/preload/index.cjs +7 -0
- package/dist/assets/Settings-B4LuoRnd.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TiptapBody-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TiptapBody-C_XjtJ82.js","./monaco-editor-BsIlgG7c.js","./monaco-editor-Cu5D__1H.css","./Skills-DaTkSOuU.js","./Panel-thElCbLX.js","./ListDetail-FvNe6fo5.js","./skillFrontmatter-DFGp4DST.js","./SaveBar-c15EEGB_.js","./ScopeSwitcher-BLep1rtB.js","./Toggle-H0rERKNI.js","./ProvenanceBadge-lAViG8yV.js","./Library-QvYVAEmY.js","./Button-C4BN5ISR.js","./listSkills-C1aWKf0T.js","./History-CL-T6Lv3.js","./historyTotals-BxFKOztb.js","./RemoteMachines-AWpARk7N.js","./useRemotePeers-mvXKNEE3.js","./Scheduler-FvduP1FG.js","./Settings-D1kTUIDB.js","./settingsSchema-BRcYkXJN.js","./claude-settings-schema-COigsajx.js","./ViewTabs-ZUWphDat.js","./Permissions-FQ9GM6Ca.js","./SystemPrompt-DxNf-soM.js","./Memory-nyLR4Yw4.js","./Plugins-D9KE7XTI.js","./McpServers-C7EmPm8B.js","./Hooks-ByWVgXIf.js","./AgentLibrary-LBg3mVL8.js","./useAgentsDirWatch-VvrgalfC.js","./TagLibrary-L6KpBV-x.js","./DataModel-CHhjk61s.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var bT=Object.defineProperty;var wT=(i,e,t)=>e in i?bT(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var Gi=(i,e,t)=>wT(i,typeof e!="symbol"?e+"":e,t);import{_ as fi}from"./monaco-editor-BsIlgG7c.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const l of r)if(l.type==="childList")for(const p of l.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&n(p)}).observe(document,{childList:!0,subtree:!0});function t(r){const l={};return r.integrity&&(l.integrity=r.integrity),r.referrerPolicy&&(l.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?l.credentials="include":r.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function n(r){if(r.ep)return;r.ep=!0;const l=t(r);fetch(r.href,l)}})();function Pw(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var g_={exports:{}},lf={},v_={exports:{}},wi={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react.production.min.js
|
|
@@ -38,9 +38,9 @@ var bT=Object.defineProperty;var wT=(i,e,t)=>e in i?bT(i,e,{enumerable:!0,config
|
|
|
38
38
|
`+O[ne].replace(" at new "," at ");return o.displayName&&De.includes("<anonymous>")&&(De=De.replace("<anonymous>",o.displayName)),De}while(1<=ne&&0<=_e);break}}}finally{oe=!1,Error.prepareStackTrace=_}return(o=o?o.displayName||o.name:"")?Q(o):""}function Oe(o){switch(o.tag){case 5:return Q(o.type);case 16:return Q("Lazy");case 13:return Q("Suspense");case 19:return Q("SuspenseList");case 0:case 2:case 15:return o=Ce(o.type,!1),o;case 11:return o=Ce(o.type.render,!1),o;case 1:return o=Ce(o.type,!0),o;default:return""}}function Xe(o){if(o==null)return null;if(typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case L:return"Fragment";case N:return"Portal";case F:return"Profiler";case R:return"StrictMode";case ee:return"Suspense";case we:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case te:return(o.displayName||"Context")+".Consumer";case V:return(o._context.displayName||"Context")+".Provider";case he:var h=o.render;return o=o.displayName,o||(o=h.displayName||h.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case ce:return h=o.displayName||null,h!==null?h:Xe(o.type)||"Memo";case ve:h=o._payload,o=o._init;try{return Xe(o(h))}catch{}}return null}function ge(o){var h=o.type;switch(o.tag){case 24:return"Cache";case 9:return(h.displayName||"Context")+".Consumer";case 10:return(h._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return o=h.render,o=o.displayName||o.name||"",h.displayName||(o!==""?"ForwardRef("+o+")":"ForwardRef");case 7:return"Fragment";case 5:return h;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Xe(h);case 8:return h===R?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof h=="function")return h.displayName||h.name||null;if(typeof h=="string")return h}return null}function J(o){switch(typeof o){case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function je(o){var h=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(h==="checkbox"||h==="radio")}function de(o){var h=je(o)?"checked":"value",_=Object.getOwnPropertyDescriptor(o.constructor.prototype,h),A=""+o[h];if(!o.hasOwnProperty(h)&&typeof _<"u"&&typeof _.get=="function"&&typeof _.set=="function"){var O=_.get,H=_.set;return Object.defineProperty(o,h,{configurable:!0,get:function(){return O.call(this)},set:function(ne){A=""+ne,H.call(this,ne)}}),Object.defineProperty(o,h,{enumerable:_.enumerable}),{getValue:function(){return A},setValue:function(ne){A=""+ne},stopTracking:function(){o._valueTracker=null,delete o[h]}}}}function Ie(o){o._valueTracker||(o._valueTracker=de(o))}function Pe(o){if(!o)return!1;var h=o._valueTracker;if(!h)return!0;var _=h.getValue(),A="";return o&&(A=je(o)?o.checked?"true":"false":o.value),o=A,o!==_?(h.setValue(o),!0):!1}function Ye(o){if(o=o||(typeof document<"u"?document:void 0),typeof o>"u")return null;try{return o.activeElement||o.body}catch{return o.body}}function ft(o,h){var _=h.checked;return X({},h,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:_??o._wrapperState.initialChecked})}function rt(o,h){var _=h.defaultValue==null?"":h.defaultValue,A=h.checked!=null?h.checked:h.defaultChecked;_=J(h.value!=null?h.value:_),o._wrapperState={initialChecked:A,initialValue:_,controlled:h.type==="checkbox"||h.type==="radio"?h.checked!=null:h.value!=null}}function Nt(o,h){h=h.checked,h!=null&&S(o,"checked",h,!1)}function mt(o,h){Nt(o,h);var _=J(h.value),A=h.type;if(_!=null)A==="number"?(_===0&&o.value===""||o.value!=_)&&(o.value=""+_):o.value!==""+_&&(o.value=""+_);else if(A==="submit"||A==="reset"){o.removeAttribute("value");return}h.hasOwnProperty("value")?di(o,h.type,_):h.hasOwnProperty("defaultValue")&&di(o,h.type,J(h.defaultValue)),h.checked==null&&h.defaultChecked!=null&&(o.defaultChecked=!!h.defaultChecked)}function mi(o,h,_){if(h.hasOwnProperty("value")||h.hasOwnProperty("defaultValue")){var A=h.type;if(!(A!=="submit"&&A!=="reset"||h.value!==void 0&&h.value!==null))return;h=""+o._wrapperState.initialValue,_||h===o.value||(o.value=h),o.defaultValue=h}_=o.name,_!==""&&(o.name=""),o.defaultChecked=!!o._wrapperState.initialChecked,_!==""&&(o.name=_)}function di(o,h,_){(h!=="number"||Ye(o.ownerDocument)!==o)&&(_==null?o.defaultValue=""+o._wrapperState.initialValue:o.defaultValue!==""+_&&(o.defaultValue=""+_))}var _i=Array.isArray;function Je(o,h,_,A){if(o=o.options,h){h={};for(var O=0;O<_.length;O++)h["$"+_[O]]=!0;for(_=0;_<o.length;_++)O=h.hasOwnProperty("$"+o[_].value),o[_].selected!==O&&(o[_].selected=O),O&&A&&(o[_].defaultSelected=!0)}else{for(_=""+J(_),h=null,O=0;O<o.length;O++){if(o[O].value===_){o[O].selected=!0,A&&(o[O].defaultSelected=!0);return}h!==null||o[O].disabled||(h=o[O])}h!==null&&(h.selected=!0)}}function Pt(o,h){if(h.dangerouslySetInnerHTML!=null)throw Error(t(91));return X({},h,{value:void 0,defaultValue:void 0,children:""+o._wrapperState.initialValue})}function _t(o,h){var _=h.value;if(_==null){if(_=h.children,h=h.defaultValue,_!=null){if(h!=null)throw Error(t(92));if(_i(_)){if(1<_.length)throw Error(t(93));_=_[0]}h=_}h==null&&(h=""),_=h}o._wrapperState={initialValue:J(_)}}function hi(o,h){var _=J(h.value),A=J(h.defaultValue);_!=null&&(_=""+_,_!==o.value&&(o.value=_),h.defaultValue==null&&o.defaultValue!==_&&(o.defaultValue=_)),A!=null&&(o.defaultValue=""+A)}function Se(o){var h=o.textContent;h===o._wrapperState.initialValue&&h!==""&&h!==null&&(o.value=h)}function tt(o){switch(o){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function ht(o,h){return o==null||o==="http://www.w3.org/1999/xhtml"?tt(h):o==="http://www.w3.org/2000/svg"&&h==="foreignObject"?"http://www.w3.org/1999/xhtml":o}var Et,gi=(function(o){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(h,_,A,O){MSApp.execUnsafeLocalFunction(function(){return o(h,_,A,O)})}:o})(function(o,h){if(o.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in o)o.innerHTML=h;else{for(Et=Et||document.createElement("div"),Et.innerHTML="<svg>"+h.valueOf().toString()+"</svg>",h=Et.firstChild;o.firstChild;)o.removeChild(o.firstChild);for(;h.firstChild;)o.appendChild(h.firstChild)}});function Jt(o,h){if(h){var _=o.firstChild;if(_&&_===o.lastChild&&_.nodeType===3){_.nodeValue=h;return}}o.textContent=h}var oi={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Xt=["Webkit","ms","Moz","O"];Object.keys(oi).forEach(function(o){Xt.forEach(function(h){h=h+o.charAt(0).toUpperCase()+o.substring(1),oi[h]=oi[o]})});function un(o,h,_){return h==null||typeof h=="boolean"||h===""?"":_||typeof h!="number"||h===0||oi.hasOwnProperty(o)&&oi[o]?(""+h).trim():h+"px"}function wt(o,h){o=o.style;for(var _ in h)if(h.hasOwnProperty(_)){var A=_.indexOf("--")===0,O=un(_,h[_],A);_==="float"&&(_="cssFloat"),A?o.setProperty(_,O):o[_]=O}}var Ri=X({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Sn(o,h){if(h){if(Ri[o]&&(h.children!=null||h.dangerouslySetInnerHTML!=null))throw Error(t(137,o));if(h.dangerouslySetInnerHTML!=null){if(h.children!=null)throw Error(t(60));if(typeof h.dangerouslySetInnerHTML!="object"||!("__html"in h.dangerouslySetInnerHTML))throw Error(t(61))}if(h.style!=null&&typeof h.style!="object")throw Error(t(62))}}function ai(o,h){if(o.indexOf("-")===-1)return typeof h.is=="string";switch(o){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ni=null;function zi(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var fs=null,Rn=null,Nn=null;function ir(o){if(o=El(o)){if(typeof fs!="function")throw Error(t(280));var h=o.stateNode;h&&(h=Tc(h),fs(o.stateNode,o.type,h))}}function Tr(o){Rn?Nn?Nn.push(o):Nn=[o]:Rn=o}function Dr(){if(Rn){var o=Rn,h=Nn;if(Nn=Rn=null,ir(o),h)for(o=0;o<h.length;o++)ir(h[o])}}function Gs(o,h){return o(h)}function Fn(){}var Jn=!1;function nr(o,h,_){if(Jn)return o(h,_);Jn=!0;try{return Gs(o,h,_)}finally{Jn=!1,(Rn!==null||Nn!==null)&&(Fn(),Dr())}}function Hn(o,h){var _=o.stateNode;if(_===null)return null;var A=Tc(_);if(A===null)return null;_=A[h];e:switch(h){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(A=!A.disabled)||(o=o.type,A=!(o==="button"||o==="input"||o==="select"||o==="textarea")),o=!A;break e;default:o=!1}if(o)return null;if(_&&typeof _!="function")throw Error(t(231,h,typeof _));return _}var ms=!1;if(a)try{var Rs={};Object.defineProperty(Rs,"passive",{get:function(){ms=!0}}),window.addEventListener("test",Rs,Rs),window.removeEventListener("test",Rs,Rs)}catch{ms=!1}function ho(o,h,_,A,O,H,ne,_e,De){var He=Array.prototype.slice.call(arguments,3);try{h.apply(_,He)}catch(lt){this.onError(lt)}}var sr=!1,rr=null,or=!1,Gt=null,Zn={onError:function(o){sr=!0,rr=o}};function Xi(o,h,_,A,O,H,ne,_e,De){sr=!1,rr=null,ho.apply(Zn,arguments)}function Di(o,h,_,A,O,H,ne,_e,De){if(Xi.apply(this,arguments),sr){if(sr){var He=rr;sr=!1,rr=null}else throw Error(t(198));or||(or=!0,Gt=He)}}function Tt(o){var h=o,_=o;if(o.alternate)for(;h.return;)h=h.return;else{o=h;do h=o,(h.flags&4098)!==0&&(_=h.return),o=h.return;while(o)}return h.tag===3?_:null}function Vr(o){if(o.tag===13){var h=o.memoizedState;if(h===null&&(o=o.alternate,o!==null&&(h=o.memoizedState)),h!==null)return h.dehydrated}return null}function po(o){if(Tt(o)!==o)throw Error(t(188))}function Ta(o){var h=o.alternate;if(!h){if(h=Tt(o),h===null)throw Error(t(188));return h!==o?null:o}for(var _=o,A=h;;){var O=_.return;if(O===null)break;var H=O.alternate;if(H===null){if(A=O.return,A!==null){_=A;continue}break}if(O.child===H.child){for(H=O.child;H;){if(H===_)return po(O),o;if(H===A)return po(O),h;H=H.sibling}throw Error(t(188))}if(_.return!==A.return)_=O,A=H;else{for(var ne=!1,_e=O.child;_e;){if(_e===_){ne=!0,_=O,A=H;break}if(_e===A){ne=!0,A=O,_=H;break}_e=_e.sibling}if(!ne){for(_e=H.child;_e;){if(_e===_){ne=!0,_=H,A=O;break}if(_e===A){ne=!0,A=H,_=O;break}_e=_e.sibling}if(!ne)throw Error(t(189))}}if(_.alternate!==A)throw Error(t(190))}if(_.tag!==3)throw Error(t(188));return _.stateNode.current===_?o:h}function fo(o){return o=Ta(o),o!==null?mo(o):null}function mo(o){if(o.tag===5||o.tag===6)return o;for(o=o.child;o!==null;){var h=mo(o);if(h!==null)return h;o=o.sibling}return null}var Vo=e.unstable_scheduleCallback,Mn=e.unstable_cancelCallback,Da=e.unstable_shouldYield,$a=e.unstable_requestPaint,$i=e.unstable_now,Wn=e.unstable_getCurrentPriorityLevel,Zi=e.unstable_ImmediatePriority,Un=e.unstable_UserBlockingPriority,ar=e.unstable_NormalPriority,qr=e.unstable_LowPriority,$r=e.unstable_IdlePriority,gs=null,Cn=null;function Ft(o){if(Cn&&typeof Cn.onCommitFiberRoot=="function")try{Cn.onCommitFiberRoot(gs,o,void 0,(o.current.flags&128)===128)}catch{}}var Qi=Math.clz32?Math.clz32:qo,Ar=Math.log,vs=Math.LN2;function qo(o){return o>>>=0,o===0?32:31-(Ar(o)/vs|0)|0}var Ir=64,Qn=4194304;function Fs(o){switch(o&-o){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return o&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return o&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return o}}function Pr(o,h){var _=o.pendingLanes;if(_===0)return 0;var A=0,O=o.suspendedLanes,H=o.pingedLanes,ne=_&268435455;if(ne!==0){var _e=ne&~O;_e!==0?A=Fs(_e):(H&=ne,H!==0&&(A=Fs(H)))}else ne=_&~O,ne!==0?A=Fs(ne):H!==0&&(A=Fs(H));if(A===0)return 0;if(h!==0&&h!==A&&(h&O)===0&&(O=A&-A,H=h&-h,O>=H||O===16&&(H&4194240)!==0))return h;if((A&4)!==0&&(A|=_&16),h=o.entangledLanes,h!==0)for(o=o.entanglements,h&=A;0<h;)_=31-Qi(h),O=1<<_,A|=o[_],h&=~O;return A}function li(o,h){switch(o){case 1:case 2:case 4:return h+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return h+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function _s(o,h){for(var _=o.suspendedLanes,A=o.pingedLanes,O=o.expirationTimes,H=o.pendingLanes;0<H;){var ne=31-Qi(H),_e=1<<ne,De=O[ne];De===-1?((_e&_)===0||(_e&A)!==0)&&(O[ne]=li(_e,h)):De<=h&&(o.expiredLanes|=_e),H&=~_e}}function Kr(o){return o=o.pendingLanes&-1073741825,o!==0?o:o&1073741824?1073741824:0}function Ns(){var o=Ir;return Ir<<=1,(Ir&4194240)===0&&(Ir=64),o}function qe(o){for(var h=[],_=0;31>_;_++)h.push(o);return h}function es(o,h,_){o.pendingLanes|=h,h!==536870912&&(o.suspendedLanes=0,o.pingedLanes=0),o=o.eventTimes,h=31-Qi(h),o[h]=_}function gt(o,h){var _=o.pendingLanes&~h;o.pendingLanes=h,o.suspendedLanes=0,o.pingedLanes=0,o.expiredLanes&=h,o.mutableReadLanes&=h,o.entangledLanes&=h,h=o.entanglements;var A=o.eventTimes;for(o=o.expirationTimes;0<_;){var O=31-Qi(_),H=1<<O;h[O]=0,A[O]=-1,o[O]=-1,_&=~H}}function me(o,h){var _=o.entangledLanes|=h;for(o=o.entanglements;_;){var A=31-Qi(_),O=1<<A;O&h|o[A]&h&&(o[A]|=h),_&=~O}}var Ne=0;function Ze(o){return o&=-o,1<o?4<o?(o&268435455)!==0?16:536870912:4:1}var $t,ni,ci,Bi,Mi,ln=!1,Vi=[],hn=null,Oi=null,Hs=null,Yr=new Map,go=new Map,lr=[],Ed="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function vo(o,h){switch(o){case"focusin":case"focusout":hn=null;break;case"dragenter":case"dragleave":Oi=null;break;case"mouseover":case"mouseout":Hs=null;break;case"pointerover":case"pointerout":Yr.delete(h.pointerId);break;case"gotpointercapture":case"lostpointercapture":go.delete(h.pointerId)}}function _o(o,h,_,A,O,H){return o===null||o.nativeEvent!==H?(o={blockedOn:h,domEventName:_,eventSystemFlags:A,nativeEvent:H,targetContainers:[O]},h!==null&&(h=El(h),h!==null&&ni(h)),o):(o.eventSystemFlags|=A,h=o.targetContainers,O!==null&&h.indexOf(O)===-1&&h.push(O),o)}function uc(o,h,_,A,O){switch(h){case"focusin":return hn=_o(hn,o,h,_,A,O),!0;case"dragenter":return Oi=_o(Oi,o,h,_,A,O),!0;case"mouseover":return Hs=_o(Hs,o,h,_,A,O),!0;case"pointerover":var H=O.pointerId;return Yr.set(H,_o(Yr.get(H)||null,o,h,_,A,O)),!0;case"gotpointercapture":return H=O.pointerId,go.set(H,_o(go.get(H)||null,o,h,_,A,O)),!0}return!1}function ul(o){var h=Xo(o.target);if(h!==null){var _=Tt(h);if(_!==null){if(h=_.tag,h===13){if(h=Vr(_),h!==null){o.blockedOn=h,Mi(o.priority,function(){ci(_)});return}}else if(h===3&&_.stateNode.current.memoizedState.isDehydrated){o.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}o.blockedOn=null}function bo(o){if(o.blockedOn!==null)return!1;for(var h=o.targetContainers;0<h.length;){var _=Y(o.domEventName,o.eventSystemFlags,h[0],o.nativeEvent);if(_===null){_=o.nativeEvent;var A=new _.constructor(_.type,_);Ni=A,_.target.dispatchEvent(A),Ni=null}else return h=El(_),h!==null&&ni(h),o.blockedOn=_,!1;h.shift()}return!0}function Aa(o,h,_){bo(o)&&_.delete(h)}function hl(){ln=!1,hn!==null&&bo(hn)&&(hn=null),Oi!==null&&bo(Oi)&&(Oi=null),Hs!==null&&bo(Hs)&&(Hs=null),Yr.forEach(Aa),go.forEach(Aa)}function jr(o,h){o.blockedOn===h&&(o.blockedOn=null,ln||(ln=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,hl)))}function Xr(o){function h(O){return jr(O,o)}if(0<Vi.length){jr(Vi[0],o);for(var _=1;_<Vi.length;_++){var A=Vi[_];A.blockedOn===o&&(A.blockedOn=null)}}for(hn!==null&&jr(hn,o),Oi!==null&&jr(Oi,o),Hs!==null&&jr(Hs,o),Yr.forEach(h),go.forEach(h),_=0;_<lr.length;_++)A=lr[_],A.blockedOn===o&&(A.blockedOn=null);for(;0<lr.length&&(_=lr[0],_.blockedOn===null);)ul(_),_.blockedOn===null&&lr.shift()}var Rr=T.ReactCurrentBatchConfig,wo=!0;function hc(o,h,_,A){var O=Ne,H=Rr.transition;Rr.transition=null;try{Ne=1,pl(o,h,_,A)}finally{Ne=O,Rr.transition=H}}function pc(o,h,_,A){var O=Ne,H=Rr.transition;Rr.transition=null;try{Ne=4,pl(o,h,_,A)}finally{Ne=O,Rr.transition=H}}function pl(o,h,_,A){if(wo){var O=Y(o,h,_,A);if(O===null)Bd(o,h,A,fl,_),vo(o,A);else if(uc(O,o,h,_,A))A.stopPropagation();else if(vo(o,A),h&4&&-1<Ed.indexOf(o)){for(;O!==null;){var H=El(O);if(H!==null&&$t(H),H=Y(o,h,_,A),H===null&&Bd(o,h,A,fl,_),H===O)break;O=H}O!==null&&A.stopPropagation()}else Bd(o,h,A,null,_)}}var fl=null;function Y(o,h,_,A){if(fl=null,o=zi(A),o=Xo(o),o!==null)if(h=Tt(o),h===null)o=null;else if(_=h.tag,_===13){if(o=Vr(h),o!==null)return o;o=null}else if(_===3){if(h.stateNode.current.memoizedState.isDehydrated)return h.tag===3?h.stateNode.containerInfo:null;o=null}else h!==o&&(o=null);return fl=o,null}function re(o){switch(o){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Wn()){case Zi:return 1;case Un:return 4;case ar:case qr:return 16;case $r:return 536870912;default:return 16}default:return 16}}var pe=null,Te=null,ye=null;function ze(){if(ye)return ye;var o,h=Te,_=h.length,A,O="value"in pe?pe.value:pe.textContent,H=O.length;for(o=0;o<_&&h[o]===O[o];o++);var ne=_-o;for(A=1;A<=ne&&h[_-A]===O[H-A];A++);return ye=O.slice(o,1<A?1-A:void 0)}function $e(o){var h=o.keyCode;return"charCode"in o?(o=o.charCode,o===0&&h===13&&(o=13)):o=h,o===10&&(o=13),32<=o||o===13?o:0}function Ae(){return!0}function Be(){return!1}function it(o){function h(_,A,O,H,ne){this._reactName=_,this._targetInst=O,this.type=A,this.nativeEvent=H,this.target=ne,this.currentTarget=null;for(var _e in o)o.hasOwnProperty(_e)&&(_=o[_e],this[_e]=_?_(H):H[_e]);return this.isDefaultPrevented=(H.defaultPrevented!=null?H.defaultPrevented:H.returnValue===!1)?Ae:Be,this.isPropagationStopped=Be,this}return X(h.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=Ae)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=Ae)},persist:function(){},isPersistent:Ae}),h}var ot={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(o){return o.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},nt=it(ot),Ke=X({},ot,{view:0,detail:0}),jt=it(Ke),Le,dt,Ii,ei=X({},Ke,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ui,button:0,buttons:0,relatedTarget:function(o){return o.relatedTarget===void 0?o.fromElement===o.srcElement?o.toElement:o.fromElement:o.relatedTarget},movementX:function(o){return"movementX"in o?o.movementX:(o!==Ii&&(Ii&&o.type==="mousemove"?(Le=o.screenX-Ii.screenX,dt=o.screenY-Ii.screenY):dt=Le=0,Ii=o),Le)},movementY:function(o){return"movementY"in o?o.movementY:dt}}),ti=it(ei),Pi=X({},ei,{dataTransfer:0}),zt=it(Pi),Fi=X({},Ke,{relatedTarget:0}),pi=it(Fi),kn=X({},ot,{animationName:0,elapsedTime:0,pseudoElement:0}),Vn=it(kn),ts=X({},ot,{clipboardData:function(o){return"clipboardData"in o?o.clipboardData:window.clipboardData}}),Ia=it(ts),is=X({},ot,{data:0}),ml=it(is),fc={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},En={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},cr={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mc(o){var h=this.nativeEvent;return h.getModifierState?h.getModifierState(o):(o=cr[o])?!!h[o]:!1}function ui(){return mc}var Ws=X({},Ke,{key:function(o){if(o.key){var h=fc[o.key]||o.key;if(h!=="Unidentified")return h}return o.type==="keypress"?(o=$e(o),o===13?"Enter":String.fromCharCode(o)):o.type==="keydown"||o.type==="keyup"?En[o.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ui,charCode:function(o){return o.type==="keypress"?$e(o):0},keyCode:function(o){return o.type==="keydown"||o.type==="keyup"?o.keyCode:0},which:function(o){return o.type==="keypress"?$e(o):o.type==="keydown"||o.type==="keyup"?o.keyCode:0}}),Td=it(Ws),Nr=X({},ei,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ko=it(Nr),pn=X({},Ke,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ui}),ns=it(pn),gl=X({},ot,{propertyName:0,elapsedTime:0,pseudoElement:0}),ss=it(gl),gc=X({},ei,{deltaX:function(o){return"deltaX"in o?o.deltaX:"wheelDeltaX"in o?-o.wheelDeltaX:0},deltaY:function(o){return"deltaY"in o?o.deltaY:"wheelDeltaY"in o?-o.wheelDeltaY:"wheelDelta"in o?-o.wheelDelta:0},deltaZ:0,deltaMode:0}),Dd=it(gc),Mr=[9,13,27,32],Us=a&&"CompositionEvent"in window,dr=null;a&&"documentMode"in document&&(dr=document.documentMode);var fn=a&&"TextEvent"in window&&!dr,Ji=a&&(!Us||dr&&8<dr&&11>=dr),Vs=" ",vc=!1;function _c(o,h){switch(o){case"keyup":return Mr.indexOf(h.keyCode)!==-1;case"keydown":return h.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Sm(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var rs=!1;function Cm(o,h){switch(o){case"compositionend":return Sm(h);case"keypress":return h.which!==32?null:(vc=!0,Vs);case"textInput":return o=h.data,o===Vs&&vc?null:o;default:return null}}function $d(o,h){if(rs)return o==="compositionend"||!Us&&_c(o,h)?(o=ze(),ye=Te=pe=null,rs=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(h.ctrlKey||h.altKey||h.metaKey)||h.ctrlKey&&h.altKey){if(h.char&&1<h.char.length)return h.char;if(h.which)return String.fromCharCode(h.which)}return null;case"compositionend":return Ji&&h.locale!=="ko"?null:h.data;default:return null}}var Dh={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function ur(o){var h=o&&o.nodeName&&o.nodeName.toLowerCase();return h==="input"?!!Dh[o.type]:h==="textarea"}function $h(o,h,_,A){Tr(A),h=xc(h,"onChange"),0<h.length&&(_=new nt("onChange","change",null,_,A),o.push({event:_,listeners:h}))}var vl=null,_l=null;function km(o){Uh(o,0)}function bc(o){var h=Ra(o);if(Pe(h))return o}function Em(o,h){if(o==="change")return h}var Ah=!1;if(a){var Ad;if(a){var Id="oninput"in document;if(!Id){var Ih=document.createElement("div");Ih.setAttribute("oninput","return;"),Id=typeof Ih.oninput=="function"}Ad=Id}else Ad=!1;Ah=Ad&&(!document.documentMode||9<document.documentMode)}function hr(){vl&&(vl.detachEvent("onpropertychange",Ph),_l=vl=null)}function Ph(o){if(o.propertyName==="value"&&bc(_l)){var h=[];$h(h,_l,o,zi(o)),nr(km,h)}}function Tm(o,h,_){o==="focusin"?(hr(),vl=h,_l=_,vl.attachEvent("onpropertychange",Ph)):o==="focusout"&&hr()}function Dm(o){if(o==="selectionchange"||o==="keyup"||o==="keydown")return bc(_l)}function $m(o,h){if(o==="click")return bc(h)}function Am(o,h){if(o==="input"||o==="change")return bc(h)}function Im(o,h){return o===h&&(o!==0||1/o===1/h)||o!==o&&h!==h}var pr=typeof Object.is=="function"?Object.is:Im;function bl(o,h){if(pr(o,h))return!0;if(typeof o!="object"||o===null||typeof h!="object"||h===null)return!1;var _=Object.keys(o),A=Object.keys(h);if(_.length!==A.length)return!1;for(A=0;A<_.length;A++){var O=_[A];if(!d.call(h,O)||!pr(o[O],h[O]))return!1}return!0}function jh(o){for(;o&&o.firstChild;)o=o.firstChild;return o}function Rh(o,h){var _=jh(o);o=0;for(var A;_;){if(_.nodeType===3){if(A=o+_.textContent.length,o<=h&&A>=h)return{node:_,offset:h-o};o=A}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=jh(_)}}function Pd(o,h){return o&&h?o===h?!0:o&&o.nodeType===3?!1:h&&h.nodeType===3?Pd(o,h.parentNode):"contains"in o?o.contains(h):o.compareDocumentPosition?!!(o.compareDocumentPosition(h)&16):!1:!1}function jd(){for(var o=window,h=Ye();h instanceof o.HTMLIFrameElement;){try{var _=typeof h.contentWindow.location.href=="string"}catch{_=!1}if(_)o=h.contentWindow;else break;h=Ye(o.document)}return h}function Rd(o){var h=o&&o.nodeName&&o.nodeName.toLowerCase();return h&&(h==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||h==="textarea"||o.contentEditable==="true")}function Pm(o){var h=jd(),_=o.focusedElem,A=o.selectionRange;if(h!==_&&_&&_.ownerDocument&&Pd(_.ownerDocument.documentElement,_)){if(A!==null&&Rd(_)){if(h=A.start,o=A.end,o===void 0&&(o=h),"selectionStart"in _)_.selectionStart=h,_.selectionEnd=Math.min(o,_.value.length);else if(o=(h=_.ownerDocument||document)&&h.defaultView||window,o.getSelection){o=o.getSelection();var O=_.textContent.length,H=Math.min(A.start,O);A=A.end===void 0?H:Math.min(A.end,O),!o.extend&&H>A&&(O=A,A=H,H=O),O=Rh(_,H);var ne=Rh(_,A);O&&ne&&(o.rangeCount!==1||o.anchorNode!==O.node||o.anchorOffset!==O.offset||o.focusNode!==ne.node||o.focusOffset!==ne.offset)&&(h=h.createRange(),h.setStart(O.node,O.offset),o.removeAllRanges(),H>A?(o.addRange(h),o.extend(ne.node,ne.offset)):(h.setEnd(ne.node,ne.offset),o.addRange(h)))}}for(h=[],o=_;o=o.parentNode;)o.nodeType===1&&h.push({element:o,left:o.scrollLeft,top:o.scrollTop});for(typeof _.focus=="function"&&_.focus(),_=0;_<h.length;_++)o=h[_],o.element.scrollLeft=o.left,o.element.scrollTop=o.top}}var Nh=a&&"documentMode"in document&&11>=document.documentMode,wl=null,Nd=null,Yo=null,Md=!1;function Mh(o,h,_){var A=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;Md||wl==null||wl!==Ye(A)||(A=wl,"selectionStart"in A&&Rd(A)?A={start:A.selectionStart,end:A.selectionEnd}:(A=(A.ownerDocument&&A.ownerDocument.defaultView||window).getSelection(),A={anchorNode:A.anchorNode,anchorOffset:A.anchorOffset,focusNode:A.focusNode,focusOffset:A.focusOffset}),Yo&&bl(Yo,A)||(Yo=A,A=xc(Nd,"onSelect"),0<A.length&&(h=new nt("onSelect","select",null,h,_),o.push({event:h,listeners:A}),h.target=wl)))}function wc(o,h){var _={};return _[o.toLowerCase()]=h.toLowerCase(),_["Webkit"+o]="webkit"+h,_["Moz"+o]="moz"+h,_}var Jr={animationend:wc("Animation","AnimationEnd"),animationiteration:wc("Animation","AnimationIteration"),animationstart:wc("Animation","AnimationStart"),transitionend:wc("Transition","TransitionEnd")},Od={},Oh={};a&&(Oh=document.createElement("div").style,"AnimationEvent"in window||(delete Jr.animationend.animation,delete Jr.animationiteration.animation,delete Jr.animationstart.animation),"TransitionEvent"in window||delete Jr.transitionend.transition);function yl(o){if(Od[o])return Od[o];if(!Jr[o])return o;var h=Jr[o],_;for(_ in h)if(h.hasOwnProperty(_)&&_ in Oh)return Od[o]=h[_];return o}var Lh=yl("animationend"),zh=yl("animationiteration"),Bh=yl("animationstart"),Gh=yl("transitionend"),jm=new Map,Fh="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function yo(o,h){jm.set(o,h),l(h,[o])}for(var Ld=0;Ld<Fh.length;Ld++){var Hh=Fh[Ld],Rm=Hh.toLowerCase(),yi=Hh[0].toUpperCase()+Hh.slice(1);yo(Rm,"on"+yi)}yo(Lh,"onAnimationEnd"),yo(zh,"onAnimationIteration"),yo(Bh,"onAnimationStart"),yo("dblclick","onDoubleClick"),yo("focusin","onFocus"),yo("focusout","onBlur"),yo(Gh,"onTransitionEnd"),p("onMouseEnter",["mouseout","mouseover"]),p("onMouseLeave",["mouseout","mouseover"]),p("onPointerEnter",["pointerout","pointerover"]),p("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var xl="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Nm=new Set("cancel close invalid load scroll toggle".split(" ").concat(xl));function Wh(o,h,_){var A=o.type||"unknown-event";o.currentTarget=_,Di(A,h,void 0,o),o.currentTarget=null}function Uh(o,h){h=(h&4)!==0;for(var _=0;_<o.length;_++){var A=o[_],O=A.event;A=A.listeners;e:{var H=void 0;if(h)for(var ne=A.length-1;0<=ne;ne--){var _e=A[ne],De=_e.instance,He=_e.currentTarget;if(_e=_e.listener,De!==H&&O.isPropagationStopped())break e;Wh(O,_e,He),H=De}else for(ne=0;ne<A.length;ne++){if(_e=A[ne],De=_e.instance,He=_e.currentTarget,_e=_e.listener,De!==H&&O.isPropagationStopped())break e;Wh(O,_e,He),H=De}}}if(or)throw o=Gt,or=!1,Gt=null,o}function qi(o,h){var _=h[Vd];_===void 0&&(_=h[Vd]=new Set);var A=o+"__bubble";_.has(A)||(Vh(h,o,2,!1),_.add(A))}function zd(o,h,_){var A=0;h&&(A|=4),Vh(_,o,A,h)}var yc="_reactListening"+Math.random().toString(36).slice(2);function Sl(o){if(!o[yc]){o[yc]=!0,n.forEach(function(_){_!=="selectionchange"&&(Nm.has(_)||zd(_,!1,o),zd(_,!0,o))});var h=o.nodeType===9?o:o.ownerDocument;h===null||h[yc]||(h[yc]=!0,zd("selectionchange",!1,h))}}function Vh(o,h,_,A){switch(re(h)){case 1:var O=hc;break;case 4:O=pc;break;default:O=pl}_=O.bind(null,h,_,o),O=void 0,!ms||h!=="touchstart"&&h!=="touchmove"&&h!=="wheel"||(O=!0),A?O!==void 0?o.addEventListener(h,_,{capture:!0,passive:O}):o.addEventListener(h,_,!0):O!==void 0?o.addEventListener(h,_,{passive:O}):o.addEventListener(h,_,!1)}function Bd(o,h,_,A,O){var H=A;if((h&1)===0&&(h&2)===0&&A!==null)e:for(;;){if(A===null)return;var ne=A.tag;if(ne===3||ne===4){var _e=A.stateNode.containerInfo;if(_e===O||_e.nodeType===8&&_e.parentNode===O)break;if(ne===4)for(ne=A.return;ne!==null;){var De=ne.tag;if((De===3||De===4)&&(De=ne.stateNode.containerInfo,De===O||De.nodeType===8&&De.parentNode===O))return;ne=ne.return}for(;_e!==null;){if(ne=Xo(_e),ne===null)return;if(De=ne.tag,De===5||De===6){A=H=ne;continue e}_e=_e.parentNode}}A=A.return}nr(function(){var He=H,lt=zi(_),ct=[];e:{var at=jm.get(o);if(at!==void 0){var Dt=nt,Ot=o;switch(o){case"keypress":if($e(_)===0)break e;case"keydown":case"keyup":Dt=Td;break;case"focusin":Ot="focus",Dt=pi;break;case"focusout":Ot="blur",Dt=pi;break;case"beforeblur":case"afterblur":Dt=pi;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Dt=ti;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Dt=zt;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Dt=ns;break;case Lh:case zh:case Bh:Dt=Vn;break;case Gh:Dt=ss;break;case"scroll":Dt=jt;break;case"wheel":Dt=Dd;break;case"copy":case"cut":case"paste":Dt=Ia;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Dt=Ko}var Lt=(h&4)!==0,Wi=!Lt&&o==="scroll",Ge=Lt?at!==null?at+"Capture":null:at;Lt=[];for(var Re=He,We;Re!==null;){We=Re;var pt=We.stateNode;if(We.tag===5&&pt!==null&&(We=pt,Ge!==null&&(pt=Hn(Re,Ge),pt!=null&&Lt.push(Cl(Re,pt,We)))),Wi)break;Re=Re.return}0<Lt.length&&(at=new Dt(at,Ot,null,_,lt),ct.push({event:at,listeners:Lt}))}}if((h&7)===0){e:{if(at=o==="mouseover"||o==="pointerover",Dt=o==="mouseout"||o==="pointerout",at&&_!==Ni&&(Ot=_.relatedTarget||_.fromElement)&&(Xo(Ot)||Ot[Lr]))break e;if((Dt||at)&&(at=lt.window===lt?lt:(at=lt.ownerDocument)?at.defaultView||at.parentWindow:window,Dt?(Ot=_.relatedTarget||_.toElement,Dt=He,Ot=Ot?Xo(Ot):null,Ot!==null&&(Wi=Tt(Ot),Ot!==Wi||Ot.tag!==5&&Ot.tag!==6)&&(Ot=null)):(Dt=null,Ot=He),Dt!==Ot)){if(Lt=ti,pt="onMouseLeave",Ge="onMouseEnter",Re="mouse",(o==="pointerout"||o==="pointerover")&&(Lt=Ko,pt="onPointerLeave",Ge="onPointerEnter",Re="pointer"),Wi=Dt==null?at:Ra(Dt),We=Ot==null?at:Ra(Ot),at=new Lt(pt,Re+"leave",Dt,_,lt),at.target=Wi,at.relatedTarget=We,pt=null,Xo(lt)===He&&(Lt=new Lt(Ge,Re+"enter",Ot,_,lt),Lt.target=We,Lt.relatedTarget=Wi,pt=Lt),Wi=pt,Dt&&Ot)t:{for(Lt=Dt,Ge=Ot,Re=0,We=Lt;We;We=Pa(We))Re++;for(We=0,pt=Ge;pt;pt=Pa(pt))We++;for(;0<Re-We;)Lt=Pa(Lt),Re--;for(;0<We-Re;)Ge=Pa(Ge),We--;for(;Re--;){if(Lt===Ge||Ge!==null&&Lt===Ge.alternate)break t;Lt=Pa(Lt),Ge=Pa(Ge)}Lt=null}else Lt=null;Dt!==null&&qh(ct,at,Dt,Lt,!1),Ot!==null&&Wi!==null&&qh(ct,Wi,Ot,Lt,!0)}}e:{if(at=He?Ra(He):window,Dt=at.nodeName&&at.nodeName.toLowerCase(),Dt==="select"||Dt==="input"&&at.type==="file")var Ht=Em;else if(ur(at))if(Ah)Ht=Am;else{Ht=Dm;var Zt=Tm}else(Dt=at.nodeName)&&Dt.toLowerCase()==="input"&&(at.type==="checkbox"||at.type==="radio")&&(Ht=$m);if(Ht&&(Ht=Ht(o,He))){$h(ct,Ht,_,lt);break e}Zt&&Zt(o,at,He),o==="focusout"&&(Zt=at._wrapperState)&&Zt.controlled&&at.type==="number"&&di(at,"number",at.value)}switch(Zt=He?Ra(He):window,o){case"focusin":(ur(Zt)||Zt.contentEditable==="true")&&(wl=Zt,Nd=He,Yo=null);break;case"focusout":Yo=Nd=wl=null;break;case"mousedown":Md=!0;break;case"contextmenu":case"mouseup":case"dragend":Md=!1,Mh(ct,_,lt);break;case"selectionchange":if(Nh)break;case"keydown":case"keyup":Mh(ct,_,lt)}var Qt;if(Us)e:{switch(o){case"compositionstart":var si="onCompositionStart";break e;case"compositionend":si="onCompositionEnd";break e;case"compositionupdate":si="onCompositionUpdate";break e}si=void 0}else rs?_c(o,_)&&(si="onCompositionEnd"):o==="keydown"&&_.keyCode===229&&(si="onCompositionStart");si&&(Ji&&_.locale!=="ko"&&(rs||si!=="onCompositionStart"?si==="onCompositionEnd"&&rs&&(Qt=ze()):(pe=lt,Te="value"in pe?pe.value:pe.textContent,rs=!0)),Zt=xc(He,si),0<Zt.length&&(si=new ml(si,o,null,_,lt),ct.push({event:si,listeners:Zt}),Qt?si.data=Qt:(Qt=Sm(_),Qt!==null&&(si.data=Qt)))),(Qt=fn?Cm(o,_):$d(o,_))&&(He=xc(He,"onBeforeInput"),0<He.length&&(lt=new ml("onBeforeInput","beforeinput",null,_,lt),ct.push({event:lt,listeners:He}),lt.data=Qt))}Uh(ct,h)})}function Cl(o,h,_){return{instance:o,listener:h,currentTarget:_}}function xc(o,h){for(var _=h+"Capture",A=[];o!==null;){var O=o,H=O.stateNode;O.tag===5&&H!==null&&(O=H,H=Hn(o,_),H!=null&&A.unshift(Cl(o,H,O)),H=Hn(o,h),H!=null&&A.push(Cl(o,H,O))),o=o.return}return A}function Pa(o){if(o===null)return null;do o=o.return;while(o&&o.tag!==5);return o||null}function qh(o,h,_,A,O){for(var H=h._reactName,ne=[];_!==null&&_!==A;){var _e=_,De=_e.alternate,He=_e.stateNode;if(De!==null&&De===A)break;_e.tag===5&&He!==null&&(_e=He,O?(De=Hn(_,H),De!=null&&ne.unshift(Cl(_,De,_e))):O||(De=Hn(_,H),De!=null&&ne.push(Cl(_,De,_e)))),_=_.return}ne.length!==0&&o.push({event:h,listeners:ne})}var Sc=/\r\n?/g,Mm=/\u0000|\uFFFD/g;function Cc(o){return(typeof o=="string"?o:""+o).replace(Sc,`
|
|
39
39
|
`).replace(Mm,"")}function kc(o,h,_){if(h=Cc(h),Cc(o)!==h&&_)throw Error(t(425))}function Ec(){}var Gd=null,Fd=null;function Hd(o,h){return o==="textarea"||o==="noscript"||typeof h.children=="string"||typeof h.children=="number"||typeof h.dangerouslySetInnerHTML=="object"&&h.dangerouslySetInnerHTML!==null&&h.dangerouslySetInnerHTML.__html!=null}var Wd=typeof setTimeout=="function"?setTimeout:void 0,Om=typeof clearTimeout=="function"?clearTimeout:void 0,Kh=typeof Promise=="function"?Promise:void 0,Lm=typeof queueMicrotask=="function"?queueMicrotask:typeof Kh<"u"?function(o){return Kh.resolve(null).then(o).catch(zm)}:Wd;function zm(o){setTimeout(function(){throw o})}function Ud(o,h){var _=h,A=0;do{var O=_.nextSibling;if(o.removeChild(_),O&&O.nodeType===8)if(_=O.data,_==="/$"){if(A===0){o.removeChild(O),Xr(h);return}A--}else _!=="$"&&_!=="$?"&&_!=="$!"||A++;_=O}while(_);Xr(h)}function xo(o){for(;o!=null;o=o.nextSibling){var h=o.nodeType;if(h===1||h===3)break;if(h===8){if(h=o.data,h==="$"||h==="$!"||h==="$?")break;if(h==="/$")return null}}return o}function Yh(o){o=o.previousSibling;for(var h=0;o;){if(o.nodeType===8){var _=o.data;if(_==="$"||_==="$!"||_==="$?"){if(h===0)return o;h--}else _==="/$"&&h++}o=o.previousSibling}return null}var ja=Math.random().toString(36).slice(2),Or="__reactFiber$"+ja,kl="__reactProps$"+ja,Lr="__reactContainer$"+ja,Vd="__reactEvents$"+ja,Xh="__reactListeners$"+ja,Jh="__reactHandles$"+ja;function Xo(o){var h=o[Or];if(h)return h;for(var _=o.parentNode;_;){if(h=_[Lr]||_[Or]){if(_=h.alternate,h.child!==null||_!==null&&_.child!==null)for(o=Yh(o);o!==null;){if(_=o[Or])return _;o=Yh(o)}return h}o=_,_=o.parentNode}return null}function El(o){return o=o[Or]||o[Lr],!o||o.tag!==5&&o.tag!==6&&o.tag!==13&&o.tag!==3?null:o}function Ra(o){if(o.tag===5||o.tag===6)return o.stateNode;throw Error(t(33))}function Tc(o){return o[kl]||null}var qd=[],Na=-1;function Zr(o){return{current:o}}function Ki(o){0>Na||(o.current=qd[Na],qd[Na]=null,Na--)}function Hi(o,h){Na++,qd[Na]=o.current,o.current=h}var So={},os=Zr(So),bs=Zr(!1),Jo=So;function as(o,h){var _=o.type.contextTypes;if(!_)return So;var A=o.stateNode;if(A&&A.__reactInternalMemoizedUnmaskedChildContext===h)return A.__reactInternalMemoizedMaskedChildContext;var O={},H;for(H in _)O[H]=h[H];return A&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=h,o.__reactInternalMemoizedMaskedChildContext=O),O}function ws(o){return o=o.childContextTypes,o!=null}function Dc(){Ki(bs),Ki(os)}function Zh(o,h,_){if(os.current!==So)throw Error(t(168));Hi(os,h),Hi(bs,_)}function Qh(o,h,_){var A=o.stateNode;if(h=h.childContextTypes,typeof A.getChildContext!="function")return _;A=A.getChildContext();for(var O in A)if(!(O in h))throw Error(t(108,ge(o)||"Unknown",O));return X({},_,A)}function $c(o){return o=(o=o.stateNode)&&o.__reactInternalMemoizedMergedChildContext||So,Jo=os.current,Hi(os,o),Hi(bs,bs.current),!0}function ep(o,h,_){var A=o.stateNode;if(!A)throw Error(t(169));_?(o=Qh(o,h,Jo),A.__reactInternalMemoizedMergedChildContext=o,Ki(bs),Ki(os),Hi(os,o)):Ki(bs),Hi(bs,_)}var Qr=null,Ac=!1,Kd=!1;function tp(o){Qr===null?Qr=[o]:Qr.push(o)}function o_(o){Ac=!0,tp(o)}function Co(){if(!Kd&&Qr!==null){Kd=!0;var o=0,h=Ne;try{var _=Qr;for(Ne=1;o<_.length;o++){var A=_[o];do A=A(!0);while(A!==null)}Qr=null,Ac=!1}catch(O){throw Qr!==null&&(Qr=Qr.slice(o+1)),Vo(Zi,Co),O}finally{Ne=h,Kd=!1}}return null}var Ma=[],Oa=0,Ic=null,Pc=0,qs=[],fr=0,Ks=null,ys=1,xs="";function ko(o,h){Ma[Oa++]=Pc,Ma[Oa++]=Ic,Ic=o,Pc=h}function Zo(o,h,_){qs[fr++]=ys,qs[fr++]=xs,qs[fr++]=Ks,Ks=o;var A=ys;o=xs;var O=32-Qi(A)-1;A&=~(1<<O),_+=1;var H=32-Qi(h)+O;if(30<H){var ne=O-O%5;H=(A&(1<<ne)-1).toString(32),A>>=ne,O-=ne,ys=1<<32-Qi(h)+O|_<<O|A,xs=H+o}else ys=1<<H|_<<O|A,xs=o}function vn(o){o.return!==null&&(ko(o,1),Zo(o,1,0))}function Yd(o){for(;o===Ic;)Ic=Ma[--Oa],Ma[Oa]=null,Pc=Ma[--Oa],Ma[Oa]=null;for(;o===Ks;)Ks=qs[--fr],qs[fr]=null,xs=qs[--fr],qs[fr]=null,ys=qs[--fr],qs[fr]=null}var Ss=null,Ms=null,en=!1,Cs=null;function Xd(o,h){var _=Ls(5,null,null,0);_.elementType="DELETED",_.stateNode=h,_.return=o,h=o.deletions,h===null?(o.deletions=[_],o.flags|=16):h.push(_)}function Jd(o,h){switch(o.tag){case 5:var _=o.type;return h=h.nodeType!==1||_.toLowerCase()!==h.nodeName.toLowerCase()?null:h,h!==null?(o.stateNode=h,Ss=o,Ms=xo(h.firstChild),!0):!1;case 6:return h=o.pendingProps===""||h.nodeType!==3?null:h,h!==null?(o.stateNode=h,Ss=o,Ms=null,!0):!1;case 13:return h=h.nodeType!==8?null:h,h!==null?(_=Ks!==null?{id:ys,overflow:xs}:null,o.memoizedState={dehydrated:h,treeContext:_,retryLane:1073741824},_=Ls(18,null,null,0),_.stateNode=h,_.return=o,o.child=_,Ss=o,Ms=null,!0):!1;default:return!1}}function Zd(o){return(o.mode&1)!==0&&(o.flags&128)===0}function Qd(o){if(en){var h=Ms;if(h){var _=h;if(!Jd(o,h)){if(Zd(o))throw Error(t(418));h=xo(_.nextSibling);var A=Ss;h&&Jd(o,h)?Xd(A,_):(o.flags=o.flags&-4097|2,en=!1,Ss=o)}}else{if(Zd(o))throw Error(t(418));o.flags=o.flags&-4097|2,en=!1,Ss=o}}}function eu(o){for(o=o.return;o!==null&&o.tag!==5&&o.tag!==3&&o.tag!==13;)o=o.return;Ss=o}function Tl(o){if(o!==Ss)return!1;if(!en)return eu(o),en=!0,!1;var h;if((h=o.tag!==3)&&!(h=o.tag!==5)&&(h=o.type,h=h!=="head"&&h!=="body"&&!Hd(o.type,o.memoizedProps)),h&&(h=Ms)){if(Zd(o))throw ip(),Error(t(418));for(;h;)Xd(o,h),h=xo(h.nextSibling)}if(eu(o),o.tag===13){if(o=o.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(t(317));e:{for(o=o.nextSibling,h=0;o;){if(o.nodeType===8){var _=o.data;if(_==="/$"){if(h===0){Ms=xo(o.nextSibling);break e}h--}else _!=="$"&&_!=="$!"&&_!=="$?"||h++}o=o.nextSibling}Ms=null}}else Ms=Ss?xo(o.stateNode.nextSibling):null;return!0}function ip(){for(var o=Ms;o;)o=xo(o.nextSibling)}function Qo(){Ms=Ss=null,en=!1}function tu(o){Cs===null?Cs=[o]:Cs.push(o)}var iu=T.ReactCurrentBatchConfig;function La(o,h,_){if(o=_.ref,o!==null&&typeof o!="function"&&typeof o!="object"){if(_._owner){if(_=_._owner,_){if(_.tag!==1)throw Error(t(309));var A=_.stateNode}if(!A)throw Error(t(147,o));var O=A,H=""+o;return h!==null&&h.ref!==null&&typeof h.ref=="function"&&h.ref._stringRef===H?h.ref:(h=function(ne){var _e=O.refs;ne===null?delete _e[H]:_e[H]=ne},h._stringRef=H,h)}if(typeof o!="string")throw Error(t(284));if(!_._owner)throw Error(t(290,o))}return o}function jc(o,h){throw o=Object.prototype.toString.call(h),Error(t(31,o==="[object Object]"?"object with keys {"+Object.keys(h).join(", ")+"}":o))}function np(o){var h=o._init;return h(o._payload)}function Bm(o){function h(Ge,Re){if(o){var We=Ge.deletions;We===null?(Ge.deletions=[Re],Ge.flags|=16):We.push(Re)}}function _(Ge,Re){if(!o)return null;for(;Re!==null;)h(Ge,Re),Re=Re.sibling;return null}function A(Ge,Re){for(Ge=new Map;Re!==null;)Re.key!==null?Ge.set(Re.key,Re):Ge.set(Re.index,Re),Re=Re.sibling;return Ge}function O(Ge,Re){return Ge=jo(Ge,Re),Ge.index=0,Ge.sibling=null,Ge}function H(Ge,Re,We){return Ge.index=We,o?(We=Ge.alternate,We!==null?(We=We.index,We<Re?(Ge.flags|=2,Re):We):(Ge.flags|=2,Re)):(Ge.flags|=1048576,Re)}function ne(Ge){return o&&Ge.alternate===null&&(Ge.flags|=2),Ge}function _e(Ge,Re,We,pt){return Re===null||Re.tag!==6?(Re=Qu(We,Ge.mode,pt),Re.return=Ge,Re):(Re=O(Re,We),Re.return=Ge,Re)}function De(Ge,Re,We,pt){var Ht=We.type;return Ht===L?lt(Ge,Re,We.props.children,pt,We.key):Re!==null&&(Re.elementType===Ht||typeof Ht=="object"&&Ht!==null&&Ht.$$typeof===ve&&np(Ht)===Re.type)?(pt=O(Re,We.props),pt.ref=La(Ge,Re,We),pt.return=Ge,pt):(pt=td(We.type,We.key,We.props,null,Ge.mode,pt),pt.ref=La(Ge,Re,We),pt.return=Ge,pt)}function He(Ge,Re,We,pt){return Re===null||Re.tag!==4||Re.stateNode.containerInfo!==We.containerInfo||Re.stateNode.implementation!==We.implementation?(Re=eh(We,Ge.mode,pt),Re.return=Ge,Re):(Re=O(Re,We.children||[]),Re.return=Ge,Re)}function lt(Ge,Re,We,pt,Ht){return Re===null||Re.tag!==7?(Re=Ka(We,Ge.mode,pt,Ht),Re.return=Ge,Re):(Re=O(Re,We),Re.return=Ge,Re)}function ct(Ge,Re,We){if(typeof Re=="string"&&Re!==""||typeof Re=="number")return Re=Qu(""+Re,Ge.mode,We),Re.return=Ge,Re;if(typeof Re=="object"&&Re!==null){switch(Re.$$typeof){case j:return We=td(Re.type,Re.key,Re.props,null,Ge.mode,We),We.ref=La(Ge,null,Re),We.return=Ge,We;case N:return Re=eh(Re,Ge.mode,We),Re.return=Ge,Re;case ve:var pt=Re._init;return ct(Ge,pt(Re._payload),We)}if(_i(Re)||U(Re))return Re=Ka(Re,Ge.mode,We,null),Re.return=Ge,Re;jc(Ge,Re)}return null}function at(Ge,Re,We,pt){var Ht=Re!==null?Re.key:null;if(typeof We=="string"&&We!==""||typeof We=="number")return Ht!==null?null:_e(Ge,Re,""+We,pt);if(typeof We=="object"&&We!==null){switch(We.$$typeof){case j:return We.key===Ht?De(Ge,Re,We,pt):null;case N:return We.key===Ht?He(Ge,Re,We,pt):null;case ve:return Ht=We._init,at(Ge,Re,Ht(We._payload),pt)}if(_i(We)||U(We))return Ht!==null?null:lt(Ge,Re,We,pt,null);jc(Ge,We)}return null}function Dt(Ge,Re,We,pt,Ht){if(typeof pt=="string"&&pt!==""||typeof pt=="number")return Ge=Ge.get(We)||null,_e(Re,Ge,""+pt,Ht);if(typeof pt=="object"&&pt!==null){switch(pt.$$typeof){case j:return Ge=Ge.get(pt.key===null?We:pt.key)||null,De(Re,Ge,pt,Ht);case N:return Ge=Ge.get(pt.key===null?We:pt.key)||null,He(Re,Ge,pt,Ht);case ve:var Zt=pt._init;return Dt(Ge,Re,We,Zt(pt._payload),Ht)}if(_i(pt)||U(pt))return Ge=Ge.get(We)||null,lt(Re,Ge,pt,Ht,null);jc(Re,pt)}return null}function Ot(Ge,Re,We,pt){for(var Ht=null,Zt=null,Qt=Re,si=Re=0,$n=null;Qt!==null&&si<We.length;si++){Qt.index>si?($n=Qt,Qt=null):$n=Qt.sibling;var ki=at(Ge,Qt,We[si],pt);if(ki===null){Qt===null&&(Qt=$n);break}o&&Qt&&ki.alternate===null&&h(Ge,Qt),Re=H(ki,Re,si),Zt===null?Ht=ki:Zt.sibling=ki,Zt=ki,Qt=$n}if(si===We.length)return _(Ge,Qt),en&&ko(Ge,si),Ht;if(Qt===null){for(;si<We.length;si++)Qt=ct(Ge,We[si],pt),Qt!==null&&(Re=H(Qt,Re,si),Zt===null?Ht=Qt:Zt.sibling=Qt,Zt=Qt);return en&&ko(Ge,si),Ht}for(Qt=A(Ge,Qt);si<We.length;si++)$n=Dt(Qt,Ge,si,We[si],pt),$n!==null&&(o&&$n.alternate!==null&&Qt.delete($n.key===null?si:$n.key),Re=H($n,Re,si),Zt===null?Ht=$n:Zt.sibling=$n,Zt=$n);return o&&Qt.forEach(function(so){return h(Ge,so)}),en&&ko(Ge,si),Ht}function Lt(Ge,Re,We,pt){var Ht=U(We);if(typeof Ht!="function")throw Error(t(150));if(We=Ht.call(We),We==null)throw Error(t(151));for(var Zt=Ht=null,Qt=Re,si=Re=0,$n=null,ki=We.next();Qt!==null&&!ki.done;si++,ki=We.next()){Qt.index>si?($n=Qt,Qt=null):$n=Qt.sibling;var so=at(Ge,Qt,ki.value,pt);if(so===null){Qt===null&&(Qt=$n);break}o&&Qt&&so.alternate===null&&h(Ge,Qt),Re=H(so,Re,si),Zt===null?Ht=so:Zt.sibling=so,Zt=so,Qt=$n}if(ki.done)return _(Ge,Qt),en&&ko(Ge,si),Ht;if(Qt===null){for(;!ki.done;si++,ki=We.next())ki=ct(Ge,ki.value,pt),ki!==null&&(Re=H(ki,Re,si),Zt===null?Ht=ki:Zt.sibling=ki,Zt=ki);return en&&ko(Ge,si),Ht}for(Qt=A(Ge,Qt);!ki.done;si++,ki=We.next())ki=Dt(Qt,Ge,si,ki.value,pt),ki!==null&&(o&&ki.alternate!==null&&Qt.delete(ki.key===null?si:ki.key),Re=H(ki,Re,si),Zt===null?Ht=ki:Zt.sibling=ki,Zt=ki);return o&&Qt.forEach(function(bg){return h(Ge,bg)}),en&&ko(Ge,si),Ht}function Wi(Ge,Re,We,pt){if(typeof We=="object"&&We!==null&&We.type===L&&We.key===null&&(We=We.props.children),typeof We=="object"&&We!==null){switch(We.$$typeof){case j:e:{for(var Ht=We.key,Zt=Re;Zt!==null;){if(Zt.key===Ht){if(Ht=We.type,Ht===L){if(Zt.tag===7){_(Ge,Zt.sibling),Re=O(Zt,We.props.children),Re.return=Ge,Ge=Re;break e}}else if(Zt.elementType===Ht||typeof Ht=="object"&&Ht!==null&&Ht.$$typeof===ve&&np(Ht)===Zt.type){_(Ge,Zt.sibling),Re=O(Zt,We.props),Re.ref=La(Ge,Zt,We),Re.return=Ge,Ge=Re;break e}_(Ge,Zt);break}else h(Ge,Zt);Zt=Zt.sibling}We.type===L?(Re=Ka(We.props.children,Ge.mode,pt,We.key),Re.return=Ge,Ge=Re):(pt=td(We.type,We.key,We.props,null,Ge.mode,pt),pt.ref=La(Ge,Re,We),pt.return=Ge,Ge=pt)}return ne(Ge);case N:e:{for(Zt=We.key;Re!==null;){if(Re.key===Zt)if(Re.tag===4&&Re.stateNode.containerInfo===We.containerInfo&&Re.stateNode.implementation===We.implementation){_(Ge,Re.sibling),Re=O(Re,We.children||[]),Re.return=Ge,Ge=Re;break e}else{_(Ge,Re);break}else h(Ge,Re);Re=Re.sibling}Re=eh(We,Ge.mode,pt),Re.return=Ge,Ge=Re}return ne(Ge);case ve:return Zt=We._init,Wi(Ge,Re,Zt(We._payload),pt)}if(_i(We))return Ot(Ge,Re,We,pt);if(U(We))return Lt(Ge,Re,We,pt);jc(Ge,We)}return typeof We=="string"&&We!==""||typeof We=="number"?(We=""+We,Re!==null&&Re.tag===6?(_(Ge,Re.sibling),Re=O(Re,We),Re.return=Ge,Ge=Re):(_(Ge,Re),Re=Qu(We,Ge.mode,pt),Re.return=Ge,Ge=Re),ne(Ge)):_(Ge,Re)}return Wi}var za=Bm(!0),nu=Bm(!1),ea=Zr(null),Rc=null,ta=null,su=null;function ru(){su=ta=Rc=null}function ou(o){var h=ea.current;Ki(ea),o._currentValue=h}function sp(o,h,_){for(;o!==null;){var A=o.alternate;if((o.childLanes&h)!==h?(o.childLanes|=h,A!==null&&(A.childLanes|=h)):A!==null&&(A.childLanes&h)!==h&&(A.childLanes|=h),o===_)break;o=o.return}}function Ba(o,h){Rc=o,su=ta=null,o=o.dependencies,o!==null&&o.firstContext!==null&&((o.lanes&h)!==0&&(ks=!0),o.firstContext=null)}function Ys(o){var h=o._currentValue;if(su!==o)if(o={context:o,memoizedValue:h,next:null},ta===null){if(Rc===null)throw Error(t(308));ta=o,Rc.dependencies={lanes:0,firstContext:o}}else ta=ta.next=o;return h}var Ga=null;function au(o){Ga===null?Ga=[o]:Ga.push(o)}function Nc(o,h,_,A){var O=h.interleaved;return O===null?(_.next=_,au(h)):(_.next=O.next,O.next=_),h.interleaved=_,eo(o,A)}function eo(o,h){o.lanes|=h;var _=o.alternate;for(_!==null&&(_.lanes|=h),_=o,o=o.return;o!==null;)o.childLanes|=h,_=o.alternate,_!==null&&(_.childLanes|=h),_=o,o=o.return;return _.tag===3?_.stateNode:null}var zr=!1;function Mc(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function lu(o,h){o=o.updateQueue,h.updateQueue===o&&(h.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,effects:o.effects})}function to(o,h){return{eventTime:o,lane:h,tag:0,payload:null,callback:null,next:null}}function Eo(o,h,_){var A=o.updateQueue;if(A===null)return null;if(A=A.shared,(xi&2)!==0){var O=A.pending;return O===null?h.next=h:(h.next=O.next,O.next=h),A.pending=h,eo(o,_)}return O=A.interleaved,O===null?(h.next=h,au(A)):(h.next=O.next,O.next=h),A.interleaved=h,eo(o,_)}function Dl(o,h,_){if(h=h.updateQueue,h!==null&&(h=h.shared,(_&4194240)!==0)){var A=h.lanes;A&=o.pendingLanes,_|=A,h.lanes=_,me(o,_)}}function Gm(o,h){var _=o.updateQueue,A=o.alternate;if(A!==null&&(A=A.updateQueue,_===A)){var O=null,H=null;if(_=_.firstBaseUpdate,_!==null){do{var ne={eventTime:_.eventTime,lane:_.lane,tag:_.tag,payload:_.payload,callback:_.callback,next:null};H===null?O=H=ne:H=H.next=ne,_=_.next}while(_!==null);H===null?O=H=h:H=H.next=h}else O=H=h;_={baseState:A.baseState,firstBaseUpdate:O,lastBaseUpdate:H,shared:A.shared,effects:A.effects},o.updateQueue=_;return}o=_.lastBaseUpdate,o===null?_.firstBaseUpdate=h:o.next=h,_.lastBaseUpdate=h}function Oc(o,h,_,A){var O=o.updateQueue;zr=!1;var H=O.firstBaseUpdate,ne=O.lastBaseUpdate,_e=O.shared.pending;if(_e!==null){O.shared.pending=null;var De=_e,He=De.next;De.next=null,ne===null?H=He:ne.next=He,ne=De;var lt=o.alternate;lt!==null&&(lt=lt.updateQueue,_e=lt.lastBaseUpdate,_e!==ne&&(_e===null?lt.firstBaseUpdate=He:_e.next=He,lt.lastBaseUpdate=De))}if(H!==null){var ct=O.baseState;ne=0,lt=He=De=null,_e=H;do{var at=_e.lane,Dt=_e.eventTime;if((A&at)===at){lt!==null&&(lt=lt.next={eventTime:Dt,lane:0,tag:_e.tag,payload:_e.payload,callback:_e.callback,next:null});e:{var Ot=o,Lt=_e;switch(at=h,Dt=_,Lt.tag){case 1:if(Ot=Lt.payload,typeof Ot=="function"){ct=Ot.call(Dt,ct,at);break e}ct=Ot;break e;case 3:Ot.flags=Ot.flags&-65537|128;case 0:if(Ot=Lt.payload,at=typeof Ot=="function"?Ot.call(Dt,ct,at):Ot,at==null)break e;ct=X({},ct,at);break e;case 2:zr=!0}}_e.callback!==null&&_e.lane!==0&&(o.flags|=64,at=O.effects,at===null?O.effects=[_e]:at.push(_e))}else Dt={eventTime:Dt,lane:at,tag:_e.tag,payload:_e.payload,callback:_e.callback,next:null},lt===null?(He=lt=Dt,De=ct):lt=lt.next=Dt,ne|=at;if(_e=_e.next,_e===null){if(_e=O.shared.pending,_e===null)break;at=_e,_e=at.next,at.next=null,O.lastBaseUpdate=at,O.shared.pending=null}}while(!0);if(lt===null&&(De=ct),O.baseState=De,O.firstBaseUpdate=He,O.lastBaseUpdate=lt,h=O.shared.interleaved,h!==null){O=h;do ne|=O.lane,O=O.next;while(O!==h)}else H===null&&(O.shared.lanes=0);aa|=ne,o.lanes=ne,o.memoizedState=ct}}function Fm(o,h,_){if(o=h.effects,h.effects=null,o!==null)for(h=0;h<o.length;h++){var A=o[h],O=A.callback;if(O!==null){if(A.callback=null,A=_,typeof O!="function")throw Error(t(191,O));O.call(A)}}}var $l={},Br=Zr($l),Al=Zr($l),Fa=Zr($l);function ia(o){if(o===$l)throw Error(t(174));return o}function cu(o,h){switch(Hi(Fa,h),Hi(Al,o),Hi(Br,$l),o=h.nodeType,o){case 9:case 11:h=(h=h.documentElement)?h.namespaceURI:ht(null,"");break;default:o=o===8?h.parentNode:h,h=o.namespaceURI||null,o=o.tagName,h=ht(h,o)}Ki(Br),Hi(Br,h)}function na(){Ki(Br),Ki(Al),Ki(Fa)}function rp(o){ia(Fa.current);var h=ia(Br.current),_=ht(h,o.type);h!==_&&(Hi(Al,o),Hi(Br,_))}function du(o){Al.current===o&&(Ki(Br),Ki(Al))}var nn=Zr(0);function Lc(o){for(var h=o;h!==null;){if(h.tag===13){var _=h.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||_.data==="$?"||_.data==="$!"))return h}else if(h.tag===19&&h.memoizedProps.revealOrder!==void 0){if((h.flags&128)!==0)return h}else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===o)break;for(;h.sibling===null;){if(h.return===null||h.return===o)return null;h=h.return}h.sibling.return=h.return,h=h.sibling}return null}var uu=[];function hu(){for(var o=0;o<uu.length;o++)uu[o]._workInProgressVersionPrimary=null;uu.length=0}var pu=T.ReactCurrentDispatcher,fu=T.ReactCurrentBatchConfig,sa=0,tn=null,_n=null,Tn=null,mu=!1,ra=!1,To=0,op=0;function qn(){throw Error(t(321))}function gu(o,h){if(h===null)return!1;for(var _=0;_<h.length&&_<o.length;_++)if(!pr(o[_],h[_]))return!1;return!0}function vu(o,h,_,A,O,H){if(sa=H,tn=h,h.memoizedState=null,h.updateQueue=null,h.lanes=0,pu.current=o===null||o.memoizedState===null?Km:Ym,o=_(A,O),ra){H=0;do{if(ra=!1,To=0,25<=H)throw Error(t(301));H+=1,Tn=_n=null,h.updateQueue=null,pu.current=l_,o=_(A,O)}while(ra)}if(pu.current=Fc,h=_n!==null&&_n.next!==null,sa=0,Tn=_n=tn=null,mu=!1,h)throw Error(t(300));return o}function _u(){var o=To!==0;return To=0,o}function mr(){var o={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Tn===null?tn.memoizedState=Tn=o:Tn=Tn.next=o,Tn}function Xs(){if(_n===null){var o=tn.alternate;o=o!==null?o.memoizedState:null}else o=_n.next;var h=Tn===null?tn.memoizedState:Tn.next;if(h!==null)Tn=h,_n=o;else{if(o===null)throw Error(t(310));_n=o,o={memoizedState:_n.memoizedState,baseState:_n.baseState,baseQueue:_n.baseQueue,queue:_n.queue,next:null},Tn===null?tn.memoizedState=Tn=o:Tn=Tn.next=o}return Tn}function Il(o,h){return typeof h=="function"?h(o):h}function bu(o){var h=Xs(),_=h.queue;if(_===null)throw Error(t(311));_.lastRenderedReducer=o;var A=_n,O=A.baseQueue,H=_.pending;if(H!==null){if(O!==null){var ne=O.next;O.next=H.next,H.next=ne}A.baseQueue=O=H,_.pending=null}if(O!==null){H=O.next,A=A.baseState;var _e=ne=null,De=null,He=H;do{var lt=He.lane;if((sa<)===lt)De!==null&&(De=De.next={lane:0,action:He.action,hasEagerState:He.hasEagerState,eagerState:He.eagerState,next:null}),A=He.hasEagerState?He.eagerState:o(A,He.action);else{var ct={lane:lt,action:He.action,hasEagerState:He.hasEagerState,eagerState:He.eagerState,next:null};De===null?(_e=De=ct,ne=A):De=De.next=ct,tn.lanes|=lt,aa|=lt}He=He.next}while(He!==null&&He!==H);De===null?ne=A:De.next=_e,pr(A,h.memoizedState)||(ks=!0),h.memoizedState=A,h.baseState=ne,h.baseQueue=De,_.lastRenderedState=A}if(o=_.interleaved,o!==null){O=o;do H=O.lane,tn.lanes|=H,aa|=H,O=O.next;while(O!==o)}else O===null&&(_.lanes=0);return[h.memoizedState,_.dispatch]}function ap(o){var h=Xs(),_=h.queue;if(_===null)throw Error(t(311));_.lastRenderedReducer=o;var A=_.dispatch,O=_.pending,H=h.memoizedState;if(O!==null){_.pending=null;var ne=O=O.next;do H=o(H,ne.action),ne=ne.next;while(ne!==O);pr(H,h.memoizedState)||(ks=!0),h.memoizedState=H,h.baseQueue===null&&(h.baseState=H),_.lastRenderedState=H}return[H,A]}function lp(){}function wu(o,h){var _=tn,A=Xs(),O=h(),H=!pr(A.memoizedState,O);if(H&&(A.memoizedState=O,ks=!0),A=A.queue,gp(up.bind(null,_,A,o),[o]),A.getSnapshot!==h||H||Tn!==null&&Tn.memoizedState.tag&1){if(_.flags|=2048,zc(9,dp.bind(null,_,A,O,h),void 0,null),wn===null)throw Error(t(349));(sa&30)!==0||cp(_,h,O)}return O}function cp(o,h,_){o.flags|=16384,o={getSnapshot:h,value:_},h=tn.updateQueue,h===null?(h={lastEffect:null,stores:null},tn.updateQueue=h,h.stores=[o]):(_=h.stores,_===null?h.stores=[o]:_.push(o))}function dp(o,h,_,A){h.value=_,h.getSnapshot=A,Hm(h)&&hp(o)}function up(o,h,_){return _(function(){Hm(h)&&hp(o)})}function Hm(o){var h=o.getSnapshot;o=o.value;try{var _=h();return!pr(o,_)}catch{return!0}}function hp(o){var h=eo(o,1);h!==null&&_r(h,o,1,-1)}function pp(o){var h=mr();return typeof o=="function"&&(o=o()),h.memoizedState=h.baseState=o,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Il,lastRenderedState:o},h.queue=o,o=o.dispatch=Vm.bind(null,tn,o),[h.memoizedState,o]}function zc(o,h,_,A){return o={tag:o,create:h,destroy:_,deps:A,next:null},h=tn.updateQueue,h===null?(h={lastEffect:null,stores:null},tn.updateQueue=h,h.lastEffect=o.next=o):(_=h.lastEffect,_===null?h.lastEffect=o.next=o:(A=_.next,_.next=o,o.next=A,h.lastEffect=o)),o}function fp(){return Xs().memoizedState}function Bc(o,h,_,A){var O=mr();tn.flags|=o,O.memoizedState=zc(1|h,_,void 0,A===void 0?null:A)}function Gc(o,h,_,A){var O=Xs();A=A===void 0?null:A;var H=void 0;if(_n!==null){var ne=_n.memoizedState;if(H=ne.destroy,A!==null&&gu(A,ne.deps)){O.memoizedState=zc(h,_,H,A);return}}tn.flags|=o,O.memoizedState=zc(1|h,_,H,A)}function mp(o,h){return Bc(8390656,8,o,h)}function gp(o,h){return Gc(2048,8,o,h)}function vp(o,h){return Gc(4,2,o,h)}function _p(o,h){return Gc(4,4,o,h)}function bp(o,h){if(typeof h=="function")return o=o(),h(o),function(){h(null)};if(h!=null)return o=o(),h.current=o,function(){h.current=null}}function Wm(o,h,_){return _=_!=null?_.concat([o]):null,Gc(4,4,bp.bind(null,h,o),_)}function yu(){}function wp(o,h){var _=Xs();h=h===void 0?null:h;var A=_.memoizedState;return A!==null&&h!==null&&gu(h,A[1])?A[0]:(_.memoizedState=[o,h],o)}function yp(o,h){var _=Xs();h=h===void 0?null:h;var A=_.memoizedState;return A!==null&&h!==null&&gu(h,A[1])?A[0]:(o=o(),_.memoizedState=[o,h],o)}function xp(o,h,_){return(sa&21)===0?(o.baseState&&(o.baseState=!1,ks=!0),o.memoizedState=_):(pr(_,h)||(_=Ns(),tn.lanes|=_,aa|=_,o.baseState=!0),h)}function a_(o,h){var _=Ne;Ne=_!==0&&4>_?_:4,o(!0);var A=fu.transition;fu.transition={};try{o(!1),h()}finally{Ne=_,fu.transition=A}}function Sp(){return Xs().memoizedState}function Um(o,h,_){var A=Io(o);if(_={lane:A,action:_,hasEagerState:!1,eagerState:null,next:null},Cp(o))qm(h,_);else if(_=Nc(o,h,_,A),_!==null){var O=cs();_r(_,o,A,O),kp(_,h,A)}}function Vm(o,h,_){var A=Io(o),O={lane:A,action:_,hasEagerState:!1,eagerState:null,next:null};if(Cp(o))qm(h,O);else{var H=o.alternate;if(o.lanes===0&&(H===null||H.lanes===0)&&(H=h.lastRenderedReducer,H!==null))try{var ne=h.lastRenderedState,_e=H(ne,_);if(O.hasEagerState=!0,O.eagerState=_e,pr(_e,ne)){var De=h.interleaved;De===null?(O.next=O,au(h)):(O.next=De.next,De.next=O),h.interleaved=O;return}}catch{}finally{}_=Nc(o,h,O,A),_!==null&&(O=cs(),_r(_,o,A,O),kp(_,h,A))}}function Cp(o){var h=o.alternate;return o===tn||h!==null&&h===tn}function qm(o,h){ra=mu=!0;var _=o.pending;_===null?h.next=h:(h.next=_.next,_.next=h),o.pending=h}function kp(o,h,_){if((_&4194240)!==0){var A=h.lanes;A&=o.pendingLanes,_|=A,h.lanes=_,me(o,_)}}var Fc={readContext:Ys,useCallback:qn,useContext:qn,useEffect:qn,useImperativeHandle:qn,useInsertionEffect:qn,useLayoutEffect:qn,useMemo:qn,useReducer:qn,useRef:qn,useState:qn,useDebugValue:qn,useDeferredValue:qn,useTransition:qn,useMutableSource:qn,useSyncExternalStore:qn,useId:qn,unstable_isNewReconciler:!1},Km={readContext:Ys,useCallback:function(o,h){return mr().memoizedState=[o,h===void 0?null:h],o},useContext:Ys,useEffect:mp,useImperativeHandle:function(o,h,_){return _=_!=null?_.concat([o]):null,Bc(4194308,4,bp.bind(null,h,o),_)},useLayoutEffect:function(o,h){return Bc(4194308,4,o,h)},useInsertionEffect:function(o,h){return Bc(4,2,o,h)},useMemo:function(o,h){var _=mr();return h=h===void 0?null:h,o=o(),_.memoizedState=[o,h],o},useReducer:function(o,h,_){var A=mr();return h=_!==void 0?_(h):h,A.memoizedState=A.baseState=h,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:h},A.queue=o,o=o.dispatch=Um.bind(null,tn,o),[A.memoizedState,o]},useRef:function(o){var h=mr();return o={current:o},h.memoizedState=o},useState:pp,useDebugValue:yu,useDeferredValue:function(o){return mr().memoizedState=o},useTransition:function(){var o=pp(!1),h=o[0];return o=a_.bind(null,o[1]),mr().memoizedState=o,[h,o]},useMutableSource:function(){},useSyncExternalStore:function(o,h,_){var A=tn,O=mr();if(en){if(_===void 0)throw Error(t(407));_=_()}else{if(_=h(),wn===null)throw Error(t(349));(sa&30)!==0||cp(A,h,_)}O.memoizedState=_;var H={value:_,getSnapshot:h};return O.queue=H,mp(up.bind(null,A,H,o),[o]),A.flags|=2048,zc(9,dp.bind(null,A,H,_,h),void 0,null),_},useId:function(){var o=mr(),h=wn.identifierPrefix;if(en){var _=xs,A=ys;_=(A&~(1<<32-Qi(A)-1)).toString(32)+_,h=":"+h+"R"+_,_=To++,0<_&&(h+="H"+_.toString(32)),h+=":"}else _=op++,h=":"+h+"r"+_.toString(32)+":";return o.memoizedState=h},unstable_isNewReconciler:!1},Ym={readContext:Ys,useCallback:wp,useContext:Ys,useEffect:gp,useImperativeHandle:Wm,useInsertionEffect:vp,useLayoutEffect:_p,useMemo:yp,useReducer:bu,useRef:fp,useState:function(){return bu(Il)},useDebugValue:yu,useDeferredValue:function(o){var h=Xs();return xp(h,_n.memoizedState,o)},useTransition:function(){var o=bu(Il)[0],h=Xs().memoizedState;return[o,h]},useMutableSource:lp,useSyncExternalStore:wu,useId:Sp,unstable_isNewReconciler:!1},l_={readContext:Ys,useCallback:wp,useContext:Ys,useEffect:gp,useImperativeHandle:Wm,useInsertionEffect:vp,useLayoutEffect:_p,useMemo:yp,useReducer:ap,useRef:fp,useState:function(){return ap(Il)},useDebugValue:yu,useDeferredValue:function(o){var h=Xs();return _n===null?h.memoizedState=o:xp(h,_n.memoizedState,o)},useTransition:function(){var o=ap(Il)[0],h=Xs().memoizedState;return[o,h]},useMutableSource:lp,useSyncExternalStore:wu,useId:Sp,unstable_isNewReconciler:!1};function bn(o,h){if(o&&o.defaultProps){h=X({},h),o=o.defaultProps;for(var _ in o)h[_]===void 0&&(h[_]=o[_]);return h}return h}function Gr(o,h,_,A){h=o.memoizedState,_=_(A,h),_=_==null?h:X({},h,_),o.memoizedState=_,o.lanes===0&&(o.updateQueue.baseState=_)}var io={isMounted:function(o){return(o=o._reactInternals)?Tt(o)===o:!1},enqueueSetState:function(o,h,_){o=o._reactInternals;var A=cs(),O=Io(o),H=to(A,O);H.payload=h,_!=null&&(H.callback=_),h=Eo(o,H,O),h!==null&&(_r(h,o,O,A),Dl(h,o,O))},enqueueReplaceState:function(o,h,_){o=o._reactInternals;var A=cs(),O=Io(o),H=to(A,O);H.tag=1,H.payload=h,_!=null&&(H.callback=_),h=Eo(o,H,O),h!==null&&(_r(h,o,O,A),Dl(h,o,O))},enqueueForceUpdate:function(o,h){o=o._reactInternals;var _=cs(),A=Io(o),O=to(_,A);O.tag=2,h!=null&&(O.callback=h),h=Eo(o,O,A),h!==null&&(_r(h,o,A,_),Dl(h,o,A))}};function oa(o,h,_,A,O,H,ne){return o=o.stateNode,typeof o.shouldComponentUpdate=="function"?o.shouldComponentUpdate(A,H,ne):h.prototype&&h.prototype.isPureReactComponent?!bl(_,A)||!bl(O,H):!0}function Ep(o,h,_){var A=!1,O=So,H=h.contextType;return typeof H=="object"&&H!==null?H=Ys(H):(O=ws(h)?Jo:os.current,A=h.contextTypes,H=(A=A!=null)?as(o,O):So),h=new h(_,H),o.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=io,o.stateNode=h,h._reactInternals=o,A&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=O,o.__reactInternalMemoizedMaskedChildContext=H),h}function Tp(o,h,_,A){o=h.state,typeof h.componentWillReceiveProps=="function"&&h.componentWillReceiveProps(_,A),typeof h.UNSAFE_componentWillReceiveProps=="function"&&h.UNSAFE_componentWillReceiveProps(_,A),h.state!==o&&io.enqueueReplaceState(h,h.state,null)}function xu(o,h,_,A){var O=o.stateNode;O.props=_,O.state=o.memoizedState,O.refs={},Mc(o);var H=h.contextType;typeof H=="object"&&H!==null?O.context=Ys(H):(H=ws(h)?Jo:os.current,O.context=as(o,H)),O.state=o.memoizedState,H=h.getDerivedStateFromProps,typeof H=="function"&&(Gr(o,h,H,_),O.state=o.memoizedState),typeof h.getDerivedStateFromProps=="function"||typeof O.getSnapshotBeforeUpdate=="function"||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(h=O.state,typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount(),h!==O.state&&io.enqueueReplaceState(O,O.state,null),Oc(o,_,O,A),O.state=o.memoizedState),typeof O.componentDidMount=="function"&&(o.flags|=4194308)}function Ha(o,h){try{var _="",A=h;do _+=Oe(A),A=A.return;while(A);var O=_}catch(H){O=`
|
|
40
40
|
Error generating stack: `+H.message+`
|
|
41
|
-
`+H.stack}return{value:o,source:h,stack:O,digest:null}}function Su(o,h,_){return{value:o,source:null,stack:_??null,digest:h??null}}function Cu(o,h){try{console.error(h.value)}catch(_){setTimeout(function(){throw _})}}var Xm=typeof WeakMap=="function"?WeakMap:Map;function Dp(o,h,_){_=to(-1,_),_.tag=3,_.payload={element:null};var A=h.value;return _.callback=function(){Xc||(Xc=!0,Uu=A),Cu(o,h)},_}function $p(o,h,_){_=to(-1,_),_.tag=3;var A=o.type.getDerivedStateFromError;if(typeof A=="function"){var O=h.value;_.payload=function(){return A(O)},_.callback=function(){Cu(o,h)}}var H=o.stateNode;return H!==null&&typeof H.componentDidCatch=="function"&&(_.callback=function(){Cu(o,h),typeof A!="function"&&(Ao===null?Ao=new Set([this]):Ao.add(this));var ne=h.stack;this.componentDidCatch(h.value,{componentStack:ne!==null?ne:""})}),_}function Ap(o,h,_){var A=o.pingCache;if(A===null){A=o.pingCache=new Xm;var O=new Set;A.set(h,O)}else O=A.get(h),O===void 0&&(O=new Set,A.set(h,O));O.has(_)||(O.add(_),o=lg.bind(null,o,h,_),h.then(o,o))}function Jm(o){do{var h;if((h=o.tag===13)&&(h=o.memoizedState,h=h!==null?h.dehydrated!==null:!0),h)return o;o=o.return}while(o!==null);return null}function ls(o,h,_,A,O){return(o.mode&1)===0?(o===h?o.flags|=65536:(o.flags|=128,_.flags|=131072,_.flags&=-52805,_.tag===1&&(_.alternate===null?_.tag=17:(h=to(-1,1),h.tag=2,Eo(_,h,1))),_.lanes|=1),o):(o.flags|=65536,o.lanes=O,o)}var Zm=T.ReactCurrentOwner,ks=!1;function Kn(o,h,_,A){h.child=o===null?nu(h,null,_,A):za(h,o.child,_,A)}function Ip(o,h,_,A,O){_=_.render;var H=h.ref;return Ba(h,O),A=vu(o,h,_,A,H,O),_=_u(),o!==null&&!ks?(h.updateQueue=o.updateQueue,h.flags&=-2053,o.lanes&=~O,no(o,h,O)):(en&&_&&vn(h),h.flags|=1,Kn(o,h,A,O),h.child)}function Pl(o,h,_,A,O){if(o===null){var H=_.type;return typeof H=="function"&&!Zu(H)&&H.defaultProps===void 0&&_.compare===null&&_.defaultProps===void 0?(h.tag=15,h.type=H,Pp(o,h,H,A,O)):(o=td(_.type,null,A,h,h.mode,O),o.ref=h.ref,o.return=h,h.child=o)}if(H=o.child,(o.lanes&O)===0){var ne=H.memoizedProps;if(_=_.compare,_=_!==null?_:bl,_(ne,A)&&o.ref===h.ref)return no(o,h,O)}return h.flags|=1,o=jo(H,A),o.ref=h.ref,o.return=h,h.child=o}function Pp(o,h,_,A,O){if(o!==null){var H=o.memoizedProps;if(bl(H,A)&&o.ref===h.ref)if(ks=!1,h.pendingProps=A=H,(o.lanes&O)!==0)(o.flags&131072)!==0&&(ks=!0);else return h.lanes=o.lanes,no(o,h,O)}return ku(o,h,_,A,O)}function jp(o,h,_){var A=h.pendingProps,O=A.children,H=o!==null?o.memoizedState:null;if(A.mode==="hidden")if((h.mode&1)===0)h.memoizedState={baseLanes:0,cachePool:null,transitions:null},Hi(Ua,Os),Os|=_;else{if((_&1073741824)===0)return o=H!==null?H.baseLanes|_:_,h.lanes=h.childLanes=1073741824,h.memoizedState={baseLanes:o,cachePool:null,transitions:null},h.updateQueue=null,Hi(Ua,Os),Os|=o,null;h.memoizedState={baseLanes:0,cachePool:null,transitions:null},A=H!==null?H.baseLanes:_,Hi(Ua,Os),Os|=A}else H!==null?(A=H.baseLanes|_,h.memoizedState=null):A=_,Hi(Ua,Os),Os|=A;return Kn(o,h,O,_),h.child}function Rp(o,h){var _=h.ref;(o===null&&_!==null||o!==null&&o.ref!==_)&&(h.flags|=512,h.flags|=2097152)}function ku(o,h,_,A,O){var H=ws(_)?Jo:os.current;return H=as(h,H),Ba(h,O),_=vu(o,h,_,A,H,O),A=_u(),o!==null&&!ks?(h.updateQueue=o.updateQueue,h.flags&=-2053,o.lanes&=~O,no(o,h,O)):(en&&A&&vn(h),h.flags|=1,Kn(o,h,_,O),h.child)}function Np(o,h,_,A,O){if(ws(_)){var H=!0;$c(h)}else H=!1;if(Ba(h,O),h.stateNode===null)Wc(o,h),Ep(h,_,A),xu(h,_,A,O),A=!0;else if(o===null){var ne=h.stateNode,_e=h.memoizedProps;ne.props=_e;var De=ne.context,He=_.contextType;typeof He=="object"&&He!==null?He=Ys(He):(He=ws(_)?Jo:os.current,He=as(h,He));var lt=_.getDerivedStateFromProps,ct=typeof lt=="function"||typeof ne.getSnapshotBeforeUpdate=="function";ct||typeof ne.UNSAFE_componentWillReceiveProps!="function"&&typeof ne.componentWillReceiveProps!="function"||(_e!==A||De!==He)&&Tp(h,ne,A,He),zr=!1;var at=h.memoizedState;ne.state=at,Oc(h,A,ne,O),De=h.memoizedState,_e!==A||at!==De||bs.current||zr?(typeof lt=="function"&&(Gr(h,_,lt,A),De=h.memoizedState),(_e=zr||oa(h,_,_e,A,at,De,He))?(ct||typeof ne.UNSAFE_componentWillMount!="function"&&typeof ne.componentWillMount!="function"||(typeof ne.componentWillMount=="function"&&ne.componentWillMount(),typeof ne.UNSAFE_componentWillMount=="function"&&ne.UNSAFE_componentWillMount()),typeof ne.componentDidMount=="function"&&(h.flags|=4194308)):(typeof ne.componentDidMount=="function"&&(h.flags|=4194308),h.memoizedProps=A,h.memoizedState=De),ne.props=A,ne.state=De,ne.context=He,A=_e):(typeof ne.componentDidMount=="function"&&(h.flags|=4194308),A=!1)}else{ne=h.stateNode,lu(o,h),_e=h.memoizedProps,He=h.type===h.elementType?_e:bn(h.type,_e),ne.props=He,ct=h.pendingProps,at=ne.context,De=_.contextType,typeof De=="object"&&De!==null?De=Ys(De):(De=ws(_)?Jo:os.current,De=as(h,De));var Dt=_.getDerivedStateFromProps;(lt=typeof Dt=="function"||typeof ne.getSnapshotBeforeUpdate=="function")||typeof ne.UNSAFE_componentWillReceiveProps!="function"&&typeof ne.componentWillReceiveProps!="function"||(_e!==ct||at!==De)&&Tp(h,ne,A,De),zr=!1,at=h.memoizedState,ne.state=at,Oc(h,A,ne,O);var Ot=h.memoizedState;_e!==ct||at!==Ot||bs.current||zr?(typeof Dt=="function"&&(Gr(h,_,Dt,A),Ot=h.memoizedState),(He=zr||oa(h,_,He,A,at,Ot,De)||!1)?(lt||typeof ne.UNSAFE_componentWillUpdate!="function"&&typeof ne.componentWillUpdate!="function"||(typeof ne.componentWillUpdate=="function"&&ne.componentWillUpdate(A,Ot,De),typeof ne.UNSAFE_componentWillUpdate=="function"&&ne.UNSAFE_componentWillUpdate(A,Ot,De)),typeof ne.componentDidUpdate=="function"&&(h.flags|=4),typeof ne.getSnapshotBeforeUpdate=="function"&&(h.flags|=1024)):(typeof ne.componentDidUpdate!="function"||_e===o.memoizedProps&&at===o.memoizedState||(h.flags|=4),typeof ne.getSnapshotBeforeUpdate!="function"||_e===o.memoizedProps&&at===o.memoizedState||(h.flags|=1024),h.memoizedProps=A,h.memoizedState=Ot),ne.props=A,ne.state=Ot,ne.context=De,A=He):(typeof ne.componentDidUpdate!="function"||_e===o.memoizedProps&&at===o.memoizedState||(h.flags|=4),typeof ne.getSnapshotBeforeUpdate!="function"||_e===o.memoizedProps&&at===o.memoizedState||(h.flags|=1024),A=!1)}return Eu(o,h,_,A,H,O)}function Eu(o,h,_,A,O,H){Rp(o,h);var ne=(h.flags&128)!==0;if(!A&&!ne)return O&&ep(h,_,!1),no(o,h,H);A=h.stateNode,Zm.current=h;var _e=ne&&typeof _.getDerivedStateFromError!="function"?null:A.render();return h.flags|=1,o!==null&&ne?(h.child=za(h,o.child,null,H),h.child=za(h,null,_e,H)):Kn(o,h,_e,H),h.memoizedState=A.state,O&&ep(h,_,!0),h.child}function Tu(o){var h=o.stateNode;h.pendingContext?Zh(o,h.pendingContext,h.pendingContext!==h.context):h.context&&Zh(o,h.context,!1),cu(o,h.containerInfo)}function Mp(o,h,_,A,O){return Qo(),tu(O),h.flags|=256,Kn(o,h,_,A),h.child}var Du={dehydrated:null,treeContext:null,retryLane:0};function $u(o){return{baseLanes:o,cachePool:null,transitions:null}}function Op(o,h,_){var A=h.pendingProps,O=nn.current,H=!1,ne=(h.flags&128)!==0,_e;if((_e=ne)||(_e=o!==null&&o.memoizedState===null?!1:(O&2)!==0),_e?(H=!0,h.flags&=-129):(o===null||o.memoizedState!==null)&&(O|=1),Hi(nn,O&1),o===null)return Qd(h),o=h.memoizedState,o!==null&&(o=o.dehydrated,o!==null)?((h.mode&1)===0?h.lanes=1:o.data==="$!"?h.lanes=8:h.lanes=1073741824,null):(ne=A.children,o=A.fallback,H?(A=h.mode,H=h.child,ne={mode:"hidden",children:ne},(A&1)===0&&H!==null?(H.childLanes=0,H.pendingProps=ne):H=id(ne,A,0,null),o=Ka(o,A,_,null),H.return=h,o.return=h,H.sibling=o,h.child=H,h.child.memoizedState=$u(_),h.memoizedState=Du,o):jl(h,ne));if(O=o.memoizedState,O!==null&&(_e=O.dehydrated,_e!==null))return Qm(o,h,ne,A,_e,O,_);if(H){H=A.fallback,ne=h.mode,O=o.child,_e=O.sibling;var De={mode:"hidden",children:A.children};return(ne&1)===0&&h.child!==O?(A=h.child,A.childLanes=0,A.pendingProps=De,h.deletions=null):(A=jo(O,De),A.subtreeFlags=O.subtreeFlags&14680064),_e!==null?H=jo(_e,H):(H=Ka(H,ne,_,null),H.flags|=2),H.return=h,A.return=h,A.sibling=H,h.child=A,A=H,H=h.child,ne=o.child.memoizedState,ne=ne===null?$u(_):{baseLanes:ne.baseLanes|_,cachePool:null,transitions:ne.transitions},H.memoizedState=ne,H.childLanes=o.childLanes&~_,h.memoizedState=Du,A}return H=o.child,o=H.sibling,A=jo(H,{mode:"visible",children:A.children}),(h.mode&1)===0&&(A.lanes=_),A.return=h,A.sibling=null,o!==null&&(_=h.deletions,_===null?(h.deletions=[o],h.flags|=16):_.push(o)),h.child=A,h.memoizedState=null,A}function jl(o,h){return h=id({mode:"visible",children:h},o.mode,0,null),h.return=o,o.child=h}function Hc(o,h,_,A){return A!==null&&tu(A),za(h,o.child,null,_),o=jl(h,h.pendingProps.children),o.flags|=2,h.memoizedState=null,o}function Qm(o,h,_,A,O,H,ne){if(_)return h.flags&256?(h.flags&=-257,A=Su(Error(t(422))),Hc(o,h,ne,A)):h.memoizedState!==null?(h.child=o.child,h.flags|=128,null):(H=A.fallback,O=h.mode,A=id({mode:"visible",children:A.children},O,0,null),H=Ka(H,O,ne,null),H.flags|=2,A.return=h,H.return=h,A.sibling=H,h.child=A,(h.mode&1)!==0&&za(h,o.child,null,ne),h.child.memoizedState=$u(ne),h.memoizedState=Du,H);if((h.mode&1)===0)return Hc(o,h,ne,null);if(O.data==="$!"){if(A=O.nextSibling&&O.nextSibling.dataset,A)var _e=A.dgst;return A=_e,H=Error(t(419)),A=Su(H,A,void 0),Hc(o,h,ne,A)}if(_e=(ne&o.childLanes)!==0,ks||_e){if(A=wn,A!==null){switch(ne&-ne){case 4:O=2;break;case 16:O=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:O=32;break;case 536870912:O=268435456;break;default:O=0}O=(O&(A.suspendedLanes|ne))!==0?0:O,O!==0&&O!==H.retryLane&&(H.retryLane=O,eo(o,O),_r(A,o,O,-1))}return Ju(),A=Su(Error(t(421))),Hc(o,h,ne,A)}return O.data==="$?"?(h.flags|=128,h.child=o.child,h=dg.bind(null,o),O._reactRetry=h,null):(o=H.treeContext,Ms=xo(O.nextSibling),Ss=h,en=!0,Cs=null,o!==null&&(qs[fr++]=ys,qs[fr++]=xs,qs[fr++]=Ks,ys=o.id,xs=o.overflow,Ks=h),h=jl(h,A.children),h.flags|=4096,h)}function Lp(o,h,_){o.lanes|=h;var A=o.alternate;A!==null&&(A.lanes|=h),sp(o.return,h,_)}function Au(o,h,_,A,O){var H=o.memoizedState;H===null?o.memoizedState={isBackwards:h,rendering:null,renderingStartTime:0,last:A,tail:_,tailMode:O}:(H.isBackwards=h,H.rendering=null,H.renderingStartTime=0,H.last=A,H.tail=_,H.tailMode=O)}function Iu(o,h,_){var A=h.pendingProps,O=A.revealOrder,H=A.tail;if(Kn(o,h,A.children,_),A=nn.current,(A&2)!==0)A=A&1|2,h.flags|=128;else{if(o!==null&&(o.flags&128)!==0)e:for(o=h.child;o!==null;){if(o.tag===13)o.memoizedState!==null&&Lp(o,_,h);else if(o.tag===19)Lp(o,_,h);else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===h)break e;for(;o.sibling===null;){if(o.return===null||o.return===h)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}A&=1}if(Hi(nn,A),(h.mode&1)===0)h.memoizedState=null;else switch(O){case"forwards":for(_=h.child,O=null;_!==null;)o=_.alternate,o!==null&&Lc(o)===null&&(O=_),_=_.sibling;_=O,_===null?(O=h.child,h.child=null):(O=_.sibling,_.sibling=null),Au(h,!1,O,_,H);break;case"backwards":for(_=null,O=h.child,h.child=null;O!==null;){if(o=O.alternate,o!==null&&Lc(o)===null){h.child=O;break}o=O.sibling,O.sibling=_,_=O,O=o}Au(h,!0,_,null,H);break;case"together":Au(h,!1,null,null,void 0);break;default:h.memoizedState=null}return h.child}function Wc(o,h){(h.mode&1)===0&&o!==null&&(o.alternate=null,h.alternate=null,h.flags|=2)}function no(o,h,_){if(o!==null&&(h.dependencies=o.dependencies),aa|=h.lanes,(_&h.childLanes)===0)return null;if(o!==null&&h.child!==o.child)throw Error(t(153));if(h.child!==null){for(o=h.child,_=jo(o,o.pendingProps),h.child=_,_.return=h;o.sibling!==null;)o=o.sibling,_=_.sibling=jo(o,o.pendingProps),_.return=h;_.sibling=null}return h.child}function c_(o,h,_){switch(h.tag){case 3:Tu(h),Qo();break;case 5:rp(h);break;case 1:ws(h.type)&&$c(h);break;case 4:cu(h,h.stateNode.containerInfo);break;case 10:var A=h.type._context,O=h.memoizedProps.value;Hi(ea,A._currentValue),A._currentValue=O;break;case 13:if(A=h.memoizedState,A!==null)return A.dehydrated!==null?(Hi(nn,nn.current&1),h.flags|=128,null):(_&h.child.childLanes)!==0?Op(o,h,_):(Hi(nn,nn.current&1),o=no(o,h,_),o!==null?o.sibling:null);Hi(nn,nn.current&1);break;case 19:if(A=(_&h.childLanes)!==0,(o.flags&128)!==0){if(A)return Iu(o,h,_);h.flags|=128}if(O=h.memoizedState,O!==null&&(O.rendering=null,O.tail=null,O.lastEffect=null),Hi(nn,nn.current),A)break;return null;case 22:case 23:return h.lanes=0,jp(o,h,_)}return no(o,h,_)}var Pu,ju,zp,Bp;Pu=function(o,h){for(var _=h.child;_!==null;){if(_.tag===5||_.tag===6)o.appendChild(_.stateNode);else if(_.tag!==4&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===h)break;for(;_.sibling===null;){if(_.return===null||_.return===h)return;_=_.return}_.sibling.return=_.return,_=_.sibling}},ju=function(){},zp=function(o,h,_,A){var O=o.memoizedProps;if(O!==A){o=h.stateNode,ia(Br.current);var H=null;switch(_){case"input":O=ft(o,O),A=ft(o,A),H=[];break;case"select":O=X({},O,{value:void 0}),A=X({},A,{value:void 0}),H=[];break;case"textarea":O=Pt(o,O),A=Pt(o,A),H=[];break;default:typeof O.onClick!="function"&&typeof A.onClick=="function"&&(o.onclick=Ec)}Sn(_,A);var ne;_=null;for(He in O)if(!A.hasOwnProperty(He)&&O.hasOwnProperty(He)&&O[He]!=null)if(He==="style"){var _e=O[He];for(ne in _e)_e.hasOwnProperty(ne)&&(_||(_={}),_[ne]="")}else He!=="dangerouslySetInnerHTML"&&He!=="children"&&He!=="suppressContentEditableWarning"&&He!=="suppressHydrationWarning"&&He!=="autoFocus"&&(r.hasOwnProperty(He)?H||(H=[]):(H=H||[]).push(He,null));for(He in A){var De=A[He];if(_e=O!=null?O[He]:void 0,A.hasOwnProperty(He)&&De!==_e&&(De!=null||_e!=null))if(He==="style")if(_e){for(ne in _e)!_e.hasOwnProperty(ne)||De&&De.hasOwnProperty(ne)||(_||(_={}),_[ne]="");for(ne in De)De.hasOwnProperty(ne)&&_e[ne]!==De[ne]&&(_||(_={}),_[ne]=De[ne])}else _||(H||(H=[]),H.push(He,_)),_=De;else He==="dangerouslySetInnerHTML"?(De=De?De.__html:void 0,_e=_e?_e.__html:void 0,De!=null&&_e!==De&&(H=H||[]).push(He,De)):He==="children"?typeof De!="string"&&typeof De!="number"||(H=H||[]).push(He,""+De):He!=="suppressContentEditableWarning"&&He!=="suppressHydrationWarning"&&(r.hasOwnProperty(He)?(De!=null&&He==="onScroll"&&qi("scroll",o),H||_e===De||(H=[])):(H=H||[]).push(He,De))}_&&(H=H||[]).push("style",_);var He=H;(h.updateQueue=He)&&(h.flags|=4)}},Bp=function(o,h,_,A){_!==A&&(h.flags|=4)};function Uc(o,h){if(!en)switch(o.tailMode){case"hidden":h=o.tail;for(var _=null;h!==null;)h.alternate!==null&&(_=h),h=h.sibling;_===null?o.tail=null:_.sibling=null;break;case"collapsed":_=o.tail;for(var A=null;_!==null;)_.alternate!==null&&(A=_),_=_.sibling;A===null?h||o.tail===null?o.tail=null:o.tail.sibling=null:A.sibling=null}}function Yn(o){var h=o.alternate!==null&&o.alternate.child===o.child,_=0,A=0;if(h)for(var O=o.child;O!==null;)_|=O.lanes|O.childLanes,A|=O.subtreeFlags&14680064,A|=O.flags&14680064,O.return=o,O=O.sibling;else for(O=o.child;O!==null;)_|=O.lanes|O.childLanes,A|=O.subtreeFlags,A|=O.flags,O.return=o,O=O.sibling;return o.subtreeFlags|=A,o.childLanes=_,h}function eg(o,h,_){var A=h.pendingProps;switch(Yd(h),h.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Yn(h),null;case 1:return ws(h.type)&&Dc(),Yn(h),null;case 3:return A=h.stateNode,na(),Ki(bs),Ki(os),hu(),A.pendingContext&&(A.context=A.pendingContext,A.pendingContext=null),(o===null||o.child===null)&&(Tl(h)?h.flags|=4:o===null||o.memoizedState.isDehydrated&&(h.flags&256)===0||(h.flags|=1024,Cs!==null&&(Ku(Cs),Cs=null))),ju(o,h),Yn(h),null;case 5:du(h);var O=ia(Fa.current);if(_=h.type,o!==null&&h.stateNode!=null)zp(o,h,_,A,O),o.ref!==h.ref&&(h.flags|=512,h.flags|=2097152);else{if(!A){if(h.stateNode===null)throw Error(t(166));return Yn(h),null}if(o=ia(Br.current),Tl(h)){A=h.stateNode,_=h.type;var H=h.memoizedProps;switch(A[Or]=h,A[kl]=H,o=(h.mode&1)!==0,_){case"dialog":qi("cancel",A),qi("close",A);break;case"iframe":case"object":case"embed":qi("load",A);break;case"video":case"audio":for(O=0;O<xl.length;O++)qi(xl[O],A);break;case"source":qi("error",A);break;case"img":case"image":case"link":qi("error",A),qi("load",A);break;case"details":qi("toggle",A);break;case"input":rt(A,H),qi("invalid",A);break;case"select":A._wrapperState={wasMultiple:!!H.multiple},qi("invalid",A);break;case"textarea":_t(A,H),qi("invalid",A)}Sn(_,H),O=null;for(var ne in H)if(H.hasOwnProperty(ne)){var _e=H[ne];ne==="children"?typeof _e=="string"?A.textContent!==_e&&(H.suppressHydrationWarning!==!0&&kc(A.textContent,_e,o),O=["children",_e]):typeof _e=="number"&&A.textContent!==""+_e&&(H.suppressHydrationWarning!==!0&&kc(A.textContent,_e,o),O=["children",""+_e]):r.hasOwnProperty(ne)&&_e!=null&&ne==="onScroll"&&qi("scroll",A)}switch(_){case"input":Ie(A),mi(A,H,!0);break;case"textarea":Ie(A),Se(A);break;case"select":case"option":break;default:typeof H.onClick=="function"&&(A.onclick=Ec)}A=O,h.updateQueue=A,A!==null&&(h.flags|=4)}else{ne=O.nodeType===9?O:O.ownerDocument,o==="http://www.w3.org/1999/xhtml"&&(o=tt(_)),o==="http://www.w3.org/1999/xhtml"?_==="script"?(o=ne.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild)):typeof A.is=="string"?o=ne.createElement(_,{is:A.is}):(o=ne.createElement(_),_==="select"&&(ne=o,A.multiple?ne.multiple=!0:A.size&&(ne.size=A.size))):o=ne.createElementNS(o,_),o[Or]=h,o[kl]=A,Pu(o,h,!1,!1),h.stateNode=o;e:{switch(ne=ai(_,A),_){case"dialog":qi("cancel",o),qi("close",o),O=A;break;case"iframe":case"object":case"embed":qi("load",o),O=A;break;case"video":case"audio":for(O=0;O<xl.length;O++)qi(xl[O],o);O=A;break;case"source":qi("error",o),O=A;break;case"img":case"image":case"link":qi("error",o),qi("load",o),O=A;break;case"details":qi("toggle",o),O=A;break;case"input":rt(o,A),O=ft(o,A),qi("invalid",o);break;case"option":O=A;break;case"select":o._wrapperState={wasMultiple:!!A.multiple},O=X({},A,{value:void 0}),qi("invalid",o);break;case"textarea":_t(o,A),O=Pt(o,A),qi("invalid",o);break;default:O=A}Sn(_,O),_e=O;for(H in _e)if(_e.hasOwnProperty(H)){var De=_e[H];H==="style"?wt(o,De):H==="dangerouslySetInnerHTML"?(De=De?De.__html:void 0,De!=null&&gi(o,De)):H==="children"?typeof De=="string"?(_!=="textarea"||De!=="")&&Jt(o,De):typeof De=="number"&&Jt(o,""+De):H!=="suppressContentEditableWarning"&&H!=="suppressHydrationWarning"&&H!=="autoFocus"&&(r.hasOwnProperty(H)?De!=null&&H==="onScroll"&&qi("scroll",o):De!=null&&S(o,H,De,ne))}switch(_){case"input":Ie(o),mi(o,A,!1);break;case"textarea":Ie(o),Se(o);break;case"option":A.value!=null&&o.setAttribute("value",""+J(A.value));break;case"select":o.multiple=!!A.multiple,H=A.value,H!=null?Je(o,!!A.multiple,H,!1):A.defaultValue!=null&&Je(o,!!A.multiple,A.defaultValue,!0);break;default:typeof O.onClick=="function"&&(o.onclick=Ec)}switch(_){case"button":case"input":case"select":case"textarea":A=!!A.autoFocus;break e;case"img":A=!0;break e;default:A=!1}}A&&(h.flags|=4)}h.ref!==null&&(h.flags|=512,h.flags|=2097152)}return Yn(h),null;case 6:if(o&&h.stateNode!=null)Bp(o,h,o.memoizedProps,A);else{if(typeof A!="string"&&h.stateNode===null)throw Error(t(166));if(_=ia(Fa.current),ia(Br.current),Tl(h)){if(A=h.stateNode,_=h.memoizedProps,A[Or]=h,(H=A.nodeValue!==_)&&(o=Ss,o!==null))switch(o.tag){case 3:kc(A.nodeValue,_,(o.mode&1)!==0);break;case 5:o.memoizedProps.suppressHydrationWarning!==!0&&kc(A.nodeValue,_,(o.mode&1)!==0)}H&&(h.flags|=4)}else A=(_.nodeType===9?_:_.ownerDocument).createTextNode(A),A[Or]=h,h.stateNode=A}return Yn(h),null;case 13:if(Ki(nn),A=h.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(en&&Ms!==null&&(h.mode&1)!==0&&(h.flags&128)===0)ip(),Qo(),h.flags|=98560,H=!1;else if(H=Tl(h),A!==null&&A.dehydrated!==null){if(o===null){if(!H)throw Error(t(318));if(H=h.memoizedState,H=H!==null?H.dehydrated:null,!H)throw Error(t(317));H[Or]=h}else Qo(),(h.flags&128)===0&&(h.memoizedState=null),h.flags|=4;Yn(h),H=!1}else Cs!==null&&(Ku(Cs),Cs=null),H=!0;if(!H)return h.flags&65536?h:null}return(h.flags&128)!==0?(h.lanes=_,h):(A=A!==null,A!==(o!==null&&o.memoizedState!==null)&&A&&(h.child.flags|=8192,(h.mode&1)!==0&&(o===null||(nn.current&1)!==0?Dn===0&&(Dn=3):Ju())),h.updateQueue!==null&&(h.flags|=4),Yn(h),null);case 4:return na(),ju(o,h),o===null&&Sl(h.stateNode.containerInfo),Yn(h),null;case 10:return ou(h.type._context),Yn(h),null;case 17:return ws(h.type)&&Dc(),Yn(h),null;case 19:if(Ki(nn),H=h.memoizedState,H===null)return Yn(h),null;if(A=(h.flags&128)!==0,ne=H.rendering,ne===null)if(A)Uc(H,!1);else{if(Dn!==0||o!==null&&(o.flags&128)!==0)for(o=h.child;o!==null;){if(ne=Lc(o),ne!==null){for(h.flags|=128,Uc(H,!1),A=ne.updateQueue,A!==null&&(h.updateQueue=A,h.flags|=4),h.subtreeFlags=0,A=_,_=h.child;_!==null;)H=_,o=A,H.flags&=14680066,ne=H.alternate,ne===null?(H.childLanes=0,H.lanes=o,H.child=null,H.subtreeFlags=0,H.memoizedProps=null,H.memoizedState=null,H.updateQueue=null,H.dependencies=null,H.stateNode=null):(H.childLanes=ne.childLanes,H.lanes=ne.lanes,H.child=ne.child,H.subtreeFlags=0,H.deletions=null,H.memoizedProps=ne.memoizedProps,H.memoizedState=ne.memoizedState,H.updateQueue=ne.updateQueue,H.type=ne.type,o=ne.dependencies,H.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),_=_.sibling;return Hi(nn,nn.current&1|2),h.child}o=o.sibling}H.tail!==null&&$i()>Va&&(h.flags|=128,A=!0,Uc(H,!1),h.lanes=4194304)}else{if(!A)if(o=Lc(ne),o!==null){if(h.flags|=128,A=!0,_=o.updateQueue,_!==null&&(h.updateQueue=_,h.flags|=4),Uc(H,!0),H.tail===null&&H.tailMode==="hidden"&&!ne.alternate&&!en)return Yn(h),null}else 2*$i()-H.renderingStartTime>Va&&_!==1073741824&&(h.flags|=128,A=!0,Uc(H,!1),h.lanes=4194304);H.isBackwards?(ne.sibling=h.child,h.child=ne):(_=H.last,_!==null?_.sibling=ne:h.child=ne,H.last=ne)}return H.tail!==null?(h=H.tail,H.rendering=h,H.tail=h.sibling,H.renderingStartTime=$i(),h.sibling=null,_=nn.current,Hi(nn,A?_&1|2:_&1),h):(Yn(h),null);case 22:case 23:return Xu(),A=h.memoizedState!==null,o!==null&&o.memoizedState!==null!==A&&(h.flags|=8192),A&&(h.mode&1)!==0?(Os&1073741824)!==0&&(Yn(h),h.subtreeFlags&6&&(h.flags|=8192)):Yn(h),null;case 24:return null;case 25:return null}throw Error(t(156,h.tag))}function tg(o,h){switch(Yd(h),h.tag){case 1:return ws(h.type)&&Dc(),o=h.flags,o&65536?(h.flags=o&-65537|128,h):null;case 3:return na(),Ki(bs),Ki(os),hu(),o=h.flags,(o&65536)!==0&&(o&128)===0?(h.flags=o&-65537|128,h):null;case 5:return du(h),null;case 13:if(Ki(nn),o=h.memoizedState,o!==null&&o.dehydrated!==null){if(h.alternate===null)throw Error(t(340));Qo()}return o=h.flags,o&65536?(h.flags=o&-65537|128,h):null;case 19:return Ki(nn),null;case 4:return na(),null;case 10:return ou(h.type._context),null;case 22:case 23:return Xu(),null;case 24:return null;default:return null}}var Ru=!1,Xn=!1,ig=typeof WeakSet=="function"?WeakSet:Set,Mt=null;function Wa(o,h){var _=o.ref;if(_!==null)if(typeof _=="function")try{_(null)}catch(A){sn(o,h,A)}else _.current=null}function Nu(o,h,_){try{_()}catch(A){sn(o,h,A)}}var Gp=!1;function ng(o,h){if(Gd=wo,o=jd(),Rd(o)){if("selectionStart"in o)var _={start:o.selectionStart,end:o.selectionEnd};else e:{_=(_=o.ownerDocument)&&_.defaultView||window;var A=_.getSelection&&_.getSelection();if(A&&A.rangeCount!==0){_=A.anchorNode;var O=A.anchorOffset,H=A.focusNode;A=A.focusOffset;try{_.nodeType,H.nodeType}catch{_=null;break e}var ne=0,_e=-1,De=-1,He=0,lt=0,ct=o,at=null;t:for(;;){for(var Dt;ct!==_||O!==0&&ct.nodeType!==3||(_e=ne+O),ct!==H||A!==0&&ct.nodeType!==3||(De=ne+A),ct.nodeType===3&&(ne+=ct.nodeValue.length),(Dt=ct.firstChild)!==null;)at=ct,ct=Dt;for(;;){if(ct===o)break t;if(at===_&&++He===O&&(_e=ne),at===H&&++lt===A&&(De=ne),(Dt=ct.nextSibling)!==null)break;ct=at,at=ct.parentNode}ct=Dt}_=_e===-1||De===-1?null:{start:_e,end:De}}else _=null}_=_||{start:0,end:0}}else _=null;for(Fd={focusedElem:o,selectionRange:_},wo=!1,Mt=h;Mt!==null;)if(h=Mt,o=h.child,(h.subtreeFlags&1028)!==0&&o!==null)o.return=h,Mt=o;else for(;Mt!==null;){h=Mt;try{var Ot=h.alternate;if((h.flags&1024)!==0)switch(h.tag){case 0:case 11:case 15:break;case 1:if(Ot!==null){var Lt=Ot.memoizedProps,Wi=Ot.memoizedState,Ge=h.stateNode,Re=Ge.getSnapshotBeforeUpdate(h.elementType===h.type?Lt:bn(h.type,Lt),Wi);Ge.__reactInternalSnapshotBeforeUpdate=Re}break;case 3:var We=h.stateNode.containerInfo;We.nodeType===1?We.textContent="":We.nodeType===9&&We.documentElement&&We.removeChild(We.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(pt){sn(h,h.return,pt)}if(o=h.sibling,o!==null){o.return=h.return,Mt=o;break}Mt=h.return}return Ot=Gp,Gp=!1,Ot}function Rl(o,h,_){var A=h.updateQueue;if(A=A!==null?A.lastEffect:null,A!==null){var O=A=A.next;do{if((O.tag&o)===o){var H=O.destroy;O.destroy=void 0,H!==void 0&&Nu(h,_,H)}O=O.next}while(O!==A)}}function Mu(o,h){if(h=h.updateQueue,h=h!==null?h.lastEffect:null,h!==null){var _=h=h.next;do{if((_.tag&o)===o){var A=_.create;_.destroy=A()}_=_.next}while(_!==h)}}function Ou(o){var h=o.ref;if(h!==null){var _=o.stateNode;switch(o.tag){case 5:o=_;break;default:o=_}typeof h=="function"?h(o):h.current=o}}function Fp(o){var h=o.alternate;h!==null&&(o.alternate=null,Fp(h)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(h=o.stateNode,h!==null&&(delete h[Or],delete h[kl],delete h[Vd],delete h[Xh],delete h[Jh])),o.stateNode=null,o.return=null,o.dependencies=null,o.memoizedProps=null,o.memoizedState=null,o.pendingProps=null,o.stateNode=null,o.updateQueue=null}function Hp(o){return o.tag===5||o.tag===3||o.tag===4}function Wp(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||Hp(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function Lu(o,h,_){var A=o.tag;if(A===5||A===6)o=o.stateNode,h?_.nodeType===8?_.parentNode.insertBefore(o,h):_.insertBefore(o,h):(_.nodeType===8?(h=_.parentNode,h.insertBefore(o,_)):(h=_,h.appendChild(o)),_=_._reactRootContainer,_!=null||h.onclick!==null||(h.onclick=Ec));else if(A!==4&&(o=o.child,o!==null))for(Lu(o,h,_),o=o.sibling;o!==null;)Lu(o,h,_),o=o.sibling}function zu(o,h,_){var A=o.tag;if(A===5||A===6)o=o.stateNode,h?_.insertBefore(o,h):_.appendChild(o);else if(A!==4&&(o=o.child,o!==null))for(zu(o,h,_),o=o.sibling;o!==null;)zu(o,h,_),o=o.sibling}var On=null,gr=!1;function Do(o,h,_){for(_=_.child;_!==null;)sg(o,h,_),_=_.sibling}function sg(o,h,_){if(Cn&&typeof Cn.onCommitFiberUnmount=="function")try{Cn.onCommitFiberUnmount(gs,_)}catch{}switch(_.tag){case 5:Xn||Wa(_,h);case 6:var A=On,O=gr;On=null,Do(o,h,_),On=A,gr=O,On!==null&&(gr?(o=On,_=_.stateNode,o.nodeType===8?o.parentNode.removeChild(_):o.removeChild(_)):On.removeChild(_.stateNode));break;case 18:On!==null&&(gr?(o=On,_=_.stateNode,o.nodeType===8?Ud(o.parentNode,_):o.nodeType===1&&Ud(o,_),Xr(o)):Ud(On,_.stateNode));break;case 4:A=On,O=gr,On=_.stateNode.containerInfo,gr=!0,Do(o,h,_),On=A,gr=O;break;case 0:case 11:case 14:case 15:if(!Xn&&(A=_.updateQueue,A!==null&&(A=A.lastEffect,A!==null))){O=A=A.next;do{var H=O,ne=H.destroy;H=H.tag,ne!==void 0&&((H&2)!==0||(H&4)!==0)&&Nu(_,h,ne),O=O.next}while(O!==A)}Do(o,h,_);break;case 1:if(!Xn&&(Wa(_,h),A=_.stateNode,typeof A.componentWillUnmount=="function"))try{A.props=_.memoizedProps,A.state=_.memoizedState,A.componentWillUnmount()}catch(_e){sn(_,h,_e)}Do(o,h,_);break;case 21:Do(o,h,_);break;case 22:_.mode&1?(Xn=(A=Xn)||_.memoizedState!==null,Do(o,h,_),Xn=A):Do(o,h,_);break;default:Do(o,h,_)}}function Nl(o){var h=o.updateQueue;if(h!==null){o.updateQueue=null;var _=o.stateNode;_===null&&(_=o.stateNode=new ig),h.forEach(function(A){var O=ug.bind(null,o,A);_.has(A)||(_.add(A),A.then(O,O))})}}function Js(o,h){var _=h.deletions;if(_!==null)for(var A=0;A<_.length;A++){var O=_[A];try{var H=o,ne=h,_e=ne;e:for(;_e!==null;){switch(_e.tag){case 5:On=_e.stateNode,gr=!1;break e;case 3:On=_e.stateNode.containerInfo,gr=!0;break e;case 4:On=_e.stateNode.containerInfo,gr=!0;break e}_e=_e.return}if(On===null)throw Error(t(160));sg(H,ne,O),On=null,gr=!1;var De=O.alternate;De!==null&&(De.return=null),O.return=null}catch(He){sn(O,h,He)}}if(h.subtreeFlags&12854)for(h=h.child;h!==null;)Bu(h,o),h=h.sibling}function Bu(o,h){var _=o.alternate,A=o.flags;switch(o.tag){case 0:case 11:case 14:case 15:if(Js(h,o),vr(o),A&4){try{Rl(3,o,o.return),Mu(3,o)}catch(Lt){sn(o,o.return,Lt)}try{Rl(5,o,o.return)}catch(Lt){sn(o,o.return,Lt)}}break;case 1:Js(h,o),vr(o),A&512&&_!==null&&Wa(_,_.return);break;case 5:if(Js(h,o),vr(o),A&512&&_!==null&&Wa(_,_.return),o.flags&32){var O=o.stateNode;try{Jt(O,"")}catch(Lt){sn(o,o.return,Lt)}}if(A&4&&(O=o.stateNode,O!=null)){var H=o.memoizedProps,ne=_!==null?_.memoizedProps:H,_e=o.type,De=o.updateQueue;if(o.updateQueue=null,De!==null)try{_e==="input"&&H.type==="radio"&&H.name!=null&&Nt(O,H),ai(_e,ne);var He=ai(_e,H);for(ne=0;ne<De.length;ne+=2){var lt=De[ne],ct=De[ne+1];lt==="style"?wt(O,ct):lt==="dangerouslySetInnerHTML"?gi(O,ct):lt==="children"?Jt(O,ct):S(O,lt,ct,He)}switch(_e){case"input":mt(O,H);break;case"textarea":hi(O,H);break;case"select":var at=O._wrapperState.wasMultiple;O._wrapperState.wasMultiple=!!H.multiple;var Dt=H.value;Dt!=null?Je(O,!!H.multiple,Dt,!1):at!==!!H.multiple&&(H.defaultValue!=null?Je(O,!!H.multiple,H.defaultValue,!0):Je(O,!!H.multiple,H.multiple?[]:"",!1))}O[kl]=H}catch(Lt){sn(o,o.return,Lt)}}break;case 6:if(Js(h,o),vr(o),A&4){if(o.stateNode===null)throw Error(t(162));O=o.stateNode,H=o.memoizedProps;try{O.nodeValue=H}catch(Lt){sn(o,o.return,Lt)}}break;case 3:if(Js(h,o),vr(o),A&4&&_!==null&&_.memoizedState.isDehydrated)try{Xr(h.containerInfo)}catch(Lt){sn(o,o.return,Lt)}break;case 4:Js(h,o),vr(o);break;case 13:Js(h,o),vr(o),O=o.child,O.flags&8192&&(H=O.memoizedState!==null,O.stateNode.isHidden=H,!H||O.alternate!==null&&O.alternate.memoizedState!==null||(Wu=$i())),A&4&&Nl(o);break;case 22:if(lt=_!==null&&_.memoizedState!==null,o.mode&1?(Xn=(He=Xn)||lt,Js(h,o),Xn=He):Js(h,o),vr(o),A&8192){if(He=o.memoizedState!==null,(o.stateNode.isHidden=He)&&!lt&&(o.mode&1)!==0)for(Mt=o,lt=o.child;lt!==null;){for(ct=Mt=lt;Mt!==null;){switch(at=Mt,Dt=at.child,at.tag){case 0:case 11:case 14:case 15:Rl(4,at,at.return);break;case 1:Wa(at,at.return);var Ot=at.stateNode;if(typeof Ot.componentWillUnmount=="function"){A=at,_=at.return;try{h=A,Ot.props=h.memoizedProps,Ot.state=h.memoizedState,Ot.componentWillUnmount()}catch(Lt){sn(A,_,Lt)}}break;case 5:Wa(at,at.return);break;case 22:if(at.memoizedState!==null){Gu(ct);continue}}Dt!==null?(Dt.return=at,Mt=Dt):Gu(ct)}lt=lt.sibling}e:for(lt=null,ct=o;;){if(ct.tag===5){if(lt===null){lt=ct;try{O=ct.stateNode,He?(H=O.style,typeof H.setProperty=="function"?H.setProperty("display","none","important"):H.display="none"):(_e=ct.stateNode,De=ct.memoizedProps.style,ne=De!=null&&De.hasOwnProperty("display")?De.display:null,_e.style.display=un("display",ne))}catch(Lt){sn(o,o.return,Lt)}}}else if(ct.tag===6){if(lt===null)try{ct.stateNode.nodeValue=He?"":ct.memoizedProps}catch(Lt){sn(o,o.return,Lt)}}else if((ct.tag!==22&&ct.tag!==23||ct.memoizedState===null||ct===o)&&ct.child!==null){ct.child.return=ct,ct=ct.child;continue}if(ct===o)break e;for(;ct.sibling===null;){if(ct.return===null||ct.return===o)break e;lt===ct&&(lt=null),ct=ct.return}lt===ct&&(lt=null),ct.sibling.return=ct.return,ct=ct.sibling}}break;case 19:Js(h,o),vr(o),A&4&&Nl(o);break;case 21:break;default:Js(h,o),vr(o)}}function vr(o){var h=o.flags;if(h&2){try{e:{for(var _=o.return;_!==null;){if(Hp(_)){var A=_;break e}_=_.return}throw Error(t(160))}switch(A.tag){case 5:var O=A.stateNode;A.flags&32&&(Jt(O,""),A.flags&=-33);var H=Wp(o);zu(o,H,O);break;case 3:case 4:var ne=A.stateNode.containerInfo,_e=Wp(o);Lu(o,_e,ne);break;default:throw Error(t(161))}}catch(De){sn(o,o.return,De)}o.flags&=-3}h&4096&&(o.flags&=-4097)}function Up(o,h,_){Mt=o,Vp(o)}function Vp(o,h,_){for(var A=(o.mode&1)!==0;Mt!==null;){var O=Mt,H=O.child;if(O.tag===22&&A){var ne=O.memoizedState!==null||Ru;if(!ne){var _e=O.alternate,De=_e!==null&&_e.memoizedState!==null||Xn;_e=Ru;var He=Xn;if(Ru=ne,(Xn=De)&&!He)for(Mt=O;Mt!==null;)ne=Mt,De=ne.child,ne.tag===22&&ne.memoizedState!==null?Fu(O):De!==null?(De.return=ne,Mt=De):Fu(O);for(;H!==null;)Mt=H,Vp(H),H=H.sibling;Mt=O,Ru=_e,Xn=He}qp(o)}else(O.subtreeFlags&8772)!==0&&H!==null?(H.return=O,Mt=H):qp(o)}}function qp(o){for(;Mt!==null;){var h=Mt;if((h.flags&8772)!==0){var _=h.alternate;try{if((h.flags&8772)!==0)switch(h.tag){case 0:case 11:case 15:Xn||Mu(5,h);break;case 1:var A=h.stateNode;if(h.flags&4&&!Xn)if(_===null)A.componentDidMount();else{var O=h.elementType===h.type?_.memoizedProps:bn(h.type,_.memoizedProps);A.componentDidUpdate(O,_.memoizedState,A.__reactInternalSnapshotBeforeUpdate)}var H=h.updateQueue;H!==null&&Fm(h,H,A);break;case 3:var ne=h.updateQueue;if(ne!==null){if(_=null,h.child!==null)switch(h.child.tag){case 5:_=h.child.stateNode;break;case 1:_=h.child.stateNode}Fm(h,ne,_)}break;case 5:var _e=h.stateNode;if(_===null&&h.flags&4){_=_e;var De=h.memoizedProps;switch(h.type){case"button":case"input":case"select":case"textarea":De.autoFocus&&_.focus();break;case"img":De.src&&(_.src=De.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(h.memoizedState===null){var He=h.alternate;if(He!==null){var lt=He.memoizedState;if(lt!==null){var ct=lt.dehydrated;ct!==null&&Xr(ct)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(t(163))}Xn||h.flags&512&&Ou(h)}catch(at){sn(h,h.return,at)}}if(h===o){Mt=null;break}if(_=h.sibling,_!==null){_.return=h.return,Mt=_;break}Mt=h.return}}function Gu(o){for(;Mt!==null;){var h=Mt;if(h===o){Mt=null;break}var _=h.sibling;if(_!==null){_.return=h.return,Mt=_;break}Mt=h.return}}function Fu(o){for(;Mt!==null;){var h=Mt;try{switch(h.tag){case 0:case 11:case 15:var _=h.return;try{Mu(4,h)}catch(De){sn(h,_,De)}break;case 1:var A=h.stateNode;if(typeof A.componentDidMount=="function"){var O=h.return;try{A.componentDidMount()}catch(De){sn(h,O,De)}}var H=h.return;try{Ou(h)}catch(De){sn(h,H,De)}break;case 5:var ne=h.return;try{Ou(h)}catch(De){sn(h,ne,De)}}}catch(De){sn(h,h.return,De)}if(h===o){Mt=null;break}var _e=h.sibling;if(_e!==null){_e.return=h.return,Mt=_e;break}Mt=h.return}}var rg=Math.ceil,Vc=T.ReactCurrentDispatcher,qc=T.ReactCurrentOwner,Zs=T.ReactCurrentBatchConfig,xi=0,wn=null,mn=null,Ln=0,Os=0,Ua=Zr(0),Dn=0,Ml=null,aa=0,Kc=0,Hu=0,Yc=null,Es=null,Wu=0,Va=1/0,$o=null,Xc=!1,Uu=null,Ao=null,Jc=!1,la=null,Zc=0,Ol=0,Vu=null,Ll=-1,Qc=0;function cs(){return(xi&6)!==0?$i():Ll!==-1?Ll:Ll=$i()}function Io(o){return(o.mode&1)===0?1:(xi&2)!==0&&Ln!==0?Ln&-Ln:iu.transition!==null?(Qc===0&&(Qc=Ns()),Qc):(o=Ne,o!==0||(o=window.event,o=o===void 0?16:re(o.type)),o)}function _r(o,h,_,A){if(50<Ol)throw Ol=0,Vu=null,Error(t(185));es(o,_,A),((xi&2)===0||o!==wn)&&(o===wn&&((xi&2)===0&&(Kc|=_),Dn===4&&Po(o,Ln)),Ts(o,A),_===1&&xi===0&&(h.mode&1)===0&&(Va=$i()+500,Ac&&Co()))}function Ts(o,h){var _=o.callbackNode;_s(o,h);var A=Pr(o,o===wn?Ln:0);if(A===0)_!==null&&Mn(_),o.callbackNode=null,o.callbackPriority=0;else if(h=A&-A,o.callbackPriority!==h){if(_!=null&&Mn(_),h===1)o.tag===0?o_(Xp.bind(null,o)):tp(Xp.bind(null,o)),Lm(function(){(xi&6)===0&&Co()}),_=null;else{switch(Ze(A)){case 1:_=Zi;break;case 4:_=Un;break;case 16:_=ar;break;case 536870912:_=$r;break;default:_=ar}_=nf(_,Kp.bind(null,o))}o.callbackPriority=h,o.callbackNode=_}}function Kp(o,h){if(Ll=-1,Qc=0,(xi&6)!==0)throw Error(t(327));var _=o.callbackNode;if(qa()&&o.callbackNode!==_)return null;var A=Pr(o,o===wn?Ln:0);if(A===0)return null;if((A&30)!==0||(A&o.expiredLanes)!==0||h)h=ed(o,A);else{h=A;var O=xi;xi|=2;var H=og();(wn!==o||Ln!==h)&&($o=null,Va=$i()+500,da(o,h));do try{d_();break}catch(_e){Jp(o,_e)}while(!0);ru(),Vc.current=H,xi=O,mn!==null?h=0:(wn=null,Ln=0,h=Dn)}if(h!==0){if(h===2&&(O=Kr(o),O!==0&&(A=O,h=qu(o,O))),h===1)throw _=Ml,da(o,0),Po(o,A),Ts(o,$i()),_;if(h===6)Po(o,A);else{if(O=o.current.alternate,(A&30)===0&&!Yp(O)&&(h=ed(o,A),h===2&&(H=Kr(o),H!==0&&(A=H,h=qu(o,H))),h===1))throw _=Ml,da(o,0),Po(o,A),Ts(o,$i()),_;switch(o.finishedWork=O,o.finishedLanes=A,h){case 0:case 1:throw Error(t(345));case 2:ua(o,Es,$o);break;case 3:if(Po(o,A),(A&130023424)===A&&(h=Wu+500-$i(),10<h)){if(Pr(o,0)!==0)break;if(O=o.suspendedLanes,(O&A)!==A){cs(),o.pingedLanes|=o.suspendedLanes&O;break}o.timeoutHandle=Wd(ua.bind(null,o,Es,$o),h);break}ua(o,Es,$o);break;case 4:if(Po(o,A),(A&4194240)===A)break;for(h=o.eventTimes,O=-1;0<A;){var ne=31-Qi(A);H=1<<ne,ne=h[ne],ne>O&&(O=ne),A&=~H}if(A=O,A=$i()-A,A=(120>A?120:480>A?480:1080>A?1080:1920>A?1920:3e3>A?3e3:4320>A?4320:1960*rg(A/1960))-A,10<A){o.timeoutHandle=Wd(ua.bind(null,o,Es,$o),A);break}ua(o,Es,$o);break;case 5:ua(o,Es,$o);break;default:throw Error(t(329))}}}return Ts(o,$i()),o.callbackNode===_?Kp.bind(null,o):null}function qu(o,h){var _=Yc;return o.current.memoizedState.isDehydrated&&(da(o,h).flags|=256),o=ed(o,h),o!==2&&(h=Es,Es=_,h!==null&&Ku(h)),o}function Ku(o){Es===null?Es=o:Es.push.apply(Es,o)}function Yp(o){for(var h=o;;){if(h.flags&16384){var _=h.updateQueue;if(_!==null&&(_=_.stores,_!==null))for(var A=0;A<_.length;A++){var O=_[A],H=O.getSnapshot;O=O.value;try{if(!pr(H(),O))return!1}catch{return!1}}}if(_=h.child,h.subtreeFlags&16384&&_!==null)_.return=h,h=_;else{if(h===o)break;for(;h.sibling===null;){if(h.return===null||h.return===o)return!0;h=h.return}h.sibling.return=h.return,h=h.sibling}}return!0}function Po(o,h){for(h&=~Hu,h&=~Kc,o.suspendedLanes|=h,o.pingedLanes&=~h,o=o.expirationTimes;0<h;){var _=31-Qi(h),A=1<<_;o[_]=-1,h&=~A}}function Xp(o){if((xi&6)!==0)throw Error(t(327));qa();var h=Pr(o,0);if((h&1)===0)return Ts(o,$i()),null;var _=ed(o,h);if(o.tag!==0&&_===2){var A=Kr(o);A!==0&&(h=A,_=qu(o,A))}if(_===1)throw _=Ml,da(o,0),Po(o,h),Ts(o,$i()),_;if(_===6)throw Error(t(345));return o.finishedWork=o.current.alternate,o.finishedLanes=h,ua(o,Es,$o),Ts(o,$i()),null}function Yu(o,h){var _=xi;xi|=1;try{return o(h)}finally{xi=_,xi===0&&(Va=$i()+500,Ac&&Co())}}function ca(o){la!==null&&la.tag===0&&(xi&6)===0&&qa();var h=xi;xi|=1;var _=Zs.transition,A=Ne;try{if(Zs.transition=null,Ne=1,o)return o()}finally{Ne=A,Zs.transition=_,xi=h,(xi&6)===0&&Co()}}function Xu(){Os=Ua.current,Ki(Ua)}function da(o,h){o.finishedWork=null,o.finishedLanes=0;var _=o.timeoutHandle;if(_!==-1&&(o.timeoutHandle=-1,Om(_)),mn!==null)for(_=mn.return;_!==null;){var A=_;switch(Yd(A),A.tag){case 1:A=A.type.childContextTypes,A!=null&&Dc();break;case 3:na(),Ki(bs),Ki(os),hu();break;case 5:du(A);break;case 4:na();break;case 13:Ki(nn);break;case 19:Ki(nn);break;case 10:ou(A.type._context);break;case 22:case 23:Xu()}_=_.return}if(wn=o,mn=o=jo(o.current,null),Ln=Os=h,Dn=0,Ml=null,Hu=Kc=aa=0,Es=Yc=null,Ga!==null){for(h=0;h<Ga.length;h++)if(_=Ga[h],A=_.interleaved,A!==null){_.interleaved=null;var O=A.next,H=_.pending;if(H!==null){var ne=H.next;H.next=O,A.next=ne}_.pending=A}Ga=null}return o}function Jp(o,h){do{var _=mn;try{if(ru(),pu.current=Fc,mu){for(var A=tn.memoizedState;A!==null;){var O=A.queue;O!==null&&(O.pending=null),A=A.next}mu=!1}if(sa=0,Tn=_n=tn=null,ra=!1,To=0,qc.current=null,_===null||_.return===null){Dn=1,Ml=h,mn=null;break}e:{var H=o,ne=_.return,_e=_,De=h;if(h=Ln,_e.flags|=32768,De!==null&&typeof De=="object"&&typeof De.then=="function"){var He=De,lt=_e,ct=lt.tag;if((lt.mode&1)===0&&(ct===0||ct===11||ct===15)){var at=lt.alternate;at?(lt.updateQueue=at.updateQueue,lt.memoizedState=at.memoizedState,lt.lanes=at.lanes):(lt.updateQueue=null,lt.memoizedState=null)}var Dt=Jm(ne);if(Dt!==null){Dt.flags&=-257,ls(Dt,ne,_e,H,h),Dt.mode&1&&Ap(H,He,h),h=Dt,De=He;var Ot=h.updateQueue;if(Ot===null){var Lt=new Set;Lt.add(De),h.updateQueue=Lt}else Ot.add(De);break e}else{if((h&1)===0){Ap(H,He,h),Ju();break e}De=Error(t(426))}}else if(en&&_e.mode&1){var Wi=Jm(ne);if(Wi!==null){(Wi.flags&65536)===0&&(Wi.flags|=256),ls(Wi,ne,_e,H,h),tu(Ha(De,_e));break e}}H=De=Ha(De,_e),Dn!==4&&(Dn=2),Yc===null?Yc=[H]:Yc.push(H),H=ne;do{switch(H.tag){case 3:H.flags|=65536,h&=-h,H.lanes|=h;var Ge=Dp(H,De,h);Gm(H,Ge);break e;case 1:_e=De;var Re=H.type,We=H.stateNode;if((H.flags&128)===0&&(typeof Re.getDerivedStateFromError=="function"||We!==null&&typeof We.componentDidCatch=="function"&&(Ao===null||!Ao.has(We)))){H.flags|=65536,h&=-h,H.lanes|=h;var pt=$p(H,_e,h);Gm(H,pt);break e}}H=H.return}while(H!==null)}zl(_)}catch(Ht){h=Ht,mn===_&&_!==null&&(mn=_=_.return);continue}break}while(!0)}function og(){var o=Vc.current;return Vc.current=Fc,o===null?Fc:o}function Ju(){(Dn===0||Dn===3||Dn===2)&&(Dn=4),wn===null||(aa&268435455)===0&&(Kc&268435455)===0||Po(wn,Ln)}function ed(o,h){var _=xi;xi|=2;var A=og();(wn!==o||Ln!==h)&&($o=null,da(o,h));do try{ag();break}catch(O){Jp(o,O)}while(!0);if(ru(),xi=_,Vc.current=A,mn!==null)throw Error(t(261));return wn=null,Ln=0,Dn}function ag(){for(;mn!==null;)Zp(mn)}function d_(){for(;mn!==null&&!Da();)Zp(mn)}function Zp(o){var h=tf(o.alternate,o,Os);o.memoizedProps=o.pendingProps,h===null?zl(o):mn=h,qc.current=null}function zl(o){var h=o;do{var _=h.alternate;if(o=h.return,(h.flags&32768)===0){if(_=eg(_,h,Os),_!==null){mn=_;return}}else{if(_=tg(_,h),_!==null){_.flags&=32767,mn=_;return}if(o!==null)o.flags|=32768,o.subtreeFlags=0,o.deletions=null;else{Dn=6,mn=null;return}}if(h=h.sibling,h!==null){mn=h;return}mn=h=o}while(h!==null);Dn===0&&(Dn=5)}function ua(o,h,_){var A=Ne,O=Zs.transition;try{Zs.transition=null,Ne=1,Qp(o,h,_,A)}finally{Zs.transition=O,Ne=A}return null}function Qp(o,h,_,A){do qa();while(la!==null);if((xi&6)!==0)throw Error(t(327));_=o.finishedWork;var O=o.finishedLanes;if(_===null)return null;if(o.finishedWork=null,o.finishedLanes=0,_===o.current)throw Error(t(177));o.callbackNode=null,o.callbackPriority=0;var H=_.lanes|_.childLanes;if(gt(o,H),o===wn&&(mn=wn=null,Ln=0),(_.subtreeFlags&2064)===0&&(_.flags&2064)===0||Jc||(Jc=!0,nf(ar,function(){return qa(),null})),H=(_.flags&15990)!==0,(_.subtreeFlags&15990)!==0||H){H=Zs.transition,Zs.transition=null;var ne=Ne;Ne=1;var _e=xi;xi|=4,qc.current=null,ng(o,_),Bu(_,o),Pm(Fd),wo=!!Gd,Fd=Gd=null,o.current=_,Up(_),$a(),xi=_e,Ne=ne,Zs.transition=H}else o.current=_;if(Jc&&(Jc=!1,la=o,Zc=O),H=o.pendingLanes,H===0&&(Ao=null),Ft(_.stateNode),Ts(o,$i()),h!==null)for(A=o.onRecoverableError,_=0;_<h.length;_++)O=h[_],A(O.value,{componentStack:O.stack,digest:O.digest});if(Xc)throw Xc=!1,o=Uu,Uu=null,o;return(Zc&1)!==0&&o.tag!==0&&qa(),H=o.pendingLanes,(H&1)!==0?o===Vu?Ol++:(Ol=0,Vu=o):Ol=0,Co(),null}function qa(){if(la!==null){var o=Ze(Zc),h=Zs.transition,_=Ne;try{if(Zs.transition=null,Ne=16>o?16:o,la===null)var A=!1;else{if(o=la,la=null,Zc=0,(xi&6)!==0)throw Error(t(331));var O=xi;for(xi|=4,Mt=o.current;Mt!==null;){var H=Mt,ne=H.child;if((Mt.flags&16)!==0){var _e=H.deletions;if(_e!==null){for(var De=0;De<_e.length;De++){var He=_e[De];for(Mt=He;Mt!==null;){var lt=Mt;switch(lt.tag){case 0:case 11:case 15:Rl(8,lt,H)}var ct=lt.child;if(ct!==null)ct.return=lt,Mt=ct;else for(;Mt!==null;){lt=Mt;var at=lt.sibling,Dt=lt.return;if(Fp(lt),lt===He){Mt=null;break}if(at!==null){at.return=Dt,Mt=at;break}Mt=Dt}}}var Ot=H.alternate;if(Ot!==null){var Lt=Ot.child;if(Lt!==null){Ot.child=null;do{var Wi=Lt.sibling;Lt.sibling=null,Lt=Wi}while(Lt!==null)}}Mt=H}}if((H.subtreeFlags&2064)!==0&&ne!==null)ne.return=H,Mt=ne;else e:for(;Mt!==null;){if(H=Mt,(H.flags&2048)!==0)switch(H.tag){case 0:case 11:case 15:Rl(9,H,H.return)}var Ge=H.sibling;if(Ge!==null){Ge.return=H.return,Mt=Ge;break e}Mt=H.return}}var Re=o.current;for(Mt=Re;Mt!==null;){ne=Mt;var We=ne.child;if((ne.subtreeFlags&2064)!==0&&We!==null)We.return=ne,Mt=We;else e:for(ne=Re;Mt!==null;){if(_e=Mt,(_e.flags&2048)!==0)try{switch(_e.tag){case 0:case 11:case 15:Mu(9,_e)}}catch(Ht){sn(_e,_e.return,Ht)}if(_e===ne){Mt=null;break e}var pt=_e.sibling;if(pt!==null){pt.return=_e.return,Mt=pt;break e}Mt=_e.return}}if(xi=O,Co(),Cn&&typeof Cn.onPostCommitFiberRoot=="function")try{Cn.onPostCommitFiberRoot(gs,o)}catch{}A=!0}return A}finally{Ne=_,Zs.transition=h}}return!1}function ef(o,h,_){h=Ha(_,h),h=Dp(o,h,1),o=Eo(o,h,1),h=cs(),o!==null&&(es(o,1,h),Ts(o,h))}function sn(o,h,_){if(o.tag===3)ef(o,o,_);else for(;h!==null;){if(h.tag===3){ef(h,o,_);break}else if(h.tag===1){var A=h.stateNode;if(typeof h.type.getDerivedStateFromError=="function"||typeof A.componentDidCatch=="function"&&(Ao===null||!Ao.has(A))){o=Ha(_,o),o=$p(h,o,1),h=Eo(h,o,1),o=cs(),h!==null&&(es(h,1,o),Ts(h,o));break}}h=h.return}}function lg(o,h,_){var A=o.pingCache;A!==null&&A.delete(h),h=cs(),o.pingedLanes|=o.suspendedLanes&_,wn===o&&(Ln&_)===_&&(Dn===4||Dn===3&&(Ln&130023424)===Ln&&500>$i()-Wu?da(o,0):Hu|=_),Ts(o,h)}function cg(o,h){h===0&&((o.mode&1)===0?h=1:(h=Qn,Qn<<=1,(Qn&130023424)===0&&(Qn=4194304)));var _=cs();o=eo(o,h),o!==null&&(es(o,h,_),Ts(o,_))}function dg(o){var h=o.memoizedState,_=0;h!==null&&(_=h.retryLane),cg(o,_)}function ug(o,h){var _=0;switch(o.tag){case 13:var A=o.stateNode,O=o.memoizedState;O!==null&&(_=O.retryLane);break;case 19:A=o.stateNode;break;default:throw Error(t(314))}A!==null&&A.delete(h),cg(o,_)}var tf;tf=function(o,h,_){if(o!==null)if(o.memoizedProps!==h.pendingProps||bs.current)ks=!0;else{if((o.lanes&_)===0&&(h.flags&128)===0)return ks=!1,c_(o,h,_);ks=(o.flags&131072)!==0}else ks=!1,en&&(h.flags&1048576)!==0&&Zo(h,Pc,h.index);switch(h.lanes=0,h.tag){case 2:var A=h.type;Wc(o,h),o=h.pendingProps;var O=as(h,os.current);Ba(h,_),O=vu(null,h,A,o,O,_);var H=_u();return h.flags|=1,typeof O=="object"&&O!==null&&typeof O.render=="function"&&O.$$typeof===void 0?(h.tag=1,h.memoizedState=null,h.updateQueue=null,ws(A)?(H=!0,$c(h)):H=!1,h.memoizedState=O.state!==null&&O.state!==void 0?O.state:null,Mc(h),O.updater=io,h.stateNode=O,O._reactInternals=h,xu(h,A,o,_),h=Eu(null,h,A,!0,H,_)):(h.tag=0,en&&H&&vn(h),Kn(null,h,O,_),h=h.child),h;case 16:A=h.elementType;e:{switch(Wc(o,h),o=h.pendingProps,O=A._init,A=O(A._payload),h.type=A,O=h.tag=hg(A),o=bn(A,o),O){case 0:h=ku(null,h,A,o,_);break e;case 1:h=Np(null,h,A,o,_);break e;case 11:h=Ip(null,h,A,o,_);break e;case 14:h=Pl(null,h,A,bn(A.type,o),_);break e}throw Error(t(306,A,""))}return h;case 0:return A=h.type,O=h.pendingProps,O=h.elementType===A?O:bn(A,O),ku(o,h,A,O,_);case 1:return A=h.type,O=h.pendingProps,O=h.elementType===A?O:bn(A,O),Np(o,h,A,O,_);case 3:e:{if(Tu(h),o===null)throw Error(t(387));A=h.pendingProps,H=h.memoizedState,O=H.element,lu(o,h),Oc(h,A,null,_);var ne=h.memoizedState;if(A=ne.element,H.isDehydrated)if(H={element:A,isDehydrated:!1,cache:ne.cache,pendingSuspenseBoundaries:ne.pendingSuspenseBoundaries,transitions:ne.transitions},h.updateQueue.baseState=H,h.memoizedState=H,h.flags&256){O=Ha(Error(t(423)),h),h=Mp(o,h,A,_,O);break e}else if(A!==O){O=Ha(Error(t(424)),h),h=Mp(o,h,A,_,O);break e}else for(Ms=xo(h.stateNode.containerInfo.firstChild),Ss=h,en=!0,Cs=null,_=nu(h,null,A,_),h.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling;else{if(Qo(),A===O){h=no(o,h,_);break e}Kn(o,h,A,_)}h=h.child}return h;case 5:return rp(h),o===null&&Qd(h),A=h.type,O=h.pendingProps,H=o!==null?o.memoizedProps:null,ne=O.children,Hd(A,O)?ne=null:H!==null&&Hd(A,H)&&(h.flags|=32),Rp(o,h),Kn(o,h,ne,_),h.child;case 6:return o===null&&Qd(h),null;case 13:return Op(o,h,_);case 4:return cu(h,h.stateNode.containerInfo),A=h.pendingProps,o===null?h.child=za(h,null,A,_):Kn(o,h,A,_),h.child;case 11:return A=h.type,O=h.pendingProps,O=h.elementType===A?O:bn(A,O),Ip(o,h,A,O,_);case 7:return Kn(o,h,h.pendingProps,_),h.child;case 8:return Kn(o,h,h.pendingProps.children,_),h.child;case 12:return Kn(o,h,h.pendingProps.children,_),h.child;case 10:e:{if(A=h.type._context,O=h.pendingProps,H=h.memoizedProps,ne=O.value,Hi(ea,A._currentValue),A._currentValue=ne,H!==null)if(pr(H.value,ne)){if(H.children===O.children&&!bs.current){h=no(o,h,_);break e}}else for(H=h.child,H!==null&&(H.return=h);H!==null;){var _e=H.dependencies;if(_e!==null){ne=H.child;for(var De=_e.firstContext;De!==null;){if(De.context===A){if(H.tag===1){De=to(-1,_&-_),De.tag=2;var He=H.updateQueue;if(He!==null){He=He.shared;var lt=He.pending;lt===null?De.next=De:(De.next=lt.next,lt.next=De),He.pending=De}}H.lanes|=_,De=H.alternate,De!==null&&(De.lanes|=_),sp(H.return,_,h),_e.lanes|=_;break}De=De.next}}else if(H.tag===10)ne=H.type===h.type?null:H.child;else if(H.tag===18){if(ne=H.return,ne===null)throw Error(t(341));ne.lanes|=_,_e=ne.alternate,_e!==null&&(_e.lanes|=_),sp(ne,_,h),ne=H.sibling}else ne=H.child;if(ne!==null)ne.return=H;else for(ne=H;ne!==null;){if(ne===h){ne=null;break}if(H=ne.sibling,H!==null){H.return=ne.return,ne=H;break}ne=ne.return}H=ne}Kn(o,h,O.children,_),h=h.child}return h;case 9:return O=h.type,A=h.pendingProps.children,Ba(h,_),O=Ys(O),A=A(O),h.flags|=1,Kn(o,h,A,_),h.child;case 14:return A=h.type,O=bn(A,h.pendingProps),O=bn(A.type,O),Pl(o,h,A,O,_);case 15:return Pp(o,h,h.type,h.pendingProps,_);case 17:return A=h.type,O=h.pendingProps,O=h.elementType===A?O:bn(A,O),Wc(o,h),h.tag=1,ws(A)?(o=!0,$c(h)):o=!1,Ba(h,_),Ep(h,A,O),xu(h,A,O,_),Eu(null,h,A,!0,o,_);case 19:return Iu(o,h,_);case 22:return jp(o,h,_)}throw Error(t(156,h.tag))};function nf(o,h){return Vo(o,h)}function u_(o,h,_,A){this.tag=o,this.key=_,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=h,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=A,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ls(o,h,_,A){return new u_(o,h,_,A)}function Zu(o){return o=o.prototype,!(!o||!o.isReactComponent)}function hg(o){if(typeof o=="function")return Zu(o)?1:0;if(o!=null){if(o=o.$$typeof,o===he)return 11;if(o===ce)return 14}return 2}function jo(o,h){var _=o.alternate;return _===null?(_=Ls(o.tag,h,o.key,o.mode),_.elementType=o.elementType,_.type=o.type,_.stateNode=o.stateNode,_.alternate=o,o.alternate=_):(_.pendingProps=h,_.type=o.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=o.flags&14680064,_.childLanes=o.childLanes,_.lanes=o.lanes,_.child=o.child,_.memoizedProps=o.memoizedProps,_.memoizedState=o.memoizedState,_.updateQueue=o.updateQueue,h=o.dependencies,_.dependencies=h===null?null:{lanes:h.lanes,firstContext:h.firstContext},_.sibling=o.sibling,_.index=o.index,_.ref=o.ref,_}function td(o,h,_,A,O,H){var ne=2;if(A=o,typeof o=="function")Zu(o)&&(ne=1);else if(typeof o=="string")ne=5;else e:switch(o){case L:return Ka(_.children,O,H,h);case R:ne=8,O|=8;break;case F:return o=Ls(12,_,h,O|2),o.elementType=F,o.lanes=H,o;case ee:return o=Ls(13,_,h,O),o.elementType=ee,o.lanes=H,o;case we:return o=Ls(19,_,h,O),o.elementType=we,o.lanes=H,o;case Ee:return id(_,O,H,h);default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case V:ne=10;break e;case te:ne=9;break e;case he:ne=11;break e;case ce:ne=14;break e;case ve:ne=16,A=null;break e}throw Error(t(130,o==null?o:typeof o,""))}return h=Ls(ne,_,h,O),h.elementType=o,h.type=A,h.lanes=H,h}function Ka(o,h,_,A){return o=Ls(7,o,A,h),o.lanes=_,o}function id(o,h,_,A){return o=Ls(22,o,A,h),o.elementType=Ee,o.lanes=_,o.stateNode={isHidden:!1},o}function Qu(o,h,_){return o=Ls(6,o,null,h),o.lanes=_,o}function eh(o,h,_){return h=Ls(4,o.children!==null?o.children:[],o.key,h),h.lanes=_,h.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},h}function h_(o,h,_,A,O){this.tag=h,this.containerInfo=o,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=qe(0),this.expirationTimes=qe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qe(0),this.identifierPrefix=A,this.onRecoverableError=O,this.mutableSourceEagerHydrationData=null}function th(o,h,_,A,O,H,ne,_e,De){return o=new h_(o,h,_,_e,De),h===1?(h=1,H===!0&&(h|=8)):h=0,H=Ls(3,null,null,h),o.current=H,H.stateNode=o,H.memoizedState={element:A,isDehydrated:_,cache:null,transitions:null,pendingSuspenseBoundaries:null},Mc(H),o}function p_(o,h,_){var A=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:N,key:A==null?null:""+A,children:o,containerInfo:h,implementation:_}}function sf(o){if(!o)return So;o=o._reactInternals;e:{if(Tt(o)!==o||o.tag!==1)throw Error(t(170));var h=o;do{switch(h.tag){case 3:h=h.stateNode.context;break e;case 1:if(ws(h.type)){h=h.stateNode.__reactInternalMemoizedMergedChildContext;break e}}h=h.return}while(h!==null);throw Error(t(171))}if(o.tag===1){var _=o.type;if(ws(_))return Qh(o,_,h)}return h}function pg(o,h,_,A,O,H,ne,_e,De){return o=th(_,A,!0,o,O,H,ne,_e,De),o.context=sf(null),_=o.current,A=cs(),O=Io(_),H=to(A,O),H.callback=h??null,Eo(_,H,O),o.current.lanes=O,es(o,O,A),Ts(o,A),o}function nd(o,h,_,A){var O=h.current,H=cs(),ne=Io(O);return _=sf(_),h.context===null?h.context=_:h.pendingContext=_,h=to(H,ne),h.payload={element:o},A=A===void 0?null:A,A!==null&&(h.callback=A),o=Eo(O,h,ne),o!==null&&(_r(o,O,ne,H),Dl(o,O,ne)),ne}function sd(o){if(o=o.current,!o.child)return null;switch(o.child.tag){case 5:return o.child.stateNode;default:return o.child.stateNode}}function rf(o,h){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var _=o.retryLane;o.retryLane=_!==0&&_<h?_:h}}function ih(o,h){rf(o,h),(o=o.alternate)&&rf(o,h)}function fg(){return null}var mg=typeof reportError=="function"?reportError:function(o){console.error(o)};function nh(o){this._internalRoot=o}Ya.prototype.render=nh.prototype.render=function(o){var h=this._internalRoot;if(h===null)throw Error(t(409));nd(o,h,null,null)},Ya.prototype.unmount=nh.prototype.unmount=function(){var o=this._internalRoot;if(o!==null){this._internalRoot=null;var h=o.containerInfo;ca(function(){nd(null,o,null,null)}),h[Lr]=null}};function Ya(o){this._internalRoot=o}Ya.prototype.unstable_scheduleHydration=function(o){if(o){var h=Bi();o={blockedOn:null,target:o,priority:h};for(var _=0;_<lr.length&&h!==0&&h<lr[_].priority;_++);lr.splice(_,0,o),_===0&&ul(o)}};function sh(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function rd(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11&&(o.nodeType!==8||o.nodeValue!==" react-mount-point-unstable "))}function gg(){}function vg(o,h,_,A,O){if(O){if(typeof A=="function"){var H=A;A=function(){var He=sd(ne);H.call(He)}}var ne=pg(h,A,o,0,null,!1,!1,"",gg);return o._reactRootContainer=ne,o[Lr]=ne.current,Sl(o.nodeType===8?o.parentNode:o),ca(),ne}for(;O=o.lastChild;)o.removeChild(O);if(typeof A=="function"){var _e=A;A=function(){var He=sd(De);_e.call(He)}}var De=th(o,0,!1,null,null,!1,!1,"",gg);return o._reactRootContainer=De,o[Lr]=De.current,Sl(o.nodeType===8?o.parentNode:o),ca(function(){nd(h,De,_,A)}),De}function Bl(o,h,_,A,O){var H=_._reactRootContainer;if(H){var ne=H;if(typeof O=="function"){var _e=O;O=function(){var De=sd(ne);_e.call(De)}}nd(h,ne,o,O)}else ne=vg(_,h,o,O,A);return sd(ne)}$t=function(o){switch(o.tag){case 3:var h=o.stateNode;if(h.current.memoizedState.isDehydrated){var _=Fs(h.pendingLanes);_!==0&&(me(h,_|1),Ts(h,$i()),(xi&6)===0&&(Va=$i()+500,Co()))}break;case 13:ca(function(){var A=eo(o,1);if(A!==null){var O=cs();_r(A,o,1,O)}}),ih(o,1)}},ni=function(o){if(o.tag===13){var h=eo(o,134217728);if(h!==null){var _=cs();_r(h,o,134217728,_)}ih(o,134217728)}},ci=function(o){if(o.tag===13){var h=Io(o),_=eo(o,h);if(_!==null){var A=cs();_r(_,o,h,A)}ih(o,h)}},Bi=function(){return Ne},Mi=function(o,h){var _=Ne;try{return Ne=o,h()}finally{Ne=_}},fs=function(o,h,_){switch(h){case"input":if(mt(o,_),h=_.name,_.type==="radio"&&h!=null){for(_=o;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll("input[name="+JSON.stringify(""+h)+'][type="radio"]'),h=0;h<_.length;h++){var A=_[h];if(A!==o&&A.form===o.form){var O=Tc(A);if(!O)throw Error(t(90));Pe(A),mt(A,O)}}}break;case"textarea":hi(o,_);break;case"select":h=_.value,h!=null&&Je(o,!!_.multiple,h,!1)}},Gs=Yu,Fn=ca;var of={usingClientEntryPoint:!1,Events:[El,Ra,Tc,Tr,Dr,Yu]},br={findFiberByHostInstance:Xo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},_g={bundleType:br.bundleType,version:br.version,rendererPackageName:br.rendererPackageName,rendererConfig:br.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(o){return o=fo(o),o===null?null:o.stateNode},findFiberByHostInstance:br.findFiberByHostInstance||fg,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Gl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Gl.isDisabled&&Gl.supportsFiber)try{gs=Gl.inject(_g),Cn=Gl}catch{}}return wr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=of,wr.createPortal=function(o,h){var _=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!sh(h))throw Error(t(200));return p_(o,h,null,_)},wr.createRoot=function(o,h){if(!sh(o))throw Error(t(299));var _=!1,A="",O=mg;return h!=null&&(h.unstable_strictMode===!0&&(_=!0),h.identifierPrefix!==void 0&&(A=h.identifierPrefix),h.onRecoverableError!==void 0&&(O=h.onRecoverableError)),h=th(o,1,!1,null,null,_,!1,A,O),o[Lr]=h.current,Sl(o.nodeType===8?o.parentNode:o),new nh(h)},wr.findDOMNode=function(o){if(o==null)return null;if(o.nodeType===1)return o;var h=o._reactInternals;if(h===void 0)throw typeof o.render=="function"?Error(t(188)):(o=Object.keys(o).join(","),Error(t(268,o)));return o=fo(h),o=o===null?null:o.stateNode,o},wr.flushSync=function(o){return ca(o)},wr.hydrate=function(o,h,_){if(!rd(h))throw Error(t(200));return Bl(null,o,h,!0,_)},wr.hydrateRoot=function(o,h,_){if(!sh(o))throw Error(t(405));var A=_!=null&&_.hydratedSources||null,O=!1,H="",ne=mg;if(_!=null&&(_.unstable_strictMode===!0&&(O=!0),_.identifierPrefix!==void 0&&(H=_.identifierPrefix),_.onRecoverableError!==void 0&&(ne=_.onRecoverableError)),h=pg(h,null,o,1,_??null,O,!1,H,ne),o[Lr]=h.current,Sl(o),A)for(o=0;o<A.length;o++)_=A[o],O=_._getVersion,O=O(_._source),h.mutableSourceEagerHydrationData==null?h.mutableSourceEagerHydrationData=[_,O]:h.mutableSourceEagerHydrationData.push(_,O);return new Ya(h)},wr.render=function(o,h,_){if(!rd(h))throw Error(t(200));return Bl(null,o,h,!1,_)},wr.unmountComponentAtNode=function(o){if(!rd(o))throw Error(t(40));return o._reactRootContainer?(ca(function(){Bl(null,null,o,!1,function(){o._reactRootContainer=null,o[Lr]=null})}),!0):!1},wr.unstable_batchedUpdates=Yu,wr.unstable_renderSubtreeIntoContainer=function(o,h,_,A){if(!rd(_))throw Error(t(200));if(o==null||o._reactInternals===void 0)throw Error(t(38));return Bl(o,h,_,!1,A)},wr.version="18.3.1-next-f1338f8080-20240426",wr}var Hy;function N1(){if(Hy)return __.exports;Hy=1;function i(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),__.exports=ET(),__.exports}var Wy;function TT(){if(Wy)return wg;Wy=1;var i=N1();return wg.createRoot=i.createRoot,wg.hydrateRoot=i.hydrateRoot,wg}var DT=TT();const $T=Pw(DT);var z=jw();const Rt=Pw(z),Uy=i=>{let e;const t=new Set,n=(f,m)=>{const g=typeof f=="function"?f(e):f;if(!Object.is(g,e)){const y=e;e=m??(typeof g!="object"||g===null)?g:Object.assign({},e,g),t.forEach(D=>D(e,y))}},r=()=>e,a={setState:n,getState:r,getInitialState:()=>d,subscribe:f=>(t.add(f),()=>t.delete(f))},d=e=i(n,r,a);return a},AT=(i=>i?Uy(i):Uy),IT=i=>i;function PT(i,e=IT){const t=Rt.useSyncExternalStore(i.subscribe,Rt.useCallback(()=>e(i.getState()),[i,e]),Rt.useCallback(()=>e(i.getInitialState()),[i,e]));return Rt.useDebugValue(t),t}const Vy=i=>{const e=AT(i),t=n=>PT(e,n);return Object.assign(t,e),t},jn=(i=>i?Vy(i):Vy);function kr(i){return"'"+i.replace(/'/g,"'\\''")+"'"}function Rw(i){return!i||i==="inherit"?"":` --model ${kr(i)}`}function jT(i){return!i||i==="inherit"||i.toLowerCase()==="auto"?"":` --effort ${kr(i)}`}const y_=({sessionId:i,model:e})=>`claude --dangerously-skip-permissions --session-id ${kr(i)}${Rw(e)}`,qy=({sessionId:i,model:e})=>`claude --session-id ${kr(i)}${Rw(e)}`,RT=()=>"claude --resume",M1=[{id:"sm-dangerous",label:"Session Manager (skip perms)",description:"claude --dangerously-skip-permissions in this project",category:"build",cwd:"app-cwd",command:y_},{id:"sm-safe",label:"Session Manager (safe)",description:"claude with normal permission prompts in this project",category:"build",cwd:"app-cwd",command:qy},{id:"home-dangerous",label:"Home (skip perms)",description:"claude --dangerously-skip-permissions in ~",category:"build",cwd:"home",command:y_},{id:"pick-dangerous",label:"Pick directory (skip perms)…",description:"Choose a folder, launch claude --dangerously-skip-permissions",category:"build",cwd:"pick",command:y_},{id:"pick-safe",label:"Pick directory (safe)…",description:"Choose a folder, launch claude with normal prompts",category:"build",cwd:"pick",command:qy},{id:"pick-resume",label:"Pick directory + resume…",description:"Choose a folder, then pick a past session to resume",category:"build",cwd:"pick",command:RT},{id:"pick-shell",label:"Pick directory (shell only)…",description:"Bare interactive shell, no claude auto-launch",category:"build",cwd:"pick",command:null}];let ro=null;async function NT(){if(ro)return ro;try{const i=await window.api.app.engageRulesPath();if(!i)return ro=[],ro;const e=await window.api.config.readJson(i);if(!e.exists||e.parseError||!e.data)return ro=[],ro;const t=e.data;if(!t.presets||!Array.isArray(t.presets))return ro=[],ro;const n=t.projectPath;return ro=t.presets.map(r=>({id:r.id,label:r.label,description:r.description,category:"engage",cwd:n,platform:r.platform,pipeline:r.pipeline,rules:r.rules,command:()=>`cd ${kr(n)} && ${r.cliEntry}`})),ro}catch(i){return console.warn("[presets] Failed to load engage presets:",i),ro=[],ro}}async function O1(i){const e=M1.find(n=>n.id===i);return e||((await NT()).find(n=>n.id===i)??null)}async function Ky(i){return i.cwd==="app-cwd"?window.api.app.cwd():i.cwd==="home"?window.api.app.homeDir():i.cwd==="pick"?window.api.app.pickDirectory():i.cwd}function L1(i,e){return i.command?i.command(e):null}const z1="~/.claude/session-manager/ui-settings-prefs.json";async function Eh(){var i,e;if(typeof window>"u"||!((e=(i=window.api)==null?void 0:i.config)!=null&&e.readJson))return{};try{const t=await window.api.config.readJson(z1);if(t!=null&&t.exists&&t.data&&typeof t.data=="object")return t.data}catch{}return{}}let Yy=Promise.resolve();function um(i){const e=Yy.then(async()=>{var n,r;if(typeof window>"u"||!((r=(n=window.api)==null?void 0:n.config)!=null&&r.writeJson))return;const t=await Eh();await window.api.config.writeJson(z1,{...t,...i})});return Yy=e.catch(()=>{}),e}const MT=5,Xy=100,OT=5e3,Sb=new Map;function Jy(i){const e=Sb.get(i);e!==void 0&&(clearTimeout(e),Sb.delete(i))}function LT(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`t-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}const Is=jn((i,e)=>({toasts:[],history:[],unreadCount:0,show:(t,n)=>{const r=LT(),l=Date.now();i(a=>{const d=[...a.toasts,{id:r,kind:t,message:n,createdAt:l}];for(;d.length>MT;){const g=d.shift();g&&Jy(g.id)}const m=[{id:r,kind:t,message:n,createdAt:l,read:!1},...a.history];return m.length>Xy&&(m.length=Xy),{toasts:d,history:m,unreadCount:a.unreadCount+1}});const p=setTimeout(()=>e().dismiss(r),OT);return Sb.set(r,p),r},dismiss:t=>{Jy(t),i(n=>({toasts:n.toasts.filter(r=>r.id!==t)}))},markAllRead:()=>{i(t=>t.unreadCount===0?t:{history:t.history.map(n=>n.read?n:{...n,read:!0}),unreadCount:0})},clearHistory:()=>{i({history:[],unreadCount:0})},dismissHistoryEntry:t=>{i(n=>{const r=n.history.filter(p=>p.id!==t);if(r.length===n.history.length)return n;const l=n.history.find(p=>p.id===t&&!p.read);return{history:r,unreadCount:l?Math.max(0,n.unreadCount-1):n.unreadCount}})}})),Qe={info:i=>Is.getState().show("info",i),warn:i=>Is.getState().show("warn",i),error:i=>Is.getState().show("error",i),fromOutcome:i=>Is.getState().show(i.kind??(i.ok?"info":"warn"),i.message)},B1=Object.freeze(Object.defineProperty({__proto__:null,toast:Qe,useToast:Is},Symbol.toStringTag,{value:"Module"})),zT=["opus","sonnet","haiku","fable"],BT="[1m]";function Q4(i){if(!i)return zT;const e=[...i.aliases,...i.models],t=[];for(const n of e)t.push(n,n+BT);return[...new Set(t)]}const GT="opus";function FT(i){return/^[A-Za-z0-9][A-Za-z0-9._\-]{0,79}(\[[0-9a-z]{1,4}\])?$/.test(i)}let zo=GT;const Zf=new Set;let G1=!1;async function HT(){try{const i=await Eh();if(G1)return;typeof i.rawSessionModel=="string"&&FT(i.rawSessionModel)&&(zo=i.rawSessionModel,Zf.forEach(e=>e(zo)))}catch{}}HT();function F1(){return zo}function WT(i){if(G1=!0,i===zo)return;const e=zo;zo=i,Zf.forEach(t=>t(i)),um({rawSessionModel:i}).catch(()=>{zo=e,Zf.forEach(t=>t(zo)),Qe.error("Couldn't save the default model — reverted.")})}function eB(){const[i,e]=z.useState(zo);z.useEffect(()=>{const n=r=>e(r);return Zf.add(n),zo!==i&&e(zo),()=>{Zf.delete(n)}},[]);const t=z.useCallback(n=>WT(n),[]);return{model:i,setModel:t}}async function Uv(i,e){const t=await window.api.transcripts.pathFor(i,e);return window.api.config.exists(t)}async function UT(i){var e,t;if(typeof window>"u"||typeof((t=(e=window.api)==null?void 0:e.chat)==null?void 0:t.classifyTicket)!="function")return"inline";try{return await window.api.chat.classifyTicket({text:i})==="develop"?"develop":"inline"}catch{return"inline"}}const VT={feature:{bg:"bg-sage/20",text:"text-sage",border:!0,label:"Feature"},bug:{bg:"bg-accent/15",text:"text-accent",border:!0,label:"Bug"},discussion:{bg:"bg-butter/25",text:"text-fg-dim",border:!0,label:"Discussion"},build:{bg:"bg-hive-teal/20",text:"text-hive-teal",border:!0,label:"Build"},"project-home-builder":{bg:"bg-honey/20",text:"text-honey-dark",border:!0,label:"Project Home Builder"}};function qT(i){return VT[i]}function KT(i){return i==="discussion"}class H1 extends Error{constructor(t,n){super(`${t} timed out after ${n}ms`);Gi(this,"label");Gi(this,"ms");this.name="TimeoutError",this.label=t,this.ms=n}}function YT(i){return i instanceof H1}function W1(i,e,t){return new Promise((n,r)=>{const l=setTimeout(()=>r(new H1(t,e)),e);i.then(p=>{clearTimeout(l),n(p)},p=>{clearTimeout(l),r(p)})})}const Zy=3e4;function XT(i){return`${i.label} timed out — the main process was busy, and a retry also failed.`}function U1(i){if(!YT(i.error))return null;const e=i.error;let t=!1;const n=setTimeout(()=>{t||i.retry().then(r=>{t||(t=!0,i.onRetrySuccess(r))},()=>{t||(t=!0,i.onStillFailing(XT(e)))})},Math.max(i.graceMs??Zy,Zy));return{cancel:()=>{t=!0,clearTimeout(n)}}}const JT=5e3,Wr=jn(()=>({snapshot:null,loaded:!1}));let Qy=!1,yg=!1,rh=null,oh;function ex(){return W1(window.api.schedule.state(),JT,"schedule.state")}async function ZT(){var i;if(!Qy){Qy=!0;try{const e=await ex();Wr.setState({snapshot:e,loaded:!0}),oh=((i=e.paused)==null?void 0:i.reason)??null}catch(e){oh=null;const t=U1({error:e,retry:ex,onRetrySuccess:n=>{var r;rh=null,Wr.setState({snapshot:n,loaded:!0}),oh=((r=n.paused)==null?void 0:r.reason)??null},onStillFailing:n=>{rh=null,yg||(yg=!0,Qe.error(`Scheduler state hydrate: ${n}`))}});if(t)rh=t;else if(!yg){yg=!0;const n=e instanceof Error?e.message:String(e);Qe.error(`Scheduler state hydrate failed: ${n}`)}}window.api.schedule.onState(e=>{var n;rh&&(rh.cancel(),rh=null);const t=((n=e.paused)==null?void 0:n.reason)??null;oh!==void 0&&t!==oh&&(t==="auth"?Qe.error("Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume."):t==="network"&&Qe.error("Scheduler paused: billing endpoint unreachable. Will auto-resume in 30 minutes.")),oh=t,Wr.setState({snapshot:e,loaded:!0})}),window.api.schedule.onStall(e=>{Qe.error(e.message)})}}const cl=jn((i,e)=>({modes:{},attached:{},setMode:(t,n)=>i(r=>({modes:{...r.modes,[t]:n}})),setAttached:(t,n)=>i(r=>({attached:{...r.attached,[t]:n}})),isAttached:t=>!!e().attached[t]})),QT={epicId:null,label:null,known:!1};function V1(i){if(!i)return[];const e=[];for(const t of[i.epicId,i.sourcePromptId,i.sourceTabId])typeof t=="string"&&t&&!e.includes(t)&&e.push(t);return e}function tB(i,e){const t=V1(i);if(t.length===0)return QT;for(const n of t){const r=e[n];if(r)return{epicId:n,label:r.goalText||n,known:!0}}return{epicId:t[0],label:null,known:!1}}function e2(i){return i.length>12?`${i.slice(0,12)}…`:i}function t2(i,e={}){const{suffixCase:t="lower",kDecimals:n=0}=e,r=t==="upper"?{k:"K",m:"M"}:{k:"k",m:"M"};return i>=1e6?`${(i/1e6).toFixed(1)}${r.m}`:i>=1e3?`${(i/1e3).toFixed(n)}${r.k}`:i.toFixed(0)}function bd(i){const e=i.indexOf(`
|
|
41
|
+
`+H.stack}return{value:o,source:h,stack:O,digest:null}}function Su(o,h,_){return{value:o,source:null,stack:_??null,digest:h??null}}function Cu(o,h){try{console.error(h.value)}catch(_){setTimeout(function(){throw _})}}var Xm=typeof WeakMap=="function"?WeakMap:Map;function Dp(o,h,_){_=to(-1,_),_.tag=3,_.payload={element:null};var A=h.value;return _.callback=function(){Xc||(Xc=!0,Uu=A),Cu(o,h)},_}function $p(o,h,_){_=to(-1,_),_.tag=3;var A=o.type.getDerivedStateFromError;if(typeof A=="function"){var O=h.value;_.payload=function(){return A(O)},_.callback=function(){Cu(o,h)}}var H=o.stateNode;return H!==null&&typeof H.componentDidCatch=="function"&&(_.callback=function(){Cu(o,h),typeof A!="function"&&(Ao===null?Ao=new Set([this]):Ao.add(this));var ne=h.stack;this.componentDidCatch(h.value,{componentStack:ne!==null?ne:""})}),_}function Ap(o,h,_){var A=o.pingCache;if(A===null){A=o.pingCache=new Xm;var O=new Set;A.set(h,O)}else O=A.get(h),O===void 0&&(O=new Set,A.set(h,O));O.has(_)||(O.add(_),o=lg.bind(null,o,h,_),h.then(o,o))}function Jm(o){do{var h;if((h=o.tag===13)&&(h=o.memoizedState,h=h!==null?h.dehydrated!==null:!0),h)return o;o=o.return}while(o!==null);return null}function ls(o,h,_,A,O){return(o.mode&1)===0?(o===h?o.flags|=65536:(o.flags|=128,_.flags|=131072,_.flags&=-52805,_.tag===1&&(_.alternate===null?_.tag=17:(h=to(-1,1),h.tag=2,Eo(_,h,1))),_.lanes|=1),o):(o.flags|=65536,o.lanes=O,o)}var Zm=T.ReactCurrentOwner,ks=!1;function Kn(o,h,_,A){h.child=o===null?nu(h,null,_,A):za(h,o.child,_,A)}function Ip(o,h,_,A,O){_=_.render;var H=h.ref;return Ba(h,O),A=vu(o,h,_,A,H,O),_=_u(),o!==null&&!ks?(h.updateQueue=o.updateQueue,h.flags&=-2053,o.lanes&=~O,no(o,h,O)):(en&&_&&vn(h),h.flags|=1,Kn(o,h,A,O),h.child)}function Pl(o,h,_,A,O){if(o===null){var H=_.type;return typeof H=="function"&&!Zu(H)&&H.defaultProps===void 0&&_.compare===null&&_.defaultProps===void 0?(h.tag=15,h.type=H,Pp(o,h,H,A,O)):(o=td(_.type,null,A,h,h.mode,O),o.ref=h.ref,o.return=h,h.child=o)}if(H=o.child,(o.lanes&O)===0){var ne=H.memoizedProps;if(_=_.compare,_=_!==null?_:bl,_(ne,A)&&o.ref===h.ref)return no(o,h,O)}return h.flags|=1,o=jo(H,A),o.ref=h.ref,o.return=h,h.child=o}function Pp(o,h,_,A,O){if(o!==null){var H=o.memoizedProps;if(bl(H,A)&&o.ref===h.ref)if(ks=!1,h.pendingProps=A=H,(o.lanes&O)!==0)(o.flags&131072)!==0&&(ks=!0);else return h.lanes=o.lanes,no(o,h,O)}return ku(o,h,_,A,O)}function jp(o,h,_){var A=h.pendingProps,O=A.children,H=o!==null?o.memoizedState:null;if(A.mode==="hidden")if((h.mode&1)===0)h.memoizedState={baseLanes:0,cachePool:null,transitions:null},Hi(Ua,Os),Os|=_;else{if((_&1073741824)===0)return o=H!==null?H.baseLanes|_:_,h.lanes=h.childLanes=1073741824,h.memoizedState={baseLanes:o,cachePool:null,transitions:null},h.updateQueue=null,Hi(Ua,Os),Os|=o,null;h.memoizedState={baseLanes:0,cachePool:null,transitions:null},A=H!==null?H.baseLanes:_,Hi(Ua,Os),Os|=A}else H!==null?(A=H.baseLanes|_,h.memoizedState=null):A=_,Hi(Ua,Os),Os|=A;return Kn(o,h,O,_),h.child}function Rp(o,h){var _=h.ref;(o===null&&_!==null||o!==null&&o.ref!==_)&&(h.flags|=512,h.flags|=2097152)}function ku(o,h,_,A,O){var H=ws(_)?Jo:os.current;return H=as(h,H),Ba(h,O),_=vu(o,h,_,A,H,O),A=_u(),o!==null&&!ks?(h.updateQueue=o.updateQueue,h.flags&=-2053,o.lanes&=~O,no(o,h,O)):(en&&A&&vn(h),h.flags|=1,Kn(o,h,_,O),h.child)}function Np(o,h,_,A,O){if(ws(_)){var H=!0;$c(h)}else H=!1;if(Ba(h,O),h.stateNode===null)Wc(o,h),Ep(h,_,A),xu(h,_,A,O),A=!0;else if(o===null){var ne=h.stateNode,_e=h.memoizedProps;ne.props=_e;var De=ne.context,He=_.contextType;typeof He=="object"&&He!==null?He=Ys(He):(He=ws(_)?Jo:os.current,He=as(h,He));var lt=_.getDerivedStateFromProps,ct=typeof lt=="function"||typeof ne.getSnapshotBeforeUpdate=="function";ct||typeof ne.UNSAFE_componentWillReceiveProps!="function"&&typeof ne.componentWillReceiveProps!="function"||(_e!==A||De!==He)&&Tp(h,ne,A,He),zr=!1;var at=h.memoizedState;ne.state=at,Oc(h,A,ne,O),De=h.memoizedState,_e!==A||at!==De||bs.current||zr?(typeof lt=="function"&&(Gr(h,_,lt,A),De=h.memoizedState),(_e=zr||oa(h,_,_e,A,at,De,He))?(ct||typeof ne.UNSAFE_componentWillMount!="function"&&typeof ne.componentWillMount!="function"||(typeof ne.componentWillMount=="function"&&ne.componentWillMount(),typeof ne.UNSAFE_componentWillMount=="function"&&ne.UNSAFE_componentWillMount()),typeof ne.componentDidMount=="function"&&(h.flags|=4194308)):(typeof ne.componentDidMount=="function"&&(h.flags|=4194308),h.memoizedProps=A,h.memoizedState=De),ne.props=A,ne.state=De,ne.context=He,A=_e):(typeof ne.componentDidMount=="function"&&(h.flags|=4194308),A=!1)}else{ne=h.stateNode,lu(o,h),_e=h.memoizedProps,He=h.type===h.elementType?_e:bn(h.type,_e),ne.props=He,ct=h.pendingProps,at=ne.context,De=_.contextType,typeof De=="object"&&De!==null?De=Ys(De):(De=ws(_)?Jo:os.current,De=as(h,De));var Dt=_.getDerivedStateFromProps;(lt=typeof Dt=="function"||typeof ne.getSnapshotBeforeUpdate=="function")||typeof ne.UNSAFE_componentWillReceiveProps!="function"&&typeof ne.componentWillReceiveProps!="function"||(_e!==ct||at!==De)&&Tp(h,ne,A,De),zr=!1,at=h.memoizedState,ne.state=at,Oc(h,A,ne,O);var Ot=h.memoizedState;_e!==ct||at!==Ot||bs.current||zr?(typeof Dt=="function"&&(Gr(h,_,Dt,A),Ot=h.memoizedState),(He=zr||oa(h,_,He,A,at,Ot,De)||!1)?(lt||typeof ne.UNSAFE_componentWillUpdate!="function"&&typeof ne.componentWillUpdate!="function"||(typeof ne.componentWillUpdate=="function"&&ne.componentWillUpdate(A,Ot,De),typeof ne.UNSAFE_componentWillUpdate=="function"&&ne.UNSAFE_componentWillUpdate(A,Ot,De)),typeof ne.componentDidUpdate=="function"&&(h.flags|=4),typeof ne.getSnapshotBeforeUpdate=="function"&&(h.flags|=1024)):(typeof ne.componentDidUpdate!="function"||_e===o.memoizedProps&&at===o.memoizedState||(h.flags|=4),typeof ne.getSnapshotBeforeUpdate!="function"||_e===o.memoizedProps&&at===o.memoizedState||(h.flags|=1024),h.memoizedProps=A,h.memoizedState=Ot),ne.props=A,ne.state=Ot,ne.context=De,A=He):(typeof ne.componentDidUpdate!="function"||_e===o.memoizedProps&&at===o.memoizedState||(h.flags|=4),typeof ne.getSnapshotBeforeUpdate!="function"||_e===o.memoizedProps&&at===o.memoizedState||(h.flags|=1024),A=!1)}return Eu(o,h,_,A,H,O)}function Eu(o,h,_,A,O,H){Rp(o,h);var ne=(h.flags&128)!==0;if(!A&&!ne)return O&&ep(h,_,!1),no(o,h,H);A=h.stateNode,Zm.current=h;var _e=ne&&typeof _.getDerivedStateFromError!="function"?null:A.render();return h.flags|=1,o!==null&&ne?(h.child=za(h,o.child,null,H),h.child=za(h,null,_e,H)):Kn(o,h,_e,H),h.memoizedState=A.state,O&&ep(h,_,!0),h.child}function Tu(o){var h=o.stateNode;h.pendingContext?Zh(o,h.pendingContext,h.pendingContext!==h.context):h.context&&Zh(o,h.context,!1),cu(o,h.containerInfo)}function Mp(o,h,_,A,O){return Qo(),tu(O),h.flags|=256,Kn(o,h,_,A),h.child}var Du={dehydrated:null,treeContext:null,retryLane:0};function $u(o){return{baseLanes:o,cachePool:null,transitions:null}}function Op(o,h,_){var A=h.pendingProps,O=nn.current,H=!1,ne=(h.flags&128)!==0,_e;if((_e=ne)||(_e=o!==null&&o.memoizedState===null?!1:(O&2)!==0),_e?(H=!0,h.flags&=-129):(o===null||o.memoizedState!==null)&&(O|=1),Hi(nn,O&1),o===null)return Qd(h),o=h.memoizedState,o!==null&&(o=o.dehydrated,o!==null)?((h.mode&1)===0?h.lanes=1:o.data==="$!"?h.lanes=8:h.lanes=1073741824,null):(ne=A.children,o=A.fallback,H?(A=h.mode,H=h.child,ne={mode:"hidden",children:ne},(A&1)===0&&H!==null?(H.childLanes=0,H.pendingProps=ne):H=id(ne,A,0,null),o=Ka(o,A,_,null),H.return=h,o.return=h,H.sibling=o,h.child=H,h.child.memoizedState=$u(_),h.memoizedState=Du,o):jl(h,ne));if(O=o.memoizedState,O!==null&&(_e=O.dehydrated,_e!==null))return Qm(o,h,ne,A,_e,O,_);if(H){H=A.fallback,ne=h.mode,O=o.child,_e=O.sibling;var De={mode:"hidden",children:A.children};return(ne&1)===0&&h.child!==O?(A=h.child,A.childLanes=0,A.pendingProps=De,h.deletions=null):(A=jo(O,De),A.subtreeFlags=O.subtreeFlags&14680064),_e!==null?H=jo(_e,H):(H=Ka(H,ne,_,null),H.flags|=2),H.return=h,A.return=h,A.sibling=H,h.child=A,A=H,H=h.child,ne=o.child.memoizedState,ne=ne===null?$u(_):{baseLanes:ne.baseLanes|_,cachePool:null,transitions:ne.transitions},H.memoizedState=ne,H.childLanes=o.childLanes&~_,h.memoizedState=Du,A}return H=o.child,o=H.sibling,A=jo(H,{mode:"visible",children:A.children}),(h.mode&1)===0&&(A.lanes=_),A.return=h,A.sibling=null,o!==null&&(_=h.deletions,_===null?(h.deletions=[o],h.flags|=16):_.push(o)),h.child=A,h.memoizedState=null,A}function jl(o,h){return h=id({mode:"visible",children:h},o.mode,0,null),h.return=o,o.child=h}function Hc(o,h,_,A){return A!==null&&tu(A),za(h,o.child,null,_),o=jl(h,h.pendingProps.children),o.flags|=2,h.memoizedState=null,o}function Qm(o,h,_,A,O,H,ne){if(_)return h.flags&256?(h.flags&=-257,A=Su(Error(t(422))),Hc(o,h,ne,A)):h.memoizedState!==null?(h.child=o.child,h.flags|=128,null):(H=A.fallback,O=h.mode,A=id({mode:"visible",children:A.children},O,0,null),H=Ka(H,O,ne,null),H.flags|=2,A.return=h,H.return=h,A.sibling=H,h.child=A,(h.mode&1)!==0&&za(h,o.child,null,ne),h.child.memoizedState=$u(ne),h.memoizedState=Du,H);if((h.mode&1)===0)return Hc(o,h,ne,null);if(O.data==="$!"){if(A=O.nextSibling&&O.nextSibling.dataset,A)var _e=A.dgst;return A=_e,H=Error(t(419)),A=Su(H,A,void 0),Hc(o,h,ne,A)}if(_e=(ne&o.childLanes)!==0,ks||_e){if(A=wn,A!==null){switch(ne&-ne){case 4:O=2;break;case 16:O=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:O=32;break;case 536870912:O=268435456;break;default:O=0}O=(O&(A.suspendedLanes|ne))!==0?0:O,O!==0&&O!==H.retryLane&&(H.retryLane=O,eo(o,O),_r(A,o,O,-1))}return Ju(),A=Su(Error(t(421))),Hc(o,h,ne,A)}return O.data==="$?"?(h.flags|=128,h.child=o.child,h=dg.bind(null,o),O._reactRetry=h,null):(o=H.treeContext,Ms=xo(O.nextSibling),Ss=h,en=!0,Cs=null,o!==null&&(qs[fr++]=ys,qs[fr++]=xs,qs[fr++]=Ks,ys=o.id,xs=o.overflow,Ks=h),h=jl(h,A.children),h.flags|=4096,h)}function Lp(o,h,_){o.lanes|=h;var A=o.alternate;A!==null&&(A.lanes|=h),sp(o.return,h,_)}function Au(o,h,_,A,O){var H=o.memoizedState;H===null?o.memoizedState={isBackwards:h,rendering:null,renderingStartTime:0,last:A,tail:_,tailMode:O}:(H.isBackwards=h,H.rendering=null,H.renderingStartTime=0,H.last=A,H.tail=_,H.tailMode=O)}function Iu(o,h,_){var A=h.pendingProps,O=A.revealOrder,H=A.tail;if(Kn(o,h,A.children,_),A=nn.current,(A&2)!==0)A=A&1|2,h.flags|=128;else{if(o!==null&&(o.flags&128)!==0)e:for(o=h.child;o!==null;){if(o.tag===13)o.memoizedState!==null&&Lp(o,_,h);else if(o.tag===19)Lp(o,_,h);else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===h)break e;for(;o.sibling===null;){if(o.return===null||o.return===h)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}A&=1}if(Hi(nn,A),(h.mode&1)===0)h.memoizedState=null;else switch(O){case"forwards":for(_=h.child,O=null;_!==null;)o=_.alternate,o!==null&&Lc(o)===null&&(O=_),_=_.sibling;_=O,_===null?(O=h.child,h.child=null):(O=_.sibling,_.sibling=null),Au(h,!1,O,_,H);break;case"backwards":for(_=null,O=h.child,h.child=null;O!==null;){if(o=O.alternate,o!==null&&Lc(o)===null){h.child=O;break}o=O.sibling,O.sibling=_,_=O,O=o}Au(h,!0,_,null,H);break;case"together":Au(h,!1,null,null,void 0);break;default:h.memoizedState=null}return h.child}function Wc(o,h){(h.mode&1)===0&&o!==null&&(o.alternate=null,h.alternate=null,h.flags|=2)}function no(o,h,_){if(o!==null&&(h.dependencies=o.dependencies),aa|=h.lanes,(_&h.childLanes)===0)return null;if(o!==null&&h.child!==o.child)throw Error(t(153));if(h.child!==null){for(o=h.child,_=jo(o,o.pendingProps),h.child=_,_.return=h;o.sibling!==null;)o=o.sibling,_=_.sibling=jo(o,o.pendingProps),_.return=h;_.sibling=null}return h.child}function c_(o,h,_){switch(h.tag){case 3:Tu(h),Qo();break;case 5:rp(h);break;case 1:ws(h.type)&&$c(h);break;case 4:cu(h,h.stateNode.containerInfo);break;case 10:var A=h.type._context,O=h.memoizedProps.value;Hi(ea,A._currentValue),A._currentValue=O;break;case 13:if(A=h.memoizedState,A!==null)return A.dehydrated!==null?(Hi(nn,nn.current&1),h.flags|=128,null):(_&h.child.childLanes)!==0?Op(o,h,_):(Hi(nn,nn.current&1),o=no(o,h,_),o!==null?o.sibling:null);Hi(nn,nn.current&1);break;case 19:if(A=(_&h.childLanes)!==0,(o.flags&128)!==0){if(A)return Iu(o,h,_);h.flags|=128}if(O=h.memoizedState,O!==null&&(O.rendering=null,O.tail=null,O.lastEffect=null),Hi(nn,nn.current),A)break;return null;case 22:case 23:return h.lanes=0,jp(o,h,_)}return no(o,h,_)}var Pu,ju,zp,Bp;Pu=function(o,h){for(var _=h.child;_!==null;){if(_.tag===5||_.tag===6)o.appendChild(_.stateNode);else if(_.tag!==4&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===h)break;for(;_.sibling===null;){if(_.return===null||_.return===h)return;_=_.return}_.sibling.return=_.return,_=_.sibling}},ju=function(){},zp=function(o,h,_,A){var O=o.memoizedProps;if(O!==A){o=h.stateNode,ia(Br.current);var H=null;switch(_){case"input":O=ft(o,O),A=ft(o,A),H=[];break;case"select":O=X({},O,{value:void 0}),A=X({},A,{value:void 0}),H=[];break;case"textarea":O=Pt(o,O),A=Pt(o,A),H=[];break;default:typeof O.onClick!="function"&&typeof A.onClick=="function"&&(o.onclick=Ec)}Sn(_,A);var ne;_=null;for(He in O)if(!A.hasOwnProperty(He)&&O.hasOwnProperty(He)&&O[He]!=null)if(He==="style"){var _e=O[He];for(ne in _e)_e.hasOwnProperty(ne)&&(_||(_={}),_[ne]="")}else He!=="dangerouslySetInnerHTML"&&He!=="children"&&He!=="suppressContentEditableWarning"&&He!=="suppressHydrationWarning"&&He!=="autoFocus"&&(r.hasOwnProperty(He)?H||(H=[]):(H=H||[]).push(He,null));for(He in A){var De=A[He];if(_e=O!=null?O[He]:void 0,A.hasOwnProperty(He)&&De!==_e&&(De!=null||_e!=null))if(He==="style")if(_e){for(ne in _e)!_e.hasOwnProperty(ne)||De&&De.hasOwnProperty(ne)||(_||(_={}),_[ne]="");for(ne in De)De.hasOwnProperty(ne)&&_e[ne]!==De[ne]&&(_||(_={}),_[ne]=De[ne])}else _||(H||(H=[]),H.push(He,_)),_=De;else He==="dangerouslySetInnerHTML"?(De=De?De.__html:void 0,_e=_e?_e.__html:void 0,De!=null&&_e!==De&&(H=H||[]).push(He,De)):He==="children"?typeof De!="string"&&typeof De!="number"||(H=H||[]).push(He,""+De):He!=="suppressContentEditableWarning"&&He!=="suppressHydrationWarning"&&(r.hasOwnProperty(He)?(De!=null&&He==="onScroll"&&qi("scroll",o),H||_e===De||(H=[])):(H=H||[]).push(He,De))}_&&(H=H||[]).push("style",_);var He=H;(h.updateQueue=He)&&(h.flags|=4)}},Bp=function(o,h,_,A){_!==A&&(h.flags|=4)};function Uc(o,h){if(!en)switch(o.tailMode){case"hidden":h=o.tail;for(var _=null;h!==null;)h.alternate!==null&&(_=h),h=h.sibling;_===null?o.tail=null:_.sibling=null;break;case"collapsed":_=o.tail;for(var A=null;_!==null;)_.alternate!==null&&(A=_),_=_.sibling;A===null?h||o.tail===null?o.tail=null:o.tail.sibling=null:A.sibling=null}}function Yn(o){var h=o.alternate!==null&&o.alternate.child===o.child,_=0,A=0;if(h)for(var O=o.child;O!==null;)_|=O.lanes|O.childLanes,A|=O.subtreeFlags&14680064,A|=O.flags&14680064,O.return=o,O=O.sibling;else for(O=o.child;O!==null;)_|=O.lanes|O.childLanes,A|=O.subtreeFlags,A|=O.flags,O.return=o,O=O.sibling;return o.subtreeFlags|=A,o.childLanes=_,h}function eg(o,h,_){var A=h.pendingProps;switch(Yd(h),h.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Yn(h),null;case 1:return ws(h.type)&&Dc(),Yn(h),null;case 3:return A=h.stateNode,na(),Ki(bs),Ki(os),hu(),A.pendingContext&&(A.context=A.pendingContext,A.pendingContext=null),(o===null||o.child===null)&&(Tl(h)?h.flags|=4:o===null||o.memoizedState.isDehydrated&&(h.flags&256)===0||(h.flags|=1024,Cs!==null&&(Ku(Cs),Cs=null))),ju(o,h),Yn(h),null;case 5:du(h);var O=ia(Fa.current);if(_=h.type,o!==null&&h.stateNode!=null)zp(o,h,_,A,O),o.ref!==h.ref&&(h.flags|=512,h.flags|=2097152);else{if(!A){if(h.stateNode===null)throw Error(t(166));return Yn(h),null}if(o=ia(Br.current),Tl(h)){A=h.stateNode,_=h.type;var H=h.memoizedProps;switch(A[Or]=h,A[kl]=H,o=(h.mode&1)!==0,_){case"dialog":qi("cancel",A),qi("close",A);break;case"iframe":case"object":case"embed":qi("load",A);break;case"video":case"audio":for(O=0;O<xl.length;O++)qi(xl[O],A);break;case"source":qi("error",A);break;case"img":case"image":case"link":qi("error",A),qi("load",A);break;case"details":qi("toggle",A);break;case"input":rt(A,H),qi("invalid",A);break;case"select":A._wrapperState={wasMultiple:!!H.multiple},qi("invalid",A);break;case"textarea":_t(A,H),qi("invalid",A)}Sn(_,H),O=null;for(var ne in H)if(H.hasOwnProperty(ne)){var _e=H[ne];ne==="children"?typeof _e=="string"?A.textContent!==_e&&(H.suppressHydrationWarning!==!0&&kc(A.textContent,_e,o),O=["children",_e]):typeof _e=="number"&&A.textContent!==""+_e&&(H.suppressHydrationWarning!==!0&&kc(A.textContent,_e,o),O=["children",""+_e]):r.hasOwnProperty(ne)&&_e!=null&&ne==="onScroll"&&qi("scroll",A)}switch(_){case"input":Ie(A),mi(A,H,!0);break;case"textarea":Ie(A),Se(A);break;case"select":case"option":break;default:typeof H.onClick=="function"&&(A.onclick=Ec)}A=O,h.updateQueue=A,A!==null&&(h.flags|=4)}else{ne=O.nodeType===9?O:O.ownerDocument,o==="http://www.w3.org/1999/xhtml"&&(o=tt(_)),o==="http://www.w3.org/1999/xhtml"?_==="script"?(o=ne.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild)):typeof A.is=="string"?o=ne.createElement(_,{is:A.is}):(o=ne.createElement(_),_==="select"&&(ne=o,A.multiple?ne.multiple=!0:A.size&&(ne.size=A.size))):o=ne.createElementNS(o,_),o[Or]=h,o[kl]=A,Pu(o,h,!1,!1),h.stateNode=o;e:{switch(ne=ai(_,A),_){case"dialog":qi("cancel",o),qi("close",o),O=A;break;case"iframe":case"object":case"embed":qi("load",o),O=A;break;case"video":case"audio":for(O=0;O<xl.length;O++)qi(xl[O],o);O=A;break;case"source":qi("error",o),O=A;break;case"img":case"image":case"link":qi("error",o),qi("load",o),O=A;break;case"details":qi("toggle",o),O=A;break;case"input":rt(o,A),O=ft(o,A),qi("invalid",o);break;case"option":O=A;break;case"select":o._wrapperState={wasMultiple:!!A.multiple},O=X({},A,{value:void 0}),qi("invalid",o);break;case"textarea":_t(o,A),O=Pt(o,A),qi("invalid",o);break;default:O=A}Sn(_,O),_e=O;for(H in _e)if(_e.hasOwnProperty(H)){var De=_e[H];H==="style"?wt(o,De):H==="dangerouslySetInnerHTML"?(De=De?De.__html:void 0,De!=null&&gi(o,De)):H==="children"?typeof De=="string"?(_!=="textarea"||De!=="")&&Jt(o,De):typeof De=="number"&&Jt(o,""+De):H!=="suppressContentEditableWarning"&&H!=="suppressHydrationWarning"&&H!=="autoFocus"&&(r.hasOwnProperty(H)?De!=null&&H==="onScroll"&&qi("scroll",o):De!=null&&S(o,H,De,ne))}switch(_){case"input":Ie(o),mi(o,A,!1);break;case"textarea":Ie(o),Se(o);break;case"option":A.value!=null&&o.setAttribute("value",""+J(A.value));break;case"select":o.multiple=!!A.multiple,H=A.value,H!=null?Je(o,!!A.multiple,H,!1):A.defaultValue!=null&&Je(o,!!A.multiple,A.defaultValue,!0);break;default:typeof O.onClick=="function"&&(o.onclick=Ec)}switch(_){case"button":case"input":case"select":case"textarea":A=!!A.autoFocus;break e;case"img":A=!0;break e;default:A=!1}}A&&(h.flags|=4)}h.ref!==null&&(h.flags|=512,h.flags|=2097152)}return Yn(h),null;case 6:if(o&&h.stateNode!=null)Bp(o,h,o.memoizedProps,A);else{if(typeof A!="string"&&h.stateNode===null)throw Error(t(166));if(_=ia(Fa.current),ia(Br.current),Tl(h)){if(A=h.stateNode,_=h.memoizedProps,A[Or]=h,(H=A.nodeValue!==_)&&(o=Ss,o!==null))switch(o.tag){case 3:kc(A.nodeValue,_,(o.mode&1)!==0);break;case 5:o.memoizedProps.suppressHydrationWarning!==!0&&kc(A.nodeValue,_,(o.mode&1)!==0)}H&&(h.flags|=4)}else A=(_.nodeType===9?_:_.ownerDocument).createTextNode(A),A[Or]=h,h.stateNode=A}return Yn(h),null;case 13:if(Ki(nn),A=h.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(en&&Ms!==null&&(h.mode&1)!==0&&(h.flags&128)===0)ip(),Qo(),h.flags|=98560,H=!1;else if(H=Tl(h),A!==null&&A.dehydrated!==null){if(o===null){if(!H)throw Error(t(318));if(H=h.memoizedState,H=H!==null?H.dehydrated:null,!H)throw Error(t(317));H[Or]=h}else Qo(),(h.flags&128)===0&&(h.memoizedState=null),h.flags|=4;Yn(h),H=!1}else Cs!==null&&(Ku(Cs),Cs=null),H=!0;if(!H)return h.flags&65536?h:null}return(h.flags&128)!==0?(h.lanes=_,h):(A=A!==null,A!==(o!==null&&o.memoizedState!==null)&&A&&(h.child.flags|=8192,(h.mode&1)!==0&&(o===null||(nn.current&1)!==0?Dn===0&&(Dn=3):Ju())),h.updateQueue!==null&&(h.flags|=4),Yn(h),null);case 4:return na(),ju(o,h),o===null&&Sl(h.stateNode.containerInfo),Yn(h),null;case 10:return ou(h.type._context),Yn(h),null;case 17:return ws(h.type)&&Dc(),Yn(h),null;case 19:if(Ki(nn),H=h.memoizedState,H===null)return Yn(h),null;if(A=(h.flags&128)!==0,ne=H.rendering,ne===null)if(A)Uc(H,!1);else{if(Dn!==0||o!==null&&(o.flags&128)!==0)for(o=h.child;o!==null;){if(ne=Lc(o),ne!==null){for(h.flags|=128,Uc(H,!1),A=ne.updateQueue,A!==null&&(h.updateQueue=A,h.flags|=4),h.subtreeFlags=0,A=_,_=h.child;_!==null;)H=_,o=A,H.flags&=14680066,ne=H.alternate,ne===null?(H.childLanes=0,H.lanes=o,H.child=null,H.subtreeFlags=0,H.memoizedProps=null,H.memoizedState=null,H.updateQueue=null,H.dependencies=null,H.stateNode=null):(H.childLanes=ne.childLanes,H.lanes=ne.lanes,H.child=ne.child,H.subtreeFlags=0,H.deletions=null,H.memoizedProps=ne.memoizedProps,H.memoizedState=ne.memoizedState,H.updateQueue=ne.updateQueue,H.type=ne.type,o=ne.dependencies,H.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),_=_.sibling;return Hi(nn,nn.current&1|2),h.child}o=o.sibling}H.tail!==null&&$i()>Va&&(h.flags|=128,A=!0,Uc(H,!1),h.lanes=4194304)}else{if(!A)if(o=Lc(ne),o!==null){if(h.flags|=128,A=!0,_=o.updateQueue,_!==null&&(h.updateQueue=_,h.flags|=4),Uc(H,!0),H.tail===null&&H.tailMode==="hidden"&&!ne.alternate&&!en)return Yn(h),null}else 2*$i()-H.renderingStartTime>Va&&_!==1073741824&&(h.flags|=128,A=!0,Uc(H,!1),h.lanes=4194304);H.isBackwards?(ne.sibling=h.child,h.child=ne):(_=H.last,_!==null?_.sibling=ne:h.child=ne,H.last=ne)}return H.tail!==null?(h=H.tail,H.rendering=h,H.tail=h.sibling,H.renderingStartTime=$i(),h.sibling=null,_=nn.current,Hi(nn,A?_&1|2:_&1),h):(Yn(h),null);case 22:case 23:return Xu(),A=h.memoizedState!==null,o!==null&&o.memoizedState!==null!==A&&(h.flags|=8192),A&&(h.mode&1)!==0?(Os&1073741824)!==0&&(Yn(h),h.subtreeFlags&6&&(h.flags|=8192)):Yn(h),null;case 24:return null;case 25:return null}throw Error(t(156,h.tag))}function tg(o,h){switch(Yd(h),h.tag){case 1:return ws(h.type)&&Dc(),o=h.flags,o&65536?(h.flags=o&-65537|128,h):null;case 3:return na(),Ki(bs),Ki(os),hu(),o=h.flags,(o&65536)!==0&&(o&128)===0?(h.flags=o&-65537|128,h):null;case 5:return du(h),null;case 13:if(Ki(nn),o=h.memoizedState,o!==null&&o.dehydrated!==null){if(h.alternate===null)throw Error(t(340));Qo()}return o=h.flags,o&65536?(h.flags=o&-65537|128,h):null;case 19:return Ki(nn),null;case 4:return na(),null;case 10:return ou(h.type._context),null;case 22:case 23:return Xu(),null;case 24:return null;default:return null}}var Ru=!1,Xn=!1,ig=typeof WeakSet=="function"?WeakSet:Set,Mt=null;function Wa(o,h){var _=o.ref;if(_!==null)if(typeof _=="function")try{_(null)}catch(A){sn(o,h,A)}else _.current=null}function Nu(o,h,_){try{_()}catch(A){sn(o,h,A)}}var Gp=!1;function ng(o,h){if(Gd=wo,o=jd(),Rd(o)){if("selectionStart"in o)var _={start:o.selectionStart,end:o.selectionEnd};else e:{_=(_=o.ownerDocument)&&_.defaultView||window;var A=_.getSelection&&_.getSelection();if(A&&A.rangeCount!==0){_=A.anchorNode;var O=A.anchorOffset,H=A.focusNode;A=A.focusOffset;try{_.nodeType,H.nodeType}catch{_=null;break e}var ne=0,_e=-1,De=-1,He=0,lt=0,ct=o,at=null;t:for(;;){for(var Dt;ct!==_||O!==0&&ct.nodeType!==3||(_e=ne+O),ct!==H||A!==0&&ct.nodeType!==3||(De=ne+A),ct.nodeType===3&&(ne+=ct.nodeValue.length),(Dt=ct.firstChild)!==null;)at=ct,ct=Dt;for(;;){if(ct===o)break t;if(at===_&&++He===O&&(_e=ne),at===H&&++lt===A&&(De=ne),(Dt=ct.nextSibling)!==null)break;ct=at,at=ct.parentNode}ct=Dt}_=_e===-1||De===-1?null:{start:_e,end:De}}else _=null}_=_||{start:0,end:0}}else _=null;for(Fd={focusedElem:o,selectionRange:_},wo=!1,Mt=h;Mt!==null;)if(h=Mt,o=h.child,(h.subtreeFlags&1028)!==0&&o!==null)o.return=h,Mt=o;else for(;Mt!==null;){h=Mt;try{var Ot=h.alternate;if((h.flags&1024)!==0)switch(h.tag){case 0:case 11:case 15:break;case 1:if(Ot!==null){var Lt=Ot.memoizedProps,Wi=Ot.memoizedState,Ge=h.stateNode,Re=Ge.getSnapshotBeforeUpdate(h.elementType===h.type?Lt:bn(h.type,Lt),Wi);Ge.__reactInternalSnapshotBeforeUpdate=Re}break;case 3:var We=h.stateNode.containerInfo;We.nodeType===1?We.textContent="":We.nodeType===9&&We.documentElement&&We.removeChild(We.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(pt){sn(h,h.return,pt)}if(o=h.sibling,o!==null){o.return=h.return,Mt=o;break}Mt=h.return}return Ot=Gp,Gp=!1,Ot}function Rl(o,h,_){var A=h.updateQueue;if(A=A!==null?A.lastEffect:null,A!==null){var O=A=A.next;do{if((O.tag&o)===o){var H=O.destroy;O.destroy=void 0,H!==void 0&&Nu(h,_,H)}O=O.next}while(O!==A)}}function Mu(o,h){if(h=h.updateQueue,h=h!==null?h.lastEffect:null,h!==null){var _=h=h.next;do{if((_.tag&o)===o){var A=_.create;_.destroy=A()}_=_.next}while(_!==h)}}function Ou(o){var h=o.ref;if(h!==null){var _=o.stateNode;switch(o.tag){case 5:o=_;break;default:o=_}typeof h=="function"?h(o):h.current=o}}function Fp(o){var h=o.alternate;h!==null&&(o.alternate=null,Fp(h)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(h=o.stateNode,h!==null&&(delete h[Or],delete h[kl],delete h[Vd],delete h[Xh],delete h[Jh])),o.stateNode=null,o.return=null,o.dependencies=null,o.memoizedProps=null,o.memoizedState=null,o.pendingProps=null,o.stateNode=null,o.updateQueue=null}function Hp(o){return o.tag===5||o.tag===3||o.tag===4}function Wp(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||Hp(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function Lu(o,h,_){var A=o.tag;if(A===5||A===6)o=o.stateNode,h?_.nodeType===8?_.parentNode.insertBefore(o,h):_.insertBefore(o,h):(_.nodeType===8?(h=_.parentNode,h.insertBefore(o,_)):(h=_,h.appendChild(o)),_=_._reactRootContainer,_!=null||h.onclick!==null||(h.onclick=Ec));else if(A!==4&&(o=o.child,o!==null))for(Lu(o,h,_),o=o.sibling;o!==null;)Lu(o,h,_),o=o.sibling}function zu(o,h,_){var A=o.tag;if(A===5||A===6)o=o.stateNode,h?_.insertBefore(o,h):_.appendChild(o);else if(A!==4&&(o=o.child,o!==null))for(zu(o,h,_),o=o.sibling;o!==null;)zu(o,h,_),o=o.sibling}var On=null,gr=!1;function Do(o,h,_){for(_=_.child;_!==null;)sg(o,h,_),_=_.sibling}function sg(o,h,_){if(Cn&&typeof Cn.onCommitFiberUnmount=="function")try{Cn.onCommitFiberUnmount(gs,_)}catch{}switch(_.tag){case 5:Xn||Wa(_,h);case 6:var A=On,O=gr;On=null,Do(o,h,_),On=A,gr=O,On!==null&&(gr?(o=On,_=_.stateNode,o.nodeType===8?o.parentNode.removeChild(_):o.removeChild(_)):On.removeChild(_.stateNode));break;case 18:On!==null&&(gr?(o=On,_=_.stateNode,o.nodeType===8?Ud(o.parentNode,_):o.nodeType===1&&Ud(o,_),Xr(o)):Ud(On,_.stateNode));break;case 4:A=On,O=gr,On=_.stateNode.containerInfo,gr=!0,Do(o,h,_),On=A,gr=O;break;case 0:case 11:case 14:case 15:if(!Xn&&(A=_.updateQueue,A!==null&&(A=A.lastEffect,A!==null))){O=A=A.next;do{var H=O,ne=H.destroy;H=H.tag,ne!==void 0&&((H&2)!==0||(H&4)!==0)&&Nu(_,h,ne),O=O.next}while(O!==A)}Do(o,h,_);break;case 1:if(!Xn&&(Wa(_,h),A=_.stateNode,typeof A.componentWillUnmount=="function"))try{A.props=_.memoizedProps,A.state=_.memoizedState,A.componentWillUnmount()}catch(_e){sn(_,h,_e)}Do(o,h,_);break;case 21:Do(o,h,_);break;case 22:_.mode&1?(Xn=(A=Xn)||_.memoizedState!==null,Do(o,h,_),Xn=A):Do(o,h,_);break;default:Do(o,h,_)}}function Nl(o){var h=o.updateQueue;if(h!==null){o.updateQueue=null;var _=o.stateNode;_===null&&(_=o.stateNode=new ig),h.forEach(function(A){var O=ug.bind(null,o,A);_.has(A)||(_.add(A),A.then(O,O))})}}function Js(o,h){var _=h.deletions;if(_!==null)for(var A=0;A<_.length;A++){var O=_[A];try{var H=o,ne=h,_e=ne;e:for(;_e!==null;){switch(_e.tag){case 5:On=_e.stateNode,gr=!1;break e;case 3:On=_e.stateNode.containerInfo,gr=!0;break e;case 4:On=_e.stateNode.containerInfo,gr=!0;break e}_e=_e.return}if(On===null)throw Error(t(160));sg(H,ne,O),On=null,gr=!1;var De=O.alternate;De!==null&&(De.return=null),O.return=null}catch(He){sn(O,h,He)}}if(h.subtreeFlags&12854)for(h=h.child;h!==null;)Bu(h,o),h=h.sibling}function Bu(o,h){var _=o.alternate,A=o.flags;switch(o.tag){case 0:case 11:case 14:case 15:if(Js(h,o),vr(o),A&4){try{Rl(3,o,o.return),Mu(3,o)}catch(Lt){sn(o,o.return,Lt)}try{Rl(5,o,o.return)}catch(Lt){sn(o,o.return,Lt)}}break;case 1:Js(h,o),vr(o),A&512&&_!==null&&Wa(_,_.return);break;case 5:if(Js(h,o),vr(o),A&512&&_!==null&&Wa(_,_.return),o.flags&32){var O=o.stateNode;try{Jt(O,"")}catch(Lt){sn(o,o.return,Lt)}}if(A&4&&(O=o.stateNode,O!=null)){var H=o.memoizedProps,ne=_!==null?_.memoizedProps:H,_e=o.type,De=o.updateQueue;if(o.updateQueue=null,De!==null)try{_e==="input"&&H.type==="radio"&&H.name!=null&&Nt(O,H),ai(_e,ne);var He=ai(_e,H);for(ne=0;ne<De.length;ne+=2){var lt=De[ne],ct=De[ne+1];lt==="style"?wt(O,ct):lt==="dangerouslySetInnerHTML"?gi(O,ct):lt==="children"?Jt(O,ct):S(O,lt,ct,He)}switch(_e){case"input":mt(O,H);break;case"textarea":hi(O,H);break;case"select":var at=O._wrapperState.wasMultiple;O._wrapperState.wasMultiple=!!H.multiple;var Dt=H.value;Dt!=null?Je(O,!!H.multiple,Dt,!1):at!==!!H.multiple&&(H.defaultValue!=null?Je(O,!!H.multiple,H.defaultValue,!0):Je(O,!!H.multiple,H.multiple?[]:"",!1))}O[kl]=H}catch(Lt){sn(o,o.return,Lt)}}break;case 6:if(Js(h,o),vr(o),A&4){if(o.stateNode===null)throw Error(t(162));O=o.stateNode,H=o.memoizedProps;try{O.nodeValue=H}catch(Lt){sn(o,o.return,Lt)}}break;case 3:if(Js(h,o),vr(o),A&4&&_!==null&&_.memoizedState.isDehydrated)try{Xr(h.containerInfo)}catch(Lt){sn(o,o.return,Lt)}break;case 4:Js(h,o),vr(o);break;case 13:Js(h,o),vr(o),O=o.child,O.flags&8192&&(H=O.memoizedState!==null,O.stateNode.isHidden=H,!H||O.alternate!==null&&O.alternate.memoizedState!==null||(Wu=$i())),A&4&&Nl(o);break;case 22:if(lt=_!==null&&_.memoizedState!==null,o.mode&1?(Xn=(He=Xn)||lt,Js(h,o),Xn=He):Js(h,o),vr(o),A&8192){if(He=o.memoizedState!==null,(o.stateNode.isHidden=He)&&!lt&&(o.mode&1)!==0)for(Mt=o,lt=o.child;lt!==null;){for(ct=Mt=lt;Mt!==null;){switch(at=Mt,Dt=at.child,at.tag){case 0:case 11:case 14:case 15:Rl(4,at,at.return);break;case 1:Wa(at,at.return);var Ot=at.stateNode;if(typeof Ot.componentWillUnmount=="function"){A=at,_=at.return;try{h=A,Ot.props=h.memoizedProps,Ot.state=h.memoizedState,Ot.componentWillUnmount()}catch(Lt){sn(A,_,Lt)}}break;case 5:Wa(at,at.return);break;case 22:if(at.memoizedState!==null){Gu(ct);continue}}Dt!==null?(Dt.return=at,Mt=Dt):Gu(ct)}lt=lt.sibling}e:for(lt=null,ct=o;;){if(ct.tag===5){if(lt===null){lt=ct;try{O=ct.stateNode,He?(H=O.style,typeof H.setProperty=="function"?H.setProperty("display","none","important"):H.display="none"):(_e=ct.stateNode,De=ct.memoizedProps.style,ne=De!=null&&De.hasOwnProperty("display")?De.display:null,_e.style.display=un("display",ne))}catch(Lt){sn(o,o.return,Lt)}}}else if(ct.tag===6){if(lt===null)try{ct.stateNode.nodeValue=He?"":ct.memoizedProps}catch(Lt){sn(o,o.return,Lt)}}else if((ct.tag!==22&&ct.tag!==23||ct.memoizedState===null||ct===o)&&ct.child!==null){ct.child.return=ct,ct=ct.child;continue}if(ct===o)break e;for(;ct.sibling===null;){if(ct.return===null||ct.return===o)break e;lt===ct&&(lt=null),ct=ct.return}lt===ct&&(lt=null),ct.sibling.return=ct.return,ct=ct.sibling}}break;case 19:Js(h,o),vr(o),A&4&&Nl(o);break;case 21:break;default:Js(h,o),vr(o)}}function vr(o){var h=o.flags;if(h&2){try{e:{for(var _=o.return;_!==null;){if(Hp(_)){var A=_;break e}_=_.return}throw Error(t(160))}switch(A.tag){case 5:var O=A.stateNode;A.flags&32&&(Jt(O,""),A.flags&=-33);var H=Wp(o);zu(o,H,O);break;case 3:case 4:var ne=A.stateNode.containerInfo,_e=Wp(o);Lu(o,_e,ne);break;default:throw Error(t(161))}}catch(De){sn(o,o.return,De)}o.flags&=-3}h&4096&&(o.flags&=-4097)}function Up(o,h,_){Mt=o,Vp(o)}function Vp(o,h,_){for(var A=(o.mode&1)!==0;Mt!==null;){var O=Mt,H=O.child;if(O.tag===22&&A){var ne=O.memoizedState!==null||Ru;if(!ne){var _e=O.alternate,De=_e!==null&&_e.memoizedState!==null||Xn;_e=Ru;var He=Xn;if(Ru=ne,(Xn=De)&&!He)for(Mt=O;Mt!==null;)ne=Mt,De=ne.child,ne.tag===22&&ne.memoizedState!==null?Fu(O):De!==null?(De.return=ne,Mt=De):Fu(O);for(;H!==null;)Mt=H,Vp(H),H=H.sibling;Mt=O,Ru=_e,Xn=He}qp(o)}else(O.subtreeFlags&8772)!==0&&H!==null?(H.return=O,Mt=H):qp(o)}}function qp(o){for(;Mt!==null;){var h=Mt;if((h.flags&8772)!==0){var _=h.alternate;try{if((h.flags&8772)!==0)switch(h.tag){case 0:case 11:case 15:Xn||Mu(5,h);break;case 1:var A=h.stateNode;if(h.flags&4&&!Xn)if(_===null)A.componentDidMount();else{var O=h.elementType===h.type?_.memoizedProps:bn(h.type,_.memoizedProps);A.componentDidUpdate(O,_.memoizedState,A.__reactInternalSnapshotBeforeUpdate)}var H=h.updateQueue;H!==null&&Fm(h,H,A);break;case 3:var ne=h.updateQueue;if(ne!==null){if(_=null,h.child!==null)switch(h.child.tag){case 5:_=h.child.stateNode;break;case 1:_=h.child.stateNode}Fm(h,ne,_)}break;case 5:var _e=h.stateNode;if(_===null&&h.flags&4){_=_e;var De=h.memoizedProps;switch(h.type){case"button":case"input":case"select":case"textarea":De.autoFocus&&_.focus();break;case"img":De.src&&(_.src=De.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(h.memoizedState===null){var He=h.alternate;if(He!==null){var lt=He.memoizedState;if(lt!==null){var ct=lt.dehydrated;ct!==null&&Xr(ct)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(t(163))}Xn||h.flags&512&&Ou(h)}catch(at){sn(h,h.return,at)}}if(h===o){Mt=null;break}if(_=h.sibling,_!==null){_.return=h.return,Mt=_;break}Mt=h.return}}function Gu(o){for(;Mt!==null;){var h=Mt;if(h===o){Mt=null;break}var _=h.sibling;if(_!==null){_.return=h.return,Mt=_;break}Mt=h.return}}function Fu(o){for(;Mt!==null;){var h=Mt;try{switch(h.tag){case 0:case 11:case 15:var _=h.return;try{Mu(4,h)}catch(De){sn(h,_,De)}break;case 1:var A=h.stateNode;if(typeof A.componentDidMount=="function"){var O=h.return;try{A.componentDidMount()}catch(De){sn(h,O,De)}}var H=h.return;try{Ou(h)}catch(De){sn(h,H,De)}break;case 5:var ne=h.return;try{Ou(h)}catch(De){sn(h,ne,De)}}}catch(De){sn(h,h.return,De)}if(h===o){Mt=null;break}var _e=h.sibling;if(_e!==null){_e.return=h.return,Mt=_e;break}Mt=h.return}}var rg=Math.ceil,Vc=T.ReactCurrentDispatcher,qc=T.ReactCurrentOwner,Zs=T.ReactCurrentBatchConfig,xi=0,wn=null,mn=null,Ln=0,Os=0,Ua=Zr(0),Dn=0,Ml=null,aa=0,Kc=0,Hu=0,Yc=null,Es=null,Wu=0,Va=1/0,$o=null,Xc=!1,Uu=null,Ao=null,Jc=!1,la=null,Zc=0,Ol=0,Vu=null,Ll=-1,Qc=0;function cs(){return(xi&6)!==0?$i():Ll!==-1?Ll:Ll=$i()}function Io(o){return(o.mode&1)===0?1:(xi&2)!==0&&Ln!==0?Ln&-Ln:iu.transition!==null?(Qc===0&&(Qc=Ns()),Qc):(o=Ne,o!==0||(o=window.event,o=o===void 0?16:re(o.type)),o)}function _r(o,h,_,A){if(50<Ol)throw Ol=0,Vu=null,Error(t(185));es(o,_,A),((xi&2)===0||o!==wn)&&(o===wn&&((xi&2)===0&&(Kc|=_),Dn===4&&Po(o,Ln)),Ts(o,A),_===1&&xi===0&&(h.mode&1)===0&&(Va=$i()+500,Ac&&Co()))}function Ts(o,h){var _=o.callbackNode;_s(o,h);var A=Pr(o,o===wn?Ln:0);if(A===0)_!==null&&Mn(_),o.callbackNode=null,o.callbackPriority=0;else if(h=A&-A,o.callbackPriority!==h){if(_!=null&&Mn(_),h===1)o.tag===0?o_(Xp.bind(null,o)):tp(Xp.bind(null,o)),Lm(function(){(xi&6)===0&&Co()}),_=null;else{switch(Ze(A)){case 1:_=Zi;break;case 4:_=Un;break;case 16:_=ar;break;case 536870912:_=$r;break;default:_=ar}_=nf(_,Kp.bind(null,o))}o.callbackPriority=h,o.callbackNode=_}}function Kp(o,h){if(Ll=-1,Qc=0,(xi&6)!==0)throw Error(t(327));var _=o.callbackNode;if(qa()&&o.callbackNode!==_)return null;var A=Pr(o,o===wn?Ln:0);if(A===0)return null;if((A&30)!==0||(A&o.expiredLanes)!==0||h)h=ed(o,A);else{h=A;var O=xi;xi|=2;var H=og();(wn!==o||Ln!==h)&&($o=null,Va=$i()+500,da(o,h));do try{d_();break}catch(_e){Jp(o,_e)}while(!0);ru(),Vc.current=H,xi=O,mn!==null?h=0:(wn=null,Ln=0,h=Dn)}if(h!==0){if(h===2&&(O=Kr(o),O!==0&&(A=O,h=qu(o,O))),h===1)throw _=Ml,da(o,0),Po(o,A),Ts(o,$i()),_;if(h===6)Po(o,A);else{if(O=o.current.alternate,(A&30)===0&&!Yp(O)&&(h=ed(o,A),h===2&&(H=Kr(o),H!==0&&(A=H,h=qu(o,H))),h===1))throw _=Ml,da(o,0),Po(o,A),Ts(o,$i()),_;switch(o.finishedWork=O,o.finishedLanes=A,h){case 0:case 1:throw Error(t(345));case 2:ua(o,Es,$o);break;case 3:if(Po(o,A),(A&130023424)===A&&(h=Wu+500-$i(),10<h)){if(Pr(o,0)!==0)break;if(O=o.suspendedLanes,(O&A)!==A){cs(),o.pingedLanes|=o.suspendedLanes&O;break}o.timeoutHandle=Wd(ua.bind(null,o,Es,$o),h);break}ua(o,Es,$o);break;case 4:if(Po(o,A),(A&4194240)===A)break;for(h=o.eventTimes,O=-1;0<A;){var ne=31-Qi(A);H=1<<ne,ne=h[ne],ne>O&&(O=ne),A&=~H}if(A=O,A=$i()-A,A=(120>A?120:480>A?480:1080>A?1080:1920>A?1920:3e3>A?3e3:4320>A?4320:1960*rg(A/1960))-A,10<A){o.timeoutHandle=Wd(ua.bind(null,o,Es,$o),A);break}ua(o,Es,$o);break;case 5:ua(o,Es,$o);break;default:throw Error(t(329))}}}return Ts(o,$i()),o.callbackNode===_?Kp.bind(null,o):null}function qu(o,h){var _=Yc;return o.current.memoizedState.isDehydrated&&(da(o,h).flags|=256),o=ed(o,h),o!==2&&(h=Es,Es=_,h!==null&&Ku(h)),o}function Ku(o){Es===null?Es=o:Es.push.apply(Es,o)}function Yp(o){for(var h=o;;){if(h.flags&16384){var _=h.updateQueue;if(_!==null&&(_=_.stores,_!==null))for(var A=0;A<_.length;A++){var O=_[A],H=O.getSnapshot;O=O.value;try{if(!pr(H(),O))return!1}catch{return!1}}}if(_=h.child,h.subtreeFlags&16384&&_!==null)_.return=h,h=_;else{if(h===o)break;for(;h.sibling===null;){if(h.return===null||h.return===o)return!0;h=h.return}h.sibling.return=h.return,h=h.sibling}}return!0}function Po(o,h){for(h&=~Hu,h&=~Kc,o.suspendedLanes|=h,o.pingedLanes&=~h,o=o.expirationTimes;0<h;){var _=31-Qi(h),A=1<<_;o[_]=-1,h&=~A}}function Xp(o){if((xi&6)!==0)throw Error(t(327));qa();var h=Pr(o,0);if((h&1)===0)return Ts(o,$i()),null;var _=ed(o,h);if(o.tag!==0&&_===2){var A=Kr(o);A!==0&&(h=A,_=qu(o,A))}if(_===1)throw _=Ml,da(o,0),Po(o,h),Ts(o,$i()),_;if(_===6)throw Error(t(345));return o.finishedWork=o.current.alternate,o.finishedLanes=h,ua(o,Es,$o),Ts(o,$i()),null}function Yu(o,h){var _=xi;xi|=1;try{return o(h)}finally{xi=_,xi===0&&(Va=$i()+500,Ac&&Co())}}function ca(o){la!==null&&la.tag===0&&(xi&6)===0&&qa();var h=xi;xi|=1;var _=Zs.transition,A=Ne;try{if(Zs.transition=null,Ne=1,o)return o()}finally{Ne=A,Zs.transition=_,xi=h,(xi&6)===0&&Co()}}function Xu(){Os=Ua.current,Ki(Ua)}function da(o,h){o.finishedWork=null,o.finishedLanes=0;var _=o.timeoutHandle;if(_!==-1&&(o.timeoutHandle=-1,Om(_)),mn!==null)for(_=mn.return;_!==null;){var A=_;switch(Yd(A),A.tag){case 1:A=A.type.childContextTypes,A!=null&&Dc();break;case 3:na(),Ki(bs),Ki(os),hu();break;case 5:du(A);break;case 4:na();break;case 13:Ki(nn);break;case 19:Ki(nn);break;case 10:ou(A.type._context);break;case 22:case 23:Xu()}_=_.return}if(wn=o,mn=o=jo(o.current,null),Ln=Os=h,Dn=0,Ml=null,Hu=Kc=aa=0,Es=Yc=null,Ga!==null){for(h=0;h<Ga.length;h++)if(_=Ga[h],A=_.interleaved,A!==null){_.interleaved=null;var O=A.next,H=_.pending;if(H!==null){var ne=H.next;H.next=O,A.next=ne}_.pending=A}Ga=null}return o}function Jp(o,h){do{var _=mn;try{if(ru(),pu.current=Fc,mu){for(var A=tn.memoizedState;A!==null;){var O=A.queue;O!==null&&(O.pending=null),A=A.next}mu=!1}if(sa=0,Tn=_n=tn=null,ra=!1,To=0,qc.current=null,_===null||_.return===null){Dn=1,Ml=h,mn=null;break}e:{var H=o,ne=_.return,_e=_,De=h;if(h=Ln,_e.flags|=32768,De!==null&&typeof De=="object"&&typeof De.then=="function"){var He=De,lt=_e,ct=lt.tag;if((lt.mode&1)===0&&(ct===0||ct===11||ct===15)){var at=lt.alternate;at?(lt.updateQueue=at.updateQueue,lt.memoizedState=at.memoizedState,lt.lanes=at.lanes):(lt.updateQueue=null,lt.memoizedState=null)}var Dt=Jm(ne);if(Dt!==null){Dt.flags&=-257,ls(Dt,ne,_e,H,h),Dt.mode&1&&Ap(H,He,h),h=Dt,De=He;var Ot=h.updateQueue;if(Ot===null){var Lt=new Set;Lt.add(De),h.updateQueue=Lt}else Ot.add(De);break e}else{if((h&1)===0){Ap(H,He,h),Ju();break e}De=Error(t(426))}}else if(en&&_e.mode&1){var Wi=Jm(ne);if(Wi!==null){(Wi.flags&65536)===0&&(Wi.flags|=256),ls(Wi,ne,_e,H,h),tu(Ha(De,_e));break e}}H=De=Ha(De,_e),Dn!==4&&(Dn=2),Yc===null?Yc=[H]:Yc.push(H),H=ne;do{switch(H.tag){case 3:H.flags|=65536,h&=-h,H.lanes|=h;var Ge=Dp(H,De,h);Gm(H,Ge);break e;case 1:_e=De;var Re=H.type,We=H.stateNode;if((H.flags&128)===0&&(typeof Re.getDerivedStateFromError=="function"||We!==null&&typeof We.componentDidCatch=="function"&&(Ao===null||!Ao.has(We)))){H.flags|=65536,h&=-h,H.lanes|=h;var pt=$p(H,_e,h);Gm(H,pt);break e}}H=H.return}while(H!==null)}zl(_)}catch(Ht){h=Ht,mn===_&&_!==null&&(mn=_=_.return);continue}break}while(!0)}function og(){var o=Vc.current;return Vc.current=Fc,o===null?Fc:o}function Ju(){(Dn===0||Dn===3||Dn===2)&&(Dn=4),wn===null||(aa&268435455)===0&&(Kc&268435455)===0||Po(wn,Ln)}function ed(o,h){var _=xi;xi|=2;var A=og();(wn!==o||Ln!==h)&&($o=null,da(o,h));do try{ag();break}catch(O){Jp(o,O)}while(!0);if(ru(),xi=_,Vc.current=A,mn!==null)throw Error(t(261));return wn=null,Ln=0,Dn}function ag(){for(;mn!==null;)Zp(mn)}function d_(){for(;mn!==null&&!Da();)Zp(mn)}function Zp(o){var h=tf(o.alternate,o,Os);o.memoizedProps=o.pendingProps,h===null?zl(o):mn=h,qc.current=null}function zl(o){var h=o;do{var _=h.alternate;if(o=h.return,(h.flags&32768)===0){if(_=eg(_,h,Os),_!==null){mn=_;return}}else{if(_=tg(_,h),_!==null){_.flags&=32767,mn=_;return}if(o!==null)o.flags|=32768,o.subtreeFlags=0,o.deletions=null;else{Dn=6,mn=null;return}}if(h=h.sibling,h!==null){mn=h;return}mn=h=o}while(h!==null);Dn===0&&(Dn=5)}function ua(o,h,_){var A=Ne,O=Zs.transition;try{Zs.transition=null,Ne=1,Qp(o,h,_,A)}finally{Zs.transition=O,Ne=A}return null}function Qp(o,h,_,A){do qa();while(la!==null);if((xi&6)!==0)throw Error(t(327));_=o.finishedWork;var O=o.finishedLanes;if(_===null)return null;if(o.finishedWork=null,o.finishedLanes=0,_===o.current)throw Error(t(177));o.callbackNode=null,o.callbackPriority=0;var H=_.lanes|_.childLanes;if(gt(o,H),o===wn&&(mn=wn=null,Ln=0),(_.subtreeFlags&2064)===0&&(_.flags&2064)===0||Jc||(Jc=!0,nf(ar,function(){return qa(),null})),H=(_.flags&15990)!==0,(_.subtreeFlags&15990)!==0||H){H=Zs.transition,Zs.transition=null;var ne=Ne;Ne=1;var _e=xi;xi|=4,qc.current=null,ng(o,_),Bu(_,o),Pm(Fd),wo=!!Gd,Fd=Gd=null,o.current=_,Up(_),$a(),xi=_e,Ne=ne,Zs.transition=H}else o.current=_;if(Jc&&(Jc=!1,la=o,Zc=O),H=o.pendingLanes,H===0&&(Ao=null),Ft(_.stateNode),Ts(o,$i()),h!==null)for(A=o.onRecoverableError,_=0;_<h.length;_++)O=h[_],A(O.value,{componentStack:O.stack,digest:O.digest});if(Xc)throw Xc=!1,o=Uu,Uu=null,o;return(Zc&1)!==0&&o.tag!==0&&qa(),H=o.pendingLanes,(H&1)!==0?o===Vu?Ol++:(Ol=0,Vu=o):Ol=0,Co(),null}function qa(){if(la!==null){var o=Ze(Zc),h=Zs.transition,_=Ne;try{if(Zs.transition=null,Ne=16>o?16:o,la===null)var A=!1;else{if(o=la,la=null,Zc=0,(xi&6)!==0)throw Error(t(331));var O=xi;for(xi|=4,Mt=o.current;Mt!==null;){var H=Mt,ne=H.child;if((Mt.flags&16)!==0){var _e=H.deletions;if(_e!==null){for(var De=0;De<_e.length;De++){var He=_e[De];for(Mt=He;Mt!==null;){var lt=Mt;switch(lt.tag){case 0:case 11:case 15:Rl(8,lt,H)}var ct=lt.child;if(ct!==null)ct.return=lt,Mt=ct;else for(;Mt!==null;){lt=Mt;var at=lt.sibling,Dt=lt.return;if(Fp(lt),lt===He){Mt=null;break}if(at!==null){at.return=Dt,Mt=at;break}Mt=Dt}}}var Ot=H.alternate;if(Ot!==null){var Lt=Ot.child;if(Lt!==null){Ot.child=null;do{var Wi=Lt.sibling;Lt.sibling=null,Lt=Wi}while(Lt!==null)}}Mt=H}}if((H.subtreeFlags&2064)!==0&&ne!==null)ne.return=H,Mt=ne;else e:for(;Mt!==null;){if(H=Mt,(H.flags&2048)!==0)switch(H.tag){case 0:case 11:case 15:Rl(9,H,H.return)}var Ge=H.sibling;if(Ge!==null){Ge.return=H.return,Mt=Ge;break e}Mt=H.return}}var Re=o.current;for(Mt=Re;Mt!==null;){ne=Mt;var We=ne.child;if((ne.subtreeFlags&2064)!==0&&We!==null)We.return=ne,Mt=We;else e:for(ne=Re;Mt!==null;){if(_e=Mt,(_e.flags&2048)!==0)try{switch(_e.tag){case 0:case 11:case 15:Mu(9,_e)}}catch(Ht){sn(_e,_e.return,Ht)}if(_e===ne){Mt=null;break e}var pt=_e.sibling;if(pt!==null){pt.return=_e.return,Mt=pt;break e}Mt=_e.return}}if(xi=O,Co(),Cn&&typeof Cn.onPostCommitFiberRoot=="function")try{Cn.onPostCommitFiberRoot(gs,o)}catch{}A=!0}return A}finally{Ne=_,Zs.transition=h}}return!1}function ef(o,h,_){h=Ha(_,h),h=Dp(o,h,1),o=Eo(o,h,1),h=cs(),o!==null&&(es(o,1,h),Ts(o,h))}function sn(o,h,_){if(o.tag===3)ef(o,o,_);else for(;h!==null;){if(h.tag===3){ef(h,o,_);break}else if(h.tag===1){var A=h.stateNode;if(typeof h.type.getDerivedStateFromError=="function"||typeof A.componentDidCatch=="function"&&(Ao===null||!Ao.has(A))){o=Ha(_,o),o=$p(h,o,1),h=Eo(h,o,1),o=cs(),h!==null&&(es(h,1,o),Ts(h,o));break}}h=h.return}}function lg(o,h,_){var A=o.pingCache;A!==null&&A.delete(h),h=cs(),o.pingedLanes|=o.suspendedLanes&_,wn===o&&(Ln&_)===_&&(Dn===4||Dn===3&&(Ln&130023424)===Ln&&500>$i()-Wu?da(o,0):Hu|=_),Ts(o,h)}function cg(o,h){h===0&&((o.mode&1)===0?h=1:(h=Qn,Qn<<=1,(Qn&130023424)===0&&(Qn=4194304)));var _=cs();o=eo(o,h),o!==null&&(es(o,h,_),Ts(o,_))}function dg(o){var h=o.memoizedState,_=0;h!==null&&(_=h.retryLane),cg(o,_)}function ug(o,h){var _=0;switch(o.tag){case 13:var A=o.stateNode,O=o.memoizedState;O!==null&&(_=O.retryLane);break;case 19:A=o.stateNode;break;default:throw Error(t(314))}A!==null&&A.delete(h),cg(o,_)}var tf;tf=function(o,h,_){if(o!==null)if(o.memoizedProps!==h.pendingProps||bs.current)ks=!0;else{if((o.lanes&_)===0&&(h.flags&128)===0)return ks=!1,c_(o,h,_);ks=(o.flags&131072)!==0}else ks=!1,en&&(h.flags&1048576)!==0&&Zo(h,Pc,h.index);switch(h.lanes=0,h.tag){case 2:var A=h.type;Wc(o,h),o=h.pendingProps;var O=as(h,os.current);Ba(h,_),O=vu(null,h,A,o,O,_);var H=_u();return h.flags|=1,typeof O=="object"&&O!==null&&typeof O.render=="function"&&O.$$typeof===void 0?(h.tag=1,h.memoizedState=null,h.updateQueue=null,ws(A)?(H=!0,$c(h)):H=!1,h.memoizedState=O.state!==null&&O.state!==void 0?O.state:null,Mc(h),O.updater=io,h.stateNode=O,O._reactInternals=h,xu(h,A,o,_),h=Eu(null,h,A,!0,H,_)):(h.tag=0,en&&H&&vn(h),Kn(null,h,O,_),h=h.child),h;case 16:A=h.elementType;e:{switch(Wc(o,h),o=h.pendingProps,O=A._init,A=O(A._payload),h.type=A,O=h.tag=hg(A),o=bn(A,o),O){case 0:h=ku(null,h,A,o,_);break e;case 1:h=Np(null,h,A,o,_);break e;case 11:h=Ip(null,h,A,o,_);break e;case 14:h=Pl(null,h,A,bn(A.type,o),_);break e}throw Error(t(306,A,""))}return h;case 0:return A=h.type,O=h.pendingProps,O=h.elementType===A?O:bn(A,O),ku(o,h,A,O,_);case 1:return A=h.type,O=h.pendingProps,O=h.elementType===A?O:bn(A,O),Np(o,h,A,O,_);case 3:e:{if(Tu(h),o===null)throw Error(t(387));A=h.pendingProps,H=h.memoizedState,O=H.element,lu(o,h),Oc(h,A,null,_);var ne=h.memoizedState;if(A=ne.element,H.isDehydrated)if(H={element:A,isDehydrated:!1,cache:ne.cache,pendingSuspenseBoundaries:ne.pendingSuspenseBoundaries,transitions:ne.transitions},h.updateQueue.baseState=H,h.memoizedState=H,h.flags&256){O=Ha(Error(t(423)),h),h=Mp(o,h,A,_,O);break e}else if(A!==O){O=Ha(Error(t(424)),h),h=Mp(o,h,A,_,O);break e}else for(Ms=xo(h.stateNode.containerInfo.firstChild),Ss=h,en=!0,Cs=null,_=nu(h,null,A,_),h.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling;else{if(Qo(),A===O){h=no(o,h,_);break e}Kn(o,h,A,_)}h=h.child}return h;case 5:return rp(h),o===null&&Qd(h),A=h.type,O=h.pendingProps,H=o!==null?o.memoizedProps:null,ne=O.children,Hd(A,O)?ne=null:H!==null&&Hd(A,H)&&(h.flags|=32),Rp(o,h),Kn(o,h,ne,_),h.child;case 6:return o===null&&Qd(h),null;case 13:return Op(o,h,_);case 4:return cu(h,h.stateNode.containerInfo),A=h.pendingProps,o===null?h.child=za(h,null,A,_):Kn(o,h,A,_),h.child;case 11:return A=h.type,O=h.pendingProps,O=h.elementType===A?O:bn(A,O),Ip(o,h,A,O,_);case 7:return Kn(o,h,h.pendingProps,_),h.child;case 8:return Kn(o,h,h.pendingProps.children,_),h.child;case 12:return Kn(o,h,h.pendingProps.children,_),h.child;case 10:e:{if(A=h.type._context,O=h.pendingProps,H=h.memoizedProps,ne=O.value,Hi(ea,A._currentValue),A._currentValue=ne,H!==null)if(pr(H.value,ne)){if(H.children===O.children&&!bs.current){h=no(o,h,_);break e}}else for(H=h.child,H!==null&&(H.return=h);H!==null;){var _e=H.dependencies;if(_e!==null){ne=H.child;for(var De=_e.firstContext;De!==null;){if(De.context===A){if(H.tag===1){De=to(-1,_&-_),De.tag=2;var He=H.updateQueue;if(He!==null){He=He.shared;var lt=He.pending;lt===null?De.next=De:(De.next=lt.next,lt.next=De),He.pending=De}}H.lanes|=_,De=H.alternate,De!==null&&(De.lanes|=_),sp(H.return,_,h),_e.lanes|=_;break}De=De.next}}else if(H.tag===10)ne=H.type===h.type?null:H.child;else if(H.tag===18){if(ne=H.return,ne===null)throw Error(t(341));ne.lanes|=_,_e=ne.alternate,_e!==null&&(_e.lanes|=_),sp(ne,_,h),ne=H.sibling}else ne=H.child;if(ne!==null)ne.return=H;else for(ne=H;ne!==null;){if(ne===h){ne=null;break}if(H=ne.sibling,H!==null){H.return=ne.return,ne=H;break}ne=ne.return}H=ne}Kn(o,h,O.children,_),h=h.child}return h;case 9:return O=h.type,A=h.pendingProps.children,Ba(h,_),O=Ys(O),A=A(O),h.flags|=1,Kn(o,h,A,_),h.child;case 14:return A=h.type,O=bn(A,h.pendingProps),O=bn(A.type,O),Pl(o,h,A,O,_);case 15:return Pp(o,h,h.type,h.pendingProps,_);case 17:return A=h.type,O=h.pendingProps,O=h.elementType===A?O:bn(A,O),Wc(o,h),h.tag=1,ws(A)?(o=!0,$c(h)):o=!1,Ba(h,_),Ep(h,A,O),xu(h,A,O,_),Eu(null,h,A,!0,o,_);case 19:return Iu(o,h,_);case 22:return jp(o,h,_)}throw Error(t(156,h.tag))};function nf(o,h){return Vo(o,h)}function u_(o,h,_,A){this.tag=o,this.key=_,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=h,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=A,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ls(o,h,_,A){return new u_(o,h,_,A)}function Zu(o){return o=o.prototype,!(!o||!o.isReactComponent)}function hg(o){if(typeof o=="function")return Zu(o)?1:0;if(o!=null){if(o=o.$$typeof,o===he)return 11;if(o===ce)return 14}return 2}function jo(o,h){var _=o.alternate;return _===null?(_=Ls(o.tag,h,o.key,o.mode),_.elementType=o.elementType,_.type=o.type,_.stateNode=o.stateNode,_.alternate=o,o.alternate=_):(_.pendingProps=h,_.type=o.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=o.flags&14680064,_.childLanes=o.childLanes,_.lanes=o.lanes,_.child=o.child,_.memoizedProps=o.memoizedProps,_.memoizedState=o.memoizedState,_.updateQueue=o.updateQueue,h=o.dependencies,_.dependencies=h===null?null:{lanes:h.lanes,firstContext:h.firstContext},_.sibling=o.sibling,_.index=o.index,_.ref=o.ref,_}function td(o,h,_,A,O,H){var ne=2;if(A=o,typeof o=="function")Zu(o)&&(ne=1);else if(typeof o=="string")ne=5;else e:switch(o){case L:return Ka(_.children,O,H,h);case R:ne=8,O|=8;break;case F:return o=Ls(12,_,h,O|2),o.elementType=F,o.lanes=H,o;case ee:return o=Ls(13,_,h,O),o.elementType=ee,o.lanes=H,o;case we:return o=Ls(19,_,h,O),o.elementType=we,o.lanes=H,o;case Ee:return id(_,O,H,h);default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case V:ne=10;break e;case te:ne=9;break e;case he:ne=11;break e;case ce:ne=14;break e;case ve:ne=16,A=null;break e}throw Error(t(130,o==null?o:typeof o,""))}return h=Ls(ne,_,h,O),h.elementType=o,h.type=A,h.lanes=H,h}function Ka(o,h,_,A){return o=Ls(7,o,A,h),o.lanes=_,o}function id(o,h,_,A){return o=Ls(22,o,A,h),o.elementType=Ee,o.lanes=_,o.stateNode={isHidden:!1},o}function Qu(o,h,_){return o=Ls(6,o,null,h),o.lanes=_,o}function eh(o,h,_){return h=Ls(4,o.children!==null?o.children:[],o.key,h),h.lanes=_,h.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},h}function h_(o,h,_,A,O){this.tag=h,this.containerInfo=o,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=qe(0),this.expirationTimes=qe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qe(0),this.identifierPrefix=A,this.onRecoverableError=O,this.mutableSourceEagerHydrationData=null}function th(o,h,_,A,O,H,ne,_e,De){return o=new h_(o,h,_,_e,De),h===1?(h=1,H===!0&&(h|=8)):h=0,H=Ls(3,null,null,h),o.current=H,H.stateNode=o,H.memoizedState={element:A,isDehydrated:_,cache:null,transitions:null,pendingSuspenseBoundaries:null},Mc(H),o}function p_(o,h,_){var A=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:N,key:A==null?null:""+A,children:o,containerInfo:h,implementation:_}}function sf(o){if(!o)return So;o=o._reactInternals;e:{if(Tt(o)!==o||o.tag!==1)throw Error(t(170));var h=o;do{switch(h.tag){case 3:h=h.stateNode.context;break e;case 1:if(ws(h.type)){h=h.stateNode.__reactInternalMemoizedMergedChildContext;break e}}h=h.return}while(h!==null);throw Error(t(171))}if(o.tag===1){var _=o.type;if(ws(_))return Qh(o,_,h)}return h}function pg(o,h,_,A,O,H,ne,_e,De){return o=th(_,A,!0,o,O,H,ne,_e,De),o.context=sf(null),_=o.current,A=cs(),O=Io(_),H=to(A,O),H.callback=h??null,Eo(_,H,O),o.current.lanes=O,es(o,O,A),Ts(o,A),o}function nd(o,h,_,A){var O=h.current,H=cs(),ne=Io(O);return _=sf(_),h.context===null?h.context=_:h.pendingContext=_,h=to(H,ne),h.payload={element:o},A=A===void 0?null:A,A!==null&&(h.callback=A),o=Eo(O,h,ne),o!==null&&(_r(o,O,ne,H),Dl(o,O,ne)),ne}function sd(o){if(o=o.current,!o.child)return null;switch(o.child.tag){case 5:return o.child.stateNode;default:return o.child.stateNode}}function rf(o,h){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var _=o.retryLane;o.retryLane=_!==0&&_<h?_:h}}function ih(o,h){rf(o,h),(o=o.alternate)&&rf(o,h)}function fg(){return null}var mg=typeof reportError=="function"?reportError:function(o){console.error(o)};function nh(o){this._internalRoot=o}Ya.prototype.render=nh.prototype.render=function(o){var h=this._internalRoot;if(h===null)throw Error(t(409));nd(o,h,null,null)},Ya.prototype.unmount=nh.prototype.unmount=function(){var o=this._internalRoot;if(o!==null){this._internalRoot=null;var h=o.containerInfo;ca(function(){nd(null,o,null,null)}),h[Lr]=null}};function Ya(o){this._internalRoot=o}Ya.prototype.unstable_scheduleHydration=function(o){if(o){var h=Bi();o={blockedOn:null,target:o,priority:h};for(var _=0;_<lr.length&&h!==0&&h<lr[_].priority;_++);lr.splice(_,0,o),_===0&&ul(o)}};function sh(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function rd(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11&&(o.nodeType!==8||o.nodeValue!==" react-mount-point-unstable "))}function gg(){}function vg(o,h,_,A,O){if(O){if(typeof A=="function"){var H=A;A=function(){var He=sd(ne);H.call(He)}}var ne=pg(h,A,o,0,null,!1,!1,"",gg);return o._reactRootContainer=ne,o[Lr]=ne.current,Sl(o.nodeType===8?o.parentNode:o),ca(),ne}for(;O=o.lastChild;)o.removeChild(O);if(typeof A=="function"){var _e=A;A=function(){var He=sd(De);_e.call(He)}}var De=th(o,0,!1,null,null,!1,!1,"",gg);return o._reactRootContainer=De,o[Lr]=De.current,Sl(o.nodeType===8?o.parentNode:o),ca(function(){nd(h,De,_,A)}),De}function Bl(o,h,_,A,O){var H=_._reactRootContainer;if(H){var ne=H;if(typeof O=="function"){var _e=O;O=function(){var De=sd(ne);_e.call(De)}}nd(h,ne,o,O)}else ne=vg(_,h,o,O,A);return sd(ne)}$t=function(o){switch(o.tag){case 3:var h=o.stateNode;if(h.current.memoizedState.isDehydrated){var _=Fs(h.pendingLanes);_!==0&&(me(h,_|1),Ts(h,$i()),(xi&6)===0&&(Va=$i()+500,Co()))}break;case 13:ca(function(){var A=eo(o,1);if(A!==null){var O=cs();_r(A,o,1,O)}}),ih(o,1)}},ni=function(o){if(o.tag===13){var h=eo(o,134217728);if(h!==null){var _=cs();_r(h,o,134217728,_)}ih(o,134217728)}},ci=function(o){if(o.tag===13){var h=Io(o),_=eo(o,h);if(_!==null){var A=cs();_r(_,o,h,A)}ih(o,h)}},Bi=function(){return Ne},Mi=function(o,h){var _=Ne;try{return Ne=o,h()}finally{Ne=_}},fs=function(o,h,_){switch(h){case"input":if(mt(o,_),h=_.name,_.type==="radio"&&h!=null){for(_=o;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll("input[name="+JSON.stringify(""+h)+'][type="radio"]'),h=0;h<_.length;h++){var A=_[h];if(A!==o&&A.form===o.form){var O=Tc(A);if(!O)throw Error(t(90));Pe(A),mt(A,O)}}}break;case"textarea":hi(o,_);break;case"select":h=_.value,h!=null&&Je(o,!!_.multiple,h,!1)}},Gs=Yu,Fn=ca;var of={usingClientEntryPoint:!1,Events:[El,Ra,Tc,Tr,Dr,Yu]},br={findFiberByHostInstance:Xo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},_g={bundleType:br.bundleType,version:br.version,rendererPackageName:br.rendererPackageName,rendererConfig:br.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(o){return o=fo(o),o===null?null:o.stateNode},findFiberByHostInstance:br.findFiberByHostInstance||fg,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Gl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Gl.isDisabled&&Gl.supportsFiber)try{gs=Gl.inject(_g),Cn=Gl}catch{}}return wr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=of,wr.createPortal=function(o,h){var _=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!sh(h))throw Error(t(200));return p_(o,h,null,_)},wr.createRoot=function(o,h){if(!sh(o))throw Error(t(299));var _=!1,A="",O=mg;return h!=null&&(h.unstable_strictMode===!0&&(_=!0),h.identifierPrefix!==void 0&&(A=h.identifierPrefix),h.onRecoverableError!==void 0&&(O=h.onRecoverableError)),h=th(o,1,!1,null,null,_,!1,A,O),o[Lr]=h.current,Sl(o.nodeType===8?o.parentNode:o),new nh(h)},wr.findDOMNode=function(o){if(o==null)return null;if(o.nodeType===1)return o;var h=o._reactInternals;if(h===void 0)throw typeof o.render=="function"?Error(t(188)):(o=Object.keys(o).join(","),Error(t(268,o)));return o=fo(h),o=o===null?null:o.stateNode,o},wr.flushSync=function(o){return ca(o)},wr.hydrate=function(o,h,_){if(!rd(h))throw Error(t(200));return Bl(null,o,h,!0,_)},wr.hydrateRoot=function(o,h,_){if(!sh(o))throw Error(t(405));var A=_!=null&&_.hydratedSources||null,O=!1,H="",ne=mg;if(_!=null&&(_.unstable_strictMode===!0&&(O=!0),_.identifierPrefix!==void 0&&(H=_.identifierPrefix),_.onRecoverableError!==void 0&&(ne=_.onRecoverableError)),h=pg(h,null,o,1,_??null,O,!1,H,ne),o[Lr]=h.current,Sl(o),A)for(o=0;o<A.length;o++)_=A[o],O=_._getVersion,O=O(_._source),h.mutableSourceEagerHydrationData==null?h.mutableSourceEagerHydrationData=[_,O]:h.mutableSourceEagerHydrationData.push(_,O);return new Ya(h)},wr.render=function(o,h,_){if(!rd(h))throw Error(t(200));return Bl(null,o,h,!1,_)},wr.unmountComponentAtNode=function(o){if(!rd(o))throw Error(t(40));return o._reactRootContainer?(ca(function(){Bl(null,null,o,!1,function(){o._reactRootContainer=null,o[Lr]=null})}),!0):!1},wr.unstable_batchedUpdates=Yu,wr.unstable_renderSubtreeIntoContainer=function(o,h,_,A){if(!rd(_))throw Error(t(200));if(o==null||o._reactInternals===void 0)throw Error(t(38));return Bl(o,h,_,!1,A)},wr.version="18.3.1-next-f1338f8080-20240426",wr}var Hy;function N1(){if(Hy)return __.exports;Hy=1;function i(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),__.exports=ET(),__.exports}var Wy;function TT(){if(Wy)return wg;Wy=1;var i=N1();return wg.createRoot=i.createRoot,wg.hydrateRoot=i.hydrateRoot,wg}var DT=TT();const $T=Pw(DT);var z=jw();const Rt=Pw(z),Uy=i=>{let e;const t=new Set,n=(f,m)=>{const g=typeof f=="function"?f(e):f;if(!Object.is(g,e)){const y=e;e=m??(typeof g!="object"||g===null)?g:Object.assign({},e,g),t.forEach(D=>D(e,y))}},r=()=>e,a={setState:n,getState:r,getInitialState:()=>d,subscribe:f=>(t.add(f),()=>t.delete(f))},d=e=i(n,r,a);return a},AT=(i=>i?Uy(i):Uy),IT=i=>i;function PT(i,e=IT){const t=Rt.useSyncExternalStore(i.subscribe,Rt.useCallback(()=>e(i.getState()),[i,e]),Rt.useCallback(()=>e(i.getInitialState()),[i,e]));return Rt.useDebugValue(t),t}const Vy=i=>{const e=AT(i),t=n=>PT(e,n);return Object.assign(t,e),t},jn=(i=>i?Vy(i):Vy);function kr(i){return"'"+i.replace(/'/g,"'\\''")+"'"}function Rw(i){return!i||i==="inherit"?"":` --model ${kr(i)}`}function jT(i){return!i||i==="inherit"||i.toLowerCase()==="auto"?"":` --effort ${kr(i)}`}const y_=({sessionId:i,model:e})=>`claude --dangerously-skip-permissions --session-id ${kr(i)}${Rw(e)}`,qy=({sessionId:i,model:e})=>`claude --session-id ${kr(i)}${Rw(e)}`,RT=()=>"claude --resume",M1=[{id:"sm-dangerous",label:"Session Manager (skip perms)",description:"claude --dangerously-skip-permissions in this project",category:"build",cwd:"app-cwd",command:y_},{id:"sm-safe",label:"Session Manager (safe)",description:"claude with normal permission prompts in this project",category:"build",cwd:"app-cwd",command:qy},{id:"home-dangerous",label:"Home (skip perms)",description:"claude --dangerously-skip-permissions in ~",category:"build",cwd:"home",command:y_},{id:"pick-dangerous",label:"Pick directory (skip perms)…",description:"Choose a folder, launch claude --dangerously-skip-permissions",category:"build",cwd:"pick",command:y_},{id:"pick-safe",label:"Pick directory (safe)…",description:"Choose a folder, launch claude with normal prompts",category:"build",cwd:"pick",command:qy},{id:"pick-resume",label:"Pick directory + resume…",description:"Choose a folder, then pick a past session to resume",category:"build",cwd:"pick",command:RT},{id:"pick-shell",label:"Pick directory (shell only)…",description:"Bare interactive shell, no claude auto-launch",category:"build",cwd:"pick",command:null}];let ro=null;async function NT(){if(ro)return ro;try{const i=await window.api.app.engageRulesPath();if(!i)return ro=[],ro;const e=await window.api.config.readJson(i);if(!e.exists||e.parseError||!e.data)return ro=[],ro;const t=e.data;if(!t.presets||!Array.isArray(t.presets))return ro=[],ro;const n=t.projectPath;return ro=t.presets.map(r=>({id:r.id,label:r.label,description:r.description,category:"engage",cwd:n,platform:r.platform,pipeline:r.pipeline,rules:r.rules,command:()=>`cd ${kr(n)} && ${r.cliEntry}`})),ro}catch(i){return console.warn("[presets] Failed to load engage presets:",i),ro=[],ro}}async function O1(i){const e=M1.find(n=>n.id===i);return e||((await NT()).find(n=>n.id===i)??null)}async function Ky(i){return i.cwd==="app-cwd"?window.api.app.cwd():i.cwd==="home"?window.api.app.homeDir():i.cwd==="pick"?window.api.app.pickDirectory():i.cwd}function L1(i,e){return i.command?i.command(e):null}const z1="~/.claude/session-manager/ui-settings-prefs.json";async function Eh(){var i,e;if(typeof window>"u"||!((e=(i=window.api)==null?void 0:i.config)!=null&&e.readJson))return{};try{const t=await window.api.config.readJson(z1);if(t!=null&&t.exists&&t.data&&typeof t.data=="object")return t.data}catch{}return{}}let Yy=Promise.resolve();function um(i){const e=Yy.then(async()=>{var n,r;if(typeof window>"u"||!((r=(n=window.api)==null?void 0:n.config)!=null&&r.writeJson))return;const t=await Eh();await window.api.config.writeJson(z1,{...t,...i})});return Yy=e.catch(()=>{}),e}const MT=5,Xy=100,OT=5e3,Sb=new Map;function Jy(i){const e=Sb.get(i);e!==void 0&&(clearTimeout(e),Sb.delete(i))}function LT(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`t-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}const Is=jn((i,e)=>({toasts:[],history:[],unreadCount:0,show:(t,n)=>{const r=LT(),l=Date.now();i(a=>{const d=[...a.toasts,{id:r,kind:t,message:n,createdAt:l}];for(;d.length>MT;){const g=d.shift();g&&Jy(g.id)}const m=[{id:r,kind:t,message:n,createdAt:l,read:!1},...a.history];return m.length>Xy&&(m.length=Xy),{toasts:d,history:m,unreadCount:a.unreadCount+1}});const p=setTimeout(()=>e().dismiss(r),OT);return Sb.set(r,p),r},dismiss:t=>{Jy(t),i(n=>({toasts:n.toasts.filter(r=>r.id!==t)}))},markAllRead:()=>{i(t=>t.unreadCount===0?t:{history:t.history.map(n=>n.read?n:{...n,read:!0}),unreadCount:0})},clearHistory:()=>{i({history:[],unreadCount:0})},dismissHistoryEntry:t=>{i(n=>{const r=n.history.filter(p=>p.id!==t);if(r.length===n.history.length)return n;const l=n.history.find(p=>p.id===t&&!p.read);return{history:r,unreadCount:l?Math.max(0,n.unreadCount-1):n.unreadCount}})}})),Qe={info:i=>Is.getState().show("info",i),warn:i=>Is.getState().show("warn",i),error:i=>Is.getState().show("error",i),fromOutcome:i=>Is.getState().show(i.kind??(i.ok?"info":"warn"),i.message)},B1=Object.freeze(Object.defineProperty({__proto__:null,toast:Qe,useToast:Is},Symbol.toStringTag,{value:"Module"})),zT=["opus","sonnet","haiku","fable"],BT="[1m]";function Q4(i){if(!i)return zT;const e=[...i.aliases,...i.models],t=[];for(const n of e)t.push(n,n+BT);return[...new Set(t)]}const GT="opus";function FT(i){return/^[A-Za-z0-9][A-Za-z0-9._\-]{0,79}(\[[0-9a-z]{1,4}\])?$/.test(i)}let zo=GT;const Zf=new Set;let G1=!1;async function HT(){try{const i=await Eh();if(G1)return;typeof i.rawSessionModel=="string"&&FT(i.rawSessionModel)&&(zo=i.rawSessionModel,Zf.forEach(e=>e(zo)))}catch{}}HT();function F1(){return zo}function WT(i){if(G1=!0,i===zo)return;const e=zo;zo=i,Zf.forEach(t=>t(i)),um({rawSessionModel:i}).catch(()=>{zo=e,Zf.forEach(t=>t(zo)),Qe.error("Couldn't save the default model — reverted.")})}function eB(){const[i,e]=z.useState(zo);z.useEffect(()=>{const n=r=>e(r);return Zf.add(n),zo!==i&&e(zo),()=>{Zf.delete(n)}},[]);const t=z.useCallback(n=>WT(n),[]);return{model:i,setModel:t}}async function Uv(i,e){const t=await window.api.transcripts.pathFor(i,e);return window.api.config.exists(t)}async function UT(i){var e,t;if(typeof window>"u"||typeof((t=(e=window.api)==null?void 0:e.chat)==null?void 0:t.classifyTicket)!="function")return"inline";try{return await window.api.chat.classifyTicket({text:i})==="develop"?"develop":"inline"}catch{return"inline"}}const VT={feature:{bg:"bg-sage/20",text:"text-sage",border:!0,label:"Feature"},bug:{bg:"bg-accent/15",text:"text-accent",border:!0,label:"Bug"},discussion:{bg:"bg-butter/25",text:"text-fg-dim",border:!0,label:"Discussion"},build:{bg:"bg-hive-teal/20",text:"text-hive-teal",border:!0,label:"Build"},"project-home-builder":{bg:"bg-honey/20",text:"text-honey-dark",border:!0,label:"Project Home Builder"},portfolio:{bg:"bg-butter/25",text:"text-fg-dim",border:!0,label:"Portfolio"},art:{bg:"bg-butter/25",text:"text-honey-dark",border:!0,label:"3D Art"}};function qT(i){return VT[i]}function KT(i){return i==="discussion"||i==="portfolio"}class H1 extends Error{constructor(t,n){super(`${t} timed out after ${n}ms`);Gi(this,"label");Gi(this,"ms");this.name="TimeoutError",this.label=t,this.ms=n}}function YT(i){return i instanceof H1}function W1(i,e,t){return new Promise((n,r)=>{const l=setTimeout(()=>r(new H1(t,e)),e);i.then(p=>{clearTimeout(l),n(p)},p=>{clearTimeout(l),r(p)})})}const Zy=3e4;function XT(i){return`${i.label} timed out — the main process was busy, and a retry also failed.`}function U1(i){if(!YT(i.error))return null;const e=i.error;let t=!1;const n=setTimeout(()=>{t||i.retry().then(r=>{t||(t=!0,i.onRetrySuccess(r))},()=>{t||(t=!0,i.onStillFailing(XT(e)))})},Math.max(i.graceMs??Zy,Zy));return{cancel:()=>{t=!0,clearTimeout(n)}}}const JT=5e3,Wr=jn(()=>({snapshot:null,loaded:!1}));let Qy=!1,yg=!1,rh=null,oh;function ex(){return W1(window.api.schedule.state(),JT,"schedule.state")}async function ZT(){var i;if(!Qy){Qy=!0;try{const e=await ex();Wr.setState({snapshot:e,loaded:!0}),oh=((i=e.paused)==null?void 0:i.reason)??null}catch(e){oh=null;const t=U1({error:e,retry:ex,onRetrySuccess:n=>{var r;rh=null,Wr.setState({snapshot:n,loaded:!0}),oh=((r=n.paused)==null?void 0:r.reason)??null},onStillFailing:n=>{rh=null,yg||(yg=!0,Qe.error(`Scheduler state hydrate: ${n}`))}});if(t)rh=t;else if(!yg){yg=!0;const n=e instanceof Error?e.message:String(e);Qe.error(`Scheduler state hydrate failed: ${n}`)}}window.api.schedule.onState(e=>{var n;rh&&(rh.cancel(),rh=null);const t=((n=e.paused)==null?void 0:n.reason)??null;oh!==void 0&&t!==oh&&(t==="auth"?Qe.error("Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume."):t==="network"&&Qe.error("Scheduler paused: billing endpoint unreachable. Will auto-resume in 30 minutes.")),oh=t,Wr.setState({snapshot:e,loaded:!0})}),window.api.schedule.onStall(e=>{Qe.error(e.message)})}}const cl=jn((i,e)=>({modes:{},attached:{},setMode:(t,n)=>i(r=>({modes:{...r.modes,[t]:n}})),setAttached:(t,n)=>i(r=>({attached:{...r.attached,[t]:n}})),isAttached:t=>!!e().attached[t]})),QT={epicId:null,label:null,known:!1};function V1(i){if(!i)return[];const e=[];for(const t of[i.epicId,i.sourcePromptId,i.sourceTabId])typeof t=="string"&&t&&!e.includes(t)&&e.push(t);return e}function tB(i,e){const t=V1(i);if(t.length===0)return QT;for(const n of t){const r=e[n];if(r)return{epicId:n,label:r.goalText||n,known:!0}}return{epicId:t[0],label:null,known:!1}}function e2(i){return i.length>12?`${i.slice(0,12)}…`:i}function t2(i,e={}){const{suffixCase:t="lower",kDecimals:n=0}=e,r=t==="upper"?{k:"K",m:"M"}:{k:"k",m:"M"};return i>=1e6?`${(i/1e6).toFixed(1)}${r.m}`:i>=1e3?`${(i/1e3).toFixed(n)}${r.k}`:i.toFixed(0)}function bd(i){const e=i.indexOf(`
|
|
42
42
|
|
|
43
|
-
`);return e===-1?{title:i,goal:""}:{title:i.slice(0,e),goal:i.slice(e+2)}}function ac(i,e){var D;const t=e.sessions[i];if((t==null?void 0:t.status)==="completed")return"completed";if((t==null?void 0:t.status)==="proposed")return"proposed";const n=e.chats[i];if(((n==null?void 0:n.ticketHistory)??[]).some(E=>E.status==="needs-input"))return"needs";if((((D=e.events)==null?void 0:D[i])??[]).some(E=>E.kind==="response"&&E.validation==="refuted"))return"refuted";const a=e.jobs.filter(E=>E.sourcePromptId===i);if(a.some(E=>E.status==="failed"))return"failed";if(a.some(E=>E.status==="needs_review"))return"attention";const d=(n==null?void 0:n.queuedPosition)??0,f=(n==null?void 0:n.running)===!0&&d===0,m=a.some(E=>E.status==="running");if(f||m)return"running";const g=(n==null?void 0:n.running)===!0&&d>0,y=a.some(E=>E.status==="pending");return g||y?"queued":"active"}function i2(i,e){const t=e.jobs.filter(a=>a.sourcePromptId===i),n=t.find(a=>a.status==="failed");if(n)return`failed — PRD ${n.slug} did not complete`;const r=t.find(a=>a.status==="needs_review");if(r)return`needs review — PRD ${r.slug} is asking a question`;const l=e.chats[i],p=(l==null?void 0:l.queuedPosition)??0;if((l==null?void 0:l.running)===!0&&p>0)return`queued — waiting on a session slot (position ${p})`;if(t.some(a=>a.status==="pending"))return"queued — waiting for the scheduler"}function Nw(i,e){const t=new Map(e.jobs.filter(n=>n.sourcePromptId===i).map(n=>[n.slug,n]));return e.prds.filter(n=>n.sourcePromptId===i).map(n=>{const r=t.get(n.slug)??null,l=n.archived===!0,p=(r==null?void 0:r.status)??(l?n.archivedStatus??"completed":"draft");return{slug:n.slug,title:n.title,cwd:n.cwd,mtimeMs:n.mtimeMs,estimateMinutes:n.estimateMinutes,parallelGroup:n.parallelGroup,status:p,archived:l,job:r}})}function Mw(i,e){var d;const t=e.chats[i];if(!t)return null;const n=t.turns,r=n.reduce((f,m)=>{var g;return f+(((g=m.toolUses)==null?void 0:g.length)??0)},0),l=(d=e.usage)==null?void 0:d[i],p=l?l.inputTokens+l.outputTokens:0,a=p>0?t2(p):null;return{turns:n.length,toolCalls:r,tokens:a}}function n2(i,e){return`${i.replace(/\/+$/,"")}/session-manager-operations/prompt-sessions/${e}.json`}function Vv(i){return`${i.replace(/\/+$/,"")}/session-manager-operations/prompt-sessions/active-index.json`}function tx(i,e){const t=Date.parse(i.at),n=Date.parse(e.at),r=!Number.isNaN(t),l=!Number.isNaN(n);return r&&l&&t!==n?t-n:e.causedByEventId===i.id?-1:i.causedByEventId===e.id?1:r&&l?0:r?-1:l?1:0}let ix=0;function nx(i){return ix+=1,`${i}-${Date.now().toString(36)}-${ix}`}function ah(i,e){var t,n;typeof window>"u"||!((n=(t=window.api)==null?void 0:t.auditLog)!=null&&n.append)||window.api.auditLog.append(i,e).catch(r=>{console.warn(`[auditLog] failed to append ${i}`,r)})}const Rf=new Map;function s2(i){return(Rf.get(i)??0)>0}async function r2(i){var t,n;const e=i.worktree;if(!e)return{worktree:e};if(e.status!=="active")return{worktree:e};if(typeof window>"u"||!((n=(t=window.api)==null?void 0:t.promptSessions)!=null&&n.mergeToMain))return{worktree:e};try{const r=await window.api.promptSessions.mergeToMain({cwd:i.cwd,epicId:i.id,branch:e.branch,dir:e.dir,carriedPaths:e.carriedPaths});return{worktree:{...e,status:r.ok?"merged":"needs_merge_resolution",conflictReason:r.ok?void 0:r.reason},reason:r.ok?void 0:r.reason}}catch{return{worktree:e}}}const sx=new Set;function ha(i,e,t,n=[]){var f,m;if(typeof window>"u"||!((m=(f=window.api)==null?void 0:f.promptSessions)!=null&&m.mergeActiveIndex))return Promise.resolve();const r=window.api,l=Object.fromEntries(Object.entries(e).filter(([,g])=>g.cwd===i&&(g.status==="active"||g.status==="proposed"))),p={};for(const g of Object.keys(l))p[g]=t[g]??[];const a=Vv(i);return Rf.set(a,(Rf.get(a)??0)+1),r.promptSessions.mergeActiveIndex({cwd:i,sessions:l,events:p,removedIds:n,source:"epics"}).then(()=>{},g=>{var D;const y=g instanceof Error?g.message:String(g);throw(D=r==null?void 0:r.logs)==null||D.write("promptSessions","warn",`persistActiveIndex failed for ${i}: ${y}`),g instanceof Error?g:new Error(y)}).finally(()=>{Rf.set(a,Math.max(0,(Rf.get(a)??1)-1))})}const ri=jn((i,e)=>({sessions:{},events:{},focusedEpicId:null,setFocusedEpicId:t=>i({focusedEpicId:t}),createPromptSession:async(t,n,r,l,p,a,d,f)=>{const g=(await window.api.promptSessions.create({cwd:t,goalText:n,tag:r,agentType:p,openingPrompt:a,sections:d,...f!=null&&f.model?{model:f.model}:{},...f!=null&&f.effort?{effort:f.effort}:{}})).session,y={id:nx("pevt"),promptSessionId:g.id,kind:"prompt",causedByEventId:null,at:g.createdAt,text:n},D={...e().sessions,[g.id]:g},E={...e().events,[g.id]:[y]};return i({sessions:D,events:E}),ha(t,D,E).catch(()=>{}),ah("epic_create",{cwd:t,epicId:g.id,source:l??"unknown"}),g},approveProposed:(t,n)=>{var d,f;const r=e().sessions[t];if(!r||r.status!=="proposed")return null;const l={...r,status:"active"},p={...e().sessions,[t]:l};i({sessions:p});const{title:a}=bd(r.goalText);return ha(r.cwd,p,e().events).catch(m=>{const g=e().sessions[t];g&&g.status==="active"&&i({sessions:{...e().sessions,[t]:{...g,status:"proposed"}}});const y=m instanceof Error?m.message:String(m);Qe.error(`Could not start "${a}" — ${y}. Reopened for review.`)}),ah("epic_approve",{cwd:r.cwd,epicId:t,source:n??"unknown"}),typeof window<"u"&&((f=(d=window.api)==null?void 0:d.promptSessions)!=null&&f.createWorktree)&&window.api.promptSessions.createWorktree({cwd:r.cwd,epicId:t}).then(m=>{if(!m)return;const g=e().sessions[t];if(!g||g.status!=="active")return;const y={...g,worktree:m};i({sessions:{...e().sessions,[t]:y}}),ha(r.cwd,e().sessions,e().events).catch(()=>{})}).catch(()=>{}),l},appendPromptSessionEvent:(t,n)=>{if(!e().sessions[t])throw new Error(`appendPromptSessionEvent: no PromptSession with id "${t}"`);const r=e().events[t]??[],l=r[r.length-1]??null;if(n.causedByEventId!==null){if(!l||n.causedByEventId!==l.id)throw new Error(`appendPromptSessionEvent: causedByEventId "${n.causedByEventId}" does not reference the current tail event of promptSession "${t}"`)}else if(r.length>0)throw new Error(`appendPromptSessionEvent: causedByEventId may only be null for a session's first event (promptSession "${t}" already has ${r.length})`);if(n.kind==="prd_created"&&!n.prdSlug)throw new Error("appendPromptSessionEvent: kind 'prd_created' requires prdSlug");const p={...n,id:nx("pevt"),promptSessionId:t,at:new Date().toISOString()},a={...e().events,[t]:[...r,p]};i({events:a});const d=e().sessions[t];return ha(d.cwd,e().sessions,a).catch(()=>{}),p},markCompleted:async(t,n)=>{const r=e().sessions[t];if(!r)throw new Error(`markCompleted: no PromptSession with id "${t}"`);if(r.status==="completed")return;await window.api.chat.cancel(t),window.api.pty.kill(r.claudeSessionId);const{worktree:l}=await r2(r),p=r,a=e().events[t]??[],{title:d}=bd(r.goalText),f=a.slice(-1)[0]??null;f&&e().appendPromptSessionEvent(t,{kind:"closed",causedByEventId:f.id});const m=e().events[t]??a,g={...e().events,[t]:m},y=new Date().toISOString(),D={...r,worktree:l,status:"completed",completedAt:y},E={...e().sessions,[t]:D};i({sessions:E});const C=S=>{i({sessions:{...e().sessions,[t]:p},events:{...e().events,[t]:a}}),Qe.error(`Could not mark "${d}" completed — ${S}`)};try{await ha(r.cwd,E,g,[t])}catch(S){throw C(S instanceof Error?S.message:String(S)),S}ah("epic_complete",{cwd:r.cwd,epicId:t,source:n??"unknown"});let b
|
|
43
|
+
`);return e===-1?{title:i,goal:""}:{title:i.slice(0,e),goal:i.slice(e+2)}}function ac(i,e){var D;const t=e.sessions[i];if((t==null?void 0:t.status)==="completed")return"completed";if((t==null?void 0:t.status)==="proposed")return"proposed";const n=e.chats[i];if(((n==null?void 0:n.ticketHistory)??[]).some(E=>E.status==="needs-input"))return"needs";if((((D=e.events)==null?void 0:D[i])??[]).some(E=>E.kind==="response"&&E.validation==="refuted"))return"refuted";const a=e.jobs.filter(E=>E.sourcePromptId===i);if(a.some(E=>E.status==="failed"))return"failed";if(a.some(E=>E.status==="needs_review"))return"attention";const d=(n==null?void 0:n.queuedPosition)??0,f=(n==null?void 0:n.running)===!0&&d===0,m=a.some(E=>E.status==="running");if(f||m)return"running";const g=(n==null?void 0:n.running)===!0&&d>0,y=a.some(E=>E.status==="pending");return g||y?"queued":"active"}function i2(i,e){const t=e.jobs.filter(a=>a.sourcePromptId===i),n=t.find(a=>a.status==="failed");if(n)return`failed — PRD ${n.slug} did not complete`;const r=t.find(a=>a.status==="needs_review");if(r)return`needs review — PRD ${r.slug} is asking a question`;const l=e.chats[i],p=(l==null?void 0:l.queuedPosition)??0;if((l==null?void 0:l.running)===!0&&p>0)return`queued — waiting on a session slot (position ${p})`;if(t.some(a=>a.status==="pending"))return"queued — waiting for the scheduler"}function Nw(i,e){const t=new Map(e.jobs.filter(n=>n.sourcePromptId===i).map(n=>[n.slug,n]));return e.prds.filter(n=>n.sourcePromptId===i).map(n=>{const r=t.get(n.slug)??null,l=n.archived===!0,p=(r==null?void 0:r.status)??(l?n.archivedStatus??"completed":"draft");return{slug:n.slug,title:n.title,cwd:n.cwd,mtimeMs:n.mtimeMs,estimateMinutes:n.estimateMinutes,parallelGroup:n.parallelGroup,status:p,archived:l,job:r}})}function Mw(i,e){var d;const t=e.chats[i];if(!t)return null;const n=t.turns,r=n.reduce((f,m)=>{var g;return f+(((g=m.toolUses)==null?void 0:g.length)??0)},0),l=(d=e.usage)==null?void 0:d[i],p=l?l.inputTokens+l.outputTokens:0,a=p>0?t2(p):null;return{turns:n.length,toolCalls:r,tokens:a}}function n2(i,e){return`${i.replace(/\/+$/,"")}/session-manager-operations/prompt-sessions/${e}.json`}function Vv(i){return`${i.replace(/\/+$/,"")}/session-manager-operations/prompt-sessions/active-index.json`}function tx(i,e){const t=Date.parse(i.at),n=Date.parse(e.at),r=!Number.isNaN(t),l=!Number.isNaN(n);return r&&l&&t!==n?t-n:e.causedByEventId===i.id?-1:i.causedByEventId===e.id?1:r&&l?0:r?-1:l?1:0}let ix=0;function nx(i){return ix+=1,`${i}-${Date.now().toString(36)}-${ix}`}function ah(i,e){var t,n;typeof window>"u"||!((n=(t=window.api)==null?void 0:t.auditLog)!=null&&n.append)||window.api.auditLog.append(i,e).catch(r=>{console.warn(`[auditLog] failed to append ${i}`,r)})}const Rf=new Map;function s2(i){return(Rf.get(i)??0)>0}async function r2(i){var t,n;const e=i.worktree;if(!e)return{worktree:e};if(e.status!=="active")return{worktree:e};if(typeof window>"u"||!((n=(t=window.api)==null?void 0:t.promptSessions)!=null&&n.mergeToMain))return{worktree:e};try{const r=await window.api.promptSessions.mergeToMain({cwd:i.cwd,epicId:i.id,branch:e.branch,dir:e.dir,carriedPaths:e.carriedPaths});return{worktree:{...e,status:r.ok?"merged":"needs_merge_resolution",conflictReason:r.ok?void 0:r.reason},reason:r.ok?void 0:r.reason}}catch{return{worktree:e}}}const sx=new Set;function ha(i,e,t,n=[]){var f,m;if(typeof window>"u"||!((m=(f=window.api)==null?void 0:f.promptSessions)!=null&&m.mergeActiveIndex))return Promise.resolve();const r=window.api,l=Object.fromEntries(Object.entries(e).filter(([,g])=>g.cwd===i&&(g.status==="active"||g.status==="proposed"))),p={};for(const g of Object.keys(l))p[g]=t[g]??[];const a=Vv(i);return Rf.set(a,(Rf.get(a)??0)+1),r.promptSessions.mergeActiveIndex({cwd:i,sessions:l,events:p,removedIds:n,source:"epics"}).then(()=>{},g=>{var D;const y=g instanceof Error?g.message:String(g);throw(D=r==null?void 0:r.logs)==null||D.write("promptSessions","warn",`persistActiveIndex failed for ${i}: ${y}`),g instanceof Error?g:new Error(y)}).finally(()=>{Rf.set(a,Math.max(0,(Rf.get(a)??1)-1))})}const ri=jn((i,e)=>({sessions:{},events:{},focusedEpicId:null,setFocusedEpicId:t=>i({focusedEpicId:t}),createPromptSession:async(t,n,r,l,p,a,d,f)=>{const g=(await window.api.promptSessions.create({cwd:t,goalText:n,tag:r,agentType:p,openingPrompt:a,sections:d,...f!=null&&f.model?{model:f.model}:{},...f!=null&&f.effort?{effort:f.effort}:{}})).session,y={id:nx("pevt"),promptSessionId:g.id,kind:"prompt",causedByEventId:null,at:g.createdAt,text:n},D={...e().sessions,[g.id]:g},E={...e().events,[g.id]:[y]};return i({sessions:D,events:E}),ha(t,D,E).catch(()=>{}),ah("epic_create",{cwd:t,epicId:g.id,source:l??"unknown"}),g},approveProposed:(t,n)=>{var d,f;const r=e().sessions[t];if(!r||r.status!=="proposed")return null;const l={...r,status:"active"},p={...e().sessions,[t]:l};i({sessions:p});const{title:a}=bd(r.goalText);return ha(r.cwd,p,e().events).catch(m=>{const g=e().sessions[t];g&&g.status==="active"&&i({sessions:{...e().sessions,[t]:{...g,status:"proposed"}}});const y=m instanceof Error?m.message:String(m);Qe.error(`Could not start "${a}" — ${y}. Reopened for review.`)}),ah("epic_approve",{cwd:r.cwd,epicId:t,source:n??"unknown"}),typeof window<"u"&&((f=(d=window.api)==null?void 0:d.promptSessions)!=null&&f.createWorktree)&&window.api.promptSessions.createWorktree({cwd:r.cwd,epicId:t}).then(m=>{if(!m)return;const g=e().sessions[t];if(!g||g.status!=="active")return;const y={...g,worktree:m};i({sessions:{...e().sessions,[t]:y}}),ha(r.cwd,e().sessions,e().events).catch(()=>{})}).catch(()=>{}),l},appendPromptSessionEvent:(t,n)=>{if(!e().sessions[t])throw new Error(`appendPromptSessionEvent: no PromptSession with id "${t}"`);const r=e().events[t]??[],l=r[r.length-1]??null;if(n.causedByEventId!==null){if(!l||n.causedByEventId!==l.id)throw new Error(`appendPromptSessionEvent: causedByEventId "${n.causedByEventId}" does not reference the current tail event of promptSession "${t}"`)}else if(r.length>0)throw new Error(`appendPromptSessionEvent: causedByEventId may only be null for a session's first event (promptSession "${t}" already has ${r.length})`);if(n.kind==="prd_created"&&!n.prdSlug)throw new Error("appendPromptSessionEvent: kind 'prd_created' requires prdSlug");const p={...n,id:nx("pevt"),promptSessionId:t,at:new Date().toISOString()},a={...e().events,[t]:[...r,p]};i({events:a});const d=e().sessions[t];return ha(d.cwd,e().sessions,a).catch(()=>{}),p},markCompleted:async(t,n)=>{const r=e().sessions[t];if(!r)throw new Error(`markCompleted: no PromptSession with id "${t}"`);if(r.status==="completed")return;await window.api.chat.cancel(t),window.api.pty.kill(r.claudeSessionId);const{worktree:l}=await r2(r),p=r,a=e().events[t]??[],{title:d}=bd(r.goalText),f=a.slice(-1)[0]??null;f&&e().appendPromptSessionEvent(t,{kind:"closed",causedByEventId:f.id});const m=e().events[t]??a,g={...e().events,[t]:m},y=new Date().toISOString(),D={...r,worktree:l,status:"completed",completedAt:y},E={...e().sessions,[t]:D};i({sessions:E});const C=S=>{i({sessions:{...e().sessions,[t]:p},events:{...e().events,[t]:a}}),Qe.error(`Could not mark "${d}" completed — ${S}`)};try{await ha(r.cwd,E,g,[t])}catch(S){throw C(S instanceof Error?S.message:String(S)),S}ah("epic_complete",{cwd:r.cwd,epicId:t,source:n??"unknown"});let b;try{b=await window.api.promptSessions.archiveTranscript({cwd:r.cwd,epicId:t,claudeSessionId:r.claudeSessionId})??void 0}catch(S){Qe.error(`Transcript archive failed: ${S instanceof Error?S.message:String(S)}`)}let w;if(!b)try{const{turns:S}=await window.api.promptSessionTranscript.read(r.cwd,t);S.length>0&&(w=S.map(T=>({role:T.role,text:T.text,at:T.at})))}catch{w=void 0}const x={session:D,events:e().events[t]??m,...b?{transcriptRef:b}:{},archivedAt:y,status:D.status,cwd:D.cwd,indexedAt:y,...w?{durableTurns:w}:{}};try{await window.api.config.writeJson(n2(r.cwd,t),x,"epics")}catch(S){throw C(S instanceof Error?S.message:String(S)),ha(p.cwd,e().sessions,e().events).catch(()=>{}),S}},resumeArchived:async(t,n)=>{const r=e().sessions[t];if(!r)throw new Error(`resumeArchived: no PromptSession with id "${t}"`);const l=n??"unknown",p=await e().createPromptSession(r.cwd,r.goalText,void 0,l),a={...p,resumedFromId:t},d={...e().sessions,[p.id]:a};i({sessions:d}),ha(a.cwd,d,e().events).catch(()=>{});const f=e().approveProposed(a.id,l);return ah("epic_resume",{cwd:a.cwd,epicId:a.id,source:l}),f??a},renameEpic:async(t,n,r)=>{const l=e().sessions[t];if(!l)throw new Error(`renameEpic: no PromptSession with id "${t}"`);const p=n.trim().replace(/\s*\n+\s*/g," ");if(!p)throw new Error("renameEpic: title must not be empty");const a=`${p}
|
|
44
44
|
|
|
45
45
|
${r}`,d={...l,goalText:a},f={...e().sessions,[t]:d};i({sessions:f});try{await ha(l.cwd,f,e().events)}catch(m){throw i({sessions:{...e().sessions,[t]:l}}),m}},duplicateEpic:async(t,n)=>{const r=e().sessions[t];if(!r)throw new Error(`duplicateEpic: no PromptSession with id "${t}"`);const l=n??"unknown",p=await e().createPromptSession(r.cwd,r.goalText,r.tag,l),a=e().approveProposed(p.id,l)??p;return ah("epic_duplicate",{cwd:r.cwd,epicId:a.id,source:l}),a},deleteEpic:async(t,n)=>{var g;const r=e().sessions[t];if(!r)throw new Error(`deleteEpic: no PromptSession with id "${t}"`);if((((g=Wr.getState().snapshot)==null?void 0:g.jobs)??[]).some(y=>(y.status==="running"||y.status==="pending")&&V1(y).includes(t)))throw new Error("deleteEpic: this Epic has a running or queued scheduler job — cancel it first");const p=vi.getState().chats[t];if(p&&(p.running||p.queuedPosition>0))throw new Error("deleteEpic: this Epic has a chat run in flight — wait for it to finish first");if(cl.getState().isAttached(t))throw new Error("deleteEpic: this Epic has a live Terminal session attached — detach it first");const a=e().sessions,d=e().events,f={...a},m={...d};delete f[t],delete m[t],i({sessions:f,events:m});try{await ha(r.cwd,f,m,[t])}catch(y){throw i({sessions:a,events:d}),y}ah("epic_delete",{cwd:r.cwd,epicId:t,source:n??"unknown"})},hydrate:async t=>{var n,r,l,p;if(!(typeof window>"u"||!((r=(n=window.api)==null?void 0:n.config)!=null&&r.readJson)))try{const a=Vv(t),d=await window.api.config.readJson(a),f=d.exists&&d.data?d.data:{},m=f.sessions??{},g=f.events??{},y=e().sessions,D=Object.keys(m).filter(x=>!y[x]),E=s2(a)?[]:Object.keys(y).filter(x=>y[x].cwd===t&&(y[x].status==="active"||y[x].status==="proposed")&&!m[x]),C={...y},b={...e().events};let w=!1;for(const x of D)C[x]=m[x],b[x]=g[x]??[],sx.add(x),w=!0;for(const x of E)delete C[x],delete b[x],w=!0;for(const x of Object.keys(g)){if(!y[x]||D.includes(x))continue;const S=g[x]??[],T=b[x]??[],j=new Set(T.map(L=>L.id)),N=S.filter(L=>!j.has(L.id));N.length>0&&(b[x]=[...T,...N].sort(tx),w=!0)}if(!w)return;i({sessions:C,events:b})}catch(a){const d=a instanceof Error?a.message:String(a);(p=(l=window.api)==null?void 0:l.logs)==null||p.write("promptSessions","warn",`hydrate failed for ${t}: ${d}`)}},hydrateArchived:async t=>{var n,r,l,p,a,d;if(!(typeof window>"u"||!((r=(n=window.api)==null?void 0:n.config)!=null&&r.listDir)||!((p=(l=window.api)==null?void 0:l.config)!=null&&p.readJson)))try{const f=`${t.replace(/\/+$/,"")}/session-manager-operations/prompt-sessions`,m=await window.api.config.listDir(f,{filesOnly:!0});if(!m.ok)return;const y={...e().sessions},D={...e().events};let E=!1;const C=[];for(const b of m.entries){if(!b.name.endsWith(".json")||b.name==="active-index.json")continue;const w=b.name.slice(0,-5),x=y[w],S=!!x&&x.status!=="completed"&&sx.has(w);if(x&&!S)continue;const T=await window.api.config.readJson(b.path);if(!T.exists||!T.data)continue;const j=T.data;!j.session||j.session.id!==w||(y[w]={...j.session,status:"completed"},D[w]=j.events??[],E=!0,S&&C.push(w))}if(!E)return;i({sessions:y,events:D}),C.length>0&&ha(t,y,D,C).catch(()=>{})}catch(f){const m=f instanceof Error?f.message:String(f);(d=(a=window.api)==null?void 0:a.logs)==null||d.write("promptSessions","warn",`hydrateArchived failed for ${t}: ${m}`)}},mergeAppendedEvent:(t,n,r)=>{const l=e().sessions[n];if(!l||l.cwd!==t)return;const p=e().events[n]??[];if(p.some(d=>d.id===r.id))return;const a={...e().events,[n]:[...p,r].sort(tx)};if(i({events:a}),r.kind==="response"&&n!==e().focusedEpicId){const{title:d}=bd(l.goalText),f=r.text?/^PRD (\S+) finished/.exec(r.text):null,m=f?`PRD ${f[1]} finished`:"Epic updated";Qe.info(`${m} — ${d}`)}}}));var $1;typeof window<"u"&&(($1=window.api)!=null&&$1.promptSessions)&&window.api.promptSessions.onEventAppended(({cwd:i,promptSessionId:e,event:t})=>{ri.getState().mergeAppendedEvent(i,e,t)});const rx=2e3,o2=300;function Wl(i){return typeof i!="string"||i.length===0?{}:i.length<=rx?{text:i}:{text:i.slice(0,rx)+"…",textTruncated:!0}}function Ul(i){return!Array.isArray(i)||i.length===0?{}:{names:i.filter(t=>typeof t=="string").slice(0,o2),count:i.length}}function As(i){return i&&typeof i=="object"&&!Array.isArray(i)?i:null}function Li(i){return typeof i=="string"?i:void 0}function a2(i){if(i.startsWith("mcp__")){const e=i.split("__");return{kind:"mcp",label:e[e.length-1]||i}}return i==="Skill"?{kind:"skill",label:"Skill"}:{kind:"tool",label:i}}function l2(i){for(const e of i.split(`
|
|
46
46
|
`)){const t=e.trim();if(t)return t.length>200?t.slice(0,200)+"…":t}return""}function q1(i){let e="",t=!1;const n=As(i.message),r=n==null?void 0:n.content;if(Array.isArray(r))for(const l of r){const p=As(l);if(!(!p||p.type!=="tool_result")){if(p.is_error===!0&&(t=!0),typeof p.content=="string")e=e?e+`
|
|
@@ -53,7 +53,7 @@ ${r}`,d={...l,goalText:a},f={...e().sessions,[t]:d};i({sessions:f});try{await ha
|
|
|
53
53
|
`):l();case"queued_command":return Li(p.prompt)??l();case"skill_listing":return Li(p.content)??l();case"edited_text_file":return Li(p.snippet)??l();default:return l()}}default:return l()}}function u2(i,e){var l;let t;try{t=JSON.parse(e)}catch{return null}const n=As((l=As(t))==null?void 0:l.attachment);if(!n)return null;const r=p=>Array.isArray(p)?p.filter(a=>typeof a=="string"):null;switch(i){case"deferred_tools_delta":return r(n.addedNames);case"agent_listing_delta":return r(n.addedTypes);case"command_permissions":return r(n.allowedTools);case"skill_listing":{const a=(Li(n.content)??"").split(`
|
|
54
54
|
`).map(d=>{var f,m;return(m=(f=/^-\s*([^:]+):/.exec(d))==null?void 0:f[1])==null?void 0:m.trim()}).filter(d=>!!d);return a.length?a:null}default:return null}}function Y1(i){return i==="tool_use"||i==="todo_write"||i==="plan"||i==="agent_spawn"}function lh(i){return typeof i=="string"&&i.length>0?i:void 0}function xg(i){return i===!0?!0:void 0}function h2(i){if(!i||typeof i!="object")return;const e=i,t={},n=(r,l)=>{l!==void 0&&(t[r]=l)};return n("attributionSkill",lh(e.attributionSkill)),n("attributionPlugin",lh(e.attributionPlugin)),n("attributionMcpServer",lh(e.attributionMcpServer)),n("attributionMcpTool",lh(e.attributionMcpTool)),n("effort",lh(e.effort)),n("gitBranch",lh(e.gitBranch)),n("isSidechain",xg(e.isSidechain)),n("isMeta",xg(e.isMeta)),n("isApiErrorMessage",xg(e.isApiErrorMessage)),n("interruptedByShutdown",xg(e.interruptedByShutdown)),Object.keys(t).length>0?t:void 0}const X1=[{key:"stop-signal",label:"Stop-signal protocol",start:"IMPORTANT: First deliver everything you CAN answer",end:"Otherwise complete the task and end with a concise summary of what you did."},{key:"chat-mode-truth",label:"One-shot headless run",start:"IMPORTANT: This is a one-shot headless run.",end:"reply for the work to continue."}];function J1(i){const e={preamble:null,blockKeys:[],body:i};if(typeof i!="string"||!i)return e;let t=i.length-i.trimStart().length;const n=[],r=new Set;for(;;){let p=!1;for(const a of X1){if(r.has(a.key)||!i.startsWith(a.start,t))continue;const d=i.indexOf(a.end,t+a.start.length);if(d===-1)return e;let f=d+a.end.length;for(;f<i.length&&/\s/.test(i[f]);)f++;t=f,r.add(a.key),n.push(a.key),p=!0;break}if(!p)break}if(n.length===0)return e;const l=i.slice(t);return l.trim()?{preamble:i.slice(0,t).trim(),blockKeys:n,body:l}:e}function p2(i){return i.map(e=>{var t;return((t=X1.find(n=>n.key===e))==null?void 0:t.label)??e}).join(", ")}const ox="<<<SM_NEEDS_INPUT>>>";function Ow(i){if(typeof i!="string")return null;const e=i.lastIndexOf(ox);if(e===-1)return null;const t=i.slice(e+ox.length),n=f2(t);return!n||typeof n!="object"||!Array.isArray(n.questions)?null:{body:i.slice(0,e).trim(),signalBlock:i.slice(e)}}function f2(i){if(!i)return null;const e=i.indexOf("{");if(e===-1)return null;let t=0,n=!1,r=!1;for(let l=e;l<i.length;l++){const p=i[l];if(n)r?r=!1:p==="\\"?r=!0:p==='"'&&(n=!1);else if(p==='"')n=!0;else if(p==="{")t++;else if(p==="}"&&(t--,t===0))try{return JSON.parse(i.slice(e,l+1))}catch{return null}}return null}function Z1(i,e,t){const n=ri.getState().approveProposed(i.id,e);return n?(vi.getState().send({tabId:n.id,sessionId:n.claudeSessionId,cwd:n.cwd,prompt:n.openingPrompt||n.goalText,origin:t}),n):(Qe.error("This session is no longer awaiting approval."),null)}function m2(i){var e,t;return i.status==="proposed"&&((e=i.source)==null?void 0:e.producer)==="cross-project-feedback"&&((t=i.source.autoApprove)==null?void 0:t.requestedBy)==="human"}function Cb(i,e){const t=Object.values(ri.getState().sessions).filter(n=>n.cwd===i&&(e===void 0||n.id===e)&&m2(n));for(const n of t)Z1(n,"inbound-auto-approve","inbound-proposal")}async function g2(i,e){await ri.getState().hydrate(i),Cb(i,e)}const sc={turns:[],running:!1,queuedPosition:0,started:!1,stream:"",liveToolUses:[],queue:[],activeTicket:null,ticketHistory:[]},ax=20;function yv(i,e){const t=[...i,e];return t.length>ax?t.slice(t.length-ax):t}let lx=0;function xa(){return lx+=1,`t${Date.now().toString(36)}-${lx}`}const v2="Landed",cx=60;function _2(i){const e=i.trim();if(e.length<=cx)return e;const t=e.slice(0,cx),n=t.lastIndexOf(" ");return(n>0?t.slice(0,n):t).trim()}const vi=jn((i,e)=>({chats:{},hydratedTabs:{},get:t=>e().chats[t]??sc,hydrate:async({tabId:t,cwd:n,sessionId:r})=>{var l,p,a;if(!e().hydratedTabs[t]&&(i({hydratedTabs:{...e().hydratedTabs,[t]:!0}}),!(typeof window>"u"||!((l=window.api)!=null&&l.exchanges))))try{const d=await window.api.exchanges.list({cwd:n,sessionId:r});if(!d.length)return;const f=[];for(const g of[...d].reverse()){const y=new Date(g.ts).getTime();f.push({id:xa(),role:"user",text:g.prompt,at:y}),f.push({id:xa(),role:"assistant",text:g.result,at:y})}const m=e().chats[t]??sc;i({chats:{...e().chats,[t]:{...m,turns:[...f,...m.turns],started:!0}}})}catch(d){const f=d instanceof Error?d.message:String(d);(a=(p=window.api)==null?void 0:p.logs)==null||a.write("chat","warn",`exchange hydration failed for tab ${t}: ${f}`)}},send:({tabId:t,sessionId:n,cwd:r,prompt:l,tag:p,chainRootId:a,external:d,origin:f})=>{const m=f??(d?"external":"human"),g=l.trim();if(!g)return;if(cl.getState().isAttached(t)){Qe.error("Terminal mode is active for this Epic — switch back to Chat to send a message.");return}const y=e().chats[t]??sc;if(y.running){const D={id:crypto.randomUUID(),tabId:t,sessionId:n,cwd:r,text:g,status:"queued",createdAt:Date.now(),tag:p,chainRootId:a,external:d,origin:m};i({chats:{...e().chats,[t]:{...y,queue:[...y.queue,D]}}});return}b2(t),Q1({tabId:t,sessionId:n,cwd:r,text:g,tag:p,chainRootId:a,origin:m})},resetThread:t=>{kv.delete(t),i({chats:{...e().chats,[t]:{...sc}}})},pushNotice:(t,n)=>{xv(t,"",n)},setPendingVoiceText:(t,n)=>{Bs(t,r=>({...r,pendingVoiceText:n}))},clearPendingVoiceText:t=>{Bs(t,n=>({...n,pendingVoiceText:void 0}))},dropTab:t=>{if(!(t in e().chats)&&!(t in e().hydratedTabs))return;kv.delete(t),Cv.delete(t);const n={...e().chats};delete n[t];const r={...e().hydratedTabs};delete r[t],i({chats:n,hydratedTabs:r})}}));function Bs(i,e){const t=vi.getState().chats[i]??sc;vi.setState({chats:{...vi.getState().chats,[i]:e(t)}})}function av(i,e,t={},n="done",r={}){Bs(i,l=>{const p=l.activeTicket?yv(l.ticketHistory??[],{...l.activeTicket,status:n,completedAt:Date.now(),...r}):l.ticketHistory??[],a=tC(i)&&(e.role==="assistant"||e.role==="user")?Lw(l.turns,e.role,e.text):-1,d=a!==-1?l.turns.map((f,m)=>{var g;return m===a?{...f,outcome:e.outcome??f.outcome,toolUses:(g=f.toolUses)!=null&&g.length?f.toolUses:l.liveToolUses}:f}):[...l.turns,{...e,toolUses:l.liveToolUses}];return{...l,turns:d,running:!1,queuedPosition:0,stream:"",liveToolUses:[],activeTicket:null,ticketHistory:p,...t}}),kb(i)}function b2(i){Bs(i,e=>{const t=e.ticketHistory??[];return t.some(n=>n.status==="needs-input")?{...e,ticketHistory:t.map(n=>n.status==="needs-input"?{...n,status:"done"}:n)}:e})}function Q1(i){const{tabId:e,sessionId:t,cwd:n,text:r,promptId:l,tag:p,chainRootId:a,origin:d}=i,f=vi.getState().chats[e]??sc,m={id:xa(),role:"user",text:r,at:Date.now()};Eb(e,"user",r);const g=f.activeTicket??{id:l??crypto.randomUUID(),tabId:e,sessionId:t,cwd:n,text:r,status:"running",createdAt:Date.now(),startedAt:Date.now(),tag:p,chainRootId:a};vi.setState({chats:{...vi.getState().chats,[e]:{...f,turns:[...f.turns,m],running:!0,queuedPosition:0,stream:"",activeTicket:g}}}),Uv(n,t).catch(y=>{var E,C;const D=y instanceof Error?y.message:String(y);return(C=(E=window.api)==null?void 0:E.logs)==null||C.write("chat","warn",`transcript-exists check failed for tab ${e}: ${D}`),f.started}).then(y=>window.api.chat.run({tabId:e,sessionId:t,prompt:r,cwd:n,resume:y,promptId:l,origin:d})).catch(y=>{const D=y instanceof Error?y.message:String(y);eC(e,t,D)})}function kb(i){const e=vi.getState().chats[i]??sc;if(e.queue.length===0)return;const[t,...n]=e.queue;if(Bs(i,r=>({...r,queue:n,running:!0,queuedPosition:0,activeTicket:t})),t.external){Sg(i,t);return}if(ri.getState().sessions[i]){Sg(i,t);return}if(KT(t.tag)){Sg(i,t);return}UT(t.text).then(r=>{if(r==="develop"){x2(i,t);return}Sg(i,t)})}function Sg(i,e){const t={...e,status:"running",startedAt:Date.now()};Bs(i,n=>({...n,activeTicket:t})),Q1({tabId:t.tabId,sessionId:t.sessionId,cwd:t.cwd,text:t.text,promptId:t.id,tag:t.tag,chainRootId:t.chainRootId,origin:t.origin??(t.external?"external":"human")})}function w2(i,e){var t,n,r,l,p;try{const a=(t=ri.getState().events[i])==null?void 0:t.slice(-1)[0];if(!a){(r=(n=window.api)==null?void 0:n.logs)==null||r.write("chat","warn",`appendPrdCreatedEvent: PromptSession ${i} has no tail event — skipping prd_created append for ${e}`);return}ri.getState().appendPromptSessionEvent(i,{kind:"prd_created",causedByEventId:a.id,prdSlug:e})}catch(a){const d=a instanceof Error?a.message:String(a);(p=(l=window.api)==null?void 0:l.logs)==null||p.write("chat","warn",`appendPrdCreatedEvent failed for ${i}: ${d}`)}}const dx=2e3;function Eb(i,e,t){var r,l,p,a;const n=ri.getState().sessions[i];if(n)try{(l=(r=window.api)==null?void 0:r.promptSessionTranscript)==null||l.append(n.cwd,i,{role:e,text:t})}catch(d){const f=d instanceof Error?d.message:String(d);(a=(p=window.api)==null?void 0:p.logs)==null||a.write("chat","warn",`capturePromptSessionTurn failed for ${i}: ${f}`)}}function ux(i,e){var t,n,r;try{const l=(t=ri.getState().events[i])==null?void 0:t.slice(-1)[0];if(!l)return;const p=e.length>dx?`${e.slice(0,dx)}…`:e;ri.getState().appendPromptSessionEvent(i,{kind:"response",causedByEventId:l.id,text:p})}catch(l){const p=l instanceof Error?l.message:String(l);(r=(n=window.api)==null?void 0:n.logs)==null||r.write("chat","warn",`appendResponseEvent failed for ${i}: ${p}`)}}async function y2(i,e){var n,r,l,p;const t=a=>{var d;return!!a&&((d=ri.getState().sessions[a])==null?void 0:d.status)==="active"};if(e.chainRootId){const d=((vi.getState().chats[i]??sc).ticketHistory??[]).find(m=>m.id===e.chainRootId),f=(d==null?void 0:d.promptSessionId)??null;if(f){const m=ri.getState().sessions[f];if(!m||m.status==="active")return f}}return t(i)||(await ri.getState().hydrate(e.cwd),t(i))?i:(e.chainRootId?(r=(n=window.api)==null?void 0:n.logs)==null||r.write("chat","warn",`continuation ticket ${e.id}: no resolvable PromptSession for chainRootId ${e.chainRootId} — refusing dispatch (sessions must never mint an Epic)`):(p=(l=window.api)==null?void 0:l.logs)==null||p.write("chat","warn",`ticket ${e.id}: no resolvable PromptSession for tab ${i} — refusing dispatch (sessions must never mint an Epic)`),null)}function x2(i,e){const t=n=>{Bs(i,r=>({...r,running:!1,queuedPosition:0,stream:"",liveToolUses:[],activeTicket:null,ticketHistory:yv(r.ticketHistory??[],{...e,status:"failed",completedAt:Date.now()})})),xv(i,e.sessionId,n),Qe.error(n),kb(i)};y2(i,e).then(n=>{if(!n){t(`→ Ticket ${e.id}: no Epic to dispatch this PRD into. Create one via the New Epic card (or approve a proposed one), then resend.`);return}window.api.chat.createPrd({title:_2(e.text),cwd:e.cwd,estimateMinutes:15,goal:e.text,acceptanceCriteria:["Implement the request described in Goal.","timeout 300 npm run typecheck passes"],implementationNotes:`Target project: ${e.cwd}`,sourcePromptId:n,sourceTabId:e.tabId,tag:e.tag}).then(r=>{if(!(r!=null&&r.ok)){t(`→ PRD authoring failed for ticket ${e.id}: ${(r==null?void 0:r.error)??"unknown error"}`);return}const l=r.filename,p=l.endsWith(".md")?l.slice(0,-3):l;w2(n,p);const a={...e,status:"dispatched-to-prd",completedAt:Date.now(),promptSessionId:n,...e.chainRootId?{}:{prdSlugs:[p]}};xv(i,a.sessionId,`→ dispatched to PRD ${l} (ticket ${a.id})`),Bs(i,d=>{let f=yv(d.ticketHistory??[],a);if(e.chainRootId){const m=e.chainRootId;f=f.map(g=>g.id===m?{...g,prdSlugs:[...g.prdSlugs??[],p]}:g)}return{...d,running:!1,queuedPosition:0,stream:"",liveToolUses:[],activeTicket:null,ticketHistory:f}}),kb(i)}).catch(r=>{const l=r instanceof Error?r.message:String(r);t(`→ PRD authoring failed for ticket ${e.id}: ${l}`)})})}function eC(i,e,t){Bs(i,n=>n.activeTicket?{...n,activeTicket:null,ticketHistory:yv(n.ticketHistory??[],{...n.activeTicket,status:"failed",completedAt:Date.now()})}:n),av(i,{id:xa(),role:"error",text:t,at:Date.now()}),Qe.error(t)}function xv(i,e,t){Bs(i,n=>({...n,turns:[...n.turns,{id:xa(),role:"notice",text:t,at:Date.now()}]}))}const hx=1e3,md=new Map,Sv=new Map,Cv=new Set,kv=new Map;function px(i,e){var n;const t=e.trim();return i==="user"?J1(t).body.trim():i==="assistant"?(((n=Ow(t))==null?void 0:n.body)??t).trim():t}function Lw(i,e,t){const n=px(e,t);if(!n)return-1;for(let r=i.length-1;r>=0;r--)if(i[r].role===e&&px(e,i[r].text)===n)return r;return-1}function fx(i){return i.length>hx?i.slice(i.length-hx):i}function tC(i){return Cv.has(i)}function S2(i,e,t){var m;if(t.ref){const g=kv.get(i)??{seen:new Set,lastOffset:-1,lineIndex:-1};t.ref.byteOffset===g.lastOffset?g.lineIndex+=1:(g.lastOffset=t.ref.byteOffset,g.lineIndex=0),kv.set(i,g);const y=`${t.ref.byteOffset}:${g.lineIndex}`;if(g.seen.has(y))return e;g.seen.add(y)}const n=t.raw??{},r=typeof n.timestamp=="string"&&Date.parse(n.timestamp)||Date.now(),l=n.isMeta===!0||n.isSidechain===!0,p=h2(n),a=t.data,d=typeof a=="string"?a:typeof((m=a==null?void 0:a.message)==null?void 0:m.content)=="string"?a.message.content:null;if((t.kind==="assistant"||t.kind==="user")&&d!==null&&!l){const g=t.kind;let y=e.stream;if(e.running&&g==="assistant"&&y){const E=y.indexOf(d);E!==-1&&(y=y.slice(0,E)+y.slice(E+d.length))}const D=Lw(e.turns,g,d);return D!==-1?e.turns[D].ref?{...e,stream:y}:{...e,stream:y,turns:e.turns.map((E,C)=>C===D?{...E,text:d,at:r,kind:t.kind,ref:t.ref,attribution:p??E.attribution}:E)}:{...e,stream:y,turns:fx([...e.turns,{id:xa(),role:g,text:d,at:r,kind:t.kind,ref:t.ref,attribution:p}])}}let f;try{f=d2(t.kind,t.data,t.raw)}catch{f=void 0}return{...e,turns:fx([...e.turns,{id:xa(),role:"event",text:t.previewText??"",at:r,kind:t.kind,ref:t.ref,signal:f,attribution:p}])}}function mx(i,e){e.length!==0&&Bs(i,t=>e.reduce((n,r)=>S2(i,n,r),t))}function C2(i){var a;const{tabId:e,cwd:t,sessionUuid:n}=i,r=typeof window<"u"?(a=window.api)==null?void 0:a.transcripts:void 0;if(!(r!=null&&r.onEvent)||!r.subscribe||!r.buffer)return;const l=(md.get(e)??0)+1;if(md.set(e,l),l>1)return;Cv.add(e),vi.setState({hydratedTabs:{...vi.getState().hydratedTabs,[e]:!0}});const p=window.api.transcripts.onEvent(e,d=>mx(e,d));Sv.set(e,p),window.api.transcripts.subscribe({tabId:e,cwd:t,sessionUuid:n}).then(async d=>{if(!md.has(e))return;if(!d.ok){Qe.error(`Chat transcript feed unavailable: ${d.error??"subscribe failed"}`),p(),Sv.delete(e),md.delete(e),Cv.delete(e);const m={...vi.getState().hydratedTabs};delete m[e],vi.setState({hydratedTabs:m});return}const f=await window.api.transcripts.buffer(e);mx(e,f)}).catch(d=>{var m,g;const f=d instanceof Error?d.message:String(d);(g=(m=window.api)==null?void 0:m.logs)==null||g.write("chat","warn",`transcript feed attach failed for ${e}: ${f}`)})}function k2(i){var t,n,r;const e=md.get(i);if(e){if(e>1){md.set(i,e-1);return}md.delete(i),(t=Sv.get(i))==null||t(),Sv.delete(i),(r=(n=window.api)==null?void 0:n.transcripts)==null||r.unsubscribe(i)}}var A1,I1,P1;typeof window<"u"&&((A1=window.api)!=null&&A1.chat)&&(window.api.chat.onQueued(({tabId:i,position:e})=>{Bs(i,t=>({...t,running:!0,queuedPosition:e}))}),window.api.chat.onRunStarted(({tabId:i})=>{Bs(i,e=>({...e,running:!0,started:!0,queuedPosition:0,stream:"",liveToolUses:[]}))}),window.api.chat.onOutput(({tabId:i,delta:e})=>{Bs(i,t=>({...t,stream:t.stream+e}))}),window.api.chat.onToolUse(({tabId:i,id:e,kind:t,label:n,diff:r,detail:l})=>{Bs(i,p=>({...p,liveToolUses:[...p.liveToolUses,{id:e,kind:t,label:n,diff:r,detail:l}]}))}),window.api.chat.onComplete(({tabId:i,finalMessage:e})=>{Eb(i,"assistant",e),ux(i,e),av(i,{id:xa(),role:"assistant",text:e,at:Date.now(),outcome:v2})}),window.api.chat.onNeedsInput(({tabId:i,questions:e,answerBody:t})=>{const n=xa();if(t&&t.trim()){Eb(i,"assistant",t),ux(i,t),Bs(i,r=>{const l=tC(i)&&Lw(r.turns,"assistant",t)!==-1;return{...r,turns:l?r.turns:[...r.turns,{id:xa(),role:"assistant",text:t,at:Date.now(),toolUses:r.liveToolUses}],liveToolUses:[]}}),av(i,{id:n,role:"question",text:e.join(`
|
|
55
55
|
`),questions:e,at:Date.now()},{},"needs-input",{questionTurnId:n});return}av(i,{id:n,role:"question",text:e.join(`
|
|
56
|
-
`),questions:e,at:Date.now()},{},"needs-input",{questionTurnId:n})}),window.api.chat.onError(({tabId:i,sessionId:e,message:t})=>{eC(i,e,t)}),window.api.chat.onNotice(({tabId:i,sessionId:e,message:t})=>{xv(i,e,t)}),window.api.chat.onExternalSend(({tabId:i,prompt:e,sessionId:t,cwd:n})=>{var p,a,d,f;const r=Ct.getState().tabs.find(m=>m.id===i);if(r){vi.getState().send({tabId:i,sessionId:r.sessionId,cwd:r.cwd,prompt:e,external:!0});return}const l=ri.getState().sessions[i];if(l){if(l.status==="completed"){(a=(p=window.api)==null?void 0:p.logs)==null||a.write("chat","warn",`external send ignored: Epic ${i} is completed/archived — its claudeSessionId is dead`);return}vi.getState().send({tabId:i,sessionId:l.claudeSessionId,cwd:l.cwd,prompt:e,external:!0});return}if(typeof t=="string"&&t&&typeof n=="string"&&n){vi.getState().send({tabId:i,sessionId:t,cwd:n,prompt:e,external:!0});return}(f=(d=window.api)==null?void 0:d.logs)==null||f.write("chat","warn",`external send ignored: ${i} matches neither an open tab nor a known Epic`)}),typeof((P1=(I1=window.api)==null?void 0:I1.promptSessions)==null?void 0:P1.onInboundAutoApprove)=="function"&&window.api.promptSessions.onInboundAutoApprove(({cwd:i,epicId:e})=>{g2(i,e)}));function E2(i){const e=i.split("/").filter(Boolean);return e[e.length-1]||i}async function zw(i,e=!1,t=F1()){let n=!e;n&&(n=await Uv(i.cwd,i.sessionId));const r=e&&!n?crypto.randomUUID():i.sessionId,l=n?`claude --dangerously-skip-permissions --resume ${kr(r)} --model ${kr(t)}`:`claude --dangerously-skip-permissions --session-id ${kr(r)} --model ${kr(t)}`;return{sessionId:r,startupCommand:l}}const Ct=jn((i,e)=>({tabs:[],activeTabId:null,hydrated:!1,pendingRawCommand:{},queueRawCommand:(t,n)=>{i(r=>({pendingRawCommand:{...r.pendingRawCommand,[t]:n}}))},consumeRawCommand:t=>{const n=e().pendingRawCommand[t];return n===void 0?null:(i(r=>{const l={...r.pendingRawCommand};return delete l[t],{pendingRawCommand:l}}),n)},addTab:({id:t,cwd:n,startupCommand:r,presetId:l=null,label:p,dormant:a=!1})=>{const d=t??crypto.randomUUID();if(e().tabs.find(g=>g.id===d))return i({activeTabId:d}),d;a&&r&&console.warn("[sessions] addTab: dormant tab requested with a startupCommand — command is discarded:",r);const m={id:d,sessionId:d,label:p??E2(n),cwd:n,pid:null,status:a?"dormant":"spawning",exitCode:null,startupCommand:a?null:r,presetId:l,generation:0};return i({tabs:[...e().tabs,m],activeTabId:d}),d},setTabRunning:(t,n)=>i({tabs:e().tabs.map(r=>r.id===t?{...r,pid:n,status:"running"}:r)}),setTabExited:(t,n)=>i({tabs:e().tabs.map(r=>r.id===t?{...r,status:"exited",exitCode:n}:r)}),closeTab:t=>{var l;window.api.pty.kill(t),window.api.watchers.killTab(t).catch(()=>{}),window.api.transcripts.closeTab(t).catch(()=>{}),vi.getState().dropTab(t);const n=e().tabs.filter(p=>p.id!==t),r=e().activeTabId===t?((l=n[n.length-1])==null?void 0:l.id)??null:e().activeTabId;i({tabs:n,activeTabId:r})},setActive:t=>i({activeTabId:t}),restartTab:t=>{const n=e().tabs.find(p=>p.id===t);if(!n)return;window.api.pty.kill(t);const r=crypto.randomUUID(),l=p=>{i({tabs:e().tabs.map(a=>a.id===t?{...a,sessionId:r,pid:null,status:"spawning",exitCode:null,startupCommand:p,generation:a.generation+1}:a)})};n.presetId?O1(n.presetId).then(p=>{l(p?L1(p,{sessionId:r,cwd:n.cwd}):`claude --dangerously-skip-permissions --session-id ${kr(r)}`)}):l(`claude --dangerously-skip-permissions --session-id ${kr(r)}`)},reorderTab:(t,n)=>{const r=[...e().tabs];if(t<0||t>=r.length||n<0||n>=r.length||t===n)return;const[l]=r.splice(t,1);r.splice(n,0,l),i({tabs:r})},restoreTabs:(t,n)=>i({tabs:t,activeTabId:n,hydrated:!0}),wakeTab:async(t,n)=>{var a;const r=e().tabs.find(d=>d.id===t);if(!r||r.status!=="dormant")return;(a=vi.getState().chats[t])!=null&&a.running&&(await window.api.chat.cancel(t),Qe.info("Cancelled the in-progress chat run to open a live session."));const{sessionId:l,startupCommand:p}=await zw({cwd:r.cwd,sessionId:r.sessionId},!1,n??F1());i({tabs:e().tabs.map(d=>d.id===t?{...d,sessionId:l,status:"spawning",startupCommand:p,generation:d.generation+1}:d)})},sleepTab:t=>{const n=e().tabs.find(r=>r.id===t);!n||n.status==="dormant"||(window.api.pty.kill(t),i({tabs:e().tabs.map(r=>r.id===t?{...r,pid:null,status:"dormant"}:r)}))},newSession:t=>{e().tabs.find(r=>r.id===t)&&i({tabs:e().tabs.map(r=>r.id===t?{...r,sessionId:crypto.randomUUID()}:r)})},addSessionToProject:(t,n)=>e().addTab({cwd:t,startupCommand:null,dormant:!0,...n})}));async function Tb(){var t;if(Ct.getState().hydrated)return;try{const{tabs:n,activeTabId:r,freshStart:l}=await window.api.sessions.load();if(n.length>0){const a=(await Promise.all(n.map(async f=>{try{const{sessionId:m}=await zw(f,l);return{id:f.id,sessionId:m,cwd:f.cwd,label:f.label,presetId:f.presetId,pid:null,status:"dormant",exitCode:null,startupCommand:null,generation:0}}catch(m){return console.warn("[sessions] dropping malformed persisted tab:",f==null?void 0:f.id,m),null}}))).filter(f=>f!==null),d=r&&a.find(f=>f.id===r)?r:((t=a[0])==null?void 0:t.id)??null;Ct.getState().restoreTabs(a,d)}else Ct.setState({hydrated:!0})}catch(n){console.warn("[sessions] hydrate failed:",n),Ct.setState({hydrated:!0})}const i=()=>{const{tabs:n,activeTabId:r}=Ct.getState(),l=n.map(p=>({id:p.id,sessionId:p.sessionId,cwd:p.cwd,label:p.label,presetId:p.presetId}));window.api.sessions.save({tabs:l,activeTabId:r}).catch(p=>{console.warn("[sessions] save failed:",p)})};let e=null;Ct.subscribe((n,r)=>{n.hydrated&&(n.tabs===r.tabs&&n.activeTabId===r.activeTabId||(e!==null&&window.clearTimeout(e),e=window.setTimeout(i,200)))}),i()}const T2=Object.freeze(Object.defineProperty({__proto__:null,hydrateSessions:Tb,resolveStartupCommand:zw,useSessions:Ct},Symbol.toStringTag,{value:"Module"})),gx=200,D2=/\x1b\[[0-9;]*m/g;function $2(i){return i.replace(D2,"")}const Gf=jn((i,e)=>({watchers:{},initialized:!1,init:()=>{e().initialized||(i({initialized:!0}),window.api.watchers.onLine(t=>e().ingestLine(t)),window.api.watchers.onClosed(({watcherId:t})=>e().closed(t)))},add:async({tabId:t,label:n,command:r,cwd:l})=>{try{const p=await window.api.watchers.add({tabId:t,label:n,command:r,cwd:l??null}),a={watcherId:p.watcherId,tabId:p.tabId,label:p.label,command:p.command,cwd:p.cwd,pid:p.pid,startedAt:p.startedAt,lineCount:0,lines:[],lastLineAt:null};return i({watchers:{...e().watchers,[a.watcherId]:a}}),a}catch(p){return console.error("[watchers] add failed:",p),Qe.error("Failed to add watcher"),null}},remove:async t=>{try{await window.api.watchers.remove(t)}catch(r){console.error("[watchers] remove failed:",r);const l=r instanceof Error?r.message:String(r);Qe.error(`Could not remove watcher: ${l}`)}const n={...e().watchers};delete n[t],i({watchers:n})},watchersForTab:t=>Object.values(e().watchers).filter(n=>n.tabId===t),ingestLine:t=>{const n=e().watchers[t.watcherId];if(!n)return;const r=$2(t.line),l=n.lines.length>=gx?[...n.lines.slice(n.lines.length-gx+1),{line:r,ts:t.ts}]:[...n.lines,{line:r,ts:t.ts}];i({watchers:{...e().watchers,[t.watcherId]:{...n,lines:l,lineCount:n.lineCount+1,lastLineAt:t.ts}}})},closed:t=>{if(!e().watchers[t])return;const n={...e().watchers};delete n[t],i({watchers:n})}})),yr=["home"],Cg=["project"],A2=["home","project"],hm=[{key:"overview",group:"Workspace",label:"Dashboard",icon:"home",hint:"This machine — every project, every active session",faces:yr},{key:"project-home",group:"Workspace",label:"Project Home",icon:"home",hint:"One generated overview page for this project",faces:Cg},{key:"terminal",group:"Workspace",label:"Sessions",icon:"terminal",hint:"Independent goal-scoped sessions for this project",faces:Cg},{key:"projects",group:"Workspace",label:"File Explorer",icon:"projects",hint:"Browse files + edit — starts at your home folder from Home, the active project from a Tab",faces:A2},{key:"scheduler",group:"Workspace",label:"Scheduler",icon:"scheduler",liveKind:"scheduler",hint:"This project's live PRD queue + scheduler policy",faces:Cg},{key:"history",group:"Workspace",label:"History",icon:"history",hint:"Spend, tokens and time across every project",faces:yr},{key:"remote",group:"Workspace",label:"Remote",icon:"terminal",hint:"Session Managers on your other computers — their projects, sessions and terminals",faces:yr},{key:"system-prompt",group:"Configure",label:"System Prompt",icon:"system-prompt",hint:"Your ~/.claude/CLAUDE.md — house rules for every session on this machine",faces:yr},{key:"skills",group:"Configure",label:"Skills",icon:"skills",hint:"Reusable instructions Claude loads",faces:yr},{key:"plugins",group:"Configure",label:"Plugins",icon:"plugins",hint:"Extensions for Claude Code",faces:yr},{key:"mcp",group:"Configure",label:"MCP Servers",icon:"mcp",hint:"External tools and integrations",faces:yr},{key:"hooks",group:"Configure",label:"Hooks",icon:"hooks",hint:"Run scripts on session events",faces:yr},{key:"memory",group:"Configure",label:"Memory",icon:"memory",hint:"Workspace memory store",faces:Cg},{key:"permissions",group:"Configure",label:"Permissions",icon:"permissions",hint:"Allow / deny rules",faces:yr},{key:"settings",group:"Configure",label:"Settings",icon:"settings",hint:"Theme, voice, billing window — per-session model lives in Agent Library",faces:yr},{key:"agent-library",group:"Configure",label:"Agent Library",icon:"book",hint:"Agent personas available to this machine, and which projects override them",faces:yr},{key:"tag-library",group:"Configure",label:"Tag Library",icon:"target",hint:"Session intent tags and their /develop behavior",faces:yr},{key:"voice",group:"Tools",label:"Voice",icon:"mic",hint:"On-device transcription + push-to-talk",faces:yr},{key:"data-model",group:"Tools",label:"Data Model",icon:"compass",hint:"ERD of what Session Manager actually persists, and how it joins",faces:yr}];function I2(i){return hm.filter(e=>e.faces.includes(i)).map(e=>{var t,n;return{...e,label:((t=e.labelByFace)==null?void 0:t[i])??e.label,hint:((n=e.hintByFace)==null?void 0:n[i])??e.hint}})}const P2=Object.fromEntries(hm.map(i=>[i.key,i.group]));function j2(i){const e=hm.find(t=>t.key===i);return e!=null&&e.faces.length===1&&e.faces[0]==="home"}function R2(i){const e=hm.find(t=>t.key===i);return e!=null&&e.faces.length===1&&e.faces[0]==="project"}const x_={Workspace:"Where you do the work — sessions, files, and everything currently running.",Configure:"How Claude behaves — changes here apply to every session you start.",Tools:"One-off utilities — not configuration, just things you reach for sometimes."},iC=["overview","project-home","terminal","scheduler","history","remote","skills","plugins","mcp","hooks","memory","projects","system-prompt","permissions","settings","agent-library","tag-library","voice","data-model","editor"],N2={editor:"Editor"},M2=Object.fromEntries(hm.map(i=>[i.key,i.label])),O2=Object.fromEntries(iC.map(i=>[i,N2[i]??M2[i]??i])),nC="~/.claude/session-manager/app-prefs.json";async function sC(){var i,e;if(typeof window>"u"||!((e=(i=window.api)==null?void 0:i.config)!=null&&e.readJson))return{};try{const t=await window.api.config.readJson(nC);if(t!=null&&t.exists&&t.data&&typeof t.data=="object")return t.data}catch{}return{}}async function iB(i){var t,n;if(typeof window>"u"||!((n=(t=window.api)==null?void 0:t.config)!=null&&n.writeJson))return;const e=await sC();await window.api.config.writeJson(nC,{...e,...i})}const gd=iC.map(i=>({id:i,title:O2[i],component:"screen"}));function vx(i){return i==="overview"||j2(i)?{navFace:"home"}:R2(i)?{navFace:"project"}:{}}const ji=jn((i,e)=>{var t;return{panels:[...gd],focusedPanelId:((t=gd[0])==null?void 0:t.id)??null,focusToken:0,resetToken:0,epicsWorkspaceOpen:!1,setEpicsWorkspaceOpen:n=>i({epicsWorkspaceOpen:n}),navFace:"home",setNavFace:n=>i({navFace:n}),openPanel:n=>{e().panels.some(l=>l.id===n)&&i(l=>({focusedPanelId:n,focusToken:l.focusToken+1,...vx(n)}))},openProjectPanel:n=>{e().panels.some(l=>l.id===n)&&i(l=>({focusedPanelId:n,focusToken:l.focusToken+1,navFace:"project"}))},focusPanel:n=>{e().panels.some(l=>l.id===n)&&i({focusedPanelId:n,...vx(n)})},resetLayout:()=>{i(n=>{var r;return{resetToken:n.resetToken+1,focusedPanelId:((r=gd[0])==null?void 0:r.id)??null,focusToken:n.focusToken+1,navFace:"home"}})},hydrateOpenToHomePref:async()=>{var r;(await sC()).openToHomeOnLaunch===!0&&e().focusedPanelId===(((r=gd[0])==null?void 0:r.id)??null)&&i({focusedPanelId:"overview",navFace:"home"})}}});function L2(i){return ji.getState().panels.find(e=>e.id===i)}function z2(i,e,t="project"){return i==="projects"&&e===null&&t==="project"}function Cr({name:i,size:e=17,stroke:t=1.6,className:n}){const r={width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round",className:n};switch(i){case"home":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M4 11l8-7 8 7"}),c.jsx("path",{d:"M6 10v9h12v-9"}),c.jsx("path",{d:"M10 19v-5h4v5"})]});case"terminal":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),c.jsx("path",{d:"M7 10l3 2-3 2"}),c.jsx("path",{d:"M13 14h4"})]});case"skills":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M12 3l2.5 5.5L20 9l-4 4 1 6-5-3-5 3 1-6-4-4 5.5-.5z"})});case"history":return c.jsxs("svg",{...r,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M12 7v5l3 2"}),c.jsx("path",{d:"M4 6l2 2"})]});case"usage":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M4 19V8M10 19V5M16 19v-7M22 19H2"})});case"plugins":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M9 3v4M15 3v4M5 7h14v6a5 5 0 01-5 5h-4a5 5 0 01-5-5V7z"})});case"mcp":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1.5"}),c.jsx("rect",{x:"3",y:"14",width:"18",height:"6",rx:"1.5"}),c.jsx("circle",{cx:"6.5",cy:"7",r:".5",fill:"currentColor"}),c.jsx("circle",{cx:"6.5",cy:"17",r:".5",fill:"currentColor"})]});case"hooks":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M12 4v9a3 3 0 003 3h5"}),c.jsx("path",{d:"M9 17l3 3 3-3"})]});case"keys":return c.jsxs("svg",{...r,children:[c.jsx("circle",{cx:"8",cy:"12",r:"4"}),c.jsx("path",{d:"M12 12h9M17 12v3M20 12v2"})]});case"projects":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"memory":case"agent-memory":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M9 4a4 4 0 00-4 4v1a3 3 0 000 6v1a4 4 0 004 4h6a4 4 0 004-4v-1a3 3 0 000-6V8a4 4 0 00-4-4z"}),c.jsx("path",{d:"M9 9v6M12 6v12M15 9v6"})]});case"search":return c.jsxs("svg",{...r,children:[c.jsx("circle",{cx:"11",cy:"11",r:"6"}),c.jsx("path",{d:"M16 16l4 4"})]});case"chevron":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M9 6l6 6-6 6"})});case"caret":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M6 9l6 6 6-6"})});case"dot":return c.jsx("svg",{...r,children:c.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"})});case"plus":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M12 5v14M5 12h14"})});case"folder":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"file":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M7 3h7l4 4v14H7z"}),c.jsx("path",{d:"M14 3v4h4"})]});case"play":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M8 5l11 7-11 7z",fill:"currentColor",stroke:"none"})});case"pause":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"7",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"}),c.jsx("rect",{x:"13.5",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"})]});case"sparkle":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M12 4v6M12 14v6M4 12h6M14 12h6"})});case"book":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M4 5a2 2 0 012-2h6v18H6a2 2 0 01-2-2zM12 3h6a2 2 0 012 2v14H12z"})});case"compass":return c.jsxs("svg",{...r,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M15 9l-2 5-5 2 2-5z",fill:"currentColor",stroke:"none"})]});case"scheduler":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"15",rx:"2"}),c.jsx("path",{d:"M3 10h18M8 3v4M16 3v4"}),c.jsx("path",{d:"M8 14l2 2 4-4"})]});case"settings":return c.jsxs("svg",{...r,children:[c.jsx("circle",{cx:"12",cy:"12",r:"3"}),c.jsx("path",{d:"M12 2v3M12 19v3M4 12H1M23 12h-3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1"})]});case"mic":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"9",y:"3",width:"6",height:"12",rx:"3"}),c.jsx("path",{d:"M5 11a7 7 0 0014 0M12 18v3M9 21h6"})]});case"clock":return c.jsxs("svg",{...r,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M12 7v5l3 2"})]});case"leaf":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M20 4c-9 0-14 5-14 11 0 3 2 5 5 5 6 0 9-5 9-14z"}),c.jsx("path",{d:"M6 20c2-5 5-8 11-11"})]});case"system-prompt":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"4",y:"4",width:"16",height:"14",rx:"2"}),c.jsx("path",{d:"M8 10h8M8 14h5M9 18l-2 3M15 18l2 3"})]});case"permissions":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),c.jsx("path",{d:"M8 11V8a4 4 0 018 0v3"}),c.jsx("circle",{cx:"12",cy:"15.5",r:"1.2",fill:"currentColor",stroke:"none"})]});case"tool":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M14 4a4 4 0 014 4l-7 7-4-4 7-7zM7 11l-3 3 6 6 3-3"})});case"quick-open":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),c.jsx("path",{d:"M3 9h18M7 13h10M7 16h6"})]});case"wifi":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M5 12.5a10 10 0 0114 0M8 15.5a6 6 0 018 0M12 18.5h.01"})});case"shield":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M12 3l7 3v5c0 4.5-3 8-7 10-4-2-7-5.5-7-10V6z"}),c.jsx("path",{d:"M9 12l2 2 4-4"})]});case"link":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M9 12h6"}),c.jsx("path",{d:"M10 8H7a4 4 0 000 8h3M14 8h3a4 4 0 010 8h-3"})]});case"copy":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),c.jsx("path",{d:"M5 15V5a2 2 0 012-2h8"})]});case"check":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M5 12l5 5 9-10"})});case"x":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M6 6l12 12M18 6L6 18"})});case"send":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M4 11l17-7-7 17-3-7z"})});case"target":return c.jsxs("svg",{...r,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("circle",{cx:"12",cy:"12",r:"3.5"}),c.jsx("path",{d:"M12 2v3M12 19v3M2 12h3M19 12h3"})]});case"eye":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"})]});case"arrowleft":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M19 12H5M11 6l-6 6 6 6"})});case"arrowright":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M5 12h14M13 6l6 6-6 6"})});case"reload":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M4 12a8 8 0 0114-5.3M20 12a8 8 0 01-14 5.3"}),c.jsx("path",{d:"M18 3v4h-4M6 21v-4h4"})]});case"lock":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),c.jsx("path",{d:"M8 11V8a4 4 0 018 0v3"})]});case"stop":return c.jsx("svg",{...r,children:c.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.5",fill:"currentColor",stroke:"none"})});case"star":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M12 3l2.6 5.6 6.1.6-4.6 4.1 1.3 6-5.4-3.2-5.4 3.2 1.3-6-4.6-4.1 6.1-.6z"})});case"minus":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M5 12h14"})});case"paperclip":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M8 12.5l6.5-6.5a3 3 0 014.2 4.2L11 18a5 5 0 01-7-7l7.5-7.5"})});case"expand":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M8 3H3v5"}),c.jsx("path",{d:"M16 3h5v5"}),c.jsx("path",{d:"M8 21H3v-5"}),c.jsx("path",{d:"M16 21h5v-5"})]});case"collapse":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M3 8h5V3"}),c.jsx("path",{d:"M21 8h-5V3"}),c.jsx("path",{d:"M3 16h5v5"}),c.jsx("path",{d:"M21 16h-5v5"})]});default:return null}}const B2=4,_x=40,bx=6;function G2(i){const{onReorder:e,onActivate:t}=i,n=z.useRef(null),r=z.useRef(null),l=z.useRef(0),p=z.useRef(0),[a,d]=z.useState(!1),[,f]=z.useState(0),m=z.useRef(t);m.current=t;const g=z.useCallback(()=>n.current?Array.from(n.current.querySelectorAll("[data-drag-index]")):[],[]),y=z.useCallback((b,w,x)=>{for(let S=0;S<w.length;S++){const T=w[S].left+w[S].width/2;if(b<T)return S<=x?S:S-1}return w.length-1},[]),D=z.useCallback(()=>{const b=r.current,w=n.current;if(!(b!=null&&b.active)||!w)return;const x=w.getBoundingClientRect(),S=b.startX+b.deltaX,T=S-x.left,j=x.right-S;T<_x?w.scrollLeft-=bx:j<_x&&(w.scrollLeft+=bx),l.current=requestAnimationFrame(D)},[]);z.useEffect(()=>{const b=n.current;if(!b)return;let w=!1;const x=()=>{w||(w=!0,p.current=requestAnimationFrame(()=>{w=!1,f(j=>j+1)}))},S=j=>{var V;const N=r.current;if(!N)return;const L=j.clientX-N.startX;if(!N.active&&Math.abs(L)<B2)return;if(!N.active){N.active=!0,N.tabRects=g().map(te=>te.getBoundingClientRect()),d(!0);try{(V=n.current)==null||V.setPointerCapture(N.pointerId)}catch{}l.current=requestAnimationFrame(D)}N.deltaX=L;const R=N.tabRects[N.fromIndex],F=R.left+R.width/2+L;N.currentIndex=y(F,N.tabRects,N.fromIndex),x()},T=j=>{const N=r.current;if(N&&N.pointerId===j.pointerId){cancelAnimationFrame(l.current),cancelAnimationFrame(p.current);try{b.releasePointerCapture(N.pointerId)}catch{}N.active&&N.fromIndex!==N.currentIndex?e(N.fromIndex,N.currentIndex):m.current(N.fromIndex),r.current=null,d(!1),f(L=>L+1)}};return b.addEventListener("pointermove",S),b.addEventListener("pointerup",T),b.addEventListener("pointercancel",T),()=>{b.removeEventListener("pointermove",S),b.removeEventListener("pointerup",T),b.removeEventListener("pointercancel",T),cancelAnimationFrame(l.current),cancelAnimationFrame(p.current)}},[e,g,y,D]);const E=z.useCallback((b,w)=>{b.button!==0||b.target.closest("button")||(r.current={active:!1,fromIndex:w,currentIndex:w,startX:b.clientX,deltaX:0,tabRects:[],pointerId:b.pointerId})},[]);return{getTabDragProps:z.useCallback(b=>{var S;const w=r.current,x={};if(w!=null&&w.active)if(b===w.fromIndex)x.transform=`translateX(${w.deltaX}px) scale(1.03)`,x.zIndex=10,x.opacity=.85,x.boxShadow="0 2px 8px rgba(0,0,0,0.4)",x.position="relative",x.pointerEvents="none";else{const T=w.fromIndex,j=w.currentIndex,L=(((S=w.tabRects[T])==null?void 0:S.width)??0)+4;x.transition="transform 0.15s ease",T<j&&b>T&&b<=j?x.transform=`translateX(-${L}px)`:T>j&&b>=j&&b<T?x.transform=`translateX(${L}px)`:x.transform="translateX(0)"}return{onPointerDown:T=>E(T,b),style:x,"data-drag-index":b}},[E]),isDragging:a,containerRef:n}}function rC(){const[i,e]=z.useState(()=>typeof document>"u"?!0:document.visibilityState!=="hidden");return z.useEffect(()=>{if(typeof document>"u")return;const t=()=>e(document.visibilityState!=="hidden");return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),i}const wx=()=>({title:"",body:"",tag:"bug"});function F2(i){let e=0;for(const t of i)t.statusAt!=null&&t.statusAt!==t.seenStatusAt&&e++;return e}const yx=i=>i instanceof Error?i.message:String(i),gn=jn((i,e)=>{const t=()=>window.api.customerFeedback,n=async()=>{i({items:await t().list(),loaded:!0})},r=async()=>{const p=await t().inboxList({});return p.ok?(i({inbox:p.items}),!0):(Qe.error(`Feedback inbox failed: ${p.error}`),!1)},l=async(p,a)=>{try{await a()}catch(d){Qe.error(`${p}: ${yx(d)}`)}};return{panelOpen:!1,draft:wx(),items:[],loaded:!1,submitting:!1,ownerInfo:null,inbox:[],inboxLoading:!1,openPanel:()=>i({panelOpen:!0}),closePanel:()=>i({panelOpen:!1}),togglePanel:()=>i(p=>({panelOpen:!p.panelOpen})),setDraft:p=>i(a=>({draft:{...a.draft,...p}})),load:()=>l("Feedback load failed",n),submit:async()=>{if(!e().submitting){i({submitting:!0});try{const p=await t().submit(e().draft);p.ok?(i(a=>({items:[p.item,...a.items],draft:wx()})),Qe.info("Feedback sent — thank you")):Qe.error(`Feedback not sent: ${p.error}`)}catch(p){Qe.error(`Feedback not sent: ${yx(p)}`)}finally{i({submitting:!1})}}},refreshStatus:()=>l("Feedback status refresh failed",async()=>{const p=await t().refreshStatus();p.ok||Qe.error(`Feedback status refresh failed: ${p.error}`),await n()}),markSeen:()=>l("Feedback mark-seen failed",async()=>{await t().markSeen({}),await n()}),loadOwnerInfo:()=>l("Feedback owner info failed",async()=>{i({ownerInfo:await t().ownerInfo()})}),pullInbox:async()=>{i({inboxLoading:!0}),await l("Feedback inbox pull failed",async()=>{const p=await t().inboxPull();if(!p.ok){Qe.error(`Feedback inbox pull failed: ${p.error}`);return}await r()}),i({inboxLoading:!1})},setInboxStatus:(p,a,d)=>l("Feedback status update failed",async()=>{const f=await t().inboxSetStatus({id:p,status:a,...d!==void 0?{note:d}:{}});if(!f.ok){Qe.error(`Feedback status update failed: ${f.error}`);return}await r()}),linkEpic:(p,a)=>l("Feedback epic link failed",async()=>{const d=await t().inboxLinkEpic({id:p,epicId:a});if(!d.ok){Qe.error(`Feedback epic link failed: ${d.error}`);return}await r()})}});var Th=N1();const H2=Pw(Th),dn={dialog:"z-50",tour:"z-[500]",contextMenu:"z-[600]",contextMenuScrim:"z-[590]",contextMenuDialog:"z-[700]",toast:"z-[900]",recording:"z-[1000]"},W2={dialog:50},oC={feature:{description:"Plans new functionality from the stated objective, then delegates the build to /develop.",initialPromptTemplate:"You are planning new functionality. Treat the goal below as the full objective — establish scope, then decompose and queue the work as scheduled PRDs via the /develop skill, rather than editing files inline in this conversation: this interactive session is a planner-tier model and the headless claude -p executor does the typing."},bug:{description:"Diagnoses a reported failure before queuing a fix via /develop — reproduction first.",initialPromptTemplate:"You are diagnosing a reported bug. If a reference (log, stack trace, repro steps) is attached, read it and reproduce the failure before writing a fix — do not guess at root cause from the description alone. If nothing is attached, reproduce it yourself first. Once root cause is established, queue the fix as a scheduled PRD via the /develop skill rather than typing it inline: this interactive session is a planner-tier model and the headless claude -p executor does the typing."},discussion:{description:"Open-ended research/decision conversation — no code changes expected.",initialPromptTemplate:"You are in an open-ended discussion. The goal is a decision or shared understanding, not a code change — do not start editing files unless the human explicitly asks you to after the discussion lands somewhere."},build:{description:"Prepares and publishes a release build to this project's configured registry.",initialPromptTemplate:"You are preparing a release build. Treat the goal below as the full objective — verify the project's build target configuration before publishing."},"project-home-builder":{description:"Produces a Project Home artifact for this project — the overview page or the 30-second demo video — whichever the Actor persona defines.",initialPromptTemplate:"You are producing a Project Home artifact. Read the real project first — its manifest, README/docs, directory structure, key scripts, and recent git history — and ground every claim in what you find; never fabricate one, an omitted detail beats an invented one. Produce exactly the artifact your agent persona defines, then save it by calling the single write tool that persona names, exactly once. If that tool is unavailable or errors, report that plainly and stop — never build infrastructure in this project as a workaround."}},U2=["feature","bug","discussion","project-home-builder"];function aC(i){return oC[i]}const Ev={"general-behavior":{key:"general-behavior",label:"General behaviour",description:"Universal working-style rules for every Epic, independent of which Agent persona or Mission tag is chosen — the floor every session stands on, including Epics created before any persona resolved.",text:`Work concisely: lead with the answer or the result, skip preamble, and don't recap what you just did unless asked. Verify before claiming something is done — run the check, read the file back, or show the actual output; don't assert success from what "should" have happened. Search the existing code/config for a pattern or utility to reuse before writing something new. Ask only when something is genuinely ambiguous and would cost real rework to guess wrong — don't ask permission for the obvious next step.`},"delegate-implementation":{key:"delegate-implementation",label:"Delegate implementation",description:"Keeps this interactive session in a planning-and-deciding role and pushes actual implementation to the headless scheduler, independent of which Agent persona is chosen — the same floor as General behaviour, on by default for feature/bug work.",text:"This interactive session plans and decides; it does not implement. Once scope is clear, queue the implementation as scheduled PRDs via the /develop skill and let it run headless — do not edit application source inline in this conversation. If the scheduler tools are unavailable, say so explicitly rather than falling back to implementing the work yourself."}},lC=Object.keys(Ev);function pd(i){return i.replace(/\r?\n/g," ")}function V2(i,e){const t=e.map(n=>`Reference: ${pd(n)}`);return t.length?`${i}
|
|
56
|
+
`),questions:e,at:Date.now()},{},"needs-input",{questionTurnId:n})}),window.api.chat.onError(({tabId:i,sessionId:e,message:t})=>{eC(i,e,t)}),window.api.chat.onNotice(({tabId:i,sessionId:e,message:t})=>{xv(i,e,t)}),window.api.chat.onExternalSend(({tabId:i,prompt:e,sessionId:t,cwd:n})=>{var p,a,d,f;const r=Ct.getState().tabs.find(m=>m.id===i);if(r){vi.getState().send({tabId:i,sessionId:r.sessionId,cwd:r.cwd,prompt:e,external:!0});return}const l=ri.getState().sessions[i];if(l){if(l.status==="completed"){(a=(p=window.api)==null?void 0:p.logs)==null||a.write("chat","warn",`external send ignored: Epic ${i} is completed/archived — its claudeSessionId is dead`);return}vi.getState().send({tabId:i,sessionId:l.claudeSessionId,cwd:l.cwd,prompt:e,external:!0});return}if(typeof t=="string"&&t&&typeof n=="string"&&n){vi.getState().send({tabId:i,sessionId:t,cwd:n,prompt:e,external:!0});return}(f=(d=window.api)==null?void 0:d.logs)==null||f.write("chat","warn",`external send ignored: ${i} matches neither an open tab nor a known Epic`)}),typeof((P1=(I1=window.api)==null?void 0:I1.promptSessions)==null?void 0:P1.onInboundAutoApprove)=="function"&&window.api.promptSessions.onInboundAutoApprove(({cwd:i,epicId:e})=>{g2(i,e)}));function E2(i){const e=i.split("/").filter(Boolean);return e[e.length-1]||i}async function zw(i,e=!1,t=F1()){let n=!e;n&&(n=await Uv(i.cwd,i.sessionId));const r=e&&!n?crypto.randomUUID():i.sessionId,l=n?`claude --dangerously-skip-permissions --resume ${kr(r)} --model ${kr(t)}`:`claude --dangerously-skip-permissions --session-id ${kr(r)} --model ${kr(t)}`;return{sessionId:r,startupCommand:l}}const Ct=jn((i,e)=>({tabs:[],activeTabId:null,hydrated:!1,pendingRawCommand:{},queueRawCommand:(t,n)=>{i(r=>({pendingRawCommand:{...r.pendingRawCommand,[t]:n}}))},consumeRawCommand:t=>{const n=e().pendingRawCommand[t];return n===void 0?null:(i(r=>{const l={...r.pendingRawCommand};return delete l[t],{pendingRawCommand:l}}),n)},addTab:({id:t,cwd:n,startupCommand:r,presetId:l=null,label:p,dormant:a=!1})=>{const d=t??crypto.randomUUID();if(e().tabs.find(g=>g.id===d))return i({activeTabId:d}),d;a&&r&&console.warn("[sessions] addTab: dormant tab requested with a startupCommand — command is discarded:",r);const m={id:d,sessionId:d,label:p??E2(n),cwd:n,pid:null,status:a?"dormant":"spawning",exitCode:null,startupCommand:a?null:r,presetId:l,generation:0};return i({tabs:[...e().tabs,m],activeTabId:d}),d},setTabRunning:(t,n)=>i({tabs:e().tabs.map(r=>r.id===t?{...r,pid:n,status:"running"}:r)}),setTabExited:(t,n)=>i({tabs:e().tabs.map(r=>r.id===t?{...r,status:"exited",exitCode:n}:r)}),closeTab:t=>{var l;window.api.pty.kill(t),window.api.watchers.killTab(t).catch(()=>{}),window.api.transcripts.closeTab(t).catch(()=>{}),vi.getState().dropTab(t);const n=e().tabs.filter(p=>p.id!==t),r=e().activeTabId===t?((l=n[n.length-1])==null?void 0:l.id)??null:e().activeTabId;i({tabs:n,activeTabId:r})},setActive:t=>i({activeTabId:t}),restartTab:t=>{const n=e().tabs.find(p=>p.id===t);if(!n)return;window.api.pty.kill(t);const r=crypto.randomUUID(),l=p=>{i({tabs:e().tabs.map(a=>a.id===t?{...a,sessionId:r,pid:null,status:"spawning",exitCode:null,startupCommand:p,generation:a.generation+1}:a)})};n.presetId?O1(n.presetId).then(p=>{l(p?L1(p,{sessionId:r,cwd:n.cwd}):`claude --dangerously-skip-permissions --session-id ${kr(r)}`)}):l(`claude --dangerously-skip-permissions --session-id ${kr(r)}`)},reorderTab:(t,n)=>{const r=[...e().tabs];if(t<0||t>=r.length||n<0||n>=r.length||t===n)return;const[l]=r.splice(t,1);r.splice(n,0,l),i({tabs:r})},restoreTabs:(t,n)=>i({tabs:t,activeTabId:n,hydrated:!0}),wakeTab:async(t,n)=>{var a;const r=e().tabs.find(d=>d.id===t);if(!r||r.status!=="dormant")return;(a=vi.getState().chats[t])!=null&&a.running&&(await window.api.chat.cancel(t),Qe.info("Cancelled the in-progress chat run to open a live session."));const{sessionId:l,startupCommand:p}=await zw({cwd:r.cwd,sessionId:r.sessionId},!1,n??F1());i({tabs:e().tabs.map(d=>d.id===t?{...d,sessionId:l,status:"spawning",startupCommand:p,generation:d.generation+1}:d)})},sleepTab:t=>{const n=e().tabs.find(r=>r.id===t);!n||n.status==="dormant"||(window.api.pty.kill(t),i({tabs:e().tabs.map(r=>r.id===t?{...r,pid:null,status:"dormant"}:r)}))},newSession:t=>{e().tabs.find(r=>r.id===t)&&i({tabs:e().tabs.map(r=>r.id===t?{...r,sessionId:crypto.randomUUID()}:r)})},addSessionToProject:(t,n)=>e().addTab({cwd:t,startupCommand:null,dormant:!0,...n})}));async function Tb(){var t;if(Ct.getState().hydrated)return;try{const{tabs:n,activeTabId:r,freshStart:l}=await window.api.sessions.load();if(n.length>0){const a=(await Promise.all(n.map(async f=>{try{const{sessionId:m}=await zw(f,l);return{id:f.id,sessionId:m,cwd:f.cwd,label:f.label,presetId:f.presetId,pid:null,status:"dormant",exitCode:null,startupCommand:null,generation:0}}catch(m){return console.warn("[sessions] dropping malformed persisted tab:",f==null?void 0:f.id,m),null}}))).filter(f=>f!==null),d=r&&a.find(f=>f.id===r)?r:((t=a[0])==null?void 0:t.id)??null;Ct.getState().restoreTabs(a,d)}else Ct.setState({hydrated:!0})}catch(n){console.warn("[sessions] hydrate failed:",n),Ct.setState({hydrated:!0})}const i=()=>{const{tabs:n,activeTabId:r}=Ct.getState(),l=n.map(p=>({id:p.id,sessionId:p.sessionId,cwd:p.cwd,label:p.label,presetId:p.presetId}));window.api.sessions.save({tabs:l,activeTabId:r}).catch(p=>{console.warn("[sessions] save failed:",p)})};let e=null;Ct.subscribe((n,r)=>{n.hydrated&&(n.tabs===r.tabs&&n.activeTabId===r.activeTabId||(e!==null&&window.clearTimeout(e),e=window.setTimeout(i,200)))}),i()}const T2=Object.freeze(Object.defineProperty({__proto__:null,hydrateSessions:Tb,resolveStartupCommand:zw,useSessions:Ct},Symbol.toStringTag,{value:"Module"})),gx=200,D2=/\x1b\[[0-9;]*m/g;function $2(i){return i.replace(D2,"")}const Gf=jn((i,e)=>({watchers:{},initialized:!1,init:()=>{e().initialized||(i({initialized:!0}),window.api.watchers.onLine(t=>e().ingestLine(t)),window.api.watchers.onClosed(({watcherId:t})=>e().closed(t)))},add:async({tabId:t,label:n,command:r,cwd:l})=>{try{const p=await window.api.watchers.add({tabId:t,label:n,command:r,cwd:l??null}),a={watcherId:p.watcherId,tabId:p.tabId,label:p.label,command:p.command,cwd:p.cwd,pid:p.pid,startedAt:p.startedAt,lineCount:0,lines:[],lastLineAt:null};return i({watchers:{...e().watchers,[a.watcherId]:a}}),a}catch(p){return console.error("[watchers] add failed:",p),Qe.error("Failed to add watcher"),null}},remove:async t=>{try{await window.api.watchers.remove(t)}catch(r){console.error("[watchers] remove failed:",r);const l=r instanceof Error?r.message:String(r);Qe.error(`Could not remove watcher: ${l}`)}const n={...e().watchers};delete n[t],i({watchers:n})},watchersForTab:t=>Object.values(e().watchers).filter(n=>n.tabId===t),ingestLine:t=>{const n=e().watchers[t.watcherId];if(!n)return;const r=$2(t.line),l=n.lines.length>=gx?[...n.lines.slice(n.lines.length-gx+1),{line:r,ts:t.ts}]:[...n.lines,{line:r,ts:t.ts}];i({watchers:{...e().watchers,[t.watcherId]:{...n,lines:l,lineCount:n.lineCount+1,lastLineAt:t.ts}}})},closed:t=>{if(!e().watchers[t])return;const n={...e().watchers};delete n[t],i({watchers:n})}})),yr=["home"],Cg=["project"],A2=["home","project"],hm=[{key:"overview",group:"Workspace",label:"Dashboard",icon:"home",hint:"This machine — every project, every active session",faces:yr},{key:"project-home",group:"Workspace",label:"Project Home",icon:"home",hint:"One generated overview page for this project",faces:Cg},{key:"terminal",group:"Workspace",label:"Sessions",icon:"terminal",hint:"Independent goal-scoped sessions for this project",faces:Cg},{key:"projects",group:"Workspace",label:"File Explorer",icon:"projects",hint:"Browse files + edit — starts at your home folder from Home, the active project from a Tab",faces:A2},{key:"scheduler",group:"Workspace",label:"Scheduler",icon:"scheduler",liveKind:"scheduler",hint:"This project's live PRD queue + scheduler policy",faces:Cg},{key:"history",group:"Workspace",label:"History",icon:"history",hint:"Spend, tokens and time across every project",faces:yr},{key:"remote",group:"Workspace",label:"Remote",icon:"terminal",hint:"Session Managers on your other computers — their projects, sessions and terminals",faces:yr},{key:"system-prompt",group:"Configure",label:"System Prompt",icon:"system-prompt",hint:"Your ~/.claude/CLAUDE.md — house rules for every session on this machine",faces:yr},{key:"skills",group:"Configure",label:"Skills",icon:"skills",hint:"Reusable instructions Claude loads",faces:yr},{key:"plugins",group:"Configure",label:"Plugins",icon:"plugins",hint:"Extensions for Claude Code",faces:yr},{key:"mcp",group:"Configure",label:"MCP Servers",icon:"mcp",hint:"External tools and integrations",faces:yr},{key:"hooks",group:"Configure",label:"Hooks",icon:"hooks",hint:"Run scripts on session events",faces:yr},{key:"memory",group:"Configure",label:"Memory",icon:"memory",hint:"Workspace memory store",faces:Cg},{key:"permissions",group:"Configure",label:"Permissions",icon:"permissions",hint:"Allow / deny rules",faces:yr},{key:"settings",group:"Configure",label:"Settings",icon:"settings",hint:"Theme, voice, billing window — per-session model lives in Agent Library",faces:yr},{key:"agent-library",group:"Configure",label:"Agent Library",icon:"book",hint:"Agent personas available to this machine, and which projects override them",faces:yr},{key:"tag-library",group:"Configure",label:"Tag Library",icon:"target",hint:"Session intent tags and their /develop behavior",faces:yr},{key:"voice",group:"Tools",label:"Voice",icon:"mic",hint:"On-device transcription + push-to-talk",faces:yr},{key:"data-model",group:"Tools",label:"Data Model",icon:"compass",hint:"ERD of what Session Manager actually persists, and how it joins",faces:yr}];function I2(i){return hm.filter(e=>e.faces.includes(i)).map(e=>{var t,n;return{...e,label:((t=e.labelByFace)==null?void 0:t[i])??e.label,hint:((n=e.hintByFace)==null?void 0:n[i])??e.hint}})}const P2=Object.fromEntries(hm.map(i=>[i.key,i.group]));function j2(i){const e=hm.find(t=>t.key===i);return e!=null&&e.faces.length===1&&e.faces[0]==="home"}function R2(i){const e=hm.find(t=>t.key===i);return e!=null&&e.faces.length===1&&e.faces[0]==="project"}const x_={Workspace:"Where you do the work — sessions, files, and everything currently running.",Configure:"How Claude behaves — changes here apply to every session you start.",Tools:"One-off utilities — not configuration, just things you reach for sometimes."},iC=["overview","project-home","terminal","scheduler","history","remote","skills","plugins","mcp","hooks","memory","projects","system-prompt","permissions","settings","agent-library","tag-library","voice","data-model","editor"],N2={editor:"Editor"},M2=Object.fromEntries(hm.map(i=>[i.key,i.label])),O2=Object.fromEntries(iC.map(i=>[i,N2[i]??M2[i]??i])),nC="~/.claude/session-manager/app-prefs.json";async function sC(){var i,e;if(typeof window>"u"||!((e=(i=window.api)==null?void 0:i.config)!=null&&e.readJson))return{};try{const t=await window.api.config.readJson(nC);if(t!=null&&t.exists&&t.data&&typeof t.data=="object")return t.data}catch{}return{}}async function iB(i){var t,n;if(typeof window>"u"||!((n=(t=window.api)==null?void 0:t.config)!=null&&n.writeJson))return;const e=await sC();await window.api.config.writeJson(nC,{...e,...i})}const gd=iC.map(i=>({id:i,title:O2[i],component:"screen"}));function vx(i){return i==="overview"||j2(i)?{navFace:"home"}:R2(i)?{navFace:"project"}:{}}const ji=jn((i,e)=>{var t;return{panels:[...gd],focusedPanelId:((t=gd[0])==null?void 0:t.id)??null,focusToken:0,resetToken:0,epicsWorkspaceOpen:!1,setEpicsWorkspaceOpen:n=>i({epicsWorkspaceOpen:n}),navFace:"home",setNavFace:n=>i({navFace:n}),openPanel:n=>{e().panels.some(l=>l.id===n)&&i(l=>({focusedPanelId:n,focusToken:l.focusToken+1,...vx(n)}))},openProjectPanel:n=>{e().panels.some(l=>l.id===n)&&i(l=>({focusedPanelId:n,focusToken:l.focusToken+1,navFace:"project"}))},focusPanel:n=>{e().panels.some(l=>l.id===n)&&i({focusedPanelId:n,...vx(n)})},resetLayout:()=>{i(n=>{var r;return{resetToken:n.resetToken+1,focusedPanelId:((r=gd[0])==null?void 0:r.id)??null,focusToken:n.focusToken+1,navFace:"home"}})},hydrateOpenToHomePref:async()=>{var r;(await sC()).openToHomeOnLaunch===!0&&e().focusedPanelId===(((r=gd[0])==null?void 0:r.id)??null)&&i({focusedPanelId:"overview",navFace:"home"})}}});function L2(i){return ji.getState().panels.find(e=>e.id===i)}function z2(i,e,t="project"){return i==="projects"&&e===null&&t==="project"}function Cr({name:i,size:e=17,stroke:t=1.6,className:n}){const r={width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round",className:n};switch(i){case"home":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M4 11l8-7 8 7"}),c.jsx("path",{d:"M6 10v9h12v-9"}),c.jsx("path",{d:"M10 19v-5h4v5"})]});case"terminal":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),c.jsx("path",{d:"M7 10l3 2-3 2"}),c.jsx("path",{d:"M13 14h4"})]});case"skills":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M12 3l2.5 5.5L20 9l-4 4 1 6-5-3-5 3 1-6-4-4 5.5-.5z"})});case"history":return c.jsxs("svg",{...r,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M12 7v5l3 2"}),c.jsx("path",{d:"M4 6l2 2"})]});case"usage":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M4 19V8M10 19V5M16 19v-7M22 19H2"})});case"plugins":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M9 3v4M15 3v4M5 7h14v6a5 5 0 01-5 5h-4a5 5 0 01-5-5V7z"})});case"mcp":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1.5"}),c.jsx("rect",{x:"3",y:"14",width:"18",height:"6",rx:"1.5"}),c.jsx("circle",{cx:"6.5",cy:"7",r:".5",fill:"currentColor"}),c.jsx("circle",{cx:"6.5",cy:"17",r:".5",fill:"currentColor"})]});case"hooks":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M12 4v9a3 3 0 003 3h5"}),c.jsx("path",{d:"M9 17l3 3 3-3"})]});case"keys":return c.jsxs("svg",{...r,children:[c.jsx("circle",{cx:"8",cy:"12",r:"4"}),c.jsx("path",{d:"M12 12h9M17 12v3M20 12v2"})]});case"projects":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"memory":case"agent-memory":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M9 4a4 4 0 00-4 4v1a3 3 0 000 6v1a4 4 0 004 4h6a4 4 0 004-4v-1a3 3 0 000-6V8a4 4 0 00-4-4z"}),c.jsx("path",{d:"M9 9v6M12 6v12M15 9v6"})]});case"search":return c.jsxs("svg",{...r,children:[c.jsx("circle",{cx:"11",cy:"11",r:"6"}),c.jsx("path",{d:"M16 16l4 4"})]});case"chevron":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M9 6l6 6-6 6"})});case"caret":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M6 9l6 6 6-6"})});case"dot":return c.jsx("svg",{...r,children:c.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"})});case"plus":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M12 5v14M5 12h14"})});case"folder":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"file":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M7 3h7l4 4v14H7z"}),c.jsx("path",{d:"M14 3v4h4"})]});case"play":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M8 5l11 7-11 7z",fill:"currentColor",stroke:"none"})});case"pause":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"7",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"}),c.jsx("rect",{x:"13.5",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"})]});case"sparkle":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M12 4v6M12 14v6M4 12h6M14 12h6"})});case"book":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M4 5a2 2 0 012-2h6v18H6a2 2 0 01-2-2zM12 3h6a2 2 0 012 2v14H12z"})});case"compass":return c.jsxs("svg",{...r,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M15 9l-2 5-5 2 2-5z",fill:"currentColor",stroke:"none"})]});case"scheduler":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"15",rx:"2"}),c.jsx("path",{d:"M3 10h18M8 3v4M16 3v4"}),c.jsx("path",{d:"M8 14l2 2 4-4"})]});case"settings":return c.jsxs("svg",{...r,children:[c.jsx("circle",{cx:"12",cy:"12",r:"3"}),c.jsx("path",{d:"M12 2v3M12 19v3M4 12H1M23 12h-3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1"})]});case"mic":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"9",y:"3",width:"6",height:"12",rx:"3"}),c.jsx("path",{d:"M5 11a7 7 0 0014 0M12 18v3M9 21h6"})]});case"clock":return c.jsxs("svg",{...r,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M12 7v5l3 2"})]});case"leaf":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M20 4c-9 0-14 5-14 11 0 3 2 5 5 5 6 0 9-5 9-14z"}),c.jsx("path",{d:"M6 20c2-5 5-8 11-11"})]});case"system-prompt":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"4",y:"4",width:"16",height:"14",rx:"2"}),c.jsx("path",{d:"M8 10h8M8 14h5M9 18l-2 3M15 18l2 3"})]});case"permissions":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),c.jsx("path",{d:"M8 11V8a4 4 0 018 0v3"}),c.jsx("circle",{cx:"12",cy:"15.5",r:"1.2",fill:"currentColor",stroke:"none"})]});case"tool":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M14 4a4 4 0 014 4l-7 7-4-4 7-7zM7 11l-3 3 6 6 3-3"})});case"quick-open":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),c.jsx("path",{d:"M3 9h18M7 13h10M7 16h6"})]});case"wifi":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M5 12.5a10 10 0 0114 0M8 15.5a6 6 0 018 0M12 18.5h.01"})});case"shield":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M12 3l7 3v5c0 4.5-3 8-7 10-4-2-7-5.5-7-10V6z"}),c.jsx("path",{d:"M9 12l2 2 4-4"})]});case"link":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M9 12h6"}),c.jsx("path",{d:"M10 8H7a4 4 0 000 8h3M14 8h3a4 4 0 010 8h-3"})]});case"copy":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),c.jsx("path",{d:"M5 15V5a2 2 0 012-2h8"})]});case"check":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M5 12l5 5 9-10"})});case"x":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M6 6l12 12M18 6L6 18"})});case"send":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M4 11l17-7-7 17-3-7z"})});case"target":return c.jsxs("svg",{...r,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("circle",{cx:"12",cy:"12",r:"3.5"}),c.jsx("path",{d:"M12 2v3M12 19v3M2 12h3M19 12h3"})]});case"eye":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"})]});case"arrowleft":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M19 12H5M11 6l-6 6 6 6"})});case"arrowright":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M5 12h14M13 6l6 6-6 6"})});case"reload":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M4 12a8 8 0 0114-5.3M20 12a8 8 0 01-14 5.3"}),c.jsx("path",{d:"M18 3v4h-4M6 21v-4h4"})]});case"lock":return c.jsxs("svg",{...r,children:[c.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),c.jsx("path",{d:"M8 11V8a4 4 0 018 0v3"})]});case"stop":return c.jsx("svg",{...r,children:c.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.5",fill:"currentColor",stroke:"none"})});case"star":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M12 3l2.6 5.6 6.1.6-4.6 4.1 1.3 6-5.4-3.2-5.4 3.2 1.3-6-4.6-4.1 6.1-.6z"})});case"minus":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M5 12h14"})});case"paperclip":return c.jsx("svg",{...r,children:c.jsx("path",{d:"M8 12.5l6.5-6.5a3 3 0 014.2 4.2L11 18a5 5 0 01-7-7l7.5-7.5"})});case"expand":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M8 3H3v5"}),c.jsx("path",{d:"M16 3h5v5"}),c.jsx("path",{d:"M8 21H3v-5"}),c.jsx("path",{d:"M16 21h5v-5"})]});case"collapse":return c.jsxs("svg",{...r,children:[c.jsx("path",{d:"M3 8h5V3"}),c.jsx("path",{d:"M21 8h-5V3"}),c.jsx("path",{d:"M3 16h5v5"}),c.jsx("path",{d:"M21 16h-5v5"})]});default:return null}}const B2=4,_x=40,bx=6;function G2(i){const{onReorder:e,onActivate:t}=i,n=z.useRef(null),r=z.useRef(null),l=z.useRef(0),p=z.useRef(0),[a,d]=z.useState(!1),[,f]=z.useState(0),m=z.useRef(t);m.current=t;const g=z.useCallback(()=>n.current?Array.from(n.current.querySelectorAll("[data-drag-index]")):[],[]),y=z.useCallback((b,w,x)=>{for(let S=0;S<w.length;S++){const T=w[S].left+w[S].width/2;if(b<T)return S<=x?S:S-1}return w.length-1},[]),D=z.useCallback(()=>{const b=r.current,w=n.current;if(!(b!=null&&b.active)||!w)return;const x=w.getBoundingClientRect(),S=b.startX+b.deltaX,T=S-x.left,j=x.right-S;T<_x?w.scrollLeft-=bx:j<_x&&(w.scrollLeft+=bx),l.current=requestAnimationFrame(D)},[]);z.useEffect(()=>{const b=n.current;if(!b)return;let w=!1;const x=()=>{w||(w=!0,p.current=requestAnimationFrame(()=>{w=!1,f(j=>j+1)}))},S=j=>{var V;const N=r.current;if(!N)return;const L=j.clientX-N.startX;if(!N.active&&Math.abs(L)<B2)return;if(!N.active){N.active=!0,N.tabRects=g().map(te=>te.getBoundingClientRect()),d(!0);try{(V=n.current)==null||V.setPointerCapture(N.pointerId)}catch{}l.current=requestAnimationFrame(D)}N.deltaX=L;const R=N.tabRects[N.fromIndex],F=R.left+R.width/2+L;N.currentIndex=y(F,N.tabRects,N.fromIndex),x()},T=j=>{const N=r.current;if(N&&N.pointerId===j.pointerId){cancelAnimationFrame(l.current),cancelAnimationFrame(p.current);try{b.releasePointerCapture(N.pointerId)}catch{}N.active&&N.fromIndex!==N.currentIndex?e(N.fromIndex,N.currentIndex):m.current(N.fromIndex),r.current=null,d(!1),f(L=>L+1)}};return b.addEventListener("pointermove",S),b.addEventListener("pointerup",T),b.addEventListener("pointercancel",T),()=>{b.removeEventListener("pointermove",S),b.removeEventListener("pointerup",T),b.removeEventListener("pointercancel",T),cancelAnimationFrame(l.current),cancelAnimationFrame(p.current)}},[e,g,y,D]);const E=z.useCallback((b,w)=>{b.button!==0||b.target.closest("button")||(r.current={active:!1,fromIndex:w,currentIndex:w,startX:b.clientX,deltaX:0,tabRects:[],pointerId:b.pointerId})},[]);return{getTabDragProps:z.useCallback(b=>{var S;const w=r.current,x={};if(w!=null&&w.active)if(b===w.fromIndex)x.transform=`translateX(${w.deltaX}px) scale(1.03)`,x.zIndex=10,x.opacity=.85,x.boxShadow="0 2px 8px rgba(0,0,0,0.4)",x.position="relative",x.pointerEvents="none";else{const T=w.fromIndex,j=w.currentIndex,L=(((S=w.tabRects[T])==null?void 0:S.width)??0)+4;x.transition="transform 0.15s ease",T<j&&b>T&&b<=j?x.transform=`translateX(-${L}px)`:T>j&&b>=j&&b<T?x.transform=`translateX(${L}px)`:x.transform="translateX(0)"}return{onPointerDown:T=>E(T,b),style:x,"data-drag-index":b}},[E]),isDragging:a,containerRef:n}}function rC(){const[i,e]=z.useState(()=>typeof document>"u"?!0:document.visibilityState!=="hidden");return z.useEffect(()=>{if(typeof document>"u")return;const t=()=>e(document.visibilityState!=="hidden");return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),i}const wx=()=>({title:"",body:"",tag:"bug"});function F2(i){let e=0;for(const t of i)t.statusAt!=null&&t.statusAt!==t.seenStatusAt&&e++;return e}const yx=i=>i instanceof Error?i.message:String(i),gn=jn((i,e)=>{const t=()=>window.api.customerFeedback,n=async()=>{i({items:await t().list(),loaded:!0})},r=async()=>{const p=await t().inboxList({});return p.ok?(i({inbox:p.items}),!0):(Qe.error(`Feedback inbox failed: ${p.error}`),!1)},l=async(p,a)=>{try{await a()}catch(d){Qe.error(`${p}: ${yx(d)}`)}};return{panelOpen:!1,draft:wx(),items:[],loaded:!1,submitting:!1,ownerInfo:null,inbox:[],inboxLoading:!1,openPanel:()=>i({panelOpen:!0}),closePanel:()=>i({panelOpen:!1}),togglePanel:()=>i(p=>({panelOpen:!p.panelOpen})),setDraft:p=>i(a=>({draft:{...a.draft,...p}})),load:()=>l("Feedback load failed",n),submit:async()=>{if(!e().submitting){i({submitting:!0});try{const p=await t().submit(e().draft);p.ok?(i(a=>({items:[p.item,...a.items],draft:wx()})),Qe.info("Feedback sent — thank you")):Qe.error(`Feedback not sent: ${p.error}`)}catch(p){Qe.error(`Feedback not sent: ${yx(p)}`)}finally{i({submitting:!1})}}},refreshStatus:()=>l("Feedback status refresh failed",async()=>{const p=await t().refreshStatus();p.ok||Qe.error(`Feedback status refresh failed: ${p.error}`),await n()}),markSeen:()=>l("Feedback mark-seen failed",async()=>{await t().markSeen({}),await n()}),loadOwnerInfo:()=>l("Feedback owner info failed",async()=>{i({ownerInfo:await t().ownerInfo()})}),pullInbox:async()=>{i({inboxLoading:!0}),await l("Feedback inbox pull failed",async()=>{const p=await t().inboxPull();if(!p.ok){Qe.error(`Feedback inbox pull failed: ${p.error}`);return}await r()}),i({inboxLoading:!1})},setInboxStatus:(p,a,d)=>l("Feedback status update failed",async()=>{const f=await t().inboxSetStatus({id:p,status:a,...d!==void 0?{note:d}:{}});if(!f.ok){Qe.error(`Feedback status update failed: ${f.error}`);return}await r()}),linkEpic:(p,a)=>l("Feedback epic link failed",async()=>{const d=await t().inboxLinkEpic({id:p,epicId:a});if(!d.ok){Qe.error(`Feedback epic link failed: ${d.error}`);return}await r()})}});var Th=N1();const H2=Pw(Th),dn={dialog:"z-50",tour:"z-[500]",contextMenu:"z-[600]",contextMenuScrim:"z-[590]",contextMenuDialog:"z-[700]",toast:"z-[900]",recording:"z-[1000]"},W2={dialog:50},oC={feature:{description:"Plans new functionality from the stated objective, then delegates the build to /develop.",initialPromptTemplate:"You are planning new functionality. Treat the goal below as the full objective — establish scope, then decompose and queue the work as scheduled PRDs via the /develop skill, rather than editing files inline in this conversation: this interactive session is a planner-tier model and the headless claude -p executor does the typing."},bug:{description:"Diagnoses a reported failure before queuing a fix via /develop — reproduction first.",initialPromptTemplate:"You are diagnosing a reported bug. If a reference (log, stack trace, repro steps) is attached, read it and reproduce the failure before writing a fix — do not guess at root cause from the description alone. If nothing is attached, reproduce it yourself first. Once root cause is established, queue the fix as a scheduled PRD via the /develop skill rather than typing it inline: this interactive session is a planner-tier model and the headless claude -p executor does the typing."},discussion:{description:"Open-ended research/decision conversation — no code changes expected.",initialPromptTemplate:"You are in an open-ended discussion. The goal is a decision or shared understanding, not a code change — do not start editing files unless the human explicitly asks you to after the discussion lands somewhere."},build:{description:"Prepares and publishes a release build to this project's configured registry.",initialPromptTemplate:"You are preparing a release build. Treat the goal below as the full objective — verify the project's build target configuration before publishing."},"project-home-builder":{description:"Produces a Project Home artifact for this project — the overview page or the 30-second demo video — whichever the Actor persona defines.",initialPromptTemplate:"You are producing a Project Home artifact. Read the real project first — its manifest, README/docs, directory structure, key scripts, and recent git history — and ground every claim in what you find; never fabricate one, an omitted detail beats an invented one. Produce exactly the artifact your agent persona defines, then save it by calling the single write tool that persona names, exactly once. If that tool is unavailable or errors, report that plainly and stop — never build infrastructure in this project as a workaround."},art:{description:"Plans 3D art / animation work (modeling, rigging, animation) and queues it via /develop for the project art persona.",initialPromptTemplate:"You are planning 3D art / animation work (modeling, rigging, skinning, shape keys, animation cycles). Treat the goal below as the full objective — establish scope against the project's CLAUDE.md (which names the .blend source of truth, export pipeline and engine), then decompose and queue the work as scheduled PRDs via the /develop skill with agentType set to the project's art persona (e.g. blender-artist), rather than editing assets inline in this conversation. The .blend file is the source of truth; exported assets are derived."},portfolio:{description:"Reviews the whole project portfolio and routes decided changes to the owning projects — never builds or queues PRDs itself.",initialPromptTemplate:"You are running a portfolio optimization review across the owner's projects (money, influence, online presence). The outcome is a small set of decisions, not a code change in this project. Do not edit files here. Do not queue PRDs or run /develop from this session. Route each decided change to the project that owns it with the send-feedback skill (feedback_open_session), which lands it as a proposed Epic in that project for its own human to approve."}},U2=["feature","bug","discussion","project-home-builder","art","portfolio"];function aC(i){return oC[i]}const Ev={"general-behavior":{key:"general-behavior",label:"General behaviour",description:"Universal working-style rules for every Epic, independent of which Agent persona or Mission tag is chosen — the floor every session stands on, including Epics created before any persona resolved.",text:`Work concisely: lead with the answer or the result, skip preamble, and don't recap what you just did unless asked. Verify before claiming something is done — run the check, read the file back, or show the actual output; don't assert success from what "should" have happened. Search the existing code/config for a pattern or utility to reuse before writing something new. Ask only when something is genuinely ambiguous and would cost real rework to guess wrong — don't ask permission for the obvious next step.`},"delegate-implementation":{key:"delegate-implementation",label:"Delegate implementation",description:"Keeps this interactive session in a planning-and-deciding role and pushes actual implementation to the headless scheduler, independent of which Agent persona is chosen — the same floor as General behaviour, on by default for feature/bug work.",text:"This interactive session plans and decides; it does not implement. Once scope is clear, queue the implementation as scheduled PRDs via the /develop skill and let it run headless — do not edit application source inline in this conversation. If the scheduler tools are unavailable, say so explicitly rather than falling back to implementing the work yourself."}},lC=Object.keys(Ev);function pd(i){return i.replace(/\r?\n/g," ")}function V2(i,e){const t=e.map(n=>`Reference: ${pd(n)}`);return t.length?`${i}
|
|
57
57
|
|
|
58
58
|
${t.join(`
|
|
59
59
|
`)}`:i}const S_=6e3;function q2(i){if(!i.startsWith(`---
|
|
@@ -2927,7 +2927,7 @@ ${I}`,M=v.createShaderModule({code:P,label:s.name});li("verbose",()=>`[WebGPU] $
|
|
|
2927
2927
|
* Licensed under the MIT License.
|
|
2928
2928
|
*/var Ox;function vD(){return Ox||(Ox=1,(function(i,e){var t=(()=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,p=Object.prototype.hasOwnProperty,a=(Y=>typeof lo<"u"?lo:typeof Proxy<"u"?new Proxy(Y,{get:(re,pe)=>(typeof lo<"u"?lo:re)[pe]}):Y)(function(Y){if(typeof lo<"u")return lo.apply(this,arguments);throw Error('Dynamic require of "'+Y+'" is not supported')}),d=(Y,re)=>()=>(Y&&(re=Y(Y=0)),re),f=(Y,re)=>{for(var pe in re)n(Y,pe,{get:re[pe],enumerable:!0})},m=(Y,re,pe,Te)=>{if(re&&typeof re=="object"||typeof re=="function")for(let ye of l(re))!p.call(Y,ye)&&ye!==pe&&n(Y,ye,{get:()=>re[ye],enumerable:!(Te=r(re,ye))||Te.enumerable});return Y},g=Y=>m(n({},"__esModule",{value:!0}),Y),y,D,E,C,b,w=d(()=>{y=new Map,D=[],E=(Y,re,pe)=>{if(re&&typeof re.init=="function"&&typeof re.createInferenceSessionHandler=="function"){let Te=y.get(Y);if(Te===void 0)y.set(Y,{backend:re,priority:pe});else{if(Te.priority>pe)return;if(Te.priority===pe&&Te.backend!==re)throw new Error(`cannot register backend "${Y}" using priority ${pe}`)}if(pe>=0){let ye=D.indexOf(Y);ye!==-1&&D.splice(ye,1);for(let ze=0;ze<D.length;ze++)if(y.get(D[ze]).priority<=pe){D.splice(ze,0,Y);return}D.push(Y)}return}throw new TypeError("not a valid backend")},C=async Y=>{let re=y.get(Y);if(!re)return"backend not found.";if(re.initialized)return re.backend;if(re.aborted)return re.error;{let pe=!!re.initPromise;try{return pe||(re.initPromise=re.backend.init(Y)),await re.initPromise,re.initialized=!0,re.backend}catch(Te){return pe||(re.error=`${Te}`,re.aborted=!0),re.error}finally{delete re.initPromise}}},b=async Y=>{let re=Y.executionProviders||[],pe=re.map(Be=>typeof Be=="string"?Be:Be.name),Te=pe.length===0?D:pe,ye,ze=[],$e=new Set;for(let Be of Te){let it=await C(Be);typeof it=="string"?ze.push({name:Be,err:it}):(ye||(ye=it),ye===it&&$e.add(Be))}if(!ye)throw new Error(`no available backend found. ERR: ${ze.map(Be=>`[${Be.name}] ${Be.err}`).join(", ")}`);for(let{name:Be,err:it}of ze)pe.includes(Be)&&console.warn(`removing requested execution provider "${Be}" from session options because it is not available: ${it}`);let Ae=re.filter(Be=>$e.has(typeof Be=="string"?Be:Be.name));return[ye,new Proxy(Y,{get:(Be,it)=>it==="executionProviders"?Ae:Reflect.get(Be,it)})]}}),x=d(()=>{w()}),S,T=d(()=>{S="1.26.0"}),j,N,L=d(()=>{T(),j="warning",N={wasm:{},webgl:{},webgpu:{},versions:{common:S},set logLevel(Y){if(Y!==void 0){if(typeof Y!="string"||["verbose","info","warning","error","fatal"].indexOf(Y)===-1)throw new Error(`Unsupported logging level: ${Y}`);j=Y}},get logLevel(){return j}},Object.defineProperty(N,"logLevel",{enumerable:!0})}),R,F=d(()=>{L(),R=N}),V,te,he=d(()=>{V=(Y,re)=>{let pe=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);pe.width=Y.dims[3],pe.height=Y.dims[2];let Te=pe.getContext("2d");if(Te!=null){let ye,ze;(re==null?void 0:re.tensorLayout)!==void 0&&re.tensorLayout==="NHWC"?(ye=Y.dims[2],ze=Y.dims[3]):(ye=Y.dims[3],ze=Y.dims[2]);let $e=(re==null?void 0:re.format)!==void 0?re.format:"RGB",Ae=re==null?void 0:re.norm,Be,it;Ae===void 0||Ae.mean===void 0?Be=[255,255,255,255]:typeof Ae.mean=="number"?Be=[Ae.mean,Ae.mean,Ae.mean,Ae.mean]:(Be=[Ae.mean[0],Ae.mean[1],Ae.mean[2],0],Ae.mean[3]!==void 0&&(Be[3]=Ae.mean[3])),Ae===void 0||Ae.bias===void 0?it=[0,0,0,0]:typeof Ae.bias=="number"?it=[Ae.bias,Ae.bias,Ae.bias,Ae.bias]:(it=[Ae.bias[0],Ae.bias[1],Ae.bias[2],0],Ae.bias[3]!==void 0&&(it[3]=Ae.bias[3]));let ot=ze*ye,nt=0,Ke=ot,jt=ot*2,Le=-1;$e==="RGBA"?(nt=0,Ke=ot,jt=ot*2,Le=ot*3):$e==="RGB"?(nt=0,Ke=ot,jt=ot*2):$e==="RBG"&&(nt=0,jt=ot,Ke=ot*2);for(let dt=0;dt<ze;dt++)for(let Ii=0;Ii<ye;Ii++){let ei=(Y.data[nt++]-it[0])*Be[0],ti=(Y.data[Ke++]-it[1])*Be[1],Pi=(Y.data[jt++]-it[2])*Be[2],zt=Le===-1?255:(Y.data[Le++]-it[3])*Be[3];Te.fillStyle="rgba("+ei+","+ti+","+Pi+","+zt+")",Te.fillRect(Ii,dt,1,1)}if("toDataURL"in pe)return pe.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},te=(Y,re)=>{let pe=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),Te;if(pe!=null){let ye,ze,$e;(re==null?void 0:re.tensorLayout)!==void 0&&re.tensorLayout==="NHWC"?(ye=Y.dims[2],ze=Y.dims[1],$e=Y.dims[3]):(ye=Y.dims[3],ze=Y.dims[2],$e=Y.dims[1]);let Ae=re!==void 0&&re.format!==void 0?re.format:"RGB",Be=re==null?void 0:re.norm,it,ot;Be===void 0||Be.mean===void 0?it=[255,255,255,255]:typeof Be.mean=="number"?it=[Be.mean,Be.mean,Be.mean,Be.mean]:(it=[Be.mean[0],Be.mean[1],Be.mean[2],255],Be.mean[3]!==void 0&&(it[3]=Be.mean[3])),Be===void 0||Be.bias===void 0?ot=[0,0,0,0]:typeof Be.bias=="number"?ot=[Be.bias,Be.bias,Be.bias,Be.bias]:(ot=[Be.bias[0],Be.bias[1],Be.bias[2],0],Be.bias[3]!==void 0&&(ot[3]=Be.bias[3]));let nt=ze*ye;if(re!==void 0&&(re.format!==void 0&&$e===4&&re.format!=="RGBA"||$e===3&&re.format!=="RGB"&&re.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let Ke=4,jt=0,Le=1,dt=2,Ii=3,ei=0,ti=nt,Pi=nt*2,zt=-1;Ae==="RGBA"?(ei=0,ti=nt,Pi=nt*2,zt=nt*3):Ae==="RGB"?(ei=0,ti=nt,Pi=nt*2):Ae==="RBG"&&(ei=0,Pi=nt,ti=nt*2),Te=pe.createImageData(ye,ze);for(let Fi=0;Fi<ze*ye;jt+=Ke,Le+=Ke,dt+=Ke,Ii+=Ke,Fi++)Te.data[jt]=(Y.data[ei++]-ot[0])*it[0],Te.data[Le]=(Y.data[ti++]-ot[1])*it[1],Te.data[dt]=(Y.data[Pi++]-ot[2])*it[2],Te.data[Ii]=zt===-1?255:(Y.data[zt++]-ot[3])*it[3]}else throw new Error("Can not access image data");return Te}}),ee,we,ce,ve,Ee,fe,U=d(()=>{je(),ee=(Y,re)=>{if(Y===void 0)throw new Error("Image buffer must be defined");if(re.height===void 0||re.width===void 0)throw new Error("Image height and width must be defined");if(re.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:pe,width:Te}=re,ye=re.norm??{mean:255,bias:0},ze,$e;typeof ye.mean=="number"?ze=[ye.mean,ye.mean,ye.mean,ye.mean]:ze=[ye.mean[0],ye.mean[1],ye.mean[2],ye.mean[3]??255],typeof ye.bias=="number"?$e=[ye.bias,ye.bias,ye.bias,ye.bias]:$e=[ye.bias[0],ye.bias[1],ye.bias[2],ye.bias[3]??0];let Ae=re.format!==void 0?re.format:"RGBA",Be=re.tensorFormat!==void 0&&re.tensorFormat!==void 0?re.tensorFormat:"RGB",it=pe*Te,ot=Be==="RGBA"?new Float32Array(it*4):new Float32Array(it*3),nt=4,Ke=0,jt=1,Le=2,dt=3,Ii=0,ei=it,ti=it*2,Pi=-1;Ae==="RGB"&&(nt=3,Ke=0,jt=1,Le=2,dt=-1),Be==="RGBA"?Pi=it*3:Be==="RBG"?(Ii=0,ti=it,ei=it*2):Be==="BGR"&&(ti=0,ei=it,Ii=it*2);for(let zt=0;zt<it;zt++,Ke+=nt,Le+=nt,jt+=nt,dt+=nt)ot[Ii++]=(Y[Ke]+$e[0])/ze[0],ot[ei++]=(Y[jt]+$e[1])/ze[1],ot[ti++]=(Y[Le]+$e[2])/ze[2],Pi!==-1&&dt!==-1&&(ot[Pi++]=(Y[dt]+$e[3])/ze[3]);return Be==="RGBA"?new J("float32",ot,[1,4,pe,Te]):new J("float32",ot,[1,3,pe,Te])},we=async(Y,re)=>{let pe=typeof HTMLImageElement<"u"&&Y instanceof HTMLImageElement,Te=typeof ImageData<"u"&&Y instanceof ImageData,ye=typeof ImageBitmap<"u"&&Y instanceof ImageBitmap,ze=typeof Y=="string",$e,Ae=re??{},Be=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},it=ot=>typeof HTMLCanvasElement<"u"&&ot instanceof HTMLCanvasElement||ot instanceof OffscreenCanvas?ot.getContext("2d"):null;if(pe){let ot=Be();ot.width=Y.width,ot.height=Y.height;let nt=it(ot);if(nt!=null){let Ke=Y.height,jt=Y.width;if(re!==void 0&&re.resizedHeight!==void 0&&re.resizedWidth!==void 0&&(Ke=re.resizedHeight,jt=re.resizedWidth),re!==void 0){if(Ae=re,re.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");Ae.tensorFormat="RGBA",Ae.height=Ke,Ae.width=jt}else Ae.tensorFormat="RGBA",Ae.height=Ke,Ae.width=jt;nt.drawImage(Y,0,0),$e=nt.getImageData(0,0,jt,Ke).data}else throw new Error("Can not access image data")}else if(Te){let ot,nt;if(re!==void 0&&re.resizedWidth!==void 0&&re.resizedHeight!==void 0?(ot=re.resizedHeight,nt=re.resizedWidth):(ot=Y.height,nt=Y.width),re!==void 0&&(Ae=re),Ae.format="RGBA",Ae.height=ot,Ae.width=nt,re!==void 0){let Ke=Be();Ke.width=nt,Ke.height=ot;let jt=it(Ke);if(jt!=null)jt.putImageData(Y,0,0),$e=jt.getImageData(0,0,nt,ot).data;else throw new Error("Can not access image data")}else $e=Y.data}else if(ye){if(re===void 0)throw new Error("Please provide image config with format for Imagebitmap");let ot=Be();ot.width=Y.width,ot.height=Y.height;let nt=it(ot);if(nt!=null){let Ke=Y.height,jt=Y.width;return nt.drawImage(Y,0,0,jt,Ke),$e=nt.getImageData(0,0,jt,Ke).data,Ae.height=Ke,Ae.width=jt,ee($e,Ae)}else throw new Error("Can not access image data")}else{if(ze)return new Promise((ot,nt)=>{let Ke=Be(),jt=it(Ke);if(!Y||!jt)return nt();let Le=new Image;Le.crossOrigin="Anonymous",Le.src=Y,Le.onload=()=>{Ke.width=Le.width,Ke.height=Le.height,jt.drawImage(Le,0,0,Ke.width,Ke.height);let dt=jt.getImageData(0,0,Ke.width,Ke.height);Ae.height=Ke.height,Ae.width=Ke.width,ot(ee(dt.data,Ae))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if($e!==void 0)return ee($e,Ae);throw new Error("Input data provided is not supported - aborted tensor creation")},ce=(Y,re)=>{let{width:pe,height:Te,download:ye,dispose:ze}=re,$e=[1,Te,pe,4];return new J({location:"texture",type:"float32",texture:Y,dims:$e,download:ye,dispose:ze})},ve=(Y,re)=>{let{dataType:pe,dims:Te,download:ye,dispose:ze}=re;return new J({location:"gpu-buffer",type:pe??"float32",gpuBuffer:Y,dims:Te,download:ye,dispose:ze})},Ee=(Y,re)=>{let{dataType:pe,dims:Te,download:ye,dispose:ze}=re;return new J({location:"ml-tensor",type:pe??"float32",mlTensor:Y,dims:Te,download:ye,dispose:ze})},fe=(Y,re,pe)=>new J({location:"cpu-pinned",type:Y,data:re,dims:pe??[re.length]})}),X,W,Q,oe,Ce=d(()=>{X=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),W=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),Q=!1,oe=()=>{if(!Q){Q=!0;let Y=typeof BigInt64Array<"u"&&BigInt64Array.from,re=typeof BigUint64Array<"u"&&BigUint64Array.from,pe=globalThis.Float16Array,Te=typeof pe<"u"&&pe.from;Y&&(X.set("int64",BigInt64Array),W.set(BigInt64Array,"int64")),re&&(X.set("uint64",BigUint64Array),W.set(BigUint64Array,"uint64")),Te?(X.set("float16",pe),W.set(pe,"float16")):X.set("float16",Uint16Array)}}}),Oe,Xe,ge=d(()=>{je(),Oe=Y=>{let re=1;for(let pe=0;pe<Y.length;pe++){let Te=Y[pe];if(typeof Te!="number"||!Number.isSafeInteger(Te))throw new TypeError(`dims[${pe}] must be an integer, got: ${Te}`);if(Te<0)throw new RangeError(`dims[${pe}] must be a non-negative integer, got: ${Te}`);re*=Te}return re},Xe=(Y,re)=>{switch(Y.location){case"cpu":return new J(Y.type,Y.data,re);case"cpu-pinned":return new J({location:"cpu-pinned",data:Y.data,type:Y.type,dims:re});case"texture":return new J({location:"texture",texture:Y.texture,type:Y.type,dims:re});case"gpu-buffer":return new J({location:"gpu-buffer",gpuBuffer:Y.gpuBuffer,type:Y.type,dims:re});case"ml-tensor":return new J({location:"ml-tensor",mlTensor:Y.mlTensor,type:Y.type,dims:re});default:throw new Error(`tensorReshape: tensor location ${Y.location} is not supported`)}}}),J,je=d(()=>{he(),U(),Ce(),ge(),J=class{constructor(Y,re,pe){oe();let Te,ye;if(typeof Y=="object"&&"location"in Y)switch(this.dataLocation=Y.location,Te=Y.type,ye=Y.dims,Y.location){case"cpu-pinned":{let $e=X.get(Te);if(!$e)throw new TypeError(`unsupported type "${Te}" to create tensor from pinned buffer`);if(!(Y.data instanceof $e))throw new TypeError(`buffer should be of type ${$e.name}`);this.cpuData=Y.data;break}case"texture":{if(Te!=="float32")throw new TypeError(`unsupported type "${Te}" to create tensor from texture`);this.gpuTextureData=Y.texture,this.downloader=Y.download,this.disposer=Y.dispose;break}case"gpu-buffer":{if(Te!=="float32"&&Te!=="float16"&&Te!=="int32"&&Te!=="int64"&&Te!=="uint32"&&Te!=="uint8"&&Te!=="bool"&&Te!=="uint4"&&Te!=="int4")throw new TypeError(`unsupported type "${Te}" to create tensor from gpu buffer`);this.gpuBufferData=Y.gpuBuffer,this.downloader=Y.download,this.disposer=Y.dispose;break}case"ml-tensor":{if(Te!=="float32"&&Te!=="float16"&&Te!=="int32"&&Te!=="int64"&&Te!=="uint32"&&Te!=="uint64"&&Te!=="int8"&&Te!=="uint8"&&Te!=="bool"&&Te!=="uint4"&&Te!=="int4")throw new TypeError(`unsupported type "${Te}" to create tensor from MLTensor`);this.mlTensorData=Y.mlTensor,this.downloader=Y.download,this.disposer=Y.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let $e,Ae;if(typeof Y=="string")if(Te=Y,Ae=pe,Y==="string"){if(!Array.isArray(re))throw new TypeError("A string tensor's data must be a string array.");$e=re}else{let Be=X.get(Y);if(Be===void 0)throw new TypeError(`Unsupported tensor type: ${Y}.`);if(Array.isArray(re)){if(Y==="float16"&&Be===Uint16Array||Y==="uint4"||Y==="int4")throw new TypeError(`Creating a ${Y} tensor from number array is not supported. Please use ${Be.name} as data.`);Y==="uint64"||Y==="int64"?$e=Be.from(re,BigInt):$e=Be.from(re)}else if(re instanceof Be)$e=re;else if(re instanceof Uint8ClampedArray)if(Y==="uint8")$e=Uint8Array.from(re);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(Y==="float16"&&re instanceof Uint16Array&&Be!==Uint16Array)$e=new globalThis.Float16Array(re.buffer,re.byteOffset,re.length);else throw new TypeError(`A ${Te} tensor's data must be type of ${Be}`)}else if(Ae=re,Array.isArray(Y)){if(Y.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let Be=typeof Y[0];if(Be==="string")Te="string",$e=Y;else if(Be==="boolean")Te="bool",$e=Uint8Array.from(Y);else throw new TypeError(`Invalid element type of data array: ${Be}.`)}else if(Y instanceof Uint8ClampedArray)Te="uint8",$e=Uint8Array.from(Y);else{let Be=W.get(Y.constructor);if(Be===void 0)throw new TypeError(`Unsupported type for tensor data: ${Y.constructor}.`);Te=Be,$e=Y}if(Ae===void 0)Ae=[$e.length];else if(!Array.isArray(Ae))throw new TypeError("A tensor's dims must be a number array");ye=Ae,this.cpuData=$e,this.dataLocation="cpu"}let ze=Oe(ye);if(this.cpuData&&ze!==this.cpuData.length&&!((Te==="uint4"||Te==="int4")&&Math.ceil(ze/2)===this.cpuData.length))throw new Error(`Tensor's size(${ze}) does not match data length(${this.cpuData.length}).`);this.type=Te,this.dims=ye,this.size=ze}static async fromImage(Y,re){return we(Y,re)}static fromTexture(Y,re){return ce(Y,re)}static fromGpuBuffer(Y,re){return ve(Y,re)}static fromMLTensor(Y,re){return Ee(Y,re)}static fromPinnedBuffer(Y,re,pe){return fe(Y,re,pe)}toDataURL(Y){return V(this,Y)}toImageData(Y){return te(this,Y)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(Y){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let re=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=re,Y&&this.disposer&&(this.disposer(),this.disposer=void 0),re}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(Y){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return Xe(this,Y)}}}),de,Ie=d(()=>{je(),de=J}),Pe,Ye,ft,rt,Nt,mt,mi=d(()=>{L(),Pe=(Y,re)=>{(typeof N.trace>"u"?!N.wasm.trace:!N.trace)||console.timeStamp(`${Y}::ORT::${re}`)},Ye=(Y,re)=>{var ye;let pe=((ye=new Error().stack)==null?void 0:ye.split(/\r\n|\r|\n/g))||[],Te=!1;for(let ze=0;ze<pe.length;ze++){if(Te&&!pe[ze].includes("TRACE_FUNC")){let $e=`FUNC_${Y}::${pe[ze].trim().split(" ")[1]}`;re&&($e+=`::${re}`),Pe("CPU",$e);return}pe[ze].includes("TRACE_FUNC")&&(Te=!0)}},ft=Y=>{(typeof N.trace>"u"?!N.wasm.trace:!N.trace)||Ye("BEGIN",Y)},rt=Y=>{(typeof N.trace>"u"?!N.wasm.trace:!N.trace)||Ye("END",Y)},Nt=Y=>{(typeof N.trace>"u"?!N.wasm.trace:!N.trace)||console.time(`ORT::${Y}`)},mt=Y=>{(typeof N.trace>"u"?!N.wasm.trace:!N.trace)||console.timeEnd(`ORT::${Y}`)}}),di,_i=d(()=>{w(),Ie(),mi(),di=class vC{constructor(re){this.handler=re}async run(re,pe,Te){ft(),Nt("InferenceSession.run");let ye={},ze={};if(typeof re!="object"||re===null||re instanceof de||Array.isArray(re))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let $e=!0;if(typeof pe=="object"){if(pe===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(pe instanceof de)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(pe)){if(pe.length===0)throw new TypeError("'fetches' cannot be an empty array.");$e=!1;for(let it of pe){if(typeof it!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(it)===-1)throw new RangeError(`'fetches' contains invalid output name: ${it}.`);ye[it]=null}if(typeof Te=="object"&&Te!==null)ze=Te;else if(typeof Te<"u")throw new TypeError("'options' must be an object.")}else{let it=!1,ot=Object.getOwnPropertyNames(pe);for(let nt of this.outputNames)if(ot.indexOf(nt)!==-1){let Ke=pe[nt];(Ke===null||Ke instanceof de)&&(it=!0,$e=!1,ye[nt]=Ke)}if(it){if(typeof Te=="object"&&Te!==null)ze=Te;else if(typeof Te<"u")throw new TypeError("'options' must be an object.")}else ze=pe}}else if(typeof pe<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let it of this.inputNames)if(typeof re[it]>"u")throw new Error(`input '${it}' is missing in 'feeds'.`);if($e)for(let it of this.outputNames)ye[it]=null;let Ae=await this.handler.run(re,ye,ze),Be={};for(let it in Ae)if(Object.hasOwnProperty.call(Ae,it)){let ot=Ae[it];ot instanceof de?Be[it]=ot:Be[it]=new de(ot.type,ot.data,ot.dims)}return mt("InferenceSession.run"),rt(),Be}async release(){return this.handler.dispose()}static async create(re,pe,Te,ye){ft(),Nt("InferenceSession.create");let ze,$e={};if(typeof re=="string"){if(ze=re,typeof pe=="object"&&pe!==null)$e=pe;else if(typeof pe<"u")throw new TypeError("'options' must be an object.")}else if(re instanceof Uint8Array){if(ze=re,typeof pe=="object"&&pe!==null)$e=pe;else if(typeof pe<"u")throw new TypeError("'options' must be an object.")}else if(re instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&re instanceof SharedArrayBuffer){let ot=re,nt=0,Ke=re.byteLength;if(typeof pe=="object"&&pe!==null)$e=pe;else if(typeof pe=="number"){if(nt=pe,!Number.isSafeInteger(nt))throw new RangeError("'byteOffset' must be an integer.");if(nt<0||nt>=ot.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${ot.byteLength}).`);if(Ke=re.byteLength-nt,typeof Te=="number"){if(Ke=Te,!Number.isSafeInteger(Ke))throw new RangeError("'byteLength' must be an integer.");if(Ke<=0||nt+Ke>ot.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${ot.byteLength-nt}].`);if(typeof ye=="object"&&ye!==null)$e=ye;else if(typeof ye<"u")throw new TypeError("'options' must be an object.")}else if(typeof Te<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof pe<"u")throw new TypeError("'options' must be an object.");ze=new Uint8Array(ot,nt,Ke)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[Ae,Be]=await b($e),it=await Ae.createInferenceSessionHandler(ze,Be);return mt("InferenceSession.create"),rt(),new vC(it)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}}),Je,Pt=d(()=>{_i(),Je=di}),_t=d(()=>{}),hi=d(()=>{}),Se=d(()=>{}),tt=d(()=>{}),ht={};f(ht,{InferenceSession:()=>Je,TRACE:()=>Pe,TRACE_EVENT_BEGIN:()=>Nt,TRACE_EVENT_END:()=>mt,TRACE_FUNC_BEGIN:()=>ft,TRACE_FUNC_END:()=>rt,Tensor:()=>de,env:()=>R,registerBackend:()=>E});var Et=d(()=>{x(),F(),Pt(),Ie(),_t(),hi(),mi(),Se(),tt()}),gi=d(()=>{}),Jt={};f(Jt,{default:()=>un});var oi,Xt,un,wt=d(()=>{var Y;me(),Zn(),Jn(),oi="ort-wasm-proxy-worker",Xt=((Y=globalThis.self)==null?void 0:Y.name)===oi,Xt&&(self.onmessage=re=>{let{type:pe,in:Te}=re.data;try{switch(pe){case"init-wasm":or(Te.wasm).then(()=>{qo(Te).then(()=>{postMessage({type:pe})},ye=>{postMessage({type:pe,err:ye})})},ye=>{postMessage({type:pe,err:ye})});break;case"init-ep":{let{epName:ye,env:ze}=Te;Ir(ze,ye).then(()=>{postMessage({type:pe})},$e=>{postMessage({type:pe,err:$e})});break}case"copy-from":{let{buffer:ye}=Te,ze=li(ye);postMessage({type:pe,out:ze});break}case"create":{let{model:ye,options:ze}=Te;_s(ye,ze).then($e=>{postMessage({type:pe,out:$e})},$e=>{postMessage({type:pe,err:$e})});break}case"release":Kr(Te),postMessage({type:pe});break;case"run":{let{sessionId:ye,inputIndices:ze,inputs:$e,outputIndices:Ae,options:Be}=Te;qe(ye,ze,$e,Ae,new Array(Ae.length).fill(null),Be).then(it=>{it.some(ot=>ot[3]!=="cpu")?postMessage({type:pe,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:pe,out:it},gt([...$e,...it]))},it=>{postMessage({type:pe,err:it})});break}case"end-profiling":es(Te),postMessage({type:pe});break;default:}}catch(ye){postMessage({type:pe,err:ye})}}),un=Xt?null:re=>new Worker(re??ai,{type:"classic",name:oi})}),Ri,Sn,ai,Ni,zi,fs,Rn,Nn,ir,Tr,Dr,Gs,Fn,Jn=d(()=>{gi(),Ri=typeof location>"u"?void 0:location.origin,Sn=()=>{var Y,re;return typeof document<"u"?(Y=document.currentScript)==null?void 0:Y.src:typeof self<"u"?(re=self.location)==null?void 0:re.href:void 0},ai=Sn(),Ni=()=>{if(ai&&!ai.startsWith("blob:"))return ai.substring(0,ai.lastIndexOf("/")+1)},zi=(Y,re)=>{try{let pe=re??ai;return(pe?new URL(Y,pe):new URL(Y)).origin===Ri}catch{return!1}},fs=(Y,re)=>{let pe=re??ai;try{return(pe?new URL(Y,pe):new URL(Y)).href}catch{return}},Rn=(Y,re)=>`${re??"./"}${Y}`,Nn=async Y=>{let re=await(await fetch(Y,{credentials:"same-origin"})).blob();return URL.createObjectURL(re)},ir=async Y=>(await import(Y)).default,Tr=(wt(),g(Jt)).default,Dr=async()=>{if(!ai)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(zi(ai))return[void 0,Tr()];let Y=await Nn(ai);return[Y,Tr(Y)]},Gs=void 0,Fn=async(Y,re,pe,Te)=>{let ye=Gs&&!(Y||re);if(ye)if(ai)ye=zi(ai)||Te&&!pe;else if(Te&&!pe)ye=!0;else throw new Error("cannot determine the script source URL.");if(ye)return[void 0,Gs];{let ze="ort-wasm-simd-threaded.mjs",$e=Y??fs(ze,re),Ae=pe&&$e&&!zi($e,re),Be=Ae?await Nn($e):$e??Rn(ze,re);return[Ae?Be:void 0,await ir(Be)]}}}),nr,Hn,ms,Rs,ho,sr,rr,or,Gt,Zn=d(()=>{Jn(),Hn=!1,ms=!1,Rs=!1,ho=()=>{if(typeof SharedArrayBuffer>"u")return!1;try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},sr=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},rr=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},or=async Y=>{if(Hn)return Promise.resolve();if(ms)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(Rs)throw new Error("previous call to 'initializeWebAssembly()' failed.");ms=!0;let re=Y.initTimeout,pe=Y.numThreads;if(Y.simd!==!1){if(Y.simd==="relaxed"){if(!rr())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!sr())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let Te=ho();pe>1&&!Te&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+pe+", but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info."),console.warn("WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading."),Y.numThreads=pe=1);let ye=Y.wasmPaths,ze=typeof ye=="string"?ye:void 0,$e=ye==null?void 0:ye.mjs,Ae=($e==null?void 0:$e.href)??$e,Be=ye==null?void 0:ye.wasm,it=(Be==null?void 0:Be.href)??Be,ot=Y.wasmBinary,[nt,Ke]=await Fn(Ae,ze,pe>1,!!ot||!!it),jt=!1,Le=[];if(re>0&&Le.push(new Promise(dt=>{setTimeout(()=>{jt=!0,dt()},re)})),Le.push(new Promise((dt,Ii)=>{let ei={numThreads:pe};if(ot)ei.wasmBinary=ot,ei.locateFile=ti=>ti;else if(it||ze)ei.locateFile=ti=>it??ze+ti;else if(Ae&&Ae.indexOf("blob:")!==0)ei.locateFile=ti=>new URL(ti,Ae).href;else if(nt){let ti=Ni();ti&&(ei.locateFile=Pi=>ti+Pi)}Ke(ei).then(ti=>{ms=!1,Hn=!0,nr=ti,dt(),nt&&URL.revokeObjectURL(nt)},ti=>{ms=!1,Rs=!0,Ii(ti)})})),await Promise.race(Le),jt)throw new Error(`WebAssembly backend initializing failed due to timeout: ${re}ms`)},Gt=()=>{if(Hn&&nr)return nr;throw new Error("WebAssembly is not initialized yet.")}}),Xi,Di,Tt,Vr=d(()=>{Zn(),Xi=(Y,re)=>{let pe=Gt(),Te=pe.lengthBytesUTF8(Y)+1,ye=pe._malloc(Te);return pe.stringToUTF8(Y,ye,Te),re.push(ye),ye},Di=(Y,re,pe,Te)=>{if(typeof Y=="object"&&Y!==null){if(pe.has(Y))throw new Error("Circular reference in options");pe.add(Y)}Object.entries(Y).forEach(([ye,ze])=>{let $e=re?re+ye:ye;if(typeof ze=="object")Di(ze,$e+".",pe,Te);else if(typeof ze=="string"||typeof ze=="number")Te($e,ze.toString());else if(typeof ze=="boolean")Te($e,ze?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof ze}`)})},Tt=Y=>{let re=Gt(),pe=re.stackSave();try{let Te=re.PTR_SIZE,ye=re.stackAlloc(2*Te);re._OrtGetLastError(ye,ye+Te);let ze=Number(re.getValue(ye,Te===4?"i32":"i64")),$e=re.getValue(ye+Te,"*"),Ae=$e?re.UTF8ToString($e):"";throw new Error(`${Y} ERROR_CODE: ${ze}, ERROR_MESSAGE: ${Ae}`)}finally{re.stackRestore(pe)}}}),po,Ta=d(()=>{Zn(),Vr(),po=Y=>{let re=Gt(),pe=0,Te=[],ye=Y||{};try{if((Y==null?void 0:Y.logSeverityLevel)===void 0)ye.logSeverityLevel=2;else if(typeof Y.logSeverityLevel!="number"||!Number.isInteger(Y.logSeverityLevel)||Y.logSeverityLevel<0||Y.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${Y.logSeverityLevel}`);if((Y==null?void 0:Y.logVerbosityLevel)===void 0)ye.logVerbosityLevel=0;else if(typeof Y.logVerbosityLevel!="number"||!Number.isInteger(Y.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${Y.logVerbosityLevel}`);(Y==null?void 0:Y.terminate)===void 0&&(ye.terminate=!1);let ze=0;return(Y==null?void 0:Y.tag)!==void 0&&(ze=Xi(Y.tag,Te)),pe=re._OrtCreateRunOptions(ye.logSeverityLevel,ye.logVerbosityLevel,!!ye.terminate,ze),pe===0&&Tt("Can't create run options."),(Y==null?void 0:Y.extra)!==void 0&&Di(Y.extra,"",new WeakSet,($e,Ae)=>{let Be=Xi($e,Te),it=Xi(Ae,Te);re._OrtAddRunConfigEntry(pe,Be,it)!==0&&Tt(`Can't set a run config entry: ${$e} - ${Ae}.`)}),[pe,Te]}catch(ze){throw pe!==0&&re._OrtReleaseRunOptions(pe),Te.forEach($e=>re._free($e)),ze}}}),fo,mo,Vo,Mn,Da,$a,$i=d(()=>{Zn(),Vr(),fo=Y=>{switch(Y){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"layout":return 3;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${Y}`)}},mo=Y=>{switch(Y){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${Y}`)}},Vo=Y=>{Y.extra||(Y.extra={}),Y.extra.session||(Y.extra.session={});let re=Y.extra.session;re.use_ort_model_bytes_directly||(re.use_ort_model_bytes_directly="1"),Y.executionProviders&&Y.executionProviders.some(pe=>(typeof pe=="string"?pe:pe.name)==="webgpu")&&(Y.enableMemPattern=!1)},Mn=(Y,re,pe,Te)=>{let ye=Xi(re,Te),ze=Xi(pe,Te);Gt()._OrtAddSessionConfigEntry(Y,ye,ze)!==0&&Tt(`Can't set a session config entry: ${re} - ${pe}.`)},Da=async(Y,re,pe)=>{let Te=re.executionProviders;for(let ye of Te){let ze=typeof ye=="string"?ye:ye.name,$e=[];switch(ze){case"webnn":if(ze="WEBNN",Mn(Y,"session.disable_quant_qdq","1",pe),Mn(Y,"session.disable_qdq_constant_folding","1",pe),typeof ye!="string"){let nt=ye==null?void 0:ye.deviceType;nt&&Mn(Y,"deviceType",nt,pe)}break;case"webgpu":if(ze="JS",typeof ye!="string"){let nt=ye;if(nt!=null&&nt.preferredLayout){if(nt.preferredLayout!=="NCHW"&&nt.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${nt.preferredLayout}`);Mn(Y,"preferredLayout",nt.preferredLayout,pe)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${ze}`)}let Ae=Xi(ze,pe),Be=$e.length,it=0,ot=0;if(Be>0){it=Gt()._malloc(Be*Gt().PTR_SIZE),pe.push(it),ot=Gt()._malloc(Be*Gt().PTR_SIZE),pe.push(ot);for(let nt=0;nt<Be;nt++)Gt().setValue(it+nt*Gt().PTR_SIZE,$e[nt][0],"*"),Gt().setValue(ot+nt*Gt().PTR_SIZE,$e[nt][1],"*")}await Gt()._OrtAppendExecutionProvider(Y,Ae,it,ot,Be)!==0&&Tt(`Can't append execution provider: ${ze}.`)}},$a=async Y=>{let re=Gt(),pe=0,Te=[],ye=Y||{};Vo(ye);try{let ze=fo(ye.graphOptimizationLevel??"all"),$e=mo(ye.executionMode??"sequential"),Ae=typeof ye.logId=="string"?Xi(ye.logId,Te):0,Be=ye.logSeverityLevel??2;if(!Number.isInteger(Be)||Be<0||Be>4)throw new Error(`log severity level is not valid: ${Be}`);let it=ye.logVerbosityLevel??0;if(!Number.isInteger(it)||it<0||it>4)throw new Error(`log verbosity level is not valid: ${it}`);let ot=typeof ye.optimizedModelFilePath=="string"?Xi(ye.optimizedModelFilePath,Te):0;if(pe=re._OrtCreateSessionOptions(ze,!!ye.enableCpuMemArena,!!ye.enableMemPattern,$e,!!ye.enableProfiling,0,Ae,Be,it,ot),pe===0&&Tt("Can't create session options."),ye.executionProviders&&await Da(pe,ye,Te),ye.enableGraphCapture!==void 0){if(typeof ye.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${ye.enableGraphCapture}`);Mn(pe,"enableGraphCapture",ye.enableGraphCapture.toString(),Te)}if(ye.freeDimensionOverrides)for(let[nt,Ke]of Object.entries(ye.freeDimensionOverrides)){if(typeof nt!="string")throw new Error(`free dimension override name must be a string: ${nt}`);if(typeof Ke!="number"||!Number.isInteger(Ke)||Ke<0)throw new Error(`free dimension override value must be a non-negative integer: ${Ke}`);let jt=Xi(nt,Te);re._OrtAddFreeDimensionOverride(pe,jt,Ke)!==0&&Tt(`Can't set a free dimension override: ${nt} - ${Ke}.`)}return ye.extra!==void 0&&Di(ye.extra,"",new WeakSet,(nt,Ke)=>{Mn(pe,nt,Ke,Te)}),[pe,Te]}catch(ze){throw pe!==0&&re._OrtReleaseSessionOptions(pe)!==0&&Tt("Can't release session options."),Te.forEach($e=>re._free($e)),ze}}}),Wn,Zi,Un,ar,qr,$r,gs,Cn,Ft=d(()=>{Wn=Y=>{switch(Y){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;case"int4":return 22;case"uint4":return 21;default:throw new Error(`unsupported data type: ${Y}`)}},Zi=Y=>{switch(Y){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";case 22:return"int4";case 21:return"uint4";default:throw new Error(`unsupported data type: ${Y}`)}},Un=(Y,re)=>{let pe=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][Y],Te=typeof re=="number"?re:re.reduce((ye,ze)=>ye*ze,1);return pe>0?Math.ceil(Te*pe):void 0},ar=Y=>{switch(Y){case"float16":return typeof Float16Array<"u"&&Float16Array.from?Float16Array:Uint16Array;case"float32":return Float32Array;case"uint8":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"bool":return Uint8Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${Y}`)}},qr=Y=>{switch(Y){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${Y}`)}},$r=Y=>Y==="float32"||Y==="float16"||Y==="int32"||Y==="int64"||Y==="uint32"||Y==="uint8"||Y==="bool"||Y==="uint4"||Y==="int4",gs=Y=>Y==="float32"||Y==="float16"||Y==="int32"||Y==="int64"||Y==="uint32"||Y==="uint64"||Y==="int8"||Y==="uint8"||Y==="bool"||Y==="uint4"||Y==="int4",Cn=Y=>{switch(Y){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;case"ml-tensor":return 5;default:throw new Error(`unsupported data location: ${Y}`)}}}),Qi,Ar=d(()=>{gi(),Qi=async Y=>{if(typeof Y=="string"){let re=await fetch(Y);if(!re.ok)throw new Error(`failed to load external data file: ${Y}`);let pe=re.headers.get("Content-Length"),Te=pe?parseInt(pe,10):0;if(Te<1073741824)return new Uint8Array(await re.arrayBuffer());{if(!re.body)throw new Error(`failed to load external data file: ${Y}, no response body.`);let ye=re.body.getReader(),ze;try{ze=new ArrayBuffer(Te)}catch(Ae){if(Ae instanceof RangeError){let Be=Math.ceil(Te/65536);ze=new WebAssembly.Memory({initial:Be,maximum:Be}).buffer}else throw Ae}let $e=0;for(;;){let{done:Ae,value:Be}=await ye.read();if(Ae)break;let it=Be.byteLength;new Uint8Array(ze,$e,it).set(Be),$e+=it}return new Uint8Array(ze,0,Te)}}else return Y instanceof Blob?new Uint8Array(await Y.arrayBuffer()):Y instanceof Uint8Array?Y:new Uint8Array(Y)}}),vs,qo,Ir,Qn,Fs,Pr,li,_s,Kr,Ns,qe,es,gt,me=d(()=>{Et(),Ta(),$i(),Ft(),Zn(),Vr(),Ar(),vs=(Y,re)=>{Gt()._OrtInit(Y,re)!==0&&Tt("Can't initialize onnxruntime.")},qo=async Y=>{vs(Y.wasm.numThreads,qr(Y.logLevel))},Ir=async(Y,re)=>{var Te,ye;(ye=(Te=Gt()).asyncInit)==null||ye.call(Te);let pe=Y.webgpu.adapter;if(re==="webgpu"){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");if(pe){if(typeof pe.limits!="object"||typeof pe.features!="object"||typeof pe.requestDevice!="function")throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let ze=Y.webgpu.powerPreference;if(ze!==void 0&&ze!=="low-power"&&ze!=="high-performance")throw new Error(`Invalid powerPreference setting: "${ze}"`);let $e=Y.webgpu.forceFallbackAdapter;if($e!==void 0&&typeof $e!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${$e}"`);if(pe=await navigator.gpu.requestAdapter({powerPreference:ze,forceFallbackAdapter:$e}),!pe)throw new Error('Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.')}}if(re==="webnn"&&(typeof navigator>"u"||!navigator.ml))throw new Error("WebNN is not supported in current environment")},Qn=new Map,Fs=Y=>{let re=Gt(),pe=re.stackSave();try{let Te=re.PTR_SIZE,ye=re.stackAlloc(2*Te);re._OrtGetInputOutputCount(Y,ye,ye+Te)!==0&&Tt("Can't get session input/output count.");let ze=Te===4?"i32":"i64";return[Number(re.getValue(ye,ze)),Number(re.getValue(ye+Te,ze))]}finally{re.stackRestore(pe)}},Pr=(Y,re)=>{let pe=Gt(),Te=pe.stackSave(),ye=0;try{let ze=pe.PTR_SIZE,$e=pe.stackAlloc(2*ze);pe._OrtGetInputOutputMetadata(Y,re,$e,$e+ze)!==0&&Tt("Can't get session input/output metadata.");let Ae=Number(pe.getValue($e,"*"));ye=Number(pe.getValue($e+ze,"*"));let Be=pe.HEAP32[ye/4];if(Be===0)return[Ae,0];let it=pe.HEAPU32[ye/4+1],ot=[];for(let nt=0;nt<it;nt++){let Ke=Number(pe.getValue(ye+8+nt*ze,"*"));ot.push(Ke!==0?pe.UTF8ToString(Ke):Number(pe.getValue(ye+8+(nt+it)*ze,"*")))}return[Ae,Be,ot]}finally{pe.stackRestore(Te),ye!==0&&pe._OrtFree(ye)}},li=Y=>{let re=Gt(),pe=re._malloc(Y.byteLength);if(pe===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${Y.byteLength}.`);return re.HEAPU8.set(Y,pe),[pe,Y.byteLength]},_s=async(Y,re)=>{var ot,nt,Ke;let pe,Te,ye=Gt();Array.isArray(Y)?[pe,Te]=Y:Y.buffer===ye.HEAPU8.buffer?[pe,Te]=[Y.byteOffset,Y.byteLength]:[pe,Te]=li(Y);let ze=0,$e=0,Ae=[],Be=[],it=[];try{if([$e,Ae]=await $a(re),(re==null?void 0:re.externalData)&&ye.mountExternalData){let Fi=[];for(let pi of re.externalData){let kn=typeof pi=="string"?pi:pi.path;Fi.push(Qi(typeof pi=="string"?pi:pi.data).then(Vn=>{ye.mountExternalData(kn,Vn)}))}await Promise.all(Fi)}for(let Fi of(re==null?void 0:re.executionProviders)??[])if((typeof Fi=="string"?Fi:Fi.name)==="webnn"){if(ye.shouldTransferToMLTensor=!1,typeof Fi!="string"){let pi=Fi,kn=pi==null?void 0:pi.context,Vn=pi==null?void 0:pi.gpuDevice,ts=pi==null?void 0:pi.deviceType,Ia=pi==null?void 0:pi.powerPreference;kn?ye.currentContext=kn:Vn?ye.currentContext=await ye.webnnCreateMLContext(Vn):ye.currentContext=await ye.webnnCreateMLContext({deviceType:ts,powerPreference:Ia})}else ye.currentContext=await ye.webnnCreateMLContext();break}ze=await ye._OrtCreateSession(pe,Te,$e),(ot=ye.webgpuOnCreateSession)==null||ot.call(ye,ze),ze===0&&Tt("Can't create a session."),(nt=ye.jsepOnCreateSession)==null||nt.call(ye),ye.currentContext&&(ye.webnnRegisterMLContext(ze,ye.currentContext),ye.currentContext=void 0,ye.shouldTransferToMLTensor=!0);let[jt,Le]=Fs(ze),dt=!!(re!=null&&re.enableGraphCapture),Ii=[],ei=[],ti=[],Pi=[],zt=[];for(let Fi=0;Fi<jt;Fi++){let[pi,kn,Vn]=Pr(ze,Fi);pi===0&&Tt("Can't get an input name."),Be.push(pi);let ts=ye.UTF8ToString(pi);Ii.push(ts),ti.push(kn===0?{name:ts,isTensor:!1}:{name:ts,isTensor:!0,type:Zi(kn),shape:Vn})}for(let Fi=0;Fi<Le;Fi++){let[pi,kn,Vn]=Pr(ze,Fi+jt);pi===0&&Tt("Can't get an output name."),it.push(pi);let ts=ye.UTF8ToString(pi);ei.push(ts),Pi.push(kn===0?{name:ts,isTensor:!1}:{name:ts,isTensor:!0,type:Zi(kn),shape:Vn})}return Qn.set(ze,[ze,Be,it,null,dt,!1]),[ze,Ii,ei,ti,Pi]}catch(jt){throw Be.forEach(Le=>ye._OrtFree(Le)),it.forEach(Le=>ye._OrtFree(Le)),ze!==0&&ye._OrtReleaseSession(ze)!==0&&Tt("Can't release session."),jt}finally{ye._free(pe),$e!==0&&ye._OrtReleaseSessionOptions($e)!==0&&Tt("Can't release session options."),Ae.forEach(jt=>ye._free(jt)),(Ke=ye.unmountExternalData)==null||Ke.call(ye)}},Kr=Y=>{var Be,it,ot;let re=Gt(),pe=Qn.get(Y);if(!pe)throw new Error(`cannot release session. invalid session id: ${Y}`);let[Te,ye,ze,$e,Ae]=pe;$e&&(Ae&&re._OrtClearBoundOutputs($e.handle)!==0&&Tt("Can't clear bound outputs."),re._OrtReleaseBinding($e.handle)!==0&&Tt("Can't release IO binding.")),(Be=re.jsepOnReleaseSession)==null||Be.call(re,Y),(it=re.webnnOnReleaseSession)==null||it.call(re,Y),(ot=re.webgpuOnReleaseSession)==null||ot.call(re,Y),ye.forEach(nt=>re._OrtFree(nt)),ze.forEach(nt=>re._OrtFree(nt)),re._OrtReleaseSession(Te)!==0&&Tt("Can't release session."),Qn.delete(Y)},Ns=async(Y,re,pe,Te,ye,ze,$e=!1)=>{if(!Y){re.push(0);return}let Ae=Gt(),Be=Ae.PTR_SIZE,it=Y[0],ot=Y[1],nt=Y[3],Ke=nt,jt,Le;if(it==="string"&&(nt==="gpu-buffer"||nt==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if($e&&nt!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${ze} when enableGraphCapture is true.`);if(nt==="gpu-buffer"){let ei=Y[2].gpuBuffer;Le=Un(Wn(it),ot);{let ti=Ae.jsepRegisterBuffer;if(!ti)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');jt=ti(Te,ze,ei,Le)}}else if(nt==="ml-tensor"){let ei=Y[2].mlTensor;Le=Un(Wn(it),ot);let ti=Ae.webnnRegisterMLTensor;if(!ti)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');jt=ti(Te,ei,Wn(it),ot)}else{let ei=Y[2];if(Array.isArray(ei)){Le=Be*ei.length,jt=Ae._malloc(Le),pe.push(jt);for(let ti=0;ti<ei.length;ti++){if(typeof ei[ti]!="string")throw new TypeError(`tensor data at index ${ti} is not a string`);Ae.setValue(jt+ti*Be,Xi(ei[ti],pe),"*")}}else{let ti=Ae.webnnIsGraphInput,Pi=Ae.webnnIsGraphOutput;if(it!=="string"&&ti&&Pi){let zt=Ae.UTF8ToString(ye);if(ti(Te,zt)||Pi(Te,zt)){let Fi=Wn(it);Le=Un(Fi,ot),Ke="ml-tensor";let pi=Ae.webnnCreateTemporaryTensor,kn=Ae.webnnUploadTensor;if(!pi||!kn)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let Vn=await pi(Te,Fi,ot);kn(Vn,new Uint8Array(ei.buffer,ei.byteOffset,ei.byteLength)),jt=Vn}else Le=ei.byteLength,jt=Ae._malloc(Le),pe.push(jt),Ae.HEAPU8.set(new Uint8Array(ei.buffer,ei.byteOffset,Le),jt)}else Le=ei.byteLength,jt=Ae._malloc(Le),pe.push(jt),Ae.HEAPU8.set(new Uint8Array(ei.buffer,ei.byteOffset,Le),jt)}}let dt=Ae.stackSave(),Ii=Ae.stackAlloc(4*ot.length);try{ot.forEach((ti,Pi)=>Ae.setValue(Ii+Pi*Be,ti,Be===4?"i32":"i64"));let ei=Ae._OrtCreateTensor(Wn(it),jt,Le,Ii,ot.length,Cn(Ke));ei===0&&Tt(`Can't create tensor for input/output. session=${Te}, index=${ze}.`),re.push(ei)}finally{Ae.stackRestore(dt)}},qe=async(Y,re,pe,Te,ye,ze)=>{var is,ml,fc;let $e=Gt(),Ae=$e.PTR_SIZE,Be=Qn.get(Y);if(!Be)throw new Error(`cannot run inference. invalid session id: ${Y}`);let it=Be[0],ot=Be[1],nt=Be[2],Ke=Be[3],jt=Be[4];Be[5];let Le=re.length,dt=Te.length,Ii=0,ei=[],ti=[],Pi=[],zt=[],Fi=[],pi=$e.stackSave(),kn=$e.stackAlloc(Le*Ae),Vn=$e.stackAlloc(Le*Ae),ts=$e.stackAlloc(dt*Ae),Ia=$e.stackAlloc(dt*Ae);try{[Ii,ei]=po(ze),Nt("wasm prepareInputOutputTensor");for(let ui=0;ui<Le;ui++)await Ns(pe[ui],ti,zt,Y,ot[re[ui]],re[ui],jt);for(let ui=0;ui<dt;ui++)await Ns(ye[ui],Pi,zt,Y,nt[Te[ui]],Le+Te[ui],jt);mt("wasm prepareInputOutputTensor");for(let ui=0;ui<Le;ui++)$e.setValue(kn+ui*Ae,ti[ui],"*"),$e.setValue(Vn+ui*Ae,ot[re[ui]],"*");for(let ui=0;ui<dt;ui++)$e.setValue(ts+ui*Ae,Pi[ui],"*"),$e.setValue(Ia+ui*Ae,nt[Te[ui]],"*");(is=$e.jsepOnRunStart)==null||is.call($e,it),(ml=$e.webnnOnRunStart)==null||ml.call($e,it);let En;En=await $e._OrtRun(it,Vn,kn,Le,Ia,dt,ts,Ii),En!==0&&Tt("failed to call OrtRun().");let cr=[],mc=[];Nt("wasm ProcessOutputTensor");for(let ui=0;ui<dt;ui++){let Ws=Number($e.getValue(ts+ui*Ae,"*"));if(Ws===Pi[ui]||Fi.includes(Pi[ui])){cr.push(ye[ui]),Ws!==Pi[ui]&&$e._OrtReleaseTensor(Ws)!==0&&Tt("Can't release tensor.");continue}let Td=$e.stackSave(),Nr=$e.stackAlloc(4*Ae),Ko=!1,pn,ns=0;try{$e._OrtGetTensorData(Ws,Nr,Nr+Ae,Nr+2*Ae,Nr+3*Ae)!==0&&Tt(`Can't access output tensor data on index ${ui}.`);let gl=Ae===4?"i32":"i64",ss=Number($e.getValue(Nr,gl));ns=$e.getValue(Nr+Ae,"*");let gc=$e.getValue(Nr+Ae*2,"*"),Dd=Number($e.getValue(Nr+Ae*3,gl)),Mr=[];for(let fn=0;fn<Dd;fn++)Mr.push(Number($e.getValue(gc+fn*Ae,gl)));$e._OrtFree(gc)!==0&&Tt("Can't free memory for tensor dims.");let Us=Mr.reduce((fn,Ji)=>fn*Ji,1);pn=Zi(ss);let dr=Ke==null?void 0:Ke.outputPreferredLocations[Te[ui]];if(pn==="string"){if(dr==="gpu-buffer"||dr==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let fn=[];for(let Ji=0;Ji<Us;Ji++){let Vs=$e.getValue(ns+Ji*Ae,"*"),vc=$e.getValue(ns+(Ji+1)*Ae,"*"),_c=Ji===Us-1?void 0:vc-Vs;fn.push($e.UTF8ToString(Vs,_c))}cr.push([pn,Mr,fn,"cpu"])}else if(dr==="gpu-buffer"&&Us>0){let fn=$e.jsepGetBuffer;if(!fn)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let Ji=fn(ns),Vs=Un(ss,Us);if(Vs===void 0||!$r(pn))throw new Error(`Unsupported data type: ${pn}`);Ko=!0,cr.push([pn,Mr,{gpuBuffer:Ji,download:$e.jsepCreateDownloader(Ji,Vs,pn),dispose:()=>{$e._OrtReleaseTensor(Ws)!==0&&Tt("Can't release tensor.")}},"gpu-buffer"])}else if(dr==="ml-tensor"&&Us>0){let fn=$e.webnnEnsureTensor,Ji=$e.webnnIsGraphInputOutputTypeSupported;if(!fn||!Ji)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(Un(ss,Us)===void 0||!gs(pn))throw new Error(`Unsupported data type: ${pn}`);if(!Ji(Y,pn,!1))throw new Error(`preferredLocation "ml-tensor" for ${pn} output is not supported by current WebNN Context.`);let Vs=await fn(Y,ns,ss,Mr,!1);Ko=!0,cr.push([pn,Mr,{mlTensor:Vs,download:$e.webnnCreateMLTensorDownloader(ns,pn),dispose:()=>{$e.webnnReleaseTensorId(ns),$e._OrtReleaseTensor(Ws)}},"ml-tensor"])}else if(dr==="ml-tensor-cpu-output"&&Us>0){let fn=$e.webnnCreateMLTensorDownloader(ns,pn)(),Ji=cr.length;Ko=!0,mc.push((async()=>{let Vs=[Ji,await fn];return $e.webnnReleaseTensorId(ns),$e._OrtReleaseTensor(Ws),Vs})()),cr.push([pn,Mr,[],"cpu"])}else{let fn=ar(pn),Ji=new fn(Us);new Uint8Array(Ji.buffer,Ji.byteOffset,Ji.byteLength).set($e.HEAPU8.subarray(ns,ns+Ji.byteLength)),cr.push([pn,Mr,Ji,"cpu"])}}finally{$e.stackRestore(Td),pn==="string"&&ns&&$e._free(ns),Ko||$e._OrtReleaseTensor(Ws)}}Ke&&!jt&&($e._OrtClearBoundOutputs(Ke.handle)!==0&&Tt("Can't clear bound outputs."),Qn.set(Y,[it,ot,nt,Ke,jt,!1]));for(let[ui,Ws]of await Promise.all(mc))cr[ui][2]=Ws;return mt("wasm ProcessOutputTensor"),cr}finally{(fc=$e.webnnOnRunEnd)==null||fc.call($e,it),$e.stackRestore(pi),ti.forEach(En=>$e._OrtReleaseTensor(En)),Pi.forEach(En=>$e._OrtReleaseTensor(En)),zt.forEach(En=>$e._free(En)),Ii!==0&&$e._OrtReleaseRunOptions(Ii),ei.forEach(En=>$e._free(En))}},es=Y=>{let re=Gt(),pe=Qn.get(Y);if(!pe)throw new Error("invalid session id");let Te=pe[0],ye=re._OrtEndProfiling(Te);ye===0&&Tt("Can't get an profile file name."),re._OrtFree(ye)},gt=Y=>{let re=[];for(let pe of Y){let Te=pe[2];!Array.isArray(Te)&&"buffer"in Te&&re.push(Te.buffer)}return re}}),Ne,Ze,$t,ni,ci,Bi,Mi,ln,Vi,hn,Oi,Hs,Yr,go,lr,Ed,vo,_o,uc=d(()=>{Et(),me(),Zn(),Jn(),Ne=()=>!!R.wasm.proxy&&typeof document<"u",$t=!1,ni=!1,ci=!1,ln=new Map,Vi=(Y,re)=>{let pe=ln.get(Y);pe?pe.push(re):ln.set(Y,[re])},hn=()=>{if($t||!ni||ci||!Ze)throw new Error("worker not ready")},Oi=Y=>{switch(Y.data.type){case"init-wasm":$t=!1,Y.data.err?(ci=!0,Mi[1](Y.data.err)):(ni=!0,Mi[0]()),Bi&&(URL.revokeObjectURL(Bi),Bi=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let re=ln.get(Y.data.type);Y.data.err?re.shift()[1](Y.data.err):re.shift()[0](Y.data.out);break}}},Hs=async()=>{if(!ni){if($t)throw new Error("multiple calls to 'initWasm()' detected.");if(ci)throw new Error("previous call to 'initWasm()' failed.");if($t=!0,Ne())return new Promise((Y,re)=>{Ze==null||Ze.terminate(),Dr().then(([pe,Te])=>{try{Ze=Te,Ze.onerror=ze=>re(ze),Ze.onmessage=Oi,Mi=[Y,re];let ye={type:"init-wasm",in:R};if(!ye.in.wasm.wasmPaths&&pe){let ze=Ni();ze&&(ye.in.wasm.wasmPaths=ze)}Ze.postMessage(ye),Bi=pe}catch(ye){re(ye)}},re)});try{await or(R.wasm),await qo(R),ni=!0}catch(Y){throw ci=!0,Y}finally{$t=!1}}},Yr=async Y=>{if(Ne())return hn(),new Promise((re,pe)=>{Vi("init-ep",[re,pe]);let Te={type:"init-ep",in:{epName:Y,env:R}};Ze.postMessage(Te)});await Ir(R,Y)},go=async Y=>Ne()?(hn(),new Promise((re,pe)=>{Vi("copy-from",[re,pe]);let Te={type:"copy-from",in:{buffer:Y}};Ze.postMessage(Te,[Y.buffer])})):li(Y),lr=async(Y,re)=>{if(Ne()){if(re!=null&&re.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return hn(),new Promise((pe,Te)=>{Vi("create",[pe,Te]);let ye={type:"create",in:{model:Y,options:{...re}}},ze=[];Y instanceof Uint8Array&&ze.push(Y.buffer),Ze.postMessage(ye,ze)})}else return _s(Y,re)},Ed=async Y=>{if(Ne())return hn(),new Promise((re,pe)=>{Vi("release",[re,pe]);let Te={type:"release",in:Y};Ze.postMessage(Te)});Kr(Y)},vo=async(Y,re,pe,Te,ye,ze)=>{if(Ne()){if(pe.some($e=>$e[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(ye.some($e=>$e))throw new Error("pre-allocated output tensor is not supported for proxy.");return hn(),new Promise(($e,Ae)=>{Vi("run",[$e,Ae]);let Be=pe,it={type:"run",in:{sessionId:Y,inputIndices:re,inputs:Be,outputIndices:Te,options:ze}};Ze.postMessage(it,gt(Be))})}else return qe(Y,re,pe,Te,ye,ze)},_o=async Y=>{if(Ne())return hn(),new Promise((re,pe)=>{Vi("end-profiling",[re,pe]);let Te={type:"end-profiling",in:Y};Ze.postMessage(Te)});es(Y)}}),ul,bo,Aa,hl=d(()=>{Et(),uc(),Ft(),gi(),Ar(),ul=(Y,re)=>{switch(Y.location){case"cpu":return[Y.type,Y.dims,Y.data,"cpu"];case"gpu-buffer":return[Y.type,Y.dims,{gpuBuffer:Y.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[Y.type,Y.dims,{mlTensor:Y.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${Y.location} for ${re()}`)}},bo=Y=>{switch(Y[3]){case"cpu":return new de(Y[0],Y[2],Y[1]);case"gpu-buffer":{let re=Y[0];if(!$r(re))throw new Error(`not supported data type: ${re} for deserializing GPU tensor`);let{gpuBuffer:pe,download:Te,dispose:ye}=Y[2];return de.fromGpuBuffer(pe,{dataType:re,dims:Y[1],download:Te,dispose:ye})}case"ml-tensor":{let re=Y[0];if(!gs(re))throw new Error(`not supported data type: ${re} for deserializing MLTensor tensor`);let{mlTensor:pe,download:Te,dispose:ye}=Y[2];return de.fromMLTensor(pe,{dataType:re,dims:Y[1],download:Te,dispose:ye})}default:throw new Error(`invalid data location: ${Y[3]}`)}},Aa=class{async fetchModelAndCopyToWasmMemory(Y){return go(await Qi(Y))}async loadModel(Y,re){ft();let pe;typeof Y=="string"?pe=await this.fetchModelAndCopyToWasmMemory(Y):pe=Y,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await lr(pe,re),rt()}async dispose(){return Ed(this.sessionId)}async run(Y,re,pe){ft();let Te=[],ye=[];Object.entries(Y).forEach(nt=>{let Ke=nt[0],jt=nt[1],Le=this.inputNames.indexOf(Ke);if(Le===-1)throw new Error(`invalid input '${Ke}'`);Te.push(jt),ye.push(Le)});let ze=[],$e=[];Object.entries(re).forEach(nt=>{let Ke=nt[0],jt=nt[1],Le=this.outputNames.indexOf(Ke);if(Le===-1)throw new Error(`invalid output '${Ke}'`);ze.push(jt),$e.push(Le)});let Ae=Te.map((nt,Ke)=>ul(nt,()=>`input "${this.inputNames[ye[Ke]]}"`)),Be=ze.map((nt,Ke)=>nt?ul(nt,()=>`output "${this.outputNames[$e[Ke]]}"`):null),it=await vo(this.sessionId,ye,Ae,$e,Be,pe),ot={};for(let nt=0;nt<it.length;nt++)ot[this.outputNames[$e[nt]]]=ze[nt]??bo(it[nt]);return rt(),ot}startProfiling(){}endProfiling(){_o(this.sessionId)}}}),jr={};f(jr,{OnnxruntimeWebAssemblyBackend:()=>Rr,initializeFlags:()=>Xr,wasmBackend:()=>wo});var Xr,Rr,wo,hc=d(()=>{Et(),uc(),hl(),Xr=()=>{(typeof R.wasm.initTimeout!="number"||R.wasm.initTimeout<0)&&(R.wasm.initTimeout=0);let Y=R.wasm.simd;if(typeof Y!="boolean"&&Y!==void 0&&Y!=="fixed"&&Y!=="relaxed"&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${Y}". Reset it to \`false\` and ignore SIMD feature checking.`),R.wasm.simd=!1),typeof R.wasm.proxy!="boolean"&&(R.wasm.proxy=!1),typeof R.wasm.trace!="boolean"&&(R.wasm.trace=!1),typeof R.wasm.numThreads!="number"||!Number.isInteger(R.wasm.numThreads)||R.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)R.wasm.numThreads=1;else{let re=typeof navigator>"u"?a("node:os").cpus().length:navigator.hardwareConcurrency;R.wasm.numThreads=Math.min(4,Math.ceil((re||1)/2))}},Rr=class{async init(Y){Xr(),await Hs(),await Yr(Y)}async createInferenceSessionHandler(Y,re){let pe=new Aa;return await pe.loadModel(Y,re),pe}},wo=new Rr}),pc={};f(pc,{InferenceSession:()=>Je,TRACE:()=>Pe,TRACE_EVENT_BEGIN:()=>Nt,TRACE_EVENT_END:()=>mt,TRACE_FUNC_BEGIN:()=>ft,TRACE_FUNC_END:()=>rt,Tensor:()=>de,default:()=>fl,env:()=>R,registerBackend:()=>E}),Et(),Et(),Et();var pl="1.26.0",fl=ht;{let Y=(hc(),g(jr)).wasmBackend;E("cpu",Y,10),E("wasm",Y,10)}return Object.defineProperty(R.versions,"web",{value:pl,enumerable:!0}),g(pc)})();i.exports=t})(T_)),T_.exports}var Lx;function _D(){return Lx||(Lx=1,(function(i){var e=el&&el.__createBinding||(Object.create?(function(S,T,j,N){N===void 0&&(N=j);var L=Object.getOwnPropertyDescriptor(T,j);(!L||("get"in L?!T.__esModule:L.writable||L.configurable))&&(L={enumerable:!0,get:function(){return T[j]}}),Object.defineProperty(S,N,L)}):(function(S,T,j,N){N===void 0&&(N=j),S[N]=T[j]})),t=el&&el.__setModuleDefault||(Object.create?(function(S,T){Object.defineProperty(S,"default",{enumerable:!0,value:T})}):function(S,T){S.default=T}),n=el&&el.__importStar||function(S){if(S&&S.__esModule)return S;var T={};if(S!=null)for(var j in S)j!=="default"&&Object.prototype.hasOwnProperty.call(S,j)&&e(T,S,j);return t(T,S),T};Object.defineProperty(i,"__esModule",{value:!0}),i.MicVAD=i.getDefaultRealTimeVADOptions=i.ort=i.DEFAULT_MODEL=void 0;const r=n(vD()),l=Gw(),p=Fw(),a=pm(),d=qv(),f=mC(),m=gC();i.DEFAULT_MODEL="legacy",i.ort=r;const g="vad.worklet.bundle.min.js",y="silero_vad_v5.onnx",D="silero_vad_legacy.onnx",E=S=>({...p.defaultFrameProcessorOptions,onFrameProcessed:()=>{},onVADMisfire:()=>{a.log.debug("VAD misfire")},onSpeechStart:()=>{a.log.debug("Detected speech start")},onSpeechEnd:()=>{a.log.debug("Detected speech end")},onSpeechRealStart:()=>{a.log.debug("Detected real speech start")},baseAssetPath:"./",onnxWASMBasePath:"./",model:S,workletOptions:{},getStream:async()=>await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),pauseStream:async T=>{T.getTracks().forEach(j=>{j.stop()})},resumeStream:async()=>await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),ortConfig:T=>{T.env.logLevel="error"},startOnLoad:!0,processorType:"auto"});i.getDefaultRealTimeVADOptions=E;const C=S=>"audioWorklet"in S&&typeof AudioWorkletNode=="function"?"AudioWorklet":"ScriptProcessor";async function b(S,T,j,N,L){await j.audioWorklet.addModule(S),T.processorOptions={...T.processorOptions??{},frameSamples:N};const R=new AudioWorkletNode(j,"vad-helper-worklet",T);return R.port.onmessage=async F=>{const V=F.data;if(!(typeof V=="object"&&V&&"message"in V)){console.error("Invalid message event",V);return}switch(V.message){case d.Message.AudioFrame:{if(!("data"in V&&V.data instanceof ArrayBuffer)){console.log("Audio frame message has no data");return}const te=new Float32Array(V.data);await L(te);break}}},R}async function w(S,T,j){const N=new m.Resampler({nativeSampleRate:S.sampleRate,targetSampleRate:16e3,targetFrameSize:T});a.log.debug("using script processor");const R=S.createScriptProcessor(4096,1,1);let F=!1;return R.onaudioprocess=async V=>{if(!F){F=!0;try{const te=V.inputBuffer.getChannelData(0);V.outputBuffer.getChannelData(0).fill(0);const ee=N.process(te);for(const we of ee)await j(we)}catch(te){console.error("Error processing audio:",te)}finally{F=!1}}},R.connect(S.destination),R}class x{constructor(T,j,N,L,R=!1,F=null,V=null,te=null,he=null,ee=null,we=null,ce="uninitialized",ve=!1){this.options=T,this.frameProcessor=j,this.model=N,this.frameSamples=L,this.listening=R,this.errored=F,this._stream=V,this._audioContext=te,this._vadNode=he,this._mediaStreamAudioSourceNode=ee,this._audioProcessorAdapterType=we,this.initializationState=ce,this.ownsAudioContext=ve,this.getAudioInstances=()=>{if(this._stream===null||this._audioContext===null||this._vadNode==null||this._mediaStreamAudioSourceNode==null)throw new Error("MicVAD has null stream, audio context, or processor adapter");return{stream:this._stream,audioContext:this._audioContext,vadNode:this._vadNode,mediaStreamAudioSourceNode:this._mediaStreamAudioSourceNode}},this.setErrored=Ee=>{this.initializationState="errored",this.errored=Ee},this.start=async()=>{switch(this.initializationState){case"uninitialized":{a.log.debug("initializing micVAD"),this.initializationState="initializing",this.frameProcessor.resume();try{this._stream=await this.options.getStream()}catch(Ee){throw Ee instanceof Error?this.setErrored(Ee.message):this.setErrored(String(Ee)),Ee}if(this.options.audioContext?(console.log("using custom audio context"),this._audioContext=this.options.audioContext):(console.log("using default audio context"),this._audioContext=new AudioContext,this.ownsAudioContext=!0),!this._audioContext)throw this.setErrored("Audio context is null"),Error("Audio context is null");switch(this._audioProcessorAdapterType=this.options.processorType=="auto"?C(this._audioContext):this.options.processorType,this._audioProcessorAdapterType){case"AudioWorklet":this._vadNode=await b(this.options.baseAssetPath+g,this.options.workletOptions,this._audioContext,this.frameSamples,this.processFrame);break;case"ScriptProcessor":this._vadNode=await w(this._audioContext,this.frameSamples,this.processFrame);break;default:throw new Error(`Unsupported audio processor adapter type: ${this._audioProcessorAdapterType}`)}this._mediaStreamAudioSourceNode=new MediaStreamAudioSourceNode(this._audioContext,{mediaStream:this._stream}),this._mediaStreamAudioSourceNode.connect(this._vadNode),a.log.debug("started micVAD"),this.listening=!0,this.initializationState="initialized";break}case"initializing":{a.log.warn("start called while initializing");break}case"initialized":{if(this.listening)return;this.listening=!0,this.frameProcessor.resume();const{stream:Ee,audioContext:fe,vadNode:U}=this.getAudioInstances();this._stream=await this.options.resumeStream(Ee);const X=new MediaStreamAudioSourceNode(fe,{mediaStream:this._stream});this._mediaStreamAudioSourceNode=X,X.connect(U);break}case"destroyed":{a.log.warn("start called after destroyed");break}case"errored":{a.log.error("start called after errored");break}default:{a.log.warn("weird initialization state");break}}},this.pause=async()=>{if(!this.listening)return;this.listening=!1;const{stream:Ee,mediaStreamAudioSourceNode:fe}=this.getAudioInstances();await this.options.pauseStream(Ee),fe.disconnect(),this.frameProcessor.pause(this.handleFrameProcessorEvent)},this.destroy=async()=>{var fe;a.log.debug("destroy called"),this.initializationState="destroyed";const{vadNode:Ee}=this.getAudioInstances();Ee instanceof AudioWorkletNode&&Ee.port.postMessage(d.Message.SpeechStop),this.listening&&await this.pause(),await this.model.release(),this.ownsAudioContext&&await((fe=this._audioContext)==null?void 0:fe.close())},this.setOptions=Ee=>{this.frameProcessor.setOptions(Ee)},this.processFrame=async Ee=>{await this.frameProcessor.process(Ee,this.handleFrameProcessorEvent)},this.handleFrameProcessorEvent=Ee=>{switch(Ee.msg){case d.Message.FrameProcessed:this.options.onFrameProcessed(Ee.probs,Ee.frame);break;case d.Message.SpeechStart:this.options.onSpeechStart();break;case d.Message.SpeechRealStart:this.options.onSpeechRealStart();break;case d.Message.VADMisfire:this.options.onVADMisfire();break;case d.Message.SpeechEnd:this.options.onSpeechEnd(Ee.audio);break}}}static async new(T={}){const j={...(0,i.getDefaultRealTimeVADOptions)(T.model??i.DEFAULT_MODEL),...T};(0,p.validateOptions)(j),i.ort.env.wasm.wasmPaths=j.onnxWASMBasePath,j.ortConfig!==void 0&&j.ortConfig(i.ort);const N=j.model==="v5"?y:D,L=j.baseAssetPath+N,R=j.model==="v5"?f.SileroV5.new:f.SileroLegacy.new;let F;try{F=await R(i.ort,()=>(0,l.defaultModelFetcher)(L))}catch(we){throw console.error(`Encountered an error while loading model file ${L}`),we}const V=j.model==="v5"?512:1536,te=V/16,he=new p.FrameProcessor(F.process,F.reset_state,{positiveSpeechThreshold:j.positiveSpeechThreshold,negativeSpeechThreshold:j.negativeSpeechThreshold,redemptionMs:j.redemptionMs,preSpeechPadMs:j.preSpeechPadMs,minSpeechMs:j.minSpeechMs,submitUserSpeechOnPause:j.submitUserSpeechOnPause},te),ee=new x(j,he,F,V);if(j.startOnLoad)try{await ee.start()}catch(we){throw console.error("Error starting micVad",we),we}return ee}}i.MicVAD=x})(el)),el}var zx;function bD(){return zx||(zx=1,(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.getDefaultRealTimeVADOptions=i.MicVAD=i.DEFAULT_MODEL=i.utils=i.NonRealTimeVAD=i.Message=i.FrameProcessor=i.defaultModelFetcher=i.baseAssetPath=void 0;var e=hC();Object.defineProperty(i,"baseAssetPath",{enumerable:!0,get:function(){return e.baseAssetPath}});var t=Gw();Object.defineProperty(i,"defaultModelFetcher",{enumerable:!0,get:function(){return t.defaultModelFetcher}});var n=Fw();Object.defineProperty(i,"FrameProcessor",{enumerable:!0,get:function(){return n.FrameProcessor}});var r=qv();Object.defineProperty(i,"Message",{enumerable:!0,get:function(){return r.Message}});var l=mD();Object.defineProperty(i,"NonRealTimeVAD",{enumerable:!0,get:function(){return l.NonRealTimeVAD}});const p=gD();i.utils={audioFileToArray:p.audioFileToArray,minFramesForTargetMS:p.minFramesForTargetMS,arrayBufferToBase64:p.arrayBufferToBase64,encodeWAV:p.encodeWAV};var a=_D();Object.defineProperty(i,"DEFAULT_MODEL",{enumerable:!0,get:function(){return a.DEFAULT_MODEL}}),Object.defineProperty(i,"MicVAD",{enumerable:!0,get:function(){return a.MicVAD}}),Object.defineProperty(i,"getDefaultRealTimeVADOptions",{enumerable:!0,get:function(){return a.getDefaultRealTimeVADOptions}})})(C_)),C_}var wD=bD();function kg(i,e,t,n,r){var p,a;try{(a=(p=window.api)==null?void 0:p.logs)==null||a.write(i,e,t,n,r)}catch{}const l=e==="error"?console.error:e==="warn"?console.warn:console.log;n!==void 0?l(`[${i}]`,t,n):l(`[${i}]`,t)}const ut={debug:(i,e,t)=>kg(i,"debug",e,t),info:(i,e,t)=>kg(i,"info",e,t),warn:(i,e,t)=>kg(i,"warn",e,t),error:(i,e,t,n)=>kg(i,"error",e,t,n)},_C=16e3,yD=6,ch=_C*yD,xD=400,SD=_C*xD/1e3,Bx=300,Gx=2e3,Fx=1500,Hx=3e3,CD=600,bC=.5,wC=.35,Wx=.85,Ux=.7;let Sr=null,Sa=!1,er=!1;const $b=new Set;function Eg(i){for(const e of Array.from($b))try{e(i)}catch(t){ut.warn("speech","workerDeath listener threw",{error:t instanceof Error?t.message:String(t)})}}let D_=0;const Vx=2;let bh=!1,yC=!1;function xC(i){i.addEventListener("message",e=>{var n;if(((n=e.data)==null?void 0:n.type)!=="log")return;const t=e.data.level||"info";ut[t]("whisperWorker",e.data.message??"",e.data.meta)}),i.addEventListener("error",e=>{ut.error("whisperWorker","worker error event (fatal)",{message:e.message,filename:e.filename,lineno:e.lineno}),kD(`error:${e.message||"unknown"}`)})}function Tv(){return Sr||(Sr=new Worker(new URL(""+new URL("whisperWorker-C7ZGQwKg.js",import.meta.url).href,import.meta.url),{type:"module"}),xC(Sr),ut.info("speech","worker spawned"),Sr)}let Tg=!1;function kD(i){if(!bh){if(Tg){ut.warn("speech","respawnWorker: already in flight, ignoring",{reason:i});return}if(Tg=!0,D_+=1,yC=!0,ut.warn("speech","respawnWorker: starting",{reason:i,attempt:D_}),Eg({reason:i,respawned:!1,finalOnly:!0}),D_>Vx){if(bh=!0,ut.error("speech","respawnWorker: limit exceeded, disabling speech",{limit:Vx}),Sr)try{Sr.terminate()}catch{}Sr=null,Sa=!1,er=!1,Eg({reason:"respawn-limit-exceeded",respawned:!1,finalOnly:!0}),Tg=!1;return}if(Sr)try{Sr.terminate()}catch{}Sr=null,Sa=!1,er=!1;try{Sr=new Worker(new URL(""+new URL("whisperWorker-C7ZGQwKg.js",import.meta.url).href,import.meta.url),{type:"module"}),xC(Sr),er=!0,Sr.postMessage({type:"load"}),ut.info("speech","respawnWorker: new worker spawned, load posted"),Eg({reason:i,respawned:!0,finalOnly:!0})}catch(e){bh=!0,ut.error("speech","respawnWorker: spawn failed, disabling speech",{error:e instanceof Error?e.message:String(e)}),Eg({reason:"spawn-failed",respawned:!1,finalOnly:!0})}finally{Tg=!1}}}function ED(i,e){if(Sa||er)return;er=!0;const t=Tv();ut.info("speech","preloadModel: posting load");const n=r=>{r.data.type==="status"?(i==null||i(r.data.status,r.data.message),r.data.status==="ready"&&(Sa=!0,er=!1,ut.info("speech","preloadModel: ready"),t.removeEventListener("message",n))):r.data.type==="progress"?e==null||e(r.data.pct):r.data.type==="error"&&(er=!1,ut.error("speech","preloadModel: worker reported error",{error:r.data.error}),i==null||i("error",r.data.error),t.removeEventListener("message",n))};t.addEventListener("message",n),t.postMessage({type:"load"})}function TD(){ut.info("speech","resetModel: clearing load flags"),Sa=!1,er=!1}function Kv(){var i;return typeof Worker<"u"&&!!((i=navigator.mediaDevices)!=null&&i.getUserMedia)&&typeof AudioWorkletNode<"u"}function DD(i){const e=Tv();return!Sa&&!er&&(er=!0,e.postMessage({type:"load"})),new Promise((t,n)=>{const r=l=>{var p,a,d;((p=l.data)==null?void 0:p.type)==="result"?(e.removeEventListener("message",r),t((l.data.text??"").trim())):((a=l.data)==null?void 0:a.type)==="error"?(e.removeEventListener("message",r),n(new Error(String(l.data.error??"Transcription failed")))):((d=l.data)==null?void 0:d.type)==="status"&&l.data.status==="ready"&&(Sa=!0,er=!1)};e.addEventListener("message",r),e.postMessage({type:"transcribe",audio:i},[i.buffer])})}function SC(i){let e=Tv(),t=!1,n=null,r=null,l=null,p=null,a=null;const d=[],f=new Set;let m=null,g=0,y=!1,D=0,E=!1,C=!1,b=0,w=0,x=0,S=-1,T=Bx,j=0,N=null,L="",R="",F=!1,V=0;function te(oe,Ce){const Oe=Math.min(oe.length,Ce.length);let Xe=0;for(;Xe<Oe&&oe.charCodeAt(Xe)===Ce.charCodeAt(Xe);)Xe++;return Xe}function he(oe){const Ce=te(L,oe);return L=oe,Ce>R.length&&(R=oe.slice(0,Ce)),R.length>oe.length&&(R=oe),R}const ee=()=>(m||(m=new Float32Array(ch)),m),we=()=>{g=0},ce=oe=>{const Ce=ee(),Oe=oe.length;if(Oe>=ch){Ce.set(oe.subarray(Oe-ch)),g=ch;return}if(g+Oe<=ch){Ce.set(oe,g),g+=Oe;return}const Xe=g+Oe-ch;Ce.copyWithin(0,Xe,g),g-=Xe,Ce.set(oe,g),g+=Oe},ve=()=>{N&&(clearTimeout(N),N=null)},Ee=()=>{ve(),y=!1,E=!1,C=!1,T=Bx,L="",R="",F=!1,V=0,we()},fe=()=>{if(t||!y||C||E||N)return;if(g<SD){N=setTimeout(()=>{N=null,fe()},T);return}const oe=performance.now()-b;if(oe<T&&b!==0){N=setTimeout(()=>{N=null,fe()},T-oe);return}if(yC||bh||i.partialsEnabled&&!i.partialsEnabled())return;const Ce=ee(),Oe=new Float32Array(g);Oe.set(Ce.subarray(0,g)),w+=1,x=w,E=!0,j=performance.now(),b=j,e.postMessage({type:"transcribe-partial",audio:Oe,seq:w},[Oe.buffer])},U=oe=>oe.length===0?Promise.resolve():bh?(ut.warn("speech","transcribeAudio: speech disabled (worker respawn limit hit)"),t||i.onError("Speech recognition disabled — please reload the app."),Promise.resolve()):new Promise(Ce=>{d.push(Ce),w+=1;const Oe=w;S=Oe,e.postMessage({type:"transcribe",audio:oe,seq:Oe},[oe.buffer])}),X=oe=>{const Ce=U(oe);return f.add(Ce),Ce.finally(()=>{f.delete(Ce)}),Ce},W=oe=>{var Ce,Oe,Xe,ge,J;if(oe.data.type==="result"){const je=oe.data.text,de=oe.data.seq??0;de&&de<S&&ut.warn("speech","result: seq below latestFinalSeq (delivering anyway)",{seq:de,latestFinalSeq:S}),!t&&je&&i.onFinal(je),(Ce=d.shift())==null||Ce()}else if(oe.data.type==="partial"){const je=oe.data.seq??0,de=oe.data.text??"",Ie=performance.now()-j;E=!1,Ie>=Hx?(C=!0,ut.warn("speech","partials.disabled.budget",{elapsedMs:Math.round(Ie),seq:je})):Ie>=Fx&&(T=Math.min(T*2,Gx),ut.warn("speech","partials.slowdown",{elapsedMs:Math.round(Ie),newIntervalMs:T,seq:je})),F||(F=!0,Ie>CD&&T<500&&(T=500,ut.info("speech","partials.probe.slow_host",{elapsedMs:Math.round(Ie),newIntervalMs:500})));const Pe=je!==x||je<=S;if(!t&&!Pe&&de){const Ye=he(de);Ye&&((Oe=i.onPartial)==null||Oe.call(i,Ye),V===0&&(V=performance.now(),ut.info("speech","partial.first",{msSinceSpeechStart:Math.round(V-D)})))}fe()}else if(oe.data.type==="partial-error"){const je=performance.now()-j;E=!1,je>=Hx?(C=!0,ut.warn("speech","partials.disabled.budget (after error)",{elapsedMs:Math.round(je),seq:oe.data.seq})):je>=Fx&&(T=Math.min(T*2,Gx),ut.warn("speech","partials.slowdown (after error)",{elapsedMs:Math.round(je),newIntervalMs:T,seq:oe.data.seq})),ut.warn("speech","partial encode failed",{error:oe.data.error,seq:oe.data.seq}),fe()}else oe.data.type==="error"?(t||i.onError(oe.data.error),(Xe=d.shift())==null||Xe()):oe.data.type==="status"?(t||(ge=i.onModelStatus)==null||ge.call(i,oe.data.status,oe.data.message),oe.data.status==="ready"&&(Sa=!0,er=!1)):oe.data.type==="progress"&&(t||(J=i.onProgress)==null||J.call(i,oe.data.pct))};e.addEventListener("message",W);const Q=oe=>{var Ce,Oe;if(!t){for(ut.warn("speech","createRecognition: worker death event",oe),(Ce=i.onStatusChange)==null||Ce.call(i,"restarting");d.length;)(Oe=d.shift())==null||Oe();if(f.clear(),ve(),E=!1,oe.respawned){try{e.removeEventListener("message",W)}catch{}e=Tv(),e.addEventListener("message",W)}}};return $b.add(Q),{start:async()=>{if(!t){if(bh){i.onError("Speech recognition disabled — please reload the app.");return}!Sa&&!er&&(er=!0,ut.info("speech","createRecognition.start: triggering model load"),e.postMessage({type:"load"})),ut.info("speech","createRecognition.start: initializing VAD",{modelReady:Sa,modelLoading:er});try{const oe=new URL("vad/",document.baseURI).href;ut.info("speech","vad: asset base resolved",{vadBase:oe}),dD();const Ce=i.inputDeviceId||null,Oe={channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0};Ce&&(Oe.deviceId={exact:Ce}),ut.info("speech","getUserMedia",{hasDeviceId:!!Ce,deviceIdPrefix:Ce?Ce.slice(0,8):null});const Xe=await navigator.mediaDevices.getUserMedia({audio:Oe});r=Xe,l=new AudioContext;for(const ge of Xe.getAudioTracks())ge.addEventListener("ended",()=>{t||(ut.warn("speech","mic track ended (permission revoked or device removed)"),i.onError("Microphone disconnected or permission revoked"))});try{a=l.createMediaStreamSource(r),p=l.createAnalyser(),p.fftSize=2048,p.smoothingTimeConstant=.3,a.connect(p)}catch(ge){ut.warn("speech","analyser init failed",{error:ge instanceof Error?ge.message:String(ge)}),a=null,p=null}n=await wD.MicVAD.new({audioContext:l,getStream:async()=>Xe,resumeStream:async()=>Xe,pauseStream:async()=>{},baseAssetPath:oe,onnxWASMBasePath:oe,model:"v5",positiveSpeechThreshold:bC,negativeSpeechThreshold:wC,minSpeechMs:300,redemptionMs:1500,preSpeechPadMs:300,submitUserSpeechOnPause:!0,onFrameProcessed:(ge,J)=>{var je;t||((je=i.onFrame)==null||je.call(i,ge),y&&(ce(J),fe()))},onSpeechStart:()=>{var ge;t||(Ee(),y=!0,D=performance.now(),(ge=i.onSpeechStart)==null||ge.call(i))},onSpeechEnd:ge=>{var J;t||((J=i.onStatusChange)==null||J.call(i,"transcribing"),Ee(),X(ge))},onVADMisfire:()=>{var ge,J;t||((ge=i.onStatusChange)==null||ge.call(i,"idle"),Ee(),(J=i.onMisfire)==null||J.call(i))}}),ut.info("speech","vad: ort wasm files loaded",{files:cD()}),n.start()}catch(oe){const Ce=oe instanceof Error?oe.message:"Microphone access denied",Oe=oe instanceof Error?oe.stack:"";if(ut.error("speech","createRecognition.start: VAD init failed",{error:Ce,stack:Oe}),p){try{p.disconnect()}catch{}p=null}if(a){try{a.disconnect()}catch{}a=null}if(r){try{r.getTracks().forEach(Xe=>Xe.stop())}catch{}r=null}if(l){try{await l.close()}catch{}l=null}i.onError(Ce)}}},stop:async()=>{if(n)try{await n.pause()}catch{}for(Ee();f.size>0;)await Promise.all(Array.from(f));if(n){try{await n.destroy()}catch{}n=null}if(p){try{p.disconnect()}catch{}p=null}if(a){try{a.disconnect()}catch{}a=null}if(r){try{r.getTracks().forEach(oe=>oe.stop())}catch{}r=null}if(l){try{await l.close()}catch{}l=null}},setVadThresholds:(oe,Ce)=>{if(n)try{n.setOptions({positiveSpeechThreshold:oe,negativeSpeechThreshold:Ce})}catch(Oe){ut.warn("speech","setVadThresholds failed",{error:Oe instanceof Error?Oe.message:String(Oe)})}},getAnalyser:()=>p,destroy:()=>{if(t=!0,Ee(),n){try{n.destroy()}catch{}n=null}if(p){try{p.disconnect()}catch{}p=null}if(a){try{a.disconnect()}catch{}a=null}if(l){try{l.close()}catch{}l=null}if(r){try{r.getTracks().forEach(oe=>oe.stop())}catch{}r=null}$b.delete(Q),e.removeEventListener("message",W)}}}let Ff=null;const Ab=new Set,Ib=new Set;function $D(){for(const i of Ab)try{i()}catch{}}function Pb(){for(const i of Ib)try{i()}catch{}}function AD(i){return i.replace(/```[\s\S]*?```/g,"").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/\*{1,3}([^*]+)\*{1,3}/g,"$1").replace(/_{1,3}([^_]+)_{1,3}/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/^[-*_]{3,}\s*$/gm,"").replace(/^>\s?/gm,"").replace(/^[\s]*[-*+]\s/gm,"").replace(/^[\s]*\d+\.\s/gm,"").trim()}function ID(i){if(!window.speechSynthesis)return;const e=AD(i);if(!e)return;const t=new SpeechSynthesisUtterance(e);t.rate=1,t.pitch=1,t.onstart=()=>{Ff=performance.now(),$D()},t.onend=()=>{!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(Ff=null,Pb())},t.onerror=n=>{n.error!=="canceled"&&!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(Ff=null,Pb())},window.speechSynthesis.speak(t)}function CC(){window.speechSynthesis&&(window.speechSynthesis.cancel(),Ff=null,Pb())}function kC(){var i;return((i=window.speechSynthesis)==null?void 0:i.speaking)??!1}function PD(){return Ff}function jD(i){return Ab.add(i),()=>{Ab.delete(i)}}function RD(i){return Ib.add(i),()=>{Ib.delete(i)}}function ND(i){kC()&&(i.setVadThresholds(Wx,Ux),ut.info("voice","tts.duck.on",{reason:"already-speaking-on-attach"}));const e=jD(()=>{i.setVadThresholds(Wx,Ux),ut.info("voice","tts.duck.on")}),t=RD(()=>{i.setVadThresholds(bC,wC),ut.info("voice","tts.duck.off")});return()=>{e(),t()}}const MD=[{match:/^(send|submit|enter)\.?$/i,data:"\r",label:"send"},{match:/^(cancel|escape)\.?$/i,data:"\x1B",label:"cancel"},{match:/^clear( line)?\.?$/i,data:"",label:"clear"}];function OD(i){const e=i.trim();return MD.find(t=>t.match.test(e))??null}const LD=4e4;let vd=null;function wh(){vd&&clearTimeout(vd),vd=setTimeout(()=>{vd=null,kt.getState().stopRecording()},LD)}function Dg(){vd&&(clearTimeout(vd),vd=null)}let rc=null,ec=null;const zD=.04,BD=.3;let Dv=0,jb=0;function GD(i){ec!==null&&cancelAnimationFrame(ec);const e=()=>{if(rc===null||kt.getState().submitCountdownStartAt===null){ec=null;return}const t=performance.now();if(t-jb<200&&Dv>BD){const r=t-i;ut.info("voice","submit.preempted_by_voice",{reason:"vad",prob:Dv.toFixed(2),msIntoCountdown:Math.round(r)}),Jl(),wh();return}const n=EC();if(n){const r=new Uint8Array(n.fftSize);n.getByteTimeDomainData(r);let l=0;for(let a=0;a<r.length;a++){const d=(r[a]-128)/128;l+=d*d}const p=Math.sqrt(l/r.length);if(p>zD){const a=t-i;ut.info("voice","submit.preempted_by_voice",{reason:"rms",rms:p.toFixed(3),msIntoCountdown:Math.round(a)}),Jl(),wh();return}}ec=requestAnimationFrame(e)};ec=requestAnimationFrame(e)}function qx(i){rc&&clearTimeout(rc);const e=kt.getState().submitDelayMs,t=performance.now();kt.setState({submitCountdownStartAt:t}),rc=setTimeout(()=>{var r;rc=null,kt.setState({submitCountdownStartAt:null});const n=Ct.getState().tabs.find(l=>l.id===i);if((n==null?void 0:n.status)==="dormant"){const l=(r=vi.getState().chats[i])==null?void 0:r.pendingVoiceText;l&&(vi.getState().send({tabId:i,sessionId:n.sessionId,cwd:n.cwd,prompt:l}),vi.getState().clearPendingVoiceText(i))}else try{window.api.pty.write({tabId:i,data:"\r"})}catch(l){ut.warn("voice","submit pty.write failed",{error:l instanceof Error?l.message:String(l)})}wh()},e),GD(t)}function Jl(){ec!==null&&(cancelAnimationFrame(ec),ec=null),rc&&(clearTimeout(rc),rc=null),kt.getState().submitCountdownStartAt!==null&&kt.setState({submitCountdownStartAt:null})}let ps=null,zs=null,gf=null;function EC(){var i;return((i=ps==null?void 0:ps.getAnalyser)==null?void 0:i.call(ps))??null}const $g=1e4;let Hf=null;function Ag(){Hf&&(clearTimeout(Hf),Hf=null)}let cv=null,dv=null;function Ig(){cv=null,dv&&(dv(),dv=null)}const FD=1500,HD=9e4;let Pg=0,uv=null,Rb=-1;function jg(){uv&&(clearTimeout(uv),uv=null,Rb=-1)}const WD=new Set(["you","You","Thank you.","Thanks for watching.","Thanks for watching!","Thank you for watching.","Thank you for watching!",".","Bye.","Bye!"]),kt=jn((i,e)=>({isRecording:!1,externalRecording:!1,ttsEnabled:!1,autoSubmit:!0,submitDelayMs:8e3,submitCountdownStartAt:null,lastTranscript:"",lastPartial:"",statusPill:"idle",partialsEnabled:!0,error:null,errorKind:null,modelStatus:"idle",loadingProgress:0,permissionState:"unknown",lastBargeInAt:null,hotkeyState:"idle",levelMeterEnabled:!0,turnDetectorState:"disabled",turnDetectorMode:"off",wizardArmed:!1,wizardOpen:!1,initModel:()=>{if(e().modelStatus!=="idle")return;ut.info("voice","initModel: kicking off preload"),i({modelStatus:"loading",error:null,errorKind:null,loadingProgress:0});const t=++Pg,n=()=>{t===Pg&&(jg(),Rb=t,uv=setTimeout(()=>{Rb===t&&e().modelStatus==="loading"&&(ut.warn("voice","mic.gate.timeout: no progress within 90s"),i({modelStatus:"error",error:"Model load timed out",errorKind:"timeout"}))},HD))};n(),ED((r,l)=>{t===Pg&&(r==="ready"?(jg(),ut.info("voice","modelStatus -> ready"),i({modelStatus:"ready",loadingProgress:100,errorKind:null})):r==="error"?(jg(),ut.error("voice","modelStatus -> error",{msg:l}),i({modelStatus:"error",error:l,errorKind:"load"})):(n(),i({modelStatus:"loading"})))},r=>{t===Pg&&(n(),i({loadingProgress:Math.round(r)}))})},resetAndRetryModel:()=>{ut.info("voice","mic.gate.retry"),jg(),TD(),i({modelStatus:"idle",error:null,errorKind:null,loadingProgress:0}),e().initModel()},startRecording:(t,n)=>{if(e().isRecording)return;if(ps){ut.warn("voice","startRecording: prior handle still draining, ignoring");return}if(!Kv()){i({error:"Microphone or Web Worker not available",errorKind:"recording"});return}const r=l=>{try{const p=SC({inputDeviceId:l,onStatusChange:a=>{i(a==="transcribing"?{statusPill:"transcribing"}:a==="restarting"?{statusPill:"restarting"}:{statusPill:"idle"})},onPartial:a=>{e().partialsEnabled&&i({lastPartial:a})},partialsEnabled:()=>e().partialsEnabled,onFrame:a=>{Dv=a.isSpeech,jb=performance.now()},onSpeechStart:()=>{if(i({statusPill:"listening",lastPartial:""}),Dg(),Jl(),kC()){const d=PD(),f=d!==null?performance.now()-d:null;CC(),i({lastBargeInAt:performance.now()}),ut.info("voice","barge-in",{tabId:t,utteranceOffsetMs:f})}else ut.debug("voice","barge-in.no-op",{tabId:t})},onMisfire:()=>{i({lastPartial:"",statusPill:"idle"}),wh();const a=e().lastBargeInAt;a!==null&&performance.now()-a<600&&ut.warn("voice","barge-in.misfire",{tabId:t,sinceBargeInMs:Math.round(performance.now()-a)})},onFinal:a=>{var y;wh();const d=a.trim();if(!d||WD.has(d)){i({lastTranscript:"",lastPartial:"",statusPill:"idle"});return}if(gf){gf(d),i({lastTranscript:"",lastPartial:"",statusPill:"idle"});return}if(((y=Ct.getState().tabs.find(D=>D.id===t))==null?void 0:y.status)==="dormant"){vi.getState().setPendingVoiceText(t,d),i({lastTranscript:"",lastPartial:"",statusPill:"idle"}),e().autoSubmit&&qx(t);const D=window;D.__transcripts&&(D.__transcripts.push({tabId:t,text:d}),D.__transcripts.length>500&&D.__transcripts.shift());return}const m=OD(d);if(m){ut.info("voice","voice-command",{tabId:t,label:m.label,transcript:d}),window.api.pty.write({tabId:t,data:m.data}),i({lastTranscript:"",lastPartial:"",statusPill:"idle"}),Jl();const D=window;D.__transcripts&&(D.__transcripts.push({tabId:t,text:d}),D.__transcripts.length>500&&D.__transcripts.shift());return}window.api.pty.write({tabId:t,data:d}),i({lastTranscript:"",lastPartial:"",statusPill:"idle"}),e().autoSubmit&&qx(t);const g=window;g.__transcripts&&(g.__transcripts.push({tabId:t,text:d}),g.__transcripts.length>500&&g.__transcripts.shift())},onError:a=>{ut.error("voice","recognition error",{err:a}),Jl(),i({error:a,errorKind:"recording",isRecording:!1,lastPartial:"",statusPill:"idle"}),zs==null||zs(),zs=null,Dg(),ps==null||ps.destroy(),ps=null,gf=null,Qe.error(`Microphone error: ${a}`)},onModelStatus:a=>{a==="ready"?i({modelStatus:"ready",loadingProgress:100}):a==="loading"&&i({modelStatus:"loading"})},onProgress:a=>i({loadingProgress:Math.round(a)})});ps=p,gf=(n==null?void 0:n.sink)??null,i({isRecording:!0,error:null,lastTranscript:"",lastPartial:"",statusPill:"listening"}),wh(),p.start().then(()=>{ps===p&&(zs==null||zs(),zs=ND(p))}).catch(a=>{const d=a instanceof Error?a.message:String(a);ut.error("voice","handle.start() failed",{error:d}),Qe.error(`Could not start mic: ${d}`)})}catch(p){i({error:p instanceof Error?p.message:"Failed to start recording",errorKind:"recording"})}};Promise.resolve().then(()=>{var l,p,a;return((a=(p=(l=window.api)==null?void 0:l.voice)==null?void 0:p.getDevicePref)==null?void 0:a.call(p))??Promise.resolve(null)}).then(l=>r((l==null?void 0:l.selectedDeviceId)??null)).catch(l=>{ut.warn("voice","getDevicePref failed; using default device",{error:l instanceof Error?l.message:String(l)}),r(null)})},stopRecording:()=>{const t=ps;t&&(Dg(),Jl(),Dv=0,jb=0,zs==null||zs(),zs=null,i({isRecording:!1,lastTranscript:"",lastPartial:"",statusPill:"idle"}),t.stop().finally(()=>{t.destroy(),ps===t&&(ps=null,gf=null),e().hotkeyState==="stopping"&&(Ag(),i({hotkeyState:"idle"}))}))},restartWithDevice:async()=>{if(!e().isRecording)return;const t=ps;if(!t)return;Dg(),zs==null||zs(),zs=null,i({isRecording:!1,lastTranscript:"",lastPartial:""});try{await t.stop()}catch(l){ut.warn("voice","restartWithDevice: drain rejected",{error:l instanceof Error?l.message:String(l)})}t.destroy(),ps===t&&(ps=null);const{useSessions:n}=await fi(async()=>{const{useSessions:l}=await Promise.resolve().then(()=>T2);return{useSessions:l}},[],import.meta.url),r=n.getState().activeTabId;r&&e().startRecording(r)},setExternalRecording:t=>i({externalRecording:t}),toggleTTS:()=>i(t=>({ttsEnabled:!t.ttsEnabled})),setAutoSubmit:t=>i({autoSubmit:t}),setSubmitDelayMs:t=>i({submitDelayMs:Math.max(500,Math.min(13e3,Math.floor(t)))}),cancelSubmit:()=>Jl(),setPartialsEnabled:t=>{e().partialsEnabled!==t&&(i({partialsEnabled:t}),t||i({lastPartial:""}))},clearError:()=>i({error:null,errorKind:null}),setPermissionState:t=>{e().permissionState!==t&&(ut.info("voice","mic.gate.permission_changed",{from:e().permissionState,to:t}),i({permissionState:t}))},setLevelMeterEnabled:t=>{e().levelMeterEnabled!==t&&i({levelMeterEnabled:t})},setTurnDetectorRuntimeState:t=>{e().turnDetectorState!==t&&(i({turnDetectorState:t}),t==="load_failed"?ut.warn("voice-turn","voice-turn.load_failed"):t==="runtime_error"?ut.warn("voice-turn","voice-turn.runtime_error"):t==="disabled"&&ut.info("voice-turn","voice-turn.fallback_to_vad"))},setWizardArmed:t=>{e().wizardArmed!==t&&i({wizardArmed:t})},openWizard:()=>{e().wizardOpen||i({wizardOpen:!0})},closeWizard:()=>{e().wizardOpen&&i({wizardOpen:!1})},armHotkey:({phase:t,source:n,mode:r,tabId:l})=>{const p=e(),{canRecord:a,reason:d}=$v(p);if(t==="down"){if(d==="error"||d==="load-timeout"){p.resetAndRetryModel(),ut.info("voice-hotkey","down.retry",{source:n,reason:d});return}if(!a&&d!=="loading"){ut.warn("voice-hotkey","miss-model-loading",{modelStatus:p.modelStatus,reason:d});return}if(p.hotkeyState==="recording"||p.isRecording){(r==="toggle"||n==="global")&&(i({hotkeyState:"stopping"}),Ag(),Hf=setTimeout(()=>{e().hotkeyState==="stopping"&&(ut.warn("voice-hotkey","drain-timeout",{durationMs:$g}),i({hotkeyState:"aborted"}),setTimeout(()=>{e().hotkeyState==="aborted"&&i({hotkeyState:"idle"})},0))},$g),p.stopRecording());return}if(d==="loading"){p.hotkeyState!=="armed"&&(i({hotkeyState:"armed"}),ut.info("voice-hotkey","armed",{source:n,modelStatus:p.modelStatus})),Ig(),cv={tabId:l,source:n,mode:r},dv=kt.subscribe((f,m)=>{if(cv&&f.modelStatus==="ready"&&m.modelStatus!=="ready"&&f.hotkeyState==="armed"){const g=cv;if(Ig(),!g.tabId){ut.warn("voice-hotkey","armed-promote-no-tab",{source:g.source}),i({hotkeyState:"idle"});return}ut.info("voice-hotkey","armed-promote",g),i({hotkeyState:"recording"}),kt.getState().startRecording(g.tabId)}});return}if(!l){ut.warn("voice-hotkey","no-active-tab",{source:n});return}ut.info("voice-hotkey","start",{source:n,mode:r,tabId:l}),p.startRecording(l),e().isRecording?i({hotkeyState:"recording"}):(ut.warn("voice-hotkey","start: recording did not engage",{errorKind:e().errorKind}),i({hotkeyState:"idle"}));return}if(!(r!=="hold"||n==="global")){if(p.hotkeyState==="armed"){Ig(),ut.info("voice-hotkey","miss-model-loading-armed-up"),i({hotkeyState:"idle"});return}p.hotkeyState==="recording"&&(i({hotkeyState:"stopping"}),Ag(),Hf=setTimeout(()=>{e().hotkeyState==="stopping"&&(ut.warn("voice-hotkey","drain-timeout",{durationMs:$g}),i({hotkeyState:"aborted"}),setTimeout(()=>{e().hotkeyState==="aborted"&&i({hotkeyState:"idle"})},0))},$g),p.stopRecording())}},destroyHotkey:()=>{const t=e();if(Ig(),Jl(),t.hotkeyState==="recording"){ut.warn("voice-hotkey","destroyed-mid-recording"),i({hotkeyState:"destroyed"});try{t.stopRecording()}catch{}}else(t.hotkeyState==="armed"||t.hotkeyState==="stopping")&&(Ag(),i({hotkeyState:"destroyed"}))}})),UD=i=>({isRecording:i.isRecording,statusPill:i.statusPill,lastPartial:i.lastPartial,lastTranscript:i.lastTranscript,submitCountdownStartAt:i.submitCountdownStartAt}),$v=i=>Kv()?i.permissionState==="denied"?{canRecord:!1,reason:"permission-denied"}:i.modelStatus==="ready"?{canRecord:!0,reason:"ready"}:i.modelStatus==="loading"?{canRecord:!1,reason:"loading"}:i.modelStatus==="error"?{canRecord:!1,reason:i.errorKind==="timeout"?"load-timeout":"error"}:{canRecord:!1,reason:"idle"}:{canRecord:!1,reason:"unsupported"};if(typeof window<"u"){const i=window;i.__voice=kt,i.__transcripts=[]}const Qf=6e4,VD=3e5,qD=.25,KD=5e3,em=jn(()=>({data:null,refreshing:!1}));let Kx=!1,hv=null,$_=Qf,Rg=!1,sl=null;function YD(i,e){if(i.kind==="ok")return{delayMs:Qf,nextBackoffMs:Qf};const t=Math.min(e*2,VD),n=t*qD;let r=t+(Math.random()*2-1)*n;const l=i.kind==="meter_rate_limited"?i.retryAfterMs:void 0;return typeof l=="number"&&Number.isFinite(l)&&l>r&&(r=l),{delayMs:r,nextBackoffMs:t}}function Yx(){return W1(window.api.billing.fetch(),KD,"billing.fetch")}function Xx(i){em.setState({data:i,refreshing:!1})}async function Hw(){em.setState({refreshing:!0});let i=Qf;try{const e=await Yx();sl&&(sl.cancel(),sl=null),Xx(e);const{delayMs:t,nextBackoffMs:n}=YD(e,$_);$_=n,i=t}catch(e){$_=Qf,em.setState({refreshing:!1});const t=U1({error:e,retry:Yx,onRetrySuccess:n=>{sl=null,Xx(n)},onStillFailing:n=>{sl=null,Rg||(Rg=!0,Qe.warn(`Billing usage fetch: ${n}`))}});if(t)sl=t;else if(!Rg){Rg=!0;const n=e instanceof Error?e.message:String(e);Qe.warn(`Billing usage fetch failed: ${n}`)}}hv=setTimeout(Hw,i)}function XD(){Kx||(Kx=!0,Hw())}function TC(i){return i?i.kind==="ok"||i.kind==="ok-stale"?i.data:(i.kind==="auth"||i.kind==="meter_rate_limited")&&i.cached?i.cached:null:null}function JD(){hv!==null&&(clearTimeout(hv),hv=null),sl&&(sl.cancel(),sl=null),Hw()}function tm(i){if(!i||i==="—"||i==="unknown")return i;const e=/\[(\dm)\]/.exec(i),t=/(opus|sonnet|haiku|fable)[-_](\d+)[-_.]?(\d+)?/i.exec(i);if(!t)return i;const n=t[1].charAt(0).toUpperCase()+t[1].slice(1).toLowerCase(),r=t[3]?`${t[2]}.${t[3]}`:t[2];return e?`${n} ${r} ${e[1]}`:`${n} ${r}`}function im(i){const e=/(opus|sonnet|haiku|fable)/i.exec(i);return e?e[1].toLowerCase():null}const Ng=new Map,ZD=3e4;function Ww(i){const[e,t]=z.useState(()=>{var n;return i?((n=Ng.get(i))==null?void 0:n.value)??null:null});return z.useEffect(()=>{if(!i){t(null);return}let n=!1;return(async()=>{const l=Ng.get(i);if(l&&Date.now()-l.ts<ZD){n||t(l.value);return}try{const p=await window.api.app.gitBranch(i);if(n)return;Ng.set(i,{value:p,ts:Date.now()}),t(p)}catch{if(n)return;Ng.set(i,{value:null,ts:Date.now()}),t(null)}})(),()=>{n=!0}},[i]),e}const DC="~/.claude/session-manager/ui-chrome-prefs.json",QD=180,e$=480,Nb=252,ad={sidebarWidth:Nb,sidebarCollapsed:!1,collapsedGroups:[],learningPanelCollapsed:!1,tourCompletedAt:null,density:"roomy"};function Mb(i){return Math.min(e$,Math.max(QD,i))}let tc=null,pv={};function t$(i){const e=()=>{const t=i(),n={sidebarWidth:t.sidebarWidth,sidebarCollapsed:t.sidebarCollapsed,collapsedGroups:t.collapsedGroups,learningPanelCollapsed:t.learningPanelCollapsed,tourCompletedAt:t.tourCompletedAt,density:t.density};window.api.config.writeJson(DC,n).catch(()=>{})};i().hydrated||!tc?e():tc.then(e)}function dh(i,e,t){i(t),!e().hydrated&&tc&&Object.assign(pv,t),t$(e)}const Pn=jn((i,e)=>({...ad,hydrated:!1,hydrate:()=>e().hydrated?Promise.resolve():tc||(tc=(async()=>{try{const t=await window.api.config.readJson(DC);if(t.exists&&t.data&&typeof t.data=="object"){const n=t.data;i({sidebarWidth:typeof n.sidebarWidth=="number"?Mb(n.sidebarWidth):ad.sidebarWidth,sidebarCollapsed:n.sidebarCollapsed??ad.sidebarCollapsed,collapsedGroups:Array.isArray(n.collapsedGroups)?n.collapsedGroups:ad.collapsedGroups,learningPanelCollapsed:n.learningPanelCollapsed??ad.learningPanelCollapsed,tourCompletedAt:typeof n.tourCompletedAt=="number"?n.tourCompletedAt:ad.tourCompletedAt,density:n.density==="compact"?"compact":ad.density,...pv,hydrated:!0});return}}catch{}i({...pv,hydrated:!0})})().finally(()=>{tc=null,pv={}}),tc),setSidebarWidth:t=>dh(i,e,{sidebarWidth:Mb(t)}),setSidebarCollapsed:t=>dh(i,e,{sidebarCollapsed:t}),setCollapsedGroups:t=>dh(i,e,{collapsedGroups:t}),setLearningPanelCollapsed:t=>dh(i,e,{learningPanelCollapsed:t}),setTourCompletedAt:t=>dh(i,e,{tourCompletedAt:t}),setDensity:t=>dh(i,e,{density:t})}));function i$(i){return i.filter(e=>e.group==="Tools").map(({key:e,label:t,icon:n,hint:r})=>({key:e,label:t,icon:n,hint:r}))}const n$=52;function s$(i){return new Set(i.filter(e=>e==="Workspace"||e==="Configure"||e==="Tools"))}function r$(){const i=Ct(t=>{var n;return((n=t.tabs.find(r=>r.id===t.activeTabId))==null?void 0:n.cwd)??null});return{scheduler:Wr(t=>{var n;return(((n=t.snapshot)==null?void 0:n.jobs)??[]).some(r=>r.status==="running"&&(!i||r.cwd===i))})}}function o$({active:i,onNavigate:e,onNewSession:t}){const n=Pn(ee=>ee.hydrated),r=Pn(ee=>ee.hydrate);z.useEffect(()=>{n||r()},[n,r]);const l=Pn(ee=>ee.collapsedGroups),p=Pn(ee=>ee.setCollapsedGroups),a=z.useMemo(()=>s$(l),[l]),d=z.useCallback(ee=>{const we=new Set(a);we.has(ee)?we.delete(ee):we.add(ee),p(Array.from(we))},[a,p]),f=Pn(ee=>ee.sidebarCollapsed),m=Pn(ee=>ee.setSidebarCollapsed),g=z.useCallback(()=>{m(!f)},[f,m]),y=Ct(ee=>ee.tabs),D=Ct(ee=>ee.activeTabId),E=y.find(ee=>ee.id===D)??null,C=r$(),b=ji(ee=>ee.navFace),w=I2(b),x=w.filter(ee=>ee.group==="Workspace"),S=w.filter(ee=>ee.group==="Configure"),T=i$(w),j=b==="home"&&!f,N=Pn(ee=>ee.sidebarWidth),L=Pn(ee=>ee.setSidebarWidth),[R,F]=z.useState(N),V=z.useRef(R);V.current=R,z.useEffect(()=>{F(N)},[N]);const te=z.useCallback(ee=>{ee.preventDefault();const we=ee.clientX,ce=V.current;let ve=ce;const Ee=U=>{ve=Mb(ce+(U.clientX-we)),F(ve)},fe=()=>{window.removeEventListener("pointermove",Ee),window.removeEventListener("pointerup",fe),document.body.style.cursor="",document.body.style.userSelect="",L(ve)};window.addEventListener("pointermove",Ee),window.addEventListener("pointerup",fe),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[L]),he=z.useCallback(()=>{F(Nb),L(Nb)},[L]);return c.jsxs("aside",{className:"shrink-0 bg-bg-elev border-r border-line flex flex-col relative transition-[width] duration-150",style:{width:f?n$:R},"data-testid":"tour-leftnav","aria-label":"Primary navigation",children:[c.jsx(a$,{tab:E,navFace:b,onNewSession:t,rail:f,onToggleRail:g}),c.jsx("div",{className:"flex-1 min-h-0 overflow-auto pb-3",style:{paddingInline:f?"4px":"8px"},children:j?c.jsxs(c.Fragment,{children:[c.jsx(A_,{label:"Workspace",desc:x_.Workspace,collapsed:a.has("Workspace"),count:x.length,onToggle:()=>d("Workspace")}),!a.has("Workspace")&&x.map(ee=>c.jsx(I_,{item:ee,active:i===ee.key,live:ee.liveKind?C[ee.liveKind]:!1,onClick:()=>e(ee.key),rail:!1},ee.key)),c.jsx(A_,{label:"Configure",desc:x_.Configure,collapsed:a.has("Configure"),count:S.length,onToggle:()=>d("Configure")}),!a.has("Configure")&&S.map(ee=>c.jsx(I_,{item:ee,active:i===ee.key,live:!1,onClick:()=>e(ee.key),rail:!1},ee.key)),T.length>0&&c.jsx(A_,{label:"Tools",desc:x_.Tools,collapsed:a.has("Tools"),count:T.length,onToggle:()=>d("Tools")}),T.length>0&&!a.has("Tools")&&T.map(ee=>c.jsx(Jx,{tool:ee,active:i===ee.key,onClick:()=>e(ee.key),rail:!1},ee.key))]}):c.jsx("div",{className:"pt-2",children:w.map(ee=>ee.group==="Tools"?c.jsx(Jx,{tool:{key:ee.key,label:ee.label,icon:ee.icon,hint:ee.hint},active:i===ee.key,onClick:()=>e(ee.key),rail:f},ee.key):c.jsx(I_,{item:ee,active:i===ee.key,live:ee.liveKind?C[ee.liveKind]:!1,onClick:()=>e(ee.key),rail:f},ee.key))})}),c.jsx(l$,{rail:f,navFace:b}),!f&&c.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize · double-click to reset",onPointerDown:te,onDoubleClick:he,className:"absolute top-0 right-0 h-full w-1.5 translate-x-1/2 z-10 cursor-col-resize hover:bg-accent/40 active:bg-accent/60 transition-colors"})]})}function a$({tab:i,navFace:e,onNewSession:t,rail:n,onToggleRail:r}){const l=(i==null?void 0:i.label)??"no session",p=Ww((i==null?void 0:i.cwd)??null);return n?c.jsxs("div",{className:"flex flex-col items-center gap-1.5 pt-2 pb-2 border-b border-rule",children:[c.jsx("button",{onClick:t,"data-testid":"tour-new-session",title:"Open / Start Project",className:"w-9 h-9 rounded-md bg-bg-hi border border-line text-fg hover:bg-bg-hi/80 hover:border-accent/40 transition-colors flex items-center justify-center",children:c.jsx(Cr,{name:"plus",size:15,stroke:1.8})}),c.jsx("button",{onClick:r,title:"Expand sidebar","data-testid":"sidebar-rail-toggle",className:"w-9 h-9 rounded-md text-fg-faint hover:text-fg hover:bg-bg-hi/50 transition-colors flex items-center justify-center",children:c.jsx("span",{style:{display:"inline-flex",transform:"rotate(0deg)"},children:c.jsx(Cr,{name:"chevron",size:15,stroke:1.8})})})]}):e==="home"?c.jsxs("div",{className:"px-[18px] pt-[14px] pb-[10px] border-b border-rule",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.06em] text-fg-faint uppercase",children:"Session Manager"}),c.jsx("button",{onClick:r,title:"Collapse sidebar","data-testid":"sidebar-rail-toggle",className:"w-6 h-6 rounded-md text-fg-faint hover:text-fg hover:bg-bg-hi/50 transition-colors flex items-center justify-center",children:c.jsx("span",{style:{display:"inline-flex",transform:"rotate(180deg)"},children:c.jsx(Cr,{name:"chevron",size:13,stroke:1.8})})})]}),c.jsx("div",{className:"mt-3 flex items-stretch gap-1.5",children:c.jsxs("button",{onClick:t,"data-testid":"tour-new-session",className:"flex-1 px-3 py-1.5 rounded-md bg-bg-hi border border-line text-fg text-[12.5px] font-medium hover:bg-bg-hi/80 hover:border-accent/40 transition-colors flex items-center justify-center gap-1.5",children:[c.jsx(Cr,{name:"plus",size:13,stroke:1.8}),"Open / Start Project"]})})]}):c.jsxs("div",{className:"px-[18px] pt-[14px] pb-[10px] border-b border-rule",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.06em] text-fg-faint uppercase",children:"Project"}),c.jsx("button",{onClick:r,title:"Collapse sidebar","data-testid":"sidebar-rail-toggle",className:"w-6 h-6 rounded-md text-fg-faint hover:text-fg hover:bg-bg-hi/50 transition-colors flex items-center justify-center",children:c.jsx("span",{style:{display:"inline-flex",transform:"rotate(180deg)"},children:c.jsx(Cr,{name:"chevron",size:13,stroke:1.8})})})]}),c.jsxs("div",{className:"flex items-baseline gap-2 mt-1",children:[c.jsx("span",{className:"self-center w-2 h-2 rounded-full bg-sage"}),c.jsx("span",{className:"font-serif text-[18px] font-medium text-fg truncate",title:(i==null?void 0:i.cwd)??"",children:l})]}),c.jsx("div",{className:"text-[12px] text-fg-faint font-mono mt-0.5 truncate",children:p?`⌥${p}`:i?i.cwd:"—"}),c.jsx("div",{className:"mt-3 flex items-stretch gap-1.5",children:c.jsxs("button",{onClick:t,"data-testid":"tour-new-session",className:"flex-1 px-3 py-1.5 rounded-md bg-bg-hi border border-line text-fg text-[12.5px] font-medium hover:bg-bg-hi/80 hover:border-accent/40 transition-colors flex items-center justify-center gap-1.5",children:[c.jsx(Cr,{name:"plus",size:13,stroke:1.8}),"Open / Start Project"]})})]})}function A_({label:i,desc:e,collapsed:t,count:n,onToggle:r}){return c.jsxs("div",{className:"px-3 pt-3.5 pb-1.5",children:[c.jsxs("button",{onClick:r,"aria-expanded":!t,title:t?`Expand ${i}`:`Collapse ${i}`,className:"group w-full flex items-center gap-1.5 font-serif italic text-[11px] font-bold tracking-[0.07em] uppercase text-fg-faint hover:text-fg-dim transition-colors text-left",children:[c.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 text-[9px] not-italic transition-transform",style:{transform:t?"rotate(-90deg)":"rotate(0deg)"},children:"▾"}),c.jsx("span",{className:"flex-1",children:i}),t&&c.jsx("span",{className:"not-italic text-[10px] font-mono text-fg-faint/70 normal-case tracking-normal",children:n})]}),!t&&c.jsx("p",{className:"mt-0.5 pl-3.5 text-[11px] leading-[1.35] text-fg-faint/80 normal-case tracking-normal font-sans not-italic line-clamp-2",children:e})]})}function I_({item:i,active:e,live:t,onClick:n,rail:r}){return c.jsxs("button",{onClick:n,title:i.hint,"data-testid":i.key==="scheduler"?"tour-scheduler":i.key==="terminal"?"tour-sessions":void 0,className:`relative w-full flex items-center rounded-[10px] text-left mb-0.5 transition-colors ${r?"justify-center px-0 py-[9px]":"gap-3 px-3.5 py-[9px] text-[14px]"} ${e?"bg-bg-hi text-fg font-semibold border border-line":"text-fg-dim hover:bg-bg-hi/50 hover:text-fg border border-transparent"}`,children:[e&&c.jsx("span",{"aria-hidden":!0,className:`absolute top-2 bottom-2 w-[3px] rounded-sm bg-accent ${r?"-left-[4px]":"-left-[10px]"}`}),c.jsx("span",{className:`inline-flex ${e?"text-accent":"text-fg-faint"}`,children:c.jsx(Cr,{name:i.icon,size:17,stroke:1.6})}),!r&&c.jsxs("span",{className:"flex-1 min-w-0",children:[c.jsx("span",{className:"block truncate",children:i.label}),i.hint&&c.jsx("span",{className:"block text-[11px] leading-[1.3] text-fg-faint/80 font-normal truncate",children:i.hint})]}),!r&&t&&c.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"live activity"}),r&&t&&c.jsx("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"live activity"})]})}function Jx({tool:i,active:e,onClick:t,rail:n}){return c.jsxs("button",{onClick:t,title:i.hint,className:`relative w-full flex items-center rounded-[10px] text-left mb-0.5 transition-colors ${n?"justify-center px-0 py-[7px]":"gap-3 px-3.5 py-[7px] text-[13px]"} ${e?"bg-bg-hi text-fg font-semibold border border-line":"text-fg-dim hover:bg-bg-hi/50 hover:text-fg border border-transparent"}`,children:[e&&c.jsx("span",{"aria-hidden":!0,className:`absolute top-1.5 bottom-1.5 w-[3px] rounded-sm bg-accent ${n?"-left-[4px]":"-left-[10px]"}`}),c.jsx("span",{className:`inline-flex ${e?"text-accent":"text-fg-faint"}`,children:c.jsx(Cr,{name:i.icon,size:15,stroke:1.6})}),!n&&c.jsxs("span",{className:"flex-1 min-w-0",children:[c.jsx("span",{className:"block truncate",children:i.label}),i.hint&&c.jsx("span",{className:"block text-[11px] leading-[1.3] text-fg-faint/80 font-normal truncate",children:i.hint})]})]})}function l$({rail:i,navFace:e}){const t=kt(d=>d.isRecording),n=Ct(d=>d.tabs),r=Ct(d=>d.activeTabId),l=n.find(d=>d.id===r)??null,[p,a]=z.useState(null);return z.useEffect(()=>{let d=!1;if(!(l!=null&&l.presetId)){a(null);return}return O1(l.presetId).then(f=>{d||a((f==null?void 0:f.model)??null)}).catch(()=>{d||a(null)}),()=>{d=!0}},[l==null?void 0:l.presetId]),i?c.jsx("div",{className:"py-2.5 border-t border-rule flex justify-center",children:c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${t?"bg-red-500 animate-pulse":"bg-sage"}`,title:t?"recording":"idle"})}):c.jsxs("div",{className:"px-3.5 py-2.5 border-t border-rule flex items-center gap-2 text-[11.5px] text-fg-dim font-mono",children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${t?"bg-red-500 animate-pulse":"bg-sage"}`,title:t?"recording":"idle"}),(t||e==="project")&&c.jsx("span",{className:"truncate",title:p??"",children:t?"recording…":p?`Claude · ${tm(p)}`:"Claude Code"})]})}function c$(i,e,t){return e?i.map(n=>n.id===e?{...n,lastActivityAt:t}:n):i}function d$(i,e,t){return{tabId:i,sessionUuid:t,cwd:e,path:null,todos:[],lastToolUses:[],plans:[],agents:[],usage:{inputTokens:0,outputTokens:0},lastEventAt:0,activityRing:[],activitySeq:0}}function u$(i,e,t){const n=Date.now(),r={...i,lastEventAt:t!=null&&t.replay?i.lastEventAt:n},l=[],p=(a,d)=>a.length>d?a.slice(0,d-1)+"…":a;switch(e.kind){case"todo_write":{const a=Array.isArray(e.data)?e.data:[];r.todos=a,t!=null&&t.replay||l.push({id:0,kind:"todo-update",at:n,label:`Todos · ${a.length} item${a.length!==1?"s":""}`});break}case"tool_use":{const a=e.data,d=a.input,f={};for(const m of["command","file_path","pattern","url","query","subagent_type","description"])d&&m in d&&(f[m]=d[m]);if(r.lastToolUses=[{id:a.id,name:a.name,input:f,at:n},...i.lastToolUses].slice(0,50),!(t!=null&&t.replay)){const m=a.input,g=["Edit","Write","NotebookEdit"].includes(a.name),y=typeof(m==null?void 0:m.file_path)=="string"?m.file_path:void 0,D=typeof(m==null?void 0:m.command)=="string"?m.command:void 0,E=y?y.split("/").pop()??y:D?p(D,28):"";l.push({id:0,kind:"tool-use",at:n,label:E?`${a.name} · ${E}`:a.name,target:y??D,toolName:a.name}),g&&y&&l.push({id:0,kind:"file-edit",at:n,label:`${a.name} · ${p(y.split("/").pop()??y,34)}`,target:y,toolName:a.name})}break}case"plan":{const a=e.data,d=typeof a=="string"?a:(a==null?void 0:a.plan)??JSON.stringify(a);r.plans=[{at:n,content:d??""},...i.plans].slice(0,50),t!=null&&t.replay||l.push({id:0,kind:"plan-revision",at:n,label:"Plan revised"});break}case"agent_spawn":{const a=e.data;r.agents=[{id:a==null?void 0:a.toolUseId,at:n,subagentType:a==null?void 0:a.subagent_type,description:a==null?void 0:a.description,lastActivityAt:n},...i.agents].slice(0,50),t!=null&&t.replay||l.push({id:0,kind:"agent-spawn",at:n,label:a!=null&&a.subagent_type?`Agent: ${p(a.subagent_type,32)}`:"Agent spawned"});break}case"usage":{const a=e.data,d=(i.usage.inputTokens||0)+(i.usage.outputTokens||0),f=a.input_tokens??a.inputTokens??0,m=a.output_tokens??a.outputTokens??0,g=d+f+m;r.usage={inputTokens:(i.usage.inputTokens||0)+f,outputTokens:(i.usage.outputTokens||0)+m,cacheCreationInputTokens:(i.usage.cacheCreationInputTokens||0)+(a.cache_creation_input_tokens??a.cacheCreationInputTokens??0),cacheReadInputTokens:(i.usage.cacheReadInputTokens||0)+(a.cache_read_input_tokens??a.cacheReadInputTokens??0)},!(t!=null&&t.replay)&&Math.floor(g/1e3)>Math.floor(d/1e3)&&l.push({id:0,kind:"usage-tick",at:n,label:`${Math.floor(g/1e3)}k tokens`});break}case"tool_result":{const a=e.data;r.agents=c$(i.agents,a==null?void 0:a.toolUseId,n);break}}return{next:r,newActivity:l}}const fv=jn((i,e)=>({tabs:{},refs:{},unsubs:{},subscribe:(t,n,r)=>{const l={...e().refs};if(l[t]=(l[t]??0)+1,i({refs:l}),l[t]>1)return;i({tabs:{...e().tabs,[t]:d$(t,n,r)}});const p=window.api.transcripts.onEvent(t,a=>e().ingestBatch(t,a));i({unsubs:{...e().unsubs,[t]:p}}),window.api.transcripts.subscribe({tabId:t,cwd:n,sessionUuid:r}).then(async a=>{const d=e().tabs[t];if(!d)return;if(!a.ok){const{toast:m}=await fi(async()=>{const{toast:g}=await Promise.resolve().then(()=>B1);return{toast:g}},void 0,import.meta.url);m.error(`Live view unavailable: ${a.error??"subscribe failed"}`),i({tabs:{...e().tabs,[t]:{...d,path:null}}});return}i({tabs:{...e().tabs,[t]:{...d,path:a.path}}});const f=await window.api.transcripts.buffer(t);e().ingestBatch(t,f,{replay:!0})}).catch(a=>console.error("[live] transcripts.subscribe failed:",t,a))},unsubscribe:t=>{const n={...e().refs};if(!n[t])return;if(n[t]--,n[t]>0){i({refs:n});return}delete n[t];const r=e().unsubs[t];r==null||r();const l={...e().unsubs};delete l[t];const p={...e().tabs};delete p[t],window.api.transcripts.unsubscribe(t),i({refs:n,unsubs:l,tabs:p})},ingest:(t,n,r)=>{e().ingestBatch(t,[n],r)},ingestBatch:(t,n,r)=>{const l=e().tabs[t];if(!l||n.length===0)return;let p=l,a=[];for(const d of n){const{next:f,newActivity:m}=u$(p,d,r);p=f,a=a.concat(m)}if(a.length>0){let d=l.activitySeq;const f=a.map(m=>({...m,id:++d}));p={...p,activitySeq:d,activityRing:[...l.activityRing,...f].slice(-32)}}i({tabs:{...e().tabs,[t]:p}})}}));function h$(i){const e=fv(r=>r.subscribe),t=fv(r=>r.unsubscribe),n=fv(r=>i?r.tabs[i.id]:void 0);return z.useEffect(()=>{if(i)return e(i.id,i.cwd,i.sessionId),()=>t(i.id)},[i==null?void 0:i.id,i==null?void 0:i.cwd,i==null?void 0:i.sessionId,e,t]),n}function $C(i){if(!i)return null;const e=new Date(i);if(Number.isNaN(e.getTime()))return null;const t=e.getTime()-Date.now();if(t<=0)return{rel:"now",abs:""};const n=Math.floor(t/864e5),r=Math.floor(t%864e5/36e5),l=Math.floor(t%36e5/6e4),p=n>0?`${n}d ${r}h`:r>0?`${r}h ${l}m`:`${l}m`,a=n>=1?e.toLocaleString("en-US",{timeZone:"America/Los_Angeles",weekday:"short",hour:"numeric",minute:"2-digit"}):e.toLocaleTimeString("en-US",{timeZone:"America/Los_Angeles",hour:"numeric",minute:"2-digit"});return{rel:p,abs:`${a} PT`}}function Ob(i){return!i||typeof i.utilization!="number"||Number.isNaN(i.utilization)?null:Math.round(i.utilization)}function Zx(i,e){const t=Ob(e);if(t==null)return`${i} — usage unavailable`;const n=$C((e==null?void 0:e.resets_at)??null),r=n?` · resets in ${n.rel}${n.abs?` (${n.abs})`:""}`:"";return`${i} · ${t}% used${r} — click to open Home`}function nB(i,e){return i?i==="session"||i==="five_hour"?"Session · 5h":i==="weekly_all"?"Weekly · all models":i==="weekly_scoped"?"Weekly · scoped":i:null}const AC=z.createContext(null);function p$({panelId:i,children:e}){return c.jsx(AC.Provider,{value:i,children:e})}function Yv(i){const e=z.useContext(AC),t=i??e;return ji(n=>t==null||n.focusedPanelId===t)}function Uw(i){const e=Yv(i),t=z.useRef(e);return t.current=e,t}const f$=5e3;let fd=null;const Lb=new Set;let P_=0,Wf=null;function m$(){Lb.forEach(i=>i())}async function Av(){try{fd=await window.api.schedule.sessionSlots(),m$()}catch{}}const g$=0,v$=10;async function _$(i){fd||await Av();const e=fd?fd.min:g$,t=fd?fd.max:v$,n=Math.min(t,Math.max(e,Math.round(i)));await window.api.schedule.setSessionSlots(n),await Av()}function b$(){Wf==null&&(Av(),Wf=setInterval(()=>{Av()},f$))}function w$(){Wf!=null&&(clearInterval(Wf),Wf=null)}function Vw(i){const e=Yv(i),[,t]=z.useState(0);return z.useEffect(()=>{const n=()=>t(r=>r+1);return Lb.add(n),()=>{Lb.delete(n)}},[]),z.useEffect(()=>{if(e)return P_+=1,b$(),()=>{P_-=1,P_<=0&&w$()}},[e]),fd}const y$=360*60*1e3;let IC=null;const zb=new Set;let j_=0,Uf=null;async function Qx(){try{IC=await window.api.app.updateStatus(),zb.forEach(i=>i())}catch{}}function x$(){Uf==null&&(Qx(),Uf=setInterval(()=>{Qx()},y$))}function S$(){Uf!=null&&(clearInterval(Uf),Uf=null)}function C$(){const[,i]=z.useState(0);return z.useEffect(()=>{const e=()=>i(t=>t+1);return zb.add(e),j_+=1,x$(),()=>{zb.delete(e),j_-=1,j_<=0&&S$()}},[]),IC}let PC=null;const Bb=new Set;let R_=0,mv=null,Gb=!1;function e0(i){PC=i,Bb.forEach(e=>e())}function k$(){Gb||(Gb=!0,mv=window.api.updater.onStatus(e0),window.api.updater.status().then(e0).catch(()=>{}))}function E$(){Gb=!1,mv&&(mv(),mv=null)}function T$(){const[,i]=z.useState(0);return z.useEffect(()=>{const e=()=>i(t=>t+1);return Bb.add(e),R_+=1,k$(),()=>{Bb.delete(e),R_-=1,R_<=0&&E$()}},[]),PC}function D$({total:i,inUse:e,size:t}){const n=Math.min(Math.max(e,0),i),r=t==="md"?"w-3.5 h-3.5 rounded-full border":"w-2 h-2 rounded-full border";return c.jsx(c.Fragment,{children:Array.from({length:i},(l,p)=>c.jsx("span",{"data-testid":"slot-dot","data-filled":p<n?"true":"false",className:`${r} ${p<n?"bg-accent border-accent":"bg-bg border-line"}`},p))})}function $$({onNavigate:i}){const e=Ct(ce=>ce.tabs),t=Ct(ce=>ce.activeTabId),n=e.find(ce=>ce.id===t)??null,r=h$(n),l=(r==null?void 0:r.lastEventAt)??0,p=em(ce=>ce.data),a=Wr(ce=>{var ve;return((ve=ce.snapshot)==null?void 0:ve.paused)??null}),d=Ww((n==null?void 0:n.cwd)??null),f=Vw(),m=C$(),g=T$(),y=Is(ce=>ce.show),[,D]=z.useState(0);z.useEffect(()=>{const ce=setInterval(()=>D(ve=>ve+1),6e4);return()=>clearInterval(ce)},[]);const E=async()=>{const ce=(g==null?void 0:g.latest)??"";try{const ve=await window.api.updater.install(!1),Ee=(ve==null?void 0:ve.status)??await window.api.updater.status();(Ee==null?void 0:Ee.state)==="deferred"&&y("info",`Update v${ce} will install when ${Ee.busyReason??"running jobs"} finish`)}catch(ve){y("error",ve instanceof Error?ve.message:String(ve))}},C=(r==null?void 0:r.todos)??[],[b,w]=z.useState(!1),x=z.useRef(null);z.useEffect(()=>{if(!b)return;const ce=ve=>{x.current&&!x.current.contains(ve.target)&&w(!1)};return document.addEventListener("mousedown",ce),()=>document.removeEventListener("mousedown",ce)},[b]),z.useEffect(()=>{C.length===0&&w(!1)},[C.length]);const S=TC(p),T=(S==null?void 0:S.usage.five_hour)??null,j=(S==null?void 0:S.usage.seven_day)??null,N=Ob(T),L=Ob(j),R=(p==null?void 0:p.kind)==="ok"||(p==null?void 0:p.kind)==="ok-stale",F=l>0?P$(Date.now()-l):"—",V=(f==null?void 0:f.total)??5,te=f?Math.min(Math.max(f.inUse,0),f.total):0,he=f?`${te} / ${V}`:`— / ${V}`,ee=f&&f.holders.length>0?`
|
|
2929
2929
|
`+f.holders.slice(0,5).map(ce=>ce.owner).join(`
|
|
2930
|
-
`):"",we=`${he} Claude sessions running${ee}`;return c.jsxs("div",{className:"h-[30px] shrink-0 bg-bg-elev border-t border-line flex items-center gap-4 px-[18px] font-mono text-[11.5px] text-fg-dim","data-testid":"tour-statusbar",children:[c.jsxs("button",{onClick:()=>i==null?void 0:i("settings"),className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:R?"Connected to Anthropic":"Disconnected",children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${R?"bg-sage":"bg-fg-faint"}`}),c.jsx("span",{children:R?"connected":"offline"})]}),c.jsxs("button",{onClick:()=>i==null?void 0:i("overview"),className:"hover:text-fg transition-colors",title:Zx("Session (5h window)",T),"data-testid":"footer-usage-session",children:["session ",c.jsx("span",{className:"text-fg",children:N!=null?`${N}%`:"—"})]}),c.jsxs("button",{onClick:()=>i==null?void 0:i("overview"),className:"hover:text-fg transition-colors",title:Zx("Weekly window (all models)",j),"data-testid":"footer-usage-weekly",children:["weekly ",c.jsx("span",{className:"text-fg",children:L!=null?`${L}%`:"—"})]}),a&&c.jsxs("button",{onClick:()=>i==null?void 0:i("scheduler"),title:"Scheduler is paused — click to open Scheduler",className:`flex items-center gap-1 px-1.5 py-0.5 rounded border font-mono text-[10.5px] transition-colors ${a.reason==="auth"||a.reason==="network"?"border-red-700/60 text-red-300 hover:bg-red-900/20":"border-amber-700/60 text-amber-300 hover:bg-amber-900/20"}`,children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-80"}),"Scheduler paused · ",a.reason]}),n&&c.jsxs("span",{className:"text-fg-faint",title:n.cwd,children:[n.label,d&&c.jsxs("span",{className:"text-fg-dim",children:[" · ⌥",d]})]}),c.jsxs("span",{className:"text-fg-faint",children:["last activity: ",c.jsx("span",{className:"text-fg-dim",children:F})]}),C.length>0&&c.jsx(A$,{ref:x,todos:C,open:b,onToggle:()=>w(ce=>!ce)}),c.jsx("span",{className:"flex-1"}),c.jsx("button",{onClick:()=>i==null?void 0:i("overview"),className:"flex items-center gap-1 hover:text-fg transition-colors",title:we,"data-testid":"footer-active-sessions",children:f&&f.total===0?c.jsx("span",{className:"text-fg-faint",children:"pool paused"}):c.jsx(D$,{total:V,inUse:(f==null?void 0:f.inUse)??0,size:"sm"})}),(g==null?void 0:g.state)==="ready"?c.jsxs("button",{type:"button",className:"text-amber-300 hover:underline",title:"A new version is downloaded. Click to restart and install — running jobs are waited for first.","data-testid":"footer-version",onClick:()=>{E()},children:["Update ready — restart to install v",g.latest]}):(g==null?void 0:g.state)==="deferred"?c.jsxs("span",{className:"text-amber-300",title:`Waiting for ${g.busyReason??"running jobs"} to finish before restarting`,"data-testid":"footer-version",children:["v",g.latest," installs when idle"]}):(g==null?void 0:g.state)==="downloading"?c.jsxs("span",{className:"text-fg-dim","data-testid":"footer-version",children:["Downloading v",g.latest,"…"]}):m!=null&&m.behind&&m.latest&&m.channel==="installer"?c.jsxs("button",{type:"button",className:"text-amber-300 hover:underline",title:`v${m.current} → v${m.latest}`,"data-testid":"footer-version",onClick:()=>{const ce=m.downloadUrl;ce&&window.api.shell.open({as:"external",url:ce}).catch(()=>{y("error",`Couldn't open URL: ${ce}`)})},children:["Download v",m.latest]}):m!=null&&m.behind&&m.latest?c.jsxs("span",{className:"text-amber-300",title:"A newer version is published — update the app. A stale npx cache can pin an old version.","data-testid":"footer-version",children:["v",m.current," → v",m.latest]}):c.jsxs("span",{className:"text-fg-dim","data-testid":"footer-version",children:["v",(m==null?void 0:m.current)??"0.119.1"]})]})}const A$=z.forwardRef(function({todos:e,open:t,onToggle:n},r){const l={completed:e.filter(p=>p.status==="completed").length,in_progress:e.filter(p=>p.status==="in_progress").length,pending:e.filter(p=>p.status==="pending").length};return c.jsxs("div",{ref:r,className:"relative",children:[c.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:"Live to-dos for this session","data-testid":"footer-todos",children:[c.jsxs("span",{className:"text-green-400",children:["✓",l.completed]}),c.jsxs("span",{className:"text-accent",children:["●",l.in_progress]}),c.jsxs("span",{className:"text-fg-dim",children:["○",l.pending]}),c.jsxs("span",{className:"text-fg-faint",children:["todos ",t?"▾":"▴"]})]}),t&&c.jsx("div",{className:`absolute bottom-full left-0 mb-1.5 w-80 max-h-72 overflow-auto bg-bg-elev border border-line rounded shadow-xl p-2 ${dn.dialog}`,"data-testid":"footer-todos-popover",children:c.jsx("ul",{className:"space-y-0.5",children:e.map((p,a)=>c.jsxs("li",{className:`flex items-start gap-2 py-1 px-1.5 rounded ${p.status==="in_progress"?"bg-bg-hi":""}`,children:[c.jsx(I$,{status:p.status}),c.jsx("span",{className:p.status==="completed"?"text-fg-faint line-through":p.status==="in_progress"?"text-fg":"text-fg-dim",children:p.status==="in_progress"&&p.activeForm?p.activeForm:p.content})]},a))})})]})});function I$({status:i}){return i==="completed"?c.jsx("span",{className:"text-green-400 w-3 shrink-0",children:"✓"}):i==="in_progress"?c.jsx("span",{className:"w-3 shrink-0",children:c.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse"})}):c.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:"○"})}function P$(i){const e=Math.max(0,Math.floor(i/1e3));if(e<60)return`${e}s ago`;const t=Math.floor(e/60);return t<60?`${t}m ago`:`${Math.floor(t/60)}h ago`}function j$({onClose:i,onSent:e}){const t=Ct(L=>L.tabs),[n,r]=z.useState(""),[l,p]=z.useState(()=>Object.fromEntries(t.map(L=>[L.id,!0]))),[a,d]=z.useState(!1),[f,m]=z.useState({}),g=z.useRef(null),y=z.useRef(e);z.useEffect(()=>{y.current=e},[e]),z.useEffect(()=>{p(L=>{const R={};for(const F of t)R[F.id]=L[F.id]??!0;return R})},[t]),z.useEffect(()=>{var L;(L=g.current)==null||L.focus()},[]),z.useEffect(()=>window.api.pty.onWriteError(R=>{m(F=>R.tabId in F?{...F,[R.tabId]:"skipped"}:F)}),[]),z.useEffect(()=>{if(Object.keys(f).length===0)return;const L=Object.values(f).filter(F=>F==="sent").length,R=window.setTimeout(()=>y.current(L),1500);return()=>window.clearTimeout(R)},[f]);const D=t.filter(L=>l[L.id]).map(L=>L.id),E=D.length,C=Object.keys(f).length>0,b=n.length>0&&E>0&&!a&&!C,w=()=>{if(!b)return;d(!0);const L=Ct.getState().tabs,R=new Set(L.map(V=>V.id)),F={};for(const V of D)R.has(V)?(window.api.pty.write({tabId:V,data:n+"\r"}),F[V]="sent"):F[V]="skipped";m(F),d(!1)},x=L=>{if(L.key==="Escape"){L.preventDefault(),L.stopPropagation(),i();return}L.key==="Enter"&&(L.metaKey||L.ctrlKey)&&(L.preventDefault(),w())},S=t.length>0&&t.every(L=>l[L.id]),T=()=>{const L=!S;p(Object.fromEntries(t.map(R=>[R.id,L])))},j=Object.values(f).some(L=>L==="skipped"),N=C?j?"Sent (some skipped)":"Sent":`Send to ${E} tab${E===1?"":"s"}`;return c.jsxs("div",{className:"border-b border-line bg-bg-elev px-4 py-3 flex flex-col gap-2 shrink-0",onKeyDown:x,"data-testid":"broadcast-bar",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"text-xs text-fg-dim uppercase tracking-wider",children:"Broadcast"}),c.jsx("div",{className:"text-[10px] text-fg-faint",children:"Esc to close · Cmd/Ctrl+Enter to send"})]}),c.jsx("textarea",{ref:g,value:n,onChange:L=>r(L.target.value),rows:3,placeholder:"Prompt to broadcast…",className:"w-full bg-bg border border-line rounded px-2 py-1.5 text-xs text-fg font-mono resize-y focus:outline-none focus:border-fg-faint"}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-fg-dim cursor-pointer select-none",children:[c.jsx("input",{type:"checkbox",checked:S,onChange:T,className:"accent-accent"}),c.jsxs("span",{children:["All tabs (",E,"/",t.length,")"]})]}),c.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1 max-h-24 overflow-y-auto pl-4",children:t.map(L=>c.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-fg-dim cursor-pointer select-none",children:[c.jsx("input",{type:"checkbox",checked:!!l[L.id],onChange:R=>p(F=>({...F,[L.id]:R.target.checked})),className:"accent-accent"}),c.jsx("span",{className:"truncate max-w-[12rem]",children:L.label}),f[L.id]==="sent"&&c.jsx("span",{"data-testid":"broadcast-row-sent",className:"text-[10px] text-green-500",children:"✓"}),f[L.id]==="skipped"&&c.jsx("span",{"data-testid":"broadcast-row-skipped",className:"text-[10px] text-red-400",children:"×"})]},L.id))})]}),c.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[c.jsx("button",{onClick:i,className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:"Cancel"}),c.jsx("button",{onClick:w,disabled:!b,className:"px-2 py-0.5 text-[10px] text-fg border border-accent-muted hover:border-accent rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:N})]})]})}function R$({tabId:i,cwd:e,onClose:t}){const n=Gf(E=>E.watchersForTab(i)),r=Gf(E=>E.add),l=Gf(E=>E.remove),p=z.useRef(null),[a,d]=z.useState(""),[f,m]=z.useState(""),[g,y]=z.useState(!1);z.useEffect(()=>{const E=C=>{C.key==="Escape"&&t()};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[t]),z.useEffect(()=>{const E=C=>{p.current&&!p.current.contains(C.target)&&t()};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[t]);const D=async()=>{const E=f.trim();if(!E||g)return;y(!0);const C=await r({tabId:i,label:a.trim(),command:E,cwd:e});y(!1),C&&(d(""),m(""))};return c.jsxs("div",{ref:p,className:"absolute right-2 top-full mt-1 z-30 w-[420px] max-w-[calc(100vw-1rem)] bg-bg-elev border border-line rounded shadow-lg p-3 text-xs",role:"dialog","aria-label":"Watchers","data-testid":"watchers-popover",children:[c.jsxs("div",{className:"flex items-center mb-2",children:[c.jsx("span",{className:"text-fg-dim uppercase tracking-wider",children:"Watchers"}),c.jsxs("span",{className:"text-fg-faint ml-2",children:[n.length," active"]}),c.jsx("div",{className:"flex-1"}),c.jsx("button",{onClick:t,className:"text-fg-faint hover:text-fg",title:"Close",children:"×"})]}),c.jsxs("div",{className:"flex flex-col gap-1.5 mb-3",children:[c.jsx("input",{value:a,onChange:E=>d(E.target.value),placeholder:"label (optional)",className:"bg-bg border border-line rounded px-2 py-1 text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint"}),c.jsxs("div",{className:"flex gap-1.5",children:[c.jsx("input",{value:f,onChange:E=>m(E.target.value),onKeyDown:E=>{E.key==="Enter"&&D()},placeholder:"shell command — e.g. npm test --watch",className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint font-mono","data-testid":"watcher-command-input"}),c.jsx("button",{onClick:D,disabled:!f.trim()||g,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"watcher-add",children:"Add"})]}),c.jsxs("span",{className:"text-fg-faint",children:["cwd: ",c.jsx("span",{className:"font-mono",children:e})]})]}),n.length===0?c.jsx("div",{className:"text-fg-faint italic py-2",children:"no watchers — add one above"}):c.jsx("ul",{className:"flex flex-col gap-2 max-h-64 overflow-y-auto",children:n.map(E=>{const C=E.lines[E.lines.length-1];return c.jsxs("li",{className:"border border-line rounded p-2 bg-bg",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"font-medium text-fg truncate",children:E.label}),c.jsxs("span",{className:"text-fg-faint",children:[E.lineCount," line",E.lineCount===1?"":"s"]}),c.jsx("div",{className:"flex-1"}),c.jsx("button",{onClick:()=>l(E.watcherId),className:"text-fg-faint hover:text-red-400",title:"Stop watcher","data-testid":`watcher-remove-${E.watcherId}`,children:"stop"})]}),c.jsx("div",{className:"text-fg-faint font-mono text-[10px] truncate mt-0.5",title:E.command,children:E.command}),c.jsx("div",{className:"text-fg-dim font-mono text-[10px] truncate mt-1",title:(C==null?void 0:C.line)??"",children:C?C.line:c.jsx("span",{className:"italic text-fg-faint",children:"waiting for output…"})})]},E.watcherId)})})]})}/**
|
|
2930
|
+
`):"",we=`${he} Claude sessions running${ee}`;return c.jsxs("div",{className:"h-[30px] shrink-0 bg-bg-elev border-t border-line flex items-center gap-4 px-[18px] font-mono text-[11.5px] text-fg-dim","data-testid":"tour-statusbar",children:[c.jsxs("button",{onClick:()=>i==null?void 0:i("settings"),className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:R?"Connected to Anthropic":"Disconnected",children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${R?"bg-sage":"bg-fg-faint"}`}),c.jsx("span",{children:R?"connected":"offline"})]}),c.jsxs("button",{onClick:()=>i==null?void 0:i("overview"),className:"hover:text-fg transition-colors",title:Zx("Session (5h window)",T),"data-testid":"footer-usage-session",children:["session ",c.jsx("span",{className:"text-fg",children:N!=null?`${N}%`:"—"})]}),c.jsxs("button",{onClick:()=>i==null?void 0:i("overview"),className:"hover:text-fg transition-colors",title:Zx("Weekly window (all models)",j),"data-testid":"footer-usage-weekly",children:["weekly ",c.jsx("span",{className:"text-fg",children:L!=null?`${L}%`:"—"})]}),a&&c.jsxs("button",{onClick:()=>i==null?void 0:i("scheduler"),title:"Scheduler is paused — click to open Scheduler",className:`flex items-center gap-1 px-1.5 py-0.5 rounded border font-mono text-[10.5px] transition-colors ${a.reason==="auth"||a.reason==="network"?"border-red-700/60 text-red-300 hover:bg-red-900/20":"border-amber-700/60 text-amber-300 hover:bg-amber-900/20"}`,children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-80"}),"Scheduler paused · ",a.reason]}),n&&c.jsxs("span",{className:"text-fg-faint",title:n.cwd,children:[n.label,d&&c.jsxs("span",{className:"text-fg-dim",children:[" · ⌥",d]})]}),c.jsxs("span",{className:"text-fg-faint",children:["last activity: ",c.jsx("span",{className:"text-fg-dim",children:F})]}),C.length>0&&c.jsx(A$,{ref:x,todos:C,open:b,onToggle:()=>w(ce=>!ce)}),c.jsx("span",{className:"flex-1"}),c.jsx("button",{onClick:()=>i==null?void 0:i("overview"),className:"flex items-center gap-1 hover:text-fg transition-colors",title:we,"data-testid":"footer-active-sessions",children:f&&f.total===0?c.jsx("span",{className:"text-fg-faint",children:"pool paused"}):c.jsx(D$,{total:V,inUse:(f==null?void 0:f.inUse)??0,size:"sm"})}),(g==null?void 0:g.state)==="ready"?c.jsxs("button",{type:"button",className:"text-amber-300 hover:underline",title:"A new version is downloaded. Click to restart and install — running jobs are waited for first.","data-testid":"footer-version",onClick:()=>{E()},children:["Update ready — restart to install v",g.latest]}):(g==null?void 0:g.state)==="deferred"?c.jsxs("span",{className:"text-amber-300",title:`Waiting for ${g.busyReason??"running jobs"} to finish before restarting`,"data-testid":"footer-version",children:["v",g.latest," installs when idle"]}):(g==null?void 0:g.state)==="downloading"?c.jsxs("span",{className:"text-fg-dim","data-testid":"footer-version",children:["Downloading v",g.latest,"…"]}):m!=null&&m.behind&&m.latest&&m.channel==="installer"?c.jsxs("button",{type:"button",className:"text-amber-300 hover:underline",title:`v${m.current} → v${m.latest}`,"data-testid":"footer-version",onClick:()=>{const ce=m.downloadUrl;ce&&window.api.shell.open({as:"external",url:ce}).catch(()=>{y("error",`Couldn't open URL: ${ce}`)})},children:["Download v",m.latest]}):m!=null&&m.behind&&m.latest?c.jsxs("span",{className:"text-amber-300",title:"A newer version is published — update the app. A stale npx cache can pin an old version.","data-testid":"footer-version",children:["v",m.current," → v",m.latest]}):c.jsxs("span",{className:"text-fg-dim","data-testid":"footer-version",children:["v",(m==null?void 0:m.current)??"0.120.0"]})]})}const A$=z.forwardRef(function({todos:e,open:t,onToggle:n},r){const l={completed:e.filter(p=>p.status==="completed").length,in_progress:e.filter(p=>p.status==="in_progress").length,pending:e.filter(p=>p.status==="pending").length};return c.jsxs("div",{ref:r,className:"relative",children:[c.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:"Live to-dos for this session","data-testid":"footer-todos",children:[c.jsxs("span",{className:"text-green-400",children:["✓",l.completed]}),c.jsxs("span",{className:"text-accent",children:["●",l.in_progress]}),c.jsxs("span",{className:"text-fg-dim",children:["○",l.pending]}),c.jsxs("span",{className:"text-fg-faint",children:["todos ",t?"▾":"▴"]})]}),t&&c.jsx("div",{className:`absolute bottom-full left-0 mb-1.5 w-80 max-h-72 overflow-auto bg-bg-elev border border-line rounded shadow-xl p-2 ${dn.dialog}`,"data-testid":"footer-todos-popover",children:c.jsx("ul",{className:"space-y-0.5",children:e.map((p,a)=>c.jsxs("li",{className:`flex items-start gap-2 py-1 px-1.5 rounded ${p.status==="in_progress"?"bg-bg-hi":""}`,children:[c.jsx(I$,{status:p.status}),c.jsx("span",{className:p.status==="completed"?"text-fg-faint line-through":p.status==="in_progress"?"text-fg":"text-fg-dim",children:p.status==="in_progress"&&p.activeForm?p.activeForm:p.content})]},a))})})]})});function I$({status:i}){return i==="completed"?c.jsx("span",{className:"text-green-400 w-3 shrink-0",children:"✓"}):i==="in_progress"?c.jsx("span",{className:"w-3 shrink-0",children:c.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse"})}):c.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:"○"})}function P$(i){const e=Math.max(0,Math.floor(i/1e3));if(e<60)return`${e}s ago`;const t=Math.floor(e/60);return t<60?`${t}m ago`:`${Math.floor(t/60)}h ago`}function j$({onClose:i,onSent:e}){const t=Ct(L=>L.tabs),[n,r]=z.useState(""),[l,p]=z.useState(()=>Object.fromEntries(t.map(L=>[L.id,!0]))),[a,d]=z.useState(!1),[f,m]=z.useState({}),g=z.useRef(null),y=z.useRef(e);z.useEffect(()=>{y.current=e},[e]),z.useEffect(()=>{p(L=>{const R={};for(const F of t)R[F.id]=L[F.id]??!0;return R})},[t]),z.useEffect(()=>{var L;(L=g.current)==null||L.focus()},[]),z.useEffect(()=>window.api.pty.onWriteError(R=>{m(F=>R.tabId in F?{...F,[R.tabId]:"skipped"}:F)}),[]),z.useEffect(()=>{if(Object.keys(f).length===0)return;const L=Object.values(f).filter(F=>F==="sent").length,R=window.setTimeout(()=>y.current(L),1500);return()=>window.clearTimeout(R)},[f]);const D=t.filter(L=>l[L.id]).map(L=>L.id),E=D.length,C=Object.keys(f).length>0,b=n.length>0&&E>0&&!a&&!C,w=()=>{if(!b)return;d(!0);const L=Ct.getState().tabs,R=new Set(L.map(V=>V.id)),F={};for(const V of D)R.has(V)?(window.api.pty.write({tabId:V,data:n+"\r"}),F[V]="sent"):F[V]="skipped";m(F),d(!1)},x=L=>{if(L.key==="Escape"){L.preventDefault(),L.stopPropagation(),i();return}L.key==="Enter"&&(L.metaKey||L.ctrlKey)&&(L.preventDefault(),w())},S=t.length>0&&t.every(L=>l[L.id]),T=()=>{const L=!S;p(Object.fromEntries(t.map(R=>[R.id,L])))},j=Object.values(f).some(L=>L==="skipped"),N=C?j?"Sent (some skipped)":"Sent":`Send to ${E} tab${E===1?"":"s"}`;return c.jsxs("div",{className:"border-b border-line bg-bg-elev px-4 py-3 flex flex-col gap-2 shrink-0",onKeyDown:x,"data-testid":"broadcast-bar",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"text-xs text-fg-dim uppercase tracking-wider",children:"Broadcast"}),c.jsx("div",{className:"text-[10px] text-fg-faint",children:"Esc to close · Cmd/Ctrl+Enter to send"})]}),c.jsx("textarea",{ref:g,value:n,onChange:L=>r(L.target.value),rows:3,placeholder:"Prompt to broadcast…",className:"w-full bg-bg border border-line rounded px-2 py-1.5 text-xs text-fg font-mono resize-y focus:outline-none focus:border-fg-faint"}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-fg-dim cursor-pointer select-none",children:[c.jsx("input",{type:"checkbox",checked:S,onChange:T,className:"accent-accent"}),c.jsxs("span",{children:["All tabs (",E,"/",t.length,")"]})]}),c.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1 max-h-24 overflow-y-auto pl-4",children:t.map(L=>c.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-fg-dim cursor-pointer select-none",children:[c.jsx("input",{type:"checkbox",checked:!!l[L.id],onChange:R=>p(F=>({...F,[L.id]:R.target.checked})),className:"accent-accent"}),c.jsx("span",{className:"truncate max-w-[12rem]",children:L.label}),f[L.id]==="sent"&&c.jsx("span",{"data-testid":"broadcast-row-sent",className:"text-[10px] text-green-500",children:"✓"}),f[L.id]==="skipped"&&c.jsx("span",{"data-testid":"broadcast-row-skipped",className:"text-[10px] text-red-400",children:"×"})]},L.id))})]}),c.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[c.jsx("button",{onClick:i,className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:"Cancel"}),c.jsx("button",{onClick:w,disabled:!b,className:"px-2 py-0.5 text-[10px] text-fg border border-accent-muted hover:border-accent rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:N})]})]})}function R$({tabId:i,cwd:e,onClose:t}){const n=Gf(E=>E.watchersForTab(i)),r=Gf(E=>E.add),l=Gf(E=>E.remove),p=z.useRef(null),[a,d]=z.useState(""),[f,m]=z.useState(""),[g,y]=z.useState(!1);z.useEffect(()=>{const E=C=>{C.key==="Escape"&&t()};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[t]),z.useEffect(()=>{const E=C=>{p.current&&!p.current.contains(C.target)&&t()};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[t]);const D=async()=>{const E=f.trim();if(!E||g)return;y(!0);const C=await r({tabId:i,label:a.trim(),command:E,cwd:e});y(!1),C&&(d(""),m(""))};return c.jsxs("div",{ref:p,className:"absolute right-2 top-full mt-1 z-30 w-[420px] max-w-[calc(100vw-1rem)] bg-bg-elev border border-line rounded shadow-lg p-3 text-xs",role:"dialog","aria-label":"Watchers","data-testid":"watchers-popover",children:[c.jsxs("div",{className:"flex items-center mb-2",children:[c.jsx("span",{className:"text-fg-dim uppercase tracking-wider",children:"Watchers"}),c.jsxs("span",{className:"text-fg-faint ml-2",children:[n.length," active"]}),c.jsx("div",{className:"flex-1"}),c.jsx("button",{onClick:t,className:"text-fg-faint hover:text-fg",title:"Close",children:"×"})]}),c.jsxs("div",{className:"flex flex-col gap-1.5 mb-3",children:[c.jsx("input",{value:a,onChange:E=>d(E.target.value),placeholder:"label (optional)",className:"bg-bg border border-line rounded px-2 py-1 text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint"}),c.jsxs("div",{className:"flex gap-1.5",children:[c.jsx("input",{value:f,onChange:E=>m(E.target.value),onKeyDown:E=>{E.key==="Enter"&&D()},placeholder:"shell command — e.g. npm test --watch",className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint font-mono","data-testid":"watcher-command-input"}),c.jsx("button",{onClick:D,disabled:!f.trim()||g,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"watcher-add",children:"Add"})]}),c.jsxs("span",{className:"text-fg-faint",children:["cwd: ",c.jsx("span",{className:"font-mono",children:e})]})]}),n.length===0?c.jsx("div",{className:"text-fg-faint italic py-2",children:"no watchers — add one above"}):c.jsx("ul",{className:"flex flex-col gap-2 max-h-64 overflow-y-auto",children:n.map(E=>{const C=E.lines[E.lines.length-1];return c.jsxs("li",{className:"border border-line rounded p-2 bg-bg",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"font-medium text-fg truncate",children:E.label}),c.jsxs("span",{className:"text-fg-faint",children:[E.lineCount," line",E.lineCount===1?"":"s"]}),c.jsx("div",{className:"flex-1"}),c.jsx("button",{onClick:()=>l(E.watcherId),className:"text-fg-faint hover:text-red-400",title:"Stop watcher","data-testid":`watcher-remove-${E.watcherId}`,children:"stop"})]}),c.jsx("div",{className:"text-fg-faint font-mono text-[10px] truncate mt-0.5",title:E.command,children:E.command}),c.jsx("div",{className:"text-fg-dim font-mono text-[10px] truncate mt-1",title:(C==null?void 0:C.line)??"",children:C?C.line:c.jsx("span",{className:"italic text-fg-faint",children:"waiting for output…"})})]},E.watcherId)})})]})}/**
|
|
2931
2931
|
* dockview-core
|
|
2932
2932
|
* @version 6.6.1
|
|
2933
2933
|
* @link https://github.com/mathuo/dockview
|
|
@@ -2939,7 +2939,7 @@ ${I}`,M=v.createShaderModule({code:P,label:s.name});li("verbose",()=>`[WebGPU] $
|
|
|
2939
2939
|
* @license MIT
|
|
2940
2940
|
*/const dk=(i,e)=>{const[,t]=Rt.useState(0),n=Rt.useRef(i.componentProps);return Rt.useImperativeHandle(e,()=>({update:r=>{n.current=Object.assign(Object.assign({},n.current),r),t(l=>l+1)}}),[]),Rt.createElement(i.component,n.current)};dk.displayName="DockviewReactJsBridge";const II=(()=>{let i=1;return{next:()=>`dockview_react_portal_key_${(i++).toString()}`}})(),PI=Rt.createContext({});class ka{constructor(e,t,n,r,l){this.parent=e,this.portalStore=t,this.component=n,this.parameters=r,this.context=l,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw new Error("invalid operation: resource is already disposed");this.componentInstance?this.componentInstance.update(e):this._initialProps=Object.assign(Object.assign({},this._initialProps),e)}createPortal(){if(this.disposed)throw new Error("invalid operation: resource is already disposed");if(!jI(this.component))throw new Error("Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components");const e=Rt.createElement(Rt.forwardRef(dk),{component:this.component,componentProps:this.parameters,ref:r=>{this.componentInstance=r,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),t=this.context?Rt.createElement(PI.Provider,{value:this.context},e):e,n=H2.createPortal(t,this.parent,II.next());this.ref={portal:n,disposable:this.portalStore.addPortal(n)}}dispose(){var e;(e=this.ref)===null||e===void 0||e.disposable.dispose(),this.disposed=!0}}const Zv=()=>{const[i,e]=Rt.useState([]);Rt.useDebugValue(`Portal count: ${i.length}`);const t=Rt.useCallback(n=>{e(l=>[...l,n]);let r=!1;return an.from(()=>{if(r)throw new Error("invalid operation: resource already disposed");r=!0,e(l=>l.filter(p=>p!==n))})},[]);return[i,t]};function jI(i){return typeof i=="function"||!!(i!=null&&i.$$typeof)}class _0{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._onDidFocus=new Ve,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new Ve,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new ka(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;(t=this.part)===null||t===void 0||t.update({params:e.params})}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),(e=this.part)===null||e===void 0||e.dispose()}}class b0{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new ka(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,tabLocation:e.tabLocation})}update(e){var t;(t=this.part)===null||t===void 0||t.update({params:e.params})}layout(e,t){}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}class w0{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new ka(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi})}focus(){}update(e){var t,n,r;this.parameters&&(this.parameters.params=e.params),(t=this.part)===null||t===void 0||t.update({params:(r=(n=this.parameters)===null||n===void 0?void 0:n.params)!==null&&r!==void 0?r:{}})}layout(e,t){}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}class RI{get element(){return this._element}get part(){return this._part}constructor(e,t,n){this.component=e,this.reactPortalStore=t,this._group=n,this.mutableDisposable=new Bn,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.mutableDisposable.value=new qt(this._group.model.onDidAddPanel(()=>{this.updatePanels()}),this._group.model.onDidRemovePanel(()=>{this.updatePanels()}),this._group.model.onDidActivePanelChange(()=>{this.updateActivePanel()}),e.api.onDidActiveChange(()=>{this.updateGroupActive()}),e.api.onDidLocationChange(t=>{this.updateLocation(t.location)})),this._part=new ka(this.element,this.reactPortalStore,this.component,{api:e.api,containerApi:e.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group,headerPosition:this._group.model.headerPosition,location:e.api.location})}dispose(){var e;this.mutableDisposable.dispose(),(e=this._part)===null||e===void 0||e.dispose()}update(e){var t;(t=this._part)===null||t===void 0||t.update(e.params)}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}updateLocation(e){this.update({params:{location:e}})}}class NI{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new ka(this._element,this.reactPortalStore,this.component,e)}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}class y0{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.display="inline-flex"}init(e){this.part=new ka(this._element,this.reactPortalStore,this.component,{tabGroup:e.tabGroup,api:e.api})}update(e){var t;(t=this.part)===null||t===void 0||t.update({tabGroup:e.tabGroup})}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}class x0{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.display="inline-flex"}init(e){this.part=new ka(this._element,this.reactPortalStore,this.component,{group:e.group,api:e.api})}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}function uh(i,e){return i?t=>new RI(i,e,t):void 0}const Fg="props.defaultTabComponent";function MI(i){return Xb.reduce((t,n)=>(n in i&&(t[n]=i[n]),t),{})}const uk=Rt.forwardRef((i,e)=>{const t=Rt.useRef(null),n=Rt.useRef(void 0),[r,l]=Zv();Rt.useImperativeHandle(e,()=>t.current,[]);const p=Rt.useRef({});return Rt.useEffect(()=>{const a={};Xb.forEach(d=>{const f=d,m=i[f];f in i&&m!==p.current[f]&&(a[f]=m)}),n.current&&n.current.updateOptions(a),p.current=i},Xb.map(a=>i[a])),Rt.useEffect(()=>{var a;if(!t.current)return;const d=(a=i.tabComponents)!==null&&a!==void 0?a:{};i.defaultTabComponent&&(d[Fg]=i.defaultTabComponent);const f={createLeftHeaderActionComponent:uh(i.leftHeaderActionsComponent,{addPortal:l}),createRightHeaderActionComponent:uh(i.rightHeaderActionsComponent,{addPortal:l}),createPrefixHeaderActionComponent:uh(i.prefixHeaderActionsComponent,{addPortal:l}),createComponent:E=>new _0(E.id,i.components[E.name],{addPortal:l}),createTabComponent(E){return new b0(E.id,d[E.name],{addPortal:l})},createWatermarkComponent:i.watermarkComponent?()=>new w0("watermark",i.watermarkComponent,{addPortal:l}):void 0,defaultTabComponent:i.defaultTabComponent?Fg:void 0,createContextMenuItemComponent:E=>{if(E.component)return new NI(E.id,E.component,{addPortal:l})}},m=MI(i);if(i.tabGroupChipComponent){const E=i.tabGroupChipComponent;m.createTabGroupChipComponent=()=>new y0(E,{addPortal:l})}if(i.groupDragGhostComponent){const E=i.groupDragGhostComponent;m.createGroupDragGhostComponent=()=>new x0(E,{addPortal:l})}const g=TI(t.current,Object.assign(Object.assign({},m),f)),{clientWidth:y,clientHeight:D}=t.current;return g.layout(y,D),i.onReady&&i.onReady({api:g}),n.current=g,()=>{n.current=void 0,g.dispose()}},[]),Rt.useEffect(()=>{if(!n.current)return()=>{};const a=n.current.onDidDrop(d=>{i.onDidDrop&&i.onDidDrop(d)});return()=>{a.dispose()}},[i.onDidDrop]),Rt.useEffect(()=>{if(!n.current)return()=>{};const a=n.current.onWillDrop(d=>{i.onWillDrop&&i.onWillDrop(d)});return()=>{a.dispose()}},[i.onWillDrop]),Rt.useEffect(()=>{n.current&&n.current.updateOptions({createTabGroupChipComponent:i.tabGroupChipComponent?()=>new y0(i.tabGroupChipComponent,{addPortal:l}):void 0})},[i.tabGroupChipComponent]),Rt.useEffect(()=>{n.current&&n.current.updateOptions({createGroupDragGhostComponent:i.groupDragGhostComponent?()=>new x0(i.groupDragGhostComponent,{addPortal:l}):void 0})},[i.groupDragGhostComponent]),Rt.useEffect(()=>{n.current&&n.current.updateOptions({createComponent:a=>new _0(a.id,i.components[a.name],{addPortal:l})})},[i.components]),Rt.useEffect(()=>{var a;if(!n.current)return;const d=(a=i.tabComponents)!==null&&a!==void 0?a:{};i.defaultTabComponent&&(d[Fg]=i.defaultTabComponent),n.current.updateOptions({defaultTabComponent:i.defaultTabComponent?Fg:void 0,createTabComponent(f){return new b0(f.id,d[f.name],{addPortal:l})}})},[i.tabComponents,i.defaultTabComponent]),Rt.useEffect(()=>{n.current&&n.current.updateOptions({createWatermarkComponent:i.watermarkComponent?()=>new w0("watermark",i.watermarkComponent,{addPortal:l}):void 0})},[i.watermarkComponent]),Rt.useEffect(()=>{n.current&&n.current.updateOptions({createRightHeaderActionComponent:uh(i.rightHeaderActionsComponent,{addPortal:l})})},[i.rightHeaderActionsComponent]),Rt.useEffect(()=>{n.current&&n.current.updateOptions({createLeftHeaderActionComponent:uh(i.leftHeaderActionsComponent,{addPortal:l})})},[i.leftHeaderActionsComponent]),Rt.useEffect(()=>{n.current&&n.current.updateOptions({createPrefixHeaderActionComponent:uh(i.prefixHeaderActionsComponent,{addPortal:l})})},[i.prefixHeaderActionsComponent]),Rt.createElement("div",{style:{height:"100%",width:"100%"},ref:t},r)});uk.displayName="DockviewComponent";class S0 extends EI{constructor(e,t,n,r){super(e,t),this.reactComponent=n,this.reactPortalStore=r}getComponent(){var e,t;return new ka(this.element,this.reactPortalStore,this.reactComponent,{params:(t=(e=this._params)===null||e===void 0?void 0:e.params)!==null&&t!==void 0?t:{},api:this.api,containerApi:new FC(this._params.accessor)})}}function OI(i){return Wb.reduce((t,n)=>(n in i&&(t[n]=i[n]),t),{})}const LI=Rt.forwardRef((i,e)=>{const t=Rt.useRef(null),n=Rt.useRef(void 0),[r,l]=Zv();Rt.useImperativeHandle(e,()=>t.current,[]);const p=Rt.useRef({});return Rt.useEffect(()=>{const a={};Wb.forEach(d=>{const f=d,m=i[f];f in i&&m!==p.current[f]&&(a[f]=m)}),n.current&&n.current.updateOptions(a),p.current=i},Wb.map(a=>i[a])),Rt.useEffect(()=>{if(!t.current)return()=>{};const a={createComponent:g=>new S0(g.id,g.name,i.components[g.name],{addPortal:l})},d=DI(t.current,Object.assign(Object.assign({},OI(i)),a)),{clientWidth:f,clientHeight:m}=t.current;return d.layout(f,m),i.onReady&&i.onReady({api:d}),n.current=d,()=>{n.current=void 0,d.dispose()}},[]),Rt.useEffect(()=>{n.current&&n.current.updateOptions({createComponent:a=>new S0(a.id,a.name,i.components[a.name],{addPortal:l})})},[i.components]),Rt.createElement("div",{style:{height:"100%",width:"100%"},ref:t},r)});LI.displayName="SplitviewComponent";class C0 extends lk{constructor(e,t,n,r){super(e,t),this.reactComponent=n,this.reactPortalStore=r}getComponent(){var e,t;return new ka(this.element,this.reactPortalStore,this.reactComponent,{params:(t=(e=this._params)===null||e===void 0?void 0:e.params)!==null&&t!==void 0?t:{},api:this.api,containerApi:new HC(this._params.accessor)})}}function zI(i){return Kb.reduce((t,n)=>(n in i&&(t[n]=i[n]),t),{})}const BI=Rt.forwardRef((i,e)=>{const t=Rt.useRef(null),n=Rt.useRef(void 0),[r,l]=Zv();Rt.useImperativeHandle(e,()=>t.current,[]);const p=Rt.useRef({});return Rt.useEffect(()=>{const a={};Kb.forEach(d=>{const f=d,m=i[f];f in i&&m!==p.current[f]&&(a[f]=m)}),n.current&&n.current.updateOptions(a),p.current=i},Kb.map(a=>i[a])),Rt.useEffect(()=>{if(!t.current)return()=>{};const a={createComponent:g=>new C0(g.id,g.name,i.components[g.name],{addPortal:l})},d=$I(t.current,Object.assign(Object.assign({},zI(i)),a)),{clientWidth:f,clientHeight:m}=t.current;return d.layout(f,m),i.onReady&&i.onReady({api:d}),n.current=d,()=>{n.current=void 0,d.dispose()}},[]),Rt.useEffect(()=>{n.current&&n.current.updateOptions({createComponent:a=>new C0(a.id,a.name,i.components[a.name],{addPortal:l})})},[i.components]),Rt.createElement("div",{style:{height:"100%",width:"100%"},ref:t},r)});BI.displayName="GridviewComponent";class Hg{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new ka(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;(t=this.part)===null||t===void 0||t.update(e.params)}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}function GI(i){return Yb.reduce((t,n)=>(n in i&&(t[n]=i[n]),t),{})}const FI=Rt.forwardRef((i,e)=>{const t=Rt.useRef(null),n=Rt.useRef(void 0),[r,l]=Zv();Rt.useImperativeHandle(e,()=>t.current,[]);const p=Rt.useRef({});return Rt.useEffect(()=>{const a={};Yb.forEach(d=>{const f=d,m=i[f];f in i&&m!==p.current[f]&&(a[f]=m)}),n.current&&n.current.updateOptions(a),p.current=i},Yb.map(a=>i[a])),Rt.useEffect(()=>{var a;if(!t.current)return()=>{};const d=(a=i.headerComponents)!==null&&a!==void 0?a:{},f={createComponent:D=>new Hg(D.id,i.components[D.name],{addPortal:l}),createHeaderComponent:D=>new Hg(D.id,d[D.name],{addPortal:l})},m=AI(t.current,Object.assign(Object.assign({},GI(i)),f)),{clientWidth:g,clientHeight:y}=t.current;return m.layout(g,y),i.onReady&&i.onReady({api:m}),n.current=m,()=>{n.current=void 0,m.dispose()}},[]),Rt.useEffect(()=>{n.current&&n.current.updateOptions({createComponent:a=>new Hg(a.id,i.components[a.name],{addPortal:l})})},[i.components]),Rt.useEffect(()=>{var a;if(!n.current)return;const d=(a=i.headerComponents)!==null&&a!==void 0?a:{};n.current.updateOptions({createHeaderComponent:f=>new Hg(f.id,d[f.name],{addPortal:l})})},[i.headerComponents]),Rt.useEffect(()=>{if(!n.current)return()=>{};const a=n.current.onDidDrop(d=>{i.onDidDrop&&i.onDidDrop(d)});return()=>{a.dispose()}},[i.onDidDrop]),Rt.createElement("div",{style:{height:"100%",width:"100%"},ref:t},r)});FI.displayName="PaneviewComponent";const k0=new WeakMap;function HI(i,e){var p;const t=k0.get(e);if(t!==void 0)return t;let n=0;for(const a of e.ticketHistory??[])a.status==="needs-input"&&(n=1);let r=0;for(const a of e.turns)r+=((p=a.toolUses)==null?void 0:p.length)??0;const l=`${i}:${e.running?1:0}:${e.queuedPosition??0}:${e.turns.length}:${r}:${n}`;return k0.set(e,l),l}function E0(i){const e=[];for(const t of Object.keys(i))e.push(HI(t,i[t]));return e.join("|")}function Qv(){const[i,e]=z.useState(()=>vi.getState().chats);return z.useEffect(()=>{let t=E0(vi.getState().chats);return e(vi.getState().chats),vi.subscribe(n=>{const r=E0(n.chats);r!==t&&(t=r,e(n.chats))})},[]),i}async function WI(i){const e={};try{const t=await window.api.config.readJson(`${i}/package.json`);if(t.exists&&t.data){const n=t.data.name;typeof n=="string"&&(e.name=n)}}catch{}try{const t=await window.api.config.readText(`${i}/.git/config`);if(t.exists&&t.text){const n=t.text.match(/\[remote "origin"\][^\[]*url\s*=\s*([^\n]+)/);if(n){let r=n[1].trim();r=r.replace(/^git@([^:]+):/,"$1/").replace(/\.git$/,"").replace(/^https?:\/\//,""),e.gitRemote=r}}}catch{}try{const t=await window.api.config.readText(`${i}/.git/HEAD`);if(t.exists&&t.text){const n=t.text.match(/ref: refs\/heads\/(.+)/);n&&(e.lastBranch=n[1].trim())}}catch{}try{const t=await window.api.config.readText(`${i}/CLAUDE.md`);t.exists&&t.text&&(e.claudemdPreview=t.text.slice(0,200))}catch{}if(!e.name){const t=i.split("/");e.name=t[t.length-1]||i}return e}let yh=null;const Jb=new Set;let Wg=null;function UI(){return yh?Promise.resolve(yh):Wg||(Wg=window.api.app.homeDir().then(i=>(yh=i,Jb.forEach(e=>e(i)),i)),Wg)}function e_(){const[i,e]=z.useState(yh);return z.useEffect(()=>{if(yh){e(yh);return}const t=n=>e(n);return Jb.add(t),UI(),()=>{Jb.delete(t)}},[]),i}function Er(i){const e=i.trim().replace(/\/{2,}/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")}function Go(i){const e=i.split("/").filter(Boolean);return e.length>0?e[e.length-1]:i}const VI=/\/session-manager-(job|epic)-worktrees\/([0-9a-f]{16})\/[^/]+/;function ny(i){const e=VI.exec(Er(i));return e?{kind:e[1],hash:e[2]}:null}function sy(i,e){var n;const t=(n=e[i.encoded])==null?void 0:n.cwd;return typeof t!="string"||t.trim()===""?null:Er(t)||null}function qI(i,e,t){let n=0;for(const r of i){const l=sy(r,e),p=l?ny(l):null;p&&!(t!=null&&t.get(p.hash))&&n++}return n}function KI(i,e){const t=new Set;for(const n of i){const r=sy(n,e);r&&!ny(r)&&t.add(r)}return[...t]}function YI(i,e,t){const n=new Map,r=new Map;for(const l of i){const p=sy(l,e);if(!p)continue;const a=ny(p);let d=p;if(a){const y=t==null?void 0:t.get(a.hash);if(!y||!Er(y))continue;d=Er(y)}const f=a?{}:XI(e[l.encoded]),m=n.get(d);if(!m){n.set(d,{cwd:d,name:Go(d),encoded:a?"":l.encoded,encodedIds:[l.encoded],sessionCount:l.sessionCount,sizeBytes:l.sizeBytes,lastSession:l.lastSession,details:f}),a||r.set(d,l.lastSession);continue}if(m.encodedIds.push(l.encoded),m.sessionCount+=l.sessionCount,m.sizeBytes+=l.sizeBytes,m.lastSession=Math.max(m.lastSession,l.lastSession),a)continue;const g=r.get(d);(g===void 0||l.lastSession>g)&&(m.encoded=l.encoded,m.details=f,r.set(d,l.lastSession))}return[...n.values()].sort((l,p)=>p.lastSession-l.lastSession)}function XI(i){if(!i)return{};const{cwd:e,...t}=i;return t}const JI=20;function hk(i){return i.replace(/-/g,"/")}const ZI=64*1024;async function pk(i){const t=(await window.api.config.listDir(i,{filesOnly:!0})).entries.filter(n=>n.name.endsWith(".jsonl")).sort((n,r)=>n.size-r.size);for(const n of t){const r=await window.api.config.readText(n.path,{maxBytes:ZI});if(!(!r.exists||!r.text)){for(const l of r.text.split(`
|
|
2941
2941
|
`))if(l.includes('"cwd"'))try{const p=JSON.parse(l);if(typeof p.cwd=="string"&&p.cwd.length>0)return p.cwd}catch{}}}return null}let xh={rows:[],recentSessions:[],enriched:{},loading:!0,resolving:!0};const Zb=new Set;let T0=null,oc=0;function fk(){Zb.forEach(i=>i())}function Sh(i){xh={...xh,...i},fk()}async function QI(i){const e=new Map,t=new TextEncoder;return await Promise.all(i.map(async n=>{const r=await globalThis.crypto.subtle.digest("SHA-1",t.encode(n)),l=Array.from(new Uint8Array(r),p=>p.toString(16).padStart(2,"0")).join("");e.set(l.slice(0,16),n)})),e}let gv=null,L_=null;function eP(i){const e=i.join(`
|
|
2942
|
-
`);e!==L_&&(L_=e,QI(i).then(t=>{e===L_&&(gv=t,fk())}).catch(t=>{console.error("[useKnownProjects] owner map failed:",t)}))}const Qb=6;async function ew(i,e,t){const n=new Array(i.length);let r=0;const l=Array.from({length:Math.min(e,i.length)},async()=>{for(;;){const p=r++;if(p>=i.length)return;n[p]=await t(i[p])}});return await Promise.all(l),n}async function tP(i){const e=++oc;Sh({loading:!0,resolving:!0});try{const t=await window.api.config.listDir(`${i}/.claude/projects`,{dirsOnly:!0});if(e!==oc)return;const n=t.entries,r=[],l=await ew(n,Qb,async p=>{const d=(await window.api.config.listDir(p.path,{filesOnly:!0})).entries.filter(g=>g.name.endsWith(".jsonl"));for(const g of d)r.push({sessionId:g.name.replace(/\.jsonl$/,""),projectEncoded:p.name,path:g.path,mtimeMs:g.mtimeMs,sizeBytes:g.size});const f=d.reduce((g,y)=>Math.max(g,y.mtimeMs),0),m=d.reduce((g,y)=>g+y.size,0);return{encoded:p.name,displayPath:hk(p.name),sessionCount:d.length,lastSession:f,path:p.path,sizeBytes:m}});if(e!==oc)return;l.sort((p,a)=>a.lastSession-p.lastSession),r.sort((p,a)=>a.mtimeMs-p.mtimeMs),Sh({rows:l,recentSessions:r.slice(0,JI),enriched:{},loading:!1,resolving:!0}),iP(l,e)}catch(t){console.error("[useKnownProjects] scan failed:",t),e===oc&&Sh({loading:!1,resolving:!1})}}async function iP(i,e){const t={};if(await ew(i,Qb,async l=>{if(e===oc){if(l.sessionCount===0){t[l.encoded]=null;return}try{const p=await pk(l.path);t[l.encoded]=p?Er(p):null}catch{t[l.encoded]=null}}}),e!==oc)return;const n={};for(const l of i)n[l.encoded]={cwd:t[l.encoded]??null};Sh({enriched:n,resolving:!1});const r=[...new Set(Object.values(t).filter(l=>!!l))];await ew(r,Qb,async l=>{if(e!==oc)return;let p={};try{p=await WI(l)}catch{return}if(e!==oc)return;const a={...xh.enriched};for(const[d,f]of Object.entries(t))f===l&&(a[d]={cwd:l,...p});Sh({enriched:a})})}function Cd(){const i=e_(),[,e]=z.useState(0),t=Ct(b=>b.addTab);z.useEffect(()=>{const b=()=>e(w=>w+1);return Zb.add(b),()=>{Zb.delete(b)}},[]),z.useEffect(()=>{i&&T0!==i&&(T0=i,tP(i))},[i]);const{rows:n,recentSessions:r,enriched:l,loading:p,resolving:a}=xh,d=z.useMemo(()=>KI(n,l),[n,l]);z.useEffect(()=>{eP(d)},[d]);const f=gv??new Map,m=z.useMemo(()=>YI(n,l,f),[n,l,gv]),g=z.useMemo(()=>qI(n,l,f),[n,l,gv]),y=async b=>{const w=crypto.randomUUID();t({id:w,cwd:b,startupCommand:null,presetId:"projects-tab",dormant:!0})},D=async b=>{var S;let w=((S=l[b.encoded])==null?void 0:S.cwd)??null;if(w||(w=await pk(b.path)),!w&&(w=await window.api.app.pickDirectory(),!w))return;const x=crypto.randomUUID();t({id:x,cwd:w,startupCommand:null,presetId:"projects-tab",dormant:!0})},E=async b=>{try{const w=await window.api.app.archiveProject(b);return w.ok&&Sh({rows:xh.rows.filter(x=>x.encoded!==b),enriched:Object.fromEntries(Object.entries(xh.enriched).filter(([x])=>x!==b))}),w}catch(w){return{ok:!1,error:w instanceof Error?w.message:"Archive failed"}}};return{rows:n,recentSessions:r,enriched:l,projects:m,unresolvedWorktreeFolders:g,loading:p,resolving:a,openProject:y,openInSession:D,archiveProject:E,archiveProjectByCwd:async b=>{let w={ok:!0};for(const x of b.encodedIds)if(w=await E(x),!w.ok)return w;return w}}}function nP(i,e,t){var r,l;const n=new Map;for(const p of Object.keys(e)){if(!((r=e[p])!=null&&r.running))continue;const a=(l=t[p])==null?void 0:l.cwd;if(!a)continue;const d=Er(a);n.set(d,(n.get(d)??0)+1)}return i.map(p=>({encoded:p.encoded,name:p.name,cwd:p.cwd,dotSeed:p.cwd,liveCount:n.get(p.cwd)??0,lastActivityMs:p.lastSession}))}function z_(i){return{owner:i.owner,kind:"session",at:i.at,project:null,epicTitle:null,openTarget:null,epicId:null}}function sP(i,e,t,n){return i.map(r=>{const l=r.owner;if(l.startsWith("scheduler:")){const p=l.slice(10),a=e.find(m=>m.slug===p);if(!a)return z_(r);const d=a.sourcePromptId??null,f=d?n[d]:void 0;return{owner:l,kind:"scheduler job",at:r.at,project:a.cwd?Go(a.cwd):null,epicTitle:(f==null?void 0:f.goalText)??null,openTarget:"scheduler",epicId:null}}if(l.startsWith("chat:")){const p=l.slice(5),a=t[p],d=n[p];return!(a!=null&&a.running)||!d?z_(r):{owner:l,kind:"chat run",at:r.at,project:Go(d.cwd),epicTitle:d.goalText,openTarget:"terminal",epicId:p}}return z_(r)})}function D0(i,e){for(const t of Object.keys(e))if(e[t].claudeSessionId===i)return e[t].goalText;return null}const rP=1440*60*1e3;function oP(i){const e=(i.statusHistory??[]).find(n=>n.to==="quarantined");if(!e)return null;const t=Date.parse(e.at);return Number.isNaN(t)?null:t}function aP(i,e,t,n=Date.now()){var l;const r=[];for(const p of Object.keys(i)){const a=i[p];r.push({id:`proposed:${p}`,kind:"proposed-epic",label:"Proposed Epic — awaiting approval",detail:a.goalText,meta:a.tag?`tag: ${a.tag}`:"Filed for you to decide on. Nothing has run.",project:Go(a.cwd),epicId:p,jobSlug:null})}for(const p of Object.keys(e)){const a=((l=e[p])==null?void 0:l.ticketHistory)??[],d=a[a.length-1];!d||d.status!=="needs-input"||r.push({id:`needs-input:${d.id}`,kind:"needs-input",label:"Session is asking a question",detail:d.text,meta:"Stopped mid-run, waiting on your reply.",project:Go(d.cwd),epicId:p,jobSlug:null})}for(const p of t){if(p.status==="quarantined"){const a=oP(p),d=a!=null?n-a:null,f=d!=null&&d>=rP;r.push({id:`job:${p.slug}`,kind:"job-quarantined",label:f?"Quarantined PRD — stale, needs adoption":"Scheduler PRD quarantined",detail:p.title||p.slug,meta:d!=null?`No createdVia provenance for ${Math.round(d/(3600*1e3))}h — adopt it to run, or archive from the Scheduler tab.`:"No createdVia provenance. Adopt it to run, or archive from the Scheduler tab.",project:p.cwd?Go(p.cwd):null,epicId:null,jobSlug:p.slug,escalated:f});continue}if(p.status==="running"&&p.overrun){const{ratio:a,ranMs:d,estimateMinutes:f}=p.overrun;r.push({id:`job:${p.slug}`,kind:"job-overrunning",label:"Scheduler job running over its own estimate",detail:p.title||p.slug,meta:`Ran ${Math.round(d/6e4)}m vs ${f}m estimate (${a.toFixed(1)}x). Check the run log, then let it finish or cancel it via scheduler_cancel_job.`,project:p.cwd?Go(p.cwd):null,epicId:null,jobSlug:p.slug});continue}p.status!=="failed"&&p.status!=="needs_review"||r.push({id:`job:${p.slug}`,kind:"job-failed",label:p.status==="failed"?"Scheduler job failed":"Scheduler job needs review",detail:p.title||p.slug,meta:p.error??"No error detail recorded.",project:p.cwd?Go(p.cwd):null,epicId:null,jobSlug:p.slug})}return r}let tw=null;function t_(i){tw=i,window.dispatchEvent(new CustomEvent("sm:select-prompt-session",{detail:i}))}function lP(){const i=tw;return tw=null,i}async function mk(){try{return await window.api.schedule.runNow(),!0}catch(i){const e=i instanceof Error?i.message:String(i);return Qe.error("Run now failed: "+e),!1}}const $0=["#6f7d52","#b85c34","#8a7a60","#e4b85a","#5f6f86","#4f7d72","#8a5a6e"];function cP(i){let e=0;for(let t=0;t<i.length;t++)e=e*31+i.charCodeAt(t)>>>0;return e}function gk(i){return $0[cP(i)%$0.length]}function vk(i,e,t,n){const r=e.find(l=>l.cwd===i);r?n(r.id):t({cwd:i,startupCommand:null,dormant:!0})}function mm(i,e){const[t,n]=z.useState(1),r=i.length,l=Math.max(1,Math.ceil(r/e)),p=Math.min(Math.max(1,t),l),a=z.useMemo(()=>i.slice((p-1)*e,p*e),[i,p,e]);return{page:p,setPage:n,pageItems:a,pageSize:e,total:r}}function gm({page:i,pageSize:e,totalItems:t,onPageChange:n,testIdPrefix:r="plan-pager",compact:l=!1}){if(t<=e)return null;const p=Math.max(1,Math.ceil(t/e)),a=(i-1)*e+1,d=Math.min(i*e,t),f=l?"flex items-center justify-center gap-3 px-2 py-1.5 font-mono text-[11px] text-fg-faint":"flex items-center justify-center gap-3 px-[18px] py-3 font-mono text-[12px] text-fg-faint";return c.jsxs("div",{"data-testid":r,className:f,children:[c.jsx("button",{type:"button","data-testid":`${r}-prev`,onClick:()=>n(i-1),disabled:i<=1,className:"px-2 py-1 rounded border border-line bg-bg-hi text-fg-dim hover:text-fg disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer",children:"Prev"}),c.jsxs("span",{"data-testid":`${r}-range`,children:[a,"–",d," of ",t]}),c.jsx("button",{type:"button","data-testid":`${r}-next`,onClick:()=>n(i+1),disabled:i>=p,className:"px-2 py-1 rounded border border-line bg-bg-hi text-fg-dim hover:text-fg disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer",children:"Next"})]})}function _k(i){return i>=90?{dot:"bg-accent",bar:"bg-accent",track:"bg-accent/15",text:"text-accent"}:i>=70?{dot:"bg-honey",bar:"bg-honey",track:"bg-honey/15",text:"text-honey-dark"}:{dot:"bg-sage",bar:"bg-sage",track:"bg-sage/15",text:"text-sage"}}function dP(i){return i?i.split("_").map(e=>/^\d/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1)).join(" "):null}function wf({label:i,sub:e,window:t,big:n=!1}){if(!t)return null;const r=t.utilization,l=Math.max(0,Math.min(100,r)),p=r>100,a=$C(t.resets_at),d=_k(r);return c.jsxs("div",{className:n?"py-[18px]":"py-[15px]",children:[c.jsxs("div",{className:"flex items-baseline justify-between gap-3 mb-2.5",children:[c.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[c.jsx("span",{className:`w-[9px] h-[9px] rounded-full shrink-0 ${d.dot}`}),c.jsx("span",{className:`font-semibold text-fg ${n?"text-base":"text-[15px]"}`,children:i}),e&&c.jsx("span",{className:"font-mono text-[11.5px] text-fg-faint bg-bg border border-line px-2 py-px rounded-full whitespace-nowrap",children:e})]}),c.jsxs("span",{className:`font-mono font-semibold leading-none tracking-tight shrink-0 ${n?"text-2xl":"text-xl"} ${p?"text-accent":d.text}`,children:[Math.round(r),"%"]})]}),c.jsx("div",{className:`rounded-full overflow-hidden ${n?"h-3":"h-2.5"} ${d.track}`,children:c.jsx("div",{className:`h-full rounded-full transition-[width] duration-500 ${d.bar}`,style:{width:`${l}%`}})}),a&&c.jsxs("div",{className:"flex items-center justify-between mt-2.5 gap-3",children:[c.jsxs("span",{className:"text-[12.5px] text-fg-dim",children:["resets in"," ",c.jsx("strong",{className:"text-fg font-semibold",children:a.rel}),a.abs&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-fg-faint",children:" · "}),c.jsx("span",{className:"font-mono text-xs text-fg-faint",children:a.abs})]})]}),p&&c.jsx("span",{className:"text-[11.5px] font-semibold text-accent",children:"over limit"})]})]})}function uP({extra:i}){const e=i.utilization??0,t=e>100,n=_k(e);return c.jsxs("div",{className:"border-t border-line pt-[15px] pb-[15px]",children:[c.jsxs("div",{className:"flex items-baseline justify-between mb-2.5",children:[c.jsxs("div",{className:"flex items-center gap-2.5",children:[c.jsx("span",{className:`w-[9px] h-[9px] rounded-full shrink-0 ${n.dot}`}),c.jsx("span",{className:"text-[15px] font-semibold text-fg",children:"Extra usage"}),c.jsx("span",{className:"font-mono text-[11.5px] text-fg-faint bg-bg border border-line px-2 py-px rounded-full whitespace-nowrap",children:"pay-as-you-go"})]}),c.jsxs("span",{className:`font-mono text-base font-semibold tabular-nums ${t?"text-accent":"text-fg"}`,children:[(i.used_credits??0).toFixed(2)," ",c.jsxs("span",{className:"text-fg-faint font-normal",children:["/ ",(i.monthly_limit??0).toFixed(2)," ",i.currency??""]})]})]}),c.jsx("div",{className:`h-2.5 rounded-full overflow-hidden ${n.track}`,children:c.jsx("div",{className:`h-full rounded-full transition-[width] duration-500 ${n.bar}`,style:{width:`${Math.min(e,100)}%`}})}),c.jsxs("div",{className:"flex items-center justify-between mt-2.5 gap-3",children:[c.jsxs("span",{className:"text-[12.5px] text-fg-dim",children:["monthly credit limit · resets"," ",c.jsx("span",{className:"font-mono text-xs text-fg-faint",children:"1st of month"})]}),t&&c.jsx("span",{className:"text-[11.5px] font-semibold text-accent",children:"over limit"})]})]})}function hP({data:i,updatedAt:e}){const t=i.usage,n=dP(i.subscriptionType),r=t.extra_usage,l=e!=null?`${Math.max(0,Math.round((Date.now()-e)/1e3))}s ago`:null;return c.jsxs("section",{className:"bg-bg-hi border border-line rounded-2xl px-6 py-1.5",children:[(n||i.rateLimitTier||l)&&c.jsxs("div",{className:"flex items-baseline justify-between pt-3 pb-1 mb-1",children:[c.jsxs("div",{className:"flex items-baseline gap-2",children:[n&&c.jsx("span",{className:"text-xs text-fg-dim font-mono",children:n}),i.rateLimitTier&&c.jsx("span",{className:"text-[10px] text-fg-faint font-mono",children:i.rateLimitTier})]}),l&&c.jsxs("span",{className:"text-[10px] text-fg-faint",children:["updated ",l]})]}),c.jsxs("div",{className:"divide-y divide-line",children:[c.jsx(wf,{label:"Session",sub:"5-hour",window:t.five_hour,big:!0}),c.jsx(wf,{label:"Weekly",sub:"all models",window:t.seven_day}),c.jsx(wf,{label:"Weekly",sub:"Opus",window:t.seven_day_opus}),c.jsx(wf,{label:"Weekly",sub:"Sonnet",window:t.seven_day_sonnet}),c.jsx(wf,{label:"Weekly",sub:"OAuth apps",window:t.seven_day_oauth_apps})]}),(r==null?void 0:r.is_enabled)&&c.jsx(uP,{extra:r})]})}function ry({open:i,onClose:e,title:t,sub:n,keyVals:r,tail:l,footer:p,children:a}){const[d,f]=z.useState(!1);if(z.useEffect(()=>{if(!i){f(!1);return}const y=requestAnimationFrame(()=>f(!0));return()=>cancelAnimationFrame(y)},[i]),z.useEffect(()=>{if(!i)return;const y=D=>{D.key==="Escape"&&(D.stopPropagation(),e())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[i,e]),!i)return null;const m=y=>{y.target===y.currentTarget&&e()},g=c.jsxs("div",{className:`fixed inset-0 ${dn.dialog}`,"data-testid":"home-drawer-root",children:[c.jsx("div",{className:`absolute inset-0 bg-black/50 transition-opacity duration-[220ms] ${d?"opacity-100":"opacity-0"}`,onClick:m,"data-testid":"home-drawer-backdrop"}),c.jsxs("aside",{role:"dialog","aria-modal":"true","aria-label":t,className:`absolute top-0 right-0 h-full w-full max-w-[420px] bg-bg-hi border-l border-line shadow-xl flex flex-col transition-transform duration-[220ms] ${d?"translate-x-0":"translate-x-full"}`,style:{transitionTimingFunction:"cubic-bezier(.32,.72,.28,1)"},"data-testid":"home-drawer",children:[c.jsxs("header",{className:"px-5 py-4 border-b border-line flex items-start justify-between gap-3 shrink-0",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("h2",{className:"m-0 font-serif text-[18px] font-semibold text-fg truncate",children:t}),n&&c.jsx("div",{className:"text-[12px] text-fg-faint truncate mt-0.5",children:n})]}),c.jsx("button",{onClick:e,className:"shrink-0 rounded-md border border-line bg-bg px-2.5 py-1 text-[12px] font-semibold text-fg-dim hover:bg-bg-elev","aria-label":"Close",children:"Close"})]}),c.jsxs("div",{className:"flex-1 min-h-0 overflow-auto px-5 py-4 grid gap-4 content-start",children:[a,r.length>0&&c.jsx("dl",{className:"m-0 grid gap-2",style:{gridTemplateColumns:"minmax(0,100px) minmax(0,1fr)"},children:r.map(y=>c.jsxs("div",{className:"contents",children:[c.jsx("dt",{className:"m-0 font-mono text-[11px] uppercase tracking-[0.05em] text-fg-faint",children:y.label}),c.jsx("dd",{className:"m-0 text-[12.5px] text-fg break-words",children:y.value})]},y.label))}),l&&l.length>0&&c.jsxs("div",{children:[c.jsx("div",{className:"font-mono text-[11px] uppercase tracking-[0.08em] text-fg-faint mb-2",children:"Live tail"}),c.jsx("div",{className:"grid gap-2",children:l.map(y=>c.jsxs("div",{className:"bg-bg border border-line rounded-lg px-3 py-2",children:[c.jsx("div",{className:"font-mono text-[10px] uppercase tracking-[0.05em] text-fg-faint mb-1",children:y.role}),c.jsx("div",{className:"text-[12px] text-fg-dim leading-[1.5] whitespace-pre-wrap break-words line-clamp-6",children:y.text})]},y.id))})]})]}),p&&c.jsx("footer",{className:"px-5 py-3.5 border-t border-line flex gap-2 justify-end shrink-0",children:p})]})]});return typeof document<"u"&&document.body?Th.createPortal(g,document.body):g}function pP({open:i,onClose:e,projects:t,onConfirm:n}){const[r,l]=z.useState(null);z.useEffect(()=>{var a;i&&l(((a=t[0])==null?void 0:a.cwd)??null)},[i,t]);const p=t.find(a=>a.cwd===r)??null;return c.jsx(ry,{open:i,onClose:e,title:"New session",sub:"Pick a project to start it in",keyVals:[],footer:c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:e,className:"text-[12px] font-semibold px-[13px] py-[7px] rounded-lg border border-line bg-bg text-fg-dim hover:bg-bg-elev",children:"Cancel"}),c.jsx("button",{onClick:()=>{r&&(n(r),e())},disabled:!r,className:"text-[12px] font-semibold px-[13px] py-[7px] rounded-lg bg-accent text-bg-hi hover:bg-accent-dark disabled:opacity-50",children:p?`Continue in ${p.name} → Epics`:"Continue"})]}),children:t.length===0?c.jsx("div",{className:"text-[13px] text-fg-faint py-2",children:"No known projects yet."}):c.jsx("div",{role:"radiogroup","aria-label":"Project",className:"grid gap-1.5",children:t.map(a=>c.jsxs("label",{className:`flex items-center gap-2.5 px-3 py-2 rounded-lg border cursor-pointer ${r===a.cwd?"border-accent bg-accent/10":"border-line bg-bg hover:bg-bg-elev/60"}`,children:[c.jsx("input",{type:"radio",name:"new-epic-project",value:a.cwd,checked:r===a.cwd,onChange:()=>l(a.cwd),className:"accent-accent"}),c.jsx("span",{className:"min-w-0 flex-1 text-[13px] text-fg truncate",title:a.cwd,children:a.name})]},a.encoded))})})}function fP({job:i,onClose:e,onOpenScheduler:t,onRunNow:n}){const r=z.useRef(null);return z.useEffect(()=>{const l=a=>{r.current&&!r.current.contains(a.target)&&e()},p=a=>{a.key==="Escape"&&e()};return document.addEventListener("mousedown",l),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",p)}},[e]),c.jsxs("div",{ref:r,"data-testid":"queue-job-popover",className:"absolute z-20 top-full left-0 mt-1.5 w-[226px] bg-bg-hi border border-line rounded-[11px] shadow-xl px-3.5 py-3",children:[c.jsx("div",{className:"font-mono text-[12px] font-semibold text-fg truncate mb-1.5",children:i.title||i.slug}),c.jsxs("dl",{className:"m-0 grid gap-1 mb-3",style:{gridTemplateColumns:"minmax(0,60px) minmax(0,1fr)"},children:[c.jsx("dt",{className:"m-0 font-mono text-[10px] uppercase tracking-[0.05em] text-fg-faint",children:"Slug"}),c.jsx("dd",{className:"m-0 font-mono text-[11px] text-fg-dim truncate",children:i.slug}),c.jsx("dt",{className:"m-0 font-mono text-[10px] uppercase tracking-[0.05em] text-fg-faint",children:"Project"}),c.jsx("dd",{className:"m-0 font-mono text-[11px] text-fg-dim truncate",children:i.cwd?mP(i.cwd):"—"}),i.estimateMinutes!=null&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{className:"m-0 font-mono text-[10px] uppercase tracking-[0.05em] text-fg-faint",children:"Est."}),c.jsxs("dd",{className:"m-0 font-mono text-[11px] text-fg-dim",children:["~",i.estimateMinutes,"m"]})]}),c.jsx("dt",{className:"m-0 font-mono text-[10px] uppercase tracking-[0.05em] text-fg-faint",children:"Status"}),c.jsx("dd",{className:"m-0 font-mono text-[11px] text-fg-dim",children:i.status})]}),c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsx("button",{onClick:t,className:"text-[11.5px] font-semibold px-2.5 py-[5px] rounded-md border border-line bg-bg text-fg-dim hover:bg-bg-elev text-left",children:"Open in Scheduler →"}),n&&c.jsx("button",{onClick:n,title:"Wakes the scheduler to check for due jobs immediately — does not force this specific job to run out of turn or bypass the concurrency cap.",className:"text-[11.5px] font-semibold px-2.5 py-[5px] rounded-md bg-accent text-bg-hi hover:bg-accent-dark text-left",children:"Nudge scheduler now"})]})]})}function mP(i){const e=i.split("/").filter(Boolean);return e.length>0?e[e.length-1]:i}const iw="sm:terminal:settings",nw=10,sw=22,bk=13,Fo={theme:"dark",fontSize:bk};async function wk(){try{const e=(await Eh()).terminal;return e?{theme:e.theme==="light"||e.theme==="paper"||e.theme==="dark"?e.theme:Fo.theme,fontSize:typeof e.fontSize=="number"&&e.fontSize>=nw&&e.fontSize<=sw?e.fontSize:Fo.fontSize}:Fo}catch{return Fo}}async function gP(i){try{await um({terminal:i})}catch{Qe.error("Couldn't save terminal appearance — it won't persist after restart.")}window.dispatchEvent(new CustomEvent(iw,{detail:i}))}function A0(i,e,t){i.options.theme=lc[e.theme],i.options.fontSize=e.fontSize,t==null||t()}function oy(i,e){let t=!1,n=!1;const r=vP(l=>{n=!0,A0(i,l,e)});return wk().then(l=>{!t&&!n&&A0(i,l,e)}),()=>{t=!0,r()}}function vP(i){const e=t=>{i(t.detail)};return window.addEventListener(iw,e),()=>window.removeEventListener(iw,e)}const lc={dark:{background:"#0b0d10",foreground:"#e6e8ec",cursor:"#d97757",selectionBackground:"#3a4250",black:"#1a1f27",red:"#e06c75",green:"#98c379",yellow:"#e5c07b",blue:"#61afef",magenta:"#c678dd",cyan:"#56b6c2",white:"#e6e8ec",brightBlack:"#545c68",brightRed:"#e06c75",brightGreen:"#98c379",brightYellow:"#e5c07b",brightBlue:"#61afef",brightMagenta:"#c678dd",brightCyan:"#56b6c2",brightWhite:"#ffffff"},light:{background:"#ffffff",foreground:"#1f2328",cursor:"#0969da",selectionBackground:"#cce5ff",black:"#24292f",red:"#cf222e",green:"#116329",yellow:"#a45a16",blue:"#0969da",magenta:"#8250df",cyan:"#1b7c83",white:"#6e7781",brightBlack:"#57606a",brightRed:"#a40e26",brightGreen:"#1a7f37",brightYellow:"#9a6700",brightBlue:"#218bff",brightMagenta:"#a475f9",brightCyan:"#3192aa",brightWhite:"#1f2328"},paper:{background:"#f6efe1",foreground:"#2a221a",cursor:"#a7532f",selectionBackground:"#e0d3b8",black:"#2a221a",red:"#b8443c",green:"#5c6f3a",yellow:"#8e641a",blue:"#3a6ea5",magenta:"#8a4a8c",cyan:"#38767e",white:"#5b4a36",brightBlack:"#796b54",brightRed:"#b8493f",brightGreen:"#65714a",brightYellow:"#8c641e",brightBlue:"#416ea1",brightMagenta:"#925494",brightCyan:"#3e757d",brightWhite:"#2a221a"}},_P=["dark","light","paper"];function bP(){const[i,e]=z.useState(Fo),[t,n]=z.useState(!1);z.useEffect(()=>{let p=!1;return wk().then(a=>{p||(e(a),n(!0))}),()=>{p=!0}},[]);const r=p=>{t&&e(a=>{const d={...a,...p};return gP(d),d})},l=p=>{r({fontSize:Math.min(sw,Math.max(nw,i.fontSize+p))})};return c.jsxs("section",{className:"mb-6","data-testid":"home-terminal-appearance",children:[c.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[c.jsx("h2",{className:"m-0 font-serif text-[22px] font-medium",children:"Terminal appearance"}),c.jsx("span",{className:"font-mono text-[12px] text-fg-faint",children:"every terminal, this machine"})]}),c.jsxs("div",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[c.jsxs("p",{className:"mt-0 mb-4 text-[13px] text-fg-dim leading-relaxed",children:["Applies to ",c.jsx("strong",{className:"text-fg",children:"every terminal in the app at once"})," — project Terminal tabs, an Epic’s Terminal view of its session, and the inline permission prompt. It is not per project, per session, or per tab. It does not restyle the app chrome (there is no app theme switch), and the code editor keeps its own separate paper/dark setting in the Editor tab’s Display menu. Stored in"," ",c.jsx("code",{className:"font-mono text-[12px]",children:"~/.claude/session-manager/ui-settings-prefs.json"}),", applied live without restarting a session."]}),c.jsxs("div",{className:"grid gap-5",style:{gridTemplateColumns:"minmax(0,1fr) 220px"},children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-[10px] uppercase tracking-wider text-fg-faint mb-1.5",children:"Theme"}),c.jsx("div",{className:"grid grid-cols-3 gap-2",children:_P.map(p=>c.jsxs("button",{type:"button",onClick:()=>r({theme:p}),disabled:!t,"aria-pressed":i.theme===p,"data-testid":`terminal-theme-${p}`,className:`px-2 py-2 rounded-lg text-[11px] font-medium border transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${i.theme===p?"bg-bg border-accent text-fg":"bg-bg border-line text-fg-dim hover:text-fg hover:border-fg-faint"}`,children:[c.jsx(wP,{theme:p}),c.jsx("div",{className:"mt-1.5 capitalize",children:p})]},p))})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[c.jsx("span",{className:"text-[10px] uppercase tracking-wider text-fg-faint",children:"Font size"}),c.jsxs("span",{className:"font-mono text-[11px] text-fg-dim",children:[i.fontSize,"px"]})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("button",{type:"button",onClick:()=>l(-1),disabled:!t||i.fontSize<=nw,"aria-label":"Decrease font size",className:"flex-1 py-1.5 rounded border border-line bg-bg text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed",children:"−"}),c.jsx("button",{type:"button",onClick:()=>r({fontSize:bk}),disabled:!t,className:"flex-1 py-1.5 rounded border border-line bg-bg text-[11px] text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed",children:"reset"}),c.jsx("button",{type:"button",onClick:()=>l(1),disabled:!t||i.fontSize>=sw,"aria-label":"Increase font size",className:"flex-1 py-1.5 rounded border border-line bg-bg text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed",children:"+"})]}),c.jsxs("div",{className:"mt-3 rounded border border-line px-3 py-2 font-mono",style:{background:lc[i.theme].background,color:lc[i.theme].foreground,fontSize:`${i.fontSize}px`,lineHeight:1.35},"aria-hidden":!0,children:[c.jsx("span",{style:{color:lc[i.theme].green},children:"$"})," claude"]})]})]})]})]})}function wP({theme:i}){const e=lc[i];return c.jsxs("div",{"aria-hidden":!0,className:"w-full h-5 rounded border relative overflow-hidden",style:{background:e.background,borderColor:"rgba(0,0,0,0.15)"},children:[c.jsx("div",{style:{position:"absolute",top:3,left:4,width:"40%",height:2,background:e.foreground}}),c.jsx("div",{style:{position:"absolute",top:9,left:4,width:"25%",height:2,background:e.green??e.foreground}}),c.jsx("div",{style:{position:"absolute",top:15,left:4,width:"55%",height:2,background:e.cyan??e.foreground}})]})}const I0="The MCP tool catalog is unavailable.";function yP(){const[i,e]=z.useState({tools:[],loaded:!1,error:null});return z.useEffect(()=>{let t=!1;return Promise.resolve().then(()=>window.api.mcp.catalog()).then(n=>{var r;t||(!(n!=null&&n.ok)||!((r=n.tools)!=null&&r.length)?e({tools:[],loaded:!0,error:I0}):e({tools:n.tools,loaded:!0,error:null}))}).catch(()=>{t||e({tools:[],loaded:!0,error:I0})}),()=>{t=!0}},[]),i}const xP=["scheduler","chat","feedback","help"],SP={scheduler:"Scheduler",chat:"Chat",feedback:"Feedback",help:"Help"};function CP(){const{tools:i,loaded:e,error:t}=yP(),[n,r]=z.useState(!1);if(!e)return null;if(t||i.length===0)return c.jsxs("section",{className:"mb-6","data-testid":"home-agent-tools",children:[c.jsx("h2",{className:"m-0 mb-2 font-serif text-[22px] font-medium",children:"Agent tools"}),c.jsx("p",{className:"m-0 text-xs text-fg-faint","data-testid":"home-agent-tools-error",children:"The MCP tool catalog is unavailable."})]});const l=xP.map(p=>({group:p,tools:i.filter(a=>a.group===p)})).filter(p=>p.tools.length>0);return c.jsxs("section",{className:"mb-6","data-testid":"home-agent-tools",children:[c.jsxs("button",{type:"button",onClick:()=>r(p=>!p),"aria-expanded":n,"data-testid":"home-agent-tools-toggle",className:"flex w-full items-baseline gap-2 text-left",children:[c.jsx("span",{className:"font-serif text-[22px] font-medium",children:"Agent tools"}),c.jsxs("span",{className:"font-mono text-[12px] text-fg-faint",children:["· ",i.length," MCP tools ",n?"▾":"▸"]})]}),n&&c.jsx("div",{className:"mt-3 grid gap-3 border border-line rounded-xl bg-bg-hi px-5 py-4",children:l.map(({group:p,tools:a})=>c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"mb-1 font-mono text-[10px] font-semibold uppercase tracking-wide text-fg-faint",children:SP[p]}),a.map(d=>c.jsxs("div",{"data-testid":`home-agent-tool-${d.name}`,className:"flex items-baseline gap-3 min-w-0 py-0.5",children:[c.jsx("span",{className:"shrink-0 font-mono text-[12px] font-semibold text-fg",children:d.name}),c.jsx("span",{"data-testid":"home-agent-tool-purpose",title:d.purpose,className:"min-w-0 line-clamp-1 text-xs text-fg-dim",children:d.purpose})]},d.name))]},p))})]})}function kP(i){i<0&&(i=0);const e=Math.floor(i/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60);return t<60?`${t}m${(e%60).toString().padStart(2,"0")}s`:`${Math.floor(t/60)}h${(t%60).toString().padStart(2,"0")}m`}function EP(i){i<0&&(i=0);const e=Math.floor(i/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60);if(t<60)return`${t}m`;const n=Math.floor(t/60);return n<24?`${n}h${t%60?` ${t%60}m`:""}`:`${Math.floor(n/24)}d`}function sB(i){return new Date(i).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZoneName:"short"})}function tr(i,e){if(i===null)return"never";const t=e-i;return t<0?"soon":t<5e3?"just now":`${EP(t)} ago`}function rB(i){if(!i)return"";const e=Math.max(0,Date.now()-i);return e<6e4?`saved ${Math.round(e/1e3)}s ago`:e<36e5?`saved ${Math.round(e/6e4)}m ago`:`saved ${Math.round(e/36e5)}h ago`}function TP(i){i<0&&(i=0);const e=Math.floor(i/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60);if(t<60)return`${t}m`;const n=Math.floor(t/60),r=t%60;return r>0?`${n}h ${r}m`:`${n}h`}function DP({since:i,error:e,onRetry:t}){return c.jsxs("div",{className:"flex items-center justify-between mb-3 border border-yellow-800/40 rounded px-3 py-1.5 bg-yellow-950/20 text-xs text-yellow-300",children:[c.jsxs("span",{children:["stale · last updated ",tr(i,Date.now())]}),c.jsx("button",{onClick:t,className:"ml-3 underline hover:no-underline",children:"Retry"})]})}function $P({message:i,expiredAt:e,onRetry:t}){const n=e!=null&&e<Date.now(),r=e?new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}):null,l=!n&&/^HTTP \d+/.test(i);return c.jsxs("div",{className:"mb-3 border border-red-800/40 rounded px-3 py-2 bg-red-950/20 text-xs text-red-300",children:[c.jsxs("div",{className:"font-medium mb-1",children:[n?`Credentials expired at ${r}`:"Authentication failed",l&&c.jsxs("span",{className:"font-normal ml-1 text-red-400/70",children:["(",i,")"]})]}),c.jsxs("div",{className:"text-red-400/80",children:["Run ",c.jsx("code",{className:"font-mono bg-red-950/40 px-1 rounded",children:"claude"})," in a terminal to refresh, then"," ",c.jsx("button",{onClick:t,className:"underline hover:no-underline",children:"Retry"}),"."]})]})}function AP(){return c.jsx("div",{className:"border border-yellow-800/40 rounded px-3 py-1.5 bg-yellow-950/20 text-xs text-yellow-300",children:"temporary network error — retrying in 5s"})}function IP({onRetry:i}){return c.jsxs("div",{className:"flex items-center justify-between border border-yellow-800/40 rounded px-3 py-1.5 bg-yellow-950/20 text-xs text-yellow-300",children:[c.jsx("span",{children:"usage meter is rate-limited — showing last known values"}),c.jsx("button",{onClick:i,className:"ml-3 underline hover:no-underline",children:"Retry"})]})}function PP({message:i}){const e=i.includes("not found")||i.includes("ENOENT");return c.jsxs("div",{className:"border border-line rounded px-3 py-2 bg-bg-elev text-xs text-fg-dim",children:[c.jsx("div",{className:"font-medium mb-1 text-fg",children:e?"Not signed in":"Cannot read credentials"}),c.jsx("div",{className:"text-fg-faint",children:e?c.jsxs(c.Fragment,{children:["Run ",c.jsx("code",{className:"font-mono bg-bg px-1 rounded",children:"claude login"})," in a terminal tab to sign in."]}):c.jsxs(c.Fragment,{children:["Cannot read ",c.jsx("code",{className:"font-mono bg-bg px-1 rounded",children:"~/.claude/.credentials.json"})," — ",i]})})]})}function jP({result:i,onRetry:e}){switch(i.kind){case"ok":return null;case"ok-stale":return c.jsx(DP,{since:i.staleSince,error:i.lastError,onRetry:e});case"auth":return c.jsx($P,{message:i.message,expiredAt:i.expiredAt,onRetry:e});case"transient":return c.jsx(AP,{});case"meter_rate_limited":return c.jsx(IP,{onRetry:e});case"config":return c.jsx(PP,{message:i.message})}}function yf(i){return{path:i,diskRaw:"",draftRaw:"",diskData:null,exists:!1,parseError:null,loadError:null,mtimeMs:0,baseMtimeMs:0,dirty:!1,busy:!1,lastSavedAt:null}}function B_(i,e,t){const n={...i,diskRaw:e.raw,diskData:e.data,exists:e.exists,parseError:e.parseError,loadError:e.error,mtimeMs:e.mtimeMs,busy:!1};return!t||!i.dirty?(n.draftRaw=e.raw,n.dirty=!1,n.baseMtimeMs=e.mtimeMs):n.dirty=n.draftRaw!==n.diskRaw,n}function G_(i,e,t){const n={...i,diskRaw:e.text,diskData:null,exists:e.exists,parseError:null,loadError:e.error,mtimeMs:e.mtimeMs,busy:!1};return!t||!i.dirty?(n.draftRaw=e.text,n.dirty=!1,n.baseMtimeMs=e.mtimeMs):n.dirty=n.draftRaw!==n.diskRaw,n}function P0(i){return`${i} changed on disk since you opened it. Reload to merge, or save again to overwrite.`}const Mf=jn((i,e)=>({files:{},watchRefs:{},loadJson:async t=>{const n=e().files[t];i({files:{...e().files,[t]:{...n??yf(t),busy:!0}}});const r=await window.api.config.readJson(t),l=e().files[t]??yf(t);i({files:{...e().files,[t]:B_(l,r,!1)}})},loadText:async(t,n=!1)=>{const r=e().files[t];i({files:{...e().files,[t]:{...r??yf(t),busy:!0}}});const l=await window.api.config.readText(t),p=e().files[t]??yf(t);i({files:{...e().files,[t]:G_(p,l,n)}})},setDraft:(t,n)=>{const r=e().files[t]??yf(t),l=n!==r.diskRaw;i({files:{...e().files,[t]:{...r,draftRaw:n,dirty:l}}})},revert:t=>{const n=e().files[t];n&&i({files:{...e().files,[t]:{...n,draftRaw:n.diskRaw,dirty:!1}}})},saveJson:async(t,n)=>{const r=e().files[t];if(!r)return{ok:!1,error:"not loaded"};let l;try{l=r.draftRaw.trim()===""?{}:JSON.parse(r.draftRaw)}catch(f){return{ok:!1,error:`invalid JSON: ${f.message}`}}if(!(n!=null&&n.force)){const f=await window.api.config.readJson(t);if(f.exists&&f.mtimeMs>(r.baseMtimeMs??0))return Qe.error(P0(t)),{ok:!1,error:"conflict"}}i({files:{...e().files,[t]:{...r,busy:!0}}});const p=await window.api.config.writeJson(t,l);if(!p.ok)return i({files:{...e().files,[t]:{...r,busy:!1}}}),{ok:!1,error:p.error};const a=await window.api.config.readJson(t),d=B_({...r,busy:!1},a,!1);return i({files:{...e().files,[t]:{...d,lastSavedAt:Date.now()}}}),{ok:!0}},saveText:async(t,n)=>{const r=e().files[t];if(!r)return{ok:!1,error:"not loaded"};if(!(n!=null&&n.force)){const d=await window.api.config.readText(t);if(d.exists&&d.mtimeMs>(r.baseMtimeMs??0))return Qe.error(P0(t)),{ok:!1,error:"conflict"}}i({files:{...e().files,[t]:{...r,busy:!0}}});const l=await window.api.config.writeText(t,r.draftRaw);if(!l.ok)return i({files:{...e().files,[t]:{...r,busy:!1}}}),{ok:!1,error:l.error};const p=await window.api.config.readText(t),a=G_({...r,busy:!1},p,!1);return i({files:{...e().files,[t]:{...a,lastSavedAt:Date.now()}}}),{ok:!0}},watchFile:t=>{const n={...e().watchRefs};n[t]=(n[t]??0)+1,i({watchRefs:n}),n[t]===1&&window.api.config.watch([t])},unwatchFile:t=>{const n={...e().watchRefs};n[t]&&(n[t]--,n[t]<=0&&(delete n[t],window.api.config.unwatch([t])),i({watchRefs:n}))},onExternalChange:t=>{e().files[t]&&(t.endsWith(".json")?window.api.config.readJson(t).then(r=>{const l=e().files[t];l&&i({files:{...e().files,[t]:B_(l,r,!0)}})}):window.api.config.readText(t).then(r=>{const l=e().files[t];l&&i({files:{...e().files,[t]:G_(l,r,!0)}})}))}}));function RP(){return window.api.config.onChanged(({path:i})=>{Mf.getState().onExternalChange(i)})}function Ch(...i){return i.filter(Boolean).map((e,t)=>t===0?e.replace(/\/+$/,""):e.replace(/^\/+|\/+$/g,"")).join("/")}const om={scopes:["user","project","local"],resolve:(i,e,t)=>i==="user"?Ch(e,".claude","settings.json"):t?i==="project"?Ch(t,".claude","settings.json"):Ch(t,".claude","settings.local.json"):null},F_={scopes:["user","project","local"],resolve:(i,e,t)=>i==="user"?Ch(e,".claude","CLAUDE.md"):t?i==="project"?Ch(t,"CLAUDE.md"):Ch(t,"CLAUDE.local.md"):null},oB=om,aB={user:{label:"User",hint:"~/.claude/ — applies to all projects"},project:{label:"Project",hint:"<cwd>/.claude/ — checked into git"},local:{label:"Local",hint:"<cwd>/.claude/…local — gitignored, per-machine"}},NP=[];function Ug(i){return Array.isArray(i)?"array":i!==null&&typeof i=="object"?"object":"scalar"}function MP(i){const e=i.filter(t=>t.data!==void 0);return e.length===0?{kind:"object",children:{}}:yk(e,[])}function yk(i,e){const t=NP.includes(e.join(".")),n=i.every(m=>Ug(m.data)==="object"),r=i.every(m=>Ug(m.data)==="array");if(n){const m=new Set;for(const y of i)for(const D of Object.keys(y.data))m.add(D);const g={};for(const y of m){const D=i.filter(E=>y in E.data).map(E=>({scope:E.scope,data:E.data[y]}));g[y]=yk(D,[...e,y])}return{kind:"object",children:g}}if(r&&!t){const m=[];for(const g of[...i].reverse())for(const y of g.data)m.push({value:y,fromScope:g.scope,index:m.length});return{kind:"array",items:m}}const l=[...i].reverse(),p=l[0],a=l.slice(1).map(m=>({scope:m.scope,value:m.data})),d=Ug(p.data),f=a.some(m=>Ug(m.value)!==d);return{kind:"leaf",value:p.data,winner:p.scope,shadowed:a,...f?{typeMismatch:!0}:{}}}function xk(i,e){if(e.length===0)return i;if(i.kind!=="object")return null;const[t,...n]=e,r=i.children[t];return r?xk(r,n):null}function OP(i,e,t){if(e.length===0)return t;const[n,...r]=e,l=i&&typeof i=="object"&&!Array.isArray(i)?{...i}:{};return l[n]=OP(l[n],r,t),l}const LP=["user","project","local"];function zP(i,e){const t=[];for(const n of LP){const r=e[n];if(!r)continue;const l=i[r];if(!l||!l.exists)continue;const p=l.draftRaw??"";if(p.trim())try{t.push({scope:n,data:JSON.parse(p)})}catch{}}return t}const BP=3e4;function Sk(i){const e=e_(),t=z.useMemo(()=>{if(!e)return{};const a={};for(const d of om.scopes){const f=om.resolve(d,e,i);f&&(a[d]=f)}return a},[e,i]),n=Mf(a=>a.files),r=Mf(a=>a.loadJson),l=Mf(a=>a.watchFile),p=Mf(a=>a.unwatchFile);return z.useEffect(()=>{const a=Object.values(t).filter(Boolean);a.forEach(f=>{n[f]||r(f),l(f)});const d=window.setInterval(()=>{a.forEach(f=>r(f))},BP);return()=>{clearInterval(d),a.forEach(f=>p(f))}},[JSON.stringify(t)]),z.useMemo(()=>MP(zP(n,t)),[n,t])}function Ck(i,e){const t=xk(i,e);return!t||t.kind!=="leaf"?{value:null,source:null}:{value:typeof t.value=="string"?t.value:null,source:t.winner}}function kk(i,e){return!i||!e?"effort — (model default)":e==="epic"?`effort ${i} (this session)`:e==="persona"?`effort ${i} (persona)`:e==="persona-overlay"?`effort ${i} (project persona)`:`effort ${i} (${e} settings.json)`}function GP(i){return i==="epic"?"Effort was chosen for this session only and is passed to the CLI as --effort, overriding the agent persona and settings.json.":i==="persona"||i==="persona-overlay"?"Effort comes from the agent persona and is passed to the CLI as --effort, overriding settings.json.":i?"The persona sets no effort, so the settings.json effortLevel applies.":"No effort is set by the persona or settings.json, so the model default applies."}function FP(i,e,t={}){const n=t.model&&t.model!=="inherit"?t.model:null,r=t.effort&&t.effort!=="inherit"&&t.effort!=="auto"?t.effort:null;if(r)return{...i,epicModel:n,effortLevel:r,effortSource:"epic"};if(i.personaEffort&&(i.personaEffortSource==="persona"||i.personaEffortSource==="persona-overlay"))return{...i,epicModel:n,effortLevel:i.personaEffort,effortSource:i.personaEffortSource};const{value:l,source:p}=Ck(e,["effortLevel"]);return{...i,epicModel:n,effortLevel:l,effortSource:p}}function Ek(i,e,t){const n=Sk(i),[r,l]=z.useState(null);return z.useEffect(()=>{if(!i||!e){l(null);return}let p=!1;return l(null),window.api.agents.resolveModelInfo({cwd:i,agentType:e}).then(a=>{p||l(a)},()=>{p||l(null)}),()=>{p=!0}},[i,e]),!i||!e||!r?null:FP(r,n,t)}const Tk=[{id:"project",label:"Project & Tab",realm:"machine",blurb:"A PROJECT is a cwd; a TAB is one open project.",tone:{chip:"bg-bg-elev text-fg-dim",border:"border-line",dot:"bg-fg-faint"}},{id:"epic",label:"Epic (PromptSession)",realm:"project",blurb:"The central aggregate root — one unit of work, one claude session.",tone:{chip:"bg-accent-muted text-accent-dark",border:"border-accent",dot:"bg-accent"}},{id:"scheduler",label:"Scheduler",realm:"project",blurb:"PRDs + the headless jobs that execute them.",tone:{chip:"bg-butter/30 text-honey-dark",border:"border-honey",dot:"bg-honey"}},{id:"agents",label:"Agents & Taxonomy",realm:"machine",blurb:"The ACTOR and MISSION halves of AIM.",tone:{chip:"bg-sage/20 text-sage-dark",border:"border-sage",dot:"bg-sage"}},{id:"memory",label:"Memory",realm:"machine",blurb:"Workspace, cross-project, and per-agent memory.",tone:{chip:"bg-hive-teal/20 text-hive-teal",border:"border-hive-teal",dot:"bg-hive-teal"}},{id:"transcript",label:"Transcript & Usage",realm:"machine",blurb:"The Claude CLI's own JSONL, classified events, and billing.",tone:{chip:"bg-bg-hi text-fg-dim",border:"border-rule",dot:"bg-fg-dim"}},{id:"brief",label:"Project Home & Publishing",realm:"project",blurb:"The synthesized Brief, generated pages, and bilko.run publish state.",tone:{chip:"bg-accent-muted/60 text-accent-dark",border:"border-accent-muted",dot:"bg-accent-muted"}},{id:"config",label:"Machine Config",realm:"machine",blurb:"Settings, layout, and the single-writer ownership map.",tone:{chip:"bg-line text-fg-faint",border:"border-rule",dot:"bg-fg-faint"}}];function lB(i){const e=Tk.find(t=>t.id===i);if(!e)throw new Error(`unknown ErdGroupId: ${i}`);return e}const ay=[{id:"project",name:"Project",aka:"cwd — Main Project",group:"project",store:{path:"identity only, no record of its own — folded at read time from ~/.claude/projects/<encoded>",format:"in-memory",definedIn:"src/renderer/lib/knownProjectAggregate.ts (aggregateProjectsByCwd) "},summary:"A folder whose cwd never resolved from transcript content is DROPPED, never guessed — the naive decode once reported 2044 phantom projects.",fields:[{name:"cwd",type:"string",key:"pk",note:"resolved working directory — the project's identity"},{name:"name",type:"string",note:"display name: the cwd's last path segment"},{name:"encoded",type:"string",note:"representative transcript folder (most recently active)"},{name:"encodedIds",type:"string[]",note:"every ~/.claude/projects/<encoded> folder that resolved to this cwd"},{name:"sessionCount",type:"number"},{name:"sizeBytes",type:"number"},{name:"lastSession",type:"number"}]},{id:"tab",name:"PersistedTab",aka:"TAB",group:"project",store:{path:"~/.claude/session-manager/tabs.json",format:"json",definedIn:"src/main/sessionsStore.cjs "},summary:"One TAB per project — extra sessions within a project are Epics, not tabs.",fields:[{name:"id",type:"string",key:"pk"},{name:"sessionId",type:"string"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"label",type:"string"},{name:"presetId",type:"string | null"}]},{id:"epic",name:"PromptSession",aka:"EPIC",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/active-index.json -> sessions[id]",format:"json",writer:"epics",definedIn:"src/main/lib/epic/epicMint.cjs (ensureEpic) + src/renderer/state/promptSessions.ts "},summary:"The central aggregate root — created in exactly ONE place, a human pressing New Epic.",fields:[{name:"id",type:"string",key:"pk"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"goalText",type:"string",note:"the original top-level prompt text that started this goal"},{name:"claudeSessionId",type:"string",note:"independently minted — never shared with any tab.sessionId"},{name:"status",type:"'proposed' | 'active' | 'completed'"},{name:"createdAt",type:"string"},{name:"completedAt",type:"string | null"},{name:"resumedFromId",type:"string",optional:!0,key:"fk",ref:"epic.id"},{name:"tag",type:"TicketTag",optional:!0,key:"fk",ref:"tag.tag"},{name:"openingPrompt",type:"string | null",optional:!0},{name:"source",type:"EpicSource",optional:!0,note:"{ producer, prdSlug?, runId?, sourceTabId?, fromCwd?, fromEpicId? }"},{name:"agentType",type:"string",optional:!0,key:"fk",ref:"agentPersona.name"},{name:"sections",type:"EpicIntakeSection[]",optional:!0},{name:"worktree",type:"{ dir, branch, baseCwd, status, conflictReason? }",optional:!0,note:"own git worktree on branch 'sm-epic/<id>' when Active"}],notes:["SINGLE-CREATOR LAW, fail-closed in epicMint.cjs — the New Epic IPC handler and crossProjectFeedback.cjs are the only mint authorities.","Every Epic is born proposed; nothing is created directly as active.","EPIC : claude-session is 1:1 — Chat and Terminal are two VIEWS over one session.","Title + objective are fixed for the life of the session — iterate in follow-up messages, don't repurpose."]},{id:"epicEvent",name:"PromptSessionEvent",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/active-index.json -> events[]",format:"json",writer:"epics",definedIn:"src/renderer/state/promptSessions.ts + src/main/lib/epic/activeIndexMerge.cjs "},summary:"One step in an Epic's Prompt → PRD → Response → ... → Closed chain.",fields:[{name:"id",type:"string",key:"pk"},{name:"promptSessionId",type:"string",key:"fk",ref:"epic.id"},{name:"kind",type:"'prompt' | 'prd_created' | 'response' | 'closed'"},{name:"causedByEventId",type:"string | null",key:"fk",ref:"epicEvent.id",note:"must be the session's current tail event — a chain, not a tree"},{name:"at",type:"string"},{name:"prdSlug",type:"string",optional:!0,key:"fk",ref:"prd.slug"},{name:"text",type:"string",optional:!0},{name:"outcome",type:"'completed' | 'failed' | 'needs_review'",optional:!0},{name:"validation",type:"'unvalidated' | 'validating' | 'verified' | 'refuted'",optional:!0}]},{id:"epicTranscriptTurn",name:"PromptSessionTranscriptTurn",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/transcripts/<epicId>.jsonl",format:"jsonl",writer:"epics",definedIn:"src/main/promptSessionTranscript.cjs "},summary:"The durable per-Epic transcript store, kept alongside the CLI's own JSONL as a fallback source of turns.",fields:[{name:"v",type:"1"},{name:"epicId",type:"string",key:"fk",ref:"epic.id"},{name:"eventId",type:"string | null",key:"fk",ref:"epicEvent.id"},{name:"role",type:"'user' | 'assistant'"},{name:"at",type:"string"},{name:"text",type:"string"}]},{id:"epicArchive",name:"PromptSessionArchive",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/<epicId>.json",format:"json",writer:"epics",definedIn:"src/renderer/state/promptSessions.ts (promptSessionArchivePath) "},summary:"On-disk archive written once at completion — freezes the Epic, its events, and its transcript.",fields:[{name:"session",type:"PromptSession"},{name:"events",type:"PromptSessionEvent[]"},{name:"transcript",type:"string"},{name:"archivedAt",type:"string"},{name:"durableTurns",type:"Array<{ role, text, at }>",optional:!0}]},{id:"epicWorktreeConfig",name:"EpicWorktreeConfig",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/epic-worktree-config.json",format:"json",writer:"epics",definedIn:"src/main/lib/epic/epicWorktreeProjectConfig.cjs "},summary:"Per-project 'disable Epic worktree isolation' toggle, read by gitWorktree.cjs's isWorktreeDisabled('epic', cwd) on every worktree creation attempt.",fields:[{name:"disabled",type:"boolean"}],notes:["One-shot migration from the legacy machine-wide ~/.claude/session-manager/epic-worktree-project-config.json map, keyed by project cwd — that file is left in place, never deleted."]},{id:"exchange",name:"Exchange",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/exchanges.jsonl",format:"jsonl",writer:"epics",definedIn:"src/main/exchanges.cjs "},summary:"One durable NDJSON record per completed terminal-chat exchange, appended off the hot path.",fields:[{name:"ts",type:"string"},{name:"sessionId",type:"string",key:"fk",ref:"epic.claudeSessionId",note:"the tab's claude session id"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"prompt",type:"string"},{name:"result",type:"string"},{name:"summary",type:"string",note:"produced by the shared Haiku summarizer"},{name:"model",type:"string"},{name:"degraded",type:"string",optional:!0,note:"set when summarization failed — the exchange itself is never dropped"},{name:"promptId",type:"string",optional:!0,key:"fk",ref:"prd.slug",note:"originating PromptTicket.id when dispatched from the per-tab queue; forward-only, never backfilled"}],notes:["Written via raw fs O_APPEND (not config.cjs writeJson) for atomicity across concurrent writers — assertOpsWrite is called explicitly since raw fs bypasses the normal enforcement point.","Historical rows from before this store existed remain, untouched and unmigrated, in the old global ~/.claude/knowledge-log/exchanges/<encodeCwd(cwd)>.jsonl."]},{id:"prd",name:"PRD",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/epics/<epicId>/prds/<slug>.md",format:"markdown",writer:"scheduler",definedIn:"src/main/lib/prd/prdLocations.cjs + scheduler_create_prd MCP tool "},summary:"PRD authoring is API-only via the scheduler_create_prd MCP tool — a PRD joins an EXISTING Epic and never conjures one.",fields:[{name:"slug",type:"string",key:"pk",note:"<nn>-<kebab-title>.md filename stem"},{name:"title",type:"string"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"epicId",type:"string | null",key:"fk",ref:"epic.id",note:"derived from the PRD's DIRECTORY — fact on disk"},{name:"sourcePromptId",type:"string",optional:!0,key:"fk",ref:"epic.id",note:"frontmatter intent — can disagree with epicId"},{name:"sourceTabId",type:"string",optional:!0},{name:"estimateMinutes",type:"number"},{name:"tag",type:"'feature' | 'bug' | 'discussion' | 'build' | 'project-home-builder'",optional:!0,key:"fk",ref:"tag.tag"},{name:"dependsOn",type:"string[]",optional:!0,key:"fk",ref:"prd.slug",note:"the SOLE ordering primitive"},{name:"goal",type:"string"},{name:"acceptanceCriteria",type:"string[]"},{name:"implementationNotes",type:"string"},{name:"outOfScope",type:"string[]",optional:!0},{name:"createdVia",type:"string",optional:!0},{name:"issuedAt",type:"string",optional:!0}],notes:["Flat scheduler/prds/ is RETIRED — auto-consolidated into prds-archived/ on every reconcile() pass.","epicId is derived from the DIRECTORY (fact on disk) while sourcePromptId is frontmatter intent and can disagree."]},{id:"scheduleJob",name:"ScheduleJob",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/queue.json -> jobs[]",format:"json",writer:"scheduler",definedIn:"src/main/lib/scheduler/queueStore.cjs + src/main/lib/scheduler/scheduleJobSchema.cjs "},summary:"dependsOn is the SOLE ordering primitive — parallelGroup is a display hint, never a barrier.",fields:[{name:"slug",type:"string",key:"pk",note:"shared identity with the PRD it executes"},{name:"title",type:"string"},{name:"cwd",type:"string | null",key:"fk",ref:"project.cwd"},{name:"parallelGroup",type:"number"},{name:"estimateMinutes",type:"number | null"},{name:"bodyPreview",type:"string"},{name:"status",type:"'pending' | 'running' | 'investigating' | 'completed' | 'failed' | 'needs_review' | 'quarantined'"},{name:"runId",type:"string | null",key:"fk",ref:"runLog.runId"},{name:"startedAt",type:"string | null"},{name:"finishedAt",type:"string | null"},{name:"exitCode",type:"number | null"},{name:"error",type:"string | null"},{name:"sessionId",type:"string",optional:!0},{name:"runtime",type:"ScheduleJobRuntime",optional:!0,note:"{ pid, runId, startedAt, sessionId?, cwd? }"},{name:"verifierVerdict",type:"string",optional:!0},{name:"dependsOn",type:"string[]",optional:!0,key:"fk",ref:"prd.slug"},{name:"originSessionId",type:"string | null",optional:!0,key:"fk",ref:"epic.id"},{name:"sourceTabId",type:"string | null",optional:!0},{name:"sourcePromptId",type:"string | null",optional:!0,key:"fk",ref:"epic.id"},{name:"epicId",type:"string | null",optional:!0,key:"fk",ref:"epic.id",note:"authoritative — derived from the PRD directory"},{name:"statusHistory",type:"ScheduleJobStatusHistoryEntry[]",optional:!0}],notes:["Every launch must take a slot from lib/scheduler/sessionSlots.cjs — the single machine-wide concurrency limit.","--model is always pinned on every claude -p call site.","A job in needs_review is a QUESTION routed back to the authoring Epic and never creates work on its own."]},{id:"scheduleJobStatusHistory",name:"ScheduleJobStatusHistoryEntry",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/queue.json -> jobs[].statusHistory[]",format:"json",writer:"scheduler",definedIn:"src/main/lib/scheduler/scheduleJobTransitions.cjs "},summary:"Bounded trail (~20 entries) of accepted status transitions for one ScheduleJob.",fields:[{name:"from",type:"string | null"},{name:"to",type:"string"},{name:"reason",type:"string | null"},{name:"source",type:"string | null"},{name:"at",type:"string"}]},{id:"scheduleHistoryEntry",name:"Schedule history entry",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/history.jsonl",format:"jsonl",writer:"scheduler",definedIn:"src/main/lib/scheduler/queueStore.cjs "},summary:"Terminal jobs aged out of queue.json land here, one JSON object per line.",fields:[{name:"slug",type:"string",key:"fk",ref:"prd.slug"},{name:"status",type:"ScheduleJobStatus"},{name:"finishedAt",type:"string | null"},{name:"epicId",type:"string | null",optional:!0,key:"fk",ref:"epic.id"},{name:"runId",type:"string | null",optional:!0,key:"fk",ref:"runLog.runId"}]},{id:"scheduleConfig",name:"ScheduleConfig",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/queue.json -> config",format:"json",writer:"scheduler",definedIn:"src/main/lib/scheduler/schedulerConfig.cjs "},summary:"Per-project auto-fire policy and utilization gate.",fields:[{name:"enabled",type:"boolean",note:"legacy on/off, kept for v0.4 backwards compat"},{name:"offsetMinutes",type:"number"},{name:"defaultCwd",type:"string",key:"fk",ref:"project.cwd"},{name:"firePolicy",type:"'manual' | 'on-reset' | 'when-available'"},{name:"utilizationThreshold",type:"number"},{name:"schemaVersion",type:"1"}]},{id:"runLog",name:"Run log",group:"scheduler",store:{path:"~/.claude/session-manager/scheduled-plans/runs/<runId>/",format:"directory",definedIn:"src/main/scheduler.cjs (RUNS_DIR) "},summary:"One directory per headless claude -p invocation — stdout/stderr/exit capture for a ScheduleJob's run.",fields:[{name:"runId",type:"string",key:"pk"}]},{id:"agentPersona",name:"AgentPersona",aka:"ACTOR — also an ACTION when scoped",group:"agents",store:{path:"~/.claude/agents/<name>.md",format:"markdown",definedIn:"src/main/agentLibrary.cjs + src/main/lib/persona-macro/agentPersonaSchema.cjs "},summary:"One global persona — an ACTION is this same persona given a project scope, not a fourth concept.",fields:[{name:"name",type:"string",key:"pk"},{name:"description",type:"string | null"},{name:"tools",type:"string[]"},{name:"model",type:"string | null",note:"wins over the Settings default for this Epic"},{name:"color",type:"string | null"},{name:"tags",type:"AgentPersonaTag[]",key:"fk",ref:"tag.tag"},{name:"projects",type:"string[]",key:"fk",ref:"project.cwd",note:"'*' means every project"},{name:"action",type:"string | null"},{name:"actionLabel",type:"string | null"},{name:"title",type:"string | null",optional:!0},{name:"path",type:"string"},{name:"body",type:"string"},{name:"overridingProjects",type:"string[]"}]},{id:"tag",name:"Tag",aka:"MISSION — EpicTag",group:"agents",store:{path:"src/renderer/lib/tagLibrary.ts (TAG_LIBRARY)",format:"code",definedIn:"src/renderer/lib/tagLibrary.ts + src/renderer/lib/agentTagDefs.ts "},summary:"The closed 5-taxonomy union — Epic creation is agentType (who) + tag (what), two independent selections.",fields:[{name:"tag",type:"'feature' | 'bug' | 'discussion' | 'build' | 'project-home-builder'",key:"pk"},{name:"label",type:"string"},{name:"description",type:"string"},{name:"developEagerness",type:"'expected-default' | 'available-not-assumed'"},{name:"developsVia",type:"string"}]},{id:"memoryEntry",name:"MemoryEntry",group:"memory",store:{path:"~/.claude/projects/<encodedCwd>/memory/<name>.md",format:"markdown",definedIn:"src/main/memoryTool.cjs "},summary:"One workspace memory file, semantically organized by topic.",fields:[{name:"name",type:"string",key:"pk"},{name:"path",type:"string"},{name:"mtimeMs",type:"number"},{name:"bytes",type:"number"},{name:"workspace",type:"string",key:"fk",ref:"project.cwd",note:"carried on MemoryListResult, denormalized here — the directory this entry lives under"}]},{id:"memoryCluster",name:"MemoryCluster",group:"memory",store:{path:"<cwd>/session-manager-operations/memory-clusters/clusters.json",format:"json",writer:"memory-clusters",definedIn:"src/main/memoryAggregate.cjs "},summary:"Derived grouping of related MemoryEntry files, computed and cached per workspace.",fields:[{name:"id",type:"string",key:"pk"},{name:"name",type:"string"},{name:"summary",type:"string"},{name:"memberSlugs",type:"string[]",key:"fk",ref:"memoryEntry.name"},{name:"links",type:"MemoryClusterLink[]",note:"{ from, to, label? }"}]},{id:"agentMemoryEntry",name:"AgentMemoryEntry",group:"memory",store:{path:"~/.claude/agent-memory/<agent>/ | .claude/agent-memory/<agent>/ | .claude/agent-memory-local/<agent>/",format:"directory",definedIn:"src/main/lib/memoryDirResolve.cjs (resolveAgentMemoryDir)"},summary:"Per-subagent memory in Claude Code's native agent-memory directories (user, project, local scope), keyed by agent name — markdown files with a MEMORY.md index.",fields:[{name:"agent",type:"string",key:"pk",ref:"agentPersona.name",note:"directory name under the scope root"},{name:"scope",type:"'user' | 'project' | 'local'",note:"selects which agent-memory root resolveAgentMemoryDir returns"},{name:"files",type:"markdown[]",note:"topic files plus MEMORY.md index, read live from disk"}]},{id:"claudeTranscript",name:"Claude transcript",group:"transcript",store:{path:"~/.claude/projects/<encodedCwd>/<sessionUuid>.jsonl",format:"jsonl",definedIn:"written by the Claude Code CLI; tailed by src/main/transcripts.cjs "},summary:"The CLI's own append-only transcript — Session Manager only tails and classifies it, never writes it.",fields:[{name:"sessionUuid",type:"string",key:"pk"},{name:"encodedCwd",type:"string",key:"fk",ref:"project.cwd"}]},{id:"transcriptEvent",name:"TranscriptEvent",group:"transcript",store:{path:"in-memory ring buffer, broadcast as transcript:event:<tabId>",format:"in-memory",definedIn:"src/main/transcripts.cjs -> src/renderer/state/live.ts "},summary:"Classified, bounded-preview view over one raw transcript line — never the source of truth.",fields:[{name:"kind",type:"TranscriptEventKind"},{name:"data",type:"unknown"},{name:"raw",type:"unknown"},{name:"previewText",type:"string"},{name:"ref",type:"TranscriptEventRef | null",note:"{ filePath, byteOffset, byteLength }"},{name:"tabId",type:"string",key:"fk",ref:"tab.id"}]},{id:"historyRollupDay",name:"History rollup day",group:"transcript",store:{path:"~/.claude/session-manager/history-rollup.jsonl",format:"jsonl",definedIn:"src/main/lib/historyRollup.cjs "},summary:"One finalized day-per-project analytics row (History tab is analytics/cost/charts only).",fields:[{name:"date",type:"string",key:"pk"},{name:"projectCwd",type:"string",key:"fk",ref:"project.cwd"},{name:"promptCount",type:"number"},{name:"inputTokens",type:"number"},{name:"outputTokens",type:"number"},{name:"estimatedCostUsd",type:"number"}]},{id:"billingUsage",name:"UsageSnapshot",group:"transcript",store:{path:"~/.claude/session-manager/billing-cache.json",format:"json",definedIn:"src/main/usage.cjs (CACHE_PATH) "},summary:"Cached rolling-window utilization percentages from the account's billing API.",fields:[{name:"five_hour",type:"UsageWindow | null"},{name:"seven_day",type:"UsageWindow | null"},{name:"seven_day_sonnet",type:"UsageWindow | null"},{name:"seven_day_opus",type:"UsageWindow | null"},{name:"seven_day_oauth_apps",type:"UsageWindow | null"},{name:"extra_usage",type:"{ is_enabled, monthly_limit, used_credits, utilization, currency } | null"}]},{id:"projectBrief",name:"ProjectBrief",group:"brief",store:{path:"<cwd>/session-manager-operations/project-brief/brief.json",format:"json",writer:"project-home",definedIn:"src/main/projectBrief.cjs "},summary:"The synthesized project Brief — generated, with a hand-edit escape hatch.",fields:[{name:"version",type:"number"},{name:"synthesizedAt",type:"string"},{name:"editedAt",type:"string | null"},{name:"model",type:"string"},{name:"purpose",type:"string"},{name:"what",type:"string[]"},{name:"areas",type:"ProjectBriefArea[]",note:"{ name, files, note, epic, heat }"},{name:"scope",type:"ProjectBriefScopeEntry[]",note:"{ when, kind, text, src }"},{name:"conventions",type:"string[]"},{name:"pins",type:"{ what: boolean; conventions: boolean }"},{name:"pinned",type:"{ what: string[] | null; conventions: string[] | null }"}]},{id:"projectPages",name:"ProjectPagesOutput",group:"brief",store:{path:"<cwd>/session-manager-operations/project-pages/ (home.html)",format:"directory",writer:"project-home",definedIn:"project_home_write MCP tool (src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs)"},summary:"One self-contained overview page, written only via project_home_write.",fields:[{name:"html",type:"string | null"},{name:"mtimeMs",type:"number | null"}]},{id:"settingsScope",name:"Settings (scoped)",group:"config",store:{path:"~/.claude/settings.json + <cwd>/.claude/settings.json + <cwd>/.claude/settings.local.json",format:"json",definedIn:"src/main/config.cjs + src/renderer/state/config.ts + src/renderer/lib/mergeScopes.ts "},summary:"Substrate, not per-Epic curation — model is the one field carved out per-Epic (persona wins over Settings).",fields:[{name:"scope",type:"'system' | 'project' | 'local'",key:"pk"},{name:"cwd",type:"string",optional:!0,key:"fk",ref:"project.cwd"},{name:"model",type:"string",optional:!0}]},{id:"layoutEnvelope",name:"LayoutEnvelope",group:"config",store:{path:"~/.claude/session-manager/workbench-layout.json",format:"json",definedIn:"src/main/layoutStore.cjs + src/renderer/state/layout.ts "},summary:"Persisted dockview panel layout, pruned against the live panel registry on hydrate.",fields:[{name:"version",type:"number"},{name:"panels",type:"string[]",key:"fk",ref:"tab.id"},{name:"dockview",type:"Record<string, unknown>",note:"opaque SerializedDockview blob"}]},{id:"opsNamespace",name:"Ops namespace ownership",aka:"the SINGLE-WRITER LAW",group:"config",store:{path:"src/main/lib/opsOwnership.cjs (OWNERS)",format:"code",definedIn:"src/main/lib/opsOwnership.cjs (assertOpsWrite) "},summary:"Fail-closed — a new top-level ops folder must land in OWNERS (or the deliberately-unowned list) in the same PR that creates it.",fields:[{name:"namespace",type:"string",key:"pk",note:"e.g. 'prompt-sessions', 'scheduler', 'project-brief'"},{name:"writer",type:"string",note:"e.g. 'epics', 'scheduler', 'project-home'"}]},{id:"mcpServerRegistry",name:"MCP server registry",aka:"mcpServers",group:"config",store:{path:"~/.claude.json -> mcpServers",format:"json",definedIn:"src/renderer/components/tabs/McpServers.tsx "},summary:"User-scope MCP server config — no single writer, since both the claude CLI and this app read/write the same file.",fields:[{name:"name",type:"string",key:"pk"},{name:"type",type:"'stdio' | 'http' | 'sse' | 'ws' | 'streamable-http'",optional:!0},{name:"command",type:"string",optional:!0},{name:"args",type:"string[]",optional:!0},{name:"url",type:"string",optional:!0},{name:"env",type:"Record<string, string>",optional:!0},{name:"headers",type:"Record<string, string>",optional:!0},{name:"alwaysLoad",type:"boolean",optional:!0},{name:"enabled",type:"boolean",optional:!0},{name:"disabledTools",type:"string[]",optional:!0}]},{id:"pluginRegistry",name:"Installed plugins manifest",aka:"installed_plugins.json",group:"config",store:{path:"~/.claude/plugins/installed_plugins.json",format:"json",definedIn:"src/renderer/components/tabs/Plugins.tsx "},summary:'Registry of installed plugin versions, keyed by "<name>@<marketplace>" — written by `claude plugin install`, read-only in the Plugins screen.',fields:[{name:"pluginKey",type:"string",key:"pk",note:"<name>@<marketplace>"},{name:"scope",type:"string"},{name:"installPath",type:"string"},{name:"version",type:"string"},{name:"installedAt",type:"string"},{name:"lastUpdated",type:"string"},{name:"gitCommitSha",type:"string",optional:!0}]},{id:"systemPrompt",name:"User CLAUDE.md",aka:"~/.claude/CLAUDE.md",group:"config",store:{path:"~/.claude/CLAUDE.md",format:"markdown",definedIn:"src/renderer/components/tabs/SystemPrompt.tsx "},summary:"The real ~/.claude/CLAUDE.md the claude CLI loads into every session it starts on this machine, in every project — edited here as plain markdown.",fields:[{name:"content",type:"string"},{name:"imports",type:"string[]",note:"@-imported files, listed in a left rail"}]},{id:"skillsAndCommands",name:"Skills & Commands",group:"config",store:{path:"~/.claude/skills/**/SKILL.md + ~/.claude/commands/*.md (and the <cwd>/.claude equivalents for project scope)",format:"directory",definedIn:"src/renderer/components/tabs/Skills.tsx "},summary:"User- and project-scope skill/command markdown files, each editable in place.",fields:[{name:"kind",type:"'skills' | 'commands'"},{name:"scope",type:"'user' | 'project'"},{name:"name",type:"string",key:"pk"},{name:"path",type:"string",note:"absolute path to the editable markdown file"},{name:"dir",type:"string | null",note:"skill directory, if applicable"},{name:"disabled",type:"boolean",note:"skills only — disable-model-invocation: true frontmatter"},{name:"description",type:"string",optional:!0}]},{id:"mcpStatusProbe",name:"MCP status probe",group:"config",store:{path:"in-memory result of `claude mcp list`, never persisted",format:"in-memory",definedIn:"src/main/mcpStatus.cjs (runProbe) "},summary:"Read-only, non-polling live connection probe — models an in-memory-only shape honestly, the same way transcriptEvent does.",fields:[{name:"ok",type:"boolean"},{name:"servers",type:"McpServerStatus[]",note:"{ name, target, transport, status }"},{name:"error",type:"string",optional:!0},{name:"checkedAt",type:"number"}]},{id:"uiPrefs",name:"UiPrefs",aka:"ui-prefs/prefs.json",group:"config",store:{path:"<cwd>/session-manager-operations/ui-prefs/prefs.json",format:"json",writer:"ui-prefs",definedIn:"src/renderer/lib/uiPrefs.ts "},summary:"Per-project UI state that used to live in scattered global/localStorage keys — one file per project keeps it scoped to the project it belongs to by construction (PRD 1398/1399).",fields:[{name:"fileTreeExpanded",type:"string[]",optional:!0,note:"FileTree.tsx — expanded folder paths in the Files sidebar"},{name:"hiddenCompletedSlugs",type:"string[]",optional:!0,note:'SchedulePanel.tsx — "Clear completed" hides, renderer-side only'},{name:"queueFilterStatus",type:"string",optional:!0,note:"SchedulePanel.tsx — the queue's status filter chip"},{name:"epicPins",type:"Record<string, boolean>",optional:!0,key:"fk",ref:"epic.id",note:"epicsPrefs.ts — pinned-to-top Epic ids, keyed by epicId (moved off the global epics-prefs.json)"},{name:"chatVerbosityPerEpic",type:"Record<string, ChatVerbosity>",optional:!0,key:"fk",ref:"epic.id",note:"chatPrefs.ts — per-Epic verbosity overrides, keyed by epicId (moved off the global chat-prefs.json)"},{name:"editorSession",type:"{ openFiles: string[]; activeFilePath: string | null; viewModeByPath: Record<string, string> }",optional:!0,note:"editor.ts — the Editor scene's structural tab strip only; buffers/baselines/dirty are never persisted (PRD 1400)"}]}];function cB(i){const e=ay.find(t=>t.id===i);if(!e)throw new Error(`unknown ErdEntity id: ${i}`);return e}const Dk=[{from:"tab",to:"project",cardinality:"N-1",label:"belongs to"},{from:"epic",to:"project",cardinality:"N-1",label:"belongs to"},{from:"epic",to:"tag",cardinality:"N-1",label:"mission",optional:!0},{from:"epic",to:"agentPersona",cardinality:"N-1",label:"actor",optional:!0},{from:"epic",to:"epic",cardinality:"N-1",label:"resumed from",optional:!0},{from:"epic",to:"claudeTranscript",cardinality:"1-1",label:"1:1 session"},{from:"epicEvent",to:"epic",cardinality:"N-1",label:"belongs to"},{from:"epicEvent",to:"epicEvent",cardinality:"N-1",label:"caused by",optional:!0},{from:"epicEvent",to:"prd",cardinality:"N-1",label:"about",optional:!0},{from:"epicTranscriptTurn",to:"epic",cardinality:"N-1",label:"belongs to"},{from:"epicTranscriptTurn",to:"epicEvent",cardinality:"N-1",label:"labeled by",optional:!0},{from:"epicArchive",to:"epic",cardinality:"1-1",label:"freezes"},{from:"exchange",to:"epic",cardinality:"N-1",label:"session for",optional:!0},{from:"exchange",to:"project",cardinality:"N-1",label:"belongs to"},{from:"prd",to:"epic",cardinality:"N-1",label:"joins (directory fact)"},{from:"prd",to:"epic",cardinality:"N-1",via:"sourcePromptId",label:"authored from (frontmatter intent)",optional:!0},{from:"prd",to:"project",cardinality:"N-1",label:"belongs to"},{from:"prd",to:"tag",cardinality:"N-1",label:"mission",optional:!0},{from:"scheduleJob",to:"prd",cardinality:"1-1",label:"executes"},{from:"scheduleJob",to:"prd",cardinality:"N-N",via:"dependsOn",label:"depends on",optional:!0},{from:"scheduleJob",to:"epic",cardinality:"N-1",label:"belongs to",optional:!0},{from:"scheduleJob",to:"runLog",cardinality:"N-1",label:"ran as",optional:!0},{from:"scheduleJob",to:"scheduleJob",cardinality:"N-N",via:"dependsOn",label:"depends on (self)",optional:!0},{from:"scheduleJobStatusHistory",to:"scheduleJob",cardinality:"N-1",label:"transitions of"},{from:"scheduleHistoryEntry",to:"prd",cardinality:"N-1",label:"archives"},{from:"scheduleHistoryEntry",to:"epic",cardinality:"N-1",label:"belongs to",optional:!0},{from:"scheduleHistoryEntry",to:"runLog",cardinality:"N-1",label:"ran as",optional:!0},{from:"scheduleConfig",to:"project",cardinality:"1-1",label:"configures"},{from:"agentPersona",to:"tag",cardinality:"N-N",label:"tagged with"},{from:"agentPersona",to:"project",cardinality:"N-N",label:"action button in"},{from:"memoryEntry",to:"project",cardinality:"N-1",label:"workspace"},{from:"memoryCluster",to:"memoryEntry",cardinality:"1-N",label:"clusters"},{from:"agentMemoryEntry",to:"agentPersona",cardinality:"N-1",label:"belongs to"},{from:"transcriptEvent",to:"tab",cardinality:"N-1",label:"classified for"},{from:"transcriptEvent",to:"claudeTranscript",cardinality:"N-1",label:"classified from"},{from:"claudeTranscript",to:"project",cardinality:"N-1",label:"belongs to"},{from:"historyRollupDay",to:"project",cardinality:"N-N",label:"aggregates"},{from:"billingUsage",to:"scheduleConfig",cardinality:"1-N",label:"gates when-available firing"},{from:"projectBrief",to:"project",cardinality:"1-1",label:"describes"},{from:"projectBrief",to:"epic",cardinality:"N-1",via:"areas[].epic",label:"traces to",optional:!0},{from:"projectPages",to:"project",cardinality:"1-1",label:"generated for"},{from:"settingsScope",to:"project",cardinality:"N-1",label:"scoped to",optional:!0},{from:"layoutEnvelope",to:"tab",cardinality:"1-N",label:"panels for"},{from:"opsNamespace",to:"epic",cardinality:"1-N",label:"governs writes"},{from:"opsNamespace",to:"prd",cardinality:"1-N",label:"governs writes"},{from:"opsNamespace",to:"projectBrief",cardinality:"1-N",label:"governs writes"}];function HP(i){return Dk.filter(e=>e.from===i||e.to===i)}function dB(i){const e=new Set;for(const t of HP(i)){const n=t.from===i?t.to:t.from;n!==i&&e.add(n)}return[...e]}function uB(i){switch(i){case"1-1":return"1—1";case"1-N":return"1—N";case"N-1":return"N—1";case"N-N":return"N—N"}}const j0=220,R0=7,WP=44,UP=16,VP=10,qP=96,KP=28,Vg=24;function YP(i){const e=Math.min(i,R0)+(i>R0?1:0);return WP+e*UP+VP}function XP(i){const e=i.x+i.w,t=i.y+i.h*.35,n=i.y+i.h*.65,r=e+48;return{d:`M ${e} ${t} C ${r} ${t}, ${r} ${n}, ${e} ${n}`,mx:r,my:(t+n)/2}}function hB(i=ay,e=Dk){const t=Tk.map(f=>f.id).filter(f=>i.some(m=>m.group===f)),n=[],r=new Map;t.forEach((f,m)=>{const g=Vg+m*(j0+qP);let y=Vg;for(const D of i){if(D.group!==f)continue;const E=YP(D.fields.length),C={id:D.id,group:f,x:g,y,w:j0,h:E};n.push(C),r.set(D.id,C),y+=E+KP}});const l=new Set(i.map(f=>f.id)),p=[];for(const f of e){if(!l.has(f.from)||!l.has(f.to))continue;const m=r.get(f.from),g=r.get(f.to);if(!m||!g)continue;if(f.from===f.to){const j=XP(m);p.push({relation:f,...j});continue}const y=m.x<g.x,D=y?m.x+m.w:m.x,E=m.y+m.h/2,C=y?g.x:g.x+g.w,b=g.y+g.h/2,w=Math.max(40,Math.abs(C-D)/2),x=D+(y?w:-w),S=C+(y?-w:w),T=`M ${D} ${E} C ${x} ${E}, ${S} ${b}, ${C} ${b}`;p.push({relation:f,d:T,mx:(D+C)/2,my:(E+b)/2})}const a=n.reduce((f,m)=>Math.max(f,m.x+m.w),0),d=n.reduce((f,m)=>Math.max(f,m.y+m.h),0);return{boxes:n,edges:p,width:a+Vg,height:d+Vg}}const ly=[];function JP({onNavigate:i}){const e=z.useMemo(()=>{const m=new Date().getHours();return m<5?"Up late":m<12?"Good morning":m<18?"Good afternoon":"Good evening"},[]);hj();const t=ej(),n=QP(),r=Ct(m=>m.tabs),l=Ct(m=>m.addTab),p=Ct(m=>m.setActive),[a,d]=z.useState(!1),f=m=>{vk(m,r,l,p),i==null||i("terminal")};return c.jsxs("div",{className:"h-full overflow-auto",children:[c.jsxs("div",{className:"mx-auto max-w-[1400px] px-[34px] py-[26px] text-fg",children:[c.jsx(nj,{greeting:e,projectCount:n.length,needsCount:t.length,onNavigate:i,onOpenNewEpic:()=>d(!0)}),c.jsxs("div",{"data-testid":"home-panel-grid",className:"grid gap-[18px] mb-7",style:{gridTemplateColumns:"repeat(3, minmax(0,1fr))",gridTemplateRows:"repeat(2, minmax(0, 300px))"},children:[c.jsx("div",{className:"bg-bg-hi border border-line rounded-[14px] px-4 py-[14px] min-h-0 overflow-auto",children:c.jsx(dj,{})}),c.jsx(uj,{projectRows:n}),c.jsx(lj,{onNavigate:i}),c.jsx(aj,{rows:t,onNavigate:i}),c.jsx(mj,{onNavigate:i}),c.jsx(fj,{onNavigate:i})]}),c.jsxs("details",{"data-testid":"home-reference",className:"mb-6",children:[c.jsx("summary",{className:"cursor-pointer font-mono text-[11px] uppercase tracking-[0.08em] text-fg-faint mb-3",children:"Reference & appearance"}),c.jsx(CP,{}),c.jsx(tj,{}),c.jsx(ij,{onNavigate:i}),c.jsx(bP,{})]})]}),c.jsx(pP,{open:a,onClose:()=>d(!1),projects:n,onConfirm:f})]})}const ZP=z.memo(JP);function QP(){const{projects:i}=Cd(),e=Qv(),t=ri(n=>n.sessions);return z.useMemo(()=>nP(i,e,t),[i,e,t])}function ej(){const i=ri(n=>n.sessions),e=Qv(),t=Wr(n=>{var r;return(r=n.snapshot)==null?void 0:r.jobs})??ly;return z.useMemo(()=>{const n={};for(const r of Object.keys(i)){const l=i[r];l.status==="proposed"&&(n[r]={id:r,cwd:l.cwd,goalText:l.goalText,tag:l.tag})}return aP(n,e,t)},[i,e,t])}function tj(){const i=Sk(null),{value:e,source:t}=Ck(i,["effortLevel"]),n=kk(e,t);return c.jsxs("section",{className:"mb-6",children:[c.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[c.jsx("h2",{className:"m-0 font-serif text-[22px] font-medium",children:"Agents"}),c.jsxs("span",{className:"font-mono text-[12px] text-fg-faint","data-testid":"home-agents-effort",title:"Machine-wide effective reasoning effort — the settings.json scope chain's current winner, independent of any one project.",children:["1 tag per session · ",n]})]}),c.jsx("div",{className:"grid gap-2",children:U2.map(r=>{const l=oC[r],p=qT(r);return c.jsxs("div",{className:"bg-bg-hi border border-line rounded-[13px] px-4 py-[13px]",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[c.jsx("span",{className:`font-mono text-[10.5px] font-semibold uppercase tracking-[0.06em] px-1.5 py-0.5 rounded ${p.bg} ${p.text}`,children:p.label}),c.jsx("span",{className:"text-[12px] text-fg-faint",children:l.description})]}),c.jsx("p",{className:"m-0 text-[12.5px] text-fg-dim leading-[1.5] font-mono whitespace-pre-wrap",children:l.initialPromptTemplate})]},r)})})]})}function ij({onNavigate:i}){return c.jsx("section",{className:"mb-6",children:c.jsxs("button",{type:"button","data-testid":"home-data-model-card",onClick:()=>i==null?void 0:i("data-model"),className:"w-full text-left bg-bg-hi border border-line rounded-[14px] px-4 py-[14px] flex items-center justify-between hover:bg-bg-elev/40 transition-colors",children:[c.jsxs("span",{children:[c.jsx("span",{className:"block font-serif text-[16px] font-medium text-fg",children:"Data Model"}),c.jsxs("span",{className:"block text-[12.5px] text-fg-dim",children:[ay.length," entities — what Session Manager persists, and how it joins"]})]}),c.jsx("span",{className:"font-mono text-[11px] text-accent shrink-0",children:"Open →"})]})})}function nj({greeting:i,projectCount:e,needsCount:t,onNavigate:n,onOpenNewEpic:r}){const[l,p]=z.useState(!1);return c.jsxs(c.Fragment,{children:[c.jsx(sj,{greeting:i,projectCount:e,needsCount:t,onNavigate:n,onOpenNewEpic:r,legendOpen:l,onToggleLegend:()=>p(a=>!a)}),l&&c.jsx(oj,{})]})}function sj({greeting:i,projectCount:e,needsCount:t,onNavigate:n,onOpenNewEpic:r,legendOpen:l,onToggleLegend:p}){const a=Vw(),d=(a==null?void 0:a.total)??5,f=(a==null?void 0:a.inUse)??0,m=()=>{var g;(g=document.getElementById("home-needs-you"))==null||g.scrollIntoView({behavior:"smooth",block:"start"})};return c.jsxs("header",{className:"mb-[18px] flex items-end gap-4",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"font-mono text-[10.5px] font-semibold uppercase tracking-[0.08em] text-fg-faint mb-1.5",children:["This machine · ",e," project",e===1?"":"s"]}),c.jsxs("h1",{className:"m-0 font-serif text-[30px] font-semibold leading-[1.1] text-fg tracking-[-0.01em]",children:[i,". ",c.jsxs("span",{className:"text-accent",children:[f," of ",d]})," slots busy,"," ",t>0?c.jsxs("button",{onClick:m,className:"underline decoration-dotted underline-offset-4 text-honey-dark hover:text-honey",children:[t," thing",t>1?"s":""]}):c.jsx("span",{className:"text-sage",children:"nothing"})," ","need",t===1?"s":""," you."]})]}),c.jsxs("div",{className:"ml-auto flex gap-2 shrink-0",children:[c.jsx(H_,{onClick:p,children:l?"Hide interactions":"Interactions"}),c.jsx(H_,{onClick:()=>n==null?void 0:n("history"),children:"All history"}),c.jsx(H_,{primary:!0,onClick:r,children:"New epic"})]})]})}const rj=[{term:"Usage card",description:"Read-only — shows the live 5-hour and weekly billing windows. Not clickable."},{term:"Queued job",description:`Click a job row to open a popover with its real details (project, estimate, status) and actions — Open in Scheduler, plus Nudge scheduler now while it's pending. Use "Open Scheduler →" in the card header to jump straight to the Scheduler tab.`},{term:"Needs-you row",description:"Click a row to expand it inline, then Approve & start / Discard a proposed session, Open a session waiting on input, Retry / view a failed job, or Adopt / view a quarantined PRD."},{term:"Active session row",description:"Click Open to jump to the Scheduler tab (job) or the session's Terminal view."},{term:"Recent row",description:"Click resume to open a new Terminal tab that resumes that transcript session."},{term:"Project row",description:"Click a project to activate its open Terminal tab, or open a new dormant one."},{term:"New session",description:"Opens a project picker; confirming activates-or-opens that project's tab and lands you in its Sessions workspace to start the session."}];function oj(){return c.jsxs("div",{className:"mb-7 bg-bg-hi border border-line rounded-[13px] px-4 py-[13px]",children:[c.jsx("div",{className:"font-mono text-[11px] uppercase tracking-[0.08em] text-fg-faint mb-2.5",children:"Interactions"}),c.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:"minmax(0,140px) minmax(0,1fr)"},children:rj.map(i=>c.jsxs("div",{className:"contents",children:[c.jsx("div",{className:"text-[12.5px] font-semibold text-fg underline decoration-dotted underline-offset-4",children:i.term}),c.jsx("div",{className:"text-[12.5px] text-fg-dim leading-[1.5]",children:i.description})]},i.term))})]})}function H_({children:i,onClick:e,primary:t}){return c.jsx("button",{onClick:e,className:t?"rounded-lg bg-accent text-bg-hi px-4 py-2 text-[12.5px] font-semibold hover:bg-accent-dark":"rounded-lg border border-line bg-bg-hi px-4 py-2 text-[12.5px] font-semibold text-fg-dim hover:bg-bg-elev",children:i})}function aj({rows:i,onNavigate:e}){const[t,n]=z.useState(null),[r,l]=z.useState(null),p=mm(i,4),a=D=>{n(null),p.setPage(D)},d=D=>{if(!(!D.epicId||r)){l(D.id);try{const E=ri.getState().approveProposed(D.epicId,"Home needs-you");if(!E){Qe.error("This session is no longer awaiting approval.");return}vi.getState().send({tabId:E.id,sessionId:E.claudeSessionId,cwd:E.cwd,prompt:E.openingPrompt||E.goalText}),Qe.info("Session approved and started.")}finally{l(null),n(null)}}},f=D=>{!D.epicId||r||(l(D.id),ri.getState().markCompleted(D.epicId,"Home needs-you discard").catch(()=>{}).finally(()=>{l(null),n(null)}))},m=D=>{D.epicId&&(t_(D.epicId),e==null||e("terminal"))},g=D=>{!D.jobSlug||r||(l(D.id),window.api.schedule.resetJob(D.jobSlug).then(E=>{E.ok?Qe.info(`${D.jobSlug} reset to pending.`):Qe.error(E.error??"Could not reset job.")}).catch(E=>Qe.error(E instanceof Error?E.message:String(E))).finally(()=>{l(null),n(null)}))},y=D=>{!D.jobSlug||r||(l(D.id),window.api.schedule.adoptPrd(D.jobSlug).then(E=>{E.ok?Qe.info(`${D.jobSlug} adopted — will run on the next tick.`):Qe.error(E.message??"Could not adopt PRD.")}).catch(E=>Qe.error(E instanceof Error?E.message:String(E))).finally(()=>{l(null),n(null)}))};return c.jsxs("section",{id:"home-needs-you",className:"bg-bg-hi border border-line rounded-[14px] px-4 py-[14px] min-h-0 overflow-auto scroll-mt-4",children:[c.jsxs("div",{className:"flex items-baseline justify-between gap-2 mb-2.5",children:[c.jsx("h2",{className:"m-0 font-mono text-[11px] uppercase tracking-[0.08em] text-fg-faint font-normal",children:"Needs you"}),c.jsx("span",{className:"font-mono text-[12px] text-fg-faint",children:i.length?`${i.length} open`:"all clear"})]}),i.length===0&&c.jsx("div",{className:"bg-bg-hi border border-line rounded-[11px] px-4 py-[18px] text-center text-[13px] text-fg-faint",children:"Nothing waiting on you. Proposed Epics, mid-run questions, and failed jobs will surface here."}),c.jsx("div",{className:"grid gap-[7px]",children:p.pageItems.map(D=>{const E=t===D.id,C=D.kind==="job-failed"?"bg-accent":D.kind==="job-quarantined"?D.escalated?"bg-accent":"bg-honey":D.kind==="needs-input"?"bg-honey":"bg-sage";return c.jsxs("div",{className:`border rounded-[11px] overflow-hidden ${E?"bg-bg-hi border-line":"bg-bg border-line/60"}`,children:[c.jsxs("button",{onClick:()=>n(E?null:D.id),className:"w-full grid items-center gap-2.5 px-[13px] py-[10px] text-left",style:{gridTemplateColumns:"6px minmax(0,1fr) auto"},children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${C}`}),c.jsxs("span",{className:"min-w-0",children:[c.jsx("span",{className:"block text-[12.5px] font-semibold text-fg",children:D.label}),c.jsxs("span",{className:"block text-[11.5px] text-fg-faint truncate",children:[D.project?`${D.project} · `:"",D.detail]})]}),c.jsx("span",{className:"font-mono text-[11px] text-fg-faint",children:E?"▴":"▾"})]}),E&&c.jsxs("div",{className:"border-t border-line px-[13px] pt-[11px] pb-3 grid gap-2.5",children:[c.jsx("div",{className:"text-[12.5px] text-fg-dim leading-relaxed",children:D.meta}),c.jsxs("div",{className:"flex gap-2",children:[D.kind==="proposed-epic"&&c.jsxs(c.Fragment,{children:[c.jsx(ld,{onClick:()=>d(D),disabled:r===D.id,children:"Approve & start"}),c.jsx(ld,{quiet:!0,onClick:()=>f(D),disabled:r===D.id,children:"Discard"})]}),D.kind==="needs-input"&&c.jsx(ld,{onClick:()=>m(D),children:"Open session"}),D.kind==="job-failed"&&c.jsxs(c.Fragment,{children:[c.jsx(ld,{onClick:()=>g(D),disabled:r===D.id,children:"Retry now"}),c.jsx(ld,{quiet:!0,onClick:()=>e==null?void 0:e("scheduler"),children:"View in Scheduler"})]}),D.kind==="job-quarantined"&&c.jsxs(c.Fragment,{children:[c.jsx(ld,{onClick:()=>y(D),disabled:r===D.id,children:"Adopt PRD"}),c.jsx(ld,{quiet:!0,onClick:()=>e==null?void 0:e("scheduler"),children:"View in Scheduler"})]})]})]})]},D.id)})}),c.jsx(gm,{compact:!0,testIdPrefix:"home-needs-pager",page:p.page,pageSize:p.pageSize,totalItems:p.total,onPageChange:a})]})}function ld({children:i,onClick:e,disabled:t,quiet:n}){return c.jsx("button",{onClick:e,disabled:t,className:n?"rounded-md border border-line bg-bg px-3 py-[5px] text-[11.5px] font-semibold text-fg-dim hover:bg-bg-elev disabled:opacity-50":"rounded-md bg-accent text-bg-hi px-3 py-[5px] text-[11.5px] font-semibold hover:bg-accent-dark disabled:opacity-50",children:i})}function lj({onNavigate:i}){const e=Wr(a=>{var d;return(d=a.snapshot)==null?void 0:d.jobs})??ly,t=z.useMemo(()=>e.filter(a=>a.status==="pending"),[e]),n=mm(t,5),[r,l]=z.useState(null),p=()=>{mk(),l(null)};return c.jsxs("div",{className:"bg-bg-hi border border-line rounded-[14px] px-4 py-[14px] min-h-0 overflow-auto",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2.5",children:[c.jsxs("div",{className:"font-mono text-[11px] uppercase tracking-[0.08em] text-fg-faint",children:["Queued",t.length>0?` · ${t.length}`:""]}),c.jsx("button",{onClick:()=>i==null?void 0:i("scheduler"),className:"font-mono text-[10.5px] text-accent hover:underline",children:"Open Scheduler →"})]}),t.length===0?c.jsx("div",{className:"text-[13px] text-fg-faint py-1",children:"Nothing pending."}):c.jsx("div",{className:"space-y-2.5",children:n.pageItems.map(a=>c.jsxs("div",{className:"relative",children:[c.jsxs("button",{onClick:()=>l(r===a.slug?null:a.slug),className:"w-full text-left hover:bg-bg/40 rounded-md -mx-1 px-1 py-0.5 transition-colors",children:[c.jsx("div",{className:"font-mono text-[11.5px] font-semibold text-fg truncate",children:a.title||a.slug}),c.jsxs("div",{className:"text-[11px] text-fg-faint truncate",children:[a.cwd?Go(a.cwd):"—",a.estimateMinutes!=null?` · ~${a.estimateMinutes}m`:""]})]}),r===a.slug&&c.jsx(fP,{job:a,onClose:()=>l(null),onOpenScheduler:()=>{l(null),i==null||i("scheduler")},onRunNow:a.status==="pending"?p:void 0})]},a.slug))}),c.jsx(gm,{compact:!0,testIdPrefix:"home-queued-pager",page:n.page,pageSize:n.pageSize,totalItems:n.total,onPageChange:n.setPage})]})}function cj({slots:i}){const e=(i==null?void 0:i.min)??0,t=(i==null?void 0:i.max)??10,n=(i==null?void 0:i.total)??5,r=(i==null?void 0:i.envOverride)??!1,[l,p]=z.useState(null),[a,d]=z.useState(!1),f=l??n,m=g=>{p(g),d(!0),_$(g).catch(y=>{Qe.error(`Could not set session slots: ${y instanceof Error?y.message:String(y)}`)}).finally(()=>{d(!1),p(null)})};return c.jsxs("span",{className:"flex items-center gap-2.5 shrink-0",title:r?"Pinned by SM_SESSION_SLOTS env var":"Max concurrent claude -p sessions on this machine (0 pauses new launches)",children:[c.jsx("span",{className:"font-mono text-[11px] text-fg-faint",children:"Max slots"}),c.jsx("input",{type:"range",min:e,max:t,step:1,value:f,disabled:r||a,onChange:g=>m(Number(g.target.value)),className:"w-24 accent-accent disabled:opacity-40 disabled:cursor-not-allowed"}),c.jsx("span",{className:"font-mono text-[12px] font-semibold text-fg w-4 text-right",children:f})]})}function dj(){const i=em(t=>t.data),e=TC(i);return c.jsxs("div",{className:"space-y-3",children:[i&&i.kind!=="ok"&&i.kind!=="ok-stale"&&c.jsx(jP,{result:i,onRetry:JD}),!i&&c.jsx("div",{className:"text-xs text-fg-faint",children:"loading usage…"}),e&&c.jsx(hP,{data:e,updatedAt:e.fetchedAt})]})}function uj({projectRows:i}){const e=Ct(a=>a.tabs),t=Ct(a=>a.addTab),n=Ct(a=>a.setActive),{unresolvedWorktreeFolders:r}=Cd(),l=mm(i,8),p=a=>{vk(a,e,t,n),ji.getState().setEpicsWorkspaceOpen(!1)};return c.jsxs("div",{className:"bg-bg-hi border border-line rounded-[14px] px-4 py-[14px] min-h-0 overflow-auto",children:[c.jsx("div",{className:"font-mono text-[11px] uppercase tracking-[0.08em] text-fg-faint mb-2.5",children:"Projects"}),i.length===0?c.jsx("div",{className:"text-[13px] text-fg-faint py-2",children:"No known projects yet."}):c.jsx("div",{className:"space-y-1",children:l.pageItems.map(a=>c.jsxs("button",{onClick:()=>p(a.cwd),className:"w-full flex items-center gap-2.5 text-left px-2 py-1.5 rounded-lg hover:bg-bg/60 transition-colors",title:a.cwd,children:[c.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:gk(a.dotSeed)}}),c.jsx("span",{className:"flex-1 min-w-0 text-[13px] text-fg truncate",children:a.name}),a.liveCount>0?c.jsxs("span",{className:"font-mono text-[11px] text-accent whitespace-nowrap",children:[a.liveCount," live"]}):c.jsx("span",{className:"font-mono text-[11px] text-fg-faint whitespace-nowrap",children:tr(a.lastActivityMs,Date.now())})]},a.encoded))}),c.jsx(gm,{compact:!0,testIdPrefix:"home-projects-pager",page:l.page,pageSize:l.pageSize,totalItems:l.total,onPageChange:l.setPage}),r>0&&c.jsxs("div",{"data-testid":"home-projects-unresolved",className:"mt-2 text-[11px] text-fg-faint",children:[r," worktree folders not matched to a project"]})]})}function hj(){const{projects:i}=Cd(),e=z.useMemo(()=>i.map(t=>t.cwd).join(`
|
|
2942
|
+
`);e!==L_&&(L_=e,QI(i).then(t=>{e===L_&&(gv=t,fk())}).catch(t=>{console.error("[useKnownProjects] owner map failed:",t)}))}const Qb=6;async function ew(i,e,t){const n=new Array(i.length);let r=0;const l=Array.from({length:Math.min(e,i.length)},async()=>{for(;;){const p=r++;if(p>=i.length)return;n[p]=await t(i[p])}});return await Promise.all(l),n}async function tP(i){const e=++oc;Sh({loading:!0,resolving:!0});try{const t=await window.api.config.listDir(`${i}/.claude/projects`,{dirsOnly:!0});if(e!==oc)return;const n=t.entries,r=[],l=await ew(n,Qb,async p=>{const d=(await window.api.config.listDir(p.path,{filesOnly:!0})).entries.filter(g=>g.name.endsWith(".jsonl"));for(const g of d)r.push({sessionId:g.name.replace(/\.jsonl$/,""),projectEncoded:p.name,path:g.path,mtimeMs:g.mtimeMs,sizeBytes:g.size});const f=d.reduce((g,y)=>Math.max(g,y.mtimeMs),0),m=d.reduce((g,y)=>g+y.size,0);return{encoded:p.name,displayPath:hk(p.name),sessionCount:d.length,lastSession:f,path:p.path,sizeBytes:m}});if(e!==oc)return;l.sort((p,a)=>a.lastSession-p.lastSession),r.sort((p,a)=>a.mtimeMs-p.mtimeMs),Sh({rows:l,recentSessions:r.slice(0,JI),enriched:{},loading:!1,resolving:!0}),iP(l,e)}catch(t){console.error("[useKnownProjects] scan failed:",t),e===oc&&Sh({loading:!1,resolving:!1})}}async function iP(i,e){const t={};if(await ew(i,Qb,async l=>{if(e===oc){if(l.sessionCount===0){t[l.encoded]=null;return}try{const p=await pk(l.path);t[l.encoded]=p?Er(p):null}catch{t[l.encoded]=null}}}),e!==oc)return;const n={};for(const l of i)n[l.encoded]={cwd:t[l.encoded]??null};Sh({enriched:n,resolving:!1});const r=[...new Set(Object.values(t).filter(l=>!!l))];await ew(r,Qb,async l=>{if(e!==oc)return;let p={};try{p=await WI(l)}catch{return}if(e!==oc)return;const a={...xh.enriched};for(const[d,f]of Object.entries(t))f===l&&(a[d]={cwd:l,...p});Sh({enriched:a})})}function Cd(){const i=e_(),[,e]=z.useState(0),t=Ct(b=>b.addTab);z.useEffect(()=>{const b=()=>e(w=>w+1);return Zb.add(b),()=>{Zb.delete(b)}},[]),z.useEffect(()=>{i&&T0!==i&&(T0=i,tP(i))},[i]);const{rows:n,recentSessions:r,enriched:l,loading:p,resolving:a}=xh,d=z.useMemo(()=>KI(n,l),[n,l]);z.useEffect(()=>{eP(d)},[d]);const f=gv??new Map,m=z.useMemo(()=>YI(n,l,f),[n,l,gv]),g=z.useMemo(()=>qI(n,l,f),[n,l,gv]),y=async b=>{const w=crypto.randomUUID();t({id:w,cwd:b,startupCommand:null,presetId:"projects-tab",dormant:!0})},D=async b=>{var S;let w=((S=l[b.encoded])==null?void 0:S.cwd)??null;if(w||(w=await pk(b.path)),!w&&(w=await window.api.app.pickDirectory(),!w))return;const x=crypto.randomUUID();t({id:x,cwd:w,startupCommand:null,presetId:"projects-tab",dormant:!0})},E=async b=>{try{const w=await window.api.app.archiveProject(b);return w.ok&&Sh({rows:xh.rows.filter(x=>x.encoded!==b),enriched:Object.fromEntries(Object.entries(xh.enriched).filter(([x])=>x!==b))}),w}catch(w){return{ok:!1,error:w instanceof Error?w.message:"Archive failed"}}};return{rows:n,recentSessions:r,enriched:l,projects:m,unresolvedWorktreeFolders:g,loading:p,resolving:a,openProject:y,openInSession:D,archiveProject:E,archiveProjectByCwd:async b=>{let w={ok:!0};for(const x of b.encodedIds)if(w=await E(x),!w.ok)return w;return w}}}function nP(i,e,t){var r,l;const n=new Map;for(const p of Object.keys(e)){if(!((r=e[p])!=null&&r.running))continue;const a=(l=t[p])==null?void 0:l.cwd;if(!a)continue;const d=Er(a);n.set(d,(n.get(d)??0)+1)}return i.map(p=>({encoded:p.encoded,name:p.name,cwd:p.cwd,dotSeed:p.cwd,liveCount:n.get(p.cwd)??0,lastActivityMs:p.lastSession}))}function z_(i){return{owner:i.owner,kind:"session",at:i.at,project:null,epicTitle:null,openTarget:null,epicId:null}}function sP(i,e,t,n){return i.map(r=>{const l=r.owner;if(l.startsWith("scheduler:")){const p=l.slice(10),a=e.find(m=>m.slug===p);if(!a)return z_(r);const d=a.sourcePromptId??null,f=d?n[d]:void 0;return{owner:l,kind:"scheduler job",at:r.at,project:a.cwd?Go(a.cwd):null,epicTitle:(f==null?void 0:f.goalText)??null,openTarget:"scheduler",epicId:null}}if(l.startsWith("chat:")){const p=l.slice(5),a=t[p],d=n[p];return!(a!=null&&a.running)||!d?z_(r):{owner:l,kind:"chat run",at:r.at,project:Go(d.cwd),epicTitle:d.goalText,openTarget:"terminal",epicId:p}}return z_(r)})}function D0(i,e){for(const t of Object.keys(e))if(e[t].claudeSessionId===i)return e[t].goalText;return null}const rP=1440*60*1e3;function oP(i){const e=(i.statusHistory??[]).find(n=>n.to==="quarantined");if(!e)return null;const t=Date.parse(e.at);return Number.isNaN(t)?null:t}function aP(i,e,t,n=Date.now()){var l;const r=[];for(const p of Object.keys(i)){const a=i[p];r.push({id:`proposed:${p}`,kind:"proposed-epic",label:"Proposed Epic — awaiting approval",detail:a.goalText,meta:a.tag?`tag: ${a.tag}`:"Filed for you to decide on. Nothing has run.",project:Go(a.cwd),epicId:p,jobSlug:null})}for(const p of Object.keys(e)){const a=((l=e[p])==null?void 0:l.ticketHistory)??[],d=a[a.length-1];!d||d.status!=="needs-input"||r.push({id:`needs-input:${d.id}`,kind:"needs-input",label:"Session is asking a question",detail:d.text,meta:"Stopped mid-run, waiting on your reply.",project:Go(d.cwd),epicId:p,jobSlug:null})}for(const p of t){if(p.status==="quarantined"){const a=oP(p),d=a!=null?n-a:null,f=d!=null&&d>=rP;r.push({id:`job:${p.slug}`,kind:"job-quarantined",label:f?"Quarantined PRD — stale, needs adoption":"Scheduler PRD quarantined",detail:p.title||p.slug,meta:d!=null?`No createdVia provenance for ${Math.round(d/(3600*1e3))}h — adopt it to run, or archive from the Scheduler tab.`:"No createdVia provenance. Adopt it to run, or archive from the Scheduler tab.",project:p.cwd?Go(p.cwd):null,epicId:null,jobSlug:p.slug,escalated:f});continue}if(p.status==="running"&&p.overrun){const{ratio:a,ranMs:d,estimateMinutes:f}=p.overrun;r.push({id:`job:${p.slug}`,kind:"job-overrunning",label:"Scheduler job running over its own estimate",detail:p.title||p.slug,meta:`Ran ${Math.round(d/6e4)}m vs ${f}m estimate (${a.toFixed(1)}x). Check the run log, then let it finish or cancel it via scheduler_cancel_job.`,project:p.cwd?Go(p.cwd):null,epicId:null,jobSlug:p.slug});continue}p.status!=="failed"&&p.status!=="needs_review"||r.push({id:`job:${p.slug}`,kind:"job-failed",label:p.status==="failed"?"Scheduler job failed":"Scheduler job needs review",detail:p.title||p.slug,meta:p.error??"No error detail recorded.",project:p.cwd?Go(p.cwd):null,epicId:null,jobSlug:p.slug})}return r}let tw=null;function t_(i){tw=i,window.dispatchEvent(new CustomEvent("sm:select-prompt-session",{detail:i}))}function lP(){const i=tw;return tw=null,i}async function mk(){try{return await window.api.schedule.runNow(),!0}catch(i){const e=i instanceof Error?i.message:String(i);return Qe.error("Run now failed: "+e),!1}}const $0=["#6f7d52","#b85c34","#8a7a60","#e4b85a","#5f6f86","#4f7d72","#8a5a6e"];function cP(i){let e=0;for(let t=0;t<i.length;t++)e=e*31+i.charCodeAt(t)>>>0;return e}function gk(i){return $0[cP(i)%$0.length]}function vk(i,e,t,n){const r=e.find(l=>l.cwd===i);r?n(r.id):t({cwd:i,startupCommand:null,dormant:!0})}function mm(i,e){const[t,n]=z.useState(1),r=i.length,l=Math.max(1,Math.ceil(r/e)),p=Math.min(Math.max(1,t),l),a=z.useMemo(()=>i.slice((p-1)*e,p*e),[i,p,e]);return{page:p,setPage:n,pageItems:a,pageSize:e,total:r}}function gm({page:i,pageSize:e,totalItems:t,onPageChange:n,testIdPrefix:r="plan-pager",compact:l=!1}){if(t<=e)return null;const p=Math.max(1,Math.ceil(t/e)),a=(i-1)*e+1,d=Math.min(i*e,t),f=l?"flex items-center justify-center gap-3 px-2 py-1.5 font-mono text-[11px] text-fg-faint":"flex items-center justify-center gap-3 px-[18px] py-3 font-mono text-[12px] text-fg-faint";return c.jsxs("div",{"data-testid":r,className:f,children:[c.jsx("button",{type:"button","data-testid":`${r}-prev`,onClick:()=>n(i-1),disabled:i<=1,className:"px-2 py-1 rounded border border-line bg-bg-hi text-fg-dim hover:text-fg disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer",children:"Prev"}),c.jsxs("span",{"data-testid":`${r}-range`,children:[a,"–",d," of ",t]}),c.jsx("button",{type:"button","data-testid":`${r}-next`,onClick:()=>n(i+1),disabled:i>=p,className:"px-2 py-1 rounded border border-line bg-bg-hi text-fg-dim hover:text-fg disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer",children:"Next"})]})}function _k(i){return i>=90?{dot:"bg-accent",bar:"bg-accent",track:"bg-accent/15",text:"text-accent"}:i>=70?{dot:"bg-honey",bar:"bg-honey",track:"bg-honey/15",text:"text-honey-dark"}:{dot:"bg-sage",bar:"bg-sage",track:"bg-sage/15",text:"text-sage"}}function dP(i){return i?i.split("_").map(e=>/^\d/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1)).join(" "):null}function wf({label:i,sub:e,window:t,big:n=!1}){if(!t)return null;const r=t.utilization,l=Math.max(0,Math.min(100,r)),p=r>100,a=$C(t.resets_at),d=_k(r);return c.jsxs("div",{className:n?"py-[18px]":"py-[15px]",children:[c.jsxs("div",{className:"flex items-baseline justify-between gap-3 mb-2.5",children:[c.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[c.jsx("span",{className:`w-[9px] h-[9px] rounded-full shrink-0 ${d.dot}`}),c.jsx("span",{className:`font-semibold text-fg ${n?"text-base":"text-[15px]"}`,children:i}),e&&c.jsx("span",{className:"font-mono text-[11.5px] text-fg-faint bg-bg border border-line px-2 py-px rounded-full whitespace-nowrap",children:e})]}),c.jsxs("span",{className:`font-mono font-semibold leading-none tracking-tight shrink-0 ${n?"text-2xl":"text-xl"} ${p?"text-accent":d.text}`,children:[Math.round(r),"%"]})]}),c.jsx("div",{className:`rounded-full overflow-hidden ${n?"h-3":"h-2.5"} ${d.track}`,children:c.jsx("div",{className:`h-full rounded-full transition-[width] duration-500 ${d.bar}`,style:{width:`${l}%`}})}),a&&c.jsxs("div",{className:"flex items-center justify-between mt-2.5 gap-3",children:[c.jsxs("span",{className:"text-[12.5px] text-fg-dim",children:["resets in"," ",c.jsx("strong",{className:"text-fg font-semibold",children:a.rel}),a.abs&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-fg-faint",children:" · "}),c.jsx("span",{className:"font-mono text-xs text-fg-faint",children:a.abs})]})]}),p&&c.jsx("span",{className:"text-[11.5px] font-semibold text-accent",children:"over limit"})]})]})}function uP({extra:i}){const e=i.utilization??0,t=e>100,n=_k(e);return c.jsxs("div",{className:"border-t border-line pt-[15px] pb-[15px]",children:[c.jsxs("div",{className:"flex items-baseline justify-between mb-2.5",children:[c.jsxs("div",{className:"flex items-center gap-2.5",children:[c.jsx("span",{className:`w-[9px] h-[9px] rounded-full shrink-0 ${n.dot}`}),c.jsx("span",{className:"text-[15px] font-semibold text-fg",children:"Extra usage"}),c.jsx("span",{className:"font-mono text-[11.5px] text-fg-faint bg-bg border border-line px-2 py-px rounded-full whitespace-nowrap",children:"pay-as-you-go"})]}),c.jsxs("span",{className:`font-mono text-base font-semibold tabular-nums ${t?"text-accent":"text-fg"}`,children:[(i.used_credits??0).toFixed(2)," ",c.jsxs("span",{className:"text-fg-faint font-normal",children:["/ ",(i.monthly_limit??0).toFixed(2)," ",i.currency??""]})]})]}),c.jsx("div",{className:`h-2.5 rounded-full overflow-hidden ${n.track}`,children:c.jsx("div",{className:`h-full rounded-full transition-[width] duration-500 ${n.bar}`,style:{width:`${Math.min(e,100)}%`}})}),c.jsxs("div",{className:"flex items-center justify-between mt-2.5 gap-3",children:[c.jsxs("span",{className:"text-[12.5px] text-fg-dim",children:["monthly credit limit · resets"," ",c.jsx("span",{className:"font-mono text-xs text-fg-faint",children:"1st of month"})]}),t&&c.jsx("span",{className:"text-[11.5px] font-semibold text-accent",children:"over limit"})]})]})}function hP({data:i,updatedAt:e}){const t=i.usage,n=dP(i.subscriptionType),r=t.extra_usage,l=e!=null?`${Math.max(0,Math.round((Date.now()-e)/1e3))}s ago`:null;return c.jsxs("section",{className:"bg-bg-hi border border-line rounded-2xl px-6 py-1.5",children:[(n||i.rateLimitTier||l)&&c.jsxs("div",{className:"flex items-baseline justify-between pt-3 pb-1 mb-1",children:[c.jsxs("div",{className:"flex items-baseline gap-2",children:[n&&c.jsx("span",{className:"text-xs text-fg-dim font-mono",children:n}),i.rateLimitTier&&c.jsx("span",{className:"text-[10px] text-fg-faint font-mono",children:i.rateLimitTier})]}),l&&c.jsxs("span",{className:"text-[10px] text-fg-faint",children:["updated ",l]})]}),c.jsxs("div",{className:"divide-y divide-line",children:[c.jsx(wf,{label:"Session",sub:"5-hour",window:t.five_hour,big:!0}),c.jsx(wf,{label:"Weekly",sub:"all models",window:t.seven_day}),c.jsx(wf,{label:"Weekly",sub:"Opus",window:t.seven_day_opus}),c.jsx(wf,{label:"Weekly",sub:"Sonnet",window:t.seven_day_sonnet}),c.jsx(wf,{label:"Weekly",sub:"OAuth apps",window:t.seven_day_oauth_apps})]}),(r==null?void 0:r.is_enabled)&&c.jsx(uP,{extra:r})]})}function ry({open:i,onClose:e,title:t,sub:n,keyVals:r,tail:l,footer:p,children:a}){const[d,f]=z.useState(!1);if(z.useEffect(()=>{if(!i){f(!1);return}const y=requestAnimationFrame(()=>f(!0));return()=>cancelAnimationFrame(y)},[i]),z.useEffect(()=>{if(!i)return;const y=D=>{D.key==="Escape"&&(D.stopPropagation(),e())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[i,e]),!i)return null;const m=y=>{y.target===y.currentTarget&&e()},g=c.jsxs("div",{className:`fixed inset-0 ${dn.dialog}`,"data-testid":"home-drawer-root",children:[c.jsx("div",{className:`absolute inset-0 bg-black/50 transition-opacity duration-[220ms] ${d?"opacity-100":"opacity-0"}`,onClick:m,"data-testid":"home-drawer-backdrop"}),c.jsxs("aside",{role:"dialog","aria-modal":"true","aria-label":t,className:`absolute top-0 right-0 h-full w-full max-w-[420px] bg-bg-hi border-l border-line shadow-xl flex flex-col transition-transform duration-[220ms] ${d?"translate-x-0":"translate-x-full"}`,style:{transitionTimingFunction:"cubic-bezier(.32,.72,.28,1)"},"data-testid":"home-drawer",children:[c.jsxs("header",{className:"px-5 py-4 border-b border-line flex items-start justify-between gap-3 shrink-0",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("h2",{className:"m-0 font-serif text-[18px] font-semibold text-fg truncate",children:t}),n&&c.jsx("div",{className:"text-[12px] text-fg-faint truncate mt-0.5",children:n})]}),c.jsx("button",{onClick:e,className:"shrink-0 rounded-md border border-line bg-bg px-2.5 py-1 text-[12px] font-semibold text-fg-dim hover:bg-bg-elev","aria-label":"Close",children:"Close"})]}),c.jsxs("div",{className:"flex-1 min-h-0 overflow-auto px-5 py-4 grid gap-4 content-start",children:[a,r.length>0&&c.jsx("dl",{className:"m-0 grid gap-2",style:{gridTemplateColumns:"minmax(0,100px) minmax(0,1fr)"},children:r.map(y=>c.jsxs("div",{className:"contents",children:[c.jsx("dt",{className:"m-0 font-mono text-[11px] uppercase tracking-[0.05em] text-fg-faint",children:y.label}),c.jsx("dd",{className:"m-0 text-[12.5px] text-fg break-words",children:y.value})]},y.label))}),l&&l.length>0&&c.jsxs("div",{children:[c.jsx("div",{className:"font-mono text-[11px] uppercase tracking-[0.08em] text-fg-faint mb-2",children:"Live tail"}),c.jsx("div",{className:"grid gap-2",children:l.map(y=>c.jsxs("div",{className:"bg-bg border border-line rounded-lg px-3 py-2",children:[c.jsx("div",{className:"font-mono text-[10px] uppercase tracking-[0.05em] text-fg-faint mb-1",children:y.role}),c.jsx("div",{className:"text-[12px] text-fg-dim leading-[1.5] whitespace-pre-wrap break-words line-clamp-6",children:y.text})]},y.id))})]})]}),p&&c.jsx("footer",{className:"px-5 py-3.5 border-t border-line flex gap-2 justify-end shrink-0",children:p})]})]});return typeof document<"u"&&document.body?Th.createPortal(g,document.body):g}function pP({open:i,onClose:e,projects:t,onConfirm:n}){const[r,l]=z.useState(null);z.useEffect(()=>{var a;i&&l(((a=t[0])==null?void 0:a.cwd)??null)},[i,t]);const p=t.find(a=>a.cwd===r)??null;return c.jsx(ry,{open:i,onClose:e,title:"New session",sub:"Pick a project to start it in",keyVals:[],footer:c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:e,className:"text-[12px] font-semibold px-[13px] py-[7px] rounded-lg border border-line bg-bg text-fg-dim hover:bg-bg-elev",children:"Cancel"}),c.jsx("button",{onClick:()=>{r&&(n(r),e())},disabled:!r,className:"text-[12px] font-semibold px-[13px] py-[7px] rounded-lg bg-accent text-bg-hi hover:bg-accent-dark disabled:opacity-50",children:p?`Continue in ${p.name} → Epics`:"Continue"})]}),children:t.length===0?c.jsx("div",{className:"text-[13px] text-fg-faint py-2",children:"No known projects yet."}):c.jsx("div",{role:"radiogroup","aria-label":"Project",className:"grid gap-1.5",children:t.map(a=>c.jsxs("label",{className:`flex items-center gap-2.5 px-3 py-2 rounded-lg border cursor-pointer ${r===a.cwd?"border-accent bg-accent/10":"border-line bg-bg hover:bg-bg-elev/60"}`,children:[c.jsx("input",{type:"radio",name:"new-epic-project",value:a.cwd,checked:r===a.cwd,onChange:()=>l(a.cwd),className:"accent-accent"}),c.jsx("span",{className:"min-w-0 flex-1 text-[13px] text-fg truncate",title:a.cwd,children:a.name})]},a.encoded))})})}function fP({job:i,onClose:e,onOpenScheduler:t,onRunNow:n}){const r=z.useRef(null);return z.useEffect(()=>{const l=a=>{r.current&&!r.current.contains(a.target)&&e()},p=a=>{a.key==="Escape"&&e()};return document.addEventListener("mousedown",l),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",p)}},[e]),c.jsxs("div",{ref:r,"data-testid":"queue-job-popover",className:"absolute z-20 top-full left-0 mt-1.5 w-[226px] bg-bg-hi border border-line rounded-[11px] shadow-xl px-3.5 py-3",children:[c.jsx("div",{className:"font-mono text-[12px] font-semibold text-fg truncate mb-1.5",children:i.title||i.slug}),c.jsxs("dl",{className:"m-0 grid gap-1 mb-3",style:{gridTemplateColumns:"minmax(0,60px) minmax(0,1fr)"},children:[c.jsx("dt",{className:"m-0 font-mono text-[10px] uppercase tracking-[0.05em] text-fg-faint",children:"Slug"}),c.jsx("dd",{className:"m-0 font-mono text-[11px] text-fg-dim truncate",children:i.slug}),c.jsx("dt",{className:"m-0 font-mono text-[10px] uppercase tracking-[0.05em] text-fg-faint",children:"Project"}),c.jsx("dd",{className:"m-0 font-mono text-[11px] text-fg-dim truncate",children:i.cwd?mP(i.cwd):"—"}),i.estimateMinutes!=null&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{className:"m-0 font-mono text-[10px] uppercase tracking-[0.05em] text-fg-faint",children:"Est."}),c.jsxs("dd",{className:"m-0 font-mono text-[11px] text-fg-dim",children:["~",i.estimateMinutes,"m"]})]}),c.jsx("dt",{className:"m-0 font-mono text-[10px] uppercase tracking-[0.05em] text-fg-faint",children:"Status"}),c.jsx("dd",{className:"m-0 font-mono text-[11px] text-fg-dim",children:i.status})]}),c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsx("button",{onClick:t,className:"text-[11.5px] font-semibold px-2.5 py-[5px] rounded-md border border-line bg-bg text-fg-dim hover:bg-bg-elev text-left",children:"Open in Scheduler →"}),n&&c.jsx("button",{onClick:n,title:"Wakes the scheduler to check for due jobs immediately — does not force this specific job to run out of turn or bypass the concurrency cap.",className:"text-[11.5px] font-semibold px-2.5 py-[5px] rounded-md bg-accent text-bg-hi hover:bg-accent-dark text-left",children:"Nudge scheduler now"})]})]})}function mP(i){const e=i.split("/").filter(Boolean);return e.length>0?e[e.length-1]:i}const iw="sm:terminal:settings",nw=10,sw=22,bk=13,Fo={theme:"dark",fontSize:bk};async function wk(){try{const e=(await Eh()).terminal;return e?{theme:e.theme==="light"||e.theme==="paper"||e.theme==="dark"?e.theme:Fo.theme,fontSize:typeof e.fontSize=="number"&&e.fontSize>=nw&&e.fontSize<=sw?e.fontSize:Fo.fontSize}:Fo}catch{return Fo}}async function gP(i){try{await um({terminal:i})}catch{Qe.error("Couldn't save terminal appearance — it won't persist after restart.")}window.dispatchEvent(new CustomEvent(iw,{detail:i}))}function A0(i,e,t){i.options.theme=lc[e.theme],i.options.fontSize=e.fontSize,t==null||t()}function oy(i,e){let t=!1,n=!1;const r=vP(l=>{n=!0,A0(i,l,e)});return wk().then(l=>{!t&&!n&&A0(i,l,e)}),()=>{t=!0,r()}}function vP(i){const e=t=>{i(t.detail)};return window.addEventListener(iw,e),()=>window.removeEventListener(iw,e)}const lc={dark:{background:"#0b0d10",foreground:"#e6e8ec",cursor:"#d97757",selectionBackground:"#3a4250",black:"#1a1f27",red:"#e06c75",green:"#98c379",yellow:"#e5c07b",blue:"#61afef",magenta:"#c678dd",cyan:"#56b6c2",white:"#e6e8ec",brightBlack:"#545c68",brightRed:"#e06c75",brightGreen:"#98c379",brightYellow:"#e5c07b",brightBlue:"#61afef",brightMagenta:"#c678dd",brightCyan:"#56b6c2",brightWhite:"#ffffff"},light:{background:"#ffffff",foreground:"#1f2328",cursor:"#0969da",selectionBackground:"#cce5ff",black:"#24292f",red:"#cf222e",green:"#116329",yellow:"#a45a16",blue:"#0969da",magenta:"#8250df",cyan:"#1b7c83",white:"#6e7781",brightBlack:"#57606a",brightRed:"#a40e26",brightGreen:"#1a7f37",brightYellow:"#9a6700",brightBlue:"#218bff",brightMagenta:"#a475f9",brightCyan:"#3192aa",brightWhite:"#1f2328"},paper:{background:"#f6efe1",foreground:"#2a221a",cursor:"#a7532f",selectionBackground:"#e0d3b8",black:"#2a221a",red:"#b8443c",green:"#5c6f3a",yellow:"#8e641a",blue:"#3a6ea5",magenta:"#8a4a8c",cyan:"#38767e",white:"#5b4a36",brightBlack:"#796b54",brightRed:"#b8493f",brightGreen:"#65714a",brightYellow:"#8c641e",brightBlue:"#416ea1",brightMagenta:"#925494",brightCyan:"#3e757d",brightWhite:"#2a221a"}},_P=["dark","light","paper"];function bP(){const[i,e]=z.useState(Fo),[t,n]=z.useState(!1);z.useEffect(()=>{let p=!1;return wk().then(a=>{p||(e(a),n(!0))}),()=>{p=!0}},[]);const r=p=>{t&&e(a=>{const d={...a,...p};return gP(d),d})},l=p=>{r({fontSize:Math.min(sw,Math.max(nw,i.fontSize+p))})};return c.jsxs("section",{className:"mb-6","data-testid":"home-terminal-appearance",children:[c.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[c.jsx("h2",{className:"m-0 font-serif text-[22px] font-medium",children:"Terminal appearance"}),c.jsx("span",{className:"font-mono text-[12px] text-fg-faint",children:"every terminal, this machine"})]}),c.jsxs("div",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[c.jsxs("p",{className:"mt-0 mb-4 text-[13px] text-fg-dim leading-relaxed",children:["Applies to ",c.jsx("strong",{className:"text-fg",children:"every terminal in the app at once"})," — project Terminal tabs, an Epic’s Terminal view of its session, and the inline permission prompt. It is not per project, per session, or per tab. It does not restyle the app chrome (there is no app theme switch), and the code editor keeps its own separate paper/dark setting in the Editor tab’s Display menu. Stored in"," ",c.jsx("code",{className:"font-mono text-[12px]",children:"~/.claude/session-manager/ui-settings-prefs.json"}),", applied live without restarting a session."]}),c.jsxs("div",{className:"grid gap-5",style:{gridTemplateColumns:"minmax(0,1fr) 220px"},children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-[10px] uppercase tracking-wider text-fg-faint mb-1.5",children:"Theme"}),c.jsx("div",{className:"grid grid-cols-3 gap-2",children:_P.map(p=>c.jsxs("button",{type:"button",onClick:()=>r({theme:p}),disabled:!t,"aria-pressed":i.theme===p,"data-testid":`terminal-theme-${p}`,className:`px-2 py-2 rounded-lg text-[11px] font-medium border transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${i.theme===p?"bg-bg border-accent text-fg":"bg-bg border-line text-fg-dim hover:text-fg hover:border-fg-faint"}`,children:[c.jsx(wP,{theme:p}),c.jsx("div",{className:"mt-1.5 capitalize",children:p})]},p))})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[c.jsx("span",{className:"text-[10px] uppercase tracking-wider text-fg-faint",children:"Font size"}),c.jsxs("span",{className:"font-mono text-[11px] text-fg-dim",children:[i.fontSize,"px"]})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("button",{type:"button",onClick:()=>l(-1),disabled:!t||i.fontSize<=nw,"aria-label":"Decrease font size",className:"flex-1 py-1.5 rounded border border-line bg-bg text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed",children:"−"}),c.jsx("button",{type:"button",onClick:()=>r({fontSize:bk}),disabled:!t,className:"flex-1 py-1.5 rounded border border-line bg-bg text-[11px] text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed",children:"reset"}),c.jsx("button",{type:"button",onClick:()=>l(1),disabled:!t||i.fontSize>=sw,"aria-label":"Increase font size",className:"flex-1 py-1.5 rounded border border-line bg-bg text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed",children:"+"})]}),c.jsxs("div",{className:"mt-3 rounded border border-line px-3 py-2 font-mono",style:{background:lc[i.theme].background,color:lc[i.theme].foreground,fontSize:`${i.fontSize}px`,lineHeight:1.35},"aria-hidden":!0,children:[c.jsx("span",{style:{color:lc[i.theme].green},children:"$"})," claude"]})]})]})]})]})}function wP({theme:i}){const e=lc[i];return c.jsxs("div",{"aria-hidden":!0,className:"w-full h-5 rounded border relative overflow-hidden",style:{background:e.background,borderColor:"rgba(0,0,0,0.15)"},children:[c.jsx("div",{style:{position:"absolute",top:3,left:4,width:"40%",height:2,background:e.foreground}}),c.jsx("div",{style:{position:"absolute",top:9,left:4,width:"25%",height:2,background:e.green??e.foreground}}),c.jsx("div",{style:{position:"absolute",top:15,left:4,width:"55%",height:2,background:e.cyan??e.foreground}})]})}const I0="The MCP tool catalog is unavailable.";function yP(){const[i,e]=z.useState({tools:[],loaded:!1,error:null});return z.useEffect(()=>{let t=!1;return Promise.resolve().then(()=>window.api.mcp.catalog()).then(n=>{var r;t||(!(n!=null&&n.ok)||!((r=n.tools)!=null&&r.length)?e({tools:[],loaded:!0,error:I0}):e({tools:n.tools,loaded:!0,error:null}))}).catch(()=>{t||e({tools:[],loaded:!0,error:I0})}),()=>{t=!0}},[]),i}const xP=["scheduler","chat","feedback","help"],SP={scheduler:"Scheduler",chat:"Chat",feedback:"Feedback",help:"Help"};function CP(){const{tools:i,loaded:e,error:t}=yP(),[n,r]=z.useState(!1);if(!e)return null;if(t||i.length===0)return c.jsxs("section",{className:"mb-6","data-testid":"home-agent-tools",children:[c.jsx("h2",{className:"m-0 mb-2 font-serif text-[22px] font-medium",children:"Agent tools"}),c.jsx("p",{className:"m-0 text-xs text-fg-faint","data-testid":"home-agent-tools-error",children:"The MCP tool catalog is unavailable."})]});const l=xP.map(p=>({group:p,tools:i.filter(a=>a.group===p)})).filter(p=>p.tools.length>0);return c.jsxs("section",{className:"mb-6","data-testid":"home-agent-tools",children:[c.jsxs("button",{type:"button",onClick:()=>r(p=>!p),"aria-expanded":n,"data-testid":"home-agent-tools-toggle",className:"flex w-full items-baseline gap-2 text-left",children:[c.jsx("span",{className:"font-serif text-[22px] font-medium",children:"Agent tools"}),c.jsxs("span",{className:"font-mono text-[12px] text-fg-faint",children:["· ",i.length," MCP tools ",n?"▾":"▸"]})]}),n&&c.jsx("div",{className:"mt-3 grid gap-3 border border-line rounded-xl bg-bg-hi px-5 py-4",children:l.map(({group:p,tools:a})=>c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"mb-1 font-mono text-[10px] font-semibold uppercase tracking-wide text-fg-faint",children:SP[p]}),a.map(d=>c.jsxs("div",{"data-testid":`home-agent-tool-${d.name}`,className:"flex items-baseline gap-3 min-w-0 py-0.5",children:[c.jsx("span",{className:"shrink-0 font-mono text-[12px] font-semibold text-fg",children:d.name}),c.jsx("span",{"data-testid":"home-agent-tool-purpose",title:d.purpose,className:"min-w-0 line-clamp-1 text-xs text-fg-dim",children:d.purpose})]},d.name))]},p))})]})}function kP(i){i<0&&(i=0);const e=Math.floor(i/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60);return t<60?`${t}m${(e%60).toString().padStart(2,"0")}s`:`${Math.floor(t/60)}h${(t%60).toString().padStart(2,"0")}m`}function EP(i){i<0&&(i=0);const e=Math.floor(i/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60);if(t<60)return`${t}m`;const n=Math.floor(t/60);return n<24?`${n}h${t%60?` ${t%60}m`:""}`:`${Math.floor(n/24)}d`}function sB(i){return new Date(i).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZoneName:"short"})}function tr(i,e){if(i===null)return"never";const t=e-i;return t<0?"soon":t<5e3?"just now":`${EP(t)} ago`}function rB(i){if(!i)return"";const e=Math.max(0,Date.now()-i);return e<6e4?`saved ${Math.round(e/1e3)}s ago`:e<36e5?`saved ${Math.round(e/6e4)}m ago`:`saved ${Math.round(e/36e5)}h ago`}function TP(i){i<0&&(i=0);const e=Math.floor(i/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60);if(t<60)return`${t}m`;const n=Math.floor(t/60),r=t%60;return r>0?`${n}h ${r}m`:`${n}h`}function DP({since:i,error:e,onRetry:t}){return c.jsxs("div",{className:"flex items-center justify-between mb-3 border border-yellow-800/40 rounded px-3 py-1.5 bg-yellow-950/20 text-xs text-yellow-300",children:[c.jsxs("span",{children:["stale · last updated ",tr(i,Date.now())]}),c.jsx("button",{onClick:t,className:"ml-3 underline hover:no-underline",children:"Retry"})]})}function $P({message:i,expiredAt:e,onRetry:t}){const n=e!=null&&e<Date.now(),r=e?new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}):null,l=!n&&/^HTTP \d+/.test(i);return c.jsxs("div",{className:"mb-3 border border-red-800/40 rounded px-3 py-2 bg-red-950/20 text-xs text-red-300",children:[c.jsxs("div",{className:"font-medium mb-1",children:[n?`Credentials expired at ${r}`:"Authentication failed",l&&c.jsxs("span",{className:"font-normal ml-1 text-red-400/70",children:["(",i,")"]})]}),c.jsxs("div",{className:"text-red-400/80",children:["Run ",c.jsx("code",{className:"font-mono bg-red-950/40 px-1 rounded",children:"claude"})," in a terminal to refresh, then"," ",c.jsx("button",{onClick:t,className:"underline hover:no-underline",children:"Retry"}),"."]})]})}function AP(){return c.jsx("div",{className:"border border-yellow-800/40 rounded px-3 py-1.5 bg-yellow-950/20 text-xs text-yellow-300",children:"temporary network error — retrying in 5s"})}function IP({onRetry:i}){return c.jsxs("div",{className:"flex items-center justify-between border border-yellow-800/40 rounded px-3 py-1.5 bg-yellow-950/20 text-xs text-yellow-300",children:[c.jsx("span",{children:"usage meter is rate-limited — showing last known values"}),c.jsx("button",{onClick:i,className:"ml-3 underline hover:no-underline",children:"Retry"})]})}function PP({message:i}){const e=i.includes("not found")||i.includes("ENOENT");return c.jsxs("div",{className:"border border-line rounded px-3 py-2 bg-bg-elev text-xs text-fg-dim",children:[c.jsx("div",{className:"font-medium mb-1 text-fg",children:e?"Not signed in":"Cannot read credentials"}),c.jsx("div",{className:"text-fg-faint",children:e?c.jsxs(c.Fragment,{children:["Run ",c.jsx("code",{className:"font-mono bg-bg px-1 rounded",children:"claude login"})," in a terminal tab to sign in."]}):c.jsxs(c.Fragment,{children:["Cannot read ",c.jsx("code",{className:"font-mono bg-bg px-1 rounded",children:"~/.claude/.credentials.json"})," — ",i]})})]})}function jP({result:i,onRetry:e}){switch(i.kind){case"ok":return null;case"ok-stale":return c.jsx(DP,{since:i.staleSince,error:i.lastError,onRetry:e});case"auth":return c.jsx($P,{message:i.message,expiredAt:i.expiredAt,onRetry:e});case"transient":return c.jsx(AP,{});case"meter_rate_limited":return c.jsx(IP,{onRetry:e});case"config":return c.jsx(PP,{message:i.message})}}function yf(i){return{path:i,diskRaw:"",draftRaw:"",diskData:null,exists:!1,parseError:null,loadError:null,mtimeMs:0,baseMtimeMs:0,dirty:!1,busy:!1,lastSavedAt:null}}function B_(i,e,t){const n={...i,diskRaw:e.raw,diskData:e.data,exists:e.exists,parseError:e.parseError,loadError:e.error,mtimeMs:e.mtimeMs,busy:!1};return!t||!i.dirty?(n.draftRaw=e.raw,n.dirty=!1,n.baseMtimeMs=e.mtimeMs):n.dirty=n.draftRaw!==n.diskRaw,n}function G_(i,e,t){const n={...i,diskRaw:e.text,diskData:null,exists:e.exists,parseError:null,loadError:e.error,mtimeMs:e.mtimeMs,busy:!1};return!t||!i.dirty?(n.draftRaw=e.text,n.dirty=!1,n.baseMtimeMs=e.mtimeMs):n.dirty=n.draftRaw!==n.diskRaw,n}function P0(i){return`${i} changed on disk since you opened it. Reload to merge, or save again to overwrite.`}const Mf=jn((i,e)=>({files:{},watchRefs:{},loadJson:async t=>{const n=e().files[t];i({files:{...e().files,[t]:{...n??yf(t),busy:!0}}});const r=await window.api.config.readJson(t),l=e().files[t]??yf(t);i({files:{...e().files,[t]:B_(l,r,!1)}})},loadText:async(t,n=!1)=>{const r=e().files[t];i({files:{...e().files,[t]:{...r??yf(t),busy:!0}}});const l=await window.api.config.readText(t),p=e().files[t]??yf(t);i({files:{...e().files,[t]:G_(p,l,n)}})},setDraft:(t,n)=>{const r=e().files[t]??yf(t),l=n!==r.diskRaw;i({files:{...e().files,[t]:{...r,draftRaw:n,dirty:l}}})},revert:t=>{const n=e().files[t];n&&i({files:{...e().files,[t]:{...n,draftRaw:n.diskRaw,dirty:!1}}})},saveJson:async(t,n)=>{const r=e().files[t];if(!r)return{ok:!1,error:"not loaded"};let l;try{l=r.draftRaw.trim()===""?{}:JSON.parse(r.draftRaw)}catch(f){return{ok:!1,error:`invalid JSON: ${f.message}`}}if(!(n!=null&&n.force)){const f=await window.api.config.readJson(t);if(f.exists&&f.mtimeMs>(r.baseMtimeMs??0))return Qe.error(P0(t)),{ok:!1,error:"conflict"}}i({files:{...e().files,[t]:{...r,busy:!0}}});const p=await window.api.config.writeJson(t,l);if(!p.ok)return i({files:{...e().files,[t]:{...r,busy:!1}}}),{ok:!1,error:p.error};const a=await window.api.config.readJson(t),d=B_({...r,busy:!1},a,!1);return i({files:{...e().files,[t]:{...d,lastSavedAt:Date.now()}}}),{ok:!0}},saveText:async(t,n)=>{const r=e().files[t];if(!r)return{ok:!1,error:"not loaded"};if(!(n!=null&&n.force)){const d=await window.api.config.readText(t);if(d.exists&&d.mtimeMs>(r.baseMtimeMs??0))return Qe.error(P0(t)),{ok:!1,error:"conflict"}}i({files:{...e().files,[t]:{...r,busy:!0}}});const l=await window.api.config.writeText(t,r.draftRaw);if(!l.ok)return i({files:{...e().files,[t]:{...r,busy:!1}}}),{ok:!1,error:l.error};const p=await window.api.config.readText(t),a=G_({...r,busy:!1},p,!1);return i({files:{...e().files,[t]:{...a,lastSavedAt:Date.now()}}}),{ok:!0}},watchFile:t=>{const n={...e().watchRefs};n[t]=(n[t]??0)+1,i({watchRefs:n}),n[t]===1&&window.api.config.watch([t])},unwatchFile:t=>{const n={...e().watchRefs};n[t]&&(n[t]--,n[t]<=0&&(delete n[t],window.api.config.unwatch([t])),i({watchRefs:n}))},onExternalChange:t=>{e().files[t]&&(t.endsWith(".json")?window.api.config.readJson(t).then(r=>{const l=e().files[t];l&&i({files:{...e().files,[t]:B_(l,r,!0)}})}):window.api.config.readText(t).then(r=>{const l=e().files[t];l&&i({files:{...e().files,[t]:G_(l,r,!0)}})}))}}));function RP(){return window.api.config.onChanged(({path:i})=>{Mf.getState().onExternalChange(i)})}function Ch(...i){return i.filter(Boolean).map((e,t)=>t===0?e.replace(/\/+$/,""):e.replace(/^\/+|\/+$/g,"")).join("/")}const om={scopes:["user","project","local"],resolve:(i,e,t)=>i==="user"?Ch(e,".claude","settings.json"):t?i==="project"?Ch(t,".claude","settings.json"):Ch(t,".claude","settings.local.json"):null},F_={scopes:["user","project","local"],resolve:(i,e,t)=>i==="user"?Ch(e,".claude","CLAUDE.md"):t?i==="project"?Ch(t,"CLAUDE.md"):Ch(t,"CLAUDE.local.md"):null},oB=om,aB={user:{label:"User",hint:"~/.claude/ — applies to all projects"},project:{label:"Project",hint:"<cwd>/.claude/ — checked into git"},local:{label:"Local",hint:"<cwd>/.claude/…local — gitignored, per-machine"}},NP=[];function Ug(i){return Array.isArray(i)?"array":i!==null&&typeof i=="object"?"object":"scalar"}function MP(i){const e=i.filter(t=>t.data!==void 0);return e.length===0?{kind:"object",children:{}}:yk(e,[])}function yk(i,e){const t=NP.includes(e.join(".")),n=i.every(m=>Ug(m.data)==="object"),r=i.every(m=>Ug(m.data)==="array");if(n){const m=new Set;for(const y of i)for(const D of Object.keys(y.data))m.add(D);const g={};for(const y of m){const D=i.filter(E=>y in E.data).map(E=>({scope:E.scope,data:E.data[y]}));g[y]=yk(D,[...e,y])}return{kind:"object",children:g}}if(r&&!t){const m=[];for(const g of[...i].reverse())for(const y of g.data)m.push({value:y,fromScope:g.scope,index:m.length});return{kind:"array",items:m}}const l=[...i].reverse(),p=l[0],a=l.slice(1).map(m=>({scope:m.scope,value:m.data})),d=Ug(p.data),f=a.some(m=>Ug(m.value)!==d);return{kind:"leaf",value:p.data,winner:p.scope,shadowed:a,...f?{typeMismatch:!0}:{}}}function xk(i,e){if(e.length===0)return i;if(i.kind!=="object")return null;const[t,...n]=e,r=i.children[t];return r?xk(r,n):null}function OP(i,e,t){if(e.length===0)return t;const[n,...r]=e,l=i&&typeof i=="object"&&!Array.isArray(i)?{...i}:{};return l[n]=OP(l[n],r,t),l}const LP=["user","project","local"];function zP(i,e){const t=[];for(const n of LP){const r=e[n];if(!r)continue;const l=i[r];if(!l||!l.exists)continue;const p=l.draftRaw??"";if(p.trim())try{t.push({scope:n,data:JSON.parse(p)})}catch{}}return t}const BP=3e4;function Sk(i){const e=e_(),t=z.useMemo(()=>{if(!e)return{};const a={};for(const d of om.scopes){const f=om.resolve(d,e,i);f&&(a[d]=f)}return a},[e,i]),n=Mf(a=>a.files),r=Mf(a=>a.loadJson),l=Mf(a=>a.watchFile),p=Mf(a=>a.unwatchFile);return z.useEffect(()=>{const a=Object.values(t).filter(Boolean);a.forEach(f=>{n[f]||r(f),l(f)});const d=window.setInterval(()=>{a.forEach(f=>r(f))},BP);return()=>{clearInterval(d),a.forEach(f=>p(f))}},[JSON.stringify(t)]),z.useMemo(()=>MP(zP(n,t)),[n,t])}function Ck(i,e){const t=xk(i,e);return!t||t.kind!=="leaf"?{value:null,source:null}:{value:typeof t.value=="string"?t.value:null,source:t.winner}}function kk(i,e){return!i||!e?"effort — (model default)":e==="epic"?`effort ${i} (this session)`:e==="persona"?`effort ${i} (persona)`:e==="persona-overlay"?`effort ${i} (project persona)`:`effort ${i} (${e} settings.json)`}function GP(i){return i==="epic"?"Effort was chosen for this session only and is passed to the CLI as --effort, overriding the agent persona and settings.json.":i==="persona"||i==="persona-overlay"?"Effort comes from the agent persona and is passed to the CLI as --effort, overriding settings.json.":i?"The persona sets no effort, so the settings.json effortLevel applies.":"No effort is set by the persona or settings.json, so the model default applies."}function FP(i,e,t={}){const n=t.model&&t.model!=="inherit"?t.model:null,r=t.effort&&t.effort!=="inherit"&&t.effort!=="auto"?t.effort:null;if(r)return{...i,epicModel:n,effortLevel:r,effortSource:"epic"};if(i.personaEffort&&(i.personaEffortSource==="persona"||i.personaEffortSource==="persona-overlay"))return{...i,epicModel:n,effortLevel:i.personaEffort,effortSource:i.personaEffortSource};const{value:l,source:p}=Ck(e,["effortLevel"]);return{...i,epicModel:n,effortLevel:l,effortSource:p}}function Ek(i,e,t){const n=Sk(i),[r,l]=z.useState(null);return z.useEffect(()=>{if(!i||!e){l(null);return}let p=!1;return l(null),window.api.agents.resolveModelInfo({cwd:i,agentType:e}).then(a=>{p||l(a)},()=>{p||l(null)}),()=>{p=!0}},[i,e]),!i||!e||!r?null:FP(r,n,t)}const Tk=[{id:"project",label:"Project & Tab",realm:"machine",blurb:"A PROJECT is a cwd; a TAB is one open project.",tone:{chip:"bg-bg-elev text-fg-dim",border:"border-line",dot:"bg-fg-faint"}},{id:"epic",label:"Epic (PromptSession)",realm:"project",blurb:"The central aggregate root — one unit of work, one claude session.",tone:{chip:"bg-accent-muted text-accent-dark",border:"border-accent",dot:"bg-accent"}},{id:"scheduler",label:"Scheduler",realm:"project",blurb:"PRDs + the headless jobs that execute them.",tone:{chip:"bg-butter/30 text-honey-dark",border:"border-honey",dot:"bg-honey"}},{id:"agents",label:"Agents & Taxonomy",realm:"machine",blurb:"The ACTOR and MISSION halves of AIM.",tone:{chip:"bg-sage/20 text-sage-dark",border:"border-sage",dot:"bg-sage"}},{id:"memory",label:"Memory",realm:"machine",blurb:"Workspace, cross-project, and per-agent memory.",tone:{chip:"bg-hive-teal/20 text-hive-teal",border:"border-hive-teal",dot:"bg-hive-teal"}},{id:"transcript",label:"Transcript & Usage",realm:"machine",blurb:"The Claude CLI's own JSONL, classified events, and billing.",tone:{chip:"bg-bg-hi text-fg-dim",border:"border-rule",dot:"bg-fg-dim"}},{id:"brief",label:"Project Home & Publishing",realm:"project",blurb:"The synthesized Brief, generated pages, and bilko.run publish state.",tone:{chip:"bg-accent-muted/60 text-accent-dark",border:"border-accent-muted",dot:"bg-accent-muted"}},{id:"config",label:"Machine Config",realm:"machine",blurb:"Settings, layout, and the single-writer ownership map.",tone:{chip:"bg-line text-fg-faint",border:"border-rule",dot:"bg-fg-faint"}}];function lB(i){const e=Tk.find(t=>t.id===i);if(!e)throw new Error(`unknown ErdGroupId: ${i}`);return e}const ay=[{id:"project",name:"Project",aka:"cwd — Main Project",group:"project",store:{path:"identity only, no record of its own — folded at read time from ~/.claude/projects/<encoded>",format:"in-memory",definedIn:"src/renderer/lib/knownProjectAggregate.ts (aggregateProjectsByCwd) "},summary:"A folder whose cwd never resolved from transcript content is DROPPED, never guessed — the naive decode once reported 2044 phantom projects.",fields:[{name:"cwd",type:"string",key:"pk",note:"resolved working directory — the project's identity"},{name:"name",type:"string",note:"display name: the cwd's last path segment"},{name:"encoded",type:"string",note:"representative transcript folder (most recently active)"},{name:"encodedIds",type:"string[]",note:"every ~/.claude/projects/<encoded> folder that resolved to this cwd"},{name:"sessionCount",type:"number"},{name:"sizeBytes",type:"number"},{name:"lastSession",type:"number"}]},{id:"tab",name:"PersistedTab",aka:"TAB",group:"project",store:{path:"~/.claude/session-manager/tabs.json",format:"json",definedIn:"src/main/sessionsStore.cjs "},summary:"One TAB per project — extra sessions within a project are Epics, not tabs.",fields:[{name:"id",type:"string",key:"pk"},{name:"sessionId",type:"string"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"label",type:"string"},{name:"presetId",type:"string | null"}]},{id:"epic",name:"PromptSession",aka:"EPIC",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/active-index.json -> sessions[id]",format:"json",writer:"epics",definedIn:"src/main/lib/epic/epicMint.cjs (ensureEpic) + src/renderer/state/promptSessions.ts "},summary:"The central aggregate root — created in exactly ONE place, a human pressing New Epic.",fields:[{name:"id",type:"string",key:"pk"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"goalText",type:"string",note:"the original top-level prompt text that started this goal"},{name:"claudeSessionId",type:"string",note:"independently minted — never shared with any tab.sessionId"},{name:"status",type:"'proposed' | 'active' | 'completed'"},{name:"createdAt",type:"string"},{name:"completedAt",type:"string | null"},{name:"resumedFromId",type:"string",optional:!0,key:"fk",ref:"epic.id"},{name:"tag",type:"TicketTag",optional:!0,key:"fk",ref:"tag.tag"},{name:"openingPrompt",type:"string | null",optional:!0},{name:"source",type:"EpicSource",optional:!0,note:"{ producer, prdSlug?, runId?, sourceTabId?, fromCwd?, fromEpicId? }"},{name:"agentType",type:"string",optional:!0,key:"fk",ref:"agentPersona.name"},{name:"sections",type:"EpicIntakeSection[]",optional:!0},{name:"worktree",type:"{ dir, branch, baseCwd, status, conflictReason? }",optional:!0,note:"own git worktree on branch 'sm-epic/<id>' when Active"}],notes:["SINGLE-CREATOR LAW, fail-closed in epicMint.cjs — the New Epic IPC handler and crossProjectFeedback.cjs are the only mint authorities.","Every Epic is born proposed; nothing is created directly as active.","EPIC : claude-session is 1:1 — Chat and Terminal are two VIEWS over one session.","Title + objective are fixed for the life of the session — iterate in follow-up messages, don't repurpose."]},{id:"epicEvent",name:"PromptSessionEvent",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/active-index.json -> events[]",format:"json",writer:"epics",definedIn:"src/renderer/state/promptSessions.ts + src/main/lib/epic/activeIndexMerge.cjs "},summary:"One step in an Epic's Prompt → PRD → Response → ... → Closed chain.",fields:[{name:"id",type:"string",key:"pk"},{name:"promptSessionId",type:"string",key:"fk",ref:"epic.id"},{name:"kind",type:"'prompt' | 'prd_created' | 'response' | 'closed'"},{name:"causedByEventId",type:"string | null",key:"fk",ref:"epicEvent.id",note:"must be the session's current tail event — a chain, not a tree"},{name:"at",type:"string"},{name:"prdSlug",type:"string",optional:!0,key:"fk",ref:"prd.slug"},{name:"text",type:"string",optional:!0},{name:"outcome",type:"'completed' | 'failed' | 'needs_review'",optional:!0},{name:"validation",type:"'unvalidated' | 'validating' | 'verified' | 'refuted'",optional:!0}]},{id:"epicTranscriptTurn",name:"PromptSessionTranscriptTurn",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/transcripts/<epicId>.jsonl",format:"jsonl",writer:"epics",definedIn:"src/main/promptSessionTranscript.cjs "},summary:"The durable per-Epic transcript store, kept alongside the CLI's own JSONL as a fallback source of turns.",fields:[{name:"v",type:"1"},{name:"epicId",type:"string",key:"fk",ref:"epic.id"},{name:"eventId",type:"string | null",key:"fk",ref:"epicEvent.id"},{name:"role",type:"'user' | 'assistant'"},{name:"at",type:"string"},{name:"text",type:"string"}]},{id:"epicArchive",name:"PromptSessionArchive",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/<epicId>.json",format:"json",writer:"epics",definedIn:"src/renderer/state/promptSessions.ts (promptSessionArchivePath) "},summary:"On-disk archive written once at completion — freezes the Epic, its events, and its transcript.",fields:[{name:"session",type:"PromptSession"},{name:"events",type:"PromptSessionEvent[]"},{name:"transcript",type:"string"},{name:"archivedAt",type:"string"},{name:"durableTurns",type:"Array<{ role, text, at }>",optional:!0}]},{id:"epicWorktreeConfig",name:"EpicWorktreeConfig",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/epic-worktree-config.json",format:"json",writer:"epics",definedIn:"src/main/lib/epic/epicWorktreeProjectConfig.cjs "},summary:"Per-project 'disable Epic worktree isolation' toggle, read by gitWorktree.cjs's isWorktreeDisabled('epic', cwd) on every worktree creation attempt.",fields:[{name:"disabled",type:"boolean"}],notes:["One-shot migration from the legacy machine-wide ~/.claude/session-manager/epic-worktree-project-config.json map, keyed by project cwd — that file is left in place, never deleted."]},{id:"exchange",name:"Exchange",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/exchanges.jsonl",format:"jsonl",writer:"epics",definedIn:"src/main/exchanges.cjs "},summary:"One durable NDJSON record per completed terminal-chat exchange, appended off the hot path.",fields:[{name:"ts",type:"string"},{name:"sessionId",type:"string",key:"fk",ref:"epic.claudeSessionId",note:"the tab's claude session id"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"prompt",type:"string"},{name:"result",type:"string"},{name:"summary",type:"string",note:"produced by the shared Haiku summarizer"},{name:"model",type:"string"},{name:"degraded",type:"string",optional:!0,note:"set when summarization failed — the exchange itself is never dropped"},{name:"promptId",type:"string",optional:!0,key:"fk",ref:"prd.slug",note:"originating PromptTicket.id when dispatched from the per-tab queue; forward-only, never backfilled"}],notes:["Written via raw fs O_APPEND (not config.cjs writeJson) for atomicity across concurrent writers — assertOpsWrite is called explicitly since raw fs bypasses the normal enforcement point.","Historical rows from before this store existed remain, untouched and unmigrated, in the old global ~/.claude/knowledge-log/exchanges/<encodeCwd(cwd)>.jsonl."]},{id:"prd",name:"PRD",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/epics/<epicId>/prds/<slug>.md",format:"markdown",writer:"scheduler",definedIn:"src/main/lib/prd/prdLocations.cjs + scheduler_create_prd MCP tool "},summary:"PRD authoring is API-only via the scheduler_create_prd MCP tool — a PRD joins an EXISTING Epic and never conjures one.",fields:[{name:"slug",type:"string",key:"pk",note:"<nn>-<kebab-title>.md filename stem"},{name:"title",type:"string"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"epicId",type:"string | null",key:"fk",ref:"epic.id",note:"derived from the PRD's DIRECTORY — fact on disk"},{name:"sourcePromptId",type:"string",optional:!0,key:"fk",ref:"epic.id",note:"frontmatter intent — can disagree with epicId"},{name:"sourceTabId",type:"string",optional:!0},{name:"estimateMinutes",type:"number"},{name:"tag",type:"'feature' | 'bug' | 'discussion' | 'build' | 'project-home-builder' | 'art' | 'portfolio'",optional:!0,key:"fk",ref:"tag.tag"},{name:"dependsOn",type:"string[]",optional:!0,key:"fk",ref:"prd.slug",note:"the SOLE ordering primitive"},{name:"goal",type:"string"},{name:"acceptanceCriteria",type:"string[]"},{name:"implementationNotes",type:"string"},{name:"outOfScope",type:"string[]",optional:!0},{name:"createdVia",type:"string",optional:!0},{name:"issuedAt",type:"string",optional:!0}],notes:["Flat scheduler/prds/ is RETIRED — auto-consolidated into prds-archived/ on every reconcile() pass.","epicId is derived from the DIRECTORY (fact on disk) while sourcePromptId is frontmatter intent and can disagree."]},{id:"scheduleJob",name:"ScheduleJob",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/queue.json -> jobs[]",format:"json",writer:"scheduler",definedIn:"src/main/lib/scheduler/queueStore.cjs + src/main/lib/scheduler/scheduleJobSchema.cjs "},summary:"dependsOn is the SOLE ordering primitive — parallelGroup is a display hint, never a barrier.",fields:[{name:"slug",type:"string",key:"pk",note:"shared identity with the PRD it executes"},{name:"title",type:"string"},{name:"cwd",type:"string | null",key:"fk",ref:"project.cwd"},{name:"parallelGroup",type:"number"},{name:"estimateMinutes",type:"number | null"},{name:"bodyPreview",type:"string"},{name:"status",type:"'pending' | 'running' | 'investigating' | 'completed' | 'failed' | 'needs_review' | 'quarantined'"},{name:"runId",type:"string | null",key:"fk",ref:"runLog.runId"},{name:"startedAt",type:"string | null"},{name:"finishedAt",type:"string | null"},{name:"exitCode",type:"number | null"},{name:"error",type:"string | null"},{name:"sessionId",type:"string",optional:!0},{name:"runtime",type:"ScheduleJobRuntime",optional:!0,note:"{ pid, runId, startedAt, sessionId?, cwd? }"},{name:"verifierVerdict",type:"string",optional:!0},{name:"dependsOn",type:"string[]",optional:!0,key:"fk",ref:"prd.slug"},{name:"originSessionId",type:"string | null",optional:!0,key:"fk",ref:"epic.id"},{name:"sourceTabId",type:"string | null",optional:!0},{name:"sourcePromptId",type:"string | null",optional:!0,key:"fk",ref:"epic.id"},{name:"epicId",type:"string | null",optional:!0,key:"fk",ref:"epic.id",note:"authoritative — derived from the PRD directory"},{name:"statusHistory",type:"ScheduleJobStatusHistoryEntry[]",optional:!0}],notes:["Every launch must take a slot from lib/scheduler/sessionSlots.cjs — the single machine-wide concurrency limit.","--model is always pinned on every claude -p call site.","A job in needs_review is a QUESTION routed back to the authoring Epic and never creates work on its own."]},{id:"scheduleJobStatusHistory",name:"ScheduleJobStatusHistoryEntry",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/queue.json -> jobs[].statusHistory[]",format:"json",writer:"scheduler",definedIn:"src/main/lib/scheduler/scheduleJobTransitions.cjs "},summary:"Bounded trail (~20 entries) of accepted status transitions for one ScheduleJob.",fields:[{name:"from",type:"string | null"},{name:"to",type:"string"},{name:"reason",type:"string | null"},{name:"source",type:"string | null"},{name:"at",type:"string"}]},{id:"scheduleHistoryEntry",name:"Schedule history entry",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/history.jsonl",format:"jsonl",writer:"scheduler",definedIn:"src/main/lib/scheduler/queueStore.cjs "},summary:"Terminal jobs aged out of queue.json land here, one JSON object per line.",fields:[{name:"slug",type:"string",key:"fk",ref:"prd.slug"},{name:"status",type:"ScheduleJobStatus"},{name:"finishedAt",type:"string | null"},{name:"epicId",type:"string | null",optional:!0,key:"fk",ref:"epic.id"},{name:"runId",type:"string | null",optional:!0,key:"fk",ref:"runLog.runId"}]},{id:"scheduleConfig",name:"ScheduleConfig",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/queue.json -> config",format:"json",writer:"scheduler",definedIn:"src/main/lib/scheduler/schedulerConfig.cjs "},summary:"Per-project auto-fire policy and utilization gate.",fields:[{name:"enabled",type:"boolean",note:"legacy on/off, kept for v0.4 backwards compat"},{name:"offsetMinutes",type:"number"},{name:"defaultCwd",type:"string",key:"fk",ref:"project.cwd"},{name:"firePolicy",type:"'manual' | 'on-reset' | 'when-available'"},{name:"utilizationThreshold",type:"number"},{name:"schemaVersion",type:"1"}]},{id:"runLog",name:"Run log",group:"scheduler",store:{path:"~/.claude/session-manager/scheduled-plans/runs/<runId>/",format:"directory",definedIn:"src/main/scheduler.cjs (RUNS_DIR) "},summary:"One directory per headless claude -p invocation — stdout/stderr/exit capture for a ScheduleJob's run.",fields:[{name:"runId",type:"string",key:"pk"}]},{id:"agentPersona",name:"AgentPersona",aka:"ACTOR — also an ACTION when scoped",group:"agents",store:{path:"~/.claude/agents/<name>.md",format:"markdown",definedIn:"src/main/agentLibrary.cjs + src/main/lib/persona-macro/agentPersonaSchema.cjs "},summary:"One global persona — an ACTION is this same persona given a project scope, not a fourth concept.",fields:[{name:"name",type:"string",key:"pk"},{name:"description",type:"string | null"},{name:"tools",type:"string[]"},{name:"model",type:"string | null",note:"wins over the Settings default for this Epic"},{name:"color",type:"string | null"},{name:"tags",type:"AgentPersonaTag[]",key:"fk",ref:"tag.tag"},{name:"projects",type:"string[]",key:"fk",ref:"project.cwd",note:"'*' means every project"},{name:"action",type:"string | null"},{name:"actionLabel",type:"string | null"},{name:"title",type:"string | null",optional:!0},{name:"path",type:"string"},{name:"body",type:"string"},{name:"overridingProjects",type:"string[]"}]},{id:"tag",name:"Tag",aka:"MISSION — EpicTag",group:"agents",store:{path:"src/renderer/lib/tagLibrary.ts (TAG_LIBRARY)",format:"code",definedIn:"src/renderer/lib/tagLibrary.ts + src/renderer/lib/agentTagDefs.ts "},summary:"The closed 5-taxonomy union — Epic creation is agentType (who) + tag (what), two independent selections.",fields:[{name:"tag",type:"'feature' | 'bug' | 'discussion' | 'build' | 'project-home-builder' | 'art' | 'portfolio'",key:"pk"},{name:"label",type:"string"},{name:"description",type:"string"},{name:"developEagerness",type:"'expected-default' | 'available-not-assumed'"},{name:"developsVia",type:"string"}]},{id:"memoryEntry",name:"MemoryEntry",group:"memory",store:{path:"~/.claude/projects/<encodedCwd>/memory/<name>.md",format:"markdown",definedIn:"src/main/memoryTool.cjs "},summary:"One workspace memory file, semantically organized by topic.",fields:[{name:"name",type:"string",key:"pk"},{name:"path",type:"string"},{name:"mtimeMs",type:"number"},{name:"bytes",type:"number"},{name:"workspace",type:"string",key:"fk",ref:"project.cwd",note:"carried on MemoryListResult, denormalized here — the directory this entry lives under"}]},{id:"memoryCluster",name:"MemoryCluster",group:"memory",store:{path:"<cwd>/session-manager-operations/memory-clusters/clusters.json",format:"json",writer:"memory-clusters",definedIn:"src/main/memoryAggregate.cjs "},summary:"Derived grouping of related MemoryEntry files, computed and cached per workspace.",fields:[{name:"id",type:"string",key:"pk"},{name:"name",type:"string"},{name:"summary",type:"string"},{name:"memberSlugs",type:"string[]",key:"fk",ref:"memoryEntry.name"},{name:"links",type:"MemoryClusterLink[]",note:"{ from, to, label? }"}]},{id:"agentMemoryEntry",name:"AgentMemoryEntry",group:"memory",store:{path:"~/.claude/agent-memory/<agent>/ | .claude/agent-memory/<agent>/ | .claude/agent-memory-local/<agent>/",format:"directory",definedIn:"src/main/lib/memoryDirResolve.cjs (resolveAgentMemoryDir)"},summary:"Per-subagent memory in Claude Code's native agent-memory directories (user, project, local scope), keyed by agent name — markdown files with a MEMORY.md index.",fields:[{name:"agent",type:"string",key:"pk",ref:"agentPersona.name",note:"directory name under the scope root"},{name:"scope",type:"'user' | 'project' | 'local'",note:"selects which agent-memory root resolveAgentMemoryDir returns"},{name:"files",type:"markdown[]",note:"topic files plus MEMORY.md index, read live from disk"}]},{id:"claudeTranscript",name:"Claude transcript",group:"transcript",store:{path:"~/.claude/projects/<encodedCwd>/<sessionUuid>.jsonl",format:"jsonl",definedIn:"written by the Claude Code CLI; tailed by src/main/transcripts.cjs "},summary:"The CLI's own append-only transcript — Session Manager only tails and classifies it, never writes it.",fields:[{name:"sessionUuid",type:"string",key:"pk"},{name:"encodedCwd",type:"string",key:"fk",ref:"project.cwd"}]},{id:"transcriptEvent",name:"TranscriptEvent",group:"transcript",store:{path:"in-memory ring buffer, broadcast as transcript:event:<tabId>",format:"in-memory",definedIn:"src/main/transcripts.cjs -> src/renderer/state/live.ts "},summary:"Classified, bounded-preview view over one raw transcript line — never the source of truth.",fields:[{name:"kind",type:"TranscriptEventKind"},{name:"data",type:"unknown"},{name:"raw",type:"unknown"},{name:"previewText",type:"string"},{name:"ref",type:"TranscriptEventRef | null",note:"{ filePath, byteOffset, byteLength }"},{name:"tabId",type:"string",key:"fk",ref:"tab.id"}]},{id:"historyRollupDay",name:"History rollup day",group:"transcript",store:{path:"~/.claude/session-manager/history-rollup.jsonl",format:"jsonl",definedIn:"src/main/lib/historyRollup.cjs "},summary:"One finalized day-per-project analytics row (History tab is analytics/cost/charts only).",fields:[{name:"date",type:"string",key:"pk"},{name:"projectCwd",type:"string",key:"fk",ref:"project.cwd"},{name:"promptCount",type:"number"},{name:"inputTokens",type:"number"},{name:"outputTokens",type:"number"},{name:"estimatedCostUsd",type:"number"}]},{id:"billingUsage",name:"UsageSnapshot",group:"transcript",store:{path:"~/.claude/session-manager/billing-cache.json",format:"json",definedIn:"src/main/usage.cjs (CACHE_PATH) "},summary:"Cached rolling-window utilization percentages from the account's billing API.",fields:[{name:"five_hour",type:"UsageWindow | null"},{name:"seven_day",type:"UsageWindow | null"},{name:"seven_day_sonnet",type:"UsageWindow | null"},{name:"seven_day_opus",type:"UsageWindow | null"},{name:"seven_day_oauth_apps",type:"UsageWindow | null"},{name:"extra_usage",type:"{ is_enabled, monthly_limit, used_credits, utilization, currency } | null"}]},{id:"projectBrief",name:"ProjectBrief",group:"brief",store:{path:"<cwd>/session-manager-operations/project-brief/brief.json",format:"json",writer:"project-home",definedIn:"src/main/projectBrief.cjs "},summary:"The synthesized project Brief — generated, with a hand-edit escape hatch.",fields:[{name:"version",type:"number"},{name:"synthesizedAt",type:"string"},{name:"editedAt",type:"string | null"},{name:"model",type:"string"},{name:"purpose",type:"string"},{name:"what",type:"string[]"},{name:"areas",type:"ProjectBriefArea[]",note:"{ name, files, note, epic, heat }"},{name:"scope",type:"ProjectBriefScopeEntry[]",note:"{ when, kind, text, src }"},{name:"conventions",type:"string[]"},{name:"pins",type:"{ what: boolean; conventions: boolean }"},{name:"pinned",type:"{ what: string[] | null; conventions: string[] | null }"}]},{id:"projectPages",name:"ProjectPagesOutput",group:"brief",store:{path:"<cwd>/session-manager-operations/project-pages/ (home.html)",format:"directory",writer:"project-home",definedIn:"project_home_write MCP tool (src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs)"},summary:"One self-contained overview page, written only via project_home_write.",fields:[{name:"html",type:"string | null"},{name:"mtimeMs",type:"number | null"}]},{id:"settingsScope",name:"Settings (scoped)",group:"config",store:{path:"~/.claude/settings.json + <cwd>/.claude/settings.json + <cwd>/.claude/settings.local.json",format:"json",definedIn:"src/main/config.cjs + src/renderer/state/config.ts + src/renderer/lib/mergeScopes.ts "},summary:"Substrate, not per-Epic curation — model is the one field carved out per-Epic (persona wins over Settings).",fields:[{name:"scope",type:"'system' | 'project' | 'local'",key:"pk"},{name:"cwd",type:"string",optional:!0,key:"fk",ref:"project.cwd"},{name:"model",type:"string",optional:!0}]},{id:"layoutEnvelope",name:"LayoutEnvelope",group:"config",store:{path:"~/.claude/session-manager/workbench-layout.json",format:"json",definedIn:"src/main/layoutStore.cjs + src/renderer/state/layout.ts "},summary:"Persisted dockview panel layout, pruned against the live panel registry on hydrate.",fields:[{name:"version",type:"number"},{name:"panels",type:"string[]",key:"fk",ref:"tab.id"},{name:"dockview",type:"Record<string, unknown>",note:"opaque SerializedDockview blob"}]},{id:"opsNamespace",name:"Ops namespace ownership",aka:"the SINGLE-WRITER LAW",group:"config",store:{path:"src/main/lib/opsOwnership.cjs (OWNERS)",format:"code",definedIn:"src/main/lib/opsOwnership.cjs (assertOpsWrite) "},summary:"Fail-closed — a new top-level ops folder must land in OWNERS (or the deliberately-unowned list) in the same PR that creates it.",fields:[{name:"namespace",type:"string",key:"pk",note:"e.g. 'prompt-sessions', 'scheduler', 'project-brief'"},{name:"writer",type:"string",note:"e.g. 'epics', 'scheduler', 'project-home'"}]},{id:"mcpServerRegistry",name:"MCP server registry",aka:"mcpServers",group:"config",store:{path:"~/.claude.json -> mcpServers",format:"json",definedIn:"src/renderer/components/tabs/McpServers.tsx "},summary:"User-scope MCP server config — no single writer, since both the claude CLI and this app read/write the same file.",fields:[{name:"name",type:"string",key:"pk"},{name:"type",type:"'stdio' | 'http' | 'sse' | 'ws' | 'streamable-http'",optional:!0},{name:"command",type:"string",optional:!0},{name:"args",type:"string[]",optional:!0},{name:"url",type:"string",optional:!0},{name:"env",type:"Record<string, string>",optional:!0},{name:"headers",type:"Record<string, string>",optional:!0},{name:"alwaysLoad",type:"boolean",optional:!0},{name:"enabled",type:"boolean",optional:!0},{name:"disabledTools",type:"string[]",optional:!0}]},{id:"pluginRegistry",name:"Installed plugins manifest",aka:"installed_plugins.json",group:"config",store:{path:"~/.claude/plugins/installed_plugins.json",format:"json",definedIn:"src/renderer/components/tabs/Plugins.tsx "},summary:'Registry of installed plugin versions, keyed by "<name>@<marketplace>" — written by `claude plugin install`, read-only in the Plugins screen.',fields:[{name:"pluginKey",type:"string",key:"pk",note:"<name>@<marketplace>"},{name:"scope",type:"string"},{name:"installPath",type:"string"},{name:"version",type:"string"},{name:"installedAt",type:"string"},{name:"lastUpdated",type:"string"},{name:"gitCommitSha",type:"string",optional:!0}]},{id:"systemPrompt",name:"User CLAUDE.md",aka:"~/.claude/CLAUDE.md",group:"config",store:{path:"~/.claude/CLAUDE.md",format:"markdown",definedIn:"src/renderer/components/tabs/SystemPrompt.tsx "},summary:"The real ~/.claude/CLAUDE.md the claude CLI loads into every session it starts on this machine, in every project — edited here as plain markdown.",fields:[{name:"content",type:"string"},{name:"imports",type:"string[]",note:"@-imported files, listed in a left rail"}]},{id:"skillsAndCommands",name:"Skills & Commands",group:"config",store:{path:"~/.claude/skills/**/SKILL.md + ~/.claude/commands/*.md (and the <cwd>/.claude equivalents for project scope)",format:"directory",definedIn:"src/renderer/components/tabs/Skills.tsx "},summary:"User- and project-scope skill/command markdown files, each editable in place.",fields:[{name:"kind",type:"'skills' | 'commands'"},{name:"scope",type:"'user' | 'project'"},{name:"name",type:"string",key:"pk"},{name:"path",type:"string",note:"absolute path to the editable markdown file"},{name:"dir",type:"string | null",note:"skill directory, if applicable"},{name:"disabled",type:"boolean",note:"skills only — disable-model-invocation: true frontmatter"},{name:"description",type:"string",optional:!0}]},{id:"mcpStatusProbe",name:"MCP status probe",group:"config",store:{path:"in-memory result of `claude mcp list`, never persisted",format:"in-memory",definedIn:"src/main/mcpStatus.cjs (runProbe) "},summary:"Read-only, non-polling live connection probe — models an in-memory-only shape honestly, the same way transcriptEvent does.",fields:[{name:"ok",type:"boolean"},{name:"servers",type:"McpServerStatus[]",note:"{ name, target, transport, status }"},{name:"error",type:"string",optional:!0},{name:"checkedAt",type:"number"}]},{id:"uiPrefs",name:"UiPrefs",aka:"ui-prefs/prefs.json",group:"config",store:{path:"<cwd>/session-manager-operations/ui-prefs/prefs.json",format:"json",writer:"ui-prefs",definedIn:"src/renderer/lib/uiPrefs.ts "},summary:"Per-project UI state that used to live in scattered global/localStorage keys — one file per project keeps it scoped to the project it belongs to by construction (PRD 1398/1399).",fields:[{name:"fileTreeExpanded",type:"string[]",optional:!0,note:"FileTree.tsx — expanded folder paths in the Files sidebar"},{name:"hiddenCompletedSlugs",type:"string[]",optional:!0,note:'SchedulePanel.tsx — "Clear completed" hides, renderer-side only'},{name:"queueFilterStatus",type:"string",optional:!0,note:"SchedulePanel.tsx — the queue's status filter chip"},{name:"epicPins",type:"Record<string, boolean>",optional:!0,key:"fk",ref:"epic.id",note:"epicsPrefs.ts — pinned-to-top Epic ids, keyed by epicId (moved off the global epics-prefs.json)"},{name:"chatVerbosityPerEpic",type:"Record<string, ChatVerbosity>",optional:!0,key:"fk",ref:"epic.id",note:"chatPrefs.ts — per-Epic verbosity overrides, keyed by epicId (moved off the global chat-prefs.json)"},{name:"editorSession",type:"{ openFiles: string[]; activeFilePath: string | null; viewModeByPath: Record<string, string> }",optional:!0,note:"editor.ts — the Editor scene's structural tab strip only; buffers/baselines/dirty are never persisted (PRD 1400)"}]}];function cB(i){const e=ay.find(t=>t.id===i);if(!e)throw new Error(`unknown ErdEntity id: ${i}`);return e}const Dk=[{from:"tab",to:"project",cardinality:"N-1",label:"belongs to"},{from:"epic",to:"project",cardinality:"N-1",label:"belongs to"},{from:"epic",to:"tag",cardinality:"N-1",label:"mission",optional:!0},{from:"epic",to:"agentPersona",cardinality:"N-1",label:"actor",optional:!0},{from:"epic",to:"epic",cardinality:"N-1",label:"resumed from",optional:!0},{from:"epic",to:"claudeTranscript",cardinality:"1-1",label:"1:1 session"},{from:"epicEvent",to:"epic",cardinality:"N-1",label:"belongs to"},{from:"epicEvent",to:"epicEvent",cardinality:"N-1",label:"caused by",optional:!0},{from:"epicEvent",to:"prd",cardinality:"N-1",label:"about",optional:!0},{from:"epicTranscriptTurn",to:"epic",cardinality:"N-1",label:"belongs to"},{from:"epicTranscriptTurn",to:"epicEvent",cardinality:"N-1",label:"labeled by",optional:!0},{from:"epicArchive",to:"epic",cardinality:"1-1",label:"freezes"},{from:"exchange",to:"epic",cardinality:"N-1",label:"session for",optional:!0},{from:"exchange",to:"project",cardinality:"N-1",label:"belongs to"},{from:"prd",to:"epic",cardinality:"N-1",label:"joins (directory fact)"},{from:"prd",to:"epic",cardinality:"N-1",via:"sourcePromptId",label:"authored from (frontmatter intent)",optional:!0},{from:"prd",to:"project",cardinality:"N-1",label:"belongs to"},{from:"prd",to:"tag",cardinality:"N-1",label:"mission",optional:!0},{from:"scheduleJob",to:"prd",cardinality:"1-1",label:"executes"},{from:"scheduleJob",to:"prd",cardinality:"N-N",via:"dependsOn",label:"depends on",optional:!0},{from:"scheduleJob",to:"epic",cardinality:"N-1",label:"belongs to",optional:!0},{from:"scheduleJob",to:"runLog",cardinality:"N-1",label:"ran as",optional:!0},{from:"scheduleJob",to:"scheduleJob",cardinality:"N-N",via:"dependsOn",label:"depends on (self)",optional:!0},{from:"scheduleJobStatusHistory",to:"scheduleJob",cardinality:"N-1",label:"transitions of"},{from:"scheduleHistoryEntry",to:"prd",cardinality:"N-1",label:"archives"},{from:"scheduleHistoryEntry",to:"epic",cardinality:"N-1",label:"belongs to",optional:!0},{from:"scheduleHistoryEntry",to:"runLog",cardinality:"N-1",label:"ran as",optional:!0},{from:"scheduleConfig",to:"project",cardinality:"1-1",label:"configures"},{from:"agentPersona",to:"tag",cardinality:"N-N",label:"tagged with"},{from:"agentPersona",to:"project",cardinality:"N-N",label:"action button in"},{from:"memoryEntry",to:"project",cardinality:"N-1",label:"workspace"},{from:"memoryCluster",to:"memoryEntry",cardinality:"1-N",label:"clusters"},{from:"agentMemoryEntry",to:"agentPersona",cardinality:"N-1",label:"belongs to"},{from:"transcriptEvent",to:"tab",cardinality:"N-1",label:"classified for"},{from:"transcriptEvent",to:"claudeTranscript",cardinality:"N-1",label:"classified from"},{from:"claudeTranscript",to:"project",cardinality:"N-1",label:"belongs to"},{from:"historyRollupDay",to:"project",cardinality:"N-N",label:"aggregates"},{from:"billingUsage",to:"scheduleConfig",cardinality:"1-N",label:"gates when-available firing"},{from:"projectBrief",to:"project",cardinality:"1-1",label:"describes"},{from:"projectBrief",to:"epic",cardinality:"N-1",via:"areas[].epic",label:"traces to",optional:!0},{from:"projectPages",to:"project",cardinality:"1-1",label:"generated for"},{from:"settingsScope",to:"project",cardinality:"N-1",label:"scoped to",optional:!0},{from:"layoutEnvelope",to:"tab",cardinality:"1-N",label:"panels for"},{from:"opsNamespace",to:"epic",cardinality:"1-N",label:"governs writes"},{from:"opsNamespace",to:"prd",cardinality:"1-N",label:"governs writes"},{from:"opsNamespace",to:"projectBrief",cardinality:"1-N",label:"governs writes"}];function HP(i){return Dk.filter(e=>e.from===i||e.to===i)}function dB(i){const e=new Set;for(const t of HP(i)){const n=t.from===i?t.to:t.from;n!==i&&e.add(n)}return[...e]}function uB(i){switch(i){case"1-1":return"1—1";case"1-N":return"1—N";case"N-1":return"N—1";case"N-N":return"N—N"}}const j0=220,R0=7,WP=44,UP=16,VP=10,qP=96,KP=28,Vg=24;function YP(i){const e=Math.min(i,R0)+(i>R0?1:0);return WP+e*UP+VP}function XP(i){const e=i.x+i.w,t=i.y+i.h*.35,n=i.y+i.h*.65,r=e+48;return{d:`M ${e} ${t} C ${r} ${t}, ${r} ${n}, ${e} ${n}`,mx:r,my:(t+n)/2}}function hB(i=ay,e=Dk){const t=Tk.map(f=>f.id).filter(f=>i.some(m=>m.group===f)),n=[],r=new Map;t.forEach((f,m)=>{const g=Vg+m*(j0+qP);let y=Vg;for(const D of i){if(D.group!==f)continue;const E=YP(D.fields.length),C={id:D.id,group:f,x:g,y,w:j0,h:E};n.push(C),r.set(D.id,C),y+=E+KP}});const l=new Set(i.map(f=>f.id)),p=[];for(const f of e){if(!l.has(f.from)||!l.has(f.to))continue;const m=r.get(f.from),g=r.get(f.to);if(!m||!g)continue;if(f.from===f.to){const j=XP(m);p.push({relation:f,...j});continue}const y=m.x<g.x,D=y?m.x+m.w:m.x,E=m.y+m.h/2,C=y?g.x:g.x+g.w,b=g.y+g.h/2,w=Math.max(40,Math.abs(C-D)/2),x=D+(y?w:-w),S=C+(y?-w:w),T=`M ${D} ${E} C ${x} ${E}, ${S} ${b}, ${C} ${b}`;p.push({relation:f,d:T,mx:(D+C)/2,my:(E+b)/2})}const a=n.reduce((f,m)=>Math.max(f,m.x+m.w),0),d=n.reduce((f,m)=>Math.max(f,m.y+m.h),0);return{boxes:n,edges:p,width:a+Vg,height:d+Vg}}const ly=[];function JP({onNavigate:i}){const e=z.useMemo(()=>{const m=new Date().getHours();return m<5?"Up late":m<12?"Good morning":m<18?"Good afternoon":"Good evening"},[]);hj();const t=ej(),n=QP(),r=Ct(m=>m.tabs),l=Ct(m=>m.addTab),p=Ct(m=>m.setActive),[a,d]=z.useState(!1),f=m=>{vk(m,r,l,p),i==null||i("terminal")};return c.jsxs("div",{className:"h-full overflow-auto",children:[c.jsxs("div",{className:"mx-auto max-w-[1400px] px-[34px] py-[26px] text-fg",children:[c.jsx(nj,{greeting:e,projectCount:n.length,needsCount:t.length,onNavigate:i,onOpenNewEpic:()=>d(!0)}),c.jsxs("div",{"data-testid":"home-panel-grid",className:"grid gap-[18px] mb-7",style:{gridTemplateColumns:"repeat(3, minmax(0,1fr))",gridTemplateRows:"repeat(2, minmax(0, 300px))"},children:[c.jsx("div",{className:"bg-bg-hi border border-line rounded-[14px] px-4 py-[14px] min-h-0 overflow-auto",children:c.jsx(dj,{})}),c.jsx(uj,{projectRows:n}),c.jsx(lj,{onNavigate:i}),c.jsx(aj,{rows:t,onNavigate:i}),c.jsx(mj,{onNavigate:i}),c.jsx(fj,{onNavigate:i})]}),c.jsxs("details",{"data-testid":"home-reference",className:"mb-6",children:[c.jsx("summary",{className:"cursor-pointer font-mono text-[11px] uppercase tracking-[0.08em] text-fg-faint mb-3",children:"Reference & appearance"}),c.jsx(CP,{}),c.jsx(tj,{}),c.jsx(ij,{onNavigate:i}),c.jsx(bP,{})]})]}),c.jsx(pP,{open:a,onClose:()=>d(!1),projects:n,onConfirm:f})]})}const ZP=z.memo(JP);function QP(){const{projects:i}=Cd(),e=Qv(),t=ri(n=>n.sessions);return z.useMemo(()=>nP(i,e,t),[i,e,t])}function ej(){const i=ri(n=>n.sessions),e=Qv(),t=Wr(n=>{var r;return(r=n.snapshot)==null?void 0:r.jobs})??ly;return z.useMemo(()=>{const n={};for(const r of Object.keys(i)){const l=i[r];l.status==="proposed"&&(n[r]={id:r,cwd:l.cwd,goalText:l.goalText,tag:l.tag})}return aP(n,e,t)},[i,e,t])}function tj(){const i=Sk(null),{value:e,source:t}=Ck(i,["effortLevel"]),n=kk(e,t);return c.jsxs("section",{className:"mb-6",children:[c.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[c.jsx("h2",{className:"m-0 font-serif text-[22px] font-medium",children:"Agents"}),c.jsxs("span",{className:"font-mono text-[12px] text-fg-faint","data-testid":"home-agents-effort",title:"Machine-wide effective reasoning effort — the settings.json scope chain's current winner, independent of any one project.",children:["1 tag per session · ",n]})]}),c.jsx("div",{className:"grid gap-2",children:U2.map(r=>{const l=oC[r],p=qT(r);return c.jsxs("div",{className:"bg-bg-hi border border-line rounded-[13px] px-4 py-[13px]",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[c.jsx("span",{className:`font-mono text-[10.5px] font-semibold uppercase tracking-[0.06em] px-1.5 py-0.5 rounded ${p.bg} ${p.text}`,children:p.label}),c.jsx("span",{className:"text-[12px] text-fg-faint",children:l.description})]}),c.jsx("p",{className:"m-0 text-[12.5px] text-fg-dim leading-[1.5] font-mono whitespace-pre-wrap",children:l.initialPromptTemplate})]},r)})})]})}function ij({onNavigate:i}){return c.jsx("section",{className:"mb-6",children:c.jsxs("button",{type:"button","data-testid":"home-data-model-card",onClick:()=>i==null?void 0:i("data-model"),className:"w-full text-left bg-bg-hi border border-line rounded-[14px] px-4 py-[14px] flex items-center justify-between hover:bg-bg-elev/40 transition-colors",children:[c.jsxs("span",{children:[c.jsx("span",{className:"block font-serif text-[16px] font-medium text-fg",children:"Data Model"}),c.jsxs("span",{className:"block text-[12.5px] text-fg-dim",children:[ay.length," entities — what Session Manager persists, and how it joins"]})]}),c.jsx("span",{className:"font-mono text-[11px] text-accent shrink-0",children:"Open →"})]})})}function nj({greeting:i,projectCount:e,needsCount:t,onNavigate:n,onOpenNewEpic:r}){const[l,p]=z.useState(!1);return c.jsxs(c.Fragment,{children:[c.jsx(sj,{greeting:i,projectCount:e,needsCount:t,onNavigate:n,onOpenNewEpic:r,legendOpen:l,onToggleLegend:()=>p(a=>!a)}),l&&c.jsx(oj,{})]})}function sj({greeting:i,projectCount:e,needsCount:t,onNavigate:n,onOpenNewEpic:r,legendOpen:l,onToggleLegend:p}){const a=Vw(),d=(a==null?void 0:a.total)??5,f=(a==null?void 0:a.inUse)??0,m=()=>{var g;(g=document.getElementById("home-needs-you"))==null||g.scrollIntoView({behavior:"smooth",block:"start"})};return c.jsxs("header",{className:"mb-[18px] flex items-end gap-4",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"font-mono text-[10.5px] font-semibold uppercase tracking-[0.08em] text-fg-faint mb-1.5",children:["This machine · ",e," project",e===1?"":"s"]}),c.jsxs("h1",{className:"m-0 font-serif text-[30px] font-semibold leading-[1.1] text-fg tracking-[-0.01em]",children:[i,". ",c.jsxs("span",{className:"text-accent",children:[f," of ",d]})," slots busy,"," ",t>0?c.jsxs("button",{onClick:m,className:"underline decoration-dotted underline-offset-4 text-honey-dark hover:text-honey",children:[t," thing",t>1?"s":""]}):c.jsx("span",{className:"text-sage",children:"nothing"})," ","need",t===1?"s":""," you."]})]}),c.jsxs("div",{className:"ml-auto flex gap-2 shrink-0",children:[c.jsx(H_,{onClick:p,children:l?"Hide interactions":"Interactions"}),c.jsx(H_,{onClick:()=>n==null?void 0:n("history"),children:"All history"}),c.jsx(H_,{primary:!0,onClick:r,children:"New epic"})]})]})}const rj=[{term:"Usage card",description:"Read-only — shows the live 5-hour and weekly billing windows. Not clickable."},{term:"Queued job",description:`Click a job row to open a popover with its real details (project, estimate, status) and actions — Open in Scheduler, plus Nudge scheduler now while it's pending. Use "Open Scheduler →" in the card header to jump straight to the Scheduler tab.`},{term:"Needs-you row",description:"Click a row to expand it inline, then Approve & start / Discard a proposed session, Open a session waiting on input, Retry / view a failed job, or Adopt / view a quarantined PRD."},{term:"Active session row",description:"Click Open to jump to the Scheduler tab (job) or the session's Terminal view."},{term:"Recent row",description:"Click resume to open a new Terminal tab that resumes that transcript session."},{term:"Project row",description:"Click a project to activate its open Terminal tab, or open a new dormant one."},{term:"New session",description:"Opens a project picker; confirming activates-or-opens that project's tab and lands you in its Sessions workspace to start the session."}];function oj(){return c.jsxs("div",{className:"mb-7 bg-bg-hi border border-line rounded-[13px] px-4 py-[13px]",children:[c.jsx("div",{className:"font-mono text-[11px] uppercase tracking-[0.08em] text-fg-faint mb-2.5",children:"Interactions"}),c.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:"minmax(0,140px) minmax(0,1fr)"},children:rj.map(i=>c.jsxs("div",{className:"contents",children:[c.jsx("div",{className:"text-[12.5px] font-semibold text-fg underline decoration-dotted underline-offset-4",children:i.term}),c.jsx("div",{className:"text-[12.5px] text-fg-dim leading-[1.5]",children:i.description})]},i.term))})]})}function H_({children:i,onClick:e,primary:t}){return c.jsx("button",{onClick:e,className:t?"rounded-lg bg-accent text-bg-hi px-4 py-2 text-[12.5px] font-semibold hover:bg-accent-dark":"rounded-lg border border-line bg-bg-hi px-4 py-2 text-[12.5px] font-semibold text-fg-dim hover:bg-bg-elev",children:i})}function aj({rows:i,onNavigate:e}){const[t,n]=z.useState(null),[r,l]=z.useState(null),p=mm(i,4),a=D=>{n(null),p.setPage(D)},d=D=>{if(!(!D.epicId||r)){l(D.id);try{const E=ri.getState().approveProposed(D.epicId,"Home needs-you");if(!E){Qe.error("This session is no longer awaiting approval.");return}vi.getState().send({tabId:E.id,sessionId:E.claudeSessionId,cwd:E.cwd,prompt:E.openingPrompt||E.goalText}),Qe.info("Session approved and started.")}finally{l(null),n(null)}}},f=D=>{!D.epicId||r||(l(D.id),ri.getState().markCompleted(D.epicId,"Home needs-you discard").catch(()=>{}).finally(()=>{l(null),n(null)}))},m=D=>{D.epicId&&(t_(D.epicId),e==null||e("terminal"))},g=D=>{!D.jobSlug||r||(l(D.id),window.api.schedule.resetJob(D.jobSlug).then(E=>{E.ok?Qe.info(`${D.jobSlug} reset to pending.`):Qe.error(E.error??"Could not reset job.")}).catch(E=>Qe.error(E instanceof Error?E.message:String(E))).finally(()=>{l(null),n(null)}))},y=D=>{!D.jobSlug||r||(l(D.id),window.api.schedule.adoptPrd(D.jobSlug).then(E=>{E.ok?Qe.info(`${D.jobSlug} adopted — will run on the next tick.`):Qe.error(E.message??"Could not adopt PRD.")}).catch(E=>Qe.error(E instanceof Error?E.message:String(E))).finally(()=>{l(null),n(null)}))};return c.jsxs("section",{id:"home-needs-you",className:"bg-bg-hi border border-line rounded-[14px] px-4 py-[14px] min-h-0 overflow-auto scroll-mt-4",children:[c.jsxs("div",{className:"flex items-baseline justify-between gap-2 mb-2.5",children:[c.jsx("h2",{className:"m-0 font-mono text-[11px] uppercase tracking-[0.08em] text-fg-faint font-normal",children:"Needs you"}),c.jsx("span",{className:"font-mono text-[12px] text-fg-faint",children:i.length?`${i.length} open`:"all clear"})]}),i.length===0&&c.jsx("div",{className:"bg-bg-hi border border-line rounded-[11px] px-4 py-[18px] text-center text-[13px] text-fg-faint",children:"Nothing waiting on you. Proposed Epics, mid-run questions, and failed jobs will surface here."}),c.jsx("div",{className:"grid gap-[7px]",children:p.pageItems.map(D=>{const E=t===D.id,C=D.kind==="job-failed"?"bg-accent":D.kind==="job-quarantined"?D.escalated?"bg-accent":"bg-honey":D.kind==="needs-input"?"bg-honey":"bg-sage";return c.jsxs("div",{className:`border rounded-[11px] overflow-hidden ${E?"bg-bg-hi border-line":"bg-bg border-line/60"}`,children:[c.jsxs("button",{onClick:()=>n(E?null:D.id),className:"w-full grid items-center gap-2.5 px-[13px] py-[10px] text-left",style:{gridTemplateColumns:"6px minmax(0,1fr) auto"},children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${C}`}),c.jsxs("span",{className:"min-w-0",children:[c.jsx("span",{className:"block text-[12.5px] font-semibold text-fg",children:D.label}),c.jsxs("span",{className:"block text-[11.5px] text-fg-faint truncate",children:[D.project?`${D.project} · `:"",D.detail]})]}),c.jsx("span",{className:"font-mono text-[11px] text-fg-faint",children:E?"▴":"▾"})]}),E&&c.jsxs("div",{className:"border-t border-line px-[13px] pt-[11px] pb-3 grid gap-2.5",children:[c.jsx("div",{className:"text-[12.5px] text-fg-dim leading-relaxed",children:D.meta}),c.jsxs("div",{className:"flex gap-2",children:[D.kind==="proposed-epic"&&c.jsxs(c.Fragment,{children:[c.jsx(ld,{onClick:()=>d(D),disabled:r===D.id,children:"Approve & start"}),c.jsx(ld,{quiet:!0,onClick:()=>f(D),disabled:r===D.id,children:"Discard"})]}),D.kind==="needs-input"&&c.jsx(ld,{onClick:()=>m(D),children:"Open session"}),D.kind==="job-failed"&&c.jsxs(c.Fragment,{children:[c.jsx(ld,{onClick:()=>g(D),disabled:r===D.id,children:"Retry now"}),c.jsx(ld,{quiet:!0,onClick:()=>e==null?void 0:e("scheduler"),children:"View in Scheduler"})]}),D.kind==="job-quarantined"&&c.jsxs(c.Fragment,{children:[c.jsx(ld,{onClick:()=>y(D),disabled:r===D.id,children:"Adopt PRD"}),c.jsx(ld,{quiet:!0,onClick:()=>e==null?void 0:e("scheduler"),children:"View in Scheduler"})]})]})]})]},D.id)})}),c.jsx(gm,{compact:!0,testIdPrefix:"home-needs-pager",page:p.page,pageSize:p.pageSize,totalItems:p.total,onPageChange:a})]})}function ld({children:i,onClick:e,disabled:t,quiet:n}){return c.jsx("button",{onClick:e,disabled:t,className:n?"rounded-md border border-line bg-bg px-3 py-[5px] text-[11.5px] font-semibold text-fg-dim hover:bg-bg-elev disabled:opacity-50":"rounded-md bg-accent text-bg-hi px-3 py-[5px] text-[11.5px] font-semibold hover:bg-accent-dark disabled:opacity-50",children:i})}function lj({onNavigate:i}){const e=Wr(a=>{var d;return(d=a.snapshot)==null?void 0:d.jobs})??ly,t=z.useMemo(()=>e.filter(a=>a.status==="pending"),[e]),n=mm(t,5),[r,l]=z.useState(null),p=()=>{mk(),l(null)};return c.jsxs("div",{className:"bg-bg-hi border border-line rounded-[14px] px-4 py-[14px] min-h-0 overflow-auto",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2.5",children:[c.jsxs("div",{className:"font-mono text-[11px] uppercase tracking-[0.08em] text-fg-faint",children:["Queued",t.length>0?` · ${t.length}`:""]}),c.jsx("button",{onClick:()=>i==null?void 0:i("scheduler"),className:"font-mono text-[10.5px] text-accent hover:underline",children:"Open Scheduler →"})]}),t.length===0?c.jsx("div",{className:"text-[13px] text-fg-faint py-1",children:"Nothing pending."}):c.jsx("div",{className:"space-y-2.5",children:n.pageItems.map(a=>c.jsxs("div",{className:"relative",children:[c.jsxs("button",{onClick:()=>l(r===a.slug?null:a.slug),className:"w-full text-left hover:bg-bg/40 rounded-md -mx-1 px-1 py-0.5 transition-colors",children:[c.jsx("div",{className:"font-mono text-[11.5px] font-semibold text-fg truncate",children:a.title||a.slug}),c.jsxs("div",{className:"text-[11px] text-fg-faint truncate",children:[a.cwd?Go(a.cwd):"—",a.estimateMinutes!=null?` · ~${a.estimateMinutes}m`:""]})]}),r===a.slug&&c.jsx(fP,{job:a,onClose:()=>l(null),onOpenScheduler:()=>{l(null),i==null||i("scheduler")},onRunNow:a.status==="pending"?p:void 0})]},a.slug))}),c.jsx(gm,{compact:!0,testIdPrefix:"home-queued-pager",page:n.page,pageSize:n.pageSize,totalItems:n.total,onPageChange:n.setPage})]})}function cj({slots:i}){const e=(i==null?void 0:i.min)??0,t=(i==null?void 0:i.max)??10,n=(i==null?void 0:i.total)??5,r=(i==null?void 0:i.envOverride)??!1,[l,p]=z.useState(null),[a,d]=z.useState(!1),f=l??n,m=g=>{p(g),d(!0),_$(g).catch(y=>{Qe.error(`Could not set session slots: ${y instanceof Error?y.message:String(y)}`)}).finally(()=>{d(!1),p(null)})};return c.jsxs("span",{className:"flex items-center gap-2.5 shrink-0",title:r?"Pinned by SM_SESSION_SLOTS env var":"Max concurrent claude -p sessions on this machine (0 pauses new launches)",children:[c.jsx("span",{className:"font-mono text-[11px] text-fg-faint",children:"Max slots"}),c.jsx("input",{type:"range",min:e,max:t,step:1,value:f,disabled:r||a,onChange:g=>m(Number(g.target.value)),className:"w-24 accent-accent disabled:opacity-40 disabled:cursor-not-allowed"}),c.jsx("span",{className:"font-mono text-[12px] font-semibold text-fg w-4 text-right",children:f})]})}function dj(){const i=em(t=>t.data),e=TC(i);return c.jsxs("div",{className:"space-y-3",children:[i&&i.kind!=="ok"&&i.kind!=="ok-stale"&&c.jsx(jP,{result:i,onRetry:JD}),!i&&c.jsx("div",{className:"text-xs text-fg-faint",children:"loading usage…"}),e&&c.jsx(hP,{data:e,updatedAt:e.fetchedAt})]})}function uj({projectRows:i}){const e=Ct(a=>a.tabs),t=Ct(a=>a.addTab),n=Ct(a=>a.setActive),{unresolvedWorktreeFolders:r}=Cd(),l=mm(i,8),p=a=>{vk(a,e,t,n),ji.getState().setEpicsWorkspaceOpen(!1)};return c.jsxs("div",{className:"bg-bg-hi border border-line rounded-[14px] px-4 py-[14px] min-h-0 overflow-auto",children:[c.jsx("div",{className:"font-mono text-[11px] uppercase tracking-[0.08em] text-fg-faint mb-2.5",children:"Projects"}),i.length===0?c.jsx("div",{className:"text-[13px] text-fg-faint py-2",children:"No known projects yet."}):c.jsx("div",{className:"space-y-1",children:l.pageItems.map(a=>c.jsxs("button",{onClick:()=>p(a.cwd),className:"w-full flex items-center gap-2.5 text-left px-2 py-1.5 rounded-lg hover:bg-bg/60 transition-colors",title:a.cwd,children:[c.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:gk(a.dotSeed)}}),c.jsx("span",{className:"flex-1 min-w-0 text-[13px] text-fg truncate",children:a.name}),a.liveCount>0?c.jsxs("span",{className:"font-mono text-[11px] text-accent whitespace-nowrap",children:[a.liveCount," live"]}):c.jsx("span",{className:"font-mono text-[11px] text-fg-faint whitespace-nowrap",children:tr(a.lastActivityMs,Date.now())})]},a.encoded))}),c.jsx(gm,{compact:!0,testIdPrefix:"home-projects-pager",page:l.page,pageSize:l.pageSize,totalItems:l.total,onPageChange:l.setPage}),r>0&&c.jsxs("div",{"data-testid":"home-projects-unresolved",className:"mt-2 text-[11px] text-fg-faint",children:[r," worktree folders not matched to a project"]})]})}function hj(){const{projects:i}=Cd(),e=z.useMemo(()=>i.map(t=>t.cwd).join(`
|
|
2943
2943
|
`),[i]);z.useEffect(()=>{for(const t of e?e.split(`
|
|
2944
2944
|
`):[])ri.getState().hydrate(t),ri.getState().hydrateArchived(t)},[e])}const pj="92px minmax(0,1.2fr) minmax(0,1fr) 80px 74px 78px";function fj({onNavigate:i}){const{projects:e,recentSessions:t,loading:n}=Cd(),r=mm(t,5),l=r.pageItems,p=Ct(C=>C.addTab),a=ri(C=>C.sessions),[d,f]=z.useState(null),m=z.useMemo(()=>{const C={};for(const b of e)for(const w of b.encodedIds)C[w]=b.cwd;return C},[e]),g=C=>m[C]??hk(C),y=C=>{const b=g(C.projectEncoded);p({cwd:b,startupCommand:`claude --resume ${kr(C.sessionId)}`,presetId:"history-resume"})},D=d?D0(d.sessionId,a):null,E=d?[{label:"Session",value:d.sessionId},{label:"Project",value:g(d.projectEncoded)},{label:"Epic",value:D??"—"},{label:"Last activity",value:`${$k(d.mtimeMs)} (${tr(d.mtimeMs,Date.now())})`},{label:"Size",value:`${Math.round(d.sizeBytes/1024)}k`}]:[];return c.jsxs("section",{className:"bg-bg-hi border border-line rounded-[14px] px-4 py-[14px] min-h-0 overflow-auto",children:[c.jsxs("div",{className:"flex items-baseline justify-between gap-2 mb-2.5",children:[c.jsx("h2",{className:"m-0 font-mono text-[11px] uppercase tracking-[0.08em] text-fg-faint font-normal",children:"Recent sessions"}),c.jsx("button",{onClick:()=>i==null?void 0:i("history"),className:"text-[13px] text-accent font-medium hover:underline",children:"See all history →"})]}),c.jsxs("div",{className:"overflow-hidden",children:[n&&l.length===0&&c.jsx("div",{className:"px-[18px] py-6 text-[13px] text-fg-faint text-center",children:"Reading transcripts…"}),!n&&l.length===0&&c.jsx("div",{className:"px-[18px] py-6 text-[13px] text-fg-faint text-center",children:"No sessions yet — hit “Start a session” to begin."}),l.map((C,b)=>{const w=D0(C.sessionId,a);return c.jsxs("button",{onClick:()=>f(C),className:"w-full grid items-center gap-3.5 px-[18px] py-[11px] text-left hover:bg-bg/40 transition-colors",style:{gridTemplateColumns:pj,borderTop:b?"1px solid #d9c9a8":"none"},children:[c.jsx("span",{className:"text-[11.5px] text-fg-faint font-mono truncate",children:C.sessionId.slice(0,8)}),c.jsx("span",{className:"text-[12.5px] font-semibold text-fg truncate",title:C.projectEncoded,children:Go(g(C.projectEncoded))}),c.jsx("span",{className:"text-[12.5px] text-fg-dim truncate",children:w??"—"}),c.jsxs("span",{className:"text-[11.5px] text-fg-faint font-mono text-right",children:[Math.round(C.sizeBytes/1024),"k"]}),c.jsx("span",{className:"text-[11px] text-fg-faint font-mono text-right",children:tr(C.mtimeMs,Date.now())}),c.jsx("span",{className:"justify-self-end text-[12px] font-semibold px-[11px] py-[5px] rounded-lg text-sage bg-[#e5ecd8]",title:`Open ${C.sessionId.slice(0,8)}…`,children:"details"})]},C.path)}),c.jsx("div",{className:"px-[18px]",children:c.jsx(gm,{compact:!0,testIdPrefix:"home-recent-pager",page:r.page,pageSize:r.pageSize,totalItems:r.total,onPageChange:r.setPage})})]}),c.jsx(ry,{open:d!=null,onClose:()=>f(null),title:D??(d?Go(g(d.projectEncoded)):""),sub:d?`Recent session · ${d.sessionId.slice(0,8)}…`:null,keyVals:E,footer:d&&c.jsx("button",{onClick:()=>{y(d),f(null)},className:"text-[12px] font-semibold px-[13px] py-[7px] rounded-lg text-sage bg-[#e5ecd8] hover:brightness-95 transition-[filter]",children:"Resume"})})]})}function $k(i){return new Date(i).toLocaleString()}function mj({onNavigate:i}){var w;const e=Vw(),t=Wr(x=>{var S;return(S=x.snapshot)==null?void 0:S.jobs})??ly,n=Qv(),r=ri(x=>x.sessions),[l,p]=z.useState(null),a=(e==null?void 0:e.total)??5,d=(e==null?void 0:e.inUse)??0,f=z.useMemo(()=>t.filter(x=>x.status==="running"),[t]),m=Wr(x=>{var S;return(S=x.snapshot)==null?void 0:S.lastTick}),g=z.useMemo(()=>{var S;if(!m||m.fired)return null;const x=t.filter(T=>T.status==="pending").length;if(x===0)return null;switch(m.reason){case"memory-deferred":return`memory gate: ${m.availableMb} MB free, need ${m.threshold} MB`;case"slots-exhausted":return`all ${a} slots busy — ${m.deferredCount??x} pending`;case"held":{const T=((S=m.holds)==null?void 0:S.length)??0;return T>0?`${T} pending held behind dependencies`:m.detail??"held"}case"paused":return"scheduler paused";default:return null}},[m,t,a]),y=z.useMemo(()=>sP((e==null?void 0:e.holders)??[],f,n,r),[e,f,n,r]),D=mm(y,5),E=x=>{if(x.openTarget==="scheduler"){i==null||i("scheduler");return}x.openTarget==="terminal"&&x.epicId&&(t_(x.epicId),i==null||i("terminal"))},C=(l==null?void 0:l.kind)==="chat run"&&l.epicId?(w=n[l.epicId])==null?void 0:w.turns.slice(-4).map(x=>({id:x.id,role:x.role,text:x.text})):void 0,b=l?[{label:"Owner",value:l.owner},{label:"Kind",value:l.kind},{label:"Epic",value:l.epicTitle??"—"},{label:"Project",value:l.project??"—"},{label:"Started",value:`${$k(new Date(l.at).getTime())} (${tr(new Date(l.at).getTime(),Date.now())})`}]:[];return c.jsxs("section",{className:"bg-bg-hi border border-line rounded-[14px] px-4 py-[14px] min-h-0 overflow-auto",children:[c.jsxs("div",{className:"flex items-baseline justify-between gap-2 mb-2.5",children:[c.jsx("h2",{className:"m-0 font-mono text-[11px] uppercase tracking-[0.08em] text-fg-faint font-normal",children:"Active sessions"}),c.jsxs("span",{className:"flex items-center gap-4",children:[c.jsxs("span",{className:"font-mono text-[12px] text-fg-faint",children:[d," of ",a," slots in use",g&&c.jsxs("span",{className:"ml-2 text-amber-400/90",children:["· ",g]})]}),c.jsx(cj,{slots:e})]})]}),y.length===0?c.jsx("div",{className:"text-[13px] text-fg-faint py-1",children:"No headless Claude sessions running."}):c.jsx("div",{className:"grid gap-2",children:D.pageItems.map(x=>c.jsxs("button",{onClick:()=>p(x),className:"w-full text-left bg-bg-hi border border-line rounded-[13px] px-4 py-[13px] grid items-center gap-3.5 hover:bg-bg-elev/40 transition-colors",style:{gridTemplateColumns:"minmax(0,1fr) auto"},children:[c.jsxs("span",{className:"min-w-0",children:[c.jsxs("span",{className:"flex items-center gap-2 mb-1",children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent shrink-0"}),c.jsx("span",{className:"font-mono text-[12.5px] font-semibold text-fg truncate",children:x.owner}),c.jsx("span",{className:"font-mono text-[10.5px] text-fg-faint shrink-0",children:x.kind})]}),(x.project||x.epicTitle)&&c.jsx("span",{className:"block text-[12px] text-fg-faint truncate",children:[x.project,x.epicTitle?`Epic · ${x.epicTitle}`:null].filter(Boolean).join(" · ")})]}),c.jsxs("span",{className:"flex items-center gap-3.5 shrink-0",children:[c.jsx("span",{className:"font-mono text-[11px] text-fg-faint",children:tr(new Date(x.at).getTime(),Date.now())}),x.openTarget&&c.jsx("span",{onClick:S=>{S.stopPropagation(),E(x)},className:"border border-line bg-bg rounded-lg px-[11px] py-[5px] text-[12px] font-semibold text-fg-dim hover:bg-bg/60 transition-colors",children:"Open"})]})]},x.owner))}),c.jsx(gm,{compact:!0,testIdPrefix:"home-active-pager",page:D.page,pageSize:D.pageSize,totalItems:D.total,onPageChange:D.setPage}),c.jsx(ry,{open:l!=null,onClose:()=>p(null),title:(l==null?void 0:l.epicTitle)??(l==null?void 0:l.owner)??"",sub:l?`Active session · ${l.kind}`:null,keyVals:b,tail:C,footer:(l==null?void 0:l.openTarget)&&c.jsx("button",{onClick:()=>{E(l),p(null)},className:"text-[12px] font-semibold px-[13px] py-[7px] rounded-lg bg-accent text-bg-hi hover:bg-accent-dark",children:"Open"})})]})}function N0(i){return i.html===null?null:{html:i.html,mtimeMs:i.mtimeMs}}function gj(i){const[e,t]=z.useState(null),[n,r]=z.useState(null),[l,p]=z.useState(!1);return z.useEffect(()=>{if(!i)return;let a=!1;return p(!1),window.api.projectPages.get(i).then(d=>{a||(t(N0(d)),r(d.demoVideo),p(!0))}).catch(d=>{a||(p(!0),Qe.error(`Could not load Project Pages: ${d instanceof Error?d.message:String(d)}`))}),()=>{a=!0}},[i]),z.useEffect(()=>{if(!i)return;window.api.projectPages.watch(i);const a=window.api.projectPages.onChanged(d=>{d.cwd===i&&(t(N0(d)),r(d.demoVideo),p(!0))});return()=>{a(),window.api.projectPages.unwatch(i)}},[i]),{output:e,demoVideo:n,loaded:l}}const M0=[];function Ak(i,e,t="sessions"){if(!e)return[];const n=Er(e);return i.filter(r=>(r.surface??"sessions")===t).filter(r=>r.projects.some(l=>l==="*"||Er(l)===n)).sort((r,l)=>r.label.toLowerCase().localeCompare(l.label.toLowerCase()))}function Ik(){const[i,e]=z.useState(M0);return z.useEffect(()=>{var l,p,a;let t=!1;const n=()=>{var f,m;const d=(m=(f=window.api)==null?void 0:f.macros)==null?void 0:m.list;d&&d().then(g=>{t||e(g)}).catch(()=>{t||e(M0)})};n();const r=(a=(p=(l=window.api)==null?void 0:l.macros)==null?void 0:p.onChanged)==null?void 0:a.call(p,n);return()=>{t=!0,r==null||r()}},[]),i}const O0=[];function Pk(){const[i,e]=z.useState(O0);return z.useEffect(()=>{var l,p,a;let t=!1;const n=()=>{var f,m;const d=(m=(f=window.api)==null?void 0:f.agents)==null?void 0:m.listPersonas;d&&d().then(g=>{t||e(g)}).catch(()=>{t||e(O0)})};n();const r=(a=(p=(l=window.api)==null?void 0:l.agents)==null?void 0:p.onChanged)==null?void 0:a.call(p,n);return()=>{t=!0,r==null||r()}},[]),i}async function jk(i){const{cwd:e,agentName:t,tag:n,title:r,goal:l,agentDescription:p,source:a}=i;if(!e)throw new Error("launchSession: cwd is required");if(!t)throw new Error("launchSession: agentName is required");if(!r)throw new Error("launchSession: title is required");if(!l)throw new Error("launchSession: goal is required");const{goalText:d,openingPrompt:f,sections:m}=Bw({title:r,goal:l,tag:n,agentName:t,agentDescription:p}),g=await ri.getState().createPromptSession(e,d,n,a,t,f,m);return ri.getState().approveProposed(g.id,a),vi.getState().send({tabId:g.id,sessionId:g.claudeSessionId,cwd:e,prompt:f}),{epicId:g.id,claudeSessionId:g.claudeSessionId}}const vj=["xhigh","max"];function _j(i,e){if(!e||!e.effort||!vj.includes(e.effort))return null;const t=e.model??"the default model";return`"${i.label}" runs ${i.agentName} on ${t} at ${e.effort} effort, which can use a large share of your Claude usage. Continue?`}const rw=500,L0=8e3,Rk=/\{\{\s*([a-z][a-z0-9_]{0,31})\s*\}\}/g;function Nk(i){const e=[];for(const t of i.matchAll(new RegExp(Rk.source,"g")))e.includes(t[1])||e.push(t[1]);return e}function Mk(i){const e={};for(const t of i??[])e[t.name]=t.default??"";return e}function bj(i){return i.replace(/[\r\n\t]+/g," ").replace(/[\u0000-\u001f\u007f]/g,"").trim()}function Ok(i,e,t){if(!e||e.length===0)return{ok:!0,prompt:i};const n=Object.create(null);for(const l of e){const p=bj(t[l.name]??l.default??"");if(p===""){if(l.required)return{ok:!1,error:`"${l.label}" is required`}}else{if(p.length>rw)return{ok:!1,error:`"${l.label}" is longer than ${rw} characters`};if(l.options&&l.options.length>0&&!l.options.includes(p))return{ok:!1,error:`"${l.label}" must be one of: ${l.options.join(", ")}`}}n[l.name]=p}for(const l of Nk(i))if(!(l in n))return{ok:!1,error:`prompt uses undeclared input {{${l}}}`};const r=i.replace(Rk,(l,p)=>n[p]);return r.length>L0?{ok:!1,error:`rendered prompt is longer than ${L0} characters`}:{ok:!0,prompt:r}}function Lk(i,e,t){const n=Ct(a=>{var d;return((d=a.tabs.find(f=>f.id===a.activeTabId))==null?void 0:d.cwd)??null}),[r,l]=z.useState(null);return{launch:async(a,d,f)=>{if(!n||r)return;if(t!=null&&t.resumeActive){const D=ri.getState().sessions,E=Object.values(D).find(C=>C.cwd===n&&C.tag===a.tag&&C.agentType===a.agentName&&C.status==="active");if(E){i(E.id);return}}const m=e.find(D=>D.name===a.agentName);if(!m&&(e.length>0||t!=null&&t.requireReadiness)){Qe.error(`Agent ${a.agentName} not found — edit the macro`);return}const g=_j(a,m);if(g&&!window.confirm(g))return;const y=Ok(a.prompt,a.inputs,f??Mk(a.inputs));if(!y.ok){Qe.error(`Cannot start "${a.label}" — ${y.error}`);return}l(a.id);try{if(t!=null&&t.requireReadiness){let b;try{b=await window.api.app.delegationReadiness(n)}catch(w){Qe.error(`Cannot start "${a.label}" — could not check delegation readiness: ${w instanceof Error?w.message:String(w)}`);return}if(!b.ok){const w=b.checks.filter(x=>!x.ok).map(x=>x.label).join("; ");Qe.error(`Cannot start "${a.label}" — delegation isn't ready (${w||"unknown reason"}).`);return}}const D=d==null?void 0:d.trim(),E=D?`${y.prompt}
|
|
2945
2945
|
|
|
@@ -3032,7 +3032,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
3032
3032
|
|
|
3033
3033
|
${t}`}const zf={phase:"idle",selection:null,instruction:"",transcript:"",diff:null,editCount:0,modelStatus:null},MM=["popover","review","diff"],_E=["popover","review"];function OM(i,e){switch(e.type){case"SELECT":return{...zf,editCount:i.editCount,phase:"popover",selection:e.selection};case"CANCEL":return{...zf,editCount:i.editCount};case"LISTEN":return _E.includes(i.phase)?{...i,phase:"listening",transcript:"",modelStatus:null}:i;case"HEARD":return i.phase!=="listening"?i:{...i,phase:"review",transcript:e.transcript,modelStatus:null};case"RUN":return MM.includes(i.phase)?{...i,phase:"thinking",instruction:e.recordInstruction?e.instruction:i.instruction}:i;case"RUN_OK":return i.phase!=="thinking"?i:{...i,phase:"diff",diff:e.diff};case"RUN_ERR":return i.phase!=="thinking"?i:{...i,phase:"popover",transcript:"",diff:null};case"ACCEPT":return i.phase!=="diff"?i:{...zf,editCount:i.editCount+1};case"RESET_FILE":return{...zf,editCount:0};case"MODEL_STATUS":return i.phase!=="listening"?i:{...i,modelStatus:`${e.status}: ${e.message}`};default:return i}}function LM(i,e){let t=null;for(const n of e){const r=n.cwd;!r||!(i===r||i.startsWith(r.endsWith("/")?r:`${r}/`))||(t===null||r.length>t.length)&&(t=r)}return t}function zM(i,e,t){var l;let n=null,r=-1/0;for(const p of e){if(p.cwd!==i||p.status!=="dormant")continue;const a=((l=t[p.id])==null?void 0:l.lastEventAt)??0;(n===null||a>r)&&(n=p,r=a)}return n}const BM="sonnet";function GM(i,e){const[t,n]=z.useReducer(OM,zf),r=z.useRef(0),l=z.useRef(null),p=z.useRef(i),a=z.useRef(new Map);z.useEffect(()=>window.api.docEdit.onSessionResult(S=>{const T=a.current.get(S.requestId);T&&(a.current.delete(S.requestId),T(S))}),[]),z.useEffect(()=>{p.current!==i&&(p.current=i,r.current+=1,d(),n({type:"RESET_FILE"}))},[i]);function d(){const S=l.current;S&&(l.current=null,S.stop().catch(()=>{}),S.destroy(),kt.setState({externalRecording:!1}))}const f=z.useCallback(S=>{r.current+=1,d(),n({type:"SELECT",selection:S})},[]),m=z.useCallback(()=>{r.current+=1,d(),n({type:"CANCEL"})},[]),g=z.useCallback(()=>{if(!_E.includes(t.phase))return;if(kt.getState().isRecording){Qe.error("Microphone is already in use");return}if(!Kv()){Qe.error("Microphone or Web Worker not available");return}const S=++r.current;n({type:"LISTEN"}),kt.setState({externalRecording:!0});const T=()=>{l.current===j&&(l.current=null),kt.setState({externalRecording:!1})},j=SC({onFinal:N=>{if(r.current!==S)return;j.stop().catch(()=>{}),j.destroy(),T();const L=N.trim();if(!L){n({type:"CANCEL"});return}n({type:"HEARD",transcript:L})},onError:N=>{r.current===S&&(j.destroy(),T(),Qe.error(`Microphone error: ${N}`),n({type:"CANCEL"}))},onModelStatus:(N,L)=>{r.current===S&&n({type:"MODEL_STATUS",status:N,message:L})},onProgress:N=>{r.current===S&&n({type:"MODEL_STATUS",status:"loading",message:`${N}%`})}});l.current=j,j.start().catch(N=>{r.current===S&&(j.destroy(),T(),Qe.error(`Could not start mic: ${N instanceof Error?N.message:String(N)}`),n({type:"CANCEL"}))})},[t.phase]),y=z.useCallback(()=>{const S=LM(i,Ct.getState().tabs);if(!S)return null;const T=zM(S,Ct.getState().tabs,fv.getState().tabs);return!T||vi.getState().get(T.id).running?null:T},[i]),D=z.useCallback((S,T,j,N,L,R)=>{const F=`docedit-${Date.now()}-${Math.random().toString(36).slice(2)}`;return new Promise(V=>{a.current.set(F,V),window.api.docEdit.runInSession({tabId:S,sessionId:T,cwd:j,before:N,instruction:L,documentText:R,requestId:F})})},[]),E=z.useCallback(async(S,T)=>{const j=t.selection;if(!j)return;const N=++r.current;n({type:"RUN",instruction:S,recordInstruction:T});const L=NM(e);try{const R=y(),F=R?await D(R.id,R.sessionId,R.cwd,j.text,S,L):await window.api.docEdit.run({path:i,before:j.text,instruction:S,documentText:L});if(r.current!==N)return;if(!F.ok){Qe.error(F.error||"Edit failed"),n({type:"RUN_ERR"});return}n({type:"RUN_OK",diff:{before:j.text,after:F.after??""}})}catch(R){if(r.current!==N)return;Qe.error(R instanceof Error?R.message:"Edit failed"),n({type:"RUN_ERR"})}},[i,t.selection,e,y,D]),C=z.useCallback(S=>{E(S,!0)},[E]),b=z.useCallback(()=>{t.phase==="review"&&E(t.transcript,!0)},[E,t.phase,t.transcript]),w=z.useCallback(()=>{const S=t.instruction;S&&E(`${S}
|
|
3034
3034
|
|
|
3035
|
-
(Give a different rewrite than the last one.)`,!1)},[E,t.instruction]),x=z.useCallback(S=>{const T=t.diff;if(!T)return{ok:!1,reason:"not-found"};const j=jM(S,T.before,T.after);return j.ok?(r.current+=1,n({type:"ACCEPT"})):Qe.error(j.reason==="ambiguous"?"That text appears more than once — edit it manually instead.":"That text no longer matches the document — edit it manually instead."),j},[t.diff]);return{state:t,select:f,cancel:m,listen:g,sendHeard:b,run:C,retry:w,accept:x}}async function Ca(i){try{const e=await window.api.clipboard.writeText(i);return(e==null?void 0:e.ok)===!0}catch{return!1}}const FM=[{label:"Make concise",instruction:"Rewrite this text to be concise and specific. Preserve meaning and any markdown structure."},{label:"To bullet list",instruction:"Convert this text into a tight markdown bullet list."},{label:"Fix the tone",instruction:"Fix the tone: direct, professional, no hedging. Preserve meaning."}],bS=320,Tf=8;function HM(){return c.jsxs("span",{className:"inline-flex items-center gap-0.5","aria-hidden":"true",children:[c.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:0ms]"}),c.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:150ms]"}),c.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:300ms]"})]})}function WM(i){const e=typeof window<"u"?window.innerWidth:1024,t=Math.min(Math.max(i.left,Tf),Math.max(Tf,e-bS-Tf)),n=Math.max(i.top-Tf,Tf);return{position:"fixed",left:t,top:n,width:bS,transform:"translateY(-100%)",zIndex:W2.dialog}}function UM({phase:i,rect:e,selectedText:t,diff:n,transcript:r,modelStatus:l,onQuickAction:p,onRunCustom:a,onListen:d,onSendHeard:f,onCancel:m,onAccept:g,onReject:y,onRetry:D}){const[E,C]=z.useState(""),[b,w]=z.useState(!1),x=Is(N=>N.show),S=z.useRef(null);z.useEffect(()=>()=>{S.current&&clearTimeout(S.current)},[]);const T=async()=>{if(!await Ca(t)){x("error","Copy failed");return}w(!0),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>w(!1),1500)},j=()=>{const N=E.trim();N&&(a(N),C(""))};return c.jsxs("div",{"data-doc-edit-popover":!0,style:WM(e),className:"rounded-lg border border-line bg-bg-elev shadow-2xl text-xs text-fg",children:[i==="popover"&&c.jsxs("div",{className:"p-2",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsxs("div",{className:"flex flex-wrap gap-1",children:[c.jsx("button",{onClick:T,"data-testid":"doc-edit-copy",className:"px-2 py-1 text-[11px] rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",title:"Copy the selected text",children:b?"Copied":"Copy"}),c.jsx("button",{onClick:d,"data-testid":"doc-edit-voice",className:"px-2 py-1 text-[11px] rounded border border-line bg-bg-hi text-fg hover:border-fg-faint font-medium",title:"Speak your edit instruction",children:"🎤 Voice edit"}),FM.map(N=>c.jsx("button",{onClick:()=>p(N.instruction),className:"px-2 py-1 text-[11px] rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:N.label},N.label))]}),c.jsx("button",{onClick:m,className:"ml-2 shrink-0 text-fg-faint hover:text-fg",title:"Dismiss","aria-label":"Dismiss",children:"×"})]}),c.jsx("input",{value:E,onChange:N=>C(N.target.value),onKeyDown:N=>{N.key==="Enter"?j():N.key==="Escape"&&m()},placeholder:"tell Claude what to change…",className:"w-full px-2 py-1 text-[11px] bg-bg border border-line rounded outline-none focus:border-fg-faint text-fg placeholder:text-fg-faint"})]}),i==="listening"&&c.jsxs("div",{className:"p-3 flex items-center justify-between","data-testid":"doc-edit-listening",children:[c.jsxs("span",{className:"flex flex-col gap-0.5 text-fg-dim",children:[c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(HM,{}),"Listening…"]}),l&&c.jsx("span",{className:"text-[10px] text-fg-faint",children:l})]}),c.jsx("button",{onClick:m,className:"px-2 py-0.5 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"})]}),i==="review"&&c.jsxs("div",{className:"p-3","data-testid":"doc-edit-review",children:[c.jsxs("p",{className:"italic text-fg mb-2",children:["«",r,"»"]}),c.jsxs("div",{className:"flex justify-end gap-1.5",children:[c.jsx("button",{onClick:m,className:"px-2 py-1 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"}),c.jsx("button",{onClick:d,className:"px-2 py-1 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Re-record"}),c.jsx("button",{onClick:f,className:"px-2 py-1 text-[11px] text-white rounded bg-accent hover:opacity-90",children:"Send"})]})]}),i==="thinking"&&c.jsxs("div",{className:"p-3 flex items-center justify-between",children:[c.jsx("span",{className:"text-fg-dim animate-pulse",children:"Claude is editing…"}),c.jsx("button",{onClick:m,className:"px-2 py-0.5 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"})]}),i==="diff"&&n&&c.jsxs("div",{className:"p-3",children:[c.jsxs("div",{className:"mb-2 max-h-40 overflow-auto space-y-1",children:[c.jsx("div",{className:"text-red-400 line-through whitespace-pre-wrap",children:n.before}),c.jsx("div",{className:"text-green-400 whitespace-pre-wrap",children:n.after})]}),c.jsxs("div",{className:"flex justify-end gap-1.5",children:[c.jsx("button",{onClick:y,className:"px-2 py-1 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Reject"}),c.jsx("button",{onClick:D,className:"px-2 py-1 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Retry"}),c.jsx("button",{onClick:g,className:"px-2 py-1 text-[11px] text-white rounded bg-green-600 hover:bg-green-500",children:"Accept"})]})]})]})}function VM(){return c.jsxs("span",{className:"inline-flex items-center gap-0.5","aria-hidden":"true",children:[c.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:0ms]"}),c.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:150ms]"}),c.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:300ms]"})]})}function wS({phase:i,transcript:e,diff:t,editCount:n,modelStatus:r,onListen:l,onSendHeard:p,onCancel:a,onAccept:d,onReject:f,onRetry:m}){return c.jsxs("div",{"data-testid":"assistant-rail",className:"w-[300px] shrink-0 border-l border-line bg-bg-elev flex flex-col text-xs",children:[c.jsxs("div",{className:"flex items-center justify-between px-3 h-8 border-b border-line shrink-0",children:[c.jsx("span",{className:"font-medium text-fg",children:"Assistant"}),c.jsx("span",{className:"text-[10px] text-fg-faint",title:"Model used for Document Experience edits",children:tm(BM)})]}),c.jsxs("div",{className:"flex-1 min-h-0 overflow-auto p-3",children:[i==="idle"&&c.jsxs("div",{className:"text-fg-faint",children:[c.jsx("p",{children:"Select text in the doc…"}),c.jsxs("p",{className:"mt-2 text-[10px]",children:[n," edit",n===1?"":"s"," this session"]})]}),i==="popover"&&c.jsx("p",{className:"text-fg-faint",children:"Choose a quick action or speak an instruction from the popover."}),i==="listening"&&c.jsxs("div",{children:[c.jsxs("p",{className:"flex items-center gap-2 text-fg-dim mb-1",children:[c.jsx(VM,{}),"Listening…"]}),r&&c.jsx("p",{className:"text-[10px] text-fg-faint mb-3",children:r}),c.jsx("button",{onClick:a,className:"px-2 py-0.5 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"})]}),i==="review"&&c.jsxs("div",{children:[c.jsxs("p",{className:"italic text-fg mb-3",children:["«",e,"»"]}),c.jsxs("div",{className:"flex gap-1.5",children:[c.jsx("button",{onClick:a,className:"px-2 py-1 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"}),c.jsx("button",{onClick:l,className:"px-2 py-1 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Re-record"}),c.jsx("button",{onClick:p,className:"px-2 py-1 text-[11px] text-white rounded bg-accent hover:opacity-90",children:"Send"})]})]}),i==="thinking"&&c.jsx("p",{className:"text-fg-dim animate-pulse",children:"Claude is editing…"}),i==="diff"&&t&&c.jsxs("div",{children:[c.jsxs("div",{className:"mb-3 space-y-2",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-[10px] uppercase tracking-wide text-fg-faint mb-1",children:"Before"}),c.jsx("div",{className:"text-red-400 line-through whitespace-pre-wrap",children:t.before})]}),c.jsxs("div",{children:[c.jsx("div",{className:"text-[10px] uppercase tracking-wide text-fg-faint mb-1",children:"After"}),c.jsx("div",{className:"text-green-400 whitespace-pre-wrap",children:t.after})]})]}),c.jsxs("div",{className:"flex gap-1.5",children:[c.jsx("button",{onClick:f,className:"px-2 py-1 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Reject"}),c.jsx("button",{onClick:m,className:"px-2 py-1 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Retry"}),c.jsx("button",{onClick:d,className:"px-2 py-1 text-[11px] text-white rounded bg-green-600 hover:bg-green-500",children:"Accept"})]})]})]})]})}function qM(){const i=Ct(t=>t.tabs),e=Ct(t=>t.activeTabId);return i.find(t=>t.id===e)??null}function KM({path:i,onRenamed:e,onDeleted:t}){const[n,r]=z.useState(!1),[l,p]=z.useState(!1),[a,d]=z.useState(""),[f,m]=z.useState(!1),g=Ci(V=>V.buffers[i]),y=Ci(V=>V.openFile),D=Ci(V=>V.renameOpenFile),E=Ci(V=>V.closeFile),C=qM(),b=ba(i),w=()=>r(!1),x=()=>{d(b),p(!0),w()},S=async()=>{const V=a.trim();if(!V||V===b){p(!1);return}try{const te=await window.api.files.rename(i,V);if(te.ok){const he=i.slice(0,i.lastIndexOf("/")),ee=te.newPath??`${he}/${V}`;D(i,ee),e==null||e(i,ee),Qe.info(`Renamed to ${V}`)}else Qe.error(te.error??`Couldn't rename ${b}`)}catch(te){Qe.error(te instanceof Error?te.message:`Couldn't rename ${b}`)}p(!1)},T=async()=>{w();try{const V=await window.api.files.duplicate(i);V.ok&&V.path?(y(V.path),Qe.info(`Duplicated as ${ba(V.path)}`)):Qe.error(V.error??`Couldn't duplicate ${b}`)}catch(V){Qe.error(V instanceof Error?V.message:`Couldn't duplicate ${b}`)}},j=async()=>{try{const V=await window.api.files.delete(i);V.ok?(E(i),t==null||t(i),Qe.info(`Deleted ${b}`)):Qe.error(V.error??`Couldn't delete ${b}`)}catch(V){Qe.error(V instanceof Error?V.message:`Couldn't delete ${b}`)}m(!1)},N=async()=>{w();const V=g??"";await Ca(V)?Qe.info(`Copied ${V.length} chars`):Qe.error(`Couldn't copy ${b}`)},L=()=>{if(w(),!C){Qe.error("No terminal tab is active");return}window.api.pty.write({tabId:C.id,data:`@${i} `}),Qe.info(`Added ${b} to Claude context`)},R=()=>{w(),window.api.shell.open({as:"openPath",path:i}).then(V=>{V.ok||Qe.error(V.error??`Couldn't open ${b}`)}).catch(V=>Qe.error(V instanceof Error?V.message:`Couldn't open ${b}`))},F=()=>{w(),window.api.shell.open({as:"revealPath",path:i}).then(V=>{V.ok||Qe.error(V.error??`Couldn't reveal ${b}`)}).catch(V=>Qe.error(V instanceof Error?V.message:`Couldn't reveal ${b}`))};return c.jsxs("div",{className:"relative inline-block mr-1",children:[c.jsx("button",{onClick:()=>r(V=>!V),className:`px-2 py-0.5 text-[10px] border border-line rounded ${n?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Document actions",children:"Document ▾"}),n&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:`fixed inset-0 ${dn.contextMenuScrim}`,onMouseDown:w}),c.jsxs("div",{className:`absolute right-0 top-full mt-1 ${dn.contextMenu} w-56 rounded-lg border border-line bg-bg-elev shadow-xl text-xs py-1`,children:[c.jsx(Q_,{children:"Edit"}),c.jsx(dd,{label:"Rename",onClick:x}),c.jsx(dd,{label:"Duplicate",onClick:T}),c.jsx(dd,{label:"Delete document",danger:!0,onClick:()=>{w(),m(!0)}}),c.jsx(yS,{}),c.jsx(Q_,{children:"Open"}),c.jsx(dd,{label:"Open in default app",onClick:R}),c.jsx(dd,{label:"Reveal in OS",onClick:F}),c.jsx(yS,{}),c.jsx(Q_,{children:"Export"}),c.jsx(dd,{label:"Copy as Markdown",onClick:N}),c.jsx(dd,{label:"Add to Claude context",onClick:L,disabled:!C,title:C?void 0:"No terminal tab is active"})]})]}),l&&c.jsx(YM,{value:a,onChange:d,onCancel:()=>p(!1),onConfirm:()=>void S()}),f&&c.jsx(XM,{name:b,onCancel:()=>m(!1),onConfirm:()=>void j()})]})}function Q_({children:i}){return c.jsx("div",{className:"px-3 pt-1 pb-0.5 text-[9px] uppercase tracking-wide text-fg-faint",children:i})}function dd({label:i,onClick:e,danger:t,disabled:n,title:r}){return c.jsx("button",{onClick:e,disabled:n,title:r,className:`w-full text-left px-3 py-1.5 transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${t?"text-red-400 hover:bg-bg-hi":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:i})}function yS(){return c.jsx("div",{className:"my-1 border-t border-line"})}function YM({value:i,onChange:e,onCancel:t,onConfirm:n}){return c.jsx("div",{className:`fixed inset-0 ${dn.contextMenuDialog} flex items-center justify-center bg-black/60`,onMouseDown:r=>{r.target===r.currentTarget&&t()},children:c.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[c.jsx("h3",{className:"text-sm font-medium text-fg mb-3",children:"Rename"}),c.jsx("input",{autoFocus:!0,value:i,onChange:r=>e(r.target.value),onKeyDown:r=>{r.key==="Enter"?n():r.key==="Escape"&&t()},className:"w-full px-2 py-1 text-xs bg-bg border border-line rounded text-fg mb-3"}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx("button",{onClick:t,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"}),c.jsx("button",{onClick:n,className:"px-3 py-1 text-xs text-white rounded bg-accent hover:bg-accent/90",children:"Rename"})]})]})})}function XM({name:i,onCancel:e,onConfirm:t}){return c.jsx("div",{className:`fixed inset-0 ${dn.contextMenuDialog} flex items-center justify-center bg-black/60`,onMouseDown:n=>{n.target===n.currentTarget&&e()},children:c.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[c.jsxs("h3",{className:"text-sm font-medium text-fg mb-3",children:["Delete ",i,"? This cannot be undone."]}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx("button",{onClick:e,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"}),c.jsx("button",{onClick:t,className:"px-3 py-1 text-xs text-white rounded bg-red-600 hover:bg-red-500",children:"Delete"})]})]})})}function JM(){const[i,e]=z.useState(!1),t=_d();return c.jsxs("div",{className:"relative inline-block mr-1",children:[c.jsx("button",{onClick:()=>e(n=>!n),className:`px-2 py-0.5 text-[10px] border border-line rounded ${i?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Display preferences",children:"Display"}),i&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:`fixed inset-0 ${dn.contextMenuScrim}`,onMouseDown:()=>e(!1)}),c.jsxs("div",{className:`absolute right-0 top-full mt-1 ${dn.contextMenu} w-60 rounded-lg border border-line bg-bg-elev shadow-xl text-xs p-2 space-y-1.5`,children:[c.jsx(fh,{label:"Text size",children:c.jsxs("div",{className:"flex items-center rounded border border-line overflow-hidden",children:[c.jsx("button",{onClick:()=>t.bumpFontSize(-1),className:"px-1.5 py-0.5 text-[11px] text-fg-faint hover:text-fg",title:"Zoom out",children:"A−"}),c.jsx("span",{className:"px-2 text-[10px] text-fg-dim",children:t.fontSize}),c.jsx("button",{onClick:()=>t.bumpFontSize(1),className:"px-1.5 py-0.5 text-[11px] text-fg-faint hover:text-fg",title:"Zoom in",children:"A+"})]})}),c.jsx(fh,{label:"Word wrap",children:c.jsx(Qg,{on:t.wordWrap,onClick:t.toggleWordWrap})}),c.jsx(fh,{label:"Minimap",children:c.jsx(Qg,{on:t.minimap,onClick:t.toggleMinimap})}),c.jsx(fh,{label:"Theme",children:c.jsx("button",{onClick:()=>t.setTheme(t.theme==="dark"?"paper":"dark"),className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded",title:"Toggle editor theme",children:t.theme==="dark"?"Dark":"Paper"})}),c.jsx(fh,{label:"Autosave",children:c.jsx(Qg,{on:t.autosave,onClick:t.toggleAutosave})}),c.jsx(fh,{label:"Wide measure",children:c.jsx(Qg,{on:t.wideMeasure,onClick:t.toggleWideMeasure})})]})]})]})}function fh({label:i,children:e}){return c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("span",{className:"text-fg-faint",children:i}),e]})}function Qg({on:i,onClick:e}){return c.jsx("button",{onClick:e,className:`px-2 py-0.5 text-[10px] rounded border border-line ${i?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:i?"On":"Off"})}const ZM=z.lazy(()=>fi(()=>import("./TiptapBody-CXCMvRr_.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(i=>({default:i.TiptapBody})));function ev(i,e){if(!e.length)return i;const t=new Set(e),n={};for(const[r,l]of Object.entries(i))t.has(r)||(n[r]=l);return n}function tv(i){return Fk(i)||Hk(i)}function QM(){const i=Uw(),e=Ci(Je=>Je.openFiles),t=Ci(Je=>Je.activeFilePath),n=Ci(Je=>Je.dirty),r=Ci(Je=>Je.viewMode),l=Ci(Je=>Je.buffers),p=Ci(Je=>Je.setActive),a=Ci(Je=>Je.closeFile),d=Ci(Je=>Je.closeOthers),f=Ci(Je=>Je.closeToTheRight),m=Ci(Je=>Je.closeAll),g=Ci(Je=>Je.loadBuffer),y=Ci(Je=>Je.setBuffer),D=Ci(Je=>Je.markSaved),E=Ci(Je=>Je.setViewMode),C=_d(),[b,w]=z.useState({}),[x,S]=z.useState({}),[T,j]=z.useState(null),[N,L]=z.useState(null),[R,F]=z.useState(!1),[V,te]=z.useState(!1),[he,ee]=z.useState(!0),we=z.useRef(null),ce=z.useRef(null),ve=z.useRef(void 0),Ee=z.useRef(null),fe=z.useRef(null),U=GM(t??"",l[t??""]??""),X=z.useCallback(Je=>{we.current=Je},[]),W=z.useCallback(()=>we.current,[]);z.useEffect(()=>{Ij()},[]),z.useEffect(()=>{const Je=t;if(!Je||tv(Je))return;if(Ci.getState().hasBuffer(Je)){w(_t=>_t[Je]==="ready"?_t:{..._t,[Je]:"ready"});return}let Pt=!1;return w(_t=>({..._t,[Je]:"loading"})),window.api.files.read(Je).then(_t=>{Pt||(_t.binary?w(hi=>({...hi,[Je]:{binary:!0,size:_t.size??0,mime:_t.mime??"application/octet-stream",reason:_t.error??"Binary file"}})):_t.ok?(g(Je,_t.text),w(hi=>({...hi,[Je]:"ready"}))):w(hi=>({...hi,[Je]:{error:_t.error??"failed to read"}})))}),()=>{Pt=!0}},[t,g]),z.useEffect(()=>{L(null)},[t]);const Q=z.useCallback(async(Je,Pt=!1)=>{const _t=Ci.getState().buffers[Je];if(_t==null)return;Pt&&F(!0);const hi=await window.api.files.write(Je,_t);hi.ok?(D(Je),S(Se=>({...Se,[Je]:(Se[Je]??0)+1})),Pt||Qe.info(`Saved ${ba(Je)}`)):Qe.error(hi.error??`Couldn't save ${ba(Je)}`),Pt&&F(!1)},[D]);z.useEffect(()=>{if(!C.autosave)return;const Je=t;if(!(!Je||tv(Je)||!n[Je]))return window.clearTimeout(ve.current),ve.current=window.setTimeout(()=>{Q(Je,!0)},1200),()=>window.clearTimeout(ve.current)},[C.autosave,t,n,l,Q]);const oe=z.useCallback(Je=>{Je.length&&(w(Pt=>ev(Pt,Je)),S(Pt=>ev(Pt,Je)))},[]),Ce=z.useCallback((Je,Pt)=>{w(_t=>Je in _t?{...ev(_t,[Je]),[Pt]:_t[Je]}:_t),S(_t=>Je in _t?{...ev(_t,[Je]),[Pt]:_t[Je]}:_t)},[]),Oe=z.useCallback(Je=>{n[Je]?j({kind:"one",path:Je}):(a(Je),oe([Je]))},[n,a,oe]),Xe=z.useCallback(Je=>{e.some(_t=>_t.path!==Je&&n[_t.path])?j({kind:"others",path:Je}):(d(Je),oe(e.filter(_t=>_t.path!==Je).map(_t=>_t.path)))},[e,n,d,oe]),ge=z.useCallback(Je=>{const Pt=e.findIndex(hi=>hi.path===Je);Pt!==-1&&e.slice(Pt+1).some(hi=>n[hi.path])?j({kind:"right",path:Je}):(f(Je),oe(Pt!==-1?e.slice(Pt+1).map(hi=>hi.path):[]))},[e,n,f,oe]);z.useEffect(()=>{const Je=Pt=>{if(i.current)if((Pt.metaKey||Pt.ctrlKey)&&(Pt.key==="s"||Pt.key==="S")){const _t=Ci.getState().activeFilePath;_t&&!tv(_t)&&(Pt.preventDefault(),Q(_t))}else if((Pt.metaKey||Pt.ctrlKey)&&Pt.shiftKey&&(Pt.key==="f"||Pt.key==="F"))Pt.preventDefault(),te(_t=>!_t);else if((Pt.metaKey||Pt.ctrlKey)&&Pt.shiftKey&&(Pt.key==="w"||Pt.key==="W")){const _t=Ci.getState().activeFilePath;_t&&Ci.getState().openFiles.length>1&&(Pt.preventDefault(),Xe(_t))}else Pt.key==="Escape"&&U.state.phase!=="idle"?U.cancel():Pt.key==="Escape"&&V&&te(!1)};return window.addEventListener("keydown",Je),()=>window.removeEventListener("keydown",Je)},[Q,V,Xe,U.state.phase,U.cancel]),z.useEffect(()=>{if(U.state.phase==="idle")return;const Je=Pt=>{var hi,Se;const _t=Pt.target;(hi=fe.current)!=null&&hi.contains(_t)||(Se=Ee.current)!=null&&Se.contains(_t)||U.cancel()};return window.addEventListener("mousedown",Je),()=>window.removeEventListener("mousedown",Je)},[U.state.phase,U.cancel]),z.useEffect(()=>{U.cancel()},[t,U.cancel]);const J=z.useCallback(()=>{e.some(Pt=>n[Pt.path])?j({kind:"all",path:""}):(m(),w({}),S({}))},[e,n,m]),je=()=>{if(T){if(T.kind==="one")a(T.path),oe([T.path]);else if(T.kind==="others"){const Je=e.filter(Pt=>Pt.path!==T.path).map(Pt=>Pt.path);d(T.path),oe(Je)}else if(T.kind==="right"){const Je=e.findIndex(_t=>_t.path===T.path),Pt=Je!==-1?e.slice(Je+1).map(_t=>_t.path):[];f(T.path),oe(Pt)}else m(),w({}),S({});j(null)}};if(e.length===0)return c.jsx("div",{className:"h-full flex items-center justify-center text-fg-faint text-xs",children:c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:"mb-2",children:"no file open"}),c.jsxs("div",{children:["open the ",c.jsx("span",{className:"text-fg-dim",children:"File Explorer"})," tab and click a file to edit it here"]})]})});const de=t,Ie=de?ba(de):"",Pe=de?b[de]:void 0,Ye=de?Vk(de):!1,ft=de?Tj(de):!1,rt=de&&Ye?r[de]??Dj(de):"edit",Nt=!!de&&!tv(de)&&Pe==="ready",mt=Nt,mi=ft?["edit","wysiwyg","preview","split"]:Ye?["edit","preview"]:[],di=de&&c.jsx(iN,{path:de,name:Ie,value:l[de]??"",onChange:Je=>y(de,Je),onSave:()=>void Q(de),onReady:X,onCursor:L}),_i=R?"Saving…":de&&n[de]?C.autosave?"Editing…":"Unsaved":"All changes saved";return c.jsxs("div",{className:"relative flex flex-col h-full bg-bg",children:[!V&&c.jsx(Wj,{openFiles:e,activeFilePath:t,dirty:n,onSelectFile:p,onCloseFile:Oe,onCloseOthers:Xe,onCloseToTheRight:ge,onCloseAll:J}),de&&!V&&c.jsxs("div",{className:"flex items-center px-3 h-8 border-b border-line shrink-0 bg-bg-elev",children:[c.jsx("span",{className:"text-xs font-medium text-fg truncate",children:Ie}),c.jsx("span",{className:"ml-3 text-[10px] text-fg-faint truncate",children:de}),Nt&&c.jsxs("span",{className:"ml-3 text-[10px] text-fg-faint shrink-0",children:["· ",_i]}),nl(de)&&(rt==="preview"||rt==="split")&&c.jsx("button",{onClick:()=>ee(Je=>!Je),className:`ml-3 px-2 py-0.5 text-[10px] border border-line rounded ${he?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle document outline",children:"Outline"}),nl(de)&&(rt==="preview"||rt==="split")&&c.jsx("button",{onClick:C.toggleAssistantRail,className:`ml-1 px-2 py-0.5 text-[10px] border border-line rounded ${C.assistantRail?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle Assistant rail",children:"Assistant"}),mi.length>0&&c.jsx("div",{className:"flex items-center ml-2 rounded border border-line overflow-hidden",children:mi.map(Je=>c.jsx("button",{onClick:()=>E(de,Je),className:`px-2 py-0.5 text-[10px] capitalize transition-colors ${rt===Je?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:Je},Je))}),c.jsx("div",{className:"flex-1"}),c.jsx(KM,{path:de,onRenamed:Ce,onDeleted:Je=>oe([Je])}),Nt&&c.jsx(JM,{}),c.jsx("button",{onClick:()=>te(!0),className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded",title:"Focus mode (Cmd/Ctrl-Shift-F)",children:"Focus"})]}),V&&c.jsx("button",{onClick:()=>te(!1),className:"absolute top-2 right-3 z-10 px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded bg-bg-elev/80",title:"Exit focus mode (Esc)",children:"Exit focus"}),c.jsx("div",{className:"flex-1 min-h-0",children:de?Fk(de)?c.jsx(kM,{path:de,name:Ie}):Hk(de)?c.jsx(EM,{path:de}):Pe&&typeof Pe=="object"&&"binary"in Pe?c.jsx(PM,{path:de,name:Ie,size:Pe.size,mime:Pe.mime,reason:Pe.reason}):Pe&&typeof Pe=="object"&&"error"in Pe?c.jsx("div",{className:"p-6 text-xs text-red-400",children:Pe.error}):Pe!=="ready"?c.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"loading…"}):rt==="wysiwyg"&&nl(de)?c.jsx(z.Suspense,{fallback:c.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading editor…"}),children:c.jsx(ZM,{value:l[de]??"",onChange:Je=>y(de,Je)},de)}):rt==="split"&&nl(de)?c.jsxs("div",{className:"flex h-full",children:[he&&c.jsx(gS,{text:l[de]??"",scrollRef:ce}),c.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-line",children:[c.jsx(mS,{getEditor:W}),c.jsx("div",{className:"flex-1 min-h-0",children:di})]}),c.jsx("div",{ref:Ee,className:"flex-1 min-w-0",children:c.jsx(uw,{ref:ce,text:l[de]??"",flush:!0,wideMeasure:C.wideMeasure,onSelect:U.select,onDismissSelection:U.cancel})}),!V&&C.assistantRail&&c.jsx(wS,{phase:U.state.phase,transcript:U.state.transcript,diff:U.state.diff,editCount:U.state.editCount,modelStatus:U.state.modelStatus,onListen:U.listen,onSendHeard:U.sendHeard,onCancel:U.cancel,onAccept:()=>{const Je=U.accept(l[de]??"");Je.ok&&y(de,Je.next)},onReject:U.cancel,onRetry:U.retry})]}):rt==="preview"&&nl(de)?c.jsxs("div",{className:"flex h-full",children:[he&&c.jsx(gS,{text:l[de]??"",scrollRef:ce}),c.jsx("div",{ref:Ee,className:"flex-1 min-w-0",children:c.jsx(uw,{ref:ce,text:l[de]??"",wideMeasure:C.wideMeasure,onSelect:U.select,onDismissSelection:U.cancel})}),!V&&C.assistantRail&&c.jsx(wS,{phase:U.state.phase,transcript:U.state.transcript,diff:U.state.diff,editCount:U.state.editCount,modelStatus:U.state.modelStatus,onListen:U.listen,onSendHeard:U.sendHeard,onCancel:U.cancel,onAccept:()=>{const Je=U.accept(l[de]??"");Je.ok&&y(de,Je.next)},onReject:U.cancel,onRetry:U.retry})]}):rt==="preview"&&Gk(de)?c.jsx(SM,{path:de,dirty:!!n[de],reloadToken:x[de]??0}):rt==="preview"&&Wk(de)?c.jsx(DM,{path:de,text:l[de]??""}):rt==="preview"&&Uk(de)?c.jsx(IM,{path:de,text:l[de]??""}):nl(de)?c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsx(mS,{getEditor:W}),c.jsx("div",{className:"flex-1 min-h-0",children:di})]}):di:null}),mt&&c.jsx(xM,{text:l[de]??"",cursor:N,language:Ur(de)||void 0}),de&&nl(de)&&(rt==="preview"||rt==="split")&&U.state.phase!=="idle"&&U.state.selection&&c.jsx("div",{ref:fe,children:c.jsx(UM,{phase:U.state.phase,rect:U.state.selection.rect,selectedText:U.state.selection.text,diff:U.state.diff,transcript:U.state.transcript,modelStatus:U.state.modelStatus,onQuickAction:U.run,onRunCustom:U.run,onListen:U.listen,onSendHeard:U.sendHeard,onCancel:U.cancel,onReject:U.cancel,onRetry:U.retry,onAccept:()=>{const Je=U.accept(l[de]??"");Je.ok&&y(de,Je.next)}})}),T&&c.jsx(eO,{message:T.kind==="one"?`Discard unsaved changes to ${ba(T.path)}?`:T.kind==="others"?"Discard unsaved changes in the other open files?":T.kind==="right"?"Discard unsaved changes in the files to the right?":"Discard unsaved changes in all open files?",onCancel:()=>j(null),onConfirm:je})]})}const fw=z.memo(QM);function eO({message:i,onCancel:e,onConfirm:t}){return c.jsx("div",{className:`fixed inset-0 ${dn.contextMenuDialog} flex items-center justify-center bg-black/60`,onMouseDown:n=>{n.target===n.currentTarget&&e()},children:c.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[c.jsx("h3",{className:"text-sm font-medium text-fg mb-3",children:i}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx("button",{onClick:e,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"}),c.jsx("button",{onClick:t,className:"px-3 py-1 text-xs text-white rounded bg-red-600 hover:bg-red-500",children:"Discard"})]})]})})}const tO={sm:"max-w-md",md:"max-w-xl",lg:"max-w-3xl",xl:"max-w-5xl",full:"max-w-[min(96vw,1400px)]"},xS='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function s_({open:i,onClose:e,children:t,title:n,size:r="sm",fillHeight:l=!1,noPadding:p=!1,variant:a="overlay"}){if(a==="page")return i?c.jsxs("div",{className:"h-full w-full flex flex-col bg-bg",children:[n&&c.jsx("h2",{className:`text-base font-medium text-fg ${p?"px-6 pt-6 pb-3":"px-6 pt-4 pb-2"}`,children:n}),c.jsx("div",{className:`flex-1 min-h-0 min-w-0 flex flex-col ${p?"":"p-6 pt-0"}`,children:t})]}):null;const d=z.useRef(null),f=z.useRef(null),m=z.useRef(e);if(m.current=e,z.useEffect(()=>{if(!i)return;f.current=typeof document<"u"?document.activeElement:null;const E=setTimeout(()=>{const b=d.current;if(!b)return;const w=b.querySelector(xS);w?w.focus():b.focus()},0),C=b=>{if(b.key==="Escape"){b.stopPropagation(),m.current();return}if(b.key==="Tab"){const w=d.current;if(!w)return;const x=Array.from(w.querySelectorAll(xS)).filter(N=>!N.hasAttribute("disabled")&&N.tabIndex!==-1);if(x.length===0){b.preventDefault(),w.focus();return}const S=x[0],T=x[x.length-1],j=document.activeElement;b.shiftKey?(j===S||!w.contains(j))&&(b.preventDefault(),T.focus()):(j===T||!w.contains(j))&&(b.preventDefault(),S.focus())}};return document.addEventListener("keydown",C),()=>{clearTimeout(E),document.removeEventListener("keydown",C);const b=f.current;if(b&&b instanceof HTMLElement)try{b.focus()}catch{}f.current=null}},[i]),!i)return null;const g=D=>{D.target===D.currentTarget&&e()},y=c.jsx("div",{className:`fixed inset-0 ${dn.dialog} flex items-center justify-center bg-black/60`,onClick:g,"data-testid":"modal-backdrop",children:c.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","aria-label":n??"Dialog",tabIndex:-1,className:`bg-bg-elev border border-line rounded-lg shadow-xl w-full mx-4 outline-none flex flex-col break-words ${tO[r]} ${l?"max-h-[90vh] h-[90vh]":""} ${p?"":"p-6"}`,"data-testid":"modal-dialog",children:[n?c.jsx("h2",{className:`text-base font-medium text-fg break-words ${p?"px-6 pt-6 pb-3":"mb-3"}`,children:n}):null,l?c.jsx("div",{className:"flex-1 min-h-0 min-w-0 flex flex-col",children:t}):t]})});return typeof document<"u"&&document.body?Th.createPortal(y,document.body):y}class bE extends z.Component{constructor(){super(...arguments);Gi(this,"state",{error:null});Gi(this,"reset",()=>this.setState({error:null}))}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[ErrorBoundary]",t,n)}render(){return this.state.error?this.props.fallback?this.props.fallback(this.state.error,this.reset):c.jsxs("div",{className:"p-6 text-xs",children:[c.jsx("div",{className:"text-red-400 mb-2",children:"something broke in this panel"}),c.jsx("pre",{className:"text-fg-faint whitespace-pre-wrap mb-3",children:this.state.error.message}),c.jsx("button",{onClick:this.reset,className:"px-2 py-0.5 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"retry"})]}):this.props.children}}function iO({open:i,onClose:e,title:t,children:n,variant:r="overlay"}){return c.jsxs(s_,{open:i,onClose:e,size:"xl",fillHeight:!0,noPadding:!0,title:void 0,variant:r,children:[r==="overlay"&&c.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-line shrink-0",children:[c.jsx("h2",{className:"text-xs uppercase tracking-wider text-fg-dim",children:t}),c.jsx("button",{type:"button",onClick:e,"aria-label":"Close",className:"px-2 py-0.5 text-fg-dim hover:text-fg hover:bg-bg-hi rounded text-base leading-none",children:"✕"})]}),c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:c.jsx(bE,{children:n})})]})}function wE(i,e={}){switch(i){case"ready":return e.isRecording?"Stop voice input":"Start voice input (on-device, offline)";case"idle":return"Microphone — speech model not started";case"loading":return`Microphone — loading speech model, ${typeof e.loadingPct=="number"?Math.round(e.loadingPct):0} percent`;case"error":return e.errorMessage?`Microphone — speech model error: ${e.errorMessage}. Activate to retry.`:"Microphone — speech model error. Activate to retry.";case"load-timeout":return"Microphone — model load timed out. Activate to retry.";case"permission-denied":return"Microphone — permission denied. Open OS settings.";case"unsupported":return"Microphone — voice input not supported in this build."}}const SS=i=>Symbol.iterator in i,CS=i=>"entries"in i,kS=(i,e)=>{const t=i instanceof Map?i:new Map(i.entries()),n=e instanceof Map?e:new Map(e.entries());if(t.size!==n.size)return!1;for(const[r,l]of t)if(!n.has(r)||!Object.is(l,n.get(r)))return!1;return!0},nO=(i,e)=>{const t=i[Symbol.iterator](),n=e[Symbol.iterator]();let r=t.next(),l=n.next();for(;!r.done&&!l.done;){if(!Object.is(r.value,l.value))return!1;r=t.next(),l=n.next()}return!!r.done&&!!l.done};function sO(i,e){return Object.is(i,e)?!0:typeof i!="object"||i===null||typeof e!="object"||e===null||Object.getPrototypeOf(i)!==Object.getPrototypeOf(e)?!1:SS(i)&&SS(e)?CS(i)&&CS(e)?kS(i,e):nO(i,e):kS({entries:()=>Object.entries(i)},{entries:()=>Object.entries(e)})}function by(i){const e=Rt.useRef(void 0);return t=>{const n=i(t);return sO(e.current,n)?e.current:e.current=n}}let ES=0;const rO=1e3;function oO(i){const e=performance.now();e-ES<rO||(ES=e,ut.debug("voice","mic.gate.click_rejected",{reason:i}))}function aO(){const i=kt(f=>f.isRecording),e=kt(f=>f.error),t=kt(f=>f.loadingProgress),n=kt(by($v)),r=()=>{const f=kt.getState(),{canRecord:m,reason:g}=$v(f);if(f.isRecording)return f.stopRecording();if(f.wizardArmed&&!f.wizardOpen){f.openWizard();return}if(g==="error"||g==="load-timeout"){f.resetAndRetryModel();return}if(!m)return oO(g);const y=Ct.getState().activeTabId;y&&f.startRecording(y)},l=wE(n.reason,{loadingPct:t,errorMessage:e,isRecording:i}),p=n.reason==="unsupported",a=!n.canRecord,d=n.reason==="loading"?"text-fg-faint animate-pulse cursor-wait":n.reason==="error"||n.reason==="load-timeout"?"text-red-400 cursor-pointer":n.reason==="permission-denied"?"text-amber-400 cursor-pointer":n.reason==="idle"?"text-fg-faint cursor-pointer":n.reason==="unsupported"?"text-fg-faint cursor-not-allowed":i?"text-red-400 ring-2 ring-red-400 animate-pulse":"text-fg-dim hover:text-fg";return c.jsx("button",{onClick:r,disabled:p,"aria-disabled":a,"aria-label":l,title:l,"data-testid":"mic-button","data-state":n.reason,className:`p-1.5 rounded transition-colors ${d}`,children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{x:"9",y:"1",width:"6",height:"12",rx:"3"}),c.jsx("path",{d:"M5 10a7 7 0 0 0 14 0"}),c.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"}),c.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]})})}function lO(){const i=kt(t=>t.ttsEnabled),e=kt(t=>t.toggleTTS);return c.jsxs("button",{onClick:e,title:i?"Read Claude replies aloud: ON":"Read Claude replies aloud: OFF",className:`px-1.5 py-1 rounded transition-colors flex items-center gap-1 ${i?"text-accent":"text-fg-dim hover:text-fg"}`,children:[c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),i?c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),c.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):c.jsxs(c.Fragment,{children:[c.jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),c.jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]}),c.jsx("span",{className:"text-[10px] font-medium tracking-wide",children:"TTS"})]})}function cO(i){return/^monitor of /i.test(i.trim())}function TS(i){return i.replace(/\s*\([^)]*\)\s*$/,"").replace(/\s*#\d+\s*$/,"").replace(/\s+/g," ").trim().toLowerCase()}function DS(i,e,t){if(i){const p=t.find(a=>a.deviceId===i);if(p)return p}if(!e)return null;const n=t.filter(p=>p.label===e);if(n.length===1)return n[0];if(n.length>1)return null;const r=TS(e),l=t.filter(p=>p.label&&TS(p.label)===r);return l.length===1?l[0]:null}async function $S(i){var t;return(t=navigator.mediaDevices)!=null&&t.enumerateDevices?(await navigator.mediaDevices.enumerateDevices()).filter(n=>!(n.kind!=="audioinput"||n.label&&cO(n.label))):[]}const AS=!1;function yE(){const i=kt(f=>f.isRecording);kt(f=>f.startRecording),kt(f=>f.stopRecording);const[e,t]=z.useState([]),[n,r]=z.useState(null),[l,p]=z.useState(null);z.useEffect(()=>{let f=!1;return(async()=>{try{const m=await window.api.voice.getDevicePref();if(f)return;const g=await $S(AS);if(f)return;t(g),p(m.selectedLabel);const y=DS(m.selectedDeviceId,m.selectedLabel,g);y?(r(y.deviceId),m.selectedDeviceId&&y.deviceId!==m.selectedDeviceId&&(ut.info("voice","device-picker rebind-by-label",{fromIdPrefix:m.selectedDeviceId.slice(0,8),toIdPrefix:y.deviceId.slice(0,8)}),await window.api.voice.setDevicePref({selectedDeviceId:y.deviceId,selectedLabel:y.label||m.selectedLabel}).catch(()=>{}))):((m.selectedDeviceId||m.selectedLabel)&&(console.warn("[MicDevicePicker] previously-selected device unavailable; falling back to OS default",{savedLabel:m.selectedLabel,hadId:!!m.selectedDeviceId}),ut.warn("voice","device-picker selected-unavailable",{hadId:!!m.selectedDeviceId})),r(null))}catch(m){ut.warn("voice","device-picker init failed",{error:m instanceof Error?m.message:String(m)})}})(),()=>{f=!0}},[]);const a=z.useCallback(async()=>{try{const f=await $S(AS);if(t(f),n&&!f.some(m=>m.deviceId===n)){const m=DS(null,l,f);m?(r(m.deviceId),await window.api.voice.setDevicePref({selectedDeviceId:m.deviceId,selectedLabel:m.label||l}).catch(()=>{})):r(null)}}catch(f){ut.warn("voice","device-picker refresh failed",{error:f instanceof Error?f.message:String(f)})}},[n,l]);z.useEffect(()=>{const f=()=>{a()};return window.addEventListener("mic-device-change",f),()=>window.removeEventListener("mic-device-change",f)},[a]);const d=async f=>{var D;const m=f.target.value,g=m===""?null:m,y=g?((D=e.find(E=>E.deviceId===g))==null?void 0:D.label)??null:null;r(g),p(y);try{await window.api.voice.setDevicePref({selectedDeviceId:g,selectedLabel:y}),ut.info("voice","device-picker selected",{deviceIdPrefix:g?g.slice(0,8):null})}catch(E){ut.warn("voice","setDevicePref failed",{error:E instanceof Error?E.message:String(E)})}if(i)try{await kt.getState().restartWithDevice()}catch(E){ut.warn("voice","device-picker restart failed",{error:E instanceof Error?E.message:String(E)})}};return c.jsxs("select",{value:n??"",onChange:d,onFocus:()=>{a()},title:"Microphone input device","data-testid":"mic-device-picker",className:"text-[10px] bg-bg border border-line text-fg-dim hover:text-fg rounded px-1.5 py-1 max-w-[8rem] truncate",children:[c.jsx("option",{value:"",children:"Default"}),e.map(f=>c.jsx("option",{value:f.deviceId,children:f.label||`Mic ${f.deviceId.slice(0,6)}`},f.deviceId))]})}function dO(){const i=kt(D=>D.isRecording),e=kt(D=>D.levelMeterEnabled),[t,n]=z.useState(0),[r,l]=z.useState(0),p=z.useRef(0);p.current=r;const[a,d]=z.useState(0),[f,m]=z.useState(!1),g=z.useRef(null);if(z.useEffect(()=>{if(!i||!e){n(0),l(0);return}let D=0,E=!1,C=null,b=null;const w=()=>{if(E)return;const S=b??EC();if(!S){D=requestAnimationFrame(w);return}b!==S&&(b=S,C=new Uint8Array(new ArrayBuffer(S.fftSize)));const T=C;S.getByteTimeDomainData(T);let j=0;for(let F=0;F<T.length;F++){const V=T[F]-128;j+=V*V}const N=Math.sqrt(j/T.length)/128,L=N>0?20*Math.log10(N):-60,R=Math.max(0,Math.min(1,(L+60)/60));l(N),n(R),N>=.95&&(m(!0),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>m(!1),150)),D=requestAnimationFrame(w)};D=requestAnimationFrame(w);const x=setInterval(()=>{E||d(Math.round(p.current*100))},250);return()=>{E=!0,cancelAnimationFrame(D),clearInterval(x),g.current&&(clearTimeout(g.current),g.current=null)}},[i,e]),!i||!e)return null;const y=f?"bg-red-500":r>=.7?"bg-amber-400":"bg-green-500";return c.jsx("div",{role:"meter","aria-label":"Microphone input level","aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,"data-testid":"mic-level-meter",className:`mx-3 mb-2 h-1 rounded bg-bg overflow-hidden ${f?"ring-1 ring-red-500":""}`,children:c.jsx("div",{className:`h-full ${y} transition-[width] duration-75 ease-out`,style:{width:`${t*100}%`}})})}function xE(){const i=kt(f=>f.submitCountdownStartAt),e=kt(f=>f.submitDelayMs),[t,n]=z.useState(()=>performance.now());if(z.useEffect(()=>{if(i===null)return;let f;const m=()=>{n(performance.now()),f=requestAnimationFrame(m)};return f=requestAnimationFrame(m),()=>cancelAnimationFrame(f)},[i]),i===null)return null;const r=t-i,l=Math.max(0,e-r),p=Math.max(0,Math.min(100,l/e*100)),a=l<500,d=kt.getState().cancelSubmit;return c.jsx("div",{className:"px-3 pb-1",onClick:d,title:`Submitting in ${(l/1e3).toFixed(1)}s — click to cancel`,children:c.jsx("div",{className:"h-0.5 w-full bg-bg rounded overflow-hidden cursor-pointer",children:c.jsx("div",{className:`h-full transition-colors ${a?"bg-amber-400":"bg-accent"}`,style:{width:`${p}%`}})})})}function uO({open:i,onClose:e,variant:t="overlay"}){return c.jsx(iO,{open:i,onClose:e,title:"Voice / Microphone",variant:t,children:c.jsxs("div",{className:"p-4 space-y-4",children:[c.jsx(mO,{}),c.jsx(xE,{}),c.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c.jsx(aO,{}),c.jsx(yE,{}),c.jsx(lO,{})]}),c.jsx(hO,{}),c.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[c.jsx("button",{type:"button",onClick:()=>kt.getState().openWizard(),className:"text-xs text-fg-faint hover:text-fg-dim underline","data-testid":"run-mic-check",children:"Run mic check"}),c.jsx(fO,{})]}),c.jsx(dO,{})]})})}function hO(){const i=kt(l=>l.isRecording),[e,t]=z.useState(null);if(z.useEffect(()=>{let l=!1;window.api.voice.getHotkeyConfig().then(a=>{l||t(a)}).catch(()=>{});const p=window.api.voice.onHotkeyConfigChanged(a=>t(a));return()=>{l=!0,p()}},[]),i||!e)return null;const n=e.mode==="hold"?"Hold":"Press",r=pO(e.accelerator);return c.jsxs("div",{className:"text-[11px] text-fg-faint",children:[c.jsxs("span",{children:[n," "]}),c.jsx("kbd",{className:"px-1 py-0.5 rounded border border-line bg-bg font-mono text-fg-dim",children:r}),c.jsx("span",{children:" to record"})]})}function pO(i){const e=typeof navigator<"u"&&/Mac/.test(navigator.platform);return i.replace(/CommandOrControl/g,e?"⌘":"Ctrl").replace(/CmdOrCtrl/g,e?"⌘":"Ctrl").replace(/Command/g,"⌘").replace(/Control/g,"Ctrl").replace(/Option/g,e?"⌥":"Alt").replace(/Shift/g,e?"⇧":"Shift")}function fO(){const[i,e]=z.useState(null);if(z.useEffect(()=>{let n=!1;window.api.voice.getHotkeyConfig().then(l=>{n||e(l)}).catch(l=>ut.warn("voice-hotkey","getHotkeyConfig (toggle) failed",{error:String(l)}));const r=window.api.voice.onHotkeyConfigChanged(l=>{e(l)});return()=>{n=!0,r()}},[]),!i)return null;const t=async n=>{if(i.mode===n)return;const r={...i,mode:n};e(r);try{await window.api.voice.setHotkeyConfig(r)}catch(l){ut.warn("voice-hotkey","setHotkeyConfig (toggle) failed",{error:l instanceof Error?l.message:String(l)})}};return c.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-fg-faint select-none",title:"Mic hotkey behavior. Tap on/off: press once to start, again to stop. Hold to talk: record only while held (push-to-talk).",children:[c.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[c.jsx("input",{type:"radio",name:"hotkey-mode",checked:i.mode==="toggle",onChange:()=>t("toggle"),className:"cursor-pointer","data-testid":"hotkey-mode-toggle"}),c.jsx("span",{children:"Tap on/off"})]}),c.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[c.jsx("input",{type:"radio",name:"hotkey-mode",checked:i.mode==="hold",onChange:()=>t("hold"),className:"cursor-pointer","data-testid":"hotkey-mode-hold"}),c.jsx("span",{children:"Hold to talk"})]})]})}function mO(){const i=kt(l=>l.isRecording),e=kt(l=>l.lastTranscript),t=kt(l=>l.error),n=kt(l=>l.modelStatus),r=kt(l=>l.loadingProgress);return t?c.jsxs("div",{className:"text-[11px] text-red-400",title:t,children:["⚠ ",t]}):i?c.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-fg-dim border border-line rounded px-2 py-1.5",children:[c.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-red-400 animate-pulse shrink-0"}),c.jsx("span",{className:"truncate",title:e,children:e||"Listening…"})]}):n==="loading"?c.jsxs("div",{className:"text-[11px] text-fg-faint",children:[c.jsxs("div",{className:"flex items-center justify-between mb-1",children:[c.jsx("span",{children:"Loading speech model"}),c.jsxs("span",{className:"font-mono",children:[r,"%"]})]}),c.jsx("div",{className:"h-1 rounded bg-bg overflow-hidden",children:c.jsx("div",{className:"h-full bg-accent transition-[width] duration-200",style:{width:`${r}%`}})})]}):null}const SE="~/.claude/session-manager/projects-prefs.json";let IS=Promise.resolve(),iv=null;function PS(i){const e=IS.then(i);return IS=e.catch(()=>{}),e}async function jS(){const i=await window.api.config.readJson(SE);if(i.exists&&i.data&&typeof i.data=="object"){const e=i.data.pinned;if(e&&typeof e=="object")return{...e}}return{}}const eb=jn(i=>({pinned:{},hydrated:!1,hydrate:()=>iv||(iv=PS(async()=>{try{i({pinned:await jS(),hydrated:!0})}catch(e){console.warn("projectsPrefs: could not read launcher pins",e),i({hydrated:!0})}}),iv),togglePin:e=>{PS(async()=>{let t;try{t=await jS()}catch(r){console.warn("projectsPrefs: could not read launcher pins",r),Qe.error("Could not update pinned projects: the preferences file is unreadable.");return}const n={...t};n[e]?delete n[e]:n[e]=!0;try{await window.api.config.writeJson(SE,{pinned:n}),i({pinned:n})}catch(r){i({pinned:t}),Qe.error(`Could not save pinned projects: ${r instanceof Error?r.message:String(r)}`)}})}}));function gO(i){const e=i.replace(/\/{2,}/g,"/");return e.length>1?e.replace(/\/+$/,""):e}function vO(i,e,t){const n=z.useRef(e);n.current=e;const r=Array.from(new Set(i.filter(p=>!!p).map(gO))),l=r.slice().sort().join("\0")+`${(t==null?void 0:t.depth)??""}`;z.useEffect(()=>{if(r.length===0)return;window.api.config.watch(r,t);const p=window.api.config.onChanged(a=>{r.includes(a.path)&&n.current(a.path)});return()=>{p(),window.api.config.unwatch(r,t)}},[l])}async function _O(i){const e=await vm(i);return Array.isArray(e.fileTreeExpanded)?e.fileTreeExpanded.filter(t=>typeof t=="string"):[]}function bO(i,e){return xd(i,{fileTreeExpanded:[...e].slice(0,500)})}async function wO(){const i=await Eh();return typeof i.fileTreeShowHidden=="boolean"?i.fileTreeShowHidden:!0}function yO(i){um({fileTreeShowHidden:i}).catch(()=>{})}function tb(i,e){const t=e+"/";let n=!1;const r=new Set;for(const l of i){if(l===e||l.startsWith(t)){n=!0;continue}r.add(l)}return n?r:i}const ib={modified:{color:"#e2a93d",label:"M"},added:{color:"#3fb950",label:"A"},deleted:{color:"#f85149",label:"D"},renamed:{color:"#a371f7",label:"R"},untracked:{color:"#8b949e",label:"U"},staged:{color:"#3fb950",label:"S"},conflict:{color:"#f85149",label:"!"}},xO=new Set(["md","txt","json","jsonl","ndjson","js","jsx","ts","tsx","py","go","rs","rb","c","cpp","h","hpp","java","sh","bash","css","scss","html","xml","yaml","yml","toml","ini","conf","env","log","sql","gitignore","csv","tsv"]);function SO(i){const e=Ur(i);return xO.has(e)||Bk.has(e)||e==="pdf"}function CO(i,e){if(e)return"#d97757";switch(Ur(i)){case"ts":case"tsx":return"#3178c6";case"js":case"jsx":return"#f7df1e";case"json":return"#cbcb41";case"md":return"#8a93a0";case"css":case"scss":return"#cc6699";case"py":return"#3776ab";case"go":return"#00add8";case"rs":return"#dea584";case"sh":case"bash":return"#89e051";case"png":case"jpg":case"jpeg":case"gif":case"svg":return"#a4c639";default:return"#8a93a0"}}async function Df(i){try{return await window.api.git.fileStatus(i)}catch{return{}}}const RS=64,kO=250,EO={depth:0};function nb(i){const e=i.replace(/\/{2,}/g,"/");return e.length>1?e.replace(/\/+$/,""):e}function TO({cwd:i,onPreviewFile:e,onSendToChat:t,activeTabId:n}){const r=Uw(),l=Yv(),[p,a]=z.useState([]),[d,f]=z.useState(new Set),m=z.useRef(d);m.current=d;const g=z.useRef(!1),[y,D]=z.useState(""),[E,C]=z.useState(!0),b=z.useRef(!1);z.useEffect(()=>{let Se=!1;return wO().then(tt=>{!Se&&!b.current&&C(tt)}),()=>{Se=!0}},[]);const w=z.useCallback(Se=>{b.current=!0,C(tt=>{const ht=typeof Se=="function"?Se(tt):Se;return yO(ht),ht})},[]),[x,S]=z.useState(!1),[T,j]=z.useState(null),[N,L]=z.useState({}),[R,F]=z.useState(null),[V,te]=z.useState(null),[he,ee]=z.useState(""),[we,ce]=z.useState(null),[ve,Ee]=z.useState(""),[fe,U]=z.useState(null),X=z.useRef(null),W=z.useRef(null),Q=z.useRef(0),oe=z.useCallback(async()=>{if(!i)return;const Se=++Q.current;S(!0),j(null);const tt=await window.api.files.list(i,E);Q.current===Se&&(tt.ok?a(tt.entries.map(ht=>({...ht}))):(j(tt.error??"failed to list"),a([])),S(!1))},[i,E]),Ce=z.useCallback(async Se=>{const tt=Q.current,ht=new Map;for(const gi of Se){const Jt=gi.split("/").length,oi=ht.get(Jt);oi?oi.push(gi):ht.set(Jt,[gi])}const Et=[];for(const gi of[...ht.keys()].sort((Jt,oi)=>Jt-oi)){const Jt=ht.get(gi),oi=await Promise.all(Jt.map(async Xt=>({p:Xt,result:await window.api.files.list(Xt,E)})));if(Q.current!==tt)return Et;for(const{p:Xt,result:un}of oi)un.ok?a(wt=>vv(wt,Xt,un.entries.map(Ri=>({...Ri})))):Et.push(Xt)}return Et},[E]),Oe=z.useCallback(async Se=>(await oe(),Se.length?Ce(Se):[]),[oe,Ce]);z.useEffect(()=>{D(""),te(null),F(null),ce(null),U(null),L({});let Se=!1;return g.current=!1,(async()=>{const[tt]=await Promise.all([_O(i),oe()]);if(Se)return;if(!g.current){const Et=new Set(tt);m.current=Et,f(Et)}if(!tt.length)return;const ht=await Ce(tt);Se||!ht.length||Ye(Et=>{const gi=new Set;let Jt=!1;for(const oi of Et){if(ht.some(Xt=>oi===Xt||oi.startsWith(Xt+"/"))){Jt=!0;continue}gi.add(oi)}return Jt?gi:Et})})(),Df(i).then(tt=>{Se||L(tt)}),()=>{Se=!0}},[i]);const Xe=z.useRef(!0);z.useEffect(()=>{if(Xe.current){Xe.current=!1;return}Oe([...m.current])},[E]),z.useEffect(()=>{if(!i||!l)return;Df(i).then(L);const Se=window.setInterval(()=>{Df(i).then(L)},5e3);return()=>window.clearInterval(Se)},[i,l]);const ge=z.useMemo(()=>{if(!i)return[];const Se=[...d].filter(tt=>tt!==i);return[i,...Se.slice(-63)]},[i,d]),J=z.useRef(!1);z.useEffect(()=>{!i||d.size+1<=RS||J.current||(J.current=!0,console.warn(`FileTree: watching only ${RS} of ${d.size+1} folders (cap reached)`))},[i,d]);const je=z.useRef(new Map),de=z.useRef(new Set),Ie=z.useRef(!1);Ie.current=V!==null||we!==null;const Pe=z.useRef(()=>{});Pe.current=Se=>{if(!(Se!==nb(i)&&!m.current.has(Se))){if(Ie.current){de.current.add(Se);return}Se===nb(i)?Oe([...m.current]):rt(Se)}},vO(ge,Se=>{if(Se!==nb(i)&&!m.current.has(Se))return;const tt=je.current,ht=tt.get(Se);ht&&clearTimeout(ht),tt.set(Se,setTimeout(()=>{tt.delete(Se),Pe.current(Se)},kO))},EO),z.useEffect(()=>{if(V!==null||we!==null)return;const Se=[...de.current];de.current.clear();for(const tt of Se)Pe.current(tt)},[V,we]),z.useEffect(()=>{const Se=je.current,tt=de.current;return()=>{for(const ht of Se.values())clearTimeout(ht);Se.clear(),tt.clear()}},[i]),z.useEffect(()=>{if(!R)return;const Se=()=>F(null),tt=ht=>{r.current&&ht.key==="Escape"&&F(null)};return window.addEventListener("mousedown",Se),window.addEventListener("keydown",tt),()=>{window.removeEventListener("mousedown",Se),window.removeEventListener("keydown",tt)}},[R]),z.useEffect(()=>{V&&setTimeout(()=>{var Se;return(Se=X.current)==null?void 0:Se.select()},30)},[V]),z.useEffect(()=>{we&&setTimeout(()=>{var Se;return(Se=W.current)==null?void 0:Se.focus()},30)},[we]);const Ye=z.useCallback(Se=>{const tt=m.current,ht=Se(tt);ht!==tt&&(g.current=!0,m.current=ht,f(ht),bO(i,ht).catch(()=>{m.current===ht&&(m.current=tt,f(tt),Qe.error("Couldn't save folder expansion — reverted."))}))},[i]),ft=z.useCallback(async Se=>{if(d.has(Se.path)){Ye(ht=>tb(ht,Se.path));return}if(Ye(ht=>new Set(ht).add(Se.path)),Se.children)return;const tt=await window.api.files.list(Se.path,E);tt.ok&&a(ht=>vv(ht,Se.path,tt.entries.map(Et=>({...Et}))))},[d,E,Ye]),rt=z.useCallback(async Se=>{if(Se===i){await oe();return}const tt=await window.api.files.list(Se,E);tt.ok&&a(ht=>vv(ht,Se,tt.entries.map(Et=>({...Et}))))},[i,oe,E]),Nt=z.useCallback(Se=>{if(Se.isDirectory){ft(Se);return}SO(Se.name)&&e?e(Se.path):window.api.shell.open({as:"openPath",path:Se.path})},[ft,e]),mt=z.useCallback(Se=>{if(t){t(Se);return}if(n){const tt=Se.startsWith(i+"/")?Se.slice(i.length+1):Se;window.api.pty.write({tabId:n,data:`@${tt} `})}},[t,n,i]),mi=z.useCallback((Se,tt)=>{Se.preventDefault(),Se.stopPropagation(),F({x:Se.clientX,y:Se.clientY,node:tt})},[]),di=Se=>{te(Se.path),ee(Se.name)},_i=async()=>{if(!V)return;const Se=he.trim();if(!Se){te(null);return}const tt=await window.api.files.rename(V,Se);if(te(null),tt.ok){const ht=V.slice(0,V.lastIndexOf("/"));Ye(Et=>tb(Et,V)),await rt(ht||i),Df(i).then(L)}else{const ht=tt.error??"rename failed";j(ht),Qe.error(ht)}},Je=async()=>{if(!we)return;const Se=ve.trim();if(!Se){ce(null),Ee("");return}const tt=await window.api.files.create(we.parent,Se,we.kind);if(ce(null),Ee(""),tt.ok)await rt(we.parent),we.kind==="folder"&&Ye(ht=>new Set(ht).add(we.parent));else{const ht=tt.error??"create failed";j(ht),Qe.error(ht)}},Pt=async()=>{if(!fe)return;const Se=await window.api.files.delete(fe.path),tt=fe.path.slice(0,fe.path.lastIndexOf("/"));if(U(null),Se.ok)Ye(ht=>tb(ht,fe.path)),await rt(tt||i),Df(i).then(L);else{const ht=Se.error??"delete failed";j(ht),Qe.error(ht)}},_t=z.useMemo(()=>{if(!y.trim())return p;const Se=y.toLowerCase();return p.filter(tt=>tt.name.toLowerCase().includes(Se))},[p,y]),hi=(i==null?void 0:i.split("/").filter(Boolean).pop())||"project";return c.jsxs("div",{className:"w-full h-full flex flex-col bg-bg-elev text-fg",children:[c.jsxs("div",{className:"p-3 border-b border-line shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2 min-w-0",children:[c.jsx(kE,{size:14,className:"shrink-0 text-accent"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-xs font-medium text-fg truncate",children:hi}),c.jsx("p",{className:"text-[10px] text-fg-faint truncate",title:i,children:i})]}),c.jsx("button",{onClick:oe,className:"p-1 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"Refresh",disabled:x,children:c.jsx(jO,{size:12,className:x?"animate-spin":""})})]}),c.jsx("div",{className:"relative",children:c.jsx("input",{value:y,onChange:Se=>D(Se.target.value),placeholder:"Search files…",className:"w-full px-2 py-1 text-xs bg-bg-hi border border-line rounded text-fg placeholder-fg-faint focus:outline-none focus:border-accent/40"})})]}),c.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-line shrink-0",children:[c.jsx("button",{onClick:()=>ce({parent:i,kind:"file"}),className:"p-1.5 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"New file",children:c.jsx(RO,{size:12})}),c.jsx("button",{onClick:()=>ce({parent:i,kind:"folder"}),className:"p-1.5 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"New folder",children:c.jsx(NO,{size:12})}),c.jsx("div",{className:"flex-1"}),c.jsx("button",{onClick:()=>w(Se=>!Se),className:`p-1.5 rounded transition-colors ${E?"text-accent":"text-fg-faint hover:text-fg"} hover:bg-bg-hi`,title:E?"Hide hidden files":"Show hidden files",children:E?c.jsx(MO,{size:12}):c.jsx(OO,{size:12})})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[T&&c.jsx("div",{className:"px-3 py-2 text-[11px] text-red-400",children:T}),!T&&_t.length===0&&!x&&c.jsx("div",{className:"p-4 text-center text-[11px] text-fg-faint",children:y?"no matches":"empty folder"}),!T&&c.jsx(CE,{nodes:_t,depth:0,expanded:d,gitStatus:N,renaming:V,renameValue:he,renameInputRef:X,onRenameChange:ee,onRenameCommit:_i,onRenameCancel:()=>te(null),onToggleDir:ft,onFileClick:Nt,onSendToChat:mt,onContextMenu:mi})]}),c.jsx("div",{className:"px-3 py-1.5 border-t border-line text-[10px] text-fg-faint shrink-0",children:"Click to preview · Double-click external · Right-click for more"}),R&&c.jsx(DO,{x:R.x,y:R.y,node:R.node,onClose:()=>F(null),onRename:()=>{di(R.node),F(null)},onDelete:()=>{U(R.node),F(null)},onNewFile:()=>{ce({parent:R.node.path,kind:"file"}),F(null)},onNewFolder:()=>{ce({parent:R.node.path,kind:"folder"}),F(null)},onOpenExternal:()=>{window.api.shell.open({as:"openPath",path:R.node.path}),F(null)},onShowInFinder:()=>{window.api.shell.open({as:"revealPath",path:R.node.path}),F(null)},onCopyPath:()=>{const Se=R.node.path;Ca(Se).then(tt=>{tt||Qe.error("Couldn't copy path")}),F(null)},onSendToChat:()=>{mt(R.node.path),F(null)}}),we&&c.jsx(NS,{title:`New ${we.kind}`,subtitle:`in ${$O(we.parent)}`,onCancel:()=>{ce(null),Ee("")},onConfirm:Je,confirmLabel:"Create",confirmDisabled:!ve.trim(),children:c.jsx("input",{ref:W,value:ve,onChange:Se=>Ee(Se.target.value),onKeyDown:Se=>{Se.key==="Enter"&&Je(),Se.key==="Escape"&&(ce(null),Ee(""))},placeholder:we.kind==="file"?"filename.txt":"folder-name",className:"w-full px-3 py-2 rounded bg-bg-hi border border-line text-fg text-sm placeholder-fg-faint focus:outline-none focus:border-accent/50"})}),fe&&c.jsx(NS,{title:`Delete ${fe.isDirectory?"folder":"file"}`,subtitle:null,onCancel:()=>U(null),onConfirm:Pt,confirmLabel:"Delete",danger:!0,children:c.jsxs("p",{className:"text-sm text-fg-dim",children:["Move ",c.jsxs("span",{className:"text-fg font-medium",children:['"',fe.name,'"']})," to the trash?",fe.isDirectory&&c.jsx("span",{className:"block text-xs text-fg-faint mt-1",children:"All contents will be moved with it."})]})})]})}function CE(i){const{nodes:e,depth:t,expanded:n,gitStatus:r,renaming:l,onContextMenu:p}=i;return c.jsx(c.Fragment,{children:e.map(a=>{const d=n.has(a.path),f=l===a.path,m=r[a.path],g=CO(a.name,a.isDirectory);return c.jsxs("div",{children:[c.jsxs("div",{className:"group flex items-center gap-1.5 py-0.5 pr-2 cursor-pointer transition-colors hover:bg-bg-hi",style:{paddingLeft:`${8+t*14}px`},onClick:()=>{f||(a.isDirectory?i.onToggleDir(a):i.onFileClick(a))},onDoubleClick:()=>{a.isDirectory||window.api.shell.open({as:"openPath",path:a.path})},onContextMenu:y=>p(y,a),children:[a.isDirectory?c.jsx(PO,{size:10,className:`shrink-0 text-fg-faint transition-transform ${d?"rotate-90":""}`}):c.jsx("span",{className:"w-[10px] shrink-0"}),a.isDirectory?d?c.jsx(AO,{size:12,color:g}):c.jsx(kE,{size:12,color:g}):c.jsx(IO,{size:12,color:g}),f?c.jsx("input",{ref:i.renameInputRef,value:i.renameValue,onChange:y=>i.onRenameChange(y.target.value),onClick:y=>y.stopPropagation(),onBlur:i.onRenameCommit,onKeyDown:y=>{y.key==="Enter"&&i.onRenameCommit(),y.key==="Escape"&&i.onRenameCancel()},className:"flex-1 min-w-0 px-1 py-0 text-xs bg-bg border border-accent/40 rounded text-fg focus:outline-none"}):c.jsx("span",{className:`flex-1 truncate text-xs ${a.name.startsWith(".")?"text-fg-faint":"text-fg-dim"}`,children:a.name}),m&&c.jsx("span",{className:"shrink-0 text-[9px] font-bold px-1 rounded",style:{color:ib[m].color,backgroundColor:`${ib[m].color}20`},title:m,children:ib[m].label}),!a.isDirectory&&c.jsx("button",{onClick:y=>{y.stopPropagation(),i.onSendToChat(a.path)},title:"Send @path to active terminal",className:"opacity-0 group-hover:opacity-100 p-0.5 rounded text-fg-faint hover:text-accent hover:bg-bg transition-all shrink-0",children:c.jsx(LO,{size:10})})]}),a.isDirectory&&d&&a.children&&c.jsx(CE,{...i,nodes:a.children,depth:t+1})]},a.path)})})}function DO(i){const{x:e,y:t,node:n}=i;return c.jsxs("div",{onMouseDown:r=>r.stopPropagation(),className:`fixed ${dn.contextMenu} w-56 rounded-lg border border-line bg-bg-elev shadow-xl text-xs py-1`,style:{left:e,top:t},children:[!n.isDirectory&&c.jsx(Kl,{label:"Send to chat",onClick:i.onSendToChat}),c.jsx(Kl,{label:"Open in default app",onClick:i.onOpenExternal}),c.jsx(Kl,{label:"Reveal in OS",onClick:i.onShowInFinder}),c.jsx(sb,{}),c.jsx(Kl,{label:"Copy path",onClick:i.onCopyPath}),c.jsx(Kl,{label:"Rename",onClick:i.onRename}),n.isDirectory&&c.jsxs(c.Fragment,{children:[c.jsx(sb,{}),c.jsx(Kl,{label:"New file",onClick:i.onNewFile}),c.jsx(Kl,{label:"New folder",onClick:i.onNewFolder})]}),c.jsx(sb,{}),c.jsx(Kl,{label:"Delete",onClick:i.onDelete,danger:!0})]})}function Kl({label:i,onClick:e,danger:t}){return c.jsx("button",{onClick:e,className:`w-full text-left px-3 py-1.5 hover:bg-bg-hi transition-colors ${t?"text-red-400":"text-fg-dim hover:text-fg"}`,children:i})}function sb(){return c.jsx("div",{className:"my-1 border-t border-line"})}function NS(i){return c.jsx("div",{className:`fixed inset-0 ${dn.contextMenuDialog} flex items-center justify-center bg-black/60`,onMouseDown:e=>{e.target===e.currentTarget&&i.onCancel()},children:c.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[c.jsx("h3",{className:"text-sm font-medium text-fg mb-1",children:i.title}),i.subtitle&&c.jsx("p",{className:"text-[11px] text-fg-faint mb-3 truncate",children:i.subtitle}),c.jsx("div",{className:"mb-4",children:i.children}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx("button",{onClick:i.onCancel,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded transition-colors",children:"Cancel"}),c.jsx("button",{onClick:i.onConfirm,disabled:!!i.confirmDisabled,className:`px-3 py-1 text-xs text-white rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${i.danger?"bg-red-600 hover:bg-red-500":"bg-accent hover:bg-accent/90"}`,children:i.confirmLabel??"OK"})]})]})})}function $O(i){return i.split("/").filter(Boolean).pop()||i}function vv(i,e,t){return i.map(n=>n.path===e?{...n,children:t}:n.children?{...n,children:vv(n.children,e,t)}:n)}function Ea({size:i,children:e,className:t,color:n}){return c.jsx("svg",{width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,children:e})}function kE({size:i,className:e,color:t}){return c.jsx(Ea,{size:i,className:e,color:t,children:c.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function AO({size:i,className:e,color:t}){return c.jsx(Ea,{size:i,className:e,color:t,children:c.jsx("path",{d:"M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2"})})}function IO({size:i,className:e,color:t}){return c.jsxs(Ea,{size:i,className:e,color:t,children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function PO({size:i,className:e}){return c.jsx(Ea,{size:i,className:e,children:c.jsx("polyline",{points:"9 18 15 12 9 6"})})}function jO({size:i,className:e}){return c.jsxs(Ea,{size:i,className:e,children:[c.jsx("polyline",{points:"23 4 23 10 17 10"}),c.jsx("polyline",{points:"1 20 1 14 7 14"}),c.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function RO({size:i,className:e}){return c.jsxs(Ea,{size:i,className:e,children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"}),c.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),c.jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]})}function NO({size:i,className:e}){return c.jsxs(Ea,{size:i,className:e,children:[c.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"}),c.jsx("line",{x1:"12",y1:"11",x2:"12",y2:"17"}),c.jsx("line",{x1:"9",y1:"14",x2:"15",y2:"14"})]})}function MO({size:i,className:e}){return c.jsxs(Ea,{size:i,className:e,children:[c.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function OO({size:i,className:e}){return c.jsxs(Ea,{size:i,className:e,children:[c.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"}),c.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function LO({size:i,className:e}){return c.jsxs(Ea,{size:i,className:e,children:[c.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),c.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function EE({content:i,children:e,align:t="bottom-right"}){const[n,r]=z.useState(!1),l=t==="bottom-right"?"top-full mt-1 right-0":"top-full mt-1 left-1/2 -translate-x-1/2";return c.jsxs("span",{className:"relative inline-flex",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>r(!0),onBlur:()=>r(!1),children:[e,n&&c.jsx("span",{role:"tooltip",className:`absolute ${dn.dialog} ${l} px-2 py-1 text-[10px] leading-snug text-fg bg-bg-elev border border-line rounded shadow-lg max-w-[18rem] whitespace-normal pointer-events-none`,children:i})]})}function Xf(i,e){if(!e)return i;const t=e.length>1?e.replace(/\/+$/,""):e;if(i===t)return"~";const n=t.endsWith("/")?t:`${t}/`;return i.startsWith(n)?`~/${i.slice(n.length)}`:i}function rb(i){um(i).catch(()=>Qe.error("Couldn't save File Explorer layout."))}const ob=33,zO=20,BO=60,GO=32;function MS(i){return Math.min(BO,Math.max(zO,i))}function FO(){const i=Ct(te=>te.tabs),e=Ct(te=>te.activeTabId),t=i.find(te=>te.id===e)??null,n=ji(te=>te.navFace),r=e_(),l=n==="home"?r:(t==null?void 0:t.cwd)??null,[p,a]=z.useState(ob),[d,f]=z.useState(!1),m=z.useRef(!1),[g,y]=z.useState(!1),D=z.useRef(p);D.current=p;const E=z.useRef(d);E.current=d;const C=z.useRef(null),b=z.useRef(null),{projects:w,openProject:x,archiveProjectByCwd:S}=Cd(),T=eb(te=>te.pinned),j=eb(te=>te.togglePin);z.useEffect(()=>{eb.getState().hydrate()},[]),z.useEffect(()=>{let te=!1;return Eh().then(he=>{te||m.current||(typeof he.projectsSplitPct=="number"&&Number.isFinite(he.projectsSplitPct)&&a(MS(he.projectsSplitPct)),typeof he.projectsFileTreeCollapsed=="boolean"&&f(he.projectsFileTreeCollapsed))}),()=>{te=!0}},[]);const N=[...w].sort((te,he)=>(T[he.cwd]?1:0)-(T[te.cwd]?1:0));z.useEffect(()=>{if(!g)return;const te=he=>{b.current&&!b.current.contains(he.target)&&y(!1)};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[g]);const L=z.useCallback(te=>{Ci.getState().openFile(te)},[]),R=z.useCallback(te=>{te.preventDefault(),m.current=!0;const he=te.clientX,ee=D.current;let we=ee;const ce=Ee=>{const fe=C.current;if(!fe)return;const U=fe.getBoundingClientRect(),X=Ee.clientX-he;we=MS(ee+X/U.width*100),a(we)},ve=()=>{window.removeEventListener("pointermove",ce),window.removeEventListener("pointerup",ve),document.body.style.cursor="",document.body.style.userSelect="",rb({projectsSplitPct:we})};window.addEventListener("pointermove",ce),window.addEventListener("pointerup",ve),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]),F=z.useCallback(()=>{m.current=!0,a(ob),rb({projectsSplitPct:ob})},[]),V=z.useCallback(()=>{m.current=!0;const te=!E.current;f(te),rb({projectsFileTreeCollapsed:te})},[]);return d?c.jsxs("div",{ref:C,className:"flex h-full w-full","data-testid":"projects-workspace",children:[c.jsxs("button",{onClick:V,"data-testid":"projects-file-tree-rail-toggle",title:"Show file explorer",className:"shrink-0 flex flex-col items-center gap-2 py-2 border-r border-line text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",style:{width:GO},children:[c.jsx("span",{className:"text-[11px]",children:"▸"}),c.jsx("span",{className:"text-[10px] tracking-wide [writing-mode:vertical-rl]",children:"Files"})]}),c.jsx("div",{className:"flex-1 min-w-0","data-testid":"projects-editor-pane",children:c.jsx(fw,{})})]}):c.jsxs("div",{ref:C,className:"flex h-full w-full","data-testid":"projects-workspace",children:[c.jsxs("div",{className:"shrink-0 flex flex-col border-r border-line overflow-hidden",style:{width:`${p}%`},"data-testid":"projects-file-tree-pane",children:[c.jsxs("div",{ref:b,className:"relative shrink-0 flex items-stretch border-b border-line",children:[c.jsxs("button",{"data-testid":"projects-launcher-trigger",onClick:()=>y(te=>!te),className:"flex-1 min-w-0 px-3 py-1.5 text-[11.5px] text-fg-dim font-mono flex items-center gap-1 hover:bg-bg-hi transition-colors",children:[c.jsx("span",{className:"flex-1 truncate text-left",children:l?Xf(l,r):"Projects"}),c.jsx("span",{className:"text-fg-faint shrink-0 text-[10px]",children:g?"▲":"▼"})]}),c.jsx("button",{onClick:V,"data-testid":"projects-file-tree-collapse",title:"Hide file explorer",className:"shrink-0 px-2 border-l border-line text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors text-[11px]",children:"◂"}),g&&c.jsx("div",{"data-testid":"projects-launcher-list",className:`absolute left-0 right-0 top-full ${dn.dialog} bg-bg-elev border border-line shadow-lg max-h-60 overflow-auto`,children:N.length===0?c.jsx("div",{className:"px-3 py-2 text-[11.5px] text-fg-faint",children:"No projects found."}):N.map(te=>{const he=Xf(te.cwd,r);return c.jsxs("div",{"data-testid":"projects-launcher-row",className:"flex items-center gap-1 px-2 py-1 hover:bg-bg-hi group",children:[c.jsx(EE,{content:T[te.cwd]?"Unpin":"Pin to top",children:c.jsx("button",{onClick:()=>j(te.cwd),className:`shrink-0 text-sm leading-none transition-colors ${T[te.cwd]?"text-yellow-400":"text-fg-faint hover:text-fg-dim"}`,children:T[te.cwd]?"★":"☆"})}),c.jsx("button",{onClick:()=>{x(te.cwd),y(!1)},className:"flex-1 min-w-0 text-left text-[11.5px] font-mono truncate text-fg-dim hover:text-fg",children:he}),c.jsx("button",{onClick:async()=>{window.confirm(`Archive ${he}?`)&&await S(te)},className:"shrink-0 text-[10px] text-fg-faint hover:text-red-400 opacity-0 group-hover:opacity-100 transition-opacity",title:"Archive",children:"✕"})]},te.cwd)})})]}),l?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"px-3 py-2 border-b border-line text-[11.5px] text-fg-faint font-mono truncate shrink-0",title:l,children:Xf(l,r)}),c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:c.jsx(TO,{cwd:l,activeTabId:(t==null?void 0:t.id)??null,onPreviewFile:L})})]}):c.jsx("div",{className:"px-3 py-6 text-center text-[12px] text-fg-faint",children:n==="home"?"Loading home folder…":"No session selected."})]}),c.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize panes",title:"Drag to resize · double-click to reset",onPointerDown:R,onDoubleClick:F,className:"w-1.5 shrink-0 cursor-col-resize hover:bg-accent/40 active:bg-accent/60 transition-colors"}),c.jsx("div",{className:"flex-1 min-w-0","data-testid":"projects-editor-pane",children:c.jsx(fw,{})})]})}const HO=z.memo(FO),WO={"project-home":{headline:"The Brief — what this project is, and what is in flight",intro:"Home for a project tab is a synthesized brief: what the project is for, how it is structured, and what is currently in flight across its Epics. Content is scaffolded for now — the synthesis pipeline lands in a later update.",sections:[{title:"What you see",items:[{body:"A header naming the active project, resolved from the active tab's working directory."}]}]},overview:{headline:"Your home base — a calm landing page for your local Claude Code cockpit",intro:"Overview is the first screen you see. It greets you by time of day and frames Session Manager as a local cockpit that wraps the Claude CLI alongside skills, hooks, MCP servers, and a scheduler. Nothing here phones home. The page is a launchpad, not a settings screen: a live 5-hour usage card, a few quick-start buttons, your most-recent sessions, and a peek at what is queued in the scheduler. Click any of them to jump straight into the relevant tab.",sections:[{title:"What you see",items:[{term:"Billing meters",body:"A live read of your subscription usage — plan chip, the current 5-hour rolling window, and the weekly windows — each with percent used, a color bar, and the reset time. Same data the CLI /usage command reads."},{term:"Quick start",body:"Four buttons — Start a session, Resume last (opens History), Draft a PRD (opens Scheduler), and Add a project (opens Projects) — plus a microphone button that opens voice input."},{term:"Recent sessions",body:"Your four most-recently-touched transcripts, scanned from ~/.claude/projects. Each row shows the project, the short session id, the transcript size, and how long ago it was active. Click a row to reopen that session with claude --resume."},{term:"In the scheduler",body:"A peek at the first three jobs in the scheduler queue, each tagged running or queued with a rough time estimate. “Open scheduler →” jumps to the full Scheduler tab."}]},{title:"Behaviors this affects",items:[{body:"Overview is read-only and click-through. It never edits anything; every button just navigates you to the tab that does the work (History, Scheduler, Projects, Voice) or starts a new session."},{body:"The 5-hour countdown refreshes on a timer. If the usage card shows a dash, billing data is not loaded yet (or the Claude login has expired — re-authenticate with the CLI)."}]}]},terminal:{headline:"A real Claude Code CLI running inside the app, kept alive across tab switches",intro:"The Terminal tab is a genuine terminal running the claude CLI for you. It behaves like running claude in your own shell, but Session Manager keeps the process alive when you switch to other tabs, makes file paths and URLs clickable, smooths over copy/paste, and lets you broadcast a prompt to several tabs or attach background watchers. Each tab is one Claude session — the tab id IS the session id, so the tab maps directly to its transcript on disk.",sections:[{title:"In the terminal pane",items:[{term:"Settings gear (top-right)",body:"A small gear opens a popover to change the terminal theme (Dark / Light / Paper) and font size (10–22px, with a reset). Changes apply instantly to every open terminal and persist between launches."},{term:"Clickable file paths",body:"Paths like src/main/index.cjs:42 are detected and underlined. Clicking one opens that file in the in-app editor at the right line. URLs are also clickable and open in your system browser."},{term:"Paste images",body:"Ctrl+V pastes clipboard text as usual, but if the clipboard holds an image it is saved to a temp PNG and its path is typed in — so you can paste a screenshot and let Claude read it."},{term:"Smart Ctrl+C",body:"With text selected, Ctrl+C copies it; with nothing selected, Ctrl+C passes through to interrupt Claude (same as a normal terminal). Ctrl+Shift+C always copies."}]},{title:"Session commands (Command Palette / shortcuts)",items:[{term:"Restart session",body:"Ctrl+Shift+R kills this tab's claude process and spawns a fresh one in the same directory. Use it after editing settings, hooks, or skills so Claude reloads them."},{term:"Reboot app",body:"Relaunches Session Manager; your tabs come back automatically. Use when something feels stuck."},{term:"Broadcast",body:"Ctrl+Shift+B opens a bar to send the same prompt to several tabs at once. You tick which tabs to include; each row shows sent or skipped (a dead session is skipped)."},{term:"Watchers",body:"Ctrl+Shift+W attaches a long-running shell command (e.g. npm test --watch, tail -f log) to this tab. Each new line of its output pops up as a toast. Watchers survive tab switches and stop when you remove them."}]},{title:"Things that are easy to miss",items:[{body:"Open the Command Palette (Cmd-K / Ctrl-K) to reach the session commands above, plus copy-cwd, copy-transcript path, and open-transcript."},{body:"Switching to another tab does NOT kill the terminal — the claude process keeps running in the background and the screen is just hidden."},{body:"Voice input (the microphone in the sidebar) types into whichever terminal tab is focused — there is no separate voice tab."}]}],tips:["Press Ctrl+C with nothing selected to interrupt Claude mid-response — same as the standalone CLI.","If the prompt looks frozen, scroll up: Claude often produced output but the cursor is below the visible window."]},"system-prompt":{headline:"Edit ~/.claude/CLAUDE.md — the house rules every session on this machine starts with",intro:"CLAUDE.md is a plain-text file Claude reads at the start of every session. Whatever you write here is added to its instructions — so it's where you put coding standards, communication preferences, and “always do X / never do Y” rules. This tab edits exactly ONE of them: the User file at ~/.claude/CLAUDE.md, which applies everywhere, in every project. A project can also carry its own <repo>/CLAUDE.md and <repo>/CLAUDE.local.md — those are contextual to that project and are read by the CLI from the session's own directory when it launches there, so they are edited with the project's files, not from this machine-wide screen.",sections:[{title:"Editor / Presets toggle",items:[{term:"Editor",body:"Edit the real ~/.claude/CLAUDE.md. Save writes it to disk; Claude picks it up on its next session start."},{term:"Presets",body:"Browse a library of starter prompts. Use one as a starting point, then refine it in the editor."}]},{title:"What this file reaches — and what it doesn't",items:[{term:"User (edited here)",body:"Lives at ~/.claude/CLAUDE.md. Applies to every session you start, in every repo. Best for personal style: communication tone, default tooling preferences, things you always want."},{term:"Project (not edited here)",body:"Lives at <repo>/CLAUDE.md, checked into git — shared team context: stack, architecture, do/don't lists. It only means anything relative to a project directory, so it is picked up when a session launches in that repo; open it from the project's own files."},{term:"Local (not edited here)",body:"Lives at <repo>/CLAUDE.local.md, gitignored — personal overrides that shouldn't reach teammates. Same story as Project: contextual to one repo, applied at session launch."},{body:"At runtime every file that is present combines; more-specific wins: Local > Project > User. This screen only owns the base layer."}]},{title:"What's shown in the header",items:[{term:"chars / tokens",body:"A rough size estimate (~4 chars per token). The bigger the file, the more of Claude's context window it consumes before your real prompt — keep it tight."},{term:"unsaved edits",body:"Save and Revert live in the bottom bar; navigating away does NOT auto-save."},{body:"If the file doesn't exist yet, the bottom bar notes it will be created on save."}]}],tips:["New users: start with 3–5 bullets here (“be concise”, “use Python type hints”, “always run tests after changes”). That alone changes Claude's behavior noticeably.","Don't write essays. Claude reads CLAUDE.md before every reply, so every word costs tokens. One-line rules beat paragraphs.","Rule of thumb for what belongs here: if it would still be true in a repo you haven't created yet, it is a User rule. If it names this stack, this architecture, or this team, it belongs in that project's own CLAUDE.md."]},settings:{headline:"The settings.json files that control Claude Code's behavior",intro:"Claude Code is configured by JSON files named settings.json. This tab shows up to three of them combined: User (~/.claude/settings.json), Project (<repo>/.claude/settings.json, shared with the repo), and Local (<repo>/.claude/settings.local.json, your private overrides). The Guided view is a friendly card editor; Tree shows the merged values as a JSON tree; Raw lets you hand-edit the file. A bundled schema (from schemastore.org) gives you autocomplete and validation as you type.",sections:[{title:"Views",items:[{term:"Guided",body:"A card-based editor over the merged settings. Each setting shows which scope currently provides it; editing a card writes the change into the scope you've selected."},{term:"Tree",body:"The same merged config as an expandable JSON tree. Useful for nested settings like permissions and hooks; you can override a value into the active scope from here too."},{term:"Raw",body:"The JSON file at the active scope, edited directly. Save validates before writing; a parse error blocks the save and is shown in the bottom bar."},{term:"Telemetry",body:"Opt-in OpenTelemetry export of Session Manager's own classified transcript events (tool names, todo counts, usage tokens). Off by default, stored separately from Claude's settings, and excludes prompt/plan content unless you turn on “Include content”."}]},{title:"Common settings to know",items:[{term:"model",body:"Default model used when you start a session (e.g. “opus”, “sonnet”, “haiku”). Override per-session with /model in the terminal."},{term:"permissions",body:"Allow / Ask / Deny lists for Bash commands, file edits, MCP tools, web fetches. The dedicated Permissions tab is a friendlier UI for this same key."},{term:"hooks",body:"Shell commands the CLI runs in response to events (pre/post tool use, session start, etc.). See the Hooks tab."},{term:"env",body:"Environment variables injected into every claude process — handy for API keys or DEBUG flags."},{term:"mcpServers",body:"External tool servers Claude can call. Edit via the MCP Servers tab for a structured form."}]},{title:"Scope precedence",items:[{body:"Local overrides Project overrides User. A Project-scoped setting beats a User-scoped one when you work in that repo, and your personal Local file beats both. Project and Local require an open project tab — with no working directory, only User is editable."},{body:"Lists merge (allow + allow), but objects do not — a Project-scoped { permissions: { allow: [...] } } REPLACES the user-scoped object wholesale unless you copy the entries you want to keep."}]}],tips:["When in doubt, edit at User scope. Project-scoped settings get committed to git; teammates inherit them.","After changing settings.json, restart any open sessions (Restart session, Ctrl+Shift+R) so Claude reloads."]},permissions:{headline:"Decide which tools Claude can run automatically and which need your OK",intro:"Every action Claude takes — running a Bash command, editing a file, calling an MCP tool — passes a permission check. This tab is a structured editor for the permissions block inside settings.json (there is no separate permissions file). You build three lists — Allow / Deny / Ask — of rules; get them right and you barely see prompts, get them wrong and you're either hammered with confirmations or Claude runs something you didn't want.",sections:[{title:"Views",items:[{term:"Effective",body:"The merged permissions Claude actually sees, as a tree, with which scope each value came from. Read-and-override here."},{term:"Rules",body:"The structured editor: a Default Mode picker, the Allow / Deny / Ask lists (type a rule and press Enter or click add; × to remove), and Additional Directories. Edits write into the scope you've selected."},{term:"Presets",body:"A starter library of common permission sets to copy from."}]},{title:"The three lists",items:[{term:"Allow",body:"Claude runs matching actions silently — no confirmation. Use for safe, repetitive things: Bash(ls:*), Read(~/.claude/**), Edit(src/**)."},{term:"Deny",body:"Claude refuses outright, even if you'd say yes interactively. Use for genuinely dangerous things: Bash(rm -rf:*), Write(/etc/**)."},{term:"Ask",body:"Claude pauses and asks before running. Sits between Allow and Deny for things you want to eyeball each time."}]},{title:"Rule shape",items:[{term:"Tool(pattern)",body:"Format is <ToolName>(<pattern>). Examples: Bash(git push:*), Edit(src/**/*.ts), WebFetch(domain:*.example.com)."},{term:":*",body:"A trailing colon-star means “any arguments”. Bash(npm:*) allows every npm invocation; Bash(npm test) only the literal “npm test”."},{body:"Deny wins ties. If a request matches both Allow and Deny, Deny takes effect. (See the “rule syntax” link in the toolbar for the full grammar.)"}]},{title:"Default Mode",items:[{term:"default",body:"Out-of-the-box behavior: ask for risky operations, allow harmless reads."},{term:"acceptEdits",body:"Auto-approve file edits within the session's working tree. Speeds up iterative coding; avoid for prod repos."},{term:"plan",body:"Read-only mode. Claude can explore and propose, but cannot edit or run shell commands. Good for review sessions."},{term:"bypassPermissions",body:"Skip ALL prompts. Equivalent to --dangerously-skip-permissions. Use only in throwaway sandboxes."}]}],tips:["Start permissive at User scope (your common safe commands), then tighten at Project scope for repos with secrets.","Additional Directories lets Claude read files outside the cwd — add reference repos here as absolute paths instead of cd’ing into each one."]},skills:{headline:"Reusable instructions Claude loads on demand for specific tasks",intro:`A skill is a markdown file that teaches Claude how to do one specific thing — "write Playwright tests", "review SQL migrations", "format an OpenAPI doc". Each skill has frontmatter describing when to trigger it and a body with the actual instructions. Claude doesn't load all skills up front; it scans titles and pulls the body in only when a relevant request arrives, keeping your context tight.`,sections:[{title:"List + Detail",items:[{term:"Scope switch",body:"Toggle User vs Project at the top. User skills live in ~/.claude/skills/ and apply everywhere; Project skills live in <repo>/.claude/skills/ and only when a tab is open in that repo. The toolbar shows the item count and the file path of the selected skill."},{term:"Sidebar",body:"Two groups — Skills and Slash Commands — with a filter box that matches on name. Click an entry to open its markdown in the editor."},{term:"Enable toggle",body:"Each skill has an on/off switch. Turning it off writes disable-model-invocation into the skill's frontmatter, so Claude stops auto-invoking it; the file stays on disk and the name shows struck-through. Slash commands have no toggle."},{term:"Remove (✕)",body:"Deletes a skill's folder to the trash (recoverable). It comes out of your active set entirely — reinstall any time from the Library. This is different from the toggle, which only stops auto-invocation."},{term:"Editor",body:"Standard markdown with a Save/Revert bar at the bottom. The frontmatter (the --- block at the top) controls discovery; the body is what Claude reads when the skill fires."},{term:"Library view",body:'Switch to Library to browse a curated catalog of skills. Each row gives a "source" link and a "copy install" button (a git-clone command you paste into a terminal) — there is no one-click install for skills.'}]},{title:"Skill anatomy",items:[{term:"name",body:"Used in transcripts and the Library. Should be unique within a scope."},{term:"description",body:'Critical — Claude scans descriptions to decide when to load this skill. Be specific about WHEN to use it ("when writing E2E tests with Playwright"), not just what it does.'},{term:"allowed-tools",body:"Optional. Restricts which tools Claude can use while the skill is active. Adds an extra layer of safety on top of permissions."},{term:"Body",body:"Plain markdown. Procedures, code examples, do/don't lists. This is what Claude actually reads."}]},{title:"Slash commands",items:[{body:'Commands (in ~/.claude/commands/ or .claude/commands/) are skills you invoke explicitly with /name — they show with a leading "/" in the sidebar. Skills proper are auto-loaded; commands are user-triggered.'},{body:"This tab lists both at the active scope — same markdown shape on disk, different folders."}]}],tips:["A bad description is worse than no skill — Claude either won't load it when needed, or will load it constantly and waste tokens.","When refining a skill, use Restart Session in the terminal so Claude reloads it."]},plugins:{headline:"Bundled collections of skills, subagents, and hooks that ship together",intro:'A plugin is a directory under ~/.claude/plugins/<name>/ that packages multiple Claude Code primitives (skills, subagents, hooks, MCP servers, LSPs, monitors) under one name. Installing a plugin adds all of them at once; uninstalling removes them cleanly. Use plugins when you want to share a coherent toolkit — "react-frontend-pack", "data-pipeline-helpers" — instead of asking teammates to copy ten files into the right places.',sections:[{title:"Three views",items:[{term:"Installed",body:"A read-only inspector for every plugin folder on disk, shown as a table: name, origin, version, whether it has a manifest, and a contents summary (counts of agents · skills · hooks · monitors · bin · lsp · mcp). Click a row to drill into a full-page view: a header with name/version/description, a meta strip (author, license, homepage, and the full path), and a section index (skills, agents, MCP server, hooks, monitors, LSP, bin) beside the component listing. To edit a plugin's pieces, use the dedicated Skills / Hooks tabs — they point at the same files."},{term:"Discover",body:"A built-in list of official add-ons (LSP servers, MCP integrations). The Install button runs claude plugin install <slug> in a hidden terminal and streams its output below the row; on success the row flips to installed."},{term:"Library",body:'Browse the curated plugin catalog. Each row has a "source" link, a "copy" button for the /plugin install command, and an Install button that wires up the marketplace and installs for you.'}]},{title:"Plugin layout on disk",items:[{term:"plugin.json",body:"The manifest — name, version, description, what the plugin includes. The canonical location is .claude-plugin/plugin.json; older installs keep it at the folder root. Both are detected."},{term:"skills/",body:"Same shape as ~/.claude/skills/. Show up in the Skills tab."},{term:"agents/",body:"Markdown subagents (same shape as ~/.claude/agents/), available to the main Claude to delegate to."},{term:"hooks/hooks.json",body:"Hooks contributed by the plugin (mirrors settings.json's hooks shape, keyed by event), merged into your effective hook set."},{term:".mcp.json / .lsp.json / monitors/",body:"Optional — MCP servers, language servers, and monitors the plugin bundles. Their presence shows up in the contents summary."}]}],tips:["The Installed view is inspect-only here — it will not let you edit or delete plugin files. Edit a plugin's contents through the Skills/Hooks tabs instead.","Editing plugin contents directly is fine but be aware: an upgrade may overwrite your changes. Fork the plugin if you need persistent customizations."]},mcp:{headline:"Connect Claude to external tools — databases, APIs, filesystems — via MCP servers",intro:"MCP (Model Context Protocol) is the open spec for letting Claude call out to external tools. An MCP server is a small process (or HTTP endpoint) that exposes a set of functions; once you register it, Claude treats those functions as first-class tools. Common examples: a Postgres server that lets Claude run SELECTs, a Slack server that posts messages, a filesystem server that exposes a specific directory tree.",sections:[{title:"Where servers are stored",items:[{term:"User scope",body:"~/.claude.json under mcpServers. Available in every session, every repo."},{term:"Project scope",body:"<repo>/.mcp.json. Available only when working in this repo. Commit it so teammates pick up the same servers."},{term:"Editing",body:'Use "+ new server" to add one, click a row to edit it, rename via the name field, and Save/Revert at the bottom. A filter box narrows the list; the Library view installs catalog servers for you.'}]},{title:"Server types",items:[{term:"stdio",body:"Local process — Claude spawns the command and talks to it via stdin/stdout. Most common for tools you ship as a CLI. Fields: command, args, env."},{term:"http / streamable-http",body:"Remote endpoint with JSON-RPC. Field: url, plus headers for auth."},{term:"sse",body:"Server-Sent Events transport — deprecated; the editor flags it and suggests streamable-http instead."},{term:"ws",body:"WebSocket transport. Same url + headers fields as the other remote types."}]},{title:"Per-server controls",items:[{term:"env / headers",body:"Secrets like API keys go here (env for stdio, headers for remote types). Project-scope values get committed to git — be careful; prefer User scope for anything sensitive."},{term:"args",body:"Command-line arguments passed to a stdio server's command. Often used to point at a specific config file or directory."},{term:"alwaysLoad",body:"Bypass tool-search deferral and always load this server's tools up front (rather than only when searched for)."},{term:"enabled",body:"Uncheck to stop loading this server in new sessions without deleting its config."},{term:"disabledTools",body:"A comma-separated denylist of individual tool names to hide from this server."},{term:"permissions",body:"Per-server tool gating: inherit (default), allow all, deny all, or an explicit allowlist of tool names."}]}],tips:['The name "workspace" is reserved — the editor warns that Claude Code will refuse to load a server with that name. Names like "ide" and "tasks" get a softer caution because they collide with commonly-bundled servers.',"After adding/editing a server, restart the affected sessions so Claude reconnects and rediscovers tools."]},hooks:{headline:"Run scripts when Claude does something — pre/post-tool, session start/end, more",intro:"Hooks let you run a shell command, HTTP request, prompt, subagent, or MCP tool in response to events Claude Code emits. Want to log every Bash command Claude runs to a file? PreToolUse hook. Want a subagent to review every edit before it sticks? PostToolUse hook. Want a Slack ping when a long session ends? Stop hook. Hooks are stored in settings.json and can gate, log, or transform actions.",sections:[{title:"Two ways to view",items:[{term:"Effective",body:"The merged result of all scopes (User / Project / Local) — what actually fires. Editing here writes an override into the scope you have selected."},{term:"Events",body:"A per-event editor. The left list shows every supported event with a count of hooks attached; pick one, then add groups (with an optional matcher) and hooks under it."},{term:"Library",body:"Browse catalog hooks. Each event row links to the official hook reference."}]},{title:"The five hook types",items:[{term:"command",body:"Run a shell string (with an optional args array for the no-shell exec form). The script receives the event as JSON on stdin and can return a JSON decision. Only command hooks support the Test fire button."},{term:"http",body:"POST the event JSON to a URL. The response becomes the decision."},{term:"prompt",body:'Send a templated prompt to Claude itself for a quick gut-check. Useful for "should I really run this command?" guards.'},{term:"agent",body:"Spawn a subagent (a markdown file under ~/.claude/agents/) with the event as input. The agent's output is the decision."},{term:"mcp_tool",body:"Invoke a named MCP tool (e.g. mcp__server__tool) in response to the event."}]},{title:"Common events",items:[{term:"PreToolUse / PostToolUse",body:"Before / after Claude calls any tool. Most-used hooks live here — gating, logging, transforming. A matcher (tool-name regex or exact match) scopes a group to specific tools."},{term:"UserPromptSubmit",body:"Fires when you press Enter on a prompt. Good for prepending context (current branch, recent errors) before Claude sees the prompt."},{term:"SessionStart / SessionEnd",body:"Boot/teardown housekeeping — refresh tokens, save transcripts, post a summary."},{term:"Stop / SubagentStop",body:'When the main loop or a subagent finishes. Good for "ping me when done" notifications.'},{term:"PreCompact / PostCompact",body:"Around the auto-compaction step. Useful for archiving the full transcript before it's shrunk."},{body:"Many more are supported — permissions, tasks, worktrees, config/file changes, notifications. Hover any event in the list for its trigger and payload shape. Hooks saved under names Claude Code no longer recognizes are flagged in a warning banner."}]}],tips:['Test new hooks with the "test fire" button next to a command hook — it runs the command against an editable fake event payload (and shows whether your matcher would match) so you can debug without waiting for a real session.',"Each hook can set a timeout (ms) and command hooks can emit a terminalSequence (e.g. a bell). Slow synchronous hooks are noticeable — use http or fire-and-forget for work you don't need to wait on."]},memory:{headline:"A window onto Claude Code's own memory files for this project and its subagents",intro:"Claude Code can keep notes between conversations. These are plain markdown files, stored on your machine. For a project they live in ~/.claude/projects/<project>/memory/. MEMORY.md is the index. Topic files hold the details. At the start of each session Claude loads only the first 200 lines or 25KB of MEMORY.md, whichever comes first, so keep the index short. This tab shows those files and lets you read, edit and delete them. Nothing leaves your machine.",sections:[{title:"What memory is",items:[{term:"Index + topics",body:"MEMORY.md is a short list of one-line pointers. Each pointer names a topic file that holds the full note. Claude reads the index every session and opens a topic file when it needs it."},{term:"Load limit",body:"Only the first 200 lines / 25KB of MEMORY.md are loaded per session. Lines past that are never seen, so a long index quietly loses its tail."},{term:"Who writes",body:"Claude writes memories when you ask it to remember something, or when it decides a fact is worth keeping. You can also edit the files here by hand."}]},{title:"Workspace memories",items:[{term:"Where",body:"The project's auto memory, at ~/.claude/projects/<project>/memory/. It is picked from the active tab's folder, so a different folder shows a different set."},{term:"Worktrees",body:"All git worktrees of the same repository share one workspace memory. A note saved in one worktree is visible in the others."},{term:"Editing",body:"Open a file to read or edit it, add a new one, or delete one. The list refreshes when Claude writes to these files mid-session."}]},{title:"Subagent memories",items:[{term:"Opt-in",body:"A subagent keeps memory only if its definition has `memory: user`, `memory: project` or `memory: local` in its frontmatter. Without that line it has none."},{term:"Where",body:"user: ~/.claude/agent-memory/<agent>/. project: <project>/.claude/agent-memory/<agent>/ (can be committed and shared). local: <project>/.claude/agent-memory-local/<agent>/ (kept out of version control)."},{term:"Agent picker",body:"Pick an agent to see its memory directory. Its files look the same as workspace memory: a MEMORY.md index plus topic files."}]},{title:"What this tab adds",items:[{term:"Stale badge",body:"Marks a memory that has not been touched for a long time, so you can check whether it is still true."},{term:"Not in index",body:"Marks a topic file that MEMORY.md does not point to. Claude will not find it on its own until you add a line to the index."},{term:"Index budget",body:"A strip showing how many lines and KB of MEMORY.md you have used against the 200-line / 25KB limit. It warns when you are close or over."},{term:"Clusters",body:"Groups related memories so you can spot duplicates and merge them. It asks a model to do the grouping, so it costs tokens and only runs when you press the button."},{term:"Natural console",body:"A chat-style box for the workspace. Type list, show <name>, search <text>, remember <text>, forget <name> or help. Free-form text never writes by itself: you choose to send it to Claude in the terminal or add it as a new memory."}]}],tips:["Auto memory off means nothing here is read. Turn it back on if the files seem to have no effect.","Keep MEMORY.md lines short and move detail into topic files so the index stays under the limit.",'Check the "not in index" count after Claude has been writing for a while.']},projects:{headline:"Every directory you've ever run Claude Code in, with quick-resume and bulk tools",intro:"Whenever you start a Claude session in a new directory, Claude Code remembers it by writing transcripts under ~/.claude/projects/<encoded-cwd>/. This tab lists those directories — how many sessions each has, when you last worked there, total transcript size — plus git and CLAUDE.md details it fills in as it reads each folder. Search, filter, pin your favorites, open a folder four different ways, or archive ones you're done with.",sections:[{title:"Columns",items:[{term:"Project",body:"The directory path (with its detected project name). Hover to peek at the start of its CLAUDE.md if it has one."},{term:"Sessions",body:"How many session transcripts exist for this folder. High numbers mean you work here often."},{term:"Last active",body:"When the most recent transcript was touched. The default sort — most recent first."},{term:"Size",body:"Disk usage of all transcripts for this project. Old projects can balloon; archiving is safe if you don't need the history."},{term:"Branch / Remote",body:"The last git branch and git remote, shown once Session Manager finishes reading the folder."}]},{title:"Per-row actions",items:[{term:"Open in session",body:"Spawns a new terminal tab running claude in this directory."},{term:"Open externally",body:"Three more openers: your editor (VS Code / Cursor / Sublime / nano — pick a default up top, or Auto), your file manager, or a system terminal."},{term:"CLAUDE.md",body:"A side drawer that previews this project's CLAUDE.md read-only (no in-drawer editing)."},{term:"Pin / Archive",body:"Star a project to keep it at the top; archive moves it to ~/.claude/projects-archive/ after a confirm."}]},{title:"Finding projects",items:[{term:"Search",body:"Matches path, project name, git remote, and the CLAUDE.md preview."},{term:"Sort & filter",body:"Sort by project, sessions, last active, or size (toggle direction). Filter chips narrow by recency (≤7d / ≤30d), git remote, CLAUDE.md presence, or pinned-only."},{term:"Stats header",body:"Totals up top: project count, how many were active in 7 days, total sessions, total on-disk size, and clickable pills for your most-active projects."}]}],tips:["Tick the checkboxes to select several projects, then archive them all or open them all in your editor at once.","Sort by size to find runaway transcript folders — a multi-hundred-MB project usually means many long sessions, safe to archive if you don't need them."]},remote:{headline:"Session Managers on your other computers",intro:"Pick a paired machine to browse its projects and active sessions, or open a terminal on it. Pairing and revoking machines happens in Settings → Phone remote.",sections:[{title:"Using it",items:[{term:"Machines",body:"The switcher lists every paired computer with its OS and whether it is online right now."},{term:"Sessions / Terminal",body:"Sessions shows what the selected machine is running; Terminal opens a shell there."}]}]},history:{headline:"Every individual Claude session you've ever run, ready to resume",intro:"Where the Projects tab shows directories, the History tab shows individual sessions — one row per .jsonl transcript under ~/.claude/projects/. Two views share the tab: Log is a flat, searchable list you can resume from; Dashboard rolls the same transcripts up into prompt, token, and cost charts. Your view choice is remembered.",sections:[{title:"Log view",items:[{term:"Session id",body:"The UUID identifying the session (shown short). The same id appears in --session-id flags and Claude's own logs."},{term:"Project",body:"The folder this session belongs to (the encoded directory name, decoded back to a path)."},{term:"Last active / Size",body:"When the transcript was last touched (sorted newest first) and its size — a big transcript means a long conversation."},{term:"Resume",body:"Click Resume, pick the directory to run in, and a new tab opens running claude --resume <sessionId>. Claude reads the full transcript and continues; the tab id matches the session id."},{term:"Filter",body:"The search box matches session id and project name (case-insensitive substring); it does not search message text."}]},{title:"Dashboard view",items:[{term:"Summary",body:"Cards for total prompts, input tokens, output tokens, sessions, and estimated cost across the selected range."},{term:"Charts",body:"A daily trend line (switch between prompts, tokens, sessions, errors, or cost) and a per-day input-vs-output token stack, plus a sortable per-project table with each project's top tool and estimated cost."},{term:"Range & refresh",body:'Narrow by from/to date and by project name. Auto-refreshes every 30 seconds, with a manual refresh button and an "updated X ago" stamp. A yellow banner warns if a scan timed out and the numbers are partial.'}]}],tips:["Resume lets you pick any directory — handy when you've moved or renamed the original project folder since the session ran."]},scheduler:{headline:"Author PRDs and run them as claude -p jobs against your 5-hour window",intro:"One home for the headless-batch workflow, split into three tabs. The Queue tab combines global Options (session pool, fire policy, on-disk paths) with monitoring this project's jobs; the PRDs tab is where you author the markdown files those jobs execute; the History tab lists recent completed and failed jobs. PRDs live in each active project's own <cwd>/session-manager-operations/scheduler/prds/. A status strip across the top shows when the window resets, how many jobs are pending / running / completed today, and how much of the 5-hour window you have used. Jobs auto-pause on rate-limit and auto-resume on the next 5-hour reset.",sections:[{title:"Queue — when jobs start",items:[{term:"when available",body:'Default. The scheduler polls your billing usage every ~10 minutes and fires the next batch whenever your 5-hour utilization is below the "Pause above" percent (90% by default).'},{term:"only on reset",body:"Fire queued jobs shortly after each 5-hour window resets, instead of polling."},{term:"manually",body:'Nothing fires on its own — you start work yourself with "Fire next batch now".'}]},{title:"Queue — controls",items:[{term:"Up to N at once",body:"How many jobs in the same group may run in parallel. Defaults to 3 — raising it runs more node processes at once, which can exhaust memory on a small machine."},{term:"Fire next batch now",body:"Launches the next batch immediately, bypassing the billing-usage poll. Useful when the usage meter is itself rate-limited or you just want progress now."},{term:"Resume",body:"When the queue is paused (rate-limit, expired sign-in, network, or a manual pause), a banner explains why and offers Resume."}]},{title:"PRDs — authoring",items:[{body:"Each file is one task — frontmatter (title, cwd, estimateMinutes, parallelGroup) plus a self-contained body Claude can act on without conversation context."},{term:"parallelGroup",body:'The group number. Jobs in the same group run together (up to the concurrency cap); lower groups run before higher ones. If you omit it, the leading "NN-" number in the filename is used, else 99.'},{term:"estimateMinutes",body:"Roughly how long you expect the job to take. The scheduler uses this to pick jobs that fit in your remaining 5-hour budget."}]},{title:"Options — the session pool (global, not per-project)",items:[{term:"One pool, every consumer",body:"Session-Manager owns a machine-wide pool of concurrent Claude sessions (3 by default). Scheduler jobs and Epic chat runs each request a slot before launching and release it when they finish — no subsystem has a private cap that can stack with another's."},{term:"Guardrails",body:"Beyond the slot cap, a memory gate defers new jobs when free RAM drops below a per-job budget, and each job gets an OOM-score bias so the kernel prefers killing a restartable job over the app itself."}]}],tips:["Use the /prd skill to create a fresh PRD with the right structure — manually-written ones often miss the cwd or estimate fields.","Read PRD_AUTHORING.md before queueing a new job — it codifies two real stuck-job incidents (the fizzpop poll-hang and the etch-engine post-AC overrun).","SM_SESSION_SLOTS (1–3) overrides the pool size for one launch; the default is sized to keep three 1 GB+ jobs from starving the app."]},editor:{headline:"View and edit files in-app",intro:"Opens when you click a file in the File Explorer sidebar or a file link in the terminal. Text files open in Monaco (syntax highlighting, font zoom, word wrap, minimap, Dark/Paper theme); Markdown adds Edit / Wysiwyg / Preview / Split, HTML adds Edit / Preview. Images, PDFs, CSV/TSV tables, and JSONL records each get their own viewer; binary or oversized files show a summary instead. URLs still open in your browser.",sections:[{title:"Editing",items:[{term:"Cmd/Ctrl-S",body:'Save the active file. With Autosave on (the "Auto" toggle), edits also save automatically ~1.2 s after you stop typing.'},{term:"Cmd/Ctrl-Shift-F",body:"Toggle Focus mode — hides the tabs and header for distraction-free editing. Esc exits."},{term:"Close guard",body:"Closing a tab with unsaved changes asks before discarding."}]},{title:"Markdown",items:[{term:"Wysiwyg",body:"A rich-text mode built on Tiptap with a floating formatting toolbar (bold, italic, headings, lists, code, blockquote, links) — edit the rendered document directly instead of raw markdown. YAML frontmatter is split off, kept read-only, and rejoined on save; switch to Edit for surgical edits to PRDs and agent files, since Wysiwyg normalizes list markers and heading style."},{term:"Outline",body:"In Preview or Split mode, a document outline lists headings; click to jump. Toggle it with the Outline button."},{term:"Toolbar",body:"A formatting toolbar sits above the editor for Markdown files."}]}],tips:["Use the view toggle (Edit / Wysiwyg / Preview / Split) for Markdown, or Edit / Preview for HTML. HTML previews are sandboxed — page scripts run with no access to your files or session.","Open and Reveal buttons hand the file to your OS default app or file manager."]},voice:{headline:"Voice & microphone",intro:"Talk to Claude instead of typing. Speech is transcribed on-device with a Moonshine model that loads the first time you record (a progress bar shows the download). A press-to-record hotkey starts and stops the mic; what you say is typed into the active terminal, and an auto-submit timer fires it for you a moment after you stop speaking. A one-time mic check confirms your microphone works.",sections:[{title:"Recording controls",items:[{term:"Hotkey",body:"Press your mic hotkey to record. The default is Ctrl+Shift+Space (Cmd+Option+V on Mac); the panel shows the live binding. Two behaviours: 'Hold to talk' records only while the key is held (push-to-talk), 'Tap on/off' starts on one press and stops on the next. The default is hold-to-talk; switch with the radio buttons."},{term:"Mic button & device",body:"The mic button toggles recording with the mouse. The device picker chooses which microphone to use, and a live level meter shows that audio is coming through."},{term:"Run mic check",body:"Opens a short wizard that confirms your mic is picking up sound. It runs automatically once after a settings-format change, or any time you click 'Run mic check'."}]},{title:"Speaking & hearing back",items:[{term:"Live transcript",body:"While recording, a pulsing red dot and the latest transcribed words appear so you can see what was heard. Errors (e.g. mic blocked) surface inline in red."},{term:"TTS (read replies aloud)",body:"The speaker button toggles text-to-speech. When on, Claude's replies are read back to you out loud."}]}],tips:["The speech model downloads on first use only, then stays cached — later recordings start instantly.","Hold-to-talk is best for quick interjections; Tap on/off is better for longer dictation where you don't want to hold a key."]},"agent-library":{headline:"Agent Library — every persona available to this machine",intro:"Global agent definitions live at ~/.claude/agents/*.md. A project can overlay a same-named agent at <project>/.claude/agents/<name>.md, which Claude Code prefers over the global definition whenever both exist. New / Duplicate / Save / Delete here write the matching global .md file directly.",sections:[{title:"What it shows",items:[{term:"Global personas",body:"Every agent .md file under ~/.claude/agents, with its frontmatter (name, description, model, color, tools) and body."},{term:"Overriding projects",body:"For each agent, which of your currently-open project tabs has a local overlay of the same name — that overlay is what actually runs in that project. Dropping one here deletes that project's local .md file."}]}],tips:["Home face only — this is machine-wide data, not scoped to one project.","Only the global definition is editable here — a project overlay is created by Claude Code convention (a same-named file under <project>/.claude/agents/), not from this page."]},"tag-library":{headline:"Tag Library — the Epic intent-tag taxonomy",intro:"Every Epic carries an initial intent tag — feature, bug, discussion, or build — chosen at creation. The tag sets how eagerly /develop should fire inside that Epic's session: feature/bug/build treat PRD decomposition as the expected next step, discussion keeps /develop available but never assumed until whether-to-build is settled.",sections:[{title:"What it shows",items:[{term:"Tag",body:"The four intent tags an Epic can be created with."},{term:"/develop eagerness",body:"Whether PRD decomposition is the expected default for that tag, or available-but-not-assumed."},{term:"Agents carrying this tag",body:"Which Agent Library personas have this tag in their `tags:` frontmatter — the same relationship Agent Library edits from the agent side. Assign or remove an agent here to update that persona's file directly."}]}],tips:["Home face only — the taxonomy is machine-wide, not scoped to one project.","The tag taxonomy itself is read-only here — change an existing Epic's tag from its queue row menu, not from this page. The agent↔tag assignment, though, is editable from either Tag Library or Agent Library."]},"data-model":{headline:"Data Model — an ERD of what Session Manager actually persists",intro:"A hand-maintained diagram of the app's own storage: entities, their on-disk path/format, the single-writer owner if one is declared, their fields, and how they relate. It is a mirror of the real shapes in code (lib/dataModelErd.ts), not a live scanner — it can drift if a shape changes without an update.",sections:[{title:"What it shows",items:[{term:"Diagram",body:"Boxes grouped by realm (project/machine/both), with relation lines. Click a box for its storage path, fields, and relations; toggle a group in the legend to hide it."},{term:"Tables",body:"The same entities as a flat, grouped list of tables — useful for scanning every field at once."}]}],tips:["Home face only — this diagrams the application's own data model, which is identical for every project.","Read-only reference material, not live data — nothing here reflects the currently-open project's actual on-disk state."]}};function UO({content:i}){return c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-xs text-fg-dim leading-relaxed mb-3",children:i.intro}),i.sections.map(e=>c.jsxs("div",{className:"mb-3 last:mb-0",children:[c.jsx("h3",{className:"text-[11px] uppercase tracking-wider text-fg font-medium mb-1",children:e.title}),c.jsx("ul",{className:"space-y-1",children:e.items.map((t,n)=>c.jsxs("li",{className:"text-xs text-fg-dim leading-relaxed",children:[t.term&&c.jsx("span",{className:"text-fg font-medium",children:t.term}),t.term&&" — ",c.jsx("span",{children:t.body})]},n))})]},e.title)),i.tips&&i.tips.length>0&&c.jsxs("div",{className:"mt-3 pt-3 border-t border-line",children:[c.jsx("h3",{className:"text-[11px] uppercase tracking-wider text-fg-dim font-medium mb-1",children:"Tips"}),c.jsx("ul",{className:"space-y-1",children:i.tips.map((e,t)=>c.jsxs("li",{className:"text-xs text-fg-faint leading-relaxed",children:["• ",e]},t))})]})]})}function VO({active:i}){const e=Pn(g=>g.learningPanelCollapsed),t=Pn(g=>g.setLearningPanelCollapsed),n=Pn(g=>g.hydrated),r=Pn(g=>g.hydrate);z.useEffect(()=>{n||r()},[n,r]);const[l,p]=z.useState(()=>!e),a=z.useRef(null);z.useEffect(()=>{n&&p(!e)},[n]);const d=z.useCallback(()=>{p(g=>{const y=!g;return t(!y),y})},[t]);z.useEffect(()=>{if(!l)return;const g=y=>{var D;(D=a.current)!=null&&D.contains(y.target)||(p(!1),t(!0))};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[l,t]);const f=z.useRef(!1);z.useEffect(()=>{if(!f.current){f.current=!0;return}p(!1)},[i]);const m=WO[i];return m?c.jsxs("span",{ref:a,className:"relative inline-block",children:[c.jsx("button",{type:"button",onClick:d,className:"text-[10px] uppercase tracking-wider text-accent font-medium hover:opacity-80 transition-opacity","aria-expanded":l,title:l?"Close learning panel":"What is this?",children:"Learn"}),l&&c.jsx("div",{className:"absolute right-0 top-full z-30 mt-1 w-96 max-h-[70vh] overflow-y-auto rounded border border-line bg-bg-elev shadow-lg px-4 pb-4 pt-3 text-left",children:c.jsx(UO,{content:m})})]}):null}function qO({eyebrow:i,title:e,intro:t,frame:n=!0,learnKey:r,children:l}){const p=n&&(i||e||t);return c.jsxs("div",{className:"h-full w-full flex flex-col bg-bg text-fg",children:[p&&c.jsxs("header",{className:"shrink-0 px-8 pt-7 pb-5 flex items-start justify-between gap-4",children:[c.jsxs("div",{className:"max-w-[820px]",children:[i&&c.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-fg-faint mb-2",children:i}),e&&c.jsx("h1",{className:"font-serif text-[34px] font-medium leading-[1.1] text-fg m-0",children:e}),t&&c.jsx("p",{className:"mt-3 text-[14px] text-fg-dim leading-[1.55]",children:t})]}),r&&c.jsx(VO,{active:r})]}),c.jsx("div",{className:`flex-1 min-h-0 ${p?"px-8 pb-7":"p-8"}`,children:l})]})}const KO=z.lazy(()=>fi(()=>import("./Skills-BeCMBQ3l.js"),__vite__mapDeps([3,4,5,6,7,8,9,10,11,12,13,1,2]),import.meta.url).then(i=>({default:i.Skills}))),YO=z.lazy(()=>fi(()=>import("./History-D58whvn_.js"),__vite__mapDeps([14,4,15,1,2]),import.meta.url).then(i=>({default:i.History}))),XO=z.lazy(()=>fi(()=>import("./RemoteMachines-CtkAJvkZ.js"),__vite__mapDeps([16,17,1,2]),import.meta.url).then(i=>({default:i.RemoteMachines}))),JO=z.lazy(()=>fi(()=>import("./Scheduler-BNiYg0YD.js"),__vite__mapDeps([18,15,13,9,1,2]),import.meta.url).then(i=>({default:i.Scheduler}))),ZO=z.lazy(()=>fi(()=>import("./Settings-B4LuoRnd.js"),__vite__mapDeps([19,4,8,7,20,21,22,9,17,1,2]),import.meta.url).then(i=>({default:i.Settings}))),QO=z.lazy(()=>fi(()=>import("./Permissions-DyOqpLQx.js"),__vite__mapDeps([23,4,8,7,11,12,13,20,21,22,1,2]),import.meta.url).then(i=>({default:i.Permissions}))),e3=z.lazy(()=>fi(()=>import("./SystemPrompt-C3WmcPEF.js"),__vite__mapDeps([24,4,7,11,12,13,1,2]),import.meta.url).then(i=>({default:i.SystemPrompt}))),t3=z.lazy(()=>fi(()=>import("./Memory-BODDUBy4.js"),__vite__mapDeps([25,1,2]),import.meta.url).then(i=>({default:i.Memory}))),i3=z.lazy(()=>fi(()=>import("./Plugins-DBXzKjL2.js"),__vite__mapDeps([26,4,10,11,12,13,6,1,2,5]),import.meta.url).then(i=>({default:i.Plugins}))),n3=z.lazy(()=>fi(()=>import("./McpServers-CT0pBTF8.js"),__vite__mapDeps([27,4,5,7,8,10,11,12,13,1,2]),import.meta.url).then(i=>({default:i.McpServers}))),s3=z.lazy(()=>fi(()=>import("./Hooks-DCI9ezg4.js"),__vite__mapDeps([28,4,5,7,8,10,11,12,13,20,21,22,1,2]),import.meta.url).then(i=>({default:i.Hooks}))),r3=z.lazy(()=>fi(()=>import("./AgentLibrary-BpW0pGgk.js"),__vite__mapDeps([29,4,5,12,30,21,1,2]),import.meta.url).then(i=>({default:i.AgentLibrary}))),o3=z.lazy(()=>fi(()=>import("./TagLibrary-DP4GH7Dr.js"),__vite__mapDeps([31,4,5,30,1,2]),import.meta.url).then(i=>({default:i.TagLibrary}))),a3=z.lazy(()=>fi(()=>import("./DataModel-WG4pG_4z.js"),__vite__mapDeps([32,4,22,1,2]),import.meta.url).then(i=>({default:i.DataModel}))),l3=c.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading…"});function xr({children:i}){return c.jsx(z.Suspense,{fallback:l3,children:i})}const c3={skills:{title:"Reusable instructions",intro:"Skills are scoped pieces of context that Claude loads on demand. Add new ones, audit what is live, or disable a skill that is misbehaving."},remote:{title:"Remote machines",intro:"Open a Session Manager running on another computer — its projects, active sessions and a terminal. Pair or revoke machines in Settings → Phone remote."},history:{title:"Spend, tokens and time",intro:"Estimated spend, tokens, prompts and active time across every project — by project, model and day. Export any range to CSV."},plugins:{title:"Plugins",intro:"Extensions for Claude Code. Install, enable, or remove plugins per-scope."},mcp:{title:"MCP Servers",intro:"External tools and integrations the agent can call. Add a new server or test an existing connection."},hooks:{title:"Hooks",intro:"Run scripts on session events. Tail logs, format files, post to Slack — anything that responds to a shell command."},memory:{title:"Memory",intro:"Claude Code's own memory files for this project and its subagents — a MEMORY.md index plus topic files. Stored locally, nothing leaves your machine."},"system-prompt":{title:"System prompt",intro:"The personality and behavior contract for this app. Edits here apply to every new session you spawn."},permissions:{title:"Permissions",intro:"Allow and deny rules per scope. Adjust which tools Claude can call without prompting."},settings:{title:"Settings",intro:"Theme, voice input, billing window, density. Per-scope JSON with schema validation."},"agent-library":{title:"Agent Library",intro:'Agents are the ACTOR of the AIM framework every session opens with — "you are acting as …". Every persona on this machine lives here: global definitions in ~/.claude/agents, plus which currently-open projects override them locally. Give a persona a project scope and an opening instruction and it also becomes an Action — a one-click button in that project’s Sessions toolbar that starts a session already grounded on it. Create, edit, duplicate, or delete a persona; each change writes the matching file on disk.'},"tag-library":{title:"Tag Library",intro:"Every session intent tag, its meaning, and its /develop-eagerness default. Assign or remove which agent personas carry each tag."},voice:{title:"Voice & microphone",intro:"On-device transcription, push-to-talk hotkey, device selection, and TTS toggle."},"data-model":{title:"Data Model",intro:"A hand-maintained ERD of what Session Manager actually persists — storage paths, single-writer owners, and how entities relate."}},d3=()=>{},OS=new Map;function u3(i,e){const t=OS.get(i);if(t&&t.ctx===e)return t.node;const n=h3(i,e);return OS.set(i,{ctx:e,node:n}),n}function h3(i,e){switch(i){case"overview":return c.jsx(ZP,{onNavigate:e.onNavigate,onNewSession:e.onNewSession,onOpenVoice:e.onOpenVoice,onOpenScheduler:e.onOpenScheduler});case"project-home":return c.jsx(Gj,{});case"editor":return c.jsx(fw,{});case"projects":return c.jsx(HO,{})}const t=c3[i],n=(()=>{switch(i){case"skills":return c.jsx(xr,{children:c.jsx(KO,{})});case"history":return c.jsx(xr,{children:c.jsx(YO,{})});case"remote":return c.jsx(xr,{children:c.jsx(XO,{onOpenSettings:()=>{var l;return(l=e.onNavigate)==null?void 0:l.call(e,"settings")}})});case"scheduler":return c.jsx(xr,{children:c.jsx(JO,{navigate:e.onNavigate})});case"plugins":return c.jsx(xr,{children:c.jsx(i3,{})});case"mcp":return c.jsx(xr,{children:c.jsx(n3,{})});case"hooks":return c.jsx(xr,{children:c.jsx(s3,{})});case"memory":return c.jsx(xr,{children:c.jsx(t3,{})});case"system-prompt":return c.jsx(xr,{children:c.jsx(e3,{})});case"permissions":return c.jsx(xr,{children:c.jsx(QO,{})});case"settings":return c.jsx(xr,{children:c.jsx(ZO,{})});case"agent-library":return c.jsx(xr,{children:c.jsx(r3,{})});case"tag-library":return c.jsx(xr,{children:c.jsx(o3,{})});case"data-model":return c.jsx(xr,{children:c.jsx(a3,{})});case"voice":return c.jsx(uO,{open:!0,onClose:d3,variant:"page"});default:return null}})();if(!n)return null;const r=P2[i];return t&&r?c.jsx(qO,{eyebrow:r,title:t.title,intro:t.intro,learnKey:i,children:n}):n}var ab={exports:{}},LS;function p3(){return LS||(LS=1,(function(i,e){(function(t,n){i.exports=n()})(globalThis,(()=>(()=>{var t={4567:function(p,a,d){var f=this&&this.__decorate||function(x,S,T,j){var N,L=arguments.length,R=L<3?S:j===null?j=Object.getOwnPropertyDescriptor(S,T):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(x,S,T,j);else for(var F=x.length-1;F>=0;F--)(N=x[F])&&(R=(L<3?N(R):L>3?N(S,T,R):N(S,T))||R);return L>3&&R&&Object.defineProperty(S,T,R),R},m=this&&this.__param||function(x,S){return function(T,j){S(T,j,x)}};Object.defineProperty(a,"__esModule",{value:!0}),a.AccessibilityManager=void 0;const g=d(9042),y=d(9924),D=d(844),E=d(4725),C=d(2585),b=d(3656);let w=a.AccessibilityManager=class extends D.Disposable{constructor(x,S,T,j){super(),this._terminal=x,this._coreBrowserService=T,this._renderService=j,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let N=0;N<this._terminal.rows;N++)this._rowElements[N]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[N]);if(this._topBoundaryFocusListener=N=>this._handleBoundaryFocus(N,0),this._bottomBoundaryFocusListener=N=>this._handleBoundaryFocus(N,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new y.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((N=>this._handleResize(N.rows)))),this.register(this._terminal.onRender((N=>this._refreshRows(N.start,N.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((N=>this._handleChar(N)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
3035
|
+
(Give a different rewrite than the last one.)`,!1)},[E,t.instruction]),x=z.useCallback(S=>{const T=t.diff;if(!T)return{ok:!1,reason:"not-found"};const j=jM(S,T.before,T.after);return j.ok?(r.current+=1,n({type:"ACCEPT"})):Qe.error(j.reason==="ambiguous"?"That text appears more than once — edit it manually instead.":"That text no longer matches the document — edit it manually instead."),j},[t.diff]);return{state:t,select:f,cancel:m,listen:g,sendHeard:b,run:C,retry:w,accept:x}}async function Ca(i){try{const e=await window.api.clipboard.writeText(i);return(e==null?void 0:e.ok)===!0}catch{return!1}}const FM=[{label:"Make concise",instruction:"Rewrite this text to be concise and specific. Preserve meaning and any markdown structure."},{label:"To bullet list",instruction:"Convert this text into a tight markdown bullet list."},{label:"Fix the tone",instruction:"Fix the tone: direct, professional, no hedging. Preserve meaning."}],bS=320,Tf=8;function HM(){return c.jsxs("span",{className:"inline-flex items-center gap-0.5","aria-hidden":"true",children:[c.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:0ms]"}),c.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:150ms]"}),c.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:300ms]"})]})}function WM(i){const e=typeof window<"u"?window.innerWidth:1024,t=Math.min(Math.max(i.left,Tf),Math.max(Tf,e-bS-Tf)),n=Math.max(i.top-Tf,Tf);return{position:"fixed",left:t,top:n,width:bS,transform:"translateY(-100%)",zIndex:W2.dialog}}function UM({phase:i,rect:e,selectedText:t,diff:n,transcript:r,modelStatus:l,onQuickAction:p,onRunCustom:a,onListen:d,onSendHeard:f,onCancel:m,onAccept:g,onReject:y,onRetry:D}){const[E,C]=z.useState(""),[b,w]=z.useState(!1),x=Is(N=>N.show),S=z.useRef(null);z.useEffect(()=>()=>{S.current&&clearTimeout(S.current)},[]);const T=async()=>{if(!await Ca(t)){x("error","Copy failed");return}w(!0),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>w(!1),1500)},j=()=>{const N=E.trim();N&&(a(N),C(""))};return c.jsxs("div",{"data-doc-edit-popover":!0,style:WM(e),className:"rounded-lg border border-line bg-bg-elev shadow-2xl text-xs text-fg",children:[i==="popover"&&c.jsxs("div",{className:"p-2",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsxs("div",{className:"flex flex-wrap gap-1",children:[c.jsx("button",{onClick:T,"data-testid":"doc-edit-copy",className:"px-2 py-1 text-[11px] rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",title:"Copy the selected text",children:b?"Copied":"Copy"}),c.jsx("button",{onClick:d,"data-testid":"doc-edit-voice",className:"px-2 py-1 text-[11px] rounded border border-line bg-bg-hi text-fg hover:border-fg-faint font-medium",title:"Speak your edit instruction",children:"🎤 Voice edit"}),FM.map(N=>c.jsx("button",{onClick:()=>p(N.instruction),className:"px-2 py-1 text-[11px] rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:N.label},N.label))]}),c.jsx("button",{onClick:m,className:"ml-2 shrink-0 text-fg-faint hover:text-fg",title:"Dismiss","aria-label":"Dismiss",children:"×"})]}),c.jsx("input",{value:E,onChange:N=>C(N.target.value),onKeyDown:N=>{N.key==="Enter"?j():N.key==="Escape"&&m()},placeholder:"tell Claude what to change…",className:"w-full px-2 py-1 text-[11px] bg-bg border border-line rounded outline-none focus:border-fg-faint text-fg placeholder:text-fg-faint"})]}),i==="listening"&&c.jsxs("div",{className:"p-3 flex items-center justify-between","data-testid":"doc-edit-listening",children:[c.jsxs("span",{className:"flex flex-col gap-0.5 text-fg-dim",children:[c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(HM,{}),"Listening…"]}),l&&c.jsx("span",{className:"text-[10px] text-fg-faint",children:l})]}),c.jsx("button",{onClick:m,className:"px-2 py-0.5 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"})]}),i==="review"&&c.jsxs("div",{className:"p-3","data-testid":"doc-edit-review",children:[c.jsxs("p",{className:"italic text-fg mb-2",children:["«",r,"»"]}),c.jsxs("div",{className:"flex justify-end gap-1.5",children:[c.jsx("button",{onClick:m,className:"px-2 py-1 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"}),c.jsx("button",{onClick:d,className:"px-2 py-1 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Re-record"}),c.jsx("button",{onClick:f,className:"px-2 py-1 text-[11px] text-white rounded bg-accent hover:opacity-90",children:"Send"})]})]}),i==="thinking"&&c.jsxs("div",{className:"p-3 flex items-center justify-between",children:[c.jsx("span",{className:"text-fg-dim animate-pulse",children:"Claude is editing…"}),c.jsx("button",{onClick:m,className:"px-2 py-0.5 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"})]}),i==="diff"&&n&&c.jsxs("div",{className:"p-3",children:[c.jsxs("div",{className:"mb-2 max-h-40 overflow-auto space-y-1",children:[c.jsx("div",{className:"text-red-400 line-through whitespace-pre-wrap",children:n.before}),c.jsx("div",{className:"text-green-400 whitespace-pre-wrap",children:n.after})]}),c.jsxs("div",{className:"flex justify-end gap-1.5",children:[c.jsx("button",{onClick:y,className:"px-2 py-1 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Reject"}),c.jsx("button",{onClick:D,className:"px-2 py-1 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Retry"}),c.jsx("button",{onClick:g,className:"px-2 py-1 text-[11px] text-white rounded bg-green-600 hover:bg-green-500",children:"Accept"})]})]})]})}function VM(){return c.jsxs("span",{className:"inline-flex items-center gap-0.5","aria-hidden":"true",children:[c.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:0ms]"}),c.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:150ms]"}),c.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:300ms]"})]})}function wS({phase:i,transcript:e,diff:t,editCount:n,modelStatus:r,onListen:l,onSendHeard:p,onCancel:a,onAccept:d,onReject:f,onRetry:m}){return c.jsxs("div",{"data-testid":"assistant-rail",className:"w-[300px] shrink-0 border-l border-line bg-bg-elev flex flex-col text-xs",children:[c.jsxs("div",{className:"flex items-center justify-between px-3 h-8 border-b border-line shrink-0",children:[c.jsx("span",{className:"font-medium text-fg",children:"Assistant"}),c.jsx("span",{className:"text-[10px] text-fg-faint",title:"Model used for Document Experience edits",children:tm(BM)})]}),c.jsxs("div",{className:"flex-1 min-h-0 overflow-auto p-3",children:[i==="idle"&&c.jsxs("div",{className:"text-fg-faint",children:[c.jsx("p",{children:"Select text in the doc…"}),c.jsxs("p",{className:"mt-2 text-[10px]",children:[n," edit",n===1?"":"s"," this session"]})]}),i==="popover"&&c.jsx("p",{className:"text-fg-faint",children:"Choose a quick action or speak an instruction from the popover."}),i==="listening"&&c.jsxs("div",{children:[c.jsxs("p",{className:"flex items-center gap-2 text-fg-dim mb-1",children:[c.jsx(VM,{}),"Listening…"]}),r&&c.jsx("p",{className:"text-[10px] text-fg-faint mb-3",children:r}),c.jsx("button",{onClick:a,className:"px-2 py-0.5 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"})]}),i==="review"&&c.jsxs("div",{children:[c.jsxs("p",{className:"italic text-fg mb-3",children:["«",e,"»"]}),c.jsxs("div",{className:"flex gap-1.5",children:[c.jsx("button",{onClick:a,className:"px-2 py-1 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"}),c.jsx("button",{onClick:l,className:"px-2 py-1 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Re-record"}),c.jsx("button",{onClick:p,className:"px-2 py-1 text-[11px] text-white rounded bg-accent hover:opacity-90",children:"Send"})]})]}),i==="thinking"&&c.jsx("p",{className:"text-fg-dim animate-pulse",children:"Claude is editing…"}),i==="diff"&&t&&c.jsxs("div",{children:[c.jsxs("div",{className:"mb-3 space-y-2",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-[10px] uppercase tracking-wide text-fg-faint mb-1",children:"Before"}),c.jsx("div",{className:"text-red-400 line-through whitespace-pre-wrap",children:t.before})]}),c.jsxs("div",{children:[c.jsx("div",{className:"text-[10px] uppercase tracking-wide text-fg-faint mb-1",children:"After"}),c.jsx("div",{className:"text-green-400 whitespace-pre-wrap",children:t.after})]})]}),c.jsxs("div",{className:"flex gap-1.5",children:[c.jsx("button",{onClick:f,className:"px-2 py-1 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Reject"}),c.jsx("button",{onClick:m,className:"px-2 py-1 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Retry"}),c.jsx("button",{onClick:d,className:"px-2 py-1 text-[11px] text-white rounded bg-green-600 hover:bg-green-500",children:"Accept"})]})]})]})]})}function qM(){const i=Ct(t=>t.tabs),e=Ct(t=>t.activeTabId);return i.find(t=>t.id===e)??null}function KM({path:i,onRenamed:e,onDeleted:t}){const[n,r]=z.useState(!1),[l,p]=z.useState(!1),[a,d]=z.useState(""),[f,m]=z.useState(!1),g=Ci(V=>V.buffers[i]),y=Ci(V=>V.openFile),D=Ci(V=>V.renameOpenFile),E=Ci(V=>V.closeFile),C=qM(),b=ba(i),w=()=>r(!1),x=()=>{d(b),p(!0),w()},S=async()=>{const V=a.trim();if(!V||V===b){p(!1);return}try{const te=await window.api.files.rename(i,V);if(te.ok){const he=i.slice(0,i.lastIndexOf("/")),ee=te.newPath??`${he}/${V}`;D(i,ee),e==null||e(i,ee),Qe.info(`Renamed to ${V}`)}else Qe.error(te.error??`Couldn't rename ${b}`)}catch(te){Qe.error(te instanceof Error?te.message:`Couldn't rename ${b}`)}p(!1)},T=async()=>{w();try{const V=await window.api.files.duplicate(i);V.ok&&V.path?(y(V.path),Qe.info(`Duplicated as ${ba(V.path)}`)):Qe.error(V.error??`Couldn't duplicate ${b}`)}catch(V){Qe.error(V instanceof Error?V.message:`Couldn't duplicate ${b}`)}},j=async()=>{try{const V=await window.api.files.delete(i);V.ok?(E(i),t==null||t(i),Qe.info(`Deleted ${b}`)):Qe.error(V.error??`Couldn't delete ${b}`)}catch(V){Qe.error(V instanceof Error?V.message:`Couldn't delete ${b}`)}m(!1)},N=async()=>{w();const V=g??"";await Ca(V)?Qe.info(`Copied ${V.length} chars`):Qe.error(`Couldn't copy ${b}`)},L=()=>{if(w(),!C){Qe.error("No terminal tab is active");return}window.api.pty.write({tabId:C.id,data:`@${i} `}),Qe.info(`Added ${b} to Claude context`)},R=()=>{w(),window.api.shell.open({as:"openPath",path:i}).then(V=>{V.ok||Qe.error(V.error??`Couldn't open ${b}`)}).catch(V=>Qe.error(V instanceof Error?V.message:`Couldn't open ${b}`))},F=()=>{w(),window.api.shell.open({as:"revealPath",path:i}).then(V=>{V.ok||Qe.error(V.error??`Couldn't reveal ${b}`)}).catch(V=>Qe.error(V instanceof Error?V.message:`Couldn't reveal ${b}`))};return c.jsxs("div",{className:"relative inline-block mr-1",children:[c.jsx("button",{onClick:()=>r(V=>!V),className:`px-2 py-0.5 text-[10px] border border-line rounded ${n?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Document actions",children:"Document ▾"}),n&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:`fixed inset-0 ${dn.contextMenuScrim}`,onMouseDown:w}),c.jsxs("div",{className:`absolute right-0 top-full mt-1 ${dn.contextMenu} w-56 rounded-lg border border-line bg-bg-elev shadow-xl text-xs py-1`,children:[c.jsx(Q_,{children:"Edit"}),c.jsx(dd,{label:"Rename",onClick:x}),c.jsx(dd,{label:"Duplicate",onClick:T}),c.jsx(dd,{label:"Delete document",danger:!0,onClick:()=>{w(),m(!0)}}),c.jsx(yS,{}),c.jsx(Q_,{children:"Open"}),c.jsx(dd,{label:"Open in default app",onClick:R}),c.jsx(dd,{label:"Reveal in OS",onClick:F}),c.jsx(yS,{}),c.jsx(Q_,{children:"Export"}),c.jsx(dd,{label:"Copy as Markdown",onClick:N}),c.jsx(dd,{label:"Add to Claude context",onClick:L,disabled:!C,title:C?void 0:"No terminal tab is active"})]})]}),l&&c.jsx(YM,{value:a,onChange:d,onCancel:()=>p(!1),onConfirm:()=>void S()}),f&&c.jsx(XM,{name:b,onCancel:()=>m(!1),onConfirm:()=>void j()})]})}function Q_({children:i}){return c.jsx("div",{className:"px-3 pt-1 pb-0.5 text-[9px] uppercase tracking-wide text-fg-faint",children:i})}function dd({label:i,onClick:e,danger:t,disabled:n,title:r}){return c.jsx("button",{onClick:e,disabled:n,title:r,className:`w-full text-left px-3 py-1.5 transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${t?"text-red-400 hover:bg-bg-hi":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:i})}function yS(){return c.jsx("div",{className:"my-1 border-t border-line"})}function YM({value:i,onChange:e,onCancel:t,onConfirm:n}){return c.jsx("div",{className:`fixed inset-0 ${dn.contextMenuDialog} flex items-center justify-center bg-black/60`,onMouseDown:r=>{r.target===r.currentTarget&&t()},children:c.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[c.jsx("h3",{className:"text-sm font-medium text-fg mb-3",children:"Rename"}),c.jsx("input",{autoFocus:!0,value:i,onChange:r=>e(r.target.value),onKeyDown:r=>{r.key==="Enter"?n():r.key==="Escape"&&t()},className:"w-full px-2 py-1 text-xs bg-bg border border-line rounded text-fg mb-3"}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx("button",{onClick:t,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"}),c.jsx("button",{onClick:n,className:"px-3 py-1 text-xs text-white rounded bg-accent hover:bg-accent/90",children:"Rename"})]})]})})}function XM({name:i,onCancel:e,onConfirm:t}){return c.jsx("div",{className:`fixed inset-0 ${dn.contextMenuDialog} flex items-center justify-center bg-black/60`,onMouseDown:n=>{n.target===n.currentTarget&&e()},children:c.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[c.jsxs("h3",{className:"text-sm font-medium text-fg mb-3",children:["Delete ",i,"? This cannot be undone."]}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx("button",{onClick:e,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"}),c.jsx("button",{onClick:t,className:"px-3 py-1 text-xs text-white rounded bg-red-600 hover:bg-red-500",children:"Delete"})]})]})})}function JM(){const[i,e]=z.useState(!1),t=_d();return c.jsxs("div",{className:"relative inline-block mr-1",children:[c.jsx("button",{onClick:()=>e(n=>!n),className:`px-2 py-0.5 text-[10px] border border-line rounded ${i?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Display preferences",children:"Display"}),i&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:`fixed inset-0 ${dn.contextMenuScrim}`,onMouseDown:()=>e(!1)}),c.jsxs("div",{className:`absolute right-0 top-full mt-1 ${dn.contextMenu} w-60 rounded-lg border border-line bg-bg-elev shadow-xl text-xs p-2 space-y-1.5`,children:[c.jsx(fh,{label:"Text size",children:c.jsxs("div",{className:"flex items-center rounded border border-line overflow-hidden",children:[c.jsx("button",{onClick:()=>t.bumpFontSize(-1),className:"px-1.5 py-0.5 text-[11px] text-fg-faint hover:text-fg",title:"Zoom out",children:"A−"}),c.jsx("span",{className:"px-2 text-[10px] text-fg-dim",children:t.fontSize}),c.jsx("button",{onClick:()=>t.bumpFontSize(1),className:"px-1.5 py-0.5 text-[11px] text-fg-faint hover:text-fg",title:"Zoom in",children:"A+"})]})}),c.jsx(fh,{label:"Word wrap",children:c.jsx(Qg,{on:t.wordWrap,onClick:t.toggleWordWrap})}),c.jsx(fh,{label:"Minimap",children:c.jsx(Qg,{on:t.minimap,onClick:t.toggleMinimap})}),c.jsx(fh,{label:"Theme",children:c.jsx("button",{onClick:()=>t.setTheme(t.theme==="dark"?"paper":"dark"),className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded",title:"Toggle editor theme",children:t.theme==="dark"?"Dark":"Paper"})}),c.jsx(fh,{label:"Autosave",children:c.jsx(Qg,{on:t.autosave,onClick:t.toggleAutosave})}),c.jsx(fh,{label:"Wide measure",children:c.jsx(Qg,{on:t.wideMeasure,onClick:t.toggleWideMeasure})})]})]})]})}function fh({label:i,children:e}){return c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("span",{className:"text-fg-faint",children:i}),e]})}function Qg({on:i,onClick:e}){return c.jsx("button",{onClick:e,className:`px-2 py-0.5 text-[10px] rounded border border-line ${i?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:i?"On":"Off"})}const ZM=z.lazy(()=>fi(()=>import("./TiptapBody-C_XjtJ82.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(i=>({default:i.TiptapBody})));function ev(i,e){if(!e.length)return i;const t=new Set(e),n={};for(const[r,l]of Object.entries(i))t.has(r)||(n[r]=l);return n}function tv(i){return Fk(i)||Hk(i)}function QM(){const i=Uw(),e=Ci(Je=>Je.openFiles),t=Ci(Je=>Je.activeFilePath),n=Ci(Je=>Je.dirty),r=Ci(Je=>Je.viewMode),l=Ci(Je=>Je.buffers),p=Ci(Je=>Je.setActive),a=Ci(Je=>Je.closeFile),d=Ci(Je=>Je.closeOthers),f=Ci(Je=>Je.closeToTheRight),m=Ci(Je=>Je.closeAll),g=Ci(Je=>Je.loadBuffer),y=Ci(Je=>Je.setBuffer),D=Ci(Je=>Je.markSaved),E=Ci(Je=>Je.setViewMode),C=_d(),[b,w]=z.useState({}),[x,S]=z.useState({}),[T,j]=z.useState(null),[N,L]=z.useState(null),[R,F]=z.useState(!1),[V,te]=z.useState(!1),[he,ee]=z.useState(!0),we=z.useRef(null),ce=z.useRef(null),ve=z.useRef(void 0),Ee=z.useRef(null),fe=z.useRef(null),U=GM(t??"",l[t??""]??""),X=z.useCallback(Je=>{we.current=Je},[]),W=z.useCallback(()=>we.current,[]);z.useEffect(()=>{Ij()},[]),z.useEffect(()=>{const Je=t;if(!Je||tv(Je))return;if(Ci.getState().hasBuffer(Je)){w(_t=>_t[Je]==="ready"?_t:{..._t,[Je]:"ready"});return}let Pt=!1;return w(_t=>({..._t,[Je]:"loading"})),window.api.files.read(Je).then(_t=>{Pt||(_t.binary?w(hi=>({...hi,[Je]:{binary:!0,size:_t.size??0,mime:_t.mime??"application/octet-stream",reason:_t.error??"Binary file"}})):_t.ok?(g(Je,_t.text),w(hi=>({...hi,[Je]:"ready"}))):w(hi=>({...hi,[Je]:{error:_t.error??"failed to read"}})))}),()=>{Pt=!0}},[t,g]),z.useEffect(()=>{L(null)},[t]);const Q=z.useCallback(async(Je,Pt=!1)=>{const _t=Ci.getState().buffers[Je];if(_t==null)return;Pt&&F(!0);const hi=await window.api.files.write(Je,_t);hi.ok?(D(Je),S(Se=>({...Se,[Je]:(Se[Je]??0)+1})),Pt||Qe.info(`Saved ${ba(Je)}`)):Qe.error(hi.error??`Couldn't save ${ba(Je)}`),Pt&&F(!1)},[D]);z.useEffect(()=>{if(!C.autosave)return;const Je=t;if(!(!Je||tv(Je)||!n[Je]))return window.clearTimeout(ve.current),ve.current=window.setTimeout(()=>{Q(Je,!0)},1200),()=>window.clearTimeout(ve.current)},[C.autosave,t,n,l,Q]);const oe=z.useCallback(Je=>{Je.length&&(w(Pt=>ev(Pt,Je)),S(Pt=>ev(Pt,Je)))},[]),Ce=z.useCallback((Je,Pt)=>{w(_t=>Je in _t?{...ev(_t,[Je]),[Pt]:_t[Je]}:_t),S(_t=>Je in _t?{...ev(_t,[Je]),[Pt]:_t[Je]}:_t)},[]),Oe=z.useCallback(Je=>{n[Je]?j({kind:"one",path:Je}):(a(Je),oe([Je]))},[n,a,oe]),Xe=z.useCallback(Je=>{e.some(_t=>_t.path!==Je&&n[_t.path])?j({kind:"others",path:Je}):(d(Je),oe(e.filter(_t=>_t.path!==Je).map(_t=>_t.path)))},[e,n,d,oe]),ge=z.useCallback(Je=>{const Pt=e.findIndex(hi=>hi.path===Je);Pt!==-1&&e.slice(Pt+1).some(hi=>n[hi.path])?j({kind:"right",path:Je}):(f(Je),oe(Pt!==-1?e.slice(Pt+1).map(hi=>hi.path):[]))},[e,n,f,oe]);z.useEffect(()=>{const Je=Pt=>{if(i.current)if((Pt.metaKey||Pt.ctrlKey)&&(Pt.key==="s"||Pt.key==="S")){const _t=Ci.getState().activeFilePath;_t&&!tv(_t)&&(Pt.preventDefault(),Q(_t))}else if((Pt.metaKey||Pt.ctrlKey)&&Pt.shiftKey&&(Pt.key==="f"||Pt.key==="F"))Pt.preventDefault(),te(_t=>!_t);else if((Pt.metaKey||Pt.ctrlKey)&&Pt.shiftKey&&(Pt.key==="w"||Pt.key==="W")){const _t=Ci.getState().activeFilePath;_t&&Ci.getState().openFiles.length>1&&(Pt.preventDefault(),Xe(_t))}else Pt.key==="Escape"&&U.state.phase!=="idle"?U.cancel():Pt.key==="Escape"&&V&&te(!1)};return window.addEventListener("keydown",Je),()=>window.removeEventListener("keydown",Je)},[Q,V,Xe,U.state.phase,U.cancel]),z.useEffect(()=>{if(U.state.phase==="idle")return;const Je=Pt=>{var hi,Se;const _t=Pt.target;(hi=fe.current)!=null&&hi.contains(_t)||(Se=Ee.current)!=null&&Se.contains(_t)||U.cancel()};return window.addEventListener("mousedown",Je),()=>window.removeEventListener("mousedown",Je)},[U.state.phase,U.cancel]),z.useEffect(()=>{U.cancel()},[t,U.cancel]);const J=z.useCallback(()=>{e.some(Pt=>n[Pt.path])?j({kind:"all",path:""}):(m(),w({}),S({}))},[e,n,m]),je=()=>{if(T){if(T.kind==="one")a(T.path),oe([T.path]);else if(T.kind==="others"){const Je=e.filter(Pt=>Pt.path!==T.path).map(Pt=>Pt.path);d(T.path),oe(Je)}else if(T.kind==="right"){const Je=e.findIndex(_t=>_t.path===T.path),Pt=Je!==-1?e.slice(Je+1).map(_t=>_t.path):[];f(T.path),oe(Pt)}else m(),w({}),S({});j(null)}};if(e.length===0)return c.jsx("div",{className:"h-full flex items-center justify-center text-fg-faint text-xs",children:c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:"mb-2",children:"no file open"}),c.jsxs("div",{children:["open the ",c.jsx("span",{className:"text-fg-dim",children:"File Explorer"})," tab and click a file to edit it here"]})]})});const de=t,Ie=de?ba(de):"",Pe=de?b[de]:void 0,Ye=de?Vk(de):!1,ft=de?Tj(de):!1,rt=de&&Ye?r[de]??Dj(de):"edit",Nt=!!de&&!tv(de)&&Pe==="ready",mt=Nt,mi=ft?["edit","wysiwyg","preview","split"]:Ye?["edit","preview"]:[],di=de&&c.jsx(iN,{path:de,name:Ie,value:l[de]??"",onChange:Je=>y(de,Je),onSave:()=>void Q(de),onReady:X,onCursor:L}),_i=R?"Saving…":de&&n[de]?C.autosave?"Editing…":"Unsaved":"All changes saved";return c.jsxs("div",{className:"relative flex flex-col h-full bg-bg",children:[!V&&c.jsx(Wj,{openFiles:e,activeFilePath:t,dirty:n,onSelectFile:p,onCloseFile:Oe,onCloseOthers:Xe,onCloseToTheRight:ge,onCloseAll:J}),de&&!V&&c.jsxs("div",{className:"flex items-center px-3 h-8 border-b border-line shrink-0 bg-bg-elev",children:[c.jsx("span",{className:"text-xs font-medium text-fg truncate",children:Ie}),c.jsx("span",{className:"ml-3 text-[10px] text-fg-faint truncate",children:de}),Nt&&c.jsxs("span",{className:"ml-3 text-[10px] text-fg-faint shrink-0",children:["· ",_i]}),nl(de)&&(rt==="preview"||rt==="split")&&c.jsx("button",{onClick:()=>ee(Je=>!Je),className:`ml-3 px-2 py-0.5 text-[10px] border border-line rounded ${he?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle document outline",children:"Outline"}),nl(de)&&(rt==="preview"||rt==="split")&&c.jsx("button",{onClick:C.toggleAssistantRail,className:`ml-1 px-2 py-0.5 text-[10px] border border-line rounded ${C.assistantRail?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle Assistant rail",children:"Assistant"}),mi.length>0&&c.jsx("div",{className:"flex items-center ml-2 rounded border border-line overflow-hidden",children:mi.map(Je=>c.jsx("button",{onClick:()=>E(de,Je),className:`px-2 py-0.5 text-[10px] capitalize transition-colors ${rt===Je?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:Je},Je))}),c.jsx("div",{className:"flex-1"}),c.jsx(KM,{path:de,onRenamed:Ce,onDeleted:Je=>oe([Je])}),Nt&&c.jsx(JM,{}),c.jsx("button",{onClick:()=>te(!0),className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded",title:"Focus mode (Cmd/Ctrl-Shift-F)",children:"Focus"})]}),V&&c.jsx("button",{onClick:()=>te(!1),className:"absolute top-2 right-3 z-10 px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded bg-bg-elev/80",title:"Exit focus mode (Esc)",children:"Exit focus"}),c.jsx("div",{className:"flex-1 min-h-0",children:de?Fk(de)?c.jsx(kM,{path:de,name:Ie}):Hk(de)?c.jsx(EM,{path:de}):Pe&&typeof Pe=="object"&&"binary"in Pe?c.jsx(PM,{path:de,name:Ie,size:Pe.size,mime:Pe.mime,reason:Pe.reason}):Pe&&typeof Pe=="object"&&"error"in Pe?c.jsx("div",{className:"p-6 text-xs text-red-400",children:Pe.error}):Pe!=="ready"?c.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"loading…"}):rt==="wysiwyg"&&nl(de)?c.jsx(z.Suspense,{fallback:c.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading editor…"}),children:c.jsx(ZM,{value:l[de]??"",onChange:Je=>y(de,Je)},de)}):rt==="split"&&nl(de)?c.jsxs("div",{className:"flex h-full",children:[he&&c.jsx(gS,{text:l[de]??"",scrollRef:ce}),c.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-line",children:[c.jsx(mS,{getEditor:W}),c.jsx("div",{className:"flex-1 min-h-0",children:di})]}),c.jsx("div",{ref:Ee,className:"flex-1 min-w-0",children:c.jsx(uw,{ref:ce,text:l[de]??"",flush:!0,wideMeasure:C.wideMeasure,onSelect:U.select,onDismissSelection:U.cancel})}),!V&&C.assistantRail&&c.jsx(wS,{phase:U.state.phase,transcript:U.state.transcript,diff:U.state.diff,editCount:U.state.editCount,modelStatus:U.state.modelStatus,onListen:U.listen,onSendHeard:U.sendHeard,onCancel:U.cancel,onAccept:()=>{const Je=U.accept(l[de]??"");Je.ok&&y(de,Je.next)},onReject:U.cancel,onRetry:U.retry})]}):rt==="preview"&&nl(de)?c.jsxs("div",{className:"flex h-full",children:[he&&c.jsx(gS,{text:l[de]??"",scrollRef:ce}),c.jsx("div",{ref:Ee,className:"flex-1 min-w-0",children:c.jsx(uw,{ref:ce,text:l[de]??"",wideMeasure:C.wideMeasure,onSelect:U.select,onDismissSelection:U.cancel})}),!V&&C.assistantRail&&c.jsx(wS,{phase:U.state.phase,transcript:U.state.transcript,diff:U.state.diff,editCount:U.state.editCount,modelStatus:U.state.modelStatus,onListen:U.listen,onSendHeard:U.sendHeard,onCancel:U.cancel,onAccept:()=>{const Je=U.accept(l[de]??"");Je.ok&&y(de,Je.next)},onReject:U.cancel,onRetry:U.retry})]}):rt==="preview"&&Gk(de)?c.jsx(SM,{path:de,dirty:!!n[de],reloadToken:x[de]??0}):rt==="preview"&&Wk(de)?c.jsx(DM,{path:de,text:l[de]??""}):rt==="preview"&&Uk(de)?c.jsx(IM,{path:de,text:l[de]??""}):nl(de)?c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsx(mS,{getEditor:W}),c.jsx("div",{className:"flex-1 min-h-0",children:di})]}):di:null}),mt&&c.jsx(xM,{text:l[de]??"",cursor:N,language:Ur(de)||void 0}),de&&nl(de)&&(rt==="preview"||rt==="split")&&U.state.phase!=="idle"&&U.state.selection&&c.jsx("div",{ref:fe,children:c.jsx(UM,{phase:U.state.phase,rect:U.state.selection.rect,selectedText:U.state.selection.text,diff:U.state.diff,transcript:U.state.transcript,modelStatus:U.state.modelStatus,onQuickAction:U.run,onRunCustom:U.run,onListen:U.listen,onSendHeard:U.sendHeard,onCancel:U.cancel,onReject:U.cancel,onRetry:U.retry,onAccept:()=>{const Je=U.accept(l[de]??"");Je.ok&&y(de,Je.next)}})}),T&&c.jsx(eO,{message:T.kind==="one"?`Discard unsaved changes to ${ba(T.path)}?`:T.kind==="others"?"Discard unsaved changes in the other open files?":T.kind==="right"?"Discard unsaved changes in the files to the right?":"Discard unsaved changes in all open files?",onCancel:()=>j(null),onConfirm:je})]})}const fw=z.memo(QM);function eO({message:i,onCancel:e,onConfirm:t}){return c.jsx("div",{className:`fixed inset-0 ${dn.contextMenuDialog} flex items-center justify-center bg-black/60`,onMouseDown:n=>{n.target===n.currentTarget&&e()},children:c.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[c.jsx("h3",{className:"text-sm font-medium text-fg mb-3",children:i}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx("button",{onClick:e,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"}),c.jsx("button",{onClick:t,className:"px-3 py-1 text-xs text-white rounded bg-red-600 hover:bg-red-500",children:"Discard"})]})]})})}const tO={sm:"max-w-md",md:"max-w-xl",lg:"max-w-3xl",xl:"max-w-5xl",full:"max-w-[min(96vw,1400px)]"},xS='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function s_({open:i,onClose:e,children:t,title:n,size:r="sm",fillHeight:l=!1,noPadding:p=!1,variant:a="overlay"}){if(a==="page")return i?c.jsxs("div",{className:"h-full w-full flex flex-col bg-bg",children:[n&&c.jsx("h2",{className:`text-base font-medium text-fg ${p?"px-6 pt-6 pb-3":"px-6 pt-4 pb-2"}`,children:n}),c.jsx("div",{className:`flex-1 min-h-0 min-w-0 flex flex-col ${p?"":"p-6 pt-0"}`,children:t})]}):null;const d=z.useRef(null),f=z.useRef(null),m=z.useRef(e);if(m.current=e,z.useEffect(()=>{if(!i)return;f.current=typeof document<"u"?document.activeElement:null;const E=setTimeout(()=>{const b=d.current;if(!b)return;const w=b.querySelector(xS);w?w.focus():b.focus()},0),C=b=>{if(b.key==="Escape"){b.stopPropagation(),m.current();return}if(b.key==="Tab"){const w=d.current;if(!w)return;const x=Array.from(w.querySelectorAll(xS)).filter(N=>!N.hasAttribute("disabled")&&N.tabIndex!==-1);if(x.length===0){b.preventDefault(),w.focus();return}const S=x[0],T=x[x.length-1],j=document.activeElement;b.shiftKey?(j===S||!w.contains(j))&&(b.preventDefault(),T.focus()):(j===T||!w.contains(j))&&(b.preventDefault(),S.focus())}};return document.addEventListener("keydown",C),()=>{clearTimeout(E),document.removeEventListener("keydown",C);const b=f.current;if(b&&b instanceof HTMLElement)try{b.focus()}catch{}f.current=null}},[i]),!i)return null;const g=D=>{D.target===D.currentTarget&&e()},y=c.jsx("div",{className:`fixed inset-0 ${dn.dialog} flex items-center justify-center bg-black/60`,onClick:g,"data-testid":"modal-backdrop",children:c.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","aria-label":n??"Dialog",tabIndex:-1,className:`bg-bg-elev border border-line rounded-lg shadow-xl w-full mx-4 outline-none flex flex-col break-words ${tO[r]} ${l?"max-h-[90vh] h-[90vh]":""} ${p?"":"p-6"}`,"data-testid":"modal-dialog",children:[n?c.jsx("h2",{className:`text-base font-medium text-fg break-words ${p?"px-6 pt-6 pb-3":"mb-3"}`,children:n}):null,l?c.jsx("div",{className:"flex-1 min-h-0 min-w-0 flex flex-col",children:t}):t]})});return typeof document<"u"&&document.body?Th.createPortal(y,document.body):y}class bE extends z.Component{constructor(){super(...arguments);Gi(this,"state",{error:null});Gi(this,"reset",()=>this.setState({error:null}))}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[ErrorBoundary]",t,n)}render(){return this.state.error?this.props.fallback?this.props.fallback(this.state.error,this.reset):c.jsxs("div",{className:"p-6 text-xs",children:[c.jsx("div",{className:"text-red-400 mb-2",children:"something broke in this panel"}),c.jsx("pre",{className:"text-fg-faint whitespace-pre-wrap mb-3",children:this.state.error.message}),c.jsx("button",{onClick:this.reset,className:"px-2 py-0.5 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"retry"})]}):this.props.children}}function iO({open:i,onClose:e,title:t,children:n,variant:r="overlay"}){return c.jsxs(s_,{open:i,onClose:e,size:"xl",fillHeight:!0,noPadding:!0,title:void 0,variant:r,children:[r==="overlay"&&c.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-line shrink-0",children:[c.jsx("h2",{className:"text-xs uppercase tracking-wider text-fg-dim",children:t}),c.jsx("button",{type:"button",onClick:e,"aria-label":"Close",className:"px-2 py-0.5 text-fg-dim hover:text-fg hover:bg-bg-hi rounded text-base leading-none",children:"✕"})]}),c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:c.jsx(bE,{children:n})})]})}function wE(i,e={}){switch(i){case"ready":return e.isRecording?"Stop voice input":"Start voice input (on-device, offline)";case"idle":return"Microphone — speech model not started";case"loading":return`Microphone — loading speech model, ${typeof e.loadingPct=="number"?Math.round(e.loadingPct):0} percent`;case"error":return e.errorMessage?`Microphone — speech model error: ${e.errorMessage}. Activate to retry.`:"Microphone — speech model error. Activate to retry.";case"load-timeout":return"Microphone — model load timed out. Activate to retry.";case"permission-denied":return"Microphone — permission denied. Open OS settings.";case"unsupported":return"Microphone — voice input not supported in this build."}}const SS=i=>Symbol.iterator in i,CS=i=>"entries"in i,kS=(i,e)=>{const t=i instanceof Map?i:new Map(i.entries()),n=e instanceof Map?e:new Map(e.entries());if(t.size!==n.size)return!1;for(const[r,l]of t)if(!n.has(r)||!Object.is(l,n.get(r)))return!1;return!0},nO=(i,e)=>{const t=i[Symbol.iterator](),n=e[Symbol.iterator]();let r=t.next(),l=n.next();for(;!r.done&&!l.done;){if(!Object.is(r.value,l.value))return!1;r=t.next(),l=n.next()}return!!r.done&&!!l.done};function sO(i,e){return Object.is(i,e)?!0:typeof i!="object"||i===null||typeof e!="object"||e===null||Object.getPrototypeOf(i)!==Object.getPrototypeOf(e)?!1:SS(i)&&SS(e)?CS(i)&&CS(e)?kS(i,e):nO(i,e):kS({entries:()=>Object.entries(i)},{entries:()=>Object.entries(e)})}function by(i){const e=Rt.useRef(void 0);return t=>{const n=i(t);return sO(e.current,n)?e.current:e.current=n}}let ES=0;const rO=1e3;function oO(i){const e=performance.now();e-ES<rO||(ES=e,ut.debug("voice","mic.gate.click_rejected",{reason:i}))}function aO(){const i=kt(f=>f.isRecording),e=kt(f=>f.error),t=kt(f=>f.loadingProgress),n=kt(by($v)),r=()=>{const f=kt.getState(),{canRecord:m,reason:g}=$v(f);if(f.isRecording)return f.stopRecording();if(f.wizardArmed&&!f.wizardOpen){f.openWizard();return}if(g==="error"||g==="load-timeout"){f.resetAndRetryModel();return}if(!m)return oO(g);const y=Ct.getState().activeTabId;y&&f.startRecording(y)},l=wE(n.reason,{loadingPct:t,errorMessage:e,isRecording:i}),p=n.reason==="unsupported",a=!n.canRecord,d=n.reason==="loading"?"text-fg-faint animate-pulse cursor-wait":n.reason==="error"||n.reason==="load-timeout"?"text-red-400 cursor-pointer":n.reason==="permission-denied"?"text-amber-400 cursor-pointer":n.reason==="idle"?"text-fg-faint cursor-pointer":n.reason==="unsupported"?"text-fg-faint cursor-not-allowed":i?"text-red-400 ring-2 ring-red-400 animate-pulse":"text-fg-dim hover:text-fg";return c.jsx("button",{onClick:r,disabled:p,"aria-disabled":a,"aria-label":l,title:l,"data-testid":"mic-button","data-state":n.reason,className:`p-1.5 rounded transition-colors ${d}`,children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{x:"9",y:"1",width:"6",height:"12",rx:"3"}),c.jsx("path",{d:"M5 10a7 7 0 0 0 14 0"}),c.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"}),c.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]})})}function lO(){const i=kt(t=>t.ttsEnabled),e=kt(t=>t.toggleTTS);return c.jsxs("button",{onClick:e,title:i?"Read Claude replies aloud: ON":"Read Claude replies aloud: OFF",className:`px-1.5 py-1 rounded transition-colors flex items-center gap-1 ${i?"text-accent":"text-fg-dim hover:text-fg"}`,children:[c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),i?c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),c.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):c.jsxs(c.Fragment,{children:[c.jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),c.jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]}),c.jsx("span",{className:"text-[10px] font-medium tracking-wide",children:"TTS"})]})}function cO(i){return/^monitor of /i.test(i.trim())}function TS(i){return i.replace(/\s*\([^)]*\)\s*$/,"").replace(/\s*#\d+\s*$/,"").replace(/\s+/g," ").trim().toLowerCase()}function DS(i,e,t){if(i){const p=t.find(a=>a.deviceId===i);if(p)return p}if(!e)return null;const n=t.filter(p=>p.label===e);if(n.length===1)return n[0];if(n.length>1)return null;const r=TS(e),l=t.filter(p=>p.label&&TS(p.label)===r);return l.length===1?l[0]:null}async function $S(i){var t;return(t=navigator.mediaDevices)!=null&&t.enumerateDevices?(await navigator.mediaDevices.enumerateDevices()).filter(n=>!(n.kind!=="audioinput"||n.label&&cO(n.label))):[]}const AS=!1;function yE(){const i=kt(f=>f.isRecording);kt(f=>f.startRecording),kt(f=>f.stopRecording);const[e,t]=z.useState([]),[n,r]=z.useState(null),[l,p]=z.useState(null);z.useEffect(()=>{let f=!1;return(async()=>{try{const m=await window.api.voice.getDevicePref();if(f)return;const g=await $S(AS);if(f)return;t(g),p(m.selectedLabel);const y=DS(m.selectedDeviceId,m.selectedLabel,g);y?(r(y.deviceId),m.selectedDeviceId&&y.deviceId!==m.selectedDeviceId&&(ut.info("voice","device-picker rebind-by-label",{fromIdPrefix:m.selectedDeviceId.slice(0,8),toIdPrefix:y.deviceId.slice(0,8)}),await window.api.voice.setDevicePref({selectedDeviceId:y.deviceId,selectedLabel:y.label||m.selectedLabel}).catch(()=>{}))):((m.selectedDeviceId||m.selectedLabel)&&(console.warn("[MicDevicePicker] previously-selected device unavailable; falling back to OS default",{savedLabel:m.selectedLabel,hadId:!!m.selectedDeviceId}),ut.warn("voice","device-picker selected-unavailable",{hadId:!!m.selectedDeviceId})),r(null))}catch(m){ut.warn("voice","device-picker init failed",{error:m instanceof Error?m.message:String(m)})}})(),()=>{f=!0}},[]);const a=z.useCallback(async()=>{try{const f=await $S(AS);if(t(f),n&&!f.some(m=>m.deviceId===n)){const m=DS(null,l,f);m?(r(m.deviceId),await window.api.voice.setDevicePref({selectedDeviceId:m.deviceId,selectedLabel:m.label||l}).catch(()=>{})):r(null)}}catch(f){ut.warn("voice","device-picker refresh failed",{error:f instanceof Error?f.message:String(f)})}},[n,l]);z.useEffect(()=>{const f=()=>{a()};return window.addEventListener("mic-device-change",f),()=>window.removeEventListener("mic-device-change",f)},[a]);const d=async f=>{var D;const m=f.target.value,g=m===""?null:m,y=g?((D=e.find(E=>E.deviceId===g))==null?void 0:D.label)??null:null;r(g),p(y);try{await window.api.voice.setDevicePref({selectedDeviceId:g,selectedLabel:y}),ut.info("voice","device-picker selected",{deviceIdPrefix:g?g.slice(0,8):null})}catch(E){ut.warn("voice","setDevicePref failed",{error:E instanceof Error?E.message:String(E)})}if(i)try{await kt.getState().restartWithDevice()}catch(E){ut.warn("voice","device-picker restart failed",{error:E instanceof Error?E.message:String(E)})}};return c.jsxs("select",{value:n??"",onChange:d,onFocus:()=>{a()},title:"Microphone input device","data-testid":"mic-device-picker",className:"text-[10px] bg-bg border border-line text-fg-dim hover:text-fg rounded px-1.5 py-1 max-w-[8rem] truncate",children:[c.jsx("option",{value:"",children:"Default"}),e.map(f=>c.jsx("option",{value:f.deviceId,children:f.label||`Mic ${f.deviceId.slice(0,6)}`},f.deviceId))]})}function dO(){const i=kt(D=>D.isRecording),e=kt(D=>D.levelMeterEnabled),[t,n]=z.useState(0),[r,l]=z.useState(0),p=z.useRef(0);p.current=r;const[a,d]=z.useState(0),[f,m]=z.useState(!1),g=z.useRef(null);if(z.useEffect(()=>{if(!i||!e){n(0),l(0);return}let D=0,E=!1,C=null,b=null;const w=()=>{if(E)return;const S=b??EC();if(!S){D=requestAnimationFrame(w);return}b!==S&&(b=S,C=new Uint8Array(new ArrayBuffer(S.fftSize)));const T=C;S.getByteTimeDomainData(T);let j=0;for(let F=0;F<T.length;F++){const V=T[F]-128;j+=V*V}const N=Math.sqrt(j/T.length)/128,L=N>0?20*Math.log10(N):-60,R=Math.max(0,Math.min(1,(L+60)/60));l(N),n(R),N>=.95&&(m(!0),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>m(!1),150)),D=requestAnimationFrame(w)};D=requestAnimationFrame(w);const x=setInterval(()=>{E||d(Math.round(p.current*100))},250);return()=>{E=!0,cancelAnimationFrame(D),clearInterval(x),g.current&&(clearTimeout(g.current),g.current=null)}},[i,e]),!i||!e)return null;const y=f?"bg-red-500":r>=.7?"bg-amber-400":"bg-green-500";return c.jsx("div",{role:"meter","aria-label":"Microphone input level","aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,"data-testid":"mic-level-meter",className:`mx-3 mb-2 h-1 rounded bg-bg overflow-hidden ${f?"ring-1 ring-red-500":""}`,children:c.jsx("div",{className:`h-full ${y} transition-[width] duration-75 ease-out`,style:{width:`${t*100}%`}})})}function xE(){const i=kt(f=>f.submitCountdownStartAt),e=kt(f=>f.submitDelayMs),[t,n]=z.useState(()=>performance.now());if(z.useEffect(()=>{if(i===null)return;let f;const m=()=>{n(performance.now()),f=requestAnimationFrame(m)};return f=requestAnimationFrame(m),()=>cancelAnimationFrame(f)},[i]),i===null)return null;const r=t-i,l=Math.max(0,e-r),p=Math.max(0,Math.min(100,l/e*100)),a=l<500,d=kt.getState().cancelSubmit;return c.jsx("div",{className:"px-3 pb-1",onClick:d,title:`Submitting in ${(l/1e3).toFixed(1)}s — click to cancel`,children:c.jsx("div",{className:"h-0.5 w-full bg-bg rounded overflow-hidden cursor-pointer",children:c.jsx("div",{className:`h-full transition-colors ${a?"bg-amber-400":"bg-accent"}`,style:{width:`${p}%`}})})})}function uO({open:i,onClose:e,variant:t="overlay"}){return c.jsx(iO,{open:i,onClose:e,title:"Voice / Microphone",variant:t,children:c.jsxs("div",{className:"p-4 space-y-4",children:[c.jsx(mO,{}),c.jsx(xE,{}),c.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c.jsx(aO,{}),c.jsx(yE,{}),c.jsx(lO,{})]}),c.jsx(hO,{}),c.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[c.jsx("button",{type:"button",onClick:()=>kt.getState().openWizard(),className:"text-xs text-fg-faint hover:text-fg-dim underline","data-testid":"run-mic-check",children:"Run mic check"}),c.jsx(fO,{})]}),c.jsx(dO,{})]})})}function hO(){const i=kt(l=>l.isRecording),[e,t]=z.useState(null);if(z.useEffect(()=>{let l=!1;window.api.voice.getHotkeyConfig().then(a=>{l||t(a)}).catch(()=>{});const p=window.api.voice.onHotkeyConfigChanged(a=>t(a));return()=>{l=!0,p()}},[]),i||!e)return null;const n=e.mode==="hold"?"Hold":"Press",r=pO(e.accelerator);return c.jsxs("div",{className:"text-[11px] text-fg-faint",children:[c.jsxs("span",{children:[n," "]}),c.jsx("kbd",{className:"px-1 py-0.5 rounded border border-line bg-bg font-mono text-fg-dim",children:r}),c.jsx("span",{children:" to record"})]})}function pO(i){const e=typeof navigator<"u"&&/Mac/.test(navigator.platform);return i.replace(/CommandOrControl/g,e?"⌘":"Ctrl").replace(/CmdOrCtrl/g,e?"⌘":"Ctrl").replace(/Command/g,"⌘").replace(/Control/g,"Ctrl").replace(/Option/g,e?"⌥":"Alt").replace(/Shift/g,e?"⇧":"Shift")}function fO(){const[i,e]=z.useState(null);if(z.useEffect(()=>{let n=!1;window.api.voice.getHotkeyConfig().then(l=>{n||e(l)}).catch(l=>ut.warn("voice-hotkey","getHotkeyConfig (toggle) failed",{error:String(l)}));const r=window.api.voice.onHotkeyConfigChanged(l=>{e(l)});return()=>{n=!0,r()}},[]),!i)return null;const t=async n=>{if(i.mode===n)return;const r={...i,mode:n};e(r);try{await window.api.voice.setHotkeyConfig(r)}catch(l){ut.warn("voice-hotkey","setHotkeyConfig (toggle) failed",{error:l instanceof Error?l.message:String(l)})}};return c.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-fg-faint select-none",title:"Mic hotkey behavior. Tap on/off: press once to start, again to stop. Hold to talk: record only while held (push-to-talk).",children:[c.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[c.jsx("input",{type:"radio",name:"hotkey-mode",checked:i.mode==="toggle",onChange:()=>t("toggle"),className:"cursor-pointer","data-testid":"hotkey-mode-toggle"}),c.jsx("span",{children:"Tap on/off"})]}),c.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[c.jsx("input",{type:"radio",name:"hotkey-mode",checked:i.mode==="hold",onChange:()=>t("hold"),className:"cursor-pointer","data-testid":"hotkey-mode-hold"}),c.jsx("span",{children:"Hold to talk"})]})]})}function mO(){const i=kt(l=>l.isRecording),e=kt(l=>l.lastTranscript),t=kt(l=>l.error),n=kt(l=>l.modelStatus),r=kt(l=>l.loadingProgress);return t?c.jsxs("div",{className:"text-[11px] text-red-400",title:t,children:["⚠ ",t]}):i?c.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-fg-dim border border-line rounded px-2 py-1.5",children:[c.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-red-400 animate-pulse shrink-0"}),c.jsx("span",{className:"truncate",title:e,children:e||"Listening…"})]}):n==="loading"?c.jsxs("div",{className:"text-[11px] text-fg-faint",children:[c.jsxs("div",{className:"flex items-center justify-between mb-1",children:[c.jsx("span",{children:"Loading speech model"}),c.jsxs("span",{className:"font-mono",children:[r,"%"]})]}),c.jsx("div",{className:"h-1 rounded bg-bg overflow-hidden",children:c.jsx("div",{className:"h-full bg-accent transition-[width] duration-200",style:{width:`${r}%`}})})]}):null}const SE="~/.claude/session-manager/projects-prefs.json";let IS=Promise.resolve(),iv=null;function PS(i){const e=IS.then(i);return IS=e.catch(()=>{}),e}async function jS(){const i=await window.api.config.readJson(SE);if(i.exists&&i.data&&typeof i.data=="object"){const e=i.data.pinned;if(e&&typeof e=="object")return{...e}}return{}}const eb=jn(i=>({pinned:{},hydrated:!1,hydrate:()=>iv||(iv=PS(async()=>{try{i({pinned:await jS(),hydrated:!0})}catch(e){console.warn("projectsPrefs: could not read launcher pins",e),i({hydrated:!0})}}),iv),togglePin:e=>{PS(async()=>{let t;try{t=await jS()}catch(r){console.warn("projectsPrefs: could not read launcher pins",r),Qe.error("Could not update pinned projects: the preferences file is unreadable.");return}const n={...t};n[e]?delete n[e]:n[e]=!0;try{await window.api.config.writeJson(SE,{pinned:n}),i({pinned:n})}catch(r){i({pinned:t}),Qe.error(`Could not save pinned projects: ${r instanceof Error?r.message:String(r)}`)}})}}));function gO(i){const e=i.replace(/\/{2,}/g,"/");return e.length>1?e.replace(/\/+$/,""):e}function vO(i,e,t){const n=z.useRef(e);n.current=e;const r=Array.from(new Set(i.filter(p=>!!p).map(gO))),l=r.slice().sort().join("\0")+`${(t==null?void 0:t.depth)??""}`;z.useEffect(()=>{if(r.length===0)return;window.api.config.watch(r,t);const p=window.api.config.onChanged(a=>{r.includes(a.path)&&n.current(a.path)});return()=>{p(),window.api.config.unwatch(r,t)}},[l])}async function _O(i){const e=await vm(i);return Array.isArray(e.fileTreeExpanded)?e.fileTreeExpanded.filter(t=>typeof t=="string"):[]}function bO(i,e){return xd(i,{fileTreeExpanded:[...e].slice(0,500)})}async function wO(){const i=await Eh();return typeof i.fileTreeShowHidden=="boolean"?i.fileTreeShowHidden:!0}function yO(i){um({fileTreeShowHidden:i}).catch(()=>{})}function tb(i,e){const t=e+"/";let n=!1;const r=new Set;for(const l of i){if(l===e||l.startsWith(t)){n=!0;continue}r.add(l)}return n?r:i}const ib={modified:{color:"#e2a93d",label:"M"},added:{color:"#3fb950",label:"A"},deleted:{color:"#f85149",label:"D"},renamed:{color:"#a371f7",label:"R"},untracked:{color:"#8b949e",label:"U"},staged:{color:"#3fb950",label:"S"},conflict:{color:"#f85149",label:"!"}},xO=new Set(["md","txt","json","jsonl","ndjson","js","jsx","ts","tsx","py","go","rs","rb","c","cpp","h","hpp","java","sh","bash","css","scss","html","xml","yaml","yml","toml","ini","conf","env","log","sql","gitignore","csv","tsv"]);function SO(i){const e=Ur(i);return xO.has(e)||Bk.has(e)||e==="pdf"}function CO(i,e){if(e)return"#d97757";switch(Ur(i)){case"ts":case"tsx":return"#3178c6";case"js":case"jsx":return"#f7df1e";case"json":return"#cbcb41";case"md":return"#8a93a0";case"css":case"scss":return"#cc6699";case"py":return"#3776ab";case"go":return"#00add8";case"rs":return"#dea584";case"sh":case"bash":return"#89e051";case"png":case"jpg":case"jpeg":case"gif":case"svg":return"#a4c639";default:return"#8a93a0"}}async function Df(i){try{return await window.api.git.fileStatus(i)}catch{return{}}}const RS=64,kO=250,EO={depth:0};function nb(i){const e=i.replace(/\/{2,}/g,"/");return e.length>1?e.replace(/\/+$/,""):e}function TO({cwd:i,onPreviewFile:e,onSendToChat:t,activeTabId:n}){const r=Uw(),l=Yv(),[p,a]=z.useState([]),[d,f]=z.useState(new Set),m=z.useRef(d);m.current=d;const g=z.useRef(!1),[y,D]=z.useState(""),[E,C]=z.useState(!0),b=z.useRef(!1);z.useEffect(()=>{let Se=!1;return wO().then(tt=>{!Se&&!b.current&&C(tt)}),()=>{Se=!0}},[]);const w=z.useCallback(Se=>{b.current=!0,C(tt=>{const ht=typeof Se=="function"?Se(tt):Se;return yO(ht),ht})},[]),[x,S]=z.useState(!1),[T,j]=z.useState(null),[N,L]=z.useState({}),[R,F]=z.useState(null),[V,te]=z.useState(null),[he,ee]=z.useState(""),[we,ce]=z.useState(null),[ve,Ee]=z.useState(""),[fe,U]=z.useState(null),X=z.useRef(null),W=z.useRef(null),Q=z.useRef(0),oe=z.useCallback(async()=>{if(!i)return;const Se=++Q.current;S(!0),j(null);const tt=await window.api.files.list(i,E);Q.current===Se&&(tt.ok?a(tt.entries.map(ht=>({...ht}))):(j(tt.error??"failed to list"),a([])),S(!1))},[i,E]),Ce=z.useCallback(async Se=>{const tt=Q.current,ht=new Map;for(const gi of Se){const Jt=gi.split("/").length,oi=ht.get(Jt);oi?oi.push(gi):ht.set(Jt,[gi])}const Et=[];for(const gi of[...ht.keys()].sort((Jt,oi)=>Jt-oi)){const Jt=ht.get(gi),oi=await Promise.all(Jt.map(async Xt=>({p:Xt,result:await window.api.files.list(Xt,E)})));if(Q.current!==tt)return Et;for(const{p:Xt,result:un}of oi)un.ok?a(wt=>vv(wt,Xt,un.entries.map(Ri=>({...Ri})))):Et.push(Xt)}return Et},[E]),Oe=z.useCallback(async Se=>(await oe(),Se.length?Ce(Se):[]),[oe,Ce]);z.useEffect(()=>{D(""),te(null),F(null),ce(null),U(null),L({});let Se=!1;return g.current=!1,(async()=>{const[tt]=await Promise.all([_O(i),oe()]);if(Se)return;if(!g.current){const Et=new Set(tt);m.current=Et,f(Et)}if(!tt.length)return;const ht=await Ce(tt);Se||!ht.length||Ye(Et=>{const gi=new Set;let Jt=!1;for(const oi of Et){if(ht.some(Xt=>oi===Xt||oi.startsWith(Xt+"/"))){Jt=!0;continue}gi.add(oi)}return Jt?gi:Et})})(),Df(i).then(tt=>{Se||L(tt)}),()=>{Se=!0}},[i]);const Xe=z.useRef(!0);z.useEffect(()=>{if(Xe.current){Xe.current=!1;return}Oe([...m.current])},[E]),z.useEffect(()=>{if(!i||!l)return;Df(i).then(L);const Se=window.setInterval(()=>{Df(i).then(L)},5e3);return()=>window.clearInterval(Se)},[i,l]);const ge=z.useMemo(()=>{if(!i)return[];const Se=[...d].filter(tt=>tt!==i);return[i,...Se.slice(-63)]},[i,d]),J=z.useRef(!1);z.useEffect(()=>{!i||d.size+1<=RS||J.current||(J.current=!0,console.warn(`FileTree: watching only ${RS} of ${d.size+1} folders (cap reached)`))},[i,d]);const je=z.useRef(new Map),de=z.useRef(new Set),Ie=z.useRef(!1);Ie.current=V!==null||we!==null;const Pe=z.useRef(()=>{});Pe.current=Se=>{if(!(Se!==nb(i)&&!m.current.has(Se))){if(Ie.current){de.current.add(Se);return}Se===nb(i)?Oe([...m.current]):rt(Se)}},vO(ge,Se=>{if(Se!==nb(i)&&!m.current.has(Se))return;const tt=je.current,ht=tt.get(Se);ht&&clearTimeout(ht),tt.set(Se,setTimeout(()=>{tt.delete(Se),Pe.current(Se)},kO))},EO),z.useEffect(()=>{if(V!==null||we!==null)return;const Se=[...de.current];de.current.clear();for(const tt of Se)Pe.current(tt)},[V,we]),z.useEffect(()=>{const Se=je.current,tt=de.current;return()=>{for(const ht of Se.values())clearTimeout(ht);Se.clear(),tt.clear()}},[i]),z.useEffect(()=>{if(!R)return;const Se=()=>F(null),tt=ht=>{r.current&&ht.key==="Escape"&&F(null)};return window.addEventListener("mousedown",Se),window.addEventListener("keydown",tt),()=>{window.removeEventListener("mousedown",Se),window.removeEventListener("keydown",tt)}},[R]),z.useEffect(()=>{V&&setTimeout(()=>{var Se;return(Se=X.current)==null?void 0:Se.select()},30)},[V]),z.useEffect(()=>{we&&setTimeout(()=>{var Se;return(Se=W.current)==null?void 0:Se.focus()},30)},[we]);const Ye=z.useCallback(Se=>{const tt=m.current,ht=Se(tt);ht!==tt&&(g.current=!0,m.current=ht,f(ht),bO(i,ht).catch(()=>{m.current===ht&&(m.current=tt,f(tt),Qe.error("Couldn't save folder expansion — reverted."))}))},[i]),ft=z.useCallback(async Se=>{if(d.has(Se.path)){Ye(ht=>tb(ht,Se.path));return}if(Ye(ht=>new Set(ht).add(Se.path)),Se.children)return;const tt=await window.api.files.list(Se.path,E);tt.ok&&a(ht=>vv(ht,Se.path,tt.entries.map(Et=>({...Et}))))},[d,E,Ye]),rt=z.useCallback(async Se=>{if(Se===i){await oe();return}const tt=await window.api.files.list(Se,E);tt.ok&&a(ht=>vv(ht,Se,tt.entries.map(Et=>({...Et}))))},[i,oe,E]),Nt=z.useCallback(Se=>{if(Se.isDirectory){ft(Se);return}SO(Se.name)&&e?e(Se.path):window.api.shell.open({as:"openPath",path:Se.path})},[ft,e]),mt=z.useCallback(Se=>{if(t){t(Se);return}if(n){const tt=Se.startsWith(i+"/")?Se.slice(i.length+1):Se;window.api.pty.write({tabId:n,data:`@${tt} `})}},[t,n,i]),mi=z.useCallback((Se,tt)=>{Se.preventDefault(),Se.stopPropagation(),F({x:Se.clientX,y:Se.clientY,node:tt})},[]),di=Se=>{te(Se.path),ee(Se.name)},_i=async()=>{if(!V)return;const Se=he.trim();if(!Se){te(null);return}const tt=await window.api.files.rename(V,Se);if(te(null),tt.ok){const ht=V.slice(0,V.lastIndexOf("/"));Ye(Et=>tb(Et,V)),await rt(ht||i),Df(i).then(L)}else{const ht=tt.error??"rename failed";j(ht),Qe.error(ht)}},Je=async()=>{if(!we)return;const Se=ve.trim();if(!Se){ce(null),Ee("");return}const tt=await window.api.files.create(we.parent,Se,we.kind);if(ce(null),Ee(""),tt.ok)await rt(we.parent),we.kind==="folder"&&Ye(ht=>new Set(ht).add(we.parent));else{const ht=tt.error??"create failed";j(ht),Qe.error(ht)}},Pt=async()=>{if(!fe)return;const Se=await window.api.files.delete(fe.path),tt=fe.path.slice(0,fe.path.lastIndexOf("/"));if(U(null),Se.ok)Ye(ht=>tb(ht,fe.path)),await rt(tt||i),Df(i).then(L);else{const ht=Se.error??"delete failed";j(ht),Qe.error(ht)}},_t=z.useMemo(()=>{if(!y.trim())return p;const Se=y.toLowerCase();return p.filter(tt=>tt.name.toLowerCase().includes(Se))},[p,y]),hi=(i==null?void 0:i.split("/").filter(Boolean).pop())||"project";return c.jsxs("div",{className:"w-full h-full flex flex-col bg-bg-elev text-fg",children:[c.jsxs("div",{className:"p-3 border-b border-line shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2 min-w-0",children:[c.jsx(kE,{size:14,className:"shrink-0 text-accent"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-xs font-medium text-fg truncate",children:hi}),c.jsx("p",{className:"text-[10px] text-fg-faint truncate",title:i,children:i})]}),c.jsx("button",{onClick:oe,className:"p-1 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"Refresh",disabled:x,children:c.jsx(jO,{size:12,className:x?"animate-spin":""})})]}),c.jsx("div",{className:"relative",children:c.jsx("input",{value:y,onChange:Se=>D(Se.target.value),placeholder:"Search files…",className:"w-full px-2 py-1 text-xs bg-bg-hi border border-line rounded text-fg placeholder-fg-faint focus:outline-none focus:border-accent/40"})})]}),c.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-line shrink-0",children:[c.jsx("button",{onClick:()=>ce({parent:i,kind:"file"}),className:"p-1.5 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"New file",children:c.jsx(RO,{size:12})}),c.jsx("button",{onClick:()=>ce({parent:i,kind:"folder"}),className:"p-1.5 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"New folder",children:c.jsx(NO,{size:12})}),c.jsx("div",{className:"flex-1"}),c.jsx("button",{onClick:()=>w(Se=>!Se),className:`p-1.5 rounded transition-colors ${E?"text-accent":"text-fg-faint hover:text-fg"} hover:bg-bg-hi`,title:E?"Hide hidden files":"Show hidden files",children:E?c.jsx(MO,{size:12}):c.jsx(OO,{size:12})})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[T&&c.jsx("div",{className:"px-3 py-2 text-[11px] text-red-400",children:T}),!T&&_t.length===0&&!x&&c.jsx("div",{className:"p-4 text-center text-[11px] text-fg-faint",children:y?"no matches":"empty folder"}),!T&&c.jsx(CE,{nodes:_t,depth:0,expanded:d,gitStatus:N,renaming:V,renameValue:he,renameInputRef:X,onRenameChange:ee,onRenameCommit:_i,onRenameCancel:()=>te(null),onToggleDir:ft,onFileClick:Nt,onSendToChat:mt,onContextMenu:mi})]}),c.jsx("div",{className:"px-3 py-1.5 border-t border-line text-[10px] text-fg-faint shrink-0",children:"Click to preview · Double-click external · Right-click for more"}),R&&c.jsx(DO,{x:R.x,y:R.y,node:R.node,onClose:()=>F(null),onRename:()=>{di(R.node),F(null)},onDelete:()=>{U(R.node),F(null)},onNewFile:()=>{ce({parent:R.node.path,kind:"file"}),F(null)},onNewFolder:()=>{ce({parent:R.node.path,kind:"folder"}),F(null)},onOpenExternal:()=>{window.api.shell.open({as:"openPath",path:R.node.path}),F(null)},onShowInFinder:()=>{window.api.shell.open({as:"revealPath",path:R.node.path}),F(null)},onCopyPath:()=>{const Se=R.node.path;Ca(Se).then(tt=>{tt||Qe.error("Couldn't copy path")}),F(null)},onSendToChat:()=>{mt(R.node.path),F(null)}}),we&&c.jsx(NS,{title:`New ${we.kind}`,subtitle:`in ${$O(we.parent)}`,onCancel:()=>{ce(null),Ee("")},onConfirm:Je,confirmLabel:"Create",confirmDisabled:!ve.trim(),children:c.jsx("input",{ref:W,value:ve,onChange:Se=>Ee(Se.target.value),onKeyDown:Se=>{Se.key==="Enter"&&Je(),Se.key==="Escape"&&(ce(null),Ee(""))},placeholder:we.kind==="file"?"filename.txt":"folder-name",className:"w-full px-3 py-2 rounded bg-bg-hi border border-line text-fg text-sm placeholder-fg-faint focus:outline-none focus:border-accent/50"})}),fe&&c.jsx(NS,{title:`Delete ${fe.isDirectory?"folder":"file"}`,subtitle:null,onCancel:()=>U(null),onConfirm:Pt,confirmLabel:"Delete",danger:!0,children:c.jsxs("p",{className:"text-sm text-fg-dim",children:["Move ",c.jsxs("span",{className:"text-fg font-medium",children:['"',fe.name,'"']})," to the trash?",fe.isDirectory&&c.jsx("span",{className:"block text-xs text-fg-faint mt-1",children:"All contents will be moved with it."})]})})]})}function CE(i){const{nodes:e,depth:t,expanded:n,gitStatus:r,renaming:l,onContextMenu:p}=i;return c.jsx(c.Fragment,{children:e.map(a=>{const d=n.has(a.path),f=l===a.path,m=r[a.path],g=CO(a.name,a.isDirectory);return c.jsxs("div",{children:[c.jsxs("div",{className:"group flex items-center gap-1.5 py-0.5 pr-2 cursor-pointer transition-colors hover:bg-bg-hi",style:{paddingLeft:`${8+t*14}px`},onClick:()=>{f||(a.isDirectory?i.onToggleDir(a):i.onFileClick(a))},onDoubleClick:()=>{a.isDirectory||window.api.shell.open({as:"openPath",path:a.path})},onContextMenu:y=>p(y,a),children:[a.isDirectory?c.jsx(PO,{size:10,className:`shrink-0 text-fg-faint transition-transform ${d?"rotate-90":""}`}):c.jsx("span",{className:"w-[10px] shrink-0"}),a.isDirectory?d?c.jsx(AO,{size:12,color:g}):c.jsx(kE,{size:12,color:g}):c.jsx(IO,{size:12,color:g}),f?c.jsx("input",{ref:i.renameInputRef,value:i.renameValue,onChange:y=>i.onRenameChange(y.target.value),onClick:y=>y.stopPropagation(),onBlur:i.onRenameCommit,onKeyDown:y=>{y.key==="Enter"&&i.onRenameCommit(),y.key==="Escape"&&i.onRenameCancel()},className:"flex-1 min-w-0 px-1 py-0 text-xs bg-bg border border-accent/40 rounded text-fg focus:outline-none"}):c.jsx("span",{className:`flex-1 truncate text-xs ${a.name.startsWith(".")?"text-fg-faint":"text-fg-dim"}`,children:a.name}),m&&c.jsx("span",{className:"shrink-0 text-[9px] font-bold px-1 rounded",style:{color:ib[m].color,backgroundColor:`${ib[m].color}20`},title:m,children:ib[m].label}),!a.isDirectory&&c.jsx("button",{onClick:y=>{y.stopPropagation(),i.onSendToChat(a.path)},title:"Send @path to active terminal",className:"opacity-0 group-hover:opacity-100 p-0.5 rounded text-fg-faint hover:text-accent hover:bg-bg transition-all shrink-0",children:c.jsx(LO,{size:10})})]}),a.isDirectory&&d&&a.children&&c.jsx(CE,{...i,nodes:a.children,depth:t+1})]},a.path)})})}function DO(i){const{x:e,y:t,node:n}=i;return c.jsxs("div",{onMouseDown:r=>r.stopPropagation(),className:`fixed ${dn.contextMenu} w-56 rounded-lg border border-line bg-bg-elev shadow-xl text-xs py-1`,style:{left:e,top:t},children:[!n.isDirectory&&c.jsx(Kl,{label:"Send to chat",onClick:i.onSendToChat}),c.jsx(Kl,{label:"Open in default app",onClick:i.onOpenExternal}),c.jsx(Kl,{label:"Reveal in OS",onClick:i.onShowInFinder}),c.jsx(sb,{}),c.jsx(Kl,{label:"Copy path",onClick:i.onCopyPath}),c.jsx(Kl,{label:"Rename",onClick:i.onRename}),n.isDirectory&&c.jsxs(c.Fragment,{children:[c.jsx(sb,{}),c.jsx(Kl,{label:"New file",onClick:i.onNewFile}),c.jsx(Kl,{label:"New folder",onClick:i.onNewFolder})]}),c.jsx(sb,{}),c.jsx(Kl,{label:"Delete",onClick:i.onDelete,danger:!0})]})}function Kl({label:i,onClick:e,danger:t}){return c.jsx("button",{onClick:e,className:`w-full text-left px-3 py-1.5 hover:bg-bg-hi transition-colors ${t?"text-red-400":"text-fg-dim hover:text-fg"}`,children:i})}function sb(){return c.jsx("div",{className:"my-1 border-t border-line"})}function NS(i){return c.jsx("div",{className:`fixed inset-0 ${dn.contextMenuDialog} flex items-center justify-center bg-black/60`,onMouseDown:e=>{e.target===e.currentTarget&&i.onCancel()},children:c.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[c.jsx("h3",{className:"text-sm font-medium text-fg mb-1",children:i.title}),i.subtitle&&c.jsx("p",{className:"text-[11px] text-fg-faint mb-3 truncate",children:i.subtitle}),c.jsx("div",{className:"mb-4",children:i.children}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx("button",{onClick:i.onCancel,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded transition-colors",children:"Cancel"}),c.jsx("button",{onClick:i.onConfirm,disabled:!!i.confirmDisabled,className:`px-3 py-1 text-xs text-white rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${i.danger?"bg-red-600 hover:bg-red-500":"bg-accent hover:bg-accent/90"}`,children:i.confirmLabel??"OK"})]})]})})}function $O(i){return i.split("/").filter(Boolean).pop()||i}function vv(i,e,t){return i.map(n=>n.path===e?{...n,children:t}:n.children?{...n,children:vv(n.children,e,t)}:n)}function Ea({size:i,children:e,className:t,color:n}){return c.jsx("svg",{width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,children:e})}function kE({size:i,className:e,color:t}){return c.jsx(Ea,{size:i,className:e,color:t,children:c.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function AO({size:i,className:e,color:t}){return c.jsx(Ea,{size:i,className:e,color:t,children:c.jsx("path",{d:"M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2"})})}function IO({size:i,className:e,color:t}){return c.jsxs(Ea,{size:i,className:e,color:t,children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function PO({size:i,className:e}){return c.jsx(Ea,{size:i,className:e,children:c.jsx("polyline",{points:"9 18 15 12 9 6"})})}function jO({size:i,className:e}){return c.jsxs(Ea,{size:i,className:e,children:[c.jsx("polyline",{points:"23 4 23 10 17 10"}),c.jsx("polyline",{points:"1 20 1 14 7 14"}),c.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function RO({size:i,className:e}){return c.jsxs(Ea,{size:i,className:e,children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"}),c.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),c.jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]})}function NO({size:i,className:e}){return c.jsxs(Ea,{size:i,className:e,children:[c.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"}),c.jsx("line",{x1:"12",y1:"11",x2:"12",y2:"17"}),c.jsx("line",{x1:"9",y1:"14",x2:"15",y2:"14"})]})}function MO({size:i,className:e}){return c.jsxs(Ea,{size:i,className:e,children:[c.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function OO({size:i,className:e}){return c.jsxs(Ea,{size:i,className:e,children:[c.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"}),c.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function LO({size:i,className:e}){return c.jsxs(Ea,{size:i,className:e,children:[c.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),c.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function EE({content:i,children:e,align:t="bottom-right"}){const[n,r]=z.useState(!1),l=t==="bottom-right"?"top-full mt-1 right-0":"top-full mt-1 left-1/2 -translate-x-1/2";return c.jsxs("span",{className:"relative inline-flex",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>r(!0),onBlur:()=>r(!1),children:[e,n&&c.jsx("span",{role:"tooltip",className:`absolute ${dn.dialog} ${l} px-2 py-1 text-[10px] leading-snug text-fg bg-bg-elev border border-line rounded shadow-lg max-w-[18rem] whitespace-normal pointer-events-none`,children:i})]})}function Xf(i,e){if(!e)return i;const t=e.length>1?e.replace(/\/+$/,""):e;if(i===t)return"~";const n=t.endsWith("/")?t:`${t}/`;return i.startsWith(n)?`~/${i.slice(n.length)}`:i}function rb(i){um(i).catch(()=>Qe.error("Couldn't save File Explorer layout."))}const ob=33,zO=20,BO=60,GO=32;function MS(i){return Math.min(BO,Math.max(zO,i))}function FO(){const i=Ct(te=>te.tabs),e=Ct(te=>te.activeTabId),t=i.find(te=>te.id===e)??null,n=ji(te=>te.navFace),r=e_(),l=n==="home"?r:(t==null?void 0:t.cwd)??null,[p,a]=z.useState(ob),[d,f]=z.useState(!1),m=z.useRef(!1),[g,y]=z.useState(!1),D=z.useRef(p);D.current=p;const E=z.useRef(d);E.current=d;const C=z.useRef(null),b=z.useRef(null),{projects:w,openProject:x,archiveProjectByCwd:S}=Cd(),T=eb(te=>te.pinned),j=eb(te=>te.togglePin);z.useEffect(()=>{eb.getState().hydrate()},[]),z.useEffect(()=>{let te=!1;return Eh().then(he=>{te||m.current||(typeof he.projectsSplitPct=="number"&&Number.isFinite(he.projectsSplitPct)&&a(MS(he.projectsSplitPct)),typeof he.projectsFileTreeCollapsed=="boolean"&&f(he.projectsFileTreeCollapsed))}),()=>{te=!0}},[]);const N=[...w].sort((te,he)=>(T[he.cwd]?1:0)-(T[te.cwd]?1:0));z.useEffect(()=>{if(!g)return;const te=he=>{b.current&&!b.current.contains(he.target)&&y(!1)};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[g]);const L=z.useCallback(te=>{Ci.getState().openFile(te)},[]),R=z.useCallback(te=>{te.preventDefault(),m.current=!0;const he=te.clientX,ee=D.current;let we=ee;const ce=Ee=>{const fe=C.current;if(!fe)return;const U=fe.getBoundingClientRect(),X=Ee.clientX-he;we=MS(ee+X/U.width*100),a(we)},ve=()=>{window.removeEventListener("pointermove",ce),window.removeEventListener("pointerup",ve),document.body.style.cursor="",document.body.style.userSelect="",rb({projectsSplitPct:we})};window.addEventListener("pointermove",ce),window.addEventListener("pointerup",ve),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]),F=z.useCallback(()=>{m.current=!0,a(ob),rb({projectsSplitPct:ob})},[]),V=z.useCallback(()=>{m.current=!0;const te=!E.current;f(te),rb({projectsFileTreeCollapsed:te})},[]);return d?c.jsxs("div",{ref:C,className:"flex h-full w-full","data-testid":"projects-workspace",children:[c.jsxs("button",{onClick:V,"data-testid":"projects-file-tree-rail-toggle",title:"Show file explorer",className:"shrink-0 flex flex-col items-center gap-2 py-2 border-r border-line text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",style:{width:GO},children:[c.jsx("span",{className:"text-[11px]",children:"▸"}),c.jsx("span",{className:"text-[10px] tracking-wide [writing-mode:vertical-rl]",children:"Files"})]}),c.jsx("div",{className:"flex-1 min-w-0","data-testid":"projects-editor-pane",children:c.jsx(fw,{})})]}):c.jsxs("div",{ref:C,className:"flex h-full w-full","data-testid":"projects-workspace",children:[c.jsxs("div",{className:"shrink-0 flex flex-col border-r border-line overflow-hidden",style:{width:`${p}%`},"data-testid":"projects-file-tree-pane",children:[c.jsxs("div",{ref:b,className:"relative shrink-0 flex items-stretch border-b border-line",children:[c.jsxs("button",{"data-testid":"projects-launcher-trigger",onClick:()=>y(te=>!te),className:"flex-1 min-w-0 px-3 py-1.5 text-[11.5px] text-fg-dim font-mono flex items-center gap-1 hover:bg-bg-hi transition-colors",children:[c.jsx("span",{className:"flex-1 truncate text-left",children:l?Xf(l,r):"Projects"}),c.jsx("span",{className:"text-fg-faint shrink-0 text-[10px]",children:g?"▲":"▼"})]}),c.jsx("button",{onClick:V,"data-testid":"projects-file-tree-collapse",title:"Hide file explorer",className:"shrink-0 px-2 border-l border-line text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors text-[11px]",children:"◂"}),g&&c.jsx("div",{"data-testid":"projects-launcher-list",className:`absolute left-0 right-0 top-full ${dn.dialog} bg-bg-elev border border-line shadow-lg max-h-60 overflow-auto`,children:N.length===0?c.jsx("div",{className:"px-3 py-2 text-[11.5px] text-fg-faint",children:"No projects found."}):N.map(te=>{const he=Xf(te.cwd,r);return c.jsxs("div",{"data-testid":"projects-launcher-row",className:"flex items-center gap-1 px-2 py-1 hover:bg-bg-hi group",children:[c.jsx(EE,{content:T[te.cwd]?"Unpin":"Pin to top",children:c.jsx("button",{onClick:()=>j(te.cwd),className:`shrink-0 text-sm leading-none transition-colors ${T[te.cwd]?"text-yellow-400":"text-fg-faint hover:text-fg-dim"}`,children:T[te.cwd]?"★":"☆"})}),c.jsx("button",{onClick:()=>{x(te.cwd),y(!1)},className:"flex-1 min-w-0 text-left text-[11.5px] font-mono truncate text-fg-dim hover:text-fg",children:he}),c.jsx("button",{onClick:async()=>{window.confirm(`Archive ${he}?`)&&await S(te)},className:"shrink-0 text-[10px] text-fg-faint hover:text-red-400 opacity-0 group-hover:opacity-100 transition-opacity",title:"Archive",children:"✕"})]},te.cwd)})})]}),l?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"px-3 py-2 border-b border-line text-[11.5px] text-fg-faint font-mono truncate shrink-0",title:l,children:Xf(l,r)}),c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:c.jsx(TO,{cwd:l,activeTabId:(t==null?void 0:t.id)??null,onPreviewFile:L})})]}):c.jsx("div",{className:"px-3 py-6 text-center text-[12px] text-fg-faint",children:n==="home"?"Loading home folder…":"No session selected."})]}),c.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize panes",title:"Drag to resize · double-click to reset",onPointerDown:R,onDoubleClick:F,className:"w-1.5 shrink-0 cursor-col-resize hover:bg-accent/40 active:bg-accent/60 transition-colors"}),c.jsx("div",{className:"flex-1 min-w-0","data-testid":"projects-editor-pane",children:c.jsx(fw,{})})]})}const HO=z.memo(FO),WO={"project-home":{headline:"The Brief — what this project is, and what is in flight",intro:"Home for a project tab is a synthesized brief: what the project is for, how it is structured, and what is currently in flight across its Epics. Content is scaffolded for now — the synthesis pipeline lands in a later update.",sections:[{title:"What you see",items:[{body:"A header naming the active project, resolved from the active tab's working directory."}]}]},overview:{headline:"Your home base — a calm landing page for your local Claude Code cockpit",intro:"Overview is the first screen you see. It greets you by time of day and frames Session Manager as a local cockpit that wraps the Claude CLI alongside skills, hooks, MCP servers, and a scheduler. Nothing here phones home. The page is a launchpad, not a settings screen: a live 5-hour usage card, a few quick-start buttons, your most-recent sessions, and a peek at what is queued in the scheduler. Click any of them to jump straight into the relevant tab.",sections:[{title:"What you see",items:[{term:"Billing meters",body:"A live read of your subscription usage — plan chip, the current 5-hour rolling window, and the weekly windows — each with percent used, a color bar, and the reset time. Same data the CLI /usage command reads."},{term:"Quick start",body:"Four buttons — Start a session, Resume last (opens History), Draft a PRD (opens Scheduler), and Add a project (opens Projects) — plus a microphone button that opens voice input."},{term:"Recent sessions",body:"Your four most-recently-touched transcripts, scanned from ~/.claude/projects. Each row shows the project, the short session id, the transcript size, and how long ago it was active. Click a row to reopen that session with claude --resume."},{term:"In the scheduler",body:"A peek at the first three jobs in the scheduler queue, each tagged running or queued with a rough time estimate. “Open scheduler →” jumps to the full Scheduler tab."}]},{title:"Behaviors this affects",items:[{body:"Overview is read-only and click-through. It never edits anything; every button just navigates you to the tab that does the work (History, Scheduler, Projects, Voice) or starts a new session."},{body:"The 5-hour countdown refreshes on a timer. If the usage card shows a dash, billing data is not loaded yet (or the Claude login has expired — re-authenticate with the CLI)."}]}]},terminal:{headline:"A real Claude Code CLI running inside the app, kept alive across tab switches",intro:"The Terminal tab is a genuine terminal running the claude CLI for you. It behaves like running claude in your own shell, but Session Manager keeps the process alive when you switch to other tabs, makes file paths and URLs clickable, smooths over copy/paste, and lets you broadcast a prompt to several tabs or attach background watchers. Each tab is one Claude session — the tab id IS the session id, so the tab maps directly to its transcript on disk.",sections:[{title:"In the terminal pane",items:[{term:"Settings gear (top-right)",body:"A small gear opens a popover to change the terminal theme (Dark / Light / Paper) and font size (10–22px, with a reset). Changes apply instantly to every open terminal and persist between launches."},{term:"Clickable file paths",body:"Paths like src/main/index.cjs:42 are detected and underlined. Clicking one opens that file in the in-app editor at the right line. URLs are also clickable and open in your system browser."},{term:"Paste images",body:"Ctrl+V pastes clipboard text as usual, but if the clipboard holds an image it is saved to a temp PNG and its path is typed in — so you can paste a screenshot and let Claude read it."},{term:"Smart Ctrl+C",body:"With text selected, Ctrl+C copies it; with nothing selected, Ctrl+C passes through to interrupt Claude (same as a normal terminal). Ctrl+Shift+C always copies."}]},{title:"Session commands (Command Palette / shortcuts)",items:[{term:"Restart session",body:"Ctrl+Shift+R kills this tab's claude process and spawns a fresh one in the same directory. Use it after editing settings, hooks, or skills so Claude reloads them."},{term:"Reboot app",body:"Relaunches Session Manager; your tabs come back automatically. Use when something feels stuck."},{term:"Broadcast",body:"Ctrl+Shift+B opens a bar to send the same prompt to several tabs at once. You tick which tabs to include; each row shows sent or skipped (a dead session is skipped)."},{term:"Watchers",body:"Ctrl+Shift+W attaches a long-running shell command (e.g. npm test --watch, tail -f log) to this tab. Each new line of its output pops up as a toast. Watchers survive tab switches and stop when you remove them."}]},{title:"Things that are easy to miss",items:[{body:"Open the Command Palette (Cmd-K / Ctrl-K) to reach the session commands above, plus copy-cwd, copy-transcript path, and open-transcript."},{body:"Switching to another tab does NOT kill the terminal — the claude process keeps running in the background and the screen is just hidden."},{body:"Voice input (the microphone in the sidebar) types into whichever terminal tab is focused — there is no separate voice tab."}]}],tips:["Press Ctrl+C with nothing selected to interrupt Claude mid-response — same as the standalone CLI.","If the prompt looks frozen, scroll up: Claude often produced output but the cursor is below the visible window."]},"system-prompt":{headline:"Edit ~/.claude/CLAUDE.md — the house rules every session on this machine starts with",intro:"CLAUDE.md is a plain-text file Claude reads at the start of every session. Whatever you write here is added to its instructions — so it's where you put coding standards, communication preferences, and “always do X / never do Y” rules. This tab edits exactly ONE of them: the User file at ~/.claude/CLAUDE.md, which applies everywhere, in every project. A project can also carry its own <repo>/CLAUDE.md and <repo>/CLAUDE.local.md — those are contextual to that project and are read by the CLI from the session's own directory when it launches there, so they are edited with the project's files, not from this machine-wide screen.",sections:[{title:"Editor / Presets toggle",items:[{term:"Editor",body:"Edit the real ~/.claude/CLAUDE.md. Save writes it to disk; Claude picks it up on its next session start."},{term:"Presets",body:"Browse a library of starter prompts. Use one as a starting point, then refine it in the editor."}]},{title:"What this file reaches — and what it doesn't",items:[{term:"User (edited here)",body:"Lives at ~/.claude/CLAUDE.md. Applies to every session you start, in every repo. Best for personal style: communication tone, default tooling preferences, things you always want."},{term:"Project (not edited here)",body:"Lives at <repo>/CLAUDE.md, checked into git — shared team context: stack, architecture, do/don't lists. It only means anything relative to a project directory, so it is picked up when a session launches in that repo; open it from the project's own files."},{term:"Local (not edited here)",body:"Lives at <repo>/CLAUDE.local.md, gitignored — personal overrides that shouldn't reach teammates. Same story as Project: contextual to one repo, applied at session launch."},{body:"At runtime every file that is present combines; more-specific wins: Local > Project > User. This screen only owns the base layer."}]},{title:"What's shown in the header",items:[{term:"chars / tokens",body:"A rough size estimate (~4 chars per token). The bigger the file, the more of Claude's context window it consumes before your real prompt — keep it tight."},{term:"unsaved edits",body:"Save and Revert live in the bottom bar; navigating away does NOT auto-save."},{body:"If the file doesn't exist yet, the bottom bar notes it will be created on save."}]}],tips:["New users: start with 3–5 bullets here (“be concise”, “use Python type hints”, “always run tests after changes”). That alone changes Claude's behavior noticeably.","Don't write essays. Claude reads CLAUDE.md before every reply, so every word costs tokens. One-line rules beat paragraphs.","Rule of thumb for what belongs here: if it would still be true in a repo you haven't created yet, it is a User rule. If it names this stack, this architecture, or this team, it belongs in that project's own CLAUDE.md."]},settings:{headline:"The settings.json files that control Claude Code's behavior",intro:"Claude Code is configured by JSON files named settings.json. This tab shows up to three of them combined: User (~/.claude/settings.json), Project (<repo>/.claude/settings.json, shared with the repo), and Local (<repo>/.claude/settings.local.json, your private overrides). The Guided view is a friendly card editor; Tree shows the merged values as a JSON tree; Raw lets you hand-edit the file. A bundled schema (from schemastore.org) gives you autocomplete and validation as you type.",sections:[{title:"Views",items:[{term:"Guided",body:"A card-based editor over the merged settings. Each setting shows which scope currently provides it; editing a card writes the change into the scope you've selected."},{term:"Tree",body:"The same merged config as an expandable JSON tree. Useful for nested settings like permissions and hooks; you can override a value into the active scope from here too."},{term:"Raw",body:"The JSON file at the active scope, edited directly. Save validates before writing; a parse error blocks the save and is shown in the bottom bar."},{term:"Telemetry",body:"Opt-in OpenTelemetry export of Session Manager's own classified transcript events (tool names, todo counts, usage tokens). Off by default, stored separately from Claude's settings, and excludes prompt/plan content unless you turn on “Include content”."}]},{title:"Common settings to know",items:[{term:"model",body:"Default model used when you start a session (e.g. “opus”, “sonnet”, “haiku”). Override per-session with /model in the terminal."},{term:"permissions",body:"Allow / Ask / Deny lists for Bash commands, file edits, MCP tools, web fetches. The dedicated Permissions tab is a friendlier UI for this same key."},{term:"hooks",body:"Shell commands the CLI runs in response to events (pre/post tool use, session start, etc.). See the Hooks tab."},{term:"env",body:"Environment variables injected into every claude process — handy for API keys or DEBUG flags."},{term:"mcpServers",body:"External tool servers Claude can call. Edit via the MCP Servers tab for a structured form."}]},{title:"Scope precedence",items:[{body:"Local overrides Project overrides User. A Project-scoped setting beats a User-scoped one when you work in that repo, and your personal Local file beats both. Project and Local require an open project tab — with no working directory, only User is editable."},{body:"Lists merge (allow + allow), but objects do not — a Project-scoped { permissions: { allow: [...] } } REPLACES the user-scoped object wholesale unless you copy the entries you want to keep."}]}],tips:["When in doubt, edit at User scope. Project-scoped settings get committed to git; teammates inherit them.","After changing settings.json, restart any open sessions (Restart session, Ctrl+Shift+R) so Claude reloads."]},permissions:{headline:"Decide which tools Claude can run automatically and which need your OK",intro:"Every action Claude takes — running a Bash command, editing a file, calling an MCP tool — passes a permission check. This tab is a structured editor for the permissions block inside settings.json (there is no separate permissions file). You build three lists — Allow / Deny / Ask — of rules; get them right and you barely see prompts, get them wrong and you're either hammered with confirmations or Claude runs something you didn't want.",sections:[{title:"Views",items:[{term:"Effective",body:"The merged permissions Claude actually sees, as a tree, with which scope each value came from. Read-and-override here."},{term:"Rules",body:"The structured editor: a Default Mode picker, the Allow / Deny / Ask lists (type a rule and press Enter or click add; × to remove), and Additional Directories. Edits write into the scope you've selected."},{term:"Presets",body:"A starter library of common permission sets to copy from."}]},{title:"The three lists",items:[{term:"Allow",body:"Claude runs matching actions silently — no confirmation. Use for safe, repetitive things: Bash(ls:*), Read(~/.claude/**), Edit(src/**)."},{term:"Deny",body:"Claude refuses outright, even if you'd say yes interactively. Use for genuinely dangerous things: Bash(rm -rf:*), Write(/etc/**)."},{term:"Ask",body:"Claude pauses and asks before running. Sits between Allow and Deny for things you want to eyeball each time."}]},{title:"Rule shape",items:[{term:"Tool(pattern)",body:"Format is <ToolName>(<pattern>). Examples: Bash(git push:*), Edit(src/**/*.ts), WebFetch(domain:*.example.com)."},{term:":*",body:"A trailing colon-star means “any arguments”. Bash(npm:*) allows every npm invocation; Bash(npm test) only the literal “npm test”."},{body:"Deny wins ties. If a request matches both Allow and Deny, Deny takes effect. (See the “rule syntax” link in the toolbar for the full grammar.)"}]},{title:"Default Mode",items:[{term:"default",body:"Out-of-the-box behavior: ask for risky operations, allow harmless reads."},{term:"acceptEdits",body:"Auto-approve file edits within the session's working tree. Speeds up iterative coding; avoid for prod repos."},{term:"plan",body:"Read-only mode. Claude can explore and propose, but cannot edit or run shell commands. Good for review sessions."},{term:"bypassPermissions",body:"Skip ALL prompts. Equivalent to --dangerously-skip-permissions. Use only in throwaway sandboxes."}]}],tips:["Start permissive at User scope (your common safe commands), then tighten at Project scope for repos with secrets.","Additional Directories lets Claude read files outside the cwd — add reference repos here as absolute paths instead of cd’ing into each one."]},skills:{headline:"Reusable instructions Claude loads on demand for specific tasks",intro:`A skill is a markdown file that teaches Claude how to do one specific thing — "write Playwright tests", "review SQL migrations", "format an OpenAPI doc". Each skill has frontmatter describing when to trigger it and a body with the actual instructions. Claude doesn't load all skills up front; it scans titles and pulls the body in only when a relevant request arrives, keeping your context tight.`,sections:[{title:"List + Detail",items:[{term:"Scope switch",body:"Toggle User vs Project at the top. User skills live in ~/.claude/skills/ and apply everywhere; Project skills live in <repo>/.claude/skills/ and only when a tab is open in that repo. The toolbar shows the item count and the file path of the selected skill."},{term:"Sidebar",body:"Two groups — Skills and Slash Commands — with a filter box that matches on name. Click an entry to open its markdown in the editor."},{term:"Enable toggle",body:"Each skill has an on/off switch. Turning it off writes disable-model-invocation into the skill's frontmatter, so Claude stops auto-invoking it; the file stays on disk and the name shows struck-through. Slash commands have no toggle."},{term:"Remove (✕)",body:"Deletes a skill's folder to the trash (recoverable). It comes out of your active set entirely — reinstall any time from the Library. This is different from the toggle, which only stops auto-invocation."},{term:"Editor",body:"Standard markdown with a Save/Revert bar at the bottom. The frontmatter (the --- block at the top) controls discovery; the body is what Claude reads when the skill fires."},{term:"Library view",body:'Switch to Library to browse a curated catalog of skills. Each row gives a "source" link and a "copy install" button (a git-clone command you paste into a terminal) — there is no one-click install for skills.'}]},{title:"Skill anatomy",items:[{term:"name",body:"Used in transcripts and the Library. Should be unique within a scope."},{term:"description",body:'Critical — Claude scans descriptions to decide when to load this skill. Be specific about WHEN to use it ("when writing E2E tests with Playwright"), not just what it does.'},{term:"allowed-tools",body:"Optional. Restricts which tools Claude can use while the skill is active. Adds an extra layer of safety on top of permissions."},{term:"Body",body:"Plain markdown. Procedures, code examples, do/don't lists. This is what Claude actually reads."}]},{title:"Slash commands",items:[{body:'Commands (in ~/.claude/commands/ or .claude/commands/) are skills you invoke explicitly with /name — they show with a leading "/" in the sidebar. Skills proper are auto-loaded; commands are user-triggered.'},{body:"This tab lists both at the active scope — same markdown shape on disk, different folders."}]}],tips:["A bad description is worse than no skill — Claude either won't load it when needed, or will load it constantly and waste tokens.","When refining a skill, use Restart Session in the terminal so Claude reloads it."]},plugins:{headline:"Bundled collections of skills, subagents, and hooks that ship together",intro:'A plugin is a directory under ~/.claude/plugins/<name>/ that packages multiple Claude Code primitives (skills, subagents, hooks, MCP servers, LSPs, monitors) under one name. Installing a plugin adds all of them at once; uninstalling removes them cleanly. Use plugins when you want to share a coherent toolkit — "react-frontend-pack", "data-pipeline-helpers" — instead of asking teammates to copy ten files into the right places.',sections:[{title:"Three views",items:[{term:"Installed",body:"A read-only inspector for every plugin folder on disk, shown as a table: name, origin, version, whether it has a manifest, and a contents summary (counts of agents · skills · hooks · monitors · bin · lsp · mcp). Click a row to drill into a full-page view: a header with name/version/description, a meta strip (author, license, homepage, and the full path), and a section index (skills, agents, MCP server, hooks, monitors, LSP, bin) beside the component listing. To edit a plugin's pieces, use the dedicated Skills / Hooks tabs — they point at the same files."},{term:"Discover",body:"A built-in list of official add-ons (LSP servers, MCP integrations). The Install button runs claude plugin install <slug> in a hidden terminal and streams its output below the row; on success the row flips to installed."},{term:"Library",body:'Browse the curated plugin catalog. Each row has a "source" link, a "copy" button for the /plugin install command, and an Install button that wires up the marketplace and installs for you.'}]},{title:"Plugin layout on disk",items:[{term:"plugin.json",body:"The manifest — name, version, description, what the plugin includes. The canonical location is .claude-plugin/plugin.json; older installs keep it at the folder root. Both are detected."},{term:"skills/",body:"Same shape as ~/.claude/skills/. Show up in the Skills tab."},{term:"agents/",body:"Markdown subagents (same shape as ~/.claude/agents/), available to the main Claude to delegate to."},{term:"hooks/hooks.json",body:"Hooks contributed by the plugin (mirrors settings.json's hooks shape, keyed by event), merged into your effective hook set."},{term:".mcp.json / .lsp.json / monitors/",body:"Optional — MCP servers, language servers, and monitors the plugin bundles. Their presence shows up in the contents summary."}]}],tips:["The Installed view is inspect-only here — it will not let you edit or delete plugin files. Edit a plugin's contents through the Skills/Hooks tabs instead.","Editing plugin contents directly is fine but be aware: an upgrade may overwrite your changes. Fork the plugin if you need persistent customizations."]},mcp:{headline:"Connect Claude to external tools — databases, APIs, filesystems — via MCP servers",intro:"MCP (Model Context Protocol) is the open spec for letting Claude call out to external tools. An MCP server is a small process (or HTTP endpoint) that exposes a set of functions; once you register it, Claude treats those functions as first-class tools. Common examples: a Postgres server that lets Claude run SELECTs, a Slack server that posts messages, a filesystem server that exposes a specific directory tree.",sections:[{title:"Where servers are stored",items:[{term:"User scope",body:"~/.claude.json under mcpServers. Available in every session, every repo."},{term:"Project scope",body:"<repo>/.mcp.json. Available only when working in this repo. Commit it so teammates pick up the same servers."},{term:"Editing",body:'Use "+ new server" to add one, click a row to edit it, rename via the name field, and Save/Revert at the bottom. A filter box narrows the list; the Library view installs catalog servers for you.'}]},{title:"Server types",items:[{term:"stdio",body:"Local process — Claude spawns the command and talks to it via stdin/stdout. Most common for tools you ship as a CLI. Fields: command, args, env."},{term:"http / streamable-http",body:"Remote endpoint with JSON-RPC. Field: url, plus headers for auth."},{term:"sse",body:"Server-Sent Events transport — deprecated; the editor flags it and suggests streamable-http instead."},{term:"ws",body:"WebSocket transport. Same url + headers fields as the other remote types."}]},{title:"Per-server controls",items:[{term:"env / headers",body:"Secrets like API keys go here (env for stdio, headers for remote types). Project-scope values get committed to git — be careful; prefer User scope for anything sensitive."},{term:"args",body:"Command-line arguments passed to a stdio server's command. Often used to point at a specific config file or directory."},{term:"alwaysLoad",body:"Bypass tool-search deferral and always load this server's tools up front (rather than only when searched for)."},{term:"enabled",body:"Uncheck to stop loading this server in new sessions without deleting its config."},{term:"disabledTools",body:"A comma-separated denylist of individual tool names to hide from this server."},{term:"permissions",body:"Per-server tool gating: inherit (default), allow all, deny all, or an explicit allowlist of tool names."}]}],tips:['The name "workspace" is reserved — the editor warns that Claude Code will refuse to load a server with that name. Names like "ide" and "tasks" get a softer caution because they collide with commonly-bundled servers.',"After adding/editing a server, restart the affected sessions so Claude reconnects and rediscovers tools."]},hooks:{headline:"Run scripts when Claude does something — pre/post-tool, session start/end, more",intro:"Hooks let you run a shell command, HTTP request, prompt, subagent, or MCP tool in response to events Claude Code emits. Want to log every Bash command Claude runs to a file? PreToolUse hook. Want a subagent to review every edit before it sticks? PostToolUse hook. Want a Slack ping when a long session ends? Stop hook. Hooks are stored in settings.json and can gate, log, or transform actions.",sections:[{title:"Two ways to view",items:[{term:"Effective",body:"The merged result of all scopes (User / Project / Local) — what actually fires. Editing here writes an override into the scope you have selected."},{term:"Events",body:"A per-event editor. The left list shows every supported event with a count of hooks attached; pick one, then add groups (with an optional matcher) and hooks under it."},{term:"Library",body:"Browse catalog hooks. Each event row links to the official hook reference."}]},{title:"The five hook types",items:[{term:"command",body:"Run a shell string (with an optional args array for the no-shell exec form). The script receives the event as JSON on stdin and can return a JSON decision. Only command hooks support the Test fire button."},{term:"http",body:"POST the event JSON to a URL. The response becomes the decision."},{term:"prompt",body:'Send a templated prompt to Claude itself for a quick gut-check. Useful for "should I really run this command?" guards.'},{term:"agent",body:"Spawn a subagent (a markdown file under ~/.claude/agents/) with the event as input. The agent's output is the decision."},{term:"mcp_tool",body:"Invoke a named MCP tool (e.g. mcp__server__tool) in response to the event."}]},{title:"Common events",items:[{term:"PreToolUse / PostToolUse",body:"Before / after Claude calls any tool. Most-used hooks live here — gating, logging, transforming. A matcher (tool-name regex or exact match) scopes a group to specific tools."},{term:"UserPromptSubmit",body:"Fires when you press Enter on a prompt. Good for prepending context (current branch, recent errors) before Claude sees the prompt."},{term:"SessionStart / SessionEnd",body:"Boot/teardown housekeeping — refresh tokens, save transcripts, post a summary."},{term:"Stop / SubagentStop",body:'When the main loop or a subagent finishes. Good for "ping me when done" notifications.'},{term:"PreCompact / PostCompact",body:"Around the auto-compaction step. Useful for archiving the full transcript before it's shrunk."},{body:"Many more are supported — permissions, tasks, worktrees, config/file changes, notifications. Hover any event in the list for its trigger and payload shape. Hooks saved under names Claude Code no longer recognizes are flagged in a warning banner."}]}],tips:['Test new hooks with the "test fire" button next to a command hook — it runs the command against an editable fake event payload (and shows whether your matcher would match) so you can debug without waiting for a real session.',"Each hook can set a timeout (ms) and command hooks can emit a terminalSequence (e.g. a bell). Slow synchronous hooks are noticeable — use http or fire-and-forget for work you don't need to wait on."]},memory:{headline:"A window onto Claude Code's own memory files for this project and its subagents",intro:"Claude Code can keep notes between conversations. These are plain markdown files, stored on your machine. For a project they live in ~/.claude/projects/<project>/memory/. MEMORY.md is the index. Topic files hold the details. At the start of each session Claude loads only the first 200 lines or 25KB of MEMORY.md, whichever comes first, so keep the index short. This tab shows those files and lets you read, edit and delete them. Nothing leaves your machine.",sections:[{title:"What memory is",items:[{term:"Index + topics",body:"MEMORY.md is a short list of one-line pointers. Each pointer names a topic file that holds the full note. Claude reads the index every session and opens a topic file when it needs it."},{term:"Load limit",body:"Only the first 200 lines / 25KB of MEMORY.md are loaded per session. Lines past that are never seen, so a long index quietly loses its tail."},{term:"Who writes",body:"Claude writes memories when you ask it to remember something, or when it decides a fact is worth keeping. You can also edit the files here by hand."}]},{title:"Workspace memories",items:[{term:"Where",body:"The project's auto memory, at ~/.claude/projects/<project>/memory/. It is picked from the active tab's folder, so a different folder shows a different set."},{term:"Worktrees",body:"All git worktrees of the same repository share one workspace memory. A note saved in one worktree is visible in the others."},{term:"Editing",body:"Open a file to read or edit it, add a new one, or delete one. The list refreshes when Claude writes to these files mid-session."}]},{title:"Subagent memories",items:[{term:"Opt-in",body:"A subagent keeps memory only if its definition has `memory: user`, `memory: project` or `memory: local` in its frontmatter. Without that line it has none."},{term:"Where",body:"user: ~/.claude/agent-memory/<agent>/. project: <project>/.claude/agent-memory/<agent>/ (can be committed and shared). local: <project>/.claude/agent-memory-local/<agent>/ (kept out of version control)."},{term:"Agent picker",body:"Pick an agent to see its memory directory. Its files look the same as workspace memory: a MEMORY.md index plus topic files."}]},{title:"What this tab adds",items:[{term:"Stale badge",body:"Marks a memory that has not been touched for a long time, so you can check whether it is still true."},{term:"Not in index",body:"Marks a topic file that MEMORY.md does not point to. Claude will not find it on its own until you add a line to the index."},{term:"Index budget",body:"A strip showing how many lines and KB of MEMORY.md you have used against the 200-line / 25KB limit. It warns when you are close or over."},{term:"Clusters",body:"Groups related memories so you can spot duplicates and merge them. It asks a model to do the grouping, so it costs tokens and only runs when you press the button."},{term:"Natural console",body:"A chat-style box for the workspace. Type list, show <name>, search <text>, remember <text>, forget <name> or help. Free-form text never writes by itself: you choose to send it to Claude in the terminal or add it as a new memory."}]}],tips:["Auto memory off means nothing here is read. Turn it back on if the files seem to have no effect.","Keep MEMORY.md lines short and move detail into topic files so the index stays under the limit.",'Check the "not in index" count after Claude has been writing for a while.']},projects:{headline:"Every directory you've ever run Claude Code in, with quick-resume and bulk tools",intro:"Whenever you start a Claude session in a new directory, Claude Code remembers it by writing transcripts under ~/.claude/projects/<encoded-cwd>/. This tab lists those directories — how many sessions each has, when you last worked there, total transcript size — plus git and CLAUDE.md details it fills in as it reads each folder. Search, filter, pin your favorites, open a folder four different ways, or archive ones you're done with.",sections:[{title:"Columns",items:[{term:"Project",body:"The directory path (with its detected project name). Hover to peek at the start of its CLAUDE.md if it has one."},{term:"Sessions",body:"How many session transcripts exist for this folder. High numbers mean you work here often."},{term:"Last active",body:"When the most recent transcript was touched. The default sort — most recent first."},{term:"Size",body:"Disk usage of all transcripts for this project. Old projects can balloon; archiving is safe if you don't need the history."},{term:"Branch / Remote",body:"The last git branch and git remote, shown once Session Manager finishes reading the folder."}]},{title:"Per-row actions",items:[{term:"Open in session",body:"Spawns a new terminal tab running claude in this directory."},{term:"Open externally",body:"Three more openers: your editor (VS Code / Cursor / Sublime / nano — pick a default up top, or Auto), your file manager, or a system terminal."},{term:"CLAUDE.md",body:"A side drawer that previews this project's CLAUDE.md read-only (no in-drawer editing)."},{term:"Pin / Archive",body:"Star a project to keep it at the top; archive moves it to ~/.claude/projects-archive/ after a confirm."}]},{title:"Finding projects",items:[{term:"Search",body:"Matches path, project name, git remote, and the CLAUDE.md preview."},{term:"Sort & filter",body:"Sort by project, sessions, last active, or size (toggle direction). Filter chips narrow by recency (≤7d / ≤30d), git remote, CLAUDE.md presence, or pinned-only."},{term:"Stats header",body:"Totals up top: project count, how many were active in 7 days, total sessions, total on-disk size, and clickable pills for your most-active projects."}]}],tips:["Tick the checkboxes to select several projects, then archive them all or open them all in your editor at once.","Sort by size to find runaway transcript folders — a multi-hundred-MB project usually means many long sessions, safe to archive if you don't need them."]},remote:{headline:"Session Managers on your other computers",intro:"Pick a paired machine to browse its projects and active sessions, or open a terminal on it. Pairing and revoking machines happens in Settings → Phone remote.",sections:[{title:"Using it",items:[{term:"Machines",body:"The switcher lists every paired computer with its OS and whether it is online right now."},{term:"Sessions / Terminal",body:"Sessions shows what the selected machine is running; Terminal opens a shell there."}]}]},history:{headline:"Every individual Claude session you've ever run, ready to resume",intro:"Where the Projects tab shows directories, the History tab shows individual sessions — one row per .jsonl transcript under ~/.claude/projects/. Two views share the tab: Log is a flat, searchable list you can resume from; Dashboard rolls the same transcripts up into prompt, token, and cost charts. Your view choice is remembered.",sections:[{title:"Log view",items:[{term:"Session id",body:"The UUID identifying the session (shown short). The same id appears in --session-id flags and Claude's own logs."},{term:"Project",body:"The folder this session belongs to (the encoded directory name, decoded back to a path)."},{term:"Last active / Size",body:"When the transcript was last touched (sorted newest first) and its size — a big transcript means a long conversation."},{term:"Resume",body:"Click Resume, pick the directory to run in, and a new tab opens running claude --resume <sessionId>. Claude reads the full transcript and continues; the tab id matches the session id."},{term:"Filter",body:"The search box matches session id and project name (case-insensitive substring); it does not search message text."}]},{title:"Dashboard view",items:[{term:"Summary",body:"Cards for total prompts, input tokens, output tokens, sessions, and estimated cost across the selected range."},{term:"Charts",body:"A daily trend line (switch between prompts, tokens, sessions, errors, or cost) and a per-day input-vs-output token stack, plus a sortable per-project table with each project's top tool and estimated cost."},{term:"Range & refresh",body:'Narrow by from/to date and by project name. Auto-refreshes every 30 seconds, with a manual refresh button and an "updated X ago" stamp. A yellow banner warns if a scan timed out and the numbers are partial.'}]}],tips:["Resume lets you pick any directory — handy when you've moved or renamed the original project folder since the session ran."]},scheduler:{headline:"Author PRDs and run them as claude -p jobs against your 5-hour window",intro:"One home for the headless-batch workflow, split into three tabs. The Queue tab combines global Options (session pool, fire policy, on-disk paths) with monitoring this project's jobs; the PRDs tab is where you author the markdown files those jobs execute; the History tab lists recent completed and failed jobs. PRDs live in each active project's own <cwd>/session-manager-operations/scheduler/prds/. A status strip across the top shows when the window resets, how many jobs are pending / running / completed today, and how much of the 5-hour window you have used. Jobs auto-pause on rate-limit and auto-resume on the next 5-hour reset.",sections:[{title:"Queue — when jobs start",items:[{term:"when available",body:'Default. The scheduler polls your billing usage every ~10 minutes and fires the next batch whenever your 5-hour utilization is below the "Pause above" percent (90% by default).'},{term:"only on reset",body:"Fire queued jobs shortly after each 5-hour window resets, instead of polling."},{term:"manually",body:'Nothing fires on its own — you start work yourself with "Fire next batch now".'}]},{title:"Queue — controls",items:[{term:"Up to N at once",body:"How many jobs in the same group may run in parallel. Defaults to 3 — raising it runs more node processes at once, which can exhaust memory on a small machine."},{term:"Fire next batch now",body:"Launches the next batch immediately, bypassing the billing-usage poll. Useful when the usage meter is itself rate-limited or you just want progress now."},{term:"Resume",body:"When the queue is paused (rate-limit, expired sign-in, network, or a manual pause), a banner explains why and offers Resume."}]},{title:"PRDs — authoring",items:[{body:"Each file is one task — frontmatter (title, cwd, estimateMinutes, parallelGroup) plus a self-contained body Claude can act on without conversation context."},{term:"parallelGroup",body:'The group number. Jobs in the same group run together (up to the concurrency cap); lower groups run before higher ones. If you omit it, the leading "NN-" number in the filename is used, else 99.'},{term:"estimateMinutes",body:"Roughly how long you expect the job to take. The scheduler uses this to pick jobs that fit in your remaining 5-hour budget."}]},{title:"Options — the session pool (global, not per-project)",items:[{term:"One pool, every consumer",body:"Session-Manager owns a machine-wide pool of concurrent Claude sessions (3 by default). Scheduler jobs and Epic chat runs each request a slot before launching and release it when they finish — no subsystem has a private cap that can stack with another's."},{term:"Guardrails",body:"Beyond the slot cap, a memory gate defers new jobs when free RAM drops below a per-job budget, and each job gets an OOM-score bias so the kernel prefers killing a restartable job over the app itself."}]}],tips:["Use the /prd skill to create a fresh PRD with the right structure — manually-written ones often miss the cwd or estimate fields.","Read PRD_AUTHORING.md before queueing a new job — it codifies two real stuck-job incidents (the fizzpop poll-hang and the etch-engine post-AC overrun).","SM_SESSION_SLOTS (1–3) overrides the pool size for one launch; the default is sized to keep three 1 GB+ jobs from starving the app."]},editor:{headline:"View and edit files in-app",intro:"Opens when you click a file in the File Explorer sidebar or a file link in the terminal. Text files open in Monaco (syntax highlighting, font zoom, word wrap, minimap, Dark/Paper theme); Markdown adds Edit / Wysiwyg / Preview / Split, HTML adds Edit / Preview. Images, PDFs, CSV/TSV tables, and JSONL records each get their own viewer; binary or oversized files show a summary instead. URLs still open in your browser.",sections:[{title:"Editing",items:[{term:"Cmd/Ctrl-S",body:'Save the active file. With Autosave on (the "Auto" toggle), edits also save automatically ~1.2 s after you stop typing.'},{term:"Cmd/Ctrl-Shift-F",body:"Toggle Focus mode — hides the tabs and header for distraction-free editing. Esc exits."},{term:"Close guard",body:"Closing a tab with unsaved changes asks before discarding."}]},{title:"Markdown",items:[{term:"Wysiwyg",body:"A rich-text mode built on Tiptap with a floating formatting toolbar (bold, italic, headings, lists, code, blockquote, links) — edit the rendered document directly instead of raw markdown. YAML frontmatter is split off, kept read-only, and rejoined on save; switch to Edit for surgical edits to PRDs and agent files, since Wysiwyg normalizes list markers and heading style."},{term:"Outline",body:"In Preview or Split mode, a document outline lists headings; click to jump. Toggle it with the Outline button."},{term:"Toolbar",body:"A formatting toolbar sits above the editor for Markdown files."}]}],tips:["Use the view toggle (Edit / Wysiwyg / Preview / Split) for Markdown, or Edit / Preview for HTML. HTML previews are sandboxed — page scripts run with no access to your files or session.","Open and Reveal buttons hand the file to your OS default app or file manager."]},voice:{headline:"Voice & microphone",intro:"Talk to Claude instead of typing. Speech is transcribed on-device with a Moonshine model that loads the first time you record (a progress bar shows the download). A press-to-record hotkey starts and stops the mic; what you say is typed into the active terminal, and an auto-submit timer fires it for you a moment after you stop speaking. A one-time mic check confirms your microphone works.",sections:[{title:"Recording controls",items:[{term:"Hotkey",body:"Press your mic hotkey to record. The default is Ctrl+Shift+Space (Cmd+Option+V on Mac); the panel shows the live binding. Two behaviours: 'Hold to talk' records only while the key is held (push-to-talk), 'Tap on/off' starts on one press and stops on the next. The default is hold-to-talk; switch with the radio buttons."},{term:"Mic button & device",body:"The mic button toggles recording with the mouse. The device picker chooses which microphone to use, and a live level meter shows that audio is coming through."},{term:"Run mic check",body:"Opens a short wizard that confirms your mic is picking up sound. It runs automatically once after a settings-format change, or any time you click 'Run mic check'."}]},{title:"Speaking & hearing back",items:[{term:"Live transcript",body:"While recording, a pulsing red dot and the latest transcribed words appear so you can see what was heard. Errors (e.g. mic blocked) surface inline in red."},{term:"TTS (read replies aloud)",body:"The speaker button toggles text-to-speech. When on, Claude's replies are read back to you out loud."}]}],tips:["The speech model downloads on first use only, then stays cached — later recordings start instantly.","Hold-to-talk is best for quick interjections; Tap on/off is better for longer dictation where you don't want to hold a key."]},"agent-library":{headline:"Agent Library — every persona available to this machine",intro:"Global agent definitions live at ~/.claude/agents/*.md. A project can overlay a same-named agent at <project>/.claude/agents/<name>.md, which Claude Code prefers over the global definition whenever both exist. New / Duplicate / Save / Delete here write the matching global .md file directly.",sections:[{title:"What it shows",items:[{term:"Global personas",body:"Every agent .md file under ~/.claude/agents, with its frontmatter (name, description, model, color, tools) and body."},{term:"Overriding projects",body:"For each agent, which of your currently-open project tabs has a local overlay of the same name — that overlay is what actually runs in that project. Dropping one here deletes that project's local .md file."}]}],tips:["Home face only — this is machine-wide data, not scoped to one project.","Only the global definition is editable here — a project overlay is created by Claude Code convention (a same-named file under <project>/.claude/agents/), not from this page."]},"tag-library":{headline:"Tag Library — the Epic intent-tag taxonomy",intro:"Every Epic carries an initial intent tag — feature, bug, discussion, or build — chosen at creation. The tag sets how eagerly /develop should fire inside that Epic's session: feature/bug/build treat PRD decomposition as the expected next step, discussion keeps /develop available but never assumed until whether-to-build is settled.",sections:[{title:"What it shows",items:[{term:"Tag",body:"The four intent tags an Epic can be created with."},{term:"/develop eagerness",body:"Whether PRD decomposition is the expected default for that tag, or available-but-not-assumed."},{term:"Agents carrying this tag",body:"Which Agent Library personas have this tag in their `tags:` frontmatter — the same relationship Agent Library edits from the agent side. Assign or remove an agent here to update that persona's file directly."}]}],tips:["Home face only — the taxonomy is machine-wide, not scoped to one project.","The tag taxonomy itself is read-only here — change an existing Epic's tag from its queue row menu, not from this page. The agent↔tag assignment, though, is editable from either Tag Library or Agent Library."]},"data-model":{headline:"Data Model — an ERD of what Session Manager actually persists",intro:"A hand-maintained diagram of the app's own storage: entities, their on-disk path/format, the single-writer owner if one is declared, their fields, and how they relate. It is a mirror of the real shapes in code (lib/dataModelErd.ts), not a live scanner — it can drift if a shape changes without an update.",sections:[{title:"What it shows",items:[{term:"Diagram",body:"Boxes grouped by realm (project/machine/both), with relation lines. Click a box for its storage path, fields, and relations; toggle a group in the legend to hide it."},{term:"Tables",body:"The same entities as a flat, grouped list of tables — useful for scanning every field at once."}]}],tips:["Home face only — this diagrams the application's own data model, which is identical for every project.","Read-only reference material, not live data — nothing here reflects the currently-open project's actual on-disk state."]}};function UO({content:i}){return c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-xs text-fg-dim leading-relaxed mb-3",children:i.intro}),i.sections.map(e=>c.jsxs("div",{className:"mb-3 last:mb-0",children:[c.jsx("h3",{className:"text-[11px] uppercase tracking-wider text-fg font-medium mb-1",children:e.title}),c.jsx("ul",{className:"space-y-1",children:e.items.map((t,n)=>c.jsxs("li",{className:"text-xs text-fg-dim leading-relaxed",children:[t.term&&c.jsx("span",{className:"text-fg font-medium",children:t.term}),t.term&&" — ",c.jsx("span",{children:t.body})]},n))})]},e.title)),i.tips&&i.tips.length>0&&c.jsxs("div",{className:"mt-3 pt-3 border-t border-line",children:[c.jsx("h3",{className:"text-[11px] uppercase tracking-wider text-fg-dim font-medium mb-1",children:"Tips"}),c.jsx("ul",{className:"space-y-1",children:i.tips.map((e,t)=>c.jsxs("li",{className:"text-xs text-fg-faint leading-relaxed",children:["• ",e]},t))})]})]})}function VO({active:i}){const e=Pn(g=>g.learningPanelCollapsed),t=Pn(g=>g.setLearningPanelCollapsed),n=Pn(g=>g.hydrated),r=Pn(g=>g.hydrate);z.useEffect(()=>{n||r()},[n,r]);const[l,p]=z.useState(()=>!e),a=z.useRef(null);z.useEffect(()=>{n&&p(!e)},[n]);const d=z.useCallback(()=>{p(g=>{const y=!g;return t(!y),y})},[t]);z.useEffect(()=>{if(!l)return;const g=y=>{var D;(D=a.current)!=null&&D.contains(y.target)||(p(!1),t(!0))};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[l,t]);const f=z.useRef(!1);z.useEffect(()=>{if(!f.current){f.current=!0;return}p(!1)},[i]);const m=WO[i];return m?c.jsxs("span",{ref:a,className:"relative inline-block",children:[c.jsx("button",{type:"button",onClick:d,className:"text-[10px] uppercase tracking-wider text-accent font-medium hover:opacity-80 transition-opacity","aria-expanded":l,title:l?"Close learning panel":"What is this?",children:"Learn"}),l&&c.jsx("div",{className:"absolute right-0 top-full z-30 mt-1 w-96 max-h-[70vh] overflow-y-auto rounded border border-line bg-bg-elev shadow-lg px-4 pb-4 pt-3 text-left",children:c.jsx(UO,{content:m})})]}):null}function qO({eyebrow:i,title:e,intro:t,frame:n=!0,learnKey:r,children:l}){const p=n&&(i||e||t);return c.jsxs("div",{className:"h-full w-full flex flex-col bg-bg text-fg",children:[p&&c.jsxs("header",{className:"shrink-0 px-8 pt-7 pb-5 flex items-start justify-between gap-4",children:[c.jsxs("div",{className:"max-w-[820px]",children:[i&&c.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-fg-faint mb-2",children:i}),e&&c.jsx("h1",{className:"font-serif text-[34px] font-medium leading-[1.1] text-fg m-0",children:e}),t&&c.jsx("p",{className:"mt-3 text-[14px] text-fg-dim leading-[1.55]",children:t})]}),r&&c.jsx(VO,{active:r})]}),c.jsx("div",{className:`flex-1 min-h-0 ${p?"px-8 pb-7":"p-8"}`,children:l})]})}const KO=z.lazy(()=>fi(()=>import("./Skills-DaTkSOuU.js"),__vite__mapDeps([3,4,5,6,7,8,9,10,11,12,13,1,2]),import.meta.url).then(i=>({default:i.Skills}))),YO=z.lazy(()=>fi(()=>import("./History-CL-T6Lv3.js"),__vite__mapDeps([14,4,15,1,2]),import.meta.url).then(i=>({default:i.History}))),XO=z.lazy(()=>fi(()=>import("./RemoteMachines-AWpARk7N.js"),__vite__mapDeps([16,17,1,2]),import.meta.url).then(i=>({default:i.RemoteMachines}))),JO=z.lazy(()=>fi(()=>import("./Scheduler-FvduP1FG.js"),__vite__mapDeps([18,15,13,9,1,2]),import.meta.url).then(i=>({default:i.Scheduler}))),ZO=z.lazy(()=>fi(()=>import("./Settings-D1kTUIDB.js"),__vite__mapDeps([19,4,8,7,20,21,22,9,17,1,2]),import.meta.url).then(i=>({default:i.Settings}))),QO=z.lazy(()=>fi(()=>import("./Permissions-FQ9GM6Ca.js"),__vite__mapDeps([23,4,8,7,11,12,13,20,21,22,1,2]),import.meta.url).then(i=>({default:i.Permissions}))),e3=z.lazy(()=>fi(()=>import("./SystemPrompt-DxNf-soM.js"),__vite__mapDeps([24,4,7,11,12,13,1,2]),import.meta.url).then(i=>({default:i.SystemPrompt}))),t3=z.lazy(()=>fi(()=>import("./Memory-nyLR4Yw4.js"),__vite__mapDeps([25,1,2]),import.meta.url).then(i=>({default:i.Memory}))),i3=z.lazy(()=>fi(()=>import("./Plugins-D9KE7XTI.js"),__vite__mapDeps([26,4,10,11,12,13,6,1,2,5]),import.meta.url).then(i=>({default:i.Plugins}))),n3=z.lazy(()=>fi(()=>import("./McpServers-C7EmPm8B.js"),__vite__mapDeps([27,4,5,7,8,10,11,12,13,1,2]),import.meta.url).then(i=>({default:i.McpServers}))),s3=z.lazy(()=>fi(()=>import("./Hooks-ByWVgXIf.js"),__vite__mapDeps([28,4,5,7,8,10,11,12,13,20,21,22,1,2]),import.meta.url).then(i=>({default:i.Hooks}))),r3=z.lazy(()=>fi(()=>import("./AgentLibrary-LBg3mVL8.js"),__vite__mapDeps([29,4,5,12,30,21,1,2]),import.meta.url).then(i=>({default:i.AgentLibrary}))),o3=z.lazy(()=>fi(()=>import("./TagLibrary-L6KpBV-x.js"),__vite__mapDeps([31,4,5,30,1,2]),import.meta.url).then(i=>({default:i.TagLibrary}))),a3=z.lazy(()=>fi(()=>import("./DataModel-CHhjk61s.js"),__vite__mapDeps([32,4,22,1,2]),import.meta.url).then(i=>({default:i.DataModel}))),l3=c.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading…"});function xr({children:i}){return c.jsx(z.Suspense,{fallback:l3,children:i})}const c3={skills:{title:"Reusable instructions",intro:"Skills are scoped pieces of context that Claude loads on demand. Add new ones, audit what is live, or disable a skill that is misbehaving."},remote:{title:"Remote machines",intro:"Open a Session Manager running on another computer — its projects, active sessions and a terminal. Pair or revoke machines in Settings → Phone remote."},history:{title:"Spend, tokens and time",intro:"Estimated spend, tokens, prompts and active time across every project — by project, model and day. Export any range to CSV."},plugins:{title:"Plugins",intro:"Extensions for Claude Code. Install, enable, or remove plugins per-scope."},mcp:{title:"MCP Servers",intro:"External tools and integrations the agent can call. Add a new server or test an existing connection."},hooks:{title:"Hooks",intro:"Run scripts on session events. Tail logs, format files, post to Slack — anything that responds to a shell command."},memory:{title:"Memory",intro:"Claude Code's own memory files for this project and its subagents — a MEMORY.md index plus topic files. Stored locally, nothing leaves your machine."},"system-prompt":{title:"System prompt",intro:"The personality and behavior contract for this app. Edits here apply to every new session you spawn."},permissions:{title:"Permissions",intro:"Allow and deny rules per scope. Adjust which tools Claude can call without prompting."},settings:{title:"Settings",intro:"Theme, voice input, billing window, density. Per-scope JSON with schema validation."},"agent-library":{title:"Agent Library",intro:'Agents are the ACTOR of the AIM framework every session opens with — "you are acting as …". Every persona on this machine lives here: global definitions in ~/.claude/agents, plus which currently-open projects override them locally. Give a persona a project scope and an opening instruction and it also becomes an Action — a one-click button in that project’s Sessions toolbar that starts a session already grounded on it. Create, edit, duplicate, or delete a persona; each change writes the matching file on disk.'},"tag-library":{title:"Tag Library",intro:"Every session intent tag, its meaning, and its /develop-eagerness default. Assign or remove which agent personas carry each tag."},voice:{title:"Voice & microphone",intro:"On-device transcription, push-to-talk hotkey, device selection, and TTS toggle."},"data-model":{title:"Data Model",intro:"A hand-maintained ERD of what Session Manager actually persists — storage paths, single-writer owners, and how entities relate."}},d3=()=>{},OS=new Map;function u3(i,e){const t=OS.get(i);if(t&&t.ctx===e)return t.node;const n=h3(i,e);return OS.set(i,{ctx:e,node:n}),n}function h3(i,e){switch(i){case"overview":return c.jsx(ZP,{onNavigate:e.onNavigate,onNewSession:e.onNewSession,onOpenVoice:e.onOpenVoice,onOpenScheduler:e.onOpenScheduler});case"project-home":return c.jsx(Gj,{});case"editor":return c.jsx(fw,{});case"projects":return c.jsx(HO,{})}const t=c3[i],n=(()=>{switch(i){case"skills":return c.jsx(xr,{children:c.jsx(KO,{})});case"history":return c.jsx(xr,{children:c.jsx(YO,{})});case"remote":return c.jsx(xr,{children:c.jsx(XO,{onOpenSettings:()=>{var l;return(l=e.onNavigate)==null?void 0:l.call(e,"settings")}})});case"scheduler":return c.jsx(xr,{children:c.jsx(JO,{navigate:e.onNavigate})});case"plugins":return c.jsx(xr,{children:c.jsx(i3,{})});case"mcp":return c.jsx(xr,{children:c.jsx(n3,{})});case"hooks":return c.jsx(xr,{children:c.jsx(s3,{})});case"memory":return c.jsx(xr,{children:c.jsx(t3,{})});case"system-prompt":return c.jsx(xr,{children:c.jsx(e3,{})});case"permissions":return c.jsx(xr,{children:c.jsx(QO,{})});case"settings":return c.jsx(xr,{children:c.jsx(ZO,{})});case"agent-library":return c.jsx(xr,{children:c.jsx(r3,{})});case"tag-library":return c.jsx(xr,{children:c.jsx(o3,{})});case"data-model":return c.jsx(xr,{children:c.jsx(a3,{})});case"voice":return c.jsx(uO,{open:!0,onClose:d3,variant:"page"});default:return null}})();if(!n)return null;const r=P2[i];return t&&r?c.jsx(qO,{eyebrow:r,title:t.title,intro:t.intro,learnKey:i,children:n}):n}var ab={exports:{}},LS;function p3(){return LS||(LS=1,(function(i,e){(function(t,n){i.exports=n()})(globalThis,(()=>(()=>{var t={4567:function(p,a,d){var f=this&&this.__decorate||function(x,S,T,j){var N,L=arguments.length,R=L<3?S:j===null?j=Object.getOwnPropertyDescriptor(S,T):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(x,S,T,j);else for(var F=x.length-1;F>=0;F--)(N=x[F])&&(R=(L<3?N(R):L>3?N(S,T,R):N(S,T))||R);return L>3&&R&&Object.defineProperty(S,T,R),R},m=this&&this.__param||function(x,S){return function(T,j){S(T,j,x)}};Object.defineProperty(a,"__esModule",{value:!0}),a.AccessibilityManager=void 0;const g=d(9042),y=d(9924),D=d(844),E=d(4725),C=d(2585),b=d(3656);let w=a.AccessibilityManager=class extends D.Disposable{constructor(x,S,T,j){super(),this._terminal=x,this._coreBrowserService=T,this._renderService=j,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let N=0;N<this._terminal.rows;N++)this._rowElements[N]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[N]);if(this._topBoundaryFocusListener=N=>this._handleBoundaryFocus(N,0),this._bottomBoundaryFocusListener=N=>this._handleBoundaryFocus(N,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new y.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((N=>this._handleResize(N.rows)))),this.register(this._terminal.onRender((N=>this._refreshRows(N.start,N.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((N=>this._handleChar(N)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
3036
3036
|
`)))),this.register(this._terminal.onA11yTab((N=>this._handleTab(N)))),this.register(this._terminal.onKey((N=>this._handleKey(N.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,b.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,D.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(x){for(let S=0;S<x;S++)this._handleChar(" ")}_handleChar(x){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==x&&(this._charsToAnnounce+=x):this._charsToAnnounce+=x,x===`
|
|
3037
3037
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=g.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(x){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(x)||this._charsToConsume.push(x)}_refreshRows(x,S){this._liveRegionDebouncer.refresh(x,S,this._terminal.rows)}_renderRows(x,S){const T=this._terminal.buffer,j=T.lines.length.toString();for(let N=x;N<=S;N++){const L=T.lines.get(T.ydisp+N),R=[],F=(L==null?void 0:L.translateToString(!0,void 0,void 0,R))||"",V=(T.ydisp+N+1).toString(),te=this._rowElements[N];te&&(F.length===0?(te.innerText=" ",this._rowColumns.set(te,[0,1])):(te.textContent=F,this._rowColumns.set(te,R)),te.setAttribute("aria-posinset",V),te.setAttribute("aria-setsize",j))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(x,S){const T=x.target,j=this._rowElements[S===0?1:this._rowElements.length-2];if(T.getAttribute("aria-posinset")===(S===0?"1":`${this._terminal.buffer.lines.length}`)||x.relatedTarget!==j)return;let N,L;if(S===0?(N=T,L=this._rowElements.pop(),this._rowContainer.removeChild(L)):(N=this._rowElements.shift(),L=T,this._rowContainer.removeChild(N)),N.removeEventListener("focus",this._topBoundaryFocusListener),L.removeEventListener("focus",this._bottomBoundaryFocusListener),S===0){const R=this._createAccessibilityTreeNode();this._rowElements.unshift(R),this._rowContainer.insertAdjacentElement("afterbegin",R)}else{const R=this._createAccessibilityTreeNode();this._rowElements.push(R),this._rowContainer.appendChild(R)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(S===0?-1:1),this._rowElements[S===0?1:this._rowElements.length-2].focus(),x.preventDefault(),x.stopImmediatePropagation()}_handleSelectionChange(){var F;if(this._rowElements.length===0)return;const x=document.getSelection();if(!x)return;if(x.isCollapsed)return void(this._rowContainer.contains(x.anchorNode)&&this._terminal.clearSelection());if(!x.anchorNode||!x.focusNode)return void console.error("anchorNode and/or focusNode are null");let S={node:x.anchorNode,offset:x.anchorOffset},T={node:x.focusNode,offset:x.focusOffset};if((S.node.compareDocumentPosition(T.node)&Node.DOCUMENT_POSITION_PRECEDING||S.node===T.node&&S.offset>T.offset)&&([S,T]=[T,S]),S.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(S={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(S.node))return;const j=this._rowElements.slice(-1)[0];if(T.node.compareDocumentPosition(j)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(T={node:j,offset:((F=j.textContent)==null?void 0:F.length)??0}),!this._rowContainer.contains(T.node))return;const N=({node:V,offset:te})=>{const he=V instanceof Text?V.parentNode:V;let ee=parseInt(he==null?void 0:he.getAttribute("aria-posinset"),10)-1;if(isNaN(ee))return console.warn("row is invalid. Race condition?"),null;const we=this._rowColumns.get(he);if(!we)return console.warn("columns is null. Race condition?"),null;let ce=te<we.length?we[te]:we.slice(-1)[0]+1;return ce>=this._terminal.cols&&(++ee,ce=0),{row:ee,column:ce}},L=N(S),R=N(T);if(L&&R){if(L.row>R.row||L.row===R.row&&L.column>=R.column)throw new Error("invalid range");this._terminal.select(L.column,L.row,(R.row-L.row)*this._terminal.cols-L.column+R.column)}}_handleResize(x){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let S=this._rowContainer.children.length;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);for(;this._rowElements.length>x;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const x=this._coreBrowserService.mainDocument.createElement("div");return x.setAttribute("role","listitem"),x.tabIndex=-1,this._refreshRowDimensions(x),x}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let x=0;x<this._terminal.rows;x++)this._refreshRowDimensions(this._rowElements[x])}}_refreshRowDimensions(x){x.style.height=`${this._renderService.dimensions.css.cell.height}px`}};a.AccessibilityManager=w=f([m(1,C.IInstantiationService),m(2,E.ICoreBrowserService),m(3,E.IRenderService)],w)},3614:(p,a)=>{function d(y){return y.replace(/\r?\n/g,"\r")}function f(y,D){return D?"\x1B[200~"+y+"\x1B[201~":y}function m(y,D,E,C){y=f(y=d(y),E.decPrivateModes.bracketedPasteMode&&C.rawOptions.ignoreBracketedPasteMode!==!0),E.triggerDataEvent(y,!0),D.value=""}function g(y,D,E){const C=E.getBoundingClientRect(),b=y.clientX-C.left-10,w=y.clientY-C.top-10;D.style.width="20px",D.style.height="20px",D.style.left=`${b}px`,D.style.top=`${w}px`,D.style.zIndex="1000",D.focus()}Object.defineProperty(a,"__esModule",{value:!0}),a.rightClickHandler=a.moveTextAreaUnderMouseCursor=a.paste=a.handlePasteEvent=a.copyHandler=a.bracketTextForPaste=a.prepareTextForTerminal=void 0,a.prepareTextForTerminal=d,a.bracketTextForPaste=f,a.copyHandler=function(y,D){y.clipboardData&&y.clipboardData.setData("text/plain",D.selectionText),y.preventDefault()},a.handlePasteEvent=function(y,D,E,C){y.stopPropagation(),y.clipboardData&&m(y.clipboardData.getData("text/plain"),D,E,C)},a.paste=m,a.moveTextAreaUnderMouseCursor=g,a.rightClickHandler=function(y,D,E,C,b){g(y,D,E),b&&C.rightClickSelect(y),D.value=C.selectionText,D.select()}},7239:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.ColorContrastCache=void 0;const f=d(1505);a.ColorContrastCache=class{constructor(){this._color=new f.TwoKeyMap,this._css=new f.TwoKeyMap}setCss(m,g,y){this._css.set(m,g,y)}getCss(m,g){return this._css.get(m,g)}setColor(m,g,y){this._color.set(m,g,y)}getColor(m,g){return this._color.get(m,g)}clear(){this._color.clear(),this._css.clear()}}},3656:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.addDisposableDomListener=void 0,a.addDisposableDomListener=function(d,f,m,g){d.addEventListener(f,m,g);let y=!1;return{dispose:()=>{y||(y=!0,d.removeEventListener(f,m,g))}}}},3551:function(p,a,d){var f=this&&this.__decorate||function(w,x,S,T){var j,N=arguments.length,L=N<3?x:T===null?T=Object.getOwnPropertyDescriptor(x,S):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(w,x,S,T);else for(var R=w.length-1;R>=0;R--)(j=w[R])&&(L=(N<3?j(L):N>3?j(x,S,L):j(x,S))||L);return N>3&&L&&Object.defineProperty(x,S,L),L},m=this&&this.__param||function(w,x){return function(S,T){x(S,T,w)}};Object.defineProperty(a,"__esModule",{value:!0}),a.Linkifier=void 0;const g=d(3656),y=d(8460),D=d(844),E=d(2585),C=d(4725);let b=a.Linkifier=class extends D.Disposable{get currentLink(){return this._currentLink}constructor(w,x,S,T,j){super(),this._element=w,this._mouseService=x,this._renderService=S,this._bufferService=T,this._linkProviderService=j,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new y.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new y.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,D.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,D.toDisposable)((()=>{var N;this._lastMouseEvent=void 0,(N=this._activeProviderReplies)==null||N.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,g.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,g.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,g.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,g.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(w){this._lastMouseEvent=w;const x=this._positionFromMouseEvent(w,this._element,this._mouseService);if(!x)return;this._isMouseOut=!1;const S=w.composedPath();for(let T=0;T<S.length;T++){const j=S[T];if(j.classList.contains("xterm"))break;if(j.classList.contains("xterm-hover"))return}this._lastBufferCell&&x.x===this._lastBufferCell.x&&x.y===this._lastBufferCell.y||(this._handleHover(x),this._lastBufferCell=x)}_handleHover(w){if(this._activeLine!==w.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(w,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,w)||(this._clearCurrentLink(),this._askForLink(w,!0))}_askForLink(w,x){var T,j;this._activeProviderReplies&&x||((T=this._activeProviderReplies)==null||T.forEach((N=>{N==null||N.forEach((L=>{L.link.dispose&&L.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=w.y);let S=!1;for(const[N,L]of this._linkProviderService.linkProviders.entries())x?(j=this._activeProviderReplies)!=null&&j.get(N)&&(S=this._checkLinkProviderResult(N,w,S)):L.provideLinks(w.y,(R=>{var V,te;if(this._isMouseOut)return;const F=R==null?void 0:R.map((he=>({link:he})));(V=this._activeProviderReplies)==null||V.set(N,F),S=this._checkLinkProviderResult(N,w,S),((te=this._activeProviderReplies)==null?void 0:te.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(w.y,this._activeProviderReplies)}))}_removeIntersectingLinks(w,x){const S=new Set;for(let T=0;T<x.size;T++){const j=x.get(T);if(j)for(let N=0;N<j.length;N++){const L=j[N],R=L.link.range.start.y<w?0:L.link.range.start.x,F=L.link.range.end.y>w?this._bufferService.cols:L.link.range.end.x;for(let V=R;V<=F;V++){if(S.has(V)){j.splice(N--,1);break}S.add(V)}}}}_checkLinkProviderResult(w,x,S){var N;if(!this._activeProviderReplies)return S;const T=this._activeProviderReplies.get(w);let j=!1;for(let L=0;L<w;L++)this._activeProviderReplies.has(L)&&!this._activeProviderReplies.get(L)||(j=!0);if(!j&&T){const L=T.find((R=>this._linkAtPosition(R.link,x)));L&&(S=!0,this._handleNewLink(L))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!S)for(let L=0;L<this._activeProviderReplies.size;L++){const R=(N=this._activeProviderReplies.get(L))==null?void 0:N.find((F=>this._linkAtPosition(F.link,x)));if(R){S=!0,this._handleNewLink(R);break}}return S}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(w){if(!this._currentLink)return;const x=this._positionFromMouseEvent(w,this._element,this._mouseService);x&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,x)&&this._currentLink.link.activate(w,this._currentLink.link.text)}_clearCurrentLink(w,x){this._currentLink&&this._lastMouseEvent&&(!w||!x||this._currentLink.link.range.start.y>=w&&this._currentLink.link.range.end.y<=x)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,D.disposeArray)(this._linkCacheDisposables))}_handleNewLink(w){if(!this._lastMouseEvent)return;const x=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);x&&this._linkAtPosition(w.link,x)&&(this._currentLink=w,this._currentLink.state={decorations:{underline:w.link.decorations===void 0||w.link.decorations.underline,pointerCursor:w.link.decorations===void 0||w.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,w.link,this._lastMouseEvent),w.link.decorations={},Object.defineProperties(w.link.decorations,{pointerCursor:{get:()=>{var S,T;return(T=(S=this._currentLink)==null?void 0:S.state)==null?void 0:T.decorations.pointerCursor},set:S=>{var T;(T=this._currentLink)!=null&&T.state&&this._currentLink.state.decorations.pointerCursor!==S&&(this._currentLink.state.decorations.pointerCursor=S,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",S))}},underline:{get:()=>{var S,T;return(T=(S=this._currentLink)==null?void 0:S.state)==null?void 0:T.decorations.underline},set:S=>{var T,j,N;(T=this._currentLink)!=null&&T.state&&((N=(j=this._currentLink)==null?void 0:j.state)==null?void 0:N.decorations.underline)!==S&&(this._currentLink.state.decorations.underline=S,this._currentLink.state.isHovered&&this._fireUnderlineEvent(w.link,S))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((S=>{if(!this._currentLink)return;const T=S.start===0?0:S.start+1+this._bufferService.buffer.ydisp,j=this._bufferService.buffer.ydisp+1+S.end;if(this._currentLink.link.range.start.y>=T&&this._currentLink.link.range.end.y<=j&&(this._clearCurrentLink(T,j),this._lastMouseEvent)){const N=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);N&&this._askForLink(N,!1)}}))))}_linkHover(w,x,S){var T;(T=this._currentLink)!=null&&T.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(x,!0),this._currentLink.state.decorations.pointerCursor&&w.classList.add("xterm-cursor-pointer")),x.hover&&x.hover(S,x.text)}_fireUnderlineEvent(w,x){const S=w.range,T=this._bufferService.buffer.ydisp,j=this._createLinkUnderlineEvent(S.start.x-1,S.start.y-T-1,S.end.x,S.end.y-T-1,void 0);(x?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(j)}_linkLeave(w,x,S){var T;(T=this._currentLink)!=null&&T.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(x,!1),this._currentLink.state.decorations.pointerCursor&&w.classList.remove("xterm-cursor-pointer")),x.leave&&x.leave(S,x.text)}_linkAtPosition(w,x){const S=w.range.start.y*this._bufferService.cols+w.range.start.x,T=w.range.end.y*this._bufferService.cols+w.range.end.x,j=x.y*this._bufferService.cols+x.x;return S<=j&&j<=T}_positionFromMouseEvent(w,x,S){const T=S.getCoords(w,x,this._bufferService.cols,this._bufferService.rows);if(T)return{x:T[0],y:T[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(w,x,S,T,j){return{x1:w,y1:x,x2:S,y2:T,cols:this._bufferService.cols,fg:j}}};a.Linkifier=b=f([m(1,C.IMouseService),m(2,C.IRenderService),m(3,E.IBufferService),m(4,C.ILinkProviderService)],b)},9042:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.tooMuchOutput=a.promptLabel=void 0,a.promptLabel="Terminal input",a.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(p,a,d){var f=this&&this.__decorate||function(C,b,w,x){var S,T=arguments.length,j=T<3?b:x===null?x=Object.getOwnPropertyDescriptor(b,w):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(C,b,w,x);else for(var N=C.length-1;N>=0;N--)(S=C[N])&&(j=(T<3?S(j):T>3?S(b,w,j):S(b,w))||j);return T>3&&j&&Object.defineProperty(b,w,j),j},m=this&&this.__param||function(C,b){return function(w,x){b(w,x,C)}};Object.defineProperty(a,"__esModule",{value:!0}),a.OscLinkProvider=void 0;const g=d(511),y=d(2585);let D=a.OscLinkProvider=class{constructor(C,b,w){this._bufferService=C,this._optionsService=b,this._oscLinkService=w}provideLinks(C,b){var F;const w=this._bufferService.buffer.lines.get(C-1);if(!w)return void b(void 0);const x=[],S=this._optionsService.rawOptions.linkHandler,T=new g.CellData,j=w.getTrimmedLength();let N=-1,L=-1,R=!1;for(let V=0;V<j;V++)if(L!==-1||w.hasContent(V)){if(w.loadCell(V,T),T.hasExtendedAttrs()&&T.extended.urlId){if(L===-1){L=V,N=T.extended.urlId;continue}R=T.extended.urlId!==N}else L!==-1&&(R=!0);if(R||L!==-1&&V===j-1){const te=(F=this._oscLinkService.getLinkData(N))==null?void 0:F.uri;if(te){const he={start:{x:L+1,y:C},end:{x:V+(R||V!==j-1?0:1),y:C}};let ee=!1;if(!(S!=null&&S.allowNonHttpProtocols))try{const we=new URL(te);["http:","https:"].includes(we.protocol)||(ee=!0)}catch{ee=!0}ee||x.push({text:te,range:he,activate:(we,ce)=>S?S.activate(we,ce,he):E(0,ce),hover:(we,ce)=>{var ve;return(ve=S==null?void 0:S.hover)==null?void 0:ve.call(S,we,ce,he)},leave:(we,ce)=>{var ve;return(ve=S==null?void 0:S.leave)==null?void 0:ve.call(S,we,ce,he)}})}R=!1,T.hasExtendedAttrs()&&T.extended.urlId?(L=V,N=T.extended.urlId):(L=-1,N=-1)}}b(x)}};function E(C,b){if(confirm(`Do you want to navigate to ${b}?
|
|
3038
3038
|
|
|
@@ -3040,7 +3040,7 @@ WARNING: This link could potentially be dangerous`)){const w=window.open();if(w)
|
|
|
3040
3040
|
`:`
|
|
3041
3041
|
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(R){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),w.isLinux&&R&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(R){const F=this._getMouseBufferCoords(R),V=this._model.finalSelectionStart,te=this._model.finalSelectionEnd;return!!(V&&te&&F)&&this._areCoordsInSelection(F,V,te)}isCellInSelection(R,F){const V=this._model.finalSelectionStart,te=this._model.finalSelectionEnd;return!(!V||!te)&&this._areCoordsInSelection([R,F],V,te)}_areCoordsInSelection(R,F,V){return R[1]>F[1]&&R[1]<V[1]||F[1]===V[1]&&R[1]===F[1]&&R[0]>=F[0]&&R[0]<V[0]||F[1]<V[1]&&R[1]===V[1]&&R[0]<V[0]||F[1]<V[1]&&R[1]===F[1]&&R[0]>=F[0]}_selectWordAtCursor(R,F){var he,ee;const V=(ee=(he=this._linkifier.currentLink)==null?void 0:he.link)==null?void 0:ee.range;if(V)return this._model.selectionStart=[V.start.x-1,V.start.y-1],this._model.selectionStartLength=(0,x.getRangeLength)(V,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const te=this._getMouseBufferCoords(R);return!!te&&(this._selectWordAt(te,F),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(R,F){this._model.clearSelection(),R=Math.max(R,0),F=Math.min(F,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,R],this._model.selectionEnd=[this._bufferService.cols,F],this.refresh(),this._onSelectionChange.fire()}_handleTrim(R){this._model.handleTrim(R)&&this.refresh()}_getMouseBufferCoords(R){const F=this._mouseService.getCoords(R,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(F)return F[0]--,F[1]--,F[1]+=this._bufferService.buffer.ydisp,F}_getMouseEventScrollAmount(R){let F=(0,g.getCoordsRelativeToElement)(this._coreBrowserService.window,R,this._screenElement)[1];const V=this._renderService.dimensions.css.canvas.height;return F>=0&&F<=V?0:(F>V&&(F-=V),F=Math.min(Math.max(F,-50),50),F/=50,F/Math.abs(F)+Math.round(14*F))}shouldForceSelection(R){return w.isMac?R.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:R.shiftKey}handleMouseDown(R){if(this._mouseDownTimeStamp=R.timeStamp,(R.button!==2||!this.hasSelection)&&R.button===0){if(!this._enabled){if(!this.shouldForceSelection(R))return;R.stopPropagation()}R.preventDefault(),this._dragScrollAmount=0,this._enabled&&R.shiftKey?this._handleIncrementalClick(R):R.detail===1?this._handleSingleClick(R):R.detail===2?this._handleDoubleClick(R):R.detail===3&&this._handleTripleClick(R),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(R){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(R))}_handleSingleClick(R){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(R)?3:0,this._model.selectionStart=this._getMouseBufferCoords(R),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const F=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);F&&F.length!==this._model.selectionStart[0]&&F.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(R){this._selectWordAtCursor(R,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(R){const F=this._getMouseBufferCoords(R);F&&(this._activeSelectionMode=2,this._selectLineAt(F[1]))}shouldColumnSelect(R){return R.altKey&&!(w.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(R){if(R.stopImmediatePropagation(),!this._model.selectionStart)return;const F=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(R),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(R),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const V=this._bufferService.buffer;if(this._model.selectionEnd[1]<V.lines.length){const te=V.lines.get(this._model.selectionEnd[1]);te&&te.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}F&&F[0]===this._model.selectionEnd[0]&&F[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const R=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(R.ydisp+this._bufferService.rows,R.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=R.ydisp),this.refresh()}}_handleMouseUp(R){const F=R.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&F<500&&R.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const V=this._mouseService.getCoords(R,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(V&&V[0]!==void 0&&V[1]!==void 0){const te=(0,y.moveToCellSequence)(V[0]-1,V[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(te,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const R=this._model.finalSelectionStart,F=this._model.finalSelectionEnd,V=!(!R||!F||R[0]===F[0]&&R[1]===F[1]);V?R&&F&&(this._oldSelectionStart&&this._oldSelectionEnd&&R[0]===this._oldSelectionStart[0]&&R[1]===this._oldSelectionStart[1]&&F[0]===this._oldSelectionEnd[0]&&F[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(R,F,V)):this._oldHasSelection&&this._fireOnSelectionChange(R,F,V)}_fireOnSelectionChange(R,F,V){this._oldSelectionStart=R,this._oldSelectionEnd=F,this._oldHasSelection=V,this._onSelectionChange.fire()}_handleBufferActivate(R){this.clearSelection(),this._trimListener.dispose(),this._trimListener=R.activeBuffer.lines.onTrim((F=>this._handleTrim(F)))}_convertViewportColToCharacterIndex(R,F){let V=F;for(let te=0;F>=te;te++){const he=R.loadCell(te,this._workCell).getChars().length;this._workCell.getWidth()===0?V--:he>1&&F!==te&&(V+=he-1)}return V}setSelection(R,F,V){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[R,F],this._model.selectionStartLength=V,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(R){this._isClickInSelection(R)||(this._selectWordAtCursor(R,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(R,F,V=!0,te=!0){if(R[0]>=this._bufferService.cols)return;const he=this._bufferService.buffer,ee=he.lines.get(R[1]);if(!ee)return;const we=he.translateBufferLineToString(R[1],!1);let ce=this._convertViewportColToCharacterIndex(ee,R[0]),ve=ce;const Ee=R[0]-ce;let fe=0,U=0,X=0,W=0;if(we.charAt(ce)===" "){for(;ce>0&&we.charAt(ce-1)===" ";)ce--;for(;ve<we.length&&we.charAt(ve+1)===" ";)ve++}else{let Ce=R[0],Oe=R[0];ee.getWidth(Ce)===0&&(fe++,Ce--),ee.getWidth(Oe)===2&&(U++,Oe++);const Xe=ee.getString(Oe).length;for(Xe>1&&(W+=Xe-1,ve+=Xe-1);Ce>0&&ce>0&&!this._isCharWordSeparator(ee.loadCell(Ce-1,this._workCell));){ee.loadCell(Ce-1,this._workCell);const ge=this._workCell.getChars().length;this._workCell.getWidth()===0?(fe++,Ce--):ge>1&&(X+=ge-1,ce-=ge-1),ce--,Ce--}for(;Oe<ee.length&&ve+1<we.length&&!this._isCharWordSeparator(ee.loadCell(Oe+1,this._workCell));){ee.loadCell(Oe+1,this._workCell);const ge=this._workCell.getChars().length;this._workCell.getWidth()===2?(U++,Oe++):ge>1&&(W+=ge-1,ve+=ge-1),ve++,Oe++}}ve++;let Q=ce+Ee-fe+X,oe=Math.min(this._bufferService.cols,ve-ce+fe+U-X-W);if(F||we.slice(ce,ve).trim()!==""){if(V&&Q===0&&ee.getCodePoint(0)!==32){const Ce=he.lines.get(R[1]-1);if(Ce&&ee.isWrapped&&Ce.getCodePoint(this._bufferService.cols-1)!==32){const Oe=this._getWordAt([this._bufferService.cols-1,R[1]-1],!1,!0,!1);if(Oe){const Xe=this._bufferService.cols-Oe.start;Q-=Xe,oe+=Xe}}}if(te&&Q+oe===this._bufferService.cols&&ee.getCodePoint(this._bufferService.cols-1)!==32){const Ce=he.lines.get(R[1]+1);if(Ce!=null&&Ce.isWrapped&&Ce.getCodePoint(0)!==32){const Oe=this._getWordAt([0,R[1]+1],!1,!1,!0);Oe&&(oe+=Oe.length)}}return{start:Q,length:oe}}}_selectWordAt(R,F){const V=this._getWordAt(R,F);if(V){for(;V.start<0;)V.start+=this._bufferService.cols,R[1]--;this._model.selectionStart=[V.start,R[1]],this._model.selectionStartLength=V.length}}_selectToWordAt(R){const F=this._getWordAt(R,!0);if(F){let V=R[1];for(;F.start<0;)F.start+=this._bufferService.cols,V--;if(!this._model.areSelectionValuesReversed())for(;F.start+F.length>this._bufferService.cols;)F.length-=this._bufferService.cols,V++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?F.start:F.start+F.length,V]}}_isCharWordSeparator(R){return R.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(R.getChars())>=0}_selectLineAt(R){const F=this._bufferService.buffer.getWrappedRangeForLine(R),V={start:{x:0,y:F.first},end:{x:this._bufferService.cols-1,y:F.last}};this._model.selectionStart=[0,F.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,x.getRangeLength)(V,this._bufferService.cols)}};a.SelectionService=L=f([m(3,T.IBufferService),m(4,T.ICoreService),m(5,E.IMouseService),m(6,T.IOptionsService),m(7,E.IRenderService),m(8,E.ICoreBrowserService)],L)},4725:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.ILinkProviderService=a.IThemeService=a.ICharacterJoinerService=a.ISelectionService=a.IRenderService=a.IMouseService=a.ICoreBrowserService=a.ICharSizeService=void 0;const f=d(8343);a.ICharSizeService=(0,f.createDecorator)("CharSizeService"),a.ICoreBrowserService=(0,f.createDecorator)("CoreBrowserService"),a.IMouseService=(0,f.createDecorator)("MouseService"),a.IRenderService=(0,f.createDecorator)("RenderService"),a.ISelectionService=(0,f.createDecorator)("SelectionService"),a.ICharacterJoinerService=(0,f.createDecorator)("CharacterJoinerService"),a.IThemeService=(0,f.createDecorator)("ThemeService"),a.ILinkProviderService=(0,f.createDecorator)("LinkProviderService")},6731:function(p,a,d){var f=this&&this.__decorate||function(L,R,F,V){var te,he=arguments.length,ee=he<3?R:V===null?V=Object.getOwnPropertyDescriptor(R,F):V;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")ee=Reflect.decorate(L,R,F,V);else for(var we=L.length-1;we>=0;we--)(te=L[we])&&(ee=(he<3?te(ee):he>3?te(R,F,ee):te(R,F))||ee);return he>3&&ee&&Object.defineProperty(R,F,ee),ee},m=this&&this.__param||function(L,R){return function(F,V){R(F,V,L)}};Object.defineProperty(a,"__esModule",{value:!0}),a.ThemeService=a.DEFAULT_ANSI_COLORS=void 0;const g=d(7239),y=d(8055),D=d(8460),E=d(844),C=d(2585),b=y.css.toColor("#ffffff"),w=y.css.toColor("#000000"),x=y.css.toColor("#ffffff"),S=y.css.toColor("#000000"),T={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};a.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const L=[y.css.toColor("#2e3436"),y.css.toColor("#cc0000"),y.css.toColor("#4e9a06"),y.css.toColor("#c4a000"),y.css.toColor("#3465a4"),y.css.toColor("#75507b"),y.css.toColor("#06989a"),y.css.toColor("#d3d7cf"),y.css.toColor("#555753"),y.css.toColor("#ef2929"),y.css.toColor("#8ae234"),y.css.toColor("#fce94f"),y.css.toColor("#729fcf"),y.css.toColor("#ad7fa8"),y.css.toColor("#34e2e2"),y.css.toColor("#eeeeec")],R=[0,95,135,175,215,255];for(let F=0;F<216;F++){const V=R[F/36%6|0],te=R[F/6%6|0],he=R[F%6];L.push({css:y.channels.toCss(V,te,he),rgba:y.channels.toRgba(V,te,he)})}for(let F=0;F<24;F++){const V=8+10*F;L.push({css:y.channels.toCss(V,V,V),rgba:y.channels.toRgba(V,V,V)})}return L})());let j=a.ThemeService=class extends E.Disposable{get colors(){return this._colors}constructor(L){super(),this._optionsService=L,this._contrastCache=new g.ColorContrastCache,this._halfContrastCache=new g.ColorContrastCache,this._onChangeColors=this.register(new D.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:b,background:w,cursor:x,cursorAccent:S,selectionForeground:void 0,selectionBackgroundTransparent:T,selectionBackgroundOpaque:y.color.blend(w,T),selectionInactiveBackgroundTransparent:T,selectionInactiveBackgroundOpaque:y.color.blend(w,T),ansi:a.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(L={}){const R=this._colors;if(R.foreground=N(L.foreground,b),R.background=N(L.background,w),R.cursor=N(L.cursor,x),R.cursorAccent=N(L.cursorAccent,S),R.selectionBackgroundTransparent=N(L.selectionBackground,T),R.selectionBackgroundOpaque=y.color.blend(R.background,R.selectionBackgroundTransparent),R.selectionInactiveBackgroundTransparent=N(L.selectionInactiveBackground,R.selectionBackgroundTransparent),R.selectionInactiveBackgroundOpaque=y.color.blend(R.background,R.selectionInactiveBackgroundTransparent),R.selectionForeground=L.selectionForeground?N(L.selectionForeground,y.NULL_COLOR):void 0,R.selectionForeground===y.NULL_COLOR&&(R.selectionForeground=void 0),y.color.isOpaque(R.selectionBackgroundTransparent)&&(R.selectionBackgroundTransparent=y.color.opacity(R.selectionBackgroundTransparent,.3)),y.color.isOpaque(R.selectionInactiveBackgroundTransparent)&&(R.selectionInactiveBackgroundTransparent=y.color.opacity(R.selectionInactiveBackgroundTransparent,.3)),R.ansi=a.DEFAULT_ANSI_COLORS.slice(),R.ansi[0]=N(L.black,a.DEFAULT_ANSI_COLORS[0]),R.ansi[1]=N(L.red,a.DEFAULT_ANSI_COLORS[1]),R.ansi[2]=N(L.green,a.DEFAULT_ANSI_COLORS[2]),R.ansi[3]=N(L.yellow,a.DEFAULT_ANSI_COLORS[3]),R.ansi[4]=N(L.blue,a.DEFAULT_ANSI_COLORS[4]),R.ansi[5]=N(L.magenta,a.DEFAULT_ANSI_COLORS[5]),R.ansi[6]=N(L.cyan,a.DEFAULT_ANSI_COLORS[6]),R.ansi[7]=N(L.white,a.DEFAULT_ANSI_COLORS[7]),R.ansi[8]=N(L.brightBlack,a.DEFAULT_ANSI_COLORS[8]),R.ansi[9]=N(L.brightRed,a.DEFAULT_ANSI_COLORS[9]),R.ansi[10]=N(L.brightGreen,a.DEFAULT_ANSI_COLORS[10]),R.ansi[11]=N(L.brightYellow,a.DEFAULT_ANSI_COLORS[11]),R.ansi[12]=N(L.brightBlue,a.DEFAULT_ANSI_COLORS[12]),R.ansi[13]=N(L.brightMagenta,a.DEFAULT_ANSI_COLORS[13]),R.ansi[14]=N(L.brightCyan,a.DEFAULT_ANSI_COLORS[14]),R.ansi[15]=N(L.brightWhite,a.DEFAULT_ANSI_COLORS[15]),L.extendedAnsi){const F=Math.min(R.ansi.length-16,L.extendedAnsi.length);for(let V=0;V<F;V++)R.ansi[V+16]=N(L.extendedAnsi[V],a.DEFAULT_ANSI_COLORS[V+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(L){this._restoreColor(L),this._onChangeColors.fire(this.colors)}_restoreColor(L){if(L!==void 0)switch(L){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[L]=this._restoreColors.ansi[L]}else for(let R=0;R<this._restoreColors.ansi.length;++R)this._colors.ansi[R]=this._restoreColors.ansi[R]}modifyColors(L){L(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function N(L,R){if(L!==void 0)try{return y.css.toColor(L)}catch{}return R}a.ThemeService=j=f([m(0,C.IOptionsService)],j)},6349:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.CircularList=void 0;const f=d(8460),m=d(844);class g extends m.Disposable{constructor(D){super(),this._maxLength=D,this.onDeleteEmitter=this.register(new f.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new f.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new f.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(D){if(this._maxLength===D)return;const E=new Array(D);for(let C=0;C<Math.min(D,this.length);C++)E[C]=this._array[this._getCyclicIndex(C)];this._array=E,this._maxLength=D,this._startIndex=0}get length(){return this._length}set length(D){if(D>this._length)for(let E=this._length;E<D;E++)this._array[E]=void 0;this._length=D}get(D){return this._array[this._getCyclicIndex(D)]}set(D,E){this._array[this._getCyclicIndex(D)]=E}push(D){this._array[this._getCyclicIndex(this._length)]=D,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(D,E,...C){if(E){for(let b=D;b<this._length-E;b++)this._array[this._getCyclicIndex(b)]=this._array[this._getCyclicIndex(b+E)];this._length-=E,this.onDeleteEmitter.fire({index:D,amount:E})}for(let b=this._length-1;b>=D;b--)this._array[this._getCyclicIndex(b+C.length)]=this._array[this._getCyclicIndex(b)];for(let b=0;b<C.length;b++)this._array[this._getCyclicIndex(D+b)]=C[b];if(C.length&&this.onInsertEmitter.fire({index:D,amount:C.length}),this._length+C.length>this._maxLength){const b=this._length+C.length-this._maxLength;this._startIndex+=b,this._length=this._maxLength,this.onTrimEmitter.fire(b)}else this._length+=C.length}trimStart(D){D>this._length&&(D=this._length),this._startIndex+=D,this._length-=D,this.onTrimEmitter.fire(D)}shiftElements(D,E,C){if(!(E<=0)){if(D<0||D>=this._length)throw new Error("start argument out of range");if(D+C<0)throw new Error("Cannot shift elements in list beyond index 0");if(C>0){for(let w=E-1;w>=0;w--)this.set(D+w+C,this.get(D+w));const b=D+E+C-this._length;if(b>0)for(this._length+=b;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let b=0;b<E;b++)this.set(D+b+C,this.get(D+b))}}_getCyclicIndex(D){return(this._startIndex+D)%this._maxLength}}a.CircularList=g},1439:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.clone=void 0,a.clone=function d(f,m=5){if(typeof f!="object")return f;const g=Array.isArray(f)?[]:{};for(const y in f)g[y]=m<=1?f[y]:f[y]&&d(f[y],m-1);return g}},8055:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.contrastRatio=a.toPaddedHex=a.rgba=a.rgb=a.css=a.color=a.channels=a.NULL_COLOR=void 0;let d=0,f=0,m=0,g=0;var y,D,E,C,b;function w(S){const T=S.toString(16);return T.length<2?"0"+T:T}function x(S,T){return S<T?(T+.05)/(S+.05):(S+.05)/(T+.05)}a.NULL_COLOR={css:"#00000000",rgba:0},(function(S){S.toCss=function(T,j,N,L){return L!==void 0?`#${w(T)}${w(j)}${w(N)}${w(L)}`:`#${w(T)}${w(j)}${w(N)}`},S.toRgba=function(T,j,N,L=255){return(T<<24|j<<16|N<<8|L)>>>0},S.toColor=function(T,j,N,L){return{css:S.toCss(T,j,N,L),rgba:S.toRgba(T,j,N,L)}}})(y||(a.channels=y={})),(function(S){function T(j,N){return g=Math.round(255*N),[d,f,m]=b.toChannels(j.rgba),{css:y.toCss(d,f,m,g),rgba:y.toRgba(d,f,m,g)}}S.blend=function(j,N){if(g=(255&N.rgba)/255,g===1)return{css:N.css,rgba:N.rgba};const L=N.rgba>>24&255,R=N.rgba>>16&255,F=N.rgba>>8&255,V=j.rgba>>24&255,te=j.rgba>>16&255,he=j.rgba>>8&255;return d=V+Math.round((L-V)*g),f=te+Math.round((R-te)*g),m=he+Math.round((F-he)*g),{css:y.toCss(d,f,m),rgba:y.toRgba(d,f,m)}},S.isOpaque=function(j){return(255&j.rgba)==255},S.ensureContrastRatio=function(j,N,L){const R=b.ensureContrastRatio(j.rgba,N.rgba,L);if(R)return y.toColor(R>>24&255,R>>16&255,R>>8&255)},S.opaque=function(j){const N=(255|j.rgba)>>>0;return[d,f,m]=b.toChannels(N),{css:y.toCss(d,f,m),rgba:N}},S.opacity=T,S.multiplyOpacity=function(j,N){return g=255&j.rgba,T(j,g*N/255)},S.toColorRGB=function(j){return[j.rgba>>24&255,j.rgba>>16&255,j.rgba>>8&255]}})(D||(a.color=D={})),(function(S){let T,j;try{const N=document.createElement("canvas");N.width=1,N.height=1;const L=N.getContext("2d",{willReadFrequently:!0});L&&(T=L,T.globalCompositeOperation="copy",j=T.createLinearGradient(0,0,1,1))}catch{}S.toColor=function(N){if(N.match(/#[\da-f]{3,8}/i))switch(N.length){case 4:return d=parseInt(N.slice(1,2).repeat(2),16),f=parseInt(N.slice(2,3).repeat(2),16),m=parseInt(N.slice(3,4).repeat(2),16),y.toColor(d,f,m);case 5:return d=parseInt(N.slice(1,2).repeat(2),16),f=parseInt(N.slice(2,3).repeat(2),16),m=parseInt(N.slice(3,4).repeat(2),16),g=parseInt(N.slice(4,5).repeat(2),16),y.toColor(d,f,m,g);case 7:return{css:N,rgba:(parseInt(N.slice(1),16)<<8|255)>>>0};case 9:return{css:N,rgba:parseInt(N.slice(1),16)>>>0}}const L=N.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(L)return d=parseInt(L[1]),f=parseInt(L[2]),m=parseInt(L[3]),g=Math.round(255*(L[5]===void 0?1:parseFloat(L[5]))),y.toColor(d,f,m,g);if(!T||!j)throw new Error("css.toColor: Unsupported css format");if(T.fillStyle=j,T.fillStyle=N,typeof T.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(T.fillRect(0,0,1,1),[d,f,m,g]=T.getImageData(0,0,1,1).data,g!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(d,f,m,g),css:N}}})(E||(a.css=E={})),(function(S){function T(j,N,L){const R=j/255,F=N/255,V=L/255;return .2126*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))+.7152*(F<=.03928?F/12.92:Math.pow((F+.055)/1.055,2.4))+.0722*(V<=.03928?V/12.92:Math.pow((V+.055)/1.055,2.4))}S.relativeLuminance=function(j){return T(j>>16&255,j>>8&255,255&j)},S.relativeLuminance2=T})(C||(a.rgb=C={})),(function(S){function T(N,L,R){const F=N>>24&255,V=N>>16&255,te=N>>8&255;let he=L>>24&255,ee=L>>16&255,we=L>>8&255,ce=x(C.relativeLuminance2(he,ee,we),C.relativeLuminance2(F,V,te));for(;ce<R&&(he>0||ee>0||we>0);)he-=Math.max(0,Math.ceil(.1*he)),ee-=Math.max(0,Math.ceil(.1*ee)),we-=Math.max(0,Math.ceil(.1*we)),ce=x(C.relativeLuminance2(he,ee,we),C.relativeLuminance2(F,V,te));return(he<<24|ee<<16|we<<8|255)>>>0}function j(N,L,R){const F=N>>24&255,V=N>>16&255,te=N>>8&255;let he=L>>24&255,ee=L>>16&255,we=L>>8&255,ce=x(C.relativeLuminance2(he,ee,we),C.relativeLuminance2(F,V,te));for(;ce<R&&(he<255||ee<255||we<255);)he=Math.min(255,he+Math.ceil(.1*(255-he))),ee=Math.min(255,ee+Math.ceil(.1*(255-ee))),we=Math.min(255,we+Math.ceil(.1*(255-we))),ce=x(C.relativeLuminance2(he,ee,we),C.relativeLuminance2(F,V,te));return(he<<24|ee<<16|we<<8|255)>>>0}S.blend=function(N,L){if(g=(255&L)/255,g===1)return L;const R=L>>24&255,F=L>>16&255,V=L>>8&255,te=N>>24&255,he=N>>16&255,ee=N>>8&255;return d=te+Math.round((R-te)*g),f=he+Math.round((F-he)*g),m=ee+Math.round((V-ee)*g),y.toRgba(d,f,m)},S.ensureContrastRatio=function(N,L,R){const F=C.relativeLuminance(N>>8),V=C.relativeLuminance(L>>8);if(x(F,V)<R){if(V<F){const ee=T(N,L,R),we=x(F,C.relativeLuminance(ee>>8));if(we<R){const ce=j(N,L,R);return we>x(F,C.relativeLuminance(ce>>8))?ee:ce}return ee}const te=j(N,L,R),he=x(F,C.relativeLuminance(te>>8));if(he<R){const ee=T(N,L,R);return he>x(F,C.relativeLuminance(ee>>8))?te:ee}return te}},S.reduceLuminance=T,S.increaseLuminance=j,S.toChannels=function(N){return[N>>24&255,N>>16&255,N>>8&255,255&N]}})(b||(a.rgba=b={})),a.toPaddedHex=w,a.contrastRatio=x},8969:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.CoreTerminal=void 0;const f=d(844),m=d(2585),g=d(4348),y=d(7866),D=d(744),E=d(7302),C=d(6975),b=d(8460),w=d(1753),x=d(1480),S=d(7994),T=d(9282),j=d(5435),N=d(5981),L=d(2660);let R=!1;class F extends f.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new b.EventEmitter),this._onScroll.event((te=>{var he;(he=this._onScrollApi)==null||he.fire(te.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(te){for(const he in te)this.optionsService.options[he]=te[he]}constructor(te){super(),this._windowsWrappingHeuristics=this.register(new f.MutableDisposable),this._onBinary=this.register(new b.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new b.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new b.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new b.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new b.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new b.EventEmitter),this._instantiationService=new g.InstantiationService,this.optionsService=this.register(new E.OptionsService(te)),this._instantiationService.setService(m.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(D.BufferService)),this._instantiationService.setService(m.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(y.LogService)),this._instantiationService.setService(m.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(C.CoreService)),this._instantiationService.setService(m.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(w.CoreMouseService)),this._instantiationService.setService(m.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(x.UnicodeService)),this._instantiationService.setService(m.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(S.CharsetService),this._instantiationService.setService(m.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(L.OscLinkService),this._instantiationService.setService(m.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new j.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,b.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,b.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,b.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,b.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((he=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((he=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new N.WriteBuffer(((he,ee)=>this._inputHandler.parse(he,ee)))),this.register((0,b.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(te,he){this._writeBuffer.write(te,he)}writeSync(te,he){this._logService.logLevel<=m.LogLevelEnum.WARN&&!R&&(this._logService.warn("writeSync is unreliable and will be removed soon."),R=!0),this._writeBuffer.writeSync(te,he)}input(te,he=!0){this.coreService.triggerDataEvent(te,he)}resize(te,he){isNaN(te)||isNaN(he)||(te=Math.max(te,D.MINIMUM_COLS),he=Math.max(he,D.MINIMUM_ROWS),this._bufferService.resize(te,he))}scroll(te,he=!1){this._bufferService.scroll(te,he)}scrollLines(te,he,ee){this._bufferService.scrollLines(te,he,ee)}scrollPages(te){this.scrollLines(te*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(te){const he=te-this._bufferService.buffer.ydisp;he!==0&&this.scrollLines(he)}registerEscHandler(te,he){return this._inputHandler.registerEscHandler(te,he)}registerDcsHandler(te,he){return this._inputHandler.registerDcsHandler(te,he)}registerCsiHandler(te,he){return this._inputHandler.registerCsiHandler(te,he)}registerOscHandler(te,he){return this._inputHandler.registerOscHandler(te,he)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let te=!1;const he=this.optionsService.rawOptions.windowsPty;he&&he.buildNumber!==void 0&&he.buildNumber!==void 0?te=he.backend==="conpty"&&he.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(te=!0),te?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const te=[];te.push(this.onLineFeed(T.updateWindowsModeWrappedState.bind(null,this._bufferService))),te.push(this.registerCsiHandler({final:"H"},(()=>((0,T.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,f.toDisposable)((()=>{for(const he of te)he.dispose()}))}}}a.CoreTerminal=F},8460:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.runAndSubscribe=a.forwardEvent=a.EventEmitter=void 0,a.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=d=>(this._listeners.push(d),{dispose:()=>{if(!this._disposed){for(let f=0;f<this._listeners.length;f++)if(this._listeners[f]===d)return void this._listeners.splice(f,1)}}})),this._event}fire(d,f){const m=[];for(let g=0;g<this._listeners.length;g++)m.push(this._listeners[g]);for(let g=0;g<m.length;g++)m[g].call(void 0,d,f)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},a.forwardEvent=function(d,f){return d((m=>f.fire(m)))},a.runAndSubscribe=function(d,f){return f(void 0),d((m=>f(m)))}},5435:function(p,a,d){var f=this&&this.__decorate||function(fe,U,X,W){var Q,oe=arguments.length,Ce=oe<3?U:W===null?W=Object.getOwnPropertyDescriptor(U,X):W;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Ce=Reflect.decorate(fe,U,X,W);else for(var Oe=fe.length-1;Oe>=0;Oe--)(Q=fe[Oe])&&(Ce=(oe<3?Q(Ce):oe>3?Q(U,X,Ce):Q(U,X))||Ce);return oe>3&&Ce&&Object.defineProperty(U,X,Ce),Ce},m=this&&this.__param||function(fe,U){return function(X,W){U(X,W,fe)}};Object.defineProperty(a,"__esModule",{value:!0}),a.InputHandler=a.WindowsOptionsReportType=void 0;const g=d(2584),y=d(7116),D=d(2015),E=d(844),C=d(482),b=d(8437),w=d(8460),x=d(643),S=d(511),T=d(3734),j=d(2585),N=d(1480),L=d(6242),R=d(6351),F=d(5941),V={"(":0,")":1,"*":2,"+":3,"-":1,".":2},te=131072;function he(fe,U){if(fe>24)return U.setWinLines||!1;switch(fe){case 1:return!!U.restoreWin;case 2:return!!U.minimizeWin;case 3:return!!U.setWinPosition;case 4:return!!U.setWinSizePixels;case 5:return!!U.raiseWin;case 6:return!!U.lowerWin;case 7:return!!U.refreshWin;case 8:return!!U.setWinSizeChars;case 9:return!!U.maximizeWin;case 10:return!!U.fullscreenWin;case 11:return!!U.getWinState;case 13:return!!U.getWinPosition;case 14:return!!U.getWinSizePixels;case 15:return!!U.getScreenSizePixels;case 16:return!!U.getCellSizePixels;case 18:return!!U.getWinSizeChars;case 19:return!!U.getScreenSizeChars;case 20:return!!U.getIconTitle;case 21:return!!U.getWinTitle;case 22:return!!U.pushTitle;case 23:return!!U.popTitle;case 24:return!!U.setWinLines}return!1}var ee;(function(fe){fe[fe.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",fe[fe.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(ee||(a.WindowsOptionsReportType=ee={}));let we=0;class ce extends E.Disposable{getAttrData(){return this._curAttrData}constructor(U,X,W,Q,oe,Ce,Oe,Xe,ge=new D.EscapeSequenceParser){super(),this._bufferService=U,this._charsetService=X,this._coreService=W,this._logService=Q,this._optionsService=oe,this._oscLinkService=Ce,this._coreMouseService=Oe,this._unicodeService=Xe,this._parser=ge,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new C.StringToUtf32,this._utf8Decoder=new C.Utf8ToUtf32,this._workCell=new S.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=b.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=b.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new w.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new w.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new w.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new w.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new w.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new w.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new w.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new w.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new w.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new w.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new w.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new w.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new w.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new ve(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((J=>this._activeBuffer=J.activeBuffer))),this._parser.setCsiHandlerFallback(((J,je)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(J),params:je.toArray()})})),this._parser.setEscHandlerFallback((J=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(J)})})),this._parser.setExecuteHandlerFallback((J=>{this._logService.debug("Unknown EXECUTE code: ",{code:J})})),this._parser.setOscHandlerFallback(((J,je,de)=>{this._logService.debug("Unknown OSC code: ",{identifier:J,action:je,data:de})})),this._parser.setDcsHandlerFallback(((J,je,de)=>{je==="HOOK"&&(de=de.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(J),action:je,payload:de})})),this._parser.setPrintHandler(((J,je,de)=>this.print(J,je,de))),this._parser.registerCsiHandler({final:"@"},(J=>this.insertChars(J))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(J=>this.scrollLeft(J))),this._parser.registerCsiHandler({final:"A"},(J=>this.cursorUp(J))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(J=>this.scrollRight(J))),this._parser.registerCsiHandler({final:"B"},(J=>this.cursorDown(J))),this._parser.registerCsiHandler({final:"C"},(J=>this.cursorForward(J))),this._parser.registerCsiHandler({final:"D"},(J=>this.cursorBackward(J))),this._parser.registerCsiHandler({final:"E"},(J=>this.cursorNextLine(J))),this._parser.registerCsiHandler({final:"F"},(J=>this.cursorPrecedingLine(J))),this._parser.registerCsiHandler({final:"G"},(J=>this.cursorCharAbsolute(J))),this._parser.registerCsiHandler({final:"H"},(J=>this.cursorPosition(J))),this._parser.registerCsiHandler({final:"I"},(J=>this.cursorForwardTab(J))),this._parser.registerCsiHandler({final:"J"},(J=>this.eraseInDisplay(J,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(J=>this.eraseInDisplay(J,!0))),this._parser.registerCsiHandler({final:"K"},(J=>this.eraseInLine(J,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(J=>this.eraseInLine(J,!0))),this._parser.registerCsiHandler({final:"L"},(J=>this.insertLines(J))),this._parser.registerCsiHandler({final:"M"},(J=>this.deleteLines(J))),this._parser.registerCsiHandler({final:"P"},(J=>this.deleteChars(J))),this._parser.registerCsiHandler({final:"S"},(J=>this.scrollUp(J))),this._parser.registerCsiHandler({final:"T"},(J=>this.scrollDown(J))),this._parser.registerCsiHandler({final:"X"},(J=>this.eraseChars(J))),this._parser.registerCsiHandler({final:"Z"},(J=>this.cursorBackwardTab(J))),this._parser.registerCsiHandler({final:"`"},(J=>this.charPosAbsolute(J))),this._parser.registerCsiHandler({final:"a"},(J=>this.hPositionRelative(J))),this._parser.registerCsiHandler({final:"b"},(J=>this.repeatPrecedingCharacter(J))),this._parser.registerCsiHandler({final:"c"},(J=>this.sendDeviceAttributesPrimary(J))),this._parser.registerCsiHandler({prefix:">",final:"c"},(J=>this.sendDeviceAttributesSecondary(J))),this._parser.registerCsiHandler({final:"d"},(J=>this.linePosAbsolute(J))),this._parser.registerCsiHandler({final:"e"},(J=>this.vPositionRelative(J))),this._parser.registerCsiHandler({final:"f"},(J=>this.hVPosition(J))),this._parser.registerCsiHandler({final:"g"},(J=>this.tabClear(J))),this._parser.registerCsiHandler({final:"h"},(J=>this.setMode(J))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(J=>this.setModePrivate(J))),this._parser.registerCsiHandler({final:"l"},(J=>this.resetMode(J))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(J=>this.resetModePrivate(J))),this._parser.registerCsiHandler({final:"m"},(J=>this.charAttributes(J))),this._parser.registerCsiHandler({final:"n"},(J=>this.deviceStatus(J))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(J=>this.deviceStatusPrivate(J))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(J=>this.softReset(J))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(J=>this.setCursorStyle(J))),this._parser.registerCsiHandler({final:"r"},(J=>this.setScrollRegion(J))),this._parser.registerCsiHandler({final:"s"},(J=>this.saveCursor(J))),this._parser.registerCsiHandler({final:"t"},(J=>this.windowOptions(J))),this._parser.registerCsiHandler({final:"u"},(J=>this.restoreCursor(J))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(J=>this.insertColumns(J))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(J=>this.deleteColumns(J))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(J=>this.selectProtected(J))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(J=>this.requestMode(J,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(J=>this.requestMode(J,!1))),this._parser.setExecuteHandler(g.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(g.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(g.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(g.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(g.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(g.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(g.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(g.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(g.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(g.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(g.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(g.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new L.OscHandler((J=>(this.setTitle(J),this.setIconName(J),!0)))),this._parser.registerOscHandler(1,new L.OscHandler((J=>this.setIconName(J)))),this._parser.registerOscHandler(2,new L.OscHandler((J=>this.setTitle(J)))),this._parser.registerOscHandler(4,new L.OscHandler((J=>this.setOrReportIndexedColor(J)))),this._parser.registerOscHandler(8,new L.OscHandler((J=>this.setHyperlink(J)))),this._parser.registerOscHandler(10,new L.OscHandler((J=>this.setOrReportFgColor(J)))),this._parser.registerOscHandler(11,new L.OscHandler((J=>this.setOrReportBgColor(J)))),this._parser.registerOscHandler(12,new L.OscHandler((J=>this.setOrReportCursorColor(J)))),this._parser.registerOscHandler(104,new L.OscHandler((J=>this.restoreIndexedColor(J)))),this._parser.registerOscHandler(110,new L.OscHandler((J=>this.restoreFgColor(J)))),this._parser.registerOscHandler(111,new L.OscHandler((J=>this.restoreBgColor(J)))),this._parser.registerOscHandler(112,new L.OscHandler((J=>this.restoreCursorColor(J)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const J in y.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:J},(()=>this.selectCharset("("+J))),this._parser.registerEscHandler({intermediates:")",final:J},(()=>this.selectCharset(")"+J))),this._parser.registerEscHandler({intermediates:"*",final:J},(()=>this.selectCharset("*"+J))),this._parser.registerEscHandler({intermediates:"+",final:J},(()=>this.selectCharset("+"+J))),this._parser.registerEscHandler({intermediates:"-",final:J},(()=>this.selectCharset("-"+J))),this._parser.registerEscHandler({intermediates:".",final:J},(()=>this.selectCharset("."+J))),this._parser.registerEscHandler({intermediates:"/",final:J},(()=>this.selectCharset("/"+J)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((J=>(this._logService.error("Parsing error: ",J),J))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new R.DcsHandler(((J,je)=>this.requestStatusString(J,je))))}_preserveStack(U,X,W,Q){this._parseStack.paused=!0,this._parseStack.cursorStartX=U,this._parseStack.cursorStartY=X,this._parseStack.decodedLength=W,this._parseStack.position=Q}_logSlowResolvingAsync(U){this._logService.logLevel<=j.LogLevelEnum.WARN&&Promise.race([U,new Promise(((X,W)=>setTimeout((()=>W("#SLOW_TIMEOUT")),5e3)))]).catch((X=>{if(X!=="#SLOW_TIMEOUT")throw X;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(U,X){let W,Q=this._activeBuffer.x,oe=this._activeBuffer.y,Ce=0;const Oe=this._parseStack.paused;if(Oe){if(W=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,X))return this._logSlowResolvingAsync(W),W;Q=this._parseStack.cursorStartX,oe=this._parseStack.cursorStartY,this._parseStack.paused=!1,U.length>te&&(Ce=this._parseStack.position+te)}if(this._logService.logLevel<=j.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof U=="string"?` "${U}"`:` "${Array.prototype.map.call(U,(J=>String.fromCharCode(J))).join("")}"`),typeof U=="string"?U.split("").map((J=>J.charCodeAt(0))):U),this._parseBuffer.length<U.length&&this._parseBuffer.length<te&&(this._parseBuffer=new Uint32Array(Math.min(U.length,te))),Oe||this._dirtyRowTracker.clearRange(),U.length>te)for(let J=Ce;J<U.length;J+=te){const je=J+te<U.length?J+te:U.length,de=typeof U=="string"?this._stringDecoder.decode(U.substring(J,je),this._parseBuffer):this._utf8Decoder.decode(U.subarray(J,je),this._parseBuffer);if(W=this._parser.parse(this._parseBuffer,de))return this._preserveStack(Q,oe,de,J),this._logSlowResolvingAsync(W),W}else if(!Oe){const J=typeof U=="string"?this._stringDecoder.decode(U,this._parseBuffer):this._utf8Decoder.decode(U,this._parseBuffer);if(W=this._parser.parse(this._parseBuffer,J))return this._preserveStack(Q,oe,J,0),this._logSlowResolvingAsync(W),W}this._activeBuffer.x===Q&&this._activeBuffer.y===oe||this._onCursorMove.fire();const Xe=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),ge=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);ge<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(ge,this._bufferService.rows-1),Math.min(Xe,this._bufferService.rows-1))}print(U,X,W){let Q,oe;const Ce=this._charsetService.charset,Oe=this._optionsService.rawOptions.screenReaderMode,Xe=this._bufferService.cols,ge=this._coreService.decPrivateModes.wraparound,J=this._coreService.modes.insertMode,je=this._curAttrData;let de=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&W-X>0&&de.getWidth(this._activeBuffer.x-1)===2&&de.setCellFromCodepoint(this._activeBuffer.x-1,0,1,je);let Ie=this._parser.precedingJoinState;for(let Pe=X;Pe<W;++Pe){if(Q=U[Pe],Q<127&&Ce){const Nt=Ce[String.fromCharCode(Q)];Nt&&(Q=Nt.charCodeAt(0))}const Ye=this._unicodeService.charProperties(Q,Ie);oe=N.UnicodeService.extractWidth(Ye);const ft=N.UnicodeService.extractShouldJoin(Ye),rt=ft?N.UnicodeService.extractWidth(Ie):0;if(Ie=Ye,Oe&&this._onA11yChar.fire((0,C.stringFromCodePoint)(Q)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+oe-rt>Xe){if(ge){const Nt=de;let mt=this._activeBuffer.x-rt;for(this._activeBuffer.x=rt,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),de=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),rt>0&&de instanceof b.BufferLine&&de.copyCellsFrom(Nt,mt,0,rt,!1);mt<Xe;)Nt.setCellFromCodepoint(mt++,0,1,je)}else if(this._activeBuffer.x=Xe-1,oe===2)continue}if(ft&&this._activeBuffer.x){const Nt=de.getWidth(this._activeBuffer.x-1)?1:2;de.addCodepointToCell(this._activeBuffer.x-Nt,Q,oe);for(let mt=oe-rt;--mt>=0;)de.setCellFromCodepoint(this._activeBuffer.x++,0,0,je)}else if(J&&(de.insertCells(this._activeBuffer.x,oe-rt,this._activeBuffer.getNullCell(je)),de.getWidth(Xe-1)===2&&de.setCellFromCodepoint(Xe-1,x.NULL_CELL_CODE,x.NULL_CELL_WIDTH,je)),de.setCellFromCodepoint(this._activeBuffer.x++,Q,oe,je),oe>0)for(;--oe;)de.setCellFromCodepoint(this._activeBuffer.x++,0,0,je)}this._parser.precedingJoinState=Ie,this._activeBuffer.x<Xe&&W-X>0&&de.getWidth(this._activeBuffer.x)===0&&!de.hasContent(this._activeBuffer.x)&&de.setCellFromCodepoint(this._activeBuffer.x,0,1,je),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(U,X){return U.final!=="t"||U.prefix||U.intermediates?this._parser.registerCsiHandler(U,X):this._parser.registerCsiHandler(U,(W=>!he(W.params[0],this._optionsService.rawOptions.windowOptions)||X(W)))}registerDcsHandler(U,X){return this._parser.registerDcsHandler(U,new R.DcsHandler(X))}registerEscHandler(U,X){return this._parser.registerEscHandler(U,X)}registerOscHandler(U,X){return this._parser.registerOscHandler(U,new L.OscHandler(X))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var U;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&U.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);X.hasWidth(this._activeBuffer.x)&&!X.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const U=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-U),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(U=this._bufferService.cols-1){this._activeBuffer.x=Math.min(U,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(U,X){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=U,this._activeBuffer.y=this._activeBuffer.scrollTop+X):(this._activeBuffer.x=U,this._activeBuffer.y=X),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(U,X){this._restrictCursor(),this._setCursor(this._activeBuffer.x+U,this._activeBuffer.y+X)}cursorUp(U){const X=this._activeBuffer.y-this._activeBuffer.scrollTop;return X>=0?this._moveCursor(0,-Math.min(X,U.params[0]||1)):this._moveCursor(0,-(U.params[0]||1)),!0}cursorDown(U){const X=this._activeBuffer.scrollBottom-this._activeBuffer.y;return X>=0?this._moveCursor(0,Math.min(X,U.params[0]||1)):this._moveCursor(0,U.params[0]||1),!0}cursorForward(U){return this._moveCursor(U.params[0]||1,0),!0}cursorBackward(U){return this._moveCursor(-(U.params[0]||1),0),!0}cursorNextLine(U){return this.cursorDown(U),this._activeBuffer.x=0,!0}cursorPrecedingLine(U){return this.cursorUp(U),this._activeBuffer.x=0,!0}cursorCharAbsolute(U){return this._setCursor((U.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(U){return this._setCursor(U.length>=2?(U.params[1]||1)-1:0,(U.params[0]||1)-1),!0}charPosAbsolute(U){return this._setCursor((U.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(U){return this._moveCursor(U.params[0]||1,0),!0}linePosAbsolute(U){return this._setCursor(this._activeBuffer.x,(U.params[0]||1)-1),!0}vPositionRelative(U){return this._moveCursor(0,U.params[0]||1),!0}hVPosition(U){return this.cursorPosition(U),!0}tabClear(U){const X=U.params[0];return X===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:X===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(U){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let X=U.params[0]||1;for(;X--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(U){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let X=U.params[0]||1;for(;X--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(U){const X=U.params[0];return X===1&&(this._curAttrData.bg|=536870912),X!==2&&X!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(U,X,W,Q=!1,oe=!1){const Ce=this._activeBuffer.lines.get(this._activeBuffer.ybase+U);Ce.replaceCells(X,W,this._activeBuffer.getNullCell(this._eraseAttrData()),oe),Q&&(Ce.isWrapped=!1)}_resetBufferLine(U,X=!1){const W=this._activeBuffer.lines.get(this._activeBuffer.ybase+U);W&&(W.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),X),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+U),W.isWrapped=!1)}eraseInDisplay(U,X=!1){let W;switch(this._restrictCursor(this._bufferService.cols),U.params[0]){case 0:for(W=this._activeBuffer.y,this._dirtyRowTracker.markDirty(W),this._eraseInBufferLine(W++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,X);W<this._bufferService.rows;W++)this._resetBufferLine(W,X);this._dirtyRowTracker.markDirty(W);break;case 1:for(W=this._activeBuffer.y,this._dirtyRowTracker.markDirty(W),this._eraseInBufferLine(W,0,this._activeBuffer.x+1,!0,X),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(W+1).isWrapped=!1);W--;)this._resetBufferLine(W,X);this._dirtyRowTracker.markDirty(0);break;case 2:for(W=this._bufferService.rows,this._dirtyRowTracker.markDirty(W-1);W--;)this._resetBufferLine(W,X);this._dirtyRowTracker.markDirty(0);break;case 3:const Q=this._activeBuffer.lines.length-this._bufferService.rows;Q>0&&(this._activeBuffer.lines.trimStart(Q),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-Q,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-Q,0),this._onScroll.fire(0))}return!0}eraseInLine(U,X=!1){switch(this._restrictCursor(this._bufferService.cols),U.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,X);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,X);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,X)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(U){this._restrictCursor();let X=U.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const W=this._activeBuffer.ybase+this._activeBuffer.y,Q=this._bufferService.rows-1-this._activeBuffer.scrollBottom,oe=this._bufferService.rows-1+this._activeBuffer.ybase-Q+1;for(;X--;)this._activeBuffer.lines.splice(oe-1,1),this._activeBuffer.lines.splice(W,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(U){this._restrictCursor();let X=U.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const W=this._activeBuffer.ybase+this._activeBuffer.y;let Q;for(Q=this._bufferService.rows-1-this._activeBuffer.scrollBottom,Q=this._bufferService.rows-1+this._activeBuffer.ybase-Q;X--;)this._activeBuffer.lines.splice(W,1),this._activeBuffer.lines.splice(Q,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(U){this._restrictCursor();const X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return X&&(X.insertCells(this._activeBuffer.x,U.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(U){this._restrictCursor();const X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return X&&(X.deleteCells(this._activeBuffer.x,U.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(U){let X=U.params[0]||1;for(;X--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(U){let X=U.params[0]||1;for(;X--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(b.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(U){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const X=U.params[0]||1;for(let W=this._activeBuffer.scrollTop;W<=this._activeBuffer.scrollBottom;++W){const Q=this._activeBuffer.lines.get(this._activeBuffer.ybase+W);Q.deleteCells(0,X,this._activeBuffer.getNullCell(this._eraseAttrData())),Q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(U){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const X=U.params[0]||1;for(let W=this._activeBuffer.scrollTop;W<=this._activeBuffer.scrollBottom;++W){const Q=this._activeBuffer.lines.get(this._activeBuffer.ybase+W);Q.insertCells(0,X,this._activeBuffer.getNullCell(this._eraseAttrData())),Q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(U){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const X=U.params[0]||1;for(let W=this._activeBuffer.scrollTop;W<=this._activeBuffer.scrollBottom;++W){const Q=this._activeBuffer.lines.get(this._activeBuffer.ybase+W);Q.insertCells(this._activeBuffer.x,X,this._activeBuffer.getNullCell(this._eraseAttrData())),Q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(U){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const X=U.params[0]||1;for(let W=this._activeBuffer.scrollTop;W<=this._activeBuffer.scrollBottom;++W){const Q=this._activeBuffer.lines.get(this._activeBuffer.ybase+W);Q.deleteCells(this._activeBuffer.x,X,this._activeBuffer.getNullCell(this._eraseAttrData())),Q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(U){this._restrictCursor();const X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return X&&(X.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(U.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(U){const X=this._parser.precedingJoinState;if(!X)return!0;const W=U.params[0]||1,Q=N.UnicodeService.extractWidth(X),oe=this._activeBuffer.x-Q,Ce=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(oe),Oe=new Uint32Array(Ce.length*W);let Xe=0;for(let J=0;J<Ce.length;){const je=Ce.codePointAt(J)||0;Oe[Xe++]=je,J+=je>65535?2:1}let ge=Xe;for(let J=1;J<W;++J)Oe.copyWithin(ge,0,Xe),ge+=Xe;return this.print(Oe,0,ge),!0}sendDeviceAttributesPrimary(U){return U.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(g.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(g.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(U){return U.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(g.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(g.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(U.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(g.C0.ESC+"[>83;40003;0c")),!0}_is(U){return(this._optionsService.rawOptions.termName+"").indexOf(U)===0}setMode(U){for(let X=0;X<U.length;X++)switch(U.params[X]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(U){for(let X=0;X<U.length;X++)switch(U.params[X]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,y.DEFAULT_CHARSET),this._charsetService.setgCharset(1,y.DEFAULT_CHARSET),this._charsetService.setgCharset(2,y.DEFAULT_CHARSET),this._charsetService.setgCharset(3,y.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(U){for(let X=0;X<U.length;X++)switch(U.params[X]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(U){for(let X=0;X<U.length;X++)switch(U.params[X]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),U.params[X]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(U,X){const W=this._coreService.decPrivateModes,{activeProtocol:Q,activeEncoding:oe}=this._coreMouseService,Ce=this._coreService,{buffers:Oe,cols:Xe}=this._bufferService,{active:ge,alt:J}=Oe,je=this._optionsService.rawOptions,de=ft=>ft?1:2,Ie=U.params[0];return Pe=Ie,Ye=X?Ie===2?4:Ie===4?de(Ce.modes.insertMode):Ie===12?3:Ie===20?de(je.convertEol):0:Ie===1?de(W.applicationCursorKeys):Ie===3?je.windowOptions.setWinLines?Xe===80?2:Xe===132?1:0:0:Ie===6?de(W.origin):Ie===7?de(W.wraparound):Ie===8?3:Ie===9?de(Q==="X10"):Ie===12?de(je.cursorBlink):Ie===25?de(!Ce.isCursorHidden):Ie===45?de(W.reverseWraparound):Ie===66?de(W.applicationKeypad):Ie===67?4:Ie===1e3?de(Q==="VT200"):Ie===1002?de(Q==="DRAG"):Ie===1003?de(Q==="ANY"):Ie===1004?de(W.sendFocus):Ie===1005?4:Ie===1006?de(oe==="SGR"):Ie===1015?4:Ie===1016?de(oe==="SGR_PIXELS"):Ie===1048?1:Ie===47||Ie===1047||Ie===1049?de(ge===J):Ie===2004?de(W.bracketedPasteMode):0,Ce.triggerDataEvent(`${g.C0.ESC}[${X?"":"?"}${Pe};${Ye}$y`),!0;var Pe,Ye}_updateAttrColor(U,X,W,Q,oe){return X===2?(U|=50331648,U&=-16777216,U|=T.AttributeData.fromColorRGB([W,Q,oe])):X===5&&(U&=-50331904,U|=33554432|255&W),U}_extractColor(U,X,W){const Q=[0,0,-1,0,0,0];let oe=0,Ce=0;do{if(Q[Ce+oe]=U.params[X+Ce],U.hasSubParams(X+Ce)){const Oe=U.getSubParams(X+Ce);let Xe=0;do Q[1]===5&&(oe=1),Q[Ce+Xe+1+oe]=Oe[Xe];while(++Xe<Oe.length&&Xe+Ce+1+oe<Q.length);break}if(Q[1]===5&&Ce+oe>=2||Q[1]===2&&Ce+oe>=5)break;Q[1]&&(oe=1)}while(++Ce+X<U.length&&Ce+oe<Q.length);for(let Oe=2;Oe<Q.length;++Oe)Q[Oe]===-1&&(Q[Oe]=0);switch(Q[0]){case 38:W.fg=this._updateAttrColor(W.fg,Q[1],Q[3],Q[4],Q[5]);break;case 48:W.bg=this._updateAttrColor(W.bg,Q[1],Q[3],Q[4],Q[5]);break;case 58:W.extended=W.extended.clone(),W.extended.underlineColor=this._updateAttrColor(W.extended.underlineColor,Q[1],Q[3],Q[4],Q[5])}return Ce}_processUnderline(U,X){X.extended=X.extended.clone(),(!~U||U>5)&&(U=1),X.extended.underlineStyle=U,X.fg|=268435456,U===0&&(X.fg&=-268435457),X.updateExtended()}_processSGR0(U){U.fg=b.DEFAULT_ATTR_DATA.fg,U.bg=b.DEFAULT_ATTR_DATA.bg,U.extended=U.extended.clone(),U.extended.underlineStyle=0,U.extended.underlineColor&=-67108864,U.updateExtended()}charAttributes(U){if(U.length===1&&U.params[0]===0)return this._processSGR0(this._curAttrData),!0;const X=U.length;let W;const Q=this._curAttrData;for(let oe=0;oe<X;oe++)W=U.params[oe],W>=30&&W<=37?(Q.fg&=-50331904,Q.fg|=16777216|W-30):W>=40&&W<=47?(Q.bg&=-50331904,Q.bg|=16777216|W-40):W>=90&&W<=97?(Q.fg&=-50331904,Q.fg|=16777224|W-90):W>=100&&W<=107?(Q.bg&=-50331904,Q.bg|=16777224|W-100):W===0?this._processSGR0(Q):W===1?Q.fg|=134217728:W===3?Q.bg|=67108864:W===4?(Q.fg|=268435456,this._processUnderline(U.hasSubParams(oe)?U.getSubParams(oe)[0]:1,Q)):W===5?Q.fg|=536870912:W===7?Q.fg|=67108864:W===8?Q.fg|=1073741824:W===9?Q.fg|=2147483648:W===2?Q.bg|=134217728:W===21?this._processUnderline(2,Q):W===22?(Q.fg&=-134217729,Q.bg&=-134217729):W===23?Q.bg&=-67108865:W===24?(Q.fg&=-268435457,this._processUnderline(0,Q)):W===25?Q.fg&=-536870913:W===27?Q.fg&=-67108865:W===28?Q.fg&=-1073741825:W===29?Q.fg&=2147483647:W===39?(Q.fg&=-67108864,Q.fg|=16777215&b.DEFAULT_ATTR_DATA.fg):W===49?(Q.bg&=-67108864,Q.bg|=16777215&b.DEFAULT_ATTR_DATA.bg):W===38||W===48||W===58?oe+=this._extractColor(U,oe,Q):W===53?Q.bg|=1073741824:W===55?Q.bg&=-1073741825:W===59?(Q.extended=Q.extended.clone(),Q.extended.underlineColor=-1,Q.updateExtended()):W===100?(Q.fg&=-67108864,Q.fg|=16777215&b.DEFAULT_ATTR_DATA.fg,Q.bg&=-67108864,Q.bg|=16777215&b.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",W);return!0}deviceStatus(U){switch(U.params[0]){case 5:this._coreService.triggerDataEvent(`${g.C0.ESC}[0n`);break;case 6:const X=this._activeBuffer.y+1,W=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${g.C0.ESC}[${X};${W}R`)}return!0}deviceStatusPrivate(U){if(U.params[0]===6){const X=this._activeBuffer.y+1,W=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${g.C0.ESC}[?${X};${W}R`)}return!0}softReset(U){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=b.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(U){const X=U.params[0]||1;switch(X){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const W=X%2==1;return this._optionsService.options.cursorBlink=W,!0}setScrollRegion(U){const X=U.params[0]||1;let W;return(U.length<2||(W=U.params[1])>this._bufferService.rows||W===0)&&(W=this._bufferService.rows),W>X&&(this._activeBuffer.scrollTop=X-1,this._activeBuffer.scrollBottom=W-1,this._setCursor(0,0)),!0}windowOptions(U){if(!he(U.params[0],this._optionsService.rawOptions.windowOptions))return!0;const X=U.length>1?U.params[1]:0;switch(U.params[0]){case 14:X!==2&&this._onRequestWindowsOptionsReport.fire(ee.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(ee.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${g.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:X!==0&&X!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),X!==0&&X!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:X!==0&&X!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),X!==0&&X!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(U){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(U){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(U){return this._windowTitle=U,this._onTitleChange.fire(U),!0}setIconName(U){return this._iconName=U,!0}setOrReportIndexedColor(U){const X=[],W=U.split(";");for(;W.length>1;){const Q=W.shift(),oe=W.shift();if(/^\d+$/.exec(Q)){const Ce=parseInt(Q);if(Ee(Ce))if(oe==="?")X.push({type:0,index:Ce});else{const Oe=(0,F.parseColor)(oe);Oe&&X.push({type:1,index:Ce,color:Oe})}}}return X.length&&this._onColor.fire(X),!0}setHyperlink(U){const X=U.split(";");return!(X.length<2)&&(X[1]?this._createHyperlink(X[0],X[1]):!X[0]&&this._finishHyperlink())}_createHyperlink(U,X){this._getCurrentLinkId()&&this._finishHyperlink();const W=U.split(":");let Q;const oe=W.findIndex((Ce=>Ce.startsWith("id=")));return oe!==-1&&(Q=W[oe].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:Q,uri:X}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(U,X){const W=U.split(";");for(let Q=0;Q<W.length&&!(X>=this._specialColors.length);++Q,++X)if(W[Q]==="?")this._onColor.fire([{type:0,index:this._specialColors[X]}]);else{const oe=(0,F.parseColor)(W[Q]);oe&&this._onColor.fire([{type:1,index:this._specialColors[X],color:oe}])}return!0}setOrReportFgColor(U){return this._setOrReportSpecialColor(U,0)}setOrReportBgColor(U){return this._setOrReportSpecialColor(U,1)}setOrReportCursorColor(U){return this._setOrReportSpecialColor(U,2)}restoreIndexedColor(U){if(!U)return this._onColor.fire([{type:2}]),!0;const X=[],W=U.split(";");for(let Q=0;Q<W.length;++Q)if(/^\d+$/.exec(W[Q])){const oe=parseInt(W[Q]);Ee(oe)&&X.push({type:2,index:oe})}return X.length&&this._onColor.fire(X),!0}restoreFgColor(U){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(U){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(U){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,y.DEFAULT_CHARSET),!0}selectCharset(U){return U.length!==2?(this.selectDefaultCharset(),!0):(U[0]==="/"||this._charsetService.setgCharset(V[U[0]],y.CHARSETS[U[1]]||y.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const U=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,U,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=b.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=b.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(U){return this._charsetService.setgLevel(U),!0}screenAlignmentPattern(){const U=new S.CellData;U.content=4194373,U.fg=this._curAttrData.fg,U.bg=this._curAttrData.bg,this._setCursor(0,0);for(let X=0;X<this._bufferService.rows;++X){const W=this._activeBuffer.ybase+this._activeBuffer.y+X,Q=this._activeBuffer.lines.get(W);Q&&(Q.fill(U),Q.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(U,X){const W=this._bufferService.buffer,Q=this._optionsService.rawOptions;return(oe=>(this._coreService.triggerDataEvent(`${g.C0.ESC}${oe}${g.C0.ESC}\\`),!0))(U==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:U==='"p'?'P1$r61;1"p':U==="r"?`P1$r${W.scrollTop+1};${W.scrollBottom+1}r`:U==="m"?"P1$r0m":U===" q"?`P1$r${{block:2,underline:4,bar:6}[Q.cursorStyle]-(Q.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(U,X){this._dirtyRowTracker.markRangeDirty(U,X)}}a.InputHandler=ce;let ve=class{constructor(fe){this._bufferService=fe,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(fe){fe<this.start?this.start=fe:fe>this.end&&(this.end=fe)}markRangeDirty(fe,U){fe>U&&(we=fe,fe=U,U=we),fe<this.start&&(this.start=fe),U>this.end&&(this.end=U)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function Ee(fe){return 0<=fe&&fe<256}ve=f([m(0,j.IBufferService)],ve)},844:(p,a)=>{function d(f){for(const m of f)m.dispose();f.length=0}Object.defineProperty(a,"__esModule",{value:!0}),a.getDisposeArrayDisposable=a.disposeArray=a.toDisposable=a.MutableDisposable=a.Disposable=void 0,a.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const f of this._disposables)f.dispose();this._disposables.length=0}register(f){return this._disposables.push(f),f}unregister(f){const m=this._disposables.indexOf(f);m!==-1&&this._disposables.splice(m,1)}},a.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(f){var m;this._isDisposed||f===this._value||((m=this._value)==null||m.dispose(),this._value=f)}clear(){this.value=void 0}dispose(){var f;this._isDisposed=!0,(f=this._value)==null||f.dispose(),this._value=void 0}},a.toDisposable=function(f){return{dispose:f}},a.disposeArray=d,a.getDisposeArrayDisposable=function(f){return{dispose:()=>d(f)}}},1505:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.FourKeyMap=a.TwoKeyMap=void 0;class d{constructor(){this._data={}}set(m,g,y){this._data[m]||(this._data[m]={}),this._data[m][g]=y}get(m,g){return this._data[m]?this._data[m][g]:void 0}clear(){this._data={}}}a.TwoKeyMap=d,a.FourKeyMap=class{constructor(){this._data=new d}set(f,m,g,y,D){this._data.get(f,m)||this._data.set(f,m,new d),this._data.get(f,m).set(g,y,D)}get(f,m,g,y){var D;return(D=this._data.get(f,m))==null?void 0:D.get(g,y)}clear(){this._data.clear()}}},6114:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.isChromeOS=a.isLinux=a.isWindows=a.isIphone=a.isIpad=a.isMac=a.getSafariVersion=a.isSafari=a.isLegacyEdge=a.isFirefox=a.isNode=void 0,a.isNode=typeof process<"u"&&"title"in process;const d=a.isNode?"node":navigator.userAgent,f=a.isNode?"node":navigator.platform;a.isFirefox=d.includes("Firefox"),a.isLegacyEdge=d.includes("Edge"),a.isSafari=/^((?!chrome|android).)*safari/i.test(d),a.getSafariVersion=function(){if(!a.isSafari)return 0;const m=d.match(/Version\/(\d+)/);return m===null||m.length<2?0:parseInt(m[1])},a.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(f),a.isIpad=f==="iPad",a.isIphone=f==="iPhone",a.isWindows=["Windows","Win16","Win32","WinCE"].includes(f),a.isLinux=f.indexOf("Linux")>=0,a.isChromeOS=/\bCrOS\b/.test(d)},6106:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.SortedList=void 0;let d=0;a.SortedList=class{constructor(f){this._getKey=f,this._array=[]}clear(){this._array.length=0}insert(f){this._array.length!==0?(d=this._search(this._getKey(f)),this._array.splice(d,0,f)):this._array.push(f)}delete(f){if(this._array.length===0)return!1;const m=this._getKey(f);if(m===void 0||(d=this._search(m),d===-1)||this._getKey(this._array[d])!==m)return!1;do if(this._array[d]===f)return this._array.splice(d,1),!0;while(++d<this._array.length&&this._getKey(this._array[d])===m);return!1}*getKeyIterator(f){if(this._array.length!==0&&(d=this._search(f),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===f))do yield this._array[d];while(++d<this._array.length&&this._getKey(this._array[d])===f)}forEachByKey(f,m){if(this._array.length!==0&&(d=this._search(f),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===f))do m(this._array[d]);while(++d<this._array.length&&this._getKey(this._array[d])===f)}values(){return[...this._array].values()}_search(f){let m=0,g=this._array.length-1;for(;g>=m;){let y=m+g>>1;const D=this._getKey(this._array[y]);if(D>f)g=y-1;else{if(!(D<f)){for(;y>0&&this._getKey(this._array[y-1])===f;)y--;return y}m=y+1}}return m}}},7226:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.DebouncedIdleTask=a.IdleTaskQueue=a.PriorityTaskQueue=void 0;const f=d(6114);class m{constructor(){this._tasks=[],this._i=0}enqueue(D){this._tasks.push(D),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(D){this._idleCallback=void 0;let E=0,C=0,b=D.timeRemaining(),w=0;for(;this._i<this._tasks.length;){if(E=Date.now(),this._tasks[this._i]()||this._i++,E=Math.max(1,Date.now()-E),C=Math.max(E,C),w=D.timeRemaining(),1.5*C>w)return b-E<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(b-E))}ms`),void this._start();b=w}this.clear()}}class g extends m{_requestCallback(D){return setTimeout((()=>D(this._createDeadline(16))))}_cancelCallback(D){clearTimeout(D)}_createDeadline(D){const E=Date.now()+D;return{timeRemaining:()=>Math.max(0,E-Date.now())}}}a.PriorityTaskQueue=g,a.IdleTaskQueue=!f.isNode&&"requestIdleCallback"in window?class extends m{_requestCallback(y){return requestIdleCallback(y)}_cancelCallback(y){cancelIdleCallback(y)}}:g,a.DebouncedIdleTask=class{constructor(){this._queue=new a.IdleTaskQueue}set(y){this._queue.clear(),this._queue.enqueue(y)}flush(){this._queue.flush()}}},9282:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.updateWindowsModeWrappedState=void 0;const f=d(643);a.updateWindowsModeWrappedState=function(m){const g=m.buffer.lines.get(m.buffer.ybase+m.buffer.y-1),y=g==null?void 0:g.get(m.cols-1),D=m.buffer.lines.get(m.buffer.ybase+m.buffer.y);D&&y&&(D.isWrapped=y[f.CHAR_DATA_CODE_INDEX]!==f.NULL_CELL_CODE&&y[f.CHAR_DATA_CODE_INDEX]!==f.WHITESPACE_CELL_CODE)}},3734:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.ExtendedAttrs=a.AttributeData=void 0;class d{constructor(){this.fg=0,this.bg=0,this.extended=new f}static toColorRGB(g){return[g>>>16&255,g>>>8&255,255&g]}static fromColorRGB(g){return(255&g[0])<<16|(255&g[1])<<8|255&g[2]}clone(){const g=new d;return g.fg=this.fg,g.bg=this.bg,g.extended=this.extended.clone(),g}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}a.AttributeData=d;class f{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(g){this._ext=g}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(g){this._ext&=-469762049,this._ext|=g<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(g){this._ext&=-67108864,this._ext|=67108863&g}get urlId(){return this._urlId}set urlId(g){this._urlId=g}get underlineVariantOffset(){const g=(3758096384&this._ext)>>29;return g<0?4294967288^g:g}set underlineVariantOffset(g){this._ext&=536870911,this._ext|=g<<29&3758096384}constructor(g=0,y=0){this._ext=0,this._urlId=0,this._ext=g,this._urlId=y}clone(){return new f(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}a.ExtendedAttrs=f},9092:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.Buffer=a.MAX_BUFFER_SIZE=void 0;const f=d(6349),m=d(7226),g=d(3734),y=d(8437),D=d(4634),E=d(511),C=d(643),b=d(4863),w=d(7116);a.MAX_BUFFER_SIZE=4294967295,a.Buffer=class{constructor(x,S,T){this._hasScrollback=x,this._optionsService=S,this._bufferService=T,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=y.DEFAULT_ATTR_DATA.clone(),this.savedCharset=w.DEFAULT_CHARSET,this.markers=[],this._nullCell=E.CellData.fromCharData([0,C.NULL_CELL_CHAR,C.NULL_CELL_WIDTH,C.NULL_CELL_CODE]),this._whitespaceCell=E.CellData.fromCharData([0,C.WHITESPACE_CELL_CHAR,C.WHITESPACE_CELL_WIDTH,C.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new m.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new f.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(x){return x?(this._nullCell.fg=x.fg,this._nullCell.bg=x.bg,this._nullCell.extended=x.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new g.ExtendedAttrs),this._nullCell}getWhitespaceCell(x){return x?(this._whitespaceCell.fg=x.fg,this._whitespaceCell.bg=x.bg,this._whitespaceCell.extended=x.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new g.ExtendedAttrs),this._whitespaceCell}getBlankLine(x,S){return new y.BufferLine(this._bufferService.cols,this.getNullCell(x),S)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const x=this.ybase+this.y-this.ydisp;return x>=0&&x<this._rows}_getCorrectBufferLength(x){if(!this._hasScrollback)return x;const S=x+this._optionsService.rawOptions.scrollback;return S>a.MAX_BUFFER_SIZE?a.MAX_BUFFER_SIZE:S}fillViewportRows(x){if(this.lines.length===0){x===void 0&&(x=y.DEFAULT_ATTR_DATA);let S=this._rows;for(;S--;)this.lines.push(this.getBlankLine(x))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new f.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(x,S){const T=this.getNullCell(y.DEFAULT_ATTR_DATA);let j=0;const N=this._getCorrectBufferLength(S);if(N>this.lines.maxLength&&(this.lines.maxLength=N),this.lines.length>0){if(this._cols<x)for(let R=0;R<this.lines.length;R++)j+=+this.lines.get(R).resize(x,T);let L=0;if(this._rows<S)for(let R=this._rows;R<S;R++)this.lines.length<S+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new y.BufferLine(x,T)):this.ybase>0&&this.lines.length<=this.ybase+this.y+L+1?(this.ybase--,L++,this.ydisp>0&&this.ydisp--):this.lines.push(new y.BufferLine(x,T)));else for(let R=this._rows;R>S;R--)this.lines.length>S+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(N<this.lines.maxLength){const R=this.lines.length-N;R>0&&(this.lines.trimStart(R),this.ybase=Math.max(this.ybase-R,0),this.ydisp=Math.max(this.ydisp-R,0),this.savedY=Math.max(this.savedY-R,0)),this.lines.maxLength=N}this.x=Math.min(this.x,x-1),this.y=Math.min(this.y,S-1),L&&(this.y+=L),this.savedX=Math.min(this.savedX,x-1),this.scrollTop=0}if(this.scrollBottom=S-1,this._isReflowEnabled&&(this._reflow(x,S),this._cols>x))for(let L=0;L<this.lines.length;L++)j+=+this.lines.get(L).resize(x,T);this._cols=x,this._rows=S,this._memoryCleanupQueue.clear(),j>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let x=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,x=!1);let S=0;for(;this._memoryCleanupPosition<this.lines.length;)if(S+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),S>100)return!0;return x}get _isReflowEnabled(){const x=this._optionsService.rawOptions.windowsPty;return x&&x.buildNumber?this._hasScrollback&&x.backend==="conpty"&&x.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(x,S){this._cols!==x&&(x>this._cols?this._reflowLarger(x,S):this._reflowSmaller(x,S))}_reflowLarger(x,S){const T=(0,D.reflowLargerGetLinesToRemove)(this.lines,this._cols,x,this.ybase+this.y,this.getNullCell(y.DEFAULT_ATTR_DATA));if(T.length>0){const j=(0,D.reflowLargerCreateNewLayout)(this.lines,T);(0,D.reflowLargerApplyNewLayout)(this.lines,j.layout),this._reflowLargerAdjustViewport(x,S,j.countRemoved)}}_reflowLargerAdjustViewport(x,S,T){const j=this.getNullCell(y.DEFAULT_ATTR_DATA);let N=T;for(;N-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<S&&this.lines.push(new y.BufferLine(x,j))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-T,0)}_reflowSmaller(x,S){const T=this.getNullCell(y.DEFAULT_ATTR_DATA),j=[];let N=0;for(let L=this.lines.length-1;L>=0;L--){let R=this.lines.get(L);if(!R||!R.isWrapped&&R.getTrimmedLength()<=x)continue;const F=[R];for(;R.isWrapped&&L>0;)R=this.lines.get(--L),F.unshift(R);const V=this.ybase+this.y;if(V>=L&&V<L+F.length)continue;const te=F[F.length-1].getTrimmedLength(),he=(0,D.reflowSmallerGetNewLineLengths)(F,this._cols,x),ee=he.length-F.length;let we;we=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+ee):Math.max(0,this.lines.length-this.lines.maxLength+ee);const ce=[];for(let W=0;W<ee;W++){const Q=this.getBlankLine(y.DEFAULT_ATTR_DATA,!0);ce.push(Q)}ce.length>0&&(j.push({start:L+F.length+N,newLines:ce}),N+=ce.length),F.push(...ce);let ve=he.length-1,Ee=he[ve];Ee===0&&(ve--,Ee=he[ve]);let fe=F.length-ee-1,U=te;for(;fe>=0;){const W=Math.min(U,Ee);if(F[ve]===void 0)break;if(F[ve].copyCellsFrom(F[fe],U-W,Ee-W,W,!0),Ee-=W,Ee===0&&(ve--,Ee=he[ve]),U-=W,U===0){fe--;const Q=Math.max(fe,0);U=(0,D.getWrappedLineTrimmedLength)(F,Q,this._cols)}}for(let W=0;W<F.length;W++)he[W]<x&&F[W].setCell(he[W],T);let X=ee-we;for(;X-- >0;)this.ybase===0?this.y<S-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+N)-S&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+ee,this.ybase+S-1)}if(j.length>0){const L=[],R=[];for(let ve=0;ve<this.lines.length;ve++)R.push(this.lines.get(ve));const F=this.lines.length;let V=F-1,te=0,he=j[te];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+N);let ee=0;for(let ve=Math.min(this.lines.maxLength-1,F+N-1);ve>=0;ve--)if(he&&he.start>V+ee){for(let Ee=he.newLines.length-1;Ee>=0;Ee--)this.lines.set(ve--,he.newLines[Ee]);ve++,L.push({index:V+1,amount:he.newLines.length}),ee+=he.newLines.length,he=j[++te]}else this.lines.set(ve,R[V--]);let we=0;for(let ve=L.length-1;ve>=0;ve--)L[ve].index+=we,this.lines.onInsertEmitter.fire(L[ve]),we+=L[ve].amount;const ce=Math.max(0,F+N-this.lines.maxLength);ce>0&&this.lines.onTrimEmitter.fire(ce)}}translateBufferLineToString(x,S,T=0,j){const N=this.lines.get(x);return N?N.translateToString(S,T,j):""}getWrappedRangeForLine(x){let S=x,T=x;for(;S>0&&this.lines.get(S).isWrapped;)S--;for(;T+1<this.lines.length&&this.lines.get(T+1).isWrapped;)T++;return{first:S,last:T}}setupTabStops(x){for(x!=null?this.tabs[x]||(x=this.prevStop(x)):(this.tabs={},x=0);x<this._cols;x+=this._optionsService.rawOptions.tabStopWidth)this.tabs[x]=!0}prevStop(x){for(x==null&&(x=this.x);!this.tabs[--x]&&x>0;);return x>=this._cols?this._cols-1:x<0?0:x}nextStop(x){for(x==null&&(x=this.x);!this.tabs[++x]&&x<this._cols;);return x>=this._cols?this._cols-1:x<0?0:x}clearMarkers(x){this._isClearing=!0;for(let S=0;S<this.markers.length;S++)this.markers[S].line===x&&(this.markers[S].dispose(),this.markers.splice(S--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let x=0;x<this.markers.length;x++)this.markers[x].dispose(),this.markers.splice(x--,1);this._isClearing=!1}addMarker(x){const S=new b.Marker(x);return this.markers.push(S),S.register(this.lines.onTrim((T=>{S.line-=T,S.line<0&&S.dispose()}))),S.register(this.lines.onInsert((T=>{S.line>=T.index&&(S.line+=T.amount)}))),S.register(this.lines.onDelete((T=>{S.line>=T.index&&S.line<T.index+T.amount&&S.dispose(),S.line>T.index&&(S.line-=T.amount)}))),S.register(S.onDispose((()=>this._removeMarker(S)))),S}_removeMarker(x){this._isClearing||this.markers.splice(this.markers.indexOf(x),1)}}},8437:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.BufferLine=a.DEFAULT_ATTR_DATA=void 0;const f=d(3734),m=d(511),g=d(643),y=d(482);a.DEFAULT_ATTR_DATA=Object.freeze(new f.AttributeData);let D=0;class E{constructor(b,w,x=!1){this.isWrapped=x,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*b);const S=w||m.CellData.fromCharData([0,g.NULL_CELL_CHAR,g.NULL_CELL_WIDTH,g.NULL_CELL_CODE]);for(let T=0;T<b;++T)this.setCell(T,S);this.length=b}get(b){const w=this._data[3*b+0],x=2097151&w;return[this._data[3*b+1],2097152&w?this._combined[b]:x?(0,y.stringFromCodePoint)(x):"",w>>22,2097152&w?this._combined[b].charCodeAt(this._combined[b].length-1):x]}set(b,w){this._data[3*b+1]=w[g.CHAR_DATA_ATTR_INDEX],w[g.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[b]=w[1],this._data[3*b+0]=2097152|b|w[g.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*b+0]=w[g.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[g.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(b){return this._data[3*b+0]>>22}hasWidth(b){return 12582912&this._data[3*b+0]}getFg(b){return this._data[3*b+1]}getBg(b){return this._data[3*b+2]}hasContent(b){return 4194303&this._data[3*b+0]}getCodePoint(b){const w=this._data[3*b+0];return 2097152&w?this._combined[b].charCodeAt(this._combined[b].length-1):2097151&w}isCombined(b){return 2097152&this._data[3*b+0]}getString(b){const w=this._data[3*b+0];return 2097152&w?this._combined[b]:2097151&w?(0,y.stringFromCodePoint)(2097151&w):""}isProtected(b){return 536870912&this._data[3*b+2]}loadCell(b,w){return D=3*b,w.content=this._data[D+0],w.fg=this._data[D+1],w.bg=this._data[D+2],2097152&w.content&&(w.combinedData=this._combined[b]),268435456&w.bg&&(w.extended=this._extendedAttrs[b]),w}setCell(b,w){2097152&w.content&&(this._combined[b]=w.combinedData),268435456&w.bg&&(this._extendedAttrs[b]=w.extended),this._data[3*b+0]=w.content,this._data[3*b+1]=w.fg,this._data[3*b+2]=w.bg}setCellFromCodepoint(b,w,x,S){268435456&S.bg&&(this._extendedAttrs[b]=S.extended),this._data[3*b+0]=w|x<<22,this._data[3*b+1]=S.fg,this._data[3*b+2]=S.bg}addCodepointToCell(b,w,x){let S=this._data[3*b+0];2097152&S?this._combined[b]+=(0,y.stringFromCodePoint)(w):2097151&S?(this._combined[b]=(0,y.stringFromCodePoint)(2097151&S)+(0,y.stringFromCodePoint)(w),S&=-2097152,S|=2097152):S=w|4194304,x&&(S&=-12582913,S|=x<<22),this._data[3*b+0]=S}insertCells(b,w,x){if((b%=this.length)&&this.getWidth(b-1)===2&&this.setCellFromCodepoint(b-1,0,1,x),w<this.length-b){const S=new m.CellData;for(let T=this.length-b-w-1;T>=0;--T)this.setCell(b+w+T,this.loadCell(b+T,S));for(let T=0;T<w;++T)this.setCell(b+T,x)}else for(let S=b;S<this.length;++S)this.setCell(S,x);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,x)}deleteCells(b,w,x){if(b%=this.length,w<this.length-b){const S=new m.CellData;for(let T=0;T<this.length-b-w;++T)this.setCell(b+T,this.loadCell(b+w+T,S));for(let T=this.length-w;T<this.length;++T)this.setCell(T,x)}else for(let S=b;S<this.length;++S)this.setCell(S,x);b&&this.getWidth(b-1)===2&&this.setCellFromCodepoint(b-1,0,1,x),this.getWidth(b)!==0||this.hasContent(b)||this.setCellFromCodepoint(b,0,1,x)}replaceCells(b,w,x,S=!1){if(S)for(b&&this.getWidth(b-1)===2&&!this.isProtected(b-1)&&this.setCellFromCodepoint(b-1,0,1,x),w<this.length&&this.getWidth(w-1)===2&&!this.isProtected(w)&&this.setCellFromCodepoint(w,0,1,x);b<w&&b<this.length;)this.isProtected(b)||this.setCell(b,x),b++;else for(b&&this.getWidth(b-1)===2&&this.setCellFromCodepoint(b-1,0,1,x),w<this.length&&this.getWidth(w-1)===2&&this.setCellFromCodepoint(w,0,1,x);b<w&&b<this.length;)this.setCell(b++,x)}resize(b,w){if(b===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const x=3*b;if(b>this.length){if(this._data.buffer.byteLength>=4*x)this._data=new Uint32Array(this._data.buffer,0,x);else{const S=new Uint32Array(x);S.set(this._data),this._data=S}for(let S=this.length;S<b;++S)this.setCell(S,w)}else{this._data=this._data.subarray(0,x);const S=Object.keys(this._combined);for(let j=0;j<S.length;j++){const N=parseInt(S[j],10);N>=b&&delete this._combined[N]}const T=Object.keys(this._extendedAttrs);for(let j=0;j<T.length;j++){const N=parseInt(T[j],10);N>=b&&delete this._extendedAttrs[N]}}return this.length=b,4*x*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const b=new Uint32Array(this._data.length);return b.set(this._data),this._data=b,1}return 0}fill(b,w=!1){if(w)for(let x=0;x<this.length;++x)this.isProtected(x)||this.setCell(x,b);else{this._combined={},this._extendedAttrs={};for(let x=0;x<this.length;++x)this.setCell(x,b)}}copyFrom(b){this.length!==b.length?this._data=new Uint32Array(b._data):this._data.set(b._data),this.length=b.length,this._combined={};for(const w in b._combined)this._combined[w]=b._combined[w];this._extendedAttrs={};for(const w in b._extendedAttrs)this._extendedAttrs[w]=b._extendedAttrs[w];this.isWrapped=b.isWrapped}clone(){const b=new E(0);b._data=new Uint32Array(this._data),b.length=this.length;for(const w in this._combined)b._combined[w]=this._combined[w];for(const w in this._extendedAttrs)b._extendedAttrs[w]=this._extendedAttrs[w];return b.isWrapped=this.isWrapped,b}getTrimmedLength(){for(let b=this.length-1;b>=0;--b)if(4194303&this._data[3*b+0])return b+(this._data[3*b+0]>>22);return 0}getNoBgTrimmedLength(){for(let b=this.length-1;b>=0;--b)if(4194303&this._data[3*b+0]||50331648&this._data[3*b+2])return b+(this._data[3*b+0]>>22);return 0}copyCellsFrom(b,w,x,S,T){const j=b._data;if(T)for(let L=S-1;L>=0;L--){for(let R=0;R<3;R++)this._data[3*(x+L)+R]=j[3*(w+L)+R];268435456&j[3*(w+L)+2]&&(this._extendedAttrs[x+L]=b._extendedAttrs[w+L])}else for(let L=0;L<S;L++){for(let R=0;R<3;R++)this._data[3*(x+L)+R]=j[3*(w+L)+R];268435456&j[3*(w+L)+2]&&(this._extendedAttrs[x+L]=b._extendedAttrs[w+L])}const N=Object.keys(b._combined);for(let L=0;L<N.length;L++){const R=parseInt(N[L],10);R>=w&&(this._combined[R-w+x]=b._combined[R])}}translateToString(b,w,x,S){w=w??0,x=x??this.length,b&&(x=Math.min(x,this.getTrimmedLength())),S&&(S.length=0);let T="";for(;w<x;){const j=this._data[3*w+0],N=2097151&j,L=2097152&j?this._combined[w]:N?(0,y.stringFromCodePoint)(N):g.WHITESPACE_CELL_CHAR;if(T+=L,S)for(let R=0;R<L.length;++R)S.push(w);w+=j>>22||1}return S&&S.push(w),T}}a.BufferLine=E},4841:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.getRangeLength=void 0,a.getRangeLength=function(d,f){if(d.start.y>d.end.y)throw new Error(`Buffer range end (${d.end.x}, ${d.end.y}) cannot be before start (${d.start.x}, ${d.start.y})`);return f*(d.end.y-d.start.y)+(d.end.x-d.start.x+1)}},4634:(p,a)=>{function d(f,m,g){if(m===f.length-1)return f[m].getTrimmedLength();const y=!f[m].hasContent(g-1)&&f[m].getWidth(g-1)===1,D=f[m+1].getWidth(0)===2;return y&&D?g-1:g}Object.defineProperty(a,"__esModule",{value:!0}),a.getWrappedLineTrimmedLength=a.reflowSmallerGetNewLineLengths=a.reflowLargerApplyNewLayout=a.reflowLargerCreateNewLayout=a.reflowLargerGetLinesToRemove=void 0,a.reflowLargerGetLinesToRemove=function(f,m,g,y,D){const E=[];for(let C=0;C<f.length-1;C++){let b=C,w=f.get(++b);if(!w.isWrapped)continue;const x=[f.get(C)];for(;b<f.length&&w.isWrapped;)x.push(w),w=f.get(++b);if(y>=C&&y<b){C+=x.length-1;continue}let S=0,T=d(x,S,m),j=1,N=0;for(;j<x.length;){const R=d(x,j,m),F=R-N,V=g-T,te=Math.min(F,V);x[S].copyCellsFrom(x[j],N,T,te,!1),T+=te,T===g&&(S++,T=0),N+=te,N===R&&(j++,N=0),T===0&&S!==0&&x[S-1].getWidth(g-1)===2&&(x[S].copyCellsFrom(x[S-1],g-1,T++,1,!1),x[S-1].setCell(g-1,D))}x[S].replaceCells(T,g,D);let L=0;for(let R=x.length-1;R>0&&(R>S||x[R].getTrimmedLength()===0);R--)L++;L>0&&(E.push(C+x.length-L),E.push(L)),C+=x.length-1}return E},a.reflowLargerCreateNewLayout=function(f,m){const g=[];let y=0,D=m[y],E=0;for(let C=0;C<f.length;C++)if(D===C){const b=m[++y];f.onDeleteEmitter.fire({index:C-E,amount:b}),C+=b-1,E+=b,D=m[++y]}else g.push(C);return{layout:g,countRemoved:E}},a.reflowLargerApplyNewLayout=function(f,m){const g=[];for(let y=0;y<m.length;y++)g.push(f.get(m[y]));for(let y=0;y<g.length;y++)f.set(y,g[y]);f.length=m.length},a.reflowSmallerGetNewLineLengths=function(f,m,g){const y=[],D=f.map(((w,x)=>d(f,x,m))).reduce(((w,x)=>w+x));let E=0,C=0,b=0;for(;b<D;){if(D-b<g){y.push(D-b);break}E+=g;const w=d(f,C,m);E>w&&(E-=w,C++);const x=f[C].getWidth(E-1)===2;x&&E--;const S=x?g-1:g;y.push(S),b+=S}return y},a.getWrappedLineTrimmedLength=d},5295:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.BufferSet=void 0;const f=d(8460),m=d(844),g=d(9092);class y extends m.Disposable{constructor(E,C){super(),this._optionsService=E,this._bufferService=C,this._onBufferActivate=this.register(new f.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new g.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new g.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(E){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(E),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(E,C){this._normal.resize(E,C),this._alt.resize(E,C),this.setupTabStops(E)}setupTabStops(E){this._normal.setupTabStops(E),this._alt.setupTabStops(E)}}a.BufferSet=y},511:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.CellData=void 0;const f=d(482),m=d(643),g=d(3734);class y extends g.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new g.ExtendedAttrs,this.combinedData=""}static fromCharData(E){const C=new y;return C.setFromCharData(E),C}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,f.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(E){this.fg=E[m.CHAR_DATA_ATTR_INDEX],this.bg=0;let C=!1;if(E[m.CHAR_DATA_CHAR_INDEX].length>2)C=!0;else if(E[m.CHAR_DATA_CHAR_INDEX].length===2){const b=E[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=b&&b<=56319){const w=E[m.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=w&&w<=57343?this.content=1024*(b-55296)+w-56320+65536|E[m.CHAR_DATA_WIDTH_INDEX]<<22:C=!0}else C=!0}else this.content=E[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|E[m.CHAR_DATA_WIDTH_INDEX]<<22;C&&(this.combinedData=E[m.CHAR_DATA_CHAR_INDEX],this.content=2097152|E[m.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}a.CellData=y},643:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.WHITESPACE_CELL_CODE=a.WHITESPACE_CELL_WIDTH=a.WHITESPACE_CELL_CHAR=a.NULL_CELL_CODE=a.NULL_CELL_WIDTH=a.NULL_CELL_CHAR=a.CHAR_DATA_CODE_INDEX=a.CHAR_DATA_WIDTH_INDEX=a.CHAR_DATA_CHAR_INDEX=a.CHAR_DATA_ATTR_INDEX=a.DEFAULT_EXT=a.DEFAULT_ATTR=a.DEFAULT_COLOR=void 0,a.DEFAULT_COLOR=0,a.DEFAULT_ATTR=256|a.DEFAULT_COLOR<<9,a.DEFAULT_EXT=0,a.CHAR_DATA_ATTR_INDEX=0,a.CHAR_DATA_CHAR_INDEX=1,a.CHAR_DATA_WIDTH_INDEX=2,a.CHAR_DATA_CODE_INDEX=3,a.NULL_CELL_CHAR="",a.NULL_CELL_WIDTH=1,a.NULL_CELL_CODE=0,a.WHITESPACE_CELL_CHAR=" ",a.WHITESPACE_CELL_WIDTH=1,a.WHITESPACE_CELL_CODE=32},4863:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.Marker=void 0;const f=d(8460),m=d(844);class g{get id(){return this._id}constructor(D){this.line=D,this.isDisposed=!1,this._disposables=[],this._id=g._nextId++,this._onDispose=this.register(new f.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,m.disposeArray)(this._disposables),this._disposables.length=0)}register(D){return this._disposables.push(D),D}}a.Marker=g,g._nextId=1},7116:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.DEFAULT_CHARSET=a.CHARSETS=void 0,a.CHARSETS={},a.DEFAULT_CHARSET=a.CHARSETS.B,a.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},a.CHARSETS.A={"#":"£"},a.CHARSETS.B=void 0,a.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},a.CHARSETS.C=a.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},a.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},a.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},a.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},a.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},a.CHARSETS.E=a.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},a.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},a.CHARSETS.H=a.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},a.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(p,a)=>{var d,f,m;Object.defineProperty(a,"__esModule",{value:!0}),a.C1_ESCAPED=a.C1=a.C0=void 0,(function(g){g.NUL="\0",g.SOH="",g.STX="",g.ETX="",g.EOT="",g.ENQ="",g.ACK="",g.BEL="\x07",g.BS="\b",g.HT=" ",g.LF=`
|
|
3042
3042
|
`,g.VT="\v",g.FF="\f",g.CR="\r",g.SO="",g.SI="",g.DLE="",g.DC1="",g.DC2="",g.DC3="",g.DC4="",g.NAK="",g.SYN="",g.ETB="",g.CAN="",g.EM="",g.SUB="",g.ESC="\x1B",g.FS="",g.GS="",g.RS="",g.US="",g.SP=" ",g.DEL=""})(d||(a.C0=d={})),(function(g){g.PAD="",g.HOP="",g.BPH="",g.NBH="",g.IND="",g.NEL="
",g.SSA="",g.ESA="",g.HTS="",g.HTJ="",g.VTS="",g.PLD="",g.PLU="",g.RI="",g.SS2="",g.SS3="",g.DCS="",g.PU1="",g.PU2="",g.STS="",g.CCH="",g.MW="",g.SPA="",g.EPA="",g.SOS="",g.SGCI="",g.SCI="",g.CSI="",g.ST="",g.OSC="",g.PM="",g.APC=""})(f||(a.C1=f={})),(function(g){g.ST=`${d.ESC}\\`})(m||(a.C1_ESCAPED=m={}))},7399:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.evaluateKeyboardEvent=void 0;const f=d(2584),m={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};a.evaluateKeyboardEvent=function(g,y,D,E){const C={type:0,cancel:!1,key:void 0},b=(g.shiftKey?1:0)|(g.altKey?2:0)|(g.ctrlKey?4:0)|(g.metaKey?8:0);switch(g.keyCode){case 0:g.key==="UIKeyInputUpArrow"?C.key=y?f.C0.ESC+"OA":f.C0.ESC+"[A":g.key==="UIKeyInputLeftArrow"?C.key=y?f.C0.ESC+"OD":f.C0.ESC+"[D":g.key==="UIKeyInputRightArrow"?C.key=y?f.C0.ESC+"OC":f.C0.ESC+"[C":g.key==="UIKeyInputDownArrow"&&(C.key=y?f.C0.ESC+"OB":f.C0.ESC+"[B");break;case 8:C.key=g.ctrlKey?"\b":f.C0.DEL,g.altKey&&(C.key=f.C0.ESC+C.key);break;case 9:if(g.shiftKey){C.key=f.C0.ESC+"[Z";break}C.key=f.C0.HT,C.cancel=!0;break;case 13:C.key=g.altKey?f.C0.ESC+f.C0.CR:f.C0.CR,C.cancel=!0;break;case 27:C.key=f.C0.ESC,g.altKey&&(C.key=f.C0.ESC+f.C0.ESC),C.cancel=!0;break;case 37:if(g.metaKey)break;b?(C.key=f.C0.ESC+"[1;"+(b+1)+"D",C.key===f.C0.ESC+"[1;3D"&&(C.key=f.C0.ESC+(D?"b":"[1;5D"))):C.key=y?f.C0.ESC+"OD":f.C0.ESC+"[D";break;case 39:if(g.metaKey)break;b?(C.key=f.C0.ESC+"[1;"+(b+1)+"C",C.key===f.C0.ESC+"[1;3C"&&(C.key=f.C0.ESC+(D?"f":"[1;5C"))):C.key=y?f.C0.ESC+"OC":f.C0.ESC+"[C";break;case 38:if(g.metaKey)break;b?(C.key=f.C0.ESC+"[1;"+(b+1)+"A",D||C.key!==f.C0.ESC+"[1;3A"||(C.key=f.C0.ESC+"[1;5A")):C.key=y?f.C0.ESC+"OA":f.C0.ESC+"[A";break;case 40:if(g.metaKey)break;b?(C.key=f.C0.ESC+"[1;"+(b+1)+"B",D||C.key!==f.C0.ESC+"[1;3B"||(C.key=f.C0.ESC+"[1;5B")):C.key=y?f.C0.ESC+"OB":f.C0.ESC+"[B";break;case 45:g.shiftKey||g.ctrlKey||(C.key=f.C0.ESC+"[2~");break;case 46:C.key=b?f.C0.ESC+"[3;"+(b+1)+"~":f.C0.ESC+"[3~";break;case 36:C.key=b?f.C0.ESC+"[1;"+(b+1)+"H":y?f.C0.ESC+"OH":f.C0.ESC+"[H";break;case 35:C.key=b?f.C0.ESC+"[1;"+(b+1)+"F":y?f.C0.ESC+"OF":f.C0.ESC+"[F";break;case 33:g.shiftKey?C.type=2:g.ctrlKey?C.key=f.C0.ESC+"[5;"+(b+1)+"~":C.key=f.C0.ESC+"[5~";break;case 34:g.shiftKey?C.type=3:g.ctrlKey?C.key=f.C0.ESC+"[6;"+(b+1)+"~":C.key=f.C0.ESC+"[6~";break;case 112:C.key=b?f.C0.ESC+"[1;"+(b+1)+"P":f.C0.ESC+"OP";break;case 113:C.key=b?f.C0.ESC+"[1;"+(b+1)+"Q":f.C0.ESC+"OQ";break;case 114:C.key=b?f.C0.ESC+"[1;"+(b+1)+"R":f.C0.ESC+"OR";break;case 115:C.key=b?f.C0.ESC+"[1;"+(b+1)+"S":f.C0.ESC+"OS";break;case 116:C.key=b?f.C0.ESC+"[15;"+(b+1)+"~":f.C0.ESC+"[15~";break;case 117:C.key=b?f.C0.ESC+"[17;"+(b+1)+"~":f.C0.ESC+"[17~";break;case 118:C.key=b?f.C0.ESC+"[18;"+(b+1)+"~":f.C0.ESC+"[18~";break;case 119:C.key=b?f.C0.ESC+"[19;"+(b+1)+"~":f.C0.ESC+"[19~";break;case 120:C.key=b?f.C0.ESC+"[20;"+(b+1)+"~":f.C0.ESC+"[20~";break;case 121:C.key=b?f.C0.ESC+"[21;"+(b+1)+"~":f.C0.ESC+"[21~";break;case 122:C.key=b?f.C0.ESC+"[23;"+(b+1)+"~":f.C0.ESC+"[23~";break;case 123:C.key=b?f.C0.ESC+"[24;"+(b+1)+"~":f.C0.ESC+"[24~";break;default:if(!g.ctrlKey||g.shiftKey||g.altKey||g.metaKey)if(D&&!E||!g.altKey||g.metaKey)!D||g.altKey||g.ctrlKey||g.shiftKey||!g.metaKey?g.key&&!g.ctrlKey&&!g.altKey&&!g.metaKey&&g.keyCode>=48&&g.key.length===1?C.key=g.key:g.key&&g.ctrlKey&&(g.key==="_"&&(C.key=f.C0.US),g.key==="@"&&(C.key=f.C0.NUL)):g.keyCode===65&&(C.type=1);else{const w=m[g.keyCode],x=w==null?void 0:w[g.shiftKey?1:0];if(x)C.key=f.C0.ESC+x;else if(g.keyCode>=65&&g.keyCode<=90){const S=g.ctrlKey?g.keyCode-64:g.keyCode+32;let T=String.fromCharCode(S);g.shiftKey&&(T=T.toUpperCase()),C.key=f.C0.ESC+T}else if(g.keyCode===32)C.key=f.C0.ESC+(g.ctrlKey?f.C0.NUL:" ");else if(g.key==="Dead"&&g.code.startsWith("Key")){let S=g.code.slice(3,4);g.shiftKey||(S=S.toLowerCase()),C.key=f.C0.ESC+S,C.cancel=!0}}else g.keyCode>=65&&g.keyCode<=90?C.key=String.fromCharCode(g.keyCode-64):g.keyCode===32?C.key=f.C0.NUL:g.keyCode>=51&&g.keyCode<=55?C.key=String.fromCharCode(g.keyCode-51+27):g.keyCode===56?C.key=f.C0.DEL:g.keyCode===219?C.key=f.C0.ESC:g.keyCode===220?C.key=f.C0.FS:g.keyCode===221&&(C.key=f.C0.GS)}return C}},482:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.Utf8ToUtf32=a.StringToUtf32=a.utf32ToString=a.stringFromCodePoint=void 0,a.stringFromCodePoint=function(d){return d>65535?(d-=65536,String.fromCharCode(55296+(d>>10))+String.fromCharCode(d%1024+56320)):String.fromCharCode(d)},a.utf32ToString=function(d,f=0,m=d.length){let g="";for(let y=f;y<m;++y){let D=d[y];D>65535?(D-=65536,g+=String.fromCharCode(55296+(D>>10))+String.fromCharCode(D%1024+56320)):g+=String.fromCharCode(D)}return g},a.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(d,f){const m=d.length;if(!m)return 0;let g=0,y=0;if(this._interim){const D=d.charCodeAt(y++);56320<=D&&D<=57343?f[g++]=1024*(this._interim-55296)+D-56320+65536:(f[g++]=this._interim,f[g++]=D),this._interim=0}for(let D=y;D<m;++D){const E=d.charCodeAt(D);if(55296<=E&&E<=56319){if(++D>=m)return this._interim=E,g;const C=d.charCodeAt(D);56320<=C&&C<=57343?f[g++]=1024*(E-55296)+C-56320+65536:(f[g++]=E,f[g++]=C)}else E!==65279&&(f[g++]=E)}return g}},a.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(d,f){const m=d.length;if(!m)return 0;let g,y,D,E,C=0,b=0,w=0;if(this.interim[0]){let T=!1,j=this.interim[0];j&=(224&j)==192?31:(240&j)==224?15:7;let N,L=0;for(;(N=63&this.interim[++L])&&L<4;)j<<=6,j|=N;const R=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,F=R-L;for(;w<F;){if(w>=m)return 0;if(N=d[w++],(192&N)!=128){w--,T=!0;break}this.interim[L++]=N,j<<=6,j|=63&N}T||(R===2?j<128?w--:f[C++]=j:R===3?j<2048||j>=55296&&j<=57343||j===65279||(f[C++]=j):j<65536||j>1114111||(f[C++]=j)),this.interim.fill(0)}const x=m-4;let S=w;for(;S<m;){for(;!(!(S<x)||128&(g=d[S])||128&(y=d[S+1])||128&(D=d[S+2])||128&(E=d[S+3]));)f[C++]=g,f[C++]=y,f[C++]=D,f[C++]=E,S+=4;if(g=d[S++],g<128)f[C++]=g;else if((224&g)==192){if(S>=m)return this.interim[0]=g,C;if(y=d[S++],(192&y)!=128){S--;continue}if(b=(31&g)<<6|63&y,b<128){S--;continue}f[C++]=b}else if((240&g)==224){if(S>=m)return this.interim[0]=g,C;if(y=d[S++],(192&y)!=128){S--;continue}if(S>=m)return this.interim[0]=g,this.interim[1]=y,C;if(D=d[S++],(192&D)!=128){S--;continue}if(b=(15&g)<<12|(63&y)<<6|63&D,b<2048||b>=55296&&b<=57343||b===65279)continue;f[C++]=b}else if((248&g)==240){if(S>=m)return this.interim[0]=g,C;if(y=d[S++],(192&y)!=128){S--;continue}if(S>=m)return this.interim[0]=g,this.interim[1]=y,C;if(D=d[S++],(192&D)!=128){S--;continue}if(S>=m)return this.interim[0]=g,this.interim[1]=y,this.interim[2]=D,C;if(E=d[S++],(192&E)!=128){S--;continue}if(b=(7&g)<<18|(63&y)<<12|(63&D)<<6|63&E,b<65536||b>1114111)continue;f[C++]=b}}return C}}},225:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.UnicodeV6=void 0;const f=d(1480),m=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],g=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let y;a.UnicodeV6=class{constructor(){if(this.version="6",!y){y=new Uint8Array(65536),y.fill(1),y[0]=0,y.fill(0,1,32),y.fill(0,127,160),y.fill(2,4352,4448),y[9001]=2,y[9002]=2,y.fill(2,11904,42192),y[12351]=1,y.fill(2,44032,55204),y.fill(2,63744,64256),y.fill(2,65040,65050),y.fill(2,65072,65136),y.fill(2,65280,65377),y.fill(2,65504,65511);for(let D=0;D<m.length;++D)y.fill(0,m[D][0],m[D][1]+1)}}wcwidth(D){return D<32?0:D<127?1:D<65536?y[D]:(function(E,C){let b,w=0,x=C.length-1;if(E<C[0][0]||E>C[x][1])return!1;for(;x>=w;)if(b=w+x>>1,E>C[b][1])w=b+1;else{if(!(E<C[b][0]))return!0;x=b-1}return!1})(D,g)?0:D>=131072&&D<=196605||D>=196608&&D<=262141?2:1}charProperties(D,E){let C=this.wcwidth(D),b=C===0&&E!==0;if(b){const w=f.UnicodeService.extractWidth(E);w===0?b=!1:w>C&&(C=w)}return f.UnicodeService.createPropertyValue(0,C,b)}}},5981:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.WriteBuffer=void 0;const f=d(8460),m=d(844);class g extends m.Disposable{constructor(D){super(),this._action=D,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new f.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(D,E){if(E!==void 0&&this._syncCalls>E)return void(this._syncCalls=0);if(this._pendingData+=D.length,this._writeBuffer.push(D),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let C;for(this._isSyncWriting=!0;C=this._writeBuffer.shift();){this._action(C);const b=this._callbacks.shift();b&&b()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(D,E){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=D.length,this._writeBuffer.push(D),this._callbacks.push(E),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=D.length,this._writeBuffer.push(D),this._callbacks.push(E)}_innerWrite(D=0,E=!0){const C=D||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const b=this._writeBuffer[this._bufferOffset],w=this._action(b,E);if(w){const S=T=>Date.now()-C>=12?setTimeout((()=>this._innerWrite(0,T))):this._innerWrite(C,T);return void w.catch((T=>(queueMicrotask((()=>{throw T})),Promise.resolve(!1)))).then(S)}const x=this._callbacks[this._bufferOffset];if(x&&x(),this._bufferOffset++,this._pendingData-=b.length,Date.now()-C>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}a.WriteBuffer=g},5941:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.toRgbString=a.parseColor=void 0;const d=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,f=/^[\da-f]+$/;function m(g,y){const D=g.toString(16),E=D.length<2?"0"+D:D;switch(y){case 4:return D[0];case 8:return E;case 12:return(E+E).slice(0,3);default:return E+E}}a.parseColor=function(g){if(!g)return;let y=g.toLowerCase();if(y.indexOf("rgb:")===0){y=y.slice(4);const D=d.exec(y);if(D){const E=D[1]?15:D[4]?255:D[7]?4095:65535;return[Math.round(parseInt(D[1]||D[4]||D[7]||D[10],16)/E*255),Math.round(parseInt(D[2]||D[5]||D[8]||D[11],16)/E*255),Math.round(parseInt(D[3]||D[6]||D[9]||D[12],16)/E*255)]}}else if(y.indexOf("#")===0&&(y=y.slice(1),f.exec(y)&&[3,6,9,12].includes(y.length))){const D=y.length/3,E=[0,0,0];for(let C=0;C<3;++C){const b=parseInt(y.slice(D*C,D*C+D),16);E[C]=D===1?b<<4:D===2?b:D===3?b>>4:b>>8}return E}},a.toRgbString=function(g,y=16){const[D,E,C]=g;return`rgb:${m(D,y)}/${m(E,y)}/${m(C,y)}`}},5770:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.PAYLOAD_LIMIT=void 0,a.PAYLOAD_LIMIT=1e7},6351:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.DcsHandler=a.DcsParser=void 0;const f=d(482),m=d(8742),g=d(5770),y=[];a.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=y,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=y}registerHandler(E,C){this._handlers[E]===void 0&&(this._handlers[E]=[]);const b=this._handlers[E];return b.push(C),{dispose:()=>{const w=b.indexOf(C);w!==-1&&b.splice(w,1)}}}clearHandler(E){this._handlers[E]&&delete this._handlers[E]}setHandlerFallback(E){this._handlerFb=E}reset(){if(this._active.length)for(let E=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;E>=0;--E)this._active[E].unhook(!1);this._stack.paused=!1,this._active=y,this._ident=0}hook(E,C){if(this.reset(),this._ident=E,this._active=this._handlers[E]||y,this._active.length)for(let b=this._active.length-1;b>=0;b--)this._active[b].hook(C);else this._handlerFb(this._ident,"HOOK",C)}put(E,C,b){if(this._active.length)for(let w=this._active.length-1;w>=0;w--)this._active[w].put(E,C,b);else this._handlerFb(this._ident,"PUT",(0,f.utf32ToString)(E,C,b))}unhook(E,C=!0){if(this._active.length){let b=!1,w=this._active.length-1,x=!1;if(this._stack.paused&&(w=this._stack.loopPosition-1,b=C,x=this._stack.fallThrough,this._stack.paused=!1),!x&&b===!1){for(;w>=0&&(b=this._active[w].unhook(E),b!==!0);w--)if(b instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!1,b;w--}for(;w>=0;w--)if(b=this._active[w].unhook(!1),b instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!0,b}else this._handlerFb(this._ident,"UNHOOK",E);this._active=y,this._ident=0}};const D=new m.Params;D.addParam(0),a.DcsHandler=class{constructor(E){this._handler=E,this._data="",this._params=D,this._hitLimit=!1}hook(E){this._params=E.length>1||E.params[0]?E.clone():D,this._data="",this._hitLimit=!1}put(E,C,b){this._hitLimit||(this._data+=(0,f.utf32ToString)(E,C,b),this._data.length>g.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(E){let C=!1;if(this._hitLimit)C=!1;else if(E&&(C=this._handler(this._data,this._params),C instanceof Promise))return C.then((b=>(this._params=D,this._data="",this._hitLimit=!1,b)));return this._params=D,this._data="",this._hitLimit=!1,C}}},2015:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.EscapeSequenceParser=a.VT500_TRANSITION_TABLE=a.TransitionTable=void 0;const f=d(844),m=d(8742),g=d(6242),y=d(6351);class D{constructor(w){this.table=new Uint8Array(w)}setDefault(w,x){this.table.fill(w<<4|x)}add(w,x,S,T){this.table[x<<8|w]=S<<4|T}addMany(w,x,S,T){for(let j=0;j<w.length;j++)this.table[x<<8|w[j]]=S<<4|T}}a.TransitionTable=D;const E=160;a.VT500_TRANSITION_TABLE=(function(){const b=new D(4095),w=Array.apply(null,Array(256)).map(((L,R)=>R)),x=(L,R)=>w.slice(L,R),S=x(32,127),T=x(0,24);T.push(25),T.push.apply(T,x(28,32));const j=x(0,14);let N;for(N in b.setDefault(1,0),b.addMany(S,0,2,0),j)b.addMany([24,26,153,154],N,3,0),b.addMany(x(128,144),N,3,0),b.addMany(x(144,152),N,3,0),b.add(156,N,0,0),b.add(27,N,11,1),b.add(157,N,4,8),b.addMany([152,158,159],N,0,7),b.add(155,N,11,3),b.add(144,N,11,9);return b.addMany(T,0,3,0),b.addMany(T,1,3,1),b.add(127,1,0,1),b.addMany(T,8,0,8),b.addMany(T,3,3,3),b.add(127,3,0,3),b.addMany(T,4,3,4),b.add(127,4,0,4),b.addMany(T,6,3,6),b.addMany(T,5,3,5),b.add(127,5,0,5),b.addMany(T,2,3,2),b.add(127,2,0,2),b.add(93,1,4,8),b.addMany(S,8,5,8),b.add(127,8,5,8),b.addMany([156,27,24,26,7],8,6,0),b.addMany(x(28,32),8,0,8),b.addMany([88,94,95],1,0,7),b.addMany(S,7,0,7),b.addMany(T,7,0,7),b.add(156,7,0,0),b.add(127,7,0,7),b.add(91,1,11,3),b.addMany(x(64,127),3,7,0),b.addMany(x(48,60),3,8,4),b.addMany([60,61,62,63],3,9,4),b.addMany(x(48,60),4,8,4),b.addMany(x(64,127),4,7,0),b.addMany([60,61,62,63],4,0,6),b.addMany(x(32,64),6,0,6),b.add(127,6,0,6),b.addMany(x(64,127),6,0,0),b.addMany(x(32,48),3,9,5),b.addMany(x(32,48),5,9,5),b.addMany(x(48,64),5,0,6),b.addMany(x(64,127),5,7,0),b.addMany(x(32,48),4,9,5),b.addMany(x(32,48),1,9,2),b.addMany(x(32,48),2,9,2),b.addMany(x(48,127),2,10,0),b.addMany(x(48,80),1,10,0),b.addMany(x(81,88),1,10,0),b.addMany([89,90,92],1,10,0),b.addMany(x(96,127),1,10,0),b.add(80,1,11,9),b.addMany(T,9,0,9),b.add(127,9,0,9),b.addMany(x(28,32),9,0,9),b.addMany(x(32,48),9,9,12),b.addMany(x(48,60),9,8,10),b.addMany([60,61,62,63],9,9,10),b.addMany(T,11,0,11),b.addMany(x(32,128),11,0,11),b.addMany(x(28,32),11,0,11),b.addMany(T,10,0,10),b.add(127,10,0,10),b.addMany(x(28,32),10,0,10),b.addMany(x(48,60),10,8,10),b.addMany([60,61,62,63],10,0,11),b.addMany(x(32,48),10,9,12),b.addMany(T,12,0,12),b.add(127,12,0,12),b.addMany(x(28,32),12,0,12),b.addMany(x(32,48),12,9,12),b.addMany(x(48,64),12,0,11),b.addMany(x(64,127),12,12,13),b.addMany(x(64,127),10,12,13),b.addMany(x(64,127),9,12,13),b.addMany(T,13,13,13),b.addMany(S,13,13,13),b.add(127,13,0,13),b.addMany([27,156,24,26],13,14,0),b.add(E,0,2,0),b.add(E,8,5,8),b.add(E,6,0,6),b.add(E,11,0,11),b.add(E,13,13,13),b})();class C extends f.Disposable{constructor(w=a.VT500_TRANSITION_TABLE){super(),this._transitions=w,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new m.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(x,S,T)=>{},this._executeHandlerFb=x=>{},this._csiHandlerFb=(x,S)=>{},this._escHandlerFb=x=>{},this._errorHandlerFb=x=>x,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,f.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new g.OscParser),this._dcsParser=this.register(new y.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(w,x=[64,126]){let S=0;if(w.prefix){if(w.prefix.length>1)throw new Error("only one byte as prefix supported");if(S=w.prefix.charCodeAt(0),S&&60>S||S>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(w.intermediates){if(w.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let j=0;j<w.intermediates.length;++j){const N=w.intermediates.charCodeAt(j);if(32>N||N>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");S<<=8,S|=N}}if(w.final.length!==1)throw new Error("final must be a single byte");const T=w.final.charCodeAt(0);if(x[0]>T||T>x[1])throw new Error(`final must be in range ${x[0]} .. ${x[1]}`);return S<<=8,S|=T,S}identToString(w){const x=[];for(;w;)x.push(String.fromCharCode(255&w)),w>>=8;return x.reverse().join("")}setPrintHandler(w){this._printHandler=w}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(w,x){const S=this._identifier(w,[48,126]);this._escHandlers[S]===void 0&&(this._escHandlers[S]=[]);const T=this._escHandlers[S];return T.push(x),{dispose:()=>{const j=T.indexOf(x);j!==-1&&T.splice(j,1)}}}clearEscHandler(w){this._escHandlers[this._identifier(w,[48,126])]&&delete this._escHandlers[this._identifier(w,[48,126])]}setEscHandlerFallback(w){this._escHandlerFb=w}setExecuteHandler(w,x){this._executeHandlers[w.charCodeAt(0)]=x}clearExecuteHandler(w){this._executeHandlers[w.charCodeAt(0)]&&delete this._executeHandlers[w.charCodeAt(0)]}setExecuteHandlerFallback(w){this._executeHandlerFb=w}registerCsiHandler(w,x){const S=this._identifier(w);this._csiHandlers[S]===void 0&&(this._csiHandlers[S]=[]);const T=this._csiHandlers[S];return T.push(x),{dispose:()=>{const j=T.indexOf(x);j!==-1&&T.splice(j,1)}}}clearCsiHandler(w){this._csiHandlers[this._identifier(w)]&&delete this._csiHandlers[this._identifier(w)]}setCsiHandlerFallback(w){this._csiHandlerFb=w}registerDcsHandler(w,x){return this._dcsParser.registerHandler(this._identifier(w),x)}clearDcsHandler(w){this._dcsParser.clearHandler(this._identifier(w))}setDcsHandlerFallback(w){this._dcsParser.setHandlerFallback(w)}registerOscHandler(w,x){return this._oscParser.registerHandler(w,x)}clearOscHandler(w){this._oscParser.clearHandler(w)}setOscHandlerFallback(w){this._oscParser.setHandlerFallback(w)}setErrorHandler(w){this._errorHandler=w}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(w,x,S,T,j){this._parseStack.state=w,this._parseStack.handlers=x,this._parseStack.handlerPos=S,this._parseStack.transition=T,this._parseStack.chunkPos=j}parse(w,x,S){let T,j=0,N=0,L=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,L=this._parseStack.chunkPos+1;else{if(S===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const R=this._parseStack.handlers;let F=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(S===!1&&F>-1){for(;F>=0&&(T=R[F](this._params),T!==!0);F--)if(T instanceof Promise)return this._parseStack.handlerPos=F,T}this._parseStack.handlers=[];break;case 4:if(S===!1&&F>-1){for(;F>=0&&(T=R[F](),T!==!0);F--)if(T instanceof Promise)return this._parseStack.handlerPos=F,T}this._parseStack.handlers=[];break;case 6:if(j=w[this._parseStack.chunkPos],T=this._dcsParser.unhook(j!==24&&j!==26,S),T)return T;j===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(j=w[this._parseStack.chunkPos],T=this._oscParser.end(j!==24&&j!==26,S),T)return T;j===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,L=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let R=L;R<x;++R){switch(j=w[R],N=this._transitions.table[this.currentState<<8|(j<160?j:E)],N>>4){case 2:for(let ee=R+1;;++ee){if(ee>=x||(j=w[ee])<32||j>126&&j<E){this._printHandler(w,R,ee),R=ee-1;break}if(++ee>=x||(j=w[ee])<32||j>126&&j<E){this._printHandler(w,R,ee),R=ee-1;break}if(++ee>=x||(j=w[ee])<32||j>126&&j<E){this._printHandler(w,R,ee),R=ee-1;break}if(++ee>=x||(j=w[ee])<32||j>126&&j<E){this._printHandler(w,R,ee),R=ee-1;break}}break;case 3:this._executeHandlers[j]?this._executeHandlers[j]():this._executeHandlerFb(j),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:R,code:j,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const F=this._csiHandlers[this._collect<<8|j];let V=F?F.length-1:-1;for(;V>=0&&(T=F[V](this._params),T!==!0);V--)if(T instanceof Promise)return this._preserveStack(3,F,V,N,R),T;V<0&&this._csiHandlerFb(this._collect<<8|j,this._params),this.precedingJoinState=0;break;case 8:do switch(j){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(j-48)}while(++R<x&&(j=w[R])>47&&j<60);R--;break;case 9:this._collect<<=8,this._collect|=j;break;case 10:const te=this._escHandlers[this._collect<<8|j];let he=te?te.length-1:-1;for(;he>=0&&(T=te[he](),T!==!0);he--)if(T instanceof Promise)return this._preserveStack(4,te,he,N,R),T;he<0&&this._escHandlerFb(this._collect<<8|j),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|j,this._params);break;case 13:for(let ee=R+1;;++ee)if(ee>=x||(j=w[ee])===24||j===26||j===27||j>127&&j<E){this._dcsParser.put(w,R,ee),R=ee-1;break}break;case 14:if(T=this._dcsParser.unhook(j!==24&&j!==26),T)return this._preserveStack(6,[],0,N,R),T;j===27&&(N|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let ee=R+1;;ee++)if(ee>=x||(j=w[ee])<32||j>127&&j<E){this._oscParser.put(w,R,ee),R=ee-1;break}break;case 6:if(T=this._oscParser.end(j!==24&&j!==26),T)return this._preserveStack(5,[],0,N,R),T;j===27&&(N|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&N}}}a.EscapeSequenceParser=C},6242:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.OscHandler=a.OscParser=void 0;const f=d(5770),m=d(482),g=[];a.OscParser=class{constructor(){this._state=0,this._active=g,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(y,D){this._handlers[y]===void 0&&(this._handlers[y]=[]);const E=this._handlers[y];return E.push(D),{dispose:()=>{const C=E.indexOf(D);C!==-1&&E.splice(C,1)}}}clearHandler(y){this._handlers[y]&&delete this._handlers[y]}setHandlerFallback(y){this._handlerFb=y}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}reset(){if(this._state===2)for(let y=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;y>=0;--y)this._active[y].end(!1);this._stack.paused=!1,this._active=g,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||g,this._active.length)for(let y=this._active.length-1;y>=0;y--)this._active[y].start();else this._handlerFb(this._id,"START")}_put(y,D,E){if(this._active.length)for(let C=this._active.length-1;C>=0;C--)this._active[C].put(y,D,E);else this._handlerFb(this._id,"PUT",(0,m.utf32ToString)(y,D,E))}start(){this.reset(),this._state=1}put(y,D,E){if(this._state!==3){if(this._state===1)for(;D<E;){const C=y[D++];if(C===59){this._state=2,this._start();break}if(C<48||57<C)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+C-48}this._state===2&&E-D>0&&this._put(y,D,E)}}end(y,D=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let E=!1,C=this._active.length-1,b=!1;if(this._stack.paused&&(C=this._stack.loopPosition-1,E=D,b=this._stack.fallThrough,this._stack.paused=!1),!b&&E===!1){for(;C>=0&&(E=this._active[C].end(y),E!==!0);C--)if(E instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!1,E;C--}for(;C>=0;C--)if(E=this._active[C].end(!1),E instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!0,E}else this._handlerFb(this._id,"END",y);this._active=g,this._id=-1,this._state=0}}},a.OscHandler=class{constructor(y){this._handler=y,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(y,D,E){this._hitLimit||(this._data+=(0,m.utf32ToString)(y,D,E),this._data.length>f.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(y){let D=!1;if(this._hitLimit)D=!1;else if(y&&(D=this._handler(this._data),D instanceof Promise))return D.then((E=>(this._data="",this._hitLimit=!1,E)));return this._data="",this._hitLimit=!1,D}}},8742:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.Params=void 0;const d=2147483647;class f{static fromArray(g){const y=new f;if(!g.length)return y;for(let D=Array.isArray(g[0])?1:0;D<g.length;++D){const E=g[D];if(Array.isArray(E))for(let C=0;C<E.length;++C)y.addSubParam(E[C]);else y.addParam(E)}return y}constructor(g=32,y=32){if(this.maxLength=g,this.maxSubParamsLength=y,y>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(g),this.length=0,this._subParams=new Int32Array(y),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(g),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const g=new f(this.maxLength,this.maxSubParamsLength);return g.params.set(this.params),g.length=this.length,g._subParams.set(this._subParams),g._subParamsLength=this._subParamsLength,g._subParamsIdx.set(this._subParamsIdx),g._rejectDigits=this._rejectDigits,g._rejectSubDigits=this._rejectSubDigits,g._digitIsSub=this._digitIsSub,g}toArray(){const g=[];for(let y=0;y<this.length;++y){g.push(this.params[y]);const D=this._subParamsIdx[y]>>8,E=255&this._subParamsIdx[y];E-D>0&&g.push(Array.prototype.slice.call(this._subParams,D,E))}return g}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(g){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(g<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=g>d?d:g}}addSubParam(g){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(g<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=g>d?d:g,this._subParamsIdx[this.length-1]++}}hasSubParams(g){return(255&this._subParamsIdx[g])-(this._subParamsIdx[g]>>8)>0}getSubParams(g){const y=this._subParamsIdx[g]>>8,D=255&this._subParamsIdx[g];return D-y>0?this._subParams.subarray(y,D):null}getSubParamsAll(){const g={};for(let y=0;y<this.length;++y){const D=this._subParamsIdx[y]>>8,E=255&this._subParamsIdx[y];E-D>0&&(g[y]=this._subParams.slice(D,E))}return g}addDigit(g){let y;if(this._rejectDigits||!(y=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const D=this._digitIsSub?this._subParams:this.params,E=D[y-1];D[y-1]=~E?Math.min(10*E+g,d):g}}a.Params=f},5741:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.AddonManager=void 0,a.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let d=this._addons.length-1;d>=0;d--)this._addons[d].instance.dispose()}loadAddon(d,f){const m={instance:f,dispose:f.dispose,isDisposed:!1};this._addons.push(m),f.dispose=()=>this._wrappedAddonDispose(m),f.activate(d)}_wrappedAddonDispose(d){if(d.isDisposed)return;let f=-1;for(let m=0;m<this._addons.length;m++)if(this._addons[m]===d){f=m;break}if(f===-1)throw new Error("Could not dispose an addon that has not been loaded");d.isDisposed=!0,d.dispose.apply(d.instance),this._addons.splice(f,1)}}},8771:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.BufferApiView=void 0;const f=d(3785),m=d(511);a.BufferApiView=class{constructor(g,y){this._buffer=g,this.type=y}init(g){return this._buffer=g,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(g){const y=this._buffer.lines.get(g);if(y)return new f.BufferLineApiView(y)}getNullCell(){return new m.CellData}}},3785:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.BufferLineApiView=void 0;const f=d(511);a.BufferLineApiView=class{constructor(m){this._line=m}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(m,g){if(!(m<0||m>=this._line.length))return g?(this._line.loadCell(m,g),g):this._line.loadCell(m,new f.CellData)}translateToString(m,g,y){return this._line.translateToString(m,g,y)}}},8285:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.BufferNamespaceApi=void 0;const f=d(8771),m=d(8460),g=d(844);class y extends g.Disposable{constructor(E){super(),this._core=E,this._onBufferChange=this.register(new m.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new f.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new f.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}a.BufferNamespaceApi=y},7975:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.ParserApi=void 0,a.ParserApi=class{constructor(d){this._core=d}registerCsiHandler(d,f){return this._core.registerCsiHandler(d,(m=>f(m.toArray())))}addCsiHandler(d,f){return this.registerCsiHandler(d,f)}registerDcsHandler(d,f){return this._core.registerDcsHandler(d,((m,g)=>f(m,g.toArray())))}addDcsHandler(d,f){return this.registerDcsHandler(d,f)}registerEscHandler(d,f){return this._core.registerEscHandler(d,f)}addEscHandler(d,f){return this.registerEscHandler(d,f)}registerOscHandler(d,f){return this._core.registerOscHandler(d,f)}addOscHandler(d,f){return this.registerOscHandler(d,f)}}},7090:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.UnicodeApi=void 0,a.UnicodeApi=class{constructor(d){this._core=d}register(d){this._core.unicodeService.register(d)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(d){this._core.unicodeService.activeVersion=d}}},744:function(p,a,d){var f=this&&this.__decorate||function(b,w,x,S){var T,j=arguments.length,N=j<3?w:S===null?S=Object.getOwnPropertyDescriptor(w,x):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(b,w,x,S);else for(var L=b.length-1;L>=0;L--)(T=b[L])&&(N=(j<3?T(N):j>3?T(w,x,N):T(w,x))||N);return j>3&&N&&Object.defineProperty(w,x,N),N},m=this&&this.__param||function(b,w){return function(x,S){w(x,S,b)}};Object.defineProperty(a,"__esModule",{value:!0}),a.BufferService=a.MINIMUM_ROWS=a.MINIMUM_COLS=void 0;const g=d(8460),y=d(844),D=d(5295),E=d(2585);a.MINIMUM_COLS=2,a.MINIMUM_ROWS=1;let C=a.BufferService=class extends y.Disposable{get buffer(){return this.buffers.active}constructor(b){super(),this.isUserScrolling=!1,this._onResize=this.register(new g.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new g.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(b.rawOptions.cols||0,a.MINIMUM_COLS),this.rows=Math.max(b.rawOptions.rows||0,a.MINIMUM_ROWS),this.buffers=this.register(new D.BufferSet(b,this))}resize(b,w){this.cols=b,this.rows=w,this.buffers.resize(b,w),this._onResize.fire({cols:b,rows:w})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(b,w=!1){const x=this.buffer;let S;S=this._cachedBlankLine,S&&S.length===this.cols&&S.getFg(0)===b.fg&&S.getBg(0)===b.bg||(S=x.getBlankLine(b,w),this._cachedBlankLine=S),S.isWrapped=w;const T=x.ybase+x.scrollTop,j=x.ybase+x.scrollBottom;if(x.scrollTop===0){const N=x.lines.isFull;j===x.lines.length-1?N?x.lines.recycle().copyFrom(S):x.lines.push(S.clone()):x.lines.splice(j+1,0,S.clone()),N?this.isUserScrolling&&(x.ydisp=Math.max(x.ydisp-1,0)):(x.ybase++,this.isUserScrolling||x.ydisp++)}else{const N=j-T+1;x.lines.shiftElements(T+1,N-1,-1),x.lines.set(j,S.clone())}this.isUserScrolling||(x.ydisp=x.ybase),this._onScroll.fire(x.ydisp)}scrollLines(b,w,x){const S=this.buffer;if(b<0){if(S.ydisp===0)return;this.isUserScrolling=!0}else b+S.ydisp>=S.ybase&&(this.isUserScrolling=!1);const T=S.ydisp;S.ydisp=Math.max(Math.min(S.ydisp+b,S.ybase),0),T!==S.ydisp&&(w||this._onScroll.fire(S.ydisp))}};a.BufferService=C=f([m(0,E.IOptionsService)],C)},7994:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.CharsetService=void 0,a.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(d){this.glevel=d,this.charset=this._charsets[d]}setgCharset(d,f){this._charsets[d]=f,this.glevel===d&&(this.charset=f)}}},1753:function(p,a,d){var f=this&&this.__decorate||function(S,T,j,N){var L,R=arguments.length,F=R<3?T:N===null?N=Object.getOwnPropertyDescriptor(T,j):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")F=Reflect.decorate(S,T,j,N);else for(var V=S.length-1;V>=0;V--)(L=S[V])&&(F=(R<3?L(F):R>3?L(T,j,F):L(T,j))||F);return R>3&&F&&Object.defineProperty(T,j,F),F},m=this&&this.__param||function(S,T){return function(j,N){T(j,N,S)}};Object.defineProperty(a,"__esModule",{value:!0}),a.CoreMouseService=void 0;const g=d(2585),y=d(8460),D=d(844),E={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:S=>S.button!==4&&S.action===1&&(S.ctrl=!1,S.alt=!1,S.shift=!1,!0)},VT200:{events:19,restrict:S=>S.action!==32},DRAG:{events:23,restrict:S=>S.action!==32||S.button!==3},ANY:{events:31,restrict:S=>!0}};function C(S,T){let j=(S.ctrl?16:0)|(S.shift?4:0)|(S.alt?8:0);return S.button===4?(j|=64,j|=S.action):(j|=3&S.button,4&S.button&&(j|=64),8&S.button&&(j|=128),S.action===32?j|=32:S.action!==0||T||(j|=3)),j}const b=String.fromCharCode,w={DEFAULT:S=>{const T=[C(S,!1)+32,S.col+32,S.row+32];return T[0]>255||T[1]>255||T[2]>255?"":`\x1B[M${b(T[0])}${b(T[1])}${b(T[2])}`},SGR:S=>{const T=S.action===0&&S.button!==4?"m":"M";return`\x1B[<${C(S,!0)};${S.col};${S.row}${T}`},SGR_PIXELS:S=>{const T=S.action===0&&S.button!==4?"m":"M";return`\x1B[<${C(S,!0)};${S.x};${S.y}${T}`}};let x=a.CoreMouseService=class extends D.Disposable{constructor(S,T){super(),this._bufferService=S,this._coreService=T,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new y.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const j of Object.keys(E))this.addProtocol(j,E[j]);for(const j of Object.keys(w))this.addEncoding(j,w[j]);this.reset()}addProtocol(S,T){this._protocols[S]=T}addEncoding(S,T){this._encodings[S]=T}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(S){if(!this._protocols[S])throw new Error(`unknown protocol "${S}"`);this._activeProtocol=S,this._onProtocolChange.fire(this._protocols[S].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(S){if(!this._encodings[S])throw new Error(`unknown encoding "${S}"`);this._activeEncoding=S}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(S){if(S.col<0||S.col>=this._bufferService.cols||S.row<0||S.row>=this._bufferService.rows||S.button===4&&S.action===32||S.button===3&&S.action!==32||S.button!==4&&(S.action===2||S.action===3)||(S.col++,S.row++,S.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,S,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(S))return!1;const T=this._encodings[this._activeEncoding](S);return T&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(T):this._coreService.triggerDataEvent(T,!0)),this._lastEvent=S,!0}explainEvents(S){return{down:!!(1&S),up:!!(2&S),drag:!!(4&S),move:!!(8&S),wheel:!!(16&S)}}_equalEvents(S,T,j){if(j){if(S.x!==T.x||S.y!==T.y)return!1}else if(S.col!==T.col||S.row!==T.row)return!1;return S.button===T.button&&S.action===T.action&&S.ctrl===T.ctrl&&S.alt===T.alt&&S.shift===T.shift}};a.CoreMouseService=x=f([m(0,g.IBufferService),m(1,g.ICoreService)],x)},6975:function(p,a,d){var f=this&&this.__decorate||function(x,S,T,j){var N,L=arguments.length,R=L<3?S:j===null?j=Object.getOwnPropertyDescriptor(S,T):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(x,S,T,j);else for(var F=x.length-1;F>=0;F--)(N=x[F])&&(R=(L<3?N(R):L>3?N(S,T,R):N(S,T))||R);return L>3&&R&&Object.defineProperty(S,T,R),R},m=this&&this.__param||function(x,S){return function(T,j){S(T,j,x)}};Object.defineProperty(a,"__esModule",{value:!0}),a.CoreService=void 0;const g=d(1439),y=d(8460),D=d(844),E=d(2585),C=Object.freeze({insertMode:!1}),b=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let w=a.CoreService=class extends D.Disposable{constructor(x,S,T){super(),this._bufferService=x,this._logService=S,this._optionsService=T,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new y.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new y.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new y.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new y.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,g.clone)(C),this.decPrivateModes=(0,g.clone)(b)}reset(){this.modes=(0,g.clone)(C),this.decPrivateModes=(0,g.clone)(b)}triggerDataEvent(x,S=!1){if(this._optionsService.rawOptions.disableStdin)return;const T=this._bufferService.buffer;S&&this._optionsService.rawOptions.scrollOnUserInput&&T.ybase!==T.ydisp&&this._onRequestScrollToBottom.fire(),S&&this._onUserInput.fire(),this._logService.debug(`sending data "${x}"`,(()=>x.split("").map((j=>j.charCodeAt(0))))),this._onData.fire(x)}triggerBinaryEvent(x){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${x}"`,(()=>x.split("").map((S=>S.charCodeAt(0))))),this._onBinary.fire(x))}};a.CoreService=w=f([m(0,E.IBufferService),m(1,E.ILogService),m(2,E.IOptionsService)],w)},9074:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.DecorationService=void 0;const f=d(8055),m=d(8460),g=d(844),y=d(6106);let D=0,E=0;class C extends g.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new y.SortedList((x=>x==null?void 0:x.marker.line)),this._onDecorationRegistered=this.register(new m.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new m.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,g.toDisposable)((()=>this.reset())))}registerDecoration(x){if(x.marker.isDisposed)return;const S=new b(x);if(S){const T=S.marker.onDispose((()=>S.dispose()));S.onDispose((()=>{S&&(this._decorations.delete(S)&&this._onDecorationRemoved.fire(S),T.dispose())})),this._decorations.insert(S),this._onDecorationRegistered.fire(S)}return S}reset(){for(const x of this._decorations.values())x.dispose();this._decorations.clear()}*getDecorationsAtCell(x,S,T){let j=0,N=0;for(const L of this._decorations.getKeyIterator(S))j=L.options.x??0,N=j+(L.options.width??1),x>=j&&x<N&&(!T||(L.options.layer??"bottom")===T)&&(yield L)}forEachDecorationAtCell(x,S,T,j){this._decorations.forEachByKey(S,(N=>{D=N.options.x??0,E=D+(N.options.width??1),x>=D&&x<E&&(!T||(N.options.layer??"bottom")===T)&&j(N)}))}}a.DecorationService=C;class b extends g.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=f.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=f.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(x){super(),this.options=x,this.onRenderEmitter=this.register(new m.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new m.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=x.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.InstantiationService=a.ServiceCollection=void 0;const f=d(2585),m=d(8343);class g{constructor(...D){this._entries=new Map;for(const[E,C]of D)this.set(E,C)}set(D,E){const C=this._entries.get(D);return this._entries.set(D,E),C}forEach(D){for(const[E,C]of this._entries.entries())D(E,C)}has(D){return this._entries.has(D)}get(D){return this._entries.get(D)}}a.ServiceCollection=g,a.InstantiationService=class{constructor(){this._services=new g,this._services.set(f.IInstantiationService,this)}setService(y,D){this._services.set(y,D)}getService(y){return this._services.get(y)}createInstance(y,...D){const E=(0,m.getServiceDependencies)(y).sort(((w,x)=>w.index-x.index)),C=[];for(const w of E){const x=this._services.get(w.id);if(!x)throw new Error(`[createInstance] ${y.name} depends on UNKNOWN service ${w.id}.`);C.push(x)}const b=E.length>0?E[0].index:D.length;if(D.length!==b)throw new Error(`[createInstance] First service dependency of ${y.name} at position ${b+1} conflicts with ${D.length} static arguments`);return new y(...D,...C)}}},7866:function(p,a,d){var f=this&&this.__decorate||function(b,w,x,S){var T,j=arguments.length,N=j<3?w:S===null?S=Object.getOwnPropertyDescriptor(w,x):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(b,w,x,S);else for(var L=b.length-1;L>=0;L--)(T=b[L])&&(N=(j<3?T(N):j>3?T(w,x,N):T(w,x))||N);return j>3&&N&&Object.defineProperty(w,x,N),N},m=this&&this.__param||function(b,w){return function(x,S){w(x,S,b)}};Object.defineProperty(a,"__esModule",{value:!0}),a.traceCall=a.setTraceLogger=a.LogService=void 0;const g=d(844),y=d(2585),D={trace:y.LogLevelEnum.TRACE,debug:y.LogLevelEnum.DEBUG,info:y.LogLevelEnum.INFO,warn:y.LogLevelEnum.WARN,error:y.LogLevelEnum.ERROR,off:y.LogLevelEnum.OFF};let E,C=a.LogService=class extends g.Disposable{get logLevel(){return this._logLevel}constructor(b){super(),this._optionsService=b,this._logLevel=y.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),E=this}_updateLogLevel(){this._logLevel=D[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(b){for(let w=0;w<b.length;w++)typeof b[w]=="function"&&(b[w]=b[w]())}_log(b,w,x){this._evalLazyOptionalParams(x),b.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+w,...x)}trace(b,...w){var x;this._logLevel<=y.LogLevelEnum.TRACE&&this._log(((x=this._optionsService.options.logger)==null?void 0:x.trace.bind(this._optionsService.options.logger))??console.log,b,w)}debug(b,...w){var x;this._logLevel<=y.LogLevelEnum.DEBUG&&this._log(((x=this._optionsService.options.logger)==null?void 0:x.debug.bind(this._optionsService.options.logger))??console.log,b,w)}info(b,...w){var x;this._logLevel<=y.LogLevelEnum.INFO&&this._log(((x=this._optionsService.options.logger)==null?void 0:x.info.bind(this._optionsService.options.logger))??console.info,b,w)}warn(b,...w){var x;this._logLevel<=y.LogLevelEnum.WARN&&this._log(((x=this._optionsService.options.logger)==null?void 0:x.warn.bind(this._optionsService.options.logger))??console.warn,b,w)}error(b,...w){var x;this._logLevel<=y.LogLevelEnum.ERROR&&this._log(((x=this._optionsService.options.logger)==null?void 0:x.error.bind(this._optionsService.options.logger))??console.error,b,w)}};a.LogService=C=f([m(0,y.IOptionsService)],C),a.setTraceLogger=function(b){E=b},a.traceCall=function(b,w,x){if(typeof x.value!="function")throw new Error("not supported");const S=x.value;x.value=function(...T){if(E.logLevel!==y.LogLevelEnum.TRACE)return S.apply(this,T);E.trace(`GlyphRenderer#${S.name}(${T.map((N=>JSON.stringify(N))).join(", ")})`);const j=S.apply(this,T);return E.trace(`GlyphRenderer#${S.name} return`,j),j}}},7302:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.OptionsService=a.DEFAULT_OPTIONS=void 0;const f=d(8460),m=d(844),g=d(6114);a.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:g.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const y=["normal","bold","100","200","300","400","500","600","700","800","900"];class D extends m.Disposable{constructor(C){super(),this._onOptionChange=this.register(new f.EventEmitter),this.onOptionChange=this._onOptionChange.event;const b={...a.DEFAULT_OPTIONS};for(const w in C)if(w in b)try{const x=C[w];b[w]=this._sanitizeAndValidateOption(w,x)}catch(x){console.error(x)}this.rawOptions=b,this.options={...b},this._setupOptions(),this.register((0,m.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(C,b){return this.onOptionChange((w=>{w===C&&b(this.rawOptions[C])}))}onMultipleOptionChange(C,b){return this.onOptionChange((w=>{C.indexOf(w)!==-1&&b()}))}_setupOptions(){const C=w=>{if(!(w in a.DEFAULT_OPTIONS))throw new Error(`No option with key "${w}"`);return this.rawOptions[w]},b=(w,x)=>{if(!(w in a.DEFAULT_OPTIONS))throw new Error(`No option with key "${w}"`);x=this._sanitizeAndValidateOption(w,x),this.rawOptions[w]!==x&&(this.rawOptions[w]=x,this._onOptionChange.fire(w))};for(const w in this.rawOptions){const x={get:C.bind(this,w),set:b.bind(this,w)};Object.defineProperty(this.options,w,x)}}_sanitizeAndValidateOption(C,b){switch(C){case"cursorStyle":if(b||(b=a.DEFAULT_OPTIONS[C]),!(function(w){return w==="block"||w==="underline"||w==="bar"})(b))throw new Error(`"${b}" is not a valid value for ${C}`);break;case"wordSeparator":b||(b=a.DEFAULT_OPTIONS[C]);break;case"fontWeight":case"fontWeightBold":if(typeof b=="number"&&1<=b&&b<=1e3)break;b=y.includes(b)?b:a.DEFAULT_OPTIONS[C];break;case"cursorWidth":b=Math.floor(b);case"lineHeight":case"tabStopWidth":if(b<1)throw new Error(`${C} cannot be less than 1, value: ${b}`);break;case"minimumContrastRatio":b=Math.max(1,Math.min(21,Math.round(10*b)/10));break;case"scrollback":if((b=Math.min(b,4294967295))<0)throw new Error(`${C} cannot be less than 0, value: ${b}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(b<=0)throw new Error(`${C} cannot be less than or equal to 0, value: ${b}`);break;case"rows":case"cols":if(!b&&b!==0)throw new Error(`${C} must be numeric, value: ${b}`);break;case"windowsPty":b=b??{}}return b}}a.OptionsService=D},2660:function(p,a,d){var f=this&&this.__decorate||function(D,E,C,b){var w,x=arguments.length,S=x<3?E:b===null?b=Object.getOwnPropertyDescriptor(E,C):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(D,E,C,b);else for(var T=D.length-1;T>=0;T--)(w=D[T])&&(S=(x<3?w(S):x>3?w(E,C,S):w(E,C))||S);return x>3&&S&&Object.defineProperty(E,C,S),S},m=this&&this.__param||function(D,E){return function(C,b){E(C,b,D)}};Object.defineProperty(a,"__esModule",{value:!0}),a.OscLinkService=void 0;const g=d(2585);let y=a.OscLinkService=class{constructor(D){this._bufferService=D,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(D){const E=this._bufferService.buffer;if(D.id===void 0){const T=E.addMarker(E.ybase+E.y),j={data:D,id:this._nextId++,lines:[T]};return T.onDispose((()=>this._removeMarkerFromLink(j,T))),this._dataByLinkId.set(j.id,j),j.id}const C=D,b=this._getEntryIdKey(C),w=this._entriesWithId.get(b);if(w)return this.addLineToLink(w.id,E.ybase+E.y),w.id;const x=E.addMarker(E.ybase+E.y),S={id:this._nextId++,key:this._getEntryIdKey(C),data:C,lines:[x]};return x.onDispose((()=>this._removeMarkerFromLink(S,x))),this._entriesWithId.set(S.key,S),this._dataByLinkId.set(S.id,S),S.id}addLineToLink(D,E){const C=this._dataByLinkId.get(D);if(C&&C.lines.every((b=>b.line!==E))){const b=this._bufferService.buffer.addMarker(E);C.lines.push(b),b.onDispose((()=>this._removeMarkerFromLink(C,b)))}}getLinkData(D){var E;return(E=this._dataByLinkId.get(D))==null?void 0:E.data}_getEntryIdKey(D){return`${D.id};;${D.uri}`}_removeMarkerFromLink(D,E){const C=D.lines.indexOf(E);C!==-1&&(D.lines.splice(C,1),D.lines.length===0&&(D.data.id!==void 0&&this._entriesWithId.delete(D.key),this._dataByLinkId.delete(D.id)))}};a.OscLinkService=y=f([m(0,g.IBufferService)],y)},8343:(p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.createDecorator=a.getServiceDependencies=a.serviceRegistry=void 0;const d="di$target",f="di$dependencies";a.serviceRegistry=new Map,a.getServiceDependencies=function(m){return m[f]||[]},a.createDecorator=function(m){if(a.serviceRegistry.has(m))return a.serviceRegistry.get(m);const g=function(y,D,E){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(C,b,w){b[d]===b?b[f].push({id:C,index:w}):(b[f]=[{id:C,index:w}],b[d]=b)})(g,y,E)};return g.toString=()=>m,a.serviceRegistry.set(m,g),g}},2585:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.IDecorationService=a.IUnicodeService=a.IOscLinkService=a.IOptionsService=a.ILogService=a.LogLevelEnum=a.IInstantiationService=a.ICharsetService=a.ICoreService=a.ICoreMouseService=a.IBufferService=void 0;const f=d(8343);var m;a.IBufferService=(0,f.createDecorator)("BufferService"),a.ICoreMouseService=(0,f.createDecorator)("CoreMouseService"),a.ICoreService=(0,f.createDecorator)("CoreService"),a.ICharsetService=(0,f.createDecorator)("CharsetService"),a.IInstantiationService=(0,f.createDecorator)("InstantiationService"),(function(g){g[g.TRACE=0]="TRACE",g[g.DEBUG=1]="DEBUG",g[g.INFO=2]="INFO",g[g.WARN=3]="WARN",g[g.ERROR=4]="ERROR",g[g.OFF=5]="OFF"})(m||(a.LogLevelEnum=m={})),a.ILogService=(0,f.createDecorator)("LogService"),a.IOptionsService=(0,f.createDecorator)("OptionsService"),a.IOscLinkService=(0,f.createDecorator)("OscLinkService"),a.IUnicodeService=(0,f.createDecorator)("UnicodeService"),a.IDecorationService=(0,f.createDecorator)("DecorationService")},1480:(p,a,d)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.UnicodeService=void 0;const f=d(8460),m=d(225);class g{static extractShouldJoin(D){return(1&D)!=0}static extractWidth(D){return D>>1&3}static extractCharKind(D){return D>>3}static createPropertyValue(D,E,C=!1){return(16777215&D)<<3|(3&E)<<1|(C?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new f.EventEmitter,this.onChange=this._onChange.event;const D=new m.UnicodeV6;this.register(D),this._active=D.version,this._activeProvider=D}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(D){if(!this._providers[D])throw new Error(`unknown Unicode version "${D}"`);this._active=D,this._activeProvider=this._providers[D],this._onChange.fire(D)}register(D){this._providers[D.version]=D}wcwidth(D){return this._activeProvider.wcwidth(D)}getStringCellWidth(D){let E=0,C=0;const b=D.length;for(let w=0;w<b;++w){let x=D.charCodeAt(w);if(55296<=x&&x<=56319){if(++w>=b)return E+this.wcwidth(x);const j=D.charCodeAt(w);56320<=j&&j<=57343?x=1024*(x-55296)+j-56320+65536:E+=this.wcwidth(j)}const S=this.charProperties(x,C);let T=g.extractWidth(S);g.extractShouldJoin(S)&&(T-=g.extractWidth(C)),E+=T,C=S}return E}charProperties(D,E){return this._activeProvider.charProperties(D,E)}}a.UnicodeService=g}},n={};function r(p){var a=n[p];if(a!==void 0)return a.exports;var d=n[p]={exports:{}};return t[p].call(d.exports,d,d.exports,r),d.exports}var l={};return(()=>{var p=l;Object.defineProperty(p,"__esModule",{value:!0}),p.Terminal=void 0;const a=r(9042),d=r(3236),f=r(844),m=r(5741),g=r(8285),y=r(7975),D=r(7090),E=["cols","rows"];class C extends f.Disposable{constructor(w){super(),this._core=this.register(new d.Terminal(w)),this._addonManager=this.register(new m.AddonManager),this._publicOptions={...this._core.options};const x=T=>this._core.options[T],S=(T,j)=>{this._checkReadonlyOptions(T),this._core.options[T]=j};for(const T in this._core.options){const j={get:x.bind(this,T),set:S.bind(this,T)};Object.defineProperty(this._publicOptions,T,j)}}_checkReadonlyOptions(w){if(E.includes(w))throw new Error(`Option "${w}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new y.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new D.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new g.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const w=this._core.coreService.decPrivateModes;let x="none";switch(this._core.coreMouseService.activeProtocol){case"X10":x="x10";break;case"VT200":x="vt200";break;case"DRAG":x="drag";break;case"ANY":x="any"}return{applicationCursorKeysMode:w.applicationCursorKeys,applicationKeypadMode:w.applicationKeypad,bracketedPasteMode:w.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:x,originMode:w.origin,reverseWraparoundMode:w.reverseWraparound,sendFocusMode:w.sendFocus,wraparoundMode:w.wraparound}}get options(){return this._publicOptions}set options(w){for(const x in w)this._publicOptions[x]=w[x]}blur(){this._core.blur()}focus(){this._core.focus()}input(w,x=!0){this._core.input(w,x)}resize(w,x){this._verifyIntegers(w,x),this._core.resize(w,x)}open(w){this._core.open(w)}attachCustomKeyEventHandler(w){this._core.attachCustomKeyEventHandler(w)}attachCustomWheelEventHandler(w){this._core.attachCustomWheelEventHandler(w)}registerLinkProvider(w){return this._core.registerLinkProvider(w)}registerCharacterJoiner(w){return this._checkProposedApi(),this._core.registerCharacterJoiner(w)}deregisterCharacterJoiner(w){this._checkProposedApi(),this._core.deregisterCharacterJoiner(w)}registerMarker(w=0){return this._verifyIntegers(w),this._core.registerMarker(w)}registerDecoration(w){return this._checkProposedApi(),this._verifyPositiveIntegers(w.x??0,w.width??0,w.height??0),this._core.registerDecoration(w)}hasSelection(){return this._core.hasSelection()}select(w,x,S){this._verifyIntegers(w,x,S),this._core.select(w,x,S)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(w,x){this._verifyIntegers(w,x),this._core.selectLines(w,x)}dispose(){super.dispose()}scrollLines(w){this._verifyIntegers(w),this._core.scrollLines(w)}scrollPages(w){this._verifyIntegers(w),this._core.scrollPages(w)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(w){this._verifyIntegers(w),this._core.scrollToLine(w)}clear(){this._core.clear()}write(w,x){this._core.write(w,x)}writeln(w,x){this._core.write(w),this._core.write(`\r
|
|
3043
|
-
`,x)}paste(w){this._core.paste(w)}refresh(w,x){this._verifyIntegers(w,x),this._core.refresh(w,x)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(w){this._addonManager.loadAddon(this,w)}static get strings(){return a}_verifyIntegers(...w){for(const x of w)if(x===1/0||isNaN(x)||x%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...w){for(const x of w)if(x&&(x===1/0||isNaN(x)||x%1!=0||x<0))throw new Error("This API only accepts positive integers")}}p.Terminal=C})(),l})()))})(ab)),ab.exports}var wy=p3(),lb={exports:{}},zS;function f3(){return zS||(zS=1,(function(i,e){(function(t,n){i.exports=n()})(self,(()=>(()=>{var t={};return(()=>{var n=t;Object.defineProperty(n,"__esModule",{value:!0}),n.FitAddon=void 0,n.FitAddon=class{activate(r){this._terminal=r}dispose(){}fit(){const r=this.proposeDimensions();if(!r||!this._terminal||isNaN(r.cols)||isNaN(r.rows))return;const l=this._terminal._core;this._terminal.rows===r.rows&&this._terminal.cols===r.cols||(l._renderService.clear(),this._terminal.resize(r.cols,r.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const r=this._terminal._core,l=r._renderService.dimensions;if(l.css.cell.width===0||l.css.cell.height===0)return;const p=this._terminal.options.scrollback===0?0:r.viewport.scrollBarWidth,a=window.getComputedStyle(this._terminal.element.parentElement),d=parseInt(a.getPropertyValue("height")),f=Math.max(0,parseInt(a.getPropertyValue("width"))),m=window.getComputedStyle(this._terminal.element),g=d-(parseInt(m.getPropertyValue("padding-top"))+parseInt(m.getPropertyValue("padding-bottom"))),y=f-(parseInt(m.getPropertyValue("padding-right"))+parseInt(m.getPropertyValue("padding-left")))-p;return{cols:Math.max(2,Math.floor(y/l.css.cell.width)),rows:Math.max(1,Math.floor(g/l.css.cell.height))}}}})(),t})()))})(lb)),lb.exports}var yy=f3(),cb={exports:{}},BS;function m3(){return BS||(BS=1,(function(i,e){(function(t,n){i.exports=n()})(self,(()=>(()=>{var t={6:(p,a)=>{function d(m){try{const g=new URL(m),y=g.password&&g.username?`${g.protocol}//${g.username}:${g.password}@${g.host}`:g.username?`${g.protocol}//${g.username}@${g.host}`:`${g.protocol}//${g.host}`;return m.toLocaleLowerCase().startsWith(y.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(a,"__esModule",{value:!0}),a.LinkComputer=a.WebLinkProvider=void 0,a.WebLinkProvider=class{constructor(m,g,y,D={}){this._terminal=m,this._regex=g,this._handler=y,this._options=D}provideLinks(m,g){const y=f.computeLink(m,this._regex,this._terminal,this._handler);g(this._addCallbacks(y))}_addCallbacks(m){return m.map((g=>(g.leave=this._options.leave,g.hover=(y,D)=>{if(this._options.hover){const{range:E}=g;this._options.hover(y,D,E)}},g)))}};class f{static computeLink(g,y,D,E){const C=new RegExp(y.source,(y.flags||"")+"g"),[b,w]=f._getWindowedLineStrings(g-1,D),x=b.join("");let S;const T=[];for(;S=C.exec(x);){const j=S[0];if(!d(j))continue;const[N,L]=f._mapStrIdx(D,w,0,S.index),[R,F]=f._mapStrIdx(D,N,L,j.length);if(N===-1||L===-1||R===-1||F===-1)continue;const V={start:{x:L+1,y:N+1},end:{x:F,y:R+1}};T.push({range:V,text:j,activate:E})}return T}static _getWindowedLineStrings(g,y){let D,E=g,C=g,b=0,w="";const x=[];if(D=y.buffer.active.getLine(g)){const S=D.translateToString(!0);if(D.isWrapped&&S[0]!==" "){for(b=0;(D=y.buffer.active.getLine(--E))&&b<2048&&(w=D.translateToString(!0),b+=w.length,x.push(w),D.isWrapped&&w.indexOf(" ")===-1););x.reverse()}for(x.push(S),b=0;(D=y.buffer.active.getLine(++C))&&D.isWrapped&&b<2048&&(w=D.translateToString(!0),b+=w.length,x.push(w),w.indexOf(" ")===-1););}return[x,E]}static _mapStrIdx(g,y,D,E){const C=g.buffer.active,b=C.getNullCell();let w=D;for(;E;){const x=C.getLine(y);if(!x)return[-1,-1];for(let S=w;S<x.length;++S){x.getCell(S,b);const T=b.getChars();if(b.getWidth()&&(E-=T.length||1,S===x.length-1&&T==="")){const j=C.getLine(y+1);j&&j.isWrapped&&(j.getCell(0,b),b.getWidth()===2&&(E+=1))}if(E<0)return[y,S]}y++,w=0}return[y,w]}}a.LinkComputer=f}},n={};function r(p){var a=n[p];if(a!==void 0)return a.exports;var d=n[p]={exports:{}};return t[p](d,d.exports,r),d.exports}var l={};return(()=>{var p=l;Object.defineProperty(p,"__esModule",{value:!0}),p.WebLinksAddon=void 0;const a=r(6),d=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function f(m,g){const y=window.open();if(y){try{y.opener=null}catch{}y.location.href=g}else console.warn("Opening link blocked as opener could not be cleared")}p.WebLinksAddon=class{constructor(m=f,g={}){this._handler=m,this._options=g}activate(m){this._terminal=m;const g=this._options,y=g.urlRegex||d;this._linkProvider=this._terminal.registerLinkProvider(new a.WebLinkProvider(this._terminal,y,this._handler,g))}dispose(){var m;(m=this._linkProvider)==null||m.dispose()}}})(),l})()))})(cb)),cb.exports}var g3=m3();function v3(i){const e=i.activeTabCwd?Er(i.activeTabCwd):"";return e?{cwd:e,showSelector:!1}:{cwd:(i.picked?Er(i.picked):"")||i.knownCwds[0]||"",showSelector:!0}}function _3(i,e){const t=i.map(Er).filter(Boolean),n=e?Er(e):"";return n&&!t.includes(n)&&t.push(n),t}const GS=jn((i,e)=>({usage:{},fetch:async t=>{if(t.length===0)return;const n=new Map;for(const p of t){const a=n.get(p.cwd)??[];a.push({id:p.id,claudeSessionId:p.claudeSessionId}),n.set(p.cwd,a)}const r=await Promise.all(Array.from(n.entries()).map(async([p,a])=>{try{const d=await window.api.transcripts.usageFor(p,a.map(f=>f.claudeSessionId));return{rows:a,res:d}}catch{return{rows:a,res:{}}}})),l={...e().usage};for(const{rows:p,res:a}of r)for(const d of p){const f=a[d.claudeSessionId];f?l[d.id]=f:delete l[d.id]}i({usage:l})}})),b3=[],FS=[];function DE(){const i=Wr(n=>{var r;return(r=n.snapshot)==null?void 0:r.jobs})??b3,[e,t]=z.useState(FS);return z.useEffect(()=>{let n=!0;return window.api.schedule.listPrds().then(r=>{n&&t(r)}).catch(()=>{n&&t(FS)}),()=>{n=!1}},[i]),e}const $E=[{tag:"feature",label:"Feature",description:`The tag also sets how eagerly /develop should fire inside that Epic's session — see the session-manager-dev:develop skill's "Tag-aware default": feature/bug treat PRD decomposition as the expected next step.`,developEagerness:"expected-default",developsVia:"/develop"},{tag:"bug",label:"Bug",description:`The tag also sets how eagerly /develop should fire inside that Epic's session — see the session-manager-dev:develop skill's "Tag-aware default": feature/bug treat PRD decomposition as the expected next step.`,developEagerness:"expected-default",developsVia:"/develop"},{tag:"discussion",label:"Discussion",description:"discussion keeps /develop available but never assumed until whether-to-build is actually settled.",developEagerness:"available-not-assumed",developsVia:"/develop"},{tag:"build",label:"Build",description:"A build Epic's whole point is to run the Builder skill — decomposition into PRDs (or a direct build run) is the expected next step, the same as feature/bug.",developEagerness:"expected-default",developsVia:"/builder (not /develop)"},{tag:"project-home-builder",label:"Project Home Builder",description:"Reads a project and writes its one-page Project Home overview (home.html) via the project-home-builder local agent and the project_home_write tool. Decomposition into PRDs is the expected next step, same as feature/bug/build.",developEagerness:"expected-default",developsVia:"project-home-builder agent protocol (not /develop)"}],xy=$E.map(i=>i.tag);function _v(i){const e=$E.find(t=>t.tag===i);if(!e)throw new Error(`unknown tag: ${i}`);return e}const mw=18,w3=40,y3=["proposed","failed","attention","running","needs","queued","active","completed"],x3=["Today","This week","This month","Older"];function S3(i,e,t){let n=0,r=0,l=0,p=0;for(const a of i){const d=ac(a.id,e);d==="needs"?n++:d==="running"?r++:d==="completed"&&l++,t.has(a.id)&&p++}return{open:i.length-l,needs:n,running:r,pinned:p,all:i.length}}function lm(i,e){var l;const t=((l=e[i.id])==null?void 0:l.slice(-1)[0])??null,n=(t==null?void 0:t.at)??i.createdAt,r=Date.parse(n);return Number.isNaN(r)?0:r}function C3(i,e){return e?`${i.goalText} ${i.tag??""}`.toLowerCase().includes(e.toLowerCase()):!0}function k3(i,e,t,n,r){const l=r.trim().toLowerCase();return i.filter(p=>{const a=ac(p.id,e);return(t==="all"?!0:t==="pinned"?n.has(p.id):t==="open"?a!=="completed":t===a)&&C3(p,l)})}function E3(i,e,t,n){const r=[...i];if(e==="title")return r.sort((l,p)=>l.goalText.localeCompare(p.goalText)),r;if(e==="prdCount"){const l=new Map(r.map(p=>[p.id,Nw(p.id,t).length]));return r.sort((p,a)=>(l.get(a.id)??0)-(l.get(p.id)??0)),r}if(e==="tokens"){const l=new Map(r.map(p=>{var d;const a=(d=t.usage)==null?void 0:d[p.id];return[p.id,a?a.inputTokens+a.outputTokens:0]}));return r.sort((p,a)=>(l.get(a.id)??0)-(l.get(p.id)??0)),r}if(e==="turns"){const l=new Map(r.map(p=>{var a;return[p.id,((a=Mw(p.id,t))==null?void 0:a.turns)??0]}));return r.sort((p,a)=>(l.get(a.id)??0)-(l.get(p.id)??0)),r}return r.sort((l,p)=>lm(p,n)-lm(l,n)),r}function T3(i,e,t){const n=(t-lm(i,e))/36e5;return n<24?"Today":n<168?"This week":n<720?"This month":"Older"}function D3(i){return i==="status"?y3:i==="tag"?xy:x3}function $3(i,e,t,n,r){const l=new Map;for(const p of i){const a=e==="status"?ac(p.id,t):e==="tag"?p.tag??"discussion":T3(p,n,r);l.has(a)||l.set(a,[]),l.get(a).push(p)}return D3(e).filter(p=>l.has(p)).map(p=>({key:p,items:l.get(p)}))}function A3(i,e,t,n){const r=[...i];for(const l of e){if(t.has(l.key))continue;const p=n[l.key]??mw;r.push(...l.items.slice(0,p))}return r}function r_(i){const e=i.source;if(!e||e.producer!=="cross-project-feedback")return null;const t=e.fromCwd;if(!t)return null;const n=gw(e.proposal),r=(n==null?void 0:n.series)??null;return{fromCwd:t,...e.fromEpicId?{fromEpicId:e.fromEpicId}:{},label:ba(t),title:`Proposed by another project: ${t}`+(e.fromEpicId?` (session ${e.fromEpicId})`:"")+(n!=null&&n.originAsk?` — raised while working on: ${n.originAsk}`:"")+". Verify the claim against this codebase before approving — the sender has not read it.",proposal:n,seriesLabel:r?`Part ${r.index} of ${r.total} · ${r.title}`:null}}const db=i=>Array.isArray(i)&&i.every(e=>typeof e=="string");function gw(i){if(!i||typeof i!="object")return null;const e=i;if(typeof e.motivation!="string"||!db(e.plan)||!db(e.acceptanceCriteria)||!db(e.outOfScope))return null;const t=e.series,n=t&&typeof t=="object"&&typeof t.key=="string"&&typeof t.title=="string"&&Number.isInteger(t.index)&&Number.isInteger(t.total)?{key:t.key,title:t.title,index:t.index,total:t.total}:null;return{motivation:e.motivation,originAsk:typeof e.originAsk=="string"&&e.originAsk?e.originAsk:null,plan:e.plan,acceptanceCriteria:e.acceptanceCriteria,outOfScope:e.outOfScope,series:n}}function I3(i,e){var r,l,p,a,d;const t=(p=(l=gw((r=i.source)==null?void 0:r.proposal))==null?void 0:l.series)==null?void 0:p.key;if(!t)return[];const n=[];for(const f of e){const m=(d=gw((a=f.source)==null?void 0:a.proposal))==null?void 0:d.series;m&&m.key===t&&n.push({id:f.id,index:m.index,status:f.status,goalText:f.goalText})}return n.sort((f,m)=>f.index-m.index)}const Sy={running:{bg:"bg-accent/15",text:"text-accent",dot:"bg-accent",label:"running"},needs:{bg:"bg-delta-bad/15",text:"text-delta-bad",dot:"bg-delta-bad",label:"needs you"},refuted:{bg:"bg-accent/15",text:"text-accent",dot:"bg-accent",label:"refuted — claimed done, not delivered"},failed:{bg:"bg-accent/15",text:"text-accent",dot:"bg-accent",label:"failed"},attention:{bg:"bg-butter/25",text:"text-fg-dim",dot:"bg-butter",label:"needs review"},queued:{bg:"bg-muteband/60",text:"text-fg-dim",dot:"bg-muteband",label:"queued"},active:{bg:"transparent",text:"text-fg-faint",dot:"bg-fg-faint",label:"active",ring:!0},proposed:{bg:"bg-butter/25",text:"text-fg-dim",dot:"bg-butter",label:"proposed",ring:!0},completed:{bg:"bg-sage/20",text:"text-sage",dot:"bg-sage",label:"completed"}};function zv(i){return Sy[i].dot}function AE(i){return Sy[i].label}function IE({status:i,small:e,detail:t}){const n=Sy[i];return c.jsxs("span",{role:"status",title:t,"aria-label":t?`Status: ${n.label} — ${t}`:`Status: ${n.label}`,className:`inline-flex items-center gap-1.5 shrink-0 rounded-full font-semibold tracking-wide whitespace-nowrap ${e?"px-2 py-0.5 text-[10.5px]":"px-2.5 py-1 text-xs"} ${n.bg} ${n.text}${n.ring?" ring-1 ring-inset ring-line":""}`,children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${n.dot}`,"aria-hidden":"true"}),n.label]})}const vw={feature:{text:"text-sage",ring:"ring-sage/40",label:"FEATURE"},bug:{text:"text-accent-dark",ring:"ring-accent-dark/40",label:"BUG"},discussion:{text:"text-fg-faint",ring:"ring-fg-faint/40",label:"DISCUSSION"},build:{text:"text-hive-teal",ring:"ring-hive-teal/40",label:"BUILD"},"project-home-builder":{text:"text-honey-dark",ring:"ring-honey/40",label:"PROJECT HOME BUILDER"}},P3={feature:"bg-sage",bug:"bg-accent-dark",discussion:"bg-fg-faint",build:"bg-hive-teal","project-home-builder":"bg-honey"};function j3(i){return P3[i]}function R3(i){return vw[i].label.charAt(0)+vw[i].label.slice(1).toLowerCase()}function Cy({kind:i,small:e}){if(!i)return null;const t=vw[i];return c.jsx("span",{className:`inline-flex items-center font-mono font-semibold uppercase tracking-wide rounded ring-1 ring-inset whitespace-nowrap ${e?"px-1.5 py-0.5 text-[9.5px]":"px-[7px] py-[3px] text-[10.5px]"} ${t.text} ${t.ring}`,children:t.label})}function _w({origin:i,small:e}){return i?c.jsxs("span",{title:i.title,"data-testid":"epic-inbound-tag",className:`inline-flex items-center gap-1 font-mono font-semibold uppercase tracking-wide rounded ring-1 ring-inset whitespace-nowrap max-w-[10rem] ${e?"px-1.5 py-0.5 text-[9.5px]":"px-[7px] py-[3px] text-[10.5px]"} text-amber-300 ring-amber-400/40`,children:[c.jsx("span",{"aria-hidden":"true",children:"↘"}),c.jsx("span",{className:"truncate",children:i.label})]}):null}const HS="font-mono text-[10.5px] font-semibold uppercase tracking-wide text-fg-dim",nv="text-[12.5px] leading-relaxed text-fg-dim";function N3({epic:i,siblings:e}){var a,d;const t=r_(i);if(!t)return null;const n=t.proposal,r=c.jsxs("div",{"data-testid":"inbound-proposal-from",className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[c.jsx("span",{className:HS,children:"From"}),c.jsxs("span",{title:t.fromCwd,className:"font-mono text-[12px] font-semibold text-amber-300",children:["↘ ",t.label]}),n!=null&&n.originAsk?c.jsxs("span",{className:"text-[12px] text-fg-faint",children:["raised while working on ",n.originAsk]}):null]}),l="mb-3 max-w-[760px] space-y-2.5 rounded-md border border-line bg-bg-hi px-3.5 py-3";if(!n){const m=((d=(a=i.sections)==null?void 0:a.find(g=>g.kind==="goal"))==null?void 0:d.text)||i.openingPrompt||i.goalText;return c.jsxs("section",{"data-testid":"inbound-proposal-card",className:l,children:[r,c.jsx("div",{"data-testid":"inbound-proposal-report",className:"max-h-[50vh] overflow-y-auto whitespace-pre-wrap text-[12px] leading-relaxed text-fg-dim",children:m})]})}const p=(f,m,g)=>c.jsxs("div",{"data-testid":f,children:[c.jsx("div",{className:`mb-1 ${HS}`,children:m}),g]});return c.jsxs("section",{"data-testid":"inbound-proposal-card",className:l,children:[r,t.seriesLabel?c.jsx("span",{"data-testid":"inbound-proposal-series",className:"inline-flex items-center rounded ring-1 ring-inset ring-amber-400/40 px-[7px] py-[3px] font-mono text-[10.5px] font-semibold uppercase tracking-wide text-amber-300",children:t.seriesLabel}):null,e.length>1?c.jsx("ul",{"data-testid":"inbound-proposal-siblings",className:"space-y-0.5 text-[12px] text-fg-faint",children:e.map(f=>{var m;return c.jsxs("li",{"aria-current":f.id===i.id?"true":void 0,className:f.id===i.id?"font-semibold text-fg-dim":void 0,children:[`${f.index}/${((m=n.series)==null?void 0:m.total)??e.length} ${f.goalText} ${f.status}`,f.id===i.id?" ← this":""]},f.id)})}):null,c.jsxs("div",{className:"max-h-[50vh] space-y-2.5 overflow-y-auto",children:[p("inbound-proposal-why","Why",c.jsx("p",{className:nv,children:n.motivation})),p("inbound-proposal-plan","Proposed plan",c.jsx("ol",{className:`list-decimal space-y-0.5 pl-5 ${nv}`,children:n.plan.map((f,m)=>c.jsx("li",{children:f},m))})),p("inbound-proposal-criteria","Acceptance criteria",c.jsx("ul",{className:`list-disc space-y-0.5 pl-5 ${nv}`,children:n.acceptanceCriteria.map((f,m)=>c.jsx("li",{children:f},m))})),n.outOfScope.length>0?p("inbound-proposal-out-of-scope","Out of scope",c.jsx("ul",{className:`list-disc space-y-0.5 pl-5 ${nv}`,children:n.outOfScope.map((f,m)=>c.jsx("li",{children:f},m))})):null]})]})}const PE={active:{bg:"transparent",text:"text-fg-faint",dot:"bg-fg-faint",label:"isolated"},needs_merge_resolution:{bg:"bg-delta-bad/15",text:"text-delta-bad",dot:"bg-delta-bad",label:"merge conflict"},merged:{bg:"bg-sage/20",text:"text-sage",dot:"bg-sage",label:"merged"},disabled:{bg:"bg-muteband/60",text:"text-fg-dim",dot:"bg-muteband",label:"isolation disabled"}};function M3({worktree:i,small:e}){const t=e?"px-2 py-0.5 text-[10.5px]":"px-2.5 py-1 text-xs";if(!i)return c.jsx("span",{title:"This session runs directly in the project's shared working tree — no isolated git worktree.","data-testid":"epic-worktree-chip",className:`inline-flex items-center gap-1.5 shrink-0 rounded-full font-semibold tracking-wide whitespace-nowrap ring-1 ring-inset ring-line text-fg-faint ${t}`,children:"shared tree"});const n=PE[i.status],r=i.status==="active"?`isolated · ${i.branch}`:n.label,l=i.status==="needs_merge_resolution"&&i.conflictReason?i.conflictReason:i.status==="active"||i.status==="needs_merge_resolution"?`${i.branch} · ${i.dir}`:n.label;return c.jsxs("span",{title:l,"data-testid":"epic-worktree-chip",className:`inline-flex items-center gap-1.5 shrink-0 rounded-full font-semibold tracking-wide whitespace-nowrap ${t} ${n.bg} ${n.text}`,children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${n.dot}`,"aria-hidden":"true"}),r]})}const O3=["feature","bug","discussion"];function WS(i){const e=((i==null?void 0:i.tags)??[]).filter(t=>xy.includes(t));return e.length?e:O3}const US=["#b85c34","#a3441f","#6f7d52","#8a7a60","#7a6a8a","#5f7a7d","#c96442","#4f7d72"];function jE(i){let e=0;for(let t=0;t<i.length;t+=1)e=e*31+i.charCodeAt(t)>>>0;return US[e%US.length]}const VS=["Engineering","Product","Design","Quality","Platform","Growth"];function L3(i){var r,l;const e=new Map;for(const p of i){const a=((l=(r=p.title)==null?void 0:r.split(" — ")[0])==null?void 0:l.trim())||"Other";e.has(a)||e.set(a,[]),e.get(a).push(p)}const t=VS.filter(p=>e.has(p)).map(p=>({department:p,agents:e.get(p)})),n=[...e.keys()].filter(p=>!VS.includes(p)).sort().map(p=>({department:p,agents:e.get(p)}));return[...t,...n]}function qS(i){var e;return((e=i.title)==null?void 0:e.split(" — ")[1])||i.description||null}function RE({agents:i,value:e,onChange:t}){const n=i.find(l=>l.name===e)??i[0]??null,r=L3(i);return c.jsxs("div",{"data-testid":"new-epic-agent-picker",className:"relative focus-within:ring-1 focus-within:ring-accent-muted",children:[c.jsxs("div",{className:"flex h-[42px] min-w-0 items-center gap-2.5 rounded-[10px] border border-line bg-bg px-3.5",children:[n?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"h-2 w-2 flex-shrink-0 rounded-full",style:{background:jE(n.name)}}),c.jsx("span",{className:"font-mono text-[13px] font-semibold text-fg",children:n.name}),c.jsx("span",{className:"min-w-0 flex-1 truncate text-[12.5px] text-fg-faint",children:qS(n)})]}):c.jsx("span",{className:"min-w-0 flex-1 truncate text-[12.5px] text-fg-faint",children:"No agents in library"}),c.jsx("span",{className:"flex-shrink-0 text-[11px] text-fg-faint",children:"▾"})]}),c.jsx("select",{"data-testid":"new-epic-agent-select","aria-label":"Agent",className:"absolute inset-0 h-full w-full cursor-pointer opacity-0",value:(n==null?void 0:n.name)??"",disabled:i.length===0,onChange:l=>t(l.target.value),children:r.map(({department:l,agents:p})=>c.jsx("optgroup",{label:l,children:p.map(a=>{const d=qS(a);return c.jsx("option",{value:a.name,"data-testid":`new-epic-agent-${a.name}`,"data-selected":a.name===(n==null?void 0:n.name)?"true":"false",children:d?`${a.name} — ${d}`:a.name},a.name)})},l))})]})}const z3=60,B3=8e3,$f="w-full rounded-md border border-line bg-bg px-2 py-1 text-[12px] text-fg placeholder:text-fg-faint focus:outline-none focus:border-accent",KS=/^[a-z][a-z0-9_]{0,31}$/,Af="font-mono text-[10px] font-semibold tracking-[1px] uppercase text-fg-faint";function G3({cwd:i,agents:e,macro:t,latest:n,onClose:r}){var W,Q;const[l,p]=z.useState((t==null?void 0:t.label)??""),[a,d]=z.useState((t==null?void 0:t.agentName)??((W=e[0])==null?void 0:W.name)??""),[f,m]=z.useState((t==null?void 0:t.tag)??""),[g,y]=z.useState((t==null?void 0:t.prompt)??""),D=t?t.projects.includes("*"):!1,[E,C]=z.useState(D),[b,w]=z.useState((t==null?void 0:t.inputs)??[]),[x,S]=z.useState(!1),[T,j]=z.useState(null);z.useEffect(()=>{!a&&e[0]&&d(e[0].name)},[e,a]);const N=e.find(oe=>oe.name===a)??null,L=e.length>0&&a!==""&&!N;let R=WS(N);!N&&f&&!R.includes(f)&&(R=[f,...R]);const F=f&&R.includes(f)?f:R[0],V=oe=>{d(oe);const Ce=WS(e.find(Oe=>Oe.name===oe)??null);Ce.includes(F)||m(Ce[0])};z.useEffect(()=>{const oe=Ce=>{Ce.key==="Escape"&&r()};return document.addEventListener("keydown",oe),()=>document.removeEventListener("keydown",oe)},[r]);const te=l.trim(),he=g.trim(),ee=(((Q=t==null?void 0:t.inputs)==null?void 0:Q.length)??0)>0,we=Nk(g),ce=new Set(b.map(oe=>oe.name)),Ee=we.filter(oe=>!ce.has(oe)).length===0&&b.every(oe=>KS.test(oe.name))&&ce.size===b.length,fe=te.length>0&&he.length>0&&a!==""&&Ee,U=(oe,Ce)=>w(Oe=>Oe.map((Xe,ge)=>ge===oe?{...Xe,...Ce}:Xe)),X=async()=>{if(!(!fe||x)){S(!0),j(null);try{let oe;const Ce=n??t;Ce?E===D?oe=Ce.projects:E?oe=["*"]:oe=Ce.projects.includes("*")?[i]:Ce.projects:oe=E?["*"]:[i],await window.api.macros.save({...t?{id:t.id}:{},label:te,agentName:a,tag:F,prompt:he,projects:oe,...ee||b.length>0?{inputs:b.map(Oe=>({...Oe,label:Oe.label.trim()||Oe.name,required:Oe.required===!0,...Oe.default?{default:Oe.default}:{}}))}:{}}),Qe.info(t?`Macro "${te}" updated`:`Macro "${te}" saved`),r()}catch(oe){j(oe instanceof Error?oe.message:String(oe))}finally{S(!1)}}};return c.jsxs("form",{"data-testid":"macro-editor",className:"flex flex-col gap-2 rounded-lg border border-line bg-bg-hi p-2.5",onSubmit:oe=>{oe.preventDefault(),X()},children:[c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:Af,htmlFor:"macro-label",children:"Label"}),c.jsx("input",{id:"macro-label","data-testid":"macro-label",className:$f,value:l,maxLength:z3,placeholder:"e.g. Sweep",onChange:oe=>p(oe.target.value),autoFocus:!0})]}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("span",{className:Af,children:"Agent"}),c.jsx(RE,{agents:e,value:a,onChange:V}),L&&c.jsxs("div",{role:"alert","data-testid":"macro-agent-missing",className:"text-[11.5px] text-amber-500",children:["agent ",a," not found"]})]}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("span",{className:Af,children:"Tag"}),c.jsx("div",{className:"flex flex-wrap gap-1",role:"group","aria-label":"Tag",children:R.map(oe=>c.jsx("button",{type:"button","data-testid":"macro-tag","data-tag":oe,"aria-pressed":oe===F,onClick:()=>m(oe),className:`rounded-md border px-2 py-0.5 text-[11px] font-semibold transition-colors ${oe===F?"bg-accent text-white border-transparent":"bg-bg text-fg-dim border-line hover:text-fg"}`,children:_v(oe).label},oe))})]}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:Af,htmlFor:"macro-prompt",children:"Initial prompt"}),c.jsx("textarea",{id:"macro-prompt","data-testid":"macro-prompt",className:`${$f} min-h-[88px] resize-y`,value:g,maxLength:B3,placeholder:"What should the new session do first?",onChange:oe=>y(oe.target.value)})]}),we.length>0&&c.jsx("div",{"data-testid":"macro-placeholders",className:"flex flex-wrap gap-1 text-[11px] text-fg-dim",children:we.map(oe=>ce.has(oe)?c.jsx("code",{children:`{{${oe}}}`},oe):c.jsxs("code",{"data-testid":"macro-undeclared-placeholder",className:"text-amber-500",children:[`{{${oe}}}`," (no input)"]},oe))}),c.jsxs("div",{"data-testid":"macro-inputs",className:"flex flex-col gap-1",children:[c.jsx("span",{className:Af,children:"Inputs"}),b.map((oe,Ce)=>c.jsxs("div",{"data-testid":"macro-input-row",className:"flex flex-col gap-1 rounded-md border border-line p-1.5",children:[c.jsx("input",{"data-testid":"macro-input-name",className:$f,value:oe.name,placeholder:"name (e.g. stream)","aria-invalid":!KS.test(oe.name),onChange:Oe=>U(Ce,{name:Oe.target.value})}),c.jsx("input",{"data-testid":"macro-input-label",className:$f,value:oe.label,placeholder:"label",onChange:Oe=>U(Ce,{label:Oe.target.value})}),c.jsx("input",{"data-testid":"macro-input-default",className:$f,value:oe.default??"",placeholder:"default",onChange:Oe=>U(Ce,{default:Oe.target.value})}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("label",{className:"flex items-center gap-1.5 text-[11.5px] text-fg-dim",children:[c.jsx("input",{type:"checkbox","data-testid":"macro-input-required",checked:oe.required===!0,onChange:Oe=>U(Ce,{required:Oe.target.checked})}),"Required"]}),c.jsx("button",{type:"button","data-testid":"macro-input-remove",onClick:()=>w(Oe=>Oe.filter((Xe,ge)=>ge!==Ce)),className:"text-[11.5px] font-semibold text-fg-dim hover:text-fg",children:"Remove"})]})]},Ce)),c.jsx("button",{type:"button","data-testid":"macro-input-add",onClick:()=>w(oe=>[...oe,{name:"",label:""}]),className:"self-start rounded-md border border-line bg-bg px-2 py-0.5 text-[11.5px] font-semibold text-fg-dim hover:text-fg",children:"Add input"})]}),c.jsxs("label",{className:"flex items-center gap-1.5 text-[11.5px] text-fg-dim",children:[c.jsx("input",{type:"checkbox","data-testid":"macro-everywhere",checked:E,onChange:oe=>C(oe.target.checked)}),"Show in every project"]}),T&&c.jsx("div",{role:"alert","data-testid":"macro-error",className:"text-[11.5px] text-red-500",children:T}),c.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[c.jsx("button",{type:"button","data-testid":"macro-cancel",onClick:r,className:"rounded-md border border-line bg-bg px-2.5 py-1 text-[11.5px] font-semibold text-fg-dim hover:text-fg",children:"Cancel"}),c.jsx("button",{type:"submit","data-testid":"macro-save",disabled:!fe||x,className:"rounded-md border border-transparent bg-accent px-2.5 py-1 text-[11.5px] font-semibold text-white shadow-sm disabled:opacity-40 disabled:cursor-not-allowed",children:x?"Saving…":"Save"})]})]})}const YS="rounded-md border border-line bg-bg px-2 py-1 text-[12px] text-fg outline-none focus:border-accent";function F3({macro:i,onSubmit:e,onCancel:t}){const n=i.inputs??[],[r,l]=z.useState(()=>Mk(n)),[p,a]=z.useState(null);return c.jsxs("form",{"data-testid":"macro-inputs-form",noValidate:!0,className:"flex flex-col gap-2 rounded-lg border border-line bg-bg-hi p-2.5",onSubmit:d=>{d.preventDefault();const f=Ok(i.prompt,n,r);if(!f.ok){a(f.error);return}a(null),e(r)},onKeyDown:d=>{d.key==="Escape"&&(d.stopPropagation(),t())},children:[c.jsx("div",{className:"text-[11.5px] font-semibold text-fg",children:i.label}),n.map((d,f)=>c.jsxs("label",{className:"flex flex-col gap-1 text-[11.5px] text-fg-dim",children:[c.jsxs("span",{children:[d.label,d.required&&c.jsx("span",{className:"text-red-500",title:"Required",children:" *"})]}),d.options&&d.options.length>0?c.jsxs("select",{"data-testid":`macro-input-${d.name}`,className:YS,value:r[d.name]??"",autoFocus:f===0,onChange:m=>l(g=>({...g,[d.name]:m.target.value})),children:[!d.required&&c.jsx("option",{value:""}),d.options.map(m=>c.jsx("option",{value:m,children:m},m))]}):c.jsx("input",{type:"text","data-testid":`macro-input-${d.name}`,className:YS,value:r[d.name]??"",maxLength:rw,required:d.required,autoFocus:f===0,onChange:m=>l(g=>({...g,[d.name]:m.target.value}))})]},d.name)),p&&c.jsx("div",{"data-testid":"macro-inputs-error",role:"alert",className:"text-[11.5px] text-red-500",children:p}),c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("button",{type:"submit","data-testid":"macro-inputs-start",className:"inline-flex items-center rounded-md border border-transparent bg-accent px-2.5 py-1 text-[11.5px] font-semibold text-white",children:"Start"}),c.jsx("button",{type:"button","data-testid":"macro-inputs-cancel",onClick:t,className:"inline-flex items-center rounded-md border border-line bg-bg px-2.5 py-1 text-[11.5px] font-semibold text-fg-dim hover:text-fg",children:"Cancel"})]})]})}const NE="inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11.5px] font-semibold border transition-colors disabled:opacity-40 disabled:cursor-not-allowed",ub=`${NE} bg-bg-hi text-fg-dim border-line hover:text-fg`;function H3(i){const e=i.prompt.split(`
|
|
3043
|
+
`,x)}paste(w){this._core.paste(w)}refresh(w,x){this._verifyIntegers(w,x),this._core.refresh(w,x)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(w){this._addonManager.loadAddon(this,w)}static get strings(){return a}_verifyIntegers(...w){for(const x of w)if(x===1/0||isNaN(x)||x%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...w){for(const x of w)if(x&&(x===1/0||isNaN(x)||x%1!=0||x<0))throw new Error("This API only accepts positive integers")}}p.Terminal=C})(),l})()))})(ab)),ab.exports}var wy=p3(),lb={exports:{}},zS;function f3(){return zS||(zS=1,(function(i,e){(function(t,n){i.exports=n()})(self,(()=>(()=>{var t={};return(()=>{var n=t;Object.defineProperty(n,"__esModule",{value:!0}),n.FitAddon=void 0,n.FitAddon=class{activate(r){this._terminal=r}dispose(){}fit(){const r=this.proposeDimensions();if(!r||!this._terminal||isNaN(r.cols)||isNaN(r.rows))return;const l=this._terminal._core;this._terminal.rows===r.rows&&this._terminal.cols===r.cols||(l._renderService.clear(),this._terminal.resize(r.cols,r.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const r=this._terminal._core,l=r._renderService.dimensions;if(l.css.cell.width===0||l.css.cell.height===0)return;const p=this._terminal.options.scrollback===0?0:r.viewport.scrollBarWidth,a=window.getComputedStyle(this._terminal.element.parentElement),d=parseInt(a.getPropertyValue("height")),f=Math.max(0,parseInt(a.getPropertyValue("width"))),m=window.getComputedStyle(this._terminal.element),g=d-(parseInt(m.getPropertyValue("padding-top"))+parseInt(m.getPropertyValue("padding-bottom"))),y=f-(parseInt(m.getPropertyValue("padding-right"))+parseInt(m.getPropertyValue("padding-left")))-p;return{cols:Math.max(2,Math.floor(y/l.css.cell.width)),rows:Math.max(1,Math.floor(g/l.css.cell.height))}}}})(),t})()))})(lb)),lb.exports}var yy=f3(),cb={exports:{}},BS;function m3(){return BS||(BS=1,(function(i,e){(function(t,n){i.exports=n()})(self,(()=>(()=>{var t={6:(p,a)=>{function d(m){try{const g=new URL(m),y=g.password&&g.username?`${g.protocol}//${g.username}:${g.password}@${g.host}`:g.username?`${g.protocol}//${g.username}@${g.host}`:`${g.protocol}//${g.host}`;return m.toLocaleLowerCase().startsWith(y.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(a,"__esModule",{value:!0}),a.LinkComputer=a.WebLinkProvider=void 0,a.WebLinkProvider=class{constructor(m,g,y,D={}){this._terminal=m,this._regex=g,this._handler=y,this._options=D}provideLinks(m,g){const y=f.computeLink(m,this._regex,this._terminal,this._handler);g(this._addCallbacks(y))}_addCallbacks(m){return m.map((g=>(g.leave=this._options.leave,g.hover=(y,D)=>{if(this._options.hover){const{range:E}=g;this._options.hover(y,D,E)}},g)))}};class f{static computeLink(g,y,D,E){const C=new RegExp(y.source,(y.flags||"")+"g"),[b,w]=f._getWindowedLineStrings(g-1,D),x=b.join("");let S;const T=[];for(;S=C.exec(x);){const j=S[0];if(!d(j))continue;const[N,L]=f._mapStrIdx(D,w,0,S.index),[R,F]=f._mapStrIdx(D,N,L,j.length);if(N===-1||L===-1||R===-1||F===-1)continue;const V={start:{x:L+1,y:N+1},end:{x:F,y:R+1}};T.push({range:V,text:j,activate:E})}return T}static _getWindowedLineStrings(g,y){let D,E=g,C=g,b=0,w="";const x=[];if(D=y.buffer.active.getLine(g)){const S=D.translateToString(!0);if(D.isWrapped&&S[0]!==" "){for(b=0;(D=y.buffer.active.getLine(--E))&&b<2048&&(w=D.translateToString(!0),b+=w.length,x.push(w),D.isWrapped&&w.indexOf(" ")===-1););x.reverse()}for(x.push(S),b=0;(D=y.buffer.active.getLine(++C))&&D.isWrapped&&b<2048&&(w=D.translateToString(!0),b+=w.length,x.push(w),w.indexOf(" ")===-1););}return[x,E]}static _mapStrIdx(g,y,D,E){const C=g.buffer.active,b=C.getNullCell();let w=D;for(;E;){const x=C.getLine(y);if(!x)return[-1,-1];for(let S=w;S<x.length;++S){x.getCell(S,b);const T=b.getChars();if(b.getWidth()&&(E-=T.length||1,S===x.length-1&&T==="")){const j=C.getLine(y+1);j&&j.isWrapped&&(j.getCell(0,b),b.getWidth()===2&&(E+=1))}if(E<0)return[y,S]}y++,w=0}return[y,w]}}a.LinkComputer=f}},n={};function r(p){var a=n[p];if(a!==void 0)return a.exports;var d=n[p]={exports:{}};return t[p](d,d.exports,r),d.exports}var l={};return(()=>{var p=l;Object.defineProperty(p,"__esModule",{value:!0}),p.WebLinksAddon=void 0;const a=r(6),d=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function f(m,g){const y=window.open();if(y){try{y.opener=null}catch{}y.location.href=g}else console.warn("Opening link blocked as opener could not be cleared")}p.WebLinksAddon=class{constructor(m=f,g={}){this._handler=m,this._options=g}activate(m){this._terminal=m;const g=this._options,y=g.urlRegex||d;this._linkProvider=this._terminal.registerLinkProvider(new a.WebLinkProvider(this._terminal,y,this._handler,g))}dispose(){var m;(m=this._linkProvider)==null||m.dispose()}}})(),l})()))})(cb)),cb.exports}var g3=m3();function v3(i){const e=i.activeTabCwd?Er(i.activeTabCwd):"";return e?{cwd:e,showSelector:!1}:{cwd:(i.picked?Er(i.picked):"")||i.knownCwds[0]||"",showSelector:!0}}function _3(i,e){const t=i.map(Er).filter(Boolean),n=e?Er(e):"";return n&&!t.includes(n)&&t.push(n),t}const GS=jn((i,e)=>({usage:{},fetch:async t=>{if(t.length===0)return;const n=new Map;for(const p of t){const a=n.get(p.cwd)??[];a.push({id:p.id,claudeSessionId:p.claudeSessionId}),n.set(p.cwd,a)}const r=await Promise.all(Array.from(n.entries()).map(async([p,a])=>{try{const d=await window.api.transcripts.usageFor(p,a.map(f=>f.claudeSessionId));return{rows:a,res:d}}catch{return{rows:a,res:{}}}})),l={...e().usage};for(const{rows:p,res:a}of r)for(const d of p){const f=a[d.claudeSessionId];f?l[d.id]=f:delete l[d.id]}i({usage:l})}})),b3=[],FS=[];function DE(){const i=Wr(n=>{var r;return(r=n.snapshot)==null?void 0:r.jobs})??b3,[e,t]=z.useState(FS);return z.useEffect(()=>{let n=!0;return window.api.schedule.listPrds().then(r=>{n&&t(r)}).catch(()=>{n&&t(FS)}),()=>{n=!1}},[i]),e}const $E=[{tag:"feature",label:"Feature",description:`The tag also sets how eagerly /develop should fire inside that Epic's session — see the session-manager-dev:develop skill's "Tag-aware default": feature/bug treat PRD decomposition as the expected next step.`,developEagerness:"expected-default",developsVia:"/develop"},{tag:"bug",label:"Bug",description:`The tag also sets how eagerly /develop should fire inside that Epic's session — see the session-manager-dev:develop skill's "Tag-aware default": feature/bug treat PRD decomposition as the expected next step.`,developEagerness:"expected-default",developsVia:"/develop"},{tag:"discussion",label:"Discussion",description:"discussion keeps /develop available but never assumed until whether-to-build is actually settled.",developEagerness:"available-not-assumed",developsVia:"/develop"},{tag:"build",label:"Build",description:"A build Epic's whole point is to run the Builder skill — decomposition into PRDs (or a direct build run) is the expected next step, the same as feature/bug.",developEagerness:"expected-default",developsVia:"/builder (not /develop)"},{tag:"project-home-builder",label:"Project Home Builder",description:"Reads a project and writes its one-page Project Home overview (home.html) via the project-home-builder local agent and the project_home_write tool. Decomposition into PRDs is the expected next step, same as feature/bug/build.",developEagerness:"expected-default",developsVia:"project-home-builder agent protocol (not /develop)"},{tag:"art",label:"3D art / animation",description:"Blender modeling, rigging, skinning and animation work whose source of truth is a .blend file. Decomposition into PRDs executed by an art persona is the expected next step, same as feature/bug.",developEagerness:"expected-default",developsVia:"/develop (PRDs executed by an art persona, e.g. agentType blender-artist)"},{tag:"portfolio",label:"Portfolio Optimization",description:"A cross-project review of the owner's whole portfolio (money, influence, online presence) that judges past decisions and routes at most a few changes to the projects that own them. Like discussion it never decomposes into PRDs here; decided changes leave via send-feedback (feedback_open_session) as proposed Epics in the owning project.",developEagerness:"available-not-assumed",developsVia:"send-feedback / feedback_open_session to the owning project (never /develop here)"}],xy=$E.map(i=>i.tag);function _v(i){const e=$E.find(t=>t.tag===i);if(!e)throw new Error(`unknown tag: ${i}`);return e}const mw=18,w3=40,y3=["proposed","failed","attention","running","needs","queued","active","completed"],x3=["Today","This week","This month","Older"];function S3(i,e,t){let n=0,r=0,l=0,p=0;for(const a of i){const d=ac(a.id,e);d==="needs"?n++:d==="running"?r++:d==="completed"&&l++,t.has(a.id)&&p++}return{open:i.length-l,needs:n,running:r,pinned:p,all:i.length}}function lm(i,e){var l;const t=((l=e[i.id])==null?void 0:l.slice(-1)[0])??null,n=(t==null?void 0:t.at)??i.createdAt,r=Date.parse(n);return Number.isNaN(r)?0:r}function C3(i,e){return e?`${i.goalText} ${i.tag??""}`.toLowerCase().includes(e.toLowerCase()):!0}function k3(i,e,t,n,r){const l=r.trim().toLowerCase();return i.filter(p=>{const a=ac(p.id,e);return(t==="all"?!0:t==="pinned"?n.has(p.id):t==="open"?a!=="completed":t===a)&&C3(p,l)})}function E3(i,e,t,n){const r=[...i];if(e==="title")return r.sort((l,p)=>l.goalText.localeCompare(p.goalText)),r;if(e==="prdCount"){const l=new Map(r.map(p=>[p.id,Nw(p.id,t).length]));return r.sort((p,a)=>(l.get(a.id)??0)-(l.get(p.id)??0)),r}if(e==="tokens"){const l=new Map(r.map(p=>{var d;const a=(d=t.usage)==null?void 0:d[p.id];return[p.id,a?a.inputTokens+a.outputTokens:0]}));return r.sort((p,a)=>(l.get(a.id)??0)-(l.get(p.id)??0)),r}if(e==="turns"){const l=new Map(r.map(p=>{var a;return[p.id,((a=Mw(p.id,t))==null?void 0:a.turns)??0]}));return r.sort((p,a)=>(l.get(a.id)??0)-(l.get(p.id)??0)),r}return r.sort((l,p)=>lm(p,n)-lm(l,n)),r}function T3(i,e,t){const n=(t-lm(i,e))/36e5;return n<24?"Today":n<168?"This week":n<720?"This month":"Older"}function D3(i){return i==="status"?y3:i==="tag"?xy:x3}function $3(i,e,t,n,r){const l=new Map;for(const p of i){const a=e==="status"?ac(p.id,t):e==="tag"?p.tag??"discussion":T3(p,n,r);l.has(a)||l.set(a,[]),l.get(a).push(p)}return D3(e).filter(p=>l.has(p)).map(p=>({key:p,items:l.get(p)}))}function A3(i,e,t,n){const r=[...i];for(const l of e){if(t.has(l.key))continue;const p=n[l.key]??mw;r.push(...l.items.slice(0,p))}return r}function r_(i){const e=i.source;if(!e||e.producer!=="cross-project-feedback")return null;const t=e.fromCwd;if(!t)return null;const n=gw(e.proposal),r=(n==null?void 0:n.series)??null;return{fromCwd:t,...e.fromEpicId?{fromEpicId:e.fromEpicId}:{},label:ba(t),title:`Proposed by another project: ${t}`+(e.fromEpicId?` (session ${e.fromEpicId})`:"")+(n!=null&&n.originAsk?` — raised while working on: ${n.originAsk}`:"")+". Verify the claim against this codebase before approving — the sender has not read it.",proposal:n,seriesLabel:r?`Part ${r.index} of ${r.total} · ${r.title}`:null}}const db=i=>Array.isArray(i)&&i.every(e=>typeof e=="string");function gw(i){if(!i||typeof i!="object")return null;const e=i;if(typeof e.motivation!="string"||!db(e.plan)||!db(e.acceptanceCriteria)||!db(e.outOfScope))return null;const t=e.series,n=t&&typeof t=="object"&&typeof t.key=="string"&&typeof t.title=="string"&&Number.isInteger(t.index)&&Number.isInteger(t.total)?{key:t.key,title:t.title,index:t.index,total:t.total}:null;return{motivation:e.motivation,originAsk:typeof e.originAsk=="string"&&e.originAsk?e.originAsk:null,plan:e.plan,acceptanceCriteria:e.acceptanceCriteria,outOfScope:e.outOfScope,series:n}}function I3(i,e){var r,l,p,a,d;const t=(p=(l=gw((r=i.source)==null?void 0:r.proposal))==null?void 0:l.series)==null?void 0:p.key;if(!t)return[];const n=[];for(const f of e){const m=(d=gw((a=f.source)==null?void 0:a.proposal))==null?void 0:d.series;m&&m.key===t&&n.push({id:f.id,index:m.index,status:f.status,goalText:f.goalText})}return n.sort((f,m)=>f.index-m.index)}const Sy={running:{bg:"bg-accent/15",text:"text-accent",dot:"bg-accent",label:"running"},needs:{bg:"bg-delta-bad/15",text:"text-delta-bad",dot:"bg-delta-bad",label:"needs you"},refuted:{bg:"bg-accent/15",text:"text-accent",dot:"bg-accent",label:"refuted — claimed done, not delivered"},failed:{bg:"bg-accent/15",text:"text-accent",dot:"bg-accent",label:"failed"},attention:{bg:"bg-butter/25",text:"text-fg-dim",dot:"bg-butter",label:"needs review"},queued:{bg:"bg-muteband/60",text:"text-fg-dim",dot:"bg-muteband",label:"queued"},active:{bg:"transparent",text:"text-fg-faint",dot:"bg-fg-faint",label:"active",ring:!0},proposed:{bg:"bg-butter/25",text:"text-fg-dim",dot:"bg-butter",label:"proposed",ring:!0},completed:{bg:"bg-sage/20",text:"text-sage",dot:"bg-sage",label:"completed"}};function zv(i){return Sy[i].dot}function AE(i){return Sy[i].label}function IE({status:i,small:e,detail:t}){const n=Sy[i];return c.jsxs("span",{role:"status",title:t,"aria-label":t?`Status: ${n.label} — ${t}`:`Status: ${n.label}`,className:`inline-flex items-center gap-1.5 shrink-0 rounded-full font-semibold tracking-wide whitespace-nowrap ${e?"px-2 py-0.5 text-[10.5px]":"px-2.5 py-1 text-xs"} ${n.bg} ${n.text}${n.ring?" ring-1 ring-inset ring-line":""}`,children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${n.dot}`,"aria-hidden":"true"}),n.label]})}const vw={feature:{text:"text-sage",ring:"ring-sage/40",label:"FEATURE"},bug:{text:"text-accent-dark",ring:"ring-accent-dark/40",label:"BUG"},discussion:{text:"text-fg-faint",ring:"ring-fg-faint/40",label:"DISCUSSION"},build:{text:"text-hive-teal",ring:"ring-hive-teal/40",label:"BUILD"},"project-home-builder":{text:"text-honey-dark",ring:"ring-honey/40",label:"PROJECT HOME BUILDER"},art:{text:"text-honey-dark",ring:"ring-honey/40",label:"3D ART"},portfolio:{text:"text-fg-dim",ring:"ring-butter/40",label:"PORTFOLIO"}},P3={feature:"bg-sage",bug:"bg-accent-dark",discussion:"bg-fg-faint",build:"bg-hive-teal","project-home-builder":"bg-honey",art:"bg-butter",portfolio:"bg-butter"};function j3(i){return P3[i]}function R3(i){return vw[i].label.charAt(0)+vw[i].label.slice(1).toLowerCase()}function Cy({kind:i,small:e}){if(!i)return null;const t=vw[i];return c.jsx("span",{className:`inline-flex items-center font-mono font-semibold uppercase tracking-wide rounded ring-1 ring-inset whitespace-nowrap ${e?"px-1.5 py-0.5 text-[9.5px]":"px-[7px] py-[3px] text-[10.5px]"} ${t.text} ${t.ring}`,children:t.label})}function _w({origin:i,small:e}){return i?c.jsxs("span",{title:i.title,"data-testid":"epic-inbound-tag",className:`inline-flex items-center gap-1 font-mono font-semibold uppercase tracking-wide rounded ring-1 ring-inset whitespace-nowrap max-w-[10rem] ${e?"px-1.5 py-0.5 text-[9.5px]":"px-[7px] py-[3px] text-[10.5px]"} text-amber-300 ring-amber-400/40`,children:[c.jsx("span",{"aria-hidden":"true",children:"↘"}),c.jsx("span",{className:"truncate",children:i.label})]}):null}const HS="font-mono text-[10.5px] font-semibold uppercase tracking-wide text-fg-dim",nv="text-[12.5px] leading-relaxed text-fg-dim";function N3({epic:i,siblings:e}){var a,d;const t=r_(i);if(!t)return null;const n=t.proposal,r=c.jsxs("div",{"data-testid":"inbound-proposal-from",className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[c.jsx("span",{className:HS,children:"From"}),c.jsxs("span",{title:t.fromCwd,className:"font-mono text-[12px] font-semibold text-amber-300",children:["↘ ",t.label]}),n!=null&&n.originAsk?c.jsxs("span",{className:"text-[12px] text-fg-faint",children:["raised while working on ",n.originAsk]}):null]}),l="mb-3 max-w-[760px] space-y-2.5 rounded-md border border-line bg-bg-hi px-3.5 py-3";if(!n){const m=((d=(a=i.sections)==null?void 0:a.find(g=>g.kind==="goal"))==null?void 0:d.text)||i.openingPrompt||i.goalText;return c.jsxs("section",{"data-testid":"inbound-proposal-card",className:l,children:[r,c.jsx("div",{"data-testid":"inbound-proposal-report",className:"max-h-[50vh] overflow-y-auto whitespace-pre-wrap text-[12px] leading-relaxed text-fg-dim",children:m})]})}const p=(f,m,g)=>c.jsxs("div",{"data-testid":f,children:[c.jsx("div",{className:`mb-1 ${HS}`,children:m}),g]});return c.jsxs("section",{"data-testid":"inbound-proposal-card",className:l,children:[r,t.seriesLabel?c.jsx("span",{"data-testid":"inbound-proposal-series",className:"inline-flex items-center rounded ring-1 ring-inset ring-amber-400/40 px-[7px] py-[3px] font-mono text-[10.5px] font-semibold uppercase tracking-wide text-amber-300",children:t.seriesLabel}):null,e.length>1?c.jsx("ul",{"data-testid":"inbound-proposal-siblings",className:"space-y-0.5 text-[12px] text-fg-faint",children:e.map(f=>{var m;return c.jsxs("li",{"aria-current":f.id===i.id?"true":void 0,className:f.id===i.id?"font-semibold text-fg-dim":void 0,children:[`${f.index}/${((m=n.series)==null?void 0:m.total)??e.length} ${f.goalText} ${f.status}`,f.id===i.id?" ← this":""]},f.id)})}):null,c.jsxs("div",{className:"max-h-[50vh] space-y-2.5 overflow-y-auto",children:[p("inbound-proposal-why","Why",c.jsx("p",{className:nv,children:n.motivation})),p("inbound-proposal-plan","Proposed plan",c.jsx("ol",{className:`list-decimal space-y-0.5 pl-5 ${nv}`,children:n.plan.map((f,m)=>c.jsx("li",{children:f},m))})),p("inbound-proposal-criteria","Acceptance criteria",c.jsx("ul",{className:`list-disc space-y-0.5 pl-5 ${nv}`,children:n.acceptanceCriteria.map((f,m)=>c.jsx("li",{children:f},m))})),n.outOfScope.length>0?p("inbound-proposal-out-of-scope","Out of scope",c.jsx("ul",{className:`list-disc space-y-0.5 pl-5 ${nv}`,children:n.outOfScope.map((f,m)=>c.jsx("li",{children:f},m))})):null]})]})}const PE={active:{bg:"transparent",text:"text-fg-faint",dot:"bg-fg-faint",label:"isolated"},needs_merge_resolution:{bg:"bg-delta-bad/15",text:"text-delta-bad",dot:"bg-delta-bad",label:"merge conflict"},merged:{bg:"bg-sage/20",text:"text-sage",dot:"bg-sage",label:"merged"},disabled:{bg:"bg-muteband/60",text:"text-fg-dim",dot:"bg-muteband",label:"isolation disabled"}};function M3({worktree:i,small:e}){const t=e?"px-2 py-0.5 text-[10.5px]":"px-2.5 py-1 text-xs";if(!i)return c.jsx("span",{title:"This session runs directly in the project's shared working tree — no isolated git worktree.","data-testid":"epic-worktree-chip",className:`inline-flex items-center gap-1.5 shrink-0 rounded-full font-semibold tracking-wide whitespace-nowrap ring-1 ring-inset ring-line text-fg-faint ${t}`,children:"shared tree"});const n=PE[i.status],r=i.status==="active"?`isolated · ${i.branch}`:n.label,l=i.status==="needs_merge_resolution"&&i.conflictReason?i.conflictReason:i.status==="active"||i.status==="needs_merge_resolution"?`${i.branch} · ${i.dir}`:n.label;return c.jsxs("span",{title:l,"data-testid":"epic-worktree-chip",className:`inline-flex items-center gap-1.5 shrink-0 rounded-full font-semibold tracking-wide whitespace-nowrap ${t} ${n.bg} ${n.text}`,children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${n.dot}`,"aria-hidden":"true"}),r]})}const O3=["feature","bug","discussion"];function WS(i){const e=((i==null?void 0:i.tags)??[]).filter(t=>xy.includes(t));return e.length?e:O3}const US=["#b85c34","#a3441f","#6f7d52","#8a7a60","#7a6a8a","#5f7a7d","#c96442","#4f7d72"];function jE(i){let e=0;for(let t=0;t<i.length;t+=1)e=e*31+i.charCodeAt(t)>>>0;return US[e%US.length]}const VS=["Engineering","Product","Design","Quality","Platform","Growth"];function L3(i){var r,l;const e=new Map;for(const p of i){const a=((l=(r=p.title)==null?void 0:r.split(" — ")[0])==null?void 0:l.trim())||"Other";e.has(a)||e.set(a,[]),e.get(a).push(p)}const t=VS.filter(p=>e.has(p)).map(p=>({department:p,agents:e.get(p)})),n=[...e.keys()].filter(p=>!VS.includes(p)).sort().map(p=>({department:p,agents:e.get(p)}));return[...t,...n]}function qS(i){var e;return((e=i.title)==null?void 0:e.split(" — ")[1])||i.description||null}function RE({agents:i,value:e,onChange:t}){const n=i.find(l=>l.name===e)??i[0]??null,r=L3(i);return c.jsxs("div",{"data-testid":"new-epic-agent-picker",className:"relative focus-within:ring-1 focus-within:ring-accent-muted",children:[c.jsxs("div",{className:"flex h-[42px] min-w-0 items-center gap-2.5 rounded-[10px] border border-line bg-bg px-3.5",children:[n?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"h-2 w-2 flex-shrink-0 rounded-full",style:{background:jE(n.name)}}),c.jsx("span",{className:"font-mono text-[13px] font-semibold text-fg",children:n.name}),c.jsx("span",{className:"min-w-0 flex-1 truncate text-[12.5px] text-fg-faint",children:qS(n)})]}):c.jsx("span",{className:"min-w-0 flex-1 truncate text-[12.5px] text-fg-faint",children:"No agents in library"}),c.jsx("span",{className:"flex-shrink-0 text-[11px] text-fg-faint",children:"▾"})]}),c.jsx("select",{"data-testid":"new-epic-agent-select","aria-label":"Agent",className:"absolute inset-0 h-full w-full cursor-pointer opacity-0",value:(n==null?void 0:n.name)??"",disabled:i.length===0,onChange:l=>t(l.target.value),children:r.map(({department:l,agents:p})=>c.jsx("optgroup",{label:l,children:p.map(a=>{const d=qS(a);return c.jsx("option",{value:a.name,"data-testid":`new-epic-agent-${a.name}`,"data-selected":a.name===(n==null?void 0:n.name)?"true":"false",children:d?`${a.name} — ${d}`:a.name},a.name)})},l))})]})}const z3=60,B3=8e3,$f="w-full rounded-md border border-line bg-bg px-2 py-1 text-[12px] text-fg placeholder:text-fg-faint focus:outline-none focus:border-accent",KS=/^[a-z][a-z0-9_]{0,31}$/,Af="font-mono text-[10px] font-semibold tracking-[1px] uppercase text-fg-faint";function G3({cwd:i,agents:e,macro:t,latest:n,onClose:r}){var W,Q;const[l,p]=z.useState((t==null?void 0:t.label)??""),[a,d]=z.useState((t==null?void 0:t.agentName)??((W=e[0])==null?void 0:W.name)??""),[f,m]=z.useState((t==null?void 0:t.tag)??""),[g,y]=z.useState((t==null?void 0:t.prompt)??""),D=t?t.projects.includes("*"):!1,[E,C]=z.useState(D),[b,w]=z.useState((t==null?void 0:t.inputs)??[]),[x,S]=z.useState(!1),[T,j]=z.useState(null);z.useEffect(()=>{!a&&e[0]&&d(e[0].name)},[e,a]);const N=e.find(oe=>oe.name===a)??null,L=e.length>0&&a!==""&&!N;let R=WS(N);!N&&f&&!R.includes(f)&&(R=[f,...R]);const F=f&&R.includes(f)?f:R[0],V=oe=>{d(oe);const Ce=WS(e.find(Oe=>Oe.name===oe)??null);Ce.includes(F)||m(Ce[0])};z.useEffect(()=>{const oe=Ce=>{Ce.key==="Escape"&&r()};return document.addEventListener("keydown",oe),()=>document.removeEventListener("keydown",oe)},[r]);const te=l.trim(),he=g.trim(),ee=(((Q=t==null?void 0:t.inputs)==null?void 0:Q.length)??0)>0,we=Nk(g),ce=new Set(b.map(oe=>oe.name)),Ee=we.filter(oe=>!ce.has(oe)).length===0&&b.every(oe=>KS.test(oe.name))&&ce.size===b.length,fe=te.length>0&&he.length>0&&a!==""&&Ee,U=(oe,Ce)=>w(Oe=>Oe.map((Xe,ge)=>ge===oe?{...Xe,...Ce}:Xe)),X=async()=>{if(!(!fe||x)){S(!0),j(null);try{let oe;const Ce=n??t;Ce?E===D?oe=Ce.projects:E?oe=["*"]:oe=Ce.projects.includes("*")?[i]:Ce.projects:oe=E?["*"]:[i],await window.api.macros.save({...t?{id:t.id}:{},label:te,agentName:a,tag:F,prompt:he,projects:oe,...ee||b.length>0?{inputs:b.map(Oe=>({...Oe,label:Oe.label.trim()||Oe.name,required:Oe.required===!0,...Oe.default?{default:Oe.default}:{}}))}:{}}),Qe.info(t?`Macro "${te}" updated`:`Macro "${te}" saved`),r()}catch(oe){j(oe instanceof Error?oe.message:String(oe))}finally{S(!1)}}};return c.jsxs("form",{"data-testid":"macro-editor",className:"flex flex-col gap-2 rounded-lg border border-line bg-bg-hi p-2.5",onSubmit:oe=>{oe.preventDefault(),X()},children:[c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:Af,htmlFor:"macro-label",children:"Label"}),c.jsx("input",{id:"macro-label","data-testid":"macro-label",className:$f,value:l,maxLength:z3,placeholder:"e.g. Sweep",onChange:oe=>p(oe.target.value),autoFocus:!0})]}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("span",{className:Af,children:"Agent"}),c.jsx(RE,{agents:e,value:a,onChange:V}),L&&c.jsxs("div",{role:"alert","data-testid":"macro-agent-missing",className:"text-[11.5px] text-amber-500",children:["agent ",a," not found"]})]}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("span",{className:Af,children:"Tag"}),c.jsx("div",{className:"flex flex-wrap gap-1",role:"group","aria-label":"Tag",children:R.map(oe=>c.jsx("button",{type:"button","data-testid":"macro-tag","data-tag":oe,"aria-pressed":oe===F,onClick:()=>m(oe),className:`rounded-md border px-2 py-0.5 text-[11px] font-semibold transition-colors ${oe===F?"bg-accent text-white border-transparent":"bg-bg text-fg-dim border-line hover:text-fg"}`,children:_v(oe).label},oe))})]}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:Af,htmlFor:"macro-prompt",children:"Initial prompt"}),c.jsx("textarea",{id:"macro-prompt","data-testid":"macro-prompt",className:`${$f} min-h-[88px] resize-y`,value:g,maxLength:B3,placeholder:"What should the new session do first?",onChange:oe=>y(oe.target.value)})]}),we.length>0&&c.jsx("div",{"data-testid":"macro-placeholders",className:"flex flex-wrap gap-1 text-[11px] text-fg-dim",children:we.map(oe=>ce.has(oe)?c.jsx("code",{children:`{{${oe}}}`},oe):c.jsxs("code",{"data-testid":"macro-undeclared-placeholder",className:"text-amber-500",children:[`{{${oe}}}`," (no input)"]},oe))}),c.jsxs("div",{"data-testid":"macro-inputs",className:"flex flex-col gap-1",children:[c.jsx("span",{className:Af,children:"Inputs"}),b.map((oe,Ce)=>c.jsxs("div",{"data-testid":"macro-input-row",className:"flex flex-col gap-1 rounded-md border border-line p-1.5",children:[c.jsx("input",{"data-testid":"macro-input-name",className:$f,value:oe.name,placeholder:"name (e.g. stream)","aria-invalid":!KS.test(oe.name),onChange:Oe=>U(Ce,{name:Oe.target.value})}),c.jsx("input",{"data-testid":"macro-input-label",className:$f,value:oe.label,placeholder:"label",onChange:Oe=>U(Ce,{label:Oe.target.value})}),c.jsx("input",{"data-testid":"macro-input-default",className:$f,value:oe.default??"",placeholder:"default",onChange:Oe=>U(Ce,{default:Oe.target.value})}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("label",{className:"flex items-center gap-1.5 text-[11.5px] text-fg-dim",children:[c.jsx("input",{type:"checkbox","data-testid":"macro-input-required",checked:oe.required===!0,onChange:Oe=>U(Ce,{required:Oe.target.checked})}),"Required"]}),c.jsx("button",{type:"button","data-testid":"macro-input-remove",onClick:()=>w(Oe=>Oe.filter((Xe,ge)=>ge!==Ce)),className:"text-[11.5px] font-semibold text-fg-dim hover:text-fg",children:"Remove"})]})]},Ce)),c.jsx("button",{type:"button","data-testid":"macro-input-add",onClick:()=>w(oe=>[...oe,{name:"",label:""}]),className:"self-start rounded-md border border-line bg-bg px-2 py-0.5 text-[11.5px] font-semibold text-fg-dim hover:text-fg",children:"Add input"})]}),c.jsxs("label",{className:"flex items-center gap-1.5 text-[11.5px] text-fg-dim",children:[c.jsx("input",{type:"checkbox","data-testid":"macro-everywhere",checked:E,onChange:oe=>C(oe.target.checked)}),"Show in every project"]}),T&&c.jsx("div",{role:"alert","data-testid":"macro-error",className:"text-[11.5px] text-red-500",children:T}),c.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[c.jsx("button",{type:"button","data-testid":"macro-cancel",onClick:r,className:"rounded-md border border-line bg-bg px-2.5 py-1 text-[11.5px] font-semibold text-fg-dim hover:text-fg",children:"Cancel"}),c.jsx("button",{type:"submit","data-testid":"macro-save",disabled:!fe||x,className:"rounded-md border border-transparent bg-accent px-2.5 py-1 text-[11.5px] font-semibold text-white shadow-sm disabled:opacity-40 disabled:cursor-not-allowed",children:x?"Saving…":"Save"})]})]})}const YS="rounded-md border border-line bg-bg px-2 py-1 text-[12px] text-fg outline-none focus:border-accent";function F3({macro:i,onSubmit:e,onCancel:t}){const n=i.inputs??[],[r,l]=z.useState(()=>Mk(n)),[p,a]=z.useState(null);return c.jsxs("form",{"data-testid":"macro-inputs-form",noValidate:!0,className:"flex flex-col gap-2 rounded-lg border border-line bg-bg-hi p-2.5",onSubmit:d=>{d.preventDefault();const f=Ok(i.prompt,n,r);if(!f.ok){a(f.error);return}a(null),e(r)},onKeyDown:d=>{d.key==="Escape"&&(d.stopPropagation(),t())},children:[c.jsx("div",{className:"text-[11.5px] font-semibold text-fg",children:i.label}),n.map((d,f)=>c.jsxs("label",{className:"flex flex-col gap-1 text-[11.5px] text-fg-dim",children:[c.jsxs("span",{children:[d.label,d.required&&c.jsx("span",{className:"text-red-500",title:"Required",children:" *"})]}),d.options&&d.options.length>0?c.jsxs("select",{"data-testid":`macro-input-${d.name}`,className:YS,value:r[d.name]??"",autoFocus:f===0,onChange:m=>l(g=>({...g,[d.name]:m.target.value})),children:[!d.required&&c.jsx("option",{value:""}),d.options.map(m=>c.jsx("option",{value:m,children:m},m))]}):c.jsx("input",{type:"text","data-testid":`macro-input-${d.name}`,className:YS,value:r[d.name]??"",maxLength:rw,required:d.required,autoFocus:f===0,onChange:m=>l(g=>({...g,[d.name]:m.target.value}))})]},d.name)),p&&c.jsx("div",{"data-testid":"macro-inputs-error",role:"alert",className:"text-[11.5px] text-red-500",children:p}),c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("button",{type:"submit","data-testid":"macro-inputs-start",className:"inline-flex items-center rounded-md border border-transparent bg-accent px-2.5 py-1 text-[11.5px] font-semibold text-white",children:"Start"}),c.jsx("button",{type:"button","data-testid":"macro-inputs-cancel",onClick:t,className:"inline-flex items-center rounded-md border border-line bg-bg px-2.5 py-1 text-[11.5px] font-semibold text-fg-dim hover:text-fg",children:"Cancel"})]})]})}const NE="inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11.5px] font-semibold border transition-colors disabled:opacity-40 disabled:cursor-not-allowed",ub=`${NE} bg-bg-hi text-fg-dim border-line hover:text-fg`;function H3(i){const e=i.prompt.split(`
|
|
3044
3044
|
`).find(t=>t.trim())??"";return`Start a new ${i.tag} session as "${i.agentName}": ${e.trim()}`}function W3({macros:i,cwd:e,onEdit:t}){const[n,r]=z.useState(null),l=e?Er(e):null,p=async(d,f)=>{if(e)try{const m=await window.api.macros.setProject({id:d.id,cwd:e,enabled:f});m.ok||Qe.error(m.error)}catch(m){Qe.error(m instanceof Error?m.message:String(m))}},a=async d=>{r(null);try{await window.api.macros.delete({id:d.id})}catch(f){Qe.error(f instanceof Error?f.message:String(f))}};return c.jsx("div",{"data-testid":"hotkey-manage-panel",className:"flex flex-col gap-1 rounded-lg border border-line bg-bg-hi p-2",children:i.map(d=>{const f=d.projects.includes("*"),m=f||l!==null&&d.projects.some(g=>Er(g)===l);return c.jsxs("div",{"data-testid":"hotkey-manage-row","data-macro-id":d.id,className:"flex items-center gap-1.5 text-[11.5px]",children:[c.jsxs("label",{className:"flex min-w-0 flex-1 items-center gap-1.5 text-fg-dim",title:f?"Shown in every project":"Shown in this project",children:[c.jsx("input",{type:"checkbox","data-testid":"hotkey-manage-toggle",checked:m,disabled:f||!e,onChange:g=>void p(d,g.target.checked),"aria-label":`Show ${d.label} in this project`}),c.jsx("span",{className:"truncate text-fg",children:d.label}),f&&c.jsx("span",{className:"shrink-0 text-[10px] text-fg-faint",children:"every project"})]}),n===d.id?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-fg-dim",children:"Delete?"}),c.jsx("button",{type:"button","data-testid":"hotkey-delete-yes",onClick:()=>void a(d),className:"font-semibold text-red-500",children:"Yes"}),c.jsx("button",{type:"button","data-testid":"hotkey-delete-no",onClick:()=>r(null),className:"text-fg-dim hover:text-fg",children:"No"})]}):c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button","data-testid":"hotkey-edit",onClick:()=>t(d),className:"text-fg-dim hover:text-fg",children:"Edit"}),c.jsx("button",{type:"button","data-testid":"hotkey-delete",onClick:()=>r(d.id),className:"text-fg-dim hover:text-red-500",children:"Delete"})]})]},d.id)})})}function U3({onNew:i,onSelect:e}){var E;const t=Pk(),{launch:n,launching:r,cwd:l}=Lk(e,t),p=Ik(),a=Ak(p,l),[d,f]=z.useState(null),[m,g]=z.useState(!1),[y,D]=z.useState(null);return c.jsxs("div",{className:"flex flex-col gap-2","data-testid":"session-actions-bar",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[c.jsx("button",{type:"button",onClick:i,"data-testid":"epic-queue-new",className:`${NE} bg-accent text-white border-transparent shadow-sm`,children:"+ New Session"}),a.map(C=>c.jsx("button",{type:"button",onClick:()=>C.inputs&&C.inputs.length>0?D(C):void n(C),disabled:r!==null,title:H3(C),"data-testid":"hotkey-macro","data-macro-id":C.id,className:ub,children:r===C.id?"Starting…":C.label},C.id)),c.jsx("button",{type:"button",onClick:()=>f({macro:null}),disabled:!l,title:l?"Create a hot key that starts a session with a saved agent, tag and prompt":"Open a project tab to create a macro","data-testid":"hotkey-new-macro",className:ub,children:"New Macro"}),p.length>0&&c.jsx("button",{type:"button",onClick:()=>g(C=>!C),"aria-label":"Manage hot keys","aria-expanded":m,title:"Manage hot keys","data-testid":"hotkey-manage",className:`${ub} px-2`,children:"⋯"})]}),y&&c.jsx(F3,{macro:y,onCancel:()=>D(null),onSubmit:C=>{const b=y;D(null),n(b,void 0,C)}},y.id),m&&p.length>0&&c.jsx(W3,{macros:p,cwd:l,onEdit:C=>{f({macro:C})}}),d&&l&&c.jsx(G3,{cwd:l,agents:t,macro:d.macro,latest:d.macro?p.find(C=>C.id===d.macro.id)??null:null,onClose:()=>f(null)},((E=d.macro)==null?void 0:E.id)??"new")]})}const V3=["proposed","failed","attention","running","needs","queued","active","completed"];function q3({open:i}){return c.jsx("svg",{viewBox:"0 0 16 16",width:11,height:11,"aria-hidden":"true",className:`shrink-0 text-fg-faint transition-transform duration-100 ${i?"rotate-90":""}`,children:c.jsx("path",{d:"M5 3l6 5-6 5",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})})}function bv({filled:i}){return c.jsx("svg",{viewBox:"0 0 16 16",width:11,height:11,"aria-hidden":"true",fill:i?"currentColor":"none",children:c.jsx("path",{d:"M8 2l1.5 3.2L13 6l-2.5 2.4L11 12l-3-1.8L5 12l.5-3.6L3 6l3.5-.8L8 2z",stroke:"currentColor",strokeWidth:1.2,strokeLinejoin:"round"})})}function K3(){return c.jsxs("svg",{viewBox:"0 0 16 16",width:13,height:13,"aria-hidden":"true",fill:"currentColor",children:[c.jsx("circle",{cx:"3.5",cy:"8",r:"1.4"}),c.jsx("circle",{cx:"8",cy:"8",r:"1.4"}),c.jsx("circle",{cx:"12.5",cy:"8",r:"1.4"})]})}const Y3=3e3;function X3({anchor:i,items:e,onClose:t}){const n=z.useRef(null),[r,l]=z.useState(null),[p,a]=z.useState(null),d=z.useRef(null);return z.useLayoutEffect(()=>{const f=n.current;if(!f)return;const m=i.getBoundingClientRect(),g=f.offsetHeight,y=f.offsetWidth,D=8,E=window.innerHeight-m.bottom-D,C=m.top-D,b=E<g&&C>E;l({left:Math.max(D,Math.min(m.right-y,window.innerWidth-y-D)),top:b?Math.max(D,m.top-2-g):m.bottom+2})},[i]),z.useEffect(()=>{const f=g=>{n.current&&!n.current.contains(g.target)&&!i.contains(g.target)&&t()},m=g=>{g.key==="Escape"&&t()};return document.addEventListener("mousedown",f),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",m),d.current&&clearTimeout(d.current)}},[i,t]),c.jsx("div",{ref:n,"data-testid":"epic-queue-row-menu",className:`fixed ${dn.contextMenu} min-w-[180px] grid gap-0.5 rounded-lg border border-rule bg-bg-elev p-1 shadow-lg`,style:{left:(r==null?void 0:r.left)??-9999,top:(r==null?void 0:r.top)??-9999,visibility:r?"visible":"hidden"},children:e.map(f=>{const m=!!f.confirm&&p===f.label;return c.jsx("button",{type:"button",onClick:g=>{if(g.stopPropagation(),!f.disabled){if(f.confirm&&!m){a(f.label),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>a(null),Y3);return}d.current&&clearTimeout(d.current),t(),f.onSelect()}},disabled:f.disabled,title:f.title,"data-testid":m?"epic-queue-row-menu-confirm":f.testId,className:`rounded-md px-2.5 py-1.5 text-left text-[12.5px] font-medium hover:bg-bg-hi disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent ${f.danger?"text-delta-bad":"text-fg"}`,children:m?f.confirmLabel??"Click again to confirm…":f.label},f.label)})})}function J3({epic:i,onCancel:e}){const t=z.useMemo(()=>bd(i.goalText),[i.goalText]),[n,r]=z.useState(t.title),[l,p]=z.useState(!1),a=z.useRef(null),d=z.useRef(!0);z.useEffect(()=>()=>{d.current=!1},[]),z.useEffect(()=>{var y;(y=a.current)==null||y.focus()},[]);const f=n.trim()!==t.title.trim(),m=n.trim().length>0&&f&&!l,g=async()=>{if(m){p(!0);try{await ri.getState().renameEpic(i.id,n,t.goal),d.current&&e()}catch(y){Qe.error(y instanceof Error?y.message:String(y)),d.current&&p(!1)}}};return c.jsxs("div",{"data-testid":"epic-queue-row-editor",onClick:y=>y.stopPropagation(),onKeyDown:y=>{y.key==="Escape"?(y.stopPropagation(),e()):(y.metaKey||y.ctrlKey)&&y.key==="Enter"&&(y.stopPropagation(),g())},className:"rounded-lg border border-line bg-bg p-2.5 grid gap-1.5",children:[c.jsx("input",{ref:a,type:"text",value:n,onChange:y=>r(y.target.value),placeholder:"Title","data-testid":"epic-queue-row-editor-title",className:"w-full rounded-md border border-rule bg-bg-elev px-2 py-1 text-[12.5px] font-semibold text-fg outline-none focus:border-accent"}),c.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[c.jsx("button",{type:"button",onClick:e,disabled:l,"data-testid":"epic-queue-row-editor-cancel",className:"rounded-md px-2.5 py-1 text-[11.5px] font-semibold text-fg-faint hover:text-fg disabled:opacity-40",children:"Cancel"}),c.jsx("button",{type:"button",onClick:()=>void g(),disabled:!m,"data-testid":"epic-queue-row-editor-save",className:"rounded-md bg-accent px-2.5 py-1 text-[11.5px] font-semibold text-white disabled:opacity-40",children:"Save"})]})]})}function Z3(i,e,t,n){var a;const r=((a=t[i])==null?void 0:a.slice(-1)[0])??null,l=(r==null?void 0:r.at)??e.createdAt,p=Date.parse(l);return Number.isNaN(p)?"":tr(p,n)}function Q3(i,e,t,n){const r=[{label:"Copy session ID",onSelect:()=>{Ca(i.id).then(l=>{l?Qe.info("Session id copied"):Qe.error("Copy failed")})}},{label:"Rename title",onSelect:()=>n()}];return i.status==="active"&&(r.push({label:"Resume in terminal",onSelect:()=>{t(i.id),cl.getState().setMode(i.id,"terminal")}}),e!=="completed"&&r.push({label:"Mark completed",onSelect:()=>{ri.getState().markCompleted(i.id,"EpicQueue row menu").catch(()=>{})}})),i.status==="completed"&&r.push({label:"Reopen",onSelect:()=>{ri.getState().resumeArchived(i.id,"EpicQueue row menu").catch(l=>{Qe.error(l instanceof Error?l.message:String(l))})}}),r.push({label:"Duplicate as new session",onSelect:()=>{ri.getState().duplicateEpic(i.id,"EpicQueue row menu").then(l=>t(l.id)).catch(l=>{Qe.error(l instanceof Error?l.message:String(l))})}}),r.push({label:"Delete session",danger:!0,confirm:!0,confirmLabel:"Click again to delete…",onSelect:()=>{ri.getState().deleteEpic(i.id,"EpicQueue row menu").catch(l=>Qe.error(l instanceof Error?l.message:String(l)))}}),r}function XS({epic:i,status:e,onSelect:t,onEdit:n,className:r}){const[l,p]=z.useState(!1),a=z.useRef(null),d=Q3(i,e,t,n);return c.jsxs(c.Fragment,{children:[c.jsx("button",{ref:a,type:"button",onClick:f=>{f.stopPropagation(),p(m=>!m)},title:"Session actions","aria-label":`Actions for ${bd(i.goalText).title}`,"data-testid":"epic-queue-row-menu-trigger",className:r,children:c.jsx(K3,{})}),l&&a.current&&c.jsx(X3,{anchor:a.current,items:d,onClose:()=>p(!1)})]})}function JS({epic:i,snapshots:e,events:t,status:n,selected:r,compact:l,now:p,onSelect:a,pinned:d=!1,onPin:f}){const[m,g]=z.useState(!1),y=Z3(i.id,i,t,p),{title:D}=bd(i.goalText),E=r_(i),C=n==="queued"||n==="failed"||n==="attention"?i2(i.id,e):void 0;if(m)return c.jsx(J3,{epic:i,onCancel:()=>g(!1)});if(l)return c.jsxs("div",{className:"relative",children:[c.jsxs("button",{type:"button",onClick:()=>a(i.id),"data-testid":"epic-queue-row","data-epic-id":i.id,title:C,className:`w-full grid grid-cols-[8px_minmax(0,1fr)_auto] items-center gap-2 rounded-md py-1.5 px-2 text-left border-l-2 ${r?"bg-bg-hi border-l-accent":"border-l-transparent hover:bg-bg-hi/60"} ${f?"pr-12":"pr-6"}`,children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${zv(n)} ${n==="completed"?"opacity-45":""}`,"aria-hidden":"true"}),c.jsxs("span",{className:"min-w-0 flex items-center gap-1.5",children:[d&&c.jsx("span",{className:"text-accent shrink-0","aria-hidden":"true",children:c.jsx(bv,{filled:!0})}),c.jsx("span",{className:`min-w-0 truncate text-[12.5px] ${r?"font-semibold text-fg":"text-fg-dim"}`,children:D}),c.jsx(_w,{origin:E,small:!0})]}),c.jsx("span",{className:"font-mono text-[10px] text-fg-faint shrink-0",children:y})]}),f&&c.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),f(i.id)},title:d?"Unpin":"Pin to top","aria-label":d?`Unpin ${D}`:`Pin ${D} to top`,"data-testid":"epic-queue-row-pin",className:`absolute top-1/2 -translate-y-1/2 right-6 p-0.5 ${d?"text-accent":"text-fg-faint opacity-40 hover:opacity-100"}`,children:c.jsx(bv,{filled:d})}),c.jsx(XS,{epic:i,status:n,onSelect:a,onEdit:()=>g(!0),className:"absolute top-1/2 -translate-y-1/2 right-1 p-0.5 text-fg-faint opacity-60 hover:opacity-100 hover:text-fg"})]});const b=Nw(i.id,e),w=Mw(i.id,e);return c.jsxs("div",{className:"relative",children:[c.jsxs("button",{type:"button",onClick:()=>a(i.id),"data-testid":"epic-queue-row","data-epic-id":i.id,className:`relative w-full text-left rounded-lg p-2.5 grid gap-1.5 ${r?"bg-bg-hi shadow-sm ring-1 ring-line":"hover:bg-bg-hi/50"}`,children:[r&&c.jsx("span",{className:`absolute inset-y-0 left-0 w-[3px] rounded-l-lg ${zv(n)}`,"aria-hidden":"true"}),c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(IE,{status:n,small:!0,detail:C}),c.jsx(Cy,{kind:i.tag,small:!0}),c.jsx(_w,{origin:E,small:!0}),n!=="completed"&&c.jsx(M3,{worktree:i.worktree,small:!0}),c.jsx("span",{className:"ml-auto font-mono text-[10.5px] text-fg-faint pr-9",children:y})]}),c.jsx("span",{className:"text-[13px] font-semibold text-fg leading-snug line-clamp-1",title:D,children:D}),c.jsxs("span",{className:"flex items-center gap-3 font-mono text-[10.5px] text-fg-faint",children:[b.length>0&&c.jsxs("span",{children:[b.length," ",b.length===1?"PRD":"PRDs"]}),w!==null&&c.jsxs("span",{children:[w.turns," turns"]}),(w==null?void 0:w.tokens)&&c.jsxs("span",{children:[w.tokens," tok"]})]})]}),f&&c.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),f(i.id)},title:d?"Unpin":"Pin to top","aria-label":d?`Unpin ${D}`:`Pin ${D} to top`,"data-testid":"epic-queue-row-pin",className:`absolute top-2 right-7 p-0.5 ${d?"text-accent":"text-fg-faint opacity-40 hover:opacity-100"}`,children:c.jsx(bv,{filled:d})}),c.jsx(XS,{epic:i,status:n,onSelect:a,onEdit:()=>g(!0),className:"absolute top-2 right-2 p-0.5 text-fg-faint opacity-60 hover:opacity-100 hover:text-fg"})]})}function eL({epics:i,snapshots:e,events:t,selectedId:n,onSelect:r,onNew:l,compact:p=!1,now:a,sections:d,pinnedEpics:f=[],onPin:m,onShowMore:g,emptyState:y,closedKeys:D,onToggleSection:E,filters:C,footer:b}){const[w,x]=z.useState(()=>new Set(["completed"])),S=D??w,T=a??Date.now(),j=z.useMemo(()=>{const F=new Map;for(const V of i){const te=ac(V.id,e);F.has(te)||F.set(te,[]),F.get(te).push(V)}return V3.filter(V=>F.has(V)).map(V=>{const te=F.get(V);return{key:V,label:AE(V),dotClass:zv(V),items:te,total:te.length}})},[i,e]),N=d??j,L=F=>{if(E){E(F);return}x(V=>{const te=new Set(V);return te.has(F)?te.delete(F):te.add(F),te})},R=d?d.length===0&&f.length===0:i.length===0&&f.length===0;return c.jsxs("aside",{className:"w-[352px] h-full shrink-0 border-r border-line bg-bg-elev flex flex-col min-h-0",children:[c.jsxs("div",{className:"px-3.5 pt-3 pb-2.5 flex flex-col gap-2 border-b border-line","data-testid":"epic-queue-hotkeys",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"font-mono text-[10.5px] font-semibold tracking-[1.1px] uppercase text-fg-faint",children:"Hot keys"}),c.jsx("span",{className:"font-mono text-[10px] text-fg-faint",title:"Per project: hot keys are + New Session plus this project's Macros (macro library).",children:"per project"})]}),c.jsx(U3,{onNew:l,onSelect:r})]}),c.jsxs("div",{className:"flex-1 min-h-0 flex flex-col","data-testid":"epic-queue-widget",children:[C,c.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 px-2 py-1.5",children:R?c.jsx(Rv,{title:(y==null?void 0:y.title)??"No sessions yet",hint:(y==null?void 0:y.hint)??c.jsx("button",{type:"button",onClick:l,className:"mt-2 text-accent font-semibold text-xs",children:"+ New Session"})}):c.jsxs(c.Fragment,{children:[f.length>0&&c.jsxs("div",{className:"mb-2",children:[c.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-1.5 bg-bg-elev py-1.5 px-1.5",children:[c.jsx("span",{className:"text-accent","aria-hidden":"true",children:c.jsx(bv,{filled:!0})}),c.jsx("span",{className:"font-mono text-[10px] font-semibold tracking-[0.9px] uppercase text-fg-dim",children:"pinned"}),c.jsx("span",{className:"font-mono text-[10px] text-fg-faint",children:f.length})]}),c.jsx("div",{className:`grid ${p?"gap-px":"gap-1.5"}`,children:f.map(F=>c.jsx(JS,{epic:F,snapshots:e,events:t,status:ac(F.id,e),selected:F.id===n,compact:p,now:T,onSelect:r,pinned:!0,onPin:m},F.id))})]}),N.map(F=>{const V=S.has(F.key),te=F.total-F.items.length;return c.jsxs("div",{"data-section-key":F.key,className:"mb-1.5",children:[c.jsxs("button",{type:"button",onClick:()=>L(F.key),className:"sticky top-0 z-10 w-full flex items-center gap-1.5 bg-bg-elev py-1.5 px-1.5 text-left",children:[c.jsx(q3,{open:!V}),c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${F.dotClass}`,"aria-hidden":"true"}),c.jsx("span",{className:"font-mono text-[10px] font-semibold tracking-[0.9px] uppercase text-fg-dim",children:F.label}),c.jsx("span",{className:"font-mono text-[10px] text-fg-faint",children:F.total}),c.jsx("span",{className:"ml-auto h-px flex-1 bg-rule opacity-70"})]}),!V&&c.jsxs("div",{className:`grid ${p?"gap-px":"gap-1.5"}`,children:[F.items.map(he=>c.jsx(JS,{epic:he,snapshots:e,events:t,status:ac(he.id,e),selected:he.id===n,compact:p,now:T,onSelect:r,onPin:m},he.id)),te>0&&g&&c.jsxs("button",{type:"button",onClick:()=>g(F.key),"data-testid":"epic-queue-show-more",className:"text-left rounded-md border border-dashed border-rule px-2.5 py-1.5 my-0.5 text-[11.5px] font-semibold text-fg-faint",children:["Show ",Math.min(40,te)," more · ",te," hidden"]})]})]},F.key)})]})})]}),b]})}async function ME(i){var t;const e=new Set;if(typeof window>"u"||!((t=window.api)!=null&&t.config))return e;if(window.api.config.readJson)try{const n=await window.api.config.readJson(Vv(i));if(n.exists&&n.data&&typeof n.data=="object"){const r=n.data.sessions??{};for(const l of Object.keys(r))e.add(l)}}catch{}if(window.api.config.listDir)try{const n=`${i.replace(/\/+$/,"")}/session-manager-operations/prompt-sessions`,r=await window.api.config.listDir(n,{filesOnly:!0});if(r.ok)for(const l of r.entries)!l.name.endsWith(".json")||l.name==="active-index.json"||e.add(l.name.slice(0,-5))}catch{}return e}const ky="~/.claude/session-manager/epics-prefs.json";function hb(i){const e=i(),t={group:e.group,sort:e.sort,compact:e.compact};window.api.config.writeJson(ky,t).catch(()=>{})}async function tL(i){let e={};try{const r=await window.api.config.readJson(ky);r.exists&&r.data&&typeof r.data=="object"&&(e=r.data.pins??{})}catch{}const t=await ME(i),n={};for(const[r,l]of Object.entries(e))l&&t.has(r)&&(n[r]=l);return await xd(i,{epicPins:n}).catch(r=>{console.warn("migratePins: failed to seed ui-prefs epicPins",r)}),n}const il=jn((i,e)=>({pins:{},group:"status",sort:"recent",compact:!1,hydrated:!1,pinsCwd:null,hydrate:async t=>{if(!e().hydrated){try{const n=await window.api.config.readJson(ky);if(n.exists&&n.data&&typeof n.data=="object"){const r=n.data;i({group:r.group??"status",sort:r.sort??"recent",compact:r.compact??!1})}}catch{}i({hydrated:!0})}if(e().pinsCwd!==t){const n=await vm(t);if(n.epicPins)i({pins:n.epicPins,pinsCwd:t});else{const r=await tL(t);i({pins:r,pinsCwd:t})}}},togglePin:(t,n)=>{const r=e().pins,l={...r,[n]:!r[n]};i({pins:l}),xd(t,{epicPins:l}).catch(()=>{e().pins===l&&(i({pins:r}),Qe.error("Couldn't save pinned Epics — reverted."))})},setGroup:t=>{i({group:t}),hb(e)},setSort:t=>{i({sort:t}),hb(e)},setCompact:t=>{i({compact:t}),hb(e)}})),iL=[{value:"open",label:"Open"},{value:"needs",label:"Needs you"},{value:"running",label:"Running"},{value:"pinned",label:"Pinned"},{value:"all",label:"All"}],nL=[{value:"status",label:"status"},{value:"tag",label:"tag"},{value:"recency",label:"recency"}],sL=[{value:"recent",label:"last activity"},{value:"title",label:"title"},{value:"prdCount",label:"PRD count"},{value:"tokens",label:"tokens"},{value:"turns",label:"turns"}];function rL(i,e){if(i==="status"){const t=e;return{label:AE(t),dotClass:zv(t)}}if(i==="tag"){const t=e;return{label:R3(t),dotClass:j3(t)}}return{label:e,dotClass:"bg-fg-faint"}}function pb({label:i,value:e,onChange:t,options:n}){return c.jsxs("label",{className:"inline-flex items-center gap-1.5 bg-bg-hi border border-line rounded-md pl-2 pr-1 py-1",children:[c.jsx("span",{className:"font-mono text-[10px] uppercase tracking-wide text-fg-faint",children:i}),c.jsx("select",{value:e,onChange:r=>t(r.target.value),className:"bg-transparent outline-none cursor-pointer text-[11.5px] font-semibold text-fg pr-0.5",children:n.map(r=>c.jsx("option",{value:r.value,children:r.label},r.value))})]})}function oL(){return c.jsx("svg",{viewBox:"0 0 16 16",width:13,height:13,"aria-hidden":"true",children:c.jsx("path",{d:"M2 4h12M2 8h12M2 12h12",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",fill:"none"})})}function ZS(){return c.jsxs("svg",{viewBox:"0 0 16 16",width:13,height:13,"aria-hidden":"true",children:[c.jsx("circle",{cx:"7",cy:"7",r:"4.5",stroke:"currentColor",strokeWidth:1.4,fill:"none"}),c.jsx("path",{d:"M13 13l-2.3-2.3",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round"})]})}function aL(){return c.jsx("svg",{viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true",children:c.jsx("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round"})})}function lL(i){return i instanceof HTMLElement?["INPUT","TEXTAREA","SELECT"].includes(i.tagName)?!0:i.isContentEditable:!1}function cL(){return document.querySelector('[data-testid="command-palette-backdrop"]')!==null}function dL({cwd:i,epics:e,snapshots:t,events:n,selectedId:r,onSelect:l,onNew:p,now:a}){const[d,f]=z.useState(()=>Date.now());z.useEffect(()=>{const Pe=setInterval(()=>f(Date.now()),3e4);return()=>clearInterval(Pe)},[]);const m=a??d,[g,y]=z.useState(""),[D,E]=z.useState(!1),[C,b]=z.useState("open"),[w,x]=z.useState(()=>new Set(["completed"])),[S,T]=z.useState({}),j=il(Pe=>Pe.pins),N=il(Pe=>Pe.hydrate),L=il(Pe=>Pe.togglePin),R=il(Pe=>Pe.group),F=il(Pe=>Pe.setGroup),V=il(Pe=>Pe.sort),te=il(Pe=>Pe.setSort),he=il(Pe=>Pe.compact),ee=il(Pe=>Pe.setCompact);z.useEffect(()=>{N(i)},[i,N]);const we=Pe=>L(i,Pe),ce=z.useMemo(()=>new Set(Object.keys(j).filter(Pe=>j[Pe])),[j]),ve=z.useMemo(()=>S3(e,t,ce),[e,t,ce]),Ee=z.useMemo(()=>k3(e,t,C,ce,g),[e,t,C,ce,g]),fe=z.useMemo(()=>E3(Ee,V,t,n),[Ee,V,t,n]),U=z.useMemo(()=>fe.filter(Pe=>ce.has(Pe.id)),[fe,ce]),X=z.useMemo(()=>fe.filter(Pe=>!ce.has(Pe.id)),[fe,ce]),W=z.useMemo(()=>$3(X,R,t,n,m),[X,R,t,n,m]),Q=z.useMemo(()=>W.map(Pe=>{const Ye=S[Pe.key]??mw,{label:ft,dotClass:rt}=rL(R,Pe.key);return{key:Pe.key,label:ft,dotClass:rt,items:Pe.items.slice(0,Ye),total:Pe.items.length}}),[W,S,R]),oe=Pe=>{T(Ye=>({...Ye,[Pe]:(Ye[Pe]??mw)+w3}))},Ce=z.useMemo(()=>A3(U,Q,w,S),[U,Q,w,S]);z.useEffect(()=>{const Pe=Ye=>{if(lL(Ye.target)||cL()||Ye.key!=="j"&&Ye.key!=="k"&&Ye.key!=="ArrowDown"&&Ye.key!=="ArrowUp"||Ce.length===0)return;Ye.preventDefault();const ft=Ye.key==="j"||Ye.key==="ArrowDown"?1:-1,rt=Ce.findIndex(mi=>mi.id===r),Nt=Math.min(Ce.length-1,Math.max(0,rt<0?0:rt+ft)),mt=Ce[Nt];mt&&l(mt.id)};return window.addEventListener("keydown",Pe),()=>window.removeEventListener("keydown",Pe)},[Ce,r,l]);const Oe=()=>{y(""),b("all")},ge=e.length>0&&Q.length===0&&U.length===0?{title:g?`No sessions match "${g}".`:"No sessions match these filters.",hint:c.jsx("button",{type:"button",onClick:Oe,className:"mt-1.5 text-accent font-semibold text-xs",children:"Clear filters"})}:void 0,J=D||!!g,je=iL.map(Pe=>({value:Pe.value,label:`${Pe.label} ${Pe.value==="open"?ve.open:Pe.value==="needs"?ve.needs:Pe.value==="running"?ve.running:Pe.value==="pinned"?ve.pinned:ve.all}`})),de=c.jsxs("div",{className:"px-3 pb-2 pt-2 border-b border-line bg-bg-elev flex flex-col gap-1.5","data-testid":"epic-queue-filters",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"font-mono text-[10.5px] font-semibold tracking-[1.1px] uppercase text-fg-faint",children:"Sessions"}),c.jsx("span",{className:"font-mono text-[10.5px] text-fg-faint",children:e.length}),c.jsx("div",{className:"flex-1"}),c.jsx("button",{type:"button",onClick:()=>E(Pe=>!Pe),title:"Search sessions","aria-label":"Search sessions","aria-pressed":J,"data-testid":"epic-queue-search-toggle",className:`shrink-0 w-6 h-6 grid place-items-center rounded border ${J?"border-line bg-bg-hi text-accent":"border-transparent text-fg-faint hover:text-fg"}`,children:c.jsx(ZS,{})}),c.jsx("button",{type:"button",onClick:()=>ee(!he),title:he?"Comfortable rows":"Compact rows","aria-label":"Row density","aria-pressed":he,"data-testid":"epic-queue-density-toggle",className:`shrink-0 w-6 h-6 grid place-items-center rounded border ${he?"border-line bg-bg-hi text-accent":"border-transparent text-fg-faint hover:text-fg"}`,children:c.jsx(oL,{})})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[c.jsx(pb,{label:"show",value:C,onChange:b,options:je}),c.jsx(pb,{label:"group",value:R,onChange:F,options:nL}),c.jsx(pb,{label:"sort",value:V,onChange:te,options:sL})]}),J&&c.jsxs("div",{className:"relative",children:[c.jsx("span",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-faint pointer-events-none",children:c.jsx(ZS,{})}),c.jsx("input",{type:"text",value:g,autoFocus:!0,onChange:Pe=>y(Pe.target.value),placeholder:`Search ${e.length} sessions`,"aria-label":"Search sessions",className:"w-full bg-bg border border-line rounded-md py-1 pl-8 pr-7 text-[12.5px] text-fg outline-none focus:border-fg-faint"}),g&&c.jsx("button",{type:"button",onClick:()=>y(""),"aria-label":"Clear search",className:"absolute right-2 top-1/2 -translate-y-1/2 text-fg-faint hover:text-fg",children:c.jsx(aL,{})})]})]}),Ie=c.jsxs("div",{className:"border-t border-line px-3 py-1.5 flex items-center gap-2.5 bg-bg-elev",children:[c.jsxs("span",{className:"font-mono text-[10.5px] text-fg-faint",children:[fe.length," shown · ",ve.needs," need you"]}),c.jsx("span",{className:"ml-auto font-mono text-[10px] text-fg-faint",children:"j / k to move"})]});return c.jsx(eL,{epics:e,snapshots:t,events:n,selectedId:r,onSelect:l,onNew:p,compact:he,now:m,sections:Q,pinnedEpics:U,onPin:we,onShowMore:oe,emptyState:ge,closedKeys:w,onToggleSection:Pe=>x(Ye=>{const ft=new Set(Ye);return ft.has(Pe)?ft.delete(Pe):ft.add(Pe),ft}),filters:de,footer:Ie})}const Bv=/(?:^|[\s(])((?:\.{1,2}\/)?[\w./-]+\.[A-Za-z]\w*(?::(\d+))?(?::(\d+))?)/g,bw="data-file-link-text",uL=10,hL=/^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+$/,pL=new Set(["com","org","net","io","dev","run","ai","co","app","me","us","uk","de","info","xyz","site","tech","cloud"]);function OE(i){const e=i.replace(/(?::\d+)+$/,"");if(e.includes("/"))return!0;const t=e.lastIndexOf("."),n=t===-1?"":e.slice(t+1);return!(!n||n.length>uL||hL.test(n)||pL.has(n.toLowerCase()))}function fL(i){var r;const e=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,{acceptNode(l){const p=l.parentElement;return!p||p.closest("a, code, pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),t=[];let n;for(;n=e.nextNode();)t.push(n);for(const l of t){const p=l.textContent??"";Bv.lastIndex=0;const a=[...p.matchAll(Bv)].filter(m=>OE(m[1]));if(a.length===0)continue;const d=document.createDocumentFragment();let f=0;for(const m of a){const g=m[0],y=m[1],E=(m.index??0)+(g.length-y.length);if(E<f)continue;E>f&&d.appendChild(document.createTextNode(p.slice(f,E)));const C=document.createElement("span");C.className="chat-file-link",C.setAttribute(bw,y),C.textContent=y,d.appendChild(C),f=E+y.length}f<p.length&&d.appendChild(document.createTextNode(p.slice(f))),(r=l.parentNode)==null||r.replaceChild(d,l)}}const mL=3;function gL(i){Bv.lastIndex=0;const e=new Set,t=[];for(const n of i.matchAll(Bv)){const r=n[1];if(OE(r)&&!e.has(r)&&(e.add(r),t.push(r),t.length>=mL))break}return t}function QS(i,e){const t=i.match(/(?::(\d+))?(?::(\d+))?$/),n=i.replace(/(?::\d+)+$/,""),r=t!=null&&t[1]?parseInt(t[1],10):void 0,l=t!=null&&t[2]?parseInt(t[2],10):void 0;return{absPath:n.startsWith("/")?n:`${e}/${n}`,line:r,col:l}}const vL=/^https?:\/\/[^\s<>"']+$/i,_L="data-chat-code-url";function bL(i){for(const e of Array.from(i.querySelectorAll("code"))){if(e.closest("pre, a"))continue;const t=(e.textContent??"").trim();if(!vL.test(t))continue;const n=document.createElement("a");n.setAttribute("href",t),n.setAttribute(_L,""),e.replaceWith(n),n.appendChild(e)}}const wL=3,yL=new Set(["*","_","~","`",".",",",";",":","!","?","'",'"',"]"]),e1=(i,e)=>i.split(e).length-1;function xL(i){let e=i.length;for(;e>0;){const t=i[e-1];if(yL.has(t))e--;else if(t===")"&&e1(i.slice(0,e),")")>e1(i.slice(0,e),"("))e--;else break}return i.slice(0,e)}function SL(i){const e=new Set,t=[],n=/\[[^\]]*\]\((https?:\/\/[^\s)]+)\)|https?:\/\/[^\s"'<>`]+/g;let r;for(;r=n.exec(i);){const l=r[1]??xL(r[0]);if(!/^https?:\/\/$/.test(l)&&!e.has(l)&&(e.add(l),t.push(l),t.length>=wL))break}return t}function t1(i){const e=i.split(`
|
|
3045
3045
|
`);return e.length>0&&e[e.length-1]===""&&i.endsWith(`
|
|
3046
3046
|
`)&&e.pop(),e}function CL(i,e){const t=e!=null?t1(e):[];if(i==null)return{lines:t.map(D=>({type:"add",text:D})),added:t.length,removed:0};const n=t1(i),r=n.length,l=t.length,p=Array.from({length:r+1},()=>new Array(l+1).fill(0));for(let y=r-1;y>=0;y--)for(let D=l-1;D>=0;D--)p[y][D]=n[y]===t[D]?p[y+1][D+1]+1:Math.max(p[y+1][D],p[y][D+1]);const a=[];let d=0,f=0,m=0,g=0;for(;m<r&&g<l;)n[m]===t[g]?(a.push({type:"context",text:n[m]}),m++,g++):p[m+1][g]>=p[m][g+1]?(a.push({type:"remove",text:n[m]}),f++,m++):(a.push({type:"add",text:t[g]}),d++,g++);for(;m<r;)a.push({type:"remove",text:n[m]}),f++,m++;for(;g<l;)a.push({type:"add",text:t[g]}),d++,g++;return{lines:a,added:d,removed:f}}const Gv=new Ti.Renderer,kL=Gv.table.bind(Gv);Gv.table=i=>`<div class="prose-chat-table-wrap">${kL(i)}</div>`;const EL=400,If=new Map;function Ey(i,e){const t=(e==null?void 0:e.cache)!==!1;if(t){const r=If.get(i);if(r!==void 0)return r}const n=vy.sanitize(Ti.parse(i,{async:!1,breaks:!0,renderer:Gv}));if(!t)return n;if(If.set(i,n),If.size>EL){const r=If.keys().next().value;r!==void 0&&If.delete(r)}return n}function TL(i,e,t=!0){const[n,r]=z.useState(i),l=z.useRef(i),p=z.useRef(null);l.current=i;const a=z.useRef(!1);return!t&&n!==i&&(a.current=!0),z.useEffect(()=>{if(t&&a.current){a.current=!1,r(l.current);return}!t||p.current!==null||(p.current=setTimeout(()=>{p.current=null,r(l.current)},e))},[i,e,t]),z.useEffect(()=>()=>{p.current!==null&&clearTimeout(p.current),p.current=null},[]),t&&!a.current?n:i}async function LE(i,e){const t=i.replace(/(?::\d+)+$/,""),n=QS(i,e),r=await window.api.files.read(n.absPath);if(!r.ok&&r.error==="path outside home")return Qe.error("That path is outside the project and can't be opened."),null;if(r.ok)return{target:n,text:r.text};let l=0;if(!t.startsWith("/")){const a=Array.from(new Set(Ct.getState().tabs.map(d=>d.cwd).filter(d=>d&&d!==e)));for(const d of a){const f=QS(i,d),m=await window.api.files.read(f.absPath);if(l++,m.ok)return{target:f,text:m.text}}}const p=l===1?"tab":"tabs";return Qe.error(`${r.error||"Not found"} under ${e} (tried ${l} other open ${p})`),null}async function zE(i,e=""){if(!i)return;const t=await LE(i,e);t&&(Ci.getState().openFile(t.target.absPath,{line:t.target.line,col:t.target.col}),window.dispatchEvent(new CustomEvent("sm:open-editor")))}async function DL(i,e=""){if(!i)return null;const t=await LE(i,e);return(t==null?void 0:t.text)??null}async function $L(i,e=""){const t=i.target,n=t.closest("a");if(n){const p=n.getAttribute("href")||"";/^https?:\/\//i.test(p)&&(i.preventDefault(),window.api.shell.open({as:"external",url:p}).catch(()=>{}));return}const r=t.closest(`[${bw}]`);if(!r)return;const l=r.getAttribute(bw)??"";await zE(l,e)}function AL(i,e){var t;return i.text.trim().length>0?"text":e?"working":(t=i.toolUses)!=null&&t.length?"placeholder":"suppress"}const i1="standard",kh=["summary","brief","standard","detail","raw"],IL=[...kh].reverse(),Bf={raw:{label:"Raw",hint:"Everything — tool cards, thinking, usage/mode plumbing, and the injected prompt preamble inline."},detail:{label:"Detail",hint:"The agent’s work in full — tool calls, tool results, thinking. No transcript plumbing."},standard:{label:"Standard",hint:"What changed, not how — file diffs, queue operations, snapshots. No tool cards."},brief:{label:"Brief",hint:"Conversation only, replies in full."},summary:{label:"Summary",hint:"Conversation only, replies clamped to a lead excerpt."}};function cm(i){const e=kh.indexOf(i);return e===-1?kh.length-1:e}function Fv(i){return kh.length-cm(i)}function PL(i){return typeof i=="string"&&kh.includes(i)}const jL=new Set(["user","assistant","question","notice","error"]),RL=new Set(["queue-operation","file-history-snapshot"]),NL=new Set(["edited_text_file","queued_command"]),ML=new Set(["tool_result","content_thinking"]);function OL(i){var t;if(jL.has(i.role))return"summary";const e=i.kind;if(Y1(e)||e&&ML.has(e))return"detail";if(e&&RL.has(e))return"standard";if(e==="attachment"){const n=(t=i.signal)==null?void 0:t.subtype;if(n&&NL.has(n))return"standard"}return"raw"}function LL(i,e){const t=cm(e),n=[],r={summary:0,brief:0,standard:0,detail:0,raw:0};let l=0,p=-1;for(const a of i){const d=OL(a),f=cm(d);f<=t?n.push(a):(l++,r[d]++,f>p&&(p=f))}return{visible:n,hiddenCount:l,hiddenByLevel:r,revealLevel:p===-1?null:kh[p]}}const zL={summary:420,brief:null,standard:null,detail:null,raw:null};function BL(i){return cm(i)>=cm("standard")}function GL(i){return i==="raw"}function FL(i,e){if(e===null||e<=0||i.length<=e)return{body:i,truncated:!1,hiddenChars:0};const t=i.indexOf(`
|