@openchambery/web 1.17.1-beta.13 → 1.17.1-beta.15
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/{AgentAvatar-Coq-zdWI.js → AgentAvatar-Bms-mdYQ.js} +1 -1
- package/dist/assets/AssistantView-CUtQUcwu.js +1 -0
- package/dist/assets/{ChatContainer-BJGlptbG.js → ChatContainer-lJeTcl1C.js} +40 -40
- package/dist/assets/DiagramView-CY75x4V5.js +1 -0
- package/dist/assets/{FadeInOnReveal-1KpYuooP.js → FadeInOnReveal-EV5Qh80w.js} +1 -1
- package/dist/assets/{Icon-Vc-aDche.js → Icon-DFt6p0LW.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-B9Bv95Vd.js → MarkdownRendererImpl-Y_pR99z4.js} +2 -2
- package/dist/assets/MobileDetailNavigation-Chbop9JV.js +1 -0
- package/dist/assets/MobileShareBridge-DCeId7D-.js +4 -0
- package/dist/assets/MobileSurface-8zukJPC-.js +2 -0
- package/dist/assets/MultiRunWindow-BXk-ri0E.js +1 -0
- package/dist/assets/OnboardingScreen-Ce44652u.js +1 -0
- package/dist/assets/OverlayScrollbar-B7g5G5ND.js +1 -0
- package/dist/assets/SettingsView-Xx4UAq8J.js +25 -0
- package/dist/assets/SettingsWindow-CPP20IXh.js +1 -0
- package/dist/assets/TerminalView-BTh2Fr_z.js +8 -0
- package/dist/assets/{ToolOutputDialog-_Qzdo46T.js → ToolOutputDialog-DtR9RaL5.js} +1 -1
- package/dist/assets/appThemeRegistry-DuuP4ywp.js +2 -0
- package/dist/assets/{button-rDAIP5kY.js → button-TdqFSeGV.js} +1 -1
- package/dist/assets/clipboard-DZE4HSCz.js +1 -0
- package/dist/assets/{collapsible-nLeZm1kw.js → collapsible-BcmzZNos.js} +1 -1
- package/dist/assets/{context-menu-DeJdA9F6.js → context-menu-Q7z2QbNe.js} +1 -1
- package/dist/assets/desktopHosts-Ch7nWzqq.js +1 -0
- package/dist/assets/desktopRelayRestore-BhKR5E2i.js +1 -0
- package/dist/assets/{diagram-C7qK82ZL.js → diagram-DPzoxeQp.js} +1 -1
- package/dist/assets/dialog-D9nDFQe9.js +1 -0
- package/dist/assets/{fileQueries-D8m3PQr0.js → fileQueries-DO24BEHy.js} +1 -1
- package/dist/assets/{gitApi-DV6F5KKI.js → gitApi-Fpd9P1fY.js} +1 -1
- package/dist/assets/{gitApiHttp-BswZXfrf.js → gitApiHttp-gCfEig4j.js} +1 -1
- package/dist/assets/{input-CxulMZ9j.js → input-CRIOZS4l.js} +1 -1
- package/dist/assets/insertionBoundaries-BHlyukUf.js +1 -0
- package/dist/assets/main-CkMol2De.js +172 -0
- package/dist/assets/main-DFTaw6D9.js +2 -0
- package/dist/assets/{markdown-worker-DmBYud1m.js → markdown-worker-Cdsb6HMC.js} +1 -1
- package/dist/assets/{markdownTheme-CNJf24L-.js → markdownTheme-DXrASRAr.js} +1 -1
- package/dist/assets/miniChat-BuEgPrFf.js +2 -0
- package/dist/assets/mobile-CsVNQcOc.js +2 -0
- package/dist/assets/multirun-ChIqqmtD.js +4 -0
- package/dist/assets/{persistence-CFtygeYy.js → persistence-Dx4t3MFT.js} +1 -1
- package/dist/assets/projectMeta-D05KGl1X.js +3 -0
- package/dist/assets/radio-bGd9JnqX.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-_ugbw2x1.js +2 -0
- package/dist/assets/renderMobileApp-44aa9xko.js +23 -0
- package/dist/assets/{runtimeConfig-D4ETkuTj.js → runtimeConfig-B2uR3gVz.js} +1 -1
- package/dist/assets/runtimeEndpointReset-DwFpDiRP.js +145 -0
- package/dist/assets/sortable-tabs-strip-BqyQrsum.js +1 -0
- package/dist/assets/{terminalApi-MQ285A_s.js → terminalApi-DeRDgtLC.js} +1 -1
- package/dist/assets/{tooltip-CbxKYhKv.js → tooltip-L0UVzQuU.js} +1 -1
- package/dist/assets/{url-BSalv2ov.js → url-DNSNOUnB.js} +1 -1
- package/dist/assets/useAppFontEffects-D1Jk_var.js +7 -0
- package/dist/assets/{useAssistantUIStore-DGtjM827.js → useAssistantUIStore-CKpKMQ7k.js} +1 -1
- package/dist/assets/useDesktopWindowControlsLayout-BCwk_-QK.js +1 -0
- package/dist/assets/useEffectiveDirectory-BrFuN2US.js +1 -0
- package/dist/assets/{useFontPreferences-C7FEHFns.js → useFontPreferences-DkEh4AWh.js} +1 -1
- package/dist/assets/useMobileNavigationStore-BY-JlQ1a.js +475 -0
- package/dist/assets/useSessionAutoCleanup-DV8RhbfX.js +1 -0
- package/dist/assets/{useUIStore-WQV8IuFw.js → useUIStore-CZy3uiW5.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-C74ZKDtw.js → useWorkerHighlightedLines-C-mUlcw2.js} +1 -1
- package/dist/assets/{utils-Cwlw2GM0.js → utils-DD0PVWqD.js} +1 -1
- package/dist/index.html +8 -8
- package/dist/mini-chat.html +8 -8
- package/dist/mobile.html +8 -8
- package/package.json +1 -1
- package/server/index.d.ts +2 -0
- package/server/index.js +3 -0
- package/server/lib/desktop-hosts/routes.js +7 -2
- package/server/lib/desktop-hosts/routes.test.js +33 -0
- package/server/lib/opencode/DOCUMENTATION.md +1 -1
- package/server/lib/opencode/bootstrap-runtime.js +2 -0
- package/server/lib/opencode/openchamber-routes.js +2 -0
- package/server/lib/opencode/settings-runtime.js +1 -1
- package/dist/assets/AssistantView-BXLxZXL5.js +0 -1
- package/dist/assets/DiagramView-Czx_DVw0.js +0 -1
- package/dist/assets/MobileDetailNavigation-RupyXzPu.js +0 -1
- package/dist/assets/MobileShareBridge-LVT1_q5C.js +0 -4
- package/dist/assets/MobileSurface-BVwSEqn4.js +0 -2
- package/dist/assets/MultiRunWindow-C7hbEpv9.js +0 -1
- package/dist/assets/OnboardingScreen-CrekVj31.js +0 -1
- package/dist/assets/OverlayScrollbar-vZXoSFA9.js +0 -1
- package/dist/assets/SettingsView-C1sYcHr1.js +0 -25
- package/dist/assets/SettingsWindow-MtcqpoiN.js +0 -1
- package/dist/assets/TerminalView-DXQZlHNA.js +0 -8
- package/dist/assets/appThemeRegistry-Chv6_pxq.js +0 -2
- package/dist/assets/desktopHosts-RE7NIkeq.js +0 -1
- package/dist/assets/desktopRelayRestore-BzyaU7-i.js +0 -1
- package/dist/assets/dialog-DlUK6mj-.js +0 -1
- package/dist/assets/i18n-BAqcSln8.js +0 -1
- package/dist/assets/insertionBoundaries-7-TvMfgn.js +0 -1
- package/dist/assets/main-CADHVH9Y.js +0 -172
- package/dist/assets/main-q1V-_wWx.js +0 -2
- package/dist/assets/miniChat-VXuyA8mS.js +0 -2
- package/dist/assets/mobile-CaKZM4y3.js +0 -2
- package/dist/assets/multirun-QqMnIbXa.js +0 -4
- package/dist/assets/projectMeta-WJhNyk90.js +0 -3
- package/dist/assets/radio-C1riLnF0.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-CnmMV1o9.js +0 -2
- package/dist/assets/renderMobileApp-Bhe41b2q.js +0 -23
- package/dist/assets/runtimeEndpointReset-GtJt8YhT.js +0 -145
- package/dist/assets/sortable-tabs-strip-Fiq5nrkF.js +0 -1
- package/dist/assets/ui-D5j3JxkE.js +0 -475
- package/dist/assets/useAppFontEffects-CaGwli-K.js +0 -7
- package/dist/assets/useDesktopWindowControlsLayout-DCZXksMp.js +0 -1
- package/dist/assets/useEffectiveDirectory-CssNtlqg.js +0 -1
- package/dist/assets/useSessionAutoCleanup-B_mSwN7n.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$ as t,J as n,X as r,Y as i,Z as a,nt as o,rt as s}from"./vendor-base-ui-CnHfUmDN.js";import{n as c}from"./vendor-react-DLPElpoQ.js";import{t as l}from"./i18n-BAqcSln8.js";import{t as u}from"./utils-Cwlw2GM0.js";import{t as d}from"./SettingsView-C1sYcHr1.js";var f=c(),p=e(s(),1),m=o(),h=e=>{let o=(0,f.c)(19),{open:s,onOpenChange:c}=e,{t:h}=l(),_=p.useId(),v=g,y;o[0]===c?y=o[1]:(y=e=>{!e&&v()||c(e)},o[0]=c,o[1]=y);let b;o[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,m.jsx)(t,{className:u(`fixed inset-0 z-50 bg-black/50 dark:bg-black/75`,`transition-opacity duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`)}),o[2]=b):b=o[2];let x;o[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=u(`relative pointer-events-auto`,`w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]`,`rounded-xl border shadow-none overflow-hidden origin-center`,`bg-background`,`transition-all duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]`,`data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]`,`data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]`),o[3]=x):x=o[3];let S;o[4]===h?S=o[5]:(S=h(`settings.window.description`),o[4]=h,o[5]=S);let C;o[6]!==_||o[7]!==S?(C=(0,m.jsx)(a,{id:_,className:`sr-only`,children:S}),o[6]=_,o[7]=S,o[8]=C):C=o[8];let w;o[9]===c?w=o[10]:(w=(0,m.jsx)(d,{onClose:()=>c(!1),isWindowed:!0}),o[9]=c,o[10]=w);let T;o[11]!==_||o[12]!==C||o[13]!==w?(T=(0,m.jsxs)(i,{children:[b,(0,m.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center pointer-events-none`,children:(0,m.jsxs)(r,{"aria-describedby":_,className:x,children:[C,w]})})]}),o[11]=_,o[12]=C,o[13]=w,o[14]=T):T=o[14];let E;return o[15]!==s||o[16]!==y||o[17]!==T?(E=(0,m.jsx)(n,{open:s,onOpenChange:y,children:T}),o[15]=s,o[16]=y,o[17]=T,o[18]=E):E=o[18],E};function g(){return typeof document>`u`?!1:!!document.querySelector(`[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]`)}export{h as SettingsWindow};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{c as t,s as n,t as r}from"./useUIStore-WQV8IuFw.js";import{Xt as i,kn as a}from"./persistence-CFtygeYy.js";import{nt as o,rt as s,tt as c}from"./vendor-base-ui-CnHfUmDN.js";import{o as l}from"./terminalApi-MQ285A_s.js";import{n as u,r as d,t as f}from"./vendor-ghostty-web-HohRXr3g.js";import{l as p,t as m}from"./i18n-BAqcSln8.js";import{d as h}from"./ui-D5j3JxkE.js";import{t as g}from"./utils-Cwlw2GM0.js";import{n as _}from"./Icon-Vc-aDche.js";import{t as v}from"./button-rDAIP5kY.js";import{n as y}from"./useThemeSystem-DMzWVJaW.js";import{i as b,t as x}from"./OverlayScrollbar-vZXoSFA9.js";import{n as ee}from"./useRuntimeAPIs-DSLXJybW.js";import{n as S}from"./useEffectiveDirectory-CssNtlqg.js";import{t as C}from"./sortable-tabs-strip-Fiq5nrkF.js";import{n as w,t as T}from"./useFontPreferences-C7FEHFns.js";import{r as E}from"./projectActions-CWvNGKfA.js";var D=e(s(),1);function te(e){let{colors:t}=e,n=t.syntax.base;return{background:t.surface.background,foreground:n.foreground,cursor:t.interactive.cursor,cursorAccent:t.surface.background,selectionBackground:t.interactive.selection,selectionForeground:t.interactive.selectionForeground,selectionInactiveBackground:t.interactive.selection+`50`,black:t.surface.muted,red:t.status.error,green:t.status.success,yellow:t.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:t.status.error,brightGreen:t.status.success,brightYellow:t.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:t.surface.elevatedForeground}}function ne(e,t,n,r,i=!1){return{cursorBlink:!1,cursorStyle:`bar`,fontSize:t,lineHeight:1.15,fontFamily:`${e}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`,allowTransparency:!1,theme:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorAccent:n.cursorAccent,selectionBackground:n.selectionBackground,selectionForeground:n.selectionForeground,black:n.black,red:n.red,green:n.green,yellow:n.yellow,blue:n.blue,magenta:n.magenta,cyan:n.cyan,white:n.white,brightBlack:n.brightBlack,brightRed:n.brightRed,brightGreen:n.brightGreen,brightYellow:n.brightYellow,brightBlue:n.brightBlue,brightMagenta:n.brightMagenta,brightCyan:n.brightCyan,brightWhite:n.brightWhite},scrollback:1e4,ghostty:r,disableStdin:i}}var re=e(c(),1),O=o(),k=null;function A(){return k||=d.load(),k}function ie(e){if(typeof window>`u`)return null;let t=[e,...Array.from(e.querySelectorAll(`*`))],n=null;for(let e of t){let t=window.getComputedStyle(e).overflowY;if(t===`auto`||t===`scroll`){if(e.scrollHeight-e.clientHeight>2)return e;n||=e}}return n}var ae=D.forwardRef(({sessionKey:e,chunks:t,onInput:n,onResize:r,theme:i,fontFamily:a,fontSize:o,className:s,enableTouchScroll:c,autoFocus:l=!0,isVisible:d=!0},h)=>{let{t:_}=m(),v=D.useRef(null),y=D.useRef(null),b=D.useRef(null),ee=D.useRef(null),S=D.useRef(n),C=D.useRef(r),w=D.useRef(null),T=D.useRef(``),E=D.useRef(null),te=D.useRef(!1),k=D.useRef(null),ae=D.useRef(!0),j=D.useRef(null),M=D.useRef(null),oe=D.useRef(0),se=D.useRef(null),N=D.useRef(null),P=D.useRef(!1),F=D.useRef(!1),ce=D.useRef(null),le=D.useRef(null),ue=D.useRef(null),I=D.useRef(``),de=D.useRef(null),fe=D.useRef(!c),pe=D.useRef(d),[,me]=D.useReducer(e=>e+1,0),[he,ge]=D.useReducer(e=>e+1,0);S.current=n,C.current=r;let _e=typeof navigator<`u`&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform===`Android`),L=!!c;D.useEffect(()=>{if(!c){fe.current=!0,pe.current=d;return}!pe.current&&d&&(fe.current=!1),pe.current=d},[c,d]);let ve=D.useCallback(()=>{if(!L)return;let e=v.current,t=se.current;if(!e)return;let n=[];e.getAttribute(`contenteditable`)===`true`&&n.push(e),n.push(...Array.from(e.querySelectorAll(`[contenteditable="true"]`))),n.forEach(e=>{e.setAttribute(`data-terminal-disabled-contenteditable`,`true`),e.setAttribute(`contenteditable`,`false`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.setProperty(`user-select`,`none`),e.style.setProperty(`-webkit-user-select`,`none`)}),e.tabIndex=-1,e.removeAttribute(`role`),e.removeAttribute(`aria-multiline`),Array.from(e.querySelectorAll(`textarea`)).forEach(e=>{e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.border=`0`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.fontSize=`0`,e.style.lineHeight=`0`,e!==t&&e.getAttribute(`data-terminal-disabled-input`)!==`true`&&(e.setAttribute(`data-terminal-disabled-input`,`true`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.disabled=!0,e.style.position=`absolute`,e.style.opacity=`0`,e.style.width=`0px`,e.style.height=`0px`,e.style.pointerEvents=`none`,e.style.zIndex=`-1`)})},[L]),R=D.useCallback(e=>{if(de.current===e)return;let t=b.current;if(t)try{if(typeof t.setOption==`function`){t.setOption(`cursorBlink`,e),de.current=e;return}t.options&&(t.options.cursorBlink=e,de.current=e)}catch{}},[]),z=L&&_e,B=D.useCallback((e,t)=>{let n=z?N.current:se.current,r=v.current;if(!n||!r)return;let i=r.getBoundingClientRect(),a=typeof window<`u`?window.innerWidth:i.width,o=typeof window<`u`?window.innerHeight:i.height,s=i.left+i.width/2,c=i.top+i.height-12,l=typeof e==`number`?e:s,u=typeof t==`number`?t:c,d=Math.max(8,Math.min(a-8,l)),f=Math.max(8,Math.min(o-8,u));n.style.left=`${d}px`,n.style.top=`${f}px`,n.style.bottom=``,(n instanceof HTMLTextAreaElement||n instanceof HTMLInputElement)&&(n.disabled=!1,n.readOnly=!1,n.removeAttribute(`disabled`),n.removeAttribute(`readonly`));try{n.focus({preventScroll:!0})}catch{try{n.focus()}catch{}}},[z]),V=D.useCallback(()=>{if(L){B(),R(!0);return}b.current?.focus(),R(!0)},[B,R,L]),H=D.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??``,[]),U=D.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value=``;return}e.textContent=``},[]),ye=D.useCallback(e=>{if(typeof window>`u`||z)return;ue.current!==null&&(window.clearTimeout(ue.current),ue.current=null);let t=0,n=()=>{ue.current=window.setTimeout(()=>{ue.current=null;let r=H(e);if(!r){if(t+=1,t<3){n();return}return}let i=I.current;I.current=r;let a=r.startsWith(i)?r.slice(i.length):r;a&&S.current(a.replace(/\r\n|\r|\n/g,`\r`)),U(e),I.current=``},t===0?0:24)};n()},[U,H,z]);D.useEffect(()=>{let e=v.current;if(!L||!e||c)return;let t=t=>{let n=t.target;if(n&&n.getAttribute(`data-terminal-hidden-input`)!==`true`&&e.contains(n)){try{n.blur()}catch{}B()}};return e.addEventListener(`focusin`,t,!0),()=>{e.removeEventListener(`focusin`,t,!0)}},[c,L,B]);let W=D.useCallback(()=>{let e=b.current;if(!e||typeof e.getSelection!=`function`)return``;let t=e.getSelection();return typeof t==`string`?t:``},[]),be=D.useCallback(()=>{if(typeof window>`u`)return``;let e=window.getSelection();if(!e)return``;let t=e.toString();if(!t.trim())return``;let n=v.current;if(!n)return``;let r=e.anchorNode,i=e.focusNode;return r&&!n.contains(r)||i&&!n.contains(i)?``:t},[]),xe=D.useCallback(async()=>{if(typeof document>`u`)return;let e=W()||be();e.trim()&&await p(e)},[be,W]),Se=D.useCallback(()=>W().trim()?!0:!!be().trim(),[be,W]);D.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{Se()&&(e.preventDefault(),xe())};return window.addEventListener(`openchamber:copy`,e),()=>{window.removeEventListener(`openchamber:copy`,e)}},[xe,Se]);let G=D.useCallback(()=>{T.current=``,E.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(E.current),E.current=null,te.current=!1,k.current=null},[]),K=D.useCallback(()=>{let e=ee.current,t=b.current,n=v.current;if(!e||!t||!n)return;let r=n.getBoundingClientRect();if(!(r.width<24||r.height<24))try{e.fit();let n={cols:t.cols,rows:t.rows},r=w.current;(!r||r.cols!==n.cols||r.rows!==n.rows)&&(w.current=n,C.current(n.cols,n.rows))}catch{}},[]),q=D.useCallback(()=>{if(te.current)return;let e=b.current;if(!e){G();return}if(!T.current)return;let t=T.current;T.current=``,te.current=!0,e.write(t,()=>{te.current=!1,T.current&&(typeof window<`u`?E.current=window.requestAnimationFrame(()=>{E.current=null,q()}):q())})},[G]),Ce=D.useCallback(()=>{E.current===null&&(typeof window<`u`?E.current=window.requestAnimationFrame(()=>{E.current=null,q()}):q())},[q]),J=D.useCallback(e=>{e&&(T.current+=e,Ce())},[Ce]),we=D.useCallback(()=>{if(j.current?.(),j.current=null,M.current!==null&&typeof window<`u`&&(window.clearTimeout(M.current),M.current=null),!c){oe.current=0;return}let e=v.current;if(!e)return;let t=b.current;if(!t)return;oe.current=0;let n=2.2,r=2.8,i=.25,a=.05,s=.015,l={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},u=()=>typeof performance<`u`?performance.now():Date.now(),d=Math.max(12,Math.round(o*1.35)),f=0,p=e=>{if(!e)return!1;let n=t.getViewportY(),r=f+e,i=Math.trunc(r/d);return f=r-i*d,i!==0&&t.scrollLines(i),t.getViewportY()!==n},m=()=>{l.rafId!==null&&typeof window<`u`&&window.cancelAnimationFrame(l.rafId),l.rafId=null},h={passive:!1,capture:!1};if(typeof window<`u`&&`PointerEvent`in window){let t=Object.assign(l,{pointerId:null,startX:null,startY:null,moved:!1}),o=n=>{if(n.pointerType===`touch`){m(),t.pointerId=n.pointerId,t.startX=n.clientX,t.startY=n.clientY,t.moved=!1,t.lastY=n.clientY,t.lastTime=u(),t.velocity=0;try{e.setPointerCapture(n.pointerId)}catch{}}},d=e=>{if(e.pointerType!==`touch`||t.pointerId!==e.pointerId)return;if(t.startX!==null&&t.startY!==null&&!t.moved){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>=6&&(t.moved=!0)}if(t.lastY===null){t.lastY=e.clientY,t.lastTime=u();return}let a=t.lastY,o=t.lastTime??u(),s=u();t.lastY=e.clientY,t.lastTime=s;let c=a-e.clientY;if(Math.abs(c)<1)return;let l=Math.max(s-o,8),d=c*(n+Math.min(r,Math.abs(c)/25)),f=d/l;t.velocity=t.velocity*.75+f*i,t.velocity>8?t.velocity=8:t.velocity<-8&&(t.velocity=-8),t.moved&&(e.cancelable&&e.preventDefault(),e.stopPropagation()),p(d)},f=n=>{if(n.pointerType!==`touch`||t.pointerId!==n.pointerId)return;let r=!t.moved;t.pointerId=null,t.startX=null,t.startY=null,t.moved=!1,t.lastY=null,t.lastTime=null;try{e.releasePointerCapture(n.pointerId)}catch{}if(r){L?B(n.clientX,n.clientY):c&&!fe.current&&(fe.current=!0,b.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(t.velocity)<a){t.velocity=0;return}let i=u(),o=()=>{let e=u(),n=Math.max(e-i,8);i=e;let r=p(t.velocity*n)??!1,c=Math.sign(t.velocity),l=Math.max(0,Math.abs(t.velocity)-s*n);if(t.velocity=l*c,!r||l<=a){m(),t.velocity=0;return}t.rafId=window.requestAnimationFrame(o)};t.rafId=window.requestAnimationFrame(o)};e.addEventListener(`pointerdown`,o,h),e.addEventListener(`pointermove`,d,h),e.addEventListener(`pointerup`,f,h),e.addEventListener(`pointercancel`,f,h);let g=e.style.touchAction,_=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,j.current=()=>{m(),M.current!==null&&typeof window<`u`&&(window.clearTimeout(M.current),M.current=null),oe.current=0,e.removeEventListener(`pointerdown`,o,h),e.removeEventListener(`pointermove`,d,h),e.removeEventListener(`pointerup`,f,h),e.removeEventListener(`pointercancel`,f,h),e.style.touchAction=g,e.style.overscrollBehaviorY=_};return}let g=e=>{e.touches.length===1&&(m(),l.lastY=e.touches[0].clientY,l.lastTime=u(),l.velocity=0,l.startX=e.touches[0].clientX,l.startY=e.touches[0].clientY,l.didMove=!1)},_=e=>{if(e.touches.length!==1){l.lastY=null,l.lastTime=null,l.velocity=0,l.startX=null,l.startY=null,l.didMove=!1,m();return}let t=e.touches[0].clientX,a=e.touches[0].clientY;if(l.startX!==null&&l.startY!==null&&!l.didMove){let e=t-l.startX,n=a-l.startY;Math.hypot(e,n)>=6&&(l.didMove=!0)}if(l.lastY===null){l.lastY=a,l.lastTime=u();return}let o=l.lastY,s=l.lastTime??u(),c=u();l.lastY=a,l.lastTime=c;let d=o-a;if(Math.abs(d)<1)return;let f=Math.max(c-s,8),h=d*(n+Math.min(r,Math.abs(d)/25)),g=h/f;l.velocity=l.velocity*.75+g*i,l.velocity>8?l.velocity=8:l.velocity<-8&&(l.velocity=-8),l.didMove&&(e.preventDefault(),e.stopPropagation()),p(h)},y=e=>{let t=!l.didMove;l.lastY=null,l.lastTime=null;let n=l.velocity;if(l.startX=null,l.startY=null,l.didMove=!1,t){let t=e.changedTouches?.[0];L?B(t?.clientX,t?.clientY):c&&!fe.current&&(fe.current=!0,b.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(n)<a){l.velocity=0;return}let r=u(),i=()=>{let e=u(),t=Math.max(e-r,8);r=e;let n=p(l.velocity*t)??!1,o=Math.sign(l.velocity),c=Math.max(0,Math.abs(l.velocity)-s*t);if(l.velocity=c*o,!n||c<=a){m(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(i)};l.rafId=window.requestAnimationFrame(i)};e.addEventListener(`touchstart`,g,h),e.addEventListener(`touchmove`,_,h),e.addEventListener(`touchend`,y,h),e.addEventListener(`touchcancel`,y,h);let x=e.style.touchAction,ee=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,j.current=()=>{m(),M.current!==null&&typeof window<`u`&&(window.clearTimeout(M.current),M.current=null),oe.current=0,e.removeEventListener(`touchstart`,g,h),e.removeEventListener(`touchmove`,_,h),e.removeEventListener(`touchend`,y,h),e.removeEventListener(`touchcancel`,y,h),e.style.touchAction=x,e.style.overscrollBehaviorY=ee}},[c,L,B,o]);D.useEffect(()=>{let e=!1,t=null,n=null,r=null,s=[],l=null,d=null,p=null,m=v.current;if(!m)return;if(m.tabIndex=L?-1:0,L){let e=m.focus.bind(m),t=m;t.focus=((...e)=>{B()}),p=()=>{t.focus=e}}let h=()=>{R(!0)},g=()=>{R(!1)},_=e=>{let t=e.target;if(t&&m.contains(t)){if(L&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur(),B()},0),R(!1);return}if(c&&!fe.current&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur()},0),R(!1);return}R(!0);return}R(!1)},x=()=>{R(!1)},C=null;return(async()=>{try{let p=await A();if(e)return;let _=ne(a,o,i,p,!1),v=new u(_);ae.current=!0,L&&(v.focus=()=>{});let x=v;if(typeof x.scrollToBottom==`function`){let e=x.scrollToBottom.bind(x);x.scrollToBottom=()=>{ae.current&&e()},l=()=>{x.scrollToBottom=e}}let w=new f;if(t=v,b.current=v,ee.current=w,v.loadAddon(w),v.open(m),c){let e=v.renderer;if(e&&typeof e.renderScrollbar==`function`){let t=e.renderScrollbar.bind(e);e.renderScrollbar=()=>{},d=()=>{e.renderScrollbar=t}}}ge(),de.current=!1,C=v.textarea??m.querySelector(`textarea`),C&&(C.addEventListener(`focus`,h),C.addEventListener(`blur`,g)),ve(),typeof MutationObserver<`u`&&(r=new MutationObserver(()=>{ve()}),r.observe(m,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`contenteditable`,`role`,`tabindex`,`aria-label`]}));let T=ie(m);T?(T.classList.add(`overlay-scrollbar-target`,`overlay-scrollbar-container`),y.current=T,me()):y.current=null,K();let E=w;typeof E.observeResize==`function`&&E.observeResize(),we(),s=[v.onData(e=>{S.current(e)}),v.onScroll(e=>{if(typeof e==`number`&&Number.isFinite(e)){let t=typeof v.hasSelection==`function`&&v.hasSelection();ae.current=!t&&e<=.5}}),v.onSelectionChange(()=>{if(typeof v.hasSelection==`function`&&v.hasSelection()){ae.current=!1;return}let e=typeof v.getViewportY==`function`?v.getViewportY():0;ae.current=e<=.5})],n=new ResizeObserver(()=>{K()}),n.observe(m),typeof window<`u`&&window.setTimeout(()=>{K()},0)}catch{}})(),document.addEventListener(`focusin`,_,!0),window.addEventListener(`blur`,x),()=>{e=!0,j.current?.(),j.current=null,document.removeEventListener(`focusin`,_,!0),window.removeEventListener(`blur`,x),s.forEach(e=>e.dispose()),l?.(),l=null,d?.(),d=null,C&&(C.removeEventListener(`focus`,h),C.removeEventListener(`blur`,g)),n?.disconnect(),r?.disconnect(),p?.(),t?.dispose(),b.current=null,ee.current=null,y.current=null,w.current=null,de.current=null,G()}},[ve,c,K,B,a,o,we,i,G,R,L]),D.useEffect(()=>{let e=b.current;e&&(e.reset(),G(),w.current=null,K())},[e,he,K,G]),D.useEffect(()=>{l&&b.current&&V()},[l,V,e,he]),D.useEffect(()=>(we(),()=>{j.current?.(),j.current=null}),[we,e]),D.useEffect(()=>{let e=b.current;if(!e)return;if(t.length===0){k.current!==null&&(e.reset(),G(),K());return}let n=k.current,r;if(n===null)r=t;else{let e=t.findIndex(e=>e.id===n);r=e>=0?t.slice(e+1):t}r.length>0&&J(r.map(e=>e.data).join(``)),k.current=t[t.length-1].id},[t,he,J,K,G]),D.useImperativeHandle(h,()=>({focus:()=>{V()},clear:()=>{let e=b.current;e&&(e.reset(),G(),K())},fit:()=>{K()}}),[V,K,G]);let Y=D.useCallback(e=>{if(!L)return;let t=v.current,n=e.relatedTarget,r=n?.tagName;r===`INPUT`||r===`TEXTAREA`||n?.isContentEditable,n?.getAttribute(`data-terminal-hidden-input`),n&&t?.contains(n)},[L]),X=D.useCallback(e=>{let t=e.nativeEvent,n=t?.inputType??``,r=typeof t?.data==`string`?t.data:``;if(le.current=typeof performance<`u`?performance.now():Date.now(),n===`insertCompositionText`){P.current=!0;return}if(!n&&r){if(P.current)return;e.preventDefault(),S.current(r),ce.current={type:`insertText`,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0;return}if(n===`insertText`&&r){if(P.current)return;e.preventDefault(),S.current(r),ce.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0;return}if(n===`insertLineBreak`){if(P.current)return;e.preventDefault(),S.current(`\r`),ce.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0;return}if(n===`deleteContentBackward`){if(P.current)return;e.preventDefault(),S.current(``),ce.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0}},[]),Z=D.useCallback(e=>{let t=e.currentTarget;if(le.current=typeof performance<`u`?performance.now():Date.now(),P.current)return;if(F.current){let e=ce.current,n=typeof performance<`u`?performance.now():Date.now();if(e&&n-e.at<50){F.current=!1,U(t);return}F.current=!1}let n=H(t);if(!n)return;I.current=n;let r=n.replace(/\r\n|\r|\n/g,`\r`);S.current(r),U(t),I.current=``},[U,H]),Te=D.useCallback(e=>{e.stopPropagation();let t=e.key.toLowerCase(),n=e.metaKey&&!e.ctrlKey&&!e.altKey&&t===`c`,r=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&t===`c`;if((n||r)&&Se()){e.preventDefault(),xe();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){let t=e.key.toUpperCase();if(t>=`A`&&t<=`Z`){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),S.current(String.fromCharCode(t.charCodeAt(0)-64)),U(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),S.current(`\x1B`+e.key),U(e.currentTarget);return}let i={ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`,Escape:`\x1B`,Tab:` `,Delete:`\x1B[3~`,Home:`\x1B[H`,End:`\x1B[F`}[e.key];if(i){e.preventDefault(),S.current(i),U(e.currentTarget);return}let a=e.currentTarget;if(e.nativeEvent?.isComposing)return;let o=ce.current,s=typeof performance<`u`?performance.now():Date.now(),c=!!(o&&s-o.at<50);if(e.key===`Enter`){if(c&&o?.type===`insertLineBreak`)return;e.preventDefault(),S.current(`\r`),U(a);return}if(e.key===`Backspace`){if(e.preventDefault(),c&&o?.type===`deleteContentBackward`)return;H(a)||S.current(``)}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=le.current;t&&s-t<50||(e.preventDefault(),S.current(e.key),F.current=!0,ce.current={type:`keydown-text`,at:s})}ye(a)},[U,xe,Se,H,ye]),Ee=D.useCallback(e=>{e.stopPropagation();let t=e.currentTarget;e.nativeEvent?.isComposing||ye(t)},[ye]),De=D.useCallback(e=>{let t=e.currentTarget;P.current=!1;let n=e.data||H(t);if(le.current=typeof performance<`u`?performance.now():Date.now(),!n)return;let r=n.replace(/\r\n|\r|\n/g,`\r`);S.current(r),U(t),ce.current={type:`compositionend`,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0},[U,H]),Oe=D.useCallback(e=>{e.stopPropagation();let t=e.clipboardData?.getData(`text`)??``;if(!t)return;e.preventDefault();let n=b.current?.hasBracketedPaste?.()?`\x1b[200~${t}\x1b[201~`:t;S.current(n)},[]),ke={position:`fixed`,left:0,top:0,width:1,height:1,opacity:0,zIndex:-1,background:`transparent`,color:`transparent`,WebkitTextFillColor:`transparent`,caretColor:`transparent`,textShadow:`none`,WebkitAppearance:`none`,appearance:`none`,resize:`none`,overflow:`hidden`,whiteSpace:`nowrap`,border:`0`,padding:0,margin:0,outline:`none`,outlineOffset:0,fontSize:16,fontWeight:400,pointerEvents:`none`,WebkitUserSelect:`none`,userSelect:`none`};return(0,O.jsxs)(`div`,{ref:v,className:g(`relative h-full w-full terminal-viewport-container`,s),"data-hidden-input-overlay-active":L?`true`:void 0,style:{backgroundColor:i.background},onTouchStart:e=>{if(!(!L||c)&&!Se()){let t=e.touches?.[0];B(t?.clientX,t?.clientY)}},onClick:e=>{if(!c)if(L){if(Se())return;B(e.clientX,e.clientY)}else b.current?.focus()},onMouseUp:()=>{!c&&Se()&&xe()},onTouchEnd:()=>{!c&&Se()&&xe()},children:[L&&typeof document<`u`?(0,re.createPortal)((0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`input`,{ref:N,type:`text`,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":_(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...ke,display:z?`block`:`none`},onBlur:Y,onBeforeInput:X,onCompositionStart:()=>{P.current=!0},onInput:Z,onKeyDown:Te,onKeyUp:Ee,onCompositionEnd:De,onPaste:Oe}),(0,O.jsx)(`textarea`,{ref:se,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":_(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...ke,display:z?`none`:`block`},onBlur:Y,onBeforeInput:X,onCompositionStart:()=>{P.current=!0},onInput:Z,onKeyDown:Te,onKeyUp:Ee,onCompositionEnd:De,onPaste:Oe})]}),document.body):null,y.current&&!c?(0,O.jsx)(x,{containerRef:y,disableHorizontal:!0,className:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`}):null]})});ae.displayName=`TerminalViewport`;var j=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),M=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,oe=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,se=/Serving HTTP on .*? port (\d{2,5})/i,N=new Set([`.`,`,`,`;`,`:`,`!`,`?`]),P=e=>{let t=e;for(;t.length>0;){let e=t[t.length-1];if(e===`)`||e===`]`||e===`}`||e===`>`){let n=e===`)`?`(`:e===`]`?`[`:e===`}`?`{`:`<`,r=t.slice(0,-1);if((r.match(RegExp(`\\${n}`,`g`))||[]).length>(r.match(RegExp(`\\${e}`,`g`))||[]).length)break;t=r;continue}if(N.has(e)){t=t.slice(0,-1);continue}break}return t},F=e=>{let t=P(e);return t=t.replace(`0.0.0.0`,`127.0.0.1`),t=t.replace(`[::1]`,`127.0.0.1`),t=t.replace(`[::]`,`127.0.0.1`),t},ce=e=>{if(!e)return null;let t=e.replace(j,``),n=t.match(se);if(n?.[1]){let e=Number.parseInt(n[1],10);if(Number.isFinite(e)&&e>0&&e<=65535)return`http://127.0.0.1:${e}/`}let r=t.split(`
|
|
2
|
-
`);for(let e of r){if(!oe.test(e))continue;let t=Array.from(e.matchAll(M));if(t.length!==0)return F((t.find(e=>{try{return!!new URL(F(e[1])).port}catch{return!1}})??t[0])[1])}return null},le=async(e,t=1500)=>{if(!e||typeof window>`u`)return!1;let n;try{n=new URL(e)}catch{return!1}if(n.protocol!==`http:`&&n.protocol!==`https:`)return!1;let r=n.hostname.toLowerCase();if(r!==`localhost`&&r!==`127.0.0.1`&&r!==`0.0.0.0`&&r!==`::1`&&r!==`::`)return!1;let i=new AbortController,o=window.setTimeout(()=>i.abort(),t);try{let e=await a(`/api/system/probe-url`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:n.toString()}),cache:`no-store`,signal:i.signal});return e.ok?(await e.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(o)}},ue={esc:`\x1B`,tab:` `,enter:`\r`,"arrow-up":`\x1B[A`,"arrow-down":`\x1B[B`,"arrow-left":`\x1B[D`,"arrow-right":`\x1B[C`},I={ctrl:`5`,cmd:`3`},de={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},fe={retry:{maxRetries:8,initialDelayMs:400,maxDelayMs:8e3},connectionTimeoutMs:15e3},pe=(e,t)=>{if(t)switch(e){case`arrow-up`:return`\u001b[1;${I[t]}A`;case`arrow-down`:return`\u001b[1;${I[t]}B`;case`arrow-right`:return`\u001b[1;${I[t]}C`;case`arrow-left`:return`\u001b[1;${I[t]}D`}return ue[e]??null},me=()=>{let{t:e}=m(),{terminal:a,runtime:o}=ee(),{currentTheme:s}=y(),{monoFont:c}=T(),u=r(e=>e.terminalFontSize),d=r(e=>e.bottomTerminalHeight),f=r(e=>e.isBottomTerminalExpanded),{isMobile:p,isTablet:x,hasTouchOnlyPointer:ne}=b(),re=p||x,k=(re||ne)&&o.platform===`web`,A=o.platform!==`vscode`,ie=r(e=>e.showTerminalQuickKeysOnDesktop),j=!i()&&(re||ie),M=h(e=>e.currentSessionId),oe=h(e=>e.newSessionDraft),se=M!==null||oe?.open===!0,N=S()??null,P=w(e=>e.sessions),F=w(e=>e.hasHydrated),ue=w(e=>e.ensureDirectory),I=w(e=>e.createTab),me=w(e=>e.setActiveTab),he=w(e=>e.closeTab),ge=w(e=>e.setTabSessionId),_e=w(e=>e.setTabLifecycle),L=w(e=>e.setConnecting),ve=w(e=>e.appendToBuffer),R=w(e=>e.setTabPreviewUrl),z=w(e=>e.clearBuffer),B=r(e=>e.openContextPreview),V=D.useMemo(()=>{if(N)return P.get(N)},[P,N]),H=D.useMemo(()=>V?A?V.activeTabId??V.tabs[0]?.id??null:V.tabs[0]?.id??null:null,[V,A]),U=D.useMemo(()=>{if(V)return H?V.tabs.find(e=>e.id===H)??V.tabs[0]:V.tabs[0]},[V,H]),ye=D.useMemo(()=>(V?.tabs??[]).map(t=>({icon:(()=>{let e=t.iconKey?E[t.iconKey]??`terminal`:`terminal`;return(0,O.jsx)(_,{name:e,className:`h-4 w-4`})})(),id:t.id,label:t.label,title:t.label,closeLabel:e(`terminalView.tabs.closeTabTitle`)})),[V?.tabs,e]),W=U?.terminalSessionId??null,be=U?.lifecycle??`idle`,xe=U?.bufferChunks??[],Se=U?.isConnecting??!1,G=U?.previewUrl??null,[K,q]=D.useState(null),[Ce,J]=D.useState(!1),[we,Y]=D.useState(!1),[X,Z]=D.useState(null),[Te,Ee]=D.useState(!1),[De,Oe]=D.useState(0),ke=D.useRef(null),Ae=D.useRef(null),je=D.useRef(H),Me=D.useRef(W),Ne=D.useRef(N),Pe=D.useRef(null),Fe=D.useRef(null),Ie=D.useRef(!1),Le=D.useRef(!1),Re=D.useRef(null),ze=D.useRef(null),Be=D.useRef(new Set),Ve=D.useRef(!1),He=D.useRef(``),Ue=D.useRef(new Set),We=D.useRef(0),Ge=D.useCallback(()=>{He.current=``,Ue.current.clear(),We.current+=1},[]),Ke=D.useCallback(()=>{k||typeof document<`u`&&!document.hasFocus()||Pe.current?.focus()},[k]),qe=D.useCallback(()=>{k||Pe.current?.focus()},[k]);D.useEffect(()=>{if(!F||Ve.current)return;Ve.current=!0;let e=new Set;for(let[,t]of w.getState().sessions.entries())for(let n of t.tabs)n.terminalSessionId&&e.add(n.terminalSessionId);Be.current=e},[F]);let Je=r(e=>e.activeMainTab),Ye=r(e=>e.isBottomTerminalOpen),Xe=r(e=>e.setBottomTerminalOpen),Ze=r(e=>e.setBottomTerminalExpanded),Qe=Je===`terminal`,Q=Qe||Ye,[$e,et]=D.useState(Q);D.useEffect(()=>{!Q||o.platform===`vscode`||l()},[Q,o.platform]),D.useEffect(()=>{Q&&et(!0)},[Q]),D.useEffect(()=>{Le.current=Q},[Q]),D.useEffect(()=>{Me.current=W},[W]),D.useEffect(()=>{je.current=H,Ge()},[H,Ge]),D.useEffect(()=>{Ne.current=N},[N]),D.useEffect(()=>{!j&&X!==null&&Z(null)},[j,X,Z]),D.useEffect(()=>{!W&&X!==null&&Z(null)},[W,X,Z]);let $=D.useCallback(()=>{ke.current?.(),ke.current=null,Ae.current=null,Re.current=null,Y(!1)},[]);D.useEffect(()=>()=>{$(),Me.current=null},[$]);let tt=D.useCallback((e,t,n)=>{if(!n)return;let r=`${He.current}${n}`.replace(/\r\n|\r/g,`
|
|
3
|
-
`),i=r.split(`
|
|
4
|
-
`),a=r.endsWith(`
|
|
5
|
-
`)?i.join(`
|
|
6
|
-
`):i.slice(0,-1).join(`
|
|
7
|
-
`);if(He.current=r.endsWith(`
|
|
8
|
-
`)?``:(i[i.length-1]??``).slice(-1024),!a)return;let o=ce(a);if(!o||Ue.current.has(o))return;let s=We.current;Ue.current.add(o),le(o).then(n=>{if(Ue.current.delete(o),!n||We.current!==s)return;let r=w.getState().getDirectoryState(e)?.tabs.find(e=>e.id===t);!r||r.previewUrlLocked||r.previewUrl===o||R(e,t,o,{locked:!1,autoOpened:!1})})},[R]),nt=D.useCallback((t,n,r,i=de,o=!1)=>{if(Ae.current===r)return;$(),Ae.current=r;let s=a.connect(r,{onEvent:i=>{if(Ae.current===r)switch(i.type){case`connected`:Re.current=r,L(t,n,!1),q(null),J(!1),Y(!1),Ke(),ze.current===r&&(ze.current=null,a.sendInput(r,`\r`).catch(()=>{}));break;case`reconnecting`:q(null),J(!1),Y(!0);break;case`data`:i.data&&(ve(t,n,i.data),tt(t,n,i.data));break;case`exit`:{let r=typeof i.exitCode==`number`?i.exitCode:null,a=typeof i.signal==`number`?i.signal:null,o=!!(w.getState().getDirectoryState(t)?.tabs.find(e=>e.id===n))?.label?.startsWith(`Action:`);ve(t,n,e(`terminalView.stream.processExitedMessage`,{exitCodeSegment:r===null?``:e(`terminalView.stream.processExitedWithCode`,{exitCode:r}),signalSegment:a===null?``:e(`terminalView.stream.processExitedWithSignal`,{signal:a})})),_e(t,n,`exited`),ge(t,n,null),L(t,n,!1),q(o?null:e(`terminalView.error.sessionEnded`)),J(!1),Y(!1),$();break}}},onError:(i,a)=>{if(Ae.current===r){if(!a){q(null),J(!1);return}if(/session not found/i.test(i.message)||o){Y(!1),q(null),J(!1),L(t,n,!0),z(t,n),_e(t,n,`idle`),ge(t,n,null),$();return}Y(!1),q(e(`terminalView.error.connectionFailed`,{message:i.message})),J(!0),L(t,n,!1),z(t,n),_e(t,n,`exited`),ge(t,n,null),$()}}},i);ke.current=()=>{s.close(),Ae.current=null}},[ve,z,$,Ke,tt,L,_e,ge,e,a]);D.useEffect(()=>{let t=!1;if(!(!F||!$e)){if(!N){q(e(se?`terminalView.empty.noWorkingDirectory`:`terminalView.empty.selectSession`));return}return(async()=>{let n=N;if(!Ne.current||Ne.current!==n)return;ue(n);let r=w.getState().getDirectoryState(n);if(!r||r.tabs.length===0)return;let i=A?r.activeTabId??r.tabs[0]?.id??null:r.tabs[0]?.id??null;if(!i)return;let o=r.tabs.find(e=>e.id===i)??r.tabs[0],s=o?.terminalSessionId??null,c=o?.lifecycle??`idle`,l=!!o?.label?.startsWith(`Action:`),u=(o?.bufferLength??0)>0||(o?.bufferChunks?.length??0)>0;if(s)return;if(c===`exited`){L(n,i,!1);return}if(l&&u){L(n,i,!1);return}let d=Fe.current;if(!(!d&&Le.current)){q(null),J(!1),Y(!1),L(n,i,!0);try{let e=await a.createSession({cwd:n,cols:d?.cols,rows:d?.rows});if(!(!t&&Ne.current===n&&je.current===i)){try{await a.close(e.sessionId)}catch{}return}if(w.getState().getDirectoryState(n)?.tabs.find(e=>e.id===i)?.terminalSessionId){try{await a.close(e.sessionId)}catch{}return}ge(n,i,e.sessionId)}catch(r){t||(q(r instanceof Error?r.message:e(`terminalView.error.startSessionFailed`)),J(!0),Y(!1),L(n,i,!1))}}})(),()=>{t=!0}}},[se,N,W,be,H,$e,De,A,F,ue,L,ge,e,a]);let rt=D.useRef(nt);rt.current=nt;let it=D.useRef($);it.current=$,D.useEffect(()=>{if(!F||!$e)return;if(!N){it.current();return}let e=N,t=w.getState().getDirectoryState(e);if(!t||t.tabs.length===0){it.current();return}let n=A?t.activeTabId??t.tabs[0]?.id??null:t.tabs[0]?.id??null;if(!n){it.current();return}let r=t.tabs.find(e=>e.id===n)??t.tabs[0],i=r?.terminalSessionId??null;if(!i){it.current(),Me.current=null;return}if(Ae.current===i&&ke.current){Me.current=i;return}Me.current=i;let a=Be.current.has(i),o=a&&(r?.bufferLength??0)===0&&(r?.bufferChunks?.length??0)===0;a&&Be.current.delete(i),o&&(ze.current=i),rt.current(e,n,i,a?fe:de,a)},[N,W,H,A,$e,F]),D.useEffect(()=>{if(!Q||k)return;if(typeof window>`u`){Ke();return}let e=window.requestAnimationFrame(()=>{Ke()});return()=>{window.cancelAnimationFrame(e)}},[H,Ke,Q,k]);let at=D.useCallback(async()=>{if(!N||Te)return;let t=w.getState().getDirectoryState(N),n=A?H??t?.activeTabId??t?.tabs[0]?.id??null:t?.tabs[0]?.id??null;if(n){Ee(!0),q(null),J(!1),Y(!1),$(),z(N,n),Ge();try{await he(N,n)}catch(t){q(t instanceof Error?t.message:e(`terminalView.error.restartFailed`)),J(!0),Y(!1)}finally{Ee(!1)}}},[H,z,he,$,N,A,Te,Ge,e]),ot=D.useCallback(async()=>{await at()},[at]),st=D.useCallback(()=>{if(!N)return;let e=I(N);me(N,e),q(null),J(!1),Y(!1),$()},[I,$,N,me]),ct=D.useCallback(e=>{N&&(me(N,e),q(null),J(!1),Y(!1),$())},[$,N,me]),lt=D.useCallback(e=>{N&&(e===H&&$(),q(null),J(!1),Y(!1),he(N,e))},[H,he,$,N]),ut=D.useCallback(t=>{if(!t||we)return;let n=t,r=!1;if(X&&t.length>0){let e=t[0];if(e.length===1&&/[a-zA-Z]/.test(e)){let t=e.toUpperCase();(X===`ctrl`||X===`cmd`)&&(n=String.fromCharCode(t.charCodeAt(0)&31),r=!0)}r||=!0}let i=Me.current;!i||Re.current!==i||(a.sendInput(i,n).catch(t=>{we||q(t instanceof Error?t.message:e(`terminalView.error.sendInputFailed`))}),r&&(Z(null),qe()))},[X,qe,we,Z,e,a]),dt=D.useCallback((e,t)=>{let n=Fe.current;if((!n||n.cols!==e||n.rows!==t)&&(Fe.current={cols:e,rows:t}),Ie.current||(Ie.current=!0,Oe(e=>e+1)),!Le.current)return;let r=Me.current;!r||Re.current!==r||a.resize({sessionId:r,cols:e,rows:t}).catch(()=>{})},[a]),ft=D.useCallback(e=>{Z(t=>t===e?null:e),qe()},[qe,Z]),pt=D.useCallback(e=>{let t=pe(e,X);t&&(ut(t),Z(null),qe())},[X,qe,ut,Z]);D.useEffect(()=>{if(!j||!X||!W)return;let e=e=>{if(e.repeat)return;let t=e.key;if(!t||t===`Control`||t===`Meta`||t===`Alt`||t===`Shift`)return;let n=t.length===1?t.toLowerCase():t,r=e.code??``,i=r.startsWith(`Key`)&&r.length===4?r.slice(3).toUpperCase():null,a=t.length===1&&/[a-zA-Z]/.test(t)?t.toUpperCase():i,o={Tab:`tab`,Enter:`enter`,ArrowUp:`arrow-up`,ArrowDown:`arrow-down`,ArrowLeft:`arrow-left`,ArrowRight:`arrow-right`,Escape:`esc`,tab:`tab`,enter:`enter`,arrowup:`arrow-up`,arrowdown:`arrow-down`,arrowleft:`arrow-left`,arrowright:`arrow-right`,escape:`esc`};if(n in o){e.preventDefault(),e.stopPropagation(),pt(o[n]);return}if(X===`ctrl`&&a&&a.length===1&&a>=`A`&&a<=`Z`){let t=String.fromCharCode(a.charCodeAt(0)&31);e.preventDefault(),e.stopPropagation(),ut(t),Z(null),qe()}};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[X,pt,ut,qe,j,Z,W]);let mt=D.useMemo(()=>{let e=n[t].stack;if(typeof window>`u`)return(n[c]??n[`system-mono`]).stack;let r=window.getComputedStyle(document.documentElement).getPropertyValue(`--font-family-mono`);return r&&r.trim().length>0?r.trim():(n[c]??n[`system-mono`]).stack??e},[c]),ht=D.useMemo(()=>te(s),[s]),gt=D.useMemo(()=>`${N??`no-dir`}::${H??`no-tab`}`,[N,H]);if(D.useEffect(()=>{if(!Q||k)return;let e=Pe.current;if(!e)return;let t=()=>{e.fit()};if(typeof window<`u`){let e=window.requestAnimationFrame(()=>{t(),Ke()}),n=[220,400].map(e=>window.setTimeout(t,e));return()=>{window.cancelAnimationFrame(e),n.forEach(e=>window.clearTimeout(e))}}t()},[Ke,Q,k,gt,W]),D.useEffect(()=>{if(k||!Q||!Ye)return;let e=Pe.current;if(!e)return;let t=()=>{e.fit()};if(typeof window<`u`){let e=window.requestAnimationFrame(()=>{t()}),n=[0,80,180,320].map(e=>window.setTimeout(t,e));return()=>{window.cancelAnimationFrame(e),n.forEach(e=>window.clearTimeout(e))}}t()},[d,f,Ye,Q,k]),!se)return(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground`,children:e(`terminalView.empty.selectSession`)});if(!N)return(0,O.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground`,children:[(0,O.jsx)(`p`,{children:e(`terminalView.empty.noWorkingDirectoryForSession`)}),(0,O.jsx)(`button`,{onClick:at,className:`rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:e(`terminalView.actions.retry`)})]});let _t=!W||Se||Te||we,vt=$e,yt=!re&&Ye&&!Qe,bt=(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(v,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>pt(`esc`),disabled:_t,children:e(`terminalView.quickKeys.escape`)}),(0,O.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>pt(`tab`),disabled:_t,children:[(0,O.jsx)(_,{name:`arrow-right`,className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.tabAria`)})]}),(0,O.jsxs)(v,{type:`button`,size:`sm`,variant:`chip`,"aria-pressed":X===`ctrl`,className:`h-6 w-9 p-0`,onClick:()=>ft(`ctrl`),disabled:_t,children:[(0,O.jsx)(`span`,{className:`text-xs font-medium`,children:e(`terminalView.quickKeys.controlLabel`)}),(0,O.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.controlModifierAria`)})]}),(0,O.jsxs)(v,{type:`button`,size:`sm`,variant:`chip`,"aria-pressed":X===`cmd`,className:`h-6 w-9 p-0`,onClick:()=>ft(`cmd`),disabled:_t,children:[(0,O.jsx)(_,{name:`command`}),(0,O.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.commandModifierAria`)})]}),(0,O.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>pt(`arrow-up`),disabled:_t,children:[(0,O.jsx)(_,{name:`arrow-up`}),(0,O.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowUpAria`)})]}),(0,O.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>pt(`arrow-left`),disabled:_t,children:[(0,O.jsx)(_,{name:`arrow-left`}),(0,O.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowLeftAria`)})]}),(0,O.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>pt(`arrow-down`),disabled:_t,children:[(0,O.jsx)(_,{name:`arrow-down`}),(0,O.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowDownAria`)})]}),(0,O.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>pt(`arrow-right`),disabled:_t,children:[(0,O.jsx)(_,{name:`arrow-right`}),(0,O.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowRightAria`)})]}),(0,O.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>pt(`enter`),disabled:_t,children:[(0,O.jsx)(_,{name:`arrow-go-back`}),(0,O.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.enterAria`)})]})]});return(0,O.jsxs)(`div`,{"data-terminal-view":`true`,className:`flex h-full flex-col overflow-hidden bg-[var(--surface-background)]`,children:[(0,O.jsxs)(`div`,{className:g(`app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs`,re?`px-3 py-1.5`:`pl-3 pr-1.5 py-1`),children:[A&&V?(0,O.jsxs)(`div`,{className:`flex items-center gap-2 pl-1 pr-1`,children:[(0,O.jsx)(`div`,{className:g(`min-w-0 flex-1`,re?`h-8`:`h-7`),children:(0,O.jsx)(C,{items:ye,activeId:H,onSelect:ct,onClose:lt,layoutMode:`scrollable`,variant:`default`,className:`h-full bg-transparent`})}),(0,O.jsx)(v,{type:`button`,size:`xs`,variant:`ghost`,className:g(`shrink-0`,re?`h-8 w-8 p-0`:`h-7 w-7 p-0`),onClick:st,title:e(`terminalView.tabs.newTabTitle`),children:(0,O.jsx)(_,{name:`add`,className:`${re?`h-[18px] w-[18px]`:`h-4 w-4`}`})}),(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 overflow-visible`,children:[G?(0,O.jsxs)(v,{type:`button`,size:`xs`,variant:`outline`,className:`h-6 shrink-0 gap-1 px-2`,onClick:()=>{N&&B(N,G)},title:e(`terminalView.preview.openTitle`),children:[(0,O.jsx)(_,{name:`global`,className:`h-3.5 w-3.5 shrink-0`}),(0,O.jsx)(`span`,{className:`whitespace-nowrap`,children:e(`terminalView.preview.open`)})]}):null,yt?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(v,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>Ze(!f),className:g(`shrink-0 p-0`,p?`h-8 w-8`:`h-7 w-7`),title:e(f?`terminalView.bottomDock.restoreTitle`:`terminalView.bottomDock.expandTitle`),"aria-label":e(f?`terminalView.bottomDock.restoreAria`:`terminalView.bottomDock.expandAria`),children:f?(0,O.jsx)(_,{name:`fullscreen-exit`,className:`h-4 w-4`}):(0,O.jsx)(_,{name:`fullscreen`,className:`h-4 w-4`})}),(0,O.jsx)(v,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>Xe(!1),className:g(`shrink-0 p-0`,p?`h-8 w-8`:`h-7 w-7`),title:e(`terminalView.bottomDock.closeTitle`),"aria-label":e(`terminalView.bottomDock.closeAria`),children:(0,O.jsx)(_,{name:`close`,className:`h-4 w-4`})})]}):null]})]}):null,!p&&j&&A&&V?(0,O.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1`,children:bt}):null,j&&(p||!A||!V)?(0,O.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1`,children:bt}):null]}),(0,O.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,style:{backgroundColor:ht.background},children:[(0,O.jsx)(`div`,{className:`h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4`,children:vt?(0,O.jsx)(ae,{ref:e=>{Pe.current=e},sessionKey:gt,chunks:xe,onInput:ut,onResize:dt,theme:ht,fontFamily:mt,fontSize:u,enableTouchScroll:k,autoFocus:!k&&Q,isVisible:Q},gt):null}),!we&&K&&(0,O.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 bg-[var(--status-error-background)] px-3 py-2 text-xs text-[var(--status-error-foreground)] flex items-center justify-between gap-2`,children:[(0,O.jsx)(`span`,{children:K}),Ce&&p&&(0,O.jsx)(v,{size:`sm`,variant:`secondary`,className:`h-6 px-2 py-0 text-xs`,onClick:ot,disabled:Te,title:e(`terminalView.actions.hardRestartTitle`),type:`button`,children:e(`terminalView.actions.hardRestart`)})]})]})]})};export{me as TerminalView};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRendererImpl-B9Bv95Vd.js","assets/rolldown-runtime-C0FnF6B9.js","assets/useUIStore-WQV8IuFw.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-base-ui-CnHfUmDN.js","assets/persistence-CFtygeYy.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/vendor-reactuses-core-DDoDDyM9.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/i18n-BAqcSln8.js","assets/store-CS6l6pH7.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/ui-D5j3JxkE.js","assets/gitApiHttp-BswZXfrf.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/vendor-sonner-DVzioF3d.js","assets/useAssistantUIStore-DGtjM827.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/utils-Cwlw2GM0.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-DMzWVJaW.js","assets/markdownTheme-CNJf24L-.js","assets/vendor-pierre-diffs-BenIz2TM.js","assets/vendor-hast-util-to-html-B0p1k5Xa.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-DpDied8H.js","assets/useRuntimeAPIs-DSLXJybW.js","assets/url-BSalv2ov.js","assets/markdown-worker-DmBYud1m.js","assets/useEffectiveDirectory-CssNtlqg.js","assets/FadeInOnReveal-1KpYuooP.js","assets/vendor-morphdom-BbKiNDAu.js","assets/vendor-beautiful-mermaid-DykqIK5D.js","assets/vendor-marked-WVekxjAN.js","assets/vendor-remend-C3cXc-tf.js","assets/vendor-katex-CNGgSigB.js","assets/vendor-dompurify-CeJNOzik.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{nt as t,rt as n}from"./vendor-base-ui-CnHfUmDN.js";import{a as r,n as i,o as a}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as o}from"./vendor-react-DLPElpoQ.js";import{n as s}from"./vendor-reactuses-core-DDoDDyM9.js";import{di as c}from"./ui-D5j3JxkE.js";import{t as l}from"./utils-Cwlw2GM0.js";import{a as u,c as d,i as f}from"./markdown-worker-DmBYud1m.js";import{r as p}from"./vendor-pierre-diffs-BenIz2TM.js";var m=o(),h=e(n(),1),g=`openchamber:chunk-import-reload`,_=250,v=3e4,y=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function b(e){if(e instanceof Error)return`${e.name}\n${e.message}\n${e.stack??``}`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function x(e){let t=b(e);return y.some(e=>e.test(t))}function ee(e){return`1.17.1-beta.13:${b(e).slice(0,500)}`}function S(e){if(typeof window>`u`)return;let t=Date.now(),n=ee(e),r=null;try{let e=window.sessionStorage.getItem(g);if(e)try{r=JSON.parse(e)}catch{r=null}}catch{return}let i=typeof r?.timestamp==`number`?r.timestamp:0;if(!(r?.signature===n&&t-i<v)){try{window.sessionStorage.setItem(g,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:b(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function te(e,t={}){let n=t.retries??1,r;for(let t=0;t<=n;t+=1)try{return await e()}catch(e){if(r=e,!x(e)||t>=n)break;await new Promise(e=>setTimeout(e,_*(t+1)))}throw x(r)&&S(r),r}var C=e=>(0,h.lazy)(()=>te(e)),w=`__openchamberMobileBackRoute`,T=()=>typeof window>`u`||c()?null:{currentState:()=>window.history.state&&typeof window.history.state==`object`?window.history.state:null,pushState:e=>window.history.pushState(e,``,window.location.href),back:()=>window.history.back(),subscribe:e=>{let t=t=>e(t.state&&typeof t.state==`object`?t.state:null);return window.addEventListener(`popstate`,t),()=>window.removeEventListener(`popstate`,t)}},E=e=>{let t=e?.[w];return typeof t==`number`&&Number.isFinite(t)?t:null},D=new class{routes=[];listeners=new Set;nextToken=1;history;removeHistoryListener=null;programmaticHistoryBackToken=null;pendingHistoryRemovals=new Map;animatedBackDriver=null;presentationCancelDriver=null;constructor(e=T()){this.history=e}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getTopRoute=()=>this.routes.at(-1)??null;register=e=>{let t=this.pendingHistoryRemovals.get(e.id);this.pendingHistoryRemovals.delete(e.id);let n=!!(this.history&&t!==void 0&&E(this.history.currentState())===t),r={...e,token:n&&t!==void 0?t:this.nextToken++};this.routes.push(r),this.ensureHistoryListener(),this.history&&!n&&this.history.pushState({...this.history.currentState()??{},[w]:r.token}),this.notify();let i=!0;return()=>{if(!i)return;i=!1;let e=this.routes.indexOf(r);e<0||(this.routes.splice(e,1),this.history&&E(this.history.currentState())===r.token?(this.pendingHistoryRemovals.set(r.id,r.token),queueMicrotask(()=>{if(this.pendingHistoryRemovals.get(r.id)===r.token){if(this.pendingHistoryRemovals.delete(r.id),!this.history||E(this.history.currentState())!==r.token){this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener();return}this.programmaticHistoryBackToken=r.token,this.history.back(),this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener()}})):this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener(),this.notify())}};backImmediately=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:t.onBack()!==!1};requestAnimatedBack=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:this.animatedBackDriver?.(t)?!0:this.backImmediately(e)};setAnimatedBackDriver=e=>(this.animatedBackDriver=e,()=>{this.animatedBackDriver===e&&(this.animatedBackDriver=null)});setPresentationCancelDriver=e=>(this.presentationCancelDriver=e,()=>{this.presentationCancelDriver===e&&(this.presentationCancelDriver=null)});cancelPresentation=()=>{this.presentationCancelDriver?.()};requestBrowserBack=()=>{let e=this.getTopRoute();return e?this.history&&E(this.history.currentState())===e.token?(this.history.back(),!0):e.onBack()!==!1:!1};ensureHistoryListener(){!this.history||this.removeHistoryListener||(this.removeHistoryListener=this.history.subscribe(e=>{if(this.programmaticHistoryBackToken!==null){this.programmaticHistoryBackToken=null;return}let t=this.getTopRoute();t&&E(e)!==t.token&&t.onBack()===!1&&this.history&&this.history.pushState({...this.history.currentState()??{},[w]:t.token})}))}disposeHistoryListener(){this.removeHistoryListener?.(),this.removeHistoryListener=null,this.programmaticHistoryBackToken=null,this.pendingHistoryRemovals.clear()}notify(){this.listeners.forEach(e=>e())}},ne=e=>{let t=(0,m.c)(8),{id:n,active:r,layer:i,onBack:a,surfaceRef:o,underlayRef:c}=e,l=i===void 0?`root`:i,u=s(a),d,f;t[0]!==r||t[1]!==u||t[2]!==n||t[3]!==l||t[4]!==o||t[5]!==c?(d=()=>{if(r)return D.register({id:n,layer:l,onBack:u,getSurface:()=>o.current,getUnderlay:()=>c?.current??null})},f=[r,u,n,l,o,c],t[0]=r,t[1]=u,t[2]=n,t[3]=l,t[4]=o,t[5]=c,t[6]=d,t[7]=f):(d=t[6],f=t[7]),h.useEffect(d,f)},O=r(`OpenChamberNavigation`),k=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),A=(e,t)=>!e||!t?!1:e.onBack()!==!1,j=e=>{let t=k(e.progress),n=e.commit?1-t:t;if(n<=.001)return 0;let r=Math.max(1,e.viewportWidth??390),i=Math.abs(e.velocityX??0)/r,a=n/Math.max(e.commit?2.4:2.8,i)*1e3,o=e.commit?90:100,s=e.commit?320:260;return Math.round(Math.min(s,Math.max(o,a)))},M=e=>{let{surface:t,underlay:n,surfaceTransition:r,surfaceAnimation:i,underlayTransition:a,underlayAnimation:o}=e;t.style.removeProperty(`transform`),t.style.removeProperty(`opacity`),t.style.removeProperty(`will-change`),t.style.removeProperty(`box-shadow`),t.style.transition=r,t.style.animation=i,n&&(n.style.removeProperty(`transform`),n.style.removeProperty(`opacity`),n.style.removeProperty(`will-change`),n.style.transition=a??``,n.style.animation=o??``)},N=(e,t)=>{let n=k(t),{surface:r}=e;r.style.transform=`translate3d(${n*100}%, 0, 0)`},re=e=>!e.surfaceConnected||e.topRouteToken!==e.routeToken||e.routeSurface!==e.outgoingSurface,ie=async(e,t,n,r)=>{if(!r&&typeof e.animate==`function`){let r=e.style.transform||`translate3d(0%, 0, 0)`,i=`translate3d(${t}%, 0, 0)`,a=e.animate([{transform:r},{transform:i}],{duration:n,easing:`cubic-bezier(0.22, 1, 0.36, 1)`,fill:`forwards`}),o=!1;try{await a.finished,o=!0}catch{}finally{o&&(e.style.transform=i),a.cancel()}return}e.style.transform=`translate3d(${t}%, 0, 0)`},ae=async(e,t,n=typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,r=j({progress:Number.parseFloat(e.style.transform.match(/translate3d\(([-\d.]+)%/)?.[1]??`0`)/100,commit:t}))=>ie(e,t?100:0,r,n),oe=class{pending=0;enqueue(){this.pending+=1}take(){return this.pending!==0&&(--this.pending,!0)}clear(){this.pending=0}},se=e=>{let t=(0,m.c)(4),{enabled:n,rootRoutesBlocked:r}=e,a,o;t[0]!==n||t[1]!==r?(a=()=>{if(!n||!c()||i.getPlatform()===`web`)return;let e=!1,t=null,a=null,o=0,s=0,l=0,u=new oe,d=[],f=e=>!!e&&(!r||e?.layer===`overlay`),p=()=>{let e=f(D.getTopRoute());O.setEnabled({enabled:e}).catch(ce)},m=()=>{if(D.cancelPresentation(),a)return;let e=D.getTopRoute();if(!f(e))return;let n=e.getSurface();if(!n)return;n.getAnimations().forEach(le),a=null;let r=e.layer===`root`?e.getUnderlay():null,i=n.style.transition,o=n.style.animation,s=r?.style.transition??null,c=r?.style.animation??null;r?.getAnimations().forEach(P),n.style.transition=`none`,n.style.animation=`none`,n.style.willChange=`transform`,r&&(r.style.removeProperty(`transform`),r.style.removeProperty(`will-change`)),l+=1,t={route:e,surface:n,underlay:r,surfaceTransition:i,surfaceAnimation:o,underlayTransition:s,underlayAnimation:c},N(t,0)},h=e=>{s=k(e),!o&&(o=window.requestAnimationFrame(()=>{o=0,t&&N(t,s)}))},g=F,_=(n,r,i)=>{if(a)return n&&f(D.getTopRoute())?(u.enqueue(),!0):!1;o&&=(window.cancelAnimationFrame(o),0),t||m(),t&&r!==void 0&&N(t,r);let c=t,d=l;if(t=null,!c){if(!n)return!1;let e=D.getTopRoute();return A(e,f(e))}a=c;let p=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,h=j({progress:k(r??s),commit:n,velocityX:i,viewportWidth:window.innerWidth});return ae(c.surface,n,p,h).then(async()=>{d===l&&(!e&&n&&(c.route.onBack(),await g(c)),d===l&&(M(c),a===c&&(a=null),!e&&u.take()&&_(!0,0,0)))}),!0},v=D.setAnimatedBackDriver(e=>e!==D.getTopRoute()||!f(e)?!1:_(!0,0,0)),y=D.subscribe(p);return(async()=>{let t=await O.addListener(`backStarted`,m),n=await O.addListener(`backProgressed`,e=>h(e.progress??0)),r=await O.addListener(`backCancelled`,e=>_(!1,e.progress,e.velocityX)),i=await O.addListener(`backInvoked`,e=>_(!0,e.progress,e.velocityX));if(e){await Promise.all([t.remove(),n.remove(),r.remove(),i.remove()]);return}d.push(t,n,r,i),p()})().catch(I),p(),()=>{e=!0,l+=1,u.clear(),y(),v(),o&&window.cancelAnimationFrame(o),t&&M(t),a&&(a.surface.getAnimations().forEach(L),a.underlay?.getAnimations().forEach(R),M(a)),t=null,a=null,O.setEnabled({enabled:!1}).catch(z),d.forEach(B)}},o=[n,r],t[0]=n,t[1]=r,t[2]=a,t[3]=o):(a=t[2],o=t[3]),h.useEffect(a,o)};function ce(){}function le(e){return e.cancel()}function P(e){return e.cancel()}function F(e){return new Promise(t=>{let n=0,r=12,i=!1,a=()=>{i||(i=!0,c(),n&&window.cancelAnimationFrame(n),t())},o=()=>{let t=D.getTopRoute();return re({surfaceConnected:e.surface.isConnected,routeToken:e.route.token,topRouteToken:t?.token??null,routeSurface:e.route.getSurface(),outgoingSurface:e.surface})},s=()=>{if(o()||r<=0){a();return}--r,n=window.requestAnimationFrame(s)},c=D.subscribe(()=>{o()&&a()});s()})}function I(){}function L(e){return e.cancel()}function R(e){return e.cancel()}function z(){}function B(e){e.remove()}var V=null,H=()=>(V??=a(()=>import(`./MarkdownRendererImpl-B9Bv95Vd.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47])).catch(e=>{throw V=null,e}),V),U=()=>{H().catch(()=>void 0)},W=h.createContext(!0),G=()=>h.useContext(W),K=t(),ue=C(()=>H().then(e=>({default:e.MarkdownRenderer}))),de=C(()=>H().then(e=>({default:e.SimpleMarkdownRenderer}))),fe=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,q=e=>{let t=(0,m.c)(14),n=typeof e.content==`string`?e.content:``,r=typeof e.variant==`string`?e.variant:`assistant`,i;t[0]!==n||t[1]!==e.reserveMeasuredHeight||t[2]!==r?(i=e.reserveMeasuredHeight?u(f(n,r)):void 0,t[0]=n,t[1]=e.reserveMeasuredHeight,t[2]=r,t[3]=i):i=t[3];let a=i,o;t[4]!==e.className||t[5]!==e.variant?(o=l(`relative break-words w-full min-w-0`,fe(e.variant),typeof e.className==`string`?e.className:void 0),t[4]=e.className,t[5]=e.variant,t[6]=o):o=t[6];let s;t[7]!==n||t[8]!==e.animated||t[9]!==a?(s=(0,K.jsx)(d,{animated:e.animated,content:n,reservedHeight:a}),t[7]=n,t[8]=e.animated,t[9]=a,t[10]=s):s=t[10];let c;return t[11]!==o||t[12]!==s?(c=(0,K.jsx)(`div`,{className:o,"aria-busy":`true`,"data-markdown-hydration":`deferred`,children:s}),t[11]=o,t[12]=s,t[13]=c):c=t[13],c},pe=e=>{let t=(0,m.c)(4);if(!G()&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,K.jsx)(q,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,K.jsx)(h.Suspense,{fallback:(0,K.jsx)(q,{...e,reserveMeasuredHeight:!0}),children:(0,K.jsx)(ue,{...e})}),t[2]=e,t[3]=n),n},me=e=>{let t=(0,m.c)(4);if(!G()){let n;return t[0]===e?n=t[1]:(n=(0,K.jsx)(q,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,K.jsx)(h.Suspense,{fallback:(0,K.jsx)(q,{...e}),children:(0,K.jsx)(de,{...e})}),t[2]=e,t[3]=n),n},he=e=>/^#[0-9a-fA-F]{6}$/.test(e),ge=e=>/^#[0-9a-fA-F]{8}$/.test(e),_e=(e,t)=>/^[0-9a-fA-F]{2}$/.test(t)?he(e)?`${e}${t}`:ge(e)?`${e.slice(0,7)}${t}`:e:e,J=(e,t)=>typeof e==`string`&&e.trim().length>0?e:t,Y=e=>{let t=e.colors.syntax.base,n=e.colors.syntax.tokens??{},r=(e,t)=>J(n[e],t);return[{name:`plain`,scope:[`source`,`support.type.property-name.css`],settings:{foreground:t.foreground}},{name:`classes`,scope:[`entity.name.type.class`],settings:{foreground:r(`className`,r(`class`,t.function))}},{name:`interfaces`,scope:[`entity.name.type.interface`,`entity.name.type`],settings:{foreground:r(`interface`,t.type)}},{name:`structs`,scope:[`entity.name.type.struct`],settings:{foreground:r(`struct`,t.function)}},{name:`enums`,scope:[`entity.name.type.enum`],settings:{foreground:r(`enum`,t.function)}},{name:`keys`,scope:[`meta.object-literal.key`,`support.type.property-name`],settings:{foreground:r(`key`,t.function)}},{name:`methods`,scope:[`entity.name.function.method`,`meta.function.method`],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`functions`,scope:[`entity.name.function`,`support.function`,`meta.function-call.generic`],settings:{foreground:t.function,fontStyle:`bold`}},{name:`variables`,scope:[`variable`,`meta.variable`,`variable.other.object.property`],settings:{foreground:t.variable}},{name:`variablesOther`,scope:[`variable.other.object`,`variable.other.readwrite.alias`],settings:{foreground:r(`variableOther`,r(`method`,e.colors.status.success))}},{name:`globalVariables`,scope:[`variable.other.global`,`variable.language.this`],settings:{foreground:r(`variableGlobal`,t.number)}},{name:`localVariables`,scope:[`variable.other.local`],settings:{foreground:r(`variableLocal`,e.colors.surface.elevated)}},{name:`parameters`,scope:[`variable.parameter`,`meta.parameter`],settings:{foreground:r(`parameter`,t.foreground)}},{name:`properties`,scope:[`variable.other.property`,`meta.property`],settings:{foreground:r(`variableProperty`,e.colors.status.info)}},{name:`strings`,scope:[`string`,`string.other.link`,`markup.inline.raw.string.markdown`],settings:{foreground:t.string}},{name:`stringEscapeSequences`,scope:[`constant.character.escape`,`constant.other.placeholder`],settings:{foreground:r(`stringEscape`,t.foreground)}},{name:`keywords`,scope:[`keyword`],settings:{foreground:t.keyword}},{name:`keywordsControl`,scope:[`keyword.control.import`,`keyword.control.from`,`keyword.import`],settings:{foreground:r(`keywordImport`,t.operator)}},{name:`storageModifiers`,scope:[`storage.modifier`,`keyword.modifier`,`storage.type`],settings:{foreground:r(`storageModifier`,t.keyword)}},{name:`comments`,scope:[`comment`,`punctuation.definition.comment`],settings:{foreground:t.comment}},{name:`docComments`,scope:[`comment.documentation`,`comment.line.documentation`],settings:{foreground:r(`commentDoc`,e.colors.surface.mutedForeground)}},{name:`numbers`,scope:[`constant.numeric`],settings:{foreground:t.number}},{name:`booleans`,scope:[`constant.language.boolean`,`constant.language.json`],settings:{foreground:r(`boolean`,t.type)}},{name:`operators`,scope:[`keyword.operator`],settings:{foreground:t.operator}},{name:`macros`,scope:[`entity.name.function.preprocessor`,`meta.preprocessor`],settings:{foreground:r(`macro`,t.keyword)}},{name:`preprocessor`,scope:[`meta.preprocessor`],settings:{foreground:r(`preprocessor`,r(`label`,t.number))}},{name:`urls`,scope:[`markup.underline.link`],settings:{foreground:r(`url`,e.colors.status.info)}},{name:`tags`,scope:[`entity.name.tag`],settings:{foreground:r(`tag`,t.keyword)}},{name:`jsxTags`,scope:[`support.class.component`],settings:{foreground:r(`jsxTag`,r(`label`,t.number))}},{name:`attributes`,scope:[`entity.other.attribute-name`,`meta.attribute`],settings:{foreground:r(`tagAttribute`,t.type)}},{name:`types`,scope:[`support.type`],settings:{foreground:t.type}},{name:`constants`,scope:[`variable.other.constant`,`variable.readonly`],settings:{foreground:r(`constant`,t.foreground)}},{name:`labels`,scope:[`entity.name.label`,`punctuation.definition.label`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`namespaces`,scope:[`entity.name.namespace`,`storage.modifier.namespace`,`markup.bold.markdown`],settings:{foreground:r(`namespace`,t.type)}},{name:`modules`,scope:[`entity.name.module`,`storage.modifier.module`],settings:{foreground:r(`module`,t.operator)}},{name:`typeParameters`,scope:[`variable.type.parameter`,`variable.parameter.type`],settings:{foreground:r(`typeParameter`,t.function)}},{name:`exceptions`,scope:[`keyword.control.exception`,`keyword.control.trycatch`],settings:{foreground:r(`exception`,r(`label`,t.number))}},{name:`decorators`,scope:[`meta.decorator`,`punctuation.decorator`,`entity.name.function.decorator`],settings:{foreground:r(`decorator`,t.type)}},{name:`calls`,scope:[`variable.function`],settings:{foreground:t.foreground}},{name:`punctuation`,scope:[`punctuation`,`punctuation.terminator`,`punctuation.definition.tag`,`punctuation.separator`,`punctuation.definition.string`,`punctuation.section.block`],settings:{foreground:r(`punctuation`,t.comment)}},{name:`yellow`,scope:[`storage.type.numeric.go`,`storage.type.byte.go`,`storage.type.boolean.go`,`storage.type.string.go`,`storage.type.uintptr.go`,`storage.type.error.go`,`storage.type.rune.go`,`constant.language.go`,`support.class.dart`,`keyword.other.documentation`,`storage.modifier.import.java`,`punctuation.definition.list.begin.markdown`,`punctuation.definition.quote.begin.markdown`,`meta.separator.markdown`,`entity.name.section.markdown`],settings:{foreground:t.type}},{name:`green`,scope:[],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`cyan`,scope:[`markup.italic.markdown`,`support.type.python`,`variable.legacy.builtin.python`,`support.constant.property-value.css`,`storage.modifier.attribute.swift`],settings:{foreground:t.string}},{name:`blue`,scope:[],settings:{foreground:t.keyword}},{name:`purple`,scope:[`keyword.channel.go`,`keyword.other.platform.os.swift`],settings:{foreground:t.number}},{name:`magenta`,scope:[`punctuation.definition.heading.markdown`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`red`,scope:[],settings:{foreground:t.operator}},{name:`orange`,scope:[],settings:{foreground:t.function}}]},ve=e=>{let t=e.colors.surface,n=e.colors.interactive,r=e.colors.status,i=e.colors.syntax.base,a=e.colors.syntax.highlights??{},o=J(a.diffAddedBackground,r.successBackground),s=J(a.diffRemovedBackground,r.errorBackground);return{"editor.background":t.background,"editor.foreground":t.foreground,"editor.hoverHighlightBackground":J(n.hover,t.subtle),"editor.lineHighlightBackground":t.muted,"editor.selectionBackground":n.selection,"editor.selectionHighlightBackground":n.selection,"editor.findMatchBackground":i.type,"editor.findMatchHighlightBackground":_e(i.type,`cc`),"editor.findRangeHighlightBackground":t.muted,"editor.inactiveSelectionBackground":t.elevated,"editor.lineHighlightBorder":t.elevated,"editor.rangeHighlightBackground":J(n.active,n.borderHover),"notifications.background":t.elevated,"editorInlayHint.typeBackground":t.subtle,"editorInlayHint.typeForeground":t.foreground,"editorWhitespace.foreground":n.borderHover,"editorIndentGuide.background1":t.subtle,"editorHoverWidget.background":t.elevated,"editorLineNumber.activeForeground":J(a.lineNumberActive,t.foreground),"editorLineNumber.foreground":J(a.lineNumber,t.mutedForeground),"editorGutter.background":t.background,"editorGutter.modifiedBackground":r.info,"editorGutter.addedBackground":r.success,"editorGutter.deletedBackground":r.error,"editorBracketMatch.background":t.elevated,"editorBracketMatch.border":t.subtle,"editorError.foreground":r.error,"editorWarning.foreground":r.warning,"editorInfo.foreground":r.info,"diffEditor.insertedTextBackground":o,"diffEditor.removedTextBackground":s,"editorGroupHeader.tabsBackground":t.background,"editorGroup.border":n.border,"tab.activeBackground":t.background,"tab.inactiveBackground":t.muted,"tab.inactiveForeground":t.mutedForeground,"tab.activeForeground":t.foreground,"tab.hoverBackground":t.subtle,"tab.unfocusedHoverBackground":t.subtle,"tab.border":n.border,"tab.activeModifiedBorder":i.type,"tab.inactiveModifiedBorder":r.info,"tab.unfocusedActiveModifiedBorder":i.type,"tab.unfocusedInactiveModifiedBorder":r.info,"editorWidget.background":t.muted,"editorWidget.border":n.border,"editorSuggestWidget.background":t.background,"editorSuggestWidget.border":n.border,"editorSuggestWidget.foreground":t.foreground,"editorSuggestWidget.highlightForeground":t.mutedForeground,"editorSuggestWidget.selectedBackground":t.subtle,"peekView.border":n.border,"peekViewEditor.background":t.background,"peekViewEditor.matchHighlightBackground":t.subtle,"peekViewResult.background":t.muted,"peekViewResult.fileForeground":t.foreground,"peekViewResult.lineForeground":t.mutedForeground,"peekViewResult.matchHighlightBackground":t.subtle,"peekViewResult.selectionBackground":t.elevated,"peekViewResult.selectionForeground":t.mutedForeground,"peekViewTitle.background":t.subtle,"peekViewTitleDescription.foreground":t.mutedForeground,"peekViewTitleLabel.foreground":t.foreground,"merge.currentHeaderBackground":r.success,"merge.currentContentBackground":J(a.diffAdded,r.success),"merge.incomingHeaderBackground":r.info,"merge.incomingContentBackground":J(a.diffModified,r.info),"merge.border":n.border,"merge.commonContentBackground":t.subtle,"merge.commonHeaderBackground":t.muted,"panel.background":t.background,"panel.border":n.border,"panelTitle.activeBorder":n.borderHover,"panelTitle.activeForeground":t.foreground,"panelTitle.inactiveForeground":t.mutedForeground,"statusBar.background":t.background,"statusBar.foreground":t.foreground,"statusBar.border":n.border,"statusBar.debuggingBackground":r.error,"statusBar.debuggingForeground":r.errorForeground,"statusBar.noFolderBackground":t.subtle,"statusBar.noFolderForeground":t.mutedForeground,"titleBar.activeBackground":t.background,"titleBar.activeForeground":t.foreground,"titleBar.inactiveBackground":t.muted,"titleBar.inactiveForeground":t.mutedForeground,"titleBar.border":n.border,"menu.foreground":t.foreground,"menu.background":t.background,"menu.selectionForeground":t.foreground,"menu.selectionBackground":t.subtle,"menu.border":n.border,"editorInlayHint.foreground":t.mutedForeground,"editorInlayHint.background":t.subtle,"terminal.foreground":t.foreground,"terminal.background":t.background,"terminalCursor.foreground":t.foreground,"terminalCursor.background":t.background,"terminal.ansiRed":J(a.diffRemoved,r.error),"terminal.ansiGreen":J(a.diffAdded,r.success),"terminal.ansiYellow":r.warning,"terminal.ansiBlue":J(a.diffModified,r.info),"terminal.ansiMagenta":i.keyword,"terminal.ansiCyan":i.type,"activityBar.background":t.background,"activityBar.foreground":t.foreground,"activityBar.inactiveForeground":t.mutedForeground,"activityBar.activeBorder":t.foreground,"activityBar.border":n.border,"sideBar.background":t.background,"sideBar.foreground":t.foreground,"sideBar.border":n.border,"sideBarTitle.foreground":t.foreground,"sideBarSectionHeader.background":t.muted,"sideBarSectionHeader.foreground":t.foreground,"sideBarSectionHeader.border":n.border,"sideBar.activeBackground":t.subtle,"sideBar.activeForeground":t.foreground,"sideBar.hoverBackground":t.muted,"sideBar.hoverForeground":t.foreground,"list.warningForeground":r.warning,"list.errorForeground":r.error,"list.inactiveSelectionBackground":t.subtle,"list.activeSelectionBackground":t.elevated,"list.inactiveSelectionForeground":t.foreground,"list.activeSelectionForeground":t.foreground,"list.hoverForeground":t.foreground,"list.hoverBackground":t.muted,"input.background":t.muted,"input.foreground":t.foreground,"input.border":n.border,"input.placeholderForeground":t.mutedForeground,"inputOption.activeBorder":n.border,"inputOption.activeBackground":t.elevated,"inputOption.activeForeground":t.foreground,"inputValidation.infoBackground":r.infoBackground,"inputValidation.infoBorder":r.infoBorder,"inputValidation.warningBackground":r.warningBackground,"inputValidation.warningBorder":r.warningBorder,"inputValidation.errorBackground":r.errorBackground,"inputValidation.errorBorder":r.errorBorder,"dropdown.background":t.muted,"dropdown.foreground":t.foreground,"dropdown.border":n.border,"dropdown.listBackground":t.background,"badge.background":e.colors.primary.base,"activityBarBadge.background":e.colors.primary.base,"button.background":e.colors.primary.base,"button.foreground":J(e.colors.primary.foreground,t.background),"badge.foreground":J(e.colors.primary.foreground,t.background),"activityBarBadge.foreground":J(e.colors.primary.foreground,t.background)}};function ye(e){return{name:e.metadata.name,type:e.metadata.variant,colors:ve(e),tokenColors:Y(e)}}var be=e=>/^#[0-9a-fA-F]{8}$/.test(e),X=e=>be(e)?e.slice(0,7):e;function xe(e,t){return Object.defineProperty(e,"toString",{value:()=>t,enumerable:!1,configurable:!0}),Object.defineProperty(e,Symbol.toPrimitive,{value:()=>t,enumerable:!1,configurable:!0}),e}var Z=new Map,Q=new Set,Se=(e,t)=>{let n=e.colors?.[`editor.background`],r=e.colors?.[`editor.foreground`],i=n?X(n):void 0,a=r?X(r):void 0;if(!i||!a)throw Error(`Theme "${t}" is missing editor.background/editor.foreground`);let o=e.tokenColors??[];return xe({...e,name:t,fg:a,bg:i,settings:o},t)},Ce=e=>ye(e),$=e=>{let t=Z.get(e.metadata.id);if(t)return t;let n=Se(Ce(e),e.metadata.id);return Z.set(e.metadata.id,n),n},we=e=>{let t=e.metadata.id;if(Q.has(t))return;let n=$(e);p(t,async()=>n),Q.add(t)};export{W as a,ne as c,me as i,se as l,$ as n,U as o,pe as r,D as s,we as t,C as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e}from"./useUIStore-WQV8IuFw.js";import{Kt as t,kn as n,qt as r}from"./persistence-CFtygeYy.js";var i=e=>typeof e==`object`&&!!e,a=e=>e.trim().toLowerCase()===`authorization`,o=e=>{if(!i(e))return;let t={};for(let[n,r]of Object.entries(e)){let e=n.trim(),i=typeof r==`string`?r.trim():``;!e||!i||/[\r\n:]/.test(e)||/[\r\n]/.test(i)||a(e)||(t[e]=i)}return Object.keys(t).length>0?t:void 0},s=`connect-link`,c=(e,t)=>e.source===`connect-link`||e.relay||e.viaSshRelay||e.sshTarget?!0:t.has(e.id),l=e=>`relay://${e}`,u=e=>{if(!i(e))return null;let t=g(e,`relayUrl`)||g(e,`relay_url`),n=g(e,`serverId`)||g(e,`server_id`),r=e.hostEncPubJwk??e.host_enc_pub_jwk;return!t||!n||!i(r)?null:{relayUrl:t,serverId:n,hostEncPubJwk:r}},d=/^(t|.*(?:token|auth|secret|api).*)$/i,f=e=>{let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:t.split(`#`)[0]||null}catch{return null}},p=e=>{let t=f(e);if(!t)return null;try{let e=new URL(t);if((e.pathname.replace(/\/+$/,``)||`/`)===`/connect`&&e.searchParams.has(`t`))return{persistedUrl:e.origin,redeemUrl:e.toString(),kind:`tunnel-connect-link`}}catch{return null}return{persistedUrl:t,redeemUrl:null,kind:`normal-host`}},m=e=>{let t=f(e);if(!t)return e;try{let e=new URL(t);(e.username||e.password)&&(e.username=``,e.password=``);let n=Array.from(new Set(Array.from(e.searchParams.keys())));for(let t of n)d.test(t)&&e.searchParams.set(t,`[REDACTED]`);return e.toString()}catch{return t}},h=(e,t)=>{let n=f(e),r=f(t);if(!n||!r)return!1;try{let e=new URL(n),t=new URL(r);if(e.origin!==t.origin||t.search&&e.search!==t.search)return!1;let i=t.pathname.length>1?t.pathname.replace(/\/+$/,``):t.pathname,a=e.pathname.length>1?e.pathname.replace(/\/+$/,``):e.pathname;return i===`/`||a===i||a.startsWith(`${i}/`)}catch{return!1}},g=(e,t)=>{let n=e[t];return typeof n==`string`?n:null},_=(e,t)=>{let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null},v=e=>{if(!i(e))return null;let t=_(e,`localPort`)??_(e,`local_port`);return t===null||!Number.isInteger(t)||t<1||t>65535?null:{localPort:t}},y=e=>{if(!i(e))return null;let t=g(e,`hostId`)||g(e,`host_id`),n=g(e,`desktopClientToken`)||g(e,`desktop_client_token`);return!t?.trim()||!n?.trim()?null:{hostId:t.trim(),desktopClientToken:n.trim()}},b=e=>{if(!i(e))return null;let t=g(e,`id`),n=g(e,`label`),r=g(e,`url`),a=g(e,`apiUrl`)||g(e,`api_url`),c=g(e,`clientToken`)||g(e,`client_token`),l=o(e.requestHeaders),d=u(e.relay),f=v(e.viaSshRelay??e.via_ssh_relay),p=y(e.sshTarget??e.ssh_target),m=g(e,`source`)===`connect-link`?s:void 0;return!t||!n||!r&&!f&&!(p&&d)?null:{id:t,label:n,url:r||``,...a?{apiUrl:a}:{},...c?{clientToken:c}:{},...l?{requestHeaders:l}:{},...d?{relay:d}:{},...f?{viaSshRelay:f}:{},...p?{sshTarget:p}:{},...m?{source:m}:{}}},x=e=>{if(!i(e))return[];let t=e.hosts;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!i(e))continue;let t=g(e,`id`),r=g(e,`label`),a=_(e,`localPort`)??_(e,`local_port`);!t||!r||a===null||!Number.isInteger(a)||a<1||a>65535||n.push({id:t,label:r,url:``,apiUrl:``,viaSshRelay:{localPort:a}})}return n},S=e=>f(e.apiUrl||e.url)||e.apiUrl||e.url,C=()=>t()?(e,t)=>r(e,t):null,w=async()=>{let e=C();if(!e){let e=await n(`/api/openchamber/desktop-hosts`);if(!e.ok)throw Error(`desktop-hosts failed: ${e.status}`);return{hosts:x(await e.json().catch(()=>null)),defaultHostId:null,initialHostChoiceCompleted:!1}}let t=await e(`desktop_hosts_get`);if(!i(t))return{hosts:[],defaultHostId:null,initialHostChoiceCompleted:!1};let r=t.hosts;return{hosts:Array.isArray(r)?r.map(b).filter(e=>!!e):[],defaultHostId:g(t,`defaultHostId`)||g(t,`default_host_id`)||g(t,`defaultHostID`),initialHostChoiceCompleted:t.initialHostChoiceCompleted===!0||t.initial_host_choice_completed===!0,localOrigin:g(t,`localOrigin`)||g(t,`local_origin`)}},T=async(e,t)=>{let r=e.trim();if(!r)throw Error(`ssh-host-token requires hostId`);let a=await(t?.fetch??((e,t)=>n(e,t)))(`/api/openchamber/ssh-host-token`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...t?.headers||{}},body:JSON.stringify({hostId:r,...t?.pairingId?.trim()?{pairingId:t.pairingId.trim()}:{}})});if(!a.ok)throw Error(`ssh-host-token failed: ${a.status}`);let o=await a.json().catch(()=>null);if(!i(o))throw Error(`ssh-host-token missing token`);let s=typeof o.token==`string`?o.token.trim():``;if(!s)throw Error(`ssh-host-token missing token`);let c=o.localPort??o.local_port,l=typeof c==`number`&&Number.isFinite(c)?Math.round(c):null,u=o.reachable===!0&&l!==null&&Number.isInteger(l)&&l>=1&&l<=65535;return{token:s,localPort:u||l!==null&&Number.isInteger(l)?l:null,reachable:u}},E=async e=>{let t=C();if(!t)return;let n={hosts:e.hosts,defaultHostId:e.defaultHostId,initialHostChoiceCompleted:e.initialHostChoiceCompleted};e.localClientToken!==void 0&&(n.localClientToken=e.localClientToken),await t(`desktop_hosts_set`,{input:n})},D=async()=>{let e=C();if(!e)return``;let t=await e(`desktop_local_client_token_get`).catch(()=>null);return typeof t==`string`?t.trim():``},O=async()=>{let e=C();if(!e)return``;let t=await e(`desktop_install_id_get`).catch(()=>null);return typeof t==`string`?t.trim():``},k=8e3,A=async(t,n)=>{let r=e({relayUrl:t.relayUrl,serverId:t.serverId,hostEncPubJwk:t.hostEncPubJwk}),i=Date.now(),a=!1;try{let e,t,o,s=n?.sshTarget;if(s?.hostId&&s.desktopClientToken){let n=await T(s.hostId,{fetch:(e,t)=>r.fetch(e,t),headers:{Authorization:`Bearer ${s.desktopClientToken}`}}).catch(()=>null);if(!n?.reachable||typeof n.localPort!=`number`)return{status:`unreachable`,latencyMs:0};t=n.localPort,o=n.token,e={"x-openchamber-target-port":String(n.localPort)}}return(await Promise.race([r.fetch(`/health`,e?{headers:e}:void 0),new Promise(e=>{let t=window.setTimeout(()=>e(null),k);typeof t!=`number`&&typeof t.unref==`function`&&t.unref()})]))?.ok?(a=n?.keepTunnel===!0,{status:`ok`,latencyMs:Math.max(0,Date.now()-i),...a?{tunnel:r}:{},...t===void 0?{}:{localPort:t},...o?{sshToken:o}:{}}):{status:`unreachable`,latencyMs:0}}catch{return{status:`unreachable`,latencyMs:0}}finally{a||r.close()}},j=async(e,t)=>{let n=C();if(!n)return{status:`unreachable`,latencyMs:0};let r=await n(`desktop_host_probe`,{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0,expectedServerId:t?.expectedServerId||void 0});if(!i(r))return{status:`unreachable`,latencyMs:0};let a=r.status;return{status:a===`ok`||a===`auth`||a===`update-recommended`||a===`incompatible`||a===`wrong-service`||a===`unreachable`?a:`unreachable`,latencyMs:_(r,`latencyMs`)??_(r,`latency_ms`)??0}},M=async(e,t)=>{let n=C();n&&await n(`desktop_new_window_at_url`,{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0})},N=async e=>{let t=C();t&&await t(`desktop_new_window_for_host`,{hostId:e})};export{p as _,O as a,N as c,h as d,f,T as g,l as h,E as i,S as l,m,j as n,D as o,A as p,w as r,M as s,s as t,c as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,E as t,J as n,M as r,Y as i}from"./useUIStore-WQV8IuFw.js";import{Zt as a,kn as o}from"./persistence-CFtygeYy.js";import{f as s,g as c,i as l,l as u,n as d,p as f,r as p}from"./desktopHosts-RE7NIkeq.js";var m=e=>e===`unreachable`||e===`wrong-service`||e===`incompatible`,h=e=>e.id===`local`?`local`:`host:${e.id}`,g=e=>t()===h(e),_=t=>{let i={relayUrl:t.relay.relayUrl,serverId:t.relay.serverId,hostEncPubJwk:t.relay.hostEncPubJwk,...t.relay.grant?{grant:t.relay.grant}:{}};t.liveTunnel&&n(i,t.liveTunnel),r({apiBaseUrl:typeof window<`u`?window.location.origin:``,clientToken:t.token,runtimeKey:t.runtimeKey,relay:i,requestHeaders:{[e]:String(t.localPort)}})},v=async(e,t)=>{let n=t?.relay||e.relay||i();if(!n)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};try{let r=t?.sshToken||e.clientToken||``,i=t?.localPort??e.viaSshRelay?.localPort??null;if(!r||typeof i!=`number`||!Number.isInteger(i)||i<1||i>65535||e.sshTarget){let n=e.sshTarget?.hostId||e.id,a=e.sshTarget?.desktopClientToken,o=await c(n,{...t?.liveTunnel?{fetch:(e,n)=>t.liveTunnel.fetch(e,n)}:{},...a?{headers:{Authorization:`Bearer ${a}`}}:{}});if(!o.reachable||typeof o.localPort!=`number`)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`};r=o.token,i=o.localPort}return!r||typeof i!=`number`||!Number.isInteger(i)||i<1||i>65535?{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`}:(_({token:r,localPort:i,runtimeKey:h(e),relay:n,liveTunnel:t?.liveTunnel}),{ok:!0,via:`relay`,status:{status:`ok`,latencyMs:0,via:`relay`}})}catch{return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`}}},y=async(e,t)=>{if(!a())return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};if(e.sshTarget&&e.relay){let n=t?.cachedProbe;if(n?.status===`ok`&&n.via===`relay`)return v(e,{relay:e.relay});let r=await f(e.relay,{keepTunnel:!0,sshTarget:e.sshTarget}).catch(()=>({status:`unreachable`,latencyMs:0}));return r.status===`ok`?v(e,{relay:e.relay,liveTunnel:`tunnel`in r?r.tunnel:void 0,localPort:`localPort`in r?r.localPort:void 0,sshToken:`sshToken`in r?r.sshToken:void 0}):{ok:!1,status:{status:r.status,latencyMs:r.latencyMs},reason:`unreachable`}}let i=s(u(e))||``;if(!i&&!e.relay)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`};let o=(t,i)=>{i&&n({relayUrl:t.relayUrl,serverId:t.serverId,hostEncPubJwk:t.hostEncPubJwk},i),r({apiBaseUrl:typeof window<`u`?window.location.origin:``,clientToken:e.clientToken||null,runtimeKey:h(e),relay:t}),e.sshTarget||w(e.id)},c=t=>{r({apiBaseUrl:t,clientToken:e.clientToken||null,requestHeaders:e.requestHeaders||null,runtimeKey:h(e)})},l=t?.cachedProbe;if(l?.status===`ok`){if(l.via===`relay`&&e.relay)return o(e.relay),{ok:!0,via:`relay`,status:l};if(i&&l.via!==`relay`)return c(i),{ok:!0,via:`direct`,status:l};if(e.relay)return o(e.relay),{ok:!0,via:`relay`,status:{...l,via:`relay`}}}let p={status:`unreachable`,latencyMs:0},g=null,_;if(i){let t=await d(i,{clientToken:e.clientToken||null,requestHeaders:e.requestHeaders||null}).catch(()=>({status:`unreachable`,latencyMs:0}));p={status:t.status,latencyMs:t.latencyMs},m(t.status)||(g=`direct`)}if(!g&&e.relay){let t=await f(e.relay,{keepTunnel:!0}).catch(()=>({status:`unreachable`,latencyMs:0}));t.status===`ok`?(p={status:t.status,latencyMs:t.latencyMs,via:`relay`},g=`relay`,_=`tunnel`in t?t.tunnel:void 0):i||(p={status:t.status,latencyMs:t.latencyMs})}return g?g===`relay`&&e.relay?(o(e.relay,_),{ok:!0,via:`relay`,status:p}):(c(i),{ok:!0,via:`direct`,status:p}):{ok:!1,status:p,reason:`unreachable`}},b=5e3,x=1500,S=!1,C=async e=>{if(!a()||S)return;let n=`host:${e}`;if(t()===n){S=!0;try{let i=await p().catch(()=>null),a=i?.hosts.find(t=>t.id===e);if(!i||!a?.relay||a.sshTarget)return;let c=a.apiUrl?s(a.apiUrl):null;if(c&&c.startsWith(`https://`))return;let u=await o(`/api/client-auth/connection/candidates`).catch(()=>null);if(!u?.ok)return;let f=await u.json().catch(()=>null);if(!f||f.serverId!==a.relay.serverId)return;let m=Array.isArray(f.candidates)?f.candidates:[],h=[];for(let e of m){if(!e||typeof e!=`object`)continue;let t=e;if(t.type!==`lan`||typeof t.url!=`string`)continue;let n=s(t.url);n&&!h.includes(n)&&h.push(n)}if(h.length===0)return;let g=c&&h.includes(c)?c:h[0];g!==c&&await l({hosts:i.hosts.map(t=>t.id===e?{...t,apiUrl:g}:t),defaultHostId:i.defaultHostId,initialHostChoiceCompleted:i.initialHostChoiceCompleted}).catch(()=>void 0);let _=await d(g,{clientToken:a.clientToken||null,requestHeaders:a.requestHeaders||null,expectedServerId:a.relay.serverId}).catch(()=>({status:`unreachable`,latencyMs:0}));if(_.status===`unreachable`||_.status===`wrong-service`||_.status===`incompatible`||t()!==n)return;r({apiBaseUrl:g,clientToken:a.clientToken||null,requestHeaders:a.requestHeaders||null,runtimeKey:n})}finally{S=!1}}},w=e=>{typeof window>`u`||window.setTimeout(()=>{C(e).catch(()=>void 0)},b)},T=async e=>{if(!a())return;let n=await p().catch(()=>null);if(!n)return;let i=e||(n.defaultHostId===`local`?null:n.defaultHostId);if(!i)return;let o=n.hosts.find(e=>e.id===i);if(!o?.relay)return;let c=h(o);if(t()===c)return;if(o.sshTarget){let e=await f(o.relay,{keepTunnel:!0,sshTarget:o.sshTarget}).catch(()=>({status:`unreachable`,latencyMs:0}));if(e.status!==`ok`||!(`localPort`in e)||typeof e.localPort!=`number`)return;_({token:`sshToken`in e&&e.sshToken||o.clientToken||``,localPort:e.localPort,runtimeKey:c,relay:o.relay,liveTunnel:`tunnel`in e?e.tunnel:void 0});return}let l=e=>{r({apiBaseUrl:e,clientToken:o.clientToken||null,requestHeaders:o.requestHeaders||null,runtimeKey:c})},m=()=>{r({apiBaseUrl:typeof window<`u`?window.location.origin:``,clientToken:o.clientToken||null,runtimeKey:c,relay:o.relay??void 0}),w(o.id)},g=o.apiUrl?s(u(o)):null;if(!g){m();return}let v=e=>e.status!==`unreachable`&&e.status!==`wrong-service`&&e.status!==`incompatible`,y=d(g,{clientToken:o.clientToken||null,requestHeaders:o.requestHeaders||null,expectedServerId:o.relay.serverId}).catch(()=>({status:`unreachable`,latencyMs:0})),b=await Promise.race([y,new Promise(e=>setTimeout(()=>e(null),x))]);if(b){if(v(b)){l(g);return}m();return}m(),y.then(e=>{v(e)&&t()===c&&l(g)})};export{y as a,h as i,_ as n,v as o,g as r,T as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$ as t,J as n,K as r,Q as i,X as a,Y as o,Z as s,nt as c,q as l,rt as u}from"./vendor-base-ui-CnHfUmDN.js";import{n as d}from"./vendor-react-DLPElpoQ.js";import{t as f}from"./i18n-BAqcSln8.js";import{t as p}from"./utils-Cwlw2GM0.js";import{n as m}from"./Icon-Vc-aDche.js";var h=d(),g=e(u(),1),_=c(),v=0;function y(e,t){return e&&g.isValidElement(t)?{render:t}:{children:t}}function b(e){let t=(0,h.c)(4),r;t[0]===e?r=t[1]:({...r}=e,t[0]=e,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,_.jsx)(n,{...r}),t[2]=r,t[3]=i),i}function x(e){let t=(0,h.c)(10),n,i,a;t[0]===e?(n=t[1],i=t[2],a=t[3]):({asChild:n,children:i,...a}=e,t[0]=e,t[1]=n,t[2]=i,t[3]=a);let o;t[4]!==n||t[5]!==i?(o=y(n,i),t[4]=n,t[5]=i,t[6]=o):o=t[6];let s=o,c;return t[7]!==a||t[8]!==s?(c=(0,_.jsx)(r,{"data-slot":`dialog-trigger`,...a,...s}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function S(e){let t=(0,h.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,_.jsx)(o,{...n}),t[2]=n,t[3]=r),r}var C=g.forwardRef((e,n)=>{let r=(0,h.c)(10),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],r[3]=o):o=r[3],g.useEffect(A,o);let s=n,c;r[4]===i?c=r[5]:(c=p(`fixed inset-0 z-50 bg-black/50 dark:bg-black/75`,`transition-opacity duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`,i),r[4]=i,r[5]=c);let l;return r[6]!==a||r[7]!==s||r[8]!==c?(l=(0,_.jsx)(t,{ref:s,"data-slot":`dialog-overlay`,className:c,...a}),r[6]=a,r[7]=s,r[8]=c,r[9]=l):l=r[9],l});C.displayName=`DialogOverlay`;function w(e){let t=(0,h.c)(29),n,r,o,s,c,l;t[0]===e?(n=t[1],r=t[2],o=t[3],s=t[4],c=t[5],l=t[6]):({className:r,overlayClassName:s,containerClassName:o,children:n,showCloseButton:l,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=o,t[4]=s,t[5]=c,t[6]=l);let u=l===void 0||l,{t:d}=f(),g;t[7]===s?g=t[8]:(g=p(`rounded-none`,s),t[7]=s,t[8]=g);let v;t[9]===g?v=t[10]:(v=(0,_.jsx)(C,{className:g}),t[9]=g,t[10]=v);let y=o??`items-center p-4`,b;t[11]===y?b=t[12]:(b=p(`fixed inset-0 z-50 flex justify-center pointer-events-none`,y),t[11]=y,t[12]=b);let x;t[13]===r?x=t[14]:(x=p(`relative pointer-events-auto bg-background text-foreground flex flex-col w-full max-w-lg max-h-full gap-4 rounded-xl border p-6 shadow-none overflow-y-auto pwa-dialog-content origin-center`,`transition-all duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]`,`data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]`,`data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]`,r),t[13]=r,t[14]=x);let w;t[15]!==u||t[16]!==d?(w=u&&(0,_.jsxs)(i,{"data-slot":`dialog-close`,className:`ring-offset-background focus:ring-ring data-[open]:bg-interactive-active data-[open]:text-foreground absolute top-2 right-2 rounded-lg opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none text-muted-foreground hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,_.jsx)(m,{name:`close`}),(0,_.jsx)(`span`,{className:`sr-only`,children:d(`dialog.common.actions.close`)})]}),t[15]=u,t[16]=d,t[17]=w):w=t[17];let T;t[18]!==n||t[19]!==c||t[20]!==x||t[21]!==w?(T=(0,_.jsxs)(a,{"data-slot":`dialog-content`,"data-state-slot":`dialog`,className:x,...c,children:[n,w]}),t[18]=n,t[19]=c,t[20]=x,t[21]=w,t[22]=T):T=t[22];let E;t[23]!==b||t[24]!==T?(E=(0,_.jsx)(`div`,{className:b,children:T}),t[23]=b,t[24]=T,t[25]=E):E=t[25];let D;return t[26]!==v||t[27]!==E?(D=(0,_.jsxs)(S,{children:[v,E]}),t[26]=v,t[27]=E,t[28]=D):D=t[28],D}function T(e){let t=(0,h.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`flex flex-col gap-2 text-center sm:text-left`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,_.jsx)(`div`,{"data-slot":`dialog-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function E(e){let t=(0,h.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`flex flex-col-reverse gap-2 bottom-safe-area sm:flex-row sm:justify-end`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,_.jsx)(`div`,{"data-slot":`dialog-footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function D(e){let t=(0,h.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`typography-markdown leading-none font-semibold text-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,_.jsx)(l,{"data-slot":`dialog-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function O(e){let t=(0,h.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`text-muted-foreground typography-ui-label`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,_.jsx)(s,{"data-slot":`dialog-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function k(){v=Math.max(0,v-1),v===0&&document.documentElement.classList.remove(`oc-dialog-open`)}function A(){return v+=1,document.documentElement.classList.add(`oc-dialog-open`),k}export{T as a,E as i,w as n,D as o,O as r,x as s,b as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Kt as t,Xt as n,qt as r}from"./persistence-CFtygeYy.js";import{nt as i,rt as a}from"./vendor-base-ui-CnHfUmDN.js";import{n as o}from"./vendor-react-DLPElpoQ.js";import{a as s,i as c,o as l,t as u}from"./store-CS6l6pH7.js";async function d(e){let t=null;if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),{ok:!0,method:`clipboard`}}catch(e){t=e instanceof Error?e.message:String(e)}if(typeof document<`u`&&document.body){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-1000px`,t.style.left=`-1000px`,document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);let n=document.execCommand(`copy`);if(document.body.removeChild(t),n)return{ok:!0,method:`execCommand`}}return{ok:!1,error:t??`Clipboard access denied in current context`}}var f=e(a(),1),p=o(),m=async(e,n)=>{if(!t())throw Error(`Desktop runtime is not available`);return r(e,n)},h=async()=>{if(n())try{await m(`desktop_start_window_drag`)}catch{}},g=async e=>{if(n())try{await m(`desktop_set_window_title`,{title:e})}catch{}},_=async(e,t)=>{if(n())try{await m(`desktop_set_window_theme`,{themeMode:e,themeVariant:t})}catch{}},v=async e=>{if(n())try{await m(`desktop_set_menu_locale`,{locale:e})}catch{}},y=async()=>{if(!n())return null;try{let e=await m(`desktop_get_app_version`);return typeof e==`string`&&e.trim().length>0?e:null}catch{return null}},b=f.createContext(null),x=i(),S=e=>{let t=(0,p.c)(19),{children:n}=e,r=c(C),i=c(w),a=c(T),o=c(E),d,m;t[0]===r?(d=t[1],m=t[2]):(d=()=>{typeof document>`u`||(document.documentElement.lang=r)},m=[r],t[0]=r,t[1]=d,t[2]=m),f.useEffect(d,m);let h,g;t[3]!==a||t[4]!==r?(h=()=>{a===null&&v(r)},g=[r,a],t[3]=a,t[4]=r,t[5]=h,t[6]=g):(h=t[5],g=t[6]),f.useEffect(h,g);let _;t[7]===i?_=t[8]:(_=(e,t)=>u(i,e,t),t[7]=i,t[8]=_);let y=_,S;t[9]===y?S=t[10]:(S=e=>y(l[e]),t[9]=y,t[10]=S);let D;t[11]!==r||t[12]!==o||t[13]!==y||t[14]!==S?(D={locale:r,locales:s,setLocale:o,label:S,t:y},t[11]=r,t[12]=o,t[13]=y,t[14]=S,t[15]=D):D=t[15];let O=D,k;return t[16]!==n||t[17]!==O?(k=(0,x.jsx)(b.Provider,{value:O,children:n}),t[16]=n,t[17]=O,t[18]=k):k=t[18],k};function C(e){return e.locale}function w(e){return e.dictionary}function T(e){return e.loadingLocale}function E(e){return e.setLocale}var D={en:`en-US`,fr:`fr-FR`,"zh-CN":`zh-CN`,"zh-TW":`zh-TW`,uk:`uk-UA`,es:`es-ES`,"pt-BR":`pt-BR`,ko:`ko-KR`,pl:`pl-PL`,ja:`ja-JP`},O=e=>D[e]??`en-US`,k=()=>O(c.getState().locale);function A(){let e=f.useContext(b);if(!e)throw Error(`useI18n must be used within I18nProvider`);return e}export{m as a,h as c,y as i,d as l,k as n,_ as o,S as r,g as s,A as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{D as t,b as n,j as r,t as i,y as a}from"./useUIStore-WQV8IuFw.js";import{$t as o,D as s,d as c,k as l,u,xn as d}from"./persistence-CFtygeYy.js";import{a as f,i as p,r as m}from"./vendor-zustand-B4dlGEM2.js";import{nt as h,rt as g}from"./vendor-base-ui-CnHfUmDN.js";import{L as _,Ot as v,k as y,yt as b}from"./gitApiHttp-BswZXfrf.js";import{n as x}from"./vendor-react-DLPElpoQ.js";import{s as S}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as C}from"./vendor-reactuses-core-DDoDDyM9.js";import{t as ee}from"./i18n-BAqcSln8.js";import{Ki as te,S as ne,Ya as re,ct as ie,d as w,do as ae,fn as T,fo as E,lt as D,nn as oe,ut as se,xr as ce,y as O}from"./ui-D5j3JxkE.js";import{c as le,t as k}from"./utils-Cwlw2GM0.js";import{n as A}from"./Icon-Vc-aDche.js";import{g as j,v as M}from"./gitApi-DV6F5KKI.js";import{A as ue,M as N,p as P,s as F}from"./projectMeta-WJhNyk90.js";var I=e(g(),1),L=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},R=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,z=(e,t)=>{let n=L(t),r=L(e);if(!n||!r)return!1;let i=R(n),a=R(r);return a===i||a.startsWith(`${i}/`)},de=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=L(e);if(!t||!r||typeof r!=`object`)continue;let i=r,a=Array.isArray(i.openPaths)?Array.from(new Set(i.openPaths.filter(e=>typeof e==`string`).map(e=>L(e)).filter(e=>z(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>L(e)).filter(e=>z(e,t)))):[],s=typeof i.selectedPath==`string`?L(i.selectedPath):null,c=s&&z(s,t)?s:a[0]??null,l=typeof i.touchedAt==`number`&&Number.isFinite(i.touchedAt)?i.touchedAt:Date.now(),u=n[t];if(u){let e=Array.from(new Set([...u.openPaths,...a])),r=Array.from(new Set([...u.expandedPaths,...o]));n[t]={openPaths:e,selectedPath:u.selectedPath??c??e[0]??null,expandedPaths:r,touchedAt:Math.max(u.touchedAt,l)};continue}n[t]={openPaths:a,selectedPath:c,expandedPaths:o,touchedAt:l}}return n},B=(e,t)=>{let n=Object.entries(e);if(n.length<=t)return e;n.sort((e,t)=>(t[1]?.touchedAt??0)-(e[1]?.touchedAt??0));let r={};for(let[e,i]of n.slice(0,t))r[e]=i;return r},V=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},fe=f()(m(p((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=L((t||``).trim()),a=L((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!z(a,i)||e(e=>{let t=e.byRoot[i],n=V(t),r=n.openPaths.includes(a),o=r?n.openPaths:[...n.openPaths,a],s=n.selectedPath??a;return t&&r&&t.selectedPath===s?e:{byRoot:B({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=R(i),a=e=>R(e)===n,o=t.selectedPath?a(t.selectedPath):!1;if(!t.openPaths.some(a)&&!o)return e;let s=t.openPaths.filter(e=>!a(e)),c=o?s[0]??null:t.selectedPath;return{byRoot:B({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=R(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=R(e);return t===n||t.startsWith(a)},s=t.openPaths.filter(e=>!o(e));if(s.length===t.openPaths.length)return e;let c=t.selectedPath&&o(t.selectedPath)?s[0]??null:t.selectedPath;return{byRoot:B({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=R(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=R(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:B({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=L((t||``).trim()),a=n?L(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!z(a,i)||e(e=>{let t=e.byRoot[i],n=V(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:B({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=L((e||``).trim());if(!n)return;let r=t().byRoot[n];if(!r||r.selectedPath)return;let i=r.openPaths[0]??null;i&&t().setSelectedPath(n,i)},toggleExpandedPath:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||!z(i,r)||e(e=>{let t=e.byRoot[r],n=V(t),a=n.expandedPaths.includes(i)?n.expandedPaths.filter(e=>e!==i):[...n.expandedPaths,i];return t&&t.expandedPaths===a&&t.selectedPath===n.selectedPath&&t.openPaths===n.openPaths?e:{byRoot:B({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||!z(i,r)||e(e=>{let t=e.byRoot[r],n=V(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:B({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=L((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>L((e||``).trim())).filter(e=>e&&z(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=V(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:B({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:a(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:de(t)}},partialize:e=>({byRoot:de(e.byRoot)})}),{name:`files-view-tabs-store`})),H=x(),pe=(e,t)=>{let n=(0,H.c)(4),r=t===void 0?200:t,[i,a]=I.useState(e),o,s;return n[0]!==r||n[1]!==e?(o=()=>{let t=window.setTimeout(()=>{a(e)},r);return()=>{window.clearTimeout(t)}},s=[e,r],n[0]=r,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),I.useEffect(o,s),i},me=()=>{let e=(0,H.c)(17),t=w(U),n=T(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=ne(r),a=w(W),o=w(G),s=E(K),c=E(he),l=b(ge);if(t){let r;e[2]===i?r=e[3]:(r=O(i),e[2]=i,e[3]=r);let o=r;if(o)return o;let s;e[4]!==t||e[5]!==a?(s=a.get(t),e[4]=t,e[5]=a,e[6]=s):s=e[6];let c=s;if(c?.path)return c.path;let l;if(e[7]!==t||e[8]!==n){let r;e[10]===t?r=e[11]:(r=e=>e.id===t,e[10]=t,e[11]=r),l=n.find(r),e[7]=t,e[8]=n,e[9]=l}else l=e[9];let u=l;if(u?.directory)return u.directory}if(o?.open&&(o.bootstrapPendingDirectory||o.directoryOverride))return(o.bootstrapPendingDirectory||o.directoryOverride)??void 0;if(s){let t;if(e[12]!==s||e[13]!==c){let n;e[15]===s?n=e[16]:(n=e=>e.id===s,e[15]=s,e[16]=n),t=c.find(n),e[12]=s,e[13]=c,e[14]=t}else t=e[14];let n=t;if(n?.path)return n.path}return l??void 0};function U(e){return e.currentSessionId}function W(e){return e.worktreeMetadata}function G(e){return e.newSessionDraft}function K(e){return e.activeProjectId}function he(e){return e.projects}function ge(e){return e.currentDirectory}var _e=.4,q=8,J=e=>{let t=e.gap??q,n=Math.max(0,e.popupBottom-e.boundaryTop-t),r=e.viewportHeight*_e,i=Math.floor(Math.min(n,r));return n>=120?Math.min(n,Math.max(120,i)):i},Y=(e,t=0)=>{let n=e.closest(`main`);if(!n)return null;let r=(e.closest(`.mobile-chat-screen__content`)?.parentElement??n.parentElement?.closest(`main`)??n).querySelector(`:scope > .oc-mobile-detail-navigation`)?.getBoundingClientRect().bottom,i=n.getBoundingClientRect().top;return Math.max(r===void 0?i:Math.max(r,i),t)},ve=(e,t)=>{let n=(0,H.c)(3),[r,i]=I.useState(void 0),a;return n[0]!==e||n[1]!==t?(a=()=>{if(!t)return;let n=()=>{let t=e.current;if(!t)return;let n=window.visualViewport,r=Y(t,n?.offsetTop??0);if(r===null)return;let a=n?.height??window.innerHeight,o=J({popupBottom:t.getBoundingClientRect().bottom,boundaryTop:r,viewportHeight:a});i(e=>e===o?e:o)};return n(),window.addEventListener(`resize`,n),window.addEventListener(`oc:keyboard-settled`,n),window.visualViewport?.addEventListener(`resize`,n),window.visualViewport?.addEventListener(`scroll`,n),()=>{window.removeEventListener(`resize`,n),window.removeEventListener(`oc:keyboard-settled`,n),window.visualViewport?.removeEventListener(`resize`,n),window.visualViewport?.removeEventListener(`scroll`,n)}},n[0]=e,n[1]=t,n[2]=a):a=n[2],I.useLayoutEffect(a),t?r:void 0},ye=()=>{let e=null,t=!1,n=!1;return{pointerDown:(n,r)=>{e={x:n,y:r},t=!1},pointerMove:(n,r)=>{e&&Math.hypot(n-e.x,r-e.y)>6&&(t=!0)},pointerCancel:()=>{e=null,t=!1},pointerUp:r=>{if(!e)return!1;let i=!t;return e=null,t=!1,i?(n=!0,r(),!0):(n=!0,!1)},click:e=>n?(n=!1,!1):(e(),!0)}},X=h(),Z=I.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSessionSelect:r,onClose:a,style:o},c)=>{let{t:u}=ee(),d=me()??``,f=w(e=>e.currentSessionId),p=ce(e=>e.activeSessions),m=E(e=>e.activeProjectId),h=E(e=>e.projects),g=I.useMemo(()=>h.find(e=>e.id===m)?.path??null,[m,h]),_=I.useMemo(()=>{let e=g||d;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[g,d]),y=fe(e=>_?e.byRoot[_]:void 0),b=te(e=>e.getVisibleAgents),x=v(e=>e.searchFiles),S=pe(e,180),ne=l(),re=s(),[ae,T]=I.useState([]),[oe,se]=I.useState([]),[O,j]=I.useState(!1),[M,N]=I.useState(0),P=I.useRef(0),[F,L]=I.useState(360),[R,z]=I.useState({}),[de,B]=I.useState({}),V=I.useRef([]),H=I.useRef([]),U=I.useRef([]),W=I.useRef(null),G=I.useRef(null);G.current||=ye();let K=i(e=>e.isMobile),he=ve(W,K),ge=(e??``).trim(),_e=I.useMemo(()=>{if(!_||!y)return[];let e=[y.selectedPath,...y.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=ge.toLowerCase();return e.filter(e=>{if(t.has(e))return!1;t.add(e);let r=e.startsWith(`${_}/`)?e.slice(_.length+1):e;return!n||r.toLowerCase().includes(n)}).slice(0,6).map(e=>{let t=e.replace(/\\/g,`/`),n=t.split(`/`).filter(Boolean).pop()||t;return{name:n,path:t,relativePath:t.startsWith(`${_}/`)?t.slice(_.length+1):t,extension:n.includes(`.`)?n.split(`.`).pop()?.toLowerCase():void 0}})},[ge,_,y]),q=I.useMemo(()=>ge.length>0?oe:oe.slice(0,2),[oe,ge.length]),J=I.useMemo(()=>r?ie({sessions:p,currentSessionId:f,searchQuery:ge}):[],[p,f,ge,r]),Y=_e,Z=ae;I.useEffect(()=>{let e=e=>{let t=e.target;!t||!W.current||W.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),I.useEffect(()=>{if(!d){T([]);return}let e=(S??``).trim().replace(/^\.\//,``).replace(/^\/+/,``).toLowerCase();if(!e){T([]);return}let t=!1;j(!0);let n={includeHidden:ne,respectGitignore:!re};return Promise.all([x(d,e,80,{...n,type:`file`}),x(d,e,40,{...n,type:`directory`})]).then(([n,r])=>{if(t)return;let i=new Set(_e.map(e=>e.path));T(D({files:n,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{t||T([])}).finally(()=>{t||j(!1)}),()=>{t=!0}},[d,S,_e,x,ne,re]),I.useEffect(()=>{let t=b(),n=(e??``).trim().toLowerCase(),r=t.filter(e=>e.mode&&e.mode!==`primary`).filter(e=>!n||`${e.name} ${e.description??``}`.toLowerCase().includes(n)).map(e=>({name:e.name,description:e.description,mode:e.mode})).sort((e,t)=>e.name.localeCompare(t.name));se(r)},[b,e]),I.useEffect(()=>{N(0),z({}),B({})},[Z,Y.length,q.length,J.length]),I.useEffect(()=>{P.current=M},[M]),I.useEffect(()=>{V.current[M]?.scrollIntoView({block:`nearest`})},[M]),I.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};H.current.forEach((n,r)=>{if(!n)return;let i=U.current[r]?.offsetWidth??n.scrollWidth,a=Math.max(0,i-n.clientWidth),o=a>8;if(e[r]=o,o){let e=Math.max(.6,a/110);t[r]=e}}),z(e),B(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[Z,Y]),I.useEffect(()=>{let e=H.current[M];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&L(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[M]);let be=C(e=>{t(e)}),xe=C(e=>{n?.(e)}),Se=C(e=>{r?.(e)}),Ce=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&G.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&G.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(G.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>G.current?.pointerCancel(),onClick:()=>{G.current?.click(t)},onMouseMove:()=>N(e)});I.useImperativeHandle(c,()=>({handleKeyDown:e=>{if(e===`Escape`){a();return}let t=q.length+J.length+Y.length+Z.length;if(t!==0){if(e===`ArrowDown`){N(e=>(e+1)%t);return}if(e===`ArrowUp`){N(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){let e=(P.current%t+t)%t;if(e<q.length){let t=q[e];t&&xe(t.name);return}let n=e-q.length;if(n<J.length){let e=J[n];e&&Se(e);return}let r=n-J.length,i=r<Y.length?Y[r]:Z[r-Y.length];i&&be(i)}}}}),[Z,Y,q,J,a,be,xe,Se]);let we=e=>{if(e.isDirectory)return(0,X.jsx)(A,{name:`folder-3-fill`,className:`h-3.5 w-3.5 text-current`});switch(e.extension?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:return(0,X.jsx)(A,{name:`code`,className:`h-3.5 w-3.5 text-current`});case`json`:return(0,X.jsx)(A,{name:`code`,className:`h-3.5 w-3.5 text-current`});case`md`:case`mdx`:return(0,X.jsx)(A,{name:`file`,className:`h-3.5 w-3.5 text-current`});case`png`:case`jpg`:case`jpeg`:case`gif`:case`svg`:return(0,X.jsx)(A,{name:`file-image`,className:`h-3.5 w-3.5 text-current`});default:return(0,X.jsx)(A,{name:`file-pdf`,className:`h-3.5 w-3.5 text-current`})}};return(0,X.jsxs)(`div`,{ref:W,className:`absolute z-[100] min-w-0 w-full max-w-[640px] max-h-64 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col`,style:he===void 0?o:{...o,maxHeight:he},children:[(0,X.jsx)(ue,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,X.jsxs)(`div`,{className:`pb-2`,children:[q.length>0&&(0,X.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.agents`)}),q.map((e,t)=>(0,X.jsx)(`div`,{ref:e=>{V.current[t]=e},className:k(`flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,M===t&&`bg-interactive-selection text-interactive-selection-foreground`),...Ce(t,()=>xe(e.name)),children:(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`font-semibold truncate`,children:[`@`,e.name]}),e.description&&!K?(0,X.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:e.description}):null]})},`agent-${e.name}`)),q.length===2&&ge.length===0&&oe.length>2&&(0,X.jsx)(`div`,{className:`px-3 py-1 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.searchMoreAgents`)}),J.length>0&&(0,X.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.sessions`)}),J.map((e,t)=>{let n=q.length+t;return(0,X.jsxs)(`div`,{ref:e=>{V.current[n]=e},className:k(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,M===n&&`bg-interactive-selection text-interactive-selection-foreground`),...Ce(n,()=>Se(e)),children:[(0,X.jsx)(A,{name:`chat-thread`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title||u(`chat.fileMentionAutocomplete.untitledSession`),children:e.title||u(`chat.fileMentionAutocomplete.untitledSession`)}),K?null:(0,X.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.sessionType`)})]},`session-${e.id}`)}),Y.length>0&&(0,X.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.recentFiles`)}),Y.map((e,t)=>{let n=q.length+J.length+t,r=e.relativePath||e.name,i=le(r,{maxLength:60}),a=M===n,o=R[n]??!1,s=de[n]??2.6;return(0,X.jsxs)(`div`,{ref:e=>{V.current[n]=e},className:k(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,a&&`bg-interactive-selection text-interactive-selection-foreground`),...Ce(n,()=>be(e)),children:[we(e),(0,X.jsxs)(`span`,{ref:e=>{H.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${F}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,X.jsx)(`span`,{ref:e=>{U.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,X.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,X.jsx)(`span`,{className:`block truncate`,children:i})]})]},`recent-${e.path}`)}),Z.length>0&&(0,X.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.files`)}),Z.map((e,t)=>{let n=q.length+J.length+Y.length+t,r=e.relativePath||e.name,i=le(r,{maxLength:60}),a=M===n,o=R[n]??!1,s=de[n]??2.6;return(0,X.jsxs)(`div`,{ref:e=>{V.current[n]=e},className:k(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,a&&`bg-interactive-selection text-interactive-selection-foreground`),...Ce(n,()=>be(e)),children:[we(e),(0,X.jsxs)(`span`,{ref:e=>{H.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${F}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,X.jsx)(`span`,{ref:e=>{U.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,X.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,X.jsx)(`span`,{className:`block truncate`,children:i})]})]},e.path)}),O&&Z.length===0?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,X.jsx)(A,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!O&&Z.length===0&&Y.length===0&&q.length===0&&J.length===0&&(0,X.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.empty`)})]})}),!K&&(0,X.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})}),be=new Set([`new`,`fork`,`compact`,`undo`,`redo`,`model`,`goal`]),xe=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&be.has(n))},Se=(e,t)=>!e||t({name:e}),Ce=` `,we=(e,t)=>{let n=Math.max(0,Math.min(t,e.length)),r=n;for(;r>0&&!/\s/.test(e[r-1]);)--r;return r>=2&&e[r-1]===Ce&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},Te=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Ee=k(Te,`bg-[color-mix(in_srgb,var(--primary-base)_12%,transparent)] text-[color-mix(in_srgb,var(--primary-base)_70%,transparent)] border-[color-mix(in_srgb,var(--primary-base)_24%,transparent)]`),De=k(Te,`bg-[color-mix(in_srgb,var(--status-success)_12%,transparent)] text-[color-mix(in_srgb,var(--status-success)_70%,transparent)] border-[color-mix(in_srgb,var(--status-success)_24%,transparent)]`),Oe=k(Te,`bg-[color-mix(in_srgb,var(--status-info)_12%,transparent)] text-[color-mix(in_srgb,var(--status-info)_70%,transparent)] border-[color-mix(in_srgb,var(--status-info)_24%,transparent)]`),ke=k(Te,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),Ae=(e,t)=>{let n=t.trim();if(!n)return[...e].sort((e,t)=>e.isBuiltIn===t.isBuiltIn?e.name.localeCompare(t.name):e.isBuiltIn?-1:1);let r=se(e,n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.isBuiltIn===t.item.isBuiltIn?e.item.name.localeCompare(t.item.name):e.item.isBuiltIn?-1:1:e.score-t.score),r.map(e=>e.item)},je=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!o()}},Me=I.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:a,commandPolicy:o,commandContext:s},c)=>{let{t:l}=ee(),u=i(e=>e.isMobile),d=w(e=>e.currentSessionId),f=w(e=>!!e.newSessionDraft?.open),p=w(I.useCallback(e=>d?e.getDirectoryForSession(d):void 0,[d])),m=oe(d??``,p??void 0),h=I.useMemo(()=>s??{sessionID:d??null,hasMessages:m.length>0,hasNewDraft:f},[s,d,m.length,f]),{hasSession:g,canStartSessionCommand:_,canUseReviewHandoffFlow:v}=I.useMemo(()=>je(h,u),[h,u]),y=h.hasMessages,[b,x]=I.useState([]),[S,C]=I.useState(!1),te=ae({directory:r}),ne=I.useMemo(()=>te.data??[],[te.data]),ie=te.isFetching,T=re({directory:r}),E=I.useMemo(()=>T.data??[],[T.data]),[D,se]=I.useState(0),ce=I.useRef(0),O=I.useRef(!1),le=I.useRef([]),j=I.useRef(null),M=ve(j,u),N=I.useRef(!1),P=I.useRef(null),F=I.useRef(!1);I.useEffect(()=>{let e=e=>{let t=e.target;!t||!j.current||j.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),I.useEffect(()=>{(async()=>{C(ie);try{let t=ne.map((e,t)=>({id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,isSkill:e.source===`skill`,scope:e.scope,reference:e.reference})),n=E.map((e,t)=>({id:`skill:${e.scope}:${e.source??`opencode`}:${e.name}:${t}`,name:e.name,source:`skill`,description:e.description,isSkill:!0,scope:e.scope})),r=[{id:`openchamber:new`,name:`new`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...g&&!y?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...g?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...g?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:plan-feature`,name:`plan-feature`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.featurePlanDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:l(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[],...t,...n],i=!y,a=r.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0));x(Ae(a,e))}catch{let t=!y,n=[{id:`openchamber:new`,name:`new`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...g&&!y?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...g?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...g?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:plan-feature`,name:`plan-feature`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.featurePlanDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:l(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(o?.(e)??!0));x(Ae(n,e))}finally{C(!1)}})()},[e,y,g,_,v,ne,ie,E,l,o]),I.useEffect(()=>{se(0)},[b]),I.useEffect(()=>{ce.current=D},[D]),I.useEffect(()=>{le.current[D]?.scrollIntoView({block:`nearest`})},[D]),I.useImperativeHandle(c,()=>({handleKeyDown:e=>{let r=b.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){O.current=!0,se(e=>(e+1)%r);return}if(e===`ArrowUp`){O.current=!0,se(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(ce.current%r+r)%r,i=b[n];i&&t(i,xe(i,e===`Enter`))}}}}),[b,n,t]);let L=e=>{switch(e.name){case`new`:return(0,X.jsx)(A,{name:`add`,className:`h-3.5 w-3.5`});case`init`:return(0,X.jsx)(A,{name:`file`,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,X.jsx)(A,{name:`arrow-go-back`,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,X.jsx)(A,{name:`arrow-go-forward`,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:return(0,X.jsx)(A,{name:`time`,className:`h-3.5 w-3.5`});case`compact`:return(0,X.jsx)(A,{name:`scissors`,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,X.jsx)(A,{name:`target`,className:`h-3.5 w-3.5`});case`review`:return(0,X.jsx)(A,{name:`search-eye`,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,X.jsx)(A,{name:`terminal-box`,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,X.jsx)(A,{name:`flashlight`,className:`h-3.5 w-3.5 text-yellow-500`}):(0,X.jsx)(A,{name:`command`,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,X.jsxs)(`div`,{ref:j,className:`absolute z-[100] min-w-0 w-full max-w-[450px] max-h-64 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col`,style:M===void 0?a:{...a,maxHeight:M},children:[(0,X.jsx)(ue,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:S?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,X.jsx)(A,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,X.jsxs)(`div`,{children:[b.map((e,n)=>{let r=e.isBuiltIn,i=e.isOpenChamber;return(0,X.jsxs)(`div`,{ref:e=>{le.current[n]=e},className:k(`flex gap-2 px-3 py-2 cursor-pointer rounded-lg`,u?`items-center`:`items-start`,n===D&&`bg-interactive-selection`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(P.current={x:e.clientX,y:e.clientY},F.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!P.current)return;let t=e.clientX-P.current.x,n=e.clientY-P.current.y;Math.hypot(t,n)>6&&(F.current=!0)},onPointerUp:n=>{if(n.pointerType!==`touch`)return;let r=F.current;P.current=null,F.current=!1,!r&&(n.preventDefault(),n.stopPropagation(),N.current=!0,t(e,xe(e,u)))},onPointerCancel:()=>{P.current=null,F.current=!1},onClick:()=>{if(N.current){N.current=!1;return}t(e,xe(e,u))},onMouseMove:()=>{O.current=!1,se(n)},children:[(0,X.jsx)(`div`,{className:k(!u&&`mt-0.5`),children:L(e)}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,e.name]}),e.isSkill?(0,X.jsx)(`span`,{className:Ee,children:l(`chat.commandAutocomplete.badge.skill`)}):(0,X.jsx)(`span`,{className:Ee,children:l(`chat.commandAutocomplete.badge.command`)}),i?(0,X.jsx)(`span`,{className:ke,children:`OpenChamber`}):r?(0,X.jsx)(`span`,{className:ke,children:l(`chat.commandAutocomplete.badge.system`)}):e.scope?(0,X.jsx)(`span`,{className:e.scope===`project`?Oe:De,children:e.scope}):null,e.agent&&(0,X.jsx)(`span`,{className:ke,children:e.agent})]}),e.description&&!u&&(0,X.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:e.description})]})]},e.id)}),b.length===0&&(0,X.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.commandAutocomplete.empty`)})]})}),!u&&(0,X.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})});Me.displayName=`CommandAutocomplete`;function Ne(e){return(e.description||e.content).replace(/\s+/g,` `).trim().slice(0,120)}var Pe=I.forwardRef((e,t)=>{let n=(0,H.c)(63),{searchQuery:r,onSnippetSelect:a,onClose:o,style:s}=e,{t:c}=ee(),l=I.useRef(null),u=i(Fe),d=ve(l,u),[f,p]=I.useState(0),m=I.useRef(0),h;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],n[0]=h):h=n[0];let[g,_]=I.useState(h),v;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],n[1]=v):v=n[1];let y=I.useRef(v),b=N(Ie),x=N(Le),S=N(Re),C=N(ze),te=i(Be),ne=i(Ve),re,ie;n[2]===x?(re=n[3],ie=n[4]):(re=()=>{x()},ie=[x],n[2]=x,n[3]=re,n[4]=ie),I.useEffect(re,ie);let w,ae;n[5]!==r||n[6]!==b?(w=()=>{let e=r.trim();if(!e.length){let e=[...b].sort(He);_(e),p(+!!e.length);return}let t=se(b,e,Ue);t.sort(We);let n=t.map(Ge);_(n),p(+!!n.length)},ae=[r,b],n[5]=r,n[6]=b,n[7]=w,n[8]=ae):(w=n[7],ae=n[8]),I.useEffect(w,ae);let T,E;n[9]===f?(T=n[10],E=n[11]):(T=()=>{m.current=f,y.current[f]?.scrollIntoView({block:`nearest`})},E=[f],n[9]=f,n[10]=T,n[11]=E),I.useEffect(T,E);let D,oe;n[12]===o?(D=n[13],oe=n[14]):(oe=()=>{let e=e=>{let t=e.target;t&&l.current&&!l.current.contains(t)&&o()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},D=[o],n[12]=o,n[13]=D,n[14]=oe),I.useEffect(oe,D);let ce;n[15]!==a||n[16]!==r?(ce=e=>{let t=r.trim(),n=e.aliases.includes(t)?t:e.name;a(e,n)},n[15]=a,n[16]=r,n[17]=ce):ce=n[17];let O=ce,le;n[18]!==o||n[19]!==C||n[20]!==te||n[21]!==ne||n[22]!==S||n[23]!==b?(le=()=>{let e=new Set(b.map(Ke)),t=`new-snippet`,n=1;for(;e.has(t);)t=`new-snippet-${n++}`;S({name:t,scope:`global`}),C(t),ne(`snippets`),te(!0),o()},n[18]=o,n[19]=C,n[20]=te,n[21]=ne,n[22]=S,n[23]=b,n[24]=le):le=n[24];let j=le,M,P;n[25]!==O||n[26]!==g||n[27]!==o||n[28]!==j?(M=()=>({handleKeyDown:e=>{if(e===`Escape`){o();return}let t=g.length+1;if(e===`ArrowDown`){p(e=>(e+1)%t);return}if(e===`ArrowUp`){p(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){if(m.current===0){j();return}let e=g[m.current-1];e&&O(e)}}}),P=[O,g,o,j],n[25]=O,n[26]=g,n[27]=o,n[28]=j,n[29]=M,n[30]=P):(M=n[29],P=n[30]),I.useImperativeHandle(t,M,P);let F;n[31]!==d||n[32]!==s?(F=d===void 0?s:{...s,maxHeight:d},n[31]=d,n[32]=s,n[33]=F):F=n[33];let L;n[34]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>{y.current[0]=e},n[34]=L):L=n[34];let R=f===0&&`bg-interactive-selection`,z;n[35]===R?z=n[36]:(z=k(`flex items-center gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,R),n[35]=R,n[36]=z);let de,B;n[37]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>p(0),B=(0,X.jsx)(A,{name:`add`,className:`h-3.5 w-3.5 text-muted-foreground`}),n[37]=de,n[38]=B):(de=n[37],B=n[38]);let V;n[39]===c?V=n[40]:(V=c(`chat.snippetAutocomplete.action.addNew`),n[39]=c,n[40]=V);let fe;n[41]===V?fe=n[42]:(fe=(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:V}),n[41]=V,n[42]=fe);let pe;n[43]!==j||n[44]!==z||n[45]!==fe?(pe=(0,X.jsxs)(`div`,{ref:L,className:z,onClick:j,onMouseMove:de,children:[B,fe]}),n[43]=j,n[44]=z,n[45]=fe,n[46]=pe):pe=n[46];let me;n[47]!==O||n[48]!==g||n[49]!==u||n[50]!==f||n[51]!==c?(me=g.length?g.map((e,t)=>(0,X.jsx)(`div`,{ref:e=>{y.current[t+1]=e},className:k(`flex gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,u?`items-center`:`items-start`,t+1===f&&`bg-interactive-selection`),onClick:()=>O(e),onMouseMove:()=>p(t+1),children:(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`font-semibold truncate`,children:[`#`,e.name]}),(0,X.jsx)(`span`,{className:`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0 bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`,children:c(`snippets.source.${e.source}`)})]}),!u&&(0,X.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Ne(e)})]})},`${e.source}:${e.filePath}`)):(0,X.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:c(`chat.snippetAutocomplete.empty`)}),n[47]=O,n[48]=g,n[49]=u,n[50]=f,n[51]=c,n[52]=me):me=n[52];let U;n[53]!==pe||n[54]!==me?(U=(0,X.jsxs)(ue,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:[pe,me]}),n[53]=pe,n[54]=me,n[55]=U):U=n[55];let W;n[56]!==u||n[57]!==c?(W=!u&&(0,X.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:c(`chat.snippetAutocomplete.footer`)}),n[56]=u,n[57]=c,n[58]=W):W=n[58];let G;return n[59]!==F||n[60]!==U||n[61]!==W?(G=(0,X.jsxs)(`div`,{ref:l,className:`absolute z-[100] min-w-0 w-full max-w-[450px] max-h-60 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col`,style:F,children:[U,W]}),n[59]=F,n[60]=U,n[61]=W,n[62]=G):G=n[62],G});Pe.displayName=`SnippetAutocomplete`;function Fe(e){return e.isMobile}function Ie(e){return e.snippets}function Le(e){return e.loadSnippets}function Re(e){return e.setSnippetDraft}function ze(e){return e.setSelectedSnippet}function Be(e){return e.setSettingsDialogOpen}function Ve(e){return e.setSettingsPage}function He(e,t){return e.source===`project`&&t.source!==`project`?-1:e.source!==`project`&&t.source===`project`?1:e.name.localeCompare(t.name)}function Ue(e){return[e.name,...e.aliases]}function We(e,t){return e.score===t.score?e.item.source===`project`&&t.item.source!==`project`?-1:e.item.source!==`project`&&t.item.source===`project`?1:e.item.name.localeCompare(t.item.name):e.score-t.score}function Ge(e){return e.item}function Ke(e){return e.name}var qe=2,Je=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Ye=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},Xe=e=>Je(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&Je(e.branches),Ze=(e,t)=>JSON.stringify([e,t]),Qe=e=>`version`in e&&e.version===qe&&Je(e.entries),$e=e=>{if(!e)return null;try{let t=JSON.parse(e);return Je(t)?t.version===qe&&Je(t.entries)?{version:qe,entries:t.entries}:t:null}catch{return null}},et=(e,t)=>{try{e.setItem(`oc.gitBranchCache`,JSON.stringify(t))}catch{}},tt=(e,t,n)=>{let r=Ye(e);if(!r||!t)return null;let i;try{i=n.getItem(`oc.gitBranchCache`)}catch{return null}let a=$e(i);if(!a)return null;if(Qe(a))return Xe(a.entries[Ze(t,r)])?a.entries[Ze(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=Ye(e);r&&Xe(n)&&(o[Ze(t,r)]=n)}return et(n,{version:qe,entries:o}),o[Ze(t,r)]??null},nt=(e,t,n,r)=>{let i=Ye(e);if(!i||!t||!Xe(n))return;let a=null;try{a=r.getItem(`oc.gitBranchCache`)}catch{return}let o=$e(a);et(r,{version:qe,entries:{...o&&Qe(o)?o.entries:{},[Ze(t,i)]:n}})},rt=3e4,it=Ye,at=(e,n=t())=>c.git.branches(it(e),n),ot=(e,n=t())=>c.git.remotes(it(e),n),st=async(e,t,n)=>{n.throwIfAborted();let r=d()?.git,i=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):r?await r.getGitBranches(e,{signal:n}):await y(e,{signal:n});return n.throwIfAborted(),i},ct=async(e,t,n)=>{n.throwIfAborted();let r=d()?.git,i=t?.getRemotes?await t.getRemotes(e,{signal:n}):r?await r.getRemotes(e,{signal:n}):await _(e,{signal:n});return n.throwIfAborted(),i},lt=(e,r,i=t(),a=n())=>{let o=it(e),s=r;return{queryKey:at(o,i),queryFn:async({signal:e})=>{if(!o)throw Error(`Git branches require a directory`);let t=await st(o,s,e);return nt(o,i,t,a),t},staleTime:rt,gcTime:1/0,initialData:()=>tt(o,i,a)??void 0,initialDataUpdatedAt:0}},ut=(e,n,r=t())=>{let i=it(e),a=n;return{queryKey:ot(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return ct(i,a,e)},staleTime:rt,gcTime:1/0}},dt=(e,n,i)=>{let a=(0,H.c)(9),o=i===void 0||i,s=I.useSyncExternalStore(r,t,t),c,l,u;a[0]!==e||a[1]!==n||a[2]!==s?(c=it(e),u=S,l=lt(c,n,s),a[0]=e,a[1]=n,a[2]=s,a[3]=c,a[4]=l,a[5]=u):(c=a[3],l=a[4],u=a[5]);let d=o&&!!c,f;return a[6]!==l||a[7]!==d?(f={...l,enabled:d},a[6]=l,a[7]=d,a[8]=f):f=a[8],u(f)},ft=(e,n,i)=>{let a=(0,H.c)(9),o=i===void 0||i,s=I.useSyncExternalStore(r,t,t),c,l,u;a[0]!==e||a[1]!==n||a[2]!==s?(c=it(e),u=S,l=ut(c,n,s),a[0]=e,a[1]=n,a[2]=s,a[3]=c,a[4]=l,a[5]=u):(c=a[3],l=a[4],u=a[5]);let d=o&&!!c,f;return a[6]!==l||a[7]!==d?(f={...l,enabled:d},a[6]=l,a[7]=d,a[8]=f):f=a[8],u(f)},pt=(e,n,r=u,i=t())=>r.fetchQuery(lt(e,n,i)),mt=(e,n,r=u,i=t())=>r.fetchQuery({...lt(e,n,i),staleTime:0}),ht=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,gt=1e4,_t=6e4,vt=5e3,yt=3e4,bt=6e4,xt=25,St=40,Ct=2,wt=15e3,Tt=500,Et=30,Dt=20971520,Ot=new Map,kt=new Map,At=new Map,jt=new Map,Mt=new Map,Nt=(e,t)=>`${t}:${e}`,Pt=e=>kt.get(e)??0,Ft=e=>{let t=Pt(e)+1;return kt.set(e,t),t},It=e=>{let t=(At.get(e)??0)+1;return At.set(e,t),t},Lt=e=>{let t=Ot.get(e);if(t)return t;let n=new Set;return Ot.set(e,n),n},Q=()=>({isGitRepo:null,status:null,branches:null,branchesTransportIdentity:null,log:null,identity:null,diffCache:new Map,indexRevision:0,lastRepoCheckAt:0,lastStatusFetch:0,lastStatusChange:0,lastLogFetch:0,lastBranchesFetch:0,lastIdentityFetch:0,logMaxCount:25,isLoadingStatus:!1,isLoadingLog:!1,isLoadingBranches:!1,isLoadingIdentity:!1}),Rt=(e,t=Et,n=Dt)=>{let r=0;for(let t of e.values())r+=(t.original?.length??0)+(t.modified?.length??0);if(e.size<=t&&r<=n)return e;let i=Array.from(e.entries()).sort((e,t)=>e[1].fetchedAt-t[1].fetchedAt),a=new Map,o=0;for(let e=i.length-1;e>=0;e--){let[r,s]=i[e],c=(s.original?.length??0)+(s.modified?.length??0);if(a.size>=t)break;o+c>n&&a.size>0||(a.set(r,s),o+=c)}return a},zt=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n){let n=e[r],i=t[r];if(!(!n&&!i)&&(!n||!i||n.insertions!==i.insertions||n.deletions!==i.deletions))return!0}return!1},Bt=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,Vt=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[];if(n.length!==r.length||e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&Bt(e.upstreamComparison,t.upstreamComparison))return!0;let i=new Set(n.map(e=>`${e.path}:${e.index}:${e.working_dir}`));for(let e of r)if(!i.has(`${e.path}:${e.index}:${e.working_dir}`))return!0;return!!(t.diffStats!==void 0&&zt(e.diffStats,t.diffStats))},Ht=(e,t)=>{let n=new Set;if(!t)return n;let r=e?.files??[],i=t.files??[],a=new Map(r.map(e=>[e.path,e])),o=new Map(i.map(e=>[e.path,e])),s=new Set([...a.keys(),...o.keys()]);for(let e of s){let t=a.get(e),r=o.get(e);if(!t||!r){n.add(e);continue}if(t.index!==r.index||t.working_dir!==r.working_dir){n.add(e);continue}}if(t.diffStats!==void 0){let r=e?.diffStats??{},i=t.diffStats??{},a=new Set([...Object.keys(r),...Object.keys(i)]);for(let e of a){let t=r[e],a=i[e];if(!t||!a){n.add(e);continue}(t.insertions!==a.insertions||t.deletions!==a.deletions)&&n.add(e)}}return n},Ut=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[],i=e=>{let t=e?.trim()??``;return t===`?`?``:t},a=new Map(n.map(e=>[e.path,i(e.index)])),o=new Map(r.map(e=>[e.path,i(e.index)])),s=new Set([...a.keys(),...o.keys()]);for(let e of s)if((a.get(e)??``)!==(o.get(e)??``))return!0;return!1},Wt=e=>!e||e.trim().length===0,Gt=e=>(e||``).trim()===`U`,Kt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Gt(t)||Gt(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},qt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Gt(t)||Gt(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Jt=e=>Wt(e.index)&&Wt(e.working_dir),$=f()(m((e,n)=>({directories:new Map,activeDirectory:null,setActiveDirectory:t=>{let{activeDirectory:r,directories:i}=n();if(r!==t)if(r&&Ft(r),t&&Ft(t),t&&!i.has(t)){let n=new Map(i);n.set(t,Q()),e({activeDirectory:t,directories:n})}else e({activeDirectory:t})},getDirectoryState:e=>n().directories.get(e)??null,fetchStatus:async(t,r,i={})=>{let a=i.mode??`full`,o=Nt(t,a),s=jt.get(o)??(a===`light`?jt.get(Nt(t,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=n(),s=o.get(t);if(s||=Q(),!a){let r=new Map(n().directories),i=r.get(t)??Q();r.set(t,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>_t,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(t)),!l){let r=new Map(n().directories),i=r.get(t)??s;return r.set(t,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(t,i.mode?{mode:i.mode}:void 0);if(Vt(s.status,u)){c=!0;let r=new Map(n().directories),i=r.get(t)??Q(),s=Ht(i.status,u),l=Ut(i.status,u),d=new Set((i.status?.files??[]).map(e=>e.path)),f=new Set((u.files??[]).map(e=>e.path)),p=new Map(i.diffCache);for(let e of d)f.has(e)||p.delete(e);for(let e of s)p.delete(e);let m=s.size>0;m&&Ft(t);let h={...u,diffStats:u.diffStats===void 0&&i.status?.diffStats!==void 0?i.status.diffStats:u.diffStats,upstreamComparison:u.upstreamComparison===void 0?i.status?.upstreamComparison:u.upstreamComparison};r.set(t,{...i,isGitRepo:!0,status:h,diffCache:p,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:m?Date.now():i.lastStatusChange}),e({directories:r})}else{let r=new Map(n().directories),i=r.get(t)??Q();r.set(t,{...i,isGitRepo:!0,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:i.lastStatusChange}),e({directories:r})}}catch(e){console.error(`Failed to fetch git status:`,e)}finally{if(!a){let r=new Map(n().directories),i=r.get(t)??Q();r.set(t,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();jt.set(o,c);try{return await c}finally{jt.get(o)===c&&jt.delete(o)}},moveStatusPathsOptimistically:(t,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=n(),s=o.get(t),c=s?.status??null;if(!s||!c)return c;let l=!1,u=[];for(let e of c.files){if(!a.has(e.path)){u.push(e);continue}let t=i===`stage`?Kt(e):qt(e);t!==e&&(l=!0),Jt(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(t,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(t,r)=>{let{directories:i}=n(),a=i.get(t);if(!a)return;let o=new Map(i);o.set(t,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:t=>{let{directories:r}=n(),i=r.get(t);if(!i)return;let a=new Map(r);a.set(t,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=t(),s=It(r);{let t=new Map(n().directories),i=t.get(r)??Q();t.set(r,{...i,isLoadingBranches:!0}),e({directories:t})}try{let c=a.force?await mt(r,i,void 0,o):await pt(r,i,void 0,o);if(s!==At.get(r)||o!==t())return;let l=new Map(n().directories),u=l.get(r)??Q();l.set(r,{...u,branches:c,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:l})}catch(i){if(ht(i)||console.error(`Failed to fetch git branches:`,i),s!==At.get(r)||o!==t())return;let a=new Map(n().directories),c=a.get(r)??Q();a.set(r,{...c,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(t,r,i)=>{let{directories:a}=n(),o=a.get(t),s=i??o?.logMaxCount??25;{let r=new Map(n().directories),i=r.get(t)??Q();r.set(t,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(t,{maxCount:s}),a=new Map(n().directories),o=a.get(t)??Q();a.set(t,{...o,log:i,isLoadingLog:!1,lastLogFetch:Date.now(),logMaxCount:s}),e({directories:a})}catch(r){console.error(`Failed to fetch git log:`,r);let i=new Map(n().directories),a=i.get(t)??Q();i.set(t,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(t,r)=>{{let r=new Map(n().directories),i=r.get(t)??Q();r.set(t,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(t),a=new Map(n().directories),o=a.get(t)??Q();a.set(t,{...o,identity:i,isLoadingIdentity:!1,lastIdentityFetch:Date.now()}),e({directories:a})}catch(r){console.error(`Failed to fetch git identity:`,r);let i=new Map(n().directories),a=i.get(t)??Q();i.set(t,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(t,r,i={})=>{let{directories:a}=n(),o=a.get(t);if(!o){o=Q();let n=new Map(a);n.set(t,o),e({directories:n})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await n().fetchStatus(t,r,{silent:c&&!!o?.status});let u=n().directories.get(t);if(!u?.isGitRepo)return;await n().fetchBranches(t,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>gt||!u.log)&&await n().fetchLog(t,r),await n().fetchIdentity(t,r)},getDiff:(e,t)=>n().directories.get(e)?.diffCache.get(t)??null,setDiff:(t,r,i)=>{let a=new Map(n().directories),o=a.get(t)??Q(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=Rt(s);a.set(t,{...o,diffCache:c}),e({directories:a})},clearDiffCache:t=>{Ft(t);let r=new Map(n().directories),i=r.get(t);i&&(r.set(t,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,t)=>{let r=n().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,xt);await n().prefetchDiffs(e,t,i,{maxFiles:xt})},prefetchDiffs:async(t,r,i,a={})=>{let o=n().directories.get(t);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=St}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=Lt(t),d=[],f=new Set;for(let e of i){if(!e||f.has(e)||(f.add(e),!c.has(e))||o.diffCache.has(e)||u.has(e))continue;let t=l?.[e];t&&t.insertions+t.deletions>Tt||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=Pt(t);if(typeof document<`u`&&document.hidden)return;p.forEach(e=>u.add(e));let h=0,g=[],_=()=>{let e=h;return h+=1,e<p.length?p[e]:null},v=async e=>{let n=r.getGitFileDiff(t,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${wt}ms`)),wt)}),a=await Promise.race([n,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},y=async()=>{for(;;){if(m!==Pt(t))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{u.delete(e)}}},b=Math.min(Ct,p.length);if(await Promise.allSettled(Array.from({length:b},()=>y())),p.forEach(e=>u.delete(e)),m!==Pt(t))return;let x=new Map(n().directories),S=x.get(t);if(!S)return;let C=new Map(S.diffCache),ee=Date.now();g.forEach(e=>{C.set(e.path,{...e.diff,fetchedAt:ee})});let te=Rt(C);x.set(t,{...S,diffCache:te}),e({directories:x})},setLogMaxCount:(t,r)=>{let i=new Map(n().directories),a=i.get(t)??Q();i.set(t,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,t)=>{let r=n().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<vt||await n().fetchStatus(e,t,{silent:!!r?.status})},ensureAll:(e,t)=>{let r=Mt.get(e);if(r)return r;let i=(async()=>{let r=n().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=vt)&&await n().fetchStatus(e,t,{silent:!!r?.status});let a=n().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=yt)&&o.push(n().fetchBranches(e,t)),(!a.log||i-a.lastLogFetch>=gt)&&o.push(n().fetchLog(e,t)),(!a.identity||i-a.lastIdentityFetch>=bt)&&o.push(n().fetchIdentity(e,t)),o.length>0&&await Promise.all(o)})();return Mt.set(e,i),i.finally(()=>{Mt.get(e)===i&&Mt.delete(e)}),i},refresh:async(e,t={})=>{let{activeDirectory:r}=n();r&&await n().fetchAll(r,e,t)}}),{name:`git-store`})),Yt=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status??null:null,t[0]=e,t[1]=n),$(n)},Xt=e=>{let n=(0,H.c)(3),i=I.useSyncExternalStore(r,t,t),a;return n[0]!==e||n[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},n[0]=e,n[1]=i,n[2]=a):a=n[2],$(a)},Zt=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.log??null:null,t[0]=e,t[1]=n),$(n)},Qt=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isGitRepo??null:null,t[0]=e,t[1]=n),$(n)},$t=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status?.current?.trim()??null:null,t[0]=e,t[1]=n),$(n)},en={current:new Map},tn=()=>$(sn),nn=e=>{let t=(0,H.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=I.useRef(n),i;return t[1]===e?i=t[2]:(i=t=>{let n=r.current,i=n.size===e.length;if(i)for(let r of e){let e=t.directories.get(r),a=n.get(r);if(!a||(e?.isGitRepo??null)!==a.isGitRepo||(e?.status?.current??null)!==a.branch){i=!1;break}}if(i)return n;let a=new Map;for(let n of e){let e=t.directories.get(n);a.set(n,{isGitRepo:e?.isGitRepo??null,branch:e?.status?.current??null})}return r.current=a,a},t[1]=e,t[2]=i),$(i)},rn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingStatus??!1:!1,t[0]=e,t[1]=n),$(n)},an=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingLog??!1:!1,t[0]=e,t[1]=n),$(n)},on=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),$(n)};function sn(e){let t=en.current,n=t.size===e.directories.size;if(n){for(let[r,i]of e.directories)if(t.get(r)!==(i.status?.current??null)){n=!1;break}}if(n)return t;let r=new Map;for(let[t,n]of e.directories)r.set(t,n.status?.current??null);return en.current=r,r}var cn=e=>{let t=String(e||``).trim().replace(/^remotes\//,``);if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{remote:t.slice(0,n),branch:t.slice(n+1)}},ln=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),un=e=>e.branchName?ln(e.branchName):e.mode===`existing`?ln(e.existingBranch||e.preferredName||``):ln(e.preferredName||``),dn=async e=>{let t=await P(e);try{let n=cn((await j(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=cn((await M(e)).tracking);if(t?.remote)return t.remote}catch{}return null},fn=async(e,t)=>{let n=await dn(e),r=ln(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},pn=async(e,t,n)=>{let r=un(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await fn(e,r):i&&ln(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:ln(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},mn=async(e,t,n)=>{let r=await pn(e.path,t,n);return F(e,r)},hn=`oc:lastWorktreeSourceBranch`,gn=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,_n=({branches:e,savedSourceBranch:t,rootBranch:n})=>t&&e.includes(t)&&t?{sourceBranch:t,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&e.includes(n)?n:e.includes(`main`)?`main`:e.includes(`master`)?`master`:e[0]??``,shouldClearSavedSourceBranch:!!t},vn=(e,t,n)=>{if(!e)return e;let r=t.length>0&&!/\s$/.test(t)&&!/^\s/.test(e)&&!/[([{]$/.test(t),i=n.length>0&&!/\s$/.test(e)&&!/^\s/.test(n)&&!/^[\])}.,;:!?]/.test(n);return`${r?` `:``}${e}${i?` `:``}`},yn=(e,t,n)=>{let r=vn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},bn=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=yn(r,i,a),s=Math.max(0,o.indexOf(r)),c=i.length+s;return{text:`${i}${o}${a}`,caret:i.length+o.length,start:c,end:c+r.length}},xn=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))?[...e]:[...e,t]},Sn=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{ve as A,dt as C,we as D,Me as E,pe as M,fe as N,Se as O,mt as S,Pe as T,Zt as _,hn as a,$ as b,mn as c,tn as d,$t as f,rn as g,an as h,yn as i,me as j,Z as k,dn as l,on as m,xn as n,_n as o,Xt as p,bn as r,gn as s,Sn as t,pn as u,nn as v,ft as w,Qt as x,Yt as y};
|