@yuriai/web 0.2.19 → 0.2.20-beta.3

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.
Files changed (128) hide show
  1. package/dist/assets/AgentAvatar-D5KPQI1N.js +1 -0
  2. package/dist/assets/AssistantView-huAUB-2Y.js +3 -0
  3. package/dist/assets/{DiagramView-HNaj_sVG.js → DiagramView-DWV04Xws.js} +1 -1
  4. package/dist/assets/{FadeInOnReveal-Dq1IuEQp.js → FadeInOnReveal-CdoLG8fY.js} +1 -1
  5. package/dist/assets/{GuiPluginSurface-N-iK-MeX.js → GuiPluginSurface-DhD8BqvL.js} +1 -1
  6. package/dist/assets/{GuiPluginWindow-ClutFX_h.js → GuiPluginWindow-ezsy5l_y.js} +1 -1
  7. package/dist/assets/{Icon-tnX3bel1.js → Icon-DvqOB4Dx.js} +1 -1
  8. package/dist/assets/{ImageLoadingPlaceholder-IE6JO3WM.js → ImageLoadingPlaceholder-BVlgaa2r.js} +1 -1
  9. package/dist/assets/{LoadingImage-DNZmZRZS.js → LoadingImage-BSG8jmn5.js} +1 -1
  10. package/dist/assets/MarkdownRenderer-BiRplAST.js +2 -0
  11. package/dist/assets/{MarkdownRendererImpl-BwZ91PA5.js → MarkdownRendererImpl-CH8TUMKZ.js} +1 -1
  12. package/dist/assets/{MarkstreamRendererImpl-kgBwH_VF.js → MarkstreamRendererImpl-Bmz56IzM.js} +1 -1
  13. package/dist/assets/{MobileDetailNavigation-sm5MbnK3.js → MobileDetailNavigation-kKHM_dU3.js} +1 -1
  14. package/dist/assets/{MobileResizableSheet-Cw6rRBR2.js → MobileResizableSheet-jHNytoyX.js} +1 -1
  15. package/dist/assets/{MobileShareBridge-BjpB1cz1.js → MobileShareBridge-CSDivsPk.js} +2 -2
  16. package/dist/assets/{MobileTabPageHeader-CEsc9PYV.js → MobileTabPageHeader-BkWvNBtr.js} +1 -1
  17. package/dist/assets/{MultiRunWindow-pslncrAh.js → MultiRunWindow-DbllgaJR.js} +1 -1
  18. package/dist/assets/{OnboardingScreen-o9e7j2Lk.js → OnboardingScreen-DONIcirJ.js} +1 -1
  19. package/dist/assets/{OverlayScrollbar-BA6KEyhj.js → OverlayScrollbar-DB2eeXFh.js} +1 -1
  20. package/dist/assets/{SettingsView-20rmUHhk.js → SettingsView-6D55BNjw.js} +1 -1
  21. package/dist/assets/{SettingsWindow-D-Vjsme7.js → SettingsWindow-BrrnHfnR.js} +1 -1
  22. package/dist/assets/{TerminalView-B4bliT5i.js → TerminalView-8JYW5f-c.js} +1 -1
  23. package/dist/assets/{ToolOutputDialog-D1rZbaHo.js → ToolOutputDialog-DZO89hKv.js} +1 -1
  24. package/dist/assets/{YuriLogo-CDmH1ycw.js → YuriLogo-CYdRUurL.js} +1 -1
  25. package/dist/assets/{appThemeRegistry-DyTPt9Uq.js → appThemeRegistry-Nb-sUfbK.js} +1 -1
  26. package/dist/assets/{assistant-attachment-cache-lEUFn3mr.js → assistant-attachment-cache-C2SmtQG7.js} +1 -1
  27. package/dist/assets/{button-BEOJB042.js → button-nola46HU.js} +1 -1
  28. package/dist/assets/{capgoAdapter-BrU-ms8F.js → capgoAdapter-CHeo9q51.js} +1 -1
  29. package/dist/assets/{collapsible-DrQlDm15.js → collapsible-BQaMLh6O.js} +1 -1
  30. package/dist/assets/{desktop-dp2Z0toS.js → desktop-CiqEZVr5.js} +1 -1
  31. package/dist/assets/{desktopHosts-CYKaLp1V.js → desktopHosts-B4HMNmrx.js} +1 -1
  32. package/dist/assets/{desktopRelayRestore-5yuHB356.js → desktopRelayRestore-CRl62mqn.js} +1 -1
  33. package/dist/assets/{device-DzWRCXhq.js → device-Coc5tapU.js} +1 -1
  34. package/dist/assets/{diagram-DyQPPDKS.js → diagram-COti_aKS.js} +1 -1
  35. package/dist/assets/{dialog-CooVl0xA.js → dialog-B2CTTXwv.js} +1 -1
  36. package/dist/assets/{dropdown-menu.styles-Bj4YEb3T.js → dropdown-menu.styles-BzpQaok_.js} +1 -1
  37. package/dist/assets/{fileMentionTouchSelection-8I9u8H6l.js → fileMentionTouchSelection-CXepBNtQ.js} +1 -1
  38. package/dist/assets/{fileQueries-DbUx7NwP.js → fileQueries-Bd-OEFmO.js} +1 -1
  39. package/dist/assets/{fileReferenceActions-No7p4Kdo.js → fileReferenceActions-BnPPqYXw.js} +1 -1
  40. package/dist/assets/{gitApi-BVMvxPtG.js → gitApi-B7AeNXrj.js} +1 -1
  41. package/dist/assets/{gitApiHttp-BtI23x-7.js → gitApiHttp-CoNokuDM.js} +1 -1
  42. package/dist/assets/{gui-BCPFcL_m.js → gui-D3wrcUs6.js} +1 -1
  43. package/dist/assets/{host-BoCxB_x4.js → host-BCXyr41J.js} +1 -1
  44. package/dist/assets/{image-loading-FUFYiO1j.js → image-loading-DVZlFuU5.js} +1 -1
  45. package/dist/assets/{input-B-4VixoV.js → input-DGnhaqoc.js} +1 -1
  46. package/dist/assets/{insertionBoundaries-YVc2e3H2.js → insertionBoundaries-Db0R1aBj.js} +1 -1
  47. package/dist/assets/{main-Cs5VJerX.js → main-DQ0F0yuL.js} +21 -21
  48. package/dist/assets/{main-DZ5HVH-j.js → main-d2AaD_PZ.js} +2 -2
  49. package/dist/assets/{markdownHeightCache-SdaL8x58.js → markdownHeightCache-C_JI5qIR.js} +1 -1
  50. package/dist/assets/{mcpQueries-B1ZULr7c.js → mcpQueries-BgFj7wfO.js} +1 -1
  51. package/dist/assets/miniChat-BHdsTyJ3.js +2 -0
  52. package/dist/assets/mobile-BEhQq4tx.js +2 -0
  53. package/dist/assets/{mobileBackNavigation-D-cRdrKd.js → mobileBackNavigation-s9RsXUUH.js} +1 -1
  54. package/dist/assets/{multirun-D6bNScic.js → multirun-BZsBsBAj.js} +1 -1
  55. package/dist/assets/{native-config-obwt8WA1.js → native-config-BmrfOzkM.js} +1 -1
  56. package/dist/assets/{persistence-BfjCXjLZ.js → persistence-CNEHspb4.js} +1 -1
  57. package/dist/assets/{platform-syRnKuVU.js → platform-Q45KPuGv.js} +1 -1
  58. package/dist/assets/{projectMeta-LtQkG8fN.js → projectMeta-BCGIXTbR.js} +1 -1
  59. package/dist/assets/{queryRuntime-BuRnpVtK.js → queryRuntime-DWgXfxGx.js} +1 -1
  60. package/dist/assets/{readiness-BWBtf7Am.js → readiness-BxT5OBkk.js} +1 -1
  61. package/dist/assets/{renderElectronMiniChatApp-EL2J2wQd.js → renderElectronMiniChatApp-BbfF6SjM.js} +2 -2
  62. package/dist/assets/{renderMobileApp-DOCWKmuC.js → renderMobileApp-ulSQxT-l.js} +4 -4
  63. package/dist/assets/runtime-auth-BaBM02zI.js +1 -0
  64. package/dist/assets/{runtime-fetch-BAN5Gnnp.js → runtime-fetch-DfALP7-b.js} +1 -1
  65. package/dist/assets/{runtime-file-download-BzblfnMx.js → runtime-file-download-xvItwYMc.js} +1 -1
  66. package/dist/assets/{runtime-file-resource-D3k0hKDj.js → runtime-file-resource-DtsKbFf3.js} +1 -1
  67. package/dist/assets/{runtime-switch-CAZiOV2G.js → runtime-switch-DhMY9eiB.js} +1 -1
  68. package/dist/assets/{runtimeConfig-D577Rc9x.js → runtimeConfig-BHRHZbwI.js} +1 -1
  69. package/dist/assets/{runtimeEndpointReset-C5EiiaQf.js → runtimeEndpointReset-H2W1kxcO.js} +3 -3
  70. package/dist/assets/{scheduledTaskNavigation-CJEzv5Zr.js → scheduledTaskNavigation-CkBcoGV4.js} +1 -1
  71. package/dist/assets/{sessionChangeSummary-DAV313F8.js → sessionChangeSummary-CAU-06Bu.js} +1 -1
  72. package/dist/assets/{sessionLookup-CN_iYfk5.js → sessionLookup-YvkfClst.js} +1 -1
  73. package/dist/assets/{sortable-tabs-strip-9okrTn1K.js → sortable-tabs-strip-pCvZjmMt.js} +1 -1
  74. package/dist/assets/{speechSettingsQueries-BvJCYdR_.js → speechSettingsQueries-1LD5eEHK.js} +2 -2
  75. package/dist/assets/{src-nJdn6EvY.css → src-DGCTlpkW.css} +1 -1
  76. package/dist/assets/{terminalApi-Dw1h9m3h.js → terminalApi-DFhCeMya.js} +1 -1
  77. package/dist/assets/{textarea-9sBs8Uld.js → textarea-DSHEMw8t.js} +1 -1
  78. package/dist/assets/{tooltip-BkcQKx-p.js → tooltip-BwTvgqWG.js} +1 -1
  79. package/dist/assets/types-CiQgQf3s.js +2 -0
  80. package/dist/assets/{useAppFontEffects-D9c0mG1P.js → useAppFontEffects-Cz9eoInx.js} +9 -9
  81. package/dist/assets/{useAssistantUIStore-rdsbsVts.js → useAssistantUIStore-BZt-lLlW.js} +1 -1
  82. package/dist/assets/{useDesktopWindowControlsLayout-Dx-zWLPl.js → useDesktopWindowControlsLayout-HpOlTBoV.js} +1 -1
  83. package/dist/assets/{useEffectiveDirectory-DPvKdopQ.js → useEffectiveDirectory-DE-YccE8.js} +1 -1
  84. package/dist/assets/{useFontPreferences-B4LGrKaG.js → useFontPreferences-DmeLn0t9.js} +1 -1
  85. package/dist/assets/{useMobileNavigationStore-9pGm6Lkc.js → useMobileNavigationStore-DPE5LVui.js} +4 -4
  86. package/dist/assets/{useUIStore-NMQx_cnG.js → useUIStore-CEingF2z.js} +1 -1
  87. package/dist/assets/{useWorkerHighlightedLines-DSzghYUI.js → useWorkerHighlightedLines-o-elkNrd.js} +1 -1
  88. package/dist/index.html +21 -21
  89. package/dist/mini-chat.html +21 -21
  90. package/dist/mobile.html +21 -21
  91. package/package.json +1 -1
  92. package/server/lib/assistants/DOCUMENTATION.md +188 -16
  93. package/server/lib/assistants/assign.js +2 -1
  94. package/server/lib/assistants/contact-tools.js +11 -10
  95. package/server/lib/assistants/harness.js +23 -9
  96. package/server/lib/assistants/harness.test.js +34 -10
  97. package/server/lib/assistants/opencode-tools.js +167 -0
  98. package/server/lib/assistants/opencode-tools.test.js +295 -0
  99. package/server/lib/assistants/progressive-tools.js +33 -0
  100. package/server/lib/assistants/progressive-tools.test.js +66 -0
  101. package/server/lib/assistants/routes.js +1 -0
  102. package/server/lib/assistants/service.js +24 -35
  103. package/server/lib/assistants/service.test.js +208 -21
  104. package/server/lib/assistants/yuri-project.http.test.js +126 -0
  105. package/server/lib/assistants/yuri-tools.js +42 -0
  106. package/server/lib/assistants/yuri-tools.test.js +151 -0
  107. package/server/lib/opencode/DOCUMENTATION.md +1 -0
  108. package/server/lib/opencode/feature-routes-runtime.js +9 -0
  109. package/server/lib/opencode/feature-routes-runtime.test.js +12 -0
  110. package/server/lib/opencode/routes.js +4 -32
  111. package/server/lib/opencode/settings-runtime.js +7 -2
  112. package/server/lib/projects/DOCUMENTATION.md +29 -0
  113. package/server/lib/projects/registry.js +36 -0
  114. package/server/lib/projects/registry.test.js +107 -0
  115. package/server/lib/quota/magpie.js +2 -2
  116. package/server/lib/quota/providers/index.js +6 -2
  117. package/server/lib/quota/providers/index.test.js +6 -1
  118. package/server/lib/relay/DOCUMENTATION.md +3 -3
  119. package/server/lib/relay/host-client.js +4 -6
  120. package/server/lib/relay/host-client.reconnect.test.js +3 -2
  121. package/server/lib/relay/relay-server.e2e.test.ts +144 -1
  122. package/dist/assets/AgentAvatar-CVIpaYPU.js +0 -1
  123. package/dist/assets/AssistantView-D5vJW3gp.js +0 -3
  124. package/dist/assets/MarkdownRenderer-DuA1vlFT.js +0 -2
  125. package/dist/assets/miniChat-DUSGfEUO.js +0 -2
  126. package/dist/assets/mobile-CMXtTX1x.js +0 -2
  127. package/dist/assets/runtime-auth-ef9W7A43.js +0 -1
  128. package/dist/assets/types-BcumvHrl.js +0 -2
