@openchambery/web 1.19.0-beta.34 → 1.19.0-beta.35

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 (45) hide show
  1. package/dist/assets/AssistantView-IaH1kmtL.js +1 -0
  2. package/dist/assets/{ChatContainer-CmnHzI_W.js → ChatContainer-CN8nekZY.js} +22 -22
  3. package/dist/assets/ContextPanel-CIv9CDdO.js +288 -0
  4. package/dist/assets/{DiagramView-DIIhpKCB.js → DiagramView-DBK_oQnr.js} +1 -1
  5. package/dist/assets/{MarkdownRendererImpl-3CmQmOxt.js → MarkdownRendererImpl-mONEf7SR.js} +1 -1
  6. package/dist/assets/{MobileDetailNavigation-Cduqba5U.js → MobileDetailNavigation-CIn1W3V3.js} +1 -1
  7. package/dist/assets/{MobileShareBridge-DYDBWuQH.js → MobileShareBridge-CXp9Vfhp.js} +1 -1
  8. package/dist/assets/{MobileSurface-DxcqHtz5.js → MobileSurface-Bg2VihXc.js} +1 -1
  9. package/dist/assets/{MultiRunWindow-p8oCAAdF.js → MultiRunWindow-lCNPscu-.js} +1 -1
  10. package/dist/assets/{SettingsView-CU7MwJsJ.js → SettingsView-CKLn5zHk.js} +6 -6
  11. package/dist/assets/{SettingsWindow-BFAzmzGp.js → SettingsWindow-DdSU1aJ8.js} +1 -1
  12. package/dist/assets/{TerminalView-CO9rrrhR.js → TerminalView-DBH_K8Ym.js} +1 -1
  13. package/dist/assets/{ToolOutputDialog-CTX6xRo-.js → ToolOutputDialog-DqTpXhaV.js} +1 -1
  14. package/dist/assets/{appThemeRegistry-BVCNw3d7.js → appThemeRegistry-DjOsNU9m.js} +2 -2
  15. package/dist/assets/{gitApi-G_L1y6t4.js → gitApi-C-gMopTX.js} +3 -3
  16. package/dist/assets/insertionBoundaries-Dl86wE65.js +4 -0
  17. package/dist/assets/{main-Cmi6YDb-.js → main-BQK5qC01.js} +6 -6
  18. package/dist/assets/{main-D-lgpAqr.js → main-yqA5mVW0.js} +2 -2
  19. package/dist/assets/{miniChat-B3Vn1d_t.js → miniChat-ryqA9hOe.js} +2 -2
  20. package/dist/assets/{mobile-DoDvV8tR.js → mobile-Cf1M12K7.js} +2 -2
  21. package/dist/assets/multirun-CgAKGa6a.js +4 -0
  22. package/dist/assets/{projectMeta-CQIQWtbJ.js → projectMeta-DDgFjb62.js} +2 -2
  23. package/dist/assets/{radio-DODUfCXY.js → radio-BurHnKcg.js} +1 -1
  24. package/dist/assets/renderElectronMiniChatApp-DMh1IBDh.js +2 -0
  25. package/dist/assets/renderMobileApp-WqUAhzQG.js +23 -0
  26. package/dist/assets/{runtimeConfig--Y_x2z62.js → runtimeConfig-DE8K0bOi.js} +1 -1
  27. package/dist/assets/runtimeEndpointReset-D5gjdp03.js +4 -0
  28. package/dist/assets/{shikiHighlight-DhSvEcBG.js → shikiHighlight-BOqky8UX.js} +1 -1
  29. package/dist/assets/{useAppFontEffects-Dy_VKl9E.js → useAppFontEffects-4WtryKPT.js} +4 -4
  30. package/dist/assets/{useDesktopWindowControlsLayout-7JfdV9hT.js → useDesktopWindowControlsLayout-DMHRm-1S.js} +1 -1
  31. package/dist/assets/{useEffectiveDirectory-Px-1yKE-.js → useEffectiveDirectory-kTQjG3bM.js} +1 -1
  32. package/dist/assets/{useMobileNavigationStore-BYDKiRu_.js → useMobileNavigationStore-DC0j169I.js} +8 -8
  33. package/dist/assets/{useSessionAutoCleanup-DFVlXSQK.js → useSessionAutoCleanup-Ca5AKlM6.js} +1 -1
  34. package/dist/assets/{useWorkerHighlightedLines-DL-WIIlT.js → useWorkerHighlightedLines-BPoLqoHK.js} +1 -1
  35. package/dist/index.html +2 -2
  36. package/dist/mini-chat.html +2 -2
  37. package/dist/mobile.html +2 -2
  38. package/package.json +1 -1
  39. package/dist/assets/AssistantView-C5hxPp18.js +0 -1
  40. package/dist/assets/ContextPanel-CsNUG_x3.js +0 -288
  41. package/dist/assets/insertionBoundaries-CbvPY1wl.js +0 -4
  42. package/dist/assets/multirun-hwvFfNWy.js +0 -4
  43. package/dist/assets/renderElectronMiniChatApp-DNhrSWqF.js +0 -2
  44. package/dist/assets/renderMobileApp-BuRoq9OY.js +0 -23
  45. package/dist/assets/runtimeEndpointReset-D4-dTlGC.js +0 -4
