tarsk 0.4.27 → 0.4.28

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 (82) hide show
  1. package/dist/index.js +438 -148
  2. package/dist/public/assets/account-view-DcpSNB3N.js +1 -0
  3. package/dist/public/assets/alert-dialog-CQRWdGnn.js +1 -0
  4. package/dist/public/assets/api-CH5gAPs5.js +1 -0
  5. package/dist/public/assets/{browser-tab-DlzO5cMP.js → browser-tab-CiAz6nc1.js} +1 -1
  6. package/dist/public/assets/chat-input-container-C6U_WFFu.js +21 -0
  7. package/dist/public/assets/context-menu-A9p22S7d.js +1 -0
  8. package/dist/public/assets/conversation-history-view-CD_uVRNY.js +1 -0
  9. package/dist/public/assets/{dialogs-config-DZFG2IQM.js → dialogs-config-vkfELnGl.js} +3 -3
  10. package/dist/public/assets/diff-view-CjbcDB6m.js +3 -0
  11. package/dist/public/assets/explorer-tab-view-BfycKUUW.js +2 -0
  12. package/dist/public/assets/explorer-tree-DTFYhczJ.js +1 -0
  13. package/dist/public/assets/explorer-view-C0KcZ8NQ.js +1 -0
  14. package/dist/public/assets/history-view-Dn0hQIKU.js +1 -0
  15. package/dist/public/assets/index-Bdde81Uo.css +1 -0
  16. package/dist/public/assets/index-DKQVo4Vz.js +29 -0
  17. package/dist/public/assets/markdown-renderer-CNuyXHcy.js +10 -0
  18. package/dist/public/assets/mcp-server-card-DBEBe3Qh.js +1 -0
  19. package/dist/public/assets/onboarding-DslO5AS6.js +1 -0
  20. package/dist/public/assets/onboarding-dialog-CE-GhoDt.js +1 -0
  21. package/dist/public/assets/{page-toolbar-TvYsDwUY.js → page-toolbar-CloU_Kvo.js} +1 -1
  22. package/dist/public/assets/{project-settings-view-C7GW_R0m.js → project-settings-view-CxD9JZoB.js} +1 -1
  23. package/dist/public/assets/providers-list-view-CNxVBJlM.js +1 -0
  24. package/dist/public/assets/radio-group-Co0Lg6se.js +1 -0
  25. package/dist/public/assets/react-vendor-DyE9sO8V.js +22 -0
  26. package/dist/public/assets/{resizable-DzrIos_Y.js → resizable-dToeUeVD.js} +1 -1
  27. package/dist/public/assets/{run-stop-button-k1LeM0M-.js → run-stop-button-DZ4JFwdL.js} +2 -2
  28. package/dist/public/assets/settings-instructions-view-DWzAH2yN.js +1 -0
  29. package/dist/public/assets/{settings-mcp-servers-view-Becs_RxN.js → settings-mcp-servers-view-q6gGMMVX.js} +4 -4
  30. package/dist/public/assets/settings-models-view-BDDFQWWC.js +1 -0
  31. package/dist/public/assets/settings-rules-view-DsEwgDFr.js +8 -0
  32. package/dist/public/assets/{settings-skills-view-aPv03-bO.js → settings-skills-view-DV40_L1o.js} +2 -2
  33. package/dist/public/assets/{settings-slash-commands-view-DLMWXQXA.js → settings-slash-commands-view-BEk3BgOY.js} +1 -1
  34. package/dist/public/assets/settings-subagents-view-d3P4ylDX.js +2 -0
  35. package/dist/public/assets/settings-view-ClTMPafQ.js +2 -0
  36. package/dist/public/assets/{side-panel-container-oMcXib2A.js → side-panel-container-BAYoMt7B.js} +2 -2
  37. package/dist/public/assets/{skeleton-Bc0U0oGc.js → skeleton-DveUQR4w.js} +1 -1
  38. package/dist/public/assets/standard-list-item-BLlgm1qW.js +1 -0
  39. package/dist/public/assets/store-BcwWHqYr.js +4 -0
  40. package/dist/public/assets/{tab-context-CCvlrC0o.js → tab-context-DWD20a4z.js} +1 -1
  41. package/dist/public/assets/tabs-CgvpwOBj.js +1 -0
  42. package/dist/public/assets/{terminal-panel-GuO2XygM.js → terminal-panel-CkIe2d2K.js} +2 -2
  43. package/dist/public/assets/textarea-C2UIAa7y.js +1 -0
  44. package/dist/public/assets/todos-view-C-awG1dZ.js +1 -0
  45. package/dist/public/assets/{use-toast-DqmC-mB5.js → use-toast-yY7qQuQP.js} +1 -1
  46. package/dist/public/assets/{utils-Cy2s2TEb.js → utils-BKss67Vg.js} +1 -1
  47. package/dist/public/assets/{whisper-wasm-Clnf-l-9.js → whisper-wasm-B7iuRPFr.js} +1 -1
  48. package/dist/public/ide/antigravity.svg +1 -0
  49. package/dist/public/ide/devin.svg +1 -0
  50. package/dist/public/index.html +22 -21
  51. package/package.json +1 -1
  52. package/dist/public/assets/account-view-BFhjAYmz.js +0 -1
  53. package/dist/public/assets/alert-dialog--tUzAWFm.js +0 -1
  54. package/dist/public/assets/api-BBbysRIh.js +0 -1
  55. package/dist/public/assets/chat-input-container-B_qVOGzW.js +0 -21
  56. package/dist/public/assets/context-menu-D5slxFcc.js +0 -1
  57. package/dist/public/assets/conversation-history-view-B4zHwyrw.js +0 -1
  58. package/dist/public/assets/diff-view-fOVqrHQW.js +0 -3
  59. package/dist/public/assets/explorer-tab-view-MLrWJ1Y0.js +0 -2
  60. package/dist/public/assets/explorer-tree-8TyBYuC7.js +0 -1
  61. package/dist/public/assets/explorer-view-5U70mfAJ.js +0 -1
  62. package/dist/public/assets/history-view-BR8scGnM.js +0 -1
  63. package/dist/public/assets/index-0BuHfewk.css +0 -1
  64. package/dist/public/assets/index-BTbiyooe.js +0 -37
  65. package/dist/public/assets/mcp-server-card-DupwHcKT.js +0 -1
  66. package/dist/public/assets/onboarding-Cn5RqOCa.js +0 -1
  67. package/dist/public/assets/onboarding-dialog-BXsvjU1t.js +0 -1
  68. package/dist/public/assets/providers-list-view-AVt5I1WB.js +0 -1
  69. package/dist/public/assets/radio-group-Mifbn8sU.js +0 -1
  70. package/dist/public/assets/react-vendor-Bao-KYKs.js +0 -22
  71. package/dist/public/assets/settings-instructions-view-CgfWSPmK.js +0 -1
  72. package/dist/public/assets/settings-models-view-BqdD_7GR.js +0 -1
  73. package/dist/public/assets/settings-rules-view-D7j5OHUi.js +0 -8
  74. package/dist/public/assets/settings-subagents-view-DBYzNE4W.js +0 -2
  75. package/dist/public/assets/settings-view-CccwUKkf.js +0 -2
  76. package/dist/public/assets/standard-list-item-D2lbPXa1.js +0 -1
  77. package/dist/public/assets/store-CwvBC-YP.js +0 -2
  78. package/dist/public/assets/tabs-Mb_cjIfE.js +0 -1
  79. package/dist/public/assets/textarea-DpXOZLt8.js +0 -1
  80. package/dist/public/assets/todos-view-C4GMi1Np.js +0 -1
  81. /package/dist/public/assets/{dist-BI23Ei33.js → dist-Bjt_i1zi.js} +0 -0
  82. /package/dist/public/assets/{monaco-DDfTQM3i.js → monaco-SWcefg0q.js} +0 -0
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Ar as t,Sa as n,Si as r,Vn as i,Xt as a,Zi as o,da as s,et as c}from"./dialogs-config-vkfELnGl.js";import{t as l}from"./use-toast-yY7qQuQP.js";import{t as u}from"./skeleton-DveUQR4w.js";var d=e(n(),1),f=t();function p(){let[e,t]=(0,d.useState)(null),[n,p]=(0,d.useState)(!0);(0,d.useEffect)(()=>{m();let e=()=>{document.visibilityState===`visible`&&m()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);async function m(){p(!0);try{t(await c())}catch(e){l({title:`Error`,description:e instanceof Error?e.message:`Failed to load account info`,variant:`destructive`})}finally{p(!1)}}function h(){a(`https://buy.stripe.com/14AcN6feK0Jjbheb2H3Nm03?client_reference_id=${e?.clientReferenceId??``}`)}function g(){a(`https://buy.stripe.com/9B67sMd6CgIh70Y0o33Nm04?client_reference_id=${e?.clientReferenceId??``}`)}if(n)return(0,f.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,f.jsxs)(`div`,{className:`mb-6`,children:[(0,f.jsx)(u,{className:`h-8 w-32 mb-2`}),(0,f.jsx)(u,{className:`h-4 w-64`})]}),(0,f.jsxs)(`div`,{className:`space-y-6`,children:[(0,f.jsxs)(`div`,{className:`flex gap-4`,children:[(0,f.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-2`,children:[(0,f.jsx)(u,{className:`h-4 w-20`}),(0,f.jsx)(u,{className:`h-9 w-28`})]}),(0,f.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-3`,children:[(0,f.jsx)(u,{className:`h-4 w-24`}),(0,f.jsx)(u,{className:`h-6 w-32`}),(0,f.jsx)(u,{className:`h-4 w-full`})]})]}),(0,f.jsxs)(`div`,{className:`space-y-3`,children:[(0,f.jsx)(u,{className:`h-4 w-24`}),(0,f.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-1 flex-1`,children:[(0,f.jsx)(u,{className:`h-5 w-28`}),(0,f.jsx)(u,{className:`h-4 w-64`})]}),(0,f.jsx)(u,{className:`h-9 w-28 shrink-0`})]}),(0,f.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-1 flex-1`,children:[(0,f.jsx)(u,{className:`h-5 w-36`}),(0,f.jsx)(u,{className:`h-4 w-56`}),(0,f.jsx)(u,{className:`h-4 w-32`})]}),(0,f.jsx)(u,{className:`h-9 w-24 shrink-0`})]})]})]})]});let _=e?.plan===`unlimited-pro`;return(0,f.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,f.jsxs)(`div`,{className:`mb-6`,children:[(0,f.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Account`}),(0,f.jsx)(`p`,{className:`text-muted-foreground`,children:`Manage your Tarsk plan and prompt balance.`})]}),(0,f.jsxs)(`div`,{className:`space-y-6`,children:[(0,f.jsxs)(`div`,{className:`flex gap-4`,children:[(0,f.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-2`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,f.jsx)(r,{className:`h-4 w-4`}),`Balance`]}),(0,f.jsx)(`div`,{className:`flex items-end gap-2`,children:_?(0,f.jsx)(`span`,{className:`text-3xl font-bold`,children:`Unlimited`}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`span`,{className:`text-3xl font-bold`,children:e?.promptsRemaining.toLocaleString()??0}),(0,f.jsx)(`span`,{className:`text-muted-foreground mb-1 text-sm`,children:`prompts remaining`})]})})]}),(0,f.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-3`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,f.jsx)(o,{className:`h-4 w-4`}),`Current Plan`]}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(`span`,{className:`text-lg font-semibold`,children:_?`Unlimited Pro`:`Pay as you go`}),_&&(0,f.jsx)(`span`,{className:`rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary`,children:`Active`})]}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:_?`You have unlimited prompts with no restrictions.`:`Purchase prompts as needed. Upgrade to Pro for unlimited access.`})]})]}),!_&&(0,f.jsxs)(`div`,{className:`space-y-3`,children:[(0,f.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wide`,children:`Add Prompts`}),(0,f.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-1`,children:[(0,f.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,f.jsx)(`span`,{className:`font-semibold`,children:`1,000 Prompts`})}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Top up your balance with 1,000 additional prompts for $5.`})]}),(0,f.jsx)(i,{onClick:h,className:`shrink-0`,children:`Top Up Balance`})]}),(0,f.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-1`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(o,{className:`h-4 w-4 text-primary`}),(0,f.jsx)(`span`,{className:`font-semibold`,children:`Unlimited Pro Plan`})]}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Unlimited prompts for $100 and lifetime access to Tarsk.`}),(0,f.jsxs)(`ul`,{className:`text-sm text-muted-foreground space-y-0.5`,children:[(0,f.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,f.jsx)(s,{className:`h-3 w-3 text-primary`}),`Unlimited prompts`]}),(0,f.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,f.jsx)(s,{className:`h-3 w-3 text-primary`}),`Priority access`]})]})]}),(0,f.jsx)(i,{onClick:g,className:`shrink-0`,children:`Purchase`})]})]})]})]})}export{p as default};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Ar as t,Hn as n,Sa as r,Zn as i,ba as a}from"./dialogs-config-vkfELnGl.js";import{ct as o,dt as s,ft as c,lt as l,ot as u,pt as d,st as f,ut as p}from"./react-vendor-DyE9sO8V.js";var m=a(),h=e(r(),1),g=t(),_=c,v=s,y=h.forwardRef((e,t)=>{let n=(0,m.c)(9),r,a;n[0]===e?(r=n[1],a=n[2]):({className:r,...a}=e,n[0]=e,n[1]=r,n[2]=a);let o;n[3]===r?o=n[4]:(o=i(`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`,r),n[3]=r,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(p,{className:o,...a,ref:t}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});y.displayName=p.displayName;var b=h.forwardRef((e,t)=>{let n=(0,m.c)(10),r,a;n[0]===e?(r=n[1],a=n[2]):({className:r,...a}=e,n[0]=e,n[1]=r,n[2]=a);let s;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,g.jsx)(y,{}),n[3]=s):s=n[3];let c;n[4]===r?c=n[5]:(c=i(`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`,r),n[4]=r,n[5]=c);let l;return n[6]!==a||n[7]!==t||n[8]!==c?(l=(0,g.jsxs)(v,{children:[s,(0,g.jsx)(o,{ref:t,className:c,...a})]}),n[6]=a,n[7]=t,n[8]=c,n[9]=l):l=n[9],l});b.displayName=o.displayName;var x=e=>{let t=(0,m.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 a;t[3]===n?a=t[4]:(a=i(`flex flex-col space-y-2 text-center sm:text-left`,n),t[3]=n,t[4]=a);let o;return t[5]!==r||t[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...r}),t[5]=r,t[6]=a,t[7]=o):o=t[7],o};x.displayName=`AlertDialogHeader`;var S=e=>{let t=(0,m.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 a;t[3]===n?a=t[4]:(a=i(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,n),t[3]=n,t[4]=a);let o;return t[5]!==r||t[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...r}),t[5]=r,t[6]=a,t[7]=o):o=t[7],o};S.displayName=`AlertDialogFooter`;var C=h.forwardRef((e,t)=>{let n=(0,m.c)(9),r,a;n[0]===e?(r=n[1],a=n[2]):({className:r,...a}=e,n[0]=e,n[1]=r,n[2]=a);let o;n[3]===r?o=n[4]:(o=i(`text-lg font-semibold`,r),n[3]=r,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(d,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});C.displayName=d.displayName;var w=h.forwardRef((e,t)=>{let n=(0,m.c)(9),r,a;n[0]===e?(r=n[1],a=n[2]):({className:r,...a}=e,n[0]=e,n[1]=r,n[2]=a);let o;n[3]===r?o=n[4]:(o=i(`text-sm text-muted-foreground`,r),n[3]=r,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(l,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});w.displayName=l.displayName;var T=h.forwardRef((e,t)=>{let r=(0,m.c)(9),a,o;r[0]===e?(a=r[1],o=r[2]):({className:a,...o}=e,r[0]=e,r[1]=a,r[2]=o);let s;r[3]===a?s=r[4]:(s=i(n(),a),r[3]=a,r[4]=s);let c;return r[5]!==o||r[6]!==t||r[7]!==s?(c=(0,g.jsx)(u,{ref:t,className:s,...o}),r[5]=o,r[6]=t,r[7]=s,r[8]=c):c=r[8],c});T.displayName=u.displayName;var E=h.forwardRef((e,t)=>{let r=(0,m.c)(9),a,o;r[0]===e?(a=r[1],o=r[2]):({className:a,...o}=e,r[0]=e,r[1]=a,r[2]=o);let s;r[3]===a?s=r[4]:(s=i(n({variant:`outline`}),`mt-2 sm:mt-0`,a),r[3]=a,r[4]=s);let c;return r[5]!==o||r[6]!==t||r[7]!==s?(c=(0,g.jsx)(f,{ref:t,className:s,...o}),r[5]=o,r[6]=t,r[7]=s,r[8]=c):c=r[8],c});E.displayName=f.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};
@@ -0,0 +1 @@
1
+ import{An as e,Mn as t,Nn as n,On as r,Pn as i,jn as a,kn as o}from"./dialogs-config-vkfELnGl.js";async function s(t,n){return e(`api/threads/${o(t)}/explorer?path=${encodeURIComponent(n)}`)}async function c(t,n){return e(`api/threads/${o(t)}/ai-file?path=${encodeURIComponent(n)}`)}async function l(e,t,n){return i(`api/threads/${o(e)}/ai-file`,{path:t,content:n})}async function u(e,t){return r(`api/threads/${o(e)}/explorer?path=${encodeURIComponent(t)}`)}async function d(e,n,r){return t(`api/threads/${o(e)}/explorer`,{path:n,newName:r})}async function f(e,t,r){return n(`api/threads/${o(e)}/explorer/file`,{dirPath:t,name:r})}function p(e,t){return`${a()}/api/threads/${o(e)}/explorer/media?path=${encodeURIComponent(t)}`}async function m(e,t,r){return n(`api/threads/${o(e)}/explorer/folder`,{dirPath:t,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 +1 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Dr as t,Gi as n,Jt as r,Wr as i,Xr as a,_a as o,hi as s,ni as c,ya as l}from"./dialogs-config-DZFG2IQM.js";import{a as u}from"./store-CwvBC-YP.js";import{n as d}from"./tab-context-CCvlrC0o.js";import{t as f}from"./run-stop-button-k1LeM0M-.js";var p=o(),m=e(l(),1),h=t();function g(){let e=(0,p.c)(41),{devServerUrl:t,browserResetTrigger:o}=d(),{state:l}=u(),{selectedProjectId:g,projects:_}=l,v;if(e[0]!==_||e[1]!==g){let t;e[3]===g?t=e[4]:(t=e=>e.projectId===g,e[3]=g,e[4]=t),v=_.find(t),e[0]=_,e[1]=g,e[2]=v}else v=e[2];let y=v,[b,x]=(0,m.useState)(``),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(`desktop`),E=(0,m.useRef)(null),D;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>{C(``),x(``),E.current&&(E.current.src=``)},e[5]=D):D=e[5];let O;e[6]===o?O=e[7]:(O=[o],e[6]=o,e[7]=O),(0,m.useEffect)(D,O);let k,A;e[8]===t?(k=e[9],A=e[10]):(k=()=>{t&&(x(t),C(t))},A=[t],e[8]=t,e[9]=k,e[10]=A),(0,m.useEffect)(k,A);let j;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{let t=e.trim();t&&(!t.startsWith(`http://`)&&!t.startsWith(`https://`)&&(t=`http://`+t),x(t),C(t))},e[11]=j):j=e[11];let M=j,N;e[12]===b?N=e[13]:(N=e=>{e.key===`Enter`&&M(b)},e[12]=b,e[13]=N);let P=N,F;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>{if(E.current){let e=E.current.src;E.current.src=``,setTimeout(()=>{E.current&&(E.current.src=e)},0)}},e[14]=F):F=e[14];let I=F,L;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(L={desktop:{width:`100%`,height:`100%`},tablet:{width:`768px`,height:`1024px`},mobile:{width:`375px`,height:`667px`}},e[15]=L):L=e[15];let R=L[w],z;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>x(e.target.value),e[16]=z):z=e[16];let B;e[17]!==P||e[18]!==b?(B=(0,h.jsx)(`input`,{type:`text`,value:b,onChange:z,onKeyDown:P,placeholder:`Enter URL...`,className:`flex-1 px-4 py-1.5 text-sm bg-muted rounded-full border border-border outline-none focus:ring-1 focus:ring-ring font-mono`,spellCheck:!1}),e[17]=P,e[18]=b,e[19]=B):B=e[19];let V;e[20]===S?V=e[21]:(V=S&&(0,h.jsx)(`button`,{onClick:I,title:`Refresh page`,className:`p-1.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,children:(0,h.jsx)(c,{size:15})}),e[20]=S,e[21]=V);let H;e[22]!==w||e[23]!==S?(H=S&&(0,h.jsxs)(`div`,{className:`flex items-center bg-muted rounded-md p-0.5`,children:[(0,h.jsx)(`button`,{onClick:()=>T(`desktop`),title:`Desktop view`,className:`p-1.5 rounded transition-colors ${w===`desktop`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(s,{size:15})}),(0,h.jsx)(`button`,{onClick:()=>T(`tablet`),title:`Tablet view`,className:`p-1.5 rounded transition-colors ${w===`tablet`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(i,{size:15})}),(0,h.jsx)(`button`,{onClick:()=>T(`mobile`),title:`Mobile view`,className:`p-1.5 rounded transition-colors ${w===`mobile`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(a,{size:15})})]}),e[22]=w,e[23]=S,e[24]=H):H=e[24];let U;e[25]===S?U=e[26]:(U=S&&(0,h.jsx)(`button`,{onClick:()=>void r(S),title:`Open in external browser`,className:`p-1.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,children:(0,h.jsx)(n,{size:15})}),e[25]=S,e[26]=U);let W;e[27]!==B||e[28]!==V||e[29]!==H||e[30]!==U?(W=(0,h.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border shrink-0`,children:[B,V,H,U]}),e[27]=B,e[28]=V,e[29]=H,e[30]=U,e[31]=W):W=e[31];let G;e[32]!==R||e[33]!==w||e[34]!==S||e[35]!==y||e[36]!==g?(G=S?(0,h.jsx)(`div`,{className:`flex-1 flex items-center justify-center bg-background`,children:w===`desktop`?(0,h.jsx)(`iframe`,{ref:E,src:S,className:`flex-1 w-full h-full border-none`,title:`Browser`}):(0,h.jsx)(`div`,{className:`bg-white border border-border rounded-lg shadow-lg overflow-hidden transition-all duration-200`,style:{width:R.width,height:R.height,maxWidth:`100%`,maxHeight:`100%`},children:(0,h.jsx)(`iframe`,{ref:E,src:S,className:`w-full h-full border-none`,title:`Browser`})})}):(0,h.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-6 text-muted-foreground`,children:g&&y?.runCommand?(0,h.jsx)(f,{projectId:g,runCommand:y.runCommand,large:!0}):(0,h.jsx)(`p`,{className:`text-sm`,children:`Enter a URL to browse`})}),e[32]=R,e[33]=w,e[34]=S,e[35]=y,e[36]=g,e[37]=G):G=e[37];let K;return e[38]!==W||e[39]!==G?(K=(0,h.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[W,G]}),e[38]=W,e[39]=G,e[40]=K):K=e[40],K}export{g as BrowserTab};
1
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$r as t,Ar as n,Ji as r,Sa as i,Xt as a,ai as o,ba as s,qr as c,vi as l}from"./dialogs-config-vkfELnGl.js";import{a as u}from"./store-BcwWHqYr.js";import{n as d}from"./tab-context-DWD20a4z.js";import{t as f}from"./run-stop-button-DZ4JFwdL.js";var p=s(),m=e(i(),1),h=n();function g(){let e=(0,p.c)(41),{devServerUrl:n,browserResetTrigger:i}=d(),{state:s}=u(),{selectedProjectId:g,projects:_}=s,v;if(e[0]!==_||e[1]!==g){let t;e[3]===g?t=e[4]:(t=e=>e.projectId===g,e[3]=g,e[4]=t),v=_.find(t),e[0]=_,e[1]=g,e[2]=v}else v=e[2];let y=v,[b,x]=(0,m.useState)(``),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(`desktop`),E=(0,m.useRef)(null),D;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>{C(``),x(``),E.current&&(E.current.src=``)},e[5]=D):D=e[5];let O;e[6]===i?O=e[7]:(O=[i],e[6]=i,e[7]=O),(0,m.useEffect)(D,O);let k,A;e[8]===n?(k=e[9],A=e[10]):(k=()=>{n&&(x(n),C(n))},A=[n],e[8]=n,e[9]=k,e[10]=A),(0,m.useEffect)(k,A);let j;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{let t=e.trim();t&&(!t.startsWith(`http://`)&&!t.startsWith(`https://`)&&(t=`http://`+t),x(t),C(t))},e[11]=j):j=e[11];let M=j,N;e[12]===b?N=e[13]:(N=e=>{e.key===`Enter`&&M(b)},e[12]=b,e[13]=N);let P=N,F;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>{if(E.current){let e=E.current.src;E.current.src=``,setTimeout(()=>{E.current&&(E.current.src=e)},0)}},e[14]=F):F=e[14];let I=F,L;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(L={desktop:{width:`100%`,height:`100%`},tablet:{width:`768px`,height:`1024px`},mobile:{width:`375px`,height:`667px`}},e[15]=L):L=e[15];let R=L[w],z;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>x(e.target.value),e[16]=z):z=e[16];let B;e[17]!==P||e[18]!==b?(B=(0,h.jsx)(`input`,{type:`text`,value:b,onChange:z,onKeyDown:P,placeholder:`Enter URL...`,className:`flex-1 px-4 py-1.5 text-sm bg-muted rounded-full border border-border outline-none focus:ring-1 focus:ring-ring font-mono`,spellCheck:!1}),e[17]=P,e[18]=b,e[19]=B):B=e[19];let V;e[20]===S?V=e[21]:(V=S&&(0,h.jsx)(`button`,{onClick:I,title:`Refresh page`,className:`p-1.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,children:(0,h.jsx)(o,{size:15})}),e[20]=S,e[21]=V);let H;e[22]!==w||e[23]!==S?(H=S&&(0,h.jsxs)(`div`,{className:`flex items-center bg-muted rounded-md p-0.5`,children:[(0,h.jsx)(`button`,{onClick:()=>T(`desktop`),title:`Desktop view`,className:`p-1.5 rounded transition-colors ${w===`desktop`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(l,{size:15})}),(0,h.jsx)(`button`,{onClick:()=>T(`tablet`),title:`Tablet view`,className:`p-1.5 rounded transition-colors ${w===`tablet`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(c,{size:15})}),(0,h.jsx)(`button`,{onClick:()=>T(`mobile`),title:`Mobile view`,className:`p-1.5 rounded transition-colors ${w===`mobile`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(t,{size:15})})]}),e[22]=w,e[23]=S,e[24]=H):H=e[24];let U;e[25]===S?U=e[26]:(U=S&&(0,h.jsx)(`button`,{onClick:()=>void a(S),title:`Open in external browser`,className:`p-1.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,children:(0,h.jsx)(r,{size:15})}),e[25]=S,e[26]=U);let W;e[27]!==B||e[28]!==V||e[29]!==H||e[30]!==U?(W=(0,h.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border shrink-0`,children:[B,V,H,U]}),e[27]=B,e[28]=V,e[29]=H,e[30]=U,e[31]=W):W=e[31];let G;e[32]!==R||e[33]!==w||e[34]!==S||e[35]!==y||e[36]!==g?(G=S?(0,h.jsx)(`div`,{className:`flex-1 flex items-center justify-center bg-background`,children:w===`desktop`?(0,h.jsx)(`iframe`,{ref:E,src:S,className:`flex-1 w-full h-full border-none`,title:`Browser`}):(0,h.jsx)(`div`,{className:`bg-white border border-border rounded-lg shadow-lg overflow-hidden transition-all duration-200`,style:{width:R.width,height:R.height,maxWidth:`100%`,maxHeight:`100%`},children:(0,h.jsx)(`iframe`,{ref:E,src:S,className:`w-full h-full border-none`,title:`Browser`})})}):(0,h.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-6 text-muted-foreground`,children:g&&y?.runCommand?(0,h.jsx)(f,{projectId:g,runCommand:y.runCommand,large:!0}):(0,h.jsx)(`p`,{className:`text-sm`,children:`Enter a URL to browse`})}),e[32]=R,e[33]=w,e[34]=S,e[35]=y,e[36]=g,e[37]=G):G=e[37];let K;return e[38]!==W||e[39]!==G?(K=(0,h.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[W,G]}),e[38]=W,e[39]=G,e[40]=K):K=e[40],K}export{g as BrowserTab};
@@ -0,0 +1,21 @@
1
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Ai as t,Ar as n,At as r,Di as i,Dn as a,E as o,Ei as s,En as c,Fr as l,Ft as u,Gi as d,Gn as f,Hr as p,Ht as m,Ir as h,It as g,Jn as _,Jr as v,Kn as y,Kr as b,Li as x,Lt as S,Mi as C,Pt as w,Q as T,Sa as E,Ti as D,Ur as O,Vi as k,Vn as A,Wi as j,Xn as M,Xr as N,Yn as P,Zn as F,_i as I,aa as L,at as R,ba as z,ca as B,ci as ee,d as te,da as ne,en as V,fa as H,fi as U,fn as W,ga as re,it as G,jn as K,jt as q,k as J,m as ie,mn as ae,na as oe,nt as se,oa as ce,pt as le,qn as ue,ra as de,ri as fe,sa as pe,si as me,st as he,tt as ge,vn as _e,x as ve,xi as ye,yn as be,zi as xe}from"./dialogs-config-vkfELnGl.js";import{$ as Se,H as Ce,J as we,K as Te,Q as Ee,R as De,U as Oe,V as ke,W as Ae,X as je,Y as Me,Z as Ne,et as Pe,q as Fe,yt as Ie,z as Le}from"./react-vendor-DyE9sO8V.js";import{a as Re,l as ze,s as Be,t as Y,u as Ve}from"./store-BcwWHqYr.js";import{c as He,s as Ue,u as We}from"./history-view-Dn0hQIKU.js";import{n as Ge,t as Ke}from"./use-toast-yY7qQuQP.js";import{a as qe,c as Je,i as Ye,o as Xe,s as Ze,t as Qe}from"./alert-dialog-CQRWdGnn.js";import{n as $e}from"./tab-context-DWD20a4z.js";import{s as et}from"./onboarding-DslO5AS6.js";import{i as tt,n as nt,r as rt,t as it}from"./whisper-wasm-B7iuRPFr.js";import{n as at}from"./utils-BKss67Vg.js";var X=z(),Z=e(E(),1),Q=n();function ot(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)(ot,{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 st(e){let t=(0,X.c)(27),{nodes:n,renderNode:r,resetKey:i,defaultOpen:a,forceOpenIds:o,indent:s,childContainerClassName:c,className:l}=e,u=a===void 0?!1:a,d=s===void 0?16:s,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f={},t[0]=f):f=t[0];let[p,m]=(0,Z.useState)(f),[h,g]=(0,Z.useState)(i);i!==h&&(g(i),m({}));let _;t[1]===o?_=t[2]:(_=o?new Set(o):void 0,t[1]=o,t[2]=_);let v=_,y;t[3]===u?y=t[4]:(y=e=>{m(t=>({...t,[e]:!(t[e]??u)}))},t[3]=u,t[4]=y);let b=y,x;t[5]===l?x=t[6]:(x=F(`min-w-0`,l),t[5]=l,t[6]=x);let S;if(t[7]!==c||t[8]!==u||t[9]!==v||t[10]!==b||t[11]!==d||t[12]!==n||t[13]!==p||t[14]!==r){let e;t[16]!==c||t[17]!==u||t[18]!==v||t[19]!==b||t[20]!==d||t[21]!==p||t[22]!==r?(e=e=>(0,Q.jsx)(ot,{node:e,level:0,renderNode:r,defaultOpen:u,indent:d,childContainerClassName:c,openState:p,onToggle:b,forceOpenIds:v},e.id),t[16]=c,t[17]=u,t[18]=v,t[19]=b,t[20]=d,t[21]=p,t[22]=r,t[23]=e):e=t[23],S=n.map(e),t[7]=c,t[8]=u,t[9]=v,t[10]=b,t[11]=d,t[12]=n,t[13]=p,t[14]=r,t[15]=S}else S=t[15];let C;return t[24]!==x||t[25]!==S?(C=(0,Q.jsx)(`div`,{className:x,children:S}),t[24]=x,t[25]=S,t[26]=C):C=t[26],C}var ct=(0,Z.createContext)({todos:[],setTodos:()=>{}});function lt(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)(ct.Provider,{value:f,children:n}),t[7]=n,t[8]=f,t[9]=p):p=t[9],p}function ut(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 dt(e){let t=(0,X.c)(5),{todos:n,sequence:r}=e,{setTodos:i}=(0,Z.useContext)(ct),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 ft=new Map,pt=new Map;function mt(e){return ft.get(e)}function ht(e,t){let n=pt.get(e);return n||(n=new Set,pt.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&pt.delete(e)}}function gt(e){let t=pt.get(e);if(t)for(let e of t)e()}function _t(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 vt(e,t,n){if(ft.has(e))return;ft.set(e,{status:`running`}),gt(e);let r=K();(async()=>{try{let i=_t(r,n),a=Object.getPrototypeOf(async function(){}).constructor,o=await new a(`callTool`,t)(i),s=o===void 0?null:o;ft.set(e,{status:`success`,result:s}),gt(e),await _e(e,s)}catch(t){let n=t instanceof Error?t.stack||t.message:String(t);ft.set(e,{status:`error`,error:n}),gt(e);try{await _e(e,{error:n})}catch(e){console.error(`[browser-js-executor] failed to submit error result`,e)}}})()}function yt({initialValue:e}={}){let{state:t,dispatch:n}=Re(),[i,a]=(0,Z.useState)(()=>{let n=t.selectedThreadId;return n&&t.chatInputDrafts[n]?t.chatInputDrafts[n]:e??``}),[s,l]=(0,Z.useState)(-1),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(0),m=(0,Z.useRef)(i);(0,Z.useEffect)(()=>{m.current=i},[i]);let h=(0,Z.useRef)(t.chatInputDrafts);(0,Z.useEffect)(()=>{h.current=t.chatInputDrafts},[t.chatInputDrafts]);let g=(0,Z.useRef)(!0);(0,Z.useEffect)(()=>(g.current=!0,()=>{g.current=!1}),[]);let[_,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,F]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)([]),[R,z]=(0,Z.useState)(null),[B,ee]=(0,Z.useState)([]),[te,ne]=(0,Z.useState)(!1),[V,H]=(0,Z.useState)(``),[U,W]=(0,Z.useState)(0),[re,K]=(0,Z.useState)([]),[q,J]=(0,Z.useState)([]),[ie,ae]=(0,Z.useState)(!1),[oe,ce]=(0,Z.useState)(``),le=(0,Z.useRef)(null),ue=(0,Z.useRef)(null),de=(0,Z.useRef)(null),fe=(0,Z.useRef)(null),pe=(0,Z.useRef)(null),me=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{x.current=y?.id??``,S.current=y?.provider??``},[y?.id,y?.provider]);let he=(0,Z.useCallback)((e,r)=>{b(e);let i=t.selectedThreadId;if(!i||(n({type:Y.SetProjectModel,threadId:i,model:e}),r?.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}}),c(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,n]);(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 se(),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||he(o,{persist:s})}catch(e){console.error(`Failed to load enabled models:`,e)}})()},[t.selectedThreadId,t.selectedProjectId,t.projects,he]);let _e=(0,Z.useRef)(he);(0,Z.useEffect)(()=>{_e.current=he},[he]),(0,Z.useEffect)(()=>{t.configUpdatedAt!==0&&(async()=>{try{let e=await se(),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)||_e.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 ge(),t=Object.values(e).flat();t.length>0&&(L(t),z(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&&m.current.trim()&&h.current[ve]!==m.current&&n({type:Y.SetChatInputDraft,threadId:ve,draft:m.current});let e=!1;return queueMicrotask(()=>{e||!g.current||(ye(t.selectedThreadId),a(t.selectedThreadId?h.current[t.selectedThreadId]??``:``),ee([]),ne(!1),K([]),J([]),ae(!1),j(!1),F(!1),N(!1))}),()=>{e=!0}}},[t.selectedThreadId,ve]),(0,Z.useEffect)(()=>{t.selectedThreadId&&r(t.selectedThreadId).then(({commands:e,skills:t})=>{console.log(`Loaded slash commands:`,e,`skills:`,t),K(e),J(t)}).catch(e=>console.error(`Failed to load slash commands and skills:`,e))},[t.selectedThreadId]),(0,Z.useEffect)(()=>{t.focusChatInput&&t.selectedThreadId&&!t.isStreaming&&(ue.current?.focus(),n({type:Y.ClearFocusChatInput}))},[t.focusChatInput,t.selectedThreadId,t.isStreaming,n]),(0,Z.useEffect)(()=>{let e=t.selectedThreadId;return()=>{e&&m.current.trim()&&h.current[e]!==m.current&&n({type:Y.SetChatInputDraft,threadId:e,draft:m.current})}},[t.selectedThreadId,n]),(0,Z.useEffect)(()=>{let e=e=>{de.current&&!de.current.contains(e.target)&&T(!1),fe.current&&!fe.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:s,setHistoryIndex:l,draftMessage:u,setDraftMessage:d,cursorPosition:f,setCursorPosition:p,availableModels:_,setAvailableModels:v,selectedModel:y,setSelectedModel:he,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:F,availableImageModels:I,setAvailableImageModels:L,selectedImageModel:R,setSelectedImageModel:z,allFiles:B,setAllFiles:ee,showSuggestions:te,setShowSuggestions:ne,suggestionQuery:V,setSuggestionQuery:H,selectedIndex:U,setSelectedIndex:W,slashCommands:re,setSlashCommands:K,skills:q,setSkills:J,showCommandSuggestions:ie,setShowCommandSuggestions:ae,commandQuery:oe,setCommandQuery:ce,fileInputRef:le,textareaRef:ue,modelMenuRef:de,plusMenuRef:fe,suggestionsRef:pe,commandSuggestionsRef:me,handleNewChat:async()=>{if(t.selectedThreadId)try{let e=await o(t.selectedThreadId);n({type:Y.ClearMessages}),console.log(`New conversation started:`,e);let r=await G(t.selectedThreadId);n({type:Y.SetMessages,messages:r.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},state:t,dispatch:n}}var bt=e=>{te(e)};function xt(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:f,historyIndex:p,setHistoryIndex:m,draftMessage:h,setDraftMessage:g,cursorPosition:_,setCursorPosition:v,showSuggestions:y,setShowSuggestions:b,suggestionQuery:x,setSuggestionQuery:S,allFiles:C,setAllFiles:T,selectedIndex:E,setSelectedIndex:D,showCommandSuggestions:O,setShowCommandSuggestions:k,commandQuery:A,setCommandQuery:j,slashCommands:M,skills:N,textareaRef:P,setAttachments:F,planMode:I,setPlanMode:L,ralphMode:R,setRalphMode:z,imageMode:B,setImageMode:ee,selectedImageModel:te}=e,ne;t[0]!==i||t[1]!==f||t[2]!==B||t[3]!==l||t[4]!==s||t[5]!==n||t[6]!==o||t[7]!==I||t[8]!==R||t[9]!==d||t[10]!==te||t[11]!==a||t[12]!==c||t[13]!==F||t[14]!==g||t[15]!==m||t[16]!==r||t[17]!==u||t[18]!==P?(ne=()=>{if(!n.trim()&&i.length===0||!c)return;let e=B?te:a;e&&(l&&(u(),d()),s?f({type:Y.EnqueueChatMessage,message:{id:`queued-${Date.now()}`,threadId:c,message:n,model:e.id,attachments:i,provider:e.provider,planMode:I,imageMode:B,ralphMode:R}}):o(n,e.id,i,e.provider,I,B,R),bt(n),r(``),F([]),m(-1),g(``),c&&f({type:Y.ClearChatInputDraft,threadId:c}),P.current&&(P.current.style.height=`auto`))},t[0]=i,t[1]=f,t[2]=B,t[3]=l,t[4]=s,t[5]=n,t[6]=o,t[7]=I,t[8]=R,t[9]=d,t[10]=te,t[11]=a,t[12]=c,t[13]=F,t[14]=g,t[15]=m,t[16]=r,t[17]=u,t[18]=P,t[19]=ne):ne=t[19];let V=ne,H;t[20]!==_||t[21]!==n||t[22]!==r||t[23]!==b||t[24]!==x||t[25]!==P?(H=e=>{let t=n.substring(0,_-x.length-1);r(`${t}${e} ${n.substring(_)}`),b(!1),setTimeout(()=>{if(P.current){P.current.focus();let n=t.length+e.length+1;P.current.setSelectionRange(n,n)}},0)},t[20]=_,t[21]=n,t[22]=r,t[23]=b,t[24]=x,t[25]=P,t[26]=H):H=t[26];let U=H,W;t[27]!==A||t[28]!==_||t[29]!==n||t[30]!==ee||t[31]!==r||t[32]!==L||t[33]!==z||t[34]!==k||t[35]!==P?(W=e=>{let t=n.substring(0,_-A.length-1),i=n.substring(_);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`?(L(!0),z(!1),ee(!1)):e.metadata.mode===`ralph`&&(z(!0),L(!1),ee(!1))},t[27]=A,t[28]=_,t[29]=n,t[30]=ee,t[31]=r,t[32]=L,t[33]=z,t[34]=k,t[35]=P,t[36]=W):W=t[36];let re=W,G;t[37]!==A||t[38]!==_||t[39]!==n||t[40]!==r||t[41]!==k||t[42]!==P?(G=e=>{let t=n.substring(0,_-A.length-1),i=n.substring(_),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]=_,t[39]=n,t[40]=r,t[41]=k,t[42]=P,t[43]=G):G=t[43];let K=G,q,J,ae,oe;if(t[44]!==C||t[45]!==A||t[46]!==h||t[47]!==V||t[48]!==p||t[49]!==re||t[50]!==U||t[51]!==K||t[52]!==n||t[53]!==E||t[54]!==c||t[55]!==T||t[56]!==j||t[57]!==v||t[58]!==g||t[59]!==m||t[60]!==r||t[61]!==D||t[62]!==k||t[63]!==b||t[64]!==S||t[65]!==O||t[66]!==y||t[67]!==N||t[68]!==M||t[69]!==x){ae=e=>{if(O){if(e.key===`ArrowDown`){e.preventDefault(),D((E+1)%q.length);return}if(e.key===`ArrowUp`){e.preventDefault(),D((E-1+q.length)%q.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=q[E];t&&(t.type===`command`?re(t.data):K(t.data));return}if(e.key===`Escape`){k(!1);return}}if(y){let t=J.length>0;if(e.key===`ArrowDown`&&t){e.preventDefault(),D((E+1)%J.length);return}if(e.key===`ArrowUp`&&t){e.preventDefault(),D((E-1+J.length)%J.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),J[E]&&U(J[E]);return}if(e.key===`Escape`){b(!1);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),V();return}let t=ie();t.length!==0&&(e.key===`ArrowUp`?(e.preventDefault(),p===-1?(g(n),m(t.length-1),r(t[t.length-1])):p>0&&(m(p-1),r(t[p-1]))):e.key===`ArrowDown`&&(e.preventDefault(),p>0?(m(p-1),r(t[p-1])):p===0&&(m(-1),r(h))))};let e;t[74]!==C||t[75]!==c||t[76]!==T||t[77]!==j||t[78]!==v||t[79]!==r||t[80]!==D||t[81]!==k||t[82]!==b||t[83]!==S?(e=e=>{let t=e.target.value,n=e.target.selectionStart;r(t),v(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),b(!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(` `)?b(!1):(S(t),b(!0),D(0),C.length===0&&c&&w(c).then(e=>{T(e)}).catch(wt))}else b(!1)}else b(!1)}let o=e.target;o.style.height=`auto`,o.style.height=`${Math.min(o.scrollHeight,160)}px`},t[74]=C,t[75]=c,t[76]=T,t[77]=j,t[78]=v,t[79]=r,t[80]=D,t[81]=k,t[82]=b,t[83]=S,t[84]=e):e=t[84],oe=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(Ct),...a.map(St)],t[85]=A,t[86]=N,t[87]=M,t[88]=i}else i=t[88];q=i.slice(0,10),J=y?C.filter(e=>e.toLowerCase().includes(x.toLowerCase())).slice(0,10):[],t[44]=C,t[45]=A,t[46]=h,t[47]=V,t[48]=p,t[49]=re,t[50]=U,t[51]=K,t[52]=n,t[53]=E,t[54]=c,t[55]=T,t[56]=j,t[57]=v,t[58]=g,t[59]=m,t[60]=r,t[61]=D,t[62]=k,t[63]=b,t[64]=S,t[65]=O,t[66]=y,t[67]=N,t[68]=M,t[69]=x,t[70]=q,t[71]=J,t[72]=ae,t[73]=oe}else q=t[70],J=t[71],ae=t[72],oe=t[73];let se;return t[93]!==q||t[94]!==J||t[95]!==ae||t[96]!==V||t[97]!==oe||t[98]!==re||t[99]!==U||t[100]!==K?(se={handleSend:V,handleKeyDown:ae,handleTextareaInput:oe,insertFileReference:U,insertCommand:re,insertSkill:K,allSuggestions:q,fileSuggestions:J},t[93]=q,t[94]=J,t[95]=ae,t[96]=V,t[97]=oe,t[98]=re,t[99]=U,t[100]=K,t[101]=se):se=t[101],se}function St(e){return{type:`skill`,data:e}}function Ct(e){return{type:`command`,data:e}}function wt(e){return console.error(`Failed to fetch files:`,e)}function Tt(e){let t=(0,X.c)(21),{visible:n,commands:r,skills:i,query:a,selectedIndex:o,onSelectCommand:s,onSelectSkill:c,onMouseEnterSuggestion:u,containerRef:d}=e;if(!n)return null;let f;if(t[0]!==r||t[1]!==a||t[2]!==i){let e;t[4]===a?e=t[5]:(e=e=>e.name.toLowerCase().includes(a.toLowerCase()),t[4]=a,t[5]=e);let n=r.filter(e),o;t[6]===a?o=t[7]:(o=e=>e.name.toLowerCase().includes(a.toLowerCase()),t[6]=a,t[7]=o);let s=i.filter(o);f=[...n.map(Dt),...s.map(Et)].slice(0,10),t[0]=r,t[1]=a,t[2]=i,t[3]=f}else f=t[3];let p=f,m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(b,{className:`h-3 w-3`}),t[8]=m):m=t[8];let h=a&&` matching "${a}"`,g;t[9]===h?g=t[10]:(g=(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:[m,`Commands & Skills`,h]}),t[9]=h,t[10]=g);let _;t[11]!==p||t[12]!==u||t[13]!==s||t[14]!==c||t[15]!==o?(_=p.length>0?p.map((e,t)=>{let n=t===o;if(e.type===`command`){let r=e.data;return(0,Q.jsxs)(`button`,{type:`button`,className:F(`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:()=>s(r),onMouseEnter:()=>u(t),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(b,{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:F(`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)(l,{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]=p,t[12]=u,t[13]=s,t[14]=c,t[15]=o,t[16]=_):_=t[16];let v;return t[17]!==d||t[18]!==g||t[19]!==_?(v=(0,Q.jsxs)(`div`,{ref:d,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:[g,_]}),t[17]=d,t[18]=g,t[19]=_,t[20]=v):v=t[20],v}function Et(e){return{type:`skill`,data:e}}function Dt(e){return{type:`command`,data:e}}function Ot(e){return e.startsWith(`image/`)}function kt(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:Ot(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)(h,{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)(U,{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)(h,{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 At(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 jt(e){let t=(0,X.c)(16),{showSuggestions:n,fileSuggestions:r,suggestionQuery:i,selectedIndex:a,onSelectFile:o,onMouseEnterSuggestion:s,containerRef:c}=e;if(!n||r.length===0)return null;let l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(fe,{className:`h-3 w-3`}),t[0]=l):l=t[0];let u;t[1]===i?u=t[2]:(u=(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:[l,`Files matching "`,i,`"`]}),t[1]=i,t[2]=u);let f;if(t[3]!==r||t[4]!==s||t[5]!==o||t[6]!==a){let e;t[8]!==s||t[9]!==o||t[10]!==a?(e=(e,t)=>{let n=e.split(`/`).pop()??e;return(0,Q.jsxs)(`button`,{type:`button`,className:F(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-left transition-colors`,t===a?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>o(e),onMouseEnter:()=>s(t),children:[e.endsWith(`.ts`)||e.endsWith(`.tsx`)||e.endsWith(`.js`)||e.endsWith(`.jsx`)?(0,Q.jsx)(d,{className:`h-4 w-4 text-blue-500`}):(0,Q.jsx)(j,{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]=s,t[9]=o,t[10]=a,t[11]=e):e=t[11],f=r.map(e),t[3]=r,t[4]=s,t[5]=o,t[6]=a,t[7]=f}else f=t[7];let p;return t[12]!==c||t[13]!==u||t[14]!==f?(p=(0,Q.jsxs)(`div`,{ref:c,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:[u,f]}),t[12]=c,t[13]=u,t[14]=f,t[15]=p):p=t[15],p}function Mt(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:Nt}),t[0]=r,t[1]=i,t[2]=a):a=t[2],a}function Nt(e){e.currentTarget.style.visibility=`hidden`}function Pt(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)(Mt,{provider:p}),t[7]=p,t[8]=m);let h;t[9]===r?h=t[10]:(h=r?et(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)(pe,{className:`h-3 w-3`}),t[13]=_):_=t[13];let v;t[14]!==f||t[15]!==m||t[16]!==g?(v=(0,Q.jsxs)(A,{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(Ft,{})).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)(Mt,{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:et(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 Ft(e,t){let n=t.provider??`Other`;return e[n]||(e[n]=[]),e[n].push(t),e}var It=[{value:`build`,label:`Build`,icon:C},{value:`plan`,label:`Plan`,icon:i},{value:`image`,label:`Image`,icon:t},{value:`ralph`,label:`Ralph`,icon:me}];function Lt(e,t,n){return n?`ralph`:e?`plan`:t?`image`:`build`}function Rt(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=Lt(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=It.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)(pe,{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)(A,{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:It.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)(ne,{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 zt(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)(ee,{}),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)(A,{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)(U,{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 $=tt(`useWhisperSpeech`),Bt=`/api/voice-model/download`;function Vt(){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 rt;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 nt;h.current=o,$.info(`Checking IndexedDB model cache`,{url:Bt});try{let r=await o.loadModelByUrl(Bt);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:Bt});try{let e=await h.current.loadModelByUrl(Bt,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=it(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 Ht=Z.forwardRef((e,t)=>{let n=(0,X.c)(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,value:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===r?o=n[5]:(o=F(`relative h-4 w-full overflow-hidden rounded-full bg-secondary`,r),n[4]=r,n[5]=o);let s=`translateX(-${100-(a||0)}%)`,c;n[6]===s?c=n[7]:(c=(0,Q.jsx)(Se,{className:`h-full w-full flex-1 bg-primary transition-all`,style:{transform:s}}),n[6]=s,n[7]=c);let l;return n[8]!==i||n[9]!==t||n[10]!==o||n[11]!==c?(l=(0,Q.jsx)(Pe,{ref:t,className:o,...i,children:c}),n[8]=i,n[9]=t,n[10]=o,n[11]=c,n[12]=l):l=n[12],l});Ht.displayName=Pe.displayName;var Ut=75;function Wt(e){let t=(0,X.c)(11),{open:n,onOpenChange:r,onConfirm:i,downloading:a,progress:o,error:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsxs)(P,{children:[(0,Q.jsx)(M,{children:`Download Voice Model`}),(0,Q.jsxs)(ue,{children:[`To enable voice-to-text, a voice model needs to be downloaded. This is a one-time download of approximately `,Ut,`MB. The model will be cached locally for future use.`]})]}),t[0]=c):c=t[0];let l;t[1]!==a||t[2]!==s||t[3]!==i||t[4]!==r||t[5]!==o?(l=(0,Q.jsxs)(y,{children:[c,a?(0,Q.jsxs)(`div`,{className:`space-y-3 py-4`,children:[(0,Q.jsx)(Ht,{value:o,className:`w-full`}),(0,Q.jsx)(`p`,{className:`text-center text-sm text-muted-foreground`,children:o<100?`Downloading model... ${o}%`:`Initializing model...`})]}):s?(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)(ce,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Q.jsx)(`p`,{children:s})]}),(0,Q.jsxs)(_,{children:[(0,Q.jsx)(A,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Q.jsx)(A,{onClick:i,children:`Try Again`})]})]}):(0,Q.jsxs)(_,{children:[(0,Q.jsx)(A,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Q.jsx)(A,{onClick:i,children:`Download Model`})]})]}),t[1]=a,t[2]=s,t[3]=i,t[4]=r,t[5]=o,t[6]=l):l=t[6];let u;return t[7]!==r||t[8]!==n||t[9]!==l?(u=(0,Q.jsx)(f,{open:n,onOpenChange:r,children:l}),t[7]=r,t[8]=n,t[9]=l,t[10]=u):u=t[10],u}function Gt(e){let t=(0,X.c)(65),{onTranscript:n}=e,{state:r,isWasmSupported:i,transcript:a,error:o,downloadProgress:s,startListening:c,stopListening:l,requestModelDownload:u,resetTranscript:d}=Vt(),{toast:f}=Ge(),[p,m]=(0,Z.useState)(!1),h=(0,Z.useRef)(``),g=(0,Z.useRef)(null),_=r===`recording`,v=r===`transcribing`,y=_||v,b=r===`needs-model`,x=r===`downloading-model`||r===`initializing`,S=r===`checking-support`||r===`idle`,C,w;t[0]!==p||t[1]!==o||t[2]!==f?(C=()=>{o&&o!==g.current&&!p&&f({title:`Voice Input Error`,description:o,variant:`destructive`}),g.current=o},w=[o,p,f],t[0]=p,t[1]=o,t[2]=f,t[3]=C,t[4]=w):(C=t[3],w=t[4]),(0,Z.useEffect)(C,w);let T,E;t[5]!==n||t[6]!==a?(T=()=>{if(a&&a!==h.current){let e=a.substring(h.current.length);h.current=a,n(e)}},E=[a,n],t[5]=n,t[6]=a,t[7]=T,t[8]=E):(T=t[7],E=t[8]),(0,Z.useEffect)(T,E);let O,k;t[9]===a?(O=t[10],k=t[11]):(O=()=>{a||(h.current=``)},k=[a],t[9]=a,t[10]=O,t[11]=k),(0,Z.useEffect)(O,k);let j;t[12]!==y||t[13]!==b||t[14]!==d||t[15]!==c||t[16]!==r||t[17]!==l?(j=()=>{if(b){m(!0);return}y?l():r===`ready`&&(d(),c())},t[12]=y,t[13]=b,t[14]=d,t[15]=c,t[16]=r,t[17]=l,t[18]=j):j=t[18];let M=j,N;t[19]===u?N=t[20]:(N=()=>{u()},t[19]=u,t[20]=N);let P=N,F,I;if(t[21]!==p||t[22]!==r?(I=()=>{r===`ready`&&p&&m(!1)},F=[r,p],t[21]=p,t[22]=r,t[23]=F,t[24]=I):(F=t[23],I=t[24]),(0,Z.useEffect)(I,F),S)return null;if(i===!1){let e;return t[25]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsxs)(Ue,{children:[(0,Q.jsx)(We,{asChild:!0,children:(0,Q.jsxs)(A,{variant:`ghost`,size:`icon-sm`,disabled:!0,className:`text-muted-foreground`,children:[(0,Q.jsx)(ye,{className:`opacity-50`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Voice input not supported`})]})}),(0,Q.jsx)(He,{side:`top`,className:`bg-popover text-popover-foreground`,children:`Voice input not supported in this browser`})]}),t[25]=e):e=t[25],e}let L;t[26]!==o||t[27]!==x||t[28]!==_||t[29]!==v||t[30]!==b?(L=()=>o||(x?`Downloading speech model...`:v?`Transcribing...`:_?`Stop listening`:b?`Click to download speech model`:`Start listening`),t[26]=o,t[27]=x,t[28]=_,t[29]=v,t[30]=b,t[31]=L):L=t[31];let R=L,z;t[32]!==x||t[33]!==_||t[34]!==v?(z=()=>x||v?(0,Q.jsx)(D,{className:`animate-spin`}):_?(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)(ye,{}),t[32]=x,t[33]=_,t[34]=v,t[35]=z):z=t[35];let B=z,ee;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(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]=ee):ee=t[36];let te=_?`bg-primary text-primary-foreground hover:bg-primary/90`:v?`text-muted-foreground`:`text-muted-foreground hover:text-background`,ne=S||x||v,V;t[37]===B?V=t[38]:(V=B(),t[37]=B,t[38]=V);let H;t[39]===R?H=t[40]:(H=R(),t[39]=R,t[40]=H);let U;t[41]===H?U=t[42]:(U=(0,Q.jsx)(`span`,{className:`sr-only`,children:H}),t[41]=H,t[42]=U);let W;t[43]!==M||t[44]!==te||t[45]!==ne||t[46]!==V||t[47]!==U?(W=(0,Q.jsx)(We,{asChild:!0,children:(0,Q.jsxs)(A,{variant:`ghost`,size:`icon-sm`,className:te,onClick:M,disabled:ne,children:[V,U]})}),t[43]=M,t[44]=te,t[45]=ne,t[46]=V,t[47]=U,t[48]=W):W=t[48];let re;t[49]===R?re=t[50]:(re=R(),t[49]=R,t[50]=re);let G;t[51]===re?G=t[52]:(G=(0,Q.jsx)(He,{side:`top`,className:`bg-popover text-popover-foreground max-w-64`,children:re}),t[51]=re,t[52]=G);let K;t[53]!==W||t[54]!==G?(K=(0,Q.jsxs)(Ue,{children:[W,G]}),t[53]=W,t[54]=G,t[55]=K):K=t[55];let q;t[56]!==p||t[57]!==s||t[58]!==o||t[59]!==P||t[60]!==x?(q=(0,Q.jsx)(Wt,{open:p,onOpenChange:m,onConfirm:P,downloading:x,progress:s,error:o}),t[56]=p,t[57]=s,t[58]=o,t[59]=P,t[60]=x,t[61]=q):q=t[61];let J;return t[62]!==K||t[63]!==q?(J=(0,Q.jsxs)(Q.Fragment,{children:[ee,K,q]}),t[62]=K,t[63]=q,t[64]=J):J=t[64],J}function Kt(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)(h,{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:m,setMessage:h,historyIndex:g,setHistoryIndex:_,draftMessage:v,setDraftMessage:y,cursorPosition:b,setCursorPosition:x,availableModels:S,selectedModel:C,setSelectedModel:w,attachments:T,setAttachments:E,planMode:D,setPlanMode:O,ralphMode:k,setRalphMode:j,imageMode:M,setImageMode:P,availableImageModels:F,selectedImageModel:I,setSelectedImageModel:L,allFiles:R,setAllFiles:z,showSuggestions:B,setShowSuggestions:ee,suggestionQuery:te,setSuggestionQuery:ne,selectedIndex:V,setSelectedIndex:H,slashCommands:U,skills:W,showCommandSuggestions:G,setShowCommandSuggestions:K,commandQuery:q,setCommandQuery:J,fileInputRef:ie,textareaRef:ae,suggestionsRef:oe,commandSuggestionsRef:se,state:ce,dispatch:le}=yt(f),ue=M?I:C,de=M?F:S,fe=ce.selectedThreadId??void 0,pe;t[2]!==R||t[3]!==T||t[4]!==q||t[5]!==b||t[6]!==le||t[7]!==v||t[8]!==g||t[9]!==M||t[10]!==u||t[11]!==m||t[12]!==n||t[13]!==D||t[14]!==k||t[15]!==I||t[16]!==V||t[17]!==C||t[18]!==z||t[19]!==E||t[20]!==J||t[21]!==x||t[22]!==y||t[23]!==_||t[24]!==P||t[25]!==h||t[26]!==O||t[27]!==j||t[28]!==H||t[29]!==K||t[30]!==ee||t[31]!==ne||t[32]!==G||t[33]!==B||t[34]!==W||t[35]!==U||t[36]!==te||t[37]!==fe||t[38]!==ae?(pe={message:m,setMessage:h,attachments:T,selectedModel:C,onSend:n,isStreaming:u,selectedThreadId:fe,isListening:!1,stopListening:Zt,resetTranscript:Xt,dispatch:le,historyIndex:g,setHistoryIndex:_,draftMessage:v,setDraftMessage:y,cursorPosition:b,setCursorPosition:x,showSuggestions:B,setShowSuggestions:ee,suggestionQuery:te,setSuggestionQuery:ne,allFiles:R,setAllFiles:z,selectedIndex:V,setSelectedIndex:H,showCommandSuggestions:G,setShowCommandSuggestions:K,commandQuery:q,setCommandQuery:J,slashCommands:U,skills:W,textareaRef:ae,setAttachments:E,planMode:D,setPlanMode:O,ralphMode:k,setRalphMode:j,imageMode:M,setImageMode:P,selectedImageModel:I},t[2]=R,t[3]=T,t[4]=q,t[5]=b,t[6]=le,t[7]=v,t[8]=g,t[9]=M,t[10]=u,t[11]=m,t[12]=n,t[13]=D,t[14]=k,t[15]=I,t[16]=V,t[17]=C,t[18]=z,t[19]=E,t[20]=J,t[21]=x,t[22]=y,t[23]=_,t[24]=P,t[25]=h,t[26]=O,t[27]=j,t[28]=H,t[29]=K,t[30]=ee,t[31]=ne,t[32]=G,t[33]=B,t[34]=W,t[35]=U,t[36]=te,t[37]=fe,t[38]=ae,t[39]=pe):pe=t[39];let{handleSend:me,handleKeyDown:he,handleTextareaInput:ge,insertFileReference:_e,insertCommand:ve,insertSkill:ye,fileSuggestions:be}=xt(pe),xe;t[40]===h?xe=t[41]:(xe=e=>{h(t=>(t.endsWith(` `),t+e))},t[40]=h,t[41]=xe);let Se=xe,Ce;t[42]===E?Ce=t[43]:(Ce=e=>{let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(Yt);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];E(n=>[...n,{fileName:t.name||`pasted-image.${t.type.split(`/`)[1]||`png`}`,content:e,mimeType:t.type}])},n.readAsDataURL(t)}}},t[42]=E,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)(Kt,{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...`:D?`Describe what you want Tarsk to plan...`:M?`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]!==m||t[52]!==Oe||t[53]!==ae?(ke=(0,Q.jsx)(`textarea`,{ref:ae,value:m,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]=m,t[52]=Oe,t[53]=ae,t[54]=ke):ke=t[54];let Ae;t[55]!==q||t[56]!==se||t[57]!==ve||t[58]!==ye||t[59]!==V||t[60]!==H||t[61]!==G||t[62]!==W||t[63]!==U?(Ae=(0,Q.jsx)(Tt,{visible:G,commands:U,skills:W,query:q,selectedIndex:V,onSelectCommand:ve,onSelectSkill:ye,onMouseEnterSuggestion:H,containerRef:se}),t[55]=q,t[56]=se,t[57]=ve,t[58]=ye,t[59]=V,t[60]=H,t[61]=G,t[62]=W,t[63]=U,t[64]=Ae):Ae=t[64];let je;t[65]!==be||t[66]!==_e||t[67]!==V||t[68]!==H||t[69]!==B||t[70]!==te||t[71]!==oe?(je=(0,Q.jsx)(jt,{showSuggestions:B,fileSuggestions:be,suggestionQuery:te,selectedIndex:V,onSelectFile:_e,onMouseEnterSuggestion:H,containerRef:oe}),t[65]=be,t[66]=_e,t[67]=V,t[68]=H,t[69]=B,t[70]=te,t[71]=oe,t[72]=je):je=t[72];let Me;t[73]!==T||t[74]!==C?.id||t[75]!==C?.name||t[76]!==C?.supportsImages||t[77]!==E?(Me=T.length>0&&(0,Q.jsxs)(`div`,{className:`px-4`,children:[(0,Q.jsx)(kt,{attachments:T,onRemove:e=>E(t=>t.filter((t,n)=>n!==e))}),T.some(Jt)&&C?.supportsImages===!1&&(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-xs text-amber-500`,children:[(0,Q.jsx)(p,{className:`h-3 w-3 shrink-0`}),(0,Q.jsxs)(`span`,{children:[`Images are not supported by `,C?.name||C?.id]})]})]}),t[73]=T,t[74]=C?.id,t[75]=C?.name,t[76]=C?.supportsImages,t[77]=E,t[78]=Me):Me=t[78];let Ne;t[79]===ie?Ne=t[80]:(Ne=(0,Q.jsx)(zt,{onFileAttach:()=>ie.current?.click()}),t[79]=ie,t[80]=Ne);let Pe;t[81]===Se?Pe=t[82]:(Pe=(0,Q.jsx)(Gt,{onTranscript:Se}),t[81]=Se,t[82]=Pe);let Fe=M?L:w,Ie;t[83]!==de||t[84]!==ue||t[85]!==Fe?(Ie=(0,Q.jsx)(Pt,{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]!==M||t[92]!==D||t[93]!==k||t[94]!==P||t[95]!==O||t[96]!==j?(Re=(0,Q.jsx)(Rt,{planMode:D,imageMode:M,ralphMode:k,setPlanMode:O,setImageMode:P,setRalphMode:j}),t[91]=M,t[92]=D,t[93]=k,t[94]=P,t[95]=O,t[96]=j,t[97]=Re):Re=t[97];let ze=u?r:me,Be;t[98]!==T.length||t[99]!==a||t[100]!==ue||t[101]!==u||t[102]!==m?(Be=!u&&((a??!1)||!m.trim()&&T.length===0||!ue),t[98]=T.length,t[99]=a,t[100]=ue,t[101]=u,t[102]=m,t[103]=Be):Be=t[103];let Y;t[104]===u?Y=t[105]:(Y=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]=Y);let Ve=u?`Stop generation`:`Send message`,He;t[106]===Ve?He=t[107]:(He=(0,Q.jsx)(`span`,{className:`sr-only`,children:Ve}),t[106]=Ve,t[107]=He);let Ue;t[108]!==ze||t[109]!==Be||t[110]!==Y||t[111]!==He?(Ue=(0,Q.jsxs)(A,{size:`icon`,className:`h-7 w-7 rounded-full`,onClick:ze,disabled:Be,children:[Y,He]}),t[108]=ze,t[109]=Be,t[110]=Y,t[111]=He,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]===E?qe=t[128]:(qe=e=>At(e,e=>E(t=>[...t,...e])),t[127]=E,t[128]=qe);let Je;t[129]!==ie||t[130]!==qe?(Je=(0,Q.jsx)(`input`,{ref:ie,type:`file`,multiple:!0,className:`hidden`,onChange:qe}),t[129]=ie,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 Jt(e){return e.mimeType.startsWith(`image/`)}function Yt(e){return e.type.startsWith(`image/`)}function Xt(){}function Zt(){}var Qt=Fe,$t=Ee,en=Me,tn=Z.forwardRef((e,t)=>{let n=(0,X.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,inset:a,children:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=a&&`pl-8`,c;n[5]!==i||n[6]!==s?(c=F(`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`,s,i),n[5]=i,n[6]=s,n[7]=c):c=n[7];let l;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(B,{className:`ml-auto`}),n[8]=l):l=n[8];let u;return n[9]!==r||n[10]!==o||n[11]!==t||n[12]!==c?(u=(0,Q.jsxs)(Ne,{ref:t,className:c,...o,children:[r,l]}),n[9]=r,n[10]=o,n[11]=t,n[12]=c,n[13]=u):u=n[13],u});tn.displayName=Ne.displayName;var nn=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 a;n[3]===r?a=n[4]:(a=F(`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]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,Q.jsx)(je,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});nn.displayName=je.displayName;var rn=Z.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,sideOffset:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=a===void 0?4:a,s;n[4]===r?s=n[5]:(s=F(`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]=s);let c;return n[6]!==i||n[7]!==t||n[8]!==o||n[9]!==s?(c=(0,Q.jsx)(Ae,{children:(0,Q.jsx)(Le,{ref:t,sideOffset:o,className:s,...i})}),n[6]=i,n[7]=t,n[8]=o,n[9]=s,n[10]=c):c=n[10],c});rn.displayName=Le.displayName;var an=Z.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i&&`pl-8`,s;n[4]!==r||n[5]!==o?(s=F(`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`,o,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==a||n[8]!==t||n[9]!==s?(c=(0,Q.jsx)(ke,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});an.displayName=ke.displayName;var on=Z.forwardRef((e,t)=>{let n=(0,X.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:a,children:i,checked:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]===a?s=n[6]:(s=F(`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`,a),n[5]=a,n[6]=s);let c;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Q.jsx)(Ce,{children:(0,Q.jsx)(ne,{className:`h-4 w-4`})})}),n[7]=c):c=n[7];let l;return n[8]!==r||n[9]!==i||n[10]!==o||n[11]!==t||n[12]!==s?(l=(0,Q.jsxs)(De,{ref:t,className:s,checked:r,...o,children:[c,i]}),n[8]=r,n[9]=i,n[10]=o,n[11]=t,n[12]=s,n[13]=l):l=n[13],l});on.displayName=De.displayName;var sn=Z.forwardRef((e,t)=>{let n=(0,X.c)(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:i,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===i?o=n[5]:(o=F(`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`,i),n[4]=i,n[5]=o);let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Q.jsx)(Ce,{children:(0,Q.jsx)(de,{className:`h-2 w-2 fill-current`})})}),n[6]=s):s=n[6];let c;return n[7]!==r||n[8]!==a||n[9]!==t||n[10]!==o?(c=(0,Q.jsxs)(Te,{ref:t,className:o,...a,children:[s,r]}),n[7]=r,n[8]=a,n[9]=t,n[10]=o,n[11]=c):c=n[11],c});sn.displayName=Te.displayName;var cn=Z.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i&&`pl-8`,s;n[4]!==r||n[5]!==o?(s=F(`px-2 py-1.5 text-sm font-semibold`,o,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==a||n[8]!==t||n[9]!==s?(c=(0,Q.jsx)(Oe,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});cn.displayName=Oe.displayName;var ln=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 a;n[3]===r?a=n[4]:(a=F(`-mx-1 my-1 h-px bg-muted`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,Q.jsx)(we,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ln.displayName=we.displayName;var un=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=F(`ml-auto text-xs tracking-widest opacity-60`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a};un.displayName=`DropdownMenuShortcut`;function dn(e){let t=(0,X.c)(17),{currentBranch:n,availableBranches:r,isLoadingBranches:i,isCheckingOut:a,onLoadBranches:o,onCheckoutBranch:s}=e,c;t[0]===o?c=t[1]:(c=e=>{e&&o()},t[0]=o,t[1]=c);let l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(xe,{className:`h-3.5 w-3.5 shrink-0`}),t[2]=l):l=t[2];let u=n||`Unknown`,d;t[3]===u?d=t[4]:(d=(0,Q.jsx)($t,{asChild:!0,children:(0,Q.jsxs)(A,{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:[l,u]})}),t[3]=u,t[4]=d);let f;t[5]!==r||t[6]!==n||t[7]!==a||t[8]!==i||t[9]!==s?(f=i?(0,Q.jsxs)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground flex items-center gap-2`,children:[(0,Q.jsx)(D,{className:`h-3 w-3 animate-spin`}),`Loading branches...`]}):r.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`No branches found`}):r.map(e=>(0,Q.jsxs)(an,{disabled:e===n||a,onClick:()=>s(e),children:[(0,Q.jsx)(xe,{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]=r,t[6]=n,t[7]=a,t[8]=i,t[9]=s,t[10]=f):f=t[10];let p;t[11]===f?p=t[12]:(p=(0,Q.jsx)(rn,{align:`start`,children:f}),t[11]=f,t[12]=p);let m;return t[13]!==c||t[14]!==d||t[15]!==p?(m=(0,Q.jsxs)(Qt,{onOpenChange:c,children:[d,p]}),t[13]=c,t[14]=d,t[15]=p,t[16]=m):m=t[16],m}function fn({threadId:e,currentConversationId:t,refreshKey:n,children:r}){let[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),[c,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{y(!1)},[n]),(0,Z.useEffect)(()=>{if(!g||!e||v&&!n)return;async function r(){p(!0),h(null);try{let n=(await q(e)).currentConversationId??t,[r,i]=await Promise.allSettled([u(e).catch(e=>{throw console.error(`Thread usage summary failed:`,e),e}),n?he(e,n).catch(e=>{throw console.error(`Conversation usage failed:`,e),e}):Promise.resolve(null)]);if(r.status===`fulfilled`)a(r.value);else throw console.error(`Failed to fetch thread usage summary:`,r.reason),r.reason;if(i?.status===`fulfilled`&&i.value){if(s(i.value),i.value.model?.model){let e=i.value.model.model,t=i.value.model.provider,n=t&&e?`${t}/${e}`:e;console.log(`Fetching model info for:`,n,`(provider:`,t,`model:`,e+`)`),le(n).then(d).catch(e=>{console.warn(`Failed to fetch model info:`,e)})}}else if(i?.status===`rejected`)throw console.error(`Failed to fetch conversation usage:`,i.reason),i.reason;y(!0)}catch(e){console.error(`[TokenUsageTooltip] Failed to load usage data:`,e),h(`Failed to load usage data`)}finally{p(!1)}}r()},[g,e,t,n]),!e||e===``)return console.log(`[TokenUsageTooltip] No valid threadId, returning children only`),(0,Q.jsx)(Q.Fragment,{children:r});let b=e=>e==null||e===0?`0`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString();return e?(0,Q.jsxs)(Ue,{open:g,onOpenChange:e=>{_(e),!e&&v&&y(!1)},children:[(0,Q.jsx)(We,{asChild:!0,children:r}),(0,Q.jsx)(He,{side:`top`,align:`center`,className:`max-w-xs`,children:(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-2`,children:[f&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(H,{className:`h-3 w-3 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Loading usage...`})]}),m&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(H,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:`No usage information for this thread`})]}),!f&&!m&&i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(H,{className:`h-3 w-3`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[b(i.totalTokens),` tokens`]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(O,{className:`h-3 w-3`}),(0,Q.jsxs)(`span`,{children:[i.conversationCount,` chats`]})]})]}),o&&(0,Q.jsxs)(`div`,{className:`border-t border-border pt-2 space-y-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:`Current Chat:`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(l,{className:`h-3 w-3`}),(0,Q.jsxs)(`span`,{children:[((e,t)=>{let n=b(e);return t?`${n} (${Math.round(e/t*100)}%)`:n})(o.footprint?.totalTokens??o.usage.totalTokens,typeof c?.contextWindow==`number`?c.contextWindow:typeof c?.context_length==`number`?c.context_length:void 0),` `,`tokens`]})]}),o.model.model&&(0,Q.jsx)(`div`,{className:`text-muted-foreground`,children:o.model.model}),(c?.contextWindow||c?.context_length)&&(0,Q.jsxs)(`div`,{className:`text-muted-foreground`,children:[`Max context:`,` `,b(typeof c.contextWindow==`number`?c.contextWindow:typeof c.context_length==`number`?c.context_length:0),` `,`tokens`]})]}),(0,Q.jsxs)(`div`,{className:`border-t border-border pt-2 flex items-center gap-3 text-[10px] text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{children:[`In: `,b(i.totalInputTokens)]}),(0,Q.jsxs)(`span`,{children:[`Out: `,b(i.totalOutputTokens)]}),(0,Q.jsxs)(`span`,{children:[`Avg: `,b(i.averageTokensPerConversation),`/chat`]})]})]})]})})]}):(0,Q.jsx)(Q.Fragment,{children:r})}function pn(e,t){return`${e.filter(e=>e.sender===`agent`).length}:${t?`streaming`:`idle`}`}function mn(e){if(typeof e?.contextWindow==`number`)return e.contextWindow;if(typeof e?.context_length==`number`)return e.context_length}function hn(e){return e>75?`text-red-500`:e>50?`text-orange-500`:`text-muted-foreground`}function gn(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=hn(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 _n({threadId:e,isStreaming:t=!1,messages:n=[]}){let[r,i]=(0,Z.useState)(),[a,o]=(0,Z.useState)(),s=(0,Z.useMemo)(()=>pn(n,t),[n,t]);return(0,Z.useEffect)(()=>{async function t(){if(!e){i(void 0),o(void 0);return}try{let t=(await q(e)).currentConversationId;if(i(t),!t){o(void 0);return}let n=await he(e,t),r=n.model?.model;if(!r){o(void 0);return}let a=n.model.provider,s=mn(await le(a?`${a}/${r}`:r));if(!s){o(void 0);return}let c=n.footprint?.totalTokens??n.usage.totalTokens;o(Math.round(c/s*100))}catch(e){console.error(`Failed to fetch thread usage data:`,e),o(void 0)}}t()},[e,s]),!e||e===``?null:(0,Q.jsx)(fn,{threadId:e,currentConversationId:r,refreshKey:s,children:(0,Q.jsxs)(A,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,children:[typeof a==`number`&&a>25?(0,Q.jsx)(gn,{percentage:a}):(0,Q.jsx)(O,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`View token usage`})]})})}var vn=3e4,yn=new Map;function bn(e,t){let n=yn.get(e);if(n)for(let e of n)e(t)}function xn(e,t){let n=yn.get(e);return n||(n=new Set,yn.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&yn.delete(e)}}function Sn(e){let[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(0),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(void 0),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(`Up to date`),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(void 0),[k,A]=(0,Z.useState)(void 0),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(!1),F=(0,Z.useRef)(!0),I=(0,Z.useRef)(void 0),L=(0,Z.useCallback)(e=>{n(e.hasChanges),i(e.changedFilesCount),s(e.hasUnpushedCommits),l(e.currentBranch),b(e.hasRemoteBranch),d(e.isOnGitHub),p(e.remoteUrl),h(e.canCreateRepo),v(e.repoUrl),S(e.status),w(e.defaultBranch??null),E(e.prExists),O(e.prUrl),A(e.prState),M(e.commitsAheadOfDefault??!1)},[]),R=(0,Z.useRef)(L);R.current=L;let z=(0,Z.useCallback)(async(t=!1)=>{if(!e)return;let n=setTimeout(()=>P(!0),100);try{let n=`unified-git-status-${e}`;t&&a.invalidate(n);let r=await a.get(n,()=>g(e,t),vn);L(r),bn(e,r)}catch(e){console.error(`Failed to fetch unified git status:`,e)}finally{clearTimeout(n),P(!1)}},[e,L]);return(0,Z.useEffect)(()=>{if(e)return xn(e,e=>{R.current(e)})},[e]),(0,Z.useEffect)(()=>{if(!e)return;let t=I.current!==e;t&&(I.current=e,F.current=!0),(async()=>{if(F.current){let t=`unified-git-status-${e}`,n=a.getSync(t);n&&L(n),F.current=!1}await z(t)})()},[e,z,L]),{hasChanges:t,changedFilesCount:r,hasUnpushedCommits:o,hasRemoteBranch:y,currentBranch:c,isOnGitHub:u,remoteUrl:f,canCreateRepo:m,repoUrl:_,status:x,defaultBranch:C,prExists:T,prUrl:D,prState:k,commitsAheadOfDefault:j,isRefreshing:N,fetchUnifiedStatus:z}}function Cn(e){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),s=Sn(e);async function c(){if(!(!e||r)){i(!0);try{n((await m(e)).branches)}catch{n([])}finally{i(!1)}}}async function l(t){if(!(!e||t===s.currentBranch)){o(!0);try{await S(e,t),await s.fetchUnifiedStatus(!0),Ke({title:`Switched to branch "${t}"`})}catch(e){Ke({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 wn(e){let t=(0,X.c)(8),{collapsed:n}=e,{theme:r,setTheme:i}=at();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)(v,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),s=(0,Q.jsx)(I,{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)(A,{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 Tn({threadId:e,isStreaming:t=!1,messages:n=[]}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(null),s=Cn(e);return(0,Z.useEffect)(()=>{e&&R(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)(dn,{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)(wn,{collapsed:!1}),(0,Q.jsx)(_n,{threadId:e,isStreaming:t,messages:n}),e&&(0,Q.jsxs)(Ue,{children:[(0,Q.jsx)(We,{asChild:!0,children:(0,Q.jsx)(A,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:async()=>{if(!(!e||r)){i(!0);try{let t=await R(e);await navigator.clipboard.writeText(t)}finally{i(!1)}}},disabled:r,"aria-label":`Copy repository folder path`,children:(0,Q.jsx)(k,{className:`h-4 w-4`})})}),(0,Q.jsxs)(He,{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 En(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&&vt(e.id,e.input.code,t)}catch{}}function Dn(){let{state:e,dispatch:t}=Re(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),o=(0,Z.useRef)(``),s=(0,Z.useRef)(``),l=(0,Z.useRef)([]),u=(0,Z.useRef)(!1),d=(0,Z.useRef)(null),f=(0,Z.useRef)(null),p=(0,Z.useRef)(()=>{}),[m,h]=(0,Z.useState)(null),g=(0,Z.useRef)(!1),_=(0,Z.useRef)(!1),v=(0,Z.useRef)(null),y=(0,Z.useRef)(null),b=(0,Z.useRef)(null),{selectedThreadId:x,selectedProjectId:S,messages:C,queuedChatMessages:w,isStreaming:E,streamingModel:D,processingThreadIds:O}=e,k=!!(x&&O.includes(x)),A=(0,Z.useCallback)(n=>{if(d.current=null,f.current=null,g.current){g.current=!1;return}let r=l.current,i=Be(r)||`...`;if(v.current&&(r.length===0||i===`...`)){let r={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${v.current}`,contentType:`text`,timestamp:new Date().toISOString(),model:e.streamingModel||n,isThinking:!1};t({type:Y.AddMessage,message:r}),t({type:Y.ResetStream}),x&&t({type:Y.RemoveProcessingThread,threadId:x}),v.current=null;return}let a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:i,contentType:`markdown`,timestamp:new Date().toISOString(),model:e.streamingModel||n,isThinking:!1};o.current=``,s.current=``,l.current=[],v.current=null,t({type:Y.AddMessage,message:a}),t({type:Y.ResetStream}),x&&(t({type:Y.MarkThreadCompleted,threadId:x}),t({type:Y.RemoveProcessingThread,threadId:x}))},[e.streamingModel,t,x]);(0,Z.useEffect)(()=>{p.current=A},[A]);let j=(0,Z.useCallback)(()=>{x&&h(x),g.current=!0,x&&ae(x),d.current&&=(d.current.abort(),null),f.current&&=(f.current(),null),o.current=``,s.current=``,l.current=[],v.current=null;let n={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:n}),t({type:Y.ResetStream}),x&&(t({type:Y.MarkThreadCompleted,threadId:x}),t({type:Y.RemoveProcessingThread,threadId:x}))},[x,t,e.streamingModel]);(0,Z.useEffect)(()=>{_.current&&!E&&d.current&&(d.current.abort(),d.current=null,f.current&&=(f.current(),null),p.current(D||`default`)),_.current=E},[E,D]),(0,Z.useEffect)(()=>{if(y.current&&=(clearTimeout(y.current),null),E){let e=12e4,t=n=>{y.current&&=(clearTimeout(y.current),null),y.current=setTimeout(()=>{let n=Date.now(),r=b?.current??null;if(r!=null){let i=n-r;if(i<e){t(e-i);return}}console.warn(`[stream-safety] Streaming stuck for 2 minutes with no activity, auto-finalizing`),d.current&&=(d.current.abort(),null),f.current&&=(f.current(),null),p.current(D||`default`)},n)},n=e;if(b?.current!=null){let t=Date.now()-b.current;n=t>=e?0:e-t}t(n)}return()=>{y.current&&=(clearTimeout(y.current),null)}},[E,D]),(0,Z.useEffect)(()=>()=>{d.current&&=(d.current.abort(),null),f.current&&=(f.current(),null),o.current=``,s.current=``,l.current=[],u.current=!1,v.current=null,t({type:Y.ResetStream})},[x,t]),(0,Z.useEffect)(()=>{if(!x)return;let e=!1;async function n(){try{let n=await G(x);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}},[x,S,t]),(0,Z.useEffect)(()=>{if(!x||!k||E)return;let e=new AbortController;return d.current=e,t({type:Y.ResetStream}),t({type:Y.SetStreaming,isStreaming:!0}),o.current=``,s.current=``,l.current=[],u.current=!1,v.current=null,be(x,e.signal).then(n=>{if(!n||e.signal.aborted){p.current(`default`);return}f.current=V(n,e=>{if(t({type:Y.IncrementStreamEventCount}),e.type===`error`){let t=e.content||`Unknown error occurred`;v.current=t,r(t);return}if(e.type!==`message`){if(e.type===`toolcall_delta`){e.partial?.content?.[0]?.id&&e.delta&&t({type:Y.UpdateToolCallProgress,toolCallId:e.partial.content[0].id,progress:{toolCallId:e.partial.content[0].id,toolName:e.partial.content[0].name,delta:e.delta,partial:e.partial}});return}if(e.model&&t({type:Y.SetStreamModel,model:e.model}),e.type===`thinking`||e.isThinking){let n=e.content??``;En(n,x),s.current+=n;let r=ze(l.current,`thinking`,n);l.current=r,t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:n,segments:r})}else if(e.type===`result`)u.current=!0,o.current=e.content??``,l.current=Ve(l.current,e.content??``),t({type:Y.SetStreamContent,content:e.content??``});else{if(u.current)return;o.current+=e.content??``;let n=ze(l.current,`content`,e.content??``);l.current=n,t({type:Y.AppendStreamChunk,chunkType:`content`,content:e.content??``,segments:n})}}},()=>{p.current(`default`)},e=>{if(e.includes(`AbortError`)||e.includes(`canceled`)||e.includes(`BodyStreamBuffer was aborted`)){p.current(`default`);return}v.current=e,r(e)},e=>{if(t({type:Y.IncrementStreamEventCount}),e.role===`assistant`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(e.isThinking??!1){s.current+=r;let e=ze(l.current,`thinking`,r);l.current=e,t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:r,segments:e});return}let i=!1;if(typeof n==`object`&&Array.isArray(n)&&n.length>0)i=!0;else if(typeof r==`string`&&r.trim().startsWith(`[`))try{let e=JSON.parse(r);i=Array.isArray(e)&&e.length>0}catch{}if(i)u.current=!0,o.current=r,l.current=Ve(l.current,r),t({type:Y.SetStreamContent,content:r});else{o.current+=r;let e=ze(l.current,`content`,r);l.current=e,t({type:Y.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}else if(e.role===`tool`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(r){o.current+=r;let e=ze(l.current,`content`,r);l.current=e,t({type:Y.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}})}).catch(e=>{if(e instanceof Error&&e.name===`AbortError`){t({type:Y.ResetStream});return}if(e instanceof Error&&e.message.includes(`not currently processing`)){t({type:Y.ResetStream});return}console.error(`Failed to subscribe to chat stream:`,e),t({type:Y.ResetStream})}),()=>{e.abort(),f.current&&=(f.current(),null)}},[x,k]);let M=(0,Z.useCallback)(async(n,i,m,g,_,y,b)=>{if(!x)return;r(null),h(null),d.current&&d.current.abort(),f.current&&f.current();let C=`msg-${Date.now()}`,w;try{let e=await J(x,C);e.success&&e.stashed&&e.checkpointRef&&(w=e.checkpointRef)}catch{}let E={messageId:C,sender:`user`,content:n,contentType:`text`,timestamp:new Date().toISOString(),model:i,attachments:m.map(e=>({fileName:e.fileName,content:e.content,mimeType:e.mimeType})),checkpointRef:w};t({type:Y.AddMessage,message:E});let D=n.trim().replace(/\n/g,` `).slice(0,100);if(S&&x&&(c(x,{title:D}).catch(e=>{console.error(`Failed to update thread title:`,e)}),t({type:Y.UpdateThreadTitle,projectId:S,threadId:x,title:D})),y){let e=g??void 0;if(!e&&typeof i==`string`){let t=i.split(/[:/]/)[0]?.trim();t&&(e=t)}if(!e){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:i,isThinking:!1};t({type:Y.AddMessage,message:e}),t({type:Y.ResetStream});return}t({type:Y.SetStreaming,isStreaming:!0});try{let r=await T(n,i,e,x),a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:n,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1,generatedImageUrl:r.imageUrl,generatedImageData:r.imageData};t({type:Y.AddMessage,message:a})}catch(e){let n=e instanceof Error?e.message:`Image generation failed`,r={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${n}`,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1};t({type:Y.AddMessage,message:r})}finally{t({type:Y.ResetStream})}return}t({type:Y.ResetStream}),t({type:Y.SetStreaming,isStreaming:!0}),o.current=``,u.current=!1;let O=new AbortController;d.current=O;try{let a=await W(x,n,i,m,O.signal,g,_,b);if(!a){p.current(i);return}f.current=V(a,n=>{if(t({type:Y.IncrementStreamEventCount}),n.type===`error`){let e=n.content||`Unknown error occurred`;v.current=e,r(e);return}if(n.type!==`message`){if(n.type===`toolcall_delta`){if(n.partial?.content?.[0]?.id&&n.delta){let e=n.partial.content[0].id,r=n.partial.content[0].name;t({type:Y.UpdateToolCallProgress,toolCallId:e,progress:{toolCallId:e,toolName:r,delta:n.delta,partial:n.partial}})}return}if(n.model&&t({type:Y.SetStreamModel,model:n.model}),n.type===`thinking`||n.isThinking){let r=n.content??``;En(r,e.selectedThreadId),s.current+=r;let i=ze(l.current,`thinking`,r);l.current=i,t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:r,segments:i})}else if(n.type===`result`)u.current=!0,o.current=n.content??``,l.current=Ve(l.current,n.content??``),t({type:Y.SetStreamContent,content:n.content??``});else{if(u.current)return;o.current+=n.content??``;let e=ze(l.current,`content`,n.content??``);l.current=e,t({type:Y.AppendStreamChunk,chunkType:`content`,content:n.content??``,segments:e})}}},()=>{p.current(i)},e=>{if(e.includes(`AbortError`)||e.includes(`canceled`)||e.includes(`BodyStreamBuffer was aborted`)){p.current(i);return}v.current=e,r(e)},e=>{if(t({type:Y.IncrementStreamEventCount}),e.role===`assistant`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(e.isThinking??!1){s.current+=r;let e=ze(l.current,`thinking`,r);l.current=e,t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:r,segments:e});return}let i=!1;if(typeof n==`object`&&Array.isArray(n)&&n.length>0)i=!0;else if(typeof r==`string`&&r.trim().startsWith(`[`))try{let e=JSON.parse(r);i=Array.isArray(e)&&e.length>0}catch{}if(i)u.current=!0,o.current=r,l.current=Ve(l.current,r),t({type:Y.SetStreamContent,content:r});else{o.current+=r;let e=ze(l.current,`content`,r);l.current=e,t({type:Y.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}else if(e.role===`tool`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(r){o.current+=r;let e=ze(l.current,`content`,r);l.current=e,t({type:Y.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}})}catch(e){if(e instanceof Error&&e.name===`AbortError`||e instanceof Error&&e.message.includes(`BodyStreamBuffer was aborted`))return;if(e instanceof ve){t({type:Y.ResetStream}),a(!0);return}r(e instanceof Error?e.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`),v.current=e instanceof Error?e.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`,t({type:Y.ResetStream})}},[x,S,t]);(0,Z.useEffect)(()=>{let n=e.pendingChatMessage;if(!n||E||n.threadId!==x)return;let r=setTimeout(()=>{t({type:Y.ClearPendingChatMessage}),M(n.message,n.model,[],n.provider)},100);return()=>clearTimeout(r)},[e.pendingChatMessage,E,x,t,M]);let N=(0,Z.useMemo)(()=>x?w.filter(e=>e.threadId===x):[],[x,w]),P=(0,Z.useRef)(!1);return(0,Z.useEffect)(()=>{if(E||!x||N.length===0||P.current)return;let[e]=N;P.current=!0,t({type:Y.RemoveQueuedChatMessage,queuedMessageId:e.id});let n=setTimeout(()=>{M(e.message,e.model,e.attachments,e.provider,e.planMode,e.imageMode,e.ralphMode),P.current=!1},0);return()=>{clearTimeout(n),P.current=!1}},[t,M,E,N,x]),{error:n,setError:r,handleSend:M,handleStop:j,isStreaming:E,selectedThreadId:x,queuedMessagesForThread:N,handleRemoveQueuedMessage:(0,Z.useCallback)(e=>{let n=N.find(t=>t.id===e);t({type:Y.RemoveQueuedChatMessage,queuedMessageId:e}),!(!n||E||C.length>0||!x)&&M(n.message,n.model,n.attachments,n.provider,n.planMode,n.imageMode,n.ralphMode)},[t,M,E,C.length,N,x]),showEmptyBalanceDialog:i,setShowEmptyBalanceDialog:a}}function On(e){let t=(0,X.c)(10),{open:n,onClose:r}=e,i=Ie(),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)(Ze,{children:[(0,Q.jsx)(Je,{children:`Balance empty`}),(0,Q.jsx)(qe,{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)(Ye,{children:[o,(0,Q.jsx)(Xe,{children:(0,Q.jsx)(A,{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)(Qe,{open:n,onOpenChange:a,children:s}),t[6]=n,t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function kn(e){let t=(0,X.c)(13),{todos:n}=e,r;t[0]===n?r=t[1]:(r=n.filter(jn),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(An),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 An(e){return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`done`?(0,Q.jsx)(L,{className:`h-4 w-4 shrink-0 mt-0.5 text-brand`}):e.status===`working`?(0,Q.jsx)(oe,{className:`h-4 w-4 shrink-0 mt-0.5 text-yellow-500`}):(0,Q.jsx)(de,{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 jn(e){return e.status===`done`}function Mn(){let e=(0,X.c)(16),{todos:t}=(0,Z.useContext)(ct),[n,r]=(0,Z.useState)(!1),i;e[0]===t?i=e[1]:(i=t.filter(Nn),e[0]=t,e[1]=i);let a=i.length;if(t.length-a<=0)return null;let o,c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>r(!0),c=(0,Q.jsx)(s,{className:`h-4 w-4 shrink-0`}),e[2]=o,e[3]=c):(o=e[2],c=e[3]);let l;e[4]!==a||e[5]!==t.length?(l=(0,Q.jsxs)(A,{variant:`outline`,size:`sm`,className:`gap-2 bg-background ml-2`,onClick:o,children:[c,a,` of `,t.length,` complete`]}),e[4]=a,e[5]=t.length,e[6]=l):l=e[6];let u;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(P,{children:(0,Q.jsx)(M,{children:`Tasks`})}),e[7]=u):u=e[7];let d;e[8]===t?d=e[9]:(d=(0,Q.jsxs)(y,{className:`max-w-md`,children:[u,(0,Q.jsx)(kn,{todos:t})]}),e[8]=t,e[9]=d);let p;e[10]!==n||e[11]!==d?(p=(0,Q.jsx)(f,{open:n,onOpenChange:r,children:d}),e[10]=n,e[11]=d,e[12]=p):p=e[12];let m;return e[13]!==l||e[14]!==p?(m=(0,Q.jsxs)(Q.Fragment,{children:[l,p]}),e[13]=l,e[14]=p,e[15]=m):m=e[15],m}function Nn(e){return e.status===`done`}function Pn(e){let t=(0,X.c)(36),{messages:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?[]:n,t[0]=n,t[1]=r);let i=r,{state:a,dispatch:s}=Re(),{isCreatingProject:c,selectedThreadId:l}=a,{handleSend:u,handleStop:d,isStreaming:f,queuedMessagesForThread:p,handleRemoveQueuedMessage:m,showEmptyBalanceDialog:h,setShowEmptyBalanceDialog:g}=Dn(),_=a.pendingChatMessage?.threadId===l,v=f||_,y=i.length>0,{hasChanges:b,changedFilesCount:S}=Sn(l??void 0),{setActiveMainTab:C}=$e(),w;t[2]!==s||t[3]!==l?(w=async()=>{if(l)try{let e=await o(l);s({type:Y.ClearMessages}),console.log(`New conversation started:`,e);let t=await G(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)(On,{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]!==b||t[13]!==y||t[14]!==C?(O=(y||b)&&(0,Q.jsxs)(`div`,{className:`absolute -top-12 left-0 z-10 ml-8 flex items-center gap-2`,children:[y&&(0,Q.jsxs)(A,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:T,children:[(0,Q.jsx)(ee,{className:`h-4 w-4 shrink-0`}),`New Chat`]}),b&&(0,Q.jsxs)(A,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:()=>C(`review`),children:[(0,Q.jsx)(x,{className:`h-4 w-4 shrink-0`}),S,` `,S===1?`File`:`Files`,` Changed`]}),y&&(0,Q.jsx)(Mn,{})]}),t[10]=S,t[11]=T,t[12]=b,t[13]=y,t[14]=C,t[15]=O):O=t[15];let k=!l&&!c,j;t[16]!==v||t[17]!==m||t[18]!==u||t[19]!==d||t[20]!==p||t[21]!==k?(j=(0,Q.jsx)(qt,{onSend:u,onStop:d,isStreaming:v,disabled:k,initialValue:``,queuedMessages:p,onRemoveQueuedMessage:m,isOverlay:!1}),t[16]=v,t[17]=m,t[18]=u,t[19]=d,t[20]=p,t[21]=k,t[22]=j):j=t[22];let M;t[23]!==O||t[24]!==j?(M=(0,Q.jsxs)(`div`,{className:`relative`,children:[O,j]}),t[23]=O,t[24]=j,t[25]=M):M=t[25];let N=l??void 0,P;t[26]!==v||t[27]!==i||t[28]!==N?(P=(0,Q.jsx)(Tn,{threadId:N,isStreaming:v,messages:i}),t[26]=v,t[27]=i,t[28]=N,t[29]=P):P=t[29];let F;t[30]!==P||t[31]!==M?(F=(0,Q.jsxs)(`div`,{className:`relative mx-auto min-w-[400px] w-[90vw] max-w-3xl`,children:[M,P]}),t[30]=P,t[31]=M,t[32]=F):F=t[32];let I;return t[33]!==F||t[34]!==D?(I=(0,Q.jsxs)(Q.Fragment,{children:[D,F]}),t[33]=F,t[34]=D,t[35]=I):I=t[35],I}export{st as _,an as a,nn as c,vt as d,mt as f,ut as g,lt as h,rn as i,tn as l,dt as m,Sn as n,ln as o,ht as p,Qt as r,en as s,Pn as t,$t as u};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Ar as t,Sa as n,Zn as r,ba as i,ca as a,da as o,ra as s}from"./dialogs-config-vkfELnGl.js";import{_ as c,b as l,c as u,d,f,g as p,h as m,p as h,s as g,u as _,x as v,y}from"./react-vendor-DyE9sO8V.js";var b=i(),x=e(n(),1),S=t(),C=p,w=v,T=x.forwardRef((e,t)=>{let n=(0,b.c)(14),i,o,s,c;n[0]===e?(i=n[1],o=n[2],s=n[3],c=n[4]):({className:o,inset:s,children:i,...c}=e,n[0]=e,n[1]=i,n[2]=o,n[3]=s,n[4]=c);let u=s&&`pl-8`,d;n[5]!==o||n[6]!==u?(d=r(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground`,u,o),n[5]=o,n[6]=u,n[7]=d):d=n[7];let f;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,S.jsx)(a,{className:`ml-auto h-4 w-4`}),n[8]=f):f=n[8];let p;return n[9]!==i||n[10]!==c||n[11]!==t||n[12]!==d?(p=(0,S.jsxs)(l,{ref:t,className:d,...c,children:[i,f]}),n[9]=i,n[10]=c,n[11]=t,n[12]=d,n[13]=p):p=n[13],p});T.displayName=l.displayName;var E=x.forwardRef((e,t)=>{let n=(0,b.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`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`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,S.jsx)(y,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});E.displayName=y.displayName;var D=x.forwardRef((e,t)=>{let n=(0,b.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 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`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,S.jsx)(h,{children:(0,S.jsx)(u,{ref:t,className:o,...a})}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});D.displayName=u.displayName;var O=x.forwardRef((e,t)=>{let n=(0,b.c)(11),i,a,o;n[0]===e?(i=n[1],a=n[2],o=n[3]):({className:i,inset:a,...o}=e,n[0]=e,n[1]=i,n[2]=a,n[3]=o);let s=a&&`pl-8`,c;n[4]!==i||n[5]!==s?(c=r(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,s,i),n[4]=i,n[5]=s,n[6]=c):c=n[6];let l;return n[7]!==o||n[8]!==t||n[9]!==c?(l=(0,S.jsx)(_,{ref:t,className:c,...o}),n[7]=o,n[8]=t,n[9]=c,n[10]=l):l=n[10],l});O.displayName=_.displayName;var k=x.forwardRef((e,t)=>{let n=(0,b.c)(14),i,a,s,c;n[0]===e?(i=n[1],a=n[2],s=n[3],c=n[4]):({className:s,children:a,checked:i,...c}=e,n[0]=e,n[1]=i,n[2]=a,n[3]=s,n[4]=c);let l;n[5]===s?l=n[6]:(l=r(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,s),n[5]=s,n[6]=l);let u;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,S.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(d,{children:(0,S.jsx)(o,{className:`h-4 w-4`})})}),n[7]=u):u=n[7];let f;return n[8]!==i||n[9]!==a||n[10]!==c||n[11]!==t||n[12]!==l?(f=(0,S.jsxs)(g,{ref:t,className:l,checked:i,...c,children:[u,a]}),n[8]=i,n[9]=a,n[10]=c,n[11]=t,n[12]=l,n[13]=f):f=n[13],f});k.displayName=g.displayName;var A=x.forwardRef((e,t)=>{let n=(0,b.c)(12),i,a,o;n[0]===e?(i=n[1],a=n[2],o=n[3]):({className:a,children:i,...o}=e,n[0]=e,n[1]=i,n[2]=a,n[3]=o);let c;n[4]===a?c=n[5]:(c=r(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,a),n[4]=a,n[5]=c);let l;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,S.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(d,{children:(0,S.jsx)(s,{className:`h-2 w-2 fill-current`})})}),n[6]=l):l=n[6];let u;return n[7]!==i||n[8]!==o||n[9]!==t||n[10]!==c?(u=(0,S.jsxs)(m,{ref:t,className:c,...o,children:[l,i]}),n[7]=i,n[8]=o,n[9]=t,n[10]=c,n[11]=u):u=n[11],u});A.displayName=m.displayName;var j=x.forwardRef((e,t)=>{let n=(0,b.c)(11),i,a,o;n[0]===e?(i=n[1],a=n[2],o=n[3]):({className:i,inset:a,...o}=e,n[0]=e,n[1]=i,n[2]=a,n[3]=o);let s=a&&`pl-8`,c;n[4]!==i||n[5]!==s?(c=r(`px-2 py-1.5 text-sm font-semibold text-foreground`,s,i),n[4]=i,n[5]=s,n[6]=c):c=n[6];let l;return n[7]!==o||n[8]!==t||n[9]!==c?(l=(0,S.jsx)(f,{ref:t,className:c,...o}),n[7]=o,n[8]=t,n[9]=c,n[10]=l):l=n[10],l});j.displayName=f.displayName;var M=x.forwardRef((e,t)=>{let n=(0,b.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`-mx-1 my-1 h-px bg-border`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,S.jsx)(c,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});M.displayName=c.displayName;var N=e=>{let t=(0,b.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`ml-auto text-xs tracking-widest text-muted-foreground`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,S.jsx)(`span`,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o};N.displayName=`ContextMenuShortcut`;export{w as a,M as i,D as n,O as r,C as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./history-view-Dn0hQIKU.js";export{e as ConversationHistoryView,e as default};