@openchambery/web 2.0.5-beta.3 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/assets/{AssistantView-BeQjlQi5.js → AssistantView-kXN4mz6j.js} +3 -3
  2. package/dist/assets/{DiagramView-BPFVXhly.js → DiagramView-CGLAl3iS.js} +1 -1
  3. package/dist/assets/MarkdownRenderer-DA08bZsM.js +2 -0
  4. package/dist/assets/{MarkdownRendererImpl-DCim2MBS.js → MarkdownRendererImpl-qaVTVCHe.js} +1 -1
  5. package/dist/assets/{MarkstreamRendererImpl-DLI17gOM.js → MarkstreamRendererImpl-CQdVI8Vx.js} +1 -1
  6. package/dist/assets/{MobileDetailNavigation-C9097prS.js → MobileDetailNavigation-xaAVkxD-.js} +1 -1
  7. package/dist/assets/{MobileShareBridge-BVRtivg8.js → MobileShareBridge-z2TFroKY.js} +1 -1
  8. package/dist/assets/MobileTabPageHeader-DPlvhJFe.js +2 -0
  9. package/dist/assets/{MultiRunWindow-VdUAIkKj.js → MultiRunWindow-vJc2NLzu.js} +1 -1
  10. package/dist/assets/{SettingsView-BcQCG9q0.js → SettingsView-BG7DgHmP.js} +6 -6
  11. package/dist/assets/{SettingsWindow-BSap8D3j.js → SettingsWindow-3QrhPfuk.js} +1 -1
  12. package/dist/assets/{TerminalView-CQEmfuGt.js → TerminalView-Ciw0BIiz.js} +1 -1
  13. package/dist/assets/{ToolOutputDialog-3cIIsSBA.js → ToolOutputDialog-D_23USz-.js} +1 -1
  14. package/dist/assets/{appThemeRegistry-Dl2OjM9t.js → appThemeRegistry-lhAKuFFB.js} +1 -1
  15. package/dist/assets/{fileMentionTouchSelection-BJOHH2CX.js → fileMentionTouchSelection-DPSC4Fx2.js} +1 -1
  16. package/dist/assets/{gitApi-C-zOJTEi.js → gitApi-DeWWyR94.js} +3 -3
  17. package/dist/assets/insertionBoundaries-aV1Cm6zA.js +1 -0
  18. package/dist/assets/{main-ctL2Nr48.js → main-0XIuL0dd.js} +11 -11
  19. package/dist/assets/{main-Fbjmo73O.js → main-DZGXa6wk.js} +2 -2
  20. package/dist/assets/{mcpQueries-B1I3urB4.js → mcpQueries-pTPWjOQO.js} +1 -1
  21. package/dist/assets/{miniChat-BFctomLE.js → miniChat-C8K4fwOO.js} +2 -2
  22. package/dist/assets/{mobile-CgrEAs5U.js → mobile-Brtl2UnC.js} +2 -2
  23. package/dist/assets/multirun-B7FPVrQ-.js +3 -0
  24. package/dist/assets/{projectMeta-iGmHOQNp.js → projectMeta-D_jCNzjw.js} +1 -1
  25. package/dist/assets/{renderElectronMiniChatApp-B82q9wxX.js → renderElectronMiniChatApp-e6XqcsYi.js} +2 -2
  26. package/dist/assets/renderMobileApp-BQenfg50.js +28 -0
  27. package/dist/assets/{runtimeConfig-CCw0l6aJ.js → runtimeConfig-CJE7T1Sr.js} +1 -1
  28. package/dist/assets/{runtimeEndpointReset-CvWlsn11.js → runtimeEndpointReset-DULSaOrI.js} +6 -6
  29. package/dist/assets/{sessionChangeSummary-BCz7YMwL.js → sessionChangeSummary-CVZBClsA.js} +1 -1
  30. package/dist/assets/{sessionLookup-BpO4cCmV.js → sessionLookup--qnazVNO.js} +1 -1
  31. package/dist/assets/{useAppFontEffects-KlbtUhYE.js → useAppFontEffects-BHenW5Q2.js} +53 -53
  32. package/dist/assets/{useDesktopWindowControlsLayout-BflHVu5S.js → useDesktopWindowControlsLayout-BGgoqF_n.js} +1 -1
  33. package/dist/assets/{useEffectiveDirectory-BbQKZPcu.js → useEffectiveDirectory-CF16bcpx.js} +1 -1
  34. package/dist/assets/useMobileNavigationStore-DBML5LIl.js +415 -0
  35. package/dist/assets/{useSessionAutoCleanup-Dho6q-O2.js → useSessionAutoCleanup-moxr9XbA.js} +1 -1
  36. package/dist/assets/{useWorkerHighlightedLines-CbvulSje.js → useWorkerHighlightedLines-DYVg-cuB.js} +1 -1
  37. package/dist/index.html +2 -2
  38. package/dist/mini-chat.html +2 -2
  39. package/dist/mobile.html +2 -2
  40. package/package.json +1 -1
  41. package/server/lib/question-auto-delegate/DOCUMENTATION.md +4 -0
  42. package/server/lib/question-auto-delegate/core.d.ts +5 -0
  43. package/server/lib/question-auto-delegate/core.js +62 -13
  44. package/server/lib/question-auto-delegate/form-io.js +4 -1
  45. package/server/lib/question-auto-delegate/pause-store.d.ts +7 -0
  46. package/server/lib/question-auto-delegate/pause-store.js +39 -0
  47. package/server/lib/question-auto-delegate/runtime.js +3 -0
  48. package/server/lib/question-auto-delegate/runtime.test.js +128 -1
  49. package/dist/assets/MarkdownRenderer-D1fVOsHS.js +0 -2
  50. package/dist/assets/MobileTabPageHeader-tKa6r_KP.js +0 -2
  51. package/dist/assets/insertionBoundaries-DduQc2QR.js +0 -1
  52. package/dist/assets/multirun-BuVN-s4M.js +0 -3
  53. package/dist/assets/renderMobileApp-CM_El_gZ.js +0 -28
  54. package/dist/assets/useMobileNavigationStore-BjIptzTV.js +0 -415
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-PzT84wSx.js","assets/rolldown-runtime-C0FnF6B9.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{c as t,i as n,o as r}from"./runtime-switch-BJM2k_uH.js";import{n as i}from"./runtime-fetch-CiqQd__Y.js";import{On as a,Ut as o,Wt as s,at as c,cn as l,d as u,f as d,in as f,it as p,l as m,ln as h,m as g,nn as _,on as v,r as y,rn as b,s as x,sn as S,vn as C}from"./persistence-Dnj1QOdX.js";import{a as w,i as T,r as E}from"./vendor-zustand-DzRqcymP.js";import{nt as D,rt as O,tt as k}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as A,Nt as j,Vt as M,n as N,t as P}from"./platform-wu6wSDfg.js";import{b as F,n as I}from"./useUIStore-Dfx6TKvi.js";import{n as L}from"./vendor-react-DLPElpoQ.js";import{o as R}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{t as ee}from"./types-BuiqMmh_.js";import{A as te,G as ne,H as z,K as re,L as ie,P as ae,Q as oe,T as se,V as B,W as V,X as ce,Z as le,a as ue,g as de,ht as fe,lt as pe,mt as me,pt as he,q as ge,st as H,tt as _e}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{n as U}from"./vendor-reactuses-core-Dq5ocTF8.js";import{a as ve,d as ye,f as W,p as be,r as G,t as K}from"./button-CUwjpv-i.js";import{$n as xe,Dr as q,Qn as Se,Xa as Ce,Yn as we,Zn as Te,_r as Ee,d as De,jr as J,li as Oe,mi as ke,nr as Ae,to as je,tr as Me,vn as Ne,wr as Pe}from"./useMobileNavigationStore-BjIptzTV.js";import{a as Fe,n as Ie,o as Le,r as Re,t as ze}from"./dialog-PjKWayIU.js";import{n as Y}from"./Icon-BdzPRCSy.js";import{L as Be,_ as Ve,b as He,c as Ue,n as We,s as Ge,u as Ke}from"./gitApi-C-zOJTEi.js";import{A as qe,_ as Je,a as Ye,b as Xe,c as Ze,h as Qe,m as $e,n as et,r as tt,t as nt,x as rt}from"./projectMeta-iGmHOQNp.js";import{t as it}from"./input-BeVw4D0W.js";import{i as at,n as ot,t as st}from"./tooltip-DDNnmcXI.js";import{$t as ct,A as lt,D as ut,G as dt,Gt as ft,J as pt,Jt as mt,Kt as ht,M as gt,N as _t,U as vt,W as yt,Xt as bt,Yt as xt,g as St,in as Ct,it as wt,q as Tt,qt as Et,r as Dt,rt as Ot,ut as kt}from"./useSessionAutoCleanup-Dho6q-O2.js";import{n as At}from"./useThemeSystem-DMzWVJaW.js";import{i as jt,n as Mt}from"./OverlayScrollbar-C1C2aKOe.js";import{n as Nt,t as Pt}from"./textarea-Kl-rTWJe.js";import{n as Ft}from"./MarkdownRenderer-D1fVOsHS.js";import{a as It}from"./url-DNRMq_0R.js";import{r as Lt}from"./markdown-worker-bS5OgGO3.js";import{i as Rt,n as zt,o as Bt}from"./mcpQueries-B1I3urB4.js";import{n as Vt,r as Ht,t as Ut}from"./collapsible-paItOH3A.js";import{a as Wt,d as Gt,o as Kt,s as qt}from"./vendor-codemirror-commands-C9DCaJ0C.js";import{a as Jt,c as Yt,i as Xt,o as Zt,r as Qt,s as $t}from"./vendor-codemirror-search-D2SOgzph.js";import{n as en,t as tn}from"./vendor-replit-codemirror-vim-CEibx3EP.js";import{i as nn,n as rn,r as an,t as on}from"./projectActions-CWvNGKfA.js";var sn=[{id:`claude`,name:`Claude`},{id:`codex`,name:`Codex`},{id:`cursor`,name:`Cursor`},{id:`github-copilot`,name:`GitHub Copilot`},{id:`google`,name:`Google`},{id:`kimi-for-coding`,name:`Kimi for Coding`},{id:`nano-gpt`,name:`NanoGPT`},{id:`openrouter`,name:`OpenRouter`},{id:`zai-coding-plan`,name:`z.ai`},{id:`zhipuai-coding-plan`,name:`Zhipu AI Coding Plan`},{id:`minimax-cn-coding-plan`,name:`MiniMax Coding Plan (minimaxi.com)`},{id:`minimax-coding-plan`,name:`MiniMax Coding Plan (minimax.io)`},{id:`ollama-cloud`,name:`Ollama Cloud`},{id:`wafer`,name:`Wafer.ai`},{id:`opencode-go`,name:`OpenCode Go`},{id:`xai`,name:`Grok`}],X=L(),Z=D();function cn(e){let t=(0,X.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`path`,{d:`M15.688 2.343a2.588 2.588 0 00-3.61 0l-9.626 9.44a.863.863 0 01-1.203 0 .823.823 0 010-1.18l9.626-9.44a4.313 4.313 0 016.016 0 4.116 4.116 0 011.204 3.54 4.3 4.3 0 013.609 1.18l.05.05a4.115 4.115 0 010 5.9l-8.706 8.537a.274.274 0 000 .393l1.788 1.754a.823.823 0 010 1.18.863.863 0 01-1.203 0l-1.788-1.753a1.92 1.92 0 010-2.754l8.706-8.538a2.47 2.47 0 000-3.54l-.05-.049a2.588 2.588 0 00-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 01-1.204 0 .823.823 0 010-1.18l7.273-7.133a2.47 2.47 0 00-.003-3.537z`}),r=(0,Z.jsx)(`path`,{d:`M14.485 4.703a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a4.115 4.115 0 000 5.9 4.314 4.314 0 006.016 0l7.12-6.982a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a2.588 2.588 0 01-3.61 0 2.47 2.47 0 010-3.54l7.12-6.982z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,fill:`currentColor`,stroke:`currentColor`,strokeWidth:`0.5`,fillRule:`evenodd`,viewBox:`-0.5 -0.5 25 25`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}var ln={},un=(e,t=n())=>JSON.stringify([t,zt(e)]),dn=(e,t,n)=>{if(!e[t]?.[n])return e;let r={...e[t]};return delete r[n],{...e,[t]:r}},fn=e=>{let t=zt(e);return t?j.getScopedApiClient(t):j.getApiClient()},pn=e=>e?{location:{directory:e}}:void 0,mn=e=>zt(e===void 0?A.getState().currentDirectory:e),hn=w()(E((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=un(mn(e));return t().diagnosticsByDirectory[n]??ln},clearDiagnostic:(t,n,r)=>{let i=un(mn(n),r);e(e=>({diagnosticsByDirectory:dn(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let i=mn(r),a=n(),o=un(i,a),s=fn(i);try{await s.mcp.connect({server:t,...pn(i)})}catch(n){let r=n instanceof Error?n.message:`Connection failed`;throw e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[o]:{...e.diagnosticsByDirectory[o]??{},[t]:{status:`failed`,error:r}}}})),n}await Bt(u,i,a),e(e=>({diagnosticsByDirectory:dn(e.diagnosticsByDirectory,o,t)}))},disconnect:async(t,r)=>{let i=mn(r),a=n(),o=un(i,a);await fn(i).mcp.disconnect({server:t,...pn(i)}),await Bt(u,i,a),e(e=>({diagnosticsByDirectory:dn(e.diagnosticsByDirectory,o,t)}))},startAuth:async(e,t)=>{throw M(`mcp.auth`)},completeAuth:async(e,t,n)=>{throw M(`mcp.auth`)},clearAuth:async(e,t)=>{throw M(`mcp.auth`)},testConnection:async(t,r)=>{let i=mn(r),a=n(),o=un(i,a),s=fn(i),c=Rt(u,i,a)[t]?.status===`connected`,l,d;try{await s.mcp.connect({server:t,...pn(i)})}catch(n){l=n instanceof Error?n.message:`Connection failed`,e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[o]:{...e.diagnosticsByDirectory[o]??{},[t]:{status:`failed`,error:l??`Connection failed`}}}}))}let f=(await Bt(u,i,a))[t],p=f;if(!c&&f?.status===`connected`){try{await s.mcp.disconnect({server:t,...pn(i)})}catch(e){d=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await Bt(u,i,a)}return l||e(e=>({diagnosticsByDirectory:dn(e.diagnosticsByDirectory,o,t)})),{status:p??Rt(u,i,a)[t],error:l,warning:d}}}))),Q=e(O(),1),gn=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,_n=()=>gn(`2.0.5-beta.3`),vn=(e,t)=>gn(t)||gn(e),yn=(e,t)=>{let n=gn(e);return n?typeof t!=`number`||!Number.isFinite(t)?n:`${n} (${t})`:null},bn=async()=>{let e=_n();if(!N())return e;try{let{App:t}=await R(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2]));return vn((await t.getInfo()).version,e)}catch{return e}},xn=async()=>{if(!N())return null;try{let{App:e}=await R(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),t=await e.getInfo(),n=typeof t.build==`string`?t.build.trim():``;if(n.length===0)return null;let r=Number.parseInt(n,10);return Number.isFinite(r)?r:null}catch{return null}},Sn=`https://openchamber.xiaobe.top/v1/update/check`,Cn=`https://openchamber-update.vercel.app/v1/update/check`,wn=`https://github.com/yee94/openchamber/releases/latest`,Tn=`https://github.com/yee94/openchamber/releases`,En=`https://testflight.apple.com/join/ZCENBHtm`,Dn=1e4;function On(e){let t=String(e||``).replace(/^v/,``).split(`+`)[0]??``,n=t.indexOf(`-`);return{parts:(n>=0?t.slice(0,n):t).split(`.`).map(e=>{let t=Number.parseInt(e||`0`,10);return Number.isFinite(t)?t:0}),prerelease:n>=0}}function kn(e,t){let n=On(e),r=On(t),i=Math.max(n.parts.length,r.parts.length);for(let e=0;e<i;e+=1){let t=(n.parts[e]||0)-(r.parts[e]||0);if(t!==0)return t}return n.prerelease===r.prerelease?0:n.prerelease?-1:1}function An(){return[Sn,Cn]}function jn(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function Mn(e){return{appType:`mobile-capacitor`,deviceClass:e.deviceClass||`mobile`,platform:e.platform===`ios`||e.platform===`android`?e.platform:`android`,arch:e.arch||`unknown`,channel:`stable`,currentVersion:e.currentVersion,instanceMode:`remote`,reportUsage:e.reportUsage===!0}}async function Nn(e,t,n,r){try{if(N())try{let{CapacitorHttp:r}=await R(async()=>{let{CapacitorHttp:e}=await import(`./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js`).then(e=>e.i);return{CapacitorHttp:e}},__vite__mapDeps([2,1])),i=Object.fromEntries(new Headers(t.headers).entries()),a;if(typeof t.body==`string`)try{a=JSON.parse(t.body)}catch{a=t.body}let o=await Promise.race([r.request({url:e,method:t.method||`GET`,headers:i,data:a,connectTimeout:n,readTimeout:n}),new Promise(e=>{window.setTimeout(()=>e(null),n)})]);return o?{ok:o.status>=200&&o.status<300,status:o.status,url:typeof o.url==`string`?o.url:e,json:async()=>{if(typeof o.data==`string`)try{return JSON.parse(o.data)}catch{return o.data}return o.data}}:null}catch{}let i=await r(e,{...t,signal:AbortSignal.timeout(n)});return{ok:i.ok,status:i.status,url:i.url,json:()=>i.json()}}catch{return null}}function Pn(e,t){return e===`ios`?En:`${Tn}/download/v${t}/app-release.apk`}function Fn(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=kn(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${Tn}/tag/v${r}`,o=typeof e.downloadUrl==`string`&&e.downloadUrl.trim().length>0?e.downloadUrl.trim():typeof e.download?.url==`string`&&e.download.url.trim().length>0?e.download.url.trim():Pn(n,r);return{available:!!e.updateAvailable&&i>0,version:r,currentVersion:t,body:typeof e.releaseNotes==`string`?e.releaseNotes:void 0,releaseUrl:a,downloadUrl:o,nextSuggestedCheckInSec:typeof e.nextSuggestedCheckInSec==`number`&&Number.isFinite(e.nextSuggestedCheckInSec)?e.nextSuggestedCheckInSec:void 0}}async function In(e,t,n,r){let i=await Nn(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(Mn(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return Fn(a,t.currentVersion,t.platform)}async function Ln(e,t,n,r){let i=await Nn(wn,{method:`GET`,headers:{Accept:`text/html`},redirect:`follow`},n,r);if(!i?.ok)return null;let a=typeof i.url==`string`&&i.url.length>0?i.url:wn,o=null;try{o=new URL(a).pathname.match(/\/releases\/tag\/v(\d+\.\d+\.\d+(?:-[\w.]+)?)/)}catch{return null}if(!o?.[1])return null;let s=o[1],c=kn(s,e),l=`${Tn}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:Pn(t,s)}}async function Rn(e){let t=e.currentVersion?.trim()||`unknown`;if(t===`unknown`)return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`};let n=e.fetchImpl??fetch,r=e.now??Date.now,i=An(),a=r()+Dn;for(let[t,o]of i.entries()){let s=jn(a,i.length-t+1,r);if(s===null)break;let c=await In(o,e,s,n);if(c)return c}let o=jn(a,1,r);if(o!==null){let r=await Ln(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function zn(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=Mt();return e}catch{return`unknown`}}function Bn(){let e=typeof window<`u`?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e===`arm64`||e===`aarch64`)return`arm64`;if(e===`x64`||e===`amd64`||e===`x86_64`)return`x64`;let t=(typeof navigator<`u`?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(t===`arm`||t===`arm64`||t===`aarch64`)return`arm64`;if(t===`x86`||t===`x64`||t===`amd64`)return`x64`;let n=typeof navigator<`u`?navigator.userAgent.toLowerCase():``;return n.includes(`aarch64`)||n.includes(`arm64`)||n.includes(`armv`)?`arm64`:n.includes(`x86_64`)||n.includes(`x64`)||n.includes(`amd64`)||n.includes(`win64`)?`x64`:`unknown`}function Vn(){let e=P();if(e===`android`||e===`ios`)return e;if(typeof navigator>`u`)return`web`;let t=(navigator.platform||``).toLowerCase();return t.includes(`mac`)?`macos`:t.includes(`win`)?`windows`:t.includes(`linux`)?`linux`:`web`}function Hn(e){let t=I.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,zn()),n.set(`arch`,Bn()),n.set(`platform`,Vn()),e===`desktop`?(n.set(`appType`,`desktop-electron`),n.set(`instanceMode`,_()?`local`:`remote`),n):e===`vscode`?(n.set(`appType`,`vscode`),n.set(`instanceMode`,`local`),n):e===`mobile`?(n.set(`appType`,`mobile-capacitor`),n.set(`instanceMode`,`remote`),n):(n.set(`appType`,`web`),n.set(`instanceMode`,`unknown`),n)}async function Un(e,t){let n=t??`unknown`;try{let r=Hn(e),a=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&a&&r.set(`currentVersion`,a);let o=await i(`/api/openchamber/update-check?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),s=null;try{s=await o.json()}catch{s=null}if(!o.ok)return{available:!1,currentVersion:n,error:typeof s?.error==`string`&&s.error.trim().length>0?s.error.trim():`Server responded with ${o.status}`};if(!s)return{available:!1,currentVersion:n,error:`Update check returned an invalid response`};let c=typeof s.error==`string`&&s.error.trim().length>0?s.error.trim():void 0;return{available:s.available===!0,version:typeof s.version==`string`?s.version:void 0,currentVersion:typeof s.currentVersion==`string`?s.currentVersion:n,body:typeof s.body==`string`?s.body:void 0,releaseUrl:typeof s.releaseUrl==`string`?s.releaseUrl:void 0,downloadUrl:typeof s.downloadUrl==`string`?s.downloadUrl:void 0,nextSuggestedCheckInSec:typeof s.nextSuggestedCheckInSec==`number`&&Number.isFinite(s.nextSuggestedCheckInSec)?s.nextSuggestedCheckInSec:void 0,packageManager:typeof s.packageManager==`string`?s.packageManager:void 0,updateCommand:typeof s.updateCommand==`string`?s.updateCommand:void 0,error:c}}catch(e){return console.warn(`Failed to check for updates:`,e),{available:!1,currentVersion:n,error:e instanceof Error?e.message:`Failed to check for updates`}}}function Wn(){return N()?`mobile`:f()?`desktop`:v()?`vscode`:S()?`web`:null}var Gn={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1,lastOtaChannelOverride:null};function Kn(e,t){let n=e.isChannelRollback===!0?{isChannelRollback:!0}:{};return e.primaryAction===`apply_ota`&&e.ota.bundle?e.ota.bundle.releaseVersion===t?{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}:{available:!0,otaPhase:`available`,info:{available:!0,version:e.ota.bundle.releaseVersion,currentVersion:t,downloadUrl:e.ota.bundle.url,nextSuggestedCheckInSec:e.nextCheckInSec,inAppApply:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}}:e.primaryAction===`install_native_required`?{available:e.native.state===`required`||e.native.state===`available`,otaPhase:`idle`,info:{available:e.native.state===`required`||e.native.state===`available`,version:e.native.version,currentVersion:t,downloadUrl:e.native.installUrl,nextSuggestedCheckInSec:e.nextCheckInSec,manualUpdate:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}}:{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}}var qn=w()((e,t)=>({...Gn,checkForUpdates:async()=>{let n=Wn();if(!n)return null;e({checking:!0,error:null,runtimeType:n});try{let r=null,i=null;if(n===`desktop`){let t=await o(),n=t?.downloaded===!0;return e({checking:!1,available:t?.available??!1,downloaded:n,...n?{downloading:!1,progress:null}:{},info:t,error:null,lastChecked:Date.now(),nextCheckInSec:null}),i}if(n===`web`)r=await Un(`web`),i=r?.nextSuggestedCheckInSec??null;else if(n===`vscode`)i=(await Un(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await bn()??`unknown`,o=N()?a()?.mobileUpdates:void 0,s=I.getState().otaChannelOverride;if(o)try{let r=t().lastOtaChannelOverride!==s;e(r?{otaDecision:null,otaPhase:`checking`,downloaded:!1,otaDownloadSkipped:!1,progress:null,available:!1,info:null}:{otaPhase:`checking`});let i=await o.checkForOtaUpdate(s===`beta`||s===`stable`?{channelOverride:s}:void 0),a=Kn(i,n),c=(r?void 0:t().otaDecision?.ota.bundle?.bundleId)!==i.ota.bundle?.bundleId,l=!r&&t().downloaded&&!c;return e({checking:!1,available:a.available,info:a.info,error:a.info.error??null,lastChecked:Date.now(),nextCheckInSec:i.nextCheckInSec,otaDecision:i,otaPhase:l?`pending_restart`:a.otaPhase,lastOtaChannelOverride:s,...c||r?{downloaded:!1,otaDownloadSkipped:!1,progress:null}:{}}),i.nextCheckInSec}catch(t){if(!(t instanceof ee)){let r=t instanceof Error?t.message:`Mobile OTA check failed`;return e({checking:!1,available:!1,info:{available:!1,currentVersion:n},error:r,lastChecked:Date.now(),otaDecision:null,otaPhase:`error`,lastOtaChannelOverride:s}),null}}return r=await Rn({currentVersion:n,platform:Vn()===`ios`?`ios`:`android`,deviceClass:zn(),arch:Bn(),reportUsage:I.getState().reportUsage}),i=r?.nextSuggestedCheckInSec??null,e({checking:!1,available:r?.available??!1,info:r,error:r?.error??null,lastChecked:Date.now(),nextCheckInSec:i,otaDecision:null,otaPhase:`idle`}),i}return e({checking:!1,available:n===`vscode`?!1:r?.available??!1,info:n===`vscode`?null:r,error:n===`vscode`?null:r?.error??null,lastChecked:Date.now(),nextCheckInSec:i}),i}catch(t){return e({checking:!1,error:t instanceof Error?t.message:`Failed to check for updates`}),null}},downloadUpdate:async()=>{let{available:n,runtimeType:r,otaDecision:i,downloading:c,downloaded:l}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`&&i.ota.bundle){if(c||l)return;let t=a()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}e({downloading:!0,error:null,progress:null,otaPhase:`downloading`,otaDownloadSkipped:!1});try{let{skipped:n}=await t.downloadOtaUpdate(i.ota.bundle);await t.queueOtaUpdateForNextLaunch(),e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`,otaDownloadSkipped:n})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n)){e({downloading:!0,error:null,progress:null});try{let n=await o();if(!n?.available)throw Error(`Update detected, but desktop package is not ready yet. Retry in a moment.`);if(e(e=>({info:e.info?{...e.info,...n,body:e.info.body||n.body,available:e.info.available}:n})),n.downloaded||t().downloaded){e({downloading:!1,downloaded:!0,progress:null});return}if(n.downloading&&e({downloading:!0,progress:n.progress??{downloaded:0}}),!await s(t=>{e({progress:t})}))throw Error(`Failed to download update`);e({downloading:!1,downloaded:!0,progress:null})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`})}}},subscribeDesktopUpdateEvents:async()=>{if(!f())return()=>{};let n=[],r=await l(n=>{let r=n.event,i=n.data??null;if(r===`Started`){if(!t().downloading)return;e({error:null,progress:{downloaded:0,total:typeof i?.contentLength==`number`?i.contentLength:void 0}});return}if(r===`Progress`){if(!t().downloading)return;e({progress:{downloaded:typeof i?.downloaded==`number`?i.downloaded:0,total:typeof i?.total==`number`?i.total:void 0}});return}r===`Finished`&&e({downloading:!1,downloaded:!0,progress:null})});r&&n.push(r);let i=await h(t=>{t.downloaded&&e({downloading:!1,downloaded:!0,available:!0,progress:null})});return i&&n.push(i),async()=>{for(let e of n)try{let t=e();t instanceof Promise&&await t}catch{}}},restartToUpdate:async()=>{let{downloaded:n,runtimeType:r,otaDecision:i}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`){if(!n)return;let t=a()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}try{await t.applyOtaUpdateNow()}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n))try{if(!await C())throw Error(`Failed to restart`)}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`})}},setOtaPhase:(t,n=null)=>{e({otaPhase:t,...n===void 0?{}:{error:n}})},setOtaDownloadPercent:n=>{if(!Number.isFinite(n)||n<0||n>100)return;let r=t();if(!r.downloading)return;let i=Math.round(n);if((r.progress?.total?Math.round(r.progress.downloaded/r.progress.total*100):null)===i)return;let a=r.otaDecision?.ota.bundle?.size;if(typeof a==`number`&&Number.isFinite(a)&&a>0){e({progress:{downloaded:Math.round(a*n/100),total:a}});return}e({progress:{downloaded:n,total:100}})},setOtaDownloadFailed:t=>{e({downloading:!1,downloaded:!1,error:t??`Failed to download update`,otaPhase:`error`})},dismiss:()=>{let n=t();(n.runtimeType!==`mobile`||n.otaPhase!==`pending_restart`)&&e({available:!1,downloaded:!1,info:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1})},reset:()=>{e(Gn)}})),Jn=`https://github.com/yee94/openchamber/releases`;function Yn(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(be(),{year:`numeric`,month:`short`,day:`numeric`}).format(t)}function Xn(e){return e.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,``).trim()}function Zn(e){return e.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,`$1[@$2](https://github.com/$2)`)}function Qn(e,t){let n=e.split(`.`).map(e=>Number.parseInt(e,10)),r=t.split(`.`).map(e=>Number.parseInt(e,10));for(let e=0;e<3;e+=1){let t=Number.isFinite(n[e])?n[e]:0,i=Number.isFinite(r[e])?r[e]:0;if(t!==i)return i-t}return 0}function $n(e){let t=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[],r;for(;(r=t.exec(e))!==null;)n.push({version:r[1]??``,date:r[2]??``,start:r.index});return n.length===0?[]:n.map((t,r)=>{let i=n[r+1]?.start??e.length,a=e.slice(t.start,i).trim();return{version:t.version,date:t.date,start:t.start,end:i,raw:a}})}var er=2e3,tr=6e5;async function nr(){try{let e=await i(`/api/openchamber/update-install`,{method:`POST`,headers:{"Content-Type":`application/json`}});return e.ok?{success:!0,autoRestart:(await e.json().catch(()=>({}))).autoRestart!==!1}:{success:!1,error:(await e.json().catch(()=>({}))).error||`Server error: ${e.status}`}}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function rr(){try{return(await i(`/health`,{method:`GET`,headers:{Accept:`application/json`}})).ok}catch{return!1}}async function ir(e,t=Math.ceil(tr/er),n=er){for(let r=0;r<t;r++){try{let t=await i(`/api/openchamber/update-check`,{method:`GET`,headers:{Accept:`application/json`}});if(t.ok){let n=await t.json().catch(()=>null);if(n&&n.available===!1||n&&typeof n.currentVersion==`string`&&typeof e==`string`&&n.currentVersion!==e)return!0}else if((t.status===401||t.status===403)&&await rr())return!0}catch{}await new Promise(e=>setTimeout(e,n))}return!1}var ar=({open:e,onOpenChange:t,info:n,downloading:r,downloaded:i,progress:a,error:o,onDownload:s,onRestart:c,runtimeType:l=`desktop`})=>{let{t:u}=W(),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(`idle`),[h,g]=(0,Q.useState)(null),_=qn(e=>e.otaDownloadSkipped),v=n?.releaseUrl||(n?.version?`${Jn}/tag/v${n.version}`:Jn),y=n?.downloadUrl,b=a?.total?Math.round(a.downloaded/a.total*100):0,x=l===`web`,S=l===`mobile`,C=S&&n?.manualUpdate===!0&&!!y,w=S&&n?.inAppApply===!0,T=l===`desktop`&&n?.manualUpdate===!0,E=n?.updateCommand||`openchamber update`,D=U(e=>{!e&&w&&i&&qn.getState().dismiss(),t(e)}),O=U(()=>{qn.getState().dismiss(),t(!1)});(0,Q.useEffect)(()=>{e||(m(`idle`),g(null))},[e]);let k=async()=>{(await ye(E)).ok&&(f(!0),setTimeout(()=>f(!1),2e3))},A=(0,Q.useCallback)(async e=>{await It(e)},[]),j=(0,Q.useCallback)(async()=>{m(`updating`),g(null);let e=await nr();if(!e.success){m(`error`),g(e.error||u(`updateDialog.error.updateFailed`));return}e.autoRestart&&(m(`restarting`),await new Promise(e=>setTimeout(e,2e3))),m(`reconnecting`),await ir(n?.currentVersion)?window.location.reload():(m(`error`),g(u(`updateDialog.error.takingLonger`)))},[n?.currentVersion,u]),M=(0,Q.useCallback)(()=>{y&&A(y)},[A,y]),N=p!==`idle`&&p!==`error`,P=(0,Q.useMemo)(()=>{if(!n?.body)return null;let e=n.body.trim();if(!e)return null;let t=$n(e);if(t.length===0)return{kind:`raw`,title:u(`updateDialog.changelog.title`),content:Zn(e)};let r=[...t].sort((e,t)=>Qn(e.version,t.version));return{kind:`sections`,title:u(`updateDialog.changelog.title`),sections:r.map(t=>({version:t.version,dateLabel:Yn(t.date),content:Zn(Xn(t.raw)||e)}))}},[n?.body,u]);return(0,Z.jsx)(ze,{open:e,onOpenChange:N?void 0:D,children:(0,Z.jsxs)(Ie,{className:`max-w-4xl gap-0 p-4 sm:p-5 bg-background border-[var(--interactive-border)]`,showCloseButton:!0,children:[(0,Z.jsxs)(`div`,{className:`mb-3 pr-8 sm:mb-4`,children:[(0,Z.jsxs)(Le,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Y,{name:`download-cloud`,className:`h-5 w-5 text-[var(--primary-base)]`}),(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:u(p===`restarting`||p===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`)})]}),(n?.currentVersion||n?.version)&&(0,Z.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5 pl-7 font-mono text-[11px] leading-4 tracking-[-0.01em] tabular-nums sm:text-xs`,children:[n?.currentVersion&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/75`,children:n.currentVersion}),n?.currentVersion&&n?.version&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),n?.version&&(0,Z.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:n.version})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[x&&N&&(0,Z.jsxs)(`div`,{className:`rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(Y,{name:`loader`,className:`h-5 w-5 animate-spin text-[var(--primary-base)]`}),(0,Z.jsxs)(`div`,{className:`typography-ui-label text-foreground`,children:[p===`updating`&&u(`updateDialog.status.installingUpdate`),p===`restarting`&&u(`updateDialog.status.serverRestarting`),p===`reconnecting`&&u(`updateDialog.status.waitingForServer`)]})]}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:u(`updateDialog.status.autoReloadHint`)})]}),P&&!N&&(0,Z.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3.5 py-2.5 sm:px-4 sm:py-3`,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--primary-base)]`,"aria-hidden":`true`}),(0,Z.jsx)(`h3`,{className:`typography-ui-caption font-medium text-muted-foreground`,children:P.title})]}),(0,Z.jsx)(Nt,{className:`max-h-[min(42dvh,22rem)] p-0 sm:max-h-[400px]`,fillContainer:!1,children:P.kind===`raw`?(0,Z.jsx)(`div`,{className:`break-words p-3.5 text-[13px] leading-[1.65] text-foreground sm:p-4 sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&t.href&&(e.preventDefault(),e.stopPropagation(),A(t.href))},children:(0,Z.jsx)(Ft,{content:P.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,Z.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:P.sections.map(e=>(0,Z.jsxs)(`div`,{className:`p-3.5 sm:p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-center gap-x-2 gap-y-1 sm:mb-3`,children:[(0,Z.jsxs)(`span`,{className:`rounded-md bg-[var(--primary-base)]/10 px-1.5 py-0.5 font-mono text-[11px] font-medium leading-4 text-[var(--primary-base)] tabular-nums sm:text-xs`,children:[`v`,e.version]}),(0,Z.jsx)(`span`,{className:`text-[11px] leading-4 text-muted-foreground/75 sm:text-xs`,children:e.dateLabel})]}),(0,Z.jsx)(`div`,{className:`break-words text-[13px] leading-[1.65] text-foreground sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&t.href&&(e.preventDefault(),e.stopPropagation(),A(t.href))},children:(0,Z.jsx)(Ft,{content:e.content,disableLinkSafety:!0,enableFileReferences:!1})})]},e.version))})})]}),x&&p===`error`&&(0,Z.jsxs)(`div`,{className:`space-y-2 mt-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground`,children:[(0,Z.jsx)(Y,{name:`terminal`,className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:u(`updateDialog.fallback.updateViaTerminal`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]`,children:[(0,Z.jsx)(`code`,{className:`flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap`,children:E}),(0,Z.jsx)(`button`,{onClick:k,className:G(`flex items-center justify-center p-2 rounded`,`text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]`,`transition-colors`,d&&`text-[var(--status-success)]`),title:u(d?`updateDialog.actions.copied`:`updateDialog.actions.copyCommand`),children:d?(0,Z.jsx)(Y,{name:`check`,className:`h-4 w-4`}):(0,Z.jsx)(Y,{name:`clipboard`,className:`h-4 w-4`})})]})]}),!x&&(!S||w)&&r&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 px-3.5 py-3 sm:mt-4 sm:px-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground sm:text-[13px]`,children:u(`updateDialog.status.downloadingPayload`)}),(0,Z.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] leading-4 text-foreground tabular-nums sm:text-xs`,children:[b,`%`]})]}),(0,Z.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-all duration-300`,style:{width:`${b}%`}})})]}),(o||h)&&(0,Z.jsx)(`div`,{className:`p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg`,children:(0,Z.jsx)(`p`,{className:`text-sm text-[var(--status-error)]`,children:o||h})})]}),w&&i&&_&&(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg border border-[var(--status-success-border)] bg-[var(--status-success-background)] px-3 py-2.5 text-sm text-[var(--status-success)]`,children:[(0,Z.jsx)(Y,{name:`check`,className:`h-4 w-4 shrink-0`}),(0,Z.jsx)(`span`,{children:u(`updateDialog.status.otaBundleReused`)})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[!S||C?(0,Z.jsxs)(`a`,{href:S?y:v,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground hover:text-foreground transition-colors shrink-0`,children:[(0,Z.jsx)(Y,{name:`external-link`,className:`h-4 w-4`}),`GitHub`]}):(0,Z.jsx)(`span`,{}),(0,Z.jsxs)(`div`,{className:`flex-1 flex justify-end`,children:[!x&&(!S||w)&&!T&&!i&&!r&&(0,Z.jsxs)(K,{onClick:s,size:`default`,children:[(0,Z.jsx)(Y,{name:`download`,className:`h-4 w-4`}),u(w?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`)]}),!x&&!S&&T&&!i&&!r&&(0,Z.jsxs)(K,{onClick:()=>void A(v),size:`default`,children:[(0,Z.jsx)(Y,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),!x&&(!S||w)&&r&&(0,Z.jsxs)(K,{disabled:!0,size:`default`,children:[(0,Z.jsx)(Y,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.downloading`)]}),!x&&(!S||w)&&i&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w&&(0,Z.jsx)(K,{onClick:O,variant:`ghost`,size:`default`,children:u(`updateDialog.actions.later`)}),(0,Z.jsxs)(K,{onClick:c,size:`default`,children:[(0,Z.jsx)(Y,{name:`restart`,className:`h-4 w-4`}),u(`updateDialog.actions.restartToUpdate`)]})]}),S&&!w&&C&&(0,Z.jsxs)(K,{onClick:M,size:`default`,children:[(0,Z.jsx)(Y,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),x&&!N&&(0,Z.jsxs)(K,{onClick:j,size:`default`,children:[(0,Z.jsx)(Y,{name:`download`,className:`h-4 w-4`}),u(`updateDialog.actions.updateNow`)]}),x&&N&&(0,Z.jsxs)(K,{disabled:!0,size:`default`,children:[(0,Z.jsx)(Y,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.updating`)]})]})]})]})})},or=e(k(),1);function sr(e){let t=(0,X.c)(20),{label:n,children:r,description:i,itemId:a,ariaLabel:o,className:s,cardClassName:c,cardId:l}=e,u=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,d;t[0]===s?d=t[1]:(d=G(`oc-settings-group`,s),t[0]=s,t[1]=d);let f;t[2]!==n||t[3]!==u?(f=n?(0,Z.jsx)(`div`,{className:`oc-settings-group-label`,"data-settings-label-script":u,children:n}):null,t[2]=n,t[3]=u,t[4]=f):f=t[4];let p;t[5]===c?p=t[6]:(p=G(`oc-settings-group-card`,c),t[5]=c,t[6]=p);let m;t[7]!==l||t[8]!==r||t[9]!==a||t[10]!==p?(m=(0,Z.jsx)(`div`,{id:l,"data-settings-item":a,className:p,children:r}),t[7]=l,t[8]=r,t[9]=a,t[10]=p,t[11]=m):m=t[11];let h;t[12]===i?h=t[13]:(h=i?(0,Z.jsx)(`p`,{className:`oc-settings-group-description text-muted-foreground`,children:i}):null,t[12]=i,t[13]=h);let g;return t[14]!==o||t[15]!==d||t[16]!==f||t[17]!==m||t[18]!==h?(g=(0,Z.jsxs)(`section`,{className:d,"aria-label":o,children:[f,m,h]}),t[14]=o,t[15]=d,t[16]=f,t[17]=m,t[18]=h,t[19]=g):g=t[19],g}function cr(e){let t=(0,X.c)(20),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({label:s,description:a,descriptionPlacement:l,ariaLabel:n,groupClassName:o,cardClassName:r,children:i,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=l===void 0?`inside`:l,d=u===`outside`?a:void 0,f=u===`inside`?a:void 0,p;t[9]!==i||t[10]!==s||t[11]!==c||t[12]!==f?(p=(0,Z.jsx)(lr,{label:s,description:f,...c,children:i}),t[9]=i,t[10]=s,t[11]=c,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==n||t[15]!==r||t[16]!==o||t[17]!==d||t[18]!==p?(m=(0,Z.jsx)(sr,{ariaLabel:n,className:o,cardClassName:r,description:d,children:p}),t[14]=n,t[15]=r,t[16]=o,t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function lr(e){let t=(0,X.c)(22),{label:n,children:r,description:i,itemId:a,className:o,copyClassName:s,controlClassName:c}=e,l;t[0]===o?l=t[1]:(l=G(`oc-settings-group-row oc-settings-split-row`,o),t[0]=o,t[1]=l);let u;t[2]===s?u=t[3]:(u=G(`oc-settings-split-row-copy`,s),t[2]=s,t[3]=u);let d;t[4]===n?d=t[5]:(d=n?(0,Z.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:n}):null,t[4]=n,t[5]=d);let f;t[6]===i?f=t[7]:(f=i?(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}):null,t[6]=i,t[7]=f);let p;t[8]!==u||t[9]!==d||t[10]!==f?(p=(0,Z.jsxs)(`div`,{className:u,children:[d,f]}),t[8]=u,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===c?m=t[13]:(m=G(`oc-settings-split-row-control`,c),t[12]=c,t[13]=m);let h;t[14]!==r||t[15]!==m?(h=(0,Z.jsx)(`div`,{"data-settings-value":``,className:m,children:r}),t[14]=r,t[15]=m,t[16]=h):h=t[16];let g;return t[17]!==a||t[18]!==l||t[19]!==p||t[20]!==h?(g=(0,Z.jsxs)(`div`,{"data-settings-item":a,className:l,children:[p,h]}),t[17]=a,t[18]=l,t[19]=p,t[20]=h,t[21]=g):g=t[21],g}function ur(e){let t=(0,X.c)(32),{checked:n,onChange:r,label:i,ariaLabel:a,description:o,itemId:s,disabled:c,className:l}=e,u=c!==void 0&&c,d;t[0]!==n||t[1]!==u||t[2]!==r?(d=()=>{u||r(!n)},t[0]=n,t[1]=u,t[2]=r,t[3]=d):d=t[3];let f=d,p=dr,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=G(`oc-settings-group-row oc-settings-split-row group`,m,l),t[4]=l,t[5]=m,t[6]=h):h=t[6];let g=u?-1:0,_=u||void 0,v,y;t[7]===f?(v=t[8],y=t[9]):(v=e=>{p(e.target)||f()},y=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=v,t[9]=y);let b;t[10]===i?b=t[11]:(b=(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=b);let x;t[12]===o?x=t[13]:(x=o?(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=x);let S;t[14]!==x||t[15]!==b?(S=(0,Z.jsxs)(`div`,{className:`oc-settings-split-row-copy`,children:[b,x]}),t[14]=x,t[15]=b,t[16]=S):S=t[16];let C;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(C=(0,Z.jsx)(`div`,{"data-settings-value":``,className:`oc-settings-split-row-control`,children:(0,Z.jsx)(qe,{checked:n,onChange:r,disabled:u,ariaLabel:a})}),t[17]=a,t[18]=n,t[19]=u,t[20]=r,t[21]=C):C=t[21];let w;return t[22]!==n||t[23]!==s||t[24]!==S||t[25]!==C||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==v||t[30]!==y?(w=(0,Z.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":_,onClick:v,onKeyDown:y,children:[S,C]}),t[22]=n,t[23]=s,t[24]=S,t[25]=C,t[26]=h,t[27]=g,t[28]=_,t[29]=v,t[30]=y,t[31]=w):w=t[31],w}function dr(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}var fr=[`connection`,`personalization`,`workspace`,`opencode`,`content`,`system`],pr=[`instances`,`appearance`,`chat`,`notifications`,`sessions`,`archived-sessions`,`summary-ai`,`shortcuts`,`projects`,`git`,`remote-instances`,`providers`,`agents`,`assistants`,`behavior`,`commands`,`mcp`,`plugins`,`global-config`,`magic-prompts`,`skills.installed`,`skills.catalog`,`usage`,`voice`,`about`],mr=[`instances`,`appearance`,`chat`,`notifications`,`sessions`,`archived-sessions`,`summary-ai`,`projects`,`git`,`providers`,`agents`,`assistants`,`behavior`,`commands`,`mcp`,`plugins`,`magic-prompts`,`skills.installed`,`usage`,`voice`,`about`],hr=[{slug:`home`,title:`Settings`,group:`personalization`,kind:`single`,description:`Search and jump to common pages.`,keywords:[`search`,`settings`]},{slug:`projects`,title:`Projects`,group:`workspace`,kind:`split`,keywords:[`project`,`projects`,`worktree`,`worktrees`,`repo`,`repository`,`directory`]},{slug:`instances`,title:`Switch instance`,group:`connection`,kind:`single`,keywords:[`instance`,`instances`,`server`,`connection`,`switch`],isAvailable:e=>e.isMobile},{slug:`remote-instances`,title:`Remote Instances`,group:`workspace`,kind:`single`,keywords:[`ssh`,`remote`,`instances`,`forwarding`,`connection`],isAvailable:e=>!e.isVSCode},{slug:`providers`,title:`Providers`,group:`opencode`,kind:`split`,keywords:[`provider`,`providers`,`models`,`model`,`api key`,`api keys`,`openai`,`anthropic`,`ollama`,`credentials`]},{slug:`usage`,title:`Usage`,group:`system`,kind:`split`,keywords:[`quota`,`billing`,`tokens`,`usage`,`limits`]},{slug:`agents`,title:`Agents`,group:`opencode`,kind:`split`,keywords:[`agent`,`agents`,`prompts`,`tools`,`permissions`]},{slug:`assistants`,title:`Assistants`,group:`opencode`,kind:`split`,keywords:[`assistant`,`assistants`,`sharing`]},{slug:`behavior`,title:`Behavior`,group:`opencode`,kind:`single`,keywords:[`behavior`,`agents.md`,`system prompt`,`global rules`,`instructions`,`override`]},{slug:`commands`,title:`Commands`,group:`opencode`,kind:`split`,keywords:[`command`,`commands`,`slash`,`macros`,`automation`]},{slug:`mcp`,title:`MCP`,group:`opencode`,kind:`split`,keywords:[`mcp`,`model context protocol`,`servers`,`tools`,`remote`,`stdio`]},{slug:`plugins`,title:`Plugins`,group:`opencode`,kind:`split`,keywords:[`plugin`,`plugins`,`extensions`,`addons`,`npm`,`opencode-wakatime`]},{slug:`global-config`,title:`Global Configuration`,group:`opencode`,kind:`single`,keywords:[`global`,`configuration`,`opencode.json`,`opencode.jsonc`,`oh-my-opencode`,`oh-my-openagent`]},{slug:`skills.installed`,title:`Skills`,group:`content`,kind:`split`,keywords:[`skill`,`skills`,`instructions`,`install`,`catalog`]},{slug:`skills.catalog`,title:`Skills Catalog`,group:`content`,kind:`single`,keywords:[`install`,`catalog`,`external`,`repository`,`skills catalog`]},{slug:`git`,title:`Git`,group:`workspace`,kind:`single`,keywords:[`git`,`github`,`identity`,`identities`,`ssh`,`profiles`,`credentials`,`keys`,`commit`,`gitmoji`,`oauth`,`prs`,`issues`],isAvailable:e=>!e.isVSCode},{slug:`appearance`,title:`Appearance`,group:`personalization`,kind:`single`,keywords:[`theme`,`font`,`spacing`,`padding`,`corner radius`,`radius`,`input bar`,`keyboard`,`viewport`,`mobile`,`terminal`,`pwa`,`install name`,`app shortcuts`]},{slug:`chat`,title:`Chat`,group:`personalization`,kind:`single`,keywords:[`tools`,`diff`,`reasoning`,`dotfiles`,`draft`,`queue`,`output`,`copy`,`image`,`split messages`,`message actions`]},{slug:`shortcuts`,title:`Shortcuts`,group:`personalization`,kind:`single`,keywords:[`keyboard`,`hotkeys`,`shortcuts`,`bindings`],isAvailable:e=>!e.isVSCode},{slug:`sessions`,title:`Sessions`,group:`personalization`,kind:`single`,keywords:[`defaults`,`default agent`,`default model`,`retention`,`memory`,`limits`,`zen`]},{slug:`archived-sessions`,title:`Archived sessions`,group:`personalization`,kind:`single`,keywords:[`archive`,`archived`,`restore`,`preview`,`history`]},{slug:`summary-ai`,title:`Summary AI`,group:`personalization`,kind:`single`,keywords:[`summary`,`commit`,`session title`,`prompt`,`provider`,`custom api`,`base url`,`api token`]},{slug:`magic-prompts`,title:`Magic Prompts`,group:`content`,kind:`split`,keywords:[`prompts`,`templates`,`git`,`github`,`review`,`commit`,`pull request`],isAvailable:e=>!e.isVSCode},{slug:`notifications`,title:`Notifications`,group:`personalization`,kind:`single`,keywords:[`alerts`,`native`,`summary`,`summarization`]},{slug:`voice`,title:`Voice`,group:`system`,kind:`single`,keywords:[`tts`,`speech`,`voice`],isAvailable:e=>!e.isVSCode},{slug:`about`,title:`About`,group:`system`,kind:`single`,keywords:[`about`,`version`,`updates`,`release`,`changelog`],isAvailable:e=>e.isMobile}];function gr(e){let t=new Map(pr.map((e,t)=>[e,t])),n=new Map;for(let t of e){let e=n.get(t.group)??[];e.push(t),n.set(t.group,e)}return fr.flatMap(e=>{let r=n.get(e);return r?.length?[{group:e,pages:r.sort((e,n)=>(t.get(e.slug)??999)-(t.get(n.slug)??999))}]:[]})}var _r={sessions:`sessions`,agents:`agents`,commands:`commands`,mcp:`mcp`,skills:`skills.installed`,providers:`providers`,usage:`usage`,"git-identities":`git`,settings:`home`};function vr(e){let t=e.trim().toLowerCase();return hr.find(e=>e.slug===t)??null}function yr(e){let t=(e??``).trim().toLowerCase();if(!t)return`home`;let n=_r[t];if(n)return n;let r=vr(t);return r?r.slug:`home`}var br=`/mcp/oauth/callback`,xr=e=>{if(typeof window>`u`)return null;try{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t.length%4==0?``:`=`.repeat(4-t.length%4),r=window.atob(t+n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return new TextDecoder().decode(i)}catch{return null}},Sr=e=>{let t=wr(e.get(`state`));if(t)return t;let n=e.get(`server`);if(typeof n!=`string`||!n.trim())return null;let r=e.get(`directory`);return{name:n.trim(),directory:typeof r==`string`&&r.trim()?r.trim():null}},Cr=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},wr=e=>{if(typeof e!=`string`||!e.trim())return null;let t=xr(e.trim());if(!t)return null;try{let e=JSON.parse(t);return e?.v!==1||typeof e.n!=`string`||!e.n.trim()?null:{name:e.n.trim(),directory:typeof e.d==`string`&&e.d.trim()?e.d.trim():null}}catch{return null}},Tr=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,Er=e=>{let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=tn(e);if(!n)return{top:!1,dom:t};n.state.statusbar=t;let r=n.state.vimPlugin;return Tr(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function Dr(e){return e?[en(),_e.of(Er),ge()]:[]}var Or={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},kr={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function Ar(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries(Or)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(kr)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var jr=new WeakMap;function Mr(e,t){let n=Xt(e.state);if(!n.valid)return jr.delete(e),0;let r=jr.get(e);if(!t&&r?.doc===e.state.doc&&r.query.eq(n))return r.total;let i=n.getCursor(e.state),a=0;for(let e=i.next();!e.done;e=i.next())a+=1;return jr.set(e,{query:n,doc:e.state.doc,total:a}),a}function Nr(e){let t=Xt(e.state);if(!t.valid)return 0;let n=e.state.selection.main,r=t.getCursor(e.state),i=0,a=0;for(let e=r.next();!e.done;e=r.next()){let t=e.value;if(i+=1,a===0&&(a=i),n.from===t.from&&n.to===t.to||n.from<t.to&&n.to>t.from||t.from>=n.head)return i}return a}function Pr(e,t,n=!1){let r=e.querySelector(`.cm-search`);if(!r)return;let i=r.querySelector(`.cm-search-message`);if(!i){i=document.createElement(`span`),i.className=`cm-search-message`,i.setAttribute(`aria-live`,`polite`);let e=r.querySelector(`button[name="next"]`),t=e?.parentNode===r?e:r.firstChild;r.insertBefore(i,t)}let a=Mr(t,n),o=a===0?0:Nr(t);i.textContent=a===0?``:`${o}/${a}`}var Fr=new H,Ir=new H,Lr=new H,Rr=new H,zr=new H,Br=new H,Vr=new H,Hr=e=>e,Ur=se,Wr=Jt,Gr=Qt,Kr=class extends re{id;containerMap;constructor(e,t){super(),this.id=e,this.containerMap=t}toDOM(){let e=this.containerMap.get(this.id);return e||(e=document.createElement(`div`),e.className=`oc-block-widget`,e.dataset.widgetId=this.id,this.containerMap.set(this.id,e)),e}eq(e){return e.id===this.id}destroy(){}},qr=(e,t)=>!e||e.length===0?[]:fe.define({create(n){let r=new he,i=[...e].sort((e,t)=>e.afterLine-t.afterLine);for(let e of i){let i=n.doc.lines;if(e.afterLine>i)continue;let a=n.doc.line(e.afterLine);r.add(a.to,a.to,z.widget({widget:new Kr(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>V.decorations.from(e)}),Jr=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return ne.fromClass(class{decorations;constructor(e){this.decorations=this.build(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=this.build(e.view))}build(e){let r=new he;for(let i=t;i<=n&&i<=e.state.doc.lines;i+=1){let t=e.state.doc.line(i);r.add(t.from,t.from,z.line({class:`oc-cm-selected-line`}))}return r.finish()}},{decorations:e=>e.decorations})};function Yr({value:e,onChange:t,extensions:n,className:r,readOnly:i,lineNumbersConfig:a,highlightLines:o,onViewReady:s,onViewDestroy:c,blockWidgets:l,enableSearch:u,searchOpen:d,onSearchOpenChange:f,vimMode:p}){let m=Q.useRef(null),h=Q.useRef(null),g=Q.useRef(e),_=Q.useRef(t),v=Q.useRef(s),y=Q.useRef(c),b=Q.useRef(f),x=Q.useRef(l),S=Q.useRef(p),C=Q.useRef(new Map),[w,T]=Q.useState([]),E=Q.useCallback(e=>{let t=(e??[]).map(e=>{let t=C.current.get(e.id);return t?{id:e.id,content:e.content,container:t}:null}).filter(e=>e!==null);T(e=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.content===r.content&&e.container===r.container})?e:t)},[]),D=Q.useCallback(e=>{let t=m.current,n=e??h.current;if(!t||!n)return;let r=n.dom.querySelector(`.cm-gutters`),i=r instanceof HTMLElement?r.getBoundingClientRect().width:0;t.style.setProperty(`--oc-editor-gutter-width`,`${i}px`)},[]);return Q.useEffect(()=>{g.current=e},[e]),Q.useEffect(()=>{_.current=t},[t]),Q.useEffect(()=>{v.current=s,y.current=c},[s,c]),Q.useEffect(()=>{b.current=f},[f]),Q.useEffect(()=>{x.current=l,E(l)},[l,E]),Q.useEffect(()=>{if(!m.current)return;let e=(()=>{if(typeof document>`u`)return null;let e=document.querySelector(`meta[name="csp-nonce"]`)?.getAttribute(`content`);if(e)return e;let t=window.__OPENCHAMBER_CSP_NONCE__;return typeof t==`string`&&t.length>0?t:null})(),t=pe.create({doc:g.current,extensions:[...e?[V.cspNonce.of(e)]:[],ce({fixed:!0}),Fr.of(oe(a)),Kt(),te.of(` `),Vr.of(Dr(p)),le.of([Gt,...Wt,...qt]),V.updateListener.of(e=>{D(e.view),(e.viewportChanged||e.geometryChanged)&&E(x.current);let t=Yt(e.startState),n=Yt(e.state);t!==n&&b.current?.(n);let r=!Xt(e.startState).eq(Xt(e.state));if(n&&(t!==n||r||e.docChanged||e.selectionSet)&&Pr(e.view.dom,e.view,t!==n||r||e.docChanged),!e.docChanged)return;let i=e.state.doc.toString();g.current=i,_.current(i),E(x.current)}),Ir.of(V.editable.of(!i)),Lr.of(n??[]),Rr.of(Jr(o)),zr.of(qr(l,C.current)),Br.of(u?[Zt({top:!0}),le.of(Hr($t))]:[])]});return h.current=new V({state:t,parent:m.current}),Ur(h.current,h.current.state.doc.length,200),h.current.requestMeasure(),requestAnimationFrame(()=>{D(h.current),E(x.current)}),h.current&&v.current?.(h.current),()=>{y.current?.(),h.current?.destroy(),h.current=null,T([])}},[x,D,E]),Q.useEffect(()=>{let e=h.current;e&&(e.dispatch({effects:[Fr.reconfigure(oe(a)),Ir.reconfigure(V.editable.of(!i)),Lr.reconfigure(n??[]),Rr.reconfigure(Jr(o)),zr.reconfigure(qr(l,C.current)),Br.reconfigure(u?[Zt({top:!0}),le.of(Hr($t))]:[])]}),Ur(e,e.state.doc.length,200),e.requestMeasure(),requestAnimationFrame(()=>{D(e),E(x.current)}))},[n,o,a,i,l,u,D,E]),Q.useEffect(()=>{let e=h.current;if(!e){S.current=p;return}S.current!==p&&(S.current=p,e.dispatch({effects:Vr.reconfigure(Dr(p))}))},[p]),Q.useEffect(()=>{let e=h.current;!e||u===!1||(d?(Wr(e),requestAnimationFrame(()=>{Ar(e.dom),Pr(e.dom,e,!0)})):Gr(e))},[d,u]),Q.useEffect(()=>{let t=h.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),Ur(t,t.state.doc.length,300),t.requestMeasure(),requestAnimationFrame(()=>D(t)))},[e,D]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{ref:m,className:G(`h-full w-full`,`[&_.cm-editor]:h-full [&_.cm-editor]:w-full`,`[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6`,`[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]`,r)}),w.map(e=>(0,or.createPortal)(e.content,e.container,e.id))]})}function Xr(e,t){let n=e.metadata.variant===`dark`,r=e.config?.fonts?.mono||`monospace`,i=e.colors.syntax.highlights||{},a=e.colors.syntax.tokens||{},o=t?.fontSize?`${t.fontSize}px`:`var(--text-code)`,s=V.theme({"&":{backgroundColor:`var(--background)`,color:e.colors.syntax.base.foreground,fontSize:o,lineHeight:`1.5`,position:`relative`},".cm-scroller":{fontFamily:r,backgroundColor:`var(--background)`},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:a.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:a.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:a.boolean||e.colors.syntax.base.number},".cm-builtin":{color:a.functionCall||e.colors.syntax.base.function},".cm-def":{color:a.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:a.variableOther||a.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:a.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:a.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:a.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:a.tag||e.colors.syntax.base.keyword},".cm-link":{color:a.url||e.colors.syntax.base.keyword,textDecoration:`underline`},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:`var(--background)`,color:i.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:`sticky`,paddingRight:`8px`,left:0,zIndex:2,boxShadow:`0 0 0 var(--background)`},".cm-gutter":{backgroundColor:`var(--background)`},".cm-gutterElement":{backgroundColor:`var(--background)`},".cm-lineNumbers":{backgroundColor:`var(--background)`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`8px`,paddingRight:`8px`,minWidth:`42px`},".cm-activeLineGutter":{color:i.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-panels":{backgroundColor:`transparent`,color:e.colors.surface.foreground,position:`absolute`,top:`0`,right:`0`,left:`auto`,width:`auto`,zIndex:10,pointerEvents:`none`},".cm-panels-top":{borderBottom:`none`,position:`absolute`,top:`6px`,right:`14px`,left:`auto`,width:`auto`},".cm-panels-bottom":{position:`static`,width:`100%`,pointerEvents:`auto`},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.mutedForeground,fontFamily:`var(--font-mono)`,fontSize:`12px`,minHeight:`22px`,padding:`2px 8px`},".cm-panel.cm-search":{pointerEvents:`auto`,padding:`4px`,backgroundColor:`color-mix(in srgb, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:`10px`,boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:`auto`,minWidth:`360px`,maxWidth:`480px`},".cm-search":{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`0`,width:`100%`,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`13px`,lineHeight:`1`},".cm-search br":{display:`none`},".cm-search .cm-textfield":{appearance:`none`,height:`26px`,margin:0,padding:`0 8px`,borderRadius:`6px !important`,border:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`12px`,lineHeight:`1`,outline:`none`,transition:`border-color 150ms ease`},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:`1 1 120px`,maxWidth:`calc(100% - 142px)`,minWidth:`100px`},".cm-search label":{order:2,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`1px solid transparent`,backgroundColor:`transparent`,color:`transparent`,cursor:`pointer`,userSelect:`none`,fontSize:`1px`,lineHeight:`0`,overflow:`hidden`,position:`relative`,transition:`background-color 120ms ease, border-color 120ms ease`},".cm-search label:hover":{backgroundColor:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:`none`,WebkitAppearance:`none`,width:`0`,height:`0`,margin:`0`,padding:`0`,border:`none`,position:`absolute`,opacity:`0`,pointerEvents:`none`},".cm-search label::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`13px`,fontWeight:`600`,lineHeight:`1`,fontFamily:`inherit`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:`"Aa"`,fontSize:`12px`,letterSpacing:`-0.5px`},'.cm-search label:has(input[name="re"])::after':{content:`".*"`,fontSize:`13px`,fontFamily:`monospace`},'.cm-search label:has(input[name="word"])::after':{content:`"ab"`,fontSize:`12px`,textDecoration:`underline`,textUnderlineOffset:`2px`},".cm-search .cm-search-message":{order:3,color:e.colors.surface.mutedForeground,backgroundColor:`transparent`,border:`none`,borderRadius:`0`,padding:`0 6px`,fontSize:`11px`,whiteSpace:`nowrap`,lineHeight:`26px`},".cm-search .cm-button":{appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:`transparent`,cursor:`pointer`,fontSize:`1px`,fontWeight:`400`,lineHeight:`0`,overflow:`hidden`,position:`relative`,boxShadow:`none`,transition:`background-color 120ms ease`},".cm-search .cm-button::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`15px`,lineHeight:`1`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:`none`,boxShadow:`0 0 0 1px ${e.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:`default`,pointerEvents:`none`},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:`2px`},'.cm-search .cm-button[name="prev"]::after':{content:`"↑"`},'.cm-search .cm-button[name="next"]':{order:22,marginTop:`2px`},'.cm-search .cm-button[name="next"]::after':{content:`"↓"`},'.cm-search .cm-button[name="select"]':{order:23,marginTop:`2px`},'.cm-search .cm-button[name="select"]::after':{content:`"≡"`,fontSize:`17px`},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:`0 0 0 auto`,padding:`0`,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:e.colors.surface.mutedForeground,cursor:`pointer`,fontSize:`16px`,lineHeight:`1`,boxShadow:`none`,position:`relative`,overflow:`visible`,transition:`background-color 120ms ease, color 120ms ease`},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:e.colors.interactive.hover,color:e.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:`2px`},'.cm-search .cm-button[name="replace"]::after':{content:`"⇄"`},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:`2px`},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:`"⇉"`},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:`1 1 100%`,maxWidth:`calc(100% - 142px)`,minWidth:`80px`,marginTop:`2px`},".cm-searchMatch":{backgroundColor:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:`2px`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:`none`}},{dark:n}),c=ue.define([{tag:[B.comment,B.docComment,B.meta,B.documentMeta],class:`cm-comment`},{tag:[B.keyword,B.controlKeyword,B.moduleKeyword,B.definitionKeyword,B.modifier],class:`cm-keyword`},{tag:[B.operatorKeyword,B.operator,B.derefOperator,B.updateOperator,B.definitionOperator,B.typeOperator,B.controlOperator,B.logicOperator,B.bitwiseOperator,B.arithmeticOperator,B.compareOperator],class:`cm-operator`},{tag:[B.punctuation,B.separator,B.bracket,B.paren,B.brace,B.squareBracket,B.angleBracket],class:`cm-punctuation`},{tag:[B.string,B.regexp,B.attributeValue,B.special(B.string),B.monospace],class:`cm-string`},{tag:B.escape,class:`cm-string-2`},{tag:[B.number,B.bool,B.atom,B.null,B.self],class:`cm-number`},{tag:[B.function(B.variableName),B.function(B.definition(B.variableName)),B.function(B.propertyName),B.standard(B.variableName),B.special(B.variableName)],class:`cm-builtin`},{tag:B.definition(B.variableName),class:`cm-def`},{tag:[B.variableName,B.local(B.variableName),B.constant(B.variableName),B.literal],class:`cm-variable`},{tag:B.propertyName,class:`cm-property`},{tag:B.attributeName,class:`cm-attribute`},{tag:[B.className,B.typeName,B.namespace],class:`cm-variable-3`},{tag:[B.tagName,B.labelName,B.annotation,B.macroName],class:`cm-tag`},{tag:B.link,class:`cm-link`},{tag:[B.heading,B.heading1,B.heading2,B.heading3,B.heading4,B.heading5,B.heading6],class:`cm-keyword`}]),l=ue.define([{tag:[B.comment,B.docComment,B.meta,B.documentMeta],color:e.colors.syntax.base.comment},{tag:[B.keyword,B.controlKeyword,B.moduleKeyword,B.definitionKeyword,B.modifier],color:e.colors.syntax.base.keyword},{tag:[B.operatorKeyword,B.operator,B.derefOperator,B.updateOperator,B.definitionOperator,B.typeOperator,B.controlOperator,B.logicOperator,B.bitwiseOperator,B.arithmeticOperator,B.compareOperator],color:e.colors.syntax.base.operator},{tag:[B.string,B.regexp,B.attributeValue,B.special(B.string),B.monospace],color:e.colors.syntax.base.string},{tag:B.escape,color:a.stringEscape||e.colors.syntax.base.string},{tag:[B.number,B.bool,B.atom,B.null,B.self],color:e.colors.syntax.base.number},{tag:[B.function(B.variableName),B.function(B.definition(B.variableName)),B.function(B.propertyName),B.standard(B.variableName),B.special(B.variableName)],color:e.colors.syntax.base.function},{tag:B.definition(B.variableName),color:a.variableGlobal||e.colors.syntax.base.variable},{tag:[B.variableName,B.local(B.variableName),B.constant(B.variableName),B.literal],color:e.colors.syntax.base.variable},{tag:B.propertyName,color:a.variableProperty||e.colors.syntax.base.variable},{tag:B.attributeName,color:a.variableOther||e.colors.syntax.base.variable},{tag:[B.className,B.typeName,B.namespace],color:e.colors.syntax.base.type},{tag:[B.tagName,B.labelName,B.annotation,B.macroName],color:a.tag||e.colors.syntax.base.keyword},{tag:B.link,color:a.url||e.colors.syntax.base.function,textDecoration:`underline`},{tag:[B.punctuation,B.separator,B.bracket,B.paren,B.brace,B.squareBracket,B.angleBracket],color:a.punctuation||e.colors.syntax.base.comment}]);return t?.syntaxColors===!1?[s]:[s,ae(de,{fallback:!0}),ae(ie),ae(c),ae(l)]}var Zr=180,Qr=me.define(),$r=1,ei=2,ti=4,ni=new Map,ri=(e,t)=>{let n=`${e}|${t}`,r=ni.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&$r&&(i+=`font-style:italic;`),t&ei&&(i+=`font-weight:bold;`),t&ti&&(i+=`text-decoration:underline;`);let a=z.mark({attributes:{style:i}});return ni.set(n,a),a},ii=(e,t)=>{let n=new he,r=e.state.doc,i=Math.min(t.length,r.lines);for(let e=0;e<i;e+=1){let i=t[e];if(!i||i.length===0)continue;let a=r.line(e+1),o=a.from;for(let[e,t,r]of i){if(e<=0)continue;let i=o,s=Math.min(o+e,a.to);o+=e,!(s<=i)&&(!t&&!r||n.add(i,s,ri(t,r)))}}return n.finish()},ai=fe.define({create(){return z.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(Qr)&&(n=e.value);return n},provide:e=>V.decorations.from(e)}),oi=e=>ne.fromClass(class{timer;generation=0;abortController;constructor(e){this.tokenize(e)}update(e){e.docChanged&&this.schedule(e.view)}schedule(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(e)},Zr)}async tokenize(t){let n=++this.generation;this.abortController?.abort();let r=new AbortController;this.abortController=r;let i=t.state.doc.toString(),a=await Lt(i,e.language,e.themeName,e.theme,{signal:r.signal,priority:`visible`});a&&(r.signal.aborted||n===this.generation&&t.state.doc.length===i.length&&t.dispatch({effects:Qr.of(ii(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),si=e=>[ai,oi(e)],ci=e=>{let t=(0,X.c)(11),{currentMode:n,onToggle:r}=e,i=n===`preview`,a=i?`Switch to edit mode`:`Switch to preview mode`,o=i?`Edit`:`Preview`,s;t[0]===i?s=t[1]:(s=i?(0,Z.jsx)(Y,{name:`eye`,className:`size-4`,"aria-hidden":`true`}):(0,Z.jsx)(Y,{name:`eye-off`,className:`size-4`,"aria-hidden":`true`}),t[0]=i,t[1]=s);let c;t[2]!==a||t[3]!==r||t[4]!==s?(c=(0,Z.jsx)(at,{asChild:!0,children:(0,Z.jsx)(K,{variant:`ghost`,size:`sm`,onClick:r,"aria-label":a,className:`h-5 w-5 p-0`,children:s})}),t[2]=a,t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,Z.jsx)(ot,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Z.jsxs)(st,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},li=w()(E(T((e,t)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:t=>{e({selectedProfileId:t})},loadProfiles:async()=>{e({isLoading:!0});let n=t().profiles;try{return e({profiles:await Ve(),isLoading:!1}),!0}catch(t){return console.error(`Failed to load git identity profiles:`,t),e({profiles:n,isLoading:!1}),!1}},loadGlobalIdentity:async()=>{try{let t=await He();return t&&t.userName&&t.userEmail?e({globalIdentity:{id:`global`,name:`Global Identity`,userName:t.userName,userEmail:t.userEmail,authType:t.sshCommand?`ssh`:void 0,sshKey:t.sshCommand?t.sshCommand.replace(`ssh -i `,``):null,color:`info`,icon:`house`}}):e({globalIdentity:null}),!0}catch(t){return console.error(`Failed to load global git identity:`,t),e({globalIdentity:null}),!1}},loadDiscoveredCredentials:async()=>{try{return e({discoveredCredentials:await Ke()}),!0}catch(t){return console.error(`Failed to discover git credentials:`,t),e({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{let t=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null};try{let n=null;if(n===null){let e=a()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await i(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(n=t((await e.json().catch(()=>null))?.defaultGitIdentityId))}catch{}return e({defaultGitIdentityId:n}),!0}catch(e){return console.error(`Failed to load default git identity setting:`,e),!1}},setDefaultGitIdentityId:async t=>{try{let n=typeof t==`string`?t.trim():``,r=n.length>0?n:``;return await y({defaultGitIdentityId:r}),e({defaultGitIdentityId:r.length>0?r:null}),!0}catch(e){return console.error(`Failed to save default git identity setting:`,e),!1}},createProfile:async e=>{try{let n={...e,id:e.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:e.color||`keyword`,icon:e.icon||`branch`};return await Ge(n),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to create git identity profile:`,e),!1}},updateProfile:async(e,n)=>{try{let r=t().profiles.find(t=>t.id===e);if(!r)throw Error(`Profile not found`);let i={...r,...n};return await Be(e,i),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to update git identity profile:`,e),!1}},deleteProfile:async n=>{try{return await Ue(n),t().selectedProfileId===n&&e({selectedProfileId:null}),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to delete git identity profile:`,e),!1}},getProfileById:e=>{let{profiles:n,globalIdentity:r}=t();return e===`global`?r||void 0:n.find(t=>t.id===e)},getUnimportedCredentials:()=>{let{profiles:e,discoveredCredentials:n}=t();return n.filter(t=>!e.some(e=>e.authType===`token`&&e.host===t.host))}}),{name:`git-identities-store`,storage:F(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=li);var ui=`w-full max-w-[30rem]`,di=e=>{let t=(0,X.c)(23),{title:n,description:r,settingsItem:i,titleAccessory:a,headerAction:o,children:s,className:c,contentClassName:l}=e,u;t[0]===n?u=t[1]:(u=(0,Z.jsx)(`span`,{className:`truncate`,children:n}),t[0]=n,t[1]=u);let d;t[2]!==u||t[3]!==a?(d=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[u,a]}),t[2]=u,t[3]=a,t[4]=d):d=t[4];let f;t[5]===o?f=t[6]:(f=o?(0,Z.jsx)(`div`,{className:`shrink-0`,children:o}):null,t[5]=o,t[6]=f);let p;t[7]!==d||t[8]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[d,f]}),t[7]=d,t[8]=f,t[9]=p):p=t[9];let m;t[10]===l?m=t[11]:(m=G(`oc-settings-group-row`,l),t[10]=l,t[11]=m);let h;t[12]!==s||t[13]!==m?(h=(0,Z.jsx)(`div`,{className:m,children:s}),t[12]=s,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==r||t[16]!==p||t[17]!==h?(g=(0,Z.jsx)(sr,{className:`oc-settings-detail-group`,label:p,description:r,children:h}),t[15]=r,t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;return t[19]!==c||t[20]!==i||t[21]!==g?(_=(0,Z.jsx)(`div`,{"data-settings-item":i,className:c,children:g}),t[19]=c,t[20]=i,t[21]=g,t[22]=_):_=t[22],_},fi=450,pi=({projectRef:e=null})=>{let{t}=W(),{isMobile:n,isTablet:r}=jt(),i=n||r,a=je(e=>e.getActiveProject()),o=e?.path??a?.path??null,s=De(e=>e.getWorktreeMetadata),c=Ne(),l=A(e=>e.homeDirectory),[u,d]=Q.useState([]),[f,p]=Q.useState(!1),[m,h]=Q.useState(!1),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState([]),[S,C]=Q.useState(!1),w=Q.useRef(!1),T=Q.useMemo(()=>e?.id&&e?.path?{id:e.id,path:e.path}:!a?.id||!o?null:{id:a.id,path:o},[a?.id,o,e?.id,e?.path]),E=Q.useCallback(async()=>{if(!(!T||v===!1))try{let e=await Ze(T);x(e)}catch{}},[T,v]);Q.useEffect(()=>{if(!o)return;let e=!1;return y(null),(async()=>{try{let t=await We(o);if(e)return;y(t)}catch{}})(),()=>{e=!0}},[o]),Q.useEffect(()=>{if(!T){x([]),C(!1);return}if(v===!1){x([]),C(!1);return}let e=!1;return C(!0),x([]),(async()=>{try{let t=await Ze(T);if(e)return;x(t)}catch{}finally{e||C(!1)}})(),()=>{e=!0}},[T,v]),Q.useEffect(()=>{if(!T)return;let e=!1;return h(!0),(async()=>{try{let[t,n]=await Promise.all([Te(T),Se(T)]);if(!e){let e=t.length>0?t:[``];d(e),_(JSON.stringify(e)),p(n)}}catch{e||(d([``]),_(JSON.stringify([``])),p(!1))}finally{e||h(!1)}})(),()=>{e=!0}},[T]);let D=Q.useCallback(async e=>{if(!T)return!1;let n=e.filter(e=>e.trim().length>0);try{return await Me(T,n)?(_(JSON.stringify(e)),!0):(J.error(t(`settings.openchamber.worktrees.setup.toast.saveFailed`)),!1)}catch{return J.error(t(`settings.openchamber.worktrees.setup.toast.saveFailed`)),!1}},[T,t]),O=Q.useMemo(()=>g!==null&&g!==JSON.stringify(u),[g,u]);Q.useEffect(()=>{if(!O||m||w.current)return;let e=window.setTimeout(()=>{w.current||(w.current=!0,(async()=>{try{await D(u)}finally{w.current=!1}})())},fi);return()=>{window.clearTimeout(e)}},[O,m,D,u]);let k=Q.useCallback((e,t)=>{d(n=>{let r=[...n];return r[e]=t,r})},[]),j=Q.useCallback(()=>{d(e=>[...e,``])},[]),M=Q.useCallback(e=>{d(t=>{let n=t.filter((t,n)=>n!==e);return n.length>0?n:[``]})},[]),N=Q.useCallback(()=>{!O||w.current||(w.current=!0,(async()=>{try{await D(u)}finally{w.current=!1}})())},[O,D,u]),P=Q.useCallback(e=>{p(e),T&&Ae(T,e)},[T]),F=Q.useCallback(e=>{let t=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t(e.path),r=c.filter(e=>{let r=s(e.id);if(r?.path&&t(r.path)===n)return!0;let i=e.directory;return!!(i&&t(i)===n)}),i=new Set(r.map(e=>e.id)),a=[...q.getState().activeSessions,...q.getState().archivedSessions],o=e=>{let t=a.filter(t=>{let n=t.parentID;return n&&e.has(n)});if(t.length===0)return[];let n=new Set(t.map(e=>e.id));return[...t,...o(n)]},l=o(i),u=new Set,d=[...r,...l].filter(e=>!u.has(e.id)&&(u.add(e.id),!0));ke.requestDelete({sessions:d,mode:`worktree`,worktree:e})},[c,s]),I=Q.useMemo(()=>c.map(e=>e.id).join(`,`),[c]);Q.useEffect(()=>{v&&o&&E()},[I,v,o,E]);let L=(0,Z.jsxs)(st,{children:[(0,Z.jsx)(at,{asChild:!0,children:(0,Z.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Z.jsxs)(ot,{sideOffset:8,className:`max-w-xs`,children:[t(`settings.openchamber.worktrees.setup.tooltipPrefix`),` `,(0,Z.jsx)(`code`,{className:`font-mono text-xs bg-sidebar-accent/50 px-1 rounded`,children:`$ROOT_PROJECT_PATH`}),` `,t(`settings.openchamber.worktrees.setup.tooltipSuffix`)]})]}),R=(0,Z.jsxs)(st,{children:[(0,Z.jsx)(at,{asChild:!0,children:(0,Z.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Z.jsx)(ot,{sideOffset:8,className:`max-w-xs`,children:t(`settings.openchamber.worktrees.list.tooltip`)})]});return o?v===!1?(0,Z.jsx)(di,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.state.gitOnly`)})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(di,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,titleAccessory:L,children:m?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.setup.loading`)}):(0,Z.jsxs)(`div`,{className:G(`flex flex-col gap-2`,ui),children:[u.map((e,n)=>(0,Z.jsxs)(`div`,{className:`oc-settings-group-row flex w-full items-center gap-2`,children:[(0,Z.jsx)(it,{value:e,onChange:e=>k(n,e.target.value),onBlur:N,placeholder:t(`settings.openchamber.worktrees.setup.commandPlaceholder`),className:`min-w-0 flex-1 font-mono text-xs`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>M(n),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":t(`settings.openchamber.worktrees.setup.removeCommandAria`),children:(0,Z.jsx)(Y,{name:`close`,className:`h-4 w-4`})})]},n)),(0,Z.jsxs)(K,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:j,children:[(0,Z.jsx)(Y,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.openchamber.worktrees.setup.addCommand`)]}),(0,Z.jsxs)(`label`,{"data-settings-item":`projects.worktree.setup.wait`,className:`flex cursor-pointer items-center gap-2 py-1`,children:[(0,Z.jsx)(qe,{checked:f,onChange:P,ariaLabel:t(`settings.openchamber.worktrees.setup.waitForCommandsAria`)}),(0,Z.jsx)(`span`,{className:G(`typography-ui-label font-normal`,f?`text-foreground`:`text-foreground/60`),children:t(`settings.openchamber.worktrees.setup.waitForCommands`)})]})]})}),(0,Z.jsx)(di,{title:t(`settings.openchamber.worktrees.list.title`),titleAccessory:R,children:S?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.list.loading`)}):b.length===0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground/70`,children:t(`settings.openchamber.worktrees.list.empty`)}):(0,Z.jsx)(`div`,{className:G(`space-y-1`,ui),children:b.map(e=>(0,Z.jsxs)(`div`,{className:`group flex w-full items-center gap-2 py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`p`,{className:`typography-meta min-w-0 truncate text-foreground`,children:e.label||e.branch||t(`settings.openchamber.worktrees.list.detachedHead`)}),(0,Z.jsx)(`span`,{className:`typography-micro flex-shrink-0 self-center rounded bg-sidebar-accent/40 px-1.5 py-[1px] leading-none text-muted-foreground/60`,children:`OpenCode`})]}),(0,Z.jsx)(`p`,{className:`typography-micro truncate text-muted-foreground/60`,children:ve(e.path,l)})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>F(e),className:G(`flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,i?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":t(`settings.openchamber.worktrees.list.deleteWorktreeAria`,{name:e.branch||e.label||e.path}),children:(0,Z.jsx)(Y,{name:`delete-bin`,className:`h-4 w-4`})})]},e.path))})})]}):(0,Z.jsx)(di,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.state.selectProject`)})})},mi=(e,t)=>t.updatedAtMs-e.updatedAtMs,hi=w((e,t)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!t().isLoading){e({isLoading:!0,error:null});try{let[n,r]=await Promise.all([xt(),ct()]),i={};for(let e of r.sort(mi))i[e.id]=e;t().listenerReady||await Ct(t=>{e(e=>({statusesById:{...e.statusesById,[t.id]:t}}))}),e({instances:n.instances,statusesById:i,isLoading:!1,initialized:!0,listenerReady:!0})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:String(t)})}}},loadImports:async()=>{if(!t().isImportsLoading){e({isImportsLoading:!0,error:null});try{e({importCandidates:await mt(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await ct(),n={};for(let e of t.sort(mi))n[e.id]=e;e({statusesById:n})}catch(t){e({error:t instanceof Error?t.message:String(t)})}},setInstances:async n=>{e({isSaving:!0,error:null});try{await bt({instances:n}),e({instances:n,isSaving:!1}),await t().refreshStatuses()}catch(t){throw e({isSaving:!1,error:t instanceof Error?t.message:String(t)}),t}},upsertInstance:async e=>{let n=t().instances,r=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n];await t().setInstances(r)},createFromCommand:async(e,n,r)=>{let i=ft(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await Et(n).catch(()=>void 0);let r=t().instances.filter(e=>e.id!==n);await t().setInstances(r),e(e=>{let t={...e.statusesById};return delete t[n],{statusesById:t}})},connect:async n=>{e({error:null});try{await ht(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},disconnect:async n=>{e({error:null});try{await Et(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},retry:async e=>{await t().connect(e)},getStatus:e=>t().statusesById[e]||null,clearError:()=>e({error:null})})),gi=450,_i=()=>c(),vi=()=>({id:_i(),name:``,command:``,icon:`play`}),yi=({projectRef:e})=>{let{t}=W(),n=Q.useMemo(()=>b(),[]),r=hi(e=>e.instances),i=hi(e=>e.load),[a,o]=Q.useState([]),[s,c]=Q.useState(!1),[l,u]=Q.useState(null),[d,f]=Q.useState({}),p=Q.useRef(!1),m=Q.useRef(null);Q.useEffect(()=>{n&&i().catch(()=>void 0)},[n,i]),Q.useEffect(()=>{let t=!1;return c(!0),(async()=>{try{let n=await we(e);if(t)return;o(n.actions),u(JSON.stringify({actions:n.actions}))}catch{if(t)return;o([]),u(JSON.stringify({actions:[]}))}finally{t||c(!1)}})(),()=>{t=!0}},[e]);let h=Q.useMemo(()=>n?nn(r):[],[r,n]),g=Q.useMemo(()=>a.some(e=>e.name.trim().length===0||e.command.trim().length===0)?t(`settings.projects.actions.validation.fillNameAndCommand`):null,[a,t]),_=Q.useMemo(()=>l!==null&&l!==JSON.stringify({actions:a}),[a,l]),v=Q.useCallback(async n=>await xe(e,{actions:n,primaryActionId:null})?(u(JSON.stringify({actions:n})),typeof window<`u`&&window.dispatchEvent(new CustomEvent(on,{detail:{projectId:e.id}})),!0):(J.error(t(`settings.projects.actions.toast.saveFailed`)),!1),[e,t]);Q.useEffect(()=>{if(!_||s||g||p.current)return;let e=window.setTimeout(()=>{p.current||(p.current=!0,(async()=>{try{await v(a)}finally{p.current=!1}})())},gi);return()=>{window.clearTimeout(e)}},[a,_,s,v,g]),Q.useEffect(()=>{if(!_||!g||s){g||(m.current=null);return}let e=window.setTimeout(()=>{m.current!==g&&(m.current=g,J.error(g))},1e3);return()=>{window.clearTimeout(e)}},[_,s,g]);let y=Q.useCallback(()=>{let e=vi();o(t=>[...t,e]),f(t=>({...t,[e.id]:!0}))},[]),x=Q.useCallback(e=>{o(t=>t.filter(t=>t.id!==e)),f(t=>{let n={...t};return delete n[e],n})},[]),S=Q.useCallback((e,t)=>{o(n=>n.map(n=>n.id===e?t(n):n))},[]);return(0,Z.jsxs)(di,{title:t(`settings.projects.actions.title`),description:t(`settings.projects.actions.description`),settingsItem:`projects.actions`,headerAction:(0,Z.jsxs)(K,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:y,children:[(0,Z.jsx)(Y,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.projects.actions.actions.add`)]}),contentClassName:`space-y-0`,children:[s?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.loading`)}):a.length===0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.empty`)}):(0,Z.jsx)(`div`,{className:G(`space-y-0`,ui),children:a.map(e=>{let r=e.icon||`play`,i=an[r]||`play`,a=d[e.id]??!1,o=e.name.trim()||t(`settings.projects.actions.state.untitled`);return(0,Z.jsxs)(Ut,{open:a,onOpenChange:t=>{f(n=>({...n,[e.id]:t}))},className:`py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsxs)(Ht,{className:`group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,children:[a?(0,Z.jsx)(Y,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,Z.jsx)(Y,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(Y,{name:i,className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:o})})]}),(0,Z.jsx)(K,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]`,onClick:()=>x(e.id),children:(0,Z.jsx)(Y,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]}),(0,Z.jsx)(Vt,{className:`pt-1.5`,children:(0,Z.jsxs)(`div`,{className:`space-y-2 pb-4 pl-3 pr-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,Z.jsxs)(Ot,{children:[(0,Z.jsx)(kt,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]`,"aria-label":t(`settings.projects.actions.field.selectIconAria`),children:(0,Z.jsx)(Y,{name:i,className:`h-4 w-4`})})}),(0,Z.jsx)(wt,{align:`start`,className:`w-56 p-2`,children:(0,Z.jsx)(`div`,{className:`grid grid-cols-6 gap-1`,children:rn.map(n=>{let r=n.Icon,i=(e.icon||`play`)===n.key;return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>S(e.id,e=>({...e,icon:n.key})),className:G(`inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]`,i&&`border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]`),"aria-label":t(`settings.projects.actions.field.iconAria`,{icon:n.label}),children:(0,Z.jsx)(Y,{name:r,className:`h-4 w-4`})},n.key)})})})]}),(0,Z.jsx)(it,{value:e.name,onChange:t=>S(e.id,e=>({...e,name:t.target.value})),placeholder:t(`settings.projects.actions.field.actionNamePlaceholder`),className:`h-7 flex-1 min-w-0`})]}),(0,Z.jsxs)(`div`,{className:`py-1`,children:[(0,Z.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.command`)}),(0,Z.jsx)(Pt,{embedded:!0,value:e.command,onChange:t=>S(e.id,e=>({...e,command:t.target.value})),placeholder:t(`settings.projects.actions.field.commandPlaceholder`),className:`min-h-[88px] w-full font-mono text-xs`})]}),(0,Z.jsxs)(`div`,{className:`py-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.projects.actions.field.autoOpenUrl`)}),(0,Z.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":e.autoOpenUrl===!0,onClick:()=>S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:t=>{(t.key===` `||t.key===`Enter`)&&(t.preventDefault(),S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[(0,Z.jsx)(qe,{checked:e.autoOpenUrl===!0,onChange:t=>S(e.id,e=>({...e,...t?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:t(`settings.projects.actions.field.autoOpenUrlForAria`,{title:o})}),(0,Z.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground/80`,children:t(`settings.projects.actions.field.autoOpenUrlDescription`)})]})]}),e.autoOpenUrl===!0?(0,Z.jsxs)(`div`,{className:`mt-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(it,{value:e.openUrl||``,onChange:t=>S(e.id,e=>({...e,openUrl:t.target.value})),placeholder:t(`settings.projects.actions.field.overrideUrlPlaceholder`),className:`h-7 w-full max-w-[24rem]`}),(0,Z.jsxs)(st,{children:[(0,Z.jsx)(at,{asChild:!0,children:(0,Z.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/60 cursor-help`})}),(0,Z.jsx)(ot,{sideOffset:8,className:`max-w-xs`,children:t(`settings.projects.actions.field.overrideUrlTooltip`)})]})]}),n?(0,Z.jsxs)(`div`,{className:`mt-2`,children:[(0,Z.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.desktopSshForward`)}),h.length>0?(0,Z.jsxs)($e,{value:e.desktopOpenSshForward&&h.some(t=>t.id===e.desktopOpenSshForward)?e.desktopOpenSshForward:`__none__`,onValueChange:t=>{S(e.id,e=>({...e,...t===`__none__`?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:t}}))},children:[(0,Z.jsx)(Xe,{className:`h-7 w-full`,children:(0,Z.jsx)(rt,{placeholder:t(`settings.projects.actions.field.useOutputManualUrl`)})}),(0,Z.jsxs)(Qe,{children:[(0,Z.jsx)(Je,{value:`__none__`,children:t(`settings.projects.actions.field.useOutputManualUrl`)}),h.map(e=>(0,Z.jsx)(Je,{value:e.id,children:e.label},e.id))]})]}):(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.noDesktopSshForwards`)})]}):null]}):null]})]})})]},e.id)})}),g&&a.length>0?(0,Z.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:g}):null]})},bi=e=>{let t=(0,X.c)(123),{form:n}=e,{t:r}=W(),{currentTheme:i}=At(),{name:a,setName:o,icon:s,setIcon:c,color:l,setColor:u,iconBackground:d,setIconBackground:f,parsedDefaultModel:p,handleDefaultModelChange:m,isUploadingIcon:h,isRemovingCustomIcon:g,isDiscoveringIcon:_,pendingRemoveImageIcon:v,setPendingRemoveImageIcon:y,pendingUploadIconPreviewUrl:b,setPreviewImageFailed:x,hasPendingUploadImageIcon:S,hasCustomIcon:C,effectiveHasImageIcon:w,hasRemovableImageIcon:T,showImagePreview:E,fileInputRef:D,handleUploadIcon:O,handleRemoveImageIcon:k,handleDiscoverIcon:A,currentIconImage:j,project:M}=n;if(!M)return null;let N=l?et[l]??null:null,P;t[0]===r?P=t[1]:(P=r(`settings.projects.page.field.projectName`),t[0]=r,t[1]=P);let F;t[2]===o?F=t[3]:(F=e=>o(e.target.value),t[2]=o,t[3]=F);let I;t[4]===r?I=t[5]:(I=r(`settings.projects.page.field.projectNamePlaceholder`),t[4]=r,t[5]=I);let L;t[6]!==a||t[7]!==F||t[8]!==I?(L=(0,Z.jsx)(it,{value:a,onChange:F,placeholder:I}),t[6]=a,t[7]=F,t[8]=I,t[9]=L):L=t[9];let R;t[10]!==P||t[11]!==L?(R=(0,Z.jsx)(cr,{label:P,itemId:`projects.name`,children:L}),t[10]=P,t[11]=L,t[12]=R):R=t[12];let ee;t[13]===r?ee=t[14]:(ee=r(`settings.projects.page.field.defaultModel`),t[13]=r,t[14]=ee);let te;t[15]===r?te=t[16]:(te=r(`settings.projects.page.field.defaultModelDescription`),t[15]=r,t[16]=te);let ne;t[17]!==m||t[18]!==p.modelId||t[19]!==p.providerId?(ne=(0,Z.jsx)(pt,{providerId:p.providerId,modelId:p.modelId,onChange:m,className:`oc-settings-inline-value`}),t[17]=m,t[18]=p.modelId,t[19]=p.providerId,t[20]=ne):ne=t[20];let z;t[21]!==ee||t[22]!==te||t[23]!==ne?(z=(0,Z.jsx)(cr,{label:ee,description:te,descriptionPlacement:`outside`,itemId:`projects.default-model`,children:ne}),t[21]=ee,t[22]=te,t[23]=ne,t[24]=z):z=t[24];let re;t[25]===r?re=t[26]:(re=r(`settings.projects.page.field.accentColor`),t[25]=r,t[26]=re);let ie;t[27]===u?ie=t[28]:(ie=()=>u(null),t[27]=u,t[28]=ie);let ae=l===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,oe;t[29]===ae?oe=t[30]:(oe=G(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,ae),t[29]=ae,t[30]=oe);let se;t[31]===r?se=t[32]:(se=r(`settings.projects.page.field.none`),t[31]=r,t[32]=se);let B;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Z.jsx)(Y,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[33]=B):B=t[33];let V;t[34]!==ie||t[35]!==oe||t[36]!==se?(V=(0,Z.jsx)(`button`,{type:`button`,onClick:ie,className:oe,title:se,children:B}),t[34]=ie,t[35]=oe,t[36]=se,t[37]=V):V=t[37];let ce;t[38]!==l||t[39]!==u?(ce=nt.map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>u(e.key),className:G(`h-7 w-7 rounded-md border transition-colors`,l===e.key?`border-2 border-foreground ring-1 ring-[var(--primary-base)]/40`:`border-transparent hover:border-border/70`),style:{backgroundColor:e.cssVar},title:e.label},e.key)),t[38]=l,t[39]=u,t[40]=ce):ce=t[40];let le;t[41]!==V||t[42]!==ce?(le=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[V,ce]}),t[41]=V,t[42]=ce,t[43]=le):le=t[43];let ue;t[44]!==re||t[45]!==le?(ue=(0,Z.jsx)(cr,{label:re,itemId:`projects.accent-color`,children:le}),t[44]=re,t[45]=le,t[46]=ue):ue=t[46];let de;t[47]===r?de=t[48]:(de=r(`settings.projects.page.field.projectIcon`),t[47]=r,t[48]=de);let fe;t[49]===O?fe=t[50]:(fe=e=>{let t=e.target.files?.[0]??null;O(t),e.currentTarget.value=``},t[49]=O,t[50]=fe);let pe;t[51]!==D||t[52]!==fe?(pe=(0,Z.jsx)(`input`,{ref:D,type:`file`,accept:`image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg`,className:`hidden`,onChange:fe}),t[51]=D,t[52]=fe,t[53]=pe):pe=t[53];let me;t[54]===c?me=t[55]:(me=()=>c(null),t[54]=c,t[55]=me);let he=s===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,ge;t[56]===he?ge=t[57]:(ge=G(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,he),t[56]=he,t[57]=ge);let H;t[58]===r?H=t[59]:(H=r(`settings.projects.page.field.none`),t[58]=r,t[59]=H);let _e;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Z.jsx)(Y,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[60]=_e):_e=t[60];let U;t[61]!==me||t[62]!==ge||t[63]!==H?(U=(0,Z.jsx)(`button`,{type:`button`,onClick:me,className:ge,title:H,children:_e}),t[61]=me,t[62]=ge,t[63]=H,t[64]=U):U=t[64];let ve;t[65]!==N||t[66]!==s||t[67]!==c?(ve=tt.map(e=>{let t=e.Icon;return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c(e.key),className:G(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,s===e.key?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-transparent hover:border-border hover:bg-[var(--surface-muted)]`),title:e.label,children:(0,Z.jsx)(Y,{name:t,className:`w-4 h-4`,style:N&&s===e.key?{color:N}:void 0})},e.key)}),t[65]=N,t[66]=s,t[67]=c,t[68]=ve):ve=t[68];let ye;t[69]!==U||t[70]!==ve?(ye=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[U,ve]}),t[69]=U,t[70]=ve,t[71]=ye):ye=t[71];let be;t[72]!==j||t[73]!==i||t[74]!==w||t[75]!==S||t[76]!==d||t[77]!==b||t[78]!==M||t[79]!==x||t[80]!==E||t[81]!==r?(be=w&&E&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r(`settings.projects.page.field.preview`)}),(0,Z.jsx)(`span`,{className:`inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1`,children:(0,Z.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]`,style:d?{backgroundColor:d}:void 0,children:S&&b?(0,Z.jsx)(`img`,{src:b,alt:``,className:`h-full w-full object-contain`,draggable:!1,onError:()=>x(!0)}):(0,Z.jsx)(Ye,{project:{...M,iconImage:j??M.iconImage},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:`h-full w-full object-contain`,onError:()=>x(!0)})})})]}),t[72]=j,t[73]=i,t[74]=w,t[75]=S,t[76]=d,t[77]=b,t[78]=M,t[79]=x,t[80]=E,t[81]=r,t[82]=be):be=t[82];let xe;t[83]!==w||t[84]!==d||t[85]!==f||t[86]!==r?(xe=w&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsx)(`input`,{type:`color`,value:d??`#000000`,onChange:e=>f(e.target.value),className:`h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1`,"aria-label":r(`settings.projects.page.field.projectIconBackgroundAria`)}),(0,Z.jsx)(it,{value:d??``,onChange:e=>f(e.target.value),placeholder:`#000000`,className:`h-7 w-[8rem]`}),(0,Z.jsx)(K,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>f(null),className:`h-7 w-7 p-0`,"aria-label":r(`settings.projects.page.field.clearIconBackgroundAria`),title:r(`settings.projects.page.field.clearBackground`),disabled:!d,children:(0,Z.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]}),t[83]=w,t[84]=d,t[85]=f,t[86]=r,t[87]=xe):xe=t[87];let q;t[88]!==D||t[89]!==A||t[90]!==C||t[91]!==_||t[92]!==h||t[93]!==r?(q=!C&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(K,{size:`xs`,className:`h-6 !font-normal`,onClick:()=>D.current?.click(),disabled:h,children:r(h?`settings.projects.page.actions.uploading`:`settings.projects.page.actions.uploadIcon`)}),(0,Z.jsx)(K,{size:`xs`,className:`h-6 !font-normal`,variant:`outline`,onClick:()=>void A(),disabled:_,children:r(_?`settings.projects.page.actions.discovering`:`settings.projects.page.actions.discoverFavicon`)})]}),t[88]=D,t[89]=A,t[90]=C,t[91]=_,t[92]=h,t[93]=r,t[94]=q):q=t[94];let Se;t[95]!==k||t[96]!==T||t[97]!==g||t[98]!==r?(Se=T&&(0,Z.jsx)(K,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>void k(),disabled:g,children:r(g?`settings.projects.page.actions.removing`:`settings.projects.page.actions.removeProjectIcon`)}),t[95]=k,t[96]=T,t[97]=g,t[98]=r,t[99]=Se):Se=t[99];let Ce;t[100]!==g||t[101]!==v||t[102]!==y||t[103]!==r?(Ce=v&&(0,Z.jsx)(K,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>y(!1),disabled:g,children:r(`settings.projects.page.actions.undoRemove`)}),t[100]=g,t[101]=v,t[102]=y,t[103]=r,t[104]=Ce):Ce=t[104];let we;t[105]!==q||t[106]!==Se||t[107]!==Ce?(we=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[q,Se,Ce]}),t[105]=q,t[106]=Se,t[107]=Ce,t[108]=we):we=t[108];let Te;t[109]!==pe||t[110]!==ye||t[111]!==be||t[112]!==xe||t[113]!==we?(Te=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col items-end gap-2`,children:[pe,ye,be,xe,we]}),t[109]=pe,t[110]=ye,t[111]=be,t[112]=xe,t[113]=we,t[114]=Te):Te=t[114];let Ee;t[115]!==de||t[116]!==Te?(Ee=(0,Z.jsx)(cr,{label:de,itemId:`projects.icon`,children:Te}),t[115]=de,t[116]=Te,t[117]=Ee):Ee=t[117];let De;return t[118]!==ue||t[119]!==Ee||t[120]!==R||t[121]!==z?(De=(0,Z.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[R,z,ue,Ee]}),t[118]=ue,t[119]=Ee,t[120]=R,t[121]=z,t[122]=De):De=t[122],De},xi=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,Si=e=>{if(!e)return null;let t=e.trim();return t&&xi.test(t)?t.toLowerCase():null},Ci=e=>{let{t}=W(),n=je(e=>e.uploadProjectIcon),r=je(e=>e.removeProjectIcon),i=je(e=>e.discoverProjectIcon),a=je(t=>e?t.projects.find(t=>t.id===e.id)?.iconImage??null:null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(null),[f,p]=Q.useState(null),[m,h]=Q.useState(void 0),[g,_]=Q.useState(!1),[v,y]=Q.useState(!1),[b,x]=Q.useState(!1),[S,C]=Q.useState(!1),[w,T]=Q.useState(null),[E,D]=Q.useState(null),[O,k]=Q.useState(!1),A=Q.useRef(null),j=Q.useCallback(()=>{T(null),D(e=>(e&&URL.revokeObjectURL(e),null))},[]),M=e?.id??null;Q.useEffect(()=>{if(!e){s(``),l(null),d(null),p(null),h(void 0);return}s(e.label??``),l(e.icon??null),d(e.color??null),p(e.iconBackground??null),h(e.defaultModel),C(!1),j(),k(!1)},[e,j]),Q.useEffect(()=>()=>{j()},[j]);let N=Q.useMemo(()=>Ce(m)??{providerId:``,modelId:``},[m]),P=!!e?.iconImage,F=!!(w&&E),I=e?.iconImage?.source===`custom`,L=P&&!S||F,R=L,ee=!!(e&&P&&!S),te=!O&&(F||ee),ne=!!e&&(o.trim()!==(e?.label??``).trim()||c!==(e?.icon??null)||u!==(e?.color??null)||f!==(e?.iconBackground??null)||(m??void 0)!==(e?.defaultModel??void 0)||S||!!w),z=Q.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),re=Q.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),ie=Q.useCallback(()=>{!e||!R||v||(F&&j(),C(!!P),k(!1))},[j,F,R,P,v,e]),ae=Q.useCallback(async()=>{if(!(!e||b)){j(),C(!1),k(!1),x(!0);try{let n=await i(e.id);if(!n.ok){J.error(n.error||t(`settings.projects.page.toast.discoverIconFailed`));return}if(n.skipped){J.success(t(`settings.projects.page.toast.customIconAlreadySet`));return}J.success(t(`settings.projects.page.toast.iconDiscovered`))}finally{x(!1)}}},[j,i,b,e,t]),oe=Q.useCallback(async i=>{let a=i?.silent===!0;if(!e)return null;let s=o.trim();if(!s)return null;if(w){_(!0);let r=await n(e.id,w);if(_(!1),!r.ok)return J.error(r.error||t(`settings.projects.page.toast.uploadIconFailed`)),null;a||J.success(t(`settings.projects.page.toast.iconUpdated`)),j(),C(!1)}let l=S&&!!e.iconImage;if(l){y(!0);let n=await r(e.id);if(y(!1),!n.ok)return J.error(n.error||t(`settings.projects.page.toast.removeIconFailed`)),null;a||J.success(t(`settings.projects.page.toast.iconRemoved`)),C(!1),p(null)}return{label:s,icon:c,color:u,iconBackground:Si(l?null:f),defaultModel:m??null}},[j,u,m,c,f,o,S,w,e,r,t,n]);return Q.useEffect(()=>{k(!1)},[M,a?.updatedAt]),{name:o,setName:s,icon:c,setIcon:l,color:u,setColor:d,iconBackground:f,setIconBackground:p,defaultModel:m,parsedDefaultModel:N,handleDefaultModelChange:z,isUploadingIcon:g,isRemovingCustomIcon:v,isDiscoveringIcon:b,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:C,pendingUploadIconFile:w,pendingUploadIconPreviewUrl:E,previewImageFailed:O,setPreviewImageFailed:k,hasStoredImageIcon:P,hasPendingUploadImageIcon:F,hasCustomIcon:I,effectiveHasImageIcon:L,hasRemovableImageIcon:R,showStoredImagePreview:ee,showImagePreview:te,fileInputRef:A,clearPendingUploadIcon:j,handleUploadIcon:re,handleRemoveImageIcon:ie,handleDiscoverIcon:ae,hasChanges:ne,prepareSaveData:oe,currentIconImage:a,project:e}},wi=450,Ti=(e,t)=>{let{t:n}=W(),{hasChanges:r,name:i,icon:a,color:o,iconBackground:s,defaultModel:c,pendingRemoveImageIcon:l,pendingUploadIconFile:u,isUploadingIcon:d,isRemovingCustomIcon:f,prepareSaveData:p}=e,m=Q.useRef(!1);Q.useEffect(()=>{if(!r||!i.trim()||d||f||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{let e=await p({silent:!0});if(e)try{await t(e)}catch{J.error(n(`settings.projects.page.toast.saveFailed`))}}finally{m.current=!1}})())},wi);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},Ei=e=>{let t=(0,X.c)(25),{project:n,onIdentitySave:r}=e,{t:i}=W(),a=Ci(n),o;bb0:{if(!n){o=null;break bb0}let e;t[0]!==n.id||t[1]!==n.path?(e={id:n.id,path:n.path},t[0]=n.id,t[1]=n.path,t[2]=e):e=t[2],o=e}let s=o,c;if(t[3]===r?c=t[4]:(c=async e=>{await r(e)},t[3]=r,t[4]=c),Ti(a,c),!n||!s)return null;let l;t[5]!==n.path||t[6]!==i?(l=n.path.split(/[\\/]/).filter(Boolean).at(-1)??i(`settings.projects.page.title.default`),t[5]=n.path,t[6]=i,t[7]=l):l=t[7];let u=l,d;t[8]===u?d=t[9]:(d=(0,Z.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u}),t[8]=u,t[9]=d);let f;t[10]===n.path?f=t[11]:(f=(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,title:n.path,children:n.path}),t[10]=n.path,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Z.jsxs)(`div`,{className:`px-1`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]===a?m=t[16]:(m=(0,Z.jsx)(bi,{form:a}),t[15]=a,t[16]=m);let h,g;t[17]===s?(h=t[18],g=t[19]):(h=(0,Z.jsx)(yi,{projectRef:s}),g=(0,Z.jsx)(pi,{projectRef:s}),t[17]=s,t[18]=h,t[19]=g);let _;return t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==g?(_=(0,Z.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[p,m,h,g]}),t[20]=p,t[21]=m,t[22]=h,t[23]=g,t[24]=_):_=t[24],_};function Di(e,t,n){return Math.min(n,Math.max(t,e))}function Oi(e){if(!Number.isFinite(e))return 0;let t=String(e);if(t.includes(`e-`)){let[,e]=t.split(`e-`);return Number(e)||0}let n=t.split(`.`);return n.length===2?n[1].length:0}function ki(e,t){let n=Oi(t);return n<=0?e:Number(e.toFixed(n))}var Ai=Q.forwardRef(({value:e,onValueChange:t,min:n=-1/0,max:r=1/0,step:i=1,className:a,containerClassName:o,onBlur:s,disabled:c,fallbackValue:l,onClear:u,emptyLabel:d=`—`,...f},p)=>{let{t:m}=W(),[h,g]=Q.useState(()=>e===void 0?``:String(e)),{isMobile:_}=jt(),v=Q.useRef(!1),y=Q.useRef(null),b=Q.useCallback(()=>{if(typeof document>`u`||typeof window>`u`)return;y.current?.();let e=e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation?.(),y.current?.()},t=window.setTimeout(()=>{y.current?.()},700);y.current=()=>{window.clearTimeout(t),document.removeEventListener(`click`,e,!0),y.current=null},document.addEventListener(`click`,e,!0)},[]);Q.useEffect(()=>()=>{y.current?.()},[]),Q.useEffect(()=>{g(e===void 0?``:String(e))},[e]);let x=Q.useMemo(()=>e===void 0?l===void 0?Number.isFinite(n)?n:0:l:e,[l,n,e]),S=Q.useRef(x);Q.useEffect(()=>{S.current=x},[x]);let C=Q.useCallback(e=>{let a=ki(Di(e,n,r),i);S.current=a,t(a)},[r,n,t,i]),w=Q.useCallback(e=>{let t=e.target.value;if(g(t),t.trim()===``){u?.();return}let n=Number(t);Number.isFinite(n)&&C(n)},[C,u]),T=Q.useCallback(t=>{if(h.trim()===``){u||g(e===void 0?``:String(e)),s?.(t);return}let a=Number(h);if(!Number.isFinite(a))g(e===void 0?``:String(e));else{let t=ki(Di(a,n,r),i);t===e?S.current=t:C(a),g(String(t))}s?.(t)},[C,h,r,n,s,u,i,e]),E=!!(c||x>=r),D=!!(c||x<=n),O=()=>{D||C(S.current-i)},k=()=>{E||C(S.current+i)},A=e=>t=>{t.preventDefault(),t.stopPropagation(),v.current=!0,b(),e()},j=e=>t=>{if(v.current){v.current=!1,t.preventDefault(),t.stopPropagation();return}e()};return _?(0,Z.jsxs)(`div`,{"data-slot":`number-input`,className:G(`flex h-9 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent select-none overscroll-contain`,`[-webkit-user-select:none] [-webkit-touch-callout:none]`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onTouchStart:A(O),onClick:j(O),className:G(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!D&&`active:bg-interactive-hover`),children:(0,Z.jsx)(Y,{name:`subtract`,className:`block h-4 w-4`})}),(0,Z.jsx)(`div`,{"data-slot":`number-input-value`,className:G(`flex h-full min-w-0 w-14 items-center justify-center bg-transparent px-1.5`,`text-center text-[16px] leading-none text-foreground [font-variant-numeric:tabular-nums]`,a),"aria-live":`polite`,children:e===void 0?d:h}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onTouchStart:A(k),onClick:j(k),className:G(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!E&&`active:bg-interactive-hover`),children:(0,Z.jsx)(Y,{name:`add`,className:`block h-4 w-4`})})]}):(0,Z.jsxs)(`div`,{"data-slot":`number-input`,className:G(`flex h-7 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onClick:()=>C(S.current-i),className:G(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Z.jsx)(Y,{name:`subtract`,className:`block h-3.5 w-3.5`})}),(0,Z.jsx)(`input`,{...f,"data-slot":`number-input-value`,ref:p,type:`text`,inputMode:f.inputMode??`numeric`,value:h,onChange:w,onBlur:T,disabled:c,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,className:G(`h-full min-w-0 w-14 bg-transparent px-1.5 text-center typography-ui-label leading-none text-foreground [font-variant-numeric:tabular-nums]`,`placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground`,`appearance-none outline-none [appearance:textfield] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,`disabled:pointer-events-none disabled:cursor-not-allowed`,a)}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onClick:()=>C(S.current+i),className:G(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Z.jsx)(Y,{name:`add`,className:`block h-3.5 w-3.5`})})]})});Ai.displayName=`NumberInput`;function ji(e){let t=e.indexOf(`/`);if(t!==-1){let n=e.substring(0,t);if(n===`gemini`||n===`antigravity`)return e.substring(t+1)}return e}var Mi={google:[{id:`gemini-auth`,label:`Gemini`,matcher:e=>e.startsWith(`gemini/`),order:1},{id:`antigravity-auth`,label:`Antigravity`,matcher:e=>e.startsWith(`antigravity/`),order:2}]};function Ni(e,t){let n=Mi[t]??[];for(let t of n)if(t.matcher(e))return t;return null}function Pi(e){return Mi[e]??[]}function Fi(e){return[...e].sort((e,t)=>e.order-t.order)}function Ii(e,t){let n=new Map;for(let r of Object.keys(e)){let e=Ni(r,t)?.id??null;n.has(e)||n.set(e,[]),n.get(e).push(r)}return n}function Li(e,t,n){let r=new Map;for(let i of e){let e=Ni(t(i),n)?.id??null;r.has(e)||r.set(e,[]),r.get(e).push(i)}return r}function Ri(e,t){return t.filter(e=>{let t=e.toLowerCase(),n=t.includes(`/`)?t.split(`/`)[1]:t;return!!(n.startsWith(`gemini-3-`)||n.startsWith(`claude-`))})}var zi=6e4,Bi=0,Vi=0,Hi=new Map,Ui=e=>{let t=sn.map(e=>e.id),n=typeof e?.usageAutoRefresh==`boolean`&&e.usageAutoRefresh,r=typeof e?.usageRefreshIntervalMs==`number`&&Number.isFinite(e.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(e.usageRefreshIntervalMs))):zi,i=e?.usageDisplayMode===`remaining`?`remaining`:`usage`,a=typeof e?.usageShowPredValues==`boolean`&&e.usageShowPredValues,o=Array.isArray(e?.usageDropdownProviders)?e?.usageDropdownProviders:null,s=o?o.filter(e=>typeof e==`string`&&t.includes(e)):t,c={},l=e?.usageSelectedModels;if(l&&typeof l==`object`)for(let[e,t]of Object.entries(l))Array.isArray(t)&&(c[e]=t.filter(e=>typeof e==`string`));let u={},d=e?.usageExpandedFamilies;if(d&&typeof d==`object`)for(let[e,t]of Object.entries(d))Array.isArray(t)&&(u[e]=t.filter(e=>typeof e==`string`));return{autoRefresh:n,refreshIntervalMs:r,displayMode:i,showPredValues:a,dropdownProviderIds:s,selectedModels:c,expandedFamilies:u}},Wi=async()=>{let e=a()?.settings;if(e)try{let t=(await e.load())?.settings;return Ui(t??null)}catch{}if(!v()){let e=await i(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok)return Ui(await e.json().catch(()=>null))}return{autoRefresh:!1,refreshIntervalMs:zi,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:sn.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},Gi=(e,t,n)=>{let r=e.filter(e=>e?.providerId&&e.providerId!==t);return m(n)&&r.push(n),r},Ki=async(e,t)=>{let n=Vi;Hi.set(e,(Hi.get(e)??0)+1),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:!0}}));try{let r=await u.fetchQuery({queryKey:d.quota(e),queryFn:({signal:t})=>x(e,t),staleTime:0,retry:!1});if(n!==Vi)return{providerId:e,stale:!0};if(!m(r))throw Error(`Invalid quota response`);return t(t=>({results:Gi(t.results,e,r)})),{providerId:e,result:r}}catch(r){return n===Vi?(t(e=>e.results.every(e=>e?.providerId)?{}:{results:e.results.filter(e=>e?.providerId)}),{providerId:e,error:r instanceof Error?r.message:`Failed to fetch quota`}):{providerId:e,stale:!0}}finally{if(n===Vi){let n=(Hi.get(e)??1)-1;n>0?Hi.set(e,n):Hi.delete(e),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:n>0}}))}}},qi=()=>{Vi+=1,Bi+=1,Hi.clear(),Ji.setState({results:[],isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null})},Ji=w()(E((e,t)=>({results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:zi,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:sn.map(e=>e.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{try{e(await Wi())}catch(e){console.warn(`Failed to load usage settings:`,e)}},fetchAllQuotas:async()=>{let t=++Bi;e({isLoading:!0,error:null});let n=sn.map(e=>e.id),r=await Promise.all(n.map(t=>Ki(t,e)));if(t===Bi){let t=r.find(e=>`error`in e);e({isLoading:!1,...r.some(e=>`result`in e)?{lastUpdated:Date.now()}:{},error:t?.error??null})}},fetchProviderQuota:async t=>{let n=await Ki(t,e);`stale`in n||e({error:`error`in n?n.error:null})},setSelectedProvider:t=>e({selectedProviderId:t}),setAutoRefresh:t=>e({autoRefresh:t}),setRefreshInterval:t=>{e({refreshIntervalMs:Math.max(3e4,Math.min(3e5,Math.round(t)))})},setDisplayMode:t=>e({displayMode:t}),setShowPredValues:t=>e({showPredValues:t}),setDropdownProviderIds:t=>e({dropdownProviderIds:t}),setSelectedModels:(t,n)=>{e(e=>({selectedModels:{...e.selectedModels,[t]:n}}))},toggleModelSelected:(t,n)=>{e(e=>{let r=e.selectedModels[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n];return{selectedModels:{...e.selectedModels,[t]:i}}})},setExpandedFamilies:(n,r)=>{e(e=>({expandedFamilies:{...e.expandedFamilies,[n]:r}})),y({usageExpandedFamilies:t().expandedFamilies})},toggleFamilyExpanded:(n,r)=>{e(e=>{let t=e.expandedFamilies[n]??[],i=t.includes(r)?t.filter(e=>e!==r):[...t,r];return{expandedFamilies:{...e.expandedFamilies,[n]:i}}}),y({usageExpandedFamilies:t().expandedFamilies})},applyDefaultSelections:(n,r)=>{if((t().selectedModels[n]?.length??0)>0)return;let i=Ri(n,r);i.length!==0&&(e(e=>({selectedModels:{...e.selectedModels,[n]:i}})),y({usageSelectedModels:t().selectedModels}))}}),{name:`quota-store`})),Yi=()=>{let e=(0,X.c)(5),t=Ji(Xi),n=Ji(Zi),r=Ji(Qi),i,a;e[0]!==t||e[1]!==r||e[2]!==n?(i=()=>{if(!t)return;let e=window.setInterval(()=>{r()},n);return()=>window.clearInterval(e)},a=[t,n,r],e[0]=t,e[1]=r,e[2]=n,e[3]=i,e[4]=a):(i=e[3],a=e[4]),Q.useEffect(i,a)};function Xi(e){return e.autoRefresh}function Zi(e){return e.refreshIntervalMs}function Qi(e){return e.fetchAllQuotas}var $i=e=>{let t=(0,X.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=ut(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=_t(c),t[2]=c,t[3]=l);let u=l,d=a==null?null:Math.max(0,Math.min(100,a)),f;t[4]===u?f=t[5]:(f=u===`critical`?{backgroundColor:`var(--status-error)`}:u===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`},t[4]=u,t[5]=f);let p=f,m;t[6]===i?m=t[7]:(m=G(`relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden`,i),t[6]=i,t[7]=m);let h=`${s}%`,g;t[8]!==p||t[9]!==h?(g={...p,width:h},t[8]=p,t[9]=h,t[10]=g):g=t[10];let _;t[11]!==s||t[12]!==g?(_=(0,Z.jsx)(`div`,{className:`h-full transition-all duration-300`,style:g,role:`progressbar`,"aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100}),t[11]=s,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d!=null&&d>0&&d<100&&(0,Z.jsx)(`div`,{className:`absolute top-0 h-full w-0.5 bg-foreground`,style:{left:`${d}%`},title:`Expected usage if spread evenly: ${Math.round(d)}% of quota`,"aria-hidden":`true`}),t[14]=d,t[15]=v);let y;return t[16]!==m||t[17]!==_||t[18]!==v?(y=(0,Z.jsxs)(`div`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},ea=e=>{let t=(0,X.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=W(),s;t[0]===n.status?s=t[1]:(s=gt(n.status),t[0]=n.status,t[1]=s);let c=s,l;bb0:{switch(n.status){case`on-track`:{let e;t[2]===o?e=t[3]:(e=o(`settings.usage.pace.status.onTrack`),t[2]=o,t[3]=e),l=e;break bb0}case`slightly-fast`:{let e;t[4]===o?e=t[5]:(e=o(`settings.usage.pace.status.slightlyFast`),t[4]=o,t[5]=e),l=e;break bb0}case`too-fast`:{let e;t[6]===o?e=t[7]:(e=o(`settings.usage.pace.status.tooFast`),t[6]=o,t[7]=e),l=e;break bb0}case`exhausted`:{let e;t[8]===o?e=t[9]:(e=o(`settings.usage.pace.status.usedUp`),t[8]=o,t[9]=e),l=e;break bb0}}l=void 0}let u=l,d;t[10]!==n.predictText||t[11]!==o?(d=o(`settings.usage.pace.predictionTooltip`,{prediction:n.predictText}),t[10]=n.predictText,t[11]=o,t[12]=d):d=t[12];let f=d;if(a){let e;t[13]===r?e=t[14]:(e=G(`flex items-center gap-1.5`,r),t[13]=r,t[14]=e);let i;t[15]===c?i=t[16]:(i={backgroundColor:c},t[15]=c,t[16]=i);let a;t[17]!==u||t[18]!==i?(a=(0,Z.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:i,title:u}),t[17]=u,t[18]=i,t[19]=a):a=t[19];let s;t[20]===c?s=t[21]:(s={color:c},t[20]=c,t[21]=s);let l=n.isExhausted?void 0:f,d;t[22]!==n.isExhausted||t[23]!==n.predictText||t[24]!==n.remainingSeconds||t[25]!==o?(d=n.isExhausted?(0,Z.jsx)(Z.Fragment,{children:o(`settings.usage.pace.wait`,{duration:lt(n.remainingSeconds)})}):(0,Z.jsx)(Z.Fragment,{children:o(`settings.usage.pace.prediction`,{prediction:n.predictText})}),t[22]=n.isExhausted,t[23]=n.predictText,t[24]=n.remainingSeconds,t[25]=o,t[26]=d):d=t[26];let p;t[27]!==d||t[28]!==s||t[29]!==l?(p=(0,Z.jsx)(`span`,{className:`typography-micro tabular-nums`,style:s,title:l,children:d}),t[27]=d,t[28]=s,t[29]=l,t[30]=p):p=t[30];let m;return t[31]!==p||t[32]!==e||t[33]!==a?(m=(0,Z.jsxs)(`div`,{className:e,children:[a,p]}),t[31]=p,t[32]=e,t[33]=a,t[34]=m):m=t[34],m}let p;t[35]===r?p=t[36]:(p=G(`flex items-center justify-between gap-2`,r),t[35]=r,t[36]=p);let m;t[37]!==n.isExhausted||t[38]!==n.paceRateText||t[39]!==o?(m=!n.isExhausted&&(0,Z.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:o(`settings.usage.pace.rate`,{rate:n.paceRateText})}),t[37]=n.isExhausted,t[38]=n.paceRateText,t[39]=o,t[40]=m):m=t[40];let h;t[41]===m?h=t[42]:(h=(0,Z.jsx)(`div`,{className:`flex items-center gap-1.5`,children:m}),t[41]=m,t[42]=h);let g;t[43]===c?g=t[44]:(g={color:c},t[43]=c,t[44]=g);let _;t[45]!==n.isExhausted||t[46]!==n.predictText||t[47]!==n.remainingSeconds||t[48]!==f||t[49]!==u||t[50]!==o?(_=n.isExhausted?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:u}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.waitSeparator`)}),(0,Z.jsx)(`span`,{className:`font-medium`,children:lt(n.remainingSeconds)})]}):(0,Z.jsxs)(`span`,{title:f,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.predictionLabel`)}),(0,Z.jsx)(`span`,{className:`font-medium`,children:n.predictText})]}),t[45]=n.isExhausted,t[46]=n.predictText,t[47]=n.remainingSeconds,t[48]=f,t[49]=u,t[50]=o,t[51]=_):_=t[51];let v;t[52]!==g||t[53]!==_?(v=(0,Z.jsx)(`span`,{className:`typography-micro tabular-nums`,style:g,children:_}),t[52]=g,t[53]=_,t[54]=v):v=t[54];let y;t[55]===c?y=t[56]:(y={backgroundColor:c},t[55]=c,t[56]=y);let b;t[57]!==u||t[58]!==y?(b=(0,Z.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:y,title:u}),t[57]=u,t[58]=y,t[59]=b):b=t[59];let x;t[60]!==v||t[61]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[v,b]}),t[60]=v,t[61]=b,t[62]=x):x=t[62];let S;return t[63]!==x||t[64]!==p||t[65]!==h?(S=(0,Z.jsxs)(`div`,{className:p,children:[h,x]}),t[63]=x,t[64]=p,t[65]=h,t[66]=S):S=t[66],S},ta=e=>e instanceof Error&&e.name===`CancelledError`,na=w(()=>({setStatus:e=>dt(u,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await u.cancelQueries({queryKey:d.github.auth(r),exact:!0});try{return await yt(u,e,r)}catch(e){if(ta(e))return vt(u,r);throw e}}})),ra={displayMode:`browser`,installed:!1,browserTab:!0},ia=new Set,aa=ra,oa=!1,sa,ca=()=>{let e=Dt();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},la=()=>(!oa&&typeof window<`u`&&(aa=ca(),oa=!0),aa),$=()=>{let e=ca();oa=!0,e.displayMode!==aa.displayMode&&(aa=e,ia.forEach(e=>e()))},ua=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=[window.matchMedia(`(display-mode: standalone)`),window.matchMedia(`(display-mode: minimal-ui)`),window.matchMedia(`(display-mode: fullscreen)`),window.matchMedia(`(display-mode: window-controls-overlay)`)];for(let t of e)typeof t.addEventListener==`function`?t.addEventListener(`change`,$):typeof t.addListener==`function`&&t.addListener($);return window.addEventListener(`appinstalled`,$),window.addEventListener(`focus`,$),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,$):typeof t.removeListener==`function`&&t.removeListener($);window.removeEventListener(`appinstalled`,$),window.removeEventListener(`focus`,$)}},da=e=>(ia.add(e),sa??=ua(),$(),()=>{ia.delete(e),ia.size===0&&(sa?.(),sa=void 0)}),fa=()=>Q.useSyncExternalStore(da,la,pa);function pa(){return ra}var ma=`OPEN CHAMBER`,ha=w()(T(e=>({sidebarBrandName:ma,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:g(),version:2,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n=e;return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=ma),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=ma),n}}));typeof window<`u`&&t(e=>{r(e)&&ha.persist.rehydrate()});var ga=(e,t)=>e?t.kind===e.kind?t.projectRoot.length===e.projectRoot.length?t.projectId.localeCompare(e.projectId)<0:t.projectRoot.length>e.projectRoot.length:t.kind===`project`:!0,_a=(e,t,n)=>{ga(e.get(t),n)&&e.set(t,n)},va=e=>{let t=e;return p(t.directory)??p(t.project?.worktree)},ya=e=>{if(e===`/`||/^[A-Z]:$/.test(e))return null;let t=e.lastIndexOf(`/`);return t<0?null:t===0?`/`:t===2&&/^[A-Z]:\//.test(e)?e.slice(0,2):e.slice(0,t)},ba=(e,t,n,r,i=[])=>{let a=new Map,o=new Map;for(let e of t){let t=p(e.normalizedPath);if(!t)continue;let n=o.get(t);(!n||e.id.localeCompare(n.id)<0)&&o.set(t,e),_a(a,t,{projectId:e.id,projectRoot:t,scopeDirectory:t,kind:`project`})}if(!r)for(let[e,t]of n){let n=p(e),r=n?o.get(n):void 0;if(!(!r||!n))for(let e of t){let t=p(e.path);t&&_a(a,t,{projectId:r.id,projectRoot:n,scopeDirectory:t,kind:`worktree`})}}let s=new Map,c=new Map,l=new Map,u=new Map,d=new Map,f=e=>{if(!e)return null;if(s.has(e))return s.get(e)??null;if(r){let t=a.get(e)??null;return s.set(e,t),t}let t=[],n=e,i=null;for(;n;){if(s.has(n)){i=s.get(n)??null;break}if(t.push(n),i=a.get(n)??null,i)break;n=ya(n)}for(let e of t)s.set(e,i);return i},m=(e,t,n)=>{for(let r of e){let e=f(va(r));if(!e)continue;c.set(r.id,e);let i=t.get(e.projectId);if(i?i.push(r):t.set(e.projectId,[r]),!n)continue;let a=n.get(e.scopeDirectory);a?a.add(r.id):n.set(e.scopeDirectory,new Set([r.id]))}};return m(e,l,d),m(i,u),{bySessionId:c,sessionsByProject:l,archivedSessionsByProject:u,sessionsByScope:d,directoryResolutions:s.size}},xa=`__other__`;function Sa(e){return e.time?.updated??e.time?.archived??e.time?.created??0}function Ca({mode:e=`dialog`}){let{t}=W(),{isMobile:n,isTablet:r,hasTouchInput:i}=jt(),a=n||r||i,o=e===`page`,s=I(e=>e.isArchivedSessionsDialogOpen),c=I(e=>e.setArchivedSessionsDialogOpen),l=o||s,u=je(e=>e.projects),d=q(e=>e.archivedSessions),f=De(e=>e.setCurrentSession),p=I(e=>e.setSettingsDialogOpen),[m,h]=Q.useState(!1),[g,_]=Q.useState(null),[y,b]=Q.useState(null);Q.useEffect(()=>{if(!l){_(null),b(null);return}let e=!1;return h(!0),Ee().catch(()=>{e||J.error(t(`settings.openchamber.archivedSessions.toast.loadFailed`))}).finally(()=>{e||h(!1)}),()=>{e=!0}},[l,t]);let x=Q.useMemo(()=>{let e=ba([],u.map(e=>({id:e.id,normalizedPath:e.path})),new Map,v(),d),n=new Map;for(let[t,r]of e.archivedSessionsByProject)n.set(t,[...r].sort((e,t)=>Sa(t)-Sa(e)));let r=new Set;for(let e of n.values())for(let t of e)r.add(t.id);let i=d.filter(e=>!r.has(e.id)).sort((e,t)=>Sa(t)-Sa(e));i.length>0&&n.set(xa,i);let a=[];for(let e of u){let t=n.get(e.id)??[];t.length!==0&&a.push({projectId:e.id,label:e.label||e.path,path:e.path,sessions:t})}let o=n.get(xa);return o&&o.length>0&&a.push({projectId:xa,label:t(`settings.openchamber.archivedSessions.otherProjects`),path:null,sessions:o}),a.sort((e,t)=>t.sessions.length-e.sessions.length||e.label.localeCompare(t.label)),a},[d,u,t]),S=d.length,C=g?x.find(e=>e.projectId===g)??null:null,w=Q.useCallback(async e=>{b(e.id);try{await Oe(e.id)?J.success(t(`settings.openchamber.archivedSessions.toast.restored`)):J.error(t(`settings.openchamber.archivedSessions.toast.restoreFailed`))}finally{b(null)}},[t]),T=Q.useCallback(e=>{let t=Pe(e);f(e.id,t),c(!1),p(!1)},[f,c,p]),E=C?C.label:t(`settings.openchamber.archivedSessions.dialog.title`),D=C?C.sessions.length===1?t(`settings.openchamber.archivedSessions.dialog.sessionCountSingle`,{count:C.sessions.length}):t(`settings.openchamber.archivedSessions.dialog.sessionCountPlural`,{count:C.sessions.length}):t(`settings.openchamber.archivedSessions.dialog.description`),O=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[C?(0,Z.jsxs)(K,{type:`button`,variant:`ghost`,size:`sm`,className:`!h-7 !px-2 !font-normal text-muted-foreground`,onClick:()=>_(null),children:[(0,Z.jsx)(Y,{name:`arrow-left-s`,className:`mr-1 h-4 w-4`}),t(`settings.openchamber.archivedSessions.dialog.backToProjects`)]}):null,m?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground py-6`,children:[(0,Z.jsx)(Y,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),t(`settings.openchamber.archivedSessions.dialog.loading`)]}):C?C.sessions.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.openchamber.archivedSessions.dialog.emptyProject`)}):(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:C.sessions.map(e=>{let n=Pe(e),r=Sa(e),i=y===e.id;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-border/60 px-3 py-2.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.title||t(`sessions.sidebar.session.untitled`)}),(0,Z.jsxs)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:[r>0?St(r):null,r>0&&n?` · `:null,n?ve(n):null]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,Z.jsx)(K,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>T(e),children:t(`settings.openchamber.archivedSessions.actions.preview`)}),(0,Z.jsxs)(K,{type:`button`,variant:`default`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>void w(e),children:[i?(0,Z.jsx)(Y,{name:`loader-4`,className:`mr-1 h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(Y,{name:`inbox-unarchive`,className:`mr-1 h-3.5 w-3.5`}),t(`settings.openchamber.archivedSessions.actions.restore`)]})]})]},e.id)})}):x.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.openchamber.archivedSessions.dialog.empty`)}):(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:x.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>_(e.projectId),className:G(`flex w-full items-center gap-3 rounded-lg border border-border/60 px-3 py-2.5 text-left`,`hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),children:[(0,Z.jsx)(Y,{name:`folder`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.label}),e.path?(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:ve(e.path)}):null]}),(0,Z.jsx)(`span`,{className:`typography-meta tabular-nums text-muted-foreground shrink-0`,children:e.sessions.length===1?t(`settings.openchamber.archivedSessions.dialog.sessionCountSingle`,{count:e.sessions.length}):t(`settings.openchamber.archivedSessions.dialog.sessionCountPlural`,{count:e.sessions.length})}),(0,Z.jsx)(Y,{name:`arrow-right-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]},e.projectId))}),!C&&!m&&S>0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(S===1?`settings.openchamber.archivedSessions.summarySingle`:`settings.openchamber.archivedSessions.summaryPlural`,{count:S})}):null]});return o?(0,Z.jsxs)(`div`,{"data-settings-item":`archived-sessions.manage`,className:`oc-settings-section-stack`,children:[(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.archivedSessions.description`)}),O]}):a?(0,Z.jsx)(Tt,{open:s,title:E,onClose:()=>c(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:E}),e]}),(0,Z.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:D})]}),children:O}):(0,Z.jsx)(ze,{open:s,onOpenChange:c,children:(0,Z.jsxs)(Ie,{className:`max-h-[85vh] max-w-2xl overflow-y-auto`,children:[(0,Z.jsxs)(Fe,{children:[(0,Z.jsx)(Le,{children:E}),(0,Z.jsx)(Re,{children:D})]}),O]})})}function wa(){let e=(0,X.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(Ca,{mode:`dialog`}),e[0]=t):t=e[0],t}var Ta=48;function Ea({title:e,eyebrow:t,trailing:n,className:r}){let i=(0,Q.useRef)(null),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l=U(()=>{s.current=null;let e=i.current,t=a.current;if(!e||!t)return;let n=Math.min(1,Math.max(0,t.scrollTop/Ta)),r=o.current?.matches?Number(n>=.5):n;c.current!==null&&Math.abs(c.current-r)<.001||(c.current=r,e.style.setProperty(`--oc-mobile-title-collapse`,r.toFixed(4)))}),u=U(()=>{s.current===null&&(s.current=window.requestAnimationFrame(l))});return(0,Q.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.closest(`.oc-mobile-settings-root-surface, [role="tabpanel"]`);if(!t)return;let n=window.matchMedia(`(prefers-reduced-motion: reduce)`);return a.current=t,o.current=n,c.current=null,t.addEventListener(`scroll`,u,{passive:!0}),n.addEventListener(`change`,u),l(),()=>{t.removeEventListener(`scroll`,u),n.removeEventListener(`change`,u),s.current!==null&&window.cancelAnimationFrame(s.current),s.current=null,a.current=null,o.current=null,c.current=null}},[]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`header`,{ref:i,className:G(`oc-mobile-collapsing-header flex shrink-0 items-start gap-4`,r),children:(0,Z.jsxs)(`div`,{className:`oc-mobile-collapsing-header-inner`,children:[(0,Z.jsxs)(`div`,{className:`oc-mobile-collapsing-header-title-block min-w-0 flex-1`,children:[t?(0,Z.jsx)(`p`,{className:`oc-mobile-collapsing-header-eyebrow truncate typography-micro font-medium text-muted-foreground`,children:t}):null,(0,Z.jsx)(`h1`,{className:`oc-mobile-root-page-title truncate font-semibold text-foreground`,children:e})]}),n?(0,Z.jsx)(`div`,{className:`oc-mobile-collapsing-header-trailing flex min-h-10 shrink-0 items-center gap-3.5`,children:n}):null]})}),(0,Z.jsx)(`div`,{className:`oc-mobile-collapsing-header-spacer`,"aria-hidden":`true`})]})}export{hr as A,yn as B,si as C,Sr as D,br as E,sr as F,sn as G,bn as H,lr as I,ur as L,gr as M,yr as N,Cr as O,cr as P,ar as R,ci as S,Yr as T,hn as U,xn as V,cn as W,Fi as _,ha as a,hi as b,ea as c,Yi as d,Ji as f,Li as g,Ii as h,ba as i,vr as j,mr as k,$i as l,ji as m,wa as n,fa as o,Pi as p,Ca as r,na as s,Ea as t,qi as u,Ai as v,Xr as w,li as x,Ei as y,qn as z};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{c as t,i as n}from"./runtime-switch-BJM2k_uH.js";import{A as r,M as i,On as a,d as o,f as s,on as c}from"./persistence-Dnj1QOdX.js";import{a as l,i as u,r as d}from"./vendor-zustand-DzRqcymP.js";import{nt as f,rt as p}from"./vendor-base-ui-CnHfUmDN.js";import{B as m,Ct as h,M as g,Mt as _}from"./platform-wu6wSDfg.js";import{b as v,n as ee,x as y}from"./useUIStore-Dfx6TKvi.js";import{n as b}from"./vendor-react-DLPElpoQ.js";import{s as x}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as S}from"./vendor-reactuses-core-Dq5ocTF8.js";import{f as te,r as C,u as ne}from"./button-CUwjpv-i.js";import{Dr as re,Ra as ie,S as ae,Vt as oe,_t as w,br as se,cn as ce,d as T,dt as le,eo as ue,ft as de,mt as fe,pa as pe,pt as me,to as E,vn as D,y as he,zn as ge}from"./useMobileNavigationStore-BjIptzTV.js";import{n as O}from"./Icon-BdzPRCSy.js";import{g as _e,v as ve}from"./gitApi-C-zOJTEi.js";import{f as ye,o as be}from"./projectMeta-iGmHOQNp.js";import{n as xe}from"./textarea-Kl-rTWJe.js";import{n as Se,r as Ce,t as we}from"./fileMentionTouchSelection-BJOHH2CX.js";var Te=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`reload`:return`refresh`;case`goal`:return`target`;case`review`:return`search-eye`;case`test`:case`build`:case`run`:return`terminal-box`;default:return e.isBuiltIn?`flashlight`:`command`}},Ee=()=>`book-open`,De=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`}},k=()=>`ai-agent`,Oe=()=>`chat-thread`,ke=(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:Te(e)}}),Ae=({skills:e=[],agents:t,sessions:n,recentFiles:r,pathHits:i,untitledSession:a,sessionBadge:o,skillBadge:s})=>{let c=[];for(let t of e)c.push({id:`skill:${t.name}-${t.scope}`,title:`@${t.name}`,subtitle:t.description,badge:s??t.scope,iconName:Ee()});for(let e of t)c.push({id:`agent:${e.name}`,title:`@${e.name}`,subtitle:e.description,iconName:k()});for(let e of n)c.push({id:`session:${e.id}`,title:e.title||a,badge:o,iconName:Oe()});for(let e of r)c.push({id:`recent:${e.path}`,title:e.relativePath||e.name,iconName:De(e)});for(let e of i)c.push({id:`file:${e.path}`,title:e.relativePath||e.name,iconName:De(e)});return c},je=(e,t)=>{let n=t.trim();if(!n.length)return[...e].sort((e,t)=>e.scope===`project`&&t.scope!==`project`?-1:e.scope!==`project`&&t.scope===`project`?1:e.name.localeCompare(t.name));let r=ge([...e],n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.scope===`project`&&t.item.scope!==`project`?-1:e.item.scope!==`project`&&t.item.scope===`project`?1:e.item.name.localeCompare(t.item.name):e.score-t.score),r.map(e=>e.item)},Me=(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=ge([...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)},Ne=(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}),Pe=(e,t)=>e.highlightedIndex===t.highlightedIndex&&Ne(e.rows,t.rows),Fe=(e,t)=>Ne(e,t)?e:t.slice(),Ie=(e,t,n)=>{e&&(t.current&&Pe(t.current,n)||(t.current=n,e(n)))},Le=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},A=e(p(),1),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},M=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,N=(e,t)=>{let n=j(t),r=j(e);if(!n||!r)return!1;let i=M(n),a=M(r);return a===i||a.startsWith(`${i}/`)},Re=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=>N(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>j(e)).filter(e=>N(e,t)))):[],s=typeof i.selectedPath==`string`?j(i.selectedPath):null,c=s&&N(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},P=(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},F=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},ze=l()(d(u((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=j((t||``).trim()),a=j((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!N(a,i)||e(e=>{let t=e.byRoot[i],n=F(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:P({...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=M(i),a=e=>M(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:P({...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=M(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=M(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:P({...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=M(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=M(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:P({...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&&!N(a,i)||e(e=>{let t=e.byRoot[i],n=F(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:P({...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||!N(i,r)||e(e=>{let t=e.byRoot[r],n=F(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:P({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=j((t||``).trim()),i=j((n||``).trim());!r||!i||!N(i,r)||e(e=>{let t=e.byRoot[r],n=F(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:P({...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&&N(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=F(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:P({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:v(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:Re(t)}},partialize:e=>({byRoot:Re(e.byRoot)})}),{name:`files-view-tabs-store`})),I=b(),Be=(e,t)=>{let n=(0,I.c)(4),r=t===void 0?200:t,[i,a]=A.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]),A.useEffect(o,s),i},Ve=()=>{let e=(0,I.c)(17),t=T(L),n=D(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=ae(r),a=T(R),o=T(z),s=E(He),c=E(B),l=h(Ue);if(t){let r;e[2]===i?r=e[3]:(r=he(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 L(e){return e.currentSessionId}function R(e){return e.worktreeMetadata}function z(e){return e.newSessionDraft}function He(e){return e.activeProjectId}function B(e){return e.projects}function Ue(e){return e.currentDirectory}var V=f(),H=`bg-transparent font-[inherit] text-[var(--primary-base)]`,U=(e,t)=>{let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase();if(!r.includes(n))return e;let i=[],a=0,o=r.indexOf(n);for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push((0,V.jsx)(`mark`,{className:H,children:e.slice(o,o+n.length)},`${o}-${n}`)),a=o+n.length,o=r.indexOf(n,a);return a<e.length&&i.push(e.slice(a)),i},W=A.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:a,onSessionSelect:o,onClose:s,style:c,onRowsChange:l},u)=>{let{t:d}=te(),f=Ve()??``,p=T(e=>e.currentSessionId),m=re(e=>e.activeSessions),h=oe({enabled:!!o}),g=E(e=>e.activeProjectId),v=E(e=>e.projects),y=A.useMemo(()=>v.find(e=>e.id===g)?.path??null,[g,v]),b=A.useMemo(()=>{let e=y||f;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[y,f]),x=ze(e=>b?e.byRoot[b]:void 0),ae=pe(e=>e.getVisibleAgents),ce=_(e=>e.searchFiles),ue=Be(e,180),D=i(),he=r(),[ge,_e]=A.useState([]),[ve,ye]=A.useState([]),[be,Te]=A.useState(!1),[k,Oe]=A.useState(0),ke=A.useRef(0),[Me,Ne]=A.useState(360),[Pe,Fe]=A.useState({}),[j,M]=A.useState({}),N=A.useRef([]),Re=A.useRef([]),P=A.useRef([]),F=A.useRef(null),I=A.useRef(null),L=A.useRef(null);L.current||=we();let R=ee(e=>e.isMobile),z=(e??``).trim(),He=ie({directory:f||null}),B=A.useMemo(()=>a?je(He.data??[],z):[],[z,a,He.data]),Ue=A.useMemo(()=>{if(!b||!x)return[];let e=[x.selectedPath,...x.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r);let e=r.replace(/\\/g,`/`),i=e.split(`/`).filter(Boolean).pop()||e,a=e.startsWith(`${b}/`)?e.slice(b.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return fe(n,z,{limit:6})},[z,b,x]),H=A.useMemo(()=>z.length>0?ve:ve.slice(0,2),[ve,z.length]),W=A.useMemo(()=>o?le({sessions:se(m,h),currentSessionId:p,searchQuery:z}):[],[m,p,h,z,o]),G=Ue,K=ge;A.useEffect(()=>{let e=e=>{let t=e.target;!t||!F.current||F.current.contains(t)||s()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[s]),A.useEffect(()=>{if(!f){_e([]);return}let e=(ue??``).trim(),t=w(e);if(!t){_e([]);return}let n=!1;Te(!0);let r={includeHidden:D,respectGitignore:!he};return Promise.all([ce(f,t,80,{...r,type:`file`}),ce(f,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(Ue.map(e=>e.path));_e(de({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||_e([])}).finally(()=>{n||Te(!1)}),()=>{n=!0}},[f,ue,Ue,ce,D,he]),A.useEffect(()=>{let t=ae().filter(e=>e.mode&&e.mode!==`primary`).map(e=>({name:e.name,description:e.description,mode:e.mode}));ye(me(t,e??``))},[ae,e]),A.useEffect(()=>{Oe(0),Fe({}),M({})},[K,G.length,H.length,W.length,B.length]),A.useEffect(()=>{ke.current=k},[k]),A.useEffect(()=>{N.current[k]?.scrollIntoView({block:`nearest`})},[k]),A.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};Re.current.forEach((n,r)=>{if(!n)return;let i=P.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}}),Fe(e),M(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[K,G]),A.useEffect(()=>{let e=Re.current[k];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&Ne(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[k]);let We=S(e=>{t(e)}),Ge=S(e=>{n?.(e)}),Ke=S(e=>{o?.(e)}),q=S(e=>{a?.(e)}),J=B.length,qe=J,Je=qe+H.length,Y=Je+W.length,Ye=Y+G.length,Xe=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&L.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&L.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(L.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>L.current?.pointerCancel(),onClick:()=>{L.current?.click(t)},onMouseMove:()=>Oe(e)}),Ze=e=>{let t=J+H.length+W.length+G.length+K.length;if(t===0)return;let n=(e%t+t)%t;if(n<J){let e=B[n];e&&q(e);return}if(n<Je){let e=H[n-qe];e&&Ge(e.name);return}if(n<Y){let e=W[n-Je];e&&Ke(e);return}let r=n-Y,i=r<G.length?G[r]:K[r-G.length];i&&We(i)};A.useEffect(()=>{Ie(l,I,{rows:Ae({skills:B,agents:H,sessions:W,recentFiles:G,pathHits:K,untitledSession:d(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:d(`chat.fileMentionAutocomplete.sessionType`),skillBadge:d(`chat.commandAutocomplete.badge.skill`)}),highlightedIndex:k})},[l,k,d,H,K,G,W,B]);let X=A.useRef(l);X.current=l,A.useEffect(()=>()=>{Le(X.current,I)},[]),A.useImperativeHandle(u,()=>({acceptIndex:e=>{Ze(e)},handleKeyDown:e=>{if(e===`Escape`){s();return}let t=J+H.length+W.length+G.length+K.length;if(t!==0){if(e===`ArrowDown`){Oe(e=>(e+1)%t);return}if(e===`ArrowUp`){Oe(e=>(e-1+t)%t);return}(e===`Enter`||e===`Tab`)&&Ze(ke.current)}}}),[J,K,G,H,W,B,s,We,Ge,Ke,q]);let Z=e=>(0,V.jsx)(O,{name:De(e),className:`h-3.5 w-3.5 text-current`});return(0,V.jsxs)(Se,{ref:F,isMobile:R,className:`max-w-[640px] max-h-64`,style:c,children:[(0,V.jsx)(xe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,V.jsxs)(`div`,{className:`pb-2`,children:[B.length>0&&(0,V.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.skills`)}),B.map((e,t)=>{let n=k===t;return(0,V.jsx)(`div`,{ref:e=>{N.current[t]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,R&&`min-h-11`,Ce(R,n),!R&&n&&`text-interactive-selection-foreground`),...Xe(t,()=>q(e)),children:(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(O,{name:Ee(),className:`h-3.5 w-3.5 translate-y-px flex-shrink-0 text-current`}),(0,V.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`@`,U(e.name,z)]}),R?null:(0,V.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:e.scope})]}),e.description?(0,V.jsx)(`div`,{className:C(`pl-5.5 truncate text-muted-foreground`,R?`typography-micro`:`typography-meta`),children:U(e.description,z)}):null]})},`skill-${e.name}-${e.scope}`)}),H.length>0&&(0,V.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.agents`)}),H.map((e,t)=>{let n=qe+t,r=k===n;return(0,V.jsx)(`div`,{ref:e=>{N.current[n]=e},className:C(`flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,R&&`min-h-11`,Ce(R,r),!R&&r&&`text-interactive-selection-foreground`),...Xe(n,()=>Ge(e.name)),children:(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`div`,{className:`truncate`,children:[`@`,U(e.name,z)]}),e.description&&!R?(0,V.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:U(e.description,z)}):null]})},`agent-${e.name}`)}),H.length===2&&z.length===0&&ve.length>2&&(0,V.jsx)(`div`,{className:`px-3 py-1 typography-meta text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.searchMoreAgents`)}),W.length>0&&(0,V.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.sessions`)}),W.map((e,t)=>{let n=Je+t,r=k===n;return(0,V.jsxs)(`div`,{ref:e=>{N.current[n]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,R&&`min-h-11`,Ce(R,r),!R&&r&&`text-interactive-selection-foreground`),...Xe(n,()=>Ke(e)),children:[(0,V.jsx)(O,{name:`chat-thread`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title||d(`chat.fileMentionAutocomplete.untitledSession`),children:U(e.title||d(`chat.fileMentionAutocomplete.untitledSession`),z)}),R?null:(0,V.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.sessionType`)})]},`session-${e.id}`)}),G.length>0&&(0,V.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.recentFiles`)}),G.map((e,t)=>{let n=Y+t,r=e.relativePath||e.name,i=ne(r,{maxLength:60}),a=k===n,o=Pe[n]??!1,s=j[n]??2.6;return(0,V.jsxs)(`div`,{ref:e=>{N.current[n]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,R&&`min-h-11`,Ce(R,a),!R&&a&&`text-interactive-selection-foreground`),...Xe(n,()=>We(e)),children:[Z(e),(0,V.jsxs)(`span`,{ref:e=>{Re.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${Me}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,V.jsx)(`span`,{ref:e=>{P.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,V.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:U(r,z)}):(0,V.jsx)(`span`,{className:`block truncate`,children:U(i,z)})]})]},`recent-${e.path}`)}),K.length>0&&(0,V.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.files`)}),K.map((e,t)=>{let n=Ye+t,r=e.relativePath||e.name,i=ne(r,{maxLength:60}),a=k===n,o=Pe[n]??!1,s=j[n]??2.6;return(0,V.jsxs)(`div`,{ref:e=>{N.current[n]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,R&&`min-h-11`,Ce(R,a),!R&&a&&`text-interactive-selection-foreground`),...Xe(n,()=>We(e)),children:[Z(e),(0,V.jsxs)(`span`,{ref:e=>{Re.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${Me}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,V.jsx)(`span`,{ref:e=>{P.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,V.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:U(r,z)}):(0,V.jsx)(`span`,{className:`block truncate`,children:U(i,z)})]})]},e.path)}),be&&K.length===0?(0,V.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,V.jsx)(O,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!be&&K.length===0&&G.length===0&&H.length===0&&W.length===0&&B.length===0&&(0,V.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.empty`)})]})}),!R&&(0,V.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:d(`chat.autocomplete.keyboardHint`)})]})}),G=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`goal`,`btw`]),K=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&G.has(n))},We=(e,t)=>!e||t({name:e}),Ge=` `,Ke=(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]===Ge&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},q=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,J=C(q,`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)]`),qe=C(q,`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)]`),Je=C(q,`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)]`),Y=C(q,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),Ye=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),Xe=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!c()}},Ze=A.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:i,commandPolicy:a,commandContext:o,onRowsChange:s},l)=>{let{t:u}=te(),d=ee(e=>e.isMobile),f=T(e=>e.currentSessionId),p=T(e=>!!e.newSessionDraft?.open),m=T(A.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=ce(f??``,m??void 0),g=A.useMemo(()=>o??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[o,f,h.length,p]),{hasSession:_,canStartSessionCommand:v,canUseReviewHandoffFlow:y}=A.useMemo(()=>Xe(g,d),[g,d]),b=g.hasMessages,[x,S]=A.useState([]),[ne,re]=A.useState(!1),ie=ue({directory:r}),ae=A.useMemo(()=>ie.data??[],[ie.data]),oe=ie.isFetching,[w,se]=A.useState(0),le=A.useRef(0),de=A.useRef(!1),fe=A.useRef([]),pe=A.useRef(null),me=A.useRef(!1),E=A.useRef(null),D=A.useRef(!1),he=A.useRef(null);A.useEffect(()=>{let e=e=>{let t=e.target;!t||!pe.current||pe.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),A.useEffect(()=>{(async()=>{re(oe);try{let t=ae.flatMap((e,t)=>e.source===`skill`?[]:[{id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,scope:e.scope,reference:e.reference}]),n=[{id:`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:btw`,name:`btw`,source:`openchamber`,description:u(`chat.btw.description`),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},...c()?[{id:`openchamber:reload`,name:`reload`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.reloadDescription`),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: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],r=!b,i=Me(n.filter(e=>(r||e.name!==`init`)&&(a?.(e)??!0)),e);S(e=>Ye(e,i)?e:i)}catch{let t=!b,n=Me([{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:btw`,name:`btw`,source:`openchamber`,description:u(`chat.btw.description`),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},...c()?[{id:`openchamber:reload`,name:`reload`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.reloadDescription`),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: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`)&&(a?.(e)??!0)),e);S(e=>Ye(e,n)?e:n)}finally{re(!1)}})()},[e,b,_,v,y,ae,oe,u,a]),A.useEffect(()=>{se(0)},[x]),A.useEffect(()=>{le.current=w},[w]),A.useEffect(()=>{fe.current[w]?.scrollIntoView({block:`nearest`})},[w]),A.useEffect(()=>{Ie(s,he,{rows:ke(x,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:w})},[x,s,w,u]);let ge=A.useRef(s);ge.current=s,A.useEffect(()=>()=>{Le(ge.current,he)},[]),A.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=x[e];r&&t(r,K(r,n))},handleKeyDown:e=>{let r=x.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){de.current=!0,se(e=>(e+1)%r);return}if(e===`ArrowUp`){de.current=!0,se(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(le.current%r+r)%r,i=x[n];i&&t(i,K(i,e===`Enter`))}}}}),[x,n,t]);let _e=e=>{let t=Te(e);switch(e.name){case`new`:return(0,V.jsx)(O,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,V.jsx)(O,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,V.jsx)(O,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,V.jsx)(O,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,V.jsx)(O,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,V.jsx)(O,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,V.jsx)(O,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,V.jsx)(O,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,V.jsx)(O,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,V.jsx)(O,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,V.jsx)(O,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,V.jsxs)(Se,{ref:pe,isMobile:d,className:`max-w-[450px] max-h-64`,style:i,children:[(0,V.jsx)(xe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:ne?(0,V.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,V.jsx)(O,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,V.jsxs)(`div`,{children:[x.map((n,r)=>{let i=n.isBuiltIn,a=n.isOpenChamber;return(0,V.jsxs)(`div`,{ref:e=>{fe.current[r]=e},className:C(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,Ce(d,r===w),!d&&r===w&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(E.current={x:e.clientX,y:e.clientY},D.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!E.current)return;let t=e.clientX-E.current.x,n=e.clientY-E.current.y;Math.hypot(t,n)>6&&(D.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=D.current;E.current=null,D.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),me.current=!0,t(n,K(n,d)))},onPointerCancel:()=>{E.current=null,D.current=!1},onClick:()=>{if(me.current){me.current=!1;return}t(n,K(n,d))},onMouseMove:()=>{de.current=!1,se(r)},children:[(0,V.jsx)(`div`,{className:C(!d&&`mt-0.5`),children:_e(n)}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,U(n.name,e)]}),n.isSkill?(0,V.jsx)(`span`,{className:J,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,V.jsx)(`span`,{className:J,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,V.jsx)(`span`,{className:Y,children:`OpenChamber`}):i?(0,V.jsx)(`span`,{className:Y,children:u(`chat.commandAutocomplete.badge.system`)}):n.scope?(0,V.jsx)(`span`,{className:n.scope===`project`?Je:qe,children:n.scope}):null,n.agent&&(0,V.jsx)(`span`,{className:Y,children:n.agent})]}),n.description&&!d&&(0,V.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:U(n.description,e)})]})]},n.id)}),x.length===0&&(0,V.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,V.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});Ze.displayName=`CommandAutocomplete`;var X=2,Z=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Qe=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},$e=e=>Z(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&Z(e.branches),et=(e,t)=>JSON.stringify([e,t]),tt=e=>`version`in e&&e.version===X&&Z(e.entries),nt=e=>{if(!e)return null;try{let t=JSON.parse(e);return Z(t)?t.version===X&&Z(t.entries)?{version:X,entries:t.entries}:t:null}catch{return null}},rt=(e,t)=>{try{e.setItem(`oc.gitBranchCache`,JSON.stringify(t))}catch{}},it=(e,t,n)=>{let r=Qe(e);if(!r||!t)return null;let i;try{i=n.getItem(`oc.gitBranchCache`)}catch{return null}let a=nt(i);if(!a)return null;if(tt(a))return $e(a.entries[et(t,r)])?a.entries[et(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=Qe(e);r&&$e(n)&&(o[et(t,r)]=n)}return rt(n,{version:X,entries:o}),o[et(t,r)]??null},at=(e,t,n,r)=>{let i=Qe(e);if(!i||!t||!$e(n))return;let a=null;try{a=r.getItem(`oc.gitBranchCache`)}catch{return}let o=nt(a);rt(r,{version:X,entries:{...o&&tt(o)?o.entries:{},[et(t,i)]:n}})},ot=3e4,st=Qe,ct=(e,t=n())=>s.git.branches(st(e),t),lt=(e,t=n())=>s.git.remotes(st(e),t),ut=async(e,t,n)=>{n.throwIfAborted();let r=a()?.git,i=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):r?await r.getGitBranches(e,{signal:n}):await g(e,{signal:n});return n.throwIfAborted(),i},dt=async(e,t,n)=>{n.throwIfAborted();let r=a()?.git,i=t?.getRemotes?await t.getRemotes(e,{signal:n}):r?await r.getRemotes(e,{signal:n}):await m(e,{signal:n});return n.throwIfAborted(),i},ft=(e,t,r=n(),i=y())=>{let a=st(e),o=t;return{queryKey:ct(a,r),queryFn:async({signal:e})=>{if(!a)throw Error(`Git branches require a directory`);let t=await ut(a,o,e);return at(a,r,t,i),t},staleTime:ot,gcTime:1/0,initialData:()=>it(a,r,i)??void 0,initialDataUpdatedAt:0}},pt=(e,t,r=n())=>{let i=st(e),a=t;return{queryKey:lt(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return dt(i,a,e)},staleTime:ot,gcTime:1/0}},mt=(e,r,i)=>{let a=(0,I.c)(9),o=i===void 0||i,s=A.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=st(e),u=x,l=ft(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,I.c)(9),o=i===void 0||i,s=A.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=st(e),u=x,l=pt(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)},gt=(e,t,r=o,i=n())=>r.fetchQuery(ft(e,t,i)),_t=(e,t,r=o,i=n())=>r.fetchQuery({...ft(e,t,i),staleTime:0}),vt=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,yt=1e4,bt=6e4,xt=5e3,St=3e4,Ct=6e4,wt=25,Tt=40,Et=2,Dt=15e3,Ot=500,kt=30,At=20971520,jt=new Map,Mt=new Map,Nt=new Map,Pt=new Map,Ft=new Map,It=(e,t)=>`${t}:${e}`,Lt=e=>Mt.get(e)??0,Rt=e=>{let t=Lt(e)+1;return Mt.set(e,t),t},zt=e=>{let t=(Nt.get(e)??0)+1;return Nt.set(e,t),t},Bt=e=>{let t=jt.get(e);if(t)return t;let n=new Set;return jt.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}),Vt=(e,t=kt,n=At)=>{let r=0;for(let t of e.values())r+=(t.original?.length??0)+(t.modified?.length??0);if(e.size<=t&&r<=n)return e;let i=Array.from(e.entries()).sort((e,t)=>e[1].fetchedAt-t[1].fetchedAt),a=new Map,o=0;for(let e=i.length-1;e>=0;e--){let[r,s]=i[e],c=(s.original?.length??0)+(s.modified?.length??0);if(a.size>=t)break;o+c>n&&a.size>0||(a.set(r,s),o+=c)}return a},Ht=(e,t)=>{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},Ut=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,Wt=(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&&Ut(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&&Ht(e.diffStats,t.diffStats))},Gt=(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},Kt=(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},qt=e=>!e||e.trim().length===0,Jt=e=>(e||``).trim()===`U`,Yt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Jt(t)||Jt(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},Xt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Jt(t)||Jt(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Zt=e=>qt(e.index)&&qt(e.working_dir),$=l()(d((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&Rt(r),n&&Rt(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=It(n,a),s=Pt.get(o)??(a===`light`?Pt.get(It(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=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)>bt,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(Wt(s.status,u)){c=!0;let r=new Map(t().directories),i=r.get(n)??Q(),s=Gt(i.status,u),l=Kt(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&&Rt(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})();Pt.set(o,c);try{return await c}finally{Pt.get(o)===c&&Pt.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`?Yt(e):Xt(e);t!==e&&(l=!0),Zt(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(n,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(n,r)=>{let{directories:i}=t(),a=i.get(n);if(!a)return;let o=new Map(i);o.set(n,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:n=>{let{directories:r}=t(),i=r.get(n);if(!i)return;let a=new Map(r);a.set(n,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=n(),s=zt(r);{let n=new Map(t().directories),i=n.get(r)??Q();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await _t(r,i,void 0,o):await gt(r,i,void 0,o);if(s!==Nt.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(vt(i)||console.error(`Failed to fetch git branches:`,i),s!==Nt.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>yt||!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=Vt(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{Rt(n);let r=new Map(t().directories),i=r.get(n);i&&(r.set(n,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,n)=>{let r=t().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,wt);await t().prefetchDiffs(e,n,i,{maxFiles:wt})},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=Tt}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=Bt(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>Ot||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=Lt(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 ${Dt}ms`)),Dt)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},ee=async()=>{for(;;){if(m!==Lt(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{u.delete(e)}}},y=Math.min(Et,p.length);if(await Promise.allSettled(Array.from({length:y},()=>ee())),p.forEach(e=>u.delete(e)),m!==Lt(n))return;let b=new Map(t().directories),x=b.get(n);if(!x)return;let S=new Map(x.diffCache),te=Date.now();g.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||S.set(e.path,{...e.diff,fetchedAt:te})});let C=Vt(S);b.set(n,{...x,diffCache:C}),e({directories:b})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<xt||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=Ft.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)>=xt)&&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>=St)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=yt)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=Ct)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return Ft.set(e,i),i.finally(()=>{Ft.get(e)===i&&Ft.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Qt=e=>{let t=(0,I.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)},$t=e=>{let r=(0,I.c)(3),i=A.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)},en=e=>{let t=(0,I.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)},tn=e=>{let t=(0,I.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)},nn=e=>{let t=(0,I.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)},rn=e=>{let t=(0,I.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=A.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)},an=e=>{let t=(0,I.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)},on=e=>{let t=(0,I.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)},sn=e=>{let t=(0,I.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)},cn=e=>{let t=String(e||``).trim().replace(/^remotes\//,``);if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{remote:t.slice(0,n),branch:t.slice(n+1)}},ln=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),un=e=>e.branchName?ln(e.branchName):e.mode===`existing`?ln(e.existingBranch||e.preferredName||``):ln(e.preferredName||``),dn=async e=>{let t=await ye(e);try{let n=cn((await _e(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=cn((await ve(e)).tracking);if(t?.remote)return t.remote}catch{}return null},fn=async(e,t)=>{let n=await dn(e),r=ln(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},pn=async(e,t,n)=>{let r=un(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await fn(e,r):i&&ln(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:ln(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},mn=async(e,t,n)=>{let r=await pn(e.path,t,n);return be(e,r)},hn=`oc:lastWorktreeSourceBranch`,gn=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,_n=({branches:e,savedSourceBranch:t,rootBranch:n})=>t&&e.includes(t)&&t?{sourceBranch:t,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&e.includes(n)?n:e.includes(`main`)?`main`:e.includes(`master`)?`master`:e[0]??``,shouldClearSavedSourceBranch:!!t},vn=(e,t,n)=>{if(!e)return e;let r=t.length>0&&!/\s$/.test(t)&&!/^\s/.test(e)&&!/[([{]$/.test(t),i=n.length>0&&!/\s$/.test(e)&&!/^\s/.test(n)&&!/^[\])}.,;:!?]/.test(n);return`${r?` `:``}${e}${i?` `:``}`},yn=(e,t,n)=>{let r=vn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},bn=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=yn(r,i,a),s=Math.max(0,o.indexOf(r)),c=i.length+s;return{text:`${i}${o}${a}`,caret:i.length+o.length,start:c,end:c+r.length}},xn=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))||e.some(e=>e.range.start<t.range.end&&t.range.start<e.range.end)?[...e]:[...e,t]},Sn=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{ze as A,ht as C,W as D,We as E,Ve as O,mt as S,Ke as T,rn as _,hn as a,tn as b,mn as c,nn as d,$t as f,en as g,an as h,yn as i,Fe as j,Be as k,dn as l,on as m,xn as n,_n as o,sn as p,bn as r,gn as s,Sn as t,pn as u,Qt as v,Ze as w,_t as x,$ as y};
@@ -1,3 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{rn as t}from"./persistence-Dnj1QOdX.js";import{a as n,r}from"./vendor-zustand-DzRqcymP.js";import{nt as i,rt as a}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as o,Ln as s,Nt as c,Un as l}from"./platform-wu6wSDfg.js";import{n as u}from"./useUIStore-Dfx6TKvi.js";import{n as d}from"./vendor-react-DLPElpoQ.js";import{n as f}from"./vendor-reactuses-core-Dq5ocTF8.js";import{f as p,i as m,r as h,t as g,y as _}from"./button-CUwjpv-i.js";import{Dr as v,Ea as y,Qn as b,Zn as x,d as S,dr as C,jr as w,pa as T,to as E,tr as D,u as O,wa as k}from"./useMobileNavigationStore-BjIptzTV.js";import{n as A}from"./Icon-BdzPRCSy.js";import{n as j}from"./gitApi-C-zOJTEi.js";import{A as ee,D as te,O as M,S as ne,_ as re,a as N,b as ie,f as ae,g as P,h as oe,i as F,m as se,n as ce,v as I,x as le,y as L}from"./projectMeta-iGmHOQNp.js";import{t as R}from"./input-BeVw4D0W.js";import{i as z,n as B,t as V}from"./tooltip-DDNnmcXI.js";import{o as ue}from"./OverlayScrollbar-C1C2aKOe.js";import{n as H}from"./useRuntimeAPIs-DSLXJybW.js";import{r as de,t as U}from"./textarea-Kl-rTWJe.js";import{D as fe,a as W,b as G,c as K,f as q,h as J,l as Y,o as X,p as pe,r as me,w as he,y as ge}from"./insertionBoundaries-DduQc2QR.js";import{n as _e,r as ve,t as ye}from"./collapsible-paItOH3A.js";var Z=e(a(),1),be=d(),xe=/^[a-z0-9](?:[a-z0-9-]{0,48}[a-z0-9])?$/,Se=/^g[1-9]\d*$/,Q=(e,t,n,r,i)=>{if(!xe.test(e)||t!==void 0&&!Se.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}},Ce=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 Se.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)},we=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(`/`)},Te=(e,t,n,r)=>{let i=[e];return r&&i.push(r),i.push(t,n,`fusion`),i.join(`/`)},Ee=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).substring(0,50),De=(e,t)=>`${Ee(e)}-${Ee(t)}`.substring(0,60),Oe=(e,t)=>`${e}/${t}`,ke=e=>{let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.length>1?t.replace(/\/+$/,``):t},Ae=(e,t)=>{let n=ke(t),r=e.directory,i=typeof r==`string`&&r.trim().length>0?e:{...e,directory:n};l(e.id,n),S.getState().markSessionAsOpenChamberCreated(e.id),v.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},je=()=>{let e=E.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=o.getState().currentDirectory??null;if(r&&r.trim().length>0){let e=r.replace(/\\/g,`/`).replace(/\/+$/,``)||r;return{id:`path:${e}`,path:e}}return null},Me=n()(r(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=je();if(!s)return e({error:`Select a project`,isLoading:!1}),null;let l=s.path,u=await j(l)&&t.isolateRuns!==!1,d=Ee(n),f=u?await ae(l):void 0,p=u?await Y(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,v=(o.get(n)||0)+1;o.set(n,v);let y=De(g.providerID,g.modelID),x=r.length>1?`g${e+1}`:void 0,w=_>1?Oe(d,`${y}/${v}`):Oe(d,y),T=x?`${x}/${w}`:w,E=we({groupSlug:d,runGroup:x,providerID:g.providerID,modelID:g.modelID,index:_>1?v:void 0});try{if(!u){let e=await c.withDirectory(l,()=>c.createSession({title:E}));Ae(e,l),m.push({sessionId:e.id,worktreePath:l,providerID:g.providerID,modelID:g.modelID,variant:g.variant,prompt:i});continue}let e=await K(s,{preferredName:T,mode:`new`,branchName:T,worktreeName:T,startRef:t.worktreeBaseBranch||`HEAD`,setupCommands:h,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:p}),n={...e,createdFromBranch:f,kind:`standard`};await b(s)&&await C(e.path);let r=await c.withDirectory(e.path,()=>c.createSession({title:E}));Ae(r,e.path),S.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 g=o?.filter(e=>e.trim().length>0)??[];g.length>0&&D(s,g).catch(()=>{console.warn(`[MultiRun] Failed to save worktree setup commands`)});let _=m.map(e=>e.sessionId),v=m[0]?.sessionId??null;if(_.length===0)return e({error:`Failed to create any sessions`,isLoading:!1}),null;let y=a?.map(e=>({type:`file`,mime:e.mime,filename:e.filename,url:e.url}));return(async()=>{try{await Promise.allSettled(m.map(async e=>{try{await O({sessionId:e.sessionId,directory:e.worktreePath,content:e.prompt,providerID:e.providerID,modelID:e.modelID,variant:e.variant,agent:i,files:y})}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:_,firstSessionId:v}}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`})),$=i(),Ne=`h-7`,Pe=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Fe=e=>{let t=(0,be.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=h(`flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30`,Ne),t[0]=c):c=t[0];let l;t[1]!==n.modelID||t[2]!==n.providerID?(l=(0,$.jsx)(M,{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)(A,{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},Ie=e=>{let t=(0,be.c)(131),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:a,minModels:o,addButtonLabel:s,showChips:c,maxModels:l,addButtonClassName:d,dropdownSide:f,dropdownClassName:m,containerClassName:_,triggerIcon:v}=e,b=c===void 0||c,x=f===void 0?`top`:f,{t:S}=p(),C=T(Le),w=T(Re),E=u(ze),D=u(Be),{favoriteModelsList:O,recentModelsList:k}=te(),j=u(Ve),ee=u(He),[M,N]=Z.useState(!1),[ae,P]=Z.useState(``),[F,ce]=Z.useState(null),I=Z.useRef(null),L=Z.useRef(null),R=l===1,z=l===void 0||n.length<l||R,B;if(t[0]!==n){B=new Map;for(let e of n){let t=`${e.providerID}:${e.modelID}`;B.set(t,(B.get(t)||0)+1)}t[0]=n,t[1]=B}else B=t[1];let V=B,ue;t[2]===n?ue=t[3]:(ue=e=>n.filter(t=>t.providerID===e.providerID&&t.modelID===e.modelID).findIndex(t=>t.instanceId===e.instanceId)+1,t[2]=n,t[3]=ue);let H=ue,de,U;t[4]!==x||t[5]!==M?(de=()=>{if(!M||!L.current)return;let e=L.current.getBoundingClientRect();if(x===`bottom`){let t=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-e.bottom-16-112;ce(Math.max(160,Math.min(320,t)));return}let t=L.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;ce(Math.max(150,Math.min(300,r)))},U=[x,M],t[4]=x,t[5]=M,t[6]=de,t[7]=U):(de=t[6],U=t[7]),Z.useEffect(de,U);let fe,W;t[8]!==z||t[9]!==M?(fe=()=>{!z&&M&&(N(!1),P(``))},W=[z,M],t[8]=z,t[9]=M,t[10]=fe,t[11]=W):(fe=t[10],W=t[11]),Z.useEffect(fe,W);let G,K;t[12]===M?(G=t[13],K=t[14]):(G=()=>{if(!M)return;let e=e=>{I.current&&!I.current.contains(e.target)&&(N(!1),P(``))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},K=[M],t[12]=M,t[13]=G,t[14]=K),Z.useEffect(G,K);let q;t[15]!==R||t[16]!==r||t[17]!==a||t[18]!==n.length?(q=e=>{let t={providerID:e.providerID,modelID:e.modelID,displayName:y(e.model,e.modelID)||e.modelID,instanceId:Pe()};R&&n.length>0&&a?a(0,t):r(t),R&&(N(!1),P(``))},t[15]=R,t[16]=r,t[17]=a,t[18]=n.length,t[19]=q):q=t[19];let J=q,Y;t[20]===S?Y=t[21]:(Y=S(`multirun.modelMultiSelect.search.placeholder`),t[20]=S,t[21]=Y);let X;t[22]===S?X=t[23]:(X=S(`multirun.modelMultiSelect.search.noResults`),t[22]=S,t[23]=X);let pe;t[24]===S?pe=t[25]:(pe=S(`multirun.modelMultiSelect.sections.favorites`),t[24]=S,t[25]=pe);let me;t[26]===S?me=t[27]:(me=S(`multirun.modelMultiSelect.sections.recent`),t[26]=S,t[27]=me);let he;t[28]===S?he=t[29]:(he=S(`multirun.modelMultiSelect.keyboard.hint`),t[28]=S,t[29]=he);let ge;t[30]===S?ge=t[31]:(ge=S(`settings.agents.modelSelector.actions.favorite`),t[30]=S,t[31]=ge);let _e;t[32]===S?_e=t[33]:(_e=S(`settings.agents.modelSelector.actions.unfavorite`),t[32]=S,t[33]=_e);let ve;t[34]===S?ve=t[35]:(ve=S(`chat.modelControls.provider`),t[34]=S,t[35]=ve);let ye;t[36]===S?ye=t[37]:(ye=S(`chat.modelControls.capabilities`),t[36]=S,t[37]=ye);let xe;t[38]===S?xe=t[39]:(xe=S(`chat.modelControls.capability.toolCalling`),t[38]=S,t[39]=xe);let Se;t[40]===S?Se=t[41]:(Se=S(`chat.modelControls.capability.reasoning`),t[40]=S,t[41]=Se);let Q;t[42]===S?Q=t[43]:(Q=S(`chat.modelControls.modality.image`),t[42]=S,t[43]=Q);let Ce;t[44]===S?Ce=t[45]:(Ce=S(`chat.modelControls.modality.video`),t[44]=S,t[45]=Ce);let we;t[46]===S?we=t[47]:(we=S(`chat.modelControls.modality.audio`),t[46]=S,t[47]=we);let Te;t[48]===S?Te=t[49]:(Te=S(`chat.modelControls.costPerMillion`),t[48]=S,t[49]=Te);let Ee;t[50]===S?Ee=t[51]:(Ee=S(`chat.modelControls.costInput`),t[50]=S,t[51]=Ee);let De;t[52]===S?De=t[53]:(De=S(`chat.modelControls.costOutput`),t[52]=S,t[53]=De);let Oe;t[54]!==Y||t[55]!==X||t[56]!==pe||t[57]!==me||t[58]!==he||t[59]!==ge||t[60]!==_e||t[61]!==ve||t[62]!==ye||t[63]!==xe||t[64]!==Se||t[65]!==Q||t[66]!==Ce||t[67]!==we||t[68]!==Te||t[69]!==Ee||t[70]!==De?(Oe={searchPlaceholder:Y,noResults:X,favorites:pe,recent:me,keyboardHint:he,favorite:ge,unfavorite:_e,provider:ve,capabilities:ye,capabilityToolCalling:xe,capabilityReasoning:Se,modalityImage:Q,modalityVideo:Ce,modalityAudio:we,costPerMillion:Te,costInput:Ee,costOutput:De},t[54]=Y,t[55]=X,t[56]=pe,t[57]=me,t[58]=he,t[59]=ge,t[60]=_e,t[61]=ve,t[62]=ye,t[63]=xe,t[64]=Se,t[65]=Q,t[66]=Ce,t[67]=we,t[68]=Te,t[69]=Ee,t[70]=De,t[71]=Oe):Oe=t[71];let ke=Oe,Ae;t[72]===_?Ae=t[73]:(Ae=h(`relative`,_),t[72]=_,t[73]=Ae);let je;t[74]===d?je=t[75]:(je=h(Ne,`!border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70`,d),t[74]=d,t[75]=je);let Me=!z,Ie;t[76]===M?Ie=t[77]:(Ie=()=>{N(!M)},t[76]=M,t[77]=Ie);let We;t[78]===v?We=t[79]:(We=v??(0,$.jsx)(A,{name:`add`,className:`h-3.5 w-3.5 mr-1`}),t[78]=v,t[79]=We);let Ge;t[80]!==s||t[81]!==S?(Ge=s??S(`multirun.modelMultiSelect.actions.addModel`),t[80]=s,t[81]=S,t[82]=Ge):Ge=t[82];let Ke;t[83]!==je||t[84]!==Me||t[85]!==Ie||t[86]!==We||t[87]!==Ge?(Ke=(0,$.jsxs)(g,{ref:L,type:`button`,variant:`outline`,size:`sm`,className:je,disabled:Me,onClick:Ie,children:[We,Ge]}),t[83]=je,t[84]=Me,t[85]=Ie,t[86]=We,t[87]=Ge,t[88]=Ke):Ke=t[88];let qe;t[89]!==F||t[90]!==z||t[91]!==m||t[92]!==x||t[93]!==O||t[94]!==w||t[95]!==J||t[96]!==j||t[97]!==D||t[98]!==M||t[99]!==ke||t[100]!==V||t[101]!==ee||t[102]!==C||t[103]!==k||t[104]!==ae||t[105]!==E?(qe=M?(0,$.jsx)(`div`,{className:h(`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`,x===`top`?`bottom-full mb-1`:`top-full mt-1`,m),style:{background:`linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))`},children:(0,$.jsx)(ne,{providers:C,providerOrder:ee,favoriteModels:O,recentModels:k,getMetadata:w,hiddenModels:j,searchQuery:ae,onSearchQueryChange:P,onSelect:J,labels:ke,selectionCount:e=>V.get(`${e.providerID}:${e.modelID}`)||0,disabled:!z,maxHeightClassName:`flex-1`,maxHeightStyle:{maxHeight:F?`${F}px`:`300px`},stickyHeaders:!0,tooltipsEnabled:M,isFavorite:e=>D(e.providerID,e.modelID),onToggleFavorite:e=>E(e.providerID,e.modelID),onEscape:()=>{N(!1),P(``)}})}):null,t[89]=F,t[90]=z,t[91]=m,t[92]=x,t[93]=O,t[94]=w,t[95]=J,t[96]=j,t[97]=D,t[98]=M,t[99]=ke,t[100]=V,t[101]=ee,t[102]=C,t[103]=k,t[104]=ae,t[105]=E,t[106]=qe):qe=t[106];let Je;t[107]!==Ae||t[108]!==Ke||t[109]!==qe?(Je=(0,$.jsxs)(`div`,{className:Ae,ref:I,children:[Ke,qe]}),t[107]=Ae,t[108]=Ke,t[109]=qe,t[110]=Je):Je=t[110];let Ye;t[111]!==H||t[112]!==V||t[113]!==i||t[114]!==a||t[115]!==C||t[116]!==n||t[117]!==b||t[118]!==S?(Ye=b&&n.length>0&&(0,$.jsx)(`div`,{className:`flex flex-col gap-2 w-full`,children:n.map((e,t)=>{let n=`${e.providerID}:${e.modelID}`,r=V.get(n)||1,o=H(e),s=C.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)(Fe,{model:e,instanceIndex:o,totalSameModel:r,onRemove:()=>i(t)}),l&&(0,$.jsxs)(se,{value:u,onValueChange:n=>{if(!a)return;let r=n===`__default__`?void 0:n;a(t,{...e,variant:r})},children:[(0,$.jsxs)(ie,{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)(A,{name:`brain-ai-3`,className:h(`h-3.5 w-3.5 flex-shrink-0`,u===`__default__`?`text-muted-foreground`:`text-[color:var(--status-info)]`)}),(0,$.jsx)(le,{placeholder:S(`multirun.modelMultiSelect.variant.placeholder`),children:e=>e===`__default__`?S(`multirun.modelMultiSelect.variant.default`):e})]}),(0,$.jsxs)(oe,{fitContent:!0,children:[(0,$.jsx)(re,{value:`__default__`,className:`pr-2 [&>span:first-child]:hidden`,children:S(`multirun.modelMultiSelect.variant.default`)}),c.map(Ue)]})]})]},e.instanceId)})}),t[111]=H,t[112]=V,t[113]=i,t[114]=a,t[115]=C,t[116]=n,t[117]=b,t[118]=S,t[119]=Ye):Ye=t[119];let Xe;t[120]!==Je||t[121]!==Ye?(Xe=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 items-center`,children:[Je,Ye]}),t[120]=Je,t[121]=Ye,t[122]=Xe):Xe=t[122];let Ze;t[123]!==l||t[124]!==o||t[125]!==n.length||t[126]!==S?(Ze=o!==void 0&&n.length<o&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:l===void 0?S(`multirun.modelMultiSelect.validation.minOnly`,{min:o}):S(`multirun.modelMultiSelect.validation.minToMax`,{min:o,max:l})}),t[123]=l,t[124]=o,t[125]=n.length,t[126]=S,t[127]=Ze):Ze=t[127];let Qe;return t[128]!==Xe||t[129]!==Ze?(Qe=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[Xe,Ze]}),t[128]=Xe,t[129]=Ze,t[130]=Qe):Qe=t[130],Qe};function Le(e){return e.providers}function Re(e){return e.getModelMetadata}function ze(e){return e.toggleFavoriteModel}function Be(e){return e.isFavoriteModel}function Ve(e){return e.hiddenModels}function He(e){return e.providerOrder}function Ue(e){return(0,$.jsx)(re,{value:e,className:`pr-2 [&>span:first-child]:hidden`,children:e},e)}function We(e){let t=(0,be.c)(30),{git:n}=H(),r=q(e),i=G(e),a=J(e),o=pe(e),s=ge(Ye),c=ge(Je),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]),Z.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],Z.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(qe).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(Ke).map(Ge).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 Ge(e){return e.replace(/^remotes\//,``)}function Ke(e){return e.startsWith(`remotes/`)}function qe(e){return!e.startsWith(`remotes/`)}function Je(e){return e.fetchStatus}function Ye(e){return e.fetchBranches}var Xe=({directory:e,value:t,onChange:n,className:r,disabled:i,id:a})=>{let{t:o}=p(),{localBranches:s,remoteBranches:c,isLoading:l,isGitRepository:u}=We(e),d=Z.useMemo(()=>[...s,...c.map(e=>`remotes/${e}`)],[s,c]);return Z.useEffect(()=>{if(i||l||d.length===0||t&&d.includes(t))return;let r=t,a=!1;return(async()=>{try{let t=e?await ae(e).catch(()=>null):null;if(a)return;let i=localStorage.getItem(W),{sourceBranch:o,shouldClearSavedSourceBranch:s}=X({branches:d,savedSourceBranch:i,rootBranch:t});if(s&&localStorage.removeItem(W),a||r&&d.includes(r))return;o&&n(o)}catch{}})(),()=>{a=!0}},[d,e,i,l,n,t]),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(se,{value:t,onValueChange:n,disabled:i||!u||l,children:[(0,$.jsx)(ie,{id:a,size:`lg`,className:r??`w-fit typography-meta text-foreground`,children:(0,$.jsx)(le,{placeholder:o(l?`multiRun.branchSelector.status.loadingBranches`:`multiRun.branchSelector.placeholder.selectSourceBranch`)})}),(0,$.jsx)(oe,{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)(P,{children:[(0,$.jsx)(I,{className:`font-semibold text-foreground`,children:o(`multiRun.branchSelector.groups.localBranches`)}),s.map(e=>(0,$.jsx)(re,{value:e,className:`whitespace-normal break-all`,children:e},e))]}),s.length>0&&c.length>0&&(0,$.jsx)(L,{}),c.length>0&&(0,$.jsxs)(P,{children:[(0,$.jsx)(I,{className:`font-semibold text-foreground`,children:o(`multiRun.branchSelector.groups.remoteBranches`)}),c.map(e=>(0,$.jsx)(re,{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`)})]})},Ze=e=>{let t=(0,be.c)(36),{value:n,onChange:r,className:i,disabled:a,id:o,portalToBody:s}=e,{t:c}=p(),l=T(Qe),u=T($e),d=T(et),f;t[0]===l?f=t[1]:(f=l(),t[0]=l,t[1]=f);let m=f,g;t[2]===m?g=t[3]:(g=m.filter(tt),t[2]=m,t[3]=g);let _=g,v,y;t[4]!==m.length||t[5]!==u?(v=()=>{m.length===0&&u()},y=[m.length,u],t[4]=m.length,t[5]=u,t[6]=v,t[7]=y):(v=t[6],y=t[7]),Z.useEffect(v,y);let b,x;t[8]!==d||t[9]!==a||t[10]!==r||t[11]!==_||t[12]!==n?(b=()=>{if(a)return;let e=n.trim();if(e.length>0&&_.some(t=>t.name===e))return;let t=typeof d==`string`&&d.trim().length>0?d.trim():null;if(t&&_.some(e=>e.name===t)){r(t);return}let i=_[0]?.name;i&&r(i)},x=[d,a,r,_,n],t[8]=d,t[9]=a,t[10]=r,t[11]=_,t[12]=n,t[13]=b,t[14]=x):(b=t[13],x=t[14]),Z.useEffect(b,x);let S=n.trim().length>0?n:void 0,C;t[15]===i?C=t[16]:(C=h(`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 E;t[19]===w?E=t[20]:(E=(0,$.jsx)(le,{placeholder:w}),t[19]=w,t[20]=E);let D;t[21]!==o||t[22]!==C||t[23]!==E?(D=(0,$.jsx)(ie,{id:o,size:`lg`,className:C,children:E}),t[21]=o,t[22]=C,t[23]=E,t[24]=D):D=t[24];let O;t[25]===_?O=t[26]:(O=_.length>0&&(0,$.jsx)(P,{children:_.map(nt)}),t[25]=_,t[26]=O);let k;t[27]!==s||t[28]!==O?(k=(0,$.jsx)(oe,{fitContent:!0,portalToBody:s,children:O}),t[27]=s,t[28]=O,t[29]=k):k=t[29];let A;return t[30]!==a||t[31]!==r||t[32]!==S||t[33]!==D||t[34]!==k?(A=(0,$.jsxs)(se,{value:S,onValueChange:r,disabled:a,children:[D,k]}),t[30]=a,t[31]=r,t[32]=S,t[33]=D,t[34]=k,t[35]=A):A=t[35],A};function Qe(e){return e.getVisibleAgents}function $e(e){return e.loadAgents}function et(e){return e.currentAgentName}function tt(e){return k(e.mode)}function nt(e){return(0,$.jsx)(re,{value:e.name,className:`w-auto whitespace-nowrap`,children:e.name},e.name)}var rt=10485760,it=5,at=e=>{let t=(0,be.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(z,{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)(A,{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)(V,{children:[r,(0,$.jsx)(B,{side:`top`,className:`max-w-[240px]`,children:n})]}),t[1]=n,t[2]=i),i},ot=e=>{let t=(0,be.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},st=e=>{let t=m(e.path),n=e.icon?F[e.icon]:null,r=e.color?ce[e.color]:void 0,i=(0,$.jsx)(A,{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)(N,{project:e,className:`size-full object-contain`,fallback:i}):i}),(0,$.jsx)(`span`,{className:`truncate`,children:t})]})},ct=({initialPrompt:e,onCreated:n,onCancel:r,isWindowed:i=!1})=>{let{t:a}=p(),[s,c]=Z.useState(``),[l,u]=Z.useState(()=>[{id:Pe(),prompt:``,models:[]}]),[d,m]=Z.useState(``),[v,y]=Z.useState([]),[b,C]=Z.useState(!1),[T,D]=Z.useState([]),[O,k]=Z.useState(!1),[j,te]=Z.useState(!1),[M,ne]=Z.useState(!0),N=Z.useRef(null),ae=o(e=>e.currentDirectory??null),P=Z.useMemo(()=>{if(typeof window>`u`)return null;let e=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof e==`string`&&e.trim().length>0?e.trim():null},[]),F=E(e=>e.activeProjectId),ce=E(e=>e.setActiveProjectIdOnly),I=E(e=>e.projects),[L,H]=Z.useState(()=>F??null);Z.useEffect(()=>{if(F){H(F);return}!L&&I.length>0&&H(I[0].id)},[F,I,L]);let U=Z.useMemo(()=>L?I.find(e=>e.id===L)??null:null,[I,L]),fe=U?.path??ae,W=f(e=>{H(e),e!==F&&ce(e)}),G=Z.useMemo(()=>{if(U?.path)return{id:U.id,path:U.path};let e=ae??P;return e?{id:`path:${e}`,path:e}:null},[U,ae,P]),[K]=Z.useState(()=>typeof window<`u`&&t()),q=Z.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),J=ue(),Y=Z.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},[]),X=Z.useMemo(()=>K&&q||J?`pl-[5.5rem]`:`pl-3`,[K,q,J]),pe=Z.useMemo(()=>!K||!q||Y===null?``:Y>=26?`h-12`:Y<=15?`h-14`:``,[K,q,Y]),me=f(async e=>{e.target.closest(`button, a, input, select, textarea`)||e.button===0&&K&&await _()}),he=f(e=>{r&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),r())}),ge=!!r;Z.useEffect(()=>{if(ge)return window.addEventListener(`keydown`,he,!0),()=>window.removeEventListener(`keydown`,he,!0)},[ge]);let[be,xe]=Z.useState(``),{isLoading:Se,isGitRepository:Q}=We(fe),Ce=Z.useRef(!1),we=Q===!0,Te=we&&M;Z.useEffect(()=>{if(Q===!1){Ce.current=!0,ne(!1);return}Q===!0&&Ce.current&&(Ce.current=!1,ne(!0))},[Q]);let Ee=Me(e=>e.createMultiRun),De=Me(e=>e.error),Oe=Me(e=>e.clearError);Z.useEffect(()=>{typeof e==`string`&&e.trim().length>0&&u(t=>{let n=[...t];return n.length>0&&!n[0].prompt.trim()&&(n[0]={...n[0],prompt:e}),n})},[e]),Z.useEffect(()=>{if(!G)return;let e=!1;return te(!0),(async()=>{try{let t=await x(G);e||D(t)}catch{}finally{e||te(!1)}})(),()=>{e=!0}},[G]);let ke=f((e,t)=>{u(n=>n.map(n=>n.id===e?{...n,...t}:n))}),Ae=f(e=>{u(t=>t.filter(t=>t.id!==e))}),je=f(()=>{u(e=>[...e,{id:Pe(),prompt:``,models:[]}])}),Ne=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>rt){w.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)});y(t=>[...t,{id:Pe(),filename:r.name,mimeType:r.type||`application/octet-stream`,size:r.size,dataUrl:e}]),n++}catch(e){console.error(`File attach failed`,e),w.error(a(`multirun.launcher.toast.attachFailed`,{fileName:r.name}))}}n>0&&w.success(a(n===1?`multirun.launcher.toast.attachedSingle`:`multirun.launcher.toast.attachedPlural`,{count:n})),N.current&&(N.current.value=``)},Fe=e=>{y(t=>t.filter(t=>t.id!==e))},Ie=Z.useMemo(()=>l.reduce((e,t)=>e+t.models.length,0),[l]),Le=async e=>{e.preventDefault();let t=l.filter(e=>e.prompt.trim()&&e.models.length>=1);if(t.length!==0&&!(Ie<1)){C(!0),Oe();try{L&&L!==F&&ce(L);let e=v.map(e=>({mime:e.mimeType,filename:e.filename,url:e.dataUrl})),r=T.filter(e=>e.trim().length>0),i=t.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:s.trim(),groups:i,agent:d||void 0,worktreeBaseBranch:Te?be:void 0,isolateRuns:Te,files:e.length>0?e:void 0,setupCommands:r.length>0?r:void 0},o=await Ee(a);o&&(o.firstSessionId&&S.getState().setCurrentSession(o.firstSessionId),n?.())}finally{C(!1)}}},Re=!!(s.trim()&&l.some(e=>e.prompt.trim()&&e.models.length>=1)&&Ie>=1&&fe&&!Se&&(Q===!1||!Te||be)),ze=T.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:me,className:h(`relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none`,X,pe),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)(V,{children:[(0,$.jsx)(z,{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)(A,{name:`close`,className:`h-5 w-5`})})}),(0,$.jsx)(B,{children:(0,$.jsx)(`p`,{children:a(`multirun.launcher.actions.closeEsc`)})})]})})]}),(0,$.jsx)(de,{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)(ot,{htmlFor:`multirun-project`,required:!0,children:a(`multirun.launcher.project.label`)}),I.length>0?(0,$.jsxs)(se,{value:L??void 0,onValueChange:W,children:[(0,$.jsx)(ie,{id:`multirun-project`,size:`lg`,className:`w-fit max-w-full`,children:U?(0,$.jsx)(le,{children:st(U)}):(0,$.jsx)(le,{placeholder:a(`multirun.launcher.project.placeholder`)})}),(0,$.jsx)(oe,{fitContent:!0,children:I.map(e=>(0,$.jsx)(re,{value:e.id,className:`max-w-[24rem]`,children:st(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)(ot,{htmlFor:`group-name`,required:!0,info:(0,$.jsx)(at,{children:a(`multirun.launcher.groupName.info`)}),children:a(`multirun.launcher.groupName.label`)}),(0,$.jsx)(R,{id:`group-name`,value:s,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)(ot,{htmlFor:`multirun-worktree-base-branch`,info:(0,$.jsx)(at,{children:a(`multirun.launcher.baseBranch.info`)}),children:a(`multirun.launcher.baseBranch.label`)}),(0,$.jsx)(Xe,{directory:fe,value:be,onChange:xe,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)(ee,{checked:M,onChange:ne,disabled:!we,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)(ot,{htmlFor:`multirun-agent`,info:(0,$.jsx)(at,{children:a(`multirun.launcher.agent.info`)}),children:a(`multirun.launcher.agent.label`)}),(0,$.jsx)(Ze,{value:d,onChange:m,id:`multirun-agent`})]})]}),(0,$.jsxs)(ye,{open:O,onOpenChange:k,children:[(0,$.jsxs)(ve,{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)(A,{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)(A,{name:`arrow-down-s`,className:h(`h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto`,O&&`rotate-180`)})]}),(0,$.jsx)(_e,{children:(0,$.jsx)(`div`,{className:`pt-2 space-y-1.5`,children:j?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/70 px-2`,children:a(`multirun.launcher.setupCommands.loading`)}):(0,$.jsxs)($.Fragment,{children:[T.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsx)(R,{value:e,onChange:e=>{let n=[...T];n[t]=e.target.value,D(n)},placeholder:a(`multirun.launcher.setupCommands.commandPlaceholder`),className:`h-8 flex-1 font-mono text-xs`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>D(T.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)(A,{name:`close`,className:`h-3.5 w-3.5`})})]},`${e}-${t}`)),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>D([...T,``]),className:`flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1`,children:[(0,$.jsx)(A,{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)(ot,{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:N,type:`file`,multiple:!0,className:`hidden`,onChange:Ne,accept:`*/*`}),(0,$.jsxs)(V,{children:[(0,$.jsx)(z,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>N.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)(A,{name:`attachment-2`,className:`h-3 w-3`}),a(`multirun.launcher.attachments.attach`)]})}),(0,$.jsx)(B,{children:a(`multirun.launcher.attachments.tooltip`)})]}),v.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)(A,{name:`file-image`,className:`h-3 w-3 text-muted-foreground`}):(0,$.jsx)(A,{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:()=>Fe(e.id),className:`text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(A,{name:`close`,className:`h-3 w-3`})})]},e.id))]})]}),l.map((e,t)=>(0,$.jsx)(lt,{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)(A,{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&&Q!==null?(0,$.jsxs)(`div`,{className:`mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground`,children:[(0,$.jsx)(A,{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)(g,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,children:a(`multirun.launcher.actions.cancel`)}),(0,$.jsx)(g,{type:`submit`,size:`sm`,disabled:!Re||b,children:b?a(`multirun.launcher.actions.creating`):(0,$.jsx)($.Fragment,{children:a(`multirun.launcher.actions.startWithRunCount`,{count:Ie})})})]})})]})},lt=e=>{let t=(0,be.c)(94),{group:n,groupIndex:r,canRemove:i,onUpdate:a,onRemove:o}=e,{t:s}=p(),[c,l]=Z.useState(!1),[u,d]=Z.useState(``),[m,h]=Z.useState(!1),[g,_]=Z.useState(``),v=Z.useRef(null),y=Z.useRef(null),b=Z.useRef(null),x;t[0]!==n.id||t[1]!==n.models||t[2]!==a?(x=e=>{n.models.length>=it||a(n.id,{models:[...n.models,e]})},t[0]=n.id,t[1]=n.models,t[2]=a,t[3]=x):x=t[3];let S=f(x),C;t[4]!==n.id||t[5]!==n.models||t[6]!==a?(C=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]=C):C=t[7];let w=f(C),T;t[8]!==n.id||t[9]!==n.models||t[10]!==a?(T=(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]=T):T=t[11];let E=f(T),D;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(D=(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);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);(!e||/\s/.test(e))&&!t.includes(` `)&&!t.includes(`
3
- `)?(d(t),l(!0)):l(!1);return}l(!1)},t[12]=D):D=t[12];let O=f(D),k;t[13]!==n.id||t[14]!==a?(k=e=>{a(n.id,{prompt:e})},t[13]=n.id,t[14]=a,t[15]=k):k=t[15];let j=f(k),ee;t[16]!==n.prompt||t[17]!==j||t[18]!==O?(ee=e=>{let t=n.prompt,r=v.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=me(t,i===-1?r:i,r,`@${a}`);j(o.text),l(!1),d(``),requestAnimationFrame(()=>{let e=v.current;e&&(e.selectionStart=o.caret,e.selectionEnd=o.caret,e.focus()),O(o.text,o.caret)})},t[16]=n.prompt,t[17]=j,t[18]=O,t[19]=ee):ee=t[19];let te=f(ee),M;t[20]!==n.prompt||t[21]!==j||t[22]!==O?(M=e=>{let t=n.prompt,r=v.current?.selectionStart??t.length,i=t.substring(0,r).lastIndexOf(`@`),a=me(t,i===-1?r:i,r,`@${e}`);j(a.text),l(!1),d(``),requestAnimationFrame(()=>{let e=v.current;e&&(e.selectionStart=a.caret,e.selectionEnd=a.caret,e.focus()),O(a.text,a.caret)})},t[20]=n.prompt,t[21]=j,t[22]=O,t[23]=M):M=t[23];let ne=f(M),re;t[24]!==j||t[25]!==O?(re=e=>{let t=`/${e.name} `;j(t),h(!1),_(``),requestAnimationFrame(()=>{let e=v.current;e&&(e.focus(),e.selectionStart=e.value.length,e.selectionEnd=e.value.length),O(t,t.length)})},t[24]=j,t[25]=O,t[26]=re):re=t[26];let N=f(re),ie;t[27]!==m||t[28]!==c?(ie=e=>{if(m&&b.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)){e.preventDefault(),b.current.handleKeyDown(e.key);return}c&&y.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),y.current.handleKeyDown(e.key))},t[27]=m,t[28]=c,t[29]=ie):ie=t[29];let ae=f(ie),P=r+1,oe;t[30]!==s||t[31]!==P?(oe=s(`multirun.launcher.groups.groupLabel`,{index:P}),t[30]=s,t[31]=P,t[32]=oe):oe=t[32];let F;t[33]===oe?F=t[34]:(F=(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:oe}),t[33]=oe,t[34]=F);let se;t[35]!==i||t[36]!==n.id||t[37]!==o||t[38]!==s?(se=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)(A,{name:`close`,className:`h-3.5 w-3.5`})}),t[35]=i,t[36]=n.id,t[37]=o,t[38]=s,t[39]=se):se=t[39];let ce;t[40]!==F||t[41]!==se?(ce=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[F,se]}),t[40]=F,t[41]=se,t[42]=ce):ce=t[42];let I;t[43]===s?I=t[44]:(I=s(`multirun.launcher.groups.prompt.label`),t[43]=s,t[44]=I);let le;t[45]===I?le=t[46]:(le=(0,$.jsx)(ot,{required:!0,children:I}),t[45]=I,t[46]=le);let L=n.prompt,R;t[47]!==j||t[48]!==O?(R=e=>{let t=e.target.value;j(t);let n=e.target.selectionStart??t.length;O(t,n)},t[47]=j,t[48]=O,t[49]=R):R=t[49];let z;t[50]===s?z=t[51]:(z=s(`multirun.launcher.groups.prompt.placeholder`),t[50]=s,t[51]=z);let B;t[52]!==n.prompt||t[53]!==ae||t[54]!==R||t[55]!==z?(B=(0,$.jsx)(U,{ref:v,value:L,onChange:R,onKeyDown:ae,placeholder:z,className:`typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content`,required:!0}),t[52]=n.prompt,t[53]=ae,t[54]=R,t[55]=z,t[56]=B):B=t[56];let V;t[57]!==g||t[58]!==N||t[59]!==m?(V=m?(0,$.jsx)(he,{ref:b,searchQuery:g,onCommandSelect:N,onClose:()=>h(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[57]=g,t[58]=N,t[59]=m,t[60]=V):V=t[60];let ue;t[61]!==ne||t[62]!==te||t[63]!==u||t[64]!==c?(ue=c?(0,$.jsx)(fe,{ref:y,searchQuery:u,onFileSelect:te,onAgentSelect:ne,onSkillSelect:e=>ne(e.name),onClose:()=>l(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[61]=ne,t[62]=te,t[63]=u,t[64]=c,t[65]=ue):ue=t[65];let H;t[66]!==B||t[67]!==V||t[68]!==ue?(H=(0,$.jsxs)(`div`,{className:`relative`,children:[B,V,ue]}),t[66]=B,t[67]=V,t[68]=ue,t[69]=H):H=t[69];let de;t[70]!==le||t[71]!==H?(de=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[le,H]}),t[70]=le,t[71]=H,t[72]=de):de=t[72];let W;t[73]===s?W=t[74]:(W=s(`multirun.launcher.models.info`,{max:it}),t[73]=s,t[74]=W);let G;t[75]===W?G=t[76]:(G=(0,$.jsx)(at,{children:W}),t[75]=W,t[76]=G);let K;t[77]===s?K=t[78]:(K=s(`multirun.launcher.models.label`),t[77]=s,t[78]=K);let q;t[79]!==G||t[80]!==K?(q=(0,$.jsx)(ot,{required:!0,info:G,children:K}),t[79]=G,t[80]=K,t[81]=q):q=t[81];let J;t[82]!==n.models||t[83]!==S||t[84]!==w||t[85]!==E?(J=(0,$.jsx)(Ie,{selectedModels:n.models,onAdd:S,onRemove:w,onUpdate:E,minModels:1,maxModels:it}),t[82]=n.models,t[83]=S,t[84]=w,t[85]=E,t[86]=J):J=t[86];let Y;t[87]!==q||t[88]!==J?(Y=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[q,J]}),t[87]=q,t[88]=J,t[89]=Y):Y=t[89];let X;return t[90]!==ce||t[91]!==de||t[92]!==Y?(X=(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-3`,children:[ce,de,Y]}),t[90]=ce,t[91]=de,t[92]=Y,t[93]=X):X=t[93],X};export{Te as a,Pe as i,Ze as n,Ce as o,Ie as r,ct as t};