@yuriai/web 0.2.29-beta.4 → 0.2.29-beta.5
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/{AssistantContactStatus-AG7iGeRF.js → AssistantContactStatus-B67HXRUY.js} +3 -3
- package/dist/assets/{AssistantUnreadBadge-BMCaH0Cc.js → AssistantUnreadBadge-Xz7kMLSv.js} +1 -1
- package/dist/assets/{AssistantView-C5ACV-pb.js → AssistantView-YVdgtBeh.js} +1 -1
- package/dist/assets/{DiagramView-DJDzscnd.js → DiagramView-DCrAY37j.js} +1 -1
- package/dist/assets/{GuiPluginSurface-DfLl4Gd9.js → GuiPluginSurface-u815jFNI.js} +1 -1
- package/dist/assets/{MarkdownRenderer-YzZqs3v5.js → MarkdownRenderer-DZXM92vp.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-BjjAFHTQ.js → MarkdownRendererImpl-BLzRLmeZ.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-D8tam--u.js → MarkstreamRendererImpl-MqrsrtVx.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-B-AuJG6R.js → MobileDetailNavigation-CozkWJ5y.js} +1 -1
- package/dist/assets/{MobileShareBridge-B8X_MEk1.js → MobileShareBridge-yWj21Mpo.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-vvveBlBV.js → MobileTabPageHeader-BSbOGw3M.js} +1 -1
- package/dist/assets/{MultiRunWindow-C0dOS6fA.js → MultiRunWindow-BDh7FxgY.js} +1 -1
- package/dist/assets/{SettingsView-aWGqxCrZ.js → SettingsView-C1dLufb0.js} +1 -1
- package/dist/assets/{SettingsWindow-rX0TNPNO.js → SettingsWindow-DZFZJ8PI.js} +1 -1
- package/dist/assets/{TerminalView-BArR-jEl.js → TerminalView-2DhtuWTv.js} +1 -1
- package/dist/assets/{ToolOutputDialog-Bdwio4o_.js → ToolOutputDialog-COWWhGPD.js} +1 -1
- package/dist/assets/{appThemeRegistry-DOuA757r.js → appThemeRegistry-CPa7wDcf.js} +1 -1
- package/dist/assets/{capgoAdapter-BBnW57us.js → capgoAdapter-CQz-vZo-.js} +1 -1
- package/dist/assets/{gitApi-b2Mo4rXl.js → gitApi-CXkfrI_H.js} +1 -1
- package/dist/assets/{insertionBoundaries-BviApxnS.js → insertionBoundaries-CmxtGojv.js} +1 -1
- package/dist/assets/{main-Cp31rg32.js → main-CJAnB1m1.js} +4 -4
- package/dist/assets/{main-BchAIbLD.js → main-DuN735GT.js} +2 -2
- package/dist/assets/{mcpQueries-Cksi876R.js → mcpQueries-Ls770ehB.js} +1 -1
- package/dist/assets/{miniChat-BbuRxk9z.js → miniChat-BibI1YhA.js} +2 -2
- package/dist/assets/{mobile-CBiiV7GW.js → mobile-DNvOl_GU.js} +2 -2
- package/dist/assets/{mobileBackNavigation-BsbWBz8h.js → mobileBackNavigation-CXfKEN3p.js} +1 -1
- package/dist/assets/{multirun-Ce977k1P.js → multirun-CicU-KQt.js} +1 -1
- package/dist/assets/{native-config-5BNfonUF.js → native-config-BHa0LfdJ.js} +1 -1
- package/dist/assets/{projectMeta-KTYl7ter.js → projectMeta-D3GYq5jV.js} +1 -1
- package/dist/assets/{queue-abort-optimistic-CJmevpBJ.js → queue-abort-optimistic-DRJa-BrH.js} +1 -1
- package/dist/assets/{readiness-CdCOcZnK.js → readiness-lO-fOlzd.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-wFpIvOFT.js → renderElectronMiniChatApp-DnzgZv3d.js} +2 -2
- package/dist/assets/{renderMobileApp-QJ2XwXGj.js → renderMobileApp-DLFGqfxp.js} +4 -4
- package/dist/assets/{runtimeConfig-IuT6iZ4x.js → runtimeConfig-Be6cMHuS.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-DEWSVYyD.js → runtimeEndpointReset-DeWcqIyJ.js} +3 -3
- package/dist/assets/{sessionLookup-mvlGQJTe.js → sessionLookup-qvz-n65R.js} +1 -1
- package/dist/assets/{speechSettingsQueries-DEGyglgn.js → speechSettingsQueries-CsCKPsRU.js} +1 -1
- package/dist/assets/{types-COEinOJU.js → types-CTkS0uZU.js} +1 -1
- package/dist/assets/{useAppFontEffects-C__cAJlw.js → useAppFontEffects-Cs_0mUpl.js} +5 -5
- package/dist/assets/{useDesktopWindowControlsLayout-BYt7I5so.js → useDesktopWindowControlsLayout-avf-_JWZ.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-CcDsvhjq.js → useEffectiveDirectory-esZ8PL08.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-BgM0EvUr.js → useMobileNavigationStore-9lAGHZos.js} +4 -4
- package/dist/assets/{useWorkerHighlightedLines-ZOArIAed.js → useWorkerHighlightedLines-BxqdOw1S.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n}from"./runtime-switch-DEZ1K7qW.js";import{w as r}from"./desktop-JwYqThiw.js";import{a as i,i as a,r as o}from"./vendor-zustand-vDaAPGfl.js";import{J as s,Y as c,ot as l,st as u}from"./vendor-base-ui-CzHs0bHY.js";import{bt as d,kt as f}from"./gitApiHttp-DGAlAuET.js";import{r as p,x as m}from"./useUIStore-BDZCXouA.js";import{D as h,O as g}from"./persistence-Dta0OwIa.js";import{n as _}from"./vendor-react-DlzBev0S.js";import{i as v}from"./vendor-reactuses-core-DWo5Wn6R.js";import{f as y,r as b,u as x}from"./button-BF2cNEuq.js";import{Jn as S,Jr as C,St as w,V as ee,Vr as te,Yi as ne,Yn as re,da as T,fa as E,ft as D,p as O,w as k,wi as A,x as j,zi as ie}from"./useMobileNavigationStore-BgM0EvUr.js";import{a as ae,g as M,o as oe,p as N,s as P}from"./fileMentionAutocompleteState-BZJqfgae.js";import{t as se}from"./AgentAvatar-GVufO03R.js";import{n as F}from"./Icon-CLLDJn-P.js";import{g as I,v as ce}from"./gitApi-b2Mo4rXl.js";import{c as le,d as ue,l as de,n as fe,r as pe,t as me}from"./fileMentionTouchSelection-dpFpcetU.js";import{f as he,o as ge}from"./projectMeta-KTYl7ter.js";import{n as _e}from"./textarea-CIhiRPB2.js";var L=_(),R=e(u(),1),z=l(),ve=R.memo(function(e){let t=(0,L.c)(20),{checked:n,onChange:r,disabled:i,indeterminate:a,ariaLabel:o,className:l,iconClassName:u}=e,d=i!==void 0&&i,f=n||a,p;t[0]===r?p=t[1]:(p=e=>r(!!e),t[0]=r,t[1]=p);let m=f?`border-[color:color-mix(in_srgb,var(--primary-base)_65%,var(--interactive-border))] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[color:color-mix(in_srgb,var(--primary-base)_75%,var(--interactive-border))]`:`border-[var(--interactive-border)] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[var(--interactive-border)]`,h;t[2]!==l||t[3]!==m?(h=b(`group/checkbox relative flex shrink-0 self-center items-center justify-center rounded-[4px] border outline-none`,`h-[14px] w-[14px] min-h-[14px] min-w-[14px]`,`transition-[background-color,border-color,box-shadow] duration-200 ease-out`,m,`focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-transparent`,`disabled:cursor-not-allowed disabled:opacity-50`,l),t[2]=l,t[3]=m,t[4]=h):h=t[4];let g;t[5]===u?g=t[6]:(g=b(`flex items-center justify-center text-[var(--primary-base)]`,`data-[unchecked]:hidden`,u),t[5]=u,t[6]=g);let _;t[7]===a?_=t[8]:(_=a?(0,z.jsx)(F,{name:`subtract`,className:b(`h-[10px] w-[10px] min-h-[10px] min-w-[10px]`,`text-[var(--primary-base)]`)}):(0,z.jsx)(F,{name:`check`,className:b(`h-[10px] w-[10px] min-h-[10px] min-w-[10px]`,`text-[var(--primary-base)]`)}),t[7]=a,t[8]=_);let v;t[9]!==g||t[10]!==_?(v=(0,z.jsx)(s,{keepMounted:!0,className:g,children:_}),t[9]=g,t[10]=_,t[11]=v):v=t[11];let y;return t[12]!==o||t[13]!==n||t[14]!==d||t[15]!==a||t[16]!==p||t[17]!==h||t[18]!==v?(y=(0,z.jsx)(c,{checked:n,onCheckedChange:p,disabled:d,indeterminate:a,"aria-label":o,className:h,children:v}),t[12]=o,t[13]=n,t[14]=d,t[15]=a,t[16]=p,t[17]=h,t[18]=v,t[19]=y):y=t[19],y}),B=(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=M([...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)},ye=(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&&e.agentName===r.agentName}),be=(e,t)=>e.highlightedIndex===t.highlightedIndex&&ye(e.rows,t.rows),xe=(e,t)=>ye(e,t)?e:t.slice(),Se=(e,t,n)=>{e&&(t.current&&be(t.current,n)||(t.current=n,e(n)))},Ce=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},V=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},H=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,U=(e,t)=>{let n=V(t),r=V(e);if(!n||!r)return!1;let i=H(n),a=H(r);return a===i||a.startsWith(`${i}/`)},we=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=V(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=>V(e)).filter(e=>U(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>V(e)).filter(e=>U(e,t)))):[],s=typeof i.selectedPath==`string`?V(i.selectedPath):null,c=s&&U(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},W=(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},G=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Te=i()(o(a((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=V((t||``).trim()),a=V((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!U(a,i)||e(e=>{let t=e.byRoot[i],n=G(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:W({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=V((t||``).trim()),i=V((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=H(i),a=e=>H(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:W({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=V((t||``).trim()),i=V((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=H(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=H(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:W({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=V((t||``).trim()),i=V((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=H(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=H(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:W({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=V((t||``).trim()),a=n?V(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!U(a,i)||e(e=>{let t=e.byRoot[i],n=G(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:W({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=V((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=V((t||``).trim()),i=V((n||``).trim());!r||!i||!U(i,r)||e(e=>{let t=e.byRoot[r],n=G(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:W({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=V((t||``).trim()),i=V((n||``).trim());!r||!i||!U(i,r)||e(e=>{let t=e.byRoot[r],n=G(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:W({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=V((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>V((e||``).trim())).filter(e=>e&&U(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=G(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:W({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:m(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:we(t)}},partialize:e=>({byRoot:we(e.byRoot)})}),{name:`files-view-tabs-store`})),Ee=(e,t)=>{let n=(0,L.c)(4),r=t===void 0?200:t,[i,a]=R.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]),R.useEffect(o,s),i},De=()=>{let e=(0,L.c)(17),t=O(Oe),n=w(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=k(r),a=O(ke),o=O(Ae),s=E(K),c=E(q),l=d(J);if(t){let r;e[2]===i?r=e[3]:(r=j(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 Oe(e){return e.currentSessionId}function ke(e){return e.worktreeMetadata}function Ae(e){return e.newSessionDraft}function K(e){return e.activeProjectId}function q(e){return e.projects}function J(e){return e.currentDirectory}var je=`bg-transparent font-[inherit] text-[var(--primary-base)]`,Me=(e,t)=>{let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase();if(!r.includes(n))return e;let i=[],a=0,o=r.indexOf(n);for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push((0,z.jsx)(`mark`,{className:je,children:e.slice(o,o+n.length)},`${o}-${n}`)),a=o+n.length,o=r.indexOf(n,a);return a<e.length&&i.push(e.slice(a)),i},Ne=R.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:r,onSessionSelect:i,onClose:a,style:o,onRowsChange:s},c)=>{let{t:l}=y(),u=De()??``,d=O(e=>e.currentSessionId),m=C(e=>e.activeSessions),_=ee({enabled:!!i}),S=E(e=>e.activeProjectId),w=E(e=>e.projects),re=R.useMemo(()=>w.find(e=>e.id===S)?.path??null,[S,w]),T=R.useMemo(()=>{let e=re||u;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[re,u]),D=Te(e=>T?e.byRoot[T]:void 0),k=A(e=>e.agents),j=f(e=>e.searchFiles),M=Ee(e,180),I=g(),ce=h(),[ue,de]=R.useState([]),[he,ge]=R.useState(!1),[L,ve]=R.useState(0),B=R.useRef(0),ye=R.useRef({query:e,directory:u,ids:[]}),[be,xe]=R.useState(360),[V,H]=R.useState({}),[U,we]=R.useState({}),W=R.useRef([]),G=R.useRef([]),Oe=R.useRef([]),ke=R.useRef(null),Ae=R.useRef(null),K=R.useRef(null);K.current||=me();let q=p(e=>e.isMobile),J=(e??``).trim(),je=ne({directory:u||null}),Ne=R.useMemo(()=>r?je.data??[]:[],[r,je.data]),Pe=R.useMemo(()=>{if(!T||!D)return[];let e=[D.selectedPath,...D.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(`${T}/`)?e.slice(T.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return P(n,J,{limit:6})},[J,T,D]),Y=R.useMemo(()=>n?ie(k).filter(e=>e.mode!==`primary`):[],[k,n]),Fe=R.useMemo(()=>i?ae({sessions:te(m,_),currentSessionId:d,searchQuery:J}):[],[m,d,_,J,i]),Ie=Pe,Le=ue,X=R.useMemo(()=>le({skills:Ne,agents:Y,sessions:Fe,recentFiles:Ie,pathHits:Le,searchQuery:J,untitledSession:l(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:l(`chat.fileMentionAutocomplete.sessionType`),skillBadge:l(`chat.commandAutocomplete.badge.skill`)}),[Ne,Y,Fe,Ie,Le,J,l]);R.useEffect(()=>{let e=e=>{let t=e.target;!t||!ke.current||ke.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),R.useEffect(()=>{if(!u){de([]);return}let e=(M??``).trim(),t=N(e);if(!t){de([]);return}let n=!1;ge(!0);let r={includeHidden:I,respectGitignore:!ce};return Promise.all([j(u,t,80,{...r,type:`file`}),j(u,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(Pe.map(e=>e.path));de(oe({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||de([])}).finally(()=>{n||ge(!1)}),()=>{n=!0}},[u,M,Pe,j,I,ce]),R.useLayoutEffect(()=>{let t=ye.current,n=t.ids[B.current],r=t.query===e&&t.directory===u?Math.max(0,X.findIndex(e=>e.id===n)):0;ye.current={query:e,directory:u,ids:X.map(e=>e.id)},B.current=r,ve(r)},[X,e,u]),R.useEffect(()=>{H({}),we({})},[X]),R.useEffect(()=>{W.current[L]?.scrollIntoView({block:`nearest`})},[L]),R.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};G.current.forEach((n,r)=>{if(!n)return;let i=Oe.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}}),H(e),we(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[X]),R.useEffect(()=>{let e=G.current[L];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&xe(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[L]);let Re=v(e=>{t(e)}),ze=v(e=>{n?.(e)}),Be=v(e=>{i?.(e)}),Ve=v(e=>{r?.(e)}),He=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&K.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&K.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(K.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>K.current?.pointerCancel(),onClick:()=>{K.current?.click(t)},onMouseMove:()=>{B.current=e,ve(e)}}),Ue=e=>{let t=X.length;if(t===0)return;let n=(e%t+t)%t,r=X[n];if(r.agentName!==void 0){ze(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=Ne.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&Ve(e);return}if(r.id.startsWith(`session:`)){let e=Fe.find(e=>r.id===`session:${e.id}`);e&&Be(e);return}let i=r.id.startsWith(`recent:`)?Ie.find(e=>r.id===`recent:${e.path}`):Le.find(e=>r.id===`file:${e.path}`);i&&Re(i)};R.useEffect(()=>{Se(s,Ae,{rows:X,highlightedIndex:L})},[s,L,X]);let We=R.useRef(s);return We.current=s,R.useEffect(()=>()=>{Ce(We.current,Ae)},[]),R.useImperativeHandle(c,()=>({acceptIndex:e=>{Ue(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=X.length;if(t!==0){if(e===`ArrowDown`){B.current=(B.current+1)%t,ve(B.current);return}if(e===`ArrowUp`){B.current=(B.current-1+t)%t,ve(B.current);return}(e===`Enter`||e===`Tab`)&&Ue(B.current)}}})),(0,z.jsxs)(fe,{ref:ke,isMobile:q,className:`max-w-[640px] max-h-64`,style:o,children:[(0,z.jsx)(_e,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,z.jsxs)(`div`,{className:`py-1`,children:[X.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?x(e.title,{maxLength:60}):e.title,i=L===t,a=V[t]??!1,o=U[t]??2.6;return(0,z.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{W.current[t]=e},className:b(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,q&&`min-h-11`,pe(q,i),!q&&i&&`text-interactive-selection-foreground`),...He(t,()=>Ue(t)),children:[(0,z.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,z.jsx)(F,{name:e.iconName,className:`size-3.5 text-current`}):(0,z.jsx)(se,{name:e.agentName,size:20})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,z.jsxs)(`span`,{ref:e=>{G.current[t]=e},className:b(`relative block min-w-0 overflow-hidden`,n&&a&&i&&`file-mention-marquee-container`),style:i?{"--file-mention-marquee-width":`${be}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,z.jsx)(`span`,{ref:e=>{Oe.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,z.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:Me(e.title,J)}):(0,z.jsx)(`span`,{className:`block truncate`,children:Me(r,J)})]}),e.trailingLabel?(0,z.jsx)(`span`,{className:b(`max-w-[40%] shrink-0 truncate text-muted-foreground`,q?`typography-micro`:`typography-meta`),children:e.trailingLabel}):null]}),e.subtitle?(0,z.jsx)(`div`,{className:b(`truncate text-muted-foreground`,q?`typography-micro`:`typography-meta`),children:Me(e.subtitle,J)}):null]})]},e.id)}),he&&Le.length===0?(0,z.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,z.jsx)(F,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!he&&X.length===0&&(0,z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.fileMentionAutocomplete.empty`)})]})}),!q&&(0,z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})}),Pe=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`btw`]),Y=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Pe.has(n))},Fe=(e,t)=>!e||t({name:e}),Ie=` `,Le=(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]===Ie&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},X=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Re=b(X,`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)]`),ze=b(X,`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)]`),Be=b(X,`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)]`),Ve=b(X,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),He=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),Ue=e=>{let t=!!e.sessionID;return{hasSession:t,canStartSessionCommand:t||e.hasNewDraft}},We=R.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:i,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=y(),d=p(e=>e.isMobile),f=O(e=>e.currentSessionId),m=O(e=>!!e.newSessionDraft?.open),h=O(R.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),g=D(f??``,h??void 0),_=R.useMemo(()=>s??{sessionID:f??null,hasMessages:g.length>0,hasNewDraft:m},[s,f,g.length,m]),{hasSession:v,canStartSessionCommand:x}=R.useMemo(()=>Ue(_),[_]),S=_.hasMessages,[C,w]=R.useState([]),[ee,te]=R.useState(!1),ne=T({directory:i}),re=R.useMemo(()=>ne.data??[],[ne.data]),E=ne.isFetching,[k,A]=R.useState(0),j=R.useRef(0),ie=R.useRef(!1),ae=R.useRef([]),M=R.useRef(null),oe=R.useRef(!1),N=R.useRef(null),P=R.useRef(!1),se=R.useRef(null);R.useEffect(()=>{let e=e=>{let t=e.target;!t||!M.current||M.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),R.useEffect(()=>{(async()=>{te(E);try{let t=re.flatMap((e,t)=>e.source===`skill`?[]:[{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,scope:e.scope,reference:e.reference}]),n=[{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...v&&!S?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...v?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...r()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],...v?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...x?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...x?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...x?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...x?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...x?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...x?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[],...t],i=!S,a=B(n.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);w(e=>He(e,a)?e:a)}catch{let t=!S,n=B([{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...v&&!S?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...v?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...r()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],...v?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...x?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...x?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...x?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...x?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...x?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...x?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(o?.(e)??!0)),e);w(e=>He(e,n)?e:n)}finally{te(!1)}})()},[e,S,v,x,re,E,u,o]),R.useEffect(()=>{A(0)},[C]),R.useEffect(()=>{j.current=k},[k]),R.useEffect(()=>{ae.current[k]?.scrollIntoView({block:`nearest`})},[k]),R.useEffect(()=>{Se(c,se,{rows:de(C,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:k})},[C,c,k,u]);let I=R.useRef(c);I.current=c,R.useEffect(()=>()=>{Ce(I.current,se)},[]),R.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=C[e];r&&t(r,Y(r,n))},handleKeyDown:e=>{let r=C.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){ie.current=!0,A(e=>(e+1)%r);return}if(e===`ArrowUp`){ie.current=!0,A(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(j.current%r+r)%r,i=C[n];i&&t(i,Y(i,e===`Enter`))}}}}),[C,n,t]);let ce=e=>{let t=ue(e);switch(e.name){case`new`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,z.jsxs)(fe,{ref:M,isMobile:d,className:`max-w-[450px] max-h-64`,style:a,children:[(0,z.jsx)(_e,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:ee?(0,z.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,z.jsx)(F,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,z.jsxs)(`div`,{children:[C.map((n,r)=>{let i=n.isBuiltIn,a=n.isYuri;return(0,z.jsxs)(`div`,{ref:e=>{ae.current[r]=e},className:b(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,pe(d,r===k),!d&&r===k&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(N.current={x:e.clientX,y:e.clientY},P.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!N.current)return;let t=e.clientX-N.current.x,n=e.clientY-N.current.y;Math.hypot(t,n)>6&&(P.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=P.current;N.current=null,P.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),oe.current=!0,t(n,Y(n,d)))},onPointerCancel:()=>{N.current=null,P.current=!1},onClick:()=>{if(oe.current){oe.current=!1;return}t(n,Y(n,d))},onMouseMove:()=>{ie.current=!1,A(r)},children:[(0,z.jsx)(`div`,{className:b(!d&&`mt-0.5`),children:ce(n)}),(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:[`/`,Me(n.name,e)]}),n.isSkill?(0,z.jsx)(`span`,{className:Re,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,z.jsx)(`span`,{className:Re,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,z.jsx)(`span`,{className:Ve,children:`Yuri`}):i?(0,z.jsx)(`span`,{className:Ve,children:u(`chat.commandAutocomplete.badge.system`)}):n.scope?(0,z.jsx)(`span`,{className:n.scope===`project`?Be:ze,children:n.scope}):null,n.agent&&(0,z.jsx)(`span`,{className:Ve,children:n.agent})]}),n.description&&!d&&(0,z.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Me(n.description,e)})]})]},n.id)}),C.length===0&&(0,z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});We.displayName=`CommandAutocomplete`;var Ge=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,Ke=1e4,qe=6e4,Je=5e3,Ye=3e4,Xe=6e4,Ze=25,Qe=40,$e=2,et=15e3,tt=500,nt=30,rt=20971520,it=new Map,at=new Map,ot=new Map,st=new Map,ct=new Map,lt=new Map,ut=new WeakMap,dt=e=>{let t=ut.get(e);return t||(t=new Set(e.files.map(e=>e.path)),ut.set(e,t)),t},ft=(e,t)=>`${t}:${e}`,pt=e=>at.get(e)??0,mt=e=>{let t=pt(e)+1;return at.set(e,t),t},ht=e=>{let t=(ot.get(e)??0)+1;return ot.set(e,t),t},gt=e=>{let t=it.get(e);if(t)return t;let n=new Set;return it.set(e,n),n},Z=()=>({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}),_t=(e,t=nt,n=rt)=>{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},vt=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,yt=e=>{let t=e?.trim()??``;return t===`?`?``:t},bt=(e,t)=>{let n=new Set,r=!1,i=!e;e&&(i=e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&vt(e.upstreamComparison,t.upstreamComparison)||t.diffStats!==void 0&&e.diffStats===void 0);let a=new Map;for(let t of e?.files??[])a.set(t.path,t);for(let e of t.files??[]){let t=a.get(e.path);if(!t){n.add(e.path),yt(e.index)&&(r=!0);continue}a.delete(e.path),(t.index!==e.index||t.working_dir!==e.working_dir)&&n.add(e.path),!r&&yt(t.index)!==yt(e.index)&&(r=!0)}for(let[e,t]of a)n.add(e),yt(t.index)&&(r=!0);let o=t.diffStats,s=e?.diffStats;if(o!==void 0&&o!==s){let e=s??{};for(let t in o){let r=o[t],i=e[t];(!i||i.insertions!==r.insertions||i.deletions!==r.deletions)&&n.add(t)}for(let t in e)t in o||n.add(t)}return{changed:i||n.size>0,changedPaths:n,indexChanged:r}},xt=e=>!e||e.trim().length===0,St=e=>(e||``).trim()===`U`,Ct=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(St(t)||St(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},wt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(St(t)||St(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Tt=e=>xt(e.index)&&xt(e.working_dir),Q=i()(o((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&mt(r),n&&mt(n),n&&!i.has(n)){let t=new Map(i);t.set(n,Z()),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=ft(n,a),s=st.get(o)??(a===`light`?st.get(ft(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||=Z(),!a){let r=new Map(t().directories),i=r.get(n)??Z();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)>qe,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),d=t().directories.get(n)??Z(),f=lt.get(n),p=f?.received===u&&f.stored===d.status?null:bt(d.status,u);if(p?.changed){c=!0;let r=new Map(t().directories),i=r.get(n)??Z(),{changedPaths:s,indexChanged:l}=p,d=new Map(i.diffCache);for(let e of s)d.delete(e);let f=s.size>0;f&&mt(n);let m={...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:m,diffCache:d,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:f?Date.now():i.lastStatusChange}),e({directories:r}),lt.set(n,{received:u,stored:m})}else{lt.set(n,{received:u,stored:d.status});let r=new Map(t().directories),i=r.get(n)??Z();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)??Z();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();st.set(o,c);try{return await c}finally{st.get(o)===c&&st.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`?Ct(e):wt(e);t!==e&&(l=!0),Tt(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=ht(r);{let n=new Map(t().directories),i=n.get(r)??Z();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await re(r,i,void 0,o):await S(r,i,void 0,o);if(s!==ot.get(r)||o!==n())return;let l=new Map(t().directories),u=l.get(r)??Z();l.set(r,{...u,branches:c,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:l})}catch(i){if(Ge(i)||console.error(`Failed to fetch git branches:`,i),s!==ot.get(r)||o!==n())return;let a=new Map(t().directories),c=a.get(r)??Z();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)??Z();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)??Z();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)??Z();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??Z();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)??Z();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)??Z();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=Z();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>Ke||!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)??Z(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=_t(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{mt(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,Ze);await t().prefetchDiffs(e,n,i,{maxFiles:Ze})},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=Qe}=a,c=Math.min(Math.max(1,s),nt),l=dt(o.status),u=o.status.diffStats,d=gt(n),f=[],p=new Set;for(let e of i){if(p.size>=c)break;if(!e||p.has(e)||!l.has(e))continue;let t=u?.[e];t&&t.insertions+t.deletions>tt||(p.add(e),!o.diffCache.has(e)&&(d.has(e)||f.push(e)))}let m=f;if(m.length===0)return;let h=pt(n);if(typeof document<`u`&&document.hidden)return;m.forEach(e=>d.add(e));let g=0,_=[],v=()=>{let e=g;return g+=1,e<m.length?m[e]:null},y=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${et}ms`)),et)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},b=async()=>{for(;;){if(h!==pt(n))return;let e=v();if(!e)return;try{_.push(await y(e))}catch{}finally{d.delete(e)}}},x=Math.min($e,m.length);if(await Promise.allSettled(Array.from({length:x},()=>b())),m.forEach(e=>d.delete(e)),h!==pt(n))return;let S=new Map(t().directories),C=S.get(n);if(!C)return;let w=new Map(C.diffCache),ee=Date.now();_.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||w.set(e.path,{...e.diff,fetchedAt:ee})});let te=_t(w);S.set(n,{...C,diffCache:te}),e({directories:S})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Z();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<Je||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=ct.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)>=Je)&&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>=Ye)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=Ke)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=Xe)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return ct.set(e,i),i.finally(()=>{ct.get(e)===i&&ct.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Et=e=>{let t=(0,L.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),Q(n)},Dt=e=>{let r=(0,L.c)(3),i=R.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],Q(a)},Ot=e=>{let t=(0,L.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),Q(n)},kt=e=>{let t=(0,L.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),Q(n)},At=e=>{let t=(0,L.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),Q(n)},jt=e=>{let t=(0,L.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=R.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),Q(i)},Mt=e=>{let t=(0,L.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),Q(n)},Nt=e=>{let t=(0,L.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),Q(n)},Pt=e=>{let t=(0,L.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),Q(n)},Ft=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)}},$=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),It=e=>e.branchName?$(e.branchName):e.mode===`existing`?$(e.existingBranch||e.preferredName||``):$(e.preferredName||``),Lt=async e=>{let t=await he(e);try{let n=Ft((await I(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=Ft((await ce(e)).tracking);if(t?.remote)return t.remote}catch{}return null},Rt=async(e,t)=>{let n=await Lt(e),r=$(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},zt=async(e,t,n)=>{let r=It(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await Rt(e,r):i&&$(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:$(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},Bt=async(e,t,n)=>{let r=await zt(e.path,t,n);return ge(e,r)},Vt=`yuri:lastWorktreeSourceBranch`,Ht=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,Ut=({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},Wt=(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?` `:``}`},Gt=(e,t,n)=>{let r=Wt(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},Kt=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=Gt(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}},qt=(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.some(e=>e.range.start<t.range.end&&t.range.start<e.range.end)?[...e]:[...e,t]},Jt=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{Fe as C,Te as D,Ee as E,xe as O,Le as S,De as T,jt as _,Vt as a,kt as b,Bt as c,At as d,Dt as f,Ot as g,Mt as h,Gt as i,ve as k,Lt as l,Nt as m,qt as n,Ut as o,Pt as p,Kt as r,Ht as s,Jt as t,zt as u,Et as v,Ne as w,We as x,Q as y};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n}from"./runtime-switch-DEZ1K7qW.js";import{w as r}from"./desktop-JwYqThiw.js";import{a as i,i as a,r as o}from"./vendor-zustand-vDaAPGfl.js";import{J as s,Y as c,ot as l,st as u}from"./vendor-base-ui-CzHs0bHY.js";import{bt as d,kt as f}from"./gitApiHttp-DGAlAuET.js";import{r as p,x as m}from"./useUIStore-BDZCXouA.js";import{D as h,O as g}from"./persistence-Dta0OwIa.js";import{n as _}from"./vendor-react-DlzBev0S.js";import{i as v}from"./vendor-reactuses-core-DWo5Wn6R.js";import{f as y,r as b,u as x}from"./button-BF2cNEuq.js";import{Jn as S,Jr as C,St as w,V as ee,Vr as te,Yi as ne,Yn as re,da as T,fa as E,ft as D,p as O,w as k,wi as A,x as j,zi as ie}from"./useMobileNavigationStore-9lAGHZos.js";import{a as ae,g as M,o as oe,p as N,s as P}from"./fileMentionAutocompleteState-BZJqfgae.js";import{t as se}from"./AgentAvatar-GVufO03R.js";import{n as F}from"./Icon-CLLDJn-P.js";import{g as I,v as ce}from"./gitApi-CXkfrI_H.js";import{c as le,d as ue,l as de,n as fe,r as pe,t as me}from"./fileMentionTouchSelection-dpFpcetU.js";import{f as he,o as ge}from"./projectMeta-D3GYq5jV.js";import{n as _e}from"./textarea-CIhiRPB2.js";var L=_(),R=e(u(),1),z=l(),ve=R.memo(function(e){let t=(0,L.c)(20),{checked:n,onChange:r,disabled:i,indeterminate:a,ariaLabel:o,className:l,iconClassName:u}=e,d=i!==void 0&&i,f=n||a,p;t[0]===r?p=t[1]:(p=e=>r(!!e),t[0]=r,t[1]=p);let m=f?`border-[color:color-mix(in_srgb,var(--primary-base)_65%,var(--interactive-border))] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[color:color-mix(in_srgb,var(--primary-base)_75%,var(--interactive-border))]`:`border-[var(--interactive-border)] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[var(--interactive-border)]`,h;t[2]!==l||t[3]!==m?(h=b(`group/checkbox relative flex shrink-0 self-center items-center justify-center rounded-[4px] border outline-none`,`h-[14px] w-[14px] min-h-[14px] min-w-[14px]`,`transition-[background-color,border-color,box-shadow] duration-200 ease-out`,m,`focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-transparent`,`disabled:cursor-not-allowed disabled:opacity-50`,l),t[2]=l,t[3]=m,t[4]=h):h=t[4];let g;t[5]===u?g=t[6]:(g=b(`flex items-center justify-center text-[var(--primary-base)]`,`data-[unchecked]:hidden`,u),t[5]=u,t[6]=g);let _;t[7]===a?_=t[8]:(_=a?(0,z.jsx)(F,{name:`subtract`,className:b(`h-[10px] w-[10px] min-h-[10px] min-w-[10px]`,`text-[var(--primary-base)]`)}):(0,z.jsx)(F,{name:`check`,className:b(`h-[10px] w-[10px] min-h-[10px] min-w-[10px]`,`text-[var(--primary-base)]`)}),t[7]=a,t[8]=_);let v;t[9]!==g||t[10]!==_?(v=(0,z.jsx)(s,{keepMounted:!0,className:g,children:_}),t[9]=g,t[10]=_,t[11]=v):v=t[11];let y;return t[12]!==o||t[13]!==n||t[14]!==d||t[15]!==a||t[16]!==p||t[17]!==h||t[18]!==v?(y=(0,z.jsx)(c,{checked:n,onCheckedChange:p,disabled:d,indeterminate:a,"aria-label":o,className:h,children:v}),t[12]=o,t[13]=n,t[14]=d,t[15]=a,t[16]=p,t[17]=h,t[18]=v,t[19]=y):y=t[19],y}),B=(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=M([...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)},ye=(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&&e.agentName===r.agentName}),be=(e,t)=>e.highlightedIndex===t.highlightedIndex&&ye(e.rows,t.rows),xe=(e,t)=>ye(e,t)?e:t.slice(),Se=(e,t,n)=>{e&&(t.current&&be(t.current,n)||(t.current=n,e(n)))},Ce=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},V=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},H=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,U=(e,t)=>{let n=V(t),r=V(e);if(!n||!r)return!1;let i=H(n),a=H(r);return a===i||a.startsWith(`${i}/`)},we=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=V(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=>V(e)).filter(e=>U(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>V(e)).filter(e=>U(e,t)))):[],s=typeof i.selectedPath==`string`?V(i.selectedPath):null,c=s&&U(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},W=(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},G=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Te=i()(o(a((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=V((t||``).trim()),a=V((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!U(a,i)||e(e=>{let t=e.byRoot[i],n=G(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:W({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=V((t||``).trim()),i=V((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=H(i),a=e=>H(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:W({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=V((t||``).trim()),i=V((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=H(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=H(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:W({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=V((t||``).trim()),i=V((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=H(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=H(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:W({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=V((t||``).trim()),a=n?V(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!U(a,i)||e(e=>{let t=e.byRoot[i],n=G(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:W({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=V((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=V((t||``).trim()),i=V((n||``).trim());!r||!i||!U(i,r)||e(e=>{let t=e.byRoot[r],n=G(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:W({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=V((t||``).trim()),i=V((n||``).trim());!r||!i||!U(i,r)||e(e=>{let t=e.byRoot[r],n=G(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:W({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=V((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>V((e||``).trim())).filter(e=>e&&U(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=G(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:W({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:m(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:we(t)}},partialize:e=>({byRoot:we(e.byRoot)})}),{name:`files-view-tabs-store`})),Ee=(e,t)=>{let n=(0,L.c)(4),r=t===void 0?200:t,[i,a]=R.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]),R.useEffect(o,s),i},De=()=>{let e=(0,L.c)(17),t=O(Oe),n=w(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=k(r),a=O(ke),o=O(Ae),s=E(K),c=E(q),l=d(J);if(t){let r;e[2]===i?r=e[3]:(r=j(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 Oe(e){return e.currentSessionId}function ke(e){return e.worktreeMetadata}function Ae(e){return e.newSessionDraft}function K(e){return e.activeProjectId}function q(e){return e.projects}function J(e){return e.currentDirectory}var je=`bg-transparent font-[inherit] text-[var(--primary-base)]`,Me=(e,t)=>{let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase();if(!r.includes(n))return e;let i=[],a=0,o=r.indexOf(n);for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push((0,z.jsx)(`mark`,{className:je,children:e.slice(o,o+n.length)},`${o}-${n}`)),a=o+n.length,o=r.indexOf(n,a);return a<e.length&&i.push(e.slice(a)),i},Ne=R.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:r,onSessionSelect:i,onClose:a,style:o,onRowsChange:s},c)=>{let{t:l}=y(),u=De()??``,d=O(e=>e.currentSessionId),m=C(e=>e.activeSessions),_=ee({enabled:!!i}),S=E(e=>e.activeProjectId),w=E(e=>e.projects),re=R.useMemo(()=>w.find(e=>e.id===S)?.path??null,[S,w]),T=R.useMemo(()=>{let e=re||u;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[re,u]),D=Te(e=>T?e.byRoot[T]:void 0),k=A(e=>e.agents),j=f(e=>e.searchFiles),M=Ee(e,180),I=g(),ce=h(),[ue,de]=R.useState([]),[he,ge]=R.useState(!1),[L,ve]=R.useState(0),B=R.useRef(0),ye=R.useRef({query:e,directory:u,ids:[]}),[be,xe]=R.useState(360),[V,H]=R.useState({}),[U,we]=R.useState({}),W=R.useRef([]),G=R.useRef([]),Oe=R.useRef([]),ke=R.useRef(null),Ae=R.useRef(null),K=R.useRef(null);K.current||=me();let q=p(e=>e.isMobile),J=(e??``).trim(),je=ne({directory:u||null}),Ne=R.useMemo(()=>r?je.data??[]:[],[r,je.data]),Pe=R.useMemo(()=>{if(!T||!D)return[];let e=[D.selectedPath,...D.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(`${T}/`)?e.slice(T.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return P(n,J,{limit:6})},[J,T,D]),Y=R.useMemo(()=>n?ie(k).filter(e=>e.mode!==`primary`):[],[k,n]),Fe=R.useMemo(()=>i?ae({sessions:te(m,_),currentSessionId:d,searchQuery:J}):[],[m,d,_,J,i]),Ie=Pe,Le=ue,X=R.useMemo(()=>le({skills:Ne,agents:Y,sessions:Fe,recentFiles:Ie,pathHits:Le,searchQuery:J,untitledSession:l(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:l(`chat.fileMentionAutocomplete.sessionType`),skillBadge:l(`chat.commandAutocomplete.badge.skill`)}),[Ne,Y,Fe,Ie,Le,J,l]);R.useEffect(()=>{let e=e=>{let t=e.target;!t||!ke.current||ke.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),R.useEffect(()=>{if(!u){de([]);return}let e=(M??``).trim(),t=N(e);if(!t){de([]);return}let n=!1;ge(!0);let r={includeHidden:I,respectGitignore:!ce};return Promise.all([j(u,t,80,{...r,type:`file`}),j(u,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(Pe.map(e=>e.path));de(oe({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||de([])}).finally(()=>{n||ge(!1)}),()=>{n=!0}},[u,M,Pe,j,I,ce]),R.useLayoutEffect(()=>{let t=ye.current,n=t.ids[B.current],r=t.query===e&&t.directory===u?Math.max(0,X.findIndex(e=>e.id===n)):0;ye.current={query:e,directory:u,ids:X.map(e=>e.id)},B.current=r,ve(r)},[X,e,u]),R.useEffect(()=>{H({}),we({})},[X]),R.useEffect(()=>{W.current[L]?.scrollIntoView({block:`nearest`})},[L]),R.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};G.current.forEach((n,r)=>{if(!n)return;let i=Oe.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}}),H(e),we(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[X]),R.useEffect(()=>{let e=G.current[L];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&xe(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[L]);let Re=v(e=>{t(e)}),ze=v(e=>{n?.(e)}),Be=v(e=>{i?.(e)}),Ve=v(e=>{r?.(e)}),He=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&K.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&K.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(K.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>K.current?.pointerCancel(),onClick:()=>{K.current?.click(t)},onMouseMove:()=>{B.current=e,ve(e)}}),Ue=e=>{let t=X.length;if(t===0)return;let n=(e%t+t)%t,r=X[n];if(r.agentName!==void 0){ze(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=Ne.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&Ve(e);return}if(r.id.startsWith(`session:`)){let e=Fe.find(e=>r.id===`session:${e.id}`);e&&Be(e);return}let i=r.id.startsWith(`recent:`)?Ie.find(e=>r.id===`recent:${e.path}`):Le.find(e=>r.id===`file:${e.path}`);i&&Re(i)};R.useEffect(()=>{Se(s,Ae,{rows:X,highlightedIndex:L})},[s,L,X]);let We=R.useRef(s);return We.current=s,R.useEffect(()=>()=>{Ce(We.current,Ae)},[]),R.useImperativeHandle(c,()=>({acceptIndex:e=>{Ue(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=X.length;if(t!==0){if(e===`ArrowDown`){B.current=(B.current+1)%t,ve(B.current);return}if(e===`ArrowUp`){B.current=(B.current-1+t)%t,ve(B.current);return}(e===`Enter`||e===`Tab`)&&Ue(B.current)}}})),(0,z.jsxs)(fe,{ref:ke,isMobile:q,className:`max-w-[640px] max-h-64`,style:o,children:[(0,z.jsx)(_e,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,z.jsxs)(`div`,{className:`py-1`,children:[X.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?x(e.title,{maxLength:60}):e.title,i=L===t,a=V[t]??!1,o=U[t]??2.6;return(0,z.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{W.current[t]=e},className:b(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,q&&`min-h-11`,pe(q,i),!q&&i&&`text-interactive-selection-foreground`),...He(t,()=>Ue(t)),children:[(0,z.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,z.jsx)(F,{name:e.iconName,className:`size-3.5 text-current`}):(0,z.jsx)(se,{name:e.agentName,size:20})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,z.jsxs)(`span`,{ref:e=>{G.current[t]=e},className:b(`relative block min-w-0 overflow-hidden`,n&&a&&i&&`file-mention-marquee-container`),style:i?{"--file-mention-marquee-width":`${be}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,z.jsx)(`span`,{ref:e=>{Oe.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,z.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:Me(e.title,J)}):(0,z.jsx)(`span`,{className:`block truncate`,children:Me(r,J)})]}),e.trailingLabel?(0,z.jsx)(`span`,{className:b(`max-w-[40%] shrink-0 truncate text-muted-foreground`,q?`typography-micro`:`typography-meta`),children:e.trailingLabel}):null]}),e.subtitle?(0,z.jsx)(`div`,{className:b(`truncate text-muted-foreground`,q?`typography-micro`:`typography-meta`),children:Me(e.subtitle,J)}):null]})]},e.id)}),he&&Le.length===0?(0,z.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,z.jsx)(F,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!he&&X.length===0&&(0,z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.fileMentionAutocomplete.empty`)})]})}),!q&&(0,z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})}),Pe=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`btw`]),Y=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Pe.has(n))},Fe=(e,t)=>!e||t({name:e}),Ie=` `,Le=(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]===Ie&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},X=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Re=b(X,`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)]`),ze=b(X,`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)]`),Be=b(X,`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)]`),Ve=b(X,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),He=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),Ue=e=>{let t=!!e.sessionID;return{hasSession:t,canStartSessionCommand:t||e.hasNewDraft}},We=R.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:i,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=y(),d=p(e=>e.isMobile),f=O(e=>e.currentSessionId),m=O(e=>!!e.newSessionDraft?.open),h=O(R.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),g=D(f??``,h??void 0),_=R.useMemo(()=>s??{sessionID:f??null,hasMessages:g.length>0,hasNewDraft:m},[s,f,g.length,m]),{hasSession:v,canStartSessionCommand:x}=R.useMemo(()=>Ue(_),[_]),S=_.hasMessages,[C,w]=R.useState([]),[ee,te]=R.useState(!1),ne=T({directory:i}),re=R.useMemo(()=>ne.data??[],[ne.data]),E=ne.isFetching,[k,A]=R.useState(0),j=R.useRef(0),ie=R.useRef(!1),ae=R.useRef([]),M=R.useRef(null),oe=R.useRef(!1),N=R.useRef(null),P=R.useRef(!1),se=R.useRef(null);R.useEffect(()=>{let e=e=>{let t=e.target;!t||!M.current||M.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),R.useEffect(()=>{(async()=>{te(E);try{let t=re.flatMap((e,t)=>e.source===`skill`?[]:[{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,scope:e.scope,reference:e.reference}]),n=[{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...v&&!S?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...v?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...r()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],...v?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...x?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...x?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...x?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...x?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...x?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...x?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[],...t],i=!S,a=B(n.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);w(e=>He(e,a)?e:a)}catch{let t=!S,n=B([{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...v&&!S?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...v?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...r()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],...v?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...x?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...x?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...x?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...x?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...x?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...x?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(o?.(e)??!0)),e);w(e=>He(e,n)?e:n)}finally{te(!1)}})()},[e,S,v,x,re,E,u,o]),R.useEffect(()=>{A(0)},[C]),R.useEffect(()=>{j.current=k},[k]),R.useEffect(()=>{ae.current[k]?.scrollIntoView({block:`nearest`})},[k]),R.useEffect(()=>{Se(c,se,{rows:de(C,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:k})},[C,c,k,u]);let I=R.useRef(c);I.current=c,R.useEffect(()=>()=>{Ce(I.current,se)},[]),R.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=C[e];r&&t(r,Y(r,n))},handleKeyDown:e=>{let r=C.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){ie.current=!0,A(e=>(e+1)%r);return}if(e===`ArrowUp`){ie.current=!0,A(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(j.current%r+r)%r,i=C[n];i&&t(i,Y(i,e===`Enter`))}}}}),[C,n,t]);let ce=e=>{let t=ue(e);switch(e.name){case`new`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,z.jsxs)(fe,{ref:M,isMobile:d,className:`max-w-[450px] max-h-64`,style:a,children:[(0,z.jsx)(_e,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:ee?(0,z.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,z.jsx)(F,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,z.jsxs)(`div`,{children:[C.map((n,r)=>{let i=n.isBuiltIn,a=n.isYuri;return(0,z.jsxs)(`div`,{ref:e=>{ae.current[r]=e},className:b(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,pe(d,r===k),!d&&r===k&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(N.current={x:e.clientX,y:e.clientY},P.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!N.current)return;let t=e.clientX-N.current.x,n=e.clientY-N.current.y;Math.hypot(t,n)>6&&(P.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=P.current;N.current=null,P.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),oe.current=!0,t(n,Y(n,d)))},onPointerCancel:()=>{N.current=null,P.current=!1},onClick:()=>{if(oe.current){oe.current=!1;return}t(n,Y(n,d))},onMouseMove:()=>{ie.current=!1,A(r)},children:[(0,z.jsx)(`div`,{className:b(!d&&`mt-0.5`),children:ce(n)}),(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:[`/`,Me(n.name,e)]}),n.isSkill?(0,z.jsx)(`span`,{className:Re,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,z.jsx)(`span`,{className:Re,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,z.jsx)(`span`,{className:Ve,children:`Yuri`}):i?(0,z.jsx)(`span`,{className:Ve,children:u(`chat.commandAutocomplete.badge.system`)}):n.scope?(0,z.jsx)(`span`,{className:n.scope===`project`?Be:ze,children:n.scope}):null,n.agent&&(0,z.jsx)(`span`,{className:Ve,children:n.agent})]}),n.description&&!d&&(0,z.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Me(n.description,e)})]})]},n.id)}),C.length===0&&(0,z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});We.displayName=`CommandAutocomplete`;var Ge=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,Ke=1e4,qe=6e4,Je=5e3,Ye=3e4,Xe=6e4,Ze=25,Qe=40,$e=2,et=15e3,tt=500,nt=30,rt=20971520,it=new Map,at=new Map,ot=new Map,st=new Map,ct=new Map,lt=new Map,ut=new WeakMap,dt=e=>{let t=ut.get(e);return t||(t=new Set(e.files.map(e=>e.path)),ut.set(e,t)),t},ft=(e,t)=>`${t}:${e}`,pt=e=>at.get(e)??0,mt=e=>{let t=pt(e)+1;return at.set(e,t),t},ht=e=>{let t=(ot.get(e)??0)+1;return ot.set(e,t),t},gt=e=>{let t=it.get(e);if(t)return t;let n=new Set;return it.set(e,n),n},Z=()=>({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}),_t=(e,t=nt,n=rt)=>{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},vt=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,yt=e=>{let t=e?.trim()??``;return t===`?`?``:t},bt=(e,t)=>{let n=new Set,r=!1,i=!e;e&&(i=e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&vt(e.upstreamComparison,t.upstreamComparison)||t.diffStats!==void 0&&e.diffStats===void 0);let a=new Map;for(let t of e?.files??[])a.set(t.path,t);for(let e of t.files??[]){let t=a.get(e.path);if(!t){n.add(e.path),yt(e.index)&&(r=!0);continue}a.delete(e.path),(t.index!==e.index||t.working_dir!==e.working_dir)&&n.add(e.path),!r&&yt(t.index)!==yt(e.index)&&(r=!0)}for(let[e,t]of a)n.add(e),yt(t.index)&&(r=!0);let o=t.diffStats,s=e?.diffStats;if(o!==void 0&&o!==s){let e=s??{};for(let t in o){let r=o[t],i=e[t];(!i||i.insertions!==r.insertions||i.deletions!==r.deletions)&&n.add(t)}for(let t in e)t in o||n.add(t)}return{changed:i||n.size>0,changedPaths:n,indexChanged:r}},xt=e=>!e||e.trim().length===0,St=e=>(e||``).trim()===`U`,Ct=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(St(t)||St(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},wt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(St(t)||St(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Tt=e=>xt(e.index)&&xt(e.working_dir),Q=i()(o((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&mt(r),n&&mt(n),n&&!i.has(n)){let t=new Map(i);t.set(n,Z()),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=ft(n,a),s=st.get(o)??(a===`light`?st.get(ft(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||=Z(),!a){let r=new Map(t().directories),i=r.get(n)??Z();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)>qe,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),d=t().directories.get(n)??Z(),f=lt.get(n),p=f?.received===u&&f.stored===d.status?null:bt(d.status,u);if(p?.changed){c=!0;let r=new Map(t().directories),i=r.get(n)??Z(),{changedPaths:s,indexChanged:l}=p,d=new Map(i.diffCache);for(let e of s)d.delete(e);let f=s.size>0;f&&mt(n);let m={...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:m,diffCache:d,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:f?Date.now():i.lastStatusChange}),e({directories:r}),lt.set(n,{received:u,stored:m})}else{lt.set(n,{received:u,stored:d.status});let r=new Map(t().directories),i=r.get(n)??Z();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)??Z();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();st.set(o,c);try{return await c}finally{st.get(o)===c&&st.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`?Ct(e):wt(e);t!==e&&(l=!0),Tt(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=ht(r);{let n=new Map(t().directories),i=n.get(r)??Z();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await re(r,i,void 0,o):await S(r,i,void 0,o);if(s!==ot.get(r)||o!==n())return;let l=new Map(t().directories),u=l.get(r)??Z();l.set(r,{...u,branches:c,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:l})}catch(i){if(Ge(i)||console.error(`Failed to fetch git branches:`,i),s!==ot.get(r)||o!==n())return;let a=new Map(t().directories),c=a.get(r)??Z();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)??Z();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)??Z();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)??Z();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??Z();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)??Z();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)??Z();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=Z();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>Ke||!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)??Z(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=_t(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{mt(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,Ze);await t().prefetchDiffs(e,n,i,{maxFiles:Ze})},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=Qe}=a,c=Math.min(Math.max(1,s),nt),l=dt(o.status),u=o.status.diffStats,d=gt(n),f=[],p=new Set;for(let e of i){if(p.size>=c)break;if(!e||p.has(e)||!l.has(e))continue;let t=u?.[e];t&&t.insertions+t.deletions>tt||(p.add(e),!o.diffCache.has(e)&&(d.has(e)||f.push(e)))}let m=f;if(m.length===0)return;let h=pt(n);if(typeof document<`u`&&document.hidden)return;m.forEach(e=>d.add(e));let g=0,_=[],v=()=>{let e=g;return g+=1,e<m.length?m[e]:null},y=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${et}ms`)),et)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},b=async()=>{for(;;){if(h!==pt(n))return;let e=v();if(!e)return;try{_.push(await y(e))}catch{}finally{d.delete(e)}}},x=Math.min($e,m.length);if(await Promise.allSettled(Array.from({length:x},()=>b())),m.forEach(e=>d.delete(e)),h!==pt(n))return;let S=new Map(t().directories),C=S.get(n);if(!C)return;let w=new Map(C.diffCache),ee=Date.now();_.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||w.set(e.path,{...e.diff,fetchedAt:ee})});let te=_t(w);S.set(n,{...C,diffCache:te}),e({directories:S})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Z();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<Je||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=ct.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)>=Je)&&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>=Ye)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=Ke)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=Xe)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return ct.set(e,i),i.finally(()=>{ct.get(e)===i&&ct.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Et=e=>{let t=(0,L.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),Q(n)},Dt=e=>{let r=(0,L.c)(3),i=R.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],Q(a)},Ot=e=>{let t=(0,L.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),Q(n)},kt=e=>{let t=(0,L.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),Q(n)},At=e=>{let t=(0,L.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),Q(n)},jt=e=>{let t=(0,L.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=R.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),Q(i)},Mt=e=>{let t=(0,L.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),Q(n)},Nt=e=>{let t=(0,L.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),Q(n)},Pt=e=>{let t=(0,L.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),Q(n)},Ft=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)}},$=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),It=e=>e.branchName?$(e.branchName):e.mode===`existing`?$(e.existingBranch||e.preferredName||``):$(e.preferredName||``),Lt=async e=>{let t=await he(e);try{let n=Ft((await I(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=Ft((await ce(e)).tracking);if(t?.remote)return t.remote}catch{}return null},Rt=async(e,t)=>{let n=await Lt(e),r=$(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},zt=async(e,t,n)=>{let r=It(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await Rt(e,r):i&&$(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:$(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},Bt=async(e,t,n)=>{let r=await zt(e.path,t,n);return ge(e,r)},Vt=`yuri:lastWorktreeSourceBranch`,Ht=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,Ut=({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},Wt=(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?` `:``}`},Gt=(e,t,n)=>{let r=Wt(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},Kt=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=Gt(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}},qt=(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.some(e=>e.range.start<t.range.end&&t.range.start<e.range.end)?[...e]:[...e,t]},Jt=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{Fe as C,Te as D,Ee as E,xe as O,Le as S,De as T,jt as _,Vt as a,kt as b,Bt as c,At as d,Dt as f,Ot as g,Mt as h,Gt as i,ve as k,Lt as l,Nt as m,qt as n,Ut as o,Pt as p,Kt as r,Ht as s,Jt as t,zt as u,Et as v,Ne as w,We as x,Q as y};
|