@openchambery/web 1.19.7-beta.14 → 1.19.7-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/assets/AgentAvatar-CaYbcvag.js +1 -0
  2. package/dist/assets/AssistantView-xABgVjfD.js +2 -0
  3. package/dist/assets/{DiagramView-Db1VvSIR.js → DiagramView-DX8IBcDe.js} +1 -1
  4. package/dist/assets/{MarkdownRendererImpl-NBG7O4aX.js → MarkdownRendererImpl-DnVVQyrB.js} +1 -1
  5. package/dist/assets/{MarkstreamRendererImpl-Bs829ng-.js → MarkstreamRendererImpl-Ctsuex1F.js} +1 -1
  6. package/dist/assets/{MobileDetailNavigation-CooM1BN7.js → MobileDetailNavigation-D_SU7Xsa.js} +1 -1
  7. package/dist/assets/{MobileShareBridge-CcG4lLaD.js → MobileShareBridge-2WdduLce.js} +1 -1
  8. package/dist/assets/{MobileSurface-c_7RkYa2.js → MobileSurface-BDqOgK34.js} +1 -1
  9. package/dist/assets/{MultiRunWindow-Ds8nyikm.js → MultiRunWindow-BGzhbXkf.js} +1 -1
  10. package/dist/assets/{SettingsView-Dac1dDOs.js → SettingsView-DleGNrQy.js} +1 -1
  11. package/dist/assets/{SettingsWindow-CHnMwzd6.js → SettingsWindow-Do5FTFtO.js} +1 -1
  12. package/dist/assets/{TerminalView-DfGueSOI.js → TerminalView-UFVxQv8F.js} +1 -1
  13. package/dist/assets/{ToolOutputDialog-BrR9iqiW.js → ToolOutputDialog-C0xM1pGe.js} +1 -1
  14. package/dist/assets/{appThemeRegistry-BEG7NRFm.js → appThemeRegistry-COab04Pd.js} +2 -2
  15. package/dist/assets/{gitApi-Br5EdS29.js → gitApi-MwzagO0D.js} +1 -1
  16. package/dist/assets/insertionBoundaries-DDwUpUMF.js +4 -0
  17. package/dist/assets/{main-Dl-XWJxN.js → main-B_91Acbd.js} +2 -2
  18. package/dist/assets/{main-DX_9iX64.js → main-CbKJeZj5.js} +4 -4
  19. package/dist/assets/{markdownTheme-E_Ina01F.js → markdownTheme-CVS01wHf.js} +1 -1
  20. package/dist/assets/{miniChat-Cho-Pywx.js → miniChat-m8uUf72s.js} +2 -2
  21. package/dist/assets/{mobile-1_JD1EGE.js → mobile-Lh1jSmqx.js} +2 -2
  22. package/dist/assets/{multirun-ByFn3xhO.js → multirun-c6souaDn.js} +1 -1
  23. package/dist/assets/{projectMeta-BHw8kRhQ.js → projectMeta-CN4YN7l4.js} +1 -1
  24. package/dist/assets/{renderElectronMiniChatApp-CvIxnUQY.js → renderElectronMiniChatApp-DW0b2TWs.js} +2 -2
  25. package/dist/assets/{renderMobileApp-DscicBzZ.js → renderMobileApp-hf-jZ7Sv.js} +5 -5
  26. package/dist/assets/{runtimeConfig-Dkt3p8CZ.js → runtimeConfig-Cm7HkufG.js} +1 -1
  27. package/dist/assets/{runtimeEndpointReset-hBFsO83_.js → runtimeEndpointReset-Dj_N70eV.js} +1 -1
  28. package/dist/assets/{sessionLookup-jCEot_fX.js → sessionLookup-CMT99LDw.js} +1 -1
  29. package/dist/assets/src-pHfWJ9Bb.css +2 -0
  30. package/dist/assets/{useAppFontEffects-kJR0NlNH.js → useAppFontEffects-Dp_k6k7Z.js} +32 -32
  31. package/dist/assets/{useDesktopWindowControlsLayout-BmbOASBQ.js → useDesktopWindowControlsLayout-C_nNs62B.js} +1 -1
  32. package/dist/assets/{useEffectiveDirectory-DOToiRZd.js → useEffectiveDirectory-C0fksknu.js} +1 -1
  33. package/dist/assets/{useMobileNavigationStore-CEmn-d1X.js → useMobileNavigationStore-DTZvx3Os.js} +1 -1
  34. package/dist/assets/{useSessionAutoCleanup-DcmXMo-p.js → useSessionAutoCleanup-Cs-4krDg.js} +1 -1
  35. package/dist/assets/{useWorkerHighlightedLines-r5Ww4sY7.js → useWorkerHighlightedLines-7nrfBFNQ.js} +1 -1
  36. package/dist/index.html +3 -3
  37. package/dist/mini-chat.html +3 -3
  38. package/dist/mobile.html +9 -9
  39. package/package.json +1 -1
  40. package/server/lib/opencode/settings-runtime.js +2 -2
  41. package/dist/assets/AgentAvatar-BsU82CEP.js +0 -1
  42. package/dist/assets/AssistantView-CKNR7FFf.js +0 -2
  43. package/dist/assets/insertionBoundaries-ncyYkgWy.js +0 -4
  44. package/dist/assets/src-KcdsQIuP.css +0 -2
@@ -74,7 +74,7 @@
74
74
  }
75
75
  </style>
76
76
 
77
- <script type="module" crossorigin src="/assets/miniChat-Cho-Pywx.js"></script>
77
+ <script type="module" crossorigin src="/assets/miniChat-m8uUf72s.js"></script>
78
78
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
79
79
  <link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
80
80
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
@@ -91,8 +91,8 @@
91
91
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-CIIs9vFx.js">
92
92
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
93
93
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
94
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-Dkt3p8CZ.js">
95
- <link rel="stylesheet" crossorigin href="/assets/src-KcdsQIuP.css">
94
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-Cm7HkufG.js">
95
+ <link rel="stylesheet" crossorigin href="/assets/src-pHfWJ9Bb.css">
96
96
  </head>
97
97
  <body class="h-full bg-background text-foreground">
98
98
  <div id="root" class="h-full">
package/dist/mobile.html CHANGED
@@ -41,18 +41,18 @@
41
41
  // splashBg* are the resolved theme surface.background colors persisted by the app
42
42
  // theme system (see ThemeSystemContext). When absent (e.g. a fresh install before
43
43
  // the theme has been persisted once), fall back to the default theme's
44
- // surface.background — flexoki-dark/light (see lib/theme/themes), which is what the
45
- // app renders on first launch — so the pre-paint matches instead of flashing a
46
- // different colour.
47
- var bgDark = localStorage.getItem('splashBgDark') || '#171515';
48
- var bgLight = localStorage.getItem('splashBgLight') || '#fffdf4';
44
+ // surface.background — carbonfox-light / vitesse-dark-dark (see lib/theme/themes),
45
+ // which is what the app renders on first launch — so the pre-paint matches instead
46
+ // of flashing a different colour.
47
+ var bgDark = localStorage.getItem('splashBgDark') || '#121212';
48
+ var bgLight = localStorage.getItem('splashBgLight') || '#FFFFFF';
49
49
  var bg = isDark ? bgDark : bgLight;
50
50
 
51
51
  // Set the actual --background CSS variable, not just the element background.
52
52
  // `<body class="bg-background">` paints `var(--background)`, and design-system.css
53
53
  // ships a baked default (.dark { --background: ... /* #151313 */ }) that otherwise
54
54
  // overpaints our html background the moment the stylesheet loads — before React's
55
- // theme system injects the real (flexoki/custom) vars with !important. Setting the
55
+ // theme system injects the real (default/custom) vars with !important. Setting the
56
56
  // var inline on the root wins over that non-!important default, so body paints the
57
57
  // correct colour immediately; React's later !important vars still take over.
58
58
  root.style.setProperty('--background', bg);
@@ -63,7 +63,7 @@
63
63
  })();
64
64
  </script>
65
65
 
66
- <script type="module" crossorigin src="/assets/mobile-1_JD1EGE.js"></script>
66
+ <script type="module" crossorigin src="/assets/mobile-Lh1jSmqx.js"></script>
67
67
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
@@ -80,8 +80,8 @@
80
80
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-CIIs9vFx.js">
81
81
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
82
82
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
83
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-Dkt3p8CZ.js">
84
- <link rel="stylesheet" crossorigin href="/assets/src-KcdsQIuP.css">
83
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-Cm7HkufG.js">
84
+ <link rel="stylesheet" crossorigin href="/assets/src-pHfWJ9Bb.css">
85
85
  </head>
86
86
  <body class="h-full bg-background text-foreground">
87
87
  <div id="root" class="h-full"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openchambery/web",
3
- "version": "1.19.7-beta.14",
3
+ "version": "1.19.7-beta.16",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
@@ -666,8 +666,8 @@ export const createSettingsRuntime = (deps) => {
666
666
  return { settings, changed: false };
667
667
  }
668
668
 
669
- const defaultLight = 'flexoki-light';
670
- const defaultDark = 'flexoki-dark';
669
+ const defaultLight = 'carbonfox-light';
670
+ const defaultDark = 'vitesse-dark-dark';
671
671
 
672
672
  let nextLightThemeId = hasLight ? settings.lightThemeId : undefined;