@@ -1 +1 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{it as e,rt as t}from"./vendor-base-ui-CdzJ6My_.js";import{n}from"./vendor-react-BP2cRVqX.js";import{r}from"./button-BEOJB042.js";var i=n();e();var a=t();function o(e){let t=(0,i.c)(10),n,o,s;t[0]===e?(n=t[1],o=t[2],s=t[3]):({className:n,type:s,...o}=e,t[0]=e,t[1]=n,t[2]=o,t[3]=s);let c;t[4]===n?c=t[5]:(c=r(`text-foreground file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground bg-[var(--surface-elevated)] appearance-none flex h-9 w-full min-w-0 rounded-lg px-3 py-1 typography-markdown outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:typography-ui-label file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:typography-ui-label`,`ring-1 ring-inset ring-border/60 transition duration-200 ease-out`,`hover:[&:not(:focus)]:bg-[var(--surface-subtle)] hover:[&:not(:focus)]:ring-transparent`,`focus:ring-2 focus:ring-[var(--interactive-focus-ring)] focus-visible:outline-none`,`aria-invalid:ring-[var(--status-error)] aria-invalid:focus:ring-[var(--status-error)]`,n),t[4]=n,t[5]=c);let l;return t[6]!==o||t[7]!==c||t[8]!==s?(l=(0,a.jsx)(`input`,{type:s,"data-slot":`input`,className:c,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,...o}),t[6]=o,t[7]=c,t[8]=s,t[9]=l):l=t[9],l}export{o as t};
1
+ import"./rolldown-runtime-hePW80VL.js";import{it as e,rt as t}from"./vendor-base-ui-CdzJ6My_.js";import{n}from"./vendor-react-BP2cRVqX.js";import{r}from"./button-nola46HU.js";var i=n();e();var a=t();function o(e){let t=(0,i.c)(10),n,o,s;t[0]===e?(n=t[1],o=t[2],s=t[3]):({className:n,type:s,...o}=e,t[0]=e,t[1]=n,t[2]=o,t[3]=s);let c;t[4]===n?c=t[5]:(c=r(`text-foreground file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground bg-[var(--surface-elevated)] appearance-none flex h-9 w-full min-w-0 rounded-lg px-3 py-1 typography-markdown outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:typography-ui-label file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:typography-ui-label`,`ring-1 ring-inset ring-border/60 transition duration-200 ease-out`,`hover:[&:not(:focus)]:bg-[var(--surface-subtle)] hover:[&:not(:focus)]:ring-transparent`,`focus:ring-2 focus:ring-[var(--interactive-focus-ring)] focus-visible:outline-none`,`aria-invalid:ring-[var(--status-error)] aria-invalid:focus:ring-[var(--status-error)]`,n),t[4]=n,t[5]=c);let l;return t[6]!==o||t[7]!==c||t[8]!==s?(l=(0,a.jsx)(`input`,{type:s,"data-slot":`input`,className:c,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,...o}),t[6]=o,t[7]=c,t[8]=s,t[9]=l):l=t[9],l}export{o as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n}from"./runtime-switch-CAZiOV2G.js";import{C as r}from"./desktop-dp2Z0toS.js";import{t as i}from"./runtimeAPIRegistry-C2VogTny.js";import{a,i as o,r as s}from"./vendor-zustand-o69pgTEK.js";import{it as c,rt as l}from"./vendor-base-ui-CdzJ6My_.js";import{L as u,bt as d,k as f,kt as p}from"./gitApiHttp-BtI23x-7.js";import{b as m,n as ee,x as h}from"./useUIStore-NMQx_cnG.js";import{D as g,O as _}from"./persistence-BfjCXjLZ.js";import{n as v}from"./vendor-react-BP2cRVqX.js";import{s as y}from"./vendor-tanstack-react-query-CdqCAt40.js";import{a as b,o as x}from"./queryRuntime-BuRnpVtK.js";import{r as S}from"./vendor-reactuses-core-BJ-jJ4YM.js";import{f as te,r as C,u as ne}from"./button-BEOJB042.js";import{Ea as re,Gn as w,Ht as ie,Ir as ae,S as T,Va as E,Za as oe,_t as se,bn as D,ct as ce,d as O,kr as le,lt as k,mo as A,po as ue,un as de,ut as fe,y as pe}from"./useMobileNavigationStore-9pGm6Lkc.js";import{t as me}from"./AgentAvatar-CVIpaYPU.js";import{n as j}from"./Icon-tnX3bel1.js";import{g as he,v as ge}from"./gitApi-BVMvxPtG.js";import{f as _e,o as M}from"./projectMeta-LtQkG8fN.js";import{c as ve,d as ye,l as N,n as be,r as xe,t as Se}from"./fileMentionTouchSelection-8I9u8H6l.js";import{n as Ce}from"./textarea-9sBs8Uld.js";var we=(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=w([...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)},Te=(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}),Ee=(e,t)=>e.highlightedIndex===t.highlightedIndex&&Te(e.rows,t.rows),De=(e,t)=>Te(e,t)?e:t.slice(),Oe=(e,t,n)=>{e&&(t.current&&Ee(t.current,n)||(t.current=n,e(n)))},ke=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},P=e(c(),1),F=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},I=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,L=(e,t)=>{let n=F(t),r=F(e);if(!n||!r)return!1;let i=I(n),a=I(r);return a===i||a.startsWith(`${i}/`)},Ae=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=F(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=>F(e)).filter(e=>L(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>F(e)).filter(e=>L(e,t)))):[],s=typeof i.selectedPath==`string`?F(i.selectedPath):null,c=s&&L(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},R=(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},z=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},je=a()(s(o((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=F((t||``).trim()),a=F((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!L(a,i)||e(e=>{let t=e.byRoot[i],n=z(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:R({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=e=>I(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:R({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=I(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:R({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=I(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:R({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=F((t||``).trim()),a=n?F(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!L(a,i)||e(e=>{let t=e.byRoot[i],n=z(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:R({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=F((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=F((t||``).trim()),i=F((n||``).trim());!r||!i||!L(i,r)||e(e=>{let t=e.byRoot[r],n=z(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:R({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||!L(i,r)||e(e=>{let t=e.byRoot[r],n=z(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:R({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=F((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>F((e||``).trim())).filter(e=>e&&L(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=z(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:R({...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:Ae(t)}},partialize:e=>({byRoot:Ae(e.byRoot)})}),{name:`files-view-tabs-store`})),B=v(),Me=(e,t)=>{let n=(0,B.c)(4),r=t===void 0?200:t,[i,a]=P.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]),P.useEffect(o,s),i},Ne=()=>{let e=(0,B.c)(17),t=O(Pe),n=D(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=T(r),a=O(V),o=O(H),s=A(U),c=A(Fe),l=d(Ie);if(t){let r;e[2]===i?r=e[3]:(r=pe(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 Pe(e){return e.currentSessionId}function V(e){return e.worktreeMetadata}function H(e){return e.newSessionDraft}function U(e){return e.activeProjectId}function Fe(e){return e.projects}function Ie(e){return e.currentDirectory}var W=l(),Le=`bg-transparent font-[inherit] text-[var(--primary-base)]`,Re=(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,W.jsx)(`mark`,{className:Le,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},ze=P.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:r,onSessionSelect:i,onClose:a,style:o,onRowsChange:s},c)=>{let{t:l}=te(),u=Ne()??``,d=O(e=>e.currentSessionId),f=ae(e=>e.activeSessions),m=ie({enabled:!!i}),h=A(e=>e.activeProjectId),v=A(e=>e.projects),y=P.useMemo(()=>v.find(e=>e.id===h)?.path??null,[h,v]),b=P.useMemo(()=>{let e=y||u;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[y,u]),x=je(e=>b?e.byRoot[b]:void 0),w=re(e=>e.agents),T=p(e=>e.searchFiles),D=Me(e,180),ue=_(),de=g(),[pe,he]=P.useState([]),[ge,_e]=P.useState(!1),[M,ye]=P.useState(0),N=P.useRef(0),we=P.useRef({query:e,directory:u,ids:[]}),[Te,Ee]=P.useState(360),[De,F]=P.useState({}),[I,L]=P.useState({}),Ae=P.useRef([]),R=P.useRef([]),z=P.useRef([]),B=P.useRef(null),Pe=P.useRef(null),V=P.useRef(null);V.current||=Se();let H=ee(e=>e.isMobile),U=(e??``).trim(),Fe=oe({directory:u||null}),Ie=P.useMemo(()=>r?Fe.data??[]:[],[r,Fe.data]),Le=P.useMemo(()=>{if(!b||!x)return[];let e=[x.selectedPath,...x.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(`${b}/`)?e.slice(b.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return fe(n,U,{limit:6})},[U,b,x]),ze=P.useMemo(()=>n?E(w).filter(e=>e.mode!==`primary`):[],[w,n]),Be=P.useMemo(()=>i?ce({sessions:le(f,m),currentSessionId:d,searchQuery:U}):[],[f,d,m,U,i]),G=Le,Ve=pe,K=P.useMemo(()=>ve({skills:Ie,agents:ze,sessions:Be,recentFiles:G,pathHits:Ve,searchQuery:U,untitledSession:l(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:l(`chat.fileMentionAutocomplete.sessionType`),skillBadge:l(`chat.commandAutocomplete.badge.skill`)}),[Ie,ze,Be,G,Ve,U,l]);P.useEffect(()=>{let e=e=>{let t=e.target;!t||!B.current||B.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),P.useEffect(()=>{if(!u){he([]);return}let e=(D??``).trim(),t=se(e);if(!t){he([]);return}let n=!1;_e(!0);let r={includeHidden:ue,respectGitignore:!de};return Promise.all([T(u,t,80,{...r,type:`file`}),T(u,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(Le.map(e=>e.path));he(k({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||he([])}).finally(()=>{n||_e(!1)}),()=>{n=!0}},[u,D,Le,T,ue,de]),P.useLayoutEffect(()=>{let t=we.current,n=t.ids[N.current],r=t.query===e&&t.directory===u?Math.max(0,K.findIndex(e=>e.id===n)):0;we.current={query:e,directory:u,ids:K.map(e=>e.id)},N.current=r,ye(r)},[K,e,u]),P.useEffect(()=>{F({}),L({})},[K]),P.useEffect(()=>{Ae.current[M]?.scrollIntoView({block:`nearest`})},[M]),P.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};R.current.forEach((n,r)=>{if(!n)return;let i=z.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}}),F(e),L(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[K]),P.useEffect(()=>{let e=R.current[M];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&Ee(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[M]);let He=S(e=>{t(e)}),Ue=S(e=>{n?.(e)}),We=S(e=>{i?.(e)}),Ge=S(e=>{r?.(e)}),Ke=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&V.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&V.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(V.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>V.current?.pointerCancel(),onClick:()=>{V.current?.click(t)},onMouseMove:()=>{N.current=e,ye(e)}}),q=e=>{let t=K.length;if(t===0)return;let n=(e%t+t)%t,r=K[n];if(r.agentName!==void 0){Ue(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=Ie.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&Ge(e);return}if(r.id.startsWith(`session:`)){let e=Be.find(e=>r.id===`session:${e.id}`);e&&We(e);return}let i=r.id.startsWith(`recent:`)?G.find(e=>r.id===`recent:${e.path}`):Ve.find(e=>r.id===`file:${e.path}`);i&&He(i)};P.useEffect(()=>{Oe(s,Pe,{rows:K,highlightedIndex:M})},[s,M,K]);let qe=P.useRef(s);return qe.current=s,P.useEffect(()=>()=>{ke(qe.current,Pe)},[]),P.useImperativeHandle(c,()=>({acceptIndex:e=>{q(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=K.length;if(t!==0){if(e===`ArrowDown`){N.current=(N.current+1)%t,ye(N.current);return}if(e===`ArrowUp`){N.current=(N.current-1+t)%t,ye(N.current);return}(e===`Enter`||e===`Tab`)&&q(N.current)}}})),(0,W.jsxs)(be,{ref:B,isMobile:H,className:`max-w-[640px] max-h-64`,style:o,children:[(0,W.jsx)(Ce,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,W.jsxs)(`div`,{className:`py-1`,children:[K.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?ne(e.title,{maxLength:60}):e.title,i=M===t,a=De[t]??!1,o=I[t]??2.6;return(0,W.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{Ae.current[t]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,H&&`min-h-11`,xe(H,i),!H&&i&&`text-interactive-selection-foreground`),...Ke(t,()=>q(t)),children:[(0,W.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,W.jsx)(j,{name:e.iconName,className:`size-3.5 text-current`}):(0,W.jsx)(me,{name:e.agentName,size:20})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`span`,{ref:e=>{R.current[t]=e},className:`relative block min-w-0 overflow-hidden file-mention-marquee-container`,style:i?{"--file-mention-marquee-width":`${Te}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,W.jsx)(`span`,{ref:e=>{z.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,W.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:Re(e.title,U)}):(0,W.jsx)(`span`,{className:`block truncate`,children:Re(r,U)})]}),e.subtitle?(0,W.jsx)(`div`,{className:C(`truncate text-muted-foreground`,H?`typography-micro`:`typography-meta`),children:Re(e.subtitle,U)}):null]})]},e.id)}),ge&&Ve.length===0?(0,W.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,W.jsx)(j,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!ge&&K.length===0&&(0,W.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.fileMentionAutocomplete.empty`)})]})}),!H&&(0,W.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})}),Be=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`goal`,`btw`]),G=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Be.has(n))},Ve=(e,t)=>!e||t({name:e}),K=` `,He=(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]===K&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},Ue=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,We=C(Ue,`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)]`),Ge=C(Ue,`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)]`),Ke=C(Ue,`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)]`),q=C(Ue,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),qe=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),Je=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!r()}},Ye=P.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:i,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=te(),d=ee(e=>e.isMobile),f=O(e=>e.currentSessionId),p=O(e=>!!e.newSessionDraft?.open),m=O(P.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=de(f??``,m??void 0),g=P.useMemo(()=>s??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[s,f,h.length,p]),{hasSession:_,canStartSessionCommand:v,canUseReviewHandoffFlow:y}=P.useMemo(()=>Je(g,d),[g,d]),b=g.hasMessages,[x,S]=P.useState([]),[ne,re]=P.useState(!1),w=ue({directory:i}),ie=P.useMemo(()=>w.data??[],[w.data]),ae=w.isFetching,[T,E]=P.useState(0),oe=P.useRef(0),se=P.useRef(!1),D=P.useRef([]),ce=P.useRef(null),le=P.useRef(!1),k=P.useRef(null),A=P.useRef(!1),fe=P.useRef(null);P.useEffect(()=>{let e=e=>{let t=e.target;!t||!ce.current||ce.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),P.useEffect(()=>{(async()=>{re(ae);try{let t=ie.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},..._&&!b?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{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}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...y?[{id:`yuri:handoff-review`,name:`handoff-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:goal`,name:`goal`,source:`yuri`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[],...t],i=!b,a=we(n.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);S(e=>qe(e,a)?e:a)}catch{let t=!b,n=we([{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{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}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...y?[{id:`yuri:handoff-review`,name:`handoff-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:goal`,name:`goal`,source:`yuri`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{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);S(e=>qe(e,n)?e:n)}finally{re(!1)}})()},[e,b,_,v,y,ie,ae,u,o]),P.useEffect(()=>{E(0)},[x]),P.useEffect(()=>{oe.current=T},[T]),P.useEffect(()=>{D.current[T]?.scrollIntoView({block:`nearest`})},[T]),P.useEffect(()=>{Oe(c,fe,{rows:N(x,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:T})},[x,c,T,u]);let pe=P.useRef(c);pe.current=c,P.useEffect(()=>()=>{ke(pe.current,fe)},[]),P.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=x[e];r&&t(r,G(r,n))},handleKeyDown:e=>{let r=x.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){se.current=!0,E(e=>(e+1)%r);return}if(e===`ArrowUp`){se.current=!0,E(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(oe.current%r+r)%r,i=x[n];i&&t(i,G(i,e===`Enter`))}}}}),[x,n,t]);let me=e=>{let t=ye(e);switch(e.name){case`new`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,W.jsxs)(be,{ref:ce,isMobile:d,className:`max-w-[450px] max-h-64`,style:a,children:[(0,W.jsx)(Ce,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:ne?(0,W.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,W.jsx)(j,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,W.jsxs)(`div`,{children:[x.map((n,r)=>{let i=n.isBuiltIn,a=n.isYuri;return(0,W.jsxs)(`div`,{ref:e=>{D.current[r]=e},className:C(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,xe(d,r===T),!d&&r===T&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(k.current={x:e.clientX,y:e.clientY},A.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!k.current)return;let t=e.clientX-k.current.x,n=e.clientY-k.current.y;Math.hypot(t,n)>6&&(A.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=A.current;k.current=null,A.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),le.current=!0,t(n,G(n,d)))},onPointerCancel:()=>{k.current=null,A.current=!1},onClick:()=>{if(le.current){le.current=!1;return}t(n,G(n,d))},onMouseMove:()=>{se.current=!1,E(r)},children:[(0,W.jsx)(`div`,{className:C(!d&&`mt-0.5`),children:me(n)}),(0,W.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,Re(n.name,e)]}),n.isSkill?(0,W.jsx)(`span`,{className:We,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,W.jsx)(`span`,{className:We,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,W.jsx)(`span`,{className:q,children:`Yuri`}):i?(0,W.jsx)(`span`,{className:q,children:u(`chat.commandAutocomplete.badge.system`)}):n.scope?(0,W.jsx)(`span`,{className:n.scope===`project`?Ke:Ge,children:n.scope}):null,n.agent&&(0,W.jsx)(`span`,{className:q,children:n.agent})]}),n.description&&!d&&(0,W.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Re(n.description,e)})]})]},n.id)}),x.length===0&&(0,W.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,W.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});Ye.displayName=`CommandAutocomplete`;var Xe=2,Ze=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Qe=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},$e=e=>Ze(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&Ze(e.branches),J=(e,t)=>JSON.stringify([e,t]),et=e=>`version`in e&&e.version===Xe&&Ze(e.entries),tt=e=>{if(!e)return null;try{let t=JSON.parse(e);return Ze(t)?t.version===Xe&&Ze(t.entries)?{version:Xe,entries:t.entries}:t:null}catch{return null}},nt=(e,t)=>{try{e.setItem(`yuri.gitBranchCache`,JSON.stringify(t))}catch{}},rt=(e,t,n)=>{let r=Qe(e);if(!r||!t)return null;let i;try{i=n.getItem(`yuri.gitBranchCache`)}catch{return null}let a=tt(i);if(!a)return null;if(et(a))return $e(a.entries[J(t,r)])?a.entries[J(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=Qe(e);r&&$e(n)&&(o[J(t,r)]=n)}return nt(n,{version:Xe,entries:o}),o[J(t,r)]??null},it=(e,t,n,r)=>{let i=Qe(e);if(!i||!t||!$e(n))return;let a=null;try{a=r.getItem(`yuri.gitBranchCache`)}catch{return}let o=tt(a);nt(r,{version:Xe,entries:{...o&&et(o)?o.entries:{},[J(t,i)]:n}})},at=3e4,Y=Qe,ot=(e,t=n())=>x.git.branches(Y(e),t),st=(e,t=n())=>x.git.remotes(Y(e),t),ct=async(e,t,n)=>{n.throwIfAborted();let r=i()?.git,a=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):r?await r.getGitBranches(e,{signal:n}):await f(e,{signal:n});return n.throwIfAborted(),a},lt=async(e,t,n)=>{n.throwIfAborted();let r=i()?.git,a=t?.getRemotes?await t.getRemotes(e,{signal:n}):r?await r.getRemotes(e,{signal:n}):await u(e,{signal:n});return n.throwIfAborted(),a},ut=(e,t,r=n(),i=h())=>{let a=Y(e),o=t;return{queryKey:ot(a,r),queryFn:async({signal:e})=>{if(!a)throw Error(`Git branches require a directory`);let t=await ct(a,o,e);return it(a,r,t,i),t},staleTime:at,gcTime:1/0,initialData:()=>rt(a,r,i)??void 0,initialDataUpdatedAt:0}},dt=(e,t,r=n())=>{let i=Y(e),a=t;return{queryKey:st(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return lt(i,a,e)},staleTime:at,gcTime:1/0}},ft=(e,r,i)=>{let a=(0,B.c)(9),o=i===void 0||i,s=P.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=Y(e),u=y,l=ut(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)},pt=(e,r,i)=>{let a=(0,B.c)(9),o=i===void 0||i,s=P.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=Y(e),u=y,l=dt(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)},mt=(e,t,r=b,i=n())=>r.fetchQuery(ut(e,t,i)),ht=(e,t,r=b,i=n())=>r.fetchQuery({...ut(e,t,i),staleTime:0}),gt=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,_t=1e4,vt=6e4,yt=5e3,bt=3e4,xt=6e4,St=25,Ct=40,wt=2,Tt=15e3,Et=500,Dt=30,Ot=20971520,kt=new Map,At=new Map,jt=new Map,X=new Map,Mt=new Map,Nt=new Map,Pt=new WeakMap,Ft=e=>{let t=Pt.get(e);return t||(t=new Set(e.files.map(e=>e.path)),Pt.set(e,t)),t},It=(e,t)=>`${t}:${e}`,Lt=e=>At.get(e)??0,Rt=e=>{let t=Lt(e)+1;return At.set(e,t),t},zt=e=>{let t=(jt.get(e)??0)+1;return jt.set(e,t),t},Bt=e=>{let t=kt.get(e);if(t)return t;let n=new Set;return kt.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}),Vt=(e,t=Dt,n=Ot)=>{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},Ht=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,Ut=e=>{let t=e?.trim()??``;return t===`?`?``:t},Wt=(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&&Ht(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),Ut(e.index)&&(r=!0);continue}a.delete(e.path),(t.index!==e.index||t.working_dir!==e.working_dir)&&n.add(e.path),!r&&Ut(t.index)!==Ut(e.index)&&(r=!0)}for(let[e,t]of a)n.add(e),Ut(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}},Gt=e=>!e||e.trim().length===0,Kt=e=>(e||``).trim()===`U`,qt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Kt(t)||Kt(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},Jt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Kt(t)||Kt(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Yt=e=>Gt(e.index)&&Gt(e.working_dir),Q=a()(s((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&Rt(r),n&&Rt(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=It(n,a),s=X.get(o)??(a===`light`?X.get(It(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)>vt,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=Nt.get(n),p=f?.received===u&&f.stored===d.status?null:Wt(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&&Rt(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}),Nt.set(n,{received:u,stored:m})}else{Nt.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})();X.set(o,c);try{return await c}finally{X.get(o)===c&&X.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`?qt(e):Jt(e);t!==e&&(l=!0),Yt(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=zt(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 ht(r,i,void 0,o):await mt(r,i,void 0,o);if(s!==jt.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(gt(i)||console.error(`Failed to fetch git branches:`,i),s!==jt.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>_t||!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=Vt(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{Rt(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,St);await t().prefetchDiffs(e,n,i,{maxFiles:St})},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=Ct}=a,c=Math.min(Math.max(1,s),Dt),l=Ft(o.status),u=o.status.diffStats,d=Bt(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>Et||(p.add(e),!o.diffCache.has(e)&&(d.has(e)||f.push(e)))}let m=f;if(m.length===0)return;let ee=Lt(n);if(typeof document<`u`&&document.hidden)return;m.forEach(e=>d.add(e));let h=0,g=[],_=()=>{let e=h;return h+=1,e<m.length?m[e]:null},v=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${Tt}ms`)),Tt)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},y=async()=>{for(;;){if(ee!==Lt(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{d.delete(e)}}},b=Math.min(wt,m.length);if(await Promise.allSettled(Array.from({length:b},()=>y())),m.forEach(e=>d.delete(e)),ee!==Lt(n))return;let x=new Map(t().directories),S=x.get(n);if(!S)return;let te=new Map(S.diffCache),C=Date.now();g.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||te.set(e.path,{...e.diff,fetchedAt:C})});let ne=Vt(te);x.set(n,{...S,diffCache:ne}),e({directories:x})},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<yt||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=Mt.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)>=yt)&&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>=bt)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=_t)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=xt)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return Mt.set(e,i),i.finally(()=>{Mt.get(e)===i&&Mt.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Xt=e=>{let t=(0,B.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)},Zt=e=>{let r=(0,B.c)(3),i=P.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)},Qt=e=>{let t=(0,B.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)},$t=e=>{let t=(0,B.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)},en=e=>{let t=(0,B.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)},tn=e=>{let t=(0,B.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=P.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)},nn=e=>{let t=(0,B.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)},rn=e=>{let t=(0,B.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)},an=e=>{let t=(0,B.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)},on=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\//,``),sn=e=>e.branchName?$(e.branchName):e.mode===`existing`?$(e.existingBranch||e.preferredName||``):$(e.preferredName||``),cn=async e=>{let t=await _e(e);try{let n=on((await he(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=on((await ge(e)).tracking);if(t?.remote)return t.remote}catch{}return null},ln=async(e,t)=>{let n=await cn(e),r=$(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},un=async(e,t,n)=>{let r=sn(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await ln(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},dn=async(e,t,n)=>{let r=await un(e.path,t,n);return M(e,r)},fn=`yuri:lastWorktreeSourceBranch`,pn=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,mn=({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},hn=(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?` `:``}`},gn=(e,t,n)=>{let r=hn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},_n=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=gn(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}},vn=(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]},yn=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{je as A,pt as C,ze as D,Ve as E,Ne as O,ft as S,He as T,tn as _,fn as a,$t as b,dn as c,en as d,Zt as f,Qt as g,nn as h,gn as i,De as j,Me as k,cn as l,rn as m,vn as n,mn as o,an as p,_n as r,pn as s,yn as t,un as u,Xt as v,Ye as w,ht 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-DhMY9eiB.js";import{C as r}from"./desktop-CiqEZVr5.js";import{t as i}from"./runtimeAPIRegistry-C2VogTny.js";import{a,i as o,r as s}from"./vendor-zustand-o69pgTEK.js";import{it as c,rt as l}from"./vendor-base-ui-CdzJ6My_.js";import{L as u,bt as d,k as f,kt as p}from"./gitApiHttp-CoNokuDM.js";import{b as m,n as ee,x as h}from"./useUIStore-CEingF2z.js";import{D as g,O as _}from"./persistence-CNEHspb4.js";import{n as v}from"./vendor-react-BP2cRVqX.js";import{s as y}from"./vendor-tanstack-react-query-CdqCAt40.js";import{a as b,o as x}from"./queryRuntime-DWgXfxGx.js";import{r as S}from"./vendor-reactuses-core-BJ-jJ4YM.js";import{f as te,r as C,u as ne}from"./button-nola46HU.js";import{Ea as re,Gn as w,Ht as ie,Ir as ae,S as T,Va as E,Za as oe,_t as se,bn as D,ct as ce,d as O,kr as le,lt as k,mo as A,po as ue,un as de,ut as fe,y as pe}from"./useMobileNavigationStore-DPE5LVui.js";import{t as me}from"./AgentAvatar-D5KPQI1N.js";import{n as j}from"./Icon-DvqOB4Dx.js";import{g as he,v as ge}from"./gitApi-B7AeNXrj.js";import{f as _e,o as M}from"./projectMeta-BCGIXTbR.js";import{c as ve,d as ye,l as N,n as be,r as xe,t as Se}from"./fileMentionTouchSelection-CXepBNtQ.js";import{n as Ce}from"./textarea-DSHEMw8t.js";var we=(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=w([...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)},Te=(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}),Ee=(e,t)=>e.highlightedIndex===t.highlightedIndex&&Te(e.rows,t.rows),De=(e,t)=>Te(e,t)?e:t.slice(),Oe=(e,t,n)=>{e&&(t.current&&Ee(t.current,n)||(t.current=n,e(n)))},ke=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},P=e(c(),1),F=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},I=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,L=(e,t)=>{let n=F(t),r=F(e);if(!n||!r)return!1;let i=I(n),a=I(r);return a===i||a.startsWith(`${i}/`)},Ae=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=F(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=>F(e)).filter(e=>L(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>F(e)).filter(e=>L(e,t)))):[],s=typeof i.selectedPath==`string`?F(i.selectedPath):null,c=s&&L(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},R=(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},z=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},je=a()(s(o((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=F((t||``).trim()),a=F((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!L(a,i)||e(e=>{let t=e.byRoot[i],n=z(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:R({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=e=>I(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:R({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=I(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:R({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=I(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:R({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=F((t||``).trim()),a=n?F(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!L(a,i)||e(e=>{let t=e.byRoot[i],n=z(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:R({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=F((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=F((t||``).trim()),i=F((n||``).trim());!r||!i||!L(i,r)||e(e=>{let t=e.byRoot[r],n=z(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:R({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||!L(i,r)||e(e=>{let t=e.byRoot[r],n=z(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:R({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=F((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>F((e||``).trim())).filter(e=>e&&L(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=z(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:R({...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:Ae(t)}},partialize:e=>({byRoot:Ae(e.byRoot)})}),{name:`files-view-tabs-store`})),B=v(),Me=(e,t)=>{let n=(0,B.c)(4),r=t===void 0?200:t,[i,a]=P.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]),P.useEffect(o,s),i},Ne=()=>{let e=(0,B.c)(17),t=O(Pe),n=D(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=T(r),a=O(V),o=O(H),s=A(U),c=A(Fe),l=d(Ie);if(t){let r;e[2]===i?r=e[3]:(r=pe(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 Pe(e){return e.currentSessionId}function V(e){return e.worktreeMetadata}function H(e){return e.newSessionDraft}function U(e){return e.activeProjectId}function Fe(e){return e.projects}function Ie(e){return e.currentDirectory}var W=l(),Le=`bg-transparent font-[inherit] text-[var(--primary-base)]`,Re=(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,W.jsx)(`mark`,{className:Le,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},ze=P.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:r,onSessionSelect:i,onClose:a,style:o,onRowsChange:s},c)=>{let{t:l}=te(),u=Ne()??``,d=O(e=>e.currentSessionId),f=ae(e=>e.activeSessions),m=ie({enabled:!!i}),h=A(e=>e.activeProjectId),v=A(e=>e.projects),y=P.useMemo(()=>v.find(e=>e.id===h)?.path??null,[h,v]),b=P.useMemo(()=>{let e=y||u;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[y,u]),x=je(e=>b?e.byRoot[b]:void 0),w=re(e=>e.agents),T=p(e=>e.searchFiles),D=Me(e,180),ue=_(),de=g(),[pe,he]=P.useState([]),[ge,_e]=P.useState(!1),[M,ye]=P.useState(0),N=P.useRef(0),we=P.useRef({query:e,directory:u,ids:[]}),[Te,Ee]=P.useState(360),[De,F]=P.useState({}),[I,L]=P.useState({}),Ae=P.useRef([]),R=P.useRef([]),z=P.useRef([]),B=P.useRef(null),Pe=P.useRef(null),V=P.useRef(null);V.current||=Se();let H=ee(e=>e.isMobile),U=(e??``).trim(),Fe=oe({directory:u||null}),Ie=P.useMemo(()=>r?Fe.data??[]:[],[r,Fe.data]),Le=P.useMemo(()=>{if(!b||!x)return[];let e=[x.selectedPath,...x.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(`${b}/`)?e.slice(b.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return fe(n,U,{limit:6})},[U,b,x]),ze=P.useMemo(()=>n?E(w).filter(e=>e.mode!==`primary`):[],[w,n]),Be=P.useMemo(()=>i?ce({sessions:le(f,m),currentSessionId:d,searchQuery:U}):[],[f,d,m,U,i]),G=Le,Ve=pe,K=P.useMemo(()=>ve({skills:Ie,agents:ze,sessions:Be,recentFiles:G,pathHits:Ve,searchQuery:U,untitledSession:l(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:l(`chat.fileMentionAutocomplete.sessionType`),skillBadge:l(`chat.commandAutocomplete.badge.skill`)}),[Ie,ze,Be,G,Ve,U,l]);P.useEffect(()=>{let e=e=>{let t=e.target;!t||!B.current||B.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),P.useEffect(()=>{if(!u){he([]);return}let e=(D??``).trim(),t=se(e);if(!t){he([]);return}let n=!1;_e(!0);let r={includeHidden:ue,respectGitignore:!de};return Promise.all([T(u,t,80,{...r,type:`file`}),T(u,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(Le.map(e=>e.path));he(k({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||he([])}).finally(()=>{n||_e(!1)}),()=>{n=!0}},[u,D,Le,T,ue,de]),P.useLayoutEffect(()=>{let t=we.current,n=t.ids[N.current],r=t.query===e&&t.directory===u?Math.max(0,K.findIndex(e=>e.id===n)):0;we.current={query:e,directory:u,ids:K.map(e=>e.id)},N.current=r,ye(r)},[K,e,u]),P.useEffect(()=>{F({}),L({})},[K]),P.useEffect(()=>{Ae.current[M]?.scrollIntoView({block:`nearest`})},[M]),P.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};R.current.forEach((n,r)=>{if(!n)return;let i=z.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}}),F(e),L(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[K]),P.useEffect(()=>{let e=R.current[M];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&Ee(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[M]);let He=S(e=>{t(e)}),Ue=S(e=>{n?.(e)}),We=S(e=>{i?.(e)}),Ge=S(e=>{r?.(e)}),Ke=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&V.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&V.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(V.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>V.current?.pointerCancel(),onClick:()=>{V.current?.click(t)},onMouseMove:()=>{N.current=e,ye(e)}}),q=e=>{let t=K.length;if(t===0)return;let n=(e%t+t)%t,r=K[n];if(r.agentName!==void 0){Ue(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=Ie.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&Ge(e);return}if(r.id.startsWith(`session:`)){let e=Be.find(e=>r.id===`session:${e.id}`);e&&We(e);return}let i=r.id.startsWith(`recent:`)?G.find(e=>r.id===`recent:${e.path}`):Ve.find(e=>r.id===`file:${e.path}`);i&&He(i)};P.useEffect(()=>{Oe(s,Pe,{rows:K,highlightedIndex:M})},[s,M,K]);let qe=P.useRef(s);return qe.current=s,P.useEffect(()=>()=>{ke(qe.current,Pe)},[]),P.useImperativeHandle(c,()=>({acceptIndex:e=>{q(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=K.length;if(t!==0){if(e===`ArrowDown`){N.current=(N.current+1)%t,ye(N.current);return}if(e===`ArrowUp`){N.current=(N.current-1+t)%t,ye(N.current);return}(e===`Enter`||e===`Tab`)&&q(N.current)}}})),(0,W.jsxs)(be,{ref:B,isMobile:H,className:`max-w-[640px] max-h-64`,style:o,children:[(0,W.jsx)(Ce,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,W.jsxs)(`div`,{className:`py-1`,children:[K.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?ne(e.title,{maxLength:60}):e.title,i=M===t,a=De[t]??!1,o=I[t]??2.6;return(0,W.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{Ae.current[t]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,H&&`min-h-11`,xe(H,i),!H&&i&&`text-interactive-selection-foreground`),...Ke(t,()=>q(t)),children:[(0,W.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,W.jsx)(j,{name:e.iconName,className:`size-3.5 text-current`}):(0,W.jsx)(me,{name:e.agentName,size:20})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`span`,{ref:e=>{R.current[t]=e},className:`relative block min-w-0 overflow-hidden file-mention-marquee-container`,style:i?{"--file-mention-marquee-width":`${Te}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,W.jsx)(`span`,{ref:e=>{z.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,W.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:Re(e.title,U)}):(0,W.jsx)(`span`,{className:`block truncate`,children:Re(r,U)})]}),e.subtitle?(0,W.jsx)(`div`,{className:C(`truncate text-muted-foreground`,H?`typography-micro`:`typography-meta`),children:Re(e.subtitle,U)}):null]})]},e.id)}),ge&&Ve.length===0?(0,W.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,W.jsx)(j,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!ge&&K.length===0&&(0,W.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.fileMentionAutocomplete.empty`)})]})}),!H&&(0,W.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})}),Be=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`goal`,`btw`]),G=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Be.has(n))},Ve=(e,t)=>!e||t({name:e}),K=` `,He=(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]===K&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},Ue=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,We=C(Ue,`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)]`),Ge=C(Ue,`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)]`),Ke=C(Ue,`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)]`),q=C(Ue,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),qe=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),Je=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!r()}},Ye=P.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:i,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=te(),d=ee(e=>e.isMobile),f=O(e=>e.currentSessionId),p=O(e=>!!e.newSessionDraft?.open),m=O(P.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=de(f??``,m??void 0),g=P.useMemo(()=>s??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[s,f,h.length,p]),{hasSession:_,canStartSessionCommand:v,canUseReviewHandoffFlow:y}=P.useMemo(()=>Je(g,d),[g,d]),b=g.hasMessages,[x,S]=P.useState([]),[ne,re]=P.useState(!1),w=ue({directory:i}),ie=P.useMemo(()=>w.data??[],[w.data]),ae=w.isFetching,[T,E]=P.useState(0),oe=P.useRef(0),se=P.useRef(!1),D=P.useRef([]),ce=P.useRef(null),le=P.useRef(!1),k=P.useRef(null),A=P.useRef(!1),fe=P.useRef(null);P.useEffect(()=>{let e=e=>{let t=e.target;!t||!ce.current||ce.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),P.useEffect(()=>{(async()=>{re(ae);try{let t=ie.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},..._&&!b?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{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}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...y?[{id:`yuri:handoff-review`,name:`handoff-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:goal`,name:`goal`,source:`yuri`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[],...t],i=!b,a=we(n.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);S(e=>qe(e,a)?e:a)}catch{let t=!b,n=we([{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{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}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...y?[{id:`yuri:handoff-review`,name:`handoff-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:goal`,name:`goal`,source:`yuri`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{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);S(e=>qe(e,n)?e:n)}finally{re(!1)}})()},[e,b,_,v,y,ie,ae,u,o]),P.useEffect(()=>{E(0)},[x]),P.useEffect(()=>{oe.current=T},[T]),P.useEffect(()=>{D.current[T]?.scrollIntoView({block:`nearest`})},[T]),P.useEffect(()=>{Oe(c,fe,{rows:N(x,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:T})},[x,c,T,u]);let pe=P.useRef(c);pe.current=c,P.useEffect(()=>()=>{ke(pe.current,fe)},[]),P.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=x[e];r&&t(r,G(r,n))},handleKeyDown:e=>{let r=x.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){se.current=!0,E(e=>(e+1)%r);return}if(e===`ArrowUp`){se.current=!0,E(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(oe.current%r+r)%r,i=x[n];i&&t(i,G(i,e===`Enter`))}}}}),[x,n,t]);let me=e=>{let t=ye(e);switch(e.name){case`new`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,W.jsxs)(be,{ref:ce,isMobile:d,className:`max-w-[450px] max-h-64`,style:a,children:[(0,W.jsx)(Ce,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:ne?(0,W.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,W.jsx)(j,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,W.jsxs)(`div`,{children:[x.map((n,r)=>{let i=n.isBuiltIn,a=n.isYuri;return(0,W.jsxs)(`div`,{ref:e=>{D.current[r]=e},className:C(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,xe(d,r===T),!d&&r===T&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(k.current={x:e.clientX,y:e.clientY},A.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!k.current)return;let t=e.clientX-k.current.x,n=e.clientY-k.current.y;Math.hypot(t,n)>6&&(A.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=A.current;k.current=null,A.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),le.current=!0,t(n,G(n,d)))},onPointerCancel:()=>{k.current=null,A.current=!1},onClick:()=>{if(le.current){le.current=!1;return}t(n,G(n,d))},onMouseMove:()=>{se.current=!1,E(r)},children:[(0,W.jsx)(`div`,{className:C(!d&&`mt-0.5`),children:me(n)}),(0,W.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,Re(n.name,e)]}),n.isSkill?(0,W.jsx)(`span`,{className:We,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,W.jsx)(`span`,{className:We,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,W.jsx)(`span`,{className:q,children:`Yuri`}):i?(0,W.jsx)(`span`,{className:q,children:u(`chat.commandAutocomplete.badge.system`)}):n.scope?(0,W.jsx)(`span`,{className:n.scope===`project`?Ke:Ge,children:n.scope}):null,n.agent&&(0,W.jsx)(`span`,{className:q,children:n.agent})]}),n.description&&!d&&(0,W.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Re(n.description,e)})]})]},n.id)}),x.length===0&&(0,W.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,W.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});Ye.displayName=`CommandAutocomplete`;var Xe=2,Ze=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Qe=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},$e=e=>Ze(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&Ze(e.branches),J=(e,t)=>JSON.stringify([e,t]),et=e=>`version`in e&&e.version===Xe&&Ze(e.entries),tt=e=>{if(!e)return null;try{let t=JSON.parse(e);return Ze(t)?t.version===Xe&&Ze(t.entries)?{version:Xe,entries:t.entries}:t:null}catch{return null}},nt=(e,t)=>{try{e.setItem(`yuri.gitBranchCache`,JSON.stringify(t))}catch{}},rt=(e,t,n)=>{let r=Qe(e);if(!r||!t)return null;let i;try{i=n.getItem(`yuri.gitBranchCache`)}catch{return null}let a=tt(i);if(!a)return null;if(et(a))return $e(a.entries[J(t,r)])?a.entries[J(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=Qe(e);r&&$e(n)&&(o[J(t,r)]=n)}return nt(n,{version:Xe,entries:o}),o[J(t,r)]??null},it=(e,t,n,r)=>{let i=Qe(e);if(!i||!t||!$e(n))return;let a=null;try{a=r.getItem(`yuri.gitBranchCache`)}catch{return}let o=tt(a);nt(r,{version:Xe,entries:{...o&&et(o)?o.entries:{},[J(t,i)]:n}})},at=3e4,Y=Qe,ot=(e,t=n())=>x.git.branches(Y(e),t),st=(e,t=n())=>x.git.remotes(Y(e),t),ct=async(e,t,n)=>{n.throwIfAborted();let r=i()?.git,a=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):r?await r.getGitBranches(e,{signal:n}):await f(e,{signal:n});return n.throwIfAborted(),a},lt=async(e,t,n)=>{n.throwIfAborted();let r=i()?.git,a=t?.getRemotes?await t.getRemotes(e,{signal:n}):r?await r.getRemotes(e,{signal:n}):await u(e,{signal:n});return n.throwIfAborted(),a},ut=(e,t,r=n(),i=h())=>{let a=Y(e),o=t;return{queryKey:ot(a,r),queryFn:async({signal:e})=>{if(!a)throw Error(`Git branches require a directory`);let t=await ct(a,o,e);return it(a,r,t,i),t},staleTime:at,gcTime:1/0,initialData:()=>rt(a,r,i)??void 0,initialDataUpdatedAt:0}},dt=(e,t,r=n())=>{let i=Y(e),a=t;return{queryKey:st(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return lt(i,a,e)},staleTime:at,gcTime:1/0}},ft=(e,r,i)=>{let a=(0,B.c)(9),o=i===void 0||i,s=P.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=Y(e),u=y,l=ut(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)},pt=(e,r,i)=>{let a=(0,B.c)(9),o=i===void 0||i,s=P.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=Y(e),u=y,l=dt(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)},mt=(e,t,r=b,i=n())=>r.fetchQuery(ut(e,t,i)),ht=(e,t,r=b,i=n())=>r.fetchQuery({...ut(e,t,i),staleTime:0}),gt=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,_t=1e4,vt=6e4,yt=5e3,bt=3e4,xt=6e4,St=25,Ct=40,wt=2,Tt=15e3,Et=500,Dt=30,Ot=20971520,kt=new Map,At=new Map,jt=new Map,X=new Map,Mt=new Map,Nt=new Map,Pt=new WeakMap,Ft=e=>{let t=Pt.get(e);return t||(t=new Set(e.files.map(e=>e.path)),Pt.set(e,t)),t},It=(e,t)=>`${t}:${e}`,Lt=e=>At.get(e)??0,Rt=e=>{let t=Lt(e)+1;return At.set(e,t),t},zt=e=>{let t=(jt.get(e)??0)+1;return jt.set(e,t),t},Bt=e=>{let t=kt.get(e);if(t)return t;let n=new Set;return kt.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}),Vt=(e,t=Dt,n=Ot)=>{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},Ht=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,Ut=e=>{let t=e?.trim()??``;return t===`?`?``:t},Wt=(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&&Ht(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),Ut(e.index)&&(r=!0);continue}a.delete(e.path),(t.index!==e.index||t.working_dir!==e.working_dir)&&n.add(e.path),!r&&Ut(t.index)!==Ut(e.index)&&(r=!0)}for(let[e,t]of a)n.add(e),Ut(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}},Gt=e=>!e||e.trim().length===0,Kt=e=>(e||``).trim()===`U`,qt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Kt(t)||Kt(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},Jt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Kt(t)||Kt(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Yt=e=>Gt(e.index)&&Gt(e.working_dir),Q=a()(s((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&Rt(r),n&&Rt(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=It(n,a),s=X.get(o)??(a===`light`?X.get(It(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)>vt,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=Nt.get(n),p=f?.received===u&&f.stored===d.status?null:Wt(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&&Rt(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}),Nt.set(n,{received:u,stored:m})}else{Nt.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})();X.set(o,c);try{return await c}finally{X.get(o)===c&&X.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`?qt(e):Jt(e);t!==e&&(l=!0),Yt(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=zt(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 ht(r,i,void 0,o):await mt(r,i,void 0,o);if(s!==jt.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(gt(i)||console.error(`Failed to fetch git branches:`,i),s!==jt.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>_t||!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=Vt(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{Rt(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,St);await t().prefetchDiffs(e,n,i,{maxFiles:St})},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=Ct}=a,c=Math.min(Math.max(1,s),Dt),l=Ft(o.status),u=o.status.diffStats,d=Bt(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>Et||(p.add(e),!o.diffCache.has(e)&&(d.has(e)||f.push(e)))}let m=f;if(m.length===0)return;let ee=Lt(n);if(typeof document<`u`&&document.hidden)return;m.forEach(e=>d.add(e));let h=0,g=[],_=()=>{let e=h;return h+=1,e<m.length?m[e]:null},v=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${Tt}ms`)),Tt)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},y=async()=>{for(;;){if(ee!==Lt(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{d.delete(e)}}},b=Math.min(wt,m.length);if(await Promise.allSettled(Array.from({length:b},()=>y())),m.forEach(e=>d.delete(e)),ee!==Lt(n))return;let x=new Map(t().directories),S=x.get(n);if(!S)return;let te=new Map(S.diffCache),C=Date.now();g.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||te.set(e.path,{...e.diff,fetchedAt:C})});let ne=Vt(te);x.set(n,{...S,diffCache:ne}),e({directories:x})},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<yt||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=Mt.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)>=yt)&&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>=bt)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=_t)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=xt)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return Mt.set(e,i),i.finally(()=>{Mt.get(e)===i&&Mt.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Xt=e=>{let t=(0,B.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)},Zt=e=>{let r=(0,B.c)(3),i=P.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)},Qt=e=>{let t=(0,B.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)},$t=e=>{let t=(0,B.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)},en=e=>{let t=(0,B.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)},tn=e=>{let t=(0,B.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=P.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)},nn=e=>{let t=(0,B.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)},rn=e=>{let t=(0,B.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)},an=e=>{let t=(0,B.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)},on=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\//,``),sn=e=>e.branchName?$(e.branchName):e.mode===`existing`?$(e.existingBranch||e.preferredName||``):$(e.preferredName||``),cn=async e=>{let t=await _e(e);try{let n=on((await he(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=on((await ge(e)).tracking);if(t?.remote)return t.remote}catch{}return null},ln=async(e,t)=>{let n=await cn(e),r=$(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},un=async(e,t,n)=>{let r=sn(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await ln(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},dn=async(e,t,n)=>{let r=await un(e.path,t,n);return M(e,r)},fn=`yuri:lastWorktreeSourceBranch`,pn=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,mn=({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},hn=(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?` `:``}`},gn=(e,t,n)=>{let r=hn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},_n=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=gn(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}},vn=(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]},yn=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{je as A,pt as C,ze as D,Ve as E,Ne as O,ft as S,He as T,tn as _,fn as a,$t as b,dn as c,en as d,Zt as f,Qt as g,nn as h,gn as i,De as j,Me as k,cn as l,rn as m,vn as n,mn as o,an as p,_n as r,pn as s,yn as t,un as u,Xt as v,Ye as w,ht as x,Q as y};