@openchambery/web 1.19.15 → 1.19.16
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/{AssistantView-xdL1EvpR.js → AssistantView-B79FR_5m.js} +1 -1
- package/dist/assets/{DiagramView-DPgkYU-_.js → DiagramView-Bg5pX5aJ.js} +1 -1
- package/dist/assets/{MarkdownRenderer-CP7UVZdr.js → MarkdownRenderer-BrOPSCOy.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-BB1Q1RWk.js → MarkdownRendererImpl-BWTMbqp6.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-BjQrUIcq.js → MarkstreamRendererImpl-Bwxkdtts.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-Cyzs6cuR.js → MobileDetailNavigation-37jfPItf.js} +1 -1
- package/dist/assets/{MobileShareBridge-A-Z6jMUn.js → MobileShareBridge-D2RJnSvI.js} +1 -1
- package/dist/assets/{MobileSurface-DjDa20gx.js → MobileSurface-B_jx2mRT.js} +1 -1
- package/dist/assets/{MultiRunWindow-Cg5x-kJV.js → MultiRunWindow-CUYEega4.js} +1 -1
- package/dist/assets/{SettingsView-CYrTHDdp.js → SettingsView-B5BWCL5K.js} +1 -1
- package/dist/assets/{SettingsWindow-CF-0Zgxr.js → SettingsWindow--F_wFMX-.js} +1 -1
- package/dist/assets/{TerminalView-CShou18D.js → TerminalView-BqnCNcW3.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BvmxlNOa.js → ToolOutputDialog-Cxpellmm.js} +1 -1
- package/dist/assets/{appThemeRegistry-iqSTUpPj.js → appThemeRegistry-DaoSMJG1.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-CddGH2aH.js → fileMentionTouchSelection-COw1MDRz.js} +1 -1
- package/dist/assets/{gitApi-BwuaHHRQ.js → gitApi-uzDmhDPP.js} +1 -1
- package/dist/assets/{insertionBoundaries-og6NBgdn.js → insertionBoundaries-BYOyFrjB.js} +1 -1
- package/dist/assets/{main-VD-QBM47.js → main-Br8P10pP.js} +2 -2
- package/dist/assets/{main-31g3JiQx.js → main-DaaedB65.js} +4 -4
- package/dist/assets/{miniChat-DwCMTamY.js → miniChat-aQQ4d-bD.js} +2 -2
- package/dist/assets/{mobile-C7q1yowe.js → mobile-XeTOB53s.js} +2 -2
- package/dist/assets/{multirun-DcN5T0lN.js → multirun-BKVlVu2V.js} +1 -1
- package/dist/assets/{projectMeta-moNJYCK4.js → projectMeta-DX3l1Xzy.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DVkgKA6A.js → renderElectronMiniChatApp-CmYP_apQ.js} +2 -2
- package/dist/assets/{renderMobileApp-BgEXZhCO.js → renderMobileApp-ATUEcuRh.js} +4 -4
- package/dist/assets/{runtimeConfig-B49cxtgI.js → runtimeConfig-Cug6bqDv.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-9K_Dj1qR.js → runtimeEndpointReset-CRc6se81.js} +1 -1
- package/dist/assets/{sessionLookup-m3h8c4xR.js → sessionLookup-D3ISlV8R.js} +1 -1
- package/dist/assets/{useAppFontEffects-DRFi4TCE.js → useAppFontEffects-Cn7pYCz1.js} +5 -5
- package/dist/assets/{useDesktopWindowControlsLayout-BdNR3zMN.js → useDesktopWindowControlsLayout-DXAFSQuV.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-COoPja_2.js → useEffectiveDirectory-DT_EmmM0.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-Cn0-ozUB.js → useMobileNavigationStore-gXfZxA1A.js} +1 -1
- package/dist/assets/{useSessionAutoCleanup-XwgyzsEd.js → useSessionAutoCleanup-CsVhR6FK.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-GgcqEoKY.js → useWorkerHighlightedLines-C1rC3WQe.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/mini-chat.html +2 -2
- package/dist/mobile.html +2 -2
- package/package.json +1 -1
- package/server/lib/assistants/DOCUMENTATION.md +11 -1
- package/server/lib/assistants/contact-store.js +18 -4
- package/server/lib/assistants/contact-tools.js +44 -0
- package/server/lib/assistants/contact-tools.test.js +2 -0
- package/server/lib/assistants/harness.js +2 -2
- package/server/lib/assistants/memory.http.test.js +204 -0
- package/server/lib/assistants/memory.js +124 -0
- package/server/lib/assistants/memory.test.js +159 -0
- package/server/lib/assistants/service.js +9 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{c as t,i as n}from"./runtime-switch-LvWDU-SL.js";import{Cn as r,D as i,d as a,k as o,tn as s,u as c}from"./persistence-DwRBC4zl.js";import{a as l,i as u,r as d}from"./vendor-zustand-B4dlGEM2.js";import{nt as f,rt as p}from"./vendor-base-ui-CnHfUmDN.js";import{B as m,Ct as h,M as g,Mt as _}from"./platform-DQ5_LNKO.js";import{b as v,t as ee,y}from"./useUIStore-CxOoCv7B.js";import{n as b}from"./vendor-react-DLPElpoQ.js";import{s as x}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as S}from"./vendor-reactuses-core-BnW6GxJt.js";import{n as te}from"./clipboard-GUUNlWIv.js";import{Qi as ne,c as C,ct as re,dr as ie,dt as ae,eo as oe,ft as se,g as w,go as T,ho as ce,in as E,lt as D,mn as O,ot as k,st as le,y as A}from"./useMobileNavigationStore-Cn0-ozUB.js";import{c as j,t as M}from"./utils-2ZK8yboQ.js";import{n as N}from"./Icon-D1BcR8Tz.js";import{g as P,v as F}from"./gitApi-BwuaHHRQ.js";import{f as I,o as L,q as ue}from"./projectMeta-moNJYCK4.js";import{n as de,r as fe,t as pe}from"./fileMentionTouchSelection-CddGH2aH.js";import{n as me}from"./textarea-B9CmN13Z.js";var R=e=>{switch(e.name){case`new`:return`add`;case`init`:return`file`;case`undo`:return`arrow-go-back`;case`redo`:return`arrow-go-forward`;case`timeline`:return`time`;case`compact`:return`scissors`;case`goal`:return`target`;case`review`:return`search-eye`;case`test`:case`build`:case`run`:return`terminal-box`;default:return e.isBuiltIn?`flashlight`:`command`}},he=()=>`book-open`,z=e=>{if(e.isDirectory)return`folder-3-fill`;switch(e.extension?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:case`json`:return`code`;case`md`:case`mdx`:return`file`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`svg`:return`file-image`;default:return`file-pdf`}},B=()=>`ai-agent`,ge=()=>`chat-thread`,_e=(e,t)=>e.map(e=>{let n=e.isSkill?t.skill:e.isOpenChamber?`OpenChamber`:e.isBuiltIn?t.system:e.scope||e.agent||t.command;return{id:e.id,title:`/${e.name}`,subtitle:e.description,badge:n,iconName:R(e)}}),ve=e=>e.map(e=>({id:`${e.name}-${e.scope}`,title:e.name,subtitle:e.description,badge:e.scope,iconName:he()})),ye=({agents:e,sessions:t,recentFiles:n,pathHits:r,untitledSession:i,sessionBadge:a})=>{let o=[];for(let t of e)o.push({id:`agent:${t.name}`,title:`@${t.name}`,subtitle:t.description,iconName:B()});for(let e of t)o.push({id:`session:${e.id}`,title:e.title||i,badge:a,iconName:ge()});for(let e of n)o.push({id:`recent:${e.path}`,title:e.relativePath||e.name,iconName:z(e)});for(let e of r)o.push({id:`file:${e.path}`,title:e.relativePath||e.name,iconName:z(e)});return o},be=(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)},xe=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!=null&&e.id===r.id&&e.title===r.title&&(e.subtitle??``)===(r.subtitle??``)&&(e.badge??``)===(r.badge??``)&&e.iconName===r.iconName}),Se=(e,t)=>e.highlightedIndex===t.highlightedIndex&&xe(e.rows,t.rows),Ce=(e,t)=>xe(e,t)?e:t.slice(),we=(e,t,n)=>{e&&(t.current&&Se(t.current,n)||(t.current=n,e(n)))},Te=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},V=e(p(),1),H=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},U=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,W=(e,t)=>{let n=H(t),r=H(e);if(!n||!r)return!1;let i=U(n),a=U(r);return a===i||a.startsWith(`${i}/`)},G=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=H(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=>H(e)).filter(e=>W(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>H(e)).filter(e=>W(e,t)))):[],s=typeof i.selectedPath==`string`?H(i.selectedPath):null,c=s&&W(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},K=(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},q=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Ee=l()(d(u((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=H((t||``).trim()),a=H((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!W(a,i)||e(e=>{let t=e.byRoot[i],n=q(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:K({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=H((t||``).trim()),i=H((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=U(i),a=e=>U(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:K({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=H((t||``).trim()),i=H((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=U(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=U(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:K({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=H((t||``).trim()),i=H((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=U(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=U(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:K({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=H((t||``).trim()),a=n?H(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!W(a,i)||e(e=>{let t=e.byRoot[i],n=q(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:K({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=H((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=H((t||``).trim()),i=H((n||``).trim());!r||!i||!W(i,r)||e(e=>{let t=e.byRoot[r],n=q(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:K({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=H((t||``).trim()),i=H((n||``).trim());!r||!i||!W(i,r)||e(e=>{let t=e.byRoot[r],n=q(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:K({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=H((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>H((e||``).trim())).filter(e=>e&&W(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=q(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:K({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:y(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:G(t)}},partialize:e=>({byRoot:G(e.byRoot)})}),{name:`files-view-tabs-store`})),J=b(),De=(e,t)=>{let n=(0,J.c)(4),r=t===void 0?200:t,[i,a]=V.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]),V.useEffect(o,s),i},Oe=()=>{let e=(0,J.c)(17),t=C(Y),n=O(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=A(r),a=C(X),o=C(ke),s=T(Ae),c=T(je),l=h(Me);if(t){let r;e[2]===i?r=e[3]:(r=w(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 Y(e){return e.currentSessionId}function X(e){return e.worktreeMetadata}function ke(e){return e.newSessionDraft}function Ae(e){return e.activeProjectId}function je(e){return e.projects}function Me(e){return e.currentDirectory}var Z=f(),Ne=V.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSessionSelect:r,onClose:a,style:s,onRowsChange:c},l)=>{let{t:u}=te(),d=Oe()??``,f=C(e=>e.currentSessionId),p=ie(e=>e.activeSessions),m=T(e=>e.activeProjectId),h=T(e=>e.projects),g=V.useMemo(()=>h.find(e=>e.id===m)?.path??null,[m,h]),v=V.useMemo(()=>{let e=g||d;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[g,d]),y=Ee(e=>v?e.byRoot[v]:void 0),b=ne(e=>e.getVisibleAgents),x=_(e=>e.searchFiles),oe=De(e,180),se=o(),w=i(),[ce,E]=V.useState([]),[O,A]=V.useState([]),[P,F]=V.useState(!1),[I,L]=V.useState(0),ue=V.useRef(0),[R,he]=V.useState(360),[B,ge]=V.useState({}),[_e,ve]=V.useState({}),be=V.useRef([]),xe=V.useRef([]),Se=V.useRef([]),Ce=V.useRef(null),H=V.useRef(null),U=V.useRef(null);U.current||=pe();let W=ee(e=>e.isMobile),G=(e??``).trim(),K=V.useMemo(()=>{if(!v||!y)return[];let e=[y.selectedPath,...y.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r);let e=r.replace(/\\/g,`/`),i=e.split(`/`).filter(Boolean).pop()||e,a=e.startsWith(`${v}/`)?e.slice(v.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return D(n,G,{limit:6})},[G,v,y]),q=V.useMemo(()=>G.length>0?O:O.slice(0,2),[O,G.length]),J=V.useMemo(()=>r?k({sessions:p,currentSessionId:f,searchQuery:G}):[],[p,f,G,r]),Y=K,X=ce;V.useEffect(()=>{let e=e=>{let t=e.target;!t||!Ce.current||Ce.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),V.useEffect(()=>{if(!d){E([]);return}let e=(oe??``).trim(),t=ae(e);if(!t){E([]);return}let n=!1;F(!0);let r={includeHidden:se,respectGitignore:!w};return Promise.all([x(d,t,80,{...r,type:`file`}),x(d,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(K.map(e=>e.path));E(le({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||E([])}).finally(()=>{n||F(!1)}),()=>{n=!0}},[d,oe,K,x,se,w]),V.useEffect(()=>{let t=b().filter(e=>e.mode&&e.mode!==`primary`).map(e=>({name:e.name,description:e.description,mode:e.mode}));A(re(t,e??``))},[b,e]),V.useEffect(()=>{L(0),ge({}),ve({})},[X,Y.length,q.length,J.length]),V.useEffect(()=>{ue.current=I},[I]),V.useEffect(()=>{be.current[I]?.scrollIntoView({block:`nearest`})},[I]),V.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};xe.current.forEach((n,r)=>{if(!n)return;let i=Se.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}}),ge(e),ve(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[X,Y]),V.useEffect(()=>{let e=xe.current[I];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&he(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[I]);let ke=S(e=>{t(e)}),Ae=S(e=>{n?.(e)}),je=S(e=>{r?.(e)}),Me=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&U.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&U.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(U.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>U.current?.pointerCancel(),onClick:()=>{U.current?.click(t)},onMouseMove:()=>L(e)}),Ne=e=>{let t=q.length+J.length+Y.length+X.length;if(t===0)return;let n=(e%t+t)%t;if(n<q.length){let e=q[n];e&&Ae(e.name);return}let r=n-q.length;if(r<J.length){let e=J[r];e&&je(e);return}let i=r-J.length,a=i<Y.length?Y[i]:X[i-Y.length];a&&ke(a)};V.useEffect(()=>{we(c,H,{rows:ye({agents:q,sessions:J,recentFiles:Y,pathHits:X,untitledSession:u(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:u(`chat.fileMentionAutocomplete.sessionType`)}),highlightedIndex:I})},[c,I,u,q,X,Y,J]);let Pe=V.useRef(c);Pe.current=c,V.useEffect(()=>()=>{Te(Pe.current,H)},[]),V.useImperativeHandle(l,()=>({acceptIndex:e=>{Ne(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=q.length+J.length+Y.length+X.length;if(t!==0){if(e===`ArrowDown`){L(e=>(e+1)%t);return}if(e===`ArrowUp`){L(e=>(e-1+t)%t);return}(e===`Enter`||e===`Tab`)&&Ne(ue.current)}}}),[X,Y,q,J,a,ke,Ae,je]);let Fe=e=>(0,Z.jsx)(N,{name:z(e),className:`h-3.5 w-3.5 text-current`});return(0,Z.jsxs)(de,{ref:Ce,isMobile:W,className:`max-w-[640px] max-h-64`,style:s,children:[(0,Z.jsx)(me,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,Z.jsxs)(`div`,{className:`pb-2`,children:[q.length>0&&(0,Z.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)=>{let n=I===t;return(0,Z.jsx)(`div`,{ref:e=>{be.current[t]=e},className:M(`flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,fe(W,n),!W&&n&&`text-interactive-selection-foreground`),...Me(t,()=>Ae(e.name)),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`font-semibold truncate`,children:[`@`,e.name]}),e.description&&!W?(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:e.description}):null]})},`agent-${e.name}`)}),q.length===2&&G.length===0&&O.length>2&&(0,Z.jsx)(`div`,{className:`px-3 py-1 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.searchMoreAgents`)}),J.length>0&&(0,Z.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,r=I===n;return(0,Z.jsxs)(`div`,{ref:e=>{be.current[n]=e},className:M(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,fe(W,r),!W&&r&&`text-interactive-selection-foreground`),...Me(n,()=>je(e)),children:[(0,Z.jsx)(N,{name:`chat-thread`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title||u(`chat.fileMentionAutocomplete.untitledSession`),children:e.title||u(`chat.fileMentionAutocomplete.untitledSession`)}),W?null:(0,Z.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.sessionType`)})]},`session-${e.id}`)}),Y.length>0&&(0,Z.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=j(r,{maxLength:60}),a=I===n,o=B[n]??!1,s=_e[n]??2.6;return(0,Z.jsxs)(`div`,{ref:e=>{be.current[n]=e},className:M(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,fe(W,a),!W&&a&&`text-interactive-selection-foreground`),...Me(n,()=>ke(e)),children:[Fe(e),(0,Z.jsxs)(`span`,{ref:e=>{xe.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${R}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,Z.jsx)(`span`,{ref:e=>{Se.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,Z.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,Z.jsx)(`span`,{className:`block truncate`,children:i})]})]},`recent-${e.path}`)}),X.length>0&&(0,Z.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.files`)}),X.map((e,t)=>{let n=q.length+J.length+Y.length+t,r=e.relativePath||e.name,i=j(r,{maxLength:60}),a=I===n,o=B[n]??!1,s=_e[n]??2.6;return(0,Z.jsxs)(`div`,{ref:e=>{be.current[n]=e},className:M(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,fe(W,a),!W&&a&&`text-interactive-selection-foreground`),...Me(n,()=>ke(e)),children:[Fe(e),(0,Z.jsxs)(`span`,{ref:e=>{xe.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${R}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,Z.jsx)(`span`,{ref:e=>{Se.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,Z.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,Z.jsx)(`span`,{className:`block truncate`,children:i})]})]},e.path)}),P&&X.length===0?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,Z.jsx)(N,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!P&&X.length===0&&Y.length===0&&q.length===0&&J.length===0&&(0,Z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.empty`)})]})}),!W&&(0,Z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})}),Pe=new Set([`new`,`fork`,`compact`,`undo`,`redo`,`model`,`goal`]),Fe=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Pe.has(n))},Ie=(e,t)=>!e||t({name:e}),Le=` `,Re=(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]===Le&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},ze=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Be=M(ze,`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)]`),Ve=M(ze,`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)]`),He=M(ze,`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)]`),Ue=M(ze,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),We=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id),Ge=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!s()}},Ke=V.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:i,commandPolicy:a,commandContext:o,onRowsChange:s},c)=>{let{t:l}=te(),u=ee(e=>e.isMobile),d=C(e=>e.currentSessionId),f=C(e=>!!e.newSessionDraft?.open),p=C(V.useCallback(e=>d?e.getDirectoryForSession(d):void 0,[d])),m=E(d??``,p??void 0),h=V.useMemo(()=>o??{sessionID:d??null,hasMessages:m.length>0,hasNewDraft:f},[o,d,m.length,f]),{hasSession:g,canStartSessionCommand:_,canUseReviewHandoffFlow:v}=V.useMemo(()=>Ge(h,u),[h,u]),y=h.hasMessages,[b,x]=V.useState([]),[S,ne]=V.useState(!1),re=ce({directory:r}),ie=V.useMemo(()=>re.data??[],[re.data]),ae=re.isFetching,se=oe({directory:r}),w=V.useMemo(()=>se.data??[],[se.data]),[T,D]=V.useState(0),O=V.useRef(0),k=V.useRef(!1),le=V.useRef([]),A=V.useRef(null),j=V.useRef(!1),P=V.useRef(null),F=V.useRef(!1),I=V.useRef(null);V.useEffect(()=>{let e=e=>{let t=e.target;!t||!A.current||A.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),V.useEffect(()=>{(async()=>{ne(ae);try{let t=ie.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=w.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: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,o=be(r.filter(e=>(i||e.name!==`init`)&&(a?.(e)??!0)),e);x(e=>We(e,o)?e:o)}catch{let t=!y,n=be([{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: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`)&&(a?.(e)??!0)),e);x(e=>We(e,n)?e:n)}finally{ne(!1)}})()},[e,y,g,_,v,ie,ae,w,l,a]),V.useEffect(()=>{D(0)},[b]),V.useEffect(()=>{O.current=T},[T]),V.useEffect(()=>{le.current[T]?.scrollIntoView({block:`nearest`})},[T]),V.useEffect(()=>{we(s,I,{rows:_e(b,{skill:l(`chat.commandAutocomplete.badge.skill`),command:l(`chat.commandAutocomplete.badge.command`),system:l(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:T})},[b,s,T,l]);let L=V.useRef(s);L.current=s,V.useEffect(()=>()=>{Te(L.current,I)},[]),V.useImperativeHandle(c,()=>({acceptIndex:(e,n=!0)=>{let r=b[e];r&&t(r,Fe(r,n))},handleKeyDown:e=>{let r=b.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){k.current=!0,D(e=>(e+1)%r);return}if(e===`ArrowUp`){k.current=!0,D(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(O.current%r+r)%r,i=b[n];i&&t(i,Fe(i,e===`Enter`))}}}}),[b,n,t]);let ue=e=>{let t=R(e);switch(e.name){case`new`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,Z.jsxs)(de,{ref:A,isMobile:u,className:`max-w-[450px] max-h-64`,style:i,children:[(0,Z.jsx)(me,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:S?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,Z.jsx)(N,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,Z.jsxs)(`div`,{children:[b.map((e,n)=>{let r=e.isBuiltIn,i=e.isOpenChamber;return(0,Z.jsxs)(`div`,{ref:e=>{le.current[n]=e},className:M(`flex gap-2 px-3 py-2 cursor-pointer rounded-lg`,u?`items-center`:`items-start`,fe(u,n===T)),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(),j.current=!0,t(e,Fe(e,u)))},onPointerCancel:()=>{P.current=null,F.current=!1},onClick:()=>{if(j.current){j.current=!1;return}t(e,Fe(e,u))},onMouseMove:()=>{k.current=!1,D(n)},children:[(0,Z.jsx)(`div`,{className:M(!u&&`mt-0.5`),children:ue(e)}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,e.name]}),e.isSkill?(0,Z.jsx)(`span`,{className:Be,children:l(`chat.commandAutocomplete.badge.skill`)}):(0,Z.jsx)(`span`,{className:Be,children:l(`chat.commandAutocomplete.badge.command`)}),i?(0,Z.jsx)(`span`,{className:Ue,children:`OpenChamber`}):r?(0,Z.jsx)(`span`,{className:Ue,children:l(`chat.commandAutocomplete.badge.system`)}):e.scope?(0,Z.jsx)(`span`,{className:e.scope===`project`?He:Ve,children:e.scope}):null,e.agent&&(0,Z.jsx)(`span`,{className:Ue,children:e.agent})]}),e.description&&!u&&(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:e.description})]})]},e.id)}),b.length===0&&(0,Z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.commandAutocomplete.empty`)})]})}),!u&&(0,Z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})});Ke.displayName=`CommandAutocomplete`;function qe(e){return(e.description||e.content).replace(/\s+/g,` `).trim().slice(0,120)}var Je=V.forwardRef((e,t)=>{let n=(0,J.c)(62),{searchQuery:r,onSnippetSelect:i,onClose:a,style:o}=e,{t:s}=te(),c=V.useRef(null),l=ee(Ye),[u,d]=V.useState(0),f=V.useRef(0),p;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],n[0]=p):p=n[0];let[m,h]=V.useState(p),g;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],n[1]=g):g=n[1];let _=V.useRef(g),v=ue(Xe),y=ue(Ze),b=ue(Qe),x=ue($e),S=ee(et),ne=ee(tt),C,re;n[2]===y?(C=n[3],re=n[4]):(C=()=>{y()},re=[y],n[2]=y,n[3]=C,n[4]=re),V.useEffect(C,re);let ie,ae;n[5]!==r||n[6]!==v?(ie=()=>{let e=r.trim();if(!e.length){let e=[...v].sort(nt);h(e),d(+!!e.length);return}let t=se(v,e,rt);t.sort(it);let n=t.map(at);h(n),d(+!!n.length)},ae=[r,v],n[5]=r,n[6]=v,n[7]=ie,n[8]=ae):(ie=n[7],ae=n[8]),V.useEffect(ie,ae);let oe,w;n[9]===u?(oe=n[10],w=n[11]):(oe=()=>{f.current=u,_.current[u]?.scrollIntoView({block:`nearest`})},w=[u],n[9]=u,n[10]=oe,n[11]=w),V.useEffect(oe,w);let T,ce;n[12]===a?(T=n[13],ce=n[14]):(ce=()=>{let e=e=>{let t=e.target;t&&c.current&&!c.current.contains(t)&&a()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},T=[a],n[12]=a,n[13]=T,n[14]=ce),V.useEffect(ce,T);let E;n[15]!==i||n[16]!==r?(E=e=>{let t=r.trim(),n=e.aliases.includes(t)?t:e.name;i(e,n)},n[15]=i,n[16]=r,n[17]=E):E=n[17];let D=E,O;n[18]!==a||n[19]!==x||n[20]!==S||n[21]!==ne||n[22]!==b||n[23]!==v?(O=()=>{let e=new Set(v.map(ot)),t=`new-snippet`,n=1;for(;e.has(t);)t=`new-snippet-${n++}`;b({name:t,scope:`global`}),x(t),ne(`snippets`),S(!0),a()},n[18]=a,n[19]=x,n[20]=S,n[21]=ne,n[22]=b,n[23]=v,n[24]=O):O=n[24];let k=O,le,A;n[25]!==D||n[26]!==m||n[27]!==a||n[28]!==k?(le=()=>({handleKeyDown:e=>{if(e===`Escape`){a();return}let t=m.length+1;if(e===`ArrowDown`){d(e=>(e+1)%t);return}if(e===`ArrowUp`){d(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){if(f.current===0){k();return}let e=m[f.current-1];e&&D(e)}}}),A=[D,m,a,k],n[25]=D,n[26]=m,n[27]=a,n[28]=k,n[29]=le,n[30]=A):(le=n[29],A=n[30]),V.useImperativeHandle(t,le,A);let j;n[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{_.current[0]=e},n[31]=j):j=n[31];let P;n[32]!==l||n[33]!==u?(P=M(`flex items-center gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,fe(l,u===0)),n[32]=l,n[33]=u,n[34]=P):P=n[34];let F,I;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>d(0),I=(0,Z.jsx)(N,{name:`add`,className:`h-3.5 w-3.5 text-muted-foreground`}),n[35]=F,n[36]=I):(F=n[35],I=n[36]);let L;n[37]===s?L=n[38]:(L=s(`chat.snippetAutocomplete.action.addNew`),n[37]=s,n[38]=L);let pe;n[39]===L?pe=n[40]:(pe=(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:L}),n[39]=L,n[40]=pe);let R;n[41]!==k||n[42]!==P||n[43]!==pe?(R=(0,Z.jsxs)(`div`,{ref:j,className:P,onClick:k,onMouseMove:F,children:[I,pe]}),n[41]=k,n[42]=P,n[43]=pe,n[44]=R):R=n[44];let he;n[45]!==D||n[46]!==m||n[47]!==l||n[48]!==u||n[49]!==s?(he=m.length?m.map((e,t)=>(0,Z.jsx)(`div`,{ref:e=>{_.current[t+1]=e},className:M(`flex gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,l?`items-center`:`items-start`,fe(l,t+1===u)),onClick:()=>D(e),onMouseMove:()=>d(t+1),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`font-semibold truncate`,children:[`#`,e.name]}),(0,Z.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:s(`snippets.source.${e.source}`)})]}),!l&&(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:qe(e)})]})},`${e.source}:${e.filePath}`)):(0,Z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:s(`chat.snippetAutocomplete.empty`)}),n[45]=D,n[46]=m,n[47]=l,n[48]=u,n[49]=s,n[50]=he):he=n[50];let z;n[51]!==R||n[52]!==he?(z=(0,Z.jsxs)(me,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:[R,he]}),n[51]=R,n[52]=he,n[53]=z):z=n[53];let B;n[54]!==l||n[55]!==s?(B=!l&&(0,Z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:s(`chat.snippetAutocomplete.footer`)}),n[54]=l,n[55]=s,n[56]=B):B=n[56];let ge;return n[57]!==l||n[58]!==o||n[59]!==z||n[60]!==B?(ge=(0,Z.jsxs)(de,{ref:c,isMobile:l,className:`max-w-[450px] max-h-60`,style:o,children:[z,B]}),n[57]=l,n[58]=o,n[59]=z,n[60]=B,n[61]=ge):ge=n[61],ge});Je.displayName=`SnippetAutocomplete`;function Ye(e){return e.isMobile}function Xe(e){return e.snippets}function Ze(e){return e.loadSnippets}function Qe(e){return e.setSnippetDraft}function $e(e){return e.setSelectedSnippet}function et(e){return e.setSettingsDialogOpen}function tt(e){return e.setSettingsPage}function nt(e,t){return e.source===`project`&&t.source!==`project`?-1:e.source!==`project`&&t.source===`project`?1:e.name.localeCompare(t.name)}function rt(e){return[e.name,...e.aliases]}function it(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 at(e){return e.item}function ot(e){return e.name}var st=2,ct=e=>!!e&&typeof e==`object`&&!Array.isArray(e),lt=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},ut=e=>ct(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&ct(e.branches),dt=(e,t)=>JSON.stringify([e,t]),ft=e=>`version`in e&&e.version===st&&ct(e.entries),pt=e=>{if(!e)return null;try{let t=JSON.parse(e);return ct(t)?t.version===st&&ct(t.entries)?{version:st,entries:t.entries}:t:null}catch{return null}},mt=(e,t)=>{try{e.setItem(`oc.gitBranchCache`,JSON.stringify(t))}catch{}},ht=(e,t,n)=>{let r=lt(e);if(!r||!t)return null;let i;try{i=n.getItem(`oc.gitBranchCache`)}catch{return null}let a=pt(i);if(!a)return null;if(ft(a))return ut(a.entries[dt(t,r)])?a.entries[dt(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=lt(e);r&&ut(n)&&(o[dt(t,r)]=n)}return mt(n,{version:st,entries:o}),o[dt(t,r)]??null},gt=(e,t,n,r)=>{let i=lt(e);if(!i||!t||!ut(n))return;let a=null;try{a=r.getItem(`oc.gitBranchCache`)}catch{return}let o=pt(a);mt(r,{version:st,entries:{...o&&ft(o)?o.entries:{},[dt(t,i)]:n}})},_t=3e4,vt=lt,yt=(e,t=n())=>a.git.branches(vt(e),t),bt=(e,t=n())=>a.git.remotes(vt(e),t),xt=async(e,t,n)=>{n.throwIfAborted();let i=r()?.git,a=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):i?await i.getGitBranches(e,{signal:n}):await g(e,{signal:n});return n.throwIfAborted(),a},St=async(e,t,n)=>{n.throwIfAborted();let i=r()?.git,a=t?.getRemotes?await t.getRemotes(e,{signal:n}):i?await i.getRemotes(e,{signal:n}):await m(e,{signal:n});return n.throwIfAborted(),a},Ct=(e,t,r=n(),i=v())=>{let a=vt(e),o=t;return{queryKey:yt(a,r),queryFn:async({signal:e})=>{if(!a)throw Error(`Git branches require a directory`);let t=await xt(a,o,e);return gt(a,r,t,i),t},staleTime:_t,gcTime:1/0,initialData:()=>ht(a,r,i)??void 0,initialDataUpdatedAt:0}},wt=(e,t,r=n())=>{let i=vt(e),a=t;return{queryKey:bt(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return St(i,a,e)},staleTime:_t,gcTime:1/0}},Tt=(e,r,i)=>{let a=(0,J.c)(9),o=i===void 0||i,s=V.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=vt(e),u=x,l=Ct(c,r,s),a[0]=e,a[1]=r,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)},Et=(e,r,i)=>{let a=(0,J.c)(9),o=i===void 0||i,s=V.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=vt(e),u=x,l=wt(c,r,s),a[0]=e,a[1]=r,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)},Dt=(e,t,r=c,i=n())=>r.fetchQuery(Ct(e,t,i)),Ot=(e,t,r=c,i=n())=>r.fetchQuery({...Ct(e,t,i),staleTime:0}),kt=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,At=1e4,jt=6e4,Mt=5e3,Nt=3e4,Pt=6e4,Ft=25,It=40,Lt=2,Rt=15e3,zt=500,Bt=30,Vt=20971520,Ht=new Map,Ut=new Map,Wt=new Map,Gt=new Map,Kt=new Map,qt=(e,t)=>`${t}:${e}`,Jt=e=>Ut.get(e)??0,Yt=e=>{let t=Jt(e)+1;return Ut.set(e,t),t},Xt=e=>{let t=(Wt.get(e)??0)+1;return Wt.set(e,t),t},Zt=e=>{let t=Ht.get(e);if(t)return t;let n=new Set;return Ht.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}),Qt=(e,t=Bt,n=Vt)=>{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},$t=(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},en=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,tn=(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&&en(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&&$t(e.diffStats,t.diffStats))},nn=(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},rn=(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},an=e=>!e||e.trim().length===0,on=e=>(e||``).trim()===`U`,sn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(on(t)||on(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},cn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(on(t)||on(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},ln=e=>an(e.index)&&an(e.working_dir),$=l()(d((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&Yt(r),n&&Yt(n),n&&!i.has(n)){let t=new Map(i);t.set(n,Q()),e({activeDirectory:n,directories:t})}else e({activeDirectory:n})},getDirectoryState:e=>t().directories.get(e)??null,fetchStatus:async(n,r,i={})=>{let a=i.mode??`full`,o=qt(n,a),s=Gt.get(o)??(a===`light`?Gt.get(qt(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=Q(),!a){let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>jt,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(n)),!l){let r=new Map(t().directories),i=r.get(n)??s;return r.set(n,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(n,i.mode?{mode:i.mode}:void 0);if(tn(s.status,u)){c=!0;let r=new Map(t().directories),i=r.get(n)??Q(),s=nn(i.status,u),l=rn(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&&Yt(n);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(n,{...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(t().directories),i=r.get(n)??Q();r.set(n,{...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(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();Gt.set(o,c);try{return await c}finally{Gt.get(o)===c&&Gt.delete(o)}},moveStatusPathsOptimistically:(n,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=t(),s=o.get(n),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`?sn(e):cn(e);t!==e&&(l=!0),ln(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(n,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(n,r)=>{let{directories:i}=t(),a=i.get(n);if(!a)return;let o=new Map(i);o.set(n,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:n=>{let{directories:r}=t(),i=r.get(n);if(!i)return;let a=new Map(r);a.set(n,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=n(),s=Xt(r);{let n=new Map(t().directories),i=n.get(r)??Q();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await Ot(r,i,void 0,o):await Dt(r,i,void 0,o);if(s!==Wt.get(r)||o!==n())return;let l=new Map(t().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(kt(i)||console.error(`Failed to fetch git branches:`,i),s!==Wt.get(r)||o!==n())return;let a=new Map(t().directories),c=a.get(r)??Q();a.set(r,{...c,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(n,r,i)=>{let{directories:a}=t(),o=a.get(n),s=i??o?.logMaxCount??25;{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(n,{maxCount:s}),a=new Map(t().directories),o=a.get(n)??Q();a.set(n,{...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(t().directories),a=i.get(n)??Q();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(n),a=new Map(t().directories),o=a.get(n)??Q();a.set(n,{...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(t().directories),a=i.get(n)??Q();i.set(n,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(n,r,i={})=>{let{directories:a}=t(),o=a.get(n);if(!o){o=Q();let t=new Map(a);t.set(n,o),e({directories:t})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await t().fetchStatus(n,r,{silent:c&&!!o?.status});let u=t().directories.get(n);if(!u?.isGitRepo)return;await t().fetchBranches(n,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>At||!u.log)&&await t().fetchLog(n,r),await t().fetchIdentity(n,r)},getDiff:(e,n)=>t().directories.get(e)?.diffCache.get(n)??null,setDiff:(n,r,i)=>{let a=new Map(t().directories),o=a.get(n)??Q(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=Qt(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{Yt(n);let r=new Map(t().directories),i=r.get(n);i&&(r.set(n,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,n)=>{let r=t().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,Ft);await t().prefetchDiffs(e,n,i,{maxFiles:Ft})},prefetchDiffs:async(n,r,i,a={})=>{let o=t().directories.get(n);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=It}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=Zt(n),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>zt||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=Jt(n);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 t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${Rt}ms`)),Rt)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},ee=async()=>{for(;;){if(m!==Jt(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{u.delete(e)}}},y=Math.min(Lt,p.length);if(await Promise.allSettled(Array.from({length:y},()=>ee())),p.forEach(e=>u.delete(e)),m!==Jt(n))return;let b=new Map(t().directories),x=b.get(n);if(!x)return;let S=new Map(x.diffCache),te=Date.now();g.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||S.set(e.path,{...e.diff,fetchedAt:te})});let ne=Qt(S);b.set(n,{...x,diffCache:ne}),e({directories:b})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<Mt||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=Kt.get(e);if(r)return r;let i=(async()=>{let r=t().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=Mt)&&await t().fetchStatus(e,n,{silent:!!r?.status});let a=t().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=Nt)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=At)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=Pt)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return Kt.set(e,i),i.finally(()=>{Kt.get(e)===i&&Kt.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),un=e=>{let t=(0,J.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)},dn=e=>{let r=(0,J.c)(3),i=V.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],$(a)},fn=e=>{let t=(0,J.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)},pn=e=>{let t=(0,J.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)},mn=e=>{let t=(0,J.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)},hn={current:new Map},gn=()=>$(xn),_n=e=>{let t=(0,J.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=V.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)},vn=e=>{let t=(0,J.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)},yn=e=>{let t=(0,J.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)},bn=e=>{let t=(0,J.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 xn(e){let t=hn.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 hn.current=r,r}var Sn=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)}},Cn=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),wn=e=>e.branchName?Cn(e.branchName):e.mode===`existing`?Cn(e.existingBranch||e.preferredName||``):Cn(e.preferredName||``),Tn=async e=>{let t=await I(e);try{let n=Sn((await P(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=Sn((await F(e)).tracking);if(t?.remote)return t.remote}catch{}return null},En=async(e,t)=>{let n=await Tn(e),r=Cn(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},Dn=async(e,t,n)=>{let r=wn(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await En(e,r):i&&Cn(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:Cn(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},On=async(e,t,n)=>{let r=await Dn(e.path,t,n);return L(e,r)},kn=`oc:lastWorktreeSourceBranch`,An=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,jn=({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},Mn=(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?` `:``}`},Nn=(e,t,n)=>{let r=Mn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},Pn=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=Nn(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}},Fn=(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]},In=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{Oe as A,Tt as C,Re as D,Ke as E,Te as F,ve as I,Ee as M,Ce as N,Ie as O,we as P,Ot as S,Je as T,fn as _,kn as a,$ as b,On as c,gn as d,mn as f,vn as g,yn as h,Nn as i,De as j,Ne as k,Tn as l,bn as m,Fn as n,jn as o,dn as p,Pn as r,An as s,In as t,Dn as u,_n as v,Et as w,pn as x,un as y};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{c as t,i as n}from"./runtime-switch-LvWDU-SL.js";import{Cn as r,D as i,d as a,k as o,tn as s,u as c}from"./persistence-DwRBC4zl.js";import{a as l,i as u,r as d}from"./vendor-zustand-B4dlGEM2.js";import{nt as f,rt as p}from"./vendor-base-ui-CnHfUmDN.js";import{B as m,Ct as h,M as g,Mt as _}from"./platform-DQ5_LNKO.js";import{b as v,t as ee,y}from"./useUIStore-CxOoCv7B.js";import{n as b}from"./vendor-react-DLPElpoQ.js";import{s as x}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as S}from"./vendor-reactuses-core-BnW6GxJt.js";import{n as te}from"./clipboard-GUUNlWIv.js";import{Qi as ne,c as C,ct as re,dr as ie,dt as ae,eo as oe,ft as se,g as w,go as T,ho as ce,in as E,lt as D,mn as O,ot as k,st as le,y as A}from"./useMobileNavigationStore-gXfZxA1A.js";import{c as j,t as M}from"./utils-2ZK8yboQ.js";import{n as N}from"./Icon-D1BcR8Tz.js";import{g as P,v as F}from"./gitApi-uzDmhDPP.js";import{f as I,o as L,q as ue}from"./projectMeta-DX3l1Xzy.js";import{n as de,r as fe,t as pe}from"./fileMentionTouchSelection-COw1MDRz.js";import{n as me}from"./textarea-B9CmN13Z.js";var R=e=>{switch(e.name){case`new`:return`add`;case`init`:return`file`;case`undo`:return`arrow-go-back`;case`redo`:return`arrow-go-forward`;case`timeline`:return`time`;case`compact`:return`scissors`;case`goal`:return`target`;case`review`:return`search-eye`;case`test`:case`build`:case`run`:return`terminal-box`;default:return e.isBuiltIn?`flashlight`:`command`}},he=()=>`book-open`,z=e=>{if(e.isDirectory)return`folder-3-fill`;switch(e.extension?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:case`json`:return`code`;case`md`:case`mdx`:return`file`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`svg`:return`file-image`;default:return`file-pdf`}},B=()=>`ai-agent`,ge=()=>`chat-thread`,_e=(e,t)=>e.map(e=>{let n=e.isSkill?t.skill:e.isOpenChamber?`OpenChamber`:e.isBuiltIn?t.system:e.scope||e.agent||t.command;return{id:e.id,title:`/${e.name}`,subtitle:e.description,badge:n,iconName:R(e)}}),ve=e=>e.map(e=>({id:`${e.name}-${e.scope}`,title:e.name,subtitle:e.description,badge:e.scope,iconName:he()})),ye=({agents:e,sessions:t,recentFiles:n,pathHits:r,untitledSession:i,sessionBadge:a})=>{let o=[];for(let t of e)o.push({id:`agent:${t.name}`,title:`@${t.name}`,subtitle:t.description,iconName:B()});for(let e of t)o.push({id:`session:${e.id}`,title:e.title||i,badge:a,iconName:ge()});for(let e of n)o.push({id:`recent:${e.path}`,title:e.relativePath||e.name,iconName:z(e)});for(let e of r)o.push({id:`file:${e.path}`,title:e.relativePath||e.name,iconName:z(e)});return o},be=(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)},xe=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!=null&&e.id===r.id&&e.title===r.title&&(e.subtitle??``)===(r.subtitle??``)&&(e.badge??``)===(r.badge??``)&&e.iconName===r.iconName}),Se=(e,t)=>e.highlightedIndex===t.highlightedIndex&&xe(e.rows,t.rows),Ce=(e,t)=>xe(e,t)?e:t.slice(),we=(e,t,n)=>{e&&(t.current&&Se(t.current,n)||(t.current=n,e(n)))},Te=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},V=e(p(),1),H=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},U=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,W=(e,t)=>{let n=H(t),r=H(e);if(!n||!r)return!1;let i=U(n),a=U(r);return a===i||a.startsWith(`${i}/`)},G=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=H(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=>H(e)).filter(e=>W(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>H(e)).filter(e=>W(e,t)))):[],s=typeof i.selectedPath==`string`?H(i.selectedPath):null,c=s&&W(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},K=(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},q=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Ee=l()(d(u((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=H((t||``).trim()),a=H((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!W(a,i)||e(e=>{let t=e.byRoot[i],n=q(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:K({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=H((t||``).trim()),i=H((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=U(i),a=e=>U(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:K({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=H((t||``).trim()),i=H((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=U(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=U(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:K({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=H((t||``).trim()),i=H((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=U(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=U(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:K({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=H((t||``).trim()),a=n?H(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!W(a,i)||e(e=>{let t=e.byRoot[i],n=q(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:K({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=H((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=H((t||``).trim()),i=H((n||``).trim());!r||!i||!W(i,r)||e(e=>{let t=e.byRoot[r],n=q(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:K({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=H((t||``).trim()),i=H((n||``).trim());!r||!i||!W(i,r)||e(e=>{let t=e.byRoot[r],n=q(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:K({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=H((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>H((e||``).trim())).filter(e=>e&&W(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=q(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:K({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:y(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:G(t)}},partialize:e=>({byRoot:G(e.byRoot)})}),{name:`files-view-tabs-store`})),J=b(),De=(e,t)=>{let n=(0,J.c)(4),r=t===void 0?200:t,[i,a]=V.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]),V.useEffect(o,s),i},Oe=()=>{let e=(0,J.c)(17),t=C(Y),n=O(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=A(r),a=C(X),o=C(ke),s=T(Ae),c=T(je),l=h(Me);if(t){let r;e[2]===i?r=e[3]:(r=w(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 Y(e){return e.currentSessionId}function X(e){return e.worktreeMetadata}function ke(e){return e.newSessionDraft}function Ae(e){return e.activeProjectId}function je(e){return e.projects}function Me(e){return e.currentDirectory}var Z=f(),Ne=V.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSessionSelect:r,onClose:a,style:s,onRowsChange:c},l)=>{let{t:u}=te(),d=Oe()??``,f=C(e=>e.currentSessionId),p=ie(e=>e.activeSessions),m=T(e=>e.activeProjectId),h=T(e=>e.projects),g=V.useMemo(()=>h.find(e=>e.id===m)?.path??null,[m,h]),v=V.useMemo(()=>{let e=g||d;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[g,d]),y=Ee(e=>v?e.byRoot[v]:void 0),b=ne(e=>e.getVisibleAgents),x=_(e=>e.searchFiles),oe=De(e,180),se=o(),w=i(),[ce,E]=V.useState([]),[O,A]=V.useState([]),[P,F]=V.useState(!1),[I,L]=V.useState(0),ue=V.useRef(0),[R,he]=V.useState(360),[B,ge]=V.useState({}),[_e,ve]=V.useState({}),be=V.useRef([]),xe=V.useRef([]),Se=V.useRef([]),Ce=V.useRef(null),H=V.useRef(null),U=V.useRef(null);U.current||=pe();let W=ee(e=>e.isMobile),G=(e??``).trim(),K=V.useMemo(()=>{if(!v||!y)return[];let e=[y.selectedPath,...y.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r);let e=r.replace(/\\/g,`/`),i=e.split(`/`).filter(Boolean).pop()||e,a=e.startsWith(`${v}/`)?e.slice(v.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return D(n,G,{limit:6})},[G,v,y]),q=V.useMemo(()=>G.length>0?O:O.slice(0,2),[O,G.length]),J=V.useMemo(()=>r?k({sessions:p,currentSessionId:f,searchQuery:G}):[],[p,f,G,r]),Y=K,X=ce;V.useEffect(()=>{let e=e=>{let t=e.target;!t||!Ce.current||Ce.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),V.useEffect(()=>{if(!d){E([]);return}let e=(oe??``).trim(),t=ae(e);if(!t){E([]);return}let n=!1;F(!0);let r={includeHidden:se,respectGitignore:!w};return Promise.all([x(d,t,80,{...r,type:`file`}),x(d,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(K.map(e=>e.path));E(le({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||E([])}).finally(()=>{n||F(!1)}),()=>{n=!0}},[d,oe,K,x,se,w]),V.useEffect(()=>{let t=b().filter(e=>e.mode&&e.mode!==`primary`).map(e=>({name:e.name,description:e.description,mode:e.mode}));A(re(t,e??``))},[b,e]),V.useEffect(()=>{L(0),ge({}),ve({})},[X,Y.length,q.length,J.length]),V.useEffect(()=>{ue.current=I},[I]),V.useEffect(()=>{be.current[I]?.scrollIntoView({block:`nearest`})},[I]),V.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};xe.current.forEach((n,r)=>{if(!n)return;let i=Se.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}}),ge(e),ve(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[X,Y]),V.useEffect(()=>{let e=xe.current[I];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&he(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[I]);let ke=S(e=>{t(e)}),Ae=S(e=>{n?.(e)}),je=S(e=>{r?.(e)}),Me=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&U.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&U.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(U.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>U.current?.pointerCancel(),onClick:()=>{U.current?.click(t)},onMouseMove:()=>L(e)}),Ne=e=>{let t=q.length+J.length+Y.length+X.length;if(t===0)return;let n=(e%t+t)%t;if(n<q.length){let e=q[n];e&&Ae(e.name);return}let r=n-q.length;if(r<J.length){let e=J[r];e&&je(e);return}let i=r-J.length,a=i<Y.length?Y[i]:X[i-Y.length];a&&ke(a)};V.useEffect(()=>{we(c,H,{rows:ye({agents:q,sessions:J,recentFiles:Y,pathHits:X,untitledSession:u(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:u(`chat.fileMentionAutocomplete.sessionType`)}),highlightedIndex:I})},[c,I,u,q,X,Y,J]);let Pe=V.useRef(c);Pe.current=c,V.useEffect(()=>()=>{Te(Pe.current,H)},[]),V.useImperativeHandle(l,()=>({acceptIndex:e=>{Ne(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=q.length+J.length+Y.length+X.length;if(t!==0){if(e===`ArrowDown`){L(e=>(e+1)%t);return}if(e===`ArrowUp`){L(e=>(e-1+t)%t);return}(e===`Enter`||e===`Tab`)&&Ne(ue.current)}}}),[X,Y,q,J,a,ke,Ae,je]);let Fe=e=>(0,Z.jsx)(N,{name:z(e),className:`h-3.5 w-3.5 text-current`});return(0,Z.jsxs)(de,{ref:Ce,isMobile:W,className:`max-w-[640px] max-h-64`,style:s,children:[(0,Z.jsx)(me,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,Z.jsxs)(`div`,{className:`pb-2`,children:[q.length>0&&(0,Z.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)=>{let n=I===t;return(0,Z.jsx)(`div`,{ref:e=>{be.current[t]=e},className:M(`flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,fe(W,n),!W&&n&&`text-interactive-selection-foreground`),...Me(t,()=>Ae(e.name)),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`font-semibold truncate`,children:[`@`,e.name]}),e.description&&!W?(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:e.description}):null]})},`agent-${e.name}`)}),q.length===2&&G.length===0&&O.length>2&&(0,Z.jsx)(`div`,{className:`px-3 py-1 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.searchMoreAgents`)}),J.length>0&&(0,Z.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,r=I===n;return(0,Z.jsxs)(`div`,{ref:e=>{be.current[n]=e},className:M(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,fe(W,r),!W&&r&&`text-interactive-selection-foreground`),...Me(n,()=>je(e)),children:[(0,Z.jsx)(N,{name:`chat-thread`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title||u(`chat.fileMentionAutocomplete.untitledSession`),children:e.title||u(`chat.fileMentionAutocomplete.untitledSession`)}),W?null:(0,Z.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.sessionType`)})]},`session-${e.id}`)}),Y.length>0&&(0,Z.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=j(r,{maxLength:60}),a=I===n,o=B[n]??!1,s=_e[n]??2.6;return(0,Z.jsxs)(`div`,{ref:e=>{be.current[n]=e},className:M(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,fe(W,a),!W&&a&&`text-interactive-selection-foreground`),...Me(n,()=>ke(e)),children:[Fe(e),(0,Z.jsxs)(`span`,{ref:e=>{xe.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${R}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,Z.jsx)(`span`,{ref:e=>{Se.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,Z.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,Z.jsx)(`span`,{className:`block truncate`,children:i})]})]},`recent-${e.path}`)}),X.length>0&&(0,Z.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.files`)}),X.map((e,t)=>{let n=q.length+J.length+Y.length+t,r=e.relativePath||e.name,i=j(r,{maxLength:60}),a=I===n,o=B[n]??!1,s=_e[n]??2.6;return(0,Z.jsxs)(`div`,{ref:e=>{be.current[n]=e},className:M(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,fe(W,a),!W&&a&&`text-interactive-selection-foreground`),...Me(n,()=>ke(e)),children:[Fe(e),(0,Z.jsxs)(`span`,{ref:e=>{xe.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${R}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,Z.jsx)(`span`,{ref:e=>{Se.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,Z.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,Z.jsx)(`span`,{className:`block truncate`,children:i})]})]},e.path)}),P&&X.length===0?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,Z.jsx)(N,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!P&&X.length===0&&Y.length===0&&q.length===0&&J.length===0&&(0,Z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.empty`)})]})}),!W&&(0,Z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})}),Pe=new Set([`new`,`fork`,`compact`,`undo`,`redo`,`model`,`goal`]),Fe=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Pe.has(n))},Ie=(e,t)=>!e||t({name:e}),Le=` `,Re=(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]===Le&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},ze=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Be=M(ze,`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)]`),Ve=M(ze,`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)]`),He=M(ze,`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)]`),Ue=M(ze,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),We=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id),Ge=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!s()}},Ke=V.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:i,commandPolicy:a,commandContext:o,onRowsChange:s},c)=>{let{t:l}=te(),u=ee(e=>e.isMobile),d=C(e=>e.currentSessionId),f=C(e=>!!e.newSessionDraft?.open),p=C(V.useCallback(e=>d?e.getDirectoryForSession(d):void 0,[d])),m=E(d??``,p??void 0),h=V.useMemo(()=>o??{sessionID:d??null,hasMessages:m.length>0,hasNewDraft:f},[o,d,m.length,f]),{hasSession:g,canStartSessionCommand:_,canUseReviewHandoffFlow:v}=V.useMemo(()=>Ge(h,u),[h,u]),y=h.hasMessages,[b,x]=V.useState([]),[S,ne]=V.useState(!1),re=ce({directory:r}),ie=V.useMemo(()=>re.data??[],[re.data]),ae=re.isFetching,se=oe({directory:r}),w=V.useMemo(()=>se.data??[],[se.data]),[T,D]=V.useState(0),O=V.useRef(0),k=V.useRef(!1),le=V.useRef([]),A=V.useRef(null),j=V.useRef(!1),P=V.useRef(null),F=V.useRef(!1),I=V.useRef(null);V.useEffect(()=>{let e=e=>{let t=e.target;!t||!A.current||A.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),V.useEffect(()=>{(async()=>{ne(ae);try{let t=ie.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=w.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: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,o=be(r.filter(e=>(i||e.name!==`init`)&&(a?.(e)??!0)),e);x(e=>We(e,o)?e:o)}catch{let t=!y,n=be([{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: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`)&&(a?.(e)??!0)),e);x(e=>We(e,n)?e:n)}finally{ne(!1)}})()},[e,y,g,_,v,ie,ae,w,l,a]),V.useEffect(()=>{D(0)},[b]),V.useEffect(()=>{O.current=T},[T]),V.useEffect(()=>{le.current[T]?.scrollIntoView({block:`nearest`})},[T]),V.useEffect(()=>{we(s,I,{rows:_e(b,{skill:l(`chat.commandAutocomplete.badge.skill`),command:l(`chat.commandAutocomplete.badge.command`),system:l(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:T})},[b,s,T,l]);let L=V.useRef(s);L.current=s,V.useEffect(()=>()=>{Te(L.current,I)},[]),V.useImperativeHandle(c,()=>({acceptIndex:(e,n=!0)=>{let r=b[e];r&&t(r,Fe(r,n))},handleKeyDown:e=>{let r=b.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){k.current=!0,D(e=>(e+1)%r);return}if(e===`ArrowUp`){k.current=!0,D(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(O.current%r+r)%r,i=b[n];i&&t(i,Fe(i,e===`Enter`))}}}}),[b,n,t]);let ue=e=>{let t=R(e);switch(e.name){case`new`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,Z.jsx)(N,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,Z.jsxs)(de,{ref:A,isMobile:u,className:`max-w-[450px] max-h-64`,style:i,children:[(0,Z.jsx)(me,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:S?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,Z.jsx)(N,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,Z.jsxs)(`div`,{children:[b.map((e,n)=>{let r=e.isBuiltIn,i=e.isOpenChamber;return(0,Z.jsxs)(`div`,{ref:e=>{le.current[n]=e},className:M(`flex gap-2 px-3 py-2 cursor-pointer rounded-lg`,u?`items-center`:`items-start`,fe(u,n===T)),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(),j.current=!0,t(e,Fe(e,u)))},onPointerCancel:()=>{P.current=null,F.current=!1},onClick:()=>{if(j.current){j.current=!1;return}t(e,Fe(e,u))},onMouseMove:()=>{k.current=!1,D(n)},children:[(0,Z.jsx)(`div`,{className:M(!u&&`mt-0.5`),children:ue(e)}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,e.name]}),e.isSkill?(0,Z.jsx)(`span`,{className:Be,children:l(`chat.commandAutocomplete.badge.skill`)}):(0,Z.jsx)(`span`,{className:Be,children:l(`chat.commandAutocomplete.badge.command`)}),i?(0,Z.jsx)(`span`,{className:Ue,children:`OpenChamber`}):r?(0,Z.jsx)(`span`,{className:Ue,children:l(`chat.commandAutocomplete.badge.system`)}):e.scope?(0,Z.jsx)(`span`,{className:e.scope===`project`?He:Ve,children:e.scope}):null,e.agent&&(0,Z.jsx)(`span`,{className:Ue,children:e.agent})]}),e.description&&!u&&(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:e.description})]})]},e.id)}),b.length===0&&(0,Z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.commandAutocomplete.empty`)})]})}),!u&&(0,Z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})});Ke.displayName=`CommandAutocomplete`;function qe(e){return(e.description||e.content).replace(/\s+/g,` `).trim().slice(0,120)}var Je=V.forwardRef((e,t)=>{let n=(0,J.c)(62),{searchQuery:r,onSnippetSelect:i,onClose:a,style:o}=e,{t:s}=te(),c=V.useRef(null),l=ee(Ye),[u,d]=V.useState(0),f=V.useRef(0),p;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],n[0]=p):p=n[0];let[m,h]=V.useState(p),g;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],n[1]=g):g=n[1];let _=V.useRef(g),v=ue(Xe),y=ue(Ze),b=ue(Qe),x=ue($e),S=ee(et),ne=ee(tt),C,re;n[2]===y?(C=n[3],re=n[4]):(C=()=>{y()},re=[y],n[2]=y,n[3]=C,n[4]=re),V.useEffect(C,re);let ie,ae;n[5]!==r||n[6]!==v?(ie=()=>{let e=r.trim();if(!e.length){let e=[...v].sort(nt);h(e),d(+!!e.length);return}let t=se(v,e,rt);t.sort(it);let n=t.map(at);h(n),d(+!!n.length)},ae=[r,v],n[5]=r,n[6]=v,n[7]=ie,n[8]=ae):(ie=n[7],ae=n[8]),V.useEffect(ie,ae);let oe,w;n[9]===u?(oe=n[10],w=n[11]):(oe=()=>{f.current=u,_.current[u]?.scrollIntoView({block:`nearest`})},w=[u],n[9]=u,n[10]=oe,n[11]=w),V.useEffect(oe,w);let T,ce;n[12]===a?(T=n[13],ce=n[14]):(ce=()=>{let e=e=>{let t=e.target;t&&c.current&&!c.current.contains(t)&&a()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},T=[a],n[12]=a,n[13]=T,n[14]=ce),V.useEffect(ce,T);let E;n[15]!==i||n[16]!==r?(E=e=>{let t=r.trim(),n=e.aliases.includes(t)?t:e.name;i(e,n)},n[15]=i,n[16]=r,n[17]=E):E=n[17];let D=E,O;n[18]!==a||n[19]!==x||n[20]!==S||n[21]!==ne||n[22]!==b||n[23]!==v?(O=()=>{let e=new Set(v.map(ot)),t=`new-snippet`,n=1;for(;e.has(t);)t=`new-snippet-${n++}`;b({name:t,scope:`global`}),x(t),ne(`snippets`),S(!0),a()},n[18]=a,n[19]=x,n[20]=S,n[21]=ne,n[22]=b,n[23]=v,n[24]=O):O=n[24];let k=O,le,A;n[25]!==D||n[26]!==m||n[27]!==a||n[28]!==k?(le=()=>({handleKeyDown:e=>{if(e===`Escape`){a();return}let t=m.length+1;if(e===`ArrowDown`){d(e=>(e+1)%t);return}if(e===`ArrowUp`){d(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){if(f.current===0){k();return}let e=m[f.current-1];e&&D(e)}}}),A=[D,m,a,k],n[25]=D,n[26]=m,n[27]=a,n[28]=k,n[29]=le,n[30]=A):(le=n[29],A=n[30]),V.useImperativeHandle(t,le,A);let j;n[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{_.current[0]=e},n[31]=j):j=n[31];let P;n[32]!==l||n[33]!==u?(P=M(`flex items-center gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,fe(l,u===0)),n[32]=l,n[33]=u,n[34]=P):P=n[34];let F,I;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>d(0),I=(0,Z.jsx)(N,{name:`add`,className:`h-3.5 w-3.5 text-muted-foreground`}),n[35]=F,n[36]=I):(F=n[35],I=n[36]);let L;n[37]===s?L=n[38]:(L=s(`chat.snippetAutocomplete.action.addNew`),n[37]=s,n[38]=L);let pe;n[39]===L?pe=n[40]:(pe=(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:L}),n[39]=L,n[40]=pe);let R;n[41]!==k||n[42]!==P||n[43]!==pe?(R=(0,Z.jsxs)(`div`,{ref:j,className:P,onClick:k,onMouseMove:F,children:[I,pe]}),n[41]=k,n[42]=P,n[43]=pe,n[44]=R):R=n[44];let he;n[45]!==D||n[46]!==m||n[47]!==l||n[48]!==u||n[49]!==s?(he=m.length?m.map((e,t)=>(0,Z.jsx)(`div`,{ref:e=>{_.current[t+1]=e},className:M(`flex gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,l?`items-center`:`items-start`,fe(l,t+1===u)),onClick:()=>D(e),onMouseMove:()=>d(t+1),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`font-semibold truncate`,children:[`#`,e.name]}),(0,Z.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:s(`snippets.source.${e.source}`)})]}),!l&&(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:qe(e)})]})},`${e.source}:${e.filePath}`)):(0,Z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:s(`chat.snippetAutocomplete.empty`)}),n[45]=D,n[46]=m,n[47]=l,n[48]=u,n[49]=s,n[50]=he):he=n[50];let z;n[51]!==R||n[52]!==he?(z=(0,Z.jsxs)(me,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:[R,he]}),n[51]=R,n[52]=he,n[53]=z):z=n[53];let B;n[54]!==l||n[55]!==s?(B=!l&&(0,Z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:s(`chat.snippetAutocomplete.footer`)}),n[54]=l,n[55]=s,n[56]=B):B=n[56];let ge;return n[57]!==l||n[58]!==o||n[59]!==z||n[60]!==B?(ge=(0,Z.jsxs)(de,{ref:c,isMobile:l,className:`max-w-[450px] max-h-60`,style:o,children:[z,B]}),n[57]=l,n[58]=o,n[59]=z,n[60]=B,n[61]=ge):ge=n[61],ge});Je.displayName=`SnippetAutocomplete`;function Ye(e){return e.isMobile}function Xe(e){return e.snippets}function Ze(e){return e.loadSnippets}function Qe(e){return e.setSnippetDraft}function $e(e){return e.setSelectedSnippet}function et(e){return e.setSettingsDialogOpen}function tt(e){return e.setSettingsPage}function nt(e,t){return e.source===`project`&&t.source!==`project`?-1:e.source!==`project`&&t.source===`project`?1:e.name.localeCompare(t.name)}function rt(e){return[e.name,...e.aliases]}function it(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 at(e){return e.item}function ot(e){return e.name}var st=2,ct=e=>!!e&&typeof e==`object`&&!Array.isArray(e),lt=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},ut=e=>ct(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&ct(e.branches),dt=(e,t)=>JSON.stringify([e,t]),ft=e=>`version`in e&&e.version===st&&ct(e.entries),pt=e=>{if(!e)return null;try{let t=JSON.parse(e);return ct(t)?t.version===st&&ct(t.entries)?{version:st,entries:t.entries}:t:null}catch{return null}},mt=(e,t)=>{try{e.setItem(`oc.gitBranchCache`,JSON.stringify(t))}catch{}},ht=(e,t,n)=>{let r=lt(e);if(!r||!t)return null;let i;try{i=n.getItem(`oc.gitBranchCache`)}catch{return null}let a=pt(i);if(!a)return null;if(ft(a))return ut(a.entries[dt(t,r)])?a.entries[dt(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=lt(e);r&&ut(n)&&(o[dt(t,r)]=n)}return mt(n,{version:st,entries:o}),o[dt(t,r)]??null},gt=(e,t,n,r)=>{let i=lt(e);if(!i||!t||!ut(n))return;let a=null;try{a=r.getItem(`oc.gitBranchCache`)}catch{return}let o=pt(a);mt(r,{version:st,entries:{...o&&ft(o)?o.entries:{},[dt(t,i)]:n}})},_t=3e4,vt=lt,yt=(e,t=n())=>a.git.branches(vt(e),t),bt=(e,t=n())=>a.git.remotes(vt(e),t),xt=async(e,t,n)=>{n.throwIfAborted();let i=r()?.git,a=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):i?await i.getGitBranches(e,{signal:n}):await g(e,{signal:n});return n.throwIfAborted(),a},St=async(e,t,n)=>{n.throwIfAborted();let i=r()?.git,a=t?.getRemotes?await t.getRemotes(e,{signal:n}):i?await i.getRemotes(e,{signal:n}):await m(e,{signal:n});return n.throwIfAborted(),a},Ct=(e,t,r=n(),i=v())=>{let a=vt(e),o=t;return{queryKey:yt(a,r),queryFn:async({signal:e})=>{if(!a)throw Error(`Git branches require a directory`);let t=await xt(a,o,e);return gt(a,r,t,i),t},staleTime:_t,gcTime:1/0,initialData:()=>ht(a,r,i)??void 0,initialDataUpdatedAt:0}},wt=(e,t,r=n())=>{let i=vt(e),a=t;return{queryKey:bt(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return St(i,a,e)},staleTime:_t,gcTime:1/0}},Tt=(e,r,i)=>{let a=(0,J.c)(9),o=i===void 0||i,s=V.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=vt(e),u=x,l=Ct(c,r,s),a[0]=e,a[1]=r,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)},Et=(e,r,i)=>{let a=(0,J.c)(9),o=i===void 0||i,s=V.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=vt(e),u=x,l=wt(c,r,s),a[0]=e,a[1]=r,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)},Dt=(e,t,r=c,i=n())=>r.fetchQuery(Ct(e,t,i)),Ot=(e,t,r=c,i=n())=>r.fetchQuery({...Ct(e,t,i),staleTime:0}),kt=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,At=1e4,jt=6e4,Mt=5e3,Nt=3e4,Pt=6e4,Ft=25,It=40,Lt=2,Rt=15e3,zt=500,Bt=30,Vt=20971520,Ht=new Map,Ut=new Map,Wt=new Map,Gt=new Map,Kt=new Map,qt=(e,t)=>`${t}:${e}`,Jt=e=>Ut.get(e)??0,Yt=e=>{let t=Jt(e)+1;return Ut.set(e,t),t},Xt=e=>{let t=(Wt.get(e)??0)+1;return Wt.set(e,t),t},Zt=e=>{let t=Ht.get(e);if(t)return t;let n=new Set;return Ht.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}),Qt=(e,t=Bt,n=Vt)=>{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},$t=(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},en=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,tn=(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&&en(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&&$t(e.diffStats,t.diffStats))},nn=(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},rn=(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},an=e=>!e||e.trim().length===0,on=e=>(e||``).trim()===`U`,sn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(on(t)||on(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},cn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(on(t)||on(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},ln=e=>an(e.index)&&an(e.working_dir),$=l()(d((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&Yt(r),n&&Yt(n),n&&!i.has(n)){let t=new Map(i);t.set(n,Q()),e({activeDirectory:n,directories:t})}else e({activeDirectory:n})},getDirectoryState:e=>t().directories.get(e)??null,fetchStatus:async(n,r,i={})=>{let a=i.mode??`full`,o=qt(n,a),s=Gt.get(o)??(a===`light`?Gt.get(qt(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=Q(),!a){let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>jt,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(n)),!l){let r=new Map(t().directories),i=r.get(n)??s;return r.set(n,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(n,i.mode?{mode:i.mode}:void 0);if(tn(s.status,u)){c=!0;let r=new Map(t().directories),i=r.get(n)??Q(),s=nn(i.status,u),l=rn(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&&Yt(n);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(n,{...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(t().directories),i=r.get(n)??Q();r.set(n,{...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(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();Gt.set(o,c);try{return await c}finally{Gt.get(o)===c&&Gt.delete(o)}},moveStatusPathsOptimistically:(n,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=t(),s=o.get(n),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`?sn(e):cn(e);t!==e&&(l=!0),ln(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(n,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(n,r)=>{let{directories:i}=t(),a=i.get(n);if(!a)return;let o=new Map(i);o.set(n,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:n=>{let{directories:r}=t(),i=r.get(n);if(!i)return;let a=new Map(r);a.set(n,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=n(),s=Xt(r);{let n=new Map(t().directories),i=n.get(r)??Q();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await Ot(r,i,void 0,o):await Dt(r,i,void 0,o);if(s!==Wt.get(r)||o!==n())return;let l=new Map(t().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(kt(i)||console.error(`Failed to fetch git branches:`,i),s!==Wt.get(r)||o!==n())return;let a=new Map(t().directories),c=a.get(r)??Q();a.set(r,{...c,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(n,r,i)=>{let{directories:a}=t(),o=a.get(n),s=i??o?.logMaxCount??25;{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(n,{maxCount:s}),a=new Map(t().directories),o=a.get(n)??Q();a.set(n,{...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(t().directories),a=i.get(n)??Q();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(n),a=new Map(t().directories),o=a.get(n)??Q();a.set(n,{...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(t().directories),a=i.get(n)??Q();i.set(n,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(n,r,i={})=>{let{directories:a}=t(),o=a.get(n);if(!o){o=Q();let t=new Map(a);t.set(n,o),e({directories:t})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await t().fetchStatus(n,r,{silent:c&&!!o?.status});let u=t().directories.get(n);if(!u?.isGitRepo)return;await t().fetchBranches(n,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>At||!u.log)&&await t().fetchLog(n,r),await t().fetchIdentity(n,r)},getDiff:(e,n)=>t().directories.get(e)?.diffCache.get(n)??null,setDiff:(n,r,i)=>{let a=new Map(t().directories),o=a.get(n)??Q(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=Qt(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{Yt(n);let r=new Map(t().directories),i=r.get(n);i&&(r.set(n,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,n)=>{let r=t().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,Ft);await t().prefetchDiffs(e,n,i,{maxFiles:Ft})},prefetchDiffs:async(n,r,i,a={})=>{let o=t().directories.get(n);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=It}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=Zt(n),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>zt||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=Jt(n);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 t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${Rt}ms`)),Rt)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},ee=async()=>{for(;;){if(m!==Jt(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{u.delete(e)}}},y=Math.min(Lt,p.length);if(await Promise.allSettled(Array.from({length:y},()=>ee())),p.forEach(e=>u.delete(e)),m!==Jt(n))return;let b=new Map(t().directories),x=b.get(n);if(!x)return;let S=new Map(x.diffCache),te=Date.now();g.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||S.set(e.path,{...e.diff,fetchedAt:te})});let ne=Qt(S);b.set(n,{...x,diffCache:ne}),e({directories:b})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<Mt||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=Kt.get(e);if(r)return r;let i=(async()=>{let r=t().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=Mt)&&await t().fetchStatus(e,n,{silent:!!r?.status});let a=t().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=Nt)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=At)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=Pt)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return Kt.set(e,i),i.finally(()=>{Kt.get(e)===i&&Kt.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),un=e=>{let t=(0,J.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)},dn=e=>{let r=(0,J.c)(3),i=V.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],$(a)},fn=e=>{let t=(0,J.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)},pn=e=>{let t=(0,J.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)},mn=e=>{let t=(0,J.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)},hn={current:new Map},gn=()=>$(xn),_n=e=>{let t=(0,J.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=V.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)},vn=e=>{let t=(0,J.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)},yn=e=>{let t=(0,J.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)},bn=e=>{let t=(0,J.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 xn(e){let t=hn.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 hn.current=r,r}var Sn=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)}},Cn=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),wn=e=>e.branchName?Cn(e.branchName):e.mode===`existing`?Cn(e.existingBranch||e.preferredName||``):Cn(e.preferredName||``),Tn=async e=>{let t=await I(e);try{let n=Sn((await P(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=Sn((await F(e)).tracking);if(t?.remote)return t.remote}catch{}return null},En=async(e,t)=>{let n=await Tn(e),r=Cn(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},Dn=async(e,t,n)=>{let r=wn(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await En(e,r):i&&Cn(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:Cn(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},On=async(e,t,n)=>{let r=await Dn(e.path,t,n);return L(e,r)},kn=`oc:lastWorktreeSourceBranch`,An=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,jn=({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},Mn=(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?` `:``}`},Nn=(e,t,n)=>{let r=Mn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},Pn=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=Nn(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}},Fn=(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]},In=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{Oe as A,Tt as C,Re as D,Ke as E,Te as F,ve as I,Ee as M,Ce as N,Ie as O,we as P,Ot as S,Je as T,fn as _,kn as a,$ as b,On as c,gn as d,mn as f,vn as g,yn as h,Nn as i,De as j,Ne as k,Tn as l,bn as m,Fn as n,jn as o,dn as p,Pn as r,An as s,In as t,Dn as u,_n as v,Et as w,pn as x,un as y};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-workbox-window-qnW0Nbv7.js","assets/rolldown-runtime-C0FnF6B9.js","assets/renderMobileApp-
|
|
2
|
-
import{n as e,t}from"./runtimeConfig-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-workbox-window-qnW0Nbv7.js","assets/rolldown-runtime-C0FnF6B9.js","assets/renderMobileApp-ATUEcuRh.js","assets/runtime-auth-D66yq6ie.js","assets/runtime-switch-LvWDU-SL.js","assets/runtime-fetch-zIalUnbb.js","assets/persistence-DwRBC4zl.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-base-ui-CnHfUmDN.js","assets/useUIStore-CxOoCv7B.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/platform-DQ5_LNKO.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/capgoAdapter-DCowZ2ab.js","assets/types-BuiqMmh_.js","assets/vendor-pierre-diffs-DX7XTPG3.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/vendor-sonner-DVzioF3d.js","assets/vendor-reactuses-core-BnW6GxJt.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/clipboard-GUUNlWIv.js","assets/store-ClnJdJSj.js","assets/MobileShareBridge-D2RJnSvI.js","assets/MobileDetailNavigation-37jfPItf.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/useMobileNavigationStore-gXfZxA1A.js","assets/useAssistantUIStore-CLPCNoj_.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/utils-2ZK8yboQ.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/Icon-D1BcR8Tz.js","assets/button-9R-WgVMl.js","assets/dialog-DhMGbF_B.js","assets/AgentAvatar-m1jNq4bX.js","assets/gitApi-uzDmhDPP.js","assets/useAppFontEffects-Cn7pYCz1.js","assets/desktopHosts-B052a4UK.js","assets/desktopRelayRestore-OjKNXr10.js","assets/vendor-codemirror-autocomplete-DHomsvW7.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/projectMeta-DX3l1Xzy.js","assets/input-Cd_1HyQv.js","assets/tooltip-DSjr26A_.js","assets/OverlayScrollbar-Bahg_P3r.js","assets/textarea-B9CmN13Z.js","assets/vendor-dnd-kit-core-CvWxUPdb.js","assets/vendor-dnd-kit-accessibility-BY5LhhUB.js","assets/vendor-dnd-kit-sortable-hHdP9lLb.js","assets/useSessionAutoCleanup-CsVhR6FK.js","assets/vendor-codemirror-lang-angular-DShkBD6m.js","assets/vendor-codemirror-lang-json-CYJRHck9.js","assets/vendor-codemirror-lang-markdown-WORgx6ZD.js","assets/vendor-codemirror-lang-python-Du6XQ8Zw.js","assets/vendor-codemirror-legacy-modes-DuRAjNvB.js","assets/useThemeSystem-DMzWVJaW.js","assets/dropdown-menu.styles-Bzo6L3FH.js","assets/vendor-codemirror-language-data-BfYFhIH1.js","assets/markdownTheme-DOfGg-A7.js","assets/useRuntimeAPIs-DSLXJybW.js","assets/insertionBoundaries-BYOyFrjB.js","assets/fileMentionTouchSelection-COw1MDRz.js","assets/appThemeRegistry-DaoSMJG1.js","assets/MarkdownRenderer-BrOPSCOy.js","assets/markdownHeightCache-BL8CUQ0M.js","assets/dualLimitLru-D8Sphgua.js","assets/url-CMQwHq4k.js","assets/markdown-worker-CptoICmq.js","assets/useEffectiveDirectory-DT_EmmM0.js","assets/FadeInOnReveal-UGwClbL_.js","assets/imageSource-BlAJJUEI.js","assets/relay-image-stream-DM7atqJs.js","assets/useWorkerHighlightedLines-C1rC3WQe.js","assets/vendor-tanstack-react-virtual-tlDgH6PG.js","assets/sessionChangeSummary-BG7l2heP.js","assets/vendor-cmdk-CeAGfrLo.js","assets/vendor-aria-hidden-BbL3cEyI.js","assets/sortable-tabs-strip-dYW6SH62.js","assets/vendor-framer-motion-DFy_BSVd.js","assets/vendor-legendapp-list-WE32lwNk.js","assets/useFontPreferences-DCaY8NbU.js","assets/terminalApi-CfgOfnZk.js","assets/MobileSurface-B_jx2mRT.js","assets/collapsible-Bbz9KiJf.js","assets/vendor-codemirror-commands-C9DCaJ0C.js","assets/vendor-codemirror-search-D2SOgzph.js","assets/vendor-replit-codemirror-vim-CEibx3EP.js","assets/projectActions-CWvNGKfA.js","assets/runtimeEndpointReset-CRc6se81.js","assets/sessionLookup-D3ISlV8R.js","assets/context-menu-CSyOhRz8.js","assets/vendor-cron-parser-CCD11YFT.js","assets/SettingsView-B5BWCL5K.js","assets/vendor-yaml-DIcAK3EC.js","assets/vendor-qrcode-DAuVxiQR.js","assets/vendor-dijkstrajs-DztKuCwY.js","assets/AssistantView-B79FR_5m.js","assets/assistant-attachment-cache-C0aRnFkj.js","assets/fileQueries-B_s_B-fH.js","assets/src-CO9q_82J.css","assets/main-DaaedB65.js","assets/useDesktopWindowControlsLayout-DXAFSQuV.js","assets/diagram-NdsZih8P.js","assets/vendor-react-drawio-ECtEwvbc.js","assets/multirun-BKVlVu2V.js","assets/vendor-zumer-snapdom-yq9vlCKr.js","assets/vendor-html-to-image-BDMm2v6d.js","assets/main-qSeeJRW1.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{n as e,t}from"./runtimeConfig-Cug6bqDv.js";import{o as n}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";/* empty css */var r=`true`,i=`false`,a=r===`true`,o=i===`true`;function s(e={}){let{immediate:t=!1,onNeedReload:r,onNeedRefresh:i,onOfflineReady:s,onRegistered:c,onRegisteredSW:l,onRegisterError:u}=e,d,f,p,m=async(e=!0)=>{await f,a||p?.()};async function h(){if(`serviceWorker`in navigator){if(d=await n(async()=>{let{Workbox:e}=await import(`./vendor-workbox-window-qnW0Nbv7.js`).then(e=>e.t);return{Workbox:e}},__vite__mapDeps([0,1])).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{u?.(e)}),!d)return;if(p=()=>{d?.messageSkipWaiting()},!o)if(a)d.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&(r?r():window.location.reload())}),d.addEventListener(`installed`,e=>{e.isUpdate||s?.()});else{let e=!1,t=()=>{e=!0,d?.addEventListener(`controlling`,e=>{e.isUpdate&&(r?r():window.location.reload())}),i?.()};d.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&s?.():n.isExternal?t():!e&&s?.():n.isUpdate||s?.()}),d.addEventListener(`waiting`,t)}d.register({immediate:t}).then(e=>{l?l(`/sw.js`,e):c?.(e)}).catch(e=>{u?.(e)})}}return f=h(),m}window.__OPENCHAMBER_RUNTIME_APIS__=t();var c=()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(pointer: coarse)`).matches,l=(()=>{let e=new URLSearchParams(window.location.search).get(`surface`);if(e===`mobile`)return`mobile`;if(e===`desktop`)return`desktop`;let t=Math.min(window.innerWidth||0,window.screen?.width||window.innerWidth||0),n=navigator.maxTouchPoints||0;return t>0&&t<=760&&(n>0||c())?`mobile`:`desktop`})();window.__OPENCHAMBER_SURFACE__=l;var u=()=>!(!(`serviceWorker`in navigator)||!window.isSecureContext||window.location.protocol!==`http:`&&window.location.protocol!==`https:`||document.prerendering||String(document.visibilityState)===`prerender`),d=e=>{let t=!1,n=()=>{t||u()&&(t=!0,e())},r=()=>{setTimeout(n,0)};document.readyState===`complete`?r():window.addEventListener(`load`,r,{once:!0}),(document.prerendering||String(document.visibilityState)===`prerender`)&&document.addEventListener(`visibilitychange`,n,{once:!0})},f=()=>{d(()=>{try{s({onRegisterError(e){console.warn(`[PWA] service worker registration skipped:`,e)}})}catch(e){console.warn(`[PWA] service worker registration skipped:`,e)}})},p=`openchamber.dev.module-reload`,m=(e,t)=>{console.error(`[openchamber] failed to load ${t}:`,e)};l===`mobile`?n(async()=>{let{renderMobileApp:e}=await import(`./renderMobileApp-ATUEcuRh.js`);return{renderMobileApp:e}},__vite__mapDeps([2,1,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,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111])).then(({renderMobileApp:e})=>{try{sessionStorage.removeItem(p)}catch{}e(window.__OPENCHAMBER_RUNTIME_APIS__??t())}).catch(e=>m(e,`renderMobileApp`)):e().then(()=>n(()=>import(`./main-DaaedB65.js`),__vite__mapDeps([112,1,3,4,5,6,7,8,9,10,11,12,49,13,14,15,36,93,51,18,19,20,21,22,23,24,25,26,27,29,30,31,32,33,35,37,28,38,39,40,41,42,43,44,45,47,48,50,46,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,94,17,95,96,97,98,99,113,100,101,102,103,114,115,116,117,118,119,111]))).then(()=>{try{sessionStorage.removeItem(p)}catch{}}).catch(e=>m(e,`desktop main`)),f();
|