673
673
  let nextDarkThemeId = hasDark ? settings.darkThemeId : undefined;
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-C0FnF6B9.js";import{nt as e,rt as t}from"./vendor-base-ui-CnHfUmDN.js";import{n}from"./vendor-react-DLPElpoQ.js";import{c as r,l as i}from"./dialog-BkhHBTd4.js";import{t as a}from"./utils-B0mQXN9L.js";var o=n();t();var s=e(),c=e=>{let t=(0,o.c)(27),{name:n,emoji:c,size:u,className:d,label:f}=e,p=u===void 0?16:u,m,h,g;if(t[0]!==d||t[1]!==c||t[2]!==n){m=i(n);let e;t[6]===n?e=t[7]:(e=r(n),t[6]=n,t[7]=e),h=e,g=a(`inline-flex aspect-square shrink-0 overflow-hidden rounded-sm`,c&&`items-center justify-center select-none`,m.class,d),t[0]=d,t[1]=c,t[2]=n,t[3]=m,t[4]=h,t[5]=g}else m=t[3],h=t[4],g=t[5];let _=`calc(${p}px * var(--dpt-n, 1))`,v=`calc(${p}px * var(--dpt-n, 1))`,y=`calc(${p}px * var(--dpt-n, 1))`,b=`calc(${p}px * var(--dpt-n, 1))`,x=`calc(${p}px * var(--dpt-n, 1))`,S=`calc(${p}px * var(--dpt-n, 1))`,C=`var(${m.var})`,w;t[8]!==_||t[9]!==v||t[10]!==y||t[11]!==b||t[12]!==x||t[13]!==S||t[14]!==C?(w={width:_,minWidth:v,maxWidth:y,height:b,minHeight:x,maxHeight:S,color:C},t[8]=_,t[9]=v,t[10]=y,t[11]=b,t[12]=x,t[13]=S,t[14]=C,t[15]=w):w=t[15];let T=f?`img`:void 0,E=!f||void 0,D;t[16]!==c||t[17]!==h||t[18]!==p?(D=c?(0,s.jsx)(`span`,{"aria-hidden":`true`,style:{fontSize:`calc(${p*.75}px * var(--dpt-n, 1))`,lineHeight:1},children:c}):(0,s.jsxs)(`svg`,{width:p,height:p,viewBox:`0 0 5 5`,shapeRendering:`crispEdges`,className:`oc-agent-avatar block h-full w-full`,"aria-hidden":`true`,children:[(0,s.jsx)(`rect`,{width:`5`,height:`5`,fill:`currentColor`,opacity:.14}),h.map(l)]}),t[16]=c,t[17]=h,t[18]=p,t[19]=D):D=t[19];let O;return t[20]!==f||t[21]!==w||t[22]!==T||t[23]!==E||t[24]!==D||t[25]!==g?(O=(0,s.jsx)(`span`,{className:g,style:w,role:T,"aria-label":f,"aria-hidden":E,children:D}),t[20]=f,t[21]=w,t[22]=T,t[23]=E,t[24]=D,t[25]=g,t[26]=O):O=t[26],O};function l(e,t){return e.map((e,n)=>e?(0,s.jsx)(`rect`,{x:n,y:t,width:`1`,height:`1`,fill:`currentColor`},`${n}-${t}`):null)}export{c as t};
@@ -1,2 +0,0 @@
1
- import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{A as n,E as r,t as i}from"./useUIStore-CqqO11ZI.js";import{et as a}from"./persistence-CSZp1CNB.js";import{a as o}from"./vendor-zustand-B4dlGEM2.js";import{nt as s,rt as c}from"./vendor-base-ui-CnHfUmDN.js";import{r as l}from"./platform-CenlWqxu.js";import{n as u}from"./vendor-react-DLPElpoQ.js";import{r as d}from"./vendor-sonner-DVzioF3d.js";import{n as f}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as p}from"./clipboard-BXxLshVq.js";import{a as m,n as h}from"./MobileShareBridge-CcG4lLaD.js";import{dr as g,ko as _,qt as v,r as y,vn as b}from"./useMobileNavigationStore-CEmn-d1X.js";import{a as x,b as S,c as C,f as w,h as ee,p as T,r as E,t as D,v as O}from"./MobileDetailNavigation-CooM1BN7.js";import{i as k,n as A,r as j}from"./useAssistantUIStore-BHacrxe_.js";import{a as M,i as N,n as P,o as F,r as I,t as L}from"./dialog-BkhHBTd4.js";import{t as R}from"./utils-B0mQXN9L.js";import{t as z}from"./AgentAvatar-BsU82CEP.js";import{n as B}from"./Icon-4My8YZwt.js";import{t as V}from"./button-Or0daT9o.js";import{i as H}from"./OverlayScrollbar-BZB21Yp_.js";import{a as U,i as te,n as ne,r as re,t as ie,u as ae}from"./sessionChangeSummary-CX2MJIkc.js";import{a as W,i as oe,n as G,r as se,t as ce}from"./context-menu-Dpjla5p4.js";import{t as le}from"./sessionLookup-jCEot_fX.js";var K=u(),q=e(c(),1),J=s(),ue=e=>{let t=(0,K.c)(17),{name:n,emoji:r,size:i,label:a,working:o,className:s}=e,c=i===void 0?24:i,l=o!==void 0&&o,{t:u}=p(),d=`calc(${c}px * var(--dpt-n, 1))`,f;t[0]===s?f=t[1]:(f=R(`relative inline-block shrink-0 align-middle leading-none`,s),t[0]=s,t[1]=f);let m;t[2]===d?m=t[3]:(m={width:d,height:d},t[2]=d,t[3]=m);let h;t[4]!==r||t[5]!==a||t[6]!==n||t[7]!==c?(h=(0,J.jsx)(z,{name:n,emoji:r,size:c,label:a,className:`block`}),t[4]=r,t[5]=a,t[6]=n,t[7]=c,t[8]=h):h=t[8];let g;t[9]!==u||t[10]!==l?(g=l?(0,J.jsx)(`span`,{className:`pointer-events-none absolute right-0 bottom-0 size-2 translate-x-1/4 translate-y-1/4 rounded-full bg-[var(--status-success)] ring-2 ring-background`,"data-assistant-working-dot":``,"aria-label":u(`assistants.contact.working`)}):null,t[9]=u,t[10]=l,t[11]=g):g=t[11];let _;return t[12]!==f||t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,J.jsxs)(`span`,{className:f,style:m,"data-assistant-working-avatar":``,children:[h,g]}),t[12]=f,t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16],_},Y=o(e=>({workingByID:{},setWorking:(t,n)=>e(e=>({workingByID:{...e.workingByID,[t]:n}}))})),de=({sending:e=!1,processing:t=!1})=>e||t,fe=e=>{let t=(0,K.c)(4),n;t[0]===e?n=t[1]:(n=t=>!!t.workingByID[e],t[0]=e,t[1]=n);let r=Y(n),i;return t[2]===r?i=t[3]:(i=de({processing:r}),t[2]=r,t[3]=i),i},X=[],pe=e=>e.flatMap(e=>e.type===`text`&&e.text.trim()?[e.text]:[]).join(`
2
- `),me=(e,t,n,r=Date.now())=>({assistantID:e,messageID:t,parts:n,status:`sending`,createdAt:r}),he=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},ge=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},Z=(e,t,n,r)=>({messageID:t?`${e.turnID}:preview:${t.bubbleIndex}`:`${e.turnID}:preview:${r}`,assistantID:e.assistantID,role:`assistant`,turnID:e.turnID,bubbleIndex:t?.bubbleIndex??0,createdAt:t?.occurredAt??e.occurredAt,ordinal:n,status:r,fromAssistantID:null,fromAssistantName:null,parts:t?[{type:`text`,text:t.text}]:[],text:t?.text??``,cards:[]}),_e=(e,t,n)=>{let r=e.bubbles.filter(e=>!t.has(e.bubbleIndex)).map((t,r)=>Z(e,t,n+r,t.done?`complete`:`streaming`));return e.status===`admitted`&&e.bubbles.length===0&&t.size===0?[Z(e,null,n,`admitted`)]:e.status===`failed`?[...r,Z(e,null,n+r.length,`failed`)]:r},ve=(e,t,n,r=[])=>{let i=new Set(e.map(e=>e.messageID)),a=t.flatMap((t,r)=>t.assistantID!==n||i.has(t.messageID)?[]:[{messageID:t.messageID,assistantID:n,role:`user`,turnID:t.messageID,bubbleIndex:0,createdAt:t.createdAt,ordinal:e.length+r,status:t.status,fromAssistantID:null,fromAssistantName:null,parts:[...t.parts],text:pe(t.parts),cards:[]}]),o=a.length===0?e:[...e,...a],s=r.filter(e=>e.assistantID===n);if(s.length===0)return o;let c=new Map,l=new Map;o.forEach((e,t)=>{if(c.set(e.turnID,t),e.role!==`assistant`||e.messageID.includes(`:preview:`))return;let n=l.get(e.turnID)??new Set;n.add(e.bubbleIndex),l.set(e.turnID,n)});let u=new Map,d=[];for(let e of s){let t=_e(e,l.get(e.turnID)??new Set,o.length+d.length);if(t.length===0)continue;let n=c.get(e.turnID);if(n===void 0){d.push(...t);continue}let r=u.get(n)??[];r.push(...t),u.set(n,r)}return u.size===0&&d.length===0?o:o.flatMap((e,t)=>[e,...u.get(t)??[]]).concat(d)},ye=(e,t)=>{let n=new Set(t.map(e=>e.messageID)),r=e.filter(e=>!n.has(e.messageID));return r.length===e.length?e:r},be=(e,t)=>e.map(e=>e.messageID===t?{...e,status:`admitted`}:e),Q=(e,t,n,r=Date.now())=>e.some(e=>e.assistantID===t&&e.turnID===n)?e:[...e,{assistantID:t,turnID:n,status:`admitted`,bubbles:[],occurredAt:r}],xe=(e,t)=>Q(e,t.assistantID,t.turnID,t.occurredAt).map(e=>{if(e.assistantID!==t.assistantID||e.turnID!==t.turnID||e.status===`failed`||e.status===`complete`)return e;let n=e.bubbles.find(e=>e.bubbleIndex===t.bubbleIndex);if(n?.done)return e;let r=n?{...n,text:`${n.text}${t.delta}`,done:t.done,occurredAt:t.occurredAt}:{bubbleIndex:t.bubbleIndex,text:t.delta,done:t.done,occurredAt:t.occurredAt},i=n?e.bubbles.map(e=>e.bubbleIndex===t.bubbleIndex?r:e):[...e.bubbles,r].sort((e,t)=>e.bubbleIndex-t.bubbleIndex);return{...e,status:`streaming`,bubbles:i}}),$=(e,t)=>Q(e,t.assistantID,t.turnID,t.occurredAt).map(e=>e.assistantID!==t.assistantID||e.turnID!==t.turnID?e:{...e,status:t.status===`error`?`failed`:`complete`,...t.error?{error:t.error}:{}}),Se=(e,t)=>{let n=new Set(t.flatMap(e=>e.role===`assistant`?[e.turnID]:[])),r=e.filter(e=>e.status!==`complete`||!n.has(e.turnID));return r.length===e.length?e:r},Ce=(e,t,n)=>e.map(e=>e.messageID===t?{...e,status:`failed`,error:n}:e),we=(e,t)=>{if(e instanceof O){if(e.code===`no_provider`)return t.noProvider;if(e.code===`admission_timeout`||e.code===`generate_timeout`)return t.timedOut;if(e.message&&e.message!==e.code)return e.message}return S(e)?t.timedOut:t.sendFailed},Te=()=>{let e=!1;return{tryAcquire:()=>!e&&(e=!0,!0),release:()=>{e=!1}}},Ee=e=>{let t=e.text.trim();if(e.sending||!t&&e.attachments.length===0||!e.gate.tryAcquire())return{ok:!1};let n=[...t?[{type:`text`,text:t}]:[],...e.attachments.map(e=>({type:`file`,mime:e.mime,url:e.url,filename:e.name}))],r=e.createMessageID();return{ok:!0,messageID:r,parts:n,turn:me(e.assistantID,r,n,e.createdAt)}},De=e=>e.some(e=>e.status===`sending`),Oe=e=>e.some(e=>e.status===`admitted`||e.status===`streaming`),ke=[`cursor-pointer rounded-[1.35rem] bg-[var(--surface-elevated)] ring-1 ring-inset ring-[var(--surface-subtle)]`,`px-3.5 py-3 text-left transition-[background-color,box-shadow,transform] duration-200 ease-out motion-reduce:transition-none`,`hover:-translate-y-px hover:bg-interactive-hover/45 hover:shadow-sm active:translate-y-0 motion-reduce:hover:translate-y-0`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`].join(` `),Ae=`${ke} w-fit max-w-[15rem]`,je=`${ke} w-fit max-w-[20rem]`;function Me(e,t){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())}var Ne=e=>{let t=(0,K.c)(26),{card:n}=e,{t:r}=p(),i=ae(),a;t[0]===i?a=t[1]:(a=i&&!l(),t[0]=i,t[1]=a);let o=!!a,s=n.name,c=`${n.providerID}/${n.modelID}`,u;t[2]!==n.mode||t[3]!==c?(u=[c,n.mode].filter(Boolean),t[2]=n.mode,t[3]=c,t[4]=u):u=t[4];let d=u,m;t[5]!==n.assistantID||t[6]!==o?(m=()=>{if(o){y.getState().openAssistant(n.assistantID);return}A(n.assistantID)},t[5]=n.assistantID,t[6]=o,t[7]=m):m=t[7];let h=f(m),g;t[8]===h?g=t[9]:(g=e=>{Me(e,h)},t[8]=h,t[9]=g);let _=f(g),v;t[10]!==r||t[11]!==s?(v=r(`assistants.contact.card.assistant.aria`,{name:s}),t[10]=r,t[11]=s,t[12]=v):v=t[12];let b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,J.jsx)(`span`,{className:`relative inline-block size-6 shrink-0 leading-none`,children:(0,J.jsx)(`span`,{className:`flex size-6 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,J.jsx)(B,{name:`robot-2`,className:`size-3`})})}),t[13]=b):b=t[13];let x;t[14]===s?x=t[15]:(x=(0,J.jsx)(`h3`,{className:`min-w-0 truncate typography-ui-label font-medium text-foreground`,children:s}),t[14]=s,t[15]=x);let S;t[16]===d?S=t[17]:(S=d.length>0?(0,J.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:d.join(` · `)}):null,t[16]=d,t[17]=S);let C;t[18]!==x||t[19]!==S?(C=(0,J.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[b,(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[x,S]})]}),t[18]=x,t[19]=S,t[20]=C):C=t[20];let w;return t[21]!==_||t[22]!==h||t[23]!==C||t[24]!==v?(w=(0,J.jsx)(`article`,{className:Ae,role:`button`,tabIndex:0,"aria-label":v,"data-assistant-contact-card":`assistant`,onClick:h,onKeyDown:_,children:C}),t[21]=_,t[22]=h,t[23]=C,t[24]=v,t[25]=w):w=t[25],w},Pe=e=>{let t=(0,K.c)(25),{card:n}=e,{t:r}=p(),i=n.name,a;t[0]!==n.kind||t[1]!==n.time||t[2]!==n.timezone?(a=[n.kind,n.time,n.timezone].filter(Boolean),t[0]=n.kind,t[1]=n.time,t[2]=n.timezone,t[3]=a):a=t[3];let o=a.join(` `),s;t[4]!==n.prompt||t[5]!==o?(s=o.trim()||(typeof n.prompt==`string`?n.prompt.trim():``),t[4]=n.prompt,t[5]=o,t[6]=s):s=t[6];let c=s,l=f(Fe),u;t[7]===l?u=t[8]:(u=e=>{Me(e,l)},t[7]=l,t[8]=u);let d=f(u),m;t[9]!==r||t[10]!==i?(m=r(`assistants.contact.card.schedule.aria`,{name:i}),t[9]=r,t[10]=i,t[11]=m):m=t[11];let h;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,J.jsx)(`span`,{className:`relative inline-block size-6 shrink-0 leading-none`,children:(0,J.jsx)(`span`,{className:`flex size-6 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,J.jsx)(B,{name:`calendar`,className:`size-3`})})}),t[12]=h):h=t[12];let g;t[13]===i?g=t[14]:(g=(0,J.jsx)(`h3`,{className:`min-w-0 truncate typography-ui-label font-medium text-foreground`,children:i}),t[13]=i,t[14]=g);let _;t[15]===c?_=t[16]:(_=c?(0,J.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c}):null,t[15]=c,t[16]=_);let v;t[17]!==g||t[18]!==_?(v=(0,J.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[h,(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[g,_]})]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;return t[20]!==d||t[21]!==l||t[22]!==m||t[23]!==v?(y=(0,J.jsx)(`article`,{className:Ae,role:`button`,tabIndex:0,"aria-label":m,"data-assistant-contact-card":`schedule`,onClick:l,onKeyDown:d,children:v}),t[20]=d,t[21]=l,t[22]=m,t[23]=v,t[24]=y):y=t[24],y};function Fe(){i.getState().setActiveMainTab(`schedule`),i.getState().setScheduledTasksDialogOpen(!0)}var Ie=(e,t)=>e===`busy`||e===`retry`?e:t===`error`||t===`question`||t===`complete`?t:e===`idle`?`complete`:t===`busy`||t===`retry`||t===`idle`?t:t||`busy`,Le=e=>e===`busy`?`assistants.contact.card.session.status.busy`:e===`retry`?`assistants.contact.card.session.status.retry`:e===`idle`?`assistants.contact.card.session.status.idle`:e===`complete`?`assistants.contact.card.session.status.complete`:e===`error`?`assistants.contact.card.session.status.error`:e===`question`?`assistants.contact.card.session.status.question`:null,Re=e=>e===`busy`?`bg-[var(--status-info)]/10 text-[var(--status-info)]`:e===`retry`||e===`question`?`bg-[var(--status-warning)]/10 text-[var(--status-warning)]`:e===`error`?`bg-[var(--status-error)]/10 text-[var(--status-error)]`:e===`idle`||e===`complete`?`bg-[var(--status-success)]/10 text-[var(--status-success)]`:`bg-[var(--surface-muted)] text-muted-foreground`,ze=e=>e.split(/[/\\]/u).filter(Boolean).at(-1)||e,Be=e=>{let t=(0,K.c)(35),{card:n}=e,{t:r}=p(),a=ae(),o;t[0]===a?o=t[1]:(o=a&&!l(),t[0]=a,t[1]=o);let s=!!o,c;t[2]===n.sessionID?c=t[3]:(c=e=>e.activeSessions.find(e=>e.id===n.sessionID)??e.archivedSessions.find(e=>e.id===n.sessionID)??null,t[2]=n.sessionID,t[3]=c);let u=g(c),d=v(n.sessionID),m=(typeof u?.title==`string`&&u.title.trim()?u.title.trim():null)||n.title||r(`assistants.contact.card.session.untitled`),h=Ie(d?.type,n.status),_=Le(h),y=h===`busy`||h===`retry`,x=ze(typeof u?.directory==`string`&&u.directory.trim()?u.directory.trim():n.directory),S=ne(u)||n.branch,C=te(u),w=re(u),ee=ie(w),T=[x,C,S].filter(Ve),E;t[4]!==n.directory||t[5]!==n.sessionID||t[6]!==s?(E=()=>{let e=le(n.sessionID)?.directory||n.directory;b(n.sessionID,e,{phoneShell:s,switchToChat:!0}),s||i.getState().setActiveMainTab(`chat`)},t[4]=n.directory,t[5]=n.sessionID,t[6]=s,t[7]=E):E=t[7];let D=f(E),O;t[8]===D?O=t[9]:(O=e=>{Me(e,D)},t[8]=D,t[9]=O);let k=f(O),A=je,j=r(`assistants.contact.card.session.aria`,{title:m}),M;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,J.jsx)(`span`,{className:`flex size-6 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,J.jsx)(B,{name:`chat-3`,className:`size-3`})}),t[10]=M):M=t[10];let N;t[11]===y?N=t[12]:(N=y?(0,J.jsx)(`span`,{className:`pointer-events-none absolute right-0 bottom-0 size-2 translate-x-1/4 translate-y-1/4 rounded-full bg-[var(--status-success)] ring-2 ring-[var(--surface-elevated)]`,"data-assistant-working-dot":``,"aria-hidden":!0}):null,t[11]=y,t[12]=N);let P;t[13]===N?P=t[14]:(P=(0,J.jsxs)(`span`,{className:`relative inline-block size-6 shrink-0 leading-none`,children:[M,N]}),t[13]=N,t[14]=P);let F;t[15]===m?F=t[16]:(F=(0,J.jsx)(`h3`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:m}),t[15]=m,t[16]=F);let I=_?(0,J.jsx)(`span`,{className:R(`shrink-0 rounded-full px-1.5 py-0.5 typography-micro leading-none`,Re(h)),children:r(_)}):null,L;t[17]!==F||t[18]!==I?(L=(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[F,I]}),t[17]=F,t[18]=I,t[19]=L):L=t[19];let z;t[20]===T?z=t[21]:(z=T.length>0?(0,J.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:T.join(` · `)}):null,t[20]=T,t[21]=z);let V=ee||w?.files!==void 0&&w.files>0?(0,J.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-1.5 typography-micro tabular-nums`,children:[w?.additions===void 0?null:(0,J.jsxs)(`span`,{className:`text-[var(--status-success)]`,children:[`+`,w.additions]}),w?.deletions===void 0?null:(0,J.jsxs)(`span`,{className:`text-[var(--status-error)]`,children:[`−`,w.deletions]}),w?.files===void 0?null:(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:w.files===1?r(`assistants.contact.card.session.changes.filesSingle`,{count:w.files}):r(`assistants.contact.card.session.changes.filesPlural`,{count:w.files})})]}):null,H;t[22]!==L||t[23]!==z||t[24]!==V?(H=(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[L,z,V]}),t[22]=L,t[23]=z,t[24]=V,t[25]=H):H=t[25];let U;t[26]!==P||t[27]!==H?(U=(0,J.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[P,H]}),t[26]=P,t[27]=H,t[28]=U):U=t[28];let W;return t[29]!==k||t[30]!==D||t[31]!==U||t[32]!==A||t[33]!==j?(W=(0,J.jsx)(`article`,{className:A,role:`button`,tabIndex:0,"aria-label":j,"data-assistant-contact-card":`session`,onClick:D,onKeyDown:k,children:U}),t[29]=k,t[30]=D,t[31]=U,t[32]=A,t[33]=j,t[34]=W):W=t[34],W};function Ve(e){return!!(e&&e.trim())}var He=64,Ue=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{t(typeof r.result==`string`?r.result:``)},r.onerror=()=>{n(r.error??Error(`read_failed`))},r.readAsDataURL(e)}),We=e=>{if(!e)return[];let t=Array.from(e.files||[]);return t.length>0?t:Array.from(e.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e instanceof File)},Ge=e=>Array.from(e?.files||[]),Ke=async(e,t=a)=>{let n=[],r=0;for(let i of Array.from(e||[])){if(!i||i.size<=0)continue;if(i.size>52428800){r+=1;continue}let e=await Ue(i);e.startsWith(`data:`)&&n.push({id:t(),url:e,name:i.name.trim()||`attachment`,mime:i.type.trim()||`application/octet-stream`})}return{attachments:n,skippedTooLarge:r}},qe=(e,t)=>[...e,...t].slice(0,He),Je={"oc.settle.complete":`assistants.contact.settle.complete`,"oc.settle.error":`assistants.contact.settle.error`,"oc.settle.question":`assistants.contact.settle.question`},Ye=({assistant:e,warning:t,active:n})=>{let{t:r}=p(),o=i(e=>e.isMobile),s=w(),c=ee(),l=T(e.id,n),u=m(e.name),d=u.displayName||e.name,g=(e,t)=>{let n=e?c.data?.assistants.find(t=>t.id===e):void 0;return n?m(n.name).displayName||n.name:t||r(`assistants.contact.peer.unknown`)},[v,y]=q.useState(``),[b,x]=q.useState([]),[S,E]=q.useState([]),[D,O]=q.useState([]),[k,A]=q.useState(null),j=q.useMemo(()=>Te(),[]),M=q.useRef(new Set),N=Y(e=>e.setWorking),P=q.useRef(null),F=l.data?.messages??X,I=he(S,e.id),L=ge(D,e.id),z=ve(F,I,e.id,L),V=De(I),H=Oe(L),te=L.reduce((e,t)=>e+t.bubbles.reduce((e,t)=>e+t.text.length,0),0),ne=new Map(L.map(e=>[e.turnID,e]));q.useEffect(()=>{A(null),M.current.clear(),E(t=>he(t,e.id)),O(t=>ge(t,e.id))},[e.id]),q.useEffect(()=>{E(e=>ye(e,F)),O(e=>Se(e,F))},[F]),q.useEffect(()=>{N(e.id,V||H)},[e.id,H,V,N]),q.useEffect(()=>{let t=e.id;return()=>{N(t,!1)}},[e.id,N]);let re=f(t=>{if(!(!(`assistantID`in t)||t.assistantID!==e.id)){if(t.type===`contact-turn-start`){if(M.current.has(t.turnID))return;O(e=>Q(e,t.assistantID,t.turnID,t.occurredAt));return}if(t.type===`contact-bubble-delta`){if(M.current.has(t.turnID))return;O(e=>xe(e,t));return}t.type===`contact-turn-end`&&(M.current.add(t.turnID),O(e=>Se($(e,t),F)))}});q.useEffect(()=>{if(n)return _(re)},[n,e.id]),q.useEffect(()=>{let e=P.current;e&&(e.scrollTop=e.scrollHeight)},[te,z.length]);let ie=f(async e=>{let t=await Ke(e);t.skippedTooLarge>0&&A(r(`assistants.contact.attachment.tooLarge`)),t.attachments.length!==0&&x(e=>qe(e,t.attachments))}),ae=f(e=>{let t=We(e.clipboardData);t.length!==0&&(e.preventDefault(),ie(t))}),W=f(e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}),oe=f(e=>{let t=Ge(e.dataTransfer);t.length!==0&&(e.preventDefault(),ie(t))}),G=f(async()=>{let t=v,n=b,i=e.id,o=Ee({gate:j,sending:De(I),text:t,attachments:n,assistantID:i,createMessageID:()=>`oc_contact_${a()}`});if(o.ok){E(e=>[...e,o.turn]),y(``),x([]),A(null);try{await C(i,o.messageID,{parts:o.parts}),E(e=>be(e,o.messageID)),M.current.has(o.messageID)||O(e=>Q(e,i,o.messageID)),s.data?.serverInstanceID&&h({serverInstanceID:s.data.serverInstanceID,assistantID:i,name:d,avatarSeed:i,...u.avatarEmoji?{avatarEmoji:u.avatarEmoji}:{}}).catch(()=>void 0)}catch(e){let t=we(e,{noProvider:r(`assistants.contact.noProvider`),sendFailed:r(`assistants.contact.sendFailed`),timedOut:r(`assistants.contact.timedOut`)});E(e=>Ce(e,o.messageID,t))}finally{j.release()}}}),se=l.isError&&z.length===0,ce=l.isSuccess&&z.length===0,le=new Map(I.map(e=>[e.messageID,e]));return(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,children:[(0,J.jsxs)(`div`,{ref:P,className:`min-h-0 flex-1 overflow-y-auto px-4 pt-5 pb-9 sm:px-8 sm:pt-7 sm:pb-12`,"data-assistant-contact-transcript":``,children:[t?(0,J.jsx)(`p`,{className:`mb-3 typography-micro text-[var(--status-warning)]`,children:t}):null,se?(0,J.jsxs)(`div`,{className:`mx-auto flex h-full min-h-56 max-w-xs flex-col items-center justify-center pb-16 text-center`,"data-assistant-contact-error":``,children:[(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(ue,{name:e.id,emoji:u.avatarEmoji,size:44,label:d}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:`absolute -right-1 -bottom-1 flex size-5 items-center justify-center rounded-full bg-[var(--surface-elevated)] text-[var(--status-error)] ring-2 ring-background`,children:(0,J.jsx)(B,{name:`error-warning`,className:`size-3`})})]}),(0,J.jsx)(`p`,{className:`mt-4 typography-ui-label font-medium text-foreground`,children:d}),(0,J.jsx)(`p`,{className:`mt-1.5 typography-ui leading-6 text-muted-foreground`,children:r(`assistants.contact.loadFailed`)})]}):ce?(0,J.jsxs)(`div`,{className:`mx-auto flex h-full min-h-56 max-w-sm flex-col items-center justify-center pb-16 text-center`,"data-assistant-contact-empty":``,children:[(0,J.jsx)(ue,{name:e.id,emoji:u.avatarEmoji,size:48,label:d,className:`opacity-90`}),(0,J.jsx)(`p`,{className:`mt-5 typography-ui-header font-medium tracking-[-0.01em] text-foreground`,children:r(`assistants.conversation.emptyTitle`,{name:d})}),(0,J.jsx)(`p`,{className:`mt-2 max-w-xs typography-ui leading-6 text-muted-foreground/80`,children:r(`assistants.contact.empty`)})]}):(0,J.jsx)(`div`,{className:`mx-auto flex w-full max-w-[42rem] flex-col`,children:z.map((t,n)=>{let i=n>0?z[n-1]:null,a=t.role===`user`,o=t.role===`peer`,s=t.role===`assistant`&&i?.role===`assistant`&&i.turnID===t.turnID,l=i?.turnID!==t.turnID,u=!a&&(o||!s),f=o?g(t.fromAssistantID,t.fromAssistantName):d,p=o&&t.fromAssistantID?c.data?.assistants.find(e=>e.id===t.fromAssistantID):e,h=p?m(p.name):null,_=le.get(t.messageID),v=ne.get(t.turnID),y=t.status===`admitted`&&t.messageID.endsWith(`:preview:admitted`),b=t.status===`failed`&&t.messageID.endsWith(`:preview:failed`);return(0,J.jsxs)(`div`,{className:R(`flex w-full`,a?`justify-end`:`justify-start`,l?`mt-6 first:mt-0`:s?`mt-1.5`:`mt-3`),"data-assistant-contact-role":t.role,"data-assistant-contact-turn-status":_?.status??t.status,"data-assistant-contact-run-start":t.role===`assistant`&&!s?``:void 0,children:[a?null:(0,J.jsx)(`div`,{className:`mr-2.5 flex w-8 shrink-0 justify-center pt-0.5`,children:u?(0,J.jsx)(ue,{name:p?.id||t.fromAssistantID||e.id,emoji:h?.avatarEmoji,size:28,label:f}):(0,J.jsx)(`span`,{className:`size-7`,"aria-hidden":!0})}),(0,J.jsxs)(`div`,{className:R(`flex min-w-0 flex-col gap-1.5`,a?`max-w-[min(82%,30rem)] items-end`:`max-w-[min(84%,34rem)] items-start`),children:[o?(0,J.jsx)(`span`,{className:`mb-0.5 px-1 typography-micro text-muted-foreground/75`,children:r(`assistants.contact.peer.from`,{name:f})}):null,y?(0,J.jsxs)(`div`,{role:`status`,"aria-label":r(`assistants.contact.processing`),className:`inline-flex w-fit items-center gap-1 rounded-full bg-[var(--surface-muted)] px-3.5 py-2.5 text-muted-foreground/70`,"data-assistant-contact-processing":``,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-delay:-0.45s] [animation-duration:1.4s] motion-reduce:animate-none`}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-delay:-0.22s] [animation-duration:1.4s] motion-reduce:animate-none`}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-duration:1.4s] motion-reduce:animate-none`})]}):null,t.parts.map((e,n)=>e.type===`card`&&e.cardType===`session`?(0,J.jsx)(Be,{card:e},`${t.messageID}:card:${n}`):e.type===`card`&&e.cardType===`assistant`?(0,J.jsx)(Ne,{card:e},`${t.messageID}:card:${n}`):e.type===`card`&&e.cardType===`schedule`?(0,J.jsx)(Pe,{card:e},`${t.messageID}:card:${n}`):e.type===`file`&&e.mime.startsWith(`image/`)&&e.url?(0,J.jsx)(`img`,{src:e.url,alt:e.filename||r(`assistants.contact.attachment.image`),className:`max-h-72 max-w-full rounded-[1.35rem] border border-border/40 object-contain`,"data-assistant-contact-image":``},`${t.messageID}:file:${n}`):e.type===`file`?(0,J.jsxs)(`div`,{className:`flex max-w-full items-center gap-2.5 rounded-[1.25rem] bg-[var(--surface-muted)] px-3.5 py-2.5 ring-1 ring-inset ring-[var(--surface-subtle)]`,"data-assistant-contact-file":``,children:[(0,J.jsx)(B,{name:`file-text`,className:`size-4 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`min-w-0 truncate typography-ui`,children:e.filename||r(`assistants.contact.attachment.file`)})]},`${t.messageID}:file:${n}`):e.type===`text`&&(e.text.trim()||t.status===`streaming`)?(0,J.jsxs)(`div`,{"aria-label":o?r(`assistants.contact.peer.aria`,{name:f}):void 0,className:R(`whitespace-pre-wrap break-words rounded-[1.35rem] px-4 py-2.5 typography-ui leading-6`,a?`rounded-[1.15rem] rounded-br-lg bg-[var(--primary-base)]/90 text-[var(--primary-foreground)]`:o?`rounded-[1.25rem] border border-dashed border-border/50 bg-[var(--surface-muted)]/70 text-foreground`:R(`bg-[var(--surface-muted)] text-foreground`,s&&`rounded-tl-lg`)),children:[Je[e.text]?r(Je[e.text]):e.text,t.status===`streaming`&&n===t.parts.length-1?(0,J.jsx)(`span`,{"aria-hidden":!0,className:`ml-0.5 inline-block h-[1em] w-px translate-y-[0.12em] animate-pulse bg-current opacity-45 [animation-duration:1.1s] motion-reduce:animate-none`,"data-assistant-contact-streaming-caret":``}):null]},`${t.messageID}:text:${n}`):null),_?.status===`sending`?(0,J.jsx)(`p`,{className:`px-1 typography-micro text-muted-foreground/75`,children:r(`assistants.contact.sending`)}):null,_?.status===`failed`?(0,J.jsx)(`p`,{className:`px-1 typography-micro text-[var(--status-error)]`,children:_.error||r(`assistants.contact.sendFailed`)}):null,b?(0,J.jsx)(`p`,{className:`px-1 typography-micro text-[var(--status-error)]`,children:v?.error||r(`assistants.contact.sendFailed`)}):null]})]},t.messageID)})})]}),(0,J.jsxs)(`footer`,{className:`relative z-10 shrink-0 bg-background pt-1`,"data-assistant-contact-composer":``,children:[k?(0,J.jsx)(`p`,{className:`chat-input-column mb-2 typography-micro text-[var(--status-error)]`,children:k}):null,(0,J.jsx)(`form`,{className:R(`relative w-full pt-1.5 pb-4`,o&&`bottom-safe-area oc-mobile-composer`),onSubmit:e=>{e.preventDefault(),G()},onDragOver:W,onDrop:oe,children:(0,J.jsx)(`div`,{className:`chat-input-column relative overflow-visible`,children:(0,J.jsx)(U,{layout:`inline`,value:v,attachments:b,pending:!1,isMobile:o,placeholder:r(`assistants.contact.placeholder`,{name:d}),sendLabel:r(`assistants.contact.send`),addFilesLabel:r(`assistants.contact.addFiles`),removeAttachmentLabel:r(`assistants.contact.removeAttachment`),fileAccept:`*/*`,onChange:e=>y(e),onSubmit:()=>{G()},onAddFiles:e=>{ie(e)},onRemoveAttachment:e=>{x(t=>t.filter(t=>t.id!==e))},onPaste:ae,onDragOver:W,onDrop:oe,className:R(`relative z-10`,o&&`oc-mobile-composer-surface`),style:{borderRadius:`1.5rem`},"data-assistant-contact-composer-surface":``,textareaProps:{"aria-label":r(`assistants.contact.placeholder`,{name:d})}})})})]})]})};async function Xe(e){await E(e);let t=k.getState().defaultShareAssistant;if(t?.assistantID!==e.id)return;let n=await x();n.serverInstanceID&&t.serverInstanceID===n.serverInstanceID&&k.getState().setDefaultShareAssistant(null)}function Ze({assistant:e,open:t,onOpenChange:n,onDeleted:r}){let{t:i}=p(),[a,o]=q.useState(!1),s=e?m(e.name).displayName||e.name:``,c=f(e=>{a&&!e||n(e)}),l=f(()=>{a||n(!1)}),u=f(async()=>{if(!(!e||a)){o(!0);try{await Xe(e),r?.(e.id),n(!1),d.success(i(`assistants.settings.toast.deleted`))}catch{d.error(i(`assistants.settings.toast.deleteFailed`))}finally{o(!1)}}});return(0,J.jsx)(L,{open:t&&e!==null,onOpenChange:c,children:(0,J.jsxs)(P,{className:`max-w-md`,children:[(0,J.jsxs)(M,{children:[(0,J.jsx)(F,{children:i(`assistants.settings.delete`)}),(0,J.jsx)(I,{children:i(`assistants.settings.deleteConfirm`,{name:s})})]}),(0,J.jsxs)(N,{children:[(0,J.jsx)(V,{size:`sm`,variant:`ghost`,onClick:l,disabled:a,children:i(`settings.common.actions.cancel`)}),(0,J.jsx)(V,{size:`sm`,variant:`destructive`,onClick:u,disabled:a,children:i(`settings.common.actions.delete`)})]})]})})}var Qe=e=>e.capabilityPending?`loading`:e.capabilityError||e.supported!==!0||e.capabilityEnabled!==!0?`unavailable`:e.snapshotPending?`loading`:e.snapshotEnabled===!0?e.assistantCount===0?`onboarding`:e.hasAssistant?`ready`:e.snapshotSettled?`unavailable`:`loading`:`unavailable`,$e=t({AssistantView:()=>nt}),et=e=>{let t=(0,K.c)(21),{assistant:n,onBack:r}=e,{t:i}=p(),a=ae(),o;t[0]===n?o=t[1]:(o=n?m(n.name):null,t[0]=n,t[1]=o);let s=o,c=n&&s?s.displayName||n.name:``,l;t[2]!==n||t[3]!==a?(l=()=>{n&&j(n.id,a?{openMobileSettings:a.openSettings}:void 0)},t[2]=n,t[3]=a,t[4]=l):l=t[4];let u=f(l),d;t[5]!==n||t[6]!==c||t[7]!==s?.avatarEmoji||t[8]!==i?(d=n?(0,J.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2.5`,children:[(0,J.jsx)(ue,{name:n.id,emoji:s?.avatarEmoji,size:28,label:c}),(0,J.jsx)(`span`,{className:`truncate font-medium tracking-[-0.01em]`,children:c||i(`assistants.title`)})]}):c||i(`assistants.title`),t[5]=n,t[6]=c,t[7]=s?.avatarEmoji,t[8]=i,t[9]=d):d=t[9];let h;t[10]===i?h=t[11]:(h=i(`assistants.actions.backToChat`),t[10]=i,t[11]=h);let g;t[12]!==n||t[13]!==u||t[14]!==i?(g=n?[{icon:`settings-3`,ariaLabel:i(`assistants.conversation.openSettings`),onClick:u}]:[],t[12]=n,t[13]=u,t[14]=i,t[15]=g):g=t[15];let _;return t[16]!==r||t[17]!==d||t[18]!==h||t[19]!==g?(_=(0,J.jsx)(D,{title:d,backAriaLabel:h,onBack:r,actions:g,overlay:!0}),t[16]=r,t[17]=d,t[18]=h,t[19]=g,t[20]=_):_=t[20],_},tt=e=>{let t=(0,K.c)(46),{assistantID:n,displayName:r,avatarEmoji:i,subtitle:a,selected:o,enabled:s,editLabel:c,deleteLabel:l,onSelect:u,onEdit:d,onDelete:p,assignedSessionIDs:m,serverWorking:h}=e,g=fe(n),[_,v]=q.useState(!1),y;t[0]===u?y=t[1]:(y=()=>u(),t[0]=u,t[1]=y);let b=f(y),x;t[2]===d?x=t[3]:(x=()=>{v(!1),d()},t[2]=d,t[3]=x);let S=f(x),C;t[4]===p?C=t[5]:(C=()=>{v(!1),p()},t[4]=p,t[5]=C);let w=f(C),ee;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(ee=e=>{e.preventDefault(),v(!0)},t[6]=ee):ee=t[6];let T=o?`border-border/50 bg-[var(--surface-elevated)]`:`border-transparent hover:bg-interactive-hover`,E=!s&&`opacity-65`,D;t[7]!==T||t[8]!==E?(D=R(`flex w-full min-h-11 items-center gap-3 rounded-xl border px-3 py-3 text-left outline-none transition-[background-color,border-color,opacity] duration-150 ease-out active:bg-interactive-active focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,T,E),t[7]=T,t[8]=E,t[9]=D):D=t[9];let O;t[10]!==b||t[11]!==o||t[12]!==D?(O=(0,J.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":o,onClick:b,onContextMenu:ee,className:D}),t[10]=b,t[11]=o,t[12]=D,t[13]=O):O=t[13];let k;t[14]!==n||t[15]!==i||t[16]!==r||t[17]!==g?(k=(0,J.jsx)(ue,{name:n,emoji:i,size:24,label:r,working:g}),t[14]=n,t[15]=i,t[16]=r,t[17]=g,t[18]=k):k=t[18];let A;t[19]===r?A=t[20]:(A=(0,J.jsx)(`span`,{className:`block truncate typography-ui-label font-medium`,children:r}),t[19]=r,t[20]=A);let j;t[21]===a?j=t[22]:(j=(0,J.jsx)(`span`,{className:`mt-0.5 block truncate typography-micro text-muted-foreground`,children:a}),t[21]=a,t[22]=j);let M;t[23]!==A||t[24]!==j?(M=(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[A,j]}),t[23]=A,t[24]=j,t[25]=M):M=t[25];let N;t[26]!==O||t[27]!==k||t[28]!==M?(N=(0,J.jsxs)(W,{render:O,children:[k,M]}),t[26]=O,t[27]=k,t[28]=M,t[29]=N):N=t[29];let P;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,J.jsx)(B,{name:`edit`,className:`size-4`}),t[30]=P):P=t[30];let F;t[31]!==c||t[32]!==S?(F=(0,J.jsxs)(se,{onClick:S,children:[P,c]}),t[31]=c,t[32]=S,t[33]=F):F=t[33];let I;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,J.jsx)(oe,{}),t[34]=I):I=t[34];let L;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,J.jsx)(B,{name:`delete-bin`,className:`size-4`}),t[35]=L):L=t[35];let z;t[36]!==l||t[37]!==w?(z=(0,J.jsxs)(se,{onClick:w,className:`text-[var(--status-error)] focus:text-[var(--status-error)] data-[highlighted]:text-[var(--status-error)] [&_svg]:text-[var(--status-error)]`,children:[L,l]}),t[36]=l,t[37]=w,t[38]=z):z=t[38];let V;t[39]!==F||t[40]!==z?(V=(0,J.jsxs)(G,{className:`min-w-[10rem]`,children:[F,I,z]}),t[39]=F,t[40]=z,t[41]=V):V=t[41];let H;return t[42]!==_||t[43]!==N||t[44]!==V?(H=(0,J.jsxs)(ce,{open:_,onOpenChange:v,children:[N,V]}),t[42]=_,t[43]=N,t[44]=V,t[45]=H):H=t[45],H},nt=e=>{let t=(0,K.c)(108),{activeOverride:a,onMobileBack:o}=e,{t:s}=p(),{isMobile:c}=H(),l=ae(),u=q.useSyncExternalStore(n,r,r),d=i(rt),h=a??d,g=i(it),_=c||g,v=w(),y=ee(),b=y.data,x;t[0]===u?x=t[1]:(x=e=>e.assistantByTransport[u]??null,t[0]=u,t[1]=x);let S=k(x),C=k(at),T=k(ot),E;t[2]!==S||t[3]!==b?.assistants?(E=b?.assistants.find(e=>e.id===S)??null,t[2]=S,t[3]=b?.assistants,t[4]=E):E=t[4];let D=E,O;t[5]!==C||t[6]!==S||t[7]!==b?(O=()=>{!S&&b?.assistants[0]&&C(b.assistants[0].id)},t[5]=C,t[6]=S,t[7]=b,t[8]=O):O=t[8];let A=b?.assistants,M;t[9]!==C||t[10]!==S||t[11]!==A?(M=[C,S,A],t[9]=C,t[10]=S,t[11]=A,t[12]=M):M=t[12],q.useEffect(O,M);let N;t[13]!==D||t[14]!==C||t[15]!==S||t[16]!==b?.assistants||t[17]!==y.isSuccess?(N=()=>{y.isSuccess&&S&&!D&&C(b?.assistants[0]?.id??null)},t[13]=D,t[14]=C,t[15]=S,t[16]=b?.assistants,t[17]=y.isSuccess,t[18]=N):N=t[18];let P=b?.assistants,F;t[19]!==D||t[20]!==C||t[21]!==S||t[22]!==y.isSuccess||t[23]!==P?(F=[D,C,S,P,y.isSuccess],t[19]=D,t[20]=C,t[21]=S,t[22]=y.isSuccess,t[23]=P,t[24]=F):F=t[24],q.useEffect(N,F);let I;t[25]!==l||t[26]!==T?(I=()=>{if(T(),l){l.openSettings();return}let e=i.getState();e.setSettingsPage(`assistants`),e.setSettingsDialogOpen(!0)},t[25]=l,t[26]=T,t[27]=I):I=t[27];let L=f(I),z;t[28]===l?z=t[29]:(z=e=>{j(e,l?{openMobileSettings:l.openSettings}:void 0)},t[28]=l,t[29]=z);let U=f(z),te;t[30]!==D||t[31]!==l?(te=()=>{D&&j(D.id,l?{openMobileSettings:l.openSettings}:void 0)},t[30]=D,t[31]=l,t[32]=te):te=t[32];let ne=f(te),[re,ie]=q.useState(null),W;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>{ie(e)},t[33]=W):W=t[33];let oe=f(W),G;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>{e||ie(null)},t[34]=G):G=t[34];let se=f(G),ce=f(st),le;t[35]!==o||t[36]!==ce?(le=()=>{if(o){o();return}ce()},t[35]=o,t[36]=ce,t[37]=le):le=t[37];let Y=f(le),de=Qe({capabilityPending:v.isPending,snapshotPending:y.isPending,capabilityError:v.isError,supported:v.data?.supported,capabilityEnabled:v.data?.enabled,snapshotEnabled:b?.enabled,snapshotSettled:y.isSuccess,assistantCount:b?.assistants.length??0,hasAssistant:!!D}),fe;t[38]!==D||t[39]!==Y||t[40]!==_?(fe=(e,t,n,r)=>(0,J.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[_?(0,J.jsx)(et,{assistant:D,onBack:Y}):null,(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 pt-[calc(max(0.25rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height,3.5rem))] text-center`,children:[(0,J.jsx)(B,{name:e,className:`size-6 text-muted-foreground`}),(0,J.jsx)(`h1`,{className:`mt-4 typography-ui-header font-semibold`,children:t}),n?(0,J.jsx)(`p`,{className:`mt-2 max-w-md typography-ui text-muted-foreground`,children:n}):null,r?(0,J.jsx)(`div`,{className:`mt-5`,children:r}):null]})]}),t[38]=D,t[39]=Y,t[40]=_,t[41]=fe):fe=t[41];let X=fe;if(de===`loading`){let e;t[42]!==D||t[43]!==Y||t[44]!==_?(e=_?(0,J.jsx)(et,{assistant:D,onBack:Y}):null,t[42]=D,t[43]=Y,t[44]=_,t[45]=e):e=t[45];let n;t[46]===s?n=t[47]:(n=s(`common.loading`),t[46]=s,t[47]=n);let r;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,J.jsx)(B,{name:`loader-4`,className:`size-6 animate-spin text-muted-foreground`}),t[48]=r):r=t[48];let i;t[49]===n?i=t[50]:(i=(0,J.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 pt-[calc(max(0.25rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height,3.5rem))] text-center`,"aria-busy":`true`,"aria-label":n,"data-assistant-workspace-loading":``,children:r}),t[49]=n,t[50]=i);let a;return t[51]!==e||t[52]!==i?(a=(0,J.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[e,i]}),t[51]=e,t[52]=i,t[53]=a):a=t[53],a}if(de===`unavailable`){let e;return t[54]!==X||t[55]!==s?(e=X(`cloud-off`,s(`assistants.state.unavailable`)),t[54]=X,t[55]=s,t[56]=e):e=t[56],e}if(de===`onboarding`){let e;if(t[57]!==L||t[58]!==X||t[59]!==s){let n=s(`assistants.onboarding.title`),r=s(`assistants.onboarding.description`),i;t[61]===s?i=t[62]:(i=s(`assistants.onboarding.action`),t[61]=s,t[62]=i);let a;t[63]!==L||t[64]!==i?(a=(0,J.jsx)(V,{onClick:L,children:i}),t[63]=L,t[64]=i,t[65]=a):a=t[65],e=X(`ai-agent`,n,r,a),t[57]=L,t[58]=X,t[59]=s,t[60]=e}else e=t[60];return e}if(!b||!D){let e;return t[66]!==X||t[67]!==s?(e=X(`cloud-off`,s(`assistants.state.unavailable`)),t[66]=X,t[67]=s,t[68]=e):e=t[68],e}let pe;t[69]===D.name?pe=t[70]:(pe=m(D.name),t[69]=D.name,t[70]=pe);let me=pe,he;t[71]!==D.enabled||t[72]!==y.isError||t[73]!==s?(he=D.enabled?y.isError?s(`assistants.state.staleSnapshot`):null:s(`assistants.state.assistantDisabled`),t[71]=D.enabled,t[72]=y.isError,t[73]=s,t[74]=he):he=t[74];let ge=he,Z;t[75]!==_||t[76]!==U||t[77]!==oe||t[78]!==C||t[79]!==S||t[80]!==b||t[81]!==s?(Z=_?null:(0,J.jsxs)(`section`,{className:`flex h-full min-h-0 w-[clamp(16rem,22vw,20rem)] shrink-0 flex-col overflow-hidden`,children:[(0,J.jsx)(`header`,{className:`shrink-0 px-4 pb-3 pt-4 sm:px-5`,children:(0,J.jsx)(`h1`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:s(`assistants.title`)})}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-4 sm:px-4`,role:`listbox`,"aria-label":s(`assistants.listAria`),children:(0,J.jsx)(`div`,{className:`flex flex-col gap-1 border-t border-border/40 pt-3`,children:b.assistants.map(e=>{let t=e.id===S,n=m(e.name);return(0,J.jsx)(tt,{assistantID:e.id,displayName:n.displayName,avatarEmoji:n.avatarEmoji??void 0,subtitle:[e.providerID,e.modelID].filter(Boolean).join(`/`)||e.defaultPrompt.trim(),selected:t,enabled:e.enabled,editLabel:s(`assistants.menu.edit`),deleteLabel:s(`assistants.settings.delete`),assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onSelect:()=>C(e.id),onEdit:()=>U(e.id),onDelete:()=>oe(e)},e.id)})})})]}),t[75]=_,t[76]=U,t[77]=oe,t[78]=C,t[79]=S,t[80]=b,t[81]=s,t[82]=Z):Z=t[82];let _e=re!==null,ve;t[83]!==re||t[84]!==se||t[85]!==_e?(ve=(0,J.jsx)(Ze,{assistant:re,open:_e,onOpenChange:se}),t[83]=re,t[84]=se,t[85]=_e,t[86]=ve):ve=t[86];let ye=!_&&`border-l border-[var(--surface-subtle)]`,be;t[87]===ye?be=t[88]:(be=R(`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background`,ye),t[87]=ye,t[88]=be);let Q;t[89]!==D||t[90]!==Y||t[91]!==_||t[92]!==ne||t[93]!==me||t[94]!==s?(Q=_?(0,J.jsx)(et,{assistant:D,onBack:Y}):(0,J.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center gap-3.5 border-b border-[var(--surface-subtle)]/70 px-5 sm:px-7`,children:[(0,J.jsx)(ue,{name:D.id,emoji:me.avatarEmoji,size:30,label:me.displayName||D.name}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`div`,{className:`truncate typography-ui-label font-semibold tracking-[-0.01em] text-foreground`,children:me.displayName}),(0,J.jsx)(`div`,{className:`mt-1 truncate typography-micro leading-none text-muted-foreground/55`,children:s(`assistants.conversation.contactHint`)})]}),(0,J.jsx)(V,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 shrink-0 rounded-full text-muted-foreground/65 transition-colors hover:text-foreground`,onClick:ne,"aria-label":s(`assistants.conversation.openSettings`),children:(0,J.jsx)(B,{name:`settings-3`,className:`size-4`})})]}),t[89]=D,t[90]=Y,t[91]=_,t[92]=ne,t[93]=me,t[94]=s,t[95]=Q):Q=t[95];let xe;t[96]!==h||t[97]!==D||t[98]!==ge?(xe=(0,J.jsx)(Ye,{assistant:D,warning:ge,active:h}),t[96]=h,t[97]=D,t[98]=ge,t[99]=xe):xe=t[99];let $;t[100]!==be||t[101]!==Q||t[102]!==xe?($=(0,J.jsxs)(`div`,{className:be,children:[Q,xe]}),t[100]=be,t[101]=Q,t[102]=xe,t[103]=$):$=t[103];let Se;return t[104]!==Z||t[105]!==ve||t[106]!==$?(Se=(0,J.jsxs)(`div`,{className:`relative flex h-full min-h-0 overflow-hidden bg-background`,"data-presentation":`workspace`,children:[Z,ve,$]}),t[104]=Z,t[105]=ve,t[106]=$,t[107]=Se):Se=t[107],Se};function rt(e){return e.activeMainTab===`assistant`}function it(e){return e.isMobile}function at(e){return e.selectAssistant}function ot(e){return e.requestCreate}function st(){i.getState().setActiveMainTab(`chat`)}export{ue as a,fe as i,$e as n,Ze as r,nt as t};
@@ -1,4 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,E as n,b as r,t as i,y as a}from"./useUIStore-CqqO11ZI.js";import{$t as o,D as s,d as c,k as l,ot as u,u as d,xn as f}from"./persistence-CSZp1CNB.js";import{a as p,i as m,r as h}from"./vendor-zustand-B4dlGEM2.js";import{nt as g,rt as _,tt as v}from"./vendor-base-ui-CnHfUmDN.js";import{B as y,Ct as b,M as x,Mt as S}from"./platform-CenlWqxu.js";import{n as ee}from"./vendor-react-DLPElpoQ.js";import{s as C}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as w}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as te}from"./clipboard-BXxLshVq.js";import{$a as ne,Zi as re,at as ie,c as T,ct as ae,dr as oe,dt as E,ft as D,g as O,go as k,ho as se,in as A,lt as ce,mn as j,ot as le,st as M,y as N}from"./useMobileNavigationStore-CEmn-d1X.js";import{c as ue,t as P}from"./utils-B0mQXN9L.js";import{n as F,r as I,t as L}from"./Icon-4My8YZwt.js";import{g as R,v as de}from"./gitApi-Br5EdS29.js";import{f as z,o as B,q as fe}from"./projectMeta-BHw8kRhQ.js";import{n as pe}from"./textarea-CIO34TZz.js";var V=e(_(),1),H=ee(),U=g(),W=e(v(),1),me=e=>{switch(e.name){case`new`:return`add`;case`init`:return`file`;case`undo`:return`arrow-go-back`;case`redo`:return`arrow-go-forward`;case`timeline`:return`time`;case`compact`:return`scissors`;case`goal`:return`target`;case`review`:return`search-eye`;case`test`:case`build`:case`run`:return`terminal-box`;default:return e.isBuiltIn?`flashlight`:`command`}},he=()=>`book-open`,ge=e=>{if(e.isDirectory)return`folder-3-fill`;switch(e.extension?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:case`json`:return`code`;case`md`:case`mdx`:return`file`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`svg`:return`file-image`;default:return`file-pdf`}},_e=()=>`ai-agent`,ve=()=>`chat-thread`,G=32,K=(e,t)=>{let n=I[e];return typeof n!=`string`||n.length===0?null:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="${t}" stroke-width="${L}" stroke-linecap="round" stroke-linejoin="round">${n}</svg>`},ye=(e,t)=>{let n=K(e,t);return!n||typeof document>`u`?Promise.resolve(null):new Promise(e=>{let t=new Image;t.decoding=`async`,t.onload=()=>{try{let n=document.createElement(`canvas`);n.width=G,n.height=G;let r=n.getContext(`2d`);if(!r){e(null);return}r.clearRect(0,0,G,G),r.drawImage(t,0,0,G,G);let i=n.toDataURL(`image/png`),a=i.indexOf(`,`);e(a>=0?i.slice(a+1):null)}catch{e(null)}},t.onerror=()=>e(null),t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`})},be=(e,t)=>e.map(e=>{let n=e.isSkill?t.skill:e.isOpenChamber?`OpenChamber`:e.isBuiltIn?t.system:e.scope||e.agent||t.command;return{id:e.id,title:`/${e.name}`,subtitle:e.description,badge:n,iconName:me(e)}}),q=e=>e.map(e=>({id:`${e.name}-${e.scope}`,title:e.name,subtitle:e.description,badge:e.scope,iconName:he()})),xe=({agents:e,sessions:t,recentFiles:n,pathHits:r,untitledSession:i,sessionBadge:a})=>{let o=[];for(let t of e)o.push({id:`agent:${t.name}`,title:`@${t.name}`,subtitle:t.description,iconName:_e()});for(let e of t)o.push({id:`session:${e.id}`,title:e.title||i,badge:a,iconName:ve()});for(let e of n)o.push({id:`recent:${e.path}`,title:e.relativePath||e.name,iconName:ge(e)});for(let e of r)o.push({id:`file:${e.path}`,title:e.relativePath||e.name,iconName:ge(e)});return o},J=(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=D([...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)},Y=(e,t)=>{if(!e.includes(`/`)||t.size===0)return[];let n=RegExp(`(^|\\s)/(${u})?([A-Za-z0-9][A-Za-z0-9_-]*)(?=$|\\s)`,`g`),r=[],i;for(;(i=n.exec(e))!==null;){let e=i[3]??``;if(!t.has(e.toLowerCase()))continue;let n=i[2]??``,a=i.index+(i[1]?.length??0);r.push({start:a,end:a+1+n.length+e.length,name:e,hasSlot:n.length>0})}return r},X=(e,t,n=e.length)=>{let r=Y(e,t).filter(e=>!e.hasSlot);if(r.length===0)return null;let i=e,a=n;for(let e=r.length-1;e>=0;--e){let t=r[e].start+1;i=`${i.slice(0,t)}${u}${i.slice(t)}`,a>t&&(a+=u.length)}return i===e?null:{text:i,caret:a}},Se=e=>e.startsWith(u)?e.slice(u.length):e,Ce=e=>{if(e.inputMode===`shell`)return null;let t=e.text,n=Math.max(0,Math.min(e.cursor,t.length));if(t.startsWith(`/`)){let e=t.indexOf(` `),r=t.indexOf(`
2
- `),i=Math.min(e===-1?t.length:e,r===-1?t.length:r);if(n<=i&&e===-1)return{kind:`slash-command`,query:Se(t.substring(1,i)),tokenStart:0,tokenEnd:i}}let r=t.substring(0,n),i=r.lastIndexOf(`/`);if(i!==-1){let e=i>0?r[i-1]:null,t=Se(r.substring(i+1)),a=t.includes(` `)||t.includes(`
3
- `);if((!e||/\s/.test(e))&&!a)return{kind:`slash-skill`,query:t,tokenStart:i,tokenEnd:n}}let a=r.lastIndexOf(`#`);if(a!==-1){let e=a>0?r[a-1]:null,t=r.substring(a+1);if((!e||/\s/.test(e))&&!t.includes(` `)&&!t.includes(`
4
- `))return{kind:`snippet`,query:t,tokenStart:a,tokenEnd:n}}let o=ie({value:t,cursorPosition:n,inputSource:e.mentionInputSource??`manual`,insertedText:e.insertedText});return o===null?null:{kind:`mention`,query:o,tokenStart:r.lastIndexOf(`@`),tokenEnd:n}},we=e=>e===`mention`?`@`:e===`snippet`?`#`:`/`,Te=(e,t,n)=>{if(n&&n.tokenStart>=0&&n.tokenEnd>=n.tokenStart&&n.tokenEnd<=e.length&&e.startsWith(we(n.kind),n.tokenStart))return{start:n.tokenStart,end:n.tokenEnd};let r=Ce({text:e,cursor:t});return r?{start:r.tokenStart,end:r.tokenEnd}:null},Ee=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!=null&&e.id===r.id&&e.title===r.title&&(e.subtitle??``)===(r.subtitle??``)&&(e.badge??``)===(r.badge??``)&&e.iconName===r.iconName}),De=(e,t)=>e.highlightedIndex===t.highlightedIndex&&Ee(e.rows,t.rows),Oe=(e,t)=>Ee(e,t)?e:t.slice(),ke=(e,t,n)=>{e&&(t.current&&De(t.current,n)||(t.current=n,e(n)))},Ae=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},Z=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},je=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,Me=(e,t)=>{let n=Z(t),r=Z(e);if(!n||!r)return!1;let i=je(n),a=je(r);return a===i||a.startsWith(`${i}/`)},Ne=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=Z(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=>Z(e)).filter(e=>Me(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>Z(e)).filter(e=>Me(e,t)))):[],s=typeof i.selectedPath==`string`?Z(i.selectedPath):null,c=s&&Me(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},Pe=(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},Fe=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Ie=p()(h(m((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=Z((t||``).trim()),a=Z((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!Me(a,i)||e(e=>{let t=e.byRoot[i],n=Fe(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:Pe({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=Z((t||``).trim()),i=Z((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=je(i),a=e=>je(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:Pe({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=Z((t||``).trim()),i=Z((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=je(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=je(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:Pe({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=Z((t||``).trim()),i=Z((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=je(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=je(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:Pe({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=Z((t||``).trim()),a=n?Z(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!Me(a,i)||e(e=>{let t=e.byRoot[i],n=Fe(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:Pe({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=Z((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=Z((t||``).trim()),i=Z((n||``).trim());!r||!i||!Me(i,r)||e(e=>{let t=e.byRoot[r],n=Fe(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:Pe({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=Z((t||``).trim()),i=Z((n||``).trim());!r||!i||!Me(i,r)||e(e=>{let t=e.byRoot[r],n=Fe(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:Pe({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=Z((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>Z((e||``).trim())).filter(e=>e&&Me(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=Fe(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:Pe({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:a(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:Ne(t)}},partialize:e=>({byRoot:Ne(e.byRoot)})}),{name:`files-view-tabs-store`})),Le=(e,t)=>{let n=(0,H.c)(4),r=t===void 0?200:t,[i,a]=V.useState(e),o,s;return n[0]!==r||n[1]!==e?(o=()=>{let t=window.setTimeout(()=>{a(e)},r);return()=>{window.clearTimeout(t)}},s=[e,r],n[0]=r,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),V.useEffect(o,s),i},Re=()=>{let e=(0,H.c)(17),t=T(ze),n=j(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=N(r),a=T(Be),o=T(Ve),s=k(He),c=k(Ue),l=b(We);if(t){let r;e[2]===i?r=e[3]:(r=O(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 ze(e){return e.currentSessionId}function Be(e){return e.worktreeMetadata}function Ve(e){return e.newSessionDraft}function He(e){return e.activeProjectId}function Ue(e){return e.projects}function We(e){return e.currentDirectory}var Ge=`absolute z-[100] min-w-0 w-full bottom-full mb-2 left-0 flex flex-col rounded-xl`,Ke=`pointer-events-auto absolute z-[100] min-w-0 flex flex-col rounded-xl`;function qe(e,t){return P(e?Ke:Ge,e?`oc-mobile-overlay-surface oc-mobile-overlay-surface--translucent oc-composer-autocomplete-surface`:`bg-background border-2 border-border/60 shadow-none`,t)}function Je(e,t){return e?`oc-composer-autocomplete-row`:t?`bg-interactive-selection`:void 0}var Ye=.4,Xe=e=>{let t=e.gap??8,n=e.composerTop-t;return{left:e.composerLeft,width:e.composerWidth,bottom:Math.max(0,e.visibleBottom-n),maxHeight:Ze({popupBottom:n,boundaryTop:e.boundaryTop,viewportHeight:e.viewportHeight,gap:t})}},Ze=e=>{let t=e.gap??8,n=Math.max(0,e.popupBottom-e.boundaryTop-t),r=e.viewportHeight*Ye,i=Math.floor(Math.min(n,r));return n>=120?Math.min(n,Math.max(120,i)):i},Qe=(e,t=0)=>{let n=e.closest(`main`);if(!n)return null;let r=(e.closest(`.mobile-chat-screen__content`)?.parentElement??n.parentElement?.closest(`main`)??n).querySelector(`:scope > .oc-mobile-detail-navigation`)?.getBoundingClientRect().bottom,i=n.getBoundingClientRect().top;return Math.max(r===void 0?i:Math.max(r,i),t)},$e=(e,t)=>{let n=(0,H.c)(5),[r,i]=V.useState(void 0),a;n[0]!==t||n[1]!==e?(a=()=>{if(!t){i(void 0);return}let n=()=>{let t=e.current?.parentElement;if(!t)return;let n=t.getBoundingClientRect(),r=window.visualViewport,a=r?.offsetTop??0,o=r?.height??window.innerHeight,s=Qe(t,a)??a,c=Xe({composerTop:n.top,composerLeft:n.left,composerWidth:n.width,visibleBottom:a+o,boundaryTop:s,viewportHeight:o});i(e=>e&&e.left===c.left&&e.width===c.width&&e.bottom===c.bottom&&e.maxHeight===c.maxHeight?e:c)};return n(),window.addEventListener(`resize`,n),window.addEventListener(`oc:keyboard-settled`,n),window.visualViewport?.addEventListener(`resize`,n),window.visualViewport?.addEventListener(`scroll`,n),()=>{window.removeEventListener(`resize`,n),window.removeEventListener(`oc:keyboard-settled`,n),window.visualViewport?.removeEventListener(`resize`,n),window.visualViewport?.removeEventListener(`scroll`,n)}},n[0]=t,n[1]=e,n[2]=a):a=n[2];let o;return n[3]===t?o=n[4]:(o=[t],n[3]=t,n[4]=o),V.useLayoutEffect(a,o),t?r:void 0},et=e=>e?e.closest(`.oc-chat-composer-swap-scope`)??e.closest(`main`):null,tt=V.forwardRef((e,t)=>{let n=(0,H.c)(28),{isMobile:r,className:i,style:a,children:o}=e,s=V.useRef(null),[c,l]=V.useState(null),u=$e(s,r),d,f;if(n[0]===r?(d=n[1],f=n[2]):(d=()=>{if(!r){l(null);return}l(et(s.current?.parentElement??null))},f=[r],n[0]=r,n[1]=d,n[2]=f),V.useLayoutEffect(d,f),!r){let e;n[3]===i?e=n[4]:(e=qe(!1,i),n[3]=i,n[4]=e);let r;return n[5]!==o||n[6]!==t||n[7]!==a||n[8]!==e?(r=(0,U.jsx)(`div`,{ref:t,className:e,style:a,children:o}),n[5]=o,n[6]=t,n[7]=a,n[8]=e,n[9]=r):r=n[9],r}let p;n[10]===i?p=n[11]:(p=qe(!0,i),n[10]=i,n[11]=p);let m;n[12]===u?m=n[13]:(m=u?{left:u.left,width:u.width,bottom:u.bottom,maxHeight:u.maxHeight}:{visibility:`hidden`},n[12]=u,n[13]=m);let h;n[14]!==a||n[15]!==m?(h={...a,...m},n[14]=a,n[15]=m,n[16]=h):h=n[16];let g;n[17]!==o||n[18]!==t||n[19]!==p||n[20]!==h?(g=(0,U.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[100]`,children:(0,U.jsx)(`div`,{ref:t,className:p,style:h,children:o})}),n[17]=o,n[18]=t,n[19]=p,n[20]=h,n[21]=g):g=n[21];let _=g,v;n[22]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,U.jsx)(`span`,{ref:s,className:`hidden`,"aria-hidden":!0}),n[22]=v):v=n[22];let y;n[23]!==_||n[24]!==c?(y=c?(0,W.createPortal)(_,c):_,n[23]=_,n[24]=c,n[25]=y):y=n[25];let b;return n[26]===y?b=n[27]:(b=(0,U.jsxs)(U.Fragment,{children:[v,y]}),n[26]=y,n[27]=b),b});tt.displayName=`ComposerAutocompleteLayer`;var nt=()=>{let e=null,t=!1,n=!1;return{pointerDown:(n,r)=>{e={x:n,y:r},t=!1},pointerMove:(n,r)=>{e&&Math.hypot(n-e.x,r-e.y)>6&&(t=!0)},pointerCancel:()=>{e=null,t=!1},pointerUp:r=>{if(!e)return!1;let i=!t;return e=null,t=!1,i?(n=!0,r(),!0):(n=!0,!1)},click:e=>n?(n=!1,!1):(e(),!0)}},rt=V.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSessionSelect:r,onClose:a,style:o,onRowsChange:c},u)=>{let{t:d}=te(),f=Re()??``,p=T(e=>e.currentSessionId),m=oe(e=>e.activeSessions),h=k(e=>e.activeProjectId),g=k(e=>e.projects),_=V.useMemo(()=>g.find(e=>e.id===h)?.path??null,[h,g]),v=V.useMemo(()=>{let e=_||f;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[_,f]),y=Ie(e=>v?e.byRoot[v]:void 0),b=re(e=>e.getVisibleAgents),x=S(e=>e.searchFiles),ee=Le(e,180),C=l(),ne=s(),[ie,D]=V.useState([]),[O,se]=V.useState([]),[A,j]=V.useState(!1),[N,I]=V.useState(0),L=V.useRef(0),[R,de]=V.useState(360),[z,B]=V.useState({}),[fe,H]=V.useState({}),W=V.useRef([]),me=V.useRef([]),he=V.useRef([]),_e=V.useRef(null),ve=V.useRef(null),G=V.useRef(null);G.current||=nt();let K=i(e=>e.isMobile),ye=(e??``).trim(),be=V.useMemo(()=>{if(!v||!y)return[];let e=[y.selectedPath,...y.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r);let e=r.replace(/\\/g,`/`),i=e.split(`/`).filter(Boolean).pop()||e,a=e.startsWith(`${v}/`)?e.slice(v.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return ce(n,ye,{limit:6})},[ye,v,y]),q=V.useMemo(()=>ye.length>0?O:O.slice(0,2),[O,ye.length]),J=V.useMemo(()=>r?le({sessions:m,currentSessionId:p,searchQuery:ye}):[],[m,p,ye,r]),Y=be,X=ie;V.useEffect(()=>{let e=e=>{let t=e.target;!t||!_e.current||_e.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),V.useEffect(()=>{if(!f){D([]);return}let e=(ee??``).trim(),t=E(e);if(!t){D([]);return}let n=!1;j(!0);let r={includeHidden:C,respectGitignore:!ne};return Promise.all([x(f,t,80,{...r,type:`file`}),x(f,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(be.map(e=>e.path));D(M({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||D([])}).finally(()=>{n||j(!1)}),()=>{n=!0}},[f,ee,be,x,C,ne]),V.useEffect(()=>{let t=b().filter(e=>e.mode&&e.mode!==`primary`).map(e=>({name:e.name,description:e.description,mode:e.mode}));se(ae(t,e??``))},[b,e]),V.useEffect(()=>{I(0),B({}),H({})},[X,Y.length,q.length,J.length]),V.useEffect(()=>{L.current=N},[N]),V.useEffect(()=>{W.current[N]?.scrollIntoView({block:`nearest`})},[N]),V.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};me.current.forEach((n,r)=>{if(!n)return;let i=he.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}}),B(e),H(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[X,Y]),V.useEffect(()=>{let e=me.current[N];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&de(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[N]);let Se=w(e=>{t(e)}),Ce=w(e=>{n?.(e)}),we=w(e=>{r?.(e)}),Te=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&G.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&G.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(G.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>G.current?.pointerCancel(),onClick:()=>{G.current?.click(t)},onMouseMove:()=>I(e)}),Ee=e=>{let t=q.length+J.length+Y.length+X.length;if(t===0)return;let n=(e%t+t)%t;if(n<q.length){let e=q[n];e&&Ce(e.name);return}let r=n-q.length;if(r<J.length){let e=J[r];e&&we(e);return}let i=r-J.length,a=i<Y.length?Y[i]:X[i-Y.length];a&&Se(a)};V.useEffect(()=>{ke(c,ve,{rows:xe({agents:q,sessions:J,recentFiles:Y,pathHits:X,untitledSession:d(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:d(`chat.fileMentionAutocomplete.sessionType`)}),highlightedIndex:N})},[c,N,d,q,X,Y,J]);let De=V.useRef(c);De.current=c,V.useEffect(()=>()=>{Ae(De.current,ve)},[]),V.useImperativeHandle(u,()=>({acceptIndex:e=>{Ee(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=q.length+J.length+Y.length+X.length;if(t!==0){if(e===`ArrowDown`){I(e=>(e+1)%t);return}if(e===`ArrowUp`){I(e=>(e-1+t)%t);return}(e===`Enter`||e===`Tab`)&&Ee(L.current)}}}),[X,Y,q,J,a,Se,Ce,we]);let Oe=e=>(0,U.jsx)(F,{name:ge(e),className:`h-3.5 w-3.5 text-current`});return(0,U.jsxs)(tt,{ref:_e,isMobile:K,className:`max-w-[640px] max-h-64`,style:o,children:[(0,U.jsx)(pe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,U.jsxs)(`div`,{className:`pb-2`,children:[q.length>0&&(0,U.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.agents`)}),q.map((e,t)=>{let n=N===t;return(0,U.jsx)(`div`,{ref:e=>{W.current[t]=e},className:P(`flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,Je(K,n),!K&&n&&`text-interactive-selection-foreground`),...Te(t,()=>Ce(e.name)),children:(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`font-semibold truncate`,children:[`@`,e.name]}),e.description&&!K?(0,U.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:e.description}):null]})},`agent-${e.name}`)}),q.length===2&&ye.length===0&&O.length>2&&(0,U.jsx)(`div`,{className:`px-3 py-1 typography-meta text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.searchMoreAgents`)}),J.length>0&&(0,U.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.sessions`)}),J.map((e,t)=>{let n=q.length+t,r=N===n;return(0,U.jsxs)(`div`,{ref:e=>{W.current[n]=e},className:P(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,Je(K,r),!K&&r&&`text-interactive-selection-foreground`),...Te(n,()=>we(e)),children:[(0,U.jsx)(F,{name:`chat-thread`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title||d(`chat.fileMentionAutocomplete.untitledSession`),children:e.title||d(`chat.fileMentionAutocomplete.untitledSession`)}),K?null:(0,U.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.sessionType`)})]},`session-${e.id}`)}),Y.length>0&&(0,U.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.recentFiles`)}),Y.map((e,t)=>{let n=q.length+J.length+t,r=e.relativePath||e.name,i=ue(r,{maxLength:60}),a=N===n,o=z[n]??!1,s=fe[n]??2.6;return(0,U.jsxs)(`div`,{ref:e=>{W.current[n]=e},className:P(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,Je(K,a),!K&&a&&`text-interactive-selection-foreground`),...Te(n,()=>Se(e)),children:[Oe(e),(0,U.jsxs)(`span`,{ref:e=>{me.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${R}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,U.jsx)(`span`,{ref:e=>{he.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,U.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,U.jsx)(`span`,{className:`block truncate`,children:i})]})]},`recent-${e.path}`)}),X.length>0&&(0,U.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.groups.files`)}),X.map((e,t)=>{let n=q.length+J.length+Y.length+t,r=e.relativePath||e.name,i=ue(r,{maxLength:60}),a=N===n,o=z[n]??!1,s=fe[n]??2.6;return(0,U.jsxs)(`div`,{ref:e=>{W.current[n]=e},className:P(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,Je(K,a),!K&&a&&`text-interactive-selection-foreground`),...Te(n,()=>Se(e)),children:[Oe(e),(0,U.jsxs)(`span`,{ref:e=>{me.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${R}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,U.jsx)(`span`,{ref:e=>{he.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,U.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,U.jsx)(`span`,{className:`block truncate`,children:i})]})]},e.path)}),A&&X.length===0?(0,U.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,U.jsx)(F,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!A&&X.length===0&&Y.length===0&&q.length===0&&J.length===0&&(0,U.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.empty`)})]})}),!K&&(0,U.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:d(`chat.autocomplete.keyboardHint`)})]})}),it=new Set([`new`,`fork`,`compact`,`undo`,`redo`,`model`,`goal`]),at=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&it.has(n))},ot=(e,t)=>!e||t({name:e}),st=` `,ct=(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]===st&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},lt=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,ut=P(lt,`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)]`),dt=P(lt,`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)]`),ft=P(lt,`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)]`),pt=P(lt,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),mt=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id),ht=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!o()}},gt=V.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=te(),d=i(e=>e.isMobile),f=T(e=>e.currentSessionId),p=T(e=>!!e.newSessionDraft?.open),m=T(V.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=A(f??``,m??void 0),g=V.useMemo(()=>s??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[s,f,h.length,p]),{hasSession:_,canStartSessionCommand:v,canUseReviewHandoffFlow:y}=V.useMemo(()=>ht(g,d),[g,d]),b=g.hasMessages,[x,S]=V.useState([]),[ee,C]=V.useState(!1),w=se({directory:r}),re=V.useMemo(()=>w.data??[],[w.data]),ie=w.isFetching,ae=ne({directory:r}),oe=V.useMemo(()=>ae.data??[],[ae.data]),[E,D]=V.useState(0),O=V.useRef(0),k=V.useRef(!1),ce=V.useRef([]),j=V.useRef(null),le=V.useRef(!1),M=V.useRef(null),N=V.useRef(!1),ue=V.useRef(null);V.useEffect(()=>{let e=e=>{let t=e.target;!t||!j.current||j.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),V.useEffect(()=>{(async()=>{C(ie);try{let t=re.map((e,t)=>({id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,isSkill:e.source===`skill`,scope:e.scope,reference:e.reference})),n=oe.map((e,t)=>({id:`skill:${e.scope}:${e.source??`opencode`}:${e.name}:${t}`,name:e.name,source:`skill`,description:e.description,isSkill:!0,scope:e.scope})),r=[{id:`openchamber:new`,name:`new`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},..._?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...y?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[],...t,...n],i=!b,a=J(r.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);S(e=>mt(e,a)?e:a)}catch{let t=!b,n=J([{id:`openchamber:new`,name:`new`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},..._?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...y?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(o?.(e)??!0)),e);S(e=>mt(e,n)?e:n)}finally{C(!1)}})()},[e,b,_,v,y,re,ie,oe,u,o]),V.useEffect(()=>{D(0)},[x]),V.useEffect(()=>{O.current=E},[E]),V.useEffect(()=>{ce.current[E]?.scrollIntoView({block:`nearest`})},[E]),V.useEffect(()=>{ke(c,ue,{rows:be(x,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:E})},[x,c,E,u]);let I=V.useRef(c);I.current=c,V.useEffect(()=>()=>{Ae(I.current,ue)},[]),V.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=x[e];r&&t(r,at(r,n))},handleKeyDown:e=>{let r=x.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){k.current=!0,D(e=>(e+1)%r);return}if(e===`ArrowUp`){k.current=!0,D(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(O.current%r+r)%r,i=x[n];i&&t(i,at(i,e===`Enter`))}}}}),[x,n,t]);let L=e=>{let t=me(e);switch(e.name){case`new`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,U.jsx)(F,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,U.jsxs)(tt,{ref:j,isMobile:d,className:`max-w-[450px] max-h-64`,style:a,children:[(0,U.jsx)(pe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:ee?(0,U.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,U.jsx)(F,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,U.jsxs)(`div`,{children:[x.map((e,n)=>{let r=e.isBuiltIn,i=e.isOpenChamber;return(0,U.jsxs)(`div`,{ref:e=>{ce.current[n]=e},className:P(`flex gap-2 px-3 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,Je(d,n===E)),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(M.current={x:e.clientX,y:e.clientY},N.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!M.current)return;let t=e.clientX-M.current.x,n=e.clientY-M.current.y;Math.hypot(t,n)>6&&(N.current=!0)},onPointerUp:n=>{if(n.pointerType!==`touch`)return;let r=N.current;M.current=null,N.current=!1,!r&&(n.preventDefault(),n.stopPropagation(),le.current=!0,t(e,at(e,d)))},onPointerCancel:()=>{M.current=null,N.current=!1},onClick:()=>{if(le.current){le.current=!1;return}t(e,at(e,d))},onMouseMove:()=>{k.current=!1,D(n)},children:[(0,U.jsx)(`div`,{className:P(!d&&`mt-0.5`),children:L(e)}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,e.name]}),e.isSkill?(0,U.jsx)(`span`,{className:ut,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,U.jsx)(`span`,{className:ut,children:u(`chat.commandAutocomplete.badge.command`)}),i?(0,U.jsx)(`span`,{className:pt,children:`OpenChamber`}):r?(0,U.jsx)(`span`,{className:pt,children:u(`chat.commandAutocomplete.badge.system`)}):e.scope?(0,U.jsx)(`span`,{className:e.scope===`project`?ft:dt,children:e.scope}):null,e.agent&&(0,U.jsx)(`span`,{className:pt,children:e.agent})]}),e.description&&!d&&(0,U.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:e.description})]})]},e.id)}),x.length===0&&(0,U.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,U.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});gt.displayName=`CommandAutocomplete`;function _t(e){return(e.description||e.content).replace(/\s+/g,` `).trim().slice(0,120)}var vt=V.forwardRef((e,t)=>{let n=(0,H.c)(62),{searchQuery:r,onSnippetSelect:a,onClose:o,style:s}=e,{t:c}=te(),l=V.useRef(null),u=i(yt),[d,f]=V.useState(0),p=V.useRef(0),m;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=[],n[0]=m):m=n[0];let[h,g]=V.useState(m),_;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(_=[],n[1]=_):_=n[1];let v=V.useRef(_),y=fe(bt),b=fe(xt),x=fe(St),S=fe(Ct),ee=i(wt),C=i(Tt),w,ne;n[2]===b?(w=n[3],ne=n[4]):(w=()=>{b()},ne=[b],n[2]=b,n[3]=w,n[4]=ne),V.useEffect(w,ne);let re,ie;n[5]!==r||n[6]!==y?(re=()=>{let e=r.trim();if(!e.length){let e=[...y].sort(Et);g(e),f(+!!e.length);return}let t=D(y,e,Dt);t.sort(Ot);let n=t.map(kt);g(n),f(+!!n.length)},ie=[r,y],n[5]=r,n[6]=y,n[7]=re,n[8]=ie):(re=n[7],ie=n[8]),V.useEffect(re,ie);let T,ae;n[9]===d?(T=n[10],ae=n[11]):(T=()=>{p.current=d,v.current[d]?.scrollIntoView({block:`nearest`})},ae=[d],n[9]=d,n[10]=T,n[11]=ae),V.useEffect(T,ae);let oe,E;n[12]===o?(oe=n[13],E=n[14]):(E=()=>{let e=e=>{let t=e.target;t&&l.current&&!l.current.contains(t)&&o()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},oe=[o],n[12]=o,n[13]=oe,n[14]=E),V.useEffect(E,oe);let O;n[15]!==a||n[16]!==r?(O=e=>{let t=r.trim(),n=e.aliases.includes(t)?t:e.name;a(e,n)},n[15]=a,n[16]=r,n[17]=O):O=n[17];let k=O,se;n[18]!==o||n[19]!==S||n[20]!==ee||n[21]!==C||n[22]!==x||n[23]!==y?(se=()=>{let e=new Set(y.map(At)),t=`new-snippet`,n=1;for(;e.has(t);)t=`new-snippet-${n++}`;x({name:t,scope:`global`}),S(t),C(`snippets`),ee(!0),o()},n[18]=o,n[19]=S,n[20]=ee,n[21]=C,n[22]=x,n[23]=y,n[24]=se):se=n[24];let A=se,ce,j;n[25]!==k||n[26]!==h||n[27]!==o||n[28]!==A?(ce=()=>({handleKeyDown:e=>{if(e===`Escape`){o();return}let t=h.length+1;if(e===`ArrowDown`){f(e=>(e+1)%t);return}if(e===`ArrowUp`){f(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){if(p.current===0){A();return}let e=h[p.current-1];e&&k(e)}}}),j=[k,h,o,A],n[25]=k,n[26]=h,n[27]=o,n[28]=A,n[29]=ce,n[30]=j):(ce=n[29],j=n[30]),V.useImperativeHandle(t,ce,j);let le;n[31]===Symbol.for(`react.memo_cache_sentinel`)?(le=e=>{v.current[0]=e},n[31]=le):le=n[31];let M;n[32]!==u||n[33]!==d?(M=P(`flex items-center gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,Je(u,d===0)),n[32]=u,n[33]=d,n[34]=M):M=n[34];let N,ue;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>f(0),ue=(0,U.jsx)(F,{name:`add`,className:`h-3.5 w-3.5 text-muted-foreground`}),n[35]=N,n[36]=ue):(N=n[35],ue=n[36]);let I;n[37]===c?I=n[38]:(I=c(`chat.snippetAutocomplete.action.addNew`),n[37]=c,n[38]=I);let L;n[39]===I?L=n[40]:(L=(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:I}),n[39]=I,n[40]=L);let R;n[41]!==A||n[42]!==M||n[43]!==L?(R=(0,U.jsxs)(`div`,{ref:le,className:M,onClick:A,onMouseMove:N,children:[ue,L]}),n[41]=A,n[42]=M,n[43]=L,n[44]=R):R=n[44];let de;n[45]!==k||n[46]!==h||n[47]!==u||n[48]!==d||n[49]!==c?(de=h.length?h.map((e,t)=>(0,U.jsx)(`div`,{ref:e=>{v.current[t+1]=e},className:P(`flex gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,u?`items-center`:`items-start`,Je(u,t+1===d)),onClick:()=>k(e),onMouseMove:()=>f(t+1),children:(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`span`,{className:`font-semibold truncate`,children:[`#`,e.name]}),(0,U.jsx)(`span`,{className:`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0 bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`,children:c(`snippets.source.${e.source}`)})]}),!u&&(0,U.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:_t(e)})]})},`${e.source}:${e.filePath}`)):(0,U.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:c(`chat.snippetAutocomplete.empty`)}),n[45]=k,n[46]=h,n[47]=u,n[48]=d,n[49]=c,n[50]=de):de=n[50];let z;n[51]!==R||n[52]!==de?(z=(0,U.jsxs)(pe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:[R,de]}),n[51]=R,n[52]=de,n[53]=z):z=n[53];let B;n[54]!==u||n[55]!==c?(B=!u&&(0,U.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:c(`chat.snippetAutocomplete.footer`)}),n[54]=u,n[55]=c,n[56]=B):B=n[56];let W;return n[57]!==u||n[58]!==s||n[59]!==z||n[60]!==B?(W=(0,U.jsxs)(tt,{ref:l,isMobile:u,className:`max-w-[450px] max-h-60`,style:s,children:[z,B]}),n[57]=u,n[58]=s,n[59]=z,n[60]=B,n[61]=W):W=n[61],W});vt.displayName=`SnippetAutocomplete`;function yt(e){return e.isMobile}function bt(e){return e.snippets}function xt(e){return e.loadSnippets}function St(e){return e.setSnippetDraft}function Ct(e){return e.setSelectedSnippet}function wt(e){return e.setSettingsDialogOpen}function Tt(e){return e.setSettingsPage}function Et(e,t){return e.source===`project`&&t.source!==`project`?-1:e.source!==`project`&&t.source===`project`?1:e.name.localeCompare(t.name)}function Dt(e){return[e.name,...e.aliases]}function Ot(e,t){return e.score===t.score?e.item.source===`project`&&t.item.source!==`project`?-1:e.item.source!==`project`&&t.item.source===`project`?1:e.item.name.localeCompare(t.item.name):e.score-t.score}function kt(e){return e.item}function At(e){return e.name}var jt=2,Mt=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Nt=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},Pt=e=>Mt(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&Mt(e.branches),Ft=(e,t)=>JSON.stringify([e,t]),It=e=>`version`in e&&e.version===jt&&Mt(e.entries),Lt=e=>{if(!e)return null;try{let t=JSON.parse(e);return Mt(t)?t.version===jt&&Mt(t.entries)?{version:jt,entries:t.entries}:t:null}catch{return null}},Rt=(e,t)=>{try{e.setItem(`oc.gitBranchCache`,JSON.stringify(t))}catch{}},zt=(e,t,n)=>{let r=Nt(e);if(!r||!t)return null;let i;try{i=n.getItem(`oc.gitBranchCache`)}catch{return null}let a=Lt(i);if(!a)return null;if(It(a))return Pt(a.entries[Ft(t,r)])?a.entries[Ft(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=Nt(e);r&&Pt(n)&&(o[Ft(t,r)]=n)}return Rt(n,{version:jt,entries:o}),o[Ft(t,r)]??null},Bt=(e,t,n,r)=>{let i=Nt(e);if(!i||!t||!Pt(n))return;let a=null;try{a=r.getItem(`oc.gitBranchCache`)}catch{return}let o=Lt(a);Rt(r,{version:jt,entries:{...o&&It(o)?o.entries:{},[Ft(t,i)]:n}})},Vt=3e4,Ht=Nt,Ut=(e,t=n())=>c.git.branches(Ht(e),t),Wt=(e,t=n())=>c.git.remotes(Ht(e),t),Gt=async(e,t,n)=>{n.throwIfAborted();let r=f()?.git,i=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):r?await r.getGitBranches(e,{signal:n}):await x(e,{signal:n});return n.throwIfAborted(),i},Kt=async(e,t,n)=>{n.throwIfAborted();let r=f()?.git,i=t?.getRemotes?await t.getRemotes(e,{signal:n}):r?await r.getRemotes(e,{signal:n}):await y(e,{signal:n});return n.throwIfAborted(),i},qt=(e,t,i=n(),a=r())=>{let o=Ht(e),s=t;return{queryKey:Ut(o,i),queryFn:async({signal:e})=>{if(!o)throw Error(`Git branches require a directory`);let t=await Gt(o,s,e);return Bt(o,i,t,a),t},staleTime:Vt,gcTime:1/0,initialData:()=>zt(o,i,a)??void 0,initialDataUpdatedAt:0}},Jt=(e,t,r=n())=>{let i=Ht(e),a=t;return{queryKey:Wt(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return Kt(i,a,e)},staleTime:Vt,gcTime:1/0}},Yt=(e,r,i)=>{let a=(0,H.c)(9),o=i===void 0||i,s=V.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=Ht(e),u=C,l=qt(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)},Xt=(e,r,i)=>{let a=(0,H.c)(9),o=i===void 0||i,s=V.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=Ht(e),u=C,l=Jt(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)},Zt=(e,t,r=d,i=n())=>r.fetchQuery(qt(e,t,i)),Qt=(e,t,r=d,i=n())=>r.fetchQuery({...qt(e,t,i),staleTime:0}),$t=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,en=1e4,tn=6e4,nn=5e3,rn=3e4,an=6e4,on=25,sn=40,cn=2,ln=15e3,un=500,dn=30,fn=20971520,pn=new Map,mn=new Map,hn=new Map,gn=new Map,_n=new Map,vn=(e,t)=>`${t}:${e}`,yn=e=>mn.get(e)??0,bn=e=>{let t=yn(e)+1;return mn.set(e,t),t},xn=e=>{let t=(hn.get(e)??0)+1;return hn.set(e,t),t},Sn=e=>{let t=pn.get(e);if(t)return t;let n=new Set;return pn.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}),Cn=(e,t=dn,n=fn)=>{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},wn=(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},Tn=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,En=(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&&Tn(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&&wn(e.diffStats,t.diffStats))},Dn=(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},On=(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},kn=e=>!e||e.trim().length===0,An=e=>(e||``).trim()===`U`,jn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(An(t)||An(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},Mn=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(An(t)||An(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Nn=e=>kn(e.index)&&kn(e.working_dir),$=p()(h((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&bn(r),n&&bn(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=vn(n,a),s=gn.get(o)??(a===`light`?gn.get(vn(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)>tn,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(En(s.status,u)){c=!0;let r=new Map(t().directories),i=r.get(n)??Q(),s=Dn(i.status,u),l=On(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&&bn(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})();gn.set(o,c);try{return await c}finally{gn.get(o)===c&&gn.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`?jn(e):Mn(e);t!==e&&(l=!0),Nn(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=xn(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 Qt(r,i,void 0,o):await Zt(r,i,void 0,o);if(s!==hn.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($t(i)||console.error(`Failed to fetch git branches:`,i),s!==hn.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>en||!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=Cn(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{bn(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,on);await t().prefetchDiffs(e,n,i,{maxFiles:on})},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=sn}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=Sn(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>un||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=yn(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 ${ln}ms`)),ln)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},y=async()=>{for(;;){if(m!==yn(n))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{u.delete(e)}}},b=Math.min(cn,p.length);if(await Promise.allSettled(Array.from({length:b},()=>y())),p.forEach(e=>u.delete(e)),m!==yn(n))return;let x=new Map(t().directories),S=x.get(n);if(!S)return;let ee=new Map(S.diffCache),C=Date.now();g.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||ee.set(e.path,{...e.diff,fetchedAt:C})});let w=Cn(ee);x.set(n,{...S,diffCache:w}),e({directories:x})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Q();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<nn||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=_n.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)>=nn)&&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>=rn)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=en)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=an)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return _n.set(e,i),i.finally(()=>{_n.get(e)===i&&_n.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Pn=e=>{let t=(0,H.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)},Fn=e=>{let r=(0,H.c)(3),i=V.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],$(a)},In=e=>{let t=(0,H.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)},Ln=e=>{let t=(0,H.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)},Rn=e=>{let t=(0,H.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)},zn={current:new Map},Bn=()=>$(Gn),Vn=e=>{let t=(0,H.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=V.useRef(n),i;return t[1]===e?i=t[2]:(i=t=>{let n=r.current,i=n.size===e.length;if(i)for(let r of e){let e=t.directories.get(r),a=n.get(r);if(!a||(e?.isGitRepo??null)!==a.isGitRepo||(e?.status?.current??null)!==a.branch){i=!1;break}}if(i)return n;let a=new Map;for(let n of e){let e=t.directories.get(n);a.set(n,{isGitRepo:e?.isGitRepo??null,branch:e?.status?.current??null})}return r.current=a,a},t[1]=e,t[2]=i),$(i)},Hn=e=>{let t=(0,H.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)},Un=e=>{let t=(0,H.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)},Wn=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),$(n)};function Gn(e){let t=zn.current,n=t.size===e.directories.size;if(n){for(let[r,i]of e.directories)if(t.get(r)!==(i.status?.current??null)){n=!1;break}}if(n)return t;let r=new Map;for(let[t,n]of e.directories)r.set(t,n.status?.current??null);return zn.current=r,r}var Kn=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)}},qn=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),Jn=e=>e.branchName?qn(e.branchName):e.mode===`existing`?qn(e.existingBranch||e.preferredName||``):qn(e.preferredName||``),Yn=async e=>{let t=await z(e);try{let n=Kn((await R(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=Kn((await de(e)).tracking);if(t?.remote)return t.remote}catch{}return null},Xn=async(e,t)=>{let n=await Yn(e),r=qn(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},Zn=async(e,t,n)=>{let r=Jn(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await Xn(e,r):i&&qn(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:qn(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},Qn=async(e,t,n)=>{let r=await Zn(e.path,t,n);return B(e,r)},$n=`oc:lastWorktreeSourceBranch`,er=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,tr=({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},nr=(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?` `:``}`},rr=(e,t,n)=>{let r=nr(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},ir=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=rr(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}},ar=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))?[...e]:[...e,t]},or=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{tt as A,X as B,Yt as C,ct as D,gt as E,Oe as F,q as H,ke as I,Ae as L,Re as M,Le as N,ot as O,Ie as P,Te as R,Qt as S,vt as T,ye as U,Se as V,In as _,$n as a,$ as b,Qn as c,Bn as d,Rn as f,Hn as g,Un as h,rr as i,Je as j,rt as k,Yn as l,Wn as m,ar as n,tr as o,Fn as p,ir as r,er as s,or as t,Zn as u,Vn as v,Xt as w,Ln as x,Pn as y,Ce as z};