@@ -1,4 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,E as n,b as r,t as i,y as a}from"./useUIStore-Wyu09VUF.js";import{$t as o,D as s,d as c,k as l,ot as u,u as d,xn as f}from"./persistence-aCOlo6ew.js";import{a as p,i as m,r as h}from"./vendor-zustand-B4dlGEM2.js";import{nt as g,rt as _}from"./vendor-base-ui-CnHfUmDN.js";import{B as v,Ct as y,M as b,Mt as x}from"./platform-ulFAVx1H.js";import{n as S}from"./vendor-react-DLPElpoQ.js";import{s as C}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as w}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as ee}from"./clipboard-mffeUZRt.js";import{Do as T,Eo as te,_ as ne,an as re,b as E,ca as ie,ct as ae,ft as D,hn as O,l as k,lt as A,ot as oe,pt as se,st as j,uo as ce,ut as le,yr as M}from"./useMobileNavigationStore-BYDKiRu_.js";import{c as N,t as P}from"./utils-CJdWZupK.js";import{n as F,r as I,t as L}from"./Icon-Bs6GJIoO.js";import{g as ue,v as de}from"./gitApi-G_L1y6t4.js";import{A as fe,W as pe,p as me,s as he}from"./projectMeta-CQIQWtbJ.js";var R=e(_(),1),z=S(),B=e=>{switch(e.name){case`new`:return`add`;case`init`:return`file`;case`undo`:return`arrow-go-back`;case`redo`:return`arrow-go-forward`;case`timeline`:return`time`;case`compact`:return`scissors`;case`goal`:return`target`;case`review`:return`search-eye`;case`test`:case`build`:case`run`:return`terminal-box`;default:return e.isBuiltIn?`flashlight`:`command`}},V=()=>`book-open`,ge=e=>{if(e.isDirectory)return`folder-3-fill`;switch(e.extension?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:case`json`:return`code`;case`md`:case`mdx`:return`file`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`svg`:return`file-image`;default:return`file-pdf`}},H=()=>`ai-agent`,_e=()=>`chat-thread`,U=32,ve=(e,t)=>{let n=I[e];return typeof n!=`string`||n.length===0?null:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="${t}" stroke-width="${L}" stroke-linecap="round" stroke-linejoin="round">${n}</svg>`},ye=(e,t)=>{let n=ve(e,t);return!n||typeof document>`u`?Promise.resolve(null):new Promise(e=>{let t=new Image;t.decoding=`async`,t.onload=()=>{try{let n=document.createElement(`canvas`);n.width=U,n.height=U;let r=n.getContext(`2d`);if(!r){e(null);return}r.clearRect(0,0,U,U),r.drawImage(t,0,0,U,U);let i=n.toDataURL(`image/png`),a=i.indexOf(`,`);e(a>=0?i.slice(a+1):null)}catch{e(null)}},t.onerror=()=>e(null),t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`})},be=(e,t)=>e.map(e=>{let n=e.isSkill?t.skill:e.isOpenChamber?`OpenChamber`:e.isBuiltIn?t.system:e.scope||e.agent||t.command;return{id:e.id,title:`/${e.name}`,subtitle:e.description,badge:n,iconName:B(e)}}),xe=e=>e.map(e=>({id:`${e.name}-${e.scope}`,title:e.name,subtitle:e.description,badge:e.scope,iconName:V()})),Se=({agents:e,sessions:t,recentFiles:n,pathHits:r,untitledSession:i,sessionBadge:a})=>{let o=[];for(let t of e)o.push({id:`agent:${t.name}`,title:`@${t.name}`,subtitle:t.description,iconName:H()});for(let e of t)o.push({id:`session:${e.id}`,title:e.title||i,badge:a,iconName:_e()});for(let e of n)o.push({id:`recent:${e.path}`,title:e.relativePath||e.name,iconName:ge(e)});for(let e of r)o.push({id:`file:${e.path}`,title:e.relativePath||e.name,iconName:ge(e)});return o},Ce=(e,t)=>{let n=t.trim();if(!n)return[...e].sort((e,t)=>e.isBuiltIn===t.isBuiltIn?e.name.localeCompare(t.name):e.isBuiltIn?-1:1);let r=se([...e],n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.isBuiltIn===t.item.isBuiltIn?e.item.name.localeCompare(t.item.name):e.item.isBuiltIn?-1:1:e.score-t.score),r.map(e=>e.item)},we=(e,t)=>{if(!e.includes(`/`)||t.size===0)return[];let n=RegExp(`(^|\\s)/(${u})?([A-Za-z0-9][A-Za-z0-9_-]*)(?=$|\\s)`,`g`),r=[],i;for(;(i=n.exec(e))!==null;){let e=i[3]??``;if(!t.has(e.toLowerCase()))continue;let n=i[2]??``,a=i.index+(i[1]?.length??0);r.push({start:a,end:a+1+n.length+e.length,name:e,hasSlot:n.length>0})}return r},W=(e,t,n=e.length)=>{let r=we(e,t).filter(e=>!e.hasSlot);if(r.length===0)return null;let i=e,a=n;for(let e=r.length-1;e>=0;--e){let t=r[e].start+1;i=`${i.slice(0,t)}${u}${i.slice(t)}`,a>t&&(a+=u.length)}return i===e?null:{text:i,caret:a}},G=e=>e.startsWith(u)?e.slice(u.length):e,K=e=>{if(e.inputMode===`shell`)return null;let t=e.text,n=Math.max(0,Math.min(e.cursor,t.length));if(t.startsWith(`/`)){let e=t.indexOf(` `),r=t.indexOf(`
2
- `),i=Math.min(e===-1?t.length:e,r===-1?t.length:r);if(n<=i&&e===-1)return{kind:`slash-command`,query:G(t.substring(1,i)),tokenStart:0,tokenEnd:i}}let r=t.substring(0,n),i=r.lastIndexOf(`/`);if(i!==-1){let e=i>0?r[i-1]:null,t=G(r.substring(i+1)),a=t.includes(` `)||t.includes(`
3
- `);if((!e||/\s/.test(e))&&!a)return{kind:`slash-skill`,query:t,tokenStart:i,tokenEnd:n}}let a=r.lastIndexOf(`#`);if(a!==-1){let e=a>0?r[a-1]:null,t=r.substring(a+1);if((!e||/\s/.test(e))&&!t.includes(` `)&&!t.includes(`
4
- `))return{kind:`snippet`,query:t,tokenStart:a,tokenEnd:n}}let o=oe({value:t,cursorPosition:n,inputSource:e.mentionInputSource??`manual`,insertedText:e.insertedText});return o===null?null:{kind:`mention`,query:o,tokenStart:r.lastIndexOf(`@`),tokenEnd:n}},q=e=>e===`mention`?`@`:e===`snippet`?`#`:`/`,Te=(e,t,n)=>{if(n&&n.tokenStart>=0&&n.tokenEnd>=n.tokenStart&&n.tokenEnd<=e.length&&e.startsWith(q(n.kind),n.tokenStart))return{start:n.tokenStart,end:n.tokenEnd};let r=K({text:e,cursor:t});return r?{start:r.tokenStart,end:r.tokenEnd}:null},Ee=(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}),De=(e,t)=>e.highlightedIndex===t.highlightedIndex&&Ee(e.rows,t.rows),Oe=(e,t)=>Ee(e,t)?e:t.slice(),ke=(e,t,n)=>{e&&(t.current&&De(t.current,n)||(t.current=n,e(n)))},Ae=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},J=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},Y=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,X=(e,t)=>{let n=J(t),r=J(e);if(!n||!r)return!1;let i=Y(n),a=Y(r);return a===i||a.startsWith(`${i}/`)},je=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=J(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=>J(e)).filter(e=>X(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>J(e)).filter(e=>X(e,t)))):[],s=typeof i.selectedPath==`string`?J(i.selectedPath):null,c=s&&X(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},Me=(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},Ne=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Pe=p()(h(m((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=J((t||``).trim()),a=J((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!X(a,i)||e(e=>{let t=e.byRoot[i],n=Ne(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:Me({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=J((t||``).trim()),i=J((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=Y(i),a=e=>Y(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:Me({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=J((t||``).trim()),i=J((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=Y(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=Y(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:Me({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=J((t||``).trim()),i=J((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=Y(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=Y(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:Me({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=J((t||``).trim()),a=n?J(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!X(a,i)||e(e=>{let t=e.byRoot[i],n=Ne(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:Me({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=J((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=J((t||``).trim()),i=J((n||``).trim());!r||!i||!X(i,r)||e(e=>{let t=e.byRoot[r],n=Ne(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:Me({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=J((t||``).trim()),i=J((n||``).trim());!r||!i||!X(i,r)||e(e=>{let t=e.byRoot[r],n=Ne(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:Me({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=J((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>J((e||``).trim())).filter(e=>e&&X(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=Ne(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:Me({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:a(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:je(t)}},partialize:e=>({byRoot:je(e.byRoot)})}),{name:`files-view-tabs-store`})),Fe=(e,t)=>{let n=(0,z.c)(4),r=t===void 0?200:t,[i,a]=R.useState(e),o,s;return n[0]!==r||n[1]!==e?(o=()=>{let t=window.setTimeout(()=>{a(e)},r);return()=>{window.clearTimeout(t)}},s=[e,r],n[0]=r,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),R.useEffect(o,s),i},Ie=()=>{let e=(0,z.c)(17),t=k(Le),n=O(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=E(r),a=k(Re),o=k(ze),s=T(Be),c=T(Ve),l=y(He);if(t){let r;e[2]===i?r=e[3]:(r=ne(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 Le(e){return e.currentSessionId}function Re(e){return e.worktreeMetadata}function ze(e){return e.newSessionDraft}function Be(e){return e.activeProjectId}function Ve(e){return e.projects}function He(e){return e.currentDirectory}var Ue=.4,We=8,Ge=e=>{let t=e.gap??We,n=Math.max(0,e.popupBottom-e.boundaryTop-t),r=e.viewportHeight*Ue,i=Math.floor(Math.min(n,r));return n>=120?Math.min(n,Math.max(120,i)):i},Ke=(e,t=0)=>{let n=e.closest(`main`);if(!n)return null;let r=(e.closest(`.mobile-chat-screen__content`)?.parentElement??n.parentElement?.closest(`main`)??n).querySelector(`:scope > .oc-mobile-detail-navigation`)?.getBoundingClientRect().bottom,i=n.getBoundingClientRect().top;return Math.max(r===void 0?i:Math.max(r,i),t)},qe=(e,t)=>{let n=(0,z.c)(3),[r,i]=R.useState(void 0),a;return n[0]!==e||n[1]!==t?(a=()=>{if(!t)return;let n=()=>{let t=e.current;if(!t)return;let n=window.visualViewport,r=Ke(t,n?.offsetTop??0);if(r===null)return;let a=n?.height??window.innerHeight,o=Ge({popupBottom:t.getBoundingClientRect().bottom,boundaryTop:r,viewportHeight:a});i(e=>e===o?e:o)};return n(),window.addEventListener(`resize`,n),window.addEventListener(`oc:keyboard-settled`,n),window.visualViewport?.addEventListener(`resize`,n),window.visualViewport?.addEventListener(`scroll`,n),()=>{window.removeEventListener(`resize`,n),window.removeEventListener(`oc:keyboard-settled`,n),window.visualViewport?.removeEventListener(`resize`,n),window.visualViewport?.removeEventListener(`scroll`,n)}},n[0]=e,n[1]=t,n[2]=a):a=n[2],R.useLayoutEffect(a),t?r:void 0},Je=()=>{let e=null,t=!1,n=!1;return{pointerDown:(n,r)=>{e={x:n,y:r},t=!1},pointerMove:(n,r)=>{e&&Math.hypot(n-e.x,r-e.y)>6&&(t=!0)},pointerCancel:()=>{e=null,t=!1},pointerUp:r=>{if(!e)return!1;let i=!t;return e=null,t=!1,i?(n=!0,r(),!0):(n=!0,!1)},click:e=>n?(n=!1,!1):(e(),!0)}},Z=g(),Ye=R.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSessionSelect:r,onClose:a,style:o,onRowsChange:c},u)=>{let{t:d}=ee(),f=Ie()??``,p=k(e=>e.currentSessionId),m=M(e=>e.activeSessions),h=T(e=>e.activeProjectId),g=T(e=>e.projects),_=R.useMemo(()=>g.find(e=>e.id===h)?.path??null,[h,g]),v=R.useMemo(()=>{let e=_||f;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[_,f]),y=Pe(e=>v?e.byRoot[v]:void 0),b=ie(e=>e.getVisibleAgents),S=x(e=>e.searchFiles),C=Fe(e,180),te=l(),ne=s(),[re,E]=R.useState([]),[O,oe]=R.useState([]),[se,ce]=R.useState(!1),[I,L]=R.useState(0),ue=R.useRef(0),[de,pe]=R.useState(360),[me,he]=R.useState({}),[z,B]=R.useState({}),V=R.useRef([]),H=R.useRef([]),_e=R.useRef([]),U=R.useRef(null),ve=R.useRef(null),ye=R.useRef(null);ye.current||=Je();let be=i(e=>e.isMobile),xe=qe(U,be),Ce=(e??``).trim(),we=R.useMemo(()=>{if(!v||!y)return[];let e=[y.selectedPath,...y.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r);let e=r.replace(/\\/g,`/`),i=e.split(`/`).filter(Boolean).pop()||e,a=e.startsWith(`${v}/`)?e.slice(v.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return le(n,Ce,{limit:6})},[Ce,v,y]),W=R.useMemo(()=>Ce.length>0?O:O.slice(0,2),[O,Ce.length]),G=R.useMemo(()=>r?j({sessions:m,currentSessionId:p,searchQuery:Ce}):[],[m,p,Ce,r]),K=we,q=re;R.useEffect(()=>{let e=e=>{let t=e.target;!t||!U.current||U.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),R.useEffect(()=>{if(!f){E([]);return}let e=(C??``).trim(),t=D(e);if(!t){E([]);return}let n=!1;ce(!0);let r={includeHidden:te,respectGitignore:!ne};return Promise.all([S(f,t,80,{...r,type:`file`}),S(f,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(we.map(e=>e.path));E(ae({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||E([])}).finally(()=>{n||ce(!1)}),()=>{n=!0}},[f,C,we,S,te,ne]),R.useEffect(()=>{let t=b().filter(e=>e.mode&&e.mode!==`primary`).map(e=>({name:e.name,description:e.description,mode:e.mode}));oe(A(t,e??``))},[b,e]),R.useEffect(()=>{L(0),he({}),B({})},[q,K.length,W.length,G.length]),R.useEffect(()=>{ue.current=I},[I]),R.useEffect(()=>{V.current[I]?.scrollIntoView({block:`nearest`})},[I]),R.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};H.current.forEach((n,r)=>{if(!n)return;let i=_e.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}}),he(e),B(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[q,K]),R.useEffect(()=>{let e=H.current[I];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&pe(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[I]);let Te=w(e=>{t(e)}),Ee=w(e=>{n?.(e)}),De=w(e=>{r?.(e)}),Oe=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&ye.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&ye.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(ye.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>ye.current?.pointerCancel(),onClick:()=>{ye.current?.click(t)},onMouseMove:()=>L(e)}),J=e=>{let t=W.length+G.length+K.length+q.length;if(t===0)return;let n=(e%t+t)%t;if(n<W.length){let e=W[n];e&&Ee(e.name);return}let r=n-W.length;if(r<G.length){let e=G[r];e&&De(e);return}let i=r-G.length,a=i<K.length?K[i]:q[i-K.length];a&&Te(a)};R.useEffect(()=>{ke(c,ve,{rows:Se({agents:W,sessions:G,recentFiles:K,pathHits:q,untitledSession:d(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:d(`chat.fileMentionAutocomplete.sessionType`)}),highlightedIndex:I})},[c,I,d,W,q,K,G]);let Y=R.useRef(c);Y.current=c,R.useEffect(()=>()=>{Ae(Y.current,ve)},[]),R.useImperativeHandle(u,()=>({acceptIndex:e=>{J(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=W.length+G.length+K.length+q.length;if(t!==0){if(e===`ArrowDown`){L(e=>(e+1)%t);return}if(e===`ArrowUp`){L(e=>(e-1+t)%t);return}(e===`Enter`||e===`Tab`)&&J(ue.current)}}}),[q,K,W,G,a,Te,Ee,De]);let X=e=>(0,Z.jsx)(F,{name:ge(e),className:`h-3.5 w-3.5 text-current`});return(0,Z.jsxs)(`div`,{ref:U,className:`absolute z-[100] min-w-0 w-full max-w-[640px] max-h-64 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col`,style:xe===void 0?o:{...o,maxHeight:xe},children:[(0,Z.jsx)(fe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,Z.jsxs)(`div`,{className:`pb-2`,children:[W.length>0&&(0,Z.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.agents`)}),W.map((e,t)=>(0,Z.jsx)(`div`,{ref:e=>{V.current[t]=e},className:P(`flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,be&&`min-h-11`,I===t&&`bg-interactive-selection text-interactive-selection-foreground`),...Oe(t,()=>Ee(e.name)),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`font-semibold truncate`,children:[`@`,e.name]}),e.description&&!be?(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:e.description}):null]})},`agent-${e.name}`)),W.length===2&&Ce.length===0&&O.length>2&&(0,Z.jsx)(`div`,{className:`px-3 py-1 typography-meta text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.searchMoreAgents`)}),G.length>0&&(0,Z.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.sessions`)}),G.map((e,t)=>{let n=W.length+t;return(0,Z.jsxs)(`div`,{ref:e=>{V.current[n]=e},className:P(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,be&&`min-h-11`,I===n&&`bg-interactive-selection text-interactive-selection-foreground`),...Oe(n,()=>De(e)),children:[(0,Z.jsx)(F,{name:`chat-thread`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title||d(`chat.fileMentionAutocomplete.untitledSession`),children:e.title||d(`chat.fileMentionAutocomplete.untitledSession`)}),be?null:(0,Z.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.sessionType`)})]},`session-${e.id}`)}),K.length>0&&(0,Z.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.recentFiles`)}),K.map((e,t)=>{let n=W.length+G.length+t,r=e.relativePath||e.name,i=N(r,{maxLength:60}),a=I===n,o=me[n]??!1,s=z[n]??2.6;return(0,Z.jsxs)(`div`,{ref:e=>{V.current[n]=e},className:P(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,be&&`min-h-11`,a&&`bg-interactive-selection text-interactive-selection-foreground`),...Oe(n,()=>Te(e)),children:[X(e),(0,Z.jsxs)(`span`,{ref:e=>{H.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${de}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,Z.jsx)(`span`,{ref:e=>{_e.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,Z.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,Z.jsx)(`span`,{className:`block truncate`,children:i})]})]},`recent-${e.path}`)}),q.length>0&&(0,Z.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.files`)}),q.map((e,t)=>{let n=W.length+G.length+K.length+t,r=e.relativePath||e.name,i=N(r,{maxLength:60}),a=I===n,o=me[n]??!1,s=z[n]??2.6;return(0,Z.jsxs)(`div`,{ref:e=>{V.current[n]=e},className:P(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,be&&`min-h-11`,a&&`bg-interactive-selection text-interactive-selection-foreground`),...Oe(n,()=>Te(e)),children:[X(e),(0,Z.jsxs)(`span`,{ref:e=>{H.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${de}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,Z.jsx)(`span`,{ref:e=>{_e.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,Z.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,Z.jsx)(`span`,{className:`block truncate`,children:i})]})]},e.path)}),se&&q.length===0?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,Z.jsx)(F,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!se&&q.length===0&&K.length===0&&W.length===0&&G.length===0&&(0,Z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.empty`)})]})}),!be&&(0,Z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:d(`chat.autocomplete.keyboardHint`)})]})}),Xe=new Set([`new`,`fork`,`compact`,`undo`,`redo`,`model`,`goal`]),Ze=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Xe.has(n))},Qe=(e,t)=>!e||t({name:e}),$e=` `,et=(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]===$e&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},tt=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,nt=P(tt,`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)]`),rt=P(tt,`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)]`),it=P(tt,`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)]`),at=P(tt,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),ot=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id),st=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!o()}},ct=R.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=ee(),d=i(e=>e.isMobile),f=k(e=>e.currentSessionId),p=k(e=>!!e.newSessionDraft?.open),m=k(R.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=re(f??``,m??void 0),g=R.useMemo(()=>s??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[s,f,h.length,p]),{hasSession:_,canStartSessionCommand:v,canUseReviewHandoffFlow:y}=R.useMemo(()=>st(g,d),[g,d]),b=g.hasMessages,[x,S]=R.useState([]),[C,w]=R.useState(!1),T=te({directory:r}),ne=R.useMemo(()=>T.data??[],[T.data]),E=T.isFetching,ie=ce({directory:r}),ae=R.useMemo(()=>ie.data??[],[ie.data]),[D,O]=R.useState(0),A=R.useRef(0),oe=R.useRef(!1),se=R.useRef([]),j=R.useRef(null),le=qe(j,d),M=R.useRef(!1),N=R.useRef(null),I=R.useRef(!1),L=R.useRef(null);R.useEffect(()=>{let e=e=>{let t=e.target;!t||!j.current||j.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),R.useEffect(()=>{(async()=>{w(E);try{let t=ne.map((e,t)=>({id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,isSkill:e.source===`skill`,scope:e.scope,reference:e.reference})),n=ae.map((e,t)=>({id:`skill:${e.scope}:${e.source??`opencode`}:${e.name}:${t}`,name:e.name,source:`skill`,description:e.description,isSkill:!0,scope:e.scope})),r=[{id:`openchamber:new`,name:`new`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},..._?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...y?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:plan-feature`,name:`plan-feature`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.featurePlanDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[],...t,...n],i=!b,a=Ce(r.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);S(e=>ot(e,a)?e:a)}catch{let t=!b,n=Ce([{id:`openchamber:new`,name:`new`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},..._?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...y?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:plan-feature`,name:`plan-feature`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.featurePlanDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(o?.(e)??!0)),e);S(e=>ot(e,n)?e:n)}finally{w(!1)}})()},[e,b,_,v,y,ne,E,ae,u,o]),R.useEffect(()=>{O(0)},[x]),R.useEffect(()=>{A.current=D},[D]),R.useEffect(()=>{se.current[D]?.scrollIntoView({block:`nearest`})},[D]),R.useEffect(()=>{ke(c,L,{rows:be(x,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:D})},[x,c,D,u]);let ue=R.useRef(c);ue.current=c,R.useEffect(()=>()=>{Ae(ue.current,L)},[]),R.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=x[e];r&&t(r,Ze(r,n))},handleKeyDown:e=>{let r=x.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){oe.current=!0,O(e=>(e+1)%r);return}if(e===`ArrowUp`){oe.current=!0,O(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(A.current%r+r)%r,i=x[n];i&&t(i,Ze(i,e===`Enter`))}}}}),[x,n,t]);let de=e=>{let t=B(e);switch(e.name){case`new`:return(0,Z.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,Z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,Z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,Z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:return(0,Z.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,Z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,Z.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,Z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,Z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,Z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,Z.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,Z.jsxs)(`div`,{ref:j,className:`absolute z-[100] min-w-0 w-full max-w-[450px] max-h-64 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col`,style:le===void 0?a:{...a,maxHeight:le},children:[(0,Z.jsx)(fe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:C?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,Z.jsx)(F,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,Z.jsxs)(`div`,{children:[x.map((e,n)=>{let r=e.isBuiltIn,i=e.isOpenChamber;return(0,Z.jsxs)(`div`,{ref:e=>{se.current[n]=e},className:P(`flex gap-2 px-3 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,n===D&&`bg-interactive-selection`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(N.current={x:e.clientX,y:e.clientY},I.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!N.current)return;let t=e.clientX-N.current.x,n=e.clientY-N.current.y;Math.hypot(t,n)>6&&(I.current=!0)},onPointerUp:n=>{if(n.pointerType!==`touch`)return;let r=I.current;N.current=null,I.current=!1,!r&&(n.preventDefault(),n.stopPropagation(),M.current=!0,t(e,Ze(e,d)))},onPointerCancel:()=>{N.current=null,I.current=!1},onClick:()=>{if(M.current){M.current=!1;return}t(e,Ze(e,d))},onMouseMove:()=>{oe.current=!1,O(n)},children:[(0,Z.jsx)(`div`,{className:P(!d&&`mt-0.5`),children:de(e)}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,e.name]}),e.isSkill?(0,Z.jsx)(`span`,{className:nt,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,Z.jsx)(`span`,{className:nt,children:u(`chat.commandAutocomplete.badge.command`)}),i?(0,Z.jsx)(`span`,{className:at,children:`OpenChamber`}):r?(0,Z.jsx)(`span`,{className:at,children:u(`chat.commandAutocomplete.badge.system`)}):e.scope?(0,Z.jsx)(`span`,{className:e.scope===`project`?it:rt,children:e.scope}):null,e.agent&&(0,Z.jsx)(`span`,{className:at,children:e.agent})]}),e.description&&!d&&(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:e.description})]})]},e.id)}),x.length===0&&(0,Z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,Z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});ct.displayName=`CommandAutocomplete`;function lt(e){return(e.description||e.content).replace(/\s+/g,` `).trim().slice(0,120)}var ut=R.forwardRef((e,t)=>{let n=(0,z.c)(63),{searchQuery:r,onSnippetSelect:a,onClose:o,style:s}=e,{t:c}=ee(),l=R.useRef(null),u=i(dt),d=qe(l,u),[f,p]=R.useState(0),m=R.useRef(0),h;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],n[0]=h):h=n[0];let[g,_]=R.useState(h),v;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],n[1]=v):v=n[1];let y=R.useRef(v),b=pe(ft),x=pe(pt),S=pe(mt),C=pe(ht),w=i(gt),T=i(_t),te,ne;n[2]===x?(te=n[3],ne=n[4]):(te=()=>{x()},ne=[x],n[2]=x,n[3]=te,n[4]=ne),R.useEffect(te,ne);let re,E;n[5]!==r||n[6]!==b?(re=()=>{let e=r.trim();if(!e.length){let e=[...b].sort(vt);_(e),p(+!!e.length);return}let t=se(b,e,yt);t.sort(bt);let n=t.map(xt);_(n),p(+!!n.length)},E=[r,b],n[5]=r,n[6]=b,n[7]=re,n[8]=E):(re=n[7],E=n[8]),R.useEffect(re,E);let ie,ae;n[9]===f?(ie=n[10],ae=n[11]):(ie=()=>{m.current=f,y.current[f]?.scrollIntoView({block:`nearest`})},ae=[f],n[9]=f,n[10]=ie,n[11]=ae),R.useEffect(ie,ae);let D,O;n[12]===o?(D=n[13],O=n[14]):(O=()=>{let e=e=>{let t=e.target;t&&l.current&&!l.current.contains(t)&&o()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},D=[o],n[12]=o,n[13]=D,n[14]=O),R.useEffect(O,D);let k;n[15]!==a||n[16]!==r?(k=e=>{let t=r.trim(),n=e.aliases.includes(t)?t:e.name;a(e,n)},n[15]=a,n[16]=r,n[17]=k):k=n[17];let A=k,oe;n[18]!==o||n[19]!==C||n[20]!==w||n[21]!==T||n[22]!==S||n[23]!==b?(oe=()=>{let e=new Set(b.map(St)),t=`new-snippet`,n=1;for(;e.has(t);)t=`new-snippet-${n++}`;S({name:t,scope:`global`}),C(t),T(`snippets`),w(!0),o()},n[18]=o,n[19]=C,n[20]=w,n[21]=T,n[22]=S,n[23]=b,n[24]=oe):oe=n[24];let j=oe,ce,le;n[25]!==A||n[26]!==g||n[27]!==o||n[28]!==j?(ce=()=>({handleKeyDown:e=>{if(e===`Escape`){o();return}let t=g.length+1;if(e===`ArrowDown`){p(e=>(e+1)%t);return}if(e===`ArrowUp`){p(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){if(m.current===0){j();return}let e=g[m.current-1];e&&A(e)}}}),le=[A,g,o,j],n[25]=A,n[26]=g,n[27]=o,n[28]=j,n[29]=ce,n[30]=le):(ce=n[29],le=n[30]),R.useImperativeHandle(t,ce,le);let M;n[31]!==d||n[32]!==s?(M=d===void 0?s:{...s,maxHeight:d},n[31]=d,n[32]=s,n[33]=M):M=n[33];let N;n[34]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{y.current[0]=e},n[34]=N):N=n[34];let I=f===0&&`bg-interactive-selection`,L;n[35]===I?L=n[36]:(L=P(`flex items-center gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,I),n[35]=I,n[36]=L);let ue,de;n[37]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>p(0),de=(0,Z.jsx)(F,{name:`add`,className:`h-3.5 w-3.5 text-muted-foreground`}),n[37]=ue,n[38]=de):(ue=n[37],de=n[38]);let me;n[39]===c?me=n[40]:(me=c(`chat.snippetAutocomplete.action.addNew`),n[39]=c,n[40]=me);let he;n[41]===me?he=n[42]:(he=(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:me}),n[41]=me,n[42]=he);let B;n[43]!==j||n[44]!==L||n[45]!==he?(B=(0,Z.jsxs)(`div`,{ref:N,className:L,onClick:j,onMouseMove:ue,children:[de,he]}),n[43]=j,n[44]=L,n[45]=he,n[46]=B):B=n[46];let V;n[47]!==A||n[48]!==g||n[49]!==u||n[50]!==f||n[51]!==c?(V=g.length?g.map((e,t)=>(0,Z.jsx)(`div`,{ref:e=>{y.current[t+1]=e},className:P(`flex gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,u?`items-center`:`items-start`,t+1===f&&`bg-interactive-selection`),onClick:()=>A(e),onMouseMove:()=>p(t+1),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`font-semibold truncate`,children:[`#`,e.name]}),(0,Z.jsx)(`span`,{className:`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0 bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`,children:c(`snippets.source.${e.source}`)})]}),!u&&(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:lt(e)})]})},`${e.source}:${e.filePath}`)):(0,Z.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:c(`chat.snippetAutocomplete.empty`)}),n[47]=A,n[48]=g,n[49]=u,n[50]=f,n[51]=c,n[52]=V):V=n[52];let ge;n[53]!==B||n[54]!==V?(ge=(0,Z.jsxs)(fe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:[B,V]}),n[53]=B,n[54]=V,n[55]=ge):ge=n[55];let H;n[56]!==u||n[57]!==c?(H=!u&&(0,Z.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:c(`chat.snippetAutocomplete.footer`)}),n[56]=u,n[57]=c,n[58]=H):H=n[58];let _e;return n[59]!==M||n[60]!==ge||n[61]!==H?(_e=(0,Z.jsxs)(`div`,{ref:l,className:`absolute z-[100] min-w-0 w-full max-w-[450px] max-h-60 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col`,style:M,children:[ge,H]}),n[59]=M,n[60]=ge,n[61]=H,n[62]=_e):_e=n[62],_e});ut.displayName=`SnippetAutocomplete`;function dt(e){return e.isMobile}function ft(e){return e.snippets}function pt(e){return e.loadSnippets}function mt(e){return e.setSnippetDraft}function ht(e){return e.setSelectedSnippet}function gt(e){return e.setSettingsDialogOpen}function _t(e){return e.setSettingsPage}function vt(e,t){return e.source===`project`&&t.source!==`project`?-1:e.source!==`project`&&t.source===`project`?1:e.name.localeCompare(t.name)}function yt(e){return[e.name,...e.aliases]}function bt(e,t){return e.score===t.score?e.item.source===`project`&&t.item.source!==`project`?-1:e.item.source!==`project`&&t.item.source===`project`?1:e.item.name.localeCompare(t.item.name):e.score-t.score}function xt(e){return e.item}function St(e){return e.name}var Ct=2,wt=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Tt=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},Et=e=>wt(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&wt(e.branches),Dt=(e,t)=>JSON.stringify([e,t]),Ot=e=>`version`in e&&e.version===Ct&&wt(e.entries),kt=e=>{if(!e)return null;try{let t=JSON.parse(e);return wt(t)?t.version===Ct&&wt(t.entries)?{version:Ct,entries:t.entries}:t:null}catch{return null}},At=(e,t)=>{try{e.setItem(`oc.gitBranchCache`,JSON.stringify(t))}catch{}},jt=(e,t,n)=>{let r=Tt(e);if(!r||!t)return null;let i;try{i=n.getItem(`oc.gitBranchCache`)}catch{return null}let a=kt(i);if(!a)return null;if(Ot(a))return Et(a.entries[Dt(t,r)])?a.entries[Dt(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=Tt(e);r&&Et(n)&&(o[Dt(t,r)]=n)}return At(n,{version:Ct,entries:o}),o[Dt(t,r)]??null},Mt=(e,t,n,r)=>{let i=Tt(e);if(!i||!t||!Et(n))return;let a=null;try{a=r.getItem(`oc.gitBranchCache`)}catch{return}let o=kt(a);At(r,{version:Ct,entries:{...o&&Ot(o)?o.entries:{},[Dt(t,i)]:n}})},Nt=3e4,Pt=Tt,Ft=(e,t=n())=>c.git.branches(Pt(e),t),It=(e,t=n())=>c.git.remotes(Pt(e),t),Lt=async(e,t,n)=>{n.throwIfAborted();let r=f()?.git,i=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):r?await r.getGitBranches(e,{signal:n}):await b(e,{signal:n});return n.throwIfAborted(),i},Rt=async(e,t,n)=>{n.throwIfAborted();let r=f()?.git,i=t?.getRemotes?await t.getRemotes(e,{signal:n}):r?await r.getRemotes(e,{signal:n}):await v(e,{signal:n});return n.throwIfAborted(),i},zt=(e,t,i=n(),a=r())=>{let o=Pt(e),s=t;return{queryKey:Ft(o,i),queryFn:async({signal:e})=>{if(!o)throw Error(`Git branches require a directory`);let t=await Lt(o,s,e);return Mt(o,i,t,a),t},staleTime:Nt,gcTime:1/0,initialData:()=>jt(o,i,a)??void 0,initialDataUpdatedAt:0}},Bt=(e,t,r=n())=>{let i=Pt(e),a=t;return{queryKey:It(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return Rt(i,a,e)},staleTime:Nt,gcTime:1/0}},Vt=(e,r,i)=>{let a=(0,z.c)(9),o=i===void 0||i,s=R.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=Pt(e),u=C,l=zt(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)},Ht=(e,r,i)=>{let a=(0,z.c)(9),o=i===void 0||i,s=R.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=Pt(e),u=C,l=Bt(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)},Ut=(e,t,r=d,i=n())=>r.fetchQuery(zt(e,t,i)),Wt=(e,t,r=d,i=n())=>r.fetchQuery({...zt(e,t,i),staleTime:0}),Gt=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,Kt=1e4,qt=6e4,Jt=5e3,Yt=3e4,Xt=6e4,Zt=25,Qt=40,$t=2,en=15e3,tn=500,nn=30,rn=20971520,an=new Map,on=new Map,sn=new Map,cn=new Map,ln=new Map,un=(e,t)=>`${t}:${e}`,dn=e=>on.get(e)??0,fn=e=>{let t=dn(e)+1;return on.set(e,t),t},pn=e=>{let t=(sn.get(e)??0)+1;return sn.set(e,t),t},mn=e=>{let t=an.get(e);if(t)return t;let n=new Set;return an.set(e,n),n},Q=()=>({isGitRepo:null,status:null,branches:null,branchesTransportIdentity:null,log:null,identity:null,diffCache:new Map,indexRevision:0,lastRepoCheckAt:0,lastStatusFetch:0,lastStatusChange:0,lastLogFetch:0,lastBranchesFetch:0,lastIdentityFetch:0,logMaxCount:25,isLoadingStatus:!1,isLoadingLog:!1,isLoadingBranches:!1,isLoadingIdentity:!1}),hn=(e,t=nn,n=rn)=>{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},gn=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n){let n=e[r],i=t[r];if(!(!n&&!i)&&(!n||!i||n.insertions!==i.insertions||n.deletions!==i.deletions))return!0}return!1},_n=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,vn=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[];if(n.length!==r.length||e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&_n(e.upstreamComparison,t.upstreamComparison))return!0;let i=new Set(n.map(e=>`${e.path}:${e.index}:${e.working_dir}`));for(let e of r)if(!i.has(`${e.path}:${e.index}:${e.working_dir}`))return!0;return!!(t.diffStats!==void 0&&gn(e.diffStats,t.diffStats))},yn=(e,t)=>{let n=new Set;if(!t)return n;let r=e?.files??[],i=t.files??[],a=new Map(r.map(e=>[e.path,e])),o=new Map(i.map(e=>[e.path,e])),s=new Set([...a.keys(),...o.keys()]);for(let e of s){let t=a.get(e),r=o.get(e);if(!t||!r){n.add(e);continue}if(t.index!==r.index||t.working_dir!==r.working_dir){n.add(e);continue}}if(t.diffStats!==void 0){let r=e?.diffStats??{},i=t.diffStats??{},a=new Set([...Object.keys(r),...Object.keys(i)]);for(let e of a){let t=r[e],a=i[e];if(!t||!a){n.add(e);continue}(t.insertions!==a.insertions||t.deletions!==a.deletions)&&n.add(e)}}return n},bn=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[],i=e=>{let t=e?.trim()??``;return t===`?`?``:t},a=new Map(n.map(e=>[e.path,i(e.index)])),o=new Map(r.map(e=>[e.path,i(e.index)])),s=new Set([...a.keys(),...o.keys()]);for(let e of s)if((a.get(e)??``)!==(o.get(e)??``))return!0;return!1},xn=e=>!e||e.trim().length===0,Sn=e=>(e||``).trim()===`U`,Cn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Sn(t)||Sn(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},wn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Sn(t)||Sn(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Tn=e=>xn(e.index)&&xn(e.working_dir),$=p()(h((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&fn(r),n&&fn(n),n&&!i.has(n)){let t=new Map(i);t.set(n,Q()),e({activeDirectory:n,directories:t})}else e({activeDirectory:n})},getDirectoryState:e=>t().directories.get(e)??null,fetchStatus:async(n,r,i={})=>{let a=i.mode??`full`,o=un(n,a),s=cn.get(o)??(a===`light`?cn.get(un(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=Q(),!a){let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>qt,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(n)),!l){let r=new Map(t().directories),i=r.get(n)??s;return r.set(n,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(n,i.mode?{mode:i.mode}:void 0);if(vn(s.status,u)){c=!0;let r=new Map(t().directories),i=r.get(n)??Q(),s=yn(i.status,u),l=bn(i.status,u),d=new Set((i.status?.files??[]).map(e=>e.path)),f=new Set((u.files??[]).map(e=>e.path)),p=new Map(i.diffCache);for(let e of d)f.has(e)||p.delete(e);for(let e of s)p.delete(e);let m=s.size>0;m&&fn(n);let h={...u,diffStats:u.diffStats===void 0&&i.status?.diffStats!==void 0?i.status.diffStats:u.diffStats,upstreamComparison:u.upstreamComparison===void 0?i.status?.upstreamComparison:u.upstreamComparison};r.set(n,{...i,isGitRepo:!0,status:h,diffCache:p,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:m?Date.now():i.lastStatusChange}),e({directories:r})}else{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isGitRepo:!0,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:i.lastStatusChange}),e({directories:r})}}catch(e){console.error(`Failed to fetch git status:`,e)}finally{if(!a){let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();cn.set(o,c);try{return await c}finally{cn.get(o)===c&&cn.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`?Cn(e):wn(e);t!==e&&(l=!0),Tn(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=pn(r);{let n=new Map(t().directories),i=n.get(r)??Q();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await Wt(r,i,void 0,o):await Ut(r,i,void 0,o);if(s!==sn.get(r)||o!==n())return;let l=new Map(t().directories),u=l.get(r)??Q();l.set(r,{...u,branches:c,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:l})}catch(i){if(Gt(i)||console.error(`Failed to fetch git branches:`,i),s!==sn.get(r)||o!==n())return;let a=new Map(t().directories),c=a.get(r)??Q();a.set(r,{...c,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(n,r,i)=>{let{directories:a}=t(),o=a.get(n),s=i??o?.logMaxCount??25;{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(n,{maxCount:s}),a=new Map(t().directories),o=a.get(n)??Q();a.set(n,{...o,log:i,isLoadingLog:!1,lastLogFetch:Date.now(),logMaxCount:s}),e({directories:a})}catch(r){console.error(`Failed to fetch git log:`,r);let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??Q();r.set(n,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(n),a=new Map(t().directories),o=a.get(n)??Q();a.set(n,{...o,identity:i,isLoadingIdentity:!1,lastIdentityFetch:Date.now()}),e({directories:a})}catch(r){console.error(`Failed to fetch git identity:`,r);let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(n,r,i={})=>{let{directories:a}=t(),o=a.get(n);if(!o){o=Q();let t=new Map(a);t.set(n,o),e({directories:t})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await t().fetchStatus(n,r,{silent:c&&!!o?.status});let u=t().directories.get(n);if(!u?.isGitRepo)return;await t().fetchBranches(n,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>Kt||!u.log)&&await t().fetchLog(n,r),await t().fetchIdentity(n,r)},getDiff:(e,n)=>t().directories.get(e)?.diffCache.get(n)??null,setDiff:(n,r,i)=>{let a=new Map(t().directories),o=a.get(n)??Q(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=hn(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{fn(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,Zt);await t().prefetchDiffs(e,n,i,{maxFiles:Zt})},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=Qt}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=mn(n),d=[],f=new Set;for(let e of i){if(!e||f.has(e)||(f.add(e),!c.has(e))||o.diffCache.has(e)||u.has(e))continue;let t=l?.[e];t&&t.insertions+t.deletions>tn||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=dn(n);if(typeof document<`u`&&document.hidden)return;p.forEach(e=>u.add(e));let h=0,g=[],_=()=>{let e=h;return h+=1,e<p.length?p[e]:null},v=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${en}ms`)),en)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},y=async()=>{for(;;){if(m!==dn(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{u.delete(e)}}},b=Math.min($t,p.length);if(await Promise.allSettled(Array.from({length:b},()=>y())),p.forEach(e=>u.delete(e)),m!==dn(n))return;let x=new Map(t().directories),S=x.get(n);if(!S)return;let C=new Map(S.diffCache),w=Date.now();g.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||C.set(e.path,{...e.diff,fetchedAt:w})});let ee=hn(C);x.set(n,{...S,diffCache:ee}),e({directories:x})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<Jt||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=ln.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)>=Jt)&&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>=Yt)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=Kt)&&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 ln.set(e,i),i.finally(()=>{ln.get(e)===i&&ln.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),En=e=>{let t=(0,z.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status??null:null,t[0]=e,t[1]=n),$(n)},Dn=e=>{let r=(0,z.c)(3),i=R.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],$(a)},On=e=>{let t=(0,z.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.log??null:null,t[0]=e,t[1]=n),$(n)},kn=e=>{let t=(0,z.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isGitRepo??null:null,t[0]=e,t[1]=n),$(n)},An=e=>{let t=(0,z.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status?.current?.trim()??null:null,t[0]=e,t[1]=n),$(n)},jn={current:new Map},Mn=()=>$(Ln),Nn=e=>{let t=(0,z.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=R.useRef(n),i;return t[1]===e?i=t[2]:(i=t=>{let n=r.current,i=n.size===e.length;if(i)for(let r of e){let e=t.directories.get(r),a=n.get(r);if(!a||(e?.isGitRepo??null)!==a.isGitRepo||(e?.status?.current??null)!==a.branch){i=!1;break}}if(i)return n;let a=new Map;for(let n of e){let e=t.directories.get(n);a.set(n,{isGitRepo:e?.isGitRepo??null,branch:e?.status?.current??null})}return r.current=a,a},t[1]=e,t[2]=i),$(i)},Pn=e=>{let t=(0,z.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingStatus??!1:!1,t[0]=e,t[1]=n),$(n)},Fn=e=>{let t=(0,z.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingLog??!1:!1,t[0]=e,t[1]=n),$(n)},In=e=>{let t=(0,z.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),$(n)};function Ln(e){let t=jn.current,n=t.size===e.directories.size;if(n){for(let[r,i]of e.directories)if(t.get(r)!==(i.status?.current??null)){n=!1;break}}if(n)return t;let r=new Map;for(let[t,n]of e.directories)r.set(t,n.status?.current??null);return jn.current=r,r}var Rn=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)}},zn=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),Bn=e=>e.branchName?zn(e.branchName):e.mode===`existing`?zn(e.existingBranch||e.preferredName||``):zn(e.preferredName||``),Vn=async e=>{let t=await me(e);try{let n=Rn((await ue(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=Rn((await de(e)).tracking);if(t?.remote)return t.remote}catch{}return null},Hn=async(e,t)=>{let n=await Vn(e),r=zn(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},Un=async(e,t,n)=>{let r=Bn(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await Hn(e,r):i&&zn(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:zn(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},Wn=async(e,t,n)=>{let r=await Un(e.path,t,n);return he(e,r)},Gn=`oc:lastWorktreeSourceBranch`,Kn=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,qn=({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},Jn=(e,t,n)=>{if(!e)return e;let r=t.length>0&&!/\s$/.test(t)&&!/^\s/.test(e)&&!/[([{]$/.test(t),i=n.length>0&&!/\s$/.test(e)&&!/^\s/.test(n)&&!/^[\])}.,;:!?]/.test(n);return`${r?` `:``}${e}${i?` `:``}`},Yn=(e,t,n)=>{let r=Jn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},Xn=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=Yn(r,i,a),s=Math.max(0,o.indexOf(r)),c=i.length+s;return{text:`${i}${o}${a}`,caret:i.length+o.length,start:c,end:c+r.length}},Zn=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))?[...e]:[...e,t]},Qn=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{qe as A,G as B,Vt as C,et as D,ct as E,ke as F,ye as H,Ae as I,Te as L,Fe as M,Pe as N,Qe as O,Oe as P,K as R,Wt as S,ut as T,xe as V,On as _,Gn as a,$ as b,Wn as c,Mn as d,An as f,Pn as g,Fn as h,Yn as i,Ie as j,Ye as k,Vn as l,In as m,Zn as n,qn as o,Dn as p,Xn as r,Kn as s,Qn as t,Un as u,Nn as v,Ht as w,kn as x,En as y,W as z};
@@ -1,4 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./useUIStore-Wyu09VUF.js";import{Xt as n}from"./persistence-aCOlo6ew.js";import{a as r,r as i}from"./vendor-zustand-B4dlGEM2.js";import{nt as a,rt as o}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as s,Nt as c}from"./platform-ulFAVx1H.js";import{n as l}from"./vendor-react-DLPElpoQ.js";import{n as u}from"./vendor-reactuses-core-DDoDDyM9.js";import{l as d,n as f}from"./clipboard-mffeUZRt.js";import{$a as p,Bn as m,Do as h,Jn as g,Sr as _,Vn as v,Za as y,c as b,ca as x,da as S,ha as C,ir as w,l as T,yr as E}from"./useMobileNavigationStore-BYDKiRu_.js";import{n as D,t as ee}from"./utils-CJdWZupK.js";import{n as O}from"./Icon-Bs6GJIoO.js";import{t as te}from"./button-DfF088a8.js";import{n as ne}from"./gitApi-G_L1y6t4.js";import{C as re,J as ie,O as k,S as ae,W as A,_ as j,a as oe,b as se,g as ce,h as le,i as M,j as ue,k as de,n as N,o as P,p as F,v as fe,x as pe,y as I}from"./projectMeta-CQIQWtbJ.js";import{t as L}from"./input-Ca2tUhgN.js";import{i as R,n as me,t as he}from"./tooltip-GC3dg3gO.js";import{o as ge}from"./OverlayScrollbar-VZKKu-cu.js";import{n as z}from"./useRuntimeAPIs-DSLXJybW.js";import{E as _e,T as ve,a as B,b as V,c as ye,g as H,k as be,l as U,m as W,o as G,p as K,r as xe,x as q}from"./insertionBoundaries-CbvPY1wl.js";import{n as J,r as Se,t as Ce}from"./collapsible-CVL-5iEB.js";var Y=e(o(),1),we=l(),X=/^[a-z0-9](?:[a-z0-9-]{0,48}[a-z0-9])?$/,Z=/^g[1-9]\d*$/,Q=(e,t,n,r,i)=>{if(!X.test(e)||t!==void 0&&!Z.test(t)||!n?.trim()||!r?.trim()||n!==n.trim()||r!==r.trim())return null;if(i===void 0)return{groupSlug:e,runGroup:t,providerID:n,modelID:r,fusion:!1};if(i===`fusion`)return{groupSlug:e,runGroup:t,providerID:n,modelID:r,fusion:!0};if(!/^\d+$/.test(i))return null;let a=Number.parseInt(i,10);return!Number.isSafeInteger(a)||a<=0?null:{groupSlug:e,runGroup:t,providerID:n,modelID:r,index:a,fusion:!1}},Te=e=>{if(!e)return null;let t=e.split(`/`);if(t.length<3||t.length>5)return null;let[n]=t;if(t.length===3)return Q(n,void 0,t[1],t[2],void 0);if(t.length===4){let[,e,r,i]=t;return Z.test(e)?Q(n,e,r,i,void 0):Q(n,void 0,e,r,i)}let[,r,i,a,o]=t;return r===``?Q(n,void 0,i,a,o):Q(n,r,i,a,o)},Ee=e=>{let t=[e.groupSlug];return e.runGroup&&t.push(e.runGroup),t.push(e.providerID,e.modelID),e.index!==void 0&&t.push(String(e.index)),t.join(`/`)},De=(e,t,n,r)=>{let i=[e];return r&&i.push(r),i.push(t,n,`fusion`),i.join(`/`)},Oe=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).substring(0,50),ke=(e,t)=>`${Oe(e)}-${Oe(t)}`.substring(0,60),Ae=(e,t)=>`${e}/${t}`,je=e=>{let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.length>1?t.replace(/\/+$/,``):t},Me=(e,t)=>{let n=je(t),r=e.directory,i=typeof r==`string`&&r.trim().length>0?e:{...e,directory:n};C(e.id,n),T.getState().markSessionAsOpenChamberCreated(e.id),E.getState().upsertSession(i);try{S().ensureChild(n,{bootstrap:!1}).setState(t=>{let n=t.session.findIndex(t=>t.id===e.id);if(n>=0&&t.session[n]===i)return t;let r=n>=0?t.session.map((e,t)=>t===n?i:e):[...t.session,i].sort((e,t)=>e.id.localeCompare(t.id));return{session:r,sessionTotal:Math.max(t.sessionTotal,r.length),limit:Math.max(t.limit,r.length)}})}catch{}return i},Ne=()=>{let e=h.getState(),t=e.activeProjectId;if(!t)return null;let n=e.projects.find(e=>e.id===t);if(n?.path)return{id:n.id,path:n.path};let r=s.getState().currentDirectory??null;if(r&&r.trim().length>0){let e=r.replace(/\\/g,`/`).replace(/\/+$/,``)||r;return{id:`path:${e}`,path:e}}return null},Pe=r()(i(e=>({isLoading:!1,error:null,createMultiRun:async t=>{let n=t.name.trim(),{groups:r,agent:i,files:a,setupCommands:o}=t;if(!n)return e({error:`Group name is required`}),null;if(!r||r.length===0)return e({error:`At least one run group is required`}),null;for(let t=0;t<r.length;t++){if(!r[t].prompt.trim())return e({error:`Group ${t+1}: prompt is required`}),null;if(r[t].models.length<1)return e({error:`Group ${t+1}: select at least 1 model`}),null;if(r[t].models.length>5)return e({error:`Group ${t+1}: maximum 5 models allowed`}),null}e({isLoading:!0,error:null});try{let s=Ne();if(!s)return e({error:`Select a project`,isLoading:!1}),null;let l=s.path,u=await ne(l)&&t.isolateRuns!==!1,d=Oe(n),f=u?await F(l):void 0,p=u?await U(l):null,m=[],h=o?.filter(e=>e.trim().length>0)??[];for(let e=0;e<r.length;e++){let n=r[e],i=n.prompt,a=new Map;for(let e of n.models){let t=`${e.providerID}:${e.modelID}`;a.set(t,(a.get(t)||0)+1)}let o=new Map;for(let g of n.models){let n=`${g.providerID}:${g.modelID}`,_=a.get(n)||1,y=(o.get(n)||0)+1;o.set(n,y);let b=ke(g.providerID,g.modelID),x=r.length>1?`g${e+1}`:void 0,S=_>1?Ae(d,`${b}/${y}`):Ae(d,b),C=x?`${x}/${S}`:S,E=Ee({groupSlug:d,runGroup:x,providerID:g.providerID,modelID:g.modelID,index:_>1?y:void 0});try{if(!u){let e=await c.withDirectory(l,()=>c.createSession({title:E}));Me(e,l),m.push({sessionId:e.id,worktreePath:l,providerID:g.providerID,modelID:g.modelID,variant:g.variant,prompt:i});continue}let e=await ye(s,{preferredName:C,mode:`new`,branchName:C,worktreeName:C,startRef:t.worktreeBaseBranch||`HEAD`,setupCommands:h,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:p}),n={...e,createdFromBranch:f,kind:`standard`};await v(s)&&await w(e.path);let r=await c.withDirectory(e.path,()=>c.createSession({title:E}));Me(r,e.path),T.getState().setWorktreeMetadata(r.id,n),m.push({sessionId:r.id,worktreePath:e.path,providerID:g.providerID,modelID:g.modelID,variant:g.variant,prompt:i})}catch(e){console.warn(`[MultiRun] Failed to create session:`,e)}}}let _=o?.filter(e=>e.trim().length>0)??[];_.length>0&&g(s,_).catch(()=>{console.warn(`[MultiRun] Failed to save worktree setup commands`)});let y=m.map(e=>e.sessionId),x=m[0]?.sessionId??null;if(y.length===0)return e({error:`Failed to create any sessions`,isLoading:!1}),null;let S=a?.map(e=>({type:`file`,mime:e.mime,filename:e.filename,url:e.url}));return(async()=>{try{let e=A.getState().expandText;await Promise.allSettled(m.map(async t=>{try{let n=await e(t.prompt).catch(()=>t.prompt);await b({sessionId:t.sessionId,directory:t.worktreePath,content:n,providerID:t.providerID,modelID:t.modelID,variant:t.variant,agent:i,files:S})}catch(e){console.warn(`[MultiRun] Failed to start run:`,e)}}))}catch(e){console.warn(`[MultiRun] Failed to start runs:`,e)}})(),e({isLoading:!1}),{groupSlug:d,sessionIds:y,firstSessionId:x}}catch(t){return e({error:t instanceof Error?t.message:`Failed to create Multi-Run`,isLoading:!1}),null}},clearError:()=>{e({error:null})}}),{name:`multirun-store`})),$=a(),Fe=`h-7`,Ie=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Le=e=>{let t=(0,we.c)(13),{model:n,instanceIndex:r,totalSameModel:i,onRemove:a}=e,o=n.displayName||`${n.providerID}/${n.modelID}`,s=i>1?`${o} (${r})`:o,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=ee(`flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30`,Fe),t[0]=c):c=t[0];let l;t[1]!==n.modelID||t[2]!==n.providerID?(l=(0,$.jsx)(de,{modelId:n.modelID,providerId:n.providerID,className:`h-3.5 w-3.5`}),t[1]=n.modelID,t[2]=n.providerID,t[3]=l):l=t[3];let u;t[4]===s?u=t[5]:(u=(0,$.jsx)(`span`,{className:`typography-meta font-medium truncate max-w-[140px]`,children:s}),t[4]=s,t[5]=u);let d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(O,{name:`close`,className:`h-3.5 w-3.5`}),t[6]=d):d=t[6];let f;t[7]===a?f=t[8]:(f=(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`text-muted-foreground hover:text-foreground ml-0.5`,children:d}),t[7]=a,t[8]=f);let p;return t[9]!==l||t[10]!==u||t[11]!==f?(p=(0,$.jsxs)(`div`,{className:c,children:[l,u,f]}),t[9]=l,t[10]=u,t[11]=f,t[12]=p):p=t[12],p},Re=e=>{let n=(0,we.c)(131),{selectedModels:r,onAdd:i,onRemove:a,onUpdate:o,minModels:s,addButtonLabel:c,showChips:l,maxModels:u,addButtonClassName:d,dropdownSide:m,dropdownClassName:h,containerClassName:g,triggerIcon:_}=e,v=l===void 0||l,y=m===void 0?`top`:m,{t:b}=f(),S=x(ze),C=x(Be),w=t(Ve),T=t(He),{favoriteModelsList:E,recentModelsList:D}=k(),ne=t(Ue),ie=t(We),[A,j]=Y.useState(!1),[oe,se]=Y.useState(``),[M,ue]=Y.useState(null),de=Y.useRef(null),N=Y.useRef(null),P=u===1,F=u===void 0||r.length<u||P,I;if(n[0]!==r){I=new Map;for(let e of r){let t=`${e.providerID}:${e.modelID}`;I.set(t,(I.get(t)||0)+1)}n[0]=r,n[1]=I}else I=n[1];let L=I,R;n[2]===r?R=n[3]:(R=e=>r.filter(t=>t.providerID===e.providerID&&t.modelID===e.modelID).findIndex(t=>t.instanceId===e.instanceId)+1,n[2]=r,n[3]=R);let me=R,he,ge;n[4]!==y||n[5]!==A?(he=()=>{if(!A||!N.current)return;let e=N.current.getBoundingClientRect();if(y===`bottom`){let t=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-e.bottom-16-112;ue(Math.max(160,Math.min(320,t)));return}let t=N.current.parentElement;for(;t&&!(t.getAttribute(`role`)===`dialog`||t.hasAttribute(`data-scroll-shadow`));){let e=getComputedStyle(t);if(e.overflow===`auto`||e.overflow===`hidden`||e.overflowY===`auto`||e.overflowY===`hidden`)break;t=t.parentElement}let n=t?t.getBoundingClientRect().top:0,r=e.top-n-16;ue(Math.max(150,Math.min(300,r)))},ge=[y,A],n[4]=y,n[5]=A,n[6]=he,n[7]=ge):(he=n[6],ge=n[7]),Y.useEffect(he,ge);let z,_e;n[8]!==F||n[9]!==A?(z=()=>{!F&&A&&(j(!1),se(``))},_e=[F,A],n[8]=F,n[9]=A,n[10]=z,n[11]=_e):(z=n[10],_e=n[11]),Y.useEffect(z,_e);let ve,B;n[12]===A?(ve=n[13],B=n[14]):(ve=()=>{if(!A)return;let e=e=>{de.current&&!de.current.contains(e.target)&&(j(!1),se(``))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},B=[A],n[12]=A,n[13]=ve,n[14]=B),Y.useEffect(ve,B);let V;n[15]!==P||n[16]!==i||n[17]!==o||n[18]!==r.length?(V=e=>{let t={providerID:e.providerID,modelID:e.modelID,displayName:p(e.model,e.modelID)||e.modelID,instanceId:Ie()};P&&r.length>0&&o?o(0,t):i(t),P&&(j(!1),se(``))},n[15]=P,n[16]=i,n[17]=o,n[18]=r.length,n[19]=V):V=n[19];let ye=V,H;n[20]===b?H=n[21]:(H=b(`multirun.modelMultiSelect.search.placeholder`),n[20]=b,n[21]=H);let be;n[22]===b?be=n[23]:(be=b(`multirun.modelMultiSelect.search.noResults`),n[22]=b,n[23]=be);let U;n[24]===b?U=n[25]:(U=b(`multirun.modelMultiSelect.sections.favorites`),n[24]=b,n[25]=U);let W;n[26]===b?W=n[27]:(W=b(`multirun.modelMultiSelect.sections.recent`),n[26]=b,n[27]=W);let G;n[28]===b?G=n[29]:(G=b(`multirun.modelMultiSelect.keyboard.hint`),n[28]=b,n[29]=G);let K;n[30]===b?K=n[31]:(K=b(`settings.agents.modelSelector.actions.favorite`),n[30]=b,n[31]=K);let xe;n[32]===b?xe=n[33]:(xe=b(`settings.agents.modelSelector.actions.unfavorite`),n[32]=b,n[33]=xe);let q;n[34]===b?q=n[35]:(q=b(`chat.modelControls.provider`),n[34]=b,n[35]=q);let J;n[36]===b?J=n[37]:(J=b(`chat.modelControls.capabilities`),n[36]=b,n[37]=J);let Se;n[38]===b?Se=n[39]:(Se=b(`chat.modelControls.capability.toolCalling`),n[38]=b,n[39]=Se);let Ce;n[40]===b?Ce=n[41]:(Ce=b(`chat.modelControls.capability.reasoning`),n[40]=b,n[41]=Ce);let X;n[42]===b?X=n[43]:(X=b(`chat.modelControls.modality.image`),n[42]=b,n[43]=X);let Z;n[44]===b?Z=n[45]:(Z=b(`chat.modelControls.modality.video`),n[44]=b,n[45]=Z);let Q;n[46]===b?Q=n[47]:(Q=b(`chat.modelControls.modality.audio`),n[46]=b,n[47]=Q);let Te;n[48]===b?Te=n[49]:(Te=b(`chat.modelControls.costPerMillion`),n[48]=b,n[49]=Te);let Ee;n[50]===b?Ee=n[51]:(Ee=b(`chat.modelControls.costInput`),n[50]=b,n[51]=Ee);let De;n[52]===b?De=n[53]:(De=b(`chat.modelControls.costOutput`),n[52]=b,n[53]=De);let Oe;n[54]!==H||n[55]!==be||n[56]!==U||n[57]!==W||n[58]!==G||n[59]!==K||n[60]!==xe||n[61]!==q||n[62]!==J||n[63]!==Se||n[64]!==Ce||n[65]!==X||n[66]!==Z||n[67]!==Q||n[68]!==Te||n[69]!==Ee||n[70]!==De?(Oe={searchPlaceholder:H,noResults:be,favorites:U,recent:W,keyboardHint:G,favorite:K,unfavorite:xe,provider:q,capabilities:J,capabilityToolCalling:Se,capabilityReasoning:Ce,modalityImage:X,modalityVideo:Z,modalityAudio:Q,costPerMillion:Te,costInput:Ee,costOutput:De},n[54]=H,n[55]=be,n[56]=U,n[57]=W,n[58]=G,n[59]=K,n[60]=xe,n[61]=q,n[62]=J,n[63]=Se,n[64]=Ce,n[65]=X,n[66]=Z,n[67]=Q,n[68]=Te,n[69]=Ee,n[70]=De,n[71]=Oe):Oe=n[71];let ke=Oe,Ae;n[72]===g?Ae=n[73]:(Ae=ee(`relative`,g),n[72]=g,n[73]=Ae);let je;n[74]===d?je=n[75]:(je=ee(Fe,`!border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70`,d),n[74]=d,n[75]=je);let Me=!F,Ne;n[76]===A?Ne=n[77]:(Ne=()=>{j(!A)},n[76]=A,n[77]=Ne);let Pe;n[78]===_?Pe=n[79]:(Pe=_??(0,$.jsx)(O,{name:`add`,className:`h-3.5 w-3.5 mr-1`}),n[78]=_,n[79]=Pe);let Re;n[80]!==c||n[81]!==b?(Re=c??b(`multirun.modelMultiSelect.actions.addModel`),n[80]=c,n[81]=b,n[82]=Re):Re=n[82];let Ke;n[83]!==je||n[84]!==Me||n[85]!==Ne||n[86]!==Pe||n[87]!==Re?(Ke=(0,$.jsxs)(te,{ref:N,type:`button`,variant:`outline`,size:`sm`,className:je,disabled:Me,onClick:Ne,children:[Pe,Re]}),n[83]=je,n[84]=Me,n[85]=Ne,n[86]=Pe,n[87]=Re,n[88]=Ke):Ke=n[88];let qe;n[89]!==M||n[90]!==F||n[91]!==h||n[92]!==y||n[93]!==E||n[94]!==C||n[95]!==ye||n[96]!==ne||n[97]!==T||n[98]!==A||n[99]!==ke||n[100]!==L||n[101]!==ie||n[102]!==S||n[103]!==D||n[104]!==oe||n[105]!==w?(qe=A?(0,$.jsx)(`div`,{className:ee(`absolute left-0 z-50 w-[min(420px,calc(100vw-2rem))] max-w-[calc(100vw-2rem)] flex flex-col overflow-hidden rounded-xl border border-border/50 shadow-lg`,y===`top`?`bottom-full mb-1`:`top-full mt-1`,h),style:{background:`linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))`},children:(0,$.jsx)(re,{providers:S,providerOrder:ie,favoriteModels:E,recentModels:D,getMetadata:C,hiddenModels:ne,searchQuery:oe,onSearchQueryChange:se,onSelect:ye,labels:ke,selectionCount:e=>L.get(`${e.providerID}:${e.modelID}`)||0,disabled:!F,maxHeightClassName:`flex-1`,maxHeightStyle:{maxHeight:M?`${M}px`:`300px`},stickyHeaders:!0,tooltipsEnabled:A,isFavorite:e=>T(e.providerID,e.modelID),onToggleFavorite:e=>w(e.providerID,e.modelID),onEscape:()=>{j(!1),se(``)}})}):null,n[89]=M,n[90]=F,n[91]=h,n[92]=y,n[93]=E,n[94]=C,n[95]=ye,n[96]=ne,n[97]=T,n[98]=A,n[99]=ke,n[100]=L,n[101]=ie,n[102]=S,n[103]=D,n[104]=oe,n[105]=w,n[106]=qe):qe=n[106];let Je;n[107]!==Ae||n[108]!==Ke||n[109]!==qe?(Je=(0,$.jsxs)(`div`,{className:Ae,ref:de,children:[Ke,qe]}),n[107]=Ae,n[108]=Ke,n[109]=qe,n[110]=Je):Je=n[110];let Ye;n[111]!==me||n[112]!==L||n[113]!==a||n[114]!==o||n[115]!==S||n[116]!==r||n[117]!==v||n[118]!==b?(Ye=v&&r.length>0&&(0,$.jsx)(`div`,{className:`flex flex-col gap-2 w-full`,children:r.map((e,t)=>{let n=`${e.providerID}:${e.modelID}`,r=L.get(n)||1,i=me(e),s=S.find(t=>t.id===e.providerID)?.models?.find(t=>t.id===e.modelID),c=s?.variants?Object.keys(s.variants):[],l=c.length>0,u=e.variant??`__default__`;return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(Le,{model:e,instanceIndex:i,totalSameModel:r,onRemove:()=>a(t)}),l&&(0,$.jsxs)(le,{value:u,onValueChange:n=>{if(!o)return;let r=n===`__default__`?void 0:n;o(t,{...e,variant:r})},children:[(0,$.jsxs)(pe,{size:`chip`,className:`px-2 gap-1.5 rounded-md !border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70 typography-meta font-medium text-foreground`,children:[(0,$.jsx)(O,{name:`brain-ai-3`,className:ee(`h-3.5 w-3.5 flex-shrink-0`,u===`__default__`?`text-muted-foreground`:`text-[color:var(--status-info)]`)}),(0,$.jsx)(ae,{placeholder:b(`multirun.modelMultiSelect.variant.placeholder`),children:e=>e===`__default__`?b(`multirun.modelMultiSelect.variant.default`):e})]}),(0,$.jsxs)(ce,{fitContent:!0,children:[(0,$.jsx)(fe,{value:`__default__`,className:`pr-2 [&>span:first-child]:hidden`,children:b(`multirun.modelMultiSelect.variant.default`)}),c.map(Ge)]})]})]},e.instanceId)})}),n[111]=me,n[112]=L,n[113]=a,n[114]=o,n[115]=S,n[116]=r,n[117]=v,n[118]=b,n[119]=Ye):Ye=n[119];let Xe;n[120]!==Je||n[121]!==Ye?(Xe=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 items-center`,children:[Je,Ye]}),n[120]=Je,n[121]=Ye,n[122]=Xe):Xe=n[122];let Ze;n[123]!==u||n[124]!==s||n[125]!==r.length||n[126]!==b?(Ze=s!==void 0&&r.length<s&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:u===void 0?b(`multirun.modelMultiSelect.validation.minOnly`,{min:s}):b(`multirun.modelMultiSelect.validation.minToMax`,{min:s,max:u})}),n[123]=u,n[124]=s,n[125]=r.length,n[126]=b,n[127]=Ze):Ze=n[127];let Qe;return n[128]!==Xe||n[129]!==Ze?(Qe=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[Xe,Ze]}),n[128]=Xe,n[129]=Ze,n[130]=Qe):Qe=n[130],Qe};function ze(e){return e.providers}function Be(e){return e.getModelMetadata}function Ve(e){return e.toggleFavoriteModel}function He(e){return e.isFavoriteModel}function Ue(e){return e.hiddenModels}function We(e){return e.providerOrder}function Ge(e){return(0,$.jsx)(fe,{value:e,className:`pr-2 [&>span:first-child]:hidden`,children:e},e)}function Ke(e){let t=(0,we.c)(30),{git:n}=z(),r=K(e),i=q(e),a=H(e),o=W(e),s=V(Ze),c=V(Xe),l,u;t[0]!==e||t[1]!==c||t[2]!==n||t[3]!==i||t[4]!==a?(l=()=>{!e||!n||i!==null||a||c(e,n,{silent:!0})},u=[e,n,c,i,a],t[0]=e,t[1]=c,t[2]=n,t[3]=i,t[4]=a,t[5]=l,t[6]=u):(l=t[5],u=t[6]),Y.useEffect(l,u);let d;t[7]!==r?.all||t[8]!==e||t[9]!==s||t[10]!==n||t[11]!==i?(d=()=>{!e||!n||i===!0&&(r?.all||s(e,n))},t[7]=r?.all,t[8]=e,t[9]=s,t[10]=n,t[11]=i,t[12]=d):d=t[12];let f=r?.all,p;t[13]!==e||t[14]!==s||t[15]!==n||t[16]!==i||t[17]!==f?(p=[e,n,i,f,s],t[13]=e,t[14]=s,t[15]=n,t[16]=i,t[17]=f,t[18]=p):p=t[18],Y.useEffect(d,p);let m=a||i===!0&&o,h;bb0:{if(!r?.all){let e;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[19]=e):e=t[19],h=e;break bb0}let e;t[20]===r.all?e=t[21]:(e=r.all.filter(Ye).sort(),t[20]=r.all,t[21]=e),h=e}let g=h,_;bb1:{if(!r?.all){let e;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[22]=e):e=t[22],_=e;break bb1}let e;t[23]===r.all?e=t[24]:(e=r.all.filter(Je).map(qe).sort(),t[23]=r.all,t[24]=e),_=e}let v=_,y;bb2:{if(!e){y=null;break bb2}if(i!==null){y=i;break bb2}if(m){y=null;break bb2}y=r?.all?!0:null}let b=y,x;return t[25]!==b||t[26]!==m||t[27]!==g||t[28]!==v?(x={localBranches:g,remoteBranches:v,isLoading:m,isGitRepository:b},t[25]=b,t[26]=m,t[27]=g,t[28]=v,t[29]=x):x=t[29],x}function qe(e){return e.replace(/^remotes\//,``)}function Je(e){return e.startsWith(`remotes/`)}function Ye(e){return!e.startsWith(`remotes/`)}function Xe(e){return e.fetchStatus}function Ze(e){return e.fetchBranches}var Qe=({directory:e,value:t,onChange:n,className:r,disabled:i,id:a})=>{let{t:o}=f(),{localBranches:s,remoteBranches:c,isLoading:l,isGitRepository:u}=Ke(e),d=Y.useMemo(()=>[...s,...c.map(e=>`remotes/${e}`)],[s,c]);return Y.useEffect(()=>{if(i||l||d.length===0||t&&d.includes(t))return;let r=t,a=!1;return(async()=>{try{let t=e?await F(e).catch(()=>null):null;if(a)return;let i=localStorage.getItem(B),{sourceBranch:o,shouldClearSavedSourceBranch:s}=G({branches:d,savedSourceBranch:i,rootBranch:t});if(s&&localStorage.removeItem(B),a||r&&d.includes(r))return;o&&n(o)}catch{}})(),()=>{a=!0}},[d,e,i,l,n,t]),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(le,{value:t,onValueChange:n,disabled:i||!u||l,children:[(0,$.jsx)(pe,{id:a,size:`lg`,className:r??`w-fit typography-meta text-foreground`,children:(0,$.jsx)(ae,{placeholder:o(l?`multiRun.branchSelector.status.loadingBranches`:`multiRun.branchSelector.placeholder.selectSourceBranch`)})}),(0,$.jsx)(ce,{className:`max-h-[280px] max-w-[320px]`,children:l?(0,$.jsx)(`div`,{className:`px-2 py-4 text-center typography-meta text-muted-foreground`,children:o(`multiRun.branchSelector.status.loadingBranches`)}):s.length===0&&c.length===0?(0,$.jsx)(`div`,{className:`px-2 py-4 text-center typography-meta text-muted-foreground`,children:o(`multiRun.branchSelector.status.noBranchesFound`)}):(0,$.jsxs)($.Fragment,{children:[s.length>0&&(0,$.jsxs)(j,{children:[(0,$.jsx)(I,{className:`font-semibold text-foreground`,children:o(`multiRun.branchSelector.groups.localBranches`)}),s.map(e=>(0,$.jsx)(fe,{value:e,className:`whitespace-normal break-all`,children:e},e))]}),s.length>0&&c.length>0&&(0,$.jsx)(se,{}),c.length>0&&(0,$.jsxs)(j,{children:[(0,$.jsx)(I,{className:`font-semibold text-foreground`,children:o(`multiRun.branchSelector.groups.remoteBranches`)}),c.map(e=>(0,$.jsx)(fe,{value:`remotes/${e}`,className:`whitespace-normal break-all`,children:e},`remotes/${e}`))]})]})})]}),u===!1&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/70 mt-2`,children:o(`multiRun.branchSelector.status.notInGitRepository`)})]})},$e=e=>{let t=(0,we.c)(36),{value:n,onChange:r,className:i,disabled:a,id:o,portalToBody:s}=e,{t:c}=f(),l=x(et),u=x(tt),d=x(nt),p;t[0]===l?p=t[1]:(p=l(),t[0]=l,t[1]=p);let m=p,h;t[2]===m?h=t[3]:(h=m.filter(rt),t[2]=m,t[3]=h);let g=h,_,v;t[4]!==m.length||t[5]!==u?(_=()=>{m.length===0&&u()},v=[m.length,u],t[4]=m.length,t[5]=u,t[6]=_,t[7]=v):(_=t[6],v=t[7]),Y.useEffect(_,v);let y,b;t[8]!==d||t[9]!==a||t[10]!==r||t[11]!==g||t[12]!==n?(y=()=>{if(a)return;let e=n.trim();if(e.length>0&&g.some(t=>t.name===e))return;let t=typeof d==`string`&&d.trim().length>0?d.trim():null;if(t&&g.some(e=>e.name===t)){r(t);return}let i=g[0]?.name;i&&r(i)},b=[d,a,r,g,n],t[8]=d,t[9]=a,t[10]=r,t[11]=g,t[12]=n,t[13]=y,t[14]=b):(y=t[13],b=t[14]),Y.useEffect(y,b);let S=n.trim().length>0?n:void 0,C;t[15]===i?C=t[16]:(C=ee(`max-w-full typography-meta text-foreground !border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70 data-[popup-open]:!bg-[var(--interactive-active)]/70`,i),t[15]=i,t[16]=C);let w;t[17]===c?w=t[18]:(w=c(`multirun.agentSelector.placeholder`),t[17]=c,t[18]=w);let T;t[19]===w?T=t[20]:(T=(0,$.jsx)(ae,{placeholder:w}),t[19]=w,t[20]=T);let E;t[21]!==o||t[22]!==C||t[23]!==T?(E=(0,$.jsx)(pe,{id:o,size:`lg`,className:C,children:T}),t[21]=o,t[22]=C,t[23]=T,t[24]=E):E=t[24];let D;t[25]===g?D=t[26]:(D=g.length>0&&(0,$.jsx)(j,{children:g.map(it)}),t[25]=g,t[26]=D);let O;t[27]!==s||t[28]!==D?(O=(0,$.jsx)(ce,{fitContent:!0,portalToBody:s,children:D}),t[27]=s,t[28]=D,t[29]=O):O=t[29];let te;return t[30]!==a||t[31]!==r||t[32]!==S||t[33]!==E||t[34]!==O?(te=(0,$.jsxs)(le,{value:S,onValueChange:r,disabled:a,children:[E,O]}),t[30]=a,t[31]=r,t[32]=S,t[33]=E,t[34]=O,t[35]=te):te=t[35],te};function et(e){return e.getVisibleAgents}function tt(e){return e.loadAgents}function nt(e){return e.currentAgentName}function rt(e){return y(e.mode)}function it(e){return(0,$.jsx)(fe,{value:e.name,className:`w-auto whitespace-nowrap`,children:e.name},e.name)}var at=10485760,ot=5,st=e=>{let t=(0,we.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,tabIndex:-1,className:`inline-flex items-center justify-center text-muted-foreground/50 hover:text-muted-foreground transition-colors`,children:(0,$.jsx)(O,{name:`information`,className:`h-3.5 w-3.5`})})}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsxs)(he,{children:[r,(0,$.jsx)(me,{side:`top`,className:`max-w-[240px]`,children:n})]}),t[1]=n,t[2]=i),i},ct=e=>{let t=(0,we.c)(9),{htmlFor:n,required:r,children:i,info:a}=e,o;t[0]===r?o=t[1]:(o=r&&(0,$.jsx)(`span`,{className:`text-destructive ml-0.5`,children:`*`}),t[0]=r,t[1]=o);let s;t[2]!==i||t[3]!==n||t[4]!==o?(s=(0,$.jsxs)(`label`,{htmlFor:n,className:`typography-meta font-medium text-foreground`,children:[i,o]}),t[2]=i,t[3]=n,t[4]=o,t[5]=s):s=t[5];let c=a&&a,l;return t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8],l},lt=e=>{let t=D(e.path),n=e.icon?M[e.icon]:null,r=e.color?N[e.color]:void 0,i=(0,$.jsx)(O,{name:n??`folder`,className:`h-3.5 w-3.5`,style:r?{color:r}:void 0});return(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,children:e.iconImage?(0,$.jsx)(oe,{project:e,className:`size-full object-contain`,fallback:i}):i}),(0,$.jsx)(`span`,{className:`truncate`,children:t})]})},ut=({initialPrompt:e,onCreated:t,onCancel:r,isWindowed:i=!1})=>{let{t:a}=f(),[o,c]=Y.useState(``),[l,p]=Y.useState(()=>[{id:Ie(),prompt:``,models:[]}]),[g,v]=Y.useState(``),[y,b]=Y.useState([]),[x,S]=Y.useState(!1),[C,w]=Y.useState([]),[E,D]=Y.useState(!1),[ne,re]=Y.useState(!1),[k,A]=Y.useState(!0),j=Y.useRef(null),oe=s(e=>e.currentDirectory??null),se=Y.useMemo(()=>{if(typeof window>`u`)return null;let e=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof e==`string`&&e.trim().length>0?e.trim():null},[]),M=h(e=>e.activeProjectId),de=h(e=>e.setActiveProjectIdOnly),N=h(e=>e.projects),[P,F]=Y.useState(()=>M??null);Y.useEffect(()=>{if(M){F(M);return}!P&&N.length>0&&F(N[0].id)},[M,N,P]);let I=Y.useMemo(()=>P?N.find(e=>e.id===P)??null:null,[N,P]),z=I?.path??oe,_e=u(e=>{F(e),e!==M&&de(e)}),ve=Y.useMemo(()=>{if(I?.path)return{id:I.id,path:I.path};let e=oe??se;return e?{id:`path:${e}`,path:e}:null},[I,oe,se]),[B]=Y.useState(()=>typeof window<`u`&&n()),V=Y.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),ye=ge(),H=Y.useMemo(()=>{if(typeof window>`u`)return null;let e=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof navigator>`u`)return null;let t=(navigator.userAgent||``).match(/Mac OS X (\d+)[._](\d+)/);if(!t)return null;let n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10);return Number.isNaN(n)?null:n===10?r:n},[]),be=Y.useMemo(()=>B&&V||ye?`pl-[5.5rem]`:`pl-3`,[B,V,ye]),U=Y.useMemo(()=>!B||!V||H===null?``:H>=26?`h-12`:H<=15?`h-14`:``,[B,V,H]),W=u(async e=>{e.target.closest(`button, a, input, select, textarea`)||e.button===0&&B&&await d()}),G=u(e=>{r&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),r())}),K=!!r;Y.useEffect(()=>{if(K)return window.addEventListener(`keydown`,G,!0),()=>window.removeEventListener(`keydown`,G,!0)},[K]);let[xe,q]=Y.useState(``),{isLoading:we,isGitRepository:X}=Ke(z),Z=Y.useRef(!1),Q=X===!0,Te=Q&&k;Y.useEffect(()=>{if(X===!1){Z.current=!0,A(!1);return}X===!0&&Z.current&&(Z.current=!1,A(!0))},[X]);let Ee=Pe(e=>e.createMultiRun),De=Pe(e=>e.error),Oe=Pe(e=>e.clearError);Y.useEffect(()=>{typeof e==`string`&&e.trim().length>0&&p(t=>{let n=[...t];return n.length>0&&!n[0].prompt.trim()&&(n[0]={...n[0],prompt:e}),n})},[e]),Y.useEffect(()=>{if(!ve)return;let e=!1;return re(!0),(async()=>{try{let t=await m(ve);e||w(t)}catch{}finally{e||re(!1)}})(),()=>{e=!0}},[ve]);let ke=u((e,t)=>{p(n=>n.map(n=>n.id===e?{...n,...t}:n))}),Ae=u(e=>{p(t=>t.filter(t=>t.id!==e))}),je=u(()=>{p(e=>[...e,{id:Ie(),prompt:``,models:[]}])}),Me=async e=>{let t=e.target.files;if(!t)return;let n=0;for(let e=0;e<t.length;e++){let r=t[e];if(r.size>at){_.error(a(`multirun.launcher.toast.fileTooLarge`,{fileName:r.name}));continue}try{let e=await new Promise((e,t)=>{let n=new FileReader;n.onload=()=>e(n.result),n.onerror=t,n.readAsDataURL(r)});b(t=>[...t,{id:Ie(),filename:r.name,mimeType:r.type||`application/octet-stream`,size:r.size,dataUrl:e}]),n++}catch(e){console.error(`File attach failed`,e),_.error(a(`multirun.launcher.toast.attachFailed`,{fileName:r.name}))}}n>0&&_.success(a(n===1?`multirun.launcher.toast.attachedSingle`:`multirun.launcher.toast.attachedPlural`,{count:n})),j.current&&(j.current.value=``)},Ne=e=>{b(t=>t.filter(t=>t.id!==e))},Fe=Y.useMemo(()=>l.reduce((e,t)=>e+t.models.length,0),[l]),Le=async e=>{e.preventDefault();let n=l.filter(e=>e.prompt.trim()&&e.models.length>=1);if(n.length!==0&&!(Fe<1)){S(!0),Oe();try{P&&P!==M&&de(P);let e=y.map(e=>({mime:e.mimeType,filename:e.filename,url:e.dataUrl})),r=C.filter(e=>e.trim().length>0),i=n.map(e=>({prompt:e.prompt.trim(),models:e.models.map(e=>({providerID:e.providerID,modelID:e.modelID,displayName:e.displayName,variant:e.variant}))})),a={name:o.trim(),groups:i,agent:g||void 0,worktreeBaseBranch:Te?xe:void 0,isolateRuns:Te,files:e.length>0?e:void 0,setupCommands:r.length>0?r:void 0},s=await Ee(a);s&&(s.firstSessionId&&T.getState().setCurrentSession(s.firstSessionId),t?.())}finally{S(!1)}}},Re=!!(o.trim()&&l.some(e=>e.prompt.trim()&&e.models.length>=1)&&Fe>=1&&z&&!we&&(X===!1||!Te||xe)),ze=C.filter(e=>e.trim()).length;return(0,$.jsxs)(`form`,{onSubmit:Le,className:`flex flex-col h-full bg-background`,children:[i?null:(0,$.jsxs)(`header`,{onMouseDown:W,className:ee(`relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none`,be,U),style:{borderColor:`var(--interactive-border)`},children:[(0,$.jsx)(`h1`,{className:`typography-ui-label font-medium`,children:a(`multirun.launcher.title`)}),r&&(0,$.jsx)(`div`,{className:`absolute right-0 flex items-center pr-3`,children:(0,$.jsxs)(he,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:r,"aria-label":a(`multirun.launcher.actions.closeEsc`),className:`inline-flex h-9 w-9 items-center justify-center p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary app-region-no-drag`,children:(0,$.jsx)(O,{name:`close`,className:`h-5 w-5`})})}),(0,$.jsx)(me,{children:(0,$.jsx)(`p`,{children:a(`multirun.launcher.actions.closeEsc`)})})]})})]}),(0,$.jsx)(ue,{className:`flex-1 min-h-0 overflow-auto`,size:64,hideTopShadow:!0,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-2xl px-4 sm:px-6 py-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(ct,{htmlFor:`multirun-project`,required:!0,children:a(`multirun.launcher.project.label`)}),N.length>0?(0,$.jsxs)(le,{value:P??void 0,onValueChange:_e,children:[(0,$.jsx)(pe,{id:`multirun-project`,size:`lg`,className:`w-fit max-w-full`,children:I?(0,$.jsx)(ae,{children:lt(I)}):(0,$.jsx)(ae,{placeholder:a(`multirun.launcher.project.placeholder`)})}),(0,$.jsx)(ce,{fitContent:!0,children:N.map(e=>(0,$.jsx)(fe,{value:e.id,className:`max-w-[24rem]`,children:lt(e)},e.id))})]}):(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground py-2`,children:a(`multirun.launcher.project.empty`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(ct,{htmlFor:`group-name`,required:!0,info:(0,$.jsx)(st,{children:a(`multirun.launcher.groupName.info`)}),children:a(`multirun.launcher.groupName.label`)}),(0,$.jsx)(L,{id:`group-name`,value:o,onChange:e=>c(e.target.value),placeholder:a(`multirun.launcher.groupName.placeholder`),className:`typography-meta w-full`,required:!0})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(ct,{htmlFor:`multirun-worktree-base-branch`,info:(0,$.jsx)(st,{children:a(`multirun.launcher.baseBranch.info`)}),children:a(`multirun.launcher.baseBranch.label`)}),(0,$.jsx)(Qe,{directory:z,value:xe,onChange:q,disabled:!Te,id:`multirun-worktree-base-branch`}),(0,$.jsxs)(`label`,{className:`mt-1.5 flex w-fit items-center gap-1.5 typography-micro text-muted-foreground`,children:[(0,$.jsx)(ie,{checked:k,onChange:A,disabled:!Q,ariaLabel:a(`multirun.launcher.isolateRuns.label`)}),(0,$.jsx)(`span`,{children:a(`multirun.launcher.isolateRuns.label`)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(ct,{htmlFor:`multirun-agent`,info:(0,$.jsx)(st,{children:a(`multirun.launcher.agent.info`)}),children:a(`multirun.launcher.agent.label`)}),(0,$.jsx)($e,{value:g,onChange:v,id:`multirun-agent`})]})]}),(0,$.jsxs)(Ce,{open:E,onOpenChange:D,children:[(0,$.jsxs)(Se,{className:`w-full flex items-center gap-2 py-1.5 px-2 -mx-2 rounded-lg hover:bg-[var(--interactive-hover)]/50 transition-colors group`,children:[(0,$.jsx)(O,{name:`terminal`,className:`h-3.5 w-3.5 text-muted-foreground/70`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-muted-foreground group-hover:text-foreground transition-colors`,children:a(`multirun.launcher.setupCommands.label`)}),ze>0&&(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center h-4 min-w-4 px-1 rounded-full typography-micro font-medium`,style:{backgroundColor:`var(--primary-base)`,color:`var(--primary-foreground)`,fontSize:`0.625rem`,lineHeight:1},children:ze}),(0,$.jsx)(O,{name:`arrow-down-s`,className:ee(`h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto`,E&&`rotate-180`)})]}),(0,$.jsx)(J,{children:(0,$.jsx)(`div`,{className:`pt-2 space-y-1.5`,children:ne?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/70 px-2`,children:a(`multirun.launcher.setupCommands.loading`)}):(0,$.jsxs)($.Fragment,{children:[C.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsx)(L,{value:e,onChange:e=>{let n=[...C];n[t]=e.target.value,w(n)},placeholder:a(`multirun.launcher.setupCommands.commandPlaceholder`),className:`h-8 flex-1 font-mono text-xs`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>w(C.filter((e,n)=>n!==t)),className:`flex-shrink-0 flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":a(`multirun.launcher.setupCommands.removeCommandAria`),children:(0,$.jsx)(O,{name:`close`,className:`h-3.5 w-3.5`})})]},`${e}-${t}`)),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>w([...C,``]),className:`flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1`,children:[(0,$.jsx)(O,{name:`add`,className:`h-3 w-3`}),a(`multirun.launcher.setupCommands.addCommand`)]})]})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(ct,{htmlFor:`prompt`,required:!0,children:a(`multirun.launcher.attachments.label`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,$.jsx)(`input`,{ref:j,type:`file`,multiple:!0,className:`hidden`,onChange:Me,accept:`*/*`}),(0,$.jsxs)(he,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>j.current?.click(),className:`inline-flex items-center gap-1 h-6 px-2 rounded-md typography-micro text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(O,{name:`attachment-2`,className:`h-3 w-3`}),a(`multirun.launcher.attachments.attach`)]})}),(0,$.jsx)(me,{children:a(`multirun.launcher.attachments.tooltip`)})]}),y.map(e=>(0,$.jsxs)(`div`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md typography-micro border`,style:{backgroundColor:`var(--surface-elevated)`,borderColor:`var(--interactive-border)`},children:[e.mimeType.startsWith(`image/`)?(0,$.jsx)(O,{name:`file-image`,className:`h-3 w-3 text-muted-foreground`}):(0,$.jsx)(O,{name:`file`,className:`h-3 w-3 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate max-w-[100px]`,title:e.filename,children:e.filename}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>Ne(e.id),className:`text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(O,{name:`close`,className:`h-3 w-3`})})]},e.id))]})]}),l.map((e,t)=>(0,$.jsx)(dt,{group:e,groupIndex:t,canRemove:l.length>1,onUpdate:ke,onRemove:Ae},e.id)),(0,$.jsxs)(`button`,{type:`button`,onClick:je,className:`flex items-center gap-1.5 py-2 px-3 -mx-3 rounded-lg typography-meta font-medium text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(O,{name:`add`,className:`h-3.5 w-3.5`}),a(`multirun.launcher.groups.addGroup`)]}),De&&(0,$.jsx)(`div`,{className:`px-3 py-2 rounded-lg typography-meta`,style:{backgroundColor:`var(--status-error-background)`,color:`var(--status-error)`,borderWidth:1,borderColor:`var(--status-error-border)`},children:De})]})})}),(0,$.jsx)(`div`,{className:`shrink-0 px-4 sm:px-6 py-3`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl flex items-center justify-end gap-2`,children:[!Te&&X!==null?(0,$.jsxs)(`div`,{className:`mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground`,children:[(0,$.jsx)(O,{name:`information`,className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:a(`multirun.launcher.project.gitRequired`)})]}):null,(0,$.jsx)(te,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,children:a(`multirun.launcher.actions.cancel`)}),(0,$.jsx)(te,{type:`submit`,size:`sm`,disabled:!Re||x,children:x?a(`multirun.launcher.actions.creating`):(0,$.jsx)($.Fragment,{children:a(`multirun.launcher.actions.startWithRunCount`,{count:Fe})})})]})})]})},dt=e=>{let t=(0,we.c)(104),{group:n,groupIndex:r,canRemove:i,onUpdate:a,onRemove:o}=e,{t:s}=f(),[c,l]=Y.useState(!1),[d,p]=Y.useState(``),[m,h]=Y.useState(!1),[g,_]=Y.useState(``),[v,y]=Y.useState(!1),[b,x]=Y.useState(``),S=Y.useRef(null),C=Y.useRef(null),w=Y.useRef(null),T=Y.useRef(null),E;t[0]!==n.id||t[1]!==n.models||t[2]!==a?(E=e=>{n.models.length>=ot||a(n.id,{models:[...n.models,e]})},t[0]=n.id,t[1]=n.models,t[2]=a,t[3]=E):E=t[3];let D=u(E),ee;t[4]!==n.id||t[5]!==n.models||t[6]!==a?(ee=e=>{a(n.id,{models:n.models.filter((t,n)=>n!==e)})},t[4]=n.id,t[5]=n.models,t[6]=a,t[7]=ee):ee=t[7];let te=u(ee),ne;t[8]!==n.id||t[9]!==n.models||t[10]!==a?(ne=(e,t)=>{a(n.id,{models:n.models.map((n,r)=>r===e?t:n)})},t[8]=n.id,t[9]=n.models,t[10]=a,t[11]=ne):ne=t[11];let re=u(ne),ie;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(e,t)=>{if(e.startsWith(`/`)){let n=e.indexOf(` `),r=e.indexOf(`
2
- `),i=Math.min(n===-1?e.length:n,r===-1?e.length:r);if(t<=i&&n===-1){_(e.substring(1,i)),h(!0),l(!1),y(!1);return}}h(!1);let n=e.substring(0,t),r=n.lastIndexOf(`#`);if(r!==-1){let e=r>0?n[r-1]:null,t=n.substring(r+1);if((!e||/\s/.test(e))&&!t.includes(` `)&&!t.includes(`
3
- `)){x(t),y(!0),l(!1);return}}y(!1);let i=n.lastIndexOf(`@`);if(i!==-1){let e=i>0?n[i-1]:null,t=n.substring(i+1);(!e||/\s/.test(e))&&!t.includes(` `)&&!t.includes(`
4
- `)?(p(t),l(!0)):l(!1);return}l(!1)},t[12]=ie):ie=t[12];let k=u(ie),ae;t[13]!==n.id||t[14]!==a?(ae=e=>{a(n.id,{prompt:e})},t[13]=n.id,t[14]=a,t[15]=ae):ae=t[15];let A=u(ae),j;t[16]!==n.prompt||t[17]!==A||t[18]!==k?(j=e=>{let t=n.prompt,r=S.current?.selectionStart??t.length,i=t.substring(0,r).lastIndexOf(`@`),a=e.relativePath&&e.relativePath.trim().length>0?e.relativePath.trim():e.path||e.name,o=xe(t,i===-1?r:i,r,`@${a}`);A(o.text),l(!1),p(``),requestAnimationFrame(()=>{let e=S.current;e&&(e.selectionStart=o.caret,e.selectionEnd=o.caret,e.focus()),k(o.text,o.caret)})},t[16]=n.prompt,t[17]=A,t[18]=k,t[19]=j):j=t[19];let oe=u(j),se;t[20]!==n.prompt||t[21]!==A||t[22]!==k?(se=e=>{let t=n.prompt,r=S.current?.selectionStart??t.length,i=t.substring(0,r).lastIndexOf(`@`),a=xe(t,i===-1?r:i,r,`@${e}`);A(a.text),l(!1),p(``),requestAnimationFrame(()=>{let e=S.current;e&&(e.selectionStart=a.caret,e.selectionEnd=a.caret,e.focus()),k(a.text,a.caret)})},t[20]=n.prompt,t[21]=A,t[22]=k,t[23]=se):se=t[23];let ce=u(se),le;t[24]!==A||t[25]!==k?(le=e=>{let t=`/${e.name} `;A(t),h(!1),_(``),y(!1),requestAnimationFrame(()=>{let e=S.current;e&&(e.focus(),e.selectionStart=e.value.length,e.selectionEnd=e.value.length),k(t,t.length)})},t[24]=A,t[25]=k,t[26]=le):le=t[26];let M=u(le),ue;t[27]!==n.prompt||t[28]!==A||t[29]!==k?(ue=(e,t)=>{let r=n.prompt,i=S.current?.selectionStart??r.length,a=r.substring(0,i).lastIndexOf(`#`),o=a===-1?i:a,s=`${r.substring(0,o)}#${t} ${r.substring(i)}`,c=o+t.length+2;A(s),y(!1),x(``),requestAnimationFrame(()=>{let e=S.current;e&&(e.selectionStart=c,e.selectionEnd=c,e.focus()),k(s,c)})},t[27]=n.prompt,t[28]=A,t[29]=k,t[30]=ue):ue=t[30];let de=u(ue),N;t[31]!==m||t[32]!==c||t[33]!==v?(N=e=>{if(m&&w.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)){e.preventDefault(),w.current.handleKeyDown(e.key);return}c&&C.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),C.current.handleKeyDown(e.key)),v&&T.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),T.current.handleKeyDown(e.key))},t[31]=m,t[32]=c,t[33]=v,t[34]=N):N=t[34];let F=u(N),fe=r+1,pe;t[35]!==s||t[36]!==fe?(pe=s(`multirun.launcher.groups.groupLabel`,{index:fe}),t[35]=s,t[36]=fe,t[37]=pe):pe=t[37];let I;t[38]===pe?I=t[39]:(I=(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:pe}),t[38]=pe,t[39]=I);let L;t[40]!==i||t[41]!==n.id||t[42]!==o||t[43]!==s?(L=i&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(n.id),className:`inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10`,"aria-label":s(`multirun.launcher.groups.removeGroup`),children:(0,$.jsx)(O,{name:`close`,className:`h-3.5 w-3.5`})}),t[40]=i,t[41]=n.id,t[42]=o,t[43]=s,t[44]=L):L=t[44];let R;t[45]!==I||t[46]!==L?(R=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[I,L]}),t[45]=I,t[46]=L,t[47]=R):R=t[47];let me;t[48]===s?me=t[49]:(me=s(`multirun.launcher.groups.prompt.label`),t[48]=s,t[49]=me);let he;t[50]===me?he=t[51]:(he=(0,$.jsx)(ct,{required:!0,children:me}),t[50]=me,t[51]=he);let ge=n.prompt,z;t[52]!==A||t[53]!==k?(z=e=>{let t=e.target.value;A(t);let n=e.target.selectionStart??t.length;k(t,n)},t[52]=A,t[53]=k,t[54]=z):z=t[54];let B;t[55]===s?B=t[56]:(B=s(`multirun.launcher.groups.prompt.placeholder`),t[55]=s,t[56]=B);let V;t[57]!==n.prompt||t[58]!==F||t[59]!==z||t[60]!==B?(V=(0,$.jsx)(P,{ref:S,value:ge,onChange:z,onKeyDown:F,placeholder:B,className:`typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content`,required:!0}),t[57]=n.prompt,t[58]=F,t[59]=z,t[60]=B,t[61]=V):V=t[61];let ye;t[62]!==g||t[63]!==M||t[64]!==m?(ye=m?(0,$.jsx)(_e,{ref:w,searchQuery:g,onCommandSelect:M,onClose:()=>h(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[62]=g,t[63]=M,t[64]=m,t[65]=ye):ye=t[65];let H;t[66]!==ce||t[67]!==oe||t[68]!==d||t[69]!==c?(H=c?(0,$.jsx)(be,{ref:C,searchQuery:d,onFileSelect:oe,onAgentSelect:ce,onClose:()=>l(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[66]=ce,t[67]=oe,t[68]=d,t[69]=c,t[70]=H):H=t[70];let U;t[71]!==de||t[72]!==v||t[73]!==b?(U=v?(0,$.jsx)(ve,{ref:T,searchQuery:b,onSnippetSelect:de,onClose:()=>y(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[71]=de,t[72]=v,t[73]=b,t[74]=U):U=t[74];let W;t[75]!==V||t[76]!==ye||t[77]!==H||t[78]!==U?(W=(0,$.jsxs)(`div`,{className:`relative`,children:[V,ye,H,U]}),t[75]=V,t[76]=ye,t[77]=H,t[78]=U,t[79]=W):W=t[79];let G;t[80]!==he||t[81]!==W?(G=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[he,W]}),t[80]=he,t[81]=W,t[82]=G):G=t[82];let K;t[83]===s?K=t[84]:(K=s(`multirun.launcher.models.info`,{max:ot}),t[83]=s,t[84]=K);let q;t[85]===K?q=t[86]:(q=(0,$.jsx)(st,{children:K}),t[85]=K,t[86]=q);let J;t[87]===s?J=t[88]:(J=s(`multirun.launcher.models.label`),t[87]=s,t[88]=J);let Se;t[89]!==q||t[90]!==J?(Se=(0,$.jsx)(ct,{required:!0,info:q,children:J}),t[89]=q,t[90]=J,t[91]=Se):Se=t[91];let Ce;t[92]!==n.models||t[93]!==D||t[94]!==te||t[95]!==re?(Ce=(0,$.jsx)(Re,{selectedModels:n.models,onAdd:D,onRemove:te,onUpdate:re,minModels:1,maxModels:ot}),t[92]=n.models,t[93]=D,t[94]=te,t[95]=re,t[96]=Ce):Ce=t[96];let X;t[97]!==Se||t[98]!==Ce?(X=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Se,Ce]}),t[97]=Se,t[98]=Ce,t[99]=X):X=t[99];let Z;return t[100]!==R||t[101]!==G||t[102]!==X?(Z=(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-3`,children:[R,G,X]}),t[100]=R,t[101]=G,t[102]=X,t[103]=Z):Z=t[103],Z};export{De as a,Ie as i,$e as n,Te as o,Re as r,ut as t};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/gitApi-G_L1y6t4.js","assets/rolldown-runtime-C0FnF6B9.js","assets/persistence-aCOlo6ew.js","assets/useUIStore-Wyu09VUF.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-base-ui-CnHfUmDN.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/platform-ulFAVx1H.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/useMobileNavigationStore-BYDKiRu_.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/vendor-sonner-DVzioF3d.js","assets/vendor-reactuses-core-DDoDDyM9.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/clipboard-mffeUZRt.js","assets/store-DcNAsu-r.js","assets/useAssistantUIStore-DxZsjSPQ.js","assets/vendor-fuse.js-DB5wDJbI.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./useUIStore-Wyu09VUF.js";import{Ft as n,Sn as r,Zt as i,n as a,qt as o,t as s}from"./persistence-aCOlo6ew.js";import{nt as c,rt as l}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as u,Nt as d}from"./platform-ulFAVx1H.js";import{o as f}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as p,t as m}from"./vendor-react-DLPElpoQ.js";/* empty css */import{n as h,s as g}from"./vendor-reactuses-core-DDoDDyM9.js";import{i as _,n as v}from"./clipboard-mffeUZRt.js";import{n as y}from"./store-DcNAsu-r.js";import{Do as b,Ka as x,Nn as ee,Pn as te,Pt as ne,an as re,b as ie,ca as S,hn as ae,l as C,pa as oe}from"./useMobileNavigationStore-BYDKiRu_.js";import{t as se}from"./utils-CJdWZupK.js";import{n as ce}from"./Icon-Bs6GJIoO.js";import{t as le}from"./button-DfF088a8.js";import{B as ue,C as de,G as w,H as fe,K as T,Q as pe,R as me,S as he,U as E,V as ge,W as _e,a as ve,q as D,t as O,z as ye}from"./useAppFontEffects-Dy_VKl9E.js";import{c as be}from"./projectMeta-CQIQWtbJ.js";import{r as xe}from"./tooltip-GC3dg3gO.js";import{A as k,P as Se,V as Ce}from"./radio-DODUfCXY.js";import{M as we,Z as Te,t as Ee}from"./ChatContainer-CmnHzI_W.js";import{n as De}from"./useRuntimeAPIs-DSLXJybW.js";import{b as Oe,f as ke}from"./insertionBoundaries-CbvPY1wl.js";import{i as Ae,n as je,r as Me,t as Ne}from"./useDesktopWindowControlsLayout-7JfdV9hT.js";var Pe=m(),A=p(),j=e(l(),1),M=c(),Fe=e=>{let t=(0,A.c)(3),{mode:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,M.jsx)(we.Provider,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i},Ie=e=>{let t=typeof e==`string`?e.trim():``;if(!t)return``;let n=typeof window<`u`?window.__OPENCHAMBER_HOME__:``;if(n&&t===n)return`~`;if(n&&t.startsWith(`${n}/`))return`~/${t.slice(n.length+1)}`;let r=t.split(`/`).filter(Boolean);return r.length<=3?t:`.../${r.slice(-3).join(`/`)}`},N=e=>{let t=typeof e==`string`?e.trim():``;if(!t)return``;let n=t.replace(/\\/g,`/`);return n===`/`?`/`:n.replace(/\/+$/,``)},P=e=>{let t=(0,A.c)(133),{mode:n}=e,{t:r}=v(),a=C(Re),s=C(ze),c=C(Be),l=u(Ve),d=b(He),f=b(Ue),p=S(We),m=S(Ge),h=ae(),g=re(a??``),_=De(),y=Oe(Ke),x;t[0]===a?x=t[1]:(x=e=>a?e.worktreeMetadata.get(a)?.path??``:``,t[0]=a,t[1]=x);let ne=C(x),oe;t[2]===a?oe=t[3]:(oe=e=>a?e.worktreeMetadata.get(a)?.branch?.trim()??null:null,t[2]=a,t[3]=oe);let ue=C(oe),de;t[4]===a?de=t[5]:(de=e=>a?e.getAttachment(a):void 0,t[4]=a,t[5]=de);let w=ie(de),fe=C(qe),[T,pe]=j.useState(!1),me=typeof window<`u`?window.__OPENCHAMBER_MACOS_MAJOR__??0:0,he=Number.isFinite(me)&&me>0,{usesFramelessChrome:E,side:ge}=Ne(),_e=he?me>=26?`h-12`:me<=15?`h-14`:``:``,ve;t[6]!==a||t[7]!==h?(ve=a?h.find(e=>e.id===a)??null:null,t[6]=a,t[7]=h,t[8]=ve):ve=t[8];let D=ve,O=D?.worktreeMetadata??null,ye,be;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(ye=()=>{i()&&o(`desktop_get_window_pinned`).then(e=>{typeof e?.pinned==`boolean`&&pe(e.pinned)})},be=[],t[9]=ye,t[10]=be):(ye=t[9],be=t[10]),j.useEffect(ye,be);let xe;t[11]!==s||t[12]!==n||t[13]!==D?.title||t[14]!==r?(xe=D?.title?.trim()||r(s||n===`draft`?`miniChat.header.newSession`:`miniChat.header.session`),t[11]=s,t[12]=n,t[13]=D?.title,t[14]=r,t[15]=xe):xe=t[15];let k=xe,Se=D?.directory??null,Ce;t[16]===Se?Ce=t[17]:(Ce=N(Se),t[16]=Se,t[17]=Ce);let we=Ce,Te=ne||O?.path||w?.cwd||w?.worktreeRoot||``,Ee;t[18]===Te?Ee=t[19]:(Ee=N(Te),t[18]=Te,t[19]=Ee);let Pe=Ee,Fe;t[20]===l?Fe=t[21]:(Fe=N(l),t[20]=l,t[21]=Fe);let P=Pe||we||fe||Fe,Le;t[22]===P?Le=t[23]:(Le=Ie(P),t[22]=P,t[23]=Le);let tt=Le,nt;t[24]!==we||t[25]!==Pe?(nt=e=>{let t=N(Pe||we||``);if(!t)return null;for(let n of e.availableWorktreesByProject.values()){let e=n.find(e=>N(e.path)===t)?.branch?.trim();if(e)return e}return null},t[24]=we,t[25]=Pe,t[26]=nt):nt=t[26];let rt=C(nt),it,at;t[27]!==y||t[28]!==P||t[29]!==_.git?(it=()=>{P&&y(P,_.git).catch(Je)},at=[y,P,_.git],t[27]=y,t[28]=P,t[29]=_.git,t[30]=it,t[31]=at):(it=t[30],at=t[31]),j.useEffect(it,at),O?.projectDirectory,w?.worktreeRoot;let ot;bb0:{let e=O?.projectDirectory??w?.worktreeRoot??null,n;t[32]===e?n=t[33]:(n=N(e),t[32]=e,t[33]=n);let r=n||P;if(!r){ot=null;break bb0}let i;t[34]!==r||t[35]!==d?(i=d.map(Ye).filter(e=>e.normalizedPath&&(e.normalizedPath===r||r.startsWith(`${e.normalizedPath}/`))).sort(Xe)[0]??null,t[34]=r,t[35]=d,t[36]=i):i=t[36],ot=i}let st=ot,ct;bb1:{let e=st??f;if(!e){ct=tt||`OpenChamber`;break bb1}let n;t[37]===e.path?n=t[38]:(n=e.path.split(/[\\/]/).filter(Boolean).at(-1)??e.path,t[37]=e.path,t[38]=n),ct=n}let lt=ct,ut=ke(P||null),dt;t[39]!==rt||t[40]!==ut||t[41]!==O?.branch||t[42]!==w?.branch||t[43]!==ue?(dt=ut||ue||O?.branch?.trim()||w?.branch?.trim()||rt,t[39]=rt,t[40]=ut,t[41]=O?.branch,t[42]=w?.branch,t[43]=ue,t[44]=dt):dt=t[44];let ft=dt,pt=ft&&ft!==`HEAD`?ft:null,mt;t[45]===p?mt=t[46]:(mt=p(),t[45]=p,t[46]=mt);let ht=mt,gt;bb2:{for(let e=g.length-1;e>=0;--e){let t=g[e];if(t.role!==`assistant`||typeof t.providerID!=`string`||typeof t.modelID!=`string`)continue;let n=m.find(e=>e.id===t.providerID)?.models.find(e=>e.id===t.modelID);if(n){gt=n;break bb2}}gt=void 0}let _t=gt,vt=ht?.limit?ht:_t,F=vt&&typeof vt.limit==`object`&&vt.limit!==null?vt.limit:null,I=F&&typeof F.context==`number`?F.context:0,yt=F&&typeof F.output==`number`?F.output:0,L;if(t[47]!==I||t[48]!==a||t[49]!==g||t[50]!==yt){bb3:{if(!a||g.length===0){L=null;break bb3}let e=te(g,Ze);if(!e||`compacted`in e){L=null;break bb3}let n=e.tokens,r=e.totalTokens,i=I>0?I:2e5,o;t[52]!==I||t[53]!==r?(o=I>0?Math.round(r/I*100):0,t[52]=I,t[53]=r,t[54]=o):o=t[54];let s=o,c=yt>0?Math.round(ee(n.output)/yt*100):void 0,l=I||0,u=yt||void 0,d;t[55]!==e||t[56]!==c||t[57]!==s||t[58]!==l||t[59]!==u||t[60]!==i||t[61]!==r?(d={totalTokens:r,percentage:s,contextLimit:l,outputLimit:u,normalizedOutput:c,thresholdLimit:i,lastMessageId:e.messageId},t[55]=e,t[56]=c,t[57]=s,t[58]=l,t[59]=u,t[60]=i,t[61]=r,t[62]=d):d=t[62],L=d}t[47]=I,t[48]=a,t[49]=g,t[50]=yt,t[51]=L}else L=t[51];let R=L,[z,bt]=j.useState(null),xt;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(xt={WebkitAppRegion:`drag`},t[63]=xt):xt=t[63];let St=xt,Ct;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(Ct={WebkitAppRegion:`no-drag`},t[64]=Ct):Ct=t[64];let wt=Ct,Tt,Et;t[65]!==R||t[66]!==a?(Tt=()=>{if(!a){bt(Qe);return}if(R&&R.totalTokens>0){bt(e=>e&&e.totalTokens===R.totalTokens&&e.percentage===R.percentage&&e.contextLimit===R.contextLimit&&(e.outputLimit??0)===(R.outputLimit??0)&&(e.normalizedOutput??0)===(R.normalizedOutput??0)&&e.thresholdLimit===R.thresholdLimit&&e.lastMessageId===R.lastMessageId?e:R);return}bt($e)},Et=[R,a],t[65]=R,t[66]=a,t[67]=Tt,t[68]=Et):(Tt=t[67],Et=t[68]),j.useEffect(Tt,Et);let Dt=z&&z.contextLimit>0?Math.min(999,z.totalTokens/z.contextLimit*100):0,Ot;t[69]===T?Ot=t[70]:(Ot=()=>{let e=!T;pe(e),o(`desktop_set_window_pinned`,{pinned:e}).catch(()=>{pe(!e)})},t[69]=T,t[70]=Ot);let kt=Ot,At;t[71]!==l||t[72]!==a||t[73]!==c||t[74]!==P||t[75]!==D?(At=()=>{let e=a?{sessionId:a,directory:D?.directory??l??``}:{mode:`draft`,directory:P||l||``,projectId:c};o(`desktop_focus_main_window`,e).then(et)},t[71]=l,t[72]=a,t[73]=c,t[74]=P,t[75]=D,t[76]=At):At=t[76];let jt=At,Mt=E?`h-12`:_e||`min-h-14`,B;t[77]===Mt?B=t[78]:(B=se(`flex items-center gap-3 bg-background pr-3`,he?`pl-[5.5rem]`:`pl-3`,Mt),t[77]=Mt,t[78]=B);let V;t[79]!==E||t[80]!==ge?(V=E&&ge===`left`?(0,M.jsx)(Me,{visible:!0,position:`left`}):null,t[79]=E,t[80]=ge,t[81]=V):V=t[81];let H;t[82]===r?H=t[83]:(H=r(`sessions.switcher.openAria`),t[82]=r,t[83]=H);let U;t[84]===k?U=t[85]:(U=(0,M.jsx)(`span`,{className:`truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full`,children:k}),t[84]=k,t[85]=U);let W;t[86]===lt?W=t[87]:(W=(0,M.jsx)(`span`,{className:`truncate`,children:lt}),t[86]=lt,t[87]=W);let G;t[88]===pt?G=t[89]:(G=pt?(0,M.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,M.jsx)(ce,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground/70`}),(0,M.jsx)(`span`,{className:`truncate`,children:pt})]}):null,t[88]=pt,t[89]=G);let K;t[90]!==W||t[91]!==G?(K=(0,M.jsxs)(`span`,{className:`flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75`,children:[W,G]}),t[90]=W,t[91]=G,t[92]=K):K=t[92];let q;t[93]!==H||t[94]!==U||t[95]!==K?(q=(0,M.jsx)(je,{children:(0,M.jsxs)(`button`,{type:`button`,"aria-label":H,style:wt,className:`flex min-w-0 max-w-full flex-col items-start rounded-md px-1 py-0.5 text-left transition-colors hover:bg-interactive-hover/60 focus-visible:outline-none focus-visible:bg-interactive-hover/60`,children:[U,K]})}),t[93]=H,t[94]=U,t[95]=K,t[96]=q):q=t[96];let Nt;t[97]===Symbol.for(`react.memo_cache_sentinel`)?(Nt=(0,M.jsx)(`div`,{className:`min-w-0 flex-1`}),t[97]=Nt):Nt=t[97];let J;t[98]!==Dt||t[99]!==z?(J=z&&z.totalTokens>0?(0,M.jsx)(Ae,{totalTokens:z.totalTokens,percentage:Dt,colorPercentage:z.percentage,contextLimit:z.contextLimit,outputLimit:z.outputLimit??0,className:`h-9 shrink-0 pl-1 pr-1 typography-ui-label`,valueClassName:`font-semibold leading-none`,hideIcon:!0,showPercentIcon:!0,percentIconClassName:`h-4.5 w-4.5`}):null,t[98]=Dt,t[99]=z,t[100]=J):J=t[100];let Y;t[101]!==T||t[102]!==r?(Y=r(T?`miniChat.actions.unpinAria`:`miniChat.actions.pinAria`),t[101]=T,t[102]=r,t[103]=Y):Y=t[103];let X;t[104]!==T||t[105]!==r?(X=r(T?`miniChat.actions.unpin`:`miniChat.actions.pin`),t[104]=T,t[105]=r,t[106]=X):X=t[106];let Z;t[107]===T?Z=t[108]:(Z=T?(0,M.jsx)(ce,{name:`pushpin-2-fill`,className:`h-4 w-4`}):(0,M.jsx)(ce,{name:`pushpin-2`,className:`h-4 w-4`}),t[107]=T,t[108]=Z);let Q;t[109]!==kt||t[110]!==Y||t[111]!==X||t[112]!==Z?(Q=(0,M.jsx)(le,{type:`button`,variant:`ghost`,size:`icon`,onClick:kt,"aria-label":Y,title:X,style:wt,children:Z}),t[109]=kt,t[110]=Y,t[111]=X,t[112]=Z,t[113]=Q):Q=t[113];let Pt;t[114]===r?Pt=t[115]:(Pt=r(`miniChat.actions.openMainAria`),t[114]=r,t[115]=Pt);let Ft;t[116]===r?Ft=t[117]:(Ft=r(`miniChat.actions.openMain`),t[116]=r,t[117]=Ft);let It;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(It=(0,M.jsx)(ce,{name:`external-link`,className:`h-4 w-4`}),t[118]=It):It=t[118];let Lt;t[119]!==jt||t[120]!==Pt||t[121]!==Ft?(Lt=(0,M.jsx)(le,{type:`button`,variant:`ghost`,size:`icon`,onClick:jt,"aria-label":Pt,title:Ft,style:wt,children:It}),t[119]=jt,t[120]=Pt,t[121]=Ft,t[122]=Lt):Lt=t[122];let Rt=E&&ge===`right`,$;t[123]===Rt?$=t[124]:($=(0,M.jsx)(Me,{visible:Rt,position:`right`}),t[123]=Rt,t[124]=$);let zt;return t[125]!==B||t[126]!==V||t[127]!==q||t[128]!==J||t[129]!==Q||t[130]!==Lt||t[131]!==$?(zt=(0,M.jsxs)(`header`,{className:B,style:St,children:[V,q,Nt,J,Q,Lt,$]}),t[125]=B,t[126]=V,t[127]=q,t[128]=J,t[129]=Q,t[130]=Lt,t[131]=$,t[132]=zt):zt=t[132],zt},Le=e=>{let t=(0,A.c)(9),{mode:n,autoOpenDraft:r,unavailable:i}=e,a=r!==void 0&&r,o=i!==void 0&&i,{t:s}=v(),c;t[0]===n?c=t[1]:(c=(0,M.jsx)(P,{mode:n}),t[0]=n,t[1]=c);let l;t[2]!==a||t[3]!==s||t[4]!==o?(l=(0,M.jsx)(`main`,{className:`min-h-0 flex-1`,children:o?(0,M.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center typography-ui-label text-muted-foreground`,children:(0,M.jsxs)(`div`,{className:`max-w-sm rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-4 py-3`,children:[(0,M.jsx)(`div`,{className:`font-medium text-foreground`,children:s(`miniChat.unavailable.title`)}),(0,M.jsx)(`div`,{className:`mt-1 typography-small text-muted-foreground`,children:s(`miniChat.unavailable.description`)})]})}):(0,M.jsx)(Fe,{mode:`mini-chat`,children:(0,M.jsx)(Ee,{autoOpenDraft:a})})}),t[2]=a,t[3]=s,t[4]=o,t[5]=l):l=t[5];let u;return t[6]!==c||t[7]!==l?(u=(0,M.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8],u};function Re(e){return e.currentSessionId}function ze(e){return!!e.newSessionDraft?.open}function Be(e){return e.newSessionDraft?.selectedProjectId??null}function Ve(e){return e.currentDirectory}function He(e){return e.projects}function Ue(e){return e.getActiveProject()}function We(e){return e.getCurrentModel}function Ge(e){return e.providers}function Ke(e){return e.ensureStatus}function qe(e){return e.newSessionDraft?.open?N(e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``):``}function Je(){}function Ye(e){return{...e,normalizedPath:N(e.path)}}function Xe(e,t){return t.path.length-e.path.length}function Ze(e){return oe(e)}function Qe(e){return e===null?e:null}function $e(e){return e===null?e:null}function et(e){return e?.focused===!0?o(`desktop_close_current_window`):null}var tt=()=>{document.querySelector(`textarea[data-chat-input="true"]`)?.focus()},nt=()=>{let e=t(e=>e.shortcutOverrides),r=u(e=>e.currentDirectory),i=b(e=>e.getActiveProject()),a=C(e=>e.openNewSessionDraft);j.useEffect(()=>{let s=t=>Se(t,e),c=e=>{if(k(e,s(`focus_input`))){e.preventDefault(),tt();return}if(n()&&k(e,s(`close_context_panel_tab`))){e.preventDefault(),o(`desktop_close_current_window`).catch(e=>{console.warn(`[mini-chat-shortcuts] failed to close current window`,e)});return}if(n()&&k(e,s(`new_mini_chat`))){e.preventDefault(),o(`desktop_open_draft_mini_chat_window`,{directory:r||i?.path||``,projectId:i?.id??null})?.catch(e=>{console.warn(`[mini-chat-shortcuts] failed to open draft mini chat window`,e)});return}if(k(e,s(`new_chat`))){e.preventDefault(),a({selectedProjectId:i?.id??null,directoryOverride:r||i?.path||null,preserveDirectoryOverride:!!(r||i?.path)}),tt();return}if(k(e,s(`open_model_selector`))){e.preventDefault();let{isModelSelectorOpen:n,setModelSelectorOpen:r}=t.getState();r(!n,{instant:!0});return}if(k(e,s(`cycle_thinking_variant`))){let t=S.getState();if(t.getCurrentModelVariants().length===0)return;e.preventDefault(),t.cycleCurrentVariant();let n=S.getState().currentVariant,r=C.getState().currentSessionId,i=S.getState().currentAgentName,a=S.getState().currentProviderId,o=S.getState().currentModelId;r&&i&&a&&o&&x.getState().saveAgentModelVariantForSession(r,i,a,o,n),i&&a&&o&&S.getState().saveAgentModelSelection(i,a,o,n);return}let c=k(e,s(`cycle_favorite_model_forward`)),l=k(e,s(`cycle_favorite_model_backward`));if(c||l){let{favoriteModels:n,addRecentModel:r}=t.getState();if(n.length===0)return;e.preventDefault();let{currentProviderId:i,currentModelId:a,providers:o,setProvider:s,setModel:l,setCurrentVariant:u}=S.getState(),d=n[(n.findIndex(e=>e.providerID===i&&e.modelID===a)+(c?1:-1)+n.length)%n.length];s(d.providerID),l(d.modelID);let f=o.find(e=>e.id===d.providerID)?.models?.find(e=>e.id===d.modelID),p=f?.variants?Object.keys(f.variants):[],m=d.variant!==void 0&&p.includes(d.variant)?d.variant:void 0;u(m),r(d.providerID,d.modelID,m)}};return window.addEventListener(`keydown`,c),()=>window.removeEventListener(`keydown`,c)},[i?.id,i?.path,r,a,e])},rt=`openchamber:mini-chat-presence`,it=()=>{let e=typeof window<`u`?new URLSearchParams(window.location.search):new URLSearchParams;return{mode:e.get(`mode`)===`session`?`session`:`draft`,sessionId:e.get(`sessionId`)?.trim()||null,directory:e.get(`directory`)?.trim()||null,projectId:e.get(`projectId`)?.trim()||null}},at=({config:e})=>{let t=ae(),n=u(e=>e.currentDirectory),r=u(e=>e.setDirectory),i=b(e=>e.projects),a=C(e=>e.currentSessionId),o=C(e=>!!e.newSessionDraft?.open),s=C(e=>e.newSessionDraft?.open?e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``:``),c=C(e=>e.setCurrentSession),l=C(e=>e.openNewSessionDraft),d=S(e=>e.initializeApp),p=S(e=>e.isInitialized),m=Te();j.useEffect(()=>{d()},[d]),j.useEffect(()=>{if(p)return;let e=!0,t=0,n=window.setInterval(()=>{if(e){if(t+=1,t>10){window.clearInterval(n);return}S.getState().isInitialized||S.getState().initializeApp()}},1e3);return()=>{e=!1,window.clearInterval(n)}},[p]);let _=j.useRef(!1);j.useEffect(()=>{if(!_.current&&e.mode===`session`&&e.directory){if(n===e.directory){_.current=!0;return}r(e.directory,{showOverlay:!1}),_.current=!0}},[e.directory,e.mode,n,r]),j.useEffect(()=>{e.mode!==`draft`||!o||a||!s||n===s||r(s,{showOverlay:!1})},[e.mode,n,a,s,o,r]),ue({enabled:!0,source:`electronMiniChat:recovery`});let v=j.useRef(!1);j.useEffect(()=>{if(v.current||e.mode!==`session`||!e.sessionId)return;if(a===e.sessionId){v.current=!0;return}if(a){v.current=!0;return}let n=t.find(t=>t.id===e.sessionId);if(!n){m.ensureSessionRenderable(e.sessionId);return}let r=n.directory??e.directory;c(e.sessionId,r),v.current=!0},[e,a,t,c,m]);let y=g(t),x=h(e=>{let t=e.detail,n=typeof t?.sessionId==`string`?t.sessionId.trim():``;if(!n||C.getState().currentSessionId===n)return;let r=typeof t?.directory==`string`&&t.directory.trim().length>0?t.directory.trim():y.current.find(e=>e.id===n)?.directory??null;m.ensureSessionRenderable(n),c(n,r),v.current=!0});j.useEffect(()=>(window.addEventListener(`openchamber:open-session`,x),()=>window.removeEventListener(`openchamber:open-session`,x)),[x]),j.useEffect(()=>{e.mode!==`draft`||o||a||l({selectedProjectId:e.projectId,directoryOverride:e.directory,preserveDirectoryOverride:!!e.directory})},[e,a,o,l]),j.useEffect(()=>{if(i.length===0)return;let e=!1;return(async()=>{await Promise.all(i.map(async t=>{let n=t.path.replace(/\\/g,`/`).replace(/\/+$/,``);if(n)try{if(!(Oe.getState().directories.get(n)?.isGitRepo??await f(()=>import(`./gitApi-G_L1y6t4.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])))||e)return;await be({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[i]);let ee=j.useRef(!1);return j.useEffect(()=>{if(ee.current||!p)return;let t=()=>{if(ee.current)return;ee.current=!0;let e=typeof document<`u`?document.getElementById(`initial-loading`):null;e&&(e.classList.add(`fade-out`),window.setTimeout(()=>e.remove(),300))},n=e.mode===`session`?a===e.sessionId:o,r=window.setTimeout(t,n?100:1500);return()=>window.clearTimeout(r)},[p,e.mode,e.sessionId,a,o]),null},ot=()=>{let e=(0,A.c)(4),t=C(mt),n=u(ht),r,i;return e[0]!==n||e[1]!==t?(r=()=>{if(!t||!n||typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(rt),r=r=>{e.postMessage({type:`mini-chat-session-presence`,sessionId:t,directory:n,viewed:r})};r(!0);let i=window.setInterval(()=>r(!0),5e3),a=()=>r(!1);return window.addEventListener(`beforeunload`,a),()=>{window.clearInterval(i),window.removeEventListener(`beforeunload`,a),r(!1),e.close()}},i=[n,t],e[0]=n,e[1]=t,e[2]=r,e[3]=i):(r=e[2],i=e[3]),j.useEffect(r,i),null},st=e=>{let t=(0,A.c)(6),n=ae(),r=C(gt),[i,a]=j.useState(!1),o,s;return t[0]!==e.mode||t[1]!==e.sessionId||t[2]!==r||t[3]!==n?(o=()=>{if(e.mode!==`session`||!e.sessionId||r===e.sessionId){a(!1);return}if(n.some(t=>t.id===e.sessionId)){a(!1);return}let t=window.setTimeout(()=>a(!0),5e3);return()=>window.clearTimeout(t)},s=[e.mode,e.sessionId,r,n],t[0]=e.mode,t[1]=e.sessionId,t[2]=r,t[3]=n,t[4]=o,t[5]=s):(o=t[4],s=t[5]),j.useEffect(o,s),i};function ct(e){let t=(0,A.c)(16),{apis:n}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=it(),t[0]=i):i=t[0];let a=i,o=u(ft),s=C(dt),c=C(ut),l,f;t[1]===o?(l=t[2],f=t[3]):(l=()=>{d.setDirectory(o||a.directory||void 0)},f=[a.directory,o],t[1]=o,t[2]=l,t[3]=f),j.useEffect(l,f);let p,m;t[4]===n?(p=t[5],m=t[6]):(p=()=>(r(n),lt),m=[n],t[4]=n,t[5]=p,t[6]=m),j.useEffect(p,m),O(),nt();let h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h={enabled:!0},t[7]=h):h=t[7],de(h),he();let g;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=d.getSdkClient(),t[8]=g):g=t[8];let _=o||a.directory||``,v=!(c&&s===null),y;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,M.jsx)(xe,{delayDuration:300,skipDelayDuration:150,children:(0,M.jsxs)(`div`,{className:`h-full text-foreground bg-background`,children:[(0,M.jsx)(pt,{config:a}),(0,M.jsx)(me,{})]})}),t[9]=y):y=t[9];let b;t[10]===n?b=t[11]:(b=(0,M.jsx)(ye,{apis:n,children:y}),t[10]=n,t[11]=b);let x;return t[12]!==b||t[13]!==_||t[14]!==v?(x=(0,M.jsx)(Ce,{children:(0,M.jsx)(ne,{sdk:g,directory:_,bootstrapDirectory:v,children:b})}),t[12]=b,t[13]=_,t[14]=v,t[15]=x):x=t[15],x}function lt(){return r(null)}function ut(e){return!!e.newSessionDraft?.open}function dt(e){return e.currentSessionId}function ft(e){return e.currentDirectory}var pt=e=>{let t=(0,A.c)(11),{config:n}=e,r=st(n),i;t[0]===n?i=t[1]:(i=(0,M.jsx)(at,{config:n}),t[0]=n,t[1]=i);let a,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,M.jsx)(ot,{}),o=(0,M.jsx)(ve,{embeddedBackgroundWorkEnabled:!0}),t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s=n.mode===`draft`,c;t[4]!==n.mode||t[5]!==r||t[6]!==s?(c=(0,M.jsx)(Le,{mode:n.mode,autoOpenDraft:s,unavailable:r}),t[4]=n.mode,t[5]=r,t[6]=s,t[7]=c):c=t[7];let l;return t[8]!==i||t[9]!==c?(l=(0,M.jsxs)(M.Fragment,{children:[i,a,o,c]}),t[8]=i,t[9]=c,t[10]=l):l=t[10],l};function mt(e){return e.currentSessionId}function ht(e){return e.currentDirectory}function gt(e){return e.currentSessionId}var _t=()=>{y(),s().then(()=>{Promise.all([a(),pe()]).catch(e=>{console.error(`[mini-chat-main] settings init failed:`,e)}),_e(),E(),fe()}).catch(e=>{console.error(`[mini-chat-main] appearance init failed:`,e)})};function vt(e){_t();let t=document.getElementById(`root`);if(!t)throw Error(`Root element not found`);(0,Pe.createRoot)(t).render((0,M.jsx)(j.StrictMode,{children:(0,M.jsx)(ge,{children:(0,M.jsx)(_,{children:(0,M.jsx)(w,{children:(0,M.jsx)(T,{children:(0,M.jsx)(D,{children:(0,M.jsx)(ct,{apis:e})})})})})})}))}export{vt as renderElectronMiniChatApp};