tarsk 0.4.30 → 0.4.31

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 (76) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/public/assets/{account-view-wqPOnMfW.js → account-view-Cdp8xegU.js} +1 -1
  3. package/dist/public/assets/alert-dialog-DAJFcjdR.js +1 -0
  4. package/dist/public/assets/api-BYFUablr.js +1 -0
  5. package/dist/public/assets/{browser-tab-BjqSmZHm.js → browser-tab-Ban23pgA.js} +1 -1
  6. package/dist/public/assets/chat-input-container-Bc7nCdKX.js +21 -0
  7. package/dist/public/assets/{context-menu-XD6khGRr.js → context-menu-D93N09Jw.js} +1 -1
  8. package/dist/public/assets/conversation-history-view-qm_qW0aD.js +1 -0
  9. package/dist/public/assets/{dialogs-config-BXDglGdB.js → dialogs-config-VlhyoYms.js} +2 -2
  10. package/dist/public/assets/diff-view-DUmzPmed.js +3 -0
  11. package/dist/public/assets/explorer-tab-view-Bbboiq-d.js +2 -0
  12. package/dist/public/assets/explorer-tree-CX03Vh31.js +1 -0
  13. package/dist/public/assets/{explorer-view-CL_9lhkq.js → explorer-view-CMcJFEtT.js} +1 -1
  14. package/dist/public/assets/history-view-Cub-F9g6.js +1 -0
  15. package/dist/public/assets/index-C-dv630o.css +1 -0
  16. package/dist/public/assets/index-DaJT5K7g.js +29 -0
  17. package/dist/public/assets/{markdown-renderer-CPSKOcqK.js → markdown-renderer-BPXg5AUu.js} +3 -3
  18. package/dist/public/assets/mcp-server-card-BCZmpcVY.js +1 -0
  19. package/dist/public/assets/onboarding-BPUo1aJX.js +1 -0
  20. package/dist/public/assets/onboarding-dialog-vqz8baom.js +1 -0
  21. package/dist/public/assets/page-toolbar-CU9dGLvm.js +1 -0
  22. package/dist/public/assets/{project-settings-view-CRRJPGNL.js → project-settings-view-BAs5RYWR.js} +1 -1
  23. package/dist/public/assets/providers-list-view-67A5O5vd.js +1 -0
  24. package/dist/public/assets/radio-group-CRwVSJCp.js +1 -0
  25. package/dist/public/assets/react-vendor-CtZx3FWA.js +22 -0
  26. package/dist/public/assets/{resizable-BLhzHL_f.js → resizable-AKojmHeo.js} +1 -1
  27. package/dist/public/assets/{run-stop-button-CIuDOHFg.js → run-stop-button-DYoC8i6e.js} +2 -2
  28. package/dist/public/assets/{settings-general-view-7Y0c9534.js → settings-general-view-mu1Qq8cl.js} +1 -1
  29. package/dist/public/assets/{settings-instructions-view-B-uTQrNZ.js → settings-instructions-view-DQRSZId7.js} +1 -1
  30. package/dist/public/assets/{settings-mcp-servers-view-nAMQQWHb.js → settings-mcp-servers-view-BqJMRVZJ.js} +4 -4
  31. package/dist/public/assets/{settings-models-skeleton-CffyGIvJ.js → settings-models-skeleton-qdDMv5hS.js} +1 -1
  32. package/dist/public/assets/settings-models-view-DSrdZZfF.js +1 -0
  33. package/dist/public/assets/settings-rules-view-Dt_lfKVv.js +8 -0
  34. package/dist/public/assets/{settings-skills-view-DBX7obT7.js → settings-skills-view-Djrk38ol.js} +2 -2
  35. package/dist/public/assets/{settings-slash-commands-view-BoT1nCir.js → settings-slash-commands-view-Cm5cy2My.js} +1 -1
  36. package/dist/public/assets/settings-subagents-view-CsGwbSvQ.js +2 -0
  37. package/dist/public/assets/{settings-view-CS-RnV6J.js → settings-view-DuTfugUO.js} +2 -2
  38. package/dist/public/assets/{side-panel-container-B33_hnhc.js → side-panel-container-Cg99BH1l.js} +2 -2
  39. package/dist/public/assets/skeleton-B1fuNMHm.js +1 -0
  40. package/dist/public/assets/{standard-list-item-BLTOBGFa.js → standard-list-item-0m99qNoa.js} +1 -1
  41. package/dist/public/assets/{store-B9rEO6q-.js → store-DUqJt-K-.js} +1 -1
  42. package/dist/public/assets/{tab-context-BUUT3x3d.js → tab-context-BYpxvaoz.js} +1 -1
  43. package/dist/public/assets/tabs-ywSKq3qp.js +1 -0
  44. package/dist/public/assets/{terminal-panel-BCHLDUbD.js → terminal-panel-C9XWZHaD.js} +2 -2
  45. package/dist/public/assets/textarea-DuuNwegn.js +1 -0
  46. package/dist/public/assets/todos-view-CRzNrsfP.js +1 -0
  47. package/dist/public/assets/use-font-size-D2A0_bAi.js +1 -0
  48. package/dist/public/assets/{use-toast-C5s-Xnwi.js → use-toast-BF5WtiOJ.js} +1 -1
  49. package/dist/public/assets/{utils-CDrGT12s.js → utils-CheqpoJ4.js} +1 -1
  50. package/dist/public/index.html +21 -21
  51. package/package.json +1 -1
  52. package/dist/public/assets/alert-dialog-Dj0hDlZC.js +0 -1
  53. package/dist/public/assets/api-RbLAI1bg.js +0 -1
  54. package/dist/public/assets/chat-input-container-BNOl7YtC.js +0 -21
  55. package/dist/public/assets/conversation-history-view-BRSNoBYn.js +0 -1
  56. package/dist/public/assets/diff-view-DiNlWcSj.js +0 -3
  57. package/dist/public/assets/explorer-tab-view-DbMBihAH.js +0 -2
  58. package/dist/public/assets/explorer-tree-D0P-HUYS.js +0 -1
  59. package/dist/public/assets/history-view-i7fGKCkc.js +0 -1
  60. package/dist/public/assets/index-BeLCtY82.css +0 -1
  61. package/dist/public/assets/index-CZZ6Jb9i.js +0 -29
  62. package/dist/public/assets/mcp-server-card-DFATg_Ie.js +0 -1
  63. package/dist/public/assets/onboarding-5CTkrfwe.js +0 -1
  64. package/dist/public/assets/onboarding-dialog-gcZ9aKKp.js +0 -1
  65. package/dist/public/assets/page-toolbar-CbwENcML.js +0 -1
  66. package/dist/public/assets/providers-list-view-D3CIB4ou.js +0 -1
  67. package/dist/public/assets/radio-group-qCcnwXV3.js +0 -1
  68. package/dist/public/assets/react-vendor-Bpg1hd5i.js +0 -22
  69. package/dist/public/assets/settings-models-view-CMZh5LlR.js +0 -1
  70. package/dist/public/assets/settings-rules-view-BaNccq1v.js +0 -8
  71. package/dist/public/assets/settings-subagents-view-Cy87X2bs.js +0 -2
  72. package/dist/public/assets/skeleton-n47_ST9G.js +0 -1
  73. package/dist/public/assets/tabs--5y6mYhG.js +0 -1
  74. package/dist/public/assets/textarea-CwXpBxom.js +0 -1
  75. package/dist/public/assets/todos-view-k0k8R9NT.js +0 -1
  76. package/dist/public/assets/use-font-size-BJl84s49.js +0 -1
@@ -0,0 +1 @@
1
+ import{t as e}from"./index-DaJT5K7g.js";export{e as TodosView};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{b as t,p as n,ya as r}from"./dialogs-config-VlhyoYms.js";var i=e(r(),1),a=75,o=125,s=100;function c(e){document.documentElement.style.fontSize=`${e}%`}function l(){let[e,r]=(0,i.useState)(()=>n(s));(0,i.useEffect)(()=>{c(e)},[e]);function l(e){let n=Math.max(a,Math.min(o,Math.round(e)));r(n),t(n)}return{scale:e,updateScale:l,resetScale:(0,i.useCallback)(()=>{l(s)},[]),min:a,max:o,default:s}}function u(){c(n(s))}export{l as n,u as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{_a as t,ha as n}from"./dialogs-config-BXDglGdB.js";var r=n(),i=e(t(),1),a=1,o=1e6,s=0;function c(){return s=(s+1)%(2**53-1),s.toString()}var l=new Map,u=e=>{if(l.has(e))return;let t=setTimeout(()=>{l.delete(e),m({type:`REMOVE_TOAST`,toastId:e})},o);l.set(e,t)},d=(e,t)=>{switch(t.type){case`ADD_TOAST`:return{...e,toasts:[t.toast,...e.toasts].slice(0,a)};case`UPDATE_TOAST`:return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case`DISMISS_TOAST`:{let{toastId:n}=t;return n?u(n):e.toasts.forEach(e=>{u(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===n||n===void 0?{...e,open:!1}:e)}}case`REMOVE_TOAST`:return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},f=[],p={toasts:[]};function m(e){p=d(p,e),f.forEach(e=>{e(p)})}function h({...e}){let t=c(),n=e=>m({type:`UPDATE_TOAST`,toast:{...e,id:t}}),r=()=>m({type:`DISMISS_TOAST`,toastId:t});return m({type:`ADD_TOAST`,toast:{...e,id:t,open:!0,onOpenChange:e=>{e||r()}}}),{id:t,dismiss:r,update:n}}function g(){let e=(0,r.c)(5),[t,n]=i.useState(p),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>(f.push(n),()=>{let e=f.indexOf(n);e>-1&&f.splice(e,1)}),e[0]=a):a=e[0];let o;e[1]===t?o=e[2]:(o=[t],e[1]=t,e[2]=o),i.useEffect(a,o);let s;return e[3]===t?s=e[4]:(s={...t,toast:h,dismiss:_},e[3]=t,e[4]=s),s}function _(e){return m({type:`DISMISS_TOAST`,toastId:e})}export{g as n,h as t};
1
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{_a as t,ya as n}from"./dialogs-config-VlhyoYms.js";var r=t(),i=e(n(),1),a=1,o=1e6,s=0;function c(){return s=(s+1)%(2**53-1),s.toString()}var l=new Map,u=e=>{if(l.has(e))return;let t=setTimeout(()=>{l.delete(e),m({type:`REMOVE_TOAST`,toastId:e})},o);l.set(e,t)},d=(e,t)=>{switch(t.type){case`ADD_TOAST`:return{...e,toasts:[t.toast,...e.toasts].slice(0,a)};case`UPDATE_TOAST`:return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case`DISMISS_TOAST`:{let{toastId:n}=t;return n?u(n):e.toasts.forEach(e=>{u(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===n||n===void 0?{...e,open:!1}:e)}}case`REMOVE_TOAST`:return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},f=[],p={toasts:[]};function m(e){p=d(p,e),f.forEach(e=>{e(p)})}function h({...e}){let t=c(),n=e=>m({type:`UPDATE_TOAST`,toast:{...e,id:t}}),r=()=>m({type:`DISMISS_TOAST`,toastId:t});return m({type:`ADD_TOAST`,toast:{...e,id:t,open:!0,onOpenChange:e=>{e||r()}}}),{id:t,dismiss:r,update:n}}function g(){let e=(0,r.c)(5),[t,n]=i.useState(p),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>(f.push(n),()=>{let e=f.indexOf(n);e>-1&&f.splice(e,1)}),e[0]=a):a=e[0];let o;e[1]===t?o=e[2]:(o=[t],e[1]=t,e[2]=o),i.useEffect(a,o);let s;return e[3]===t?s=e[4]:(s={...t,toast:h,dismiss:_},e[3]=t,e[4]=s),s}function _(e){return m({type:`DISMISS_TOAST`,toastId:e})}export{g as n,h as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{_a as t}from"./dialogs-config-BXDglGdB.js";var n=e(t(),1),r=(e,t,n,r,i,a,o,s)=>{let c=document.documentElement,l=[`light`,`dark`];function u(t){(Array.isArray(e)?e:[e]).forEach(e=>{let n=e===`class`,r=n&&a?i.map(e=>a[e]||e):i;n?(c.classList.remove(...r),c.classList.add(a&&a[t]?a[t]:t)):c.setAttribute(e,t)}),d(t)}function d(e){s&&l.includes(e)&&(c.style.colorScheme=e)}function f(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}if(r)u(r);else try{let e=localStorage.getItem(t)||n;u(o&&e===`system`?f():e)}catch{}},i=[`light`,`dark`],a=`(prefers-color-scheme: dark)`,o=typeof window>`u`,s=n.createContext(void 0),c={setTheme:e=>{},themes:[]},l=()=>n.useContext(s)??c,u=e=>n.useContext(s)?n.createElement(n.Fragment,null,e.children):n.createElement(f,{...e}),d=[`light`,`dark`],f=({forcedTheme:e,disableTransitionOnChange:t=!1,enableSystem:r=!0,enableColorScheme:o=!0,storageKey:c=`theme`,themes:l=d,defaultTheme:u=r?`system`:`light`,attribute:f=`data-theme`,value:_,children:v,nonce:y,scriptProps:b})=>{let[x,S]=n.useState(()=>m(c,u)),[C,w]=n.useState(()=>x===`system`?g():x),T=_?Object.values(_):l,E=n.useCallback(e=>{let n=e;if(!n)return;e===`system`&&r&&(n=g());let a=_?_[n]:n,s=t?h(y):null,c=document.documentElement,l=e=>{e===`class`?(c.classList.remove(...T),a&&c.classList.add(a)):e.startsWith(`data-`)&&(a?c.setAttribute(e,a):c.removeAttribute(e))};if(Array.isArray(f)?f.forEach(l):l(f),o){let e=i.includes(u)?u:null,t=i.includes(n)?n:e;c.style.colorScheme=t}s?.()},[y]),D=n.useCallback(e=>{let t=typeof e==`function`?e(x):e;S(t);try{localStorage.setItem(c,t)}catch{}},[x]),O=n.useCallback(t=>{w(g(t)),x===`system`&&r&&!e&&E(`system`)},[x,e]);n.useEffect(()=>{let e=window.matchMedia(a);return e.addListener(O),O(e),()=>e.removeListener(O)},[O]),n.useEffect(()=>{let e=e=>{e.key===c&&(e.newValue?S(e.newValue):D(u))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[D]),n.useEffect(()=>{E(e??x)},[e,x]);let k=n.useMemo(()=>({theme:x,setTheme:D,forcedTheme:e,resolvedTheme:x===`system`?C:x,themes:r?[...l,`system`]:l,systemTheme:r?C:void 0}),[x,D,e,C,r,l]);return n.createElement(s.Provider,{value:k},n.createElement(p,{forcedTheme:e,storageKey:c,attribute:f,enableSystem:r,enableColorScheme:o,defaultTheme:u,value:_,themes:l,nonce:y,scriptProps:b}),v)},p=n.memo(({forcedTheme:e,storageKey:t,attribute:i,enableSystem:a,enableColorScheme:o,defaultTheme:s,value:c,themes:l,nonce:u,scriptProps:d})=>{let f=JSON.stringify([i,t,s,e,l,c,a,o]).slice(1,-1);return n.createElement(`script`,{...d,suppressHydrationWarning:!0,nonce:typeof window>`u`?u:``,dangerouslySetInnerHTML:{__html:`(${r.toString()})(${f})`}})}),m=(e,t)=>{if(o)return;let n;try{n=localStorage.getItem(e)||void 0}catch{}return n||t},h=e=>{let t=document.createElement(`style`);return e&&t.setAttribute(`nonce`,e),t.appendChild(document.createTextNode(`*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`)),document.head.appendChild(t),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(t)},1)}},g=e=>(e||=window.matchMedia(a),e.matches?`dark`:`light`);export{l as n,u as t};
1
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{ya as t}from"./dialogs-config-VlhyoYms.js";var n=e(t(),1),r=(e,t,n,r,i,a,o,s)=>{let c=document.documentElement,l=[`light`,`dark`];function u(t){(Array.isArray(e)?e:[e]).forEach(e=>{let n=e===`class`,r=n&&a?i.map(e=>a[e]||e):i;n?(c.classList.remove(...r),c.classList.add(a&&a[t]?a[t]:t)):c.setAttribute(e,t)}),d(t)}function d(e){s&&l.includes(e)&&(c.style.colorScheme=e)}function f(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}if(r)u(r);else try{let e=localStorage.getItem(t)||n;u(o&&e===`system`?f():e)}catch{}},i=[`light`,`dark`],a=`(prefers-color-scheme: dark)`,o=typeof window>`u`,s=n.createContext(void 0),c={setTheme:e=>{},themes:[]},l=()=>n.useContext(s)??c,u=e=>n.useContext(s)?n.createElement(n.Fragment,null,e.children):n.createElement(f,{...e}),d=[`light`,`dark`],f=({forcedTheme:e,disableTransitionOnChange:t=!1,enableSystem:r=!0,enableColorScheme:o=!0,storageKey:c=`theme`,themes:l=d,defaultTheme:u=r?`system`:`light`,attribute:f=`data-theme`,value:_,children:v,nonce:y,scriptProps:b})=>{let[x,S]=n.useState(()=>m(c,u)),[C,w]=n.useState(()=>x===`system`?g():x),T=_?Object.values(_):l,E=n.useCallback(e=>{let n=e;if(!n)return;e===`system`&&r&&(n=g());let a=_?_[n]:n,s=t?h(y):null,c=document.documentElement,l=e=>{e===`class`?(c.classList.remove(...T),a&&c.classList.add(a)):e.startsWith(`data-`)&&(a?c.setAttribute(e,a):c.removeAttribute(e))};if(Array.isArray(f)?f.forEach(l):l(f),o){let e=i.includes(u)?u:null,t=i.includes(n)?n:e;c.style.colorScheme=t}s?.()},[y]),D=n.useCallback(e=>{let t=typeof e==`function`?e(x):e;S(t);try{localStorage.setItem(c,t)}catch{}},[x]),O=n.useCallback(t=>{w(g(t)),x===`system`&&r&&!e&&E(`system`)},[x,e]);n.useEffect(()=>{let e=window.matchMedia(a);return e.addListener(O),O(e),()=>e.removeListener(O)},[O]),n.useEffect(()=>{let e=e=>{e.key===c&&(e.newValue?S(e.newValue):D(u))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[D]),n.useEffect(()=>{E(e??x)},[e,x]);let k=n.useMemo(()=>({theme:x,setTheme:D,forcedTheme:e,resolvedTheme:x===`system`?C:x,themes:r?[...l,`system`]:l,systemTheme:r?C:void 0}),[x,D,e,C,r,l]);return n.createElement(s.Provider,{value:k},n.createElement(p,{forcedTheme:e,storageKey:c,attribute:f,enableSystem:r,enableColorScheme:o,defaultTheme:u,value:_,themes:l,nonce:y,scriptProps:b}),v)},p=n.memo(({forcedTheme:e,storageKey:t,attribute:i,enableSystem:a,enableColorScheme:o,defaultTheme:s,value:c,themes:l,nonce:u,scriptProps:d})=>{let f=JSON.stringify([i,t,s,e,l,c,a,o]).slice(1,-1);return n.createElement(`script`,{...d,suppressHydrationWarning:!0,nonce:typeof window>`u`?u:``,dangerouslySetInnerHTML:{__html:`(${r.toString()})(${f})`}})}),m=(e,t)=>{if(o)return;let n;try{n=localStorage.getItem(e)||void 0}catch{}return n||t},h=e=>{let t=document.createElement(`style`);return e&&t.setAttribute(`nonce`,e),t.appendChild(document.createTextNode(`*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`)),document.head.appendChild(t),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(t)},1)}},g=e=>(e||=window.matchMedia(a),e.matches?`dark`:`light`);export{l as n,u as t};
@@ -19,31 +19,31 @@
19
19
  <meta name="apple-mobile-web-app-title" content="Tarsk" />
20
20
 
21
21
  <title>Tarsk</title>
22
- <script type="module" crossorigin src="/assets/index-CZZ6Jb9i.js"></script>
22
+ <script type="module" crossorigin src="/assets/index-DaJT5K7g.js"></script>
23
23
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-B1FJdls4.js">
24
24
  <link rel="modulepreload" crossorigin href="/assets/monaco-BGyhgQtx.js">
25
- <link rel="modulepreload" crossorigin href="/assets/dialogs-config-BXDglGdB.js">
26
- <link rel="modulepreload" crossorigin href="/assets/history-view-i7fGKCkc.js">
27
- <link rel="modulepreload" crossorigin href="/assets/onboarding-5CTkrfwe.js">
28
- <link rel="modulepreload" crossorigin href="/assets/react-vendor-Bpg1hd5i.js">
29
- <link rel="modulepreload" crossorigin href="/assets/alert-dialog-Dj0hDlZC.js">
30
- <link rel="modulepreload" crossorigin href="/assets/use-toast-C5s-Xnwi.js">
31
- <link rel="modulepreload" crossorigin href="/assets/store-B9rEO6q-.js">
32
- <link rel="modulepreload" crossorigin href="/assets/tab-context-BUUT3x3d.js">
25
+ <link rel="modulepreload" crossorigin href="/assets/dialogs-config-VlhyoYms.js">
26
+ <link rel="modulepreload" crossorigin href="/assets/history-view-Cub-F9g6.js">
27
+ <link rel="modulepreload" crossorigin href="/assets/onboarding-BPUo1aJX.js">
28
+ <link rel="modulepreload" crossorigin href="/assets/react-vendor-CtZx3FWA.js">
29
+ <link rel="modulepreload" crossorigin href="/assets/alert-dialog-DAJFcjdR.js">
30
+ <link rel="modulepreload" crossorigin href="/assets/use-toast-BF5WtiOJ.js">
31
+ <link rel="modulepreload" crossorigin href="/assets/store-DUqJt-K-.js">
32
+ <link rel="modulepreload" crossorigin href="/assets/tab-context-BYpxvaoz.js">
33
33
  <link rel="modulepreload" crossorigin href="/assets/whisper-wasm-C_Ot631g.js">
34
- <link rel="modulepreload" crossorigin href="/assets/utils-CDrGT12s.js">
35
- <link rel="modulepreload" crossorigin href="/assets/chat-input-container-BNOl7YtC.js">
36
- <link rel="modulepreload" crossorigin href="/assets/markdown-renderer-CPSKOcqK.js">
37
- <link rel="modulepreload" crossorigin href="/assets/page-toolbar-CbwENcML.js">
38
- <link rel="modulepreload" crossorigin href="/assets/run-stop-button-CIuDOHFg.js">
39
- <link rel="modulepreload" crossorigin href="/assets/side-panel-container-B33_hnhc.js">
40
- <link rel="modulepreload" crossorigin href="/assets/resizable-BLhzHL_f.js">
41
- <link rel="modulepreload" crossorigin href="/assets/standard-list-item-BLTOBGFa.js">
42
- <link rel="modulepreload" crossorigin href="/assets/tabs--5y6mYhG.js">
43
- <link rel="modulepreload" crossorigin href="/assets/textarea-CwXpBxom.js">
44
- <link rel="modulepreload" crossorigin href="/assets/use-font-size-BJl84s49.js">
34
+ <link rel="modulepreload" crossorigin href="/assets/utils-CheqpoJ4.js">
35
+ <link rel="modulepreload" crossorigin href="/assets/chat-input-container-Bc7nCdKX.js">
36
+ <link rel="modulepreload" crossorigin href="/assets/markdown-renderer-BPXg5AUu.js">
37
+ <link rel="modulepreload" crossorigin href="/assets/page-toolbar-CU9dGLvm.js">
38
+ <link rel="modulepreload" crossorigin href="/assets/run-stop-button-DYoC8i6e.js">
39
+ <link rel="modulepreload" crossorigin href="/assets/side-panel-container-Cg99BH1l.js">
40
+ <link rel="modulepreload" crossorigin href="/assets/resizable-AKojmHeo.js">
41
+ <link rel="modulepreload" crossorigin href="/assets/standard-list-item-0m99qNoa.js">
42
+ <link rel="modulepreload" crossorigin href="/assets/tabs-ywSKq3qp.js">
43
+ <link rel="modulepreload" crossorigin href="/assets/textarea-DuuNwegn.js">
44
+ <link rel="modulepreload" crossorigin href="/assets/use-font-size-D2A0_bAi.js">
45
45
  <link rel="stylesheet" crossorigin href="/assets/monaco-Br_kD0ds.css">
46
- <link rel="stylesheet" crossorigin href="/assets/index-BeLCtY82.css">
46
+ <link rel="stylesheet" crossorigin href="/assets/index-C-dv630o.css">
47
47
  </head>
48
48
  <body class="font-sans antialiased">
49
49
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tarsk",
3
- "version": "0.4.30",
3
+ "version": "0.4.31",
4
4
  "description": "CLI for Tarsk - Project Threads Manager",
5
5
  "keywords": [
6
6
  "cli",
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Er as t,Nr as n,Tr as r,_a as i,ha as a}from"./dialogs-config-BXDglGdB.js";import{_t as o,dt as s,ft as c,gt as l,ht as u,mt as d,pt as f,ut as p}from"./react-vendor-Bpg1hd5i.js";var m=a(),h=e(i(),1),g=n(),_=l,v=u,y=h.forwardRef((e,n)=>{let r=(0,m.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,g.jsx)(d,{className:o,...a,ref:n}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});y.displayName=d.displayName;var b=h.forwardRef((e,n)=>{let r=(0,m.c)(10),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,g.jsx)(y,{}),r[3]=o):o=r[3];let s;r[4]===i?s=r[5]:(s=t(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,i),r[4]=i,r[5]=s);let l;return r[6]!==a||r[7]!==n||r[8]!==s?(l=(0,g.jsxs)(v,{children:[o,(0,g.jsx)(c,{ref:n,className:s,...a})]}),r[6]=a,r[7]=n,r[8]=s,r[9]=l):l=r[9],l});b.displayName=c.displayName;var x=e=>{let n=(0,m.c)(8),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=t(`flex flex-col space-y-2 text-center sm:text-left`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o};x.displayName=`AlertDialogHeader`;var S=e=>{let n=(0,m.c)(8),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=t(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o};S.displayName=`AlertDialogFooter`;var C=h.forwardRef((e,n)=>{let r=(0,m.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let s;r[3]===i?s=r[4]:(s=t(`text-lg font-semibold`,i),r[3]=i,r[4]=s);let c;return r[5]!==a||r[6]!==n||r[7]!==s?(c=(0,g.jsx)(o,{ref:n,className:s,...a}),r[5]=a,r[6]=n,r[7]=s,r[8]=c):c=r[8],c});C.displayName=o.displayName;var w=h.forwardRef((e,n)=>{let r=(0,m.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`text-sm text-muted-foreground`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,g.jsx)(f,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});w.displayName=f.displayName;var T=h.forwardRef((e,n)=>{let i=(0,m.c)(9),a,o;i[0]===e?(a=i[1],o=i[2]):({className:a,...o}=e,i[0]=e,i[1]=a,i[2]=o);let s;i[3]===a?s=i[4]:(s=t(r(),a),i[3]=a,i[4]=s);let c;return i[5]!==o||i[6]!==n||i[7]!==s?(c=(0,g.jsx)(p,{ref:n,className:s,...o}),i[5]=o,i[6]=n,i[7]=s,i[8]=c):c=i[8],c});T.displayName=p.displayName;var E=h.forwardRef((e,n)=>{let i=(0,m.c)(9),a,o;i[0]===e?(a=i[1],o=i[2]):({className:a,...o}=e,i[0]=e,i[1]=a,i[2]=o);let c;i[3]===a?c=i[4]:(c=t(r({variant:`outline`}),`mt-2 sm:mt-0`,a),i[3]=a,i[4]=c);let l;return i[5]!==o||i[6]!==n||i[7]!==c?(l=(0,g.jsx)(s,{ref:n,className:c,...o}),i[5]=o,i[6]=n,i[7]=c,i[8]=l):l=i[8],l});E.displayName=s.displayName;export{w as a,C as c,b as i,T as n,S as o,E as r,x as s,_ as t};
@@ -1 +0,0 @@
1
- import{An as e,Fn as t,In as n,Mn as r,Nn as i,Pn as a,jn as o}from"./dialogs-config-BXDglGdB.js";async function s(e,t){return r(`api/threads/${o(e)}/explorer?path=${encodeURIComponent(t)}`)}async function c(e,t){return r(`api/threads/${o(e)}/ai-file?path=${encodeURIComponent(t)}`)}async function l(e,t,r){return n(`api/threads/${o(e)}/ai-file`,{path:t,content:r})}async function u(t,n){return e(`api/threads/${o(t)}/explorer?path=${encodeURIComponent(n)}`)}async function d(e,t,n){return a(`api/threads/${o(e)}/explorer`,{path:t,newName:n})}async function f(e,n,r){return t(`api/threads/${o(e)}/explorer/file`,{dirPath:n,name:r})}function p(e,t){return`${i()}/api/threads/${o(e)}/explorer/media?path=${encodeURIComponent(t)}`}async function m(e,n,r){return t(`api/threads/${o(e)}/explorer/folder`,{dirPath:n,name:r})}export{p as a,l as c,c as i,m as n,s as o,u as r,d as s,f as t};
@@ -1,21 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$i as t,A as n,Ci as r,Di as i,Er as a,Gn as o,Hi as s,Ii as c,Jn as l,Kn as u,Lr as d,Lt as f,N as p,Nn as m,Nr as h,Nt as g,On as _,Pi as v,Pt as y,Qi as b,Ri as x,Rr as S,Rt as C,T as w,Ti as T,Un as E,Ur as D,Vi as O,Wn as k,Wr as A,Wt as j,Yr as M,Zr as N,_a as P,at as F,bi as ee,bn as I,ca as L,ci as R,ct as te,d as ne,da as re,fi as ie,gi as z,gn as B,h as ae,ha as V,ia as H,ki as U,kn as W,lt as G,mn as K,na as q,nn as oe,nt as se,ot as ce,qn as le,qr as ue,ra as de,ri as fe,sa as pe,si as me,ta as he,ut as ge,wi as _e,wr as J,xn as ve,zt as ye}from"./dialogs-config-BXDglGdB.js";import{$ as be,Ct as xe,G as Se,H as Ce,J as we,K as Te,Q as Ee,U as De,X as Oe,Z as ke,at as Ae,ct as je,et as Me,it as Ne,nt as Pe,ot as Fe,q as Ie,rt as Le,st as Re,tt as ze}from"./react-vendor-Bpg1hd5i.js";import{a as Be,l as Ve,s as He,t as Y,u as Ue}from"./store-B9rEO6q-.js";import{c as We,s as Ge,u as Ke}from"./history-view-i7fGKCkc.js";import{n as qe,t as Je}from"./use-toast-C5s-Xnwi.js";import{a as Ye,c as Xe,i as Ze,o as Qe,s as $e,t as et}from"./alert-dialog-Dj0hDlZC.js";import{n as tt}from"./tab-context-BUUT3x3d.js";import{s as nt}from"./onboarding-5CTkrfwe.js";import{i as rt,n as it,r as at,t as ot}from"./whisper-wasm-C_Ot631g.js";import{n as st}from"./utils-CDrGT12s.js";var X=V(),Z=e(P(),1),Q=h();function ct(e){let t=(0,X.c)(30),{node:n,level:r,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l,forceOpenIds:u}=e,d=!!(n.children&&n.children.length>0),f,p,m;if(t[0]!==a||t[1]!==u||t[2]!==d||t[3]!==r||t[4]!==n||t[5]!==l||t[6]!==c||t[7]!==i){f=u?.has(n.id)||(c[n.id]??a);let e;t[11]!==n.id||t[12]!==l?(e=()=>l(n.id),t[11]=n.id,t[12]=l,t[13]=e):e=t[13];let o=e;p=`min-w-0`,m=i(n,{isOpen:f,level:r,toggle:o,hasChildren:d}),t[0]=a,t[1]=u,t[2]=d,t[3]=r,t[4]=n,t[5]=l,t[6]=c,t[7]=i,t[8]=f,t[9]=p,t[10]=m}else f=t[8],p=t[9],m=t[10];let h;t[14]!==s||t[15]!==a||t[16]!==u||t[17]!==d||t[18]!==o||t[19]!==f||t[20]!==r||t[21]!==n.children||t[22]!==l||t[23]!==c||t[24]!==i?(h=d&&f&&(0,Q.jsx)(`div`,{style:{paddingLeft:o},className:s,children:n.children.map(e=>(0,Q.jsx)(ct,{node:e,level:r+1,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l,forceOpenIds:u},e.id))}),t[14]=s,t[15]=a,t[16]=u,t[17]=d,t[18]=o,t[19]=f,t[20]=r,t[21]=n.children,t[22]=l,t[23]=c,t[24]=i,t[25]=h):h=t[25];let g;return t[26]!==p||t[27]!==m||t[28]!==h?(g=(0,Q.jsxs)(`div`,{className:p,children:[m,h]}),t[26]=p,t[27]=m,t[28]=h,t[29]=g):g=t[29],g}function lt(e){let t=(0,X.c)(27),{nodes:n,renderNode:r,resetKey:i,defaultOpen:o,forceOpenIds:s,indent:c,childContainerClassName:l,className:u}=e,d=o===void 0?!1:o,f=c===void 0?16:c,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p={},t[0]=p):p=t[0];let[m,h]=(0,Z.useState)(p),[g,_]=(0,Z.useState)(i);i!==g&&(_(i),h({}));let v;t[1]===s?v=t[2]:(v=s?new Set(s):void 0,t[1]=s,t[2]=v);let y=v,b;t[3]===d?b=t[4]:(b=e=>{h(t=>({...t,[e]:!(t[e]??d)}))},t[3]=d,t[4]=b);let x=b,S;t[5]===u?S=t[6]:(S=a(`min-w-0`,u),t[5]=u,t[6]=S);let C;if(t[7]!==l||t[8]!==d||t[9]!==y||t[10]!==x||t[11]!==f||t[12]!==n||t[13]!==m||t[14]!==r){let e;t[16]!==l||t[17]!==d||t[18]!==y||t[19]!==x||t[20]!==f||t[21]!==m||t[22]!==r?(e=e=>(0,Q.jsx)(ct,{node:e,level:0,renderNode:r,defaultOpen:d,indent:f,childContainerClassName:l,openState:m,onToggle:x,forceOpenIds:y},e.id),t[16]=l,t[17]=d,t[18]=y,t[19]=x,t[20]=f,t[21]=m,t[22]=r,t[23]=e):e=t[23],C=n.map(e),t[7]=l,t[8]=d,t[9]=y,t[10]=x,t[11]=f,t[12]=n,t[13]=m,t[14]=r,t[15]=C}else C=t[15];let w;return t[24]!==S||t[25]!==C?(w=(0,Q.jsx)(`div`,{className:S,children:C}),t[24]=S,t[25]=C,t[26]=w):w=t[26],w}var ut=Re,dt=je,ft=Z.forwardRef((e,t)=>{let n=(0,X.c)(13),r,i,o,s;n[0]===e?(r=n[1],i=n[2],o=n[3],s=n[4]):({className:r,align:o,sideOffset:s,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o,n[4]=s);let c=o===void 0?`center`:o,l=s===void 0?4:s,u;n[5]===r?u=n[6]:(u=a(`z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[5]=r,n[6]=u);let d;return n[7]!==c||n[8]!==i||n[9]!==t||n[10]!==l||n[11]!==u?(d=(0,Q.jsx)(Fe,{children:(0,Q.jsx)(Ae,{ref:t,align:c,sideOffset:l,className:u,...i})}),n[7]=c,n[8]=i,n[9]=t,n[10]=l,n[11]=u,n[12]=d):d=n[12],d});ft.displayName=Ae.displayName;var pt=(0,Z.createContext)({todos:[],setTodos:()=>{}});function mt(e){let t=(0,X.c)(10),{children:n,threadId:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=[],t[0]=i):i=t[0];let[a,o]=(0,Z.useState)(i),s=(0,Z.useRef)(-1),c;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=(e,t)=>{t>=s.current&&(s.current=t,o(e))},t[1]=c):c=t[1];let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{s.current=-1,o([])},t[2]=u):u=t[2];let d;t[3]===r?d=t[4]:(d=[r],t[3]=r,t[4]=d),(0,Z.useEffect)(u,d);let f;t[5]===a?f=t[6]:(f={todos:a,setTodos:l},t[5]=a,t[6]=f);let p;return t[7]!==n||t[8]!==f?(p=(0,Q.jsx)(pt.Provider,{value:f,children:n}),t[7]=n,t[8]=f,t[9]=p):p=t[9],p}function ht(e){let t=[e.result,e.content],n=[];for(let e of t)if(typeof e==`string`)n.push(e);else if(Array.isArray(e))for(let t of e)typeof t==`object`&&t&&`text`in t&&typeof t.text==`string`&&n.push(t.text);for(let e of n){let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);if(e&&Array.isArray(e.todos))return e.todos}catch(e){console.error(`Failed to parse todo JSON:`,e)}}return null}function gt(e){let t=(0,X.c)(5),{todos:n,sequence:r}=e,{setTodos:i}=(0,Z.useContext)(pt),a,o;return t[0]!==r||t[1]!==i||t[2]!==n?(a=()=>{i(n,r)},o=[n,i,r],t[0]=r,t[1]=i,t[2]=n,t[3]=a,t[4]=o):(a=t[3],o=t[4]),(0,Z.useEffect)(a,o),null}var _t=new Map,vt=new Map;function yt(e){return _t.get(e)}function bt(e,t){let n=vt.get(e);return n||(n=new Set,vt.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&vt.delete(e)}}function xt(e){let t=vt.get(e);if(t)for(let e of t)e()}function St(e,t){return async function(n,r){let i=await fetch(e+`/api/browser-js/execute-tool`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threadId:t,toolName:n,params:r})});if(!i.ok){let e=await i.text();try{let t=JSON.parse(e).error||{};e=t.details||t.message||e}catch{}return{text:null,error:`Tool `+n+` failed: `+e}}let a=await i.json();return{text:a.content&&a.content[0]?a.content[0].text:null,error:null}}}function Ct(e,t,n){if(_t.has(e))return;_t.set(e,{status:`running`}),xt(e);let r=m();(async()=>{try{let i=St(r,n),a=Object.getPrototypeOf(async function(){}).constructor,o=await new a(`callTool`,t)(i),s=o===void 0?null:o;_t.set(e,{status:`success`,result:s}),xt(e),await I(e,s)}catch(t){let n=t instanceof Error?t.stack||t.message:String(t);_t.set(e,{status:`error`,error:n}),xt(e);try{await I(e,{error:n})}catch(e){console.error(`[browser-js-executor] failed to submit error result`,e)}}})()}function wt({initialValue:e}={}){let{state:t,dispatch:r}=Be(),[i,a]=(0,Z.useState)(()=>{let n=t.selectedThreadId;return n&&t.chatInputDrafts[n]?t.chatInputDrafts[n]:e??``}),[o,s]=(0,Z.useState)(-1),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(0),f=(0,Z.useRef)(i);(0,Z.useEffect)(()=>{f.current=i},[i]);let p=(0,Z.useRef)(t.chatInputDrafts);(0,Z.useEffect)(()=>{p.current=t.chatInputDrafts},[t.chatInputDrafts]);let m=(0,Z.useRef)(!0);(0,Z.useEffect)(()=>(m.current=!0,()=>{m.current=!1}),[]);let[h,v]=(0,Z.useState)([]),[y,b]=(0,Z.useState)(()=>(t.selectedThreadId?t.projectModelSelections[t.selectedThreadId]:void 0)??null),x=(0,Z.useRef)(y?.id??``),S=(0,Z.useRef)(y?.provider??``),C=(0,Z.useRef)(null),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)([]),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),[P,ee]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)([]),[R,ne]=(0,Z.useState)(null),[re,ie]=(0,Z.useState)([]),[z,B]=(0,Z.useState)(!1),[ae,V]=(0,Z.useState)(``),[H,U]=(0,Z.useState)(0),[W,G]=(0,Z.useState)([]),[K,q]=(0,Z.useState)([]),[oe,se]=(0,Z.useState)(!1),[le,ue]=(0,Z.useState)(``),de=(0,Z.useRef)(null),fe=(0,Z.useRef)(null),pe=(0,Z.useRef)(null),me=(0,Z.useRef)(null),he=(0,Z.useRef)(null),ge=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{x.current=y?.id??``,S.current=y?.provider??``},[y?.id,y?.provider]);let _e=(0,Z.useCallback)((e,n)=>{b(e);let i=t.selectedThreadId;if(!i||(r({type:Y.SetProjectModel,threadId:i,model:e}),n?.persist===!1))return;let a=`${i}:${e.provider??``}:${e.id}`;C.current!==a&&(C.current=a,console.log(`[useChatInputState] Persisting model to thread:`,{threadId:i,model:{id:e.id,provider:e.provider}}),_(i,{model:e.id,modelProvider:e.provider}).then(()=>{C.current===a&&(C.current=null),console.log(`[useChatInputState] Model persisted successfully`)}).catch(e=>{C.current===a&&(C.current=null),console.error(`Failed to save model to thread:`,e)}))},[t.selectedThreadId,r]);(0,Z.useEffect)(()=>{(async()=>{let e=t.selectedProjectId?t.projects.find(e=>e.projectId===t.selectedProjectId)?.threads.find(e=>e.threadId===t.selectedThreadId):void 0,n=t.selectedThreadId?t.projectModelSelections[t.selectedThreadId]:void 0,r=e?.model??n?.id??null,i=e?.modelProvider??n?.provider??null;console.log(`[useChatInputState] Loading models for thread:`,{threadId:t.selectedThreadId,projectId:t.selectedProjectId,currentThread:e?{model:e.model,modelProvider:e.modelProvider}:void 0,storedModel:n?{id:n.id,provider:n.provider}:void 0,savedModelId:r,savedModelProvider:i});try{let e=await ce(),t=Object.values(e).flat();if(t.length===0){v([]),b(null);return}v(t);let n=r&&i?t.find(e=>e.id===r&&e.provider===i)??null:null,a=t[0],o=n??a,s=!n&&!!(r||i),c=x.current===o.id&&S.current===o.provider;console.log(`[useChatInputState] Model selection decision:`,{matchedSavedModel:n?{id:n.id}:null,fallbackModel:{id:a.id},modelToSelect:{id:o.id},shouldPersistFallback:s,hasSameSelection:c,currentSelected:{id:x.current,provider:S.current}}),c||_e(o,{persist:s})}catch(e){console.error(`Failed to load enabled models:`,e)}})()},[t.selectedThreadId,t.selectedProjectId,t.projects,_e]);let J=(0,Z.useRef)(_e);(0,Z.useEffect)(()=>{J.current=_e},[_e]),(0,Z.useEffect)(()=>{t.configUpdatedAt!==0&&(async()=>{try{let e=await ce(),t=Object.values(e).flat();if(t.length>0){v(t);let e=x.current,n=S.current;t.some(t=>t.id===e&&t.provider===n)||J.current(t[0],{persist:!0})}}catch(e){console.error(`Failed to reload enabled models:`,e)}})()},[t.configUpdatedAt]),(0,Z.useEffect)(()=>{!P||I.length>0||(async()=>{try{let e=await F(),t=Object.values(e).flat();t.length>0&&(L(t),ne(e=>e??t[0]))}catch(e){console.error(`Failed to load image models:`,e)}})()},[P,I.length]);let[ve,ye]=(0,Z.useState)(t.selectedThreadId);return(0,Z.useEffect)(()=>{if(t.selectedThreadId!==ve){ve&&f.current.trim()&&p.current[ve]!==f.current&&r({type:Y.SetChatInputDraft,threadId:ve,draft:f.current});let e=!1;return queueMicrotask(()=>{e||!m.current||(ye(t.selectedThreadId),a(t.selectedThreadId?p.current[t.selectedThreadId]??``:``),ie([]),B(!1),G([]),q([]),se(!1),j(!1),ee(!1),N(!1))}),()=>{e=!0}}},[t.selectedThreadId,ve]),(0,Z.useEffect)(()=>{t.selectedThreadId&&g(t.selectedThreadId).then(({commands:e,skills:t})=>{console.log(`Loaded slash commands:`,e,`skills:`,t),G(e),q(t)}).catch(e=>console.error(`Failed to load slash commands and skills:`,e))},[t.selectedThreadId]),(0,Z.useEffect)(()=>{t.focusChatInput&&t.selectedThreadId&&!t.isStreaming&&(fe.current?.focus(),r({type:Y.ClearFocusChatInput}))},[t.focusChatInput,t.selectedThreadId,t.isStreaming,r]),(0,Z.useEffect)(()=>{let e=t.selectedThreadId;return()=>{e&&f.current.trim()&&p.current[e]!==f.current&&r({type:Y.SetChatInputDraft,threadId:e,draft:f.current})}},[t.selectedThreadId,r]),(0,Z.useEffect)(()=>{let e=e=>{pe.current&&!pe.current.contains(e.target)&&T(!1),me.current&&!me.current.contains(e.target)&&D(!1)};if(w||E)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[w,E]),{message:i,setMessage:a,historyIndex:o,setHistoryIndex:s,draftMessage:c,setDraftMessage:l,cursorPosition:u,setCursorPosition:d,availableModels:h,setAvailableModels:v,selectedModel:y,setSelectedModel:_e,selectedModelIdRef:x,showModelMenu:w,setShowModelMenu:T,showPlusMenu:E,setShowPlusMenu:D,attachments:O,setAttachments:k,planMode:A,setPlanMode:j,ralphMode:M,setRalphMode:N,imageMode:P,setImageMode:ee,availableImageModels:I,setAvailableImageModels:L,selectedImageModel:R,setSelectedImageModel:ne,allFiles:re,setAllFiles:ie,showSuggestions:z,setShowSuggestions:B,suggestionQuery:ae,setSuggestionQuery:V,selectedIndex:H,setSelectedIndex:U,slashCommands:W,setSlashCommands:G,skills:K,setSkills:q,showCommandSuggestions:oe,setShowCommandSuggestions:se,commandQuery:le,setCommandQuery:ue,fileInputRef:de,textareaRef:fe,modelMenuRef:pe,plusMenuRef:me,suggestionsRef:he,commandSuggestionsRef:ge,handleNewChat:async()=>{if(t.selectedThreadId)try{let e=await n(t.selectedThreadId);r({type:Y.ClearMessages}),console.log(`New conversation started:`,e);let i=await te(t.selectedThreadId);r({type:Y.SetMessages,messages:i.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},state:t,dispatch:r}}var Tt=e=>{ne(e)};function Et(e){let t=(0,X.c)(102),{message:n,setMessage:r,attachments:i,selectedModel:a,onSend:o,isStreaming:s,selectedThreadId:c,isListening:l,stopListening:u,resetTranscript:d,dispatch:p,historyIndex:m,setHistoryIndex:h,draftMessage:g,setDraftMessage:_,cursorPosition:v,setCursorPosition:y,showSuggestions:b,setShowSuggestions:x,suggestionQuery:S,setSuggestionQuery:C,allFiles:w,setAllFiles:T,selectedIndex:E,setSelectedIndex:D,showCommandSuggestions:O,setShowCommandSuggestions:k,commandQuery:A,setCommandQuery:j,slashCommands:M,skills:N,textareaRef:P,setAttachments:F,planMode:ee,setPlanMode:I,ralphMode:L,setRalphMode:R,imageMode:te,setImageMode:ne,selectedImageModel:re}=e,ie;t[0]!==i||t[1]!==p||t[2]!==te||t[3]!==l||t[4]!==s||t[5]!==n||t[6]!==o||t[7]!==ee||t[8]!==L||t[9]!==d||t[10]!==re||t[11]!==a||t[12]!==c||t[13]!==F||t[14]!==_||t[15]!==h||t[16]!==r||t[17]!==u||t[18]!==P?(ie=()=>{if(!n.trim()&&i.length===0||!c)return;let e=te?re:a;e&&(l&&(u(),d()),s?p({type:Y.EnqueueChatMessage,message:{id:`queued-${Date.now()}`,threadId:c,message:n,model:e.id,attachments:i,provider:e.provider,planMode:ee,imageMode:te,ralphMode:L}}):o(n,e.id,i,e.provider,ee,te,L),Tt(n),r(``),F([]),h(-1),_(``),c&&p({type:Y.ClearChatInputDraft,threadId:c}),P.current&&(P.current.style.height=`auto`))},t[0]=i,t[1]=p,t[2]=te,t[3]=l,t[4]=s,t[5]=n,t[6]=o,t[7]=ee,t[8]=L,t[9]=d,t[10]=re,t[11]=a,t[12]=c,t[13]=F,t[14]=_,t[15]=h,t[16]=r,t[17]=u,t[18]=P,t[19]=ie):ie=t[19];let z=ie,B;t[20]!==v||t[21]!==n||t[22]!==r||t[23]!==x||t[24]!==S||t[25]!==P?(B=e=>{let t=n.substring(0,v-S.length-1);r(`${t}${e} ${n.substring(v)}`),x(!1),setTimeout(()=>{if(P.current){P.current.focus();let n=t.length+e.length+1;P.current.setSelectionRange(n,n)}},0)},t[20]=v,t[21]=n,t[22]=r,t[23]=x,t[24]=S,t[25]=P,t[26]=B):B=t[26];let V=B,H;t[27]!==A||t[28]!==v||t[29]!==n||t[30]!==ne||t[31]!==r||t[32]!==I||t[33]!==R||t[34]!==k||t[35]!==P?(H=e=>{let t=n.substring(0,v-A.length-1),i=n.substring(v);r(`${t}${e.content}${i}`),k(!1),setTimeout(()=>{if(P.current){P.current.focus();let n=t.length+e.content.length;P.current.setSelectionRange(n,n)}},0),e.metadata.mode===`plan`?(I(!0),R(!1),ne(!1)):e.metadata.mode===`ralph`&&(R(!0),I(!1),ne(!1))},t[27]=A,t[28]=v,t[29]=n,t[30]=ne,t[31]=r,t[32]=I,t[33]=R,t[34]=k,t[35]=P,t[36]=H):H=t[36];let U=H,W;t[37]!==A||t[38]!==v||t[39]!==n||t[40]!==r||t[41]!==k||t[42]!==P?(W=e=>{let t=n.substring(0,v-A.length-1),i=n.substring(v),a=e.name.includes(` `)?`/"${e.name}"`:`/${e.name}`;r(`${t}${a}${i}`),k(!1),setTimeout(()=>{if(P.current){P.current.focus();let e=t.length+a.length;P.current.setSelectionRange(e,e)}},0)},t[37]=A,t[38]=v,t[39]=n,t[40]=r,t[41]=k,t[42]=P,t[43]=W):W=t[43];let G=W,K,q,oe,se;if(t[44]!==w||t[45]!==A||t[46]!==g||t[47]!==z||t[48]!==m||t[49]!==U||t[50]!==V||t[51]!==G||t[52]!==n||t[53]!==E||t[54]!==c||t[55]!==T||t[56]!==j||t[57]!==y||t[58]!==_||t[59]!==h||t[60]!==r||t[61]!==D||t[62]!==k||t[63]!==x||t[64]!==C||t[65]!==O||t[66]!==b||t[67]!==N||t[68]!==M||t[69]!==S){oe=e=>{if(O){if(e.key===`ArrowDown`){e.preventDefault(),D((E+1)%K.length);return}if(e.key===`ArrowUp`){e.preventDefault(),D((E-1+K.length)%K.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=K[E];t&&(t.type===`command`?U(t.data):G(t.data));return}if(e.key===`Escape`){k(!1);return}}if(b){let t=q.length>0;if(e.key===`ArrowDown`&&t){e.preventDefault(),D((E+1)%q.length);return}if(e.key===`ArrowUp`&&t){e.preventDefault(),D((E-1+q.length)%q.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),q[E]&&V(q[E]);return}if(e.key===`Escape`){x(!1);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),z();return}let t=ae();t.length!==0&&(e.key===`ArrowUp`?(e.preventDefault(),m===-1?(_(n),h(t.length-1),r(t[t.length-1])):m>0&&(h(m-1),r(t[m-1]))):e.key===`ArrowDown`&&(e.preventDefault(),m>0?(h(m-1),r(t[m-1])):m===0&&(h(-1),r(g))))};let e;t[74]!==w||t[75]!==c||t[76]!==T||t[77]!==j||t[78]!==y||t[79]!==r||t[80]!==D||t[81]!==k||t[82]!==x||t[83]!==C?(e=e=>{let t=e.target.value,n=e.target.selectionStart;r(t),y(n);let i=t.substring(0,n),a=i.lastIndexOf(`/`);if(a!==-1){let e=a>0?i[a-1]:``;if(a===0||/\s/.test(e)){let e=i.substring(a+1);e.includes(` `)?k(!1):(j(e),k(!0),x(!1),D(0))}else k(!1)}else{k(!1);let e=i.lastIndexOf(`#`);if(e!==-1){let t=e>0?i[e-1]:``;if(e===0||/\s/.test(t)){let t=i.substring(e+1);t.includes(` `)?x(!1):(C(t),x(!0),D(0),w.length===0&&c&&f(c).then(e=>{T(e)}).catch(kt))}else x(!1)}else x(!1)}let o=e.target;o.style.height=`auto`,o.style.height=`${Math.min(o.scrollHeight,160)}px`},t[74]=w,t[75]=c,t[76]=T,t[77]=j,t[78]=y,t[79]=r,t[80]=D,t[81]=k,t[82]=x,t[83]=C,t[84]=e):e=t[84],se=e;let i;if(t[85]!==A||t[86]!==N||t[87]!==M){let e;t[89]===A?e=t[90]:(e=e=>e.name.toLowerCase().includes(A.toLowerCase()),t[89]=A,t[90]=e);let n=M.filter(e),r;t[91]===A?r=t[92]:(r=e=>e.name.toLowerCase().includes(A.toLowerCase()),t[91]=A,t[92]=r);let a=N.filter(r);i=[...n.map(Ot),...a.map(Dt)],t[85]=A,t[86]=N,t[87]=M,t[88]=i}else i=t[88];K=i.slice(0,10),q=b?w.filter(e=>e.toLowerCase().includes(S.toLowerCase())).slice(0,10):[],t[44]=w,t[45]=A,t[46]=g,t[47]=z,t[48]=m,t[49]=U,t[50]=V,t[51]=G,t[52]=n,t[53]=E,t[54]=c,t[55]=T,t[56]=j,t[57]=y,t[58]=_,t[59]=h,t[60]=r,t[61]=D,t[62]=k,t[63]=x,t[64]=C,t[65]=O,t[66]=b,t[67]=N,t[68]=M,t[69]=S,t[70]=K,t[71]=q,t[72]=oe,t[73]=se}else K=t[70],q=t[71],oe=t[72],se=t[73];let ce;return t[93]!==K||t[94]!==q||t[95]!==oe||t[96]!==z||t[97]!==se||t[98]!==U||t[99]!==V||t[100]!==G?(ce={handleSend:z,handleKeyDown:oe,handleTextareaInput:se,insertFileReference:V,insertCommand:U,insertSkill:G,allSuggestions:K,fileSuggestions:q},t[93]=K,t[94]=q,t[95]=oe,t[96]=z,t[97]=se,t[98]=U,t[99]=V,t[100]=G,t[101]=ce):ce=t[101],ce}function Dt(e){return{type:`skill`,data:e}}function Ot(e){return{type:`command`,data:e}}function kt(e){return console.error(`Failed to fetch files:`,e)}function At(e){let t=(0,X.c)(21),{visible:n,commands:r,skills:i,query:o,selectedIndex:s,onSelectCommand:c,onSelectSkill:l,onMouseEnterSuggestion:u,containerRef:f}=e;if(!n)return null;let p;if(t[0]!==r||t[1]!==o||t[2]!==i){let e;t[4]===o?e=t[5]:(e=e=>e.name.toLowerCase().includes(o.toLowerCase()),t[4]=o,t[5]=e);let n=r.filter(e),a;t[6]===o?a=t[7]:(a=e=>e.name.toLowerCase().includes(o.toLowerCase()),t[6]=o,t[7]=a);let s=i.filter(a);p=[...n.map(Mt),...s.map(jt)].slice(0,10),t[0]=r,t[1]=o,t[2]=i,t[3]=p}else p=t[3];let m=p,h;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Q.jsx)(ue,{className:`h-3 w-3`}),t[8]=h):h=t[8];let g=o&&` matching "${o}"`,_;t[9]===g?_=t[10]:(_=(0,Q.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2`,children:[h,`Commands & Skills`,g]}),t[9]=g,t[10]=_);let v;t[11]!==m||t[12]!==u||t[13]!==c||t[14]!==l||t[15]!==s?(v=m.length>0?m.map((e,t)=>{let n=t===s;if(e.type===`command`){let r=e.data;return(0,Q.jsxs)(`button`,{type:`button`,className:a(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>c(r),onMouseEnter:()=>u(t),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ue,{className:`h-3 w-3 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),r.metadata.argumentHint&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.metadata.argumentHint}),r.scope===`project`&&(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),r.metadata.description&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.metadata.description})]},`cmd-${r.name}`)}else{let r=e.data;return(0,Q.jsxs)(`button`,{type:`button`,className:a(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>l(r),onMouseEnter:()=>u(t),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(d,{className:`h-3 w-3 text-amber-500`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] rounded-full bg-amber-500/10 px-1.5 py-0.5 text-amber-700 dark:text-amber-400`,children:`skill`}),r.scope===`project`&&(0,Q.jsx)(`span`,{className:`text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.description})]},`skill-${r.name}`)}}):(0,Q.jsxs)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:[`No commands or skills found.`,(0,Q.jsx)(`br`,{}),(0,Q.jsxs)(`span`,{className:`text-[10px]`,children:[`Create commands in `,(0,Q.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/commands/`}),` or skills in `,(0,Q.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/skills/`})]})]}),t[11]=m,t[12]=u,t[13]=c,t[14]=l,t[15]=s,t[16]=v):v=t[16];let y;return t[17]!==f||t[18]!==_||t[19]!==v?(y=(0,Q.jsxs)(`div`,{ref:f,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[_,v]}),t[17]=f,t[18]=_,t[19]=v,t[20]=y):y=t[20],y}function jt(e){return{type:`skill`,data:e}}function Mt(e){return{type:`command`,data:e}}function Nt(e){return e.startsWith(`image/`)}function Pt(e){let t=(0,X.c)(7),{attachments:n,onRemove:r}=e;if(n.length===0)return null;let i;if(t[0]!==n||t[1]!==r){let e;t[3]===r?e=t[4]:(e=(e,t)=>(0,Q.jsx)(`div`,{className:`group relative flex items-center gap-1 rounded-md bg-muted text-xs text-muted-foreground`,children:Nt(e.mimeType)?(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:e.fileName,className:`h-16 w-16 rounded-md object-cover`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full bg-foreground text-background opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,Q.jsx)(S,{className:`h-2.5 w-2.5`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[(0,Q.jsx)(ie,{className:`h-3 w-3`}),e.fileName,(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`ml-1 hover:text-foreground`,children:[(0,Q.jsx)(S,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]})},t),t[3]=r,t[4]=e),i=n.map(e),t[0]=n,t[1]=r,t[2]=i}else i=t[2];let a;return t[5]===i?a=t[6]:(a=(0,Q.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:i}),t[5]=i,t[6]=a),a}function Ft(e,t){let n=e.target.files;if(!n||n.length===0)return;let r=Array.from(n),i=r.length,a=Array.from({length:i}),o=0;e.target.value=``,r.forEach((e,n)=>{let r=new FileReader;r.onload=()=>{let s=r.result.split(`,`)[1];a[n]={fileName:e.name,content:s,mimeType:e.type||`application/octet-stream`},o+=1,o===i&&t(a)},r.readAsDataURL(e)})}function It(e){let t=(0,X.c)(16),{showSuggestions:n,fileSuggestions:r,suggestionQuery:i,selectedIndex:o,onSelectFile:c,onMouseEnterSuggestion:l,containerRef:u}=e;if(!n||r.length===0)return null;let d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(fe,{className:`h-3 w-3`}),t[0]=d):d=t[0];let f;t[1]===i?f=t[2]:(f=(0,Q.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2`,children:[d,`Files matching "`,i,`"`]}),t[1]=i,t[2]=f);let p;if(t[3]!==r||t[4]!==l||t[5]!==c||t[6]!==o){let e;t[8]!==l||t[9]!==c||t[10]!==o?(e=(e,t)=>{let n=e.split(`/`).pop()??e;return(0,Q.jsxs)(`button`,{type:`button`,className:a(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-left transition-colors`,t===o?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>c(e),onMouseEnter:()=>l(t),children:[e.endsWith(`.ts`)||e.endsWith(`.tsx`)||e.endsWith(`.js`)||e.endsWith(`.jsx`)?(0,Q.jsx)(s,{className:`h-4 w-4 text-blue-500`}):(0,Q.jsx)(O,{className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,Q.jsx)(`span`,{className:`truncate font-medium`,children:n}),(0,Q.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground opacity-70`,children:e})]})]},e)},t[8]=l,t[9]=c,t[10]=o,t[11]=e):e=t[11],p=r.map(e),t[3]=r,t[4]=l,t[5]=c,t[6]=o,t[7]=p}else p=t[7];let m;return t[12]!==u||t[13]!==f||t[14]!==p?(m=(0,Q.jsxs)(`div`,{ref:u,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[f,p]}),t[12]=u,t[13]=f,t[14]=p,t[15]=m):m=t[15],m}function Lt(e){let t=(0,X.c)(3),{provider:n}=e;if(!n)return null;let r=`https://models.tarsk.io/svg/${n}.svg`,i=`${n} logo`,a;return t[0]!==r||t[1]!==i?(a=(0,Q.jsx)(`img`,{src:r,alt:i,className:`h-3.5 w-3.5 flex-shrink-0 dark:invert`,onError:Rt}),t[0]=r,t[1]=i,t[2]=a):a=t[2],a}function Rt(e){e.currentTarget.style.visibility=`hidden`}function zt(e){let t=(0,X.c)(26),{availableModels:n,selectedModel:r,onModelSelect:i}=e,[a,o]=Z.useState(!1),s=Z.useRef(null),c,l;t[0]===a?(c=t[1],l=t[2]):(c=()=>{let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};if(a)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},l=[a],t[0]=a,t[1]=c,t[2]=l),Z.useEffect(c,l);let u;t[3]===i?u=t[4]:(u=e=>{i(e),o(!1)},t[3]=i,t[4]=u);let d=u,f;t[5]===a?f=t[6]:(f=()=>o(!a),t[5]=a,t[6]=f);let p=r?.provider,m;t[7]===p?m=t[8]:(m=(0,Q.jsx)(Lt,{provider:p}),t[7]=p,t[8]=m);let h;t[9]===r?h=t[10]:(h=r?nt(r.id):`No model`,t[9]=r,t[10]=h);let g;t[11]===h?g=t[12]:(g=(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:h}),t[11]=h,t[12]=g);let _;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(de,{className:`h-3 w-3`}),t[13]=_):_=t[13];let v;t[14]!==f||t[15]!==m||t[16]!==g?(v=(0,Q.jsxs)(J,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:f,children:[m,g,_]}),t[14]=f,t[15]=m,t[16]=g,t[17]=v):v=t[17];let y;t[18]!==n||t[19]!==d||t[20]!==r?.id||t[21]!==a?(y=a&&(0,Q.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-80 max-h-80 overflow-y-auto rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:Object.entries(n.reduce(Bt,{})).map(e=>{let[t,n]=e;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:[(0,Q.jsx)(Lt,{provider:t}),t]}),n.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:`flex w-full items-center whitespace-nowrap rounded-md px-3 py-1.5 pl-8 text-sm text-popover-foreground hover:bg-accent ${e.id===r?.id?`bg-accent font-medium`:``}`,onClick:()=>d(e),children:nt(e.id)},e.id))]},t)})}),t[18]=n,t[19]=d,t[20]=r?.id,t[21]=a,t[22]=y):y=t[22];let b;return t[23]!==v||t[24]!==y?(b=(0,Q.jsxs)(`div`,{className:`relative`,ref:s,children:[v,y]}),t[23]=v,t[24]=y,t[25]=b):b=t[25],b}function Bt(e,t){let n=t.provider??`Other`;return e[n]||(e[n]=[]),e[n].push(t),e}var Vt=[{value:`build`,label:`Build`,icon:U},{value:`plan`,label:`Plan`,icon:T},{value:`image`,label:`Image`,icon:i},{value:`ralph`,label:`Ralph`,icon:me}];function Ht(e,t,n){return n?`ralph`:e?`plan`:t?`image`:`build`}function Ut(e){let t=(0,X.c)(31),{planMode:n,imageMode:r,ralphMode:i,setPlanMode:a,setImageMode:o,setRalphMode:s}=e,[c,l]=Z.useState(!1),u=Z.useRef(null),d;t[0]!==r||t[1]!==n||t[2]!==i?(d=Ht(n,r,i),t[0]=r,t[1]=n,t[2]=i,t[3]=d):d=t[3];let f=d,p;t[4]===f?p=t[5]:(p=Vt.find(e=>e.value===f),t[4]=f,t[5]=p);let m=p,h=m.icon,g,_;t[6]===c?(g=t[7],_=t[8]):(g=()=>{let e=function(e){u.current&&!u.current.contains(e.target)&&l(!1)};if(c)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},_=[c],t[6]=c,t[7]=g,t[8]=_),Z.useEffect(g,_);let v;t[9]!==o||t[10]!==a||t[11]!==s?(v=function(e){a(e===`plan`),o(e===`image`),s(e===`ralph`),l(!1)},t[9]=o,t[10]=a,t[11]=s,t[12]=v):v=t[12];let y=v,b;t[13]===c?b=t[14]:(b=()=>l(!c),t[13]=c,t[14]=b);let x;t[15]===h?x=t[16]:(x=(0,Q.jsx)(h,{className:`h-3.5 w-3.5`}),t[15]=h,t[16]=x);let S;t[17]===m.label?S=t[18]:(S=(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:m.label}),t[17]=m.label,t[18]=S);let C;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(de,{className:`h-3 w-3`}),t[19]=C):C=t[19];let w;t[20]!==b||t[21]!==x||t[22]!==S?(w=(0,Q.jsxs)(J,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:b,children:[x,S,C]}),t[20]=b,t[21]=x,t[22]=S,t[23]=w):w=t[23];let T;t[24]!==f||t[25]!==c||t[26]!==y?(T=c&&(0,Q.jsx)(`div`,{className:`absolute bottom-full right-0 mb-1 w-40 rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:Vt.map(e=>{let t=e.icon,n=e.value===f;return(0,Q.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:()=>y(e.value),children:[(0,Q.jsx)(t,{className:`h-3.5 w-3.5`}),e.label,n&&(0,Q.jsx)(pe,{className:`ml-auto h-3.5 w-3.5`})]},e.value)})}),t[24]=f,t[25]=c,t[26]=y,t[27]=T):T=t[27];let E;return t[28]!==w||t[29]!==T?(E=(0,Q.jsxs)(`div`,{className:`relative`,ref:u,children:[w,T]}),t[28]=w,t[29]=T,t[30]=E):E=t[30],E}function Wt(e){let t=(0,X.c)(17),{onFileAttach:n}=e,[r,i]=Z.useState(!1),a=Z.useRef(null),o,s;t[0]===r?(o=t[1],s=t[2]):(o=()=>{let e=e=>{a.current&&!a.current.contains(e.target)&&i(!1)};if(r)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},s=[r],t[0]=r,t[1]=o,t[2]=s),Z.useEffect(o,s);let c;t[3]===n?c=t[4]:(c=function(){n(),i(!1)},t[3]=n,t[4]=c);let l=c,u;t[5]===r?u=t[6]:(u=()=>i(!r),t[5]=r,t[6]=u);let d,f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(R,{}),f=(0,Q.jsx)(`span`,{className:`sr-only`,children:`More options`}),t[7]=d,t[8]=f):(d=t[7],f=t[8]);let p;t[9]===u?p=t[10]:(p=(0,Q.jsxs)(J,{variant:`action`,size:`icon-sm`,onClick:u,children:[d,f]}),t[9]=u,t[10]=p);let m;t[11]!==l||t[12]!==r?(m=r&&(0,Q.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-48 rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:(0,Q.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:l,children:[(0,Q.jsx)(ie,{className:`h-3.5 w-3.5`}),`Attach File`]})}),t[11]=l,t[12]=r,t[13]=m):m=t[13];let h;return t[14]!==p||t[15]!==m?(h=(0,Q.jsxs)(`div`,{className:`relative`,ref:a,children:[p,m]}),t[14]=p,t[15]=m,t[16]=h):h=t[16],h}var $=rt(`useWhisperSpeech`),Gt=`/api/voice-model/download`;function Kt(){let[e,t]=(0,Z.useState)(`idle`),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(0),m=(0,Z.useRef)(null),h=(0,Z.useRef)(null),g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),y=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{let e=!1;async function n(){t(`checking-support`),$.separator(`VOICE SESSION START`),$.info(`Checking WASM support`,{userAgent:navigator.userAgent,platform:navigator.platform});try{let n=new at;m.current=n;let i=await n.checkWasmSupport();if(e)return;if($.info(`WASM SIMD support check result`,{supported:i}),r(i),!i){$.error(`WASM SIMD not supported — voice input disabled`),t(`error`),d(`WebAssembly SIMD is not supported in this environment.`);return}let o=new it;h.current=o,$.info(`Checking IndexedDB model cache`,{url:Gt});try{let r=await o.loadModelByUrl(Gt);if(e||($.info(`Cached model found — initializing WASM`,{sizeBytes:r.byteLength,sizeMB:(r.byteLength/1024/1024).toFixed(2)}),a(!0),t(`initializing`),await n.initModel(r),e))return;$.info(`WASM model initialized from cache — ready`),t(`ready`)}catch(n){if(e)return;$.info(`Model not in cache — download required`,{reason:n instanceof Error?n.message:String(n)}),t(`needs-model`)}}catch(n){if(e)return;let r=n instanceof Error?n.message:`Unknown error`;$.error(`Failed to check speech recognition support`,{error:r}),t(`error`),d(`Failed to check speech recognition support: ${r}`)}}return n().catch(e=>{console.error(`Failed to check speech recognition support:`,e)}),()=>{e=!0,g.current&&g.current.getTracks().forEach(e=>e.stop())}},[]);let b=(0,Z.useCallback)(async()=>{if(!(!m.current||!h.current)){t(`downloading-model`),p(0),d(null),$.info(`Model download requested`,{url:Gt});try{let e=await h.current.loadModelByUrl(Gt,e=>{p(e),e%10==0&&$.debug(`Model download progress`,{progress:e})});$.info(`Model download complete — initializing WASM`,{sizeBytes:e.byteLength,sizeMB:(e.byteLength/1024/1024).toFixed(2)}),t(`initializing`),await m.current.initModel(e),$.info(`WASM model initialized after download — ready`),a(!0),t(`ready`)}catch(e){let n=e instanceof Error?e.message:`An unknown error occurred.`;$.error(`Model download or initialization failed`,{error:n}),t(`needs-model`),d(n)}}},[]),x=(0,Z.useCallback)(async()=>{if(!(!m.current||!i)){if(y.current=!1,t(`requesting-mic`),d(null),l(``),$.separator(`RECORDING START`),$.info(`Requesting microphone access`),!navigator.mediaDevices?.getUserMedia){$.error(`navigator.mediaDevices.getUserMedia not available in this environment`),t(`ready`),s(!1),d(`Microphone is not available in this environment.`);return}try{let e=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),n=e.getAudioTracks();$.info(`Microphone access granted`,{trackCount:n.length,tracks:n.map(e=>({label:e.label,readyState:e.readyState,settings:e.getSettings()}))}),g.current=e,s(!0);let r=new AbortController;_.current=r,t(`recording`),$.info(`Recording started`),v.current=ot(e,{signal:r.signal,recordingDurationMs:12e4,logLevel:0},{onError:e=>{$.error(`Audio conversion error during recording`,{error:e instanceof Error?e.message:String(e)})}})}catch(e){if(t(`ready`),e instanceof DOMException&&e.name===`NotAllowedError`)$.error(`Microphone access denied (NotAllowedError)`),s(!1),d(`Microphone access was denied. Please allow microphone access to use voice input.`);else if(e instanceof DOMException&&e.name===`NotFoundError`)$.error(`No microphone found (NotFoundError)`),s(!1),d(`No microphone was found. Please connect a microphone to use voice input.`);else{let t=e instanceof Error?e.message:`Unknown error`;$.error(`Microphone error`,{error:t,type:e instanceof DOMException?e.name:typeof e}),d(`Microphone error: ${t}`)}}}},[i]),S=(0,Z.useCallback)(async()=>{if(!v.current){$.info(`stopListening called but no active recording`),g.current&&=(g.current.getTracks().forEach(e=>e.stop()),null),i&&t(`ready`);return}$.info(`Stopping recording — waiting for audio data`),_.current?.abort(),t(`transcribing`);try{let e=await v.current;if(y.current){$.info(`Transcription cancelled by user`),t(`ready`);return}let n=(e.audioData.length/16e3).toFixed(2);$.info(`Audio capture complete — starting transcription`,{sampleCount:e.audioData.length,durationSec:n,sampleRate:16e3}),g.current&&=(g.current.getTracks().forEach(e=>e.stop()),null);let r=Date.now(),i=typeof SharedArrayBuffer<`u`?4:1,a=m.current.createSession().streaming(e.audioData,{language:`en`,threads:i,translate:!1}),o=``,s=0;for await(let e of a){if(y.current)break;s++,o+=e.text.trim()+` `,$.debug(`Transcription segment received`,{index:s,text:e.text,timeStart:e.timeStart,timeEnd:e.timeEnd}),l(o.trim())}$.info(`Transcription complete`,{segmentCount:s,durationMs:Date.now()-r,textLength:o.trim().length,text:o.trim().slice(0,100)}),t(`ready`)}catch(e){if(y.current){t(`ready`);return}let n=e instanceof Error?e.message:`Unknown transcription error`;if($.error(`Transcription failed`,{error:n,errorType:e instanceof Error?e.constructor.name:typeof e,stack:e instanceof Error?e.stack?.split(`
2
- `).slice(0,5).join(` | `):void 0}),m.current&&n.includes(`Aborted`)){$.info(`WASM aborted — reinitializing model for next attempt`),t(`initializing`);try{await m.current.restartModel(),$.info(`WASM reinitialized successfully`)}catch(e){$.error(`WASM reinitialization failed`,{error:e instanceof Error?e.message:String(e)})}}t(`ready`),d(`Transcription failed: ${n}`)}finally{v.current=null,_.current=null}},[i]),C=(0,Z.useCallback)(()=>{l(``),d(null)},[]);return{state:e,isSupported:n===!0,isWasmSupported:n,isModelLoaded:i,isMicrophoneAvailable:o,transcript:c,error:u,downloadProgress:f,startListening:x,stopListening:S,requestModelDownload:b,resetTranscript:C}}var qt=Z.forwardRef((e,t)=>{let n=(0,X.c)(13),r,i,o;n[0]===e?(r=n[1],i=n[2],o=n[3]):({className:r,value:o,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o);let s;n[4]===r?s=n[5]:(s=a(`relative h-4 w-full overflow-hidden rounded-full bg-secondary`,r),n[4]=r,n[5]=s);let c=`translateX(-${100-(o||0)}%)`,l;n[6]===c?l=n[7]:(l=(0,Q.jsx)(Le,{className:`h-full w-full flex-1 bg-primary transition-all`,style:{transform:c}}),n[6]=c,n[7]=l);let u;return n[8]!==i||n[9]!==t||n[10]!==s||n[11]!==l?(u=(0,Q.jsx)(Ne,{ref:t,className:s,...i,children:l}),n[8]=i,n[9]=t,n[10]=s,n[11]=l,n[12]=u):u=n[12],u});qt.displayName=Ne.displayName;var Jt=75;function Yt(e){let t=(0,X.c)(11),{open:n,onOpenChange:r,onConfirm:i,downloading:a,progress:s,error:c}=e,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsxs)(le,{children:[(0,Q.jsx)(l,{children:`Download Voice Model`}),(0,Q.jsxs)(o,{children:[`To enable voice-to-text, a voice model needs to be downloaded. This is a one-time download of approximately `,Jt,`MB. The model will be cached locally for future use.`]})]}),t[0]=d):d=t[0];let f;t[1]!==a||t[2]!==c||t[3]!==i||t[4]!==r||t[5]!==s?(f=(0,Q.jsxs)(k,{children:[d,a?(0,Q.jsxs)(`div`,{className:`space-y-3 py-4`,children:[(0,Q.jsx)(qt,{value:s,className:`w-full`}),(0,Q.jsx)(`p`,{className:`text-center text-sm text-muted-foreground`,children:s<100?`Downloading model... ${s}%`:`Initializing model...`})]}):c?(0,Q.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,Q.jsx)(q,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Q.jsx)(`p`,{children:c})]}),(0,Q.jsxs)(u,{children:[(0,Q.jsx)(J,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Q.jsx)(J,{onClick:i,children:`Try Again`})]})]}):(0,Q.jsxs)(u,{children:[(0,Q.jsx)(J,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Q.jsx)(J,{onClick:i,children:`Download Model`})]})]}),t[1]=a,t[2]=c,t[3]=i,t[4]=r,t[5]=s,t[6]=f):f=t[6];let p;return t[7]!==r||t[8]!==n||t[9]!==f?(p=(0,Q.jsx)(E,{open:n,onOpenChange:r,children:f}),t[7]=r,t[8]=n,t[9]=f,t[10]=p):p=t[10],p}function Xt(e){let t=(0,X.c)(65),{onTranscript:n}=e,{state:i,isWasmSupported:a,transcript:o,error:s,downloadProgress:c,startListening:l,stopListening:u,requestModelDownload:d,resetTranscript:f}=Kt(),{toast:p}=qe(),[m,h]=(0,Z.useState)(!1),g=(0,Z.useRef)(``),_=(0,Z.useRef)(null),v=i===`recording`,y=i===`transcribing`,b=v||y,x=i===`needs-model`,S=i===`downloading-model`||i===`initializing`,C=i===`checking-support`||i===`idle`,w,T;t[0]!==m||t[1]!==s||t[2]!==p?(w=()=>{s&&s!==_.current&&!m&&p({title:`Voice Input Error`,description:s,variant:`destructive`}),_.current=s},T=[s,m,p],t[0]=m,t[1]=s,t[2]=p,t[3]=w,t[4]=T):(w=t[3],T=t[4]),(0,Z.useEffect)(w,T);let E,D;t[5]!==n||t[6]!==o?(E=()=>{if(o&&o!==g.current){let e=o.substring(g.current.length);g.current=o,n(e)}},D=[o,n],t[5]=n,t[6]=o,t[7]=E,t[8]=D):(E=t[7],D=t[8]),(0,Z.useEffect)(E,D);let O,k;t[9]===o?(O=t[10],k=t[11]):(O=()=>{o||(g.current=``)},k=[o],t[9]=o,t[10]=O,t[11]=k),(0,Z.useEffect)(O,k);let A;t[12]!==b||t[13]!==x||t[14]!==f||t[15]!==l||t[16]!==i||t[17]!==u?(A=()=>{if(x){h(!0);return}b?u():i===`ready`&&(f(),l())},t[12]=b,t[13]=x,t[14]=f,t[15]=l,t[16]=i,t[17]=u,t[18]=A):A=t[18];let j=A,M;t[19]===d?M=t[20]:(M=()=>{d()},t[19]=d,t[20]=M);let N=M,P,F;if(t[21]!==m||t[22]!==i?(F=()=>{i===`ready`&&m&&h(!1)},P=[i,m],t[21]=m,t[22]=i,t[23]=P,t[24]=F):(P=t[23],F=t[24]),(0,Z.useEffect)(F,P),C)return null;if(a===!1){let e;return t[25]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsxs)(Ge,{children:[(0,Q.jsx)(Ke,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`ghost`,size:`icon-sm`,disabled:!0,className:`text-muted-foreground`,children:[(0,Q.jsx)(ee,{className:`opacity-50`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Voice input not supported`})]})}),(0,Q.jsx)(We,{side:`top`,className:`bg-popover text-popover-foreground`,children:`Voice input not supported in this browser`})]}),t[25]=e):e=t[25],e}let I;t[26]!==s||t[27]!==S||t[28]!==v||t[29]!==y||t[30]!==x?(I=()=>s||(S?`Downloading speech model...`:y?`Transcribing...`:v?`Stop listening`:x?`Click to download speech model`:`Start listening`),t[26]=s,t[27]=S,t[28]=v,t[29]=y,t[30]=x,t[31]=I):I=t[31];let L=I,R;t[32]!==S||t[33]!==v||t[34]!==y?(R=()=>S||y?(0,Q.jsx)(r,{className:`animate-spin`}):v?(0,Q.jsxs)(`span`,{className:`recording-waveform`,"aria-hidden":!0,children:[(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`0ms`}}),(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`150ms`}}),(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`75ms`}}),(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`225ms`}})]}):(0,Q.jsx)(ee,{}),t[32]=S,t[33]=v,t[34]=y,t[35]=R):R=t[35];let te=R,ne;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Q.jsx)(`style`,{children:`
3
- .recording-waveform {
4
- display: flex;
5
- align-items: center;
6
- gap: 2px;
7
- height: 16px;
8
- }
9
- .recording-waveform-bar {
10
- display: block;
11
- width: 3px;
12
- height: 4px;
13
- border-radius: 2px;
14
- background: currentColor;
15
- animation: waveform-bounce 0.7s ease-in-out infinite alternate;
16
- }
17
- @keyframes waveform-bounce {
18
- from { height: 3px; }
19
- to { height: 14px; }
20
- }
21
- `}),t[36]=ne):ne=t[36];let re=v?`bg-primary text-primary-foreground hover:bg-primary/90`:y?`text-muted-foreground`:`text-muted-foreground hover:text-background`,ie=C||S||y,z;t[37]===te?z=t[38]:(z=te(),t[37]=te,t[38]=z);let B;t[39]===L?B=t[40]:(B=L(),t[39]=L,t[40]=B);let ae;t[41]===B?ae=t[42]:(ae=(0,Q.jsx)(`span`,{className:`sr-only`,children:B}),t[41]=B,t[42]=ae);let V;t[43]!==j||t[44]!==re||t[45]!==ie||t[46]!==z||t[47]!==ae?(V=(0,Q.jsx)(Ke,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`ghost`,size:`icon-sm`,className:re,onClick:j,disabled:ie,children:[z,ae]})}),t[43]=j,t[44]=re,t[45]=ie,t[46]=z,t[47]=ae,t[48]=V):V=t[48];let H;t[49]===L?H=t[50]:(H=L(),t[49]=L,t[50]=H);let U;t[51]===H?U=t[52]:(U=(0,Q.jsx)(We,{side:`top`,className:`bg-popover text-popover-foreground max-w-64`,children:H}),t[51]=H,t[52]=U);let W;t[53]!==V||t[54]!==U?(W=(0,Q.jsxs)(Ge,{children:[V,U]}),t[53]=V,t[54]=U,t[55]=W):W=t[55];let G;t[56]!==m||t[57]!==c||t[58]!==s||t[59]!==N||t[60]!==S?(G=(0,Q.jsx)(Yt,{open:m,onOpenChange:h,onConfirm:N,downloading:S,progress:c,error:s}),t[56]=m,t[57]=c,t[58]=s,t[59]=N,t[60]=S,t[61]=G):G=t[61];let K;return t[62]!==W||t[63]!==G?(K=(0,Q.jsxs)(Q.Fragment,{children:[ne,W,G]}),t[62]=W,t[63]=G,t[64]=K):K=t[64],K}function Zt(e){let t=(0,X.c)(8),{queuedMessages:n,onRemoveQueuedMessage:r}=e;if(n.length===0)return null;let i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`Queued messages`}),t[0]=i):i=t[0];let a;if(t[1]!==r||t[2]!==n){let e;t[4]===r?e=t[5]:(e=e=>(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border/60 bg-background px-3 py-2 text-sm`,children:[(0,Q.jsx)(`p`,{className:`flex-1 whitespace-pre-wrap text-foreground`,children:e.message}),(0,Q.jsx)(`button`,{type:`button`,className:`rounded-full p-1 text-muted-foreground transition-colors hover:bg-foreground hover:text-background`,onClick:()=>r(e.id),"aria-label":`Remove queued message`,children:(0,Q.jsx)(S,{className:`h-3.5 w-3.5`})})]},e.id),t[4]=r,t[5]=e),a=n.map(e),t[1]=r,t[2]=n,t[3]=a}else a=t[3];let o;return t[6]===a?o=t[7]:(o=(0,Q.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border/60 bg-muted/30 px-4 py-3`,children:[i,(0,Q.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:a})]}),t[6]=a,t[7]=o),o}function Qt(e){let t=(0,X.c)(136),{onSend:n,onStop:r,isStreaming:i,disabled:a,initialValue:o,queuedMessages:s,onRemoveQueuedMessage:c,isOverlay:l}=e,u=i===void 0?!1:i,d=l===void 0?!1:l,f;t[0]===o?f=t[1]:(f={initialValue:o},t[0]=o,t[1]=f);let{message:p,setMessage:m,historyIndex:h,setHistoryIndex:g,draftMessage:_,setDraftMessage:v,cursorPosition:y,setCursorPosition:b,availableModels:x,selectedModel:S,setSelectedModel:C,attachments:w,setAttachments:T,planMode:E,setPlanMode:O,ralphMode:k,setRalphMode:A,imageMode:j,setImageMode:M,availableImageModels:P,selectedImageModel:F,setSelectedImageModel:ee,allFiles:I,setAllFiles:L,showSuggestions:R,setShowSuggestions:te,suggestionQuery:ne,setSuggestionQuery:ie,selectedIndex:z,setSelectedIndex:B,slashCommands:ae,skills:V,showCommandSuggestions:H,setShowCommandSuggestions:U,commandQuery:W,setCommandQuery:G,fileInputRef:K,textareaRef:q,suggestionsRef:oe,commandSuggestionsRef:se,state:ce,dispatch:le}=wt(f),ue=j?F:S,de=j?P:x,fe=ce.selectedThreadId??void 0,pe;t[2]!==I||t[3]!==w||t[4]!==W||t[5]!==y||t[6]!==le||t[7]!==_||t[8]!==h||t[9]!==j||t[10]!==u||t[11]!==p||t[12]!==n||t[13]!==E||t[14]!==k||t[15]!==F||t[16]!==z||t[17]!==S||t[18]!==L||t[19]!==T||t[20]!==G||t[21]!==b||t[22]!==v||t[23]!==g||t[24]!==M||t[25]!==m||t[26]!==O||t[27]!==A||t[28]!==B||t[29]!==U||t[30]!==te||t[31]!==ie||t[32]!==H||t[33]!==R||t[34]!==V||t[35]!==ae||t[36]!==ne||t[37]!==fe||t[38]!==q?(pe={message:p,setMessage:m,attachments:w,selectedModel:S,onSend:n,isStreaming:u,selectedThreadId:fe,isListening:!1,stopListening:nn,resetTranscript:tn,dispatch:le,historyIndex:h,setHistoryIndex:g,draftMessage:_,setDraftMessage:v,cursorPosition:y,setCursorPosition:b,showSuggestions:R,setShowSuggestions:te,suggestionQuery:ne,setSuggestionQuery:ie,allFiles:I,setAllFiles:L,selectedIndex:z,setSelectedIndex:B,showCommandSuggestions:H,setShowCommandSuggestions:U,commandQuery:W,setCommandQuery:G,slashCommands:ae,skills:V,textareaRef:q,setAttachments:T,planMode:E,setPlanMode:O,ralphMode:k,setRalphMode:A,imageMode:j,setImageMode:M,selectedImageModel:F},t[2]=I,t[3]=w,t[4]=W,t[5]=y,t[6]=le,t[7]=_,t[8]=h,t[9]=j,t[10]=u,t[11]=p,t[12]=n,t[13]=E,t[14]=k,t[15]=F,t[16]=z,t[17]=S,t[18]=L,t[19]=T,t[20]=G,t[21]=b,t[22]=v,t[23]=g,t[24]=M,t[25]=m,t[26]=O,t[27]=A,t[28]=B,t[29]=U,t[30]=te,t[31]=ie,t[32]=H,t[33]=R,t[34]=V,t[35]=ae,t[36]=ne,t[37]=fe,t[38]=q,t[39]=pe):pe=t[39];let{handleSend:me,handleKeyDown:he,handleTextareaInput:ge,insertFileReference:_e,insertCommand:ve,insertSkill:ye,fileSuggestions:be}=Et(pe),xe;t[40]===m?xe=t[41]:(xe=e=>{m(t=>(t.endsWith(` `),t+e))},t[40]=m,t[41]=xe);let Se=xe,Ce;t[42]===T?Ce=t[43]:(Ce=e=>{let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(en);if(n.length!==0){e.preventDefault();for(let e of n){let t=e.getAsFile();if(!t)continue;let n=new FileReader;n.onload=()=>{let e=n.result.split(`,`)[1];T(n=>[...n,{fileName:t.name||`pasted-image.${t.type.split(`/`)[1]||`png`}`,content:e,mimeType:t.type}])},n.readAsDataURL(t)}}},t[42]=T,t[43]=Ce);let we=Ce,Te=d?`absolute inset-x-0 bottom-0 mx-auto w-full max-w-3xl px-4 pb-4 pointer-events-none`:`relative mx-auto w-full max-w-3xl px-4 pb-4`,Ee=`flex flex-col rounded-2xl border focus-within:ring-2 focus-within:ring-brand pointer-events-auto ${d?`border-border/50 bg-background/80 shadow-lg backdrop-blur-sm`:`border-border bg-background shadow-2xl`}`,De;t[44]!==c||t[45]!==s?(De=(0,Q.jsx)(Zt,{queuedMessages:s,onRemoveQueuedMessage:c}),t[44]=c,t[45]=s,t[46]=De):De=t[46];let Oe=k?`Describe stories for Ralph to implement autonomously...`:E?`Describe what you want Tarsk to plan...`:j?`Describe the image you want to generate...`:`Ask Tarsk anything, # for files, / for commands & skills`,ke;t[47]!==a||t[48]!==he||t[49]!==we||t[50]!==ge||t[51]!==p||t[52]!==Oe||t[53]!==q?(ke=(0,Q.jsx)(`textarea`,{ref:q,value:p,onChange:ge,onKeyDown:he,onPaste:we,placeholder:Oe,rows:1,className:`w-full resize-none bg-transparent px-6 pt-4 pb-4 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none`,disabled:a}),t[47]=a,t[48]=he,t[49]=we,t[50]=ge,t[51]=p,t[52]=Oe,t[53]=q,t[54]=ke):ke=t[54];let Ae;t[55]!==W||t[56]!==se||t[57]!==ve||t[58]!==ye||t[59]!==z||t[60]!==B||t[61]!==H||t[62]!==V||t[63]!==ae?(Ae=(0,Q.jsx)(At,{visible:H,commands:ae,skills:V,query:W,selectedIndex:z,onSelectCommand:ve,onSelectSkill:ye,onMouseEnterSuggestion:B,containerRef:se}),t[55]=W,t[56]=se,t[57]=ve,t[58]=ye,t[59]=z,t[60]=B,t[61]=H,t[62]=V,t[63]=ae,t[64]=Ae):Ae=t[64];let je;t[65]!==be||t[66]!==_e||t[67]!==z||t[68]!==B||t[69]!==R||t[70]!==ne||t[71]!==oe?(je=(0,Q.jsx)(It,{showSuggestions:R,fileSuggestions:be,suggestionQuery:ne,selectedIndex:z,onSelectFile:_e,onMouseEnterSuggestion:B,containerRef:oe}),t[65]=be,t[66]=_e,t[67]=z,t[68]=B,t[69]=R,t[70]=ne,t[71]=oe,t[72]=je):je=t[72];let Me;t[73]!==w||t[74]!==S?.id||t[75]!==S?.name||t[76]!==S?.supportsImages||t[77]!==T?(Me=w.length>0&&(0,Q.jsxs)(`div`,{className:`px-4`,children:[(0,Q.jsx)(Pt,{attachments:w,onRemove:e=>T(t=>t.filter((t,n)=>n!==e))}),w.some($t)&&S?.supportsImages===!1&&(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-xs text-amber-500`,children:[(0,Q.jsx)(D,{className:`h-3 w-3 shrink-0`}),(0,Q.jsxs)(`span`,{children:[`Images are not supported by `,S?.name||S?.id]})]})]}),t[73]=w,t[74]=S?.id,t[75]=S?.name,t[76]=S?.supportsImages,t[77]=T,t[78]=Me):Me=t[78];let Ne;t[79]===K?Ne=t[80]:(Ne=(0,Q.jsx)(Wt,{onFileAttach:()=>K.current?.click()}),t[79]=K,t[80]=Ne);let Pe;t[81]===Se?Pe=t[82]:(Pe=(0,Q.jsx)(Xt,{onTranscript:Se}),t[81]=Se,t[82]=Pe);let Fe=j?ee:C,Ie;t[83]!==de||t[84]!==ue||t[85]!==Fe?(Ie=(0,Q.jsx)(zt,{availableModels:de,selectedModel:ue,onModelSelect:Fe}),t[83]=de,t[84]=ue,t[85]=Fe,t[86]=Ie):Ie=t[86];let Le;t[87]!==Ne||t[88]!==Pe||t[89]!==Ie?(Le=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Ne,Pe,Ie]}),t[87]=Ne,t[88]=Pe,t[89]=Ie,t[90]=Le):Le=t[90];let Re;t[91]!==j||t[92]!==E||t[93]!==k||t[94]!==M||t[95]!==O||t[96]!==A?(Re=(0,Q.jsx)(Ut,{planMode:E,imageMode:j,ralphMode:k,setPlanMode:O,setImageMode:M,setRalphMode:A}),t[91]=j,t[92]=E,t[93]=k,t[94]=M,t[95]=O,t[96]=A,t[97]=Re):Re=t[97];let ze=u?r:me,Be;t[98]!==w.length||t[99]!==a||t[100]!==ue||t[101]!==u||t[102]!==p?(Be=!u&&((a??!1)||!p.trim()&&w.length===0||!ue),t[98]=w.length,t[99]=a,t[100]=ue,t[101]=u,t[102]=p,t[103]=Be):Be=t[103];let Ve;t[104]===u?Ve=t[105]:(Ve=u?(0,Q.jsx)(N,{className:`h-3 w-3 fill-current`}):(0,Q.jsx)(re,{className:`h-3 w-3`}),t[104]=u,t[105]=Ve);let He=u?`Stop generation`:`Send message`,Y;t[106]===He?Y=t[107]:(Y=(0,Q.jsx)(`span`,{className:`sr-only`,children:He}),t[106]=He,t[107]=Y);let Ue;t[108]!==ze||t[109]!==Be||t[110]!==Ve||t[111]!==Y?(Ue=(0,Q.jsxs)(J,{size:`icon`,className:`h-7 w-7 rounded-full`,onClick:ze,disabled:Be,children:[Ve,Y]}),t[108]=ze,t[109]=Be,t[110]=Ve,t[111]=Y,t[112]=Ue):Ue=t[112];let We;t[113]!==Re||t[114]!==Ue?(We=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Re,Ue]}),t[113]=Re,t[114]=Ue,t[115]=We):We=t[115];let Ge;t[116]!==Le||t[117]!==We?(Ge=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-2`,children:[Le,We]}),t[116]=Le,t[117]=We,t[118]=Ge):Ge=t[118];let Ke;t[119]!==De||t[120]!==ke||t[121]!==Ae||t[122]!==je||t[123]!==Me||t[124]!==Ge||t[125]!==Ee?(Ke=(0,Q.jsxs)(`div`,{className:Ee,children:[De,ke,Ae,je,Me,Ge]}),t[119]=De,t[120]=ke,t[121]=Ae,t[122]=je,t[123]=Me,t[124]=Ge,t[125]=Ee,t[126]=Ke):Ke=t[126];let qe;t[127]===T?qe=t[128]:(qe=e=>Ft(e,e=>T(t=>[...t,...e])),t[127]=T,t[128]=qe);let Je;t[129]!==K||t[130]!==qe?(Je=(0,Q.jsx)(`input`,{ref:K,type:`file`,multiple:!0,className:`hidden`,onChange:qe}),t[129]=K,t[130]=qe,t[131]=Je):Je=t[131];let Ye;return t[132]!==Ke||t[133]!==Je||t[134]!==Te?(Ye=(0,Q.jsxs)(`div`,{className:Te,children:[Ke,Je]}),t[132]=Ke,t[133]=Je,t[134]=Te,t[135]=Ye):Ye=t[135],Ye}function $t(e){return e.mimeType.startsWith(`image/`)}function en(e){return e.type.startsWith(`image/`)}function tn(){}function nn(){}var rn=ke,an=Pe,on=be,sn=Z.forwardRef((e,t)=>{let n=(0,X.c)(14),r,i,o,s;n[0]===e?(r=n[1],i=n[2],o=n[3],s=n[4]):({className:i,inset:o,children:r,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o,n[4]=s);let c=o&&`pl-8`,l;n[5]!==i||n[6]!==c?(l=a(`flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,c,i),n[5]=i,n[6]=c,n[7]=l):l=n[7];let u;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(H,{className:`ml-auto`}),n[8]=u):u=n[8];let d;return n[9]!==r||n[10]!==s||n[11]!==t||n[12]!==l?(d=(0,Q.jsxs)(ze,{ref:t,className:l,...s,children:[r,u]}),n[9]=r,n[10]=s,n[11]=t,n[12]=l,n[13]=d):d=n[13],d});sn.displayName=ze.displayName;var cn=Z.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let o;n[3]===r?o=n[4]:(o=a(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[3]=r,n[4]=o);let s;return n[5]!==i||n[6]!==t||n[7]!==o?(s=(0,Q.jsx)(Me,{ref:t,className:o,...i}),n[5]=i,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});cn.displayName=Me.displayName;var ln=Z.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,o;n[0]===e?(r=n[1],i=n[2],o=n[3]):({className:r,sideOffset:o,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o);let s=o===void 0?4:o,c;n[4]===r?c=n[5]:(c=a(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[4]=r,n[5]=c);let l;return n[6]!==i||n[7]!==t||n[8]!==s||n[9]!==c?(l=(0,Q.jsx)(we,{children:(0,Q.jsx)(De,{ref:t,sideOffset:s,className:c,...i})}),n[6]=i,n[7]=t,n[8]=s,n[9]=c,n[10]=l):l=n[10],l});ln.displayName=De.displayName;var un=Z.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,o;n[0]===e?(r=n[1],i=n[2],o=n[3]):({className:r,inset:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o);let s=i&&`pl-8`,c;n[4]!==r||n[5]!==s?(c=a(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,s,r),n[4]=r,n[5]=s,n[6]=c):c=n[6];let l;return n[7]!==o||n[8]!==t||n[9]!==c?(l=(0,Q.jsx)(Se,{ref:t,className:c,...o}),n[7]=o,n[8]=t,n[9]=c,n[10]=l):l=n[10],l});un.displayName=Se.displayName;var dn=Z.forwardRef((e,t)=>{let n=(0,X.c)(14),r,i,o,s;n[0]===e?(r=n[1],i=n[2],o=n[3],s=n[4]):({className:o,children:i,checked:r,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o,n[4]=s);let c;n[5]===o?c=n[6]:(c=a(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,o),n[5]=o,n[6]=c);let l;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Q.jsx)(Te,{children:(0,Q.jsx)(pe,{className:`h-4 w-4`})})}),n[7]=l):l=n[7];let u;return n[8]!==r||n[9]!==i||n[10]!==s||n[11]!==t||n[12]!==c?(u=(0,Q.jsxs)(Ce,{ref:t,className:c,checked:r,...s,children:[l,i]}),n[8]=r,n[9]=i,n[10]=s,n[11]=t,n[12]=c,n[13]=u):u=n[13],u});dn.displayName=Ce.displayName;var fn=Z.forwardRef((e,n)=>{let r=(0,X.c)(12),i,o,s;r[0]===e?(i=r[1],o=r[2],s=r[3]):({className:o,children:i,...s}=e,r[0]=e,r[1]=i,r[2]=o,r[3]=s);let c;r[4]===o?c=r[5]:(c=a(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,o),r[4]=o,r[5]=c);let l;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Q.jsx)(Te,{children:(0,Q.jsx)(t,{className:`h-2 w-2 fill-current`})})}),r[6]=l):l=r[6];let u;return r[7]!==i||r[8]!==s||r[9]!==n||r[10]!==c?(u=(0,Q.jsxs)(Oe,{ref:n,className:c,...s,children:[l,i]}),r[7]=i,r[8]=s,r[9]=n,r[10]=c,r[11]=u):u=r[11],u});fn.displayName=Oe.displayName;var pn=Z.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,o;n[0]===e?(r=n[1],i=n[2],o=n[3]):({className:r,inset:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o);let s=i&&`pl-8`,c;n[4]!==r||n[5]!==s?(c=a(`px-2 py-1.5 text-sm font-semibold`,s,r),n[4]=r,n[5]=s,n[6]=c):c=n[6];let l;return n[7]!==o||n[8]!==t||n[9]!==c?(l=(0,Q.jsx)(Ie,{ref:t,className:c,...o}),n[7]=o,n[8]=t,n[9]=c,n[10]=l):l=n[10],l});pn.displayName=Ie.displayName;var mn=Z.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let o;n[3]===r?o=n[4]:(o=a(`-mx-1 my-1 h-px bg-muted`,r),n[3]=r,n[4]=o);let s;return n[5]!==i||n[6]!==t||n[7]!==o?(s=(0,Q.jsx)(Ee,{ref:t,className:o,...i}),n[5]=i,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});mn.displayName=Ee.displayName;var hn=e=>{let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=a(`ml-auto text-xs tracking-widest opacity-60`,n),t[3]=n,t[4]=i);let o;return t[5]!==r||t[6]!==i?(o=(0,Q.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=o):o=t[7],o};hn.displayName=`DropdownMenuShortcut`;function gn(e){let t=(0,X.c)(17),{currentBranch:n,availableBranches:i,isLoadingBranches:a,isCheckingOut:o,onLoadBranches:s,onCheckoutBranch:l}=e,u;t[0]===s?u=t[1]:(u=e=>{e&&s()},t[0]=s,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(c,{className:`h-3.5 w-3.5 shrink-0`}),t[2]=d):d=t[2];let f=n||`Unknown`,p;t[3]===f?p=t[4]:(p=(0,Q.jsx)(an,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs bg-background gap-1.5 border-none text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:[d,f]})}),t[3]=f,t[4]=p);let m;t[5]!==i||t[6]!==n||t[7]!==o||t[8]!==a||t[9]!==l?(m=a?(0,Q.jsxs)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground flex items-center gap-2`,children:[(0,Q.jsx)(r,{className:`h-3 w-3 animate-spin`}),`Loading branches...`]}):i.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`No branches found`}):i.map(e=>(0,Q.jsxs)(un,{disabled:e===n||o,onClick:()=>l(e),children:[(0,Q.jsx)(c,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,Q.jsx)(`span`,{className:e===n?`font-semibold text-foreground`:``,children:e}),e===n&&(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`current`})]},e)),t[5]=i,t[6]=n,t[7]=o,t[8]=a,t[9]=l,t[10]=m):m=t[10];let h;t[11]===m?h=t[12]:(h=(0,Q.jsx)(ln,{align:`start`,children:m}),t[11]=m,t[12]=h);let g;return t[13]!==u||t[14]!==p||t[15]!==h?(g=(0,Q.jsxs)(rn,{onOpenChange:u,children:[p,h]}),t[13]=u,t[14]=p,t[15]=h,t[16]=g):g=t[16],g}var _n=[{key:`systemPrompt`,label:`System prompt`,color:`#9CA3AF`},{key:`toolDefinitions`,label:`Tool definitions`,color:`#B088F0`},{key:`rules`,label:`Rules`,color:`#88D088`},{key:`skills`,label:`Skills`,color:`#D0A000`},{key:`subagentDefinitions`,label:`Subagent definitions`,color:`#2080D0`},{key:`conversation`,label:`Conversation`,color:`#E09030`}];function vn(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function yn(e){return e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:e.toString()}function bn(e){let t=(0,X.c)(49),{breakdown:n,onClose:r}=e,{categories:i,totalTokens:a,contextWindow:o,percentageFull:s}=n,c,l,u,d,f,p;if(t[0]!==i||t[1]!==o||t[2]!==r||t[3]!==s||t[4]!==a){let e;t[11]===i?e=t[12]:(e=e=>i[e.key]>0,t[11]=i,t[12]=e);let n=_n.filter(e);d=`w-72 space-y-3`;let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Context`}),t[13]=m):m=t[13];let h;t[14]===r?h=t[15]:(h=r&&(0,Q.jsxs)(J,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:r,children:[(0,Q.jsx)(S,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Close`})]}),t[14]=r,t[15]=h),t[16]===h?f=t[17]:(f=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[m,h]}),t[16]=h,t[17]=f);let g;t[18]===s?g=t[19]:(g=(0,Q.jsxs)(`span`,{children:[s,`% Full`]}),t[18]=s,t[19]=g);let _;t[20]===a?_=t[21]:(_=vn(a),t[20]=a,t[21]=_);let v;t[22]===o?v=t[23]:(v=yn(o),t[22]=o,t[23]=v);let y;t[24]!==_||t[25]!==v?(y=(0,Q.jsxs)(`span`,{children:[`~`,_,` / `,v,` Tokens`]}),t[24]=_,t[25]=v,t[26]=y):y=t[26],t[27]!==g||t[28]!==y?(p=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[g,y]}),t[27]=g,t[28]=y,t[29]=p):p=t[29],u=`h-2 w-full overflow-hidden rounded-full bg-muted/60`,c=`flex h-full w-full`;let b;t[30]!==i||t[31]!==o?(b=e=>{let t=i[e.key],n=o>0?t/o*100:0;return(0,Q.jsx)(`div`,{style:{width:`${Math.max(n,t>0?.5:0)}%`,backgroundColor:e.color}},e.key)},t[30]=i,t[31]=o,t[32]=b):b=t[32],l=n.map(b),t[0]=i,t[1]=o,t[2]=r,t[3]=s,t[4]=a,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p}else c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10];let m;t[33]!==c||t[34]!==l?(m=(0,Q.jsx)(`div`,{className:c,children:l}),t[33]=c,t[34]=l,t[35]=m):m=t[35];let h;t[36]!==u||t[37]!==m?(h=(0,Q.jsx)(`div`,{className:u,children:m}),t[36]=u,t[37]=m,t[38]=h):h=t[38];let g;t[39]===i?g=t[40]:(g=_n.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-sm`,style:{backgroundColor:e.color}}),(0,Q.jsx)(`span`,{children:e.label})]}),(0,Q.jsx)(`span`,{className:`tabular-nums`,children:vn(i[e.key])})]},e.key)),t[39]=i,t[40]=g);let _;t[41]===g?_=t[42]:(_=(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[41]=g,t[42]=_);let v;return t[43]!==_||t[44]!==d||t[45]!==f||t[46]!==p||t[47]!==h?(v=(0,Q.jsxs)(`div`,{className:d,children:[f,p,h,_]}),t[43]=_,t[44]=d,t[45]=f,t[46]=p,t[47]=h,t[48]=v):v=t[48],v}function xn({threadId:e,currentConversationId:t,refreshKey:n,children:r}){let[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{p(!1)},[n]),(0,Z.useEffect)(()=>{if(!u||!e||f&&!n)return;async function r(){s(!0),l(null);try{let n=(await y(e)).currentConversationId??t;if(!n){l(`No active conversation`);return}a(await G(e,n)),p(!0)}catch(e){console.error(`[TokenUsageTooltip] Failed to load context data:`,e),l(`Failed to load context data`)}finally{s(!1)}}r()},[u,e,t,n]),!e||e===``?(0,Q.jsx)(Q.Fragment,{children:r}):(0,Q.jsxs)(ut,{open:u,onOpenChange:e=>{d(e),!e&&f&&p(!1)},children:[(0,Q.jsx)(dt,{asChild:!0,children:r}),(0,Q.jsxs)(ft,{side:`top`,align:`end`,className:`w-auto p-4`,children:[o&&(0,Q.jsxs)(`div`,{className:`flex w-72 items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(L,{className:`h-3 w-3 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Loading context...`})]}),c&&!o&&(0,Q.jsxs)(`div`,{className:`flex w-72 items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(L,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:c})]}),!o&&!c&&i&&(0,Q.jsx)(bn,{breakdown:i,onClose:()=>d(!1)})]})]})}function Sn(e,t){return`${e.filter(e=>e.sender===`agent`).length}:${t?`streaming`:`idle`}`}function Cn(e){return e>75?`text-red-500`:e>50?`text-orange-500`:`text-muted-foreground`}function wn(e){let t=(0,X.c)(8),{percentage:n}=e,r=2*Math.PI*7,i=r*(1-Math.min(n,100)/100),a;t[0]===n?a=t[1]:(a=Cn(n),t[0]=n,t[1]=a);let o=`h-4 w-4 ${a}`,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(`circle`,{className:`text-muted-foreground/25`,cx:`10`,cy:`10`,r:7,fill:`none`,stroke:`currentColor`,strokeWidth:`3`}),t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:7,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeDasharray:r,strokeDashoffset:i,transform:`rotate(-90 10 10)`}),t[3]=i,t[4]=c);let l;return t[5]!==o||t[6]!==c?(l=(0,Q.jsxs)(`svg`,{className:o,viewBox:`0 0 20 20`,"aria-hidden":`true`,children:[s,c]}),t[5]=o,t[6]=c,t[7]=l):l=t[7],l}function Tn(e){let t=(0,X.c)(21),{threadId:n,isStreaming:r,messages:i}=e,a=r===void 0?!1:r,o;t[0]===i?o=t[1]:(o=i===void 0?[]:i,t[0]=i,t[1]=o);let s=o,[c,l]=(0,Z.useState)(),[u,d]=(0,Z.useState)(),f;t[2]!==a||t[3]!==s?(f=Sn(s,a),t[2]=a,t[3]=s,t[4]=f):f=t[4];let p=f,m;t[5]===n?m=t[6]:(m=()=>{(async function(){if(!n){l(void 0),d(void 0);return}try{let e=(await y(n)).currentConversationId;if(l(e),!e){d(void 0);return}d((await G(n,e)).percentageFull)}catch(e){console.error(`Failed to fetch thread usage data:`,e),d(void 0)}})()},t[5]=n,t[6]=m);let h;if(t[7]!==n||t[8]!==p?(h=[n,p],t[7]=n,t[8]=p,t[9]=h):h=t[9],(0,Z.useEffect)(m,h),!n||n===``)return null;let g=typeof u==`number`&&u>25,_;t[10]!==u||t[11]!==g?(_=g?(0,Q.jsx)(wn,{percentage:u}):(0,Q.jsx)(A,{className:`h-4 w-4`}),t[10]=u,t[11]=g,t[12]=_):_=t[12];let v;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(`span`,{className:`sr-only`,children:`View token usage`}),t[13]=v):v=t[13];let b;t[14]===_?b=t[15]:(b=(0,Q.jsxs)(J,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,children:[_,v]}),t[14]=_,t[15]=b);let x;return t[16]!==c||t[17]!==b||t[18]!==n||t[19]!==p?(x=(0,Q.jsx)(xn,{threadId:n,currentConversationId:c,refreshKey:p,children:b}),t[16]=c,t[17]=b,t[18]=n,t[19]=p,t[20]=x):x=t[20],x}var En=3e4,Dn=new Map;function On(e,t){let n=Dn.get(e);if(n)for(let e of n)e(t)}function kn(e,t){let n=Dn.get(e);return n||(n=new Set,Dn.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Dn.delete(e)}}function An(e){let[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(0),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(void 0),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(`Up to date`),[x,S]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(void 0),[O,k]=(0,Z.useState)(void 0),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),P=(0,Z.useRef)(!0),F=(0,Z.useRef)(void 0),ee=(0,Z.useCallback)(e=>{n(e.hasChanges),i(e.changedFilesCount),o(e.hasUnpushedCommits),c(e.currentBranch),v(e.hasRemoteBranch),u(e.isOnGitHub),f(e.remoteUrl),m(e.canCreateRepo),g(e.repoUrl),b(e.status),S(e.defaultBranch??null),T(e.prExists),D(e.prUrl),k(e.prState),j(e.commitsAheadOfDefault??!1)},[]),I=(0,Z.useRef)(ee);I.current=ee;let L=(0,Z.useCallback)(async(t=!1)=>{if(!e)return;let n=setTimeout(()=>N(!0),100);try{let n=`unified-git-status-${e}`;t&&W.invalidate(n);let r=await W.get(n,()=>C(e,t),En);ee(r),On(e,r)}catch(e){console.error(`Failed to fetch unified git status:`,e)}finally{clearTimeout(n),N(!1)}},[e,ee]);return(0,Z.useEffect)(()=>{if(e)return kn(e,e=>{I.current(e)})},[e]),(0,Z.useEffect)(()=>{if(!e)return;let t=F.current!==e;t&&(F.current=e,P.current=!0),(async()=>{if(P.current){let t=`unified-git-status-${e}`,n=W.getSync(t);n&&ee(n),P.current=!1}await L(t)})()},[e,L,ee]),{hasChanges:t,changedFilesCount:r,hasUnpushedCommits:a,hasRemoteBranch:_,currentBranch:s,isOnGitHub:l,remoteUrl:d,canCreateRepo:p,repoUrl:h,status:y,defaultBranch:x,prExists:w,prUrl:E,prState:O,commitsAheadOfDefault:A,isRefreshing:M,fetchUnifiedStatus:L}}function jn(e){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),s=An(e);async function c(){if(!(!e||r)){i(!0);try{n((await j(e)).branches)}catch{n([])}finally{i(!1)}}}async function l(t){if(!(!e||t===s.currentBranch)){o(!0);try{await ye(e,t),await s.fetchUnifiedStatus(!0),Je({title:`Switched to branch "${t}"`})}catch(e){Je({title:`Failed to switch branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{o(!1)}}}return{currentBranch:s.currentBranch,availableBranches:t,isLoadingBranches:r,isCheckingOut:a,loadBranches:c,checkoutBranch:l,fetchUnifiedStatus:s.fetchUnifiedStatus}}function Mn(e){let t=(0,X.c)(8),{collapsed:n}=e,{theme:r,setTheme:i}=st();if(n)return null;let a;t[0]!==i||t[1]!==r?(a=()=>i(r===`dark`?`light`:`dark`),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o,s,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(M,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),s=(0,Q.jsx)(z,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100`}),c=(0,Q.jsx)(`span`,{className:`sr-only`,children:`Toggle theme`}),t[3]=o,t[4]=s,t[5]=c):(o=t[3],s=t[4],c=t[5]);let l;return t[6]===a?l=t[7]:(l=(0,Q.jsxs)(J,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:a,children:[o,s,c]}),t[6]=a,t[7]=l),l}function Nn({threadId:e,isStreaming:t=!1,messages:n=[]}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(null),s=jn(e);return(0,Z.useEffect)(()=>{e&&ge(e).then(o).catch(()=>{})},[e]),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-8 py-2 mt-[-1rem] min-h-[2.25rem]`,children:[e&&(0,Q.jsx)(gn,{currentBranch:s.currentBranch,availableBranches:s.availableBranches,isLoadingBranches:s.isLoadingBranches,isCheckingOut:s.isCheckingOut,onLoadBranches:s.loadBranches,onCheckoutBranch:s.checkoutBranch}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Mn,{collapsed:!1}),(0,Q.jsx)(Tn,{threadId:e,isStreaming:t,messages:n}),e&&(0,Q.jsxs)(Ge,{children:[(0,Q.jsx)(Ke,{asChild:!0,children:(0,Q.jsx)(J,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:async()=>{if(!(!e||r)){i(!0);try{let t=await ge(e);await navigator.clipboard.writeText(t)}finally{i(!1)}}},disabled:r,"aria-label":`Copy repository folder path`,children:(0,Q.jsx)(x,{className:`h-4 w-4`})})}),(0,Q.jsxs)(We,{side:`top`,className:`bg-slate-900 text-white`,children:[(0,Q.jsx)(`div`,{children:`Copy repository folder path`}),a&&(0,Q.jsx)(`div`,{className:`opacity-70 text-xs`,children:a})]})]})]})]})}function Pn(e,t){if(!(!t||!e.includes(`"run_js"`)))try{let n=JSON.parse(e.trim());if(!Array.isArray(n))return;for(let e of n)e?.type===`tool_use`&&e?.name===`run_js`&&e?.id&&e?.input?.code&&Ct(e.id,e.input.code,t)}catch{}}function Fn(){let{state:e,dispatch:t}=Be(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),c=(0,Z.useRef)(null),l=(0,Z.useRef)(new Map),{selectedThreadId:u,selectedProjectId:d,messages:f,queuedChatMessages:m,isStreaming:h,processingThreadIds:g}=e;c.current=u;let v=(0,Z.useCallback)((e,n,r)=>{if(l.current.get(e)!==r||(l.current.delete(e),r.stopHandled))return;let i=He(r.segments)||`...`;if(r.error&&(r.segments.length===0||i===`...`)){let i={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${r.error}`,contentType:`text`,timestamp:new Date().toISOString(),model:n||`default`,isThinking:!1};t({type:Y.AddMessage,message:i,threadId:e}),t({type:Y.ResetStream,threadId:e}),t({type:Y.RemoveProcessingThread,threadId:e});return}let a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:i,contentType:`markdown`,timestamp:new Date().toISOString(),model:n||`default`,isThinking:!1};t({type:Y.AddMessage,message:a,threadId:e}),t({type:Y.ResetStream,threadId:e}),t({type:Y.MarkThreadCompleted,threadId:e}),t({type:Y.RemoveProcessingThread,threadId:e})},[t]),y=(0,Z.useCallback)(()=>{if(!u)return;s(u);let n=l.current.get(u);n&&(n.stopHandled=!0,n.controller.abort(),n.cancel?.(),l.current.delete(u)),B(u);let r={messageId:`msg-${Date.now()}-stopped`,sender:`agent`,content:`I've stopped working on your request.`,contentType:`text`,timestamp:new Date().toISOString(),model:e.streamingModel||`default`,isThinking:!1};t({type:Y.AddMessage,message:r,threadId:u}),t({type:Y.ResetStream,threadId:u}),t({type:Y.MarkThreadCompleted,threadId:u}),t({type:Y.RemoveProcessingThread,threadId:u})},[u,t,e.streamingModel]);(0,Z.useEffect)(()=>()=>{for(let e of l.current.values())e.controller.abort(),e.cancel?.();l.current.clear()},[]),(0,Z.useEffect)(()=>{if(!u)return;let e=!1;async function n(){try{let n=await te(u);e||t({type:Y.SetMessages,messages:n.messages})}catch(n){console.error(`Failed to load chat history:`,n),e||t({type:Y.SetMessages,messages:[]})}}return n(),()=>{e=!0}},[u,d,t]);let b=(0,Z.useCallback)((e,n,i)=>{let o=l.current.get(e);o&&(o.controller.abort(),o.cancel?.());let s=new AbortController,u={controller:s,cancel:null,segments:[],assistantMessage:``,assistantThinking:``,hasStructuredContent:!1,error:null,stopHandled:!1};return l.current.set(e,u),t({type:Y.ResetStream,threadId:e}),t({type:Y.SetStreaming,isStreaming:!0,threadId:e}),n(s.signal).then(n=>{if(!n||s.signal.aborted){v(e,i,u);return}u.cancel=oe(n,n=>{if(t({type:Y.IncrementStreamEventCount,threadId:e}),n.type===`error`){let t=n.content||`Unknown error occurred`;u.error=t,e===c.current&&r(t);return}if(n.type!==`message`){if(n.type===`toolcall_delta`){n.partial?.content?.[0]?.id&&n.delta&&t({type:Y.UpdateToolCallProgress,toolCallId:n.partial.content[0].id,progress:{toolCallId:n.partial.content[0].id,toolName:n.partial.content[0].name,delta:n.delta,partial:n.partial}});return}if(n.model&&t({type:Y.SetStreamModel,model:n.model,threadId:e}),n.type===`thinking`||n.isThinking){let r=n.content??``;Pn(r,e),u.assistantThinking+=r,u.segments=Ve(u.segments,`thinking`,r),t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:r,segments:u.segments,threadId:e})}else if(n.type===`result`)u.hasStructuredContent=!0,u.assistantMessage=n.content??``,u.segments=Ue(u.segments,n.content??``),t({type:Y.SetStreamContent,content:n.content??``,threadId:e});else{if(u.hasStructuredContent)return;let r=n.content??``;u.assistantMessage+=r,u.segments=Ve(u.segments,`content`,r),t({type:Y.AppendStreamChunk,chunkType:`content`,content:r,segments:u.segments,threadId:e})}}},()=>{v(e,i,u)},t=>{if(t.includes(`AbortError`)||t.includes(`canceled`)||t.includes(`BodyStreamBuffer was aborted`)){v(e,i,u);return}u.error=t,e===c.current&&r(t)},n=>{if(t({type:Y.IncrementStreamEventCount,threadId:e}),n.role===`assistant`){let r=n.content??``,i=typeof r==`string`?r:JSON.stringify(r);if(n.isThinking??!1){u.assistantThinking+=i,u.segments=Ve(u.segments,`thinking`,i),t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:i,segments:u.segments,threadId:e});return}let a=!1;if(typeof r==`object`&&Array.isArray(r)&&r.length>0)a=!0;else if(typeof i==`string`&&i.trim().startsWith(`[`))try{let e=JSON.parse(i);a=Array.isArray(e)&&e.length>0}catch{}a?(u.hasStructuredContent=!0,u.assistantMessage=i,u.segments=Ue(u.segments,i),t({type:Y.SetStreamContent,content:i,threadId:e})):(u.assistantMessage+=i,u.segments=Ve(u.segments,`content`,i),t({type:Y.AppendStreamChunk,chunkType:`content`,content:i,segments:u.segments,threadId:e}))}else if(n.role===`tool`){let r=n.content??``,i=typeof r==`string`?r:JSON.stringify(r);i&&(u.assistantMessage+=i,u.segments=Ve(u.segments,`content`,i),t({type:Y.AppendStreamChunk,chunkType:`content`,content:i,segments:u.segments,threadId:e}))}})}).catch(n=>{if(l.current.delete(e),n instanceof Error&&n.name===`AbortError`){t({type:Y.ResetStream,threadId:e});return}if(n instanceof w){t({type:Y.ResetStream,threadId:e}),a(!0);return}if(n instanceof Error&&n.message.includes(`not currently processing`)){t({type:Y.ResetStream,threadId:e});return}let i=n instanceof Error?n.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`;e===c.current&&r(i),console.error(`Failed to subscribe to chat stream:`,n),t({type:Y.ResetStream,threadId:e})}),s},[t,v]);(0,Z.useEffect)(()=>{for(let t of g)l.current.has(t)||e.threadStreamingStates[t]?.isStreaming||b(t,e=>ve(t,e),`default`)},[b,g,e.threadStreamingStates]);let x=(0,Z.useCallback)(async(e,n,i,a,o,c,l)=>{if(!u)return;let f=u;r(null),s(null);let m=`msg-${Date.now()}`,h;try{let e=await p(f,m);e.success&&e.stashed&&e.checkpointRef&&(h=e.checkpointRef)}catch{}let g={messageId:m,sender:`user`,content:e,contentType:`text`,timestamp:new Date().toISOString(),model:n,attachments:i.map(e=>({fileName:e.fileName,content:e.content,mimeType:e.mimeType})),checkpointRef:h};t({type:Y.AddMessage,message:g,threadId:f});let v=e.trim().replace(/\n/g,` `).slice(0,100);if(d&&(_(f,{title:v}).catch(e=>{console.error(`Failed to update thread title:`,e)}),t({type:Y.UpdateThreadTitle,projectId:d,threadId:f,title:v})),c){let r=a??void 0;if(!r&&typeof n==`string`){let e=n.split(/[:/]/)[0]?.trim();e&&(r=e)}if(!r){let e={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Image generation is not available because no provider is configured for the selected model.`,contentType:`text`,timestamp:new Date().toISOString(),model:n,isThinking:!1};t({type:Y.AddMessage,message:e,threadId:f}),t({type:Y.ResetStream,threadId:f});return}t({type:Y.SetStreaming,isStreaming:!0,threadId:f});try{let i=await se(e,n,r,f),a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:e,contentType:`text`,timestamp:new Date().toISOString(),model:n,isThinking:!1,generatedImageUrl:i.imageUrl,generatedImageData:i.imageData};t({type:Y.AddMessage,message:a,threadId:f})}catch(e){let r=e instanceof Error?e.message:`Image generation failed`,i={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${r}`,contentType:`text`,timestamp:new Date().toISOString(),model:n,isThinking:!1};t({type:Y.AddMessage,message:i,threadId:f})}finally{t({type:Y.ResetStream,threadId:f})}return}b(f,t=>K(f,e,n,i,t,a,o,l),n)},[u,d,t,b]);(0,Z.useEffect)(()=>{let n=e.pendingChatMessage;if(!n||h||n.threadId!==u)return;let r=setTimeout(()=>{t({type:Y.ClearPendingChatMessage}),x(n.message,n.model,[],n.provider)},100);return()=>clearTimeout(r)},[e.pendingChatMessage,h,u,t,x]);let S=(0,Z.useMemo)(()=>u?m.filter(e=>e.threadId===u):[],[u,m]),C=(0,Z.useRef)(!1);return(0,Z.useEffect)(()=>{if(h||!u||S.length===0||C.current)return;let[e]=S;C.current=!0,t({type:Y.RemoveQueuedChatMessage,queuedMessageId:e.id});let n=setTimeout(()=>{x(e.message,e.model,e.attachments,e.provider,e.planMode,e.imageMode,e.ralphMode),C.current=!1},0);return()=>{clearTimeout(n),C.current=!1}},[t,x,h,S,u]),{error:n,setError:r,handleSend:x,handleStop:y,isStreaming:h,selectedThreadId:u,queuedMessagesForThread:S,handleRemoveQueuedMessage:(0,Z.useCallback)(e=>{let n=S.find(t=>t.id===e);t({type:Y.RemoveQueuedChatMessage,queuedMessageId:e}),!(!n||h||f.length>0||!u)&&x(n.message,n.model,n.attachments,n.provider,n.planMode,n.imageMode,n.ralphMode)},[t,x,h,f.length,S,u]),showEmptyBalanceDialog:i,setShowEmptyBalanceDialog:a}}function In(e){let t=(0,X.c)(10),{open:n,onClose:r}=e,i=xe(),a;t[0]===r?a=t[1]:(a=e=>{e||r()},t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsxs)($e,{children:[(0,Q.jsx)(Xe,{children:`Balance empty`}),(0,Q.jsx)(Ye,{children:`You have no prompts remaining. Purchase additional prompts to continue.`})]}),t[2]=o):o=t[2];let s;t[3]!==i||t[4]!==r?(s=(0,Q.jsxs)(Ze,{children:[o,(0,Q.jsx)(Qe,{children:(0,Q.jsx)(J,{onClick:()=>{r(),i(`/settings/account`)},children:`Go to Account`})})]}),t[3]=i,t[4]=r,t[5]=s):s=t[5];let c;return t[6]!==n||t[7]!==a||t[8]!==s?(c=(0,Q.jsx)(et,{open:n,onOpenChange:a,children:s}),t[6]=n,t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function Ln(e){let t=(0,X.c)(13),{todos:n}=e,r;t[0]===n?r=t[1]:(r=n.filter(zn),t[0]=n,t[1]=r);let i=r.length,a;t[2]===n.length?a=t[3]:(a=n.length===0&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No todo items.`}),t[2]=n.length,t[3]=a);let o;t[4]===n?o=t[5]:(o=n.map(Rn),t[4]=n,t[5]=o);let s;t[6]!==i||t[7]!==n.length?(s=n.length>0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground pt-1`,children:[i,`/`,n.length,` completed`]}),t[6]=i,t[7]=n.length,t[8]=s):s=t[8];let c;return t[9]!==a||t[10]!==o||t[11]!==s?(c=(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[a,o,s]}),t[9]=a,t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function Rn(e){return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`done`?(0,Q.jsx)(he,{className:`h-4 w-4 shrink-0 mt-0.5 text-brand`}):e.status===`working`?(0,Q.jsx)(b,{className:`h-4 w-4 shrink-0 mt-0.5 text-yellow-500`}):(0,Q.jsx)(t,{className:`h-4 w-4 shrink-0 mt-0.5 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:e.status===`done`?`line-through text-muted-foreground`:`text-foreground`,children:e.description})]},e.id)}function zn(e){return e.status===`done`}function Bn(){let e=(0,X.c)(16),{todos:t}=(0,Z.useContext)(pt),[n,r]=(0,Z.useState)(!1),i;e[0]===t?i=e[1]:(i=t.filter(Vn),e[0]=t,e[1]=i);let a=i.length;if(t.length-a<=0)return null;let o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>r(!0),s=(0,Q.jsx)(_e,{className:`h-4 w-4 shrink-0`}),e[2]=o,e[3]=s):(o=e[2],s=e[3]);let c;e[4]!==a||e[5]!==t.length?(c=(0,Q.jsxs)(J,{variant:`outline`,size:`sm`,className:`gap-2 bg-background ml-2`,onClick:o,children:[s,a,` of `,t.length,` complete`]}),e[4]=a,e[5]=t.length,e[6]=c):c=e[6];let u;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(le,{children:(0,Q.jsx)(l,{children:`Tasks`})}),e[7]=u):u=e[7];let d;e[8]===t?d=e[9]:(d=(0,Q.jsxs)(k,{className:`max-w-md`,children:[u,(0,Q.jsx)(Ln,{todos:t})]}),e[8]=t,e[9]=d);let f;e[10]!==n||e[11]!==d?(f=(0,Q.jsx)(E,{open:n,onOpenChange:r,children:d}),e[10]=n,e[11]=d,e[12]=f):f=e[12];let p;return e[13]!==c||e[14]!==f?(p=(0,Q.jsxs)(Q.Fragment,{children:[c,f]}),e[13]=c,e[14]=f,e[15]=p):p=e[15],p}function Vn(e){return e.status===`done`}function Hn(e){let t=(0,X.c)(36),{messages:r}=e,i;t[0]===r?i=t[1]:(i=r===void 0?[]:r,t[0]=r,t[1]=i);let a=i,{state:o,dispatch:s}=Be(),{isCreatingProject:c,selectedThreadId:l}=o,{handleSend:u,handleStop:d,isStreaming:f,queuedMessagesForThread:p,handleRemoveQueuedMessage:m,showEmptyBalanceDialog:h,setShowEmptyBalanceDialog:g}=Fn(),_=o.pendingChatMessage?.threadId===l,y=f||_,b=a.length>0,{hasChanges:x,changedFilesCount:S}=An(l??void 0),{setActiveMainTab:C}=tt(),w;t[2]!==s||t[3]!==l?(w=async()=>{if(l)try{let e=await n(l);s({type:Y.ClearMessages}),console.log(`New conversation started:`,e);let t=await te(l);s({type:Y.SetMessages,messages:t.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},t[2]=s,t[3]=l,t[4]=w):w=t[4];let T=w,E;t[5]===g?E=t[6]:(E=()=>g(!1),t[5]=g,t[6]=E);let D;t[7]!==h||t[8]!==E?(D=(0,Q.jsx)(In,{open:h,onClose:E}),t[7]=h,t[8]=E,t[9]=D):D=t[9];let O;t[10]!==S||t[11]!==T||t[12]!==x||t[13]!==b||t[14]!==C?(O=(b||x)&&(0,Q.jsxs)(`div`,{className:`absolute -top-12 left-0 z-10 ml-8 flex items-center gap-2`,children:[b&&(0,Q.jsxs)(J,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:T,children:[(0,Q.jsx)(R,{className:`h-4 w-4 shrink-0`}),`New Chat`]}),x&&(0,Q.jsxs)(J,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:()=>C(`review`),children:[(0,Q.jsx)(v,{className:`h-4 w-4 shrink-0`}),S,` `,S===1?`File`:`Files`,` Changed`]}),b&&(0,Q.jsx)(Bn,{})]}),t[10]=S,t[11]=T,t[12]=x,t[13]=b,t[14]=C,t[15]=O):O=t[15];let k=!l&&!c,A;t[16]!==y||t[17]!==m||t[18]!==u||t[19]!==d||t[20]!==p||t[21]!==k?(A=(0,Q.jsx)(Qt,{onSend:u,onStop:d,isStreaming:y,disabled:k,initialValue:``,queuedMessages:p,onRemoveQueuedMessage:m,isOverlay:!1}),t[16]=y,t[17]=m,t[18]=u,t[19]=d,t[20]=p,t[21]=k,t[22]=A):A=t[22];let j;t[23]!==O||t[24]!==A?(j=(0,Q.jsxs)(`div`,{className:`relative`,children:[O,A]}),t[23]=O,t[24]=A,t[25]=j):j=t[25];let M=l??void 0,N;t[26]!==y||t[27]!==a||t[28]!==M?(N=(0,Q.jsx)(Nn,{threadId:M,isStreaming:y,messages:a}),t[26]=y,t[27]=a,t[28]=M,t[29]=N):N=t[29];let P;t[30]!==N||t[31]!==j?(P=(0,Q.jsxs)(`div`,{className:`relative mx-auto min-w-[400px] w-[90vw] max-w-3xl`,children:[j,N]}),t[30]=N,t[31]=j,t[32]=P):P=t[32];let F;return t[33]!==P||t[34]!==D?(F=(0,Q.jsxs)(Q.Fragment,{children:[D,P]}),t[33]=P,t[34]=D,t[35]=F):F=t[35],F}export{ut as _,un as a,lt as b,cn as c,Ct as d,yt as f,ht as g,mt as h,ln as i,sn as l,gt as m,An as n,mn as o,bt as p,rn as r,on as s,Hn as t,an as u,ft as v,dt as y};
@@ -1 +0,0 @@
1
- import{t as e}from"./history-view-i7fGKCkc.js";export{e as ConversationHistoryView,e as default};
@@ -1,3 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Bi as t,Ci as n,Er as r,Jn as i,Kn as a,Li as o,Ln as s,Nr as c,On as l,Pt as u,Ri as d,Si as f,Un as p,Wn as m,_a as h,aa as g,et as _,ft as v,ha as y,ia as b,mi as x,oi as S,ot as C,pi as w,qn as T,qt as E,wr as D,xi as O,yi as k}from"./dialogs-config-BXDglGdB.js";import{D as ee}from"./react-vendor-Bpg1hd5i.js";import{Mt as A}from"./monaco-BGyhgQtx.js";import{a as j,t as M}from"./store-B9rEO6q-.js";import{t as N}from"./textarea-CwXpBxom.js";import{c as P,s as te,u as ne}from"./history-view-i7fGKCkc.js";import{b as re,t as ie}from"./chat-input-container-BNOl7YtC.js";import{t as F}from"./standard-list-item-BLTOBGFa.js";import{n as ae}from"./utils-CDrGT12s.js";import{t as oe}from"./page-toolbar-CbwENcML.js";import{n as se,r as ce,t as I}from"./resizable-BLhzHL_f.js";import{a as L,n as R,r as le,t as z}from"./context-menu-XD6khGRr.js";var B=e(h(),1),V=y(),H=c();function U(e){let t=(0,V.c)(17),{children:n,title:r,headerAction:i,footer:a}=e,o;t[0]===r?o=t[1]:(o=r&&(0,H.jsx)(`span`,{className:`text-sm font-semibold tracking-tight`,children:r}),t[0]=r,t[1]=o);let c;t[2]===o?c=t[3]:(c=(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:o}),t[2]=o,t[3]=c);let l;t[4]===i?l=t[5]:(l=i&&(0,H.jsx)(`div`,{className:`flex items-center gap-2 ml-auto`,children:i}),t[4]=i,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,H.jsxs)(`div`,{className:`flex items-center justify-between border-b border-sidebar-border px-4 py-6`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]===n?d=t[10]:(d=(0,H.jsx)(s,{className:`flex-1`,children:n}),t[9]=n,t[10]=d);let f;t[11]===a?f=t[12]:(f=a&&(0,H.jsx)(`div`,{className:`border-t border-sidebar-border`,children:a}),t[11]=a,t[12]=f);let p;return t[13]!==u||t[14]!==d||t[15]!==f?(p=(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[u,d,f]}),t[13]=u,t[14]=d,t[15]=f,t[16]=p):p=t[16],p}function ue(e){let t=[],n={};return e.forEach((e,r)=>{let i=e.path.split(`/`),a=t,o=``;for(let e=0;e<i.length-1;e++){if(o=o?`${o}/${i[e]}`:i[e],!n[o]){let t={id:`dir:${o}`,name:i[e],children:[]};n[o]=t,a.push(t)}a=n[o].children}a.push({id:`file:${e.path}`,name:i[i.length-1],fileIndex:r,status:e.status})}),t}var W={added:`text-green-500`,deleted:`text-red-500`,untracked:`text-green-500`,renamed:`text-blue-500`,modified:`text-orange-500`},G={added:`A`,deleted:`D`,untracked:`U`,renamed:`R`,modified:`M`};function K(e){return r(`status-badge font-mono text-xs font-semibold`,W[e]??`text-orange-500`)}function de(e){return G[e]??`M`}function fe(e){let i=(0,V.c)(37),{treeData:a,files:s,isLoading:c,error:l,selectedFileIndex:u,onFileSelect:f,onRevertFile:p}=e,m;i[0]===s?m=i[1]:(m=s.reduce(he,0),i[0]=s,i[1]=m);let h=m,g;i[2]===s?g=i[3]:(g=s.reduce(pe,0),i[2]=s,i[3]=g);let _=g,v=s.length===1?``:`s`,y;i[4]!==s.length||i[5]!==v?(y=(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s.length,` file`,v]}),i[4]=s.length,i[5]=v,i[6]=y):y=i[6];let x;i[7]===h?x=i[8]:(x=(0,H.jsxs)(`span`,{className:`text-xs text-green-500`,children:[`+`,h]}),i[7]=h,i[8]=x);let C;i[9]===_?C=i[10]:(C=(0,H.jsxs)(`span`,{className:`text-xs text-red-500`,children:[`-`,_]}),i[9]=_,i[10]=C);let w;i[11]!==y||i[12]!==x||i[13]!==C?(w=(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[y,x,C]}),i[11]=y,i[12]=x,i[13]=C,i[14]=w):w=i[14];let T=w;if(c){let e;i[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center pt-3 pb-2`,children:(0,H.jsx)(n,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),i[15]=e):e=i[15];let t;return i[16]===T?t=i[17]:(t=(0,H.jsx)(U,{title:`Review Changes`,headerAction:T,children:e}),i[16]=T,i[17]=t),t}if(l){let e;i[18]===l?e=i[19]:(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4 pt-7 pb-2`,children:(0,H.jsx)(`p`,{className:`text-destructive text-xs text-center`,children:l})}),i[18]=l,i[19]=e);let t;return i[20]!==T||i[21]!==e?(t=(0,H.jsx)(U,{title:`Review Changes`,headerAction:T,children:e}),i[20]=T,i[21]=e,i[22]=t):t=i[22],t}if(s.length===0){let e;i[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4 pt-7 pb-2`,children:(0,H.jsx)(`p`,{className:`text-muted-foreground text-xs text-center`,children:`No changes to review`})}),i[23]=e):e=i[23];let t;return i[24]===T?t=i[25]:(t=(0,H.jsx)(U,{title:`Review Changes`,headerAction:T,children:e}),i[24]=T,i[25]=t),t}let E;i[26]!==s||i[27]!==f||i[28]!==p||i[29]!==u?(E=(e,n)=>{let{isOpen:i,toggle:a}=n,c=!!e.children,l=(0,H.jsxs)(F,{onClick:()=>{c?a():e.fileIndex!==void 0&&f(e.fileIndex)},selected:!c&&e.fileIndex===u,className:`gap-1.5`,children:[c?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(b,{className:r(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,i&&`rotate-90`)}),i?(0,H.jsx)(d,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,H.jsx)(o,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}):(0,H.jsx)(t,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`truncate flex-1 min-w-0`,children:e.name}),!c&&e.status&&(0,H.jsx)(`span`,{className:K(e.status),children:de(e.status)})]});return c?l:(0,H.jsxs)(z,{children:[(0,H.jsx)(L,{asChild:!0,children:l}),(0,H.jsx)(R,{children:(0,H.jsxs)(le,{onClick:()=>{e.fileIndex!==void 0&&p?.(s[e.fileIndex])},children:[(0,H.jsx)(S,{className:`mr-2 h-3.5 w-3.5`}),`Revert Change`]})})]})},i[26]=s,i[27]=f,i[28]=p,i[29]=u,i[30]=E):E=i[30];let D;i[31]!==E||i[32]!==a?(D=(0,H.jsx)(`div`,{className:`flex-1 overflow-y-auto pt-3 pb-2 px-1`,children:(0,H.jsx)(re,{nodes:a,defaultOpen:!0,resetKey:a,indent:16,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:E})}),i[31]=E,i[32]=a,i[33]=D):D=i[33];let O;return i[34]!==T||i[35]!==D?(O=(0,H.jsx)(U,{title:`Review Changes`,headerAction:T,children:D}),i[34]=T,i[35]=D,i[36]=O):O=i[36],O}function pe(e,t){return e+t.hunks.reduce(q,0)}function q(e,t){return e+t.changes.filter(me).length}function me(e){return e.type===`delete`}function he(e,t){return e+t.hunks.reduce(J,0)}function J(e,t){return e+t.changes.filter(ge).length}function ge(e){return e.type===`add`}function _e(e){let t=(0,V.c)(2),{isOpen:n}=e,r=n===void 0||n?`ml-[-40px]`:``,i;return t[0]===r?i=t[1]:(i=(0,H.jsx)(I,{withHandle:!0,className:r}),t[0]=r,t[1]=i),i}function ve(e){let t=(0,V.c)(35),{open:n,lineNumber:r,lineContent:o,initialComment:s,isEditing:c,onSave:l,onDelete:u,onClose:d}=e,[f,h]=(0,B.useState)((s===void 0?``:s)??``),g;t[0]!==l||t[1]!==f?(g=()=>{f.trim()&&l(f.trim())},t[0]=l,t[1]=f,t[2]=g):g=t[2];let _=g,v;t[3]===_?v=t[4]:(v=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),_())},t[3]=_,t[4]=v);let y=v,b;t[5]===d?b=t[6]:(b=e=>{e||d()},t[5]=d,t[6]=b);let x;t[7]===r?x=t[8]:(x=(0,H.jsx)(T,{children:(0,H.jsxs)(i,{className:`text-sm font-medium`,children:[`Comment on line `,r]})}),t[7]=r,t[8]=x);let S=o||` `,C;t[9]===S?C=t[10]:(C=(0,H.jsx)(`div`,{className:`rounded bg-muted px-3 py-2 font-mono text-xs text-muted-foreground overflow-x-auto whitespace-pre`,children:S}),t[9]=S,t[10]=C);let w;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(w=e=>h(e.target.value),t[11]=w):w=t[11];let E;t[12]!==y||t[13]!==f?(E=(0,H.jsx)(N,{autoFocus:!0,placeholder:`Add a comment... (Cmd+Enter to save)`,value:f,onChange:w,onKeyDown:y,rows:12,className:`resize-none text-sm`}),t[12]=y,t[13]=f,t[14]=E):E=t[14];let O;t[15]!==c||t[16]!==u?(O=c&&u&&(0,H.jsx)(D,{variant:`destructive`,size:`sm`,onClick:u,className:`mr-auto`,children:`Delete`}),t[15]=c,t[16]=u,t[17]=O):O=t[17];let k;t[18]===f?k=t[19]:(k=f.trim(),t[18]=f,t[19]=k);let ee=!k,A;t[20]!==_||t[21]!==ee?(A=(0,H.jsx)(D,{size:`sm`,onClick:_,disabled:ee,children:`Save`}),t[20]=_,t[21]=ee,t[22]=A):A=t[22];let j;t[23]!==O||t[24]!==A?(j=(0,H.jsxs)(a,{className:`gap-2 sm:gap-0`,children:[O,A]}),t[23]=O,t[24]=A,t[25]=j):j=t[25];let M;t[26]!==j||t[27]!==x||t[28]!==C||t[29]!==E?(M=(0,H.jsxs)(m,{className:`max-w-2xl`,children:[x,C,E,j]}),t[26]=j,t[27]=x,t[28]=C,t[29]=E,t[30]=M):M=t[30];let P;return t[31]!==n||t[32]!==M||t[33]!==b?(P=(0,H.jsx)(p,{open:n,onOpenChange:b,children:M}),t[31]=n,t[32]=M,t[33]=b,t[34]=P):P=t[34],P}function Y({threadId:e,onExit:t}){let{state:n,dispatch:i}=j(),{resolvedTheme:a}=ae(),[o,s]=(0,B.useState)([]),[c,d]=(0,B.useState)(!0),[p,m]=(0,B.useState)(null),[h,y]=(0,B.useState)(0),[S,T]=(0,B.useState)(!1),[N,re]=(0,B.useState)(!1),F=(0,B.useRef)(null),I=(0,B.useMemo)(()=>n.diffComments[e]??[],[n.diffComments,e]),L=(0,B.useCallback)(t=>{let r=n.diffComments[e]??[],a=typeof t==`function`?t(r):t;i({type:M.SetDiffComments,threadId:e,comments:a})},[i,e,n.diffComments]),[R,le]=(0,B.useState)(null),[z,V]=(0,B.useState)(null),[U,W]=(0,B.useState)(null),G=(0,B.useRef)(null),K=(0,B.useRef)(I),de=(0,B.useRef)(R),pe=(0,B.useRef)({isFullView:S,selectedFileIndex:h,files:o}),q=(0,B.useRef)({original:[],modified:[]}),me=(0,B.useRef)(!0);(0,B.useEffect)(()=>{K.current=I},[I]),(0,B.useEffect)(()=>{de.current=R},[R]),(0,B.useEffect)(()=>{pe.current={isFullView:S,selectedFileIndex:h,files:o}},[S,h,o]);let he=(0,B.useCallback)(()=>{F.current&&(N?F.current.expand():F.current.collapse())},[N]),J=(0,B.useCallback)(async()=>{if(e){d(!0),m(null);try{s((await v(e)).files||[]),y(0)}catch(e){m(e instanceof Error?e.message:`Failed to load diff`)}finally{d(!1)}}},[e]);(0,B.useEffect)(()=>{J()},[J]);let ge=(0,B.useCallback)(async t=>{try{await E(e,t.path),await J()}catch(e){m(e instanceof Error?e.message:`Failed to revert file`)}},[e,J]),Y=(0,B.useRef)(!1);(0,B.useEffect)(()=>{if((n.diffComments[e]??[]).length>0){Y.current=!0;return}u(e).then(t=>{t.diffComments&&t.diffComments.length>0&&i({type:M.SetDiffComments,threadId:e,comments:t.diffComments}),Y.current=!0}).catch(()=>{Y.current=!0})},[e]),(0,B.useEffect)(()=>{Y.current&&l(e,{diffComments:I}).catch(()=>{})},[e,I]);let ye=(0,B.useMemo)(()=>ue(o),[o]),X=e=>{if(e.hunks.length===0)return null;let t=1/0,n=0;return e.hunks.forEach(e=>{let r=Math.min(e.oldStart,e.newStart),i=e.oldStart+e.oldLines,a=e.newStart+e.newLines,o=Math.max(i,a);t=Math.min(t,r),n=Math.max(n,o)}),t===1/0?null:{startLine:Math.max(1,t-2),endLine:n+2}},be=(e,t,n)=>e.split(`
2
- `).slice(t-1,n).join(`
3
- `),xe=e=>{let t=X(e);return t?t.startLine<=1:!0},Se=e=>({ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,scss:`scss`,html:`html`,py:`python`,rb:`ruby`,go:`go`,rs:`rust`,java:`java`,kt:`kotlin`,swift:`swift`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,sh:`shell`,yaml:`yaml`,yml:`yaml`,xml:`xml`,sql:`sql`})[e.split(`.`).pop()??``]||`plaintext`,Z=o[h],Ce=Z?S?Z.oldContent:(()=>{let e=X(Z);return e?be(Z.oldContent,e.startLine,e.endLine):Z.oldContent})():``,we=Z?S?Z.newContent:(()=>{let e=X(Z);return e?be(Z.newContent,e.startLine,e.endLine):Z.newContent})():``,Q=(0,B.useCallback)(()=>{if(!me.current)return;let e=G.current;if(!e)return;let{isFullView:t,selectedFileIndex:n,files:r}=pe.current,i=K.current,a=de.current,o=r[n];if(!o)return;let s=(e,r)=>{let s=t?null:X(o),c=i.filter(e=>e.fileIndex===n&&e.side===r),l=new Set(c.map(e=>s?e.lineNumber-s.startLine+1:e.lineNumber)),u=e.getModel()?.getLineCount()??0,d=[];for(let e=1;e<=u;e++)l.has(e)||d.push({range:{startLineNumber:e,startColumn:1,endLineNumber:e,endColumn:1},options:{isWholeLine:!0,glyphMarginClassName:`diff-gutter-add-comment`,glyphMarginHoverMessage:{value:`$(add) Click to add a comment`},stickiness:A.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges}});let f=c.map(e=>{let t=s?e.lineNumber-s.startLine+1:e.lineNumber;if(t<1)return null;let n=i.indexOf(e)===a;return{range:{startLineNumber:t,startColumn:1,endLineNumber:t,endColumn:1},options:{isWholeLine:!0,className:n?`diff-comment-active-line`:`diff-comment-marked-line`,glyphMarginClassName:n?`diff-comment-glyph-active`:`diff-comment-glyph`,glyphMarginHoverMessage:{value:e.comment},stickiness:A.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges}}}).filter(e=>e!==null);d.push(...f);let p=r===`original`?q.current.original:q.current.modified,m=e.deltaDecorations(p,d);r===`original`?q.current.original=m:q.current.modified=m};s(e.getOriginalEditor(),`original`),s(e.getModifiedEditor(),`modified`)},[]);(0,B.useEffect)(()=>{Q()},[Q,I,R,h,S,Z]),(0,B.useEffect)(()=>()=>{G.current=null,q.current={original:[],modified:[]}},[h]),(0,B.useEffect)(()=>()=>{me.current=!1,G.current&&=(G.current.getOriginalEditor().getModel()?.dispose(),G.current.getModifiedEditor().getModel()?.dispose(),G.current.dispose(),null),q.current={original:[],modified:[]}},[]);let Te=(0,B.useCallback)(e=>{G.current=e;let t=e=>e===A.MouseTargetType.GUTTER_GLYPH_MARGIN||e===A.MouseTargetType.GUTTER_LINE_NUMBERS||e===A.MouseTargetType.GUTTER_LINE_DECORATIONS||e===A.MouseTargetType.GUTTER_VIEW_ZONE,n=(e,n)=>{e.onMouseDown(r=>{if(!r.target?.position||!t(r.target.type))return;let i=r.target.position.lineNumber,{isFullView:a,selectedFileIndex:o,files:s}=pe.current,c=s[o];if(!c)return;let l=a?null:X(c),u=l?l.startLine+i-1:i,d=e.getModel()?.getLineContent(i)??``,f=K.current.find(e=>e.fileIndex===o&&e.lineNumber===u&&e.side===n);f?W(f):V({lineNumber:u,lineContent:d,side:n})})};n(e.getOriginalEditor(),`original`),n(e.getModifiedEditor(),`modified`),setTimeout(()=>{G.current===e&&Q()},150)},[Q]),Ee=(0,B.useCallback)(e=>{if(z&&Z){let t={id:`comment-${Date.now()}`,filePath:Z.path,fileIndex:h,lineNumber:z.lineNumber,lineContent:z.lineContent,comment:e,side:z.side};L(e=>[...e,t]),V(null)}else U&&(L(t=>t.map(t=>t.id===U.id?{...t,comment:e}:t)),W(null))},[z,U,Z,h,L]),De=(0,B.useCallback)(()=>{U&&(L(e=>e.filter(e=>e.id!==U.id)),W(null))},[U,L]),$=(0,B.useCallback)(e=>{if(I.length===0)return;let t=(e%I.length+I.length)%I.length,n=I[t];le(t),y(n.fileIndex),setTimeout(()=>{let e=G.current;if(!e)return;let t=o[n.fileIndex];if(!t)return;let r=S?null:X(t),i=r?n.lineNumber-r.startLine+1:n.lineNumber;(n.side===`original`?e.getOriginalEditor():e.getModifiedEditor()).revealLineInCenter(Math.max(1,i)),Q()},100)},[I,o,S,Q]),Oe=(0,B.useCallback)(()=>{$((R??0)-1)},[$,R]),ke=(0,B.useCallback)(()=>{$((R??-1)+1)},[$,R]),Ae=(0,B.useCallback)(async()=>{let r=n.projectModelSelections[e];if(!r)try{let e=await C(),t=Object.values(e).flat();if(t.length>0)r=t[0];else{console.error(`No models available to process comments`);return}}catch(e){console.error(`Failed to load models:`,e);return}let a=r.id,o=r.provider;try{let{prompt:n}=await _(e,I);L([]),i({type:M.SetPendingChatMessage,message:{threadId:e,message:n,model:a,provider:o}}),t()}catch(e){console.error(`Failed to fix comments:`,e),typeof window<`u`&&window.alert(`Failed to process comments. Please try again.`)}},[I,n.projectModelSelections,i,e,t,L]),je={readOnly:!0,renderSideBySide:!0,ignoreTrimWhitespace:!1,renderOverviewRuler:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1},folding:!1,glyphMargin:!0,lineNumbers:Z&&(S||xe(Z))?`on`:`off`,diffWordWrap:`on`,originalEditable:!1,automaticLayout:!0};return(0,H.jsxs)(`div`,{className:`diff-view-root flex h-full flex-col`,children:[(0,H.jsx)(`div`,{className:`diff-body flex flex-1 overflow-hidden`,children:(0,H.jsxs)(ce,{direction:`horizontal`,children:[(0,H.jsx)(se,{ref:F,defaultSize:25,minSize:12,maxSize:40,collapsible:!0,collapsedSize:0,onCollapse:()=>re(!0),onExpand:()=>re(!1),className:`border-r border-transparent`,children:(0,H.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,H.jsx)(fe,{treeData:ye,files:o,isLoading:c,error:p,selectedFileIndex:h,onFileSelect:y,onRevertFile:ge})})}),(0,H.jsx)(_e,{isOpen:!N}),(0,H.jsx)(se,{className:`overflow-hidden bg-transparent`,children:(0,H.jsxs)(`div`,{className:`diff-editor-panel flex h-full bg-transparent flex-col overflow-hidden`,children:[(0,H.jsxs)(oe,{className:r(`bg-transparent`,N&&`h-auto py-3 flex-col items-start gap-3 md:flex-row md:items-center md:h-[71px] md:py-0 md:gap-2 justify-between`),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(D,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground shrink-0`,onClick:he,children:[N?(0,H.jsx)(w,{className:`h-4 w-4`}):(0,H.jsx)(x,{className:`h-4 w-4`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Toggle file tree`})]}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:Z?Z.path:`Review Changes`})]}),(0,H.jsxs)(`div`,{className:r(`flex items-center gap-2`,N&&`ml-0`,!N&&`ml-auto`,`md:ml-auto`),children:[(0,H.jsx)(D,{variant:`ghost`,size:`sm`,onClick:()=>T(e=>!e),disabled:!Z,className:`h-8 gap-1 px-2 text-xs`,children:S?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(k,{className:`h-3 w-3`}),` Show changes only`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(f,{className:`h-3 w-3`}),` Show full file`]})}),I.length>0&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(te,{children:[(0,H.jsx)(ne,{asChild:!0,children:(0,H.jsx)(D,{variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-full`,onClick:Oe,disabled:(R??0)===0,children:(0,H.jsx)(g,{className:`h-3 w-3`})})}),(0,H.jsx)(P,{children:`Previous comment`})]}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:I.length===1?`1 Comment`:`Comment ${(R??0)+1} of ${I.length}`}),(0,H.jsxs)(te,{children:[(0,H.jsx)(ne,{asChild:!0,children:(0,H.jsx)(D,{variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-full`,onClick:ke,disabled:(R??0)===I.length-1,children:(0,H.jsx)(b,{className:`h-3 w-3`})})}),(0,H.jsx)(P,{children:`Next comment`})]})]}),I.length>0&&(0,H.jsxs)(te,{children:[(0,H.jsx)(ne,{asChild:!0,children:(0,H.jsxs)(D,{size:`sm`,onClick:Ae,className:`h-8 gap-1 px-3 text-xs bg-foreground text-background hover:bg-foreground/90`,children:[(0,H.jsx)(O,{className:`h-3 w-3`}),`Fix all comments`]})}),(0,H.jsx)(P,{children:`Send all comments to Tarsk for resolution`})]})]})]}),(0,H.jsxs)(`div`,{className:`flex-1 bg-transparent relative`,children:[(0,H.jsx)(ee,{height:`100%`,language:Se(Z?.path||``),original:Ce,modified:we,theme:a===`dark`?`vs-dark`:`vs-light`,onMount:Te,options:je},`diff-${h}`),(0,H.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0`,children:(0,H.jsx)(ie,{})})]})]})})]})}),(0,H.jsx)(ve,{open:z!==null||U!==null,lineNumber:U?.lineNumber??z?.lineNumber??0,lineContent:U?.lineContent??z?.lineContent??``,initialComment:U?.comment,isEditing:U!==null,onSave:Ee,onDelete:De,onClose:()=>{V(null),W(null)}},`${U?.id??``}-${z?.lineNumber??``}-${z?.side??``}`)]})}export{Y as DiffView,Y as default};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/explorer-tree-D0P-HUYS.js","assets/rolldown-runtime-B1FJdls4.js","assets/dialogs-config-BXDglGdB.js","assets/api-RbLAI1bg.js","assets/alert-dialog-Dj0hDlZC.js","assets/react-vendor-Bpg1hd5i.js","assets/monaco-BGyhgQtx.js","assets/monaco-Br_kD0ds.css","assets/history-view-i7fGKCkc.js","assets/context-menu-XD6khGRr.js","assets/standard-list-item-BLTOBGFa.js","assets/use-toast-C5s-Xnwi.js","assets/tab-context-BUUT3x3d.js","assets/explorer-view-CL_9lhkq.js","assets/markdown-renderer-CPSKOcqK.js","assets/page-toolbar-CbwENcML.js","assets/store-B9rEO6q-.js","assets/utils-CDrGT12s.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Ln as t,Nr as n,_a as r,ha as i}from"./dialogs-config-BXDglGdB.js";import{Pt as a}from"./monaco-BGyhgQtx.js";import{a as o}from"./store-B9rEO6q-.js";import{n as s}from"./tab-context-BUUT3x3d.js";import{n as c,r as l,t as u}from"./resizable-BLhzHL_f.js";var d=i(),f=e(r(),1),p=n(),m=(0,f.lazy)(()=>a(()=>import(`./explorer-tree-D0P-HUYS.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),h=(0,f.lazy)(()=>a(()=>import(`./explorer-view-CL_9lhkq.js`),__vite__mapDeps([13,1,2,3,14,6,7,8,15,11,16,5,17])));function g(){let e=(0,d.c)(17),{state:n}=o(),r=n.selectedThreadId,[i,a]=(0,f.useState)(null),{pendingExplorerPath:g,setPendingExplorerPath:v,explorerClearPath:y,setExplorerClearPath:b}=s(),x,S;e[0]!==g||e[1]!==v?(x=()=>{g&&(a({name:g.split(`/`).pop()??g,type:`file`,path:g}),v(null))},S=[g,v],e[0]=g,e[1]=v,e[2]=x,e[3]=S):(x=e[2],S=e[3]),(0,f.useEffect)(x,S);let C,w;e[4]!==y||e[5]!==b?(C=()=>{y&&(a(e=>e&&(e.path===y||e.path.startsWith(y+`/`)?null:e)),b(null))},w=[y,b],e[4]=y,e[5]=b,e[6]=C,e[7]=w):(C=e[6],w=e[7]),(0,f.useEffect)(C,w);let T;e[8]!==i?.path||e[9]!==r?(T=(0,p.jsx)(c,{defaultSize:25,minSize:15,maxSize:50,className:`overflow-hidden border-r border-border`,children:(0,p.jsx)(t,{className:`h-full`,children:r?(0,p.jsx)(f.Suspense,{fallback:(0,p.jsx)(`div`,{className:`space-y-1 px-2 py-2`,children:[1,2,3].map(_)}),children:(0,p.jsx)(m,{threadId:r,selectedPath:i?.path??null,onFileSelect:a})}):(0,p.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground text-center`,children:`No thread selected.`})})}),e[8]=i?.path,e[9]=r,e[10]=T):T=e[10];let E;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,p.jsx)(u,{withHandle:!0}),e[11]=E):E=e[11];let D;e[12]===i?D=e[13]:(D=(0,p.jsx)(c,{className:`overflow-hidden`,children:(0,p.jsx)(f.Suspense,{fallback:null,children:(0,p.jsx)(h,{selectedFile:i})})}),e[12]=i,e[13]=D);let O;return e[14]!==T||e[15]!==D?(O=(0,p.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:(0,p.jsxs)(l,{direction:`horizontal`,className:`flex-1 overflow-hidden`,children:[T,E,D]})}),e[14]=T,e[15]=D,e[16]=O):O=e[16],O}function _(e){return(0,p.jsx)(`div`,{className:`animate-pulse h-7 bg-muted rounded-full`},e)}export{g as default};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Bi as t,Ci as n,Li as r,Nr as i,Ri as a,_a as o,ha as s,ia as c,oa as l}from"./dialogs-config-BXDglGdB.js";import{t as u}from"./use-toast-C5s-Xnwi.js";import{t as d}from"./standard-list-item-BLTOBGFa.js";import{a as f,c as p,i as m,n as h,r as g,t as _}from"./alert-dialog-Dj0hDlZC.js";import{n as v}from"./tab-context-BUUT3x3d.js";import{a as y,i as ee,n as b,r as x,t as S}from"./context-menu-XD6khGRr.js";import{n as C,o as w,r as T,s as E,t as D}from"./api-RbLAI1bg.js";var O=s(),k=e(o(),1),A=i();function te(e){let t=(0,O.c)(17),{defaultValue:n,onCommit:r,onCancel:i,level:a,basePadding:o,icon:s}=e,c=(0,k.useRef)(null),l,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{c.current?.focus(),c.current?.select()},u=[],t[0]=l,t[1]=u):(l=t[0],u=t[1]),(0,k.useEffect)(l,u);let f;t[2]!==i||t[3]!==r?(f=function(e){if(e.key===`Enter`){let e=c.current?.value.trim()??``;e?r(e):i()}else e.key===`Escape`&&i()},t[2]=i,t[3]=r,t[4]=f):f=t[4];let p=f,m;t[5]!==i||t[6]!==r?(m=function(){let e=c.current?.value.trim()??``;e?r(e):i()},t[5]=i,t[6]=r,t[7]=m):m=t[7];let h=m,g;t[8]!==n||t[9]!==h||t[10]!==p?(g=(0,A.jsx)(`input`,{ref:c,defaultValue:n,onKeyDown:p,onBlur:h,className:`flex-1 min-w-0 bg-transparent outline-none border border-border rounded px-1 text-sm`,onClick:j}),t[8]=n,t[9]=h,t[10]=p,t[11]=g):g=t[11];let _;return t[12]!==o||t[13]!==s||t[14]!==a||t[15]!==g?(_=(0,A.jsxs)(d,{level:a,basePadding:o,children:[s,g]}),t[12]=o,t[13]=s,t[14]=a,t[15]=g,t[16]=_):_=t[16],_}function j(e){return e.stopPropagation()}function ne(e){let i=(0,O.c)(101),{node:o,level:s,selectedPath:u,expandedPaths:f,loadedDirs:p,loadingPaths:m,renamingPath:h,newItemIn:g,onToggleFolder:_,onSelectFile:v,onStartRename:C,onCommitRename:w,onCancelRename:T,onDelete:E,onNewFile:D,onNewFolder:k,onCommitNewItem:j,onCancelNewItem:P}=e,F;i[0]!==f||i[1]!==o.path?(F=f.has(o.path),i[0]=f,i[1]=o.path,i[2]=F):F=i[2];let I=F,L;i[3]!==m||i[4]!==o.path?(L=m.has(o.path),i[3]=m,i[4]=o.path,i[5]=L):L=i[5];let R=L,z,B;if(i[6]!==f||i[7]!==I||i[8]!==R||i[9]!==s||i[10]!==p||i[11]!==m||i[12]!==g||i[13]!==o||i[14]!==P||i[15]!==T||i[16]!==j||i[17]!==w||i[18]!==E||i[19]!==D||i[20]!==k||i[21]!==v||i[22]!==C||i[23]!==_||i[24]!==h||i[25]!==u){B=Symbol.for(`react.early_return_sentinel`);bb0:{let e=p.get(o.path)??[];z=h===o.path;let O=g?.dirPath===o.path&&I;if(o.type===`folder`){let M=o.ignored?`opacity-50`:void 0,F;i[28]!==o||i[29]!==_?(F=e=>{e.stopPropagation(),_(o)},i[28]=o,i[29]=_,i[30]=F):F=i[30];let L;i[31]!==I||i[32]!==R?(L=(0,A.jsx)(`span`,{className:`text-muted-foreground w-3 flex-shrink-0`,children:R?(0,A.jsx)(n,{className:`h-3 w-3 animate-spin`}):I?(0,A.jsx)(l,{className:`h-3 w-3`}):(0,A.jsx)(c,{className:`h-3 w-3`})}),i[31]=I,i[32]=R,i[33]=L):L=i[33];let V;i[34]!==I||i[35]!==z||i[36]!==o||i[37]!==T||i[38]!==w?(V=z?(0,A.jsxs)(A.Fragment,{children:[I?(0,A.jsx)(a,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0`}),(0,A.jsx)(`input`,{autoFocus:!0,defaultValue:o.name,onKeyDown:e=>{if(e.key===`Enter`){let t=e.target.value.trim();t?w(o,t):T()}else e.key===`Escape`&&T()},onBlur:e=>{let t=e.target.value.trim();t?w(o,t):T()},onClick:N,className:`flex-1 min-w-0 bg-transparent outline-none border border-border rounded px-1 text-sm`})]}):(0,A.jsxs)(A.Fragment,{children:[I?(0,A.jsx)(a,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0`}),(0,A.jsx)(`span`,{className:`flex-1 truncate`,children:o.name})]}),i[34]=I,i[35]=z,i[36]=o,i[37]=T,i[38]=w,i[39]=V):V=i[39];let H;i[40]!==s||i[41]!==M||i[42]!==F||i[43]!==L||i[44]!==V?(H=(0,A.jsxs)(d,{level:s,basePadding:10,className:M,onClick:F,children:[L,V]}),i[40]=s,i[41]=M,i[42]=F,i[43]=L,i[44]=V,i[45]=H):H=i[45];let U=I&&(0,A.jsx)(`div`,{children:R&&!p.has(o.path)?(0,A.jsx)(`div`,{className:`animate-pulse h-4 bg-muted rounded mx-4 my-1`}):(0,A.jsxs)(A.Fragment,{children:[O&&(0,A.jsx)(te,{defaultValue:``,level:s+1,basePadding:g.type===`folder`?10:22,icon:g.type===`folder`?(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(t,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),onCommit:j,onCancel:P}),e.map(e=>(0,A.jsx)(ne,{node:e,level:s+1,selectedPath:u,expandedPaths:f,loadedDirs:p,loadingPaths:m,renamingPath:h,newItemIn:g,onToggleFolder:_,onSelectFile:v,onStartRename:C,onCommitRename:w,onCancelRename:T,onDelete:E,onNewFile:D,onNewFolder:k,onCommitNewItem:j,onCancelNewItem:P},e.path))]})}),W;i[46]!==H||i[47]!==U?(W=(0,A.jsxs)(`div`,{children:[H,U]}),i[46]=H,i[47]=U,i[48]=W):W=i[48];let G=W,K;i[49]===G?K=i[50]:(K=(0,A.jsx)(y,{asChild:!0,children:G}),i[49]=G,i[50]=K);let q;i[51]!==o.path||i[52]!==D?(q=(0,A.jsx)(x,{onSelect:()=>D(o.path),children:`New File...`}),i[51]=o.path,i[52]=D,i[53]=q):q=i[53];let J;i[54]!==o.path||i[55]!==k?(J=(0,A.jsx)(x,{onSelect:()=>k(o.path),children:`New Folder...`}),i[54]=o.path,i[55]=k,i[56]=J):J=i[56];let Y;i[57]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,A.jsx)(ee,{}),i[57]=Y):Y=i[57];let X;i[58]!==o||i[59]!==C?(X=(0,A.jsx)(x,{onSelect:()=>C(o),children:`Rename...`}),i[58]=o,i[59]=C,i[60]=X):X=i[60];let Z;i[61]!==o||i[62]!==E?(Z=(0,A.jsx)(x,{onSelect:()=>E(o),className:`text-destructive focus:text-destructive`,children:`Delete`}),i[61]=o,i[62]=E,i[63]=Z):Z=i[63];let Q;i[64]!==q||i[65]!==J||i[66]!==X||i[67]!==Z?(Q=(0,A.jsxs)(b,{children:[q,J,Y,X,Z]}),i[64]=q,i[65]=J,i[66]=X,i[67]=Z,i[68]=Q):Q=i[68];let $;i[69]!==K||i[70]!==Q?($=(0,A.jsxs)(S,{children:[K,Q]}),i[69]=K,i[70]=Q,i[71]=$):$=i[71],B=$;break bb0}}i[6]=f,i[7]=I,i[8]=R,i[9]=s,i[10]=p,i[11]=m,i[12]=g,i[13]=o,i[14]=P,i[15]=T,i[16]=j,i[17]=w,i[18]=E,i[19]=D,i[20]=k,i[21]=v,i[22]=C,i[23]=_,i[24]=h,i[25]=u,i[26]=z,i[27]=B}else z=i[26],B=i[27];if(B!==Symbol.for(`react.early_return_sentinel`))return B;let V=u===o.path,H=o.ignored?`opacity-50`:void 0,U;i[72]!==o||i[73]!==v?(U=()=>v(o),i[72]=o,i[73]=v,i[74]=U):U=i[74];let W;i[75]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,A.jsx)(t,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),i[75]=W):W=i[75];let G;i[76]!==z||i[77]!==o||i[78]!==T||i[79]!==w?(G=z?(0,A.jsx)(`input`,{autoFocus:!0,defaultValue:o.name,onKeyDown:e=>{if(e.key===`Enter`){let t=e.target.value.trim();t?w(o,t):T()}else e.key===`Escape`&&T()},onBlur:e=>{let t=e.target.value.trim();t?w(o,t):T()},onClick:M,className:`flex-1 min-w-0 bg-transparent outline-none border border-border rounded px-1 text-sm`}):(0,A.jsx)(`span`,{className:`flex-1 truncate`,children:o.name}),i[76]=z,i[77]=o,i[78]=T,i[79]=w,i[80]=G):G=i[80];let K;i[81]!==s||i[82]!==V||i[83]!==H||i[84]!==U||i[85]!==G?(K=(0,A.jsxs)(d,{level:s,basePadding:22,selected:V,className:H,onClick:U,children:[W,G]}),i[81]=s,i[82]=V,i[83]=H,i[84]=U,i[85]=G,i[86]=K):K=i[86];let q=K,J;i[87]===q?J=i[88]:(J=(0,A.jsx)(y,{asChild:!0,children:q}),i[87]=q,i[88]=J);let Y;i[89]!==o||i[90]!==C?(Y=(0,A.jsx)(x,{onSelect:()=>C(o),children:`Rename...`}),i[89]=o,i[90]=C,i[91]=Y):Y=i[91];let X;i[92]!==o||i[93]!==E?(X=(0,A.jsx)(x,{onSelect:()=>E(o),className:`text-destructive focus:text-destructive`,children:`Delete`}),i[92]=o,i[93]=E,i[94]=X):X=i[94];let Z;i[95]!==Y||i[96]!==X?(Z=(0,A.jsxs)(b,{children:[Y,X]}),i[95]=Y,i[96]=X,i[97]=Z):Z=i[97];let Q;return i[98]!==J||i[99]!==Z?(Q=(0,A.jsxs)(S,{children:[J,Z]}),i[98]=J,i[99]=Z,i[100]=Q):Q=i[100],Q}function M(e){return e.stopPropagation()}function N(e){return e.stopPropagation()}function P({threadId:e,selectedPath:n,onFileSelect:i}){let[a,o]=(0,k.useState)(new Map),[s,c]=(0,k.useState)(new Set),[l,d]=(0,k.useState)(new Set),[ee,O]=(0,k.useState)(null),[j,M]=(0,k.useState)(null),[N,P]=(0,k.useState)(null),{explorerRefreshTick:F,pendingExplorerPath:I}=v();async function L(t){if(!(!e||a.has(t))){d(e=>new Set(e).add(t));try{let n=await w(e,t);o(e=>new Map(e).set(t,n.entries))}catch{u({title:`Error`,description:`Failed to load directory`,variant:`destructive`})}finally{d(e=>{let n=new Set(e);return n.delete(t),n})}}}let R=(0,k.useCallback)(async t=>{if(e){d(e=>new Set(e).add(t));try{let n=await w(e,t);o(e=>new Map(e).set(t,n.entries))}catch{u({title:`Error`,description:`Failed to reload directory`,variant:`destructive`})}finally{d(e=>{let n=new Set(e);return n.delete(t),n})}}},[e]);(0,k.useEffect)(()=>{e&&(o(new Map),c(new Set),d(new Set),O(null),M(null),L(``))},[e]),(0,k.useEffect)(()=>{if(F>0&&e){R(``);for(let e of s)R(e)}},[F]),(0,k.useEffect)(()=>{if(!I||!e)return;let t=I.split(`/`);t.pop();let n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);if(n.length!==0){c(e=>{let t=new Set(e);for(let e of n)t.add(e);return t});for(let e of n)L(e)}},[I,e]);function z(e){s.has(e.path)?c(t=>{let n=new Set(t);return n.delete(e.path),n}):(c(t=>new Set(t).add(e.path)),L(e.path))}function B(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(0,t):``}function V(e){P(e)}async function H(){if(!N)return;let t=N;P(null);try{await T(e,t.path),await R(B(t.path)),c(e=>{let n=new Set(e);for(let e of n)(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n}),o(e=>{let n=new Map(e);for(let e of n.keys())(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n})}catch{u({title:`Error`,description:`Failed to move "${t.name}" to trash`,variant:`destructive`})}}function U(e){M(null),O(e.path)}async function W(t,n){if(n===t.name){O(null);return}O(null);try{await E(e,t.path,n),await R(B(t.path)),t.type===`folder`&&(c(e=>{let n=new Set(e);for(let e of n)(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n}),o(e=>{let n=new Map(e);for(let e of n.keys())(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n}))}catch{u({title:`Error`,description:`Failed to rename "${t.name}"`,variant:`destructive`})}}function G(e){O(null),s.has(e)||(c(t=>new Set(t).add(e)),L(e)),M({dirPath:e,type:`file`})}function K(e){O(null),s.has(e)||(c(t=>new Set(t).add(e)),L(e)),M({dirPath:e,type:`folder`})}async function q(t){if(!j)return;let{dirPath:n,type:r}=j;M(null);try{r===`file`?await D(e,n,t):await C(e,n,t),await R(n)}catch{u({title:`Error`,description:`Failed to create ${r} "${t}"`,variant:`destructive`})}}function J(){M(null)}let Y=a.get(``)??[],X=l.has(``),Z=j?.dirPath===``?(0,A.jsx)(te,{defaultValue:``,level:0,basePadding:j.type===`folder`?10:22,icon:j.type===`folder`?(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(t,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),onCommit:q,onCancel:J}):null;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(_,{open:N!==null,onOpenChange:e=>!e&&P(null),children:(0,A.jsxs)(m,{children:[(0,A.jsx)(p,{children:`Move to Trash`}),(0,A.jsxs)(f,{children:[`Move “`,N?.name,`” to trash?`]}),(0,A.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[(0,A.jsx)(g,{children:`Cancel`}),(0,A.jsx)(h,{onClick:()=>void H(),children:`Move to Trash`})]})]})}),(0,A.jsxs)(S,{children:[(0,A.jsx)(y,{asChild:!0,children:(0,A.jsx)(`div`,{className:`py-2 min-h-full`,children:X?(0,A.jsx)(`div`,{className:`space-y-1 px-2`,children:[1,2,3].map(e=>(0,A.jsx)(`div`,{className:`animate-pulse h-7 bg-muted rounded-full`},e))}):(0,A.jsxs)(A.Fragment,{children:[Z,Y.map(e=>(0,A.jsx)(ne,{node:e,level:0,selectedPath:n,expandedPaths:s,loadedDirs:a,loadingPaths:l,renamingPath:ee,newItemIn:j,onToggleFolder:z,onSelectFile:i,onStartRename:U,onCommitRename:W,onCancelRename:()=>O(null),onDelete:V,onNewFile:G,onNewFolder:K,onCommitNewItem:q,onCancelNewItem:J},e.path))]})})}),(0,A.jsxs)(b,{children:[(0,A.jsx)(x,{onSelect:()=>G(``),children:`New File...`}),(0,A.jsx)(x,{onSelect:()=>K(``),children:`New Folder...`})]})]})]})}export{P as default};