@surething/cockpit 1.0.192 → 1.0.193

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/.next-prod/BUILD_ID +1 -1
  2. package/.next-prod/app-path-routes-manifest.json +3 -3
  3. package/.next-prod/build-manifest.json +3 -3
  4. package/.next-prod/prerender-manifest.json +3 -3
  5. package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -1
  6. package/.next-prod/server/app/_global-error.html +1 -1
  7. package/.next-prod/server/app/_global-error.rsc +1 -1
  8. package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  10. package/.next-prod/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  11. package/.next-prod/server/app/_global-error.segments/_head.segment.rsc +1 -1
  12. package/.next-prod/server/app/_global-error.segments/_index.segment.rsc +1 -1
  13. package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/.next-prod/server/app/_not-found.html +2 -2
  16. package/.next-prod/server/app/_not-found.rsc +4 -3
  17. package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +4 -3
  18. package/.next-prod/server/app/_not-found.segments/_head.segment.rsc +1 -1
  19. package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +4 -3
  20. package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  21. package/.next-prod/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  22. package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +3 -2
  23. package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
  24. package/.next-prod/server/app/project/page.js +7 -7
  25. package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
  26. package/.next-prod/server/app/review/[id]/page.js +1 -1
  27. package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -1
  28. package/.next-prod/server/app-paths-manifest.json +3 -3
  29. package/.next-prod/server/chunks/2338.js +1 -1
  30. package/.next-prod/server/chunks/4732.js +1 -1
  31. package/.next-prod/server/middleware-build-manifest.js +1 -1
  32. package/.next-prod/server/pages/404.html +2 -2
  33. package/.next-prod/server/pages/500.html +1 -1
  34. package/.next-prod/server/server-reference-manifest.json +1 -1
  35. package/.next-prod/static/chunks/3579-2dddc4a9ac5a5b31.js +1 -0
  36. package/.next-prod/static/chunks/9062-cf3c7d314edd19d0.js +1 -0
  37. package/.next-prod/static/chunks/app/{layout-44210aade5d56585.js → layout-fc306a84f663d5af.js} +1 -1
  38. package/.next-prod/static/chunks/app/project/page-66c22be12277e5c1.js +29 -0
  39. package/.next-prod/static/chunks/app/review/[id]/page-feeb4d9d472b00ab.js +1 -0
  40. package/.next-prod/static/chunks/{webpack-067b7836d8df9226.js → webpack-9a8ea3995034c536.js} +1 -1
  41. package/.next-prod/static/css/49923bb0dd70e411.css +1 -0
  42. package/.next-prod/static/css/e33280be1b23649f.css +1 -0
  43. package/.next-prod/trace +12 -12
  44. package/.next-prod/trace-build +1 -1
  45. package/README.md +1 -1
  46. package/README.zh.md +1 -1
  47. package/package.json +1 -1
  48. package/.next-prod/static/chunks/3579-70c6663ba8c0cf1b.js +0 -1
  49. package/.next-prod/static/chunks/9062-ea4adbf70cf62f01.js +0 -1
  50. package/.next-prod/static/chunks/app/project/page-180bad159db256a5.js +0 -29
  51. package/.next-prod/static/chunks/app/review/[id]/page-e81c220af0b68e3e.js +0 -1
  52. package/.next-prod/static/css/aefab4a01c890b38.css +0 -3
  53. /package/.next-prod/static/{smsKM7xQ0sAR3fsFWgImc → 9osElWlkhv6tmFTniHsfB}/_buildManifest.js +0 -0
  54. /package/.next-prod/static/{smsKM7xQ0sAR3fsFWgImc → 9osElWlkhv6tmFTniHsfB}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- [{"name":"run-webpack","duration":9886762,"timestamp":126155088,"id":14,"parentId":1,"tags":{},"startTime":1777210200233,"traceId":"b7af3c7ce8eb7e4c"},{"name":"run-typescript","duration":14650757,"timestamp":136045304,"id":1408,"parentId":1,"tags":{},"startTime":1777210210124,"traceId":"b7af3c7ce8eb7e4c"},{"name":"static-check","duration":850801,"timestamp":150713122,"id":1411,"parentId":1,"tags":{},"startTime":1777210224791,"traceId":"b7af3c7ce8eb7e4c"},{"name":"static-generation","duration":4840637,"timestamp":151872570,"id":1639,"parentId":1,"tags":{},"startTime":1777210225951,"traceId":"b7af3c7ce8eb7e4c"},{"name":"collect-build-traces","duration":17503378,"timestamp":151564777,"id":1636,"parentId":1,"tags":{},"startTime":1777210225643,"traceId":"b7af3c7ce8eb7e4c"},{"name":"telemetry-flush","duration":56,"timestamp":169071744,"id":1648,"parentId":1,"tags":{},"startTime":1777210243150,"traceId":"b7af3c7ce8eb7e4c"},{"name":"next-build","duration":43066418,"timestamp":126005393,"id":1,"tags":{"buildMode":"default","version":"16.2.4","bundler":"webpack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1777210200084,"traceId":"b7af3c7ce8eb7e4c"}]
1
+ [{"name":"run-webpack","duration":11677045,"timestamp":195246113,"id":14,"parentId":1,"tags":{},"startTime":1777444472478,"traceId":"ebeecd21a9a03603"},{"name":"run-typescript","duration":14690829,"timestamp":206926936,"id":1410,"parentId":1,"tags":{},"startTime":1777444484159,"traceId":"ebeecd21a9a03603"},{"name":"static-check","duration":893341,"timestamp":221633660,"id":1413,"parentId":1,"tags":{},"startTime":1777444498866,"traceId":"ebeecd21a9a03603"},{"name":"static-generation","duration":4949427,"timestamp":222846936,"id":1641,"parentId":1,"tags":{},"startTime":1777444500079,"traceId":"ebeecd21a9a03603"},{"name":"collect-build-traces","duration":18092091,"timestamp":222527781,"id":1638,"parentId":1,"tags":{},"startTime":1777444499760,"traceId":"ebeecd21a9a03603"},{"name":"telemetry-flush","duration":54,"timestamp":240623627,"id":1650,"parentId":1,"tags":{},"startTime":1777444517856,"traceId":"ebeecd21a9a03603"},{"name":"next-build","duration":45544789,"timestamp":195078905,"id":1,"tags":{"buildMode":"default","version":"16.2.4","bundler":"webpack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1777444472311,"traceId":"ebeecd21a9a03603"}]
package/README.md CHANGED
@@ -59,7 +59,7 @@ A unified development cockpit built on **Claude Code (Agent SDK)** — chat, cod
59
59
 
60
60
  No install needed — try Cockpit in your browser (5-minute sandbox, no AI chat):
61
61
 
62
- [![Try Online](https://img.shields.io/badge/Try%20Online-Cockpit%20Demo-blue?style=for-the-badge)](https://e2b-nu.vercel.app/api/try)
62
+ [![Try Online](https://img.shields.io/badge/Try%20Online-Cockpit%20Demo-blue?style=for-the-badge)](https://cocking.cc/try)
63
63
 
64
64
  ## Prerequisites
65
65
 
package/README.zh.md CHANGED
@@ -65,7 +65,7 @@ https://github.com/user-attachments/assets/18f1a5dc-64f3-4ff6-b9fc-9cd08181fbb8
65
65
 
66
66
  无需安装 — 在浏览器中直接体验 Cockpit(5 分钟沙盒,无 AI 对话):
67
67
 
68
- [![在线体验](https://img.shields.io/badge/%E5%9C%A8%E7%BA%BF%E4%BD%93%E9%AA%8C-Cockpit%20Demo-blue?style=for-the-badge)](https://e2b-nu.vercel.app/api/try)
68
+ [![在线体验](https://img.shields.io/badge/%E5%9C%A8%E7%BA%BF%E4%BD%93%E9%AA%8C-Cockpit%20Demo-blue?style=for-the-badge)](https://cocking.cc/try)
69
69
 
70
70
  ## 前置依赖
71
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surething/cockpit",
3
- "version": "1.0.192",
3
+ "version": "1.0.193",
4
4
  "description": "The Cockpit That Drives AI",
5
5
  "author": "Robert",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3579],{578:(e,t,n)=>{function r(e,t){for(let n of e){if(n.path===t)return n;if(n.children){let e=r(n.children,t);if(e)return e}}return null}function s(e,t){if(!e)return"";let n=r(t,e);if(n?.isDirectory)return e;let s=e.split("/");return s.pop(),s.join("/")}function l(e){let t=[];for(let n of e){let e=n.split("/"),r=t;for(let t=0;t<e.length;t++){let n=e[t],s=t===e.length-1,l=e.slice(0,t+1).join("/"),o=r.find(e=>e.name===n);o||(o={name:n,path:l,isDirectory:!s,children:s?void 0:[]},r.push(o)),!s&&o.children&&(r=o.children)}}let n=e=>{e.sort((e,t)=>e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)),e.forEach(e=>{e.children&&n(e.children)})};return n(t),t}function o(e){let t=[],n=e=>{for(let r of e)r.isDirectory&&(t.push(r.path),r.children&&n(r.children))};return n(e),t}n.d(t,{B_:()=>f,KH:()=>d,MB:()=>r,S7:()=>s,fw:()=>u,q3:()=>c,r6:()=>m,tE:()=>h,tW:()=>o,u:()=>i,v3:()=>l});let a=new Set(["png","jpg","jpeg","gif","svg","webp","ico","bmp"]);function i(e){let t=e.split(".").pop()?.toLowerCase();return a.has(t||"")}function c(e,t,n=!1){let r=new Set;if(!t)return r;let s=t.toLowerCase(),l=e=>{if(r.add(e.path),e.children)for(let t of e.children)l(t)},o=(e,t)=>{let a=e.name.toLowerCase(),i=n?a===s:a.includes(s);if(i&&e.children)return l(e),t.forEach(e=>r.add(e)),!0;let c=!1;if(e.children)for(let n of e.children)o(n,[...t,e.path])&&(c=!0);return(!!i||!!c)&&(r.add(e.path),t.forEach(e=>r.add(e)),!0)};for(let t of e)o(t,[]);return r}function d(e,t,n=!1){let r=new Set;if(!t)return r;let s=t.toLowerCase();for(let t of e){let e=t.split("/");for(let t=0;t<e.length;t++){let l=e[t].toLowerCase();if(n?l===s:l.includes(s)){for(let t=0;t<=e.length-1;t++)r.add(e.slice(0,t+1).join("/"));break}}}return r}function u(e){let t=Math.floor(Math.floor((Date.now()-1e3*e)/1e3)/60),n=Math.floor(t/60),r=Math.floor(n/24),s=Math.floor(r/30),l=Math.floor(r/365);return l>0?`${l}y ago`:s>0?`${s}mo ago`:r>0?`${r}d ago`:n>0?`${n}h ago`:t>0?`${t}m ago`:"just now"}function m(e){let t=new Date(e),n=new Date,r=t.getFullYear()===n.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0"),o=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0");return r?`${s}-${l} ${o}:${a}`:`${t.getFullYear()}-${s}-${l} ${o}:${a}`}let h=()=>{},f=50},1531:(e,t,n)=>{n.d(t,{k_:()=>o,nH:()=>a});var r=n(95155),s=n(12115);let l=(0,s.createContext)(null);function o({children:e}){let t=(0,s.useRef)(new Map),n=(0,s.useRef)(null),[a,i]=(0,s.useState)(!1),c=(0,s.useCallback)((e,n)=>{t.current.set(n,e)},[]),d=(0,s.useCallback)(e=>{t.current.delete(e)},[]),u=(0,s.useCallback)(e=>{n.current=e},[]),m=(0,s.useCallback)(e=>{let r=n.current;if(!r)return void console.warn("No active tab to send message");let s=t.current.get(r);s?s(e):console.warn(`No chat sender registered for tab ${r}`)},[]),h=(0,s.useMemo)(()=>({sendMessage:m,isLoading:a,registerChat:c,unregisterChat:d,setActiveTab:u,setIsLoading:i}),[m,a,c,d,u]);return(0,r.jsx)(l.Provider,{value:h,children:e})}function a(){return(0,s.useContext)(l)}},10222:(e,t,n)=>{n.d(t,{$3:()=>a,Cm:()=>o,Gw:()=>d,RP:()=>i,Un:()=>c,zL:()=>l});var r=n(87918);let s=new Set;function l(e){return s.add(e),()=>s.delete(e)}function o(){s.forEach(e=>e())}async function a(e){let t=await fetch(`/api/comments?cwd=${encodeURIComponent(e)}`);if(!t.ok)throw Error("Failed to fetch comments");let n=(await t.json()).comments||[];if(0===n.length)return[];let r=new Map;for(let e of n)e.selectedText||(r.has(e.filePath)||r.set(e.filePath,[]),r.get(e.filePath).push(e));let s=new Map;await Promise.all(Array.from(r.keys()).map(async t=>{try{let n=await fetch(`/api/files/text?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`);if(n.ok){let e=await n.json();"string"==typeof e.content&&s.set(t,e.content.split("\n"))}}catch(e){console.error(`Failed to read file ${t}:`,e)}}));let l=[];for(let e of n){if(e.selectedText){l.push({...e,codeContent:e.selectedText});continue}let t=s.get(e.filePath),n="";if(t){let r=Math.max(0,e.startLine-1),s=Math.min(t.length,e.endLine);n=t.slice(r,s).join("\n")}l.push({...e,codeContent:n})}return l}async function i(e){try{if((await fetch(`/api/comments?cwd=${encodeURIComponent(e)}&all=true`,{method:"DELETE"})).ok)return o(),!0;return!1}catch(e){return console.error("Failed to clear comments:",e),!1}}let c="__chat__";function d(e,t){let n=e.filter(e=>e.filePath===c),s=e.filter(e=>e.filePath!==c),l=[];for(let e of(s.length>0&&(l.push(`${r.A.t("comments.codeRef")}`,""),s.forEach((e,t)=>{l.push(`[${t+1}] ${e.filePath}:${e.startLine}-${e.endLine}`),l.push("```"),l.push(e.codeContent),l.push("```"),e.note&&l.push(r.A.t("comments.note",{content:e.note})),l.push("")})),n)){let t=e.codeContent.split("\n").map(e=>`> ${e}`).join("\n");l.push(t),e.note&&l.push(e.note),l.push("")}return l.push(r.A.t("comments.question",{question:t})),l.join("\n")}},10611:(e,t,n)=>{n.d(t,{G:()=>u,f:()=>m});var r=n(12115);function s(){if("u"<typeof document)return null;let e=document.querySelector('meta[name="cockpit-bridge"]');if(!e)return null;let t=e.dataset.id,n=e.dataset.version;return t?{id:t,version:n||"unknown"}:null}let l=null,o=new Set;function a(){o.forEach(e=>e())}function i(e){o.add(e);let t=s();return t&&!l&&(l=t,Promise.resolve().then(a)),()=>{o.delete(e)}}function c(){return l}function d(){return null}if("u">typeof document&&(l=s()),"u">typeof MutationObserver&&"u">typeof document){let e=new MutationObserver(()=>{let e=s();e&&(!l||e.id!==l.id||e.version!==l.version)&&(l=e,a())}),t=document.head||document.documentElement;t&&e.observe(t,{childList:!0})}function u(){return(0,r.useSyncExternalStore)(i,c,d)}function m(){return l??s()}},14978:(e,t,n)=>{n.d(t,{T:()=>w});var r=n(95155),s=n(46361),l=n(79204),o=n(98164),a=n(77815),i=n(75035),c=n(88374);n(84559),n(21227);var d=n(91334),u=n(38194),m=n(88522),h=n(12115),f=n(72816);let x=[l.A,o.A,a.jb],g=[l.A,a.jb],p=[i.A,c.A],b=[i.A];function v(e){return e.replace(/^(\|.+\|)$/gm,e=>/^\|[\s:|-]+\|$/.test(e)?e:e.replace(/`([^`]*)`/g,(e,t)=>t.includes("|")?"`"+t.replace(/\|/g,"\\|")+"`":e))}function y(e){return e.replace(/\$(\d)/g,"\\$$1")}let w=(0,h.memo)(function({content:e,isUser:t=!1,isStreaming:n=!1,enableMath:l=!0,rehypePlugins:o}){let{resolvedTheme:a}=(0,f.D)(),i="dark"===a,c=(0,h.useMemo)(()=>({code({className:e,children:t,node:n,...s}){let l=/language-(\w+)/.exec(e||""),o=String(t);if(!l&&!e&&!o.includes("\n"))return(0,r.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent text-sm font-mono",...s,children:t});let a=String(t).replace(/\n$/,""),c=l?.[1]||"text",h=Number(s["data-source-start"])||0,f=h?h+1:0,x=0;return(0,r.jsx)(d.A,{style:i?u.A:m.A,language:c,PreTag:"div",customStyle:{margin:"0.75rem 0",borderRadius:"0.375rem",fontSize:"0.875rem"},wrapLines:!0,lineProps:()=>{let e=f+x;return x++,{"data-source-start":e,"data-source-end":e,style:{display:"block"}}},children:a})},p:({children:e,node:t,...n})=>(0,r.jsx)("p",{className:"mb-3 last:mb-0",...n,children:e}),h1:({children:e,node:t,...n})=>(0,r.jsx)("h1",{className:"text-xl font-bold mb-3 mt-4 first:mt-0",...n,children:e}),h2:({children:e,node:t,...n})=>(0,r.jsx)("h2",{className:"text-lg font-bold mb-2 mt-3 first:mt-0",...n,children:e}),h3:({children:e,node:t,...n})=>(0,r.jsx)("h3",{className:"text-base font-bold mb-2 mt-3 first:mt-0",...n,children:e}),ul:({children:e,node:t,...n})=>(0,r.jsx)("ul",{className:"list-disc list-inside mb-3 space-y-1",...n,children:e}),ol:({children:e,node:t,...n})=>(0,r.jsx)("ol",{className:"list-decimal list-inside mb-3 space-y-1",...n,children:e}),li:({children:e,node:t,...n})=>(0,r.jsx)("li",{className:"leading-relaxed",...n,children:e}),blockquote:({children:e,node:t,...n})=>(0,r.jsx)("blockquote",{className:"border-l-4 border-border pl-4 my-3 italic text-muted-foreground",...n,children:e}),a:({href:e,children:t,node:n,...s})=>(0,r.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand hover:underline",...s,children:t}),table:({children:e,node:t,...n})=>(0,r.jsx)("div",{className:"overflow-x-auto my-3",...n,children:(0,r.jsx)("table",{className:"min-w-full border border-border",children:e})}),thead:({children:e,node:t,...n})=>(0,r.jsx)("thead",{className:"bg-accent",...n,children:e}),th:({children:e,node:t,...n})=>(0,r.jsx)("th",{className:"px-4 py-2 text-left font-semibold border-b border-border",...n,children:e}),td:({children:e,node:t,...n})=>(0,r.jsx)("td",{className:"px-4 py-2 border-b border-border",...n,children:e}),hr:({node:e,...t})=>(0,r.jsx)("hr",{className:"my-4 border-border",...t}),img:({src:e,alt:t,node:n,height:s,width:l,style:o,...a})=>{if(!(s||l||o))return(0,r.jsx)("img",{src:e,alt:t||"",className:"max-w-full h-auto rounded-lg my-3",...a});let i=e=>e?/^\d+$/.test(String(e))?`${e}px`:String(e):void 0,c={...o,height:i(s)??o?.height,width:i(l)??o?.width};return(0,r.jsx)("img",{src:e,alt:t||"",style:c,className:"inline-block align-middle",...a})},strong:({children:e,node:t,...n})=>(0,r.jsx)("strong",{className:"font-bold",...n,children:e}),em:({children:e,node:t,...n})=>(0,r.jsx)("em",{className:"italic",...n,children:e}),del:({children:e,node:t,...n})=>(0,r.jsx)("del",{className:"line-through",...n,children:e})}),[i]),w=l?x:g,k=l?p:b,C=(0,h.useMemo)(()=>{if(t||n)return e;let r=v(!function(e){if(/^\|[\s:|-]+\|$/m.test(e))return!1;if(/[┌┐└┘│─├┤┬┴┼╔╗╚╝║═╭╮╯╰▲▼◀▶△▽◁▷]/.test(e)||/\+[-=]{2,}\+/.test(e))return!0;let t=e.split("\n").filter(e=>/^\s*\||\|\s*$/.test(e));if(t.length>=3){let e=t.map(e=>(e.match(/\|/g)||[]).length);return!e.every(t=>t===e[0])||!(e[0]>=3)}return!1}(e)||/^```[\s\S]*```$/m.test(e.trim())?e:"```text\n"+e.trim()+"\n```");return l?y(r):r},[e,t,n,l]),j=(0,h.useMemo)(()=>o?.length?[...k,...o]:k,[o,k]);if(t)return(0,r.jsx)("div",{className:"whitespace-pre-wrap break-words",children:e});if(n){let t=e.lastIndexOf("\n");if(-1===t)return(0,r.jsx)("div",{className:"whitespace-pre-wrap break-words",children:e});let n=e.slice(0,t+1),o=e.slice(t+1);return(0,r.jsxs)("div",{className:"markdown-body",children:[(0,r.jsx)(s.oz,{remarkPlugins:w,rehypePlugins:k,components:c,children:l?y(v(n)):v(n)}),o&&(0,r.jsx)("span",{className:"whitespace-pre-wrap",children:o})]})}return(0,r.jsx)("div",{className:"markdown-body",children:(0,r.jsx)(s.oz,{remarkPlugins:w,rehypePlugins:j,components:c,children:C})})})},18658:(e,t,n)=>{n.d(t,{n:()=>o});var r=n(12115);let s="SCHEDULED_TASKS_CHANGED";function l(){try{window.parent.postMessage({type:s},"*")}catch{}document.querySelectorAll("iframe").forEach(e=>{try{e.contentWindow?.postMessage({type:s},"*")}catch{}})}function o(){let[e,t]=(0,r.useState)([]),[n,o]=(0,r.useState)(0),a=(0,r.useCallback)(()=>{fetch("/api/scheduled-tasks").then(e=>e.json()).then(e=>{t(e.tasks||[]),o(e.unreadCount||0)}).catch(()=>{})},[]);(0,r.useEffect)(()=>{a()},[a]),(0,r.useEffect)(()=>{let e=e=>{e.data?.type===s&&a()};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[a]);let i=(0,r.useCallback)(async e=>{try{let t=await fetch("/api/scheduled-tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();if(n.task)return a(),l(),n.task;return null}catch{return null}},[a]),c=(0,r.useCallback)(async e=>{await fetch("/api/scheduled-tasks",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"pause"})}).catch(()=>{}),a(),l()},[a]),d=(0,r.useCallback)(async e=>{await fetch("/api/scheduled-tasks",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"resume"})}).catch(()=>{}),a(),l()},[a]),u=(0,r.useCallback)(async e=>{await fetch("/api/scheduled-tasks",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e})}).catch(()=>{}),a(),l()},[a]),m=(0,r.useCallback)(async(e,t)=>{await fetch("/api/scheduled-tasks",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"update",fields:t})}).catch(()=>{}),a(),l()},[a]),h=(0,r.useCallback)(async e=>{await fetch("/api/scheduled-tasks",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"trigger"})}).catch(()=>{}),a(),l()},[a]),f=(0,r.useCallback)(async e=>{await fetch("/api/scheduled-tasks",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"markRead"})}).catch(()=>{}),a(),l()},[a]),x=(0,r.useCallback)(async()=>{await fetch("/api/scheduled-tasks",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:"_",action:"markAllRead"})}).catch(()=>{}),a(),l()},[a]),g=(0,r.useCallback)(async e=>{await fetch("/api/scheduled-tasks",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:"_",action:"reorder",fields:{orderedIds:e}})}).catch(()=>{}),a(),l()},[a]);return{tasks:e,unreadCount:n,reload:a,createTask:i,pauseTask:c,resumeTask:d,triggerTask:h,deleteTask:u,updateTask:m,markRead:f,markAllRead:x,reorderTasks:g}}},22552:(e,t,n)=>{n.d(t,{h:()=>l});var r=n(12115);let s=new Map;function l({url:e,onMessage:t,enabled:n=!0}){let o=(0,r.useRef)(t);(0,r.useEffect)(()=>{o.current=t}),(0,r.useEffect)(()=>{if(!n)return;let t=e=>o.current(e),r=function(e){let t=s.get(e);if(t)return t;let n={ws:null,listeners:new Set,retryCount:0,retryTimer:null,connect(){let t="https:"===window.location.protocol?"wss:":"ws:",r=new WebSocket(`${t}//${window.location.host}${e}`);r.onopen=()=>{n.retryCount=0},r.onmessage=e=>{try{let t=JSON.parse(e.data);if("ping"===t.type)return;n.listeners.forEach(e=>e(t))}catch{}},r.onclose=()=>{if(0===n.listeners.size)return;let e=Math.min(1e3*Math.pow(1.5,n.retryCount),1e4);n.retryCount++,n.retryTimer=setTimeout(()=>n.connect(),e)},r.onerror=()=>{},n.ws=r},destroy(){n.retryTimer&&clearTimeout(n.retryTimer),n.ws&&n.ws.close(),n.ws=null,s.delete(e)}};return s.set(e,n),n.connect(),n}(e);return r.listeners.add(t),()=>{r.listeners.delete(t),0===r.listeners.size&&r.destroy()}},[e,n])}},23193:(e,t,n)=>{n.d(t,{Np:()=>d,ZD:()=>i,b8:()=>c,kS:()=>o,sQ:()=>a});var r=n(67014);let s=null,l=["typescript","tsx","javascript","jsx","html","css","scss","json","yaml","python","go","rust","java","ruby","php","bash","shell","markdown","sql","c","cpp","swift","kotlin","dart","lua","graphql","xml"];function o(){return s||(s=(0,r.O_)({themes:["github-dark","github-light"],langs:[...l]})),s}function a(e){let t=e.split("/").pop()?.toLowerCase()||"",n=t.split(".").pop()?.toLowerCase();if(".env"===t||t.startsWith(".env.")||"dockerfile"===t||t.startsWith("dockerfile.")||"makefile"===t)return"bash";let r={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",html:"html",htm:"html",css:"css",scss:"scss",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",py:"python",go:"go",rs:"rust",java:"java",kt:"kotlin",rb:"ruby",php:"php",cs:"cpp",cpp:"cpp",c:"c",h:"c",sh:"bash",bash:"bash",zsh:"bash",md:"markdown",mdx:"markdown",sql:"sql",swift:"swift",dart:"dart",lua:"lua",graphql:"graphql",gql:"graphql",toml:"yaml",sass:"scss",less:"css",scala:"java",r:"python",vim:"bash",env:"bash"}[n||""]||"text";return l.includes(r)?r:"text"}function i(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function c(e){return e.map(e=>e.color?`<span style="color:${e.color}">${i(e.content)}</span>`:i(e.content)).join("")}function d(e,t,n,r){if(!t)return[];let s=[],l=n?t:t.toLowerCase();for(let t=0;t<e.length;t++){let o=n?e[t]:e[t].toLowerCase(),a=0;for(;;){let e=o.indexOf(l,a);if(-1===e)break;let n=e+l.length;if(r){let r=e>0?o[e-1]:" ",l=n<o.length?o[n]:" ",a=!/\w/.test(r),i=!/\w/.test(l);a&&i&&s.push({lineIndex:t,startCol:e,endCol:n})}else s.push({lineIndex:t,startCol:e,endCol:n});a=e+1}}return s}},28147:(e,t,n)=>{n.d(t,{E:()=>c});var r=n(95155),s=n(12115),l=n(79114),o=n(87918),a=n(72588);let i={once:[{labelKey:"scheduledTasks.5minLater",value:5},{labelKey:"scheduledTasks.15minLater",value:15},{labelKey:"scheduledTasks.30minLater",value:30},{labelKey:"scheduledTasks.1hourLater",value:60}],interval:[{labelKey:"scheduledTasks.every15min",value:15},{labelKey:"scheduledTasks.every30min",value:30},{labelKey:"scheduledTasks.every1hour",value:60},{labelKey:"scheduledTasks.every2hours",value:120}],cron:[{labelKey:"scheduledTasks.daily9am",value:"0 9 * * *"},{labelKey:"scheduledTasks.daily6pm",value:"0 18 * * *"},{labelKey:"scheduledTasks.weeklyMon9am",value:"0 9 * * 1"},{labelKey:"scheduledTasks.monthly1st9am",value:"0 9 1 * *"}]};function c({onClose:e,onCreate:t,editTask:n,onUpdate:d}){let{t:u}=(0,l.Bd)(),m=!!n,[h,f]=(0,s.useState)(n?.type||"once"),[x,g]=(0,s.useState)(n?.message||""),[p,b]=(0,s.useState)(n?String(n.delayMinutes||n.intervalMinutes||""):""),[v,y]=(0,s.useState)(n?.cron||""),[w,k]=(0,s.useState)(n?.activeFrom||"09:00"),[C,j]=(0,s.useState)(n?.activeTo||"18:00"),[N,E]=(0,s.useState)(!!(n?.activeFrom&&n?.activeTo)),[L,S]=(0,s.useState)(null),M=(0,s.useRef)(null),T=(0,s.useRef)(null);(0,s.useEffect)(()=>{T.current?.focus()},[]),(0,s.useEffect)(()=>{let t=t=>{M.current&&!M.current.contains(t.target)&&e()};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[e]);let R=(0,s.useCallback)(()=>{if(!x.trim())return;let r=null;if("once"===h){let e=L||parseInt(p,10);if(!e||e<=0)return;r={message:x.trim(),type:"once",delayMinutes:e}}else if("interval"===h){let e=L||parseInt(p,10);if(!e||e<=0)return;r={message:x.trim(),type:"interval",intervalMinutes:e,...N?{activeFrom:w,activeTo:C}:{}}}else if("cron"===h){let e=L||v.trim();if(!e)return;r={message:x.trim(),type:"cron",cron:e}}r&&(m&&n&&d?d(n.id,r):t(r),e())},[x,h,L,p,v,N,w,C,t,e,m,n,d]);return(0,r.jsxs)("div",{ref:M,className:`w-80 bg-popover border border-border rounded-lg shadow-lg z-50 ${m?"":"absolute bottom-full left-0 mb-2"}`,onKeyDown:t=>{"Escape"===t.key?e():"Enter"===t.key&&(t.metaKey||t.ctrlKey)&&R()},children:[(0,r.jsx)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 rounded-t-lg",children:(0,r.jsx)("span",{className:"text-sm font-medium",children:m?u("scheduledTasks.editTask"):u("scheduledTasks.createTask")})}),(0,r.jsxs)("div",{className:"p-3 space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:u("scheduledTasks.sendMessage")}),(0,r.jsx)("textarea",{ref:T,value:x,onChange:e=>g(e.target.value),placeholder:u("scheduledTasks.messagePlaceholder"),rows:2,className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground placeholder-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring resize-none"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:u("scheduledTasks.type")}),(0,r.jsx)("div",{className:"flex gap-1",children:["once","interval","cron"].map(e=>(0,r.jsx)("button",{onClick:()=>{f(e),S(null),b(""),y("")},className:`flex-1 px-2 py-1 text-xs rounded transition-colors ${h===e?"bg-brand text-white":"bg-muted text-muted-foreground hover:text-foreground"}`,children:"once"===e?u("scheduledTasks.once"):"interval"===e?u("scheduledTasks.interval"):"Cron"},e))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:u("scheduledTasks.quickSelect")}),(0,r.jsx)("div",{className:"grid grid-cols-2 gap-1",children:i[h].map(e=>(0,r.jsx)("button",{onClick:()=>{S(e.value),"cron"===h?y(String(e.value)):b(String(e.value))},className:`px-2 py-1 text-xs rounded border transition-colors ${L===e.value?"border-brand bg-brand/10 text-brand":"border-border text-muted-foreground hover:text-foreground hover:border-foreground/30"}`,children:u(e.labelKey)},e.labelKey))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:"cron"===h?u("scheduledTasks.customCron"):u("scheduledTasks.customMinutes")}),"cron"===h?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("input",{type:"text",value:v,onChange:e=>{y(e.target.value),S(null)},placeholder:u("scheduledTasks.cronPlaceholder"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground placeholder-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring font-mono"}),v.trim()&&(0,r.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:function(e){let t=o.A.t,n=e.trim().split(/\s+/);if(5!==n.length)return null;let[r,s,l,a,i]=n,c={0:t("cron.dowSun"),1:t("cron.dowMon"),2:t("cron.dowTue"),3:t("cron.dowWed"),4:t("cron.dowThu"),5:t("cron.dowFri"),6:t("cron.dowSat")},d={1:`1${t("cron.monthPrefix")}`,2:`2${t("cron.monthPrefix")}`,3:`3${t("cron.monthPrefix")}`,4:`4${t("cron.monthPrefix")}`,5:`5${t("cron.monthPrefix")}`,6:`6${t("cron.monthPrefix")}`,7:`7${t("cron.monthPrefix")}`,8:`8${t("cron.monthPrefix")}`,9:`9${t("cron.monthPrefix")}`,10:`10${t("cron.monthPrefix")}`,11:`11${t("cron.monthPrefix")}`,12:`12${t("cron.monthPrefix")}`};try{let e="";if(r.includes("/")||s.includes("/")){if("*"===s&&r.includes("/"))return t("cron.everyNMinutes",{n:r.split("/")[1]});if("0"===r&&s.includes("/"))return t("cron.everyNHours",{n:s.split("/")[1]});return null}let n=parseInt(s,10),o=parseInt(r,10);if(isNaN(n)&&"*"!==s||isNaN(o)&&"*"!==r)return null;e="*"===s&&"*"===r?t("cron.everyMinute"):"*"===s?t("cron.everyHourAtMin",{m:o}):"*"===r?t("cron.hourlyEveryMin",{h:n}):`${String(n).padStart(2,"0")}:${String(o).padStart(2,"0")}`;let u=[];if("*"!==a){let e=a.split(",").map(e=>d[e]||`${e}${t("cron.monthPrefix")}`);u.push(e.join(", "))}if("*"!==l)if(l.includes("-")){let[e,n]=l.split("-");u.push(t("cron.dayRange",{a:e,b:n}))}else l.includes(",")?u.push(l.split(",").map(e=>`${e}${t("cron.dayOfMonth")}`).join(", ")):u.push(`${l}${t("cron.dayOfMonth")}`);if("*"!==i)if("1-5"===i)u.push(t("cron.weekdays"));else if("0,6"===i||"6,0"===i)u.push(t("cron.weekends"));else{let e=i.split(",").map(e=>{if(e.includes("-")){let[n,r]=e.split("-");return t("cron.weekdayRange",{a:c[n]||n,b:c[r]||r})}return`${t("cron.weekdayPrefix")}${c[e]||e}`});u.push(e.join(", "))}if(0===u.length&&"*"===l&&"*"===a&&"*"===i)return t("cron.daily",{time:e});return`${u.join(" ")} ${e}`}catch{return null}}(v.trim())||(0,r.jsx)("span",{className:"text-destructive",children:u("scheduledTasks.cronFormat")})})]}):(0,r.jsx)("input",{type:"number",value:p,onChange:e=>{b(e.target.value),S(null)},placeholder:u("scheduledTasks.minutesPlaceholder"),min:1,className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground placeholder-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring"})]}),"interval"===h&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-1 cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:N,onChange:e=>E(e.target.checked),className:"rounded border-border"}),u("scheduledTasks.limitTimeRange")]}),N&&(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,r.jsx)("input",{type:"time",value:w,onChange:e=>k(e.target.value),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:u("scheduledTasks.to")}),(0,r.jsx)("input",{type:"time",value:C,onChange:e=>j(e.target.value),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring"})]})]}),(0,r.jsx)("button",{onClick:R,disabled:!(x.trim()&&("once"===h||"interval"===h?!!(L||p&&parseInt(p,10)>0):"cron"===h&&!!(L||v.trim()))),className:"w-full py-1.5 text-sm font-medium rounded bg-brand text-white hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:m?u("scheduledTasks.saveBtn",{modKey:(0,a.Mu)()}):u("scheduledTasks.createBtn",{modKey:(0,a.Mu)()})})]})]})}},31914:(e,t,n)=>{n.d(t,{b:()=>d});var r=n(95155),s=n(12115),l=n(79114),o=n(72816),a=n(38093),i=n(72588),c=n(10611);function d({isOpen:e,onClose:t}){let{t:n,i18n:u}=(0,l.Bd)(),{theme:m,setTheme:h}=(0,o.D)(),f=(0,c.G)(),[x,g]=(0,s.useState)(""),[p,b]=(0,s.useState)(""),[v,y]=(0,s.useState)("auto");(0,s.useEffect)(()=>{e&&fetch("/api/settings").then(e=>e.json()).then(e=>{e.language&&y(e.language)}).catch(()=>{})},[e]);let w=(0,s.useCallback)(e=>{y(e),fetch("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({language:e})}).catch(()=>{});let t="auto"===e?navigator.language.startsWith("zh")?"zh":"en":e;u.changeLanguage(t)},[u]),k=f?"installed":"not-installed",C=f?.version??null;if((0,s.useEffect)(()=>{e&&fetch("/api/version").then(e=>e.json()).then(e=>{e.version&&b(e.version)}).catch(()=>{})},[e]),(0,s.useEffect)(()=>{e&&fetch("/api/extension/version").then(e=>e.json()).then(e=>{e.path&&g(e.path)}).catch(()=>{})},[e]),!e)return null;let j=[{value:"system",label:n("settings.themeSystem"),icon:"\uD83D\uDCBB"},{value:"light",label:n("settings.themeLight"),icon:"☀️"},{value:"dark",label:n("settings.themeDark"),icon:"\uD83C\uDF19"}];return(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:t}),(0,r.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-md mx-4 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-foreground",children:n("settings.title")}),(0,r.jsx)("button",{onClick:t,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsxs)("div",{className:"p-4 space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:n("settings.theme")}),(0,r.jsx)("div",{className:"grid grid-cols-3 gap-2",children:j.map(e=>(0,r.jsxs)("button",{onClick:()=>h(e.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${m===e.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,r.jsx)("span",{className:"text-xl",children:e.icon}),(0,r.jsx)("span",{className:"text-xs font-medium",children:e.label})]},e.value))})]}),(0,r.jsx)("div",{className:"border-t border-border"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:n("settings.language")}),(0,r.jsx)("div",{className:"grid grid-cols-3 gap-2",children:[{value:"auto",label:n("settings.languageAuto"),icon:"\uD83C\uDF10"},{value:"en",label:"English",icon:"\uD83C\uDDFA\uD83C\uDDF8"},{value:"zh",label:"中文",icon:"\uD83C\uDDE8\uD83C\uDDF3"}].map(e=>(0,r.jsxs)("button",{onClick:()=>w(e.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${v===e.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,r.jsx)("span",{className:"text-xl",children:e.icon}),(0,r.jsx)("span",{className:"text-xs font-medium",children:e.label})]},e.value))})]}),(0,r.jsx)("div",{className:"border-t border-border"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:n("settings.browserExtension")}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${"installed"===k?"bg-green-500":"bg-slate-400"}`}),(0,r.jsxs)("span",{children:["installed"===k&&`${n("settings.extensionInstalled")}${C?` (v${C})`:""}`,"not-installed"===k&&n("settings.extensionNotInstalled")]})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:n("settings.extensionDescription")}),"installed"!==k&&(0,r.jsxs)("div",{className:"text-xs text-muted-foreground bg-muted/50 rounded-md p-2 space-y-1",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:n("settings.installSteps")}),(0,r.jsxs)("p",{children:[n("settings.step1")," ",(0,r.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-foreground",children:"chrome://extensions"})]}),(0,r.jsx)("p",{children:n("settings.step2")}),(0,r.jsx)("p",{children:n("settings.step3")}),(0,i.L)()&&(0,r.jsx)("p",{dangerouslySetInnerHTML:{__html:n("settings.step4mac")}})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{onClick:()=>{let e=x||"chrome-extension";navigator.clipboard.writeText(e),(0,a.oR)(n("toast.copiedName",{name:e}))},className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:n("settings.copyExtensionPath")}),"installed"===k&&(0,r.jsx)("button",{onClick:()=>{f?.id&&window.chrome?.runtime?.sendMessage&&(window.chrome.runtime.sendMessage(f.id,{type:"reload"}),(0,a.oR)(n("toast.pluginReloading")))},className:"px-3 py-1.5 text-xs border border-border text-foreground rounded-md hover:bg-muted transition-colors",children:n("settings.reloadExtension")})]}),x&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground font-mono truncate",children:x})]})]}),(0,r.jsx)("div",{className:"border-t border-border"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:n("settings.about")}),(0,r.jsxs)("div",{className:"text-xs text-muted-foreground space-y-1",children:[(0,r.jsxs)("p",{children:["Cockpit",p?` v${p}`:""]}),(0,r.jsx)("p",{className:"text-muted-foreground/60",children:"One seat. One AI. Everything under control."})]})]})]})]})]})}},36998:(e,t,n)=>{n.d(t,{P:()=>s});var r=n(12115);function s(){let[e,t]=(0,r.useState)([]),n=(0,r.useCallback)(()=>{fetch("/api/pinned-sessions").then(e=>e.json()).then(e=>t(e.sessions||[])).catch(()=>{})},[]);(0,r.useEffect)(()=>{n()},[n]),(0,r.useEffect)(()=>{let e=e=>{e.data?.type==="PINNED_SESSIONS_CHANGED"&&n()};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[n]);let s=(0,r.useCallback)(e=>{t(e),fetch("/api/pinned-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessions:e})}).catch(()=>{});try{window.parent.postMessage({type:"PINNED_SESSIONS_CHANGED"},"*")}catch{}},[]),l=(0,r.useCallback)(t=>e.some(e=>e.sessionId===t),[e]),o=(0,r.useCallback)((t,n,r)=>{e.some(e=>e.sessionId===t)||s([...e,{sessionId:t,cwd:n,customTitle:r}])},[e,s]),a=(0,r.useCallback)(t=>{s(e.filter(e=>e.sessionId!==t))},[e,s]),i=(0,r.useCallback)((t,n)=>{s(e.map(e=>e.sessionId===t?{...e,customTitle:n}:e))},[e,s]);return{pinnedSessions:e,isPinned:l,pinSession:o,unpinSession:a,updateTitle:i,reorder:(0,r.useCallback)(e=>{s(e)},[s]),reload:n}}},57842:(e,t,n)=>{n.d(t,{Ee:()=>m,SU:()=>c,ft:()=>u,iN:()=>d});var r=n(95155),s=n(12115),l=n(79114),o=n(47650),a=n(38093);let i=(0,s.createContext)(null);function c({container:e,children:t}){return(0,r.jsx)(i.Provider,{value:e,children:t})}function d(){return(0,s.useContext)(i)}function u({x:e,y:t,path:n,cwd:c,isDirectory:d,onClose:m,onCreateFile:h,onDelete:f,onRefresh:x,onCopyFile:g,onPaste:p}){let{t:b}=(0,l.Bd)(),v=(0,s.useRef)(null),y=(0,s.useContext)(i),w=n.split("/").pop()||n,k=`${c}/${n}`,C=n.includes("/")?n.substring(0,n.lastIndexOf("/")):"",j=C?`${c}/${C}`:c,N=d?n:C,E=d?k:j;(0,s.useEffect)(()=>{let e=e=>{v.current&&!v.current.contains(e.target)&&m()},t=e=>{"Escape"===e.key&&m()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[m]);let[L,S]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(v.current&&y){let n=y.getBoundingClientRect(),r=v.current.getBoundingClientRect(),s=e-n.left,l=t-n.top;s=Math.min(s,n.width-r.width-8),l=Math.min(l,n.height-r.height-8),S({x:s=Math.max(8,s),y:l=Math.max(8,l)})}else if(v.current){let n=v.current.getBoundingClientRect();S({x:Math.max(8,Math.min(e,window.innerWidth-n.width-8)),y:Math.max(8,Math.min(t,window.innerHeight-n.height-8))})}},[e,t,y]);let M=(0,s.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(e),(0,a.oR)(b("toast.copiedName",{name:t}),"success")}catch{(0,a.oR)(b("toast.copyFailed"),"error")}m()},[m,b]),T=d?n:C,R=[{label:b("fileContextMenu.copyRelativePath"),value:n},{label:b("fileContextMenu.copyAbsolutePath"),value:k},{label:b("fileContextMenu.copyRelativeDirPath"),value:N||"."},{label:b("fileContextMenu.copyAbsoluteDirPath"),value:E},{label:d?b("fileContextMenu.copyFolderName"):b("fileContextMenu.copyFileName"),value:w}],$=(0,r.jsxs)("div",{ref:v,className:"absolute z-[200] bg-card border border-border rounded-lg shadow-lg py-1 w-fit whitespace-nowrap",style:{left:L.x,top:L.y},children:[h&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-accent transition-colors",onClick:()=>{m(),h(T)},children:b("fileContextMenu.createFile")}),g&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-accent transition-colors",onClick:()=>{m(),g(n)},children:d?b("fileContextMenu.copyFolder"):b("fileContextMenu.copyFile")}),p&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-accent transition-colors",onClick:()=>{m(),p(T)},children:b("fileContextMenu.pasteHere")}),f&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-destructive hover:bg-accent transition-colors",onClick:()=>{m(),f(n,d,w)},children:d?b("fileContextMenu.deleteFolder"):b("fileContextMenu.deleteFile")}),(h||f||g||p)&&(0,r.jsx)("div",{className:"my-1 border-t border-border"}),R.map((e,t)=>(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-accent transition-colors",onClick:()=>M(e.value,e.label),children:e.label},t))]});return y?(0,o.createPortal)($,y):$}function m(){let[e,t]=(0,s.useState)(null);return{contextMenu:e,showContextMenu:(0,s.useCallback)((e,n,r)=>{e.preventDefault(),e.stopPropagation(),t({x:e.clientX,y:e.clientY,path:n,isDirectory:r})},[]),hideContextMenu:(0,s.useCallback)(()=>{t(null)},[])}}},71063:(e,t,n)=>{n.d(t,{_:()=>l});var r=n(12115),s=n(10222);function l({cwd:e,filePath:t}){let[n,o]=(0,r.useState)([]),[a,i]=(0,r.useState)(!1),[c,d]=(0,r.useState)(null),u=(0,r.useCallback)(async()=>{if(e&&t){i(!0),d(null);try{let n=await fetch(`/api/comments?cwd=${encodeURIComponent(e)}&filePath=${encodeURIComponent(t)}`);if(n.ok){let e=await n.json();o(e.comments||[])}else d("Failed to load comments")}catch(e){d(e instanceof Error?e.message:"Unknown error")}finally{i(!1)}}},[e,t]);(0,r.useEffect)(()=>{u()},[u]),(0,r.useEffect)(()=>(0,s.zL)(()=>{u()}),[u]);let m=(0,r.useCallback)(async(n,r,s,l)=>{try{let a=await fetch("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,filePath:t,startLine:n,endLine:r,content:s,...l?{selectedText:l}:{}})});if(a.ok){let e=await a.json();return o(t=>[...t,e.comment]),e.comment}}catch(e){console.error("Failed to add comment:",e)}return null},[e,t]),h=(0,r.useCallback)(async(t,n)=>{try{let r=await fetch("/api/comments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,id:t,content:n})});if(r.ok){let e=await r.json();return o(n=>n.map(n=>n.id===t?e.comment:n)),!0}}catch(e){console.error("Failed to update comment:",e)}return!1},[e]),f=(0,r.useCallback)(async t=>{try{if((await fetch(`/api/comments?cwd=${encodeURIComponent(e)}&id=${encodeURIComponent(t)}`,{method:"DELETE"})).ok)return o(e=>e.filter(e=>e.id!==t)),!0}catch(e){console.error("Failed to delete comment:",e)}return!1},[e]),x=(0,r.useCallback)(e=>n.filter(t=>e>=t.startLine&&e<=t.endLine),[n]);return{comments:n,isLoading:a,error:c,addComment:m,updateComment:h,deleteComment:f,refresh:u,getCommentsForLine:x}}},72588:(e,t,n)=>{n.d(t,{L:()=>s,Mu:()=>l});var r=n(41463);function s(){return!("u"<typeof navigator)&&(/Mac|iPhone|iPad/.test(navigator.platform||"")||navigator.userAgentData?.platform==="macOS")}function l(){return s()?"⌘":"Ctrl+"}r.platform,r.platform,r.platform},74446:(e,t,n)=>{n.d(t,{U:()=>l,k:()=>s});let r="cockpit-skills";function s(){let e="u"<typeof BroadcastChannel?null:new BroadcastChannel(r);if(e)try{e.postMessage({type:"changed"})}finally{e.close()}}function l(e){if("u"<typeof BroadcastChannel)return()=>{};let t=new BroadcastChannel(r),n=t=>{t.data?.type==="changed"&&e()};return t.addEventListener("message",n),()=>{t.removeEventListener("message",n),t.close()}}},74567:(e,t,n)=>{n.d(t,{f:()=>a,w:()=>o});var r=n(95155),s=n(12115),l=n(79114);function o({x:e,y:t,visible:n,container:s,onAddComment:a,onSendToAI:i,onSearch:c,isChatLoading:d}){let{t:u}=(0,l.Bd)(),m=s.getBoundingClientRect(),h=e-m.left,f=Math.max(0,t-m.top-40);return(0,r.jsxs)("div",{className:"floating-toolbar absolute z-[200] flex items-center gap-1.5 bg-card border border-border rounded-lg shadow-xl p-1.5",style:{left:h+8,top:f,visibility:n?"visible":"hidden",pointerEvents:n?"auto":"none"},children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",onClick:a,children:u("floatingToolbar.addComment")}),(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:i,disabled:d,title:u(d?"comments.aiResponding":"floatingToolbar.sendToAI"),children:u("floatingToolbar.sendToAI")}),c&&(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",onClick:c,children:u("floatingToolbar.search")})]})}let a=(0,s.memo)(function({floatingToolbarRef:e,bumpRef:t,container:n,onAddComment:l,onSendToAI:a,onSearch:i,isChatLoading:c}){let[d,u]=(0,s.useState)(0);(0,s.useEffect)(()=>{t.current=()=>u(e=>e+1)},[t]);let m=(0,s.useMemo)(()=>e.current,[d]);return(0,r.jsx)(o,{x:m?.x??0,y:m?.y??0,visible:!!m,container:n,onAddComment:l,onSendToAI:a,onSearch:i,isChatLoading:c})})},82085:(e,t,n)=>{n.d(t,{C:()=>l});var r=n(12115),s=n(23193);function l(e,t){let[n,l]=(0,r.useState)([]),[o,a]=(0,r.useState)(!1),i=(0,r.useRef)("");(0,r.useEffect)(()=>{let e=()=>{a(document.documentElement.classList.contains("dark"))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);let c=e.join("\n");return(0,r.useEffect)(()=>{if(0===e.length)return;let n=`${c}:${t}:${o}`;if(n===i.current)return;i.current=n,l(e.map(e=>(0,s.ZD)(e||" ")));let r=!1;return(async()=>{try{let n=await (0,s.kS)();if(r)return;let a=(0,s.sQ)(t),i=e.join("\n"),c=n.codeToTokens(i,{lang:a,theme:o?"github-dark":"github-light"}),d=[];for(let e=0;e<c.tokens.length;e++)if(d[e]=(0,s.b8)(c.tokens[e]),e%500==0&&e>0&&(await new Promise(e=>setTimeout(e,0)),r))return;l(d)}catch(e){console.error("Line highlight error:",e)}})(),()=>{r=!0}},[c,t,o]),n}},84392:(e,t,n)=>{n.d(t,{t:()=>o});var r=n(95155),s=n(12115),l=n(79114);function o({x:e,y:t,comment:n,container:a,onClose:i,onUpdateComment:c,onDeleteComment:d}){let{t:u}=(0,l.Bd)(),[m,h]=(0,s.useState)(!1),[f,x]=(0,s.useState)(n.content),g=(0,s.useRef)(null),[p,b]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(g.current&&a){let n=a.getBoundingClientRect(),r=g.current.getBoundingClientRect(),s=e-n.left,l=t-n.top;s+r.width>n.width-16&&(s=n.width-r.width-16),s<16&&(s=16),l+r.height>n.height-16&&(l=l-r.height-8),l<16&&(l=16),queueMicrotask(()=>b({x:s,y:l}))}},[e,t,a]),(0,s.useEffect)(()=>{let e=e=>{g.current&&!g.current.contains(e.target)&&i()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let v=async()=>{f.trim()&&(await c(n.id,f.trim()),h(!1))},y=async()=>{await d(n.id),i()};return(0,r.jsx)("div",{ref:g,className:"absolute z-[200] w-96 bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:p.x,top:p.y},children:(0,r.jsx)("div",{className:"p-3",children:m?(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("textarea",{value:f,onChange:e=>x(e.target.value),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring",rows:3,autoFocus:!0,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),v()),"Escape"===e.key&&(h(!1),x(n.content))}}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{onClick:()=>{h(!1),x(n.content)},className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground",children:u("common.cancel")}),(0,r.jsx)("button",{onClick:v,className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90",children:u("common.save")})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:n.content}),(0,r.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:u("comments.lineRange",{start:n.startLine,end:n.endLine})}),(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)("button",{onClick:()=>h(!0),className:"p-1 rounded hover:bg-accent text-muted-foreground",title:u("common.edit"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,r.jsx)("button",{onClick:y,className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-red-9",title:u("common.delete"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]})]})})})}},89662:(e,t,n)=>{n.d(t,{Cv:()=>T,XO:()=>R});var r=n(95155),s=n(12115),l=n(79114),o=n(47650),a=n(57842),i=n(91694),c=n(82085),d=n(23193),u=n(74567),m=n(84392),h=n(87918);function f({blame:e,onClick:t}){let{t:n}=(0,l.Bd)(),a=(0,s.useRef)(null),i=(0,s.useRef)(null),c=(0,s.useRef)(!1),d=(0,s.useRef)(!1),u=(0,s.useRef)(null),m=(0,s.useRef)(null),x=(0,s.useRef)(null),g=(0,s.useRef)(e);(0,s.useEffect)(()=>{g.current=e},[e]);let p=(0,s.useRef)(t);(0,s.useEffect)(()=>{p.current=t},[t]);let b=(0,s.useCallback)(()=>{let e,t=i.current,n=a.current;if(!t||!n)return;let r=n.getBoundingClientRect(),s=t.getBoundingClientRect(),l=window.innerWidth,o=window.innerHeight,c=r.left;c+s.width>l-8&&(c=l-s.width-8),c<8&&(c=8),(e=r.top-s.height-4<0?r.bottom+4:r.top-s.height-4)+s.height>o-8&&(e=o-s.height-8),t.style.left=`${c}px`,t.style.top=`${e}px`},[]),v=(0,s.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null),m.current&&(clearTimeout(m.current),m.current=null),c.current=!1,d.current=!1,i.current&&(i.current.style.display="none"),x.current&&(document.removeEventListener("mousedown",x.current.down),document.removeEventListener("mouseup",x.current.up),x.current=null)},[]),y=(0,s.useCallback)(()=>{let e=i.current;if(!e||c.current)return;c.current=!0,e.style.left="-9999px",e.style.top="-9999px",e.style.display="block",requestAnimationFrame(()=>requestAnimationFrame(b));let t=0,n=0,r=e=>{t=e.clientX,n=e.clientY},s=e=>{if(!(Math.abs(e.clientX-t)>5||Math.abs(e.clientY-n)>5)){let t;t=e.target,i.current?.contains(t)||a.current?.contains(t)||v()}};document.addEventListener("mousedown",r),document.addEventListener("mouseup",s),x.current={down:r,up:s}},[b,v]),w=(0,s.useCallback)(()=>{if(u.current&&clearTimeout(u.current),m.current&&(clearTimeout(m.current),m.current=null),c.current)return;let e=window.getSelection();(!e||e.isCollapsed)&&(u.current=setTimeout(y,500))},[y]),k=(0,s.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null),c.current&&(m.current=setTimeout(()=>{d.current||v()},200))},[v]),C=(0,s.useCallback)(()=>{d.current=!0,m.current&&(clearTimeout(m.current),m.current=null)},[]),j=(0,s.useCallback)(()=>{d.current=!1,v()},[v]),N=(0,s.useCallback)(e=>{e.stopPropagation();let t=window.getSelection();t&&t.toString().length>0&&i.current?.contains(t.anchorNode)||(p.current?.(g.current),v())},[v]);(0,s.useEffect)(()=>()=>v(),[v]);let E=e.message.split("\n")[0]||"",L=e.message.split("\n").slice(1).join("\n").trim();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{ref:a,className:"select-none text-xs text-muted-foreground/50 ml-6 cursor-default hover:text-muted-foreground/80",onMouseEnter:w,onMouseLeave:k,children:[e.author.split(" ")[0],", ",function(e){let t=h.A.t,n=Math.floor((Date.now()-1e3*e)/1e3);if(n<60)return t("common.justNow");let r=Math.floor(n/60);if(r<60)return t("common.minutesAgo",{count:r});let s=Math.floor(r/60);if(s<24)return t("common.hoursAgo",{count:s});let l=Math.floor(s/24);if(l<30)return t("common.daysAgo",{count:l});let o=Math.floor(l/30);return o<12?t("common.monthsAgo",{count:o}):t("common.yearsAgo",{count:Math.floor(o/12)})}(e.time)," \xb7 ",E]}),(0,o.createPortal)((0,r.jsxs)("div",{ref:i,className:"fixed z-[9999] bg-card border border-border rounded-lg shadow-xl p-3 text-xs text-foreground whitespace-pre-wrap max-w-md select-text",style:{display:"none",minWidth:280,cursor:"text"},"data-inline-blame-tip":"",onMouseEnter:C,onMouseLeave:j,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,r.jsx)("span",{className:"font-mono text-brand",children:e.hash}),(0,r.jsx)("span",{className:"text-muted-foreground",children:e.author}),(0,r.jsx)("span",{className:"text-muted-foreground/60",children:new Date(1e3*e.time).toLocaleString()})]}),(0,r.jsx)("div",{className:"font-medium",children:E}),L&&(0,r.jsx)("div",{className:"mt-1 text-muted-foreground",children:L}),(0,r.jsx)("div",{className:"mt-2 text-[11px] text-brand border-t border-border pt-2 cursor-pointer hover:underline",onClick:N,children:n("codeViewer.clickToViewDetails")})]}),document.body)]})}let x=[{bg:"rgba(59, 130, 246, 0.15)",border:"rgb(59, 130, 246)"},{bg:"rgba(16, 185, 129, 0.15)",border:"rgb(16, 185, 129)"},{bg:"rgba(245, 158, 11, 0.15)",border:"rgb(245, 158, 11)"},{bg:"rgba(239, 68, 68, 0.15)",border:"rgb(239, 68, 68)"},{bg:"rgba(168, 85, 247, 0.15)",border:"rgb(168, 85, 247)"},{bg:"rgba(236, 72, 153, 0.15)",border:"rgb(236, 72, 153)"},{bg:"rgba(20, 184, 166, 0.15)",border:"rgb(20, 184, 166)"},{bg:"rgba(249, 115, 22, 0.15)",border:"rgb(249, 115, 22)"}];function g(e,t){let n,r=document.caretRangeFromPoint(e.clientX,e.clientY);if(!r||!t.contains(r.startContainer))return 1;let s=r.startContainer,l=r.startOffset,o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),a=1;for(;n=o.nextNode();){if(n===s){a+=l;break}a+=n.textContent?.length||0}return a}let p=(0,s.memo)(function({virtualKey:e,lineNum:t,highlightedHtml:n,hasComments:o,firstComment:a,lineCommentsCount:i,isInRange:c,showLineNumbers:d,lineNumChars:u,commentsEnabled:m,virtualItemSize:h,virtualItemStart:x,onCommentBubbleClick:p,onCmdClick:b,onTokenHover:v,onTokenHoverLeave:y,flashLine:w,blameLine:k,showBlameInfo:C,blameAuthorColor:j,isBlameHovered:N,onBlameClick:E,onBlameMouseEnter:L,onBlameMouseLeave:S,inlineBlameData:M,onInlineBlameClick:T,isCursorLine:R,cursorCol:$}){let{t:P}=(0,l.Bd)(),I=(0,s.useMemo)(()=>R&&null!=$?function(e,t){let n=0,r=0;for(;r<e.length;){if("<"===e[r]){let t=e.indexOf(">",r);if(-1!==t){r=t+1;continue}}if(n===t){let t;if("&"===e[r]){let n=e.indexOf(";",r);t=-1!==n&&n-r<10?n+1:r+1}else t=r+1;let n=e.substring(r,t);return e.substring(0,r)+'<span class="vi-char-cursor">'+n+"</span>"+e.substring(t)}if("&"===e[r]){let t=e.indexOf(";",r);r=-1!==t&&t-r<10?t+1:r+1}else r++;n++}return e+'<span class="vi-char-cursor"> </span>'}(n,$):n,[n,R,$]),A=(0,s.useCallback)(e=>{if(!e.metaKey||!b)return;e.preventDefault(),e.stopPropagation();let n=e.currentTarget,r=g(e,n);window.getSelection()?.removeAllRanges(),b(t,r)},[t,b]),D=(0,s.useCallback)(e=>{if(!v||0!==e.buttons)return;let n=window.getSelection();if(n&&!n.isCollapsed)return;let r=e.target;if("SPAN"!==r.tagName||!r.style.color)return;let s=e.currentTarget,l=g(e,s),o=r.getBoundingClientRect();v(t,l,{x:o.left,y:o.bottom+4})},[t,v]),O=(0,s.useCallback)(()=>{k&&E&&E(k)},[k,E]),K=(0,s.useCallback)(e=>{k&&L&&L(k,e)},[k,L]);return(0,r.jsxs)("div",{"data-line":t,style:{position:"absolute",top:0,left:0,width:"100%",height:`${h}px`,transform:`translateY(${x}px)`,backgroundColor:N&&j?j.bg:void 0},className:`flex ${w===t?"flash-line":""} ${R?"vi-cursor-line":""} ${c?"bg-blue-9/20":o?"bg-amber-9/10":"hover:bg-accent/50"}`,children:[(0,r.jsxs)("div",{className:"flex shrink-0 sticky left-0 z-[2] bg-secondary",style:{backgroundColor:N&&j?j.bg:void 0},children:[k&&j&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-1 flex-shrink-0",style:{backgroundColor:j.border}}),(0,r.jsx)("div",{className:"w-48 flex-shrink-0 px-2 flex items-center gap-2 border-r border-border text-muted-foreground cursor-pointer hover:bg-accent/50",onMouseEnter:K,onMouseLeave:S,onClick:O,title:P("codeViewer.clickToViewCommit"),children:C?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"font-medium",style:{color:j.border},children:k.hash}),(0,r.jsx)("span",{className:"truncate flex-1",children:k.author.split(" ")[0]})]}):null})]}),d&&(0,r.jsxs)("span",{className:`flex-shrink-0 flex items-center justify-end gap-0.5 pr-2 select-none border-r border-border font-variant-tabular ${c?"bg-blue-9/30 text-blue-11":"bg-card/50 text-slate-9"}`,children:[m&&o&&a&&(0,r.jsx)("button",{onClick:e=>p(a,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-accent text-amber-9",title:P("codeViewer.nComments",{count:i}),children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),m&&!o&&(0,r.jsx)("span",{className:"w-4"}),(0,r.jsx)("span",{className:"text-right",style:{minWidth:`${u}ch`},children:t})]})]}),(0,r.jsxs)("span",{className:"flex-1 px-3 whitespace-pre select-text",onClick:A,onMouseOver:D,onMouseLeave:y,"data-code-content":!0,children:[(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:I}}),M&&(0,r.jsx)(f,{blame:M,onClick:T})]})]},e)});var b=n(64702),v=n(71063),y=n(10222),w=n(1531);function k(e,t,n){let r,s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),l=0;for(;(r=s.nextNode())&&r!==t;)l+=r.textContent.length;return l+n}function C(e,t){let n,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),s=t,l=null;for(;n=r.nextNode();){l=n;let e=n.textContent.length;if(s<=e)return{node:n,offset:s};s-=e}return l?{node:l,offset:l.textContent.length}:null}var j=n(578),N=n(38093);let E="white-space:pre;padding:0 12px;min-height:20px;line-height:20px";function L(e){let t=window.getSelection();if(!t?.rangeCount)return null;let n=t.getRangeAt(0),r=n.startContainer;for(;r&&r.parentElement!==e;)r=r.parentElement;if(!r)return null;let s=Array.from(e.children).indexOf(r);if(s<0)return null;let l=document.createRange();return l.selectNodeContents(r),l.setEnd(n.startContainer,n.startOffset),{line:s,offset:l.toString().length}}function S(e,t){let n,r=e.children[t.line];if(!r)return;let s=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),l=t.offset;for(;n=s.nextNode();){let e=n.textContent?.length||0;if(l<=e){let e=window.getSelection(),t=document.createRange();t.setStart(n,l),t.collapse(!0),e?.removeAllRanges(),e?.addRange(t);return}l-=e}let o=window.getSelection(),a=document.createRange();a.selectNodeContents(r),a.collapse(!1),o?.removeAllRanges(),o?.addRange(a)}function M(e){return e.map(e=>`<div style="${E}">${e}</div>`).join("")}let T=(0,s.forwardRef)(function({content:e,filePath:t,showLineNumbers:n=!0,showSearch:h=!0,className:f="",cwd:g,enableComments:T=!1,scrollToLine:R=null,scrollToLineAlign:$="center",onScrollToLineComplete:P,highlightKeyword:I=null,visibleLineRef:A,onCmdClick:D,onTokenHover:O,onTokenHoverLeave:K,onTokenHoverCancel:B,blameLines:F,inlineBlameLines:H,onSelectCommit:z,editable:W=!1,initialMtime:_,onEditorClose:q,onSaved:V,onEditorStateChange:U,viMode:X=!1,onContentMutate:J,onEnterInsertMode:Y,onViSave:Z,viStateRef:G,initialCursorLine:Q,initialCursorCol:ee,onInitialCursorSet:et,onContentSearch:en},er){let{t:es}=(0,l.Bd)(),el=(0,s.useRef)(e),eo=(0,s.useRef)(!1),[ea,ei]=(0,s.useState)(!1),[ec,ed]=(0,s.useState)(!1),[eu,em]=(0,s.useState)(()=>e.split("\n").length),eh=(0,s.useRef)(e.split("\n").length),[ef,ex]=(0,s.useState)({show:!1}),eg=(0,s.useRef)(null),ep=(0,s.useRef)(null),eb=(0,s.useRef)(_),ev=(0,s.useRef)(null),ey=(0,s.useRef)(!1),ew=(0,s.useRef)(!1),{parentRef:ek,containerRef:eC,searchInputRef:ej,floatingToolbarRef:eN,suppressHoverRef:eE,bumpToolbarRef:eL,savedSelectionRef:eS,highlightedLines:eM,isMounted:eT,cmdHeld:eR,flashLine:e$,isSearchVisible:eP,searchQuery:eI,caseSensitive:eA,wholeWord:eD,currentMatchIndex:eO,viewingComment:eK,addCommentInput:eB,sendToAIInput:eF,chatContext:eH,commentsEnabled:ez,updateComment:eW,deleteComment:e_,lines:eq,matches:eV,rowData:eU,virtualizer:eX,commentsByEndLine:eJ,linesWithComments:eY,setIsSearchVisible:eZ,setSearchQuery:eG,setCaseSensitive:eQ,setWholeWord:e0,setViewingComment:e1,setAddCommentInput:e2,setSendToAIInput:e5,goToNextMatch:e3,goToPrevMatch:e4,handleSearchKeyDown:e8,handleCommentBubbleClick:e6,handleToolbarAddComment:e9,handleToolbarSendToAI:e7,handleToolbarSearch:te,handleCommentSubmit:tt,handleSendToAISubmit:tn,getHighlightedLineHtml:tr,suppressMatchScrollRef:ts,inlineBlameLineRef:tl,inlineBlameVersion:to}=function({content:e,filePath:t,showSearch:n=!0,cwd:r,enableComments:l=!1,scrollToLine:o=null,scrollToLineAlign:a="center",onScrollToLineComplete:i,visibleLineRef:u,onContentSearch:m}){let[h,f]=(0,s.useState)(!1),x=(0,s.useRef)(null),g=(0,s.useRef)(null),p=(0,s.useRef)(null),C=(0,w.nH)();(0,s.useEffect)(()=>{f(!0)},[]);let[j,N]=(0,s.useState)(!1),[E,L]=(0,s.useState)(null),S=(0,s.useRef)(null),[M,T]=(0,s.useState)(!1),[R,$]=(0,s.useState)(""),[P,I]=(0,s.useState)(!1),[A,D]=(0,s.useState)(!1),[O,K]=(0,s.useState)(0),[B,F]=(0,s.useState)(0),H=(0,s.useRef)(!1),[z,W]=(0,s.useState)(null),_=(0,s.useRef)(null),q=(0,s.useRef)(()=>{}),V=(0,s.useRef)(!1),U=(0,s.useRef)(null),[X,J]=(0,s.useState)(null),[Y,Z]=(0,s.useState)(null),G=(0,s.useRef)(null),[Q,ee]=(0,s.useState)(0),et=l&&!!r,{comments:en,addComment:er,updateComment:es,deleteComment:el,refresh:eo}=(0,v._)({cwd:r||"",filePath:t}),ea=(0,s.useMemo)(()=>e.split("\n"),[e]),ei=(0,c.C)(ea,t),ec=(0,s.useMemo)(()=>{let e=new Map;for(let t of en){let n=t.endLine;e.has(n)||e.set(n,[]),e.get(n).push(t)}return e},[en]),ed=(0,s.useMemo)(()=>{let e=new Set;for(let t of en)for(let n=t.startLine;n<=t.endLine;n++)e.add(n);return e},[en]),eu=(0,s.useMemo)(()=>(0,d.Np)(ea,R,P,A),[ea,R,P,A]);(0,s.useEffect)(()=>{eu.length>0&&K(0)},[eu.length,R,P,A]);let em=(0,s.useMemo)(()=>{let e=[];for(let t=0;t<ea.length;t++)e.push({type:"code",lineIndex:t});return e},[ea.length]),eh=(0,b.Te)({count:em.length,getScrollElement:()=>x.current,estimateSize:()=>20,overscan:10});(0,s.useEffect)(()=>{if(!u)return;let e=x.current;if(!e)return;let t=()=>{if(!eh.range)return;let t=e.scrollTop;for(let e of eh.getVirtualItems())if(e.start>=t){let t=em[e.index];t?.type==="code"&&(u.current=t.lineIndex+1);return}};return e.addEventListener("scroll",t,{passive:!0}),t(),()=>e.removeEventListener("scroll",t)},[u,em]),(0,s.useEffect)(()=>{let e=e=>{"Meta"===e.key&&N(!0)},t=e=>{"Meta"===e.key&&N(!1)},n=()=>N(!1);return window.addEventListener("keydown",e),window.addEventListener("keyup",t),window.addEventListener("blur",n),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",t),window.removeEventListener("blur",n)}},[]),(0,s.useEffect)(()=>{if(!n)return;let e=e=>{(e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),T(!0),setTimeout(()=>p.current?.focus(),0)),"Escape"===e.key&&(M?(T(!1),$("")):Y?Z(null):X?J(null):_.current?(_.current=null,q.current()):z&&W(null))},t=g.current;if(t)return t.addEventListener("keydown",e),()=>t.removeEventListener("keydown",e)},[n,M,Y,X,z]),(0,s.useEffect)(()=>{if(H.current){H.current=!1;return}if(eu.length>0&&O>=0&&O<eu.length){let e=eu[O],t=em.findIndex(t=>"code"===t.type&&t.lineIndex===e.lineIndex);t>=0&&eh.scrollToIndex(t,{align:"center"})}},[O,eu,eh,em,B]);let ef=(0,s.useCallback)(()=>{0!==eu.length&&(K(e=>(e+1)%eu.length),F(e=>e+1))},[eu.length]),ex=(0,s.useCallback)(()=>{0!==eu.length&&(K(e=>(e-1+eu.length)%eu.length),F(e=>e+1))},[eu.length]),eg=(0,s.useRef)(o);eg.current=o,(0,s.useEffect)(()=>{if(null!==eg.current&&eg.current>0&&em.length>0){let e=eg.current,t=e-1,n=em.findIndex(e=>"code"===e.type&&e.lineIndex===t);if(n>=0){let t=()=>{eh.scrollToIndex(n,{align:a}),"center"===a&&(S.current&&clearTimeout(S.current),L(e),S.current=setTimeout(()=>L(null),500)),i?.()};"start"===a?requestAnimationFrame(t):setTimeout(t,150)}}},[o,a,em.length,eh,i]);let ep=(0,s.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?ex():ef()),"Escape"===e.key&&(T(!1),$(""))},[ef,ex]),eb=(0,s.useCallback)((e,t)=>{et&&(t.stopPropagation(),W({comment:e,x:t.clientX,y:t.clientY}),_.current=null,q.current(),J(null),Z(null))},[et]);(0,s.useEffect)(()=>{if(!et)return;let e=x.current,t=!1,n=0,r=0,s=e=>{t=!0,n=e.clientX,r=e.clientY,U.current=null,V.current=!0,_.current&&(_.current=null,q.current())},l=e=>{t=!1;let s=e.target;if(s.closest?.(".floating-toolbar"))return;let l=Math.abs(e.clientX-n)>5||Math.abs(e.clientY-r)>5,o=window.getSelection();if(!o||o.isCollapsed){V.current=!1,_.current&&(_.current=null,q.current());return}let a=o.toString();if(!a.trim()||!l){V.current=!1,_.current&&(_.current=null,q.current());return}let i=o.getRangeAt(0),c=x.current;if(!c||!c.contains(i.commonAncestorContainer))return;let d=i.startContainer,u=i.endContainer,m=e=>{if(!document.contains(e))return null;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;if(!t)return null;let n=t.closest("[data-line]");return n?parseInt(n.getAttribute("data-line")||"0",10):null},h=m(d),f=m(u);if(h&&f){let t=Math.min(h,f),n=Math.max(h,f);_.current={x:e.clientX,y:e.clientY,range:{start:t,end:n},selectedText:a},V.current=!0,q.current();let r=d.nodeType===Node.TEXT_NODE?d.parentElement?.closest("[data-line]"):d.closest("[data-line]"),s=u.nodeType===Node.TEXT_NODE?u.parentElement?.closest("[data-line]"):u.closest("[data-line]");r&&s&&(U.current={startLine:h,startOffset:k(r,i.startContainer,i.startOffset),endLine:f,endOffset:k(s,i.endContainer,i.endOffset)})}},o=()=>{if(t||!_.current)return;let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||(_.current=null,U.current=null,V.current=!1,q.current())};return e?.addEventListener("mousedown",s),document.addEventListener("mouseup",l),document.addEventListener("selectionchange",o),()=>{e?.removeEventListener("mousedown",s),document.removeEventListener("mouseup",l),document.removeEventListener("selectionchange",o)}},[et]),(0,s.useEffect)(()=>{let e=x.current;if(!e)return;let t=t=>{let n,r;if(!e.contains(t.target)){if(t.target.closest?.("[data-inline-blame-tip]"))return;null!==G.current&&(G.current=null,ee(e=>e+1));return}let s=window.getSelection();if(s&&!s.isCollapsed&&s.toString().trim())return;let l=(n=t.target,(r=n.closest?.("[data-line]"))?parseInt(r.getAttribute("data-line")||"0",10):null);l!==G.current&&(G.current=l,requestAnimationFrame(()=>ee(e=>e+1)))};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]);let ev=(0,s.useCallback)(()=>{let e=_.current;e&&(J({x:e.x,y:e.y,range:e.range,codeContent:e.selectedText}),_.current=null,q.current())},[]),ey=(0,s.useCallback)(()=>{let e=_.current;if(!e)return;let t=e.selectedText;Z({x:e.x,y:e.y,range:e.range,codeContent:t}),_.current=null,q.current()},[]),ew=(0,s.useCallback)(()=>{let e=_.current;if(!e||!m)return;let t=e.selectedText.trim();_.current=null,q.current(),t&&m(t)},[m]),ek=(0,s.useCallback)(async e=>{X&&(await er(X.range.start,X.range.end,e),J(null))},[X,er]),eC=(0,s.useCallback)(async e=>{if(Y&&C&&r)try{let n=await (0,y.$3)(r),s=[];for(let e of n)s.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});s.push({filePath:t,startLine:Y.range.start,endLine:Y.range.end,codeContent:Y.codeContent});let l=(0,y.Gw)(s,e);C.sendMessage(l),await (0,y.RP)(r),eo(),Z(null)}catch(e){console.error("Failed to send to AI:",e)}},[Y,C,t,r,eo]),ej=(0,s.useCallback)((e,t,n)=>{let r=ea[e];if(!r)return t;let s=[];if(R&&eu.length>0)for(let t of eu.filter(t=>t.lineIndex===e)){let n=eu[O]?.lineIndex===e&&eu[O]?.startCol===t.startCol;s.push({start:t.startCol,end:t.endCol,cls:n?"hl-cur":"hl-m"})}if(n&&!R&&n.length>=1){let e=n.toLowerCase(),t=r.toLowerCase(),l=0;for(;-1!==(l=t.indexOf(e,l));)s.push({start:l,end:l+n.length,cls:"hl-kw"}),l+=1}if(0===s.length)return t;s.sort((e,t)=>e.start-t.start||e.end-t.end);let l=[],o=0;for(let e of s){if(e.start<o)continue;e.start>o&&l.push((0,d.ZD)(r.substring(o,e.start)));let t=(0,d.ZD)(r.substring(e.start,e.end));l.push(`<span class="${e.cls}">${t}</span>`),o=e.end}if(o<r.length&&l.push((0,d.ZD)(r.substring(o))),t!==(0,d.ZD)(r)){let e=t;for(let t of s){let n=r.substring(t.start,t.end),s=(0,d.ZD)(n),l=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=RegExp(`(?<=>)([^<]*?)(${l})`,""),a=`$1<span class="${t.cls}">${s}</span>`,i=e.replace(o,a);i.length>e.length+200||(e=i)}return e}return l.join("")},[R,eu,O,ea]);return{parentRef:x,containerRef:g,searchInputRef:p,floatingToolbarRef:_,suppressHoverRef:V,savedSelectionRef:U,highlightedLines:ei,isMounted:h,cmdHeld:j,flashLine:E,isSearchVisible:M,searchQuery:R,caseSensitive:P,wholeWord:A,currentMatchIndex:O,viewingComment:z,bumpToolbarRef:q,addCommentInput:X,sendToAIInput:Y,chatContext:C,commentsEnabled:et,comments:en,updateComment:es,deleteComment:el,lines:ea,matches:eu,rowData:em,virtualizer:eh,commentsByEndLine:ec,linesWithComments:ed,setIsSearchVisible:T,setSearchQuery:$,suppressMatchScrollRef:H,setCaseSensitive:I,setWholeWord:D,setViewingComment:W,setAddCommentInput:J,setSendToAIInput:Z,goToNextMatch:ef,goToPrevMatch:ex,handleSearchKeyDown:ep,handleCommentBubbleClick:eb,handleToolbarAddComment:ev,handleToolbarSendToAI:ey,handleToolbarSearch:ew,handleCommentSubmit:ek,handleSendToAISubmit:eC,getHighlightedLineHtml:ej,inlineBlameLineRef:G,inlineBlameVersion:Q}}({content:e,filePath:t,showSearch:h,cwd:g,enableComments:!W&&T,scrollToLine:W?null:R,scrollToLineAlign:W?"center":$,onScrollToLineComplete:W?void 0:P,visibleLineRef:W?void 0:A,onContentSearch:en}),ta=(0,a.iN)(),ti=(0,s.useRef)(null),tc=(0,s.useRef)(null),td=(0,s.useRef)({line:0,col:0}),tu=function({lines:e,enabled:t,onContentChange:n,onEnterInsert:r,onSave:l,getVisibleLineCount:o,scrollToLine:a,onSearchExecute:i,onSearchNext:c,onSearchPrev:d,onSearchClear:u}){let[m,h]=(0,s.useState)("normal"),[f,x]=(0,s.useState)(-1),[g,p]=(0,s.useState)(0),[b,v]=(0,s.useState)(!1),[y,w]=(0,s.useState)(""),[k,C]=(0,s.useState)(""),[j,N]=(0,s.useState)(""),[E,L]=(0,s.useState)(""),S=(0,s.useRef)([]),M=(0,s.useRef)([]),T=(0,s.useRef)([]),R=(0,s.useRef)(null),$=(0,s.useRef)(e);(0,s.useEffect)(()=>{$.current=e}),(0,s.useEffect)(()=>{0!==e.length&&queueMicrotask(()=>x(t=>Math.min(t,e.length-1)))},[e.length]);let P=(0,s.useCallback)((e,t)=>Math.max(0,Math.min(t,Math.max(0,($.current[e]??"").length-1))),[]),I=(0,s.useRef)(e.length);(0,s.useEffect)(()=>{let t=Math.abs(e.length-I.current);I.current=e.length,t>10&&(queueMicrotask(()=>{x(-1),p(0),v(!1)}),S.current=[],M.current=[],T.current=[])},[e]);let A=(0,s.useCallback)(()=>{R.current&&(clearTimeout(R.current),R.current=null),w("")},[]),D=(0,s.useCallback)(()=>{R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{w(""),R.current=null},500)},[]),O=(0,s.useCallback)((e,t)=>{S.current.push(t),M.current=[],v(!0),n(e.join("\n"))},[n]),K=(0,s.useCallback)((e,t)=>{let n=Math.max(0,Math.min(e,$.current.length-1));x(n),p(P(n,t??0)),a(n,"auto")},[a,P]),B=(0,s.useCallback)(e=>{x(t=>{let n=Math.max(0,Math.min(t+e,$.current.length-1));return a(n,"auto"),p(e=>Math.max(0,Math.min(e,Math.max(0,($.current[n]??"").length-1)))),n})},[a]),F=(0,s.useCallback)(()=>{let e=$.current,t=Math.min(f,e.length-1);if(0===e.length)return;let n=e[t];T.current=[n];let r=[...e];r.splice(t,1),0===r.length&&r.push("");let s=Math.min(t,r.length-1);O(r,{lineIndex:t,oldLines:[n],newLines:[],cursorLine:t}),x(s),p(0)},[f,O]),H=(0,s.useCallback)(()=>{let e=$.current,t=Math.min(f,e.length-1);e.length>0&&(T.current=[e[t]])},[f]),z=(0,s.useCallback)(()=>{let e=T.current;if(0===e.length)return;let t=$.current,n=Math.min(f,t.length-1)+1,r=[...t];r.splice(n,0,...e),O(r,{lineIndex:n,oldLines:[],newLines:[...e],cursorLine:f}),x(n),p(0),a(n,"auto")},[f,O,a]),W=(0,s.useCallback)(()=>{let e=$.current,t=Math.min(f,e.length-1),n=e[t];if(!n||0===n.length)return;let r=n.substring(1),s=[...e];s[t]=r,O(s,{lineIndex:t,oldLines:[n],newLines:[r],cursorLine:f})},[f,O]),_=(0,s.useCallback)(()=>{let e=S.current;if(0===e.length)return;let t=e.pop(),r=[...$.current];0===t.newLines.length&&t.oldLines.length>0?r.splice(t.lineIndex,0,...t.oldLines):0===t.oldLines.length&&t.newLines.length>0?(r.splice(t.lineIndex,t.newLines.length),0===r.length&&r.push("")):r.splice(t.lineIndex,t.newLines.length,...t.oldLines),M.current.push(t),n(r.join("\n")),x(Math.min(t.cursorLine,r.length-1)),a(Math.min(t.cursorLine,r.length-1),"auto"),0===e.length&&v(!1)},[n,a]),q=(0,s.useCallback)(()=>{let e=M.current;if(0===e.length)return;let t=e.pop(),r=[...$.current];0===t.newLines.length&&t.oldLines.length>0?(r.splice(t.lineIndex,t.oldLines.length),0===r.length&&r.push("")):0===t.oldLines.length&&t.newLines.length>0?r.splice(t.lineIndex,0,...t.newLines):r.splice(t.lineIndex,t.oldLines.length,...t.newLines),S.current.push(t),v(!0),n(r.join("\n"));let s=t.lineIndex+Math.max(0,t.newLines.length-1);x(Math.min(s,r.length-1)),a(Math.min(s,r.length-1),"auto")},[n,a]),V=(0,s.useCallback)(e=>{let t=$.current,n=Math.min(f,t.length-1);if("o"===e||"O"===e){let r="o"===e?n+1:n,s=[...t];s.splice(r,0,""),O(s,{lineIndex:r,oldLines:[],newLines:[""],cursorLine:f}),n=r,x(r)}h("insert"),r(n,g,e)},[f,g,O,r]),U=(0,s.useCallback)(()=>{h("normal"),A()},[A]),X=(0,s.useCallback)(()=>{h("command"),C("")},[]),J=(0,s.useCallback)(()=>{h("normal"),C("")},[]),Y=(0,s.useCallback)(()=>{h("search"),N("")},[]),Z=(0,s.useCallback)(()=>{h("normal"),N("")},[]),G=(0,s.useCallback)(e=>{let t=e.trim();if("w"===t){l?.(),h("normal"),C("");return}if("q"===t){h("normal"),C("");return}if("wq"===t){l?.(),h("normal"),C("");return}if("noh"===t||"nohlsearch"===t){u?.(),h("normal"),C("");return}let n=parseInt(t,10);if(!isNaN(n)&&n>0){let e=Math.min(n-1,$.current.length-1);x(e),a(e,"center"),h("normal"),C("");return}h("normal"),C("")},[l,u,a]),Q=(0,s.useCallback)(e=>{if(!e){h("normal"),N("");return}L(e),i?.(e),h("normal"),N("")},[i]),ee=(0,s.useCallback)(e=>{if(!t)return!1;let n=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;if("insert"===m)return("Escape"===e.key||!!n)&&(U(),!0);if("command"===m)return!e.isComposing&&("Escape"===e.key||n?J():"Enter"===e.key?G(k):"Backspace"===e.key?0===k.length?J():C(e=>e.slice(0,-1)):1!==e.key.length||e.metaKey||e.ctrlKey||C(t=>t+e.key),!0);if("search"===m)return!e.isComposing&&("Escape"===e.key||n?Z():"Enter"===e.key?Q(j):"Backspace"===e.key?0===j.length?Z():N(e=>e.slice(0,-1)):1!==e.key.length||e.metaKey||e.ctrlKey||N(t=>t+e.key),!0);if(f<0&&(x(0),p(0)),e.metaKey)return!1;if(e.ctrlKey)return"d"===e.key?(B(Math.max(1,Math.floor(o()/2))),A(),!0):"u"===e.key?(B(-Math.max(1,Math.floor(o()/2))),A(),!0):"r"===e.key&&(q(),A(),!0);let r=e.key,s=y+r;if("g"===s)return w("g"),D(),!0;if("gg"===s)return K(0),A(),!0;if("d"===s)return w("d"),D(),!0;if("dd"===s)return F(),A(),!0;if("y"===s)return w("y"),D(),!0;if("yy"===s)return H(),A(),!0;if(y&&s!==r&&A(),"j"===r||"ArrowDown"===r)return B(1),!0;if("k"===r||"ArrowUp"===r)return B(-1),!0;if("h"===r||"ArrowLeft"===r)return p(e=>Math.max(0,e-1)),!0;if("l"===r||"ArrowRight"===r){let e=Math.max(0,($.current[f]??"").length-1);return p(t=>Math.min(e,t+1)),!0}if("0"===r)return p(0),!0;if("$"===r)return p(Math.max(0,($.current[f]??"").length-1)),!0;if("^"===r){let e=($.current[f]??"").search(/\S/);return p(e>=0?e:0),!0}return"G"===r?(K($.current.length-1),!0):"x"===r?(W(),!0):"p"===r?(z(),!0):"u"===r?(_(),!0):"i"===r||"a"===r||"I"===r||"A"===r||"o"===r||"O"===r?(V(r),!0):"/"===r?(Y(),!0):"n"===r?(c?.(),!0):"N"===r?(d?.(),!0):":"===r?(X(),!0):"Escape"!==r&&1===r.length},[t,m,y,k,j,f,U,V,X,J,Y,Z,G,Q,B,K,o,F,H,z,W,_,q,A,D,c,d]);return{state:{mode:m,cursorLine:f,cursorCol:g,isDirty:b,keyBuffer:y,commandInput:k,searchInput:j,lastSearch:E},handleKeyDown:ee,enterNormal:U,enterInsert:V,setCursorLine:x,setCursorCol:p,setCommandInput:C,setSearchInput:N,setIsDirty:v,clearUndoHistory:(0,s.useCallback)(()=>{S.current=[],M.current=[]},[])}}({lines:eq,enabled:X&&!W,onContentChange:e=>{J?.(e)},onEnterInsert:(e,t,n)=>{let r=t;if("a"===n)r=t+1;else if("A"===n)r=(eq[e]??"").length;else if("I"===n){let t=(eq[e]??"").search(/\S/);r=t>=0?t:0}else("o"===n||"O"===n)&&(r=0);td.current={line:e,col:r},Y?.(e)},onSave:Z,getVisibleLineCount:()=>{let e=ek.current;return e?Math.floor(e.clientHeight/20):20},scrollToLine:(e,t)=>{let n=eU.findIndex(t=>"code"===t.type&&t.lineIndex===e);n>=0&&eX.scrollToIndex(n,{align:t||"auto"})},onSearchExecute:e=>{eG(e),eZ(!1)},onSearchNext:e3,onSearchPrev:e4,onSearchClear:()=>{eG("")}});(0,s.useEffect)(()=>{G&&(G.current={cursorLine:tu.state.cursorLine,cursorCol:tu.state.cursorCol})},[G,tu.state.cursorLine,tu.state.cursorCol]);let tm=(0,s.useRef)(null);(0,s.useEffect)(()=>{X&&!W&&null!=Q&&t&&tm.current!==t&&(tm.current=t,tu.setCursorLine(Q-1),null!=ee&&tu.setCursorCol(ee-1),et?.())},[X,W,Q,ee,t]),(0,s.useEffect)(()=>{if(!X||W)return;let e=eC.current;if(!e)return;let t=e=>{let t=e.target;"TEXTAREA"===t.tagName||"INPUT"===t.tagName||t.isContentEditable||tu.handleKeyDown(e)&&(e.preventDefault(),e.stopPropagation())};return e.addEventListener("keydown",t,!0),()=>e.removeEventListener("keydown",t,!0)},[X,W,tu.handleKeyDown]),(0,s.useEffect)(()=>{if(!X||W)return;let e=eC.current;e&&"normal"===tu.state.mode&&requestAnimationFrame(()=>{let t=document.activeElement;t&&("TEXTAREA"===t.tagName||"INPUT"===t.tagName||t.isContentEditable)||e.focus()})},[X,W,tu.state.mode,e]);let th=(0,s.useCallback)(e=>{if(!X||W)return;let t=e.target.closest("[data-line]");if(t){let n=parseInt(t.getAttribute("data-line"),10);if(!isNaN(n)){tu.setCursorLine(n-1);let r=t.querySelector("[data-code-content]");if(r){let t=document.caretRangeFromPoint(e.clientX,e.clientY);if(t&&r.contains(t.startContainer)){let e,s=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),l=0;for(;e=s.nextNode();){if(e===t.startContainer){l+=t.startOffset;break}l+=e.textContent?.length||0}let o=eq[n-1]??"";tu.setCursorCol(Math.max(0,Math.min(l,Math.max(0,o.length-1))))}}}}let n=e.target;if("TEXTAREA"===n.tagName||"INPUT"===n.tagName||n.isContentEditable)return;let r=eC.current;r&&r.focus()},[X,W,tu.setCursorLine,tu.setCursorCol,eq]),tf=(0,s.useCallback)(e=>{X&&!W&&requestAnimationFrame(()=>{let e=window.getSelection(),t=e?.toString().trim();t&&/^\S+$/.test(t)&&(ts.current=!0,eG(t))})},[X,W,eG,ts]);(0,s.useEffect)(()=>{"command"===tu.state.mode?setTimeout(()=>ti.current?.focus(),0):"search"===tu.state.mode&&setTimeout(()=>tc.current?.focus(),0)},[tu.state.mode]),(0,s.useEffect)(()=>{let e=ek.current;if(!e)return;let t=()=>{(B??K)?.()};return e.addEventListener("mousedown",t),()=>e.removeEventListener("mousedown",t)},[B,K]),(0,s.useEffect)(()=>{eB||eF?(eE.current=!0,K?.()):eN.current||(eE.current=!1)},[eB,eF,K]),(0,s.useLayoutEffect)(()=>{let e=eS.current;if(!e)return;let t=window.getSelection();if(t&&!t.isCollapsed)return;let n=ek.current;if(!n)return;let r=n.querySelector(`[data-line="${e.startLine}"]`),s=n.querySelector(`[data-line="${e.endLine}"]`);if(!r||!s)return;let l=C(r,e.startOffset),o=C(s,e.endOffset);if(l&&o)try{let e=document.createRange();e.setStart(l.node,l.offset),e.setEnd(o.node,o.offset),t?.removeAllRanges(),t?.addRange(e)}catch{}});let tx=(0,s.useCallback)((e,t,n)=>{eE.current||O?.(e,t,n)},[O]),tg=(0,s.useCallback)((e,t)=>{eE.current||D?.(e,t)},[D]),tp=Math.max(4,String(W?eu:eq.length).length),tb=(0,s.useMemo)(()=>{let e=0;for(let t of eq){let n=0;for(let e=0;e<t.length;e++)" "===t[e]?n+=2-n%2:n+=1;n>e&&(e=n)}return e},[eq]);(0,s.useEffect)(()=>{if(W){el.current=e;let t=e.split("\n").length;eh.current=t,em(t),eo.current=!1,ei(!1),ex({show:!1}),eb.current=_}},[W,e,_]),(0,s.useEffect)(()=>{if(!W)return;let t=eg.current;if(!t)return;let n=e.split("\n");t.innerHTML=M(n.map((e,t)=>eM[t]||(0,d.ZD)(e||" "))),requestAnimationFrame(()=>{let e,r;X?(e=Math.max(0,Math.min(td.current.line,n.length-1)),r=td.current.col):(e=Math.max(0,Math.min((A?.current??1)-1,n.length-1)),r=0),t.focus(),S(t,{line:e,offset:r});let s=A?.current??1;ep.current&&(ep.current.scrollTop=(s-1)*20)})},[W]),(0,s.useEffect)(()=>{W&&U?.({isDirty:ea,isSaving:ec})},[W,ea,ec,U]);let tv=(0,s.useCallback)(()=>{let e=eg.current;if(!e)return el.current;let t=[];for(let n of e.childNodes){let e=n.textContent||"";t.push(" "===e?"":e)}return t.join("\n")},[]),ty=(0,s.useCallback)(()=>{ev.current&&clearTimeout(ev.current),ev.current=setTimeout(async()=>{let e=eg.current;if(e&&!ew.current){el.current=tv();try{let n=await (0,d.kS)(),r=(0,d.sQ)(t),s=document.documentElement.classList.contains("dark"),l=el.current.split("\n"),o=n.codeToTokens(l.join("\n"),{lang:r,theme:s?"github-dark":"github-light"}).tokens.map(e=>(0,d.b8)(e)),a=L(e);ey.current=!0,e.innerHTML=M(o),ey.current=!1,a&&S(e,a)}catch{}}},300)},[t,tv]);(0,s.useEffect)(()=>{if(W)return()=>{ev.current&&clearTimeout(ev.current)}},[W]);let tw=(0,s.useCallback)(()=>{let e=eg.current;if(!e)return;eo.current||(eo.current=!0,ei(!0));let t=e.children.length;t!==eh.current&&(eh.current=t,em(t))},[]),tk=(0,s.useCallback)(()=>{ey.current||ew.current||(tw(),ty())},[tw,ty]),tC=(0,s.useCallback)(e=>{if(!e.nativeEvent.isComposing&&("Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," ")),"Enter"===e.key)){e.preventDefault();let t=eg.current;if(!t)return;let n=window.getSelection();if(!n?.rangeCount)return;let r=n.getRangeAt(0);r.deleteContents();let s=r.startContainer;for(;s&&s.parentElement!==t;)s=s.parentElement;if(!s||!(s instanceof HTMLElement))return;let l=L(t),o=Array.from(t.children).indexOf(s),a=s.textContent||"",i=l?.offset??a.length,c=a.substring(0,i),u=a.substring(i);s.innerHTML=(0,d.ZD)(c||" ");let m=document.createElement("div");m.setAttribute("style",E),m.innerHTML=(0,d.ZD)(u||" "),s.after(m),S(t,{line:o+1,offset:0}),tw(),ty()}},[tw,ty]),tj=(0,s.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)},[]),tN=(0,s.useCallback)(async(e=!1)=>{if(g){el.current=tv(),ed(!0);try{let n=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:g,path:t,content:el.current,expectedMtime:e?void 0:eb.current})}),r=await n.json();if(409===n.status&&r.conflict){try{let e=await fetch(`/api/files/text?cwd=${encodeURIComponent(g)}&path=${encodeURIComponent(t)}`),n=await e.json();ex({show:!0,diskContent:e.ok&&"string"==typeof n.content?n.content:void 0})}catch{ex({show:!0})}return}if(!n.ok)throw Error("Failed to save file");r.mtime&&(eb.current=r.mtime),eo.current=!1,ei(!1),ex({show:!1}),(0,N.oR)(es("toast.savedSuccess"),"success"),V?.()}catch(e){console.error("Error saving file:",e),(0,N.oR)(es("toast.saveFailed"),"error")}finally{ed(!1)}}},[g,t,tv,V]),tE=(0,s.useCallback)(async()=>{ea&&!ec&&await tN(!1)},[ea,ec,tN]),tL=(0,s.useCallback)(async()=>{ex({show:!1}),await tN(!0)},[tN]),tS=(0,s.useCallback)(()=>{if(void 0!==ef.diskContent){el.current=ef.diskContent;let t=ef.diskContent.split("\n").length;eh.current=t,em(t);let n=ef.diskContent!==e;eo.current=n,ei(n);let r=eg.current;r&&(r.innerHTML=M(ef.diskContent.split("\n").map(e=>(0,d.ZD)(e||" "))),ty())}ex({show:!1}),V?.()},[ef.diskContent,e,V,ty]),tM=(0,s.useCallback)(()=>{let e=ep.current;return e?Math.floor(e.scrollTop/20)+1:A?.current??1},[A]),tT=(0,s.useCallback)(async()=>{(!ea||await (0,N.lJ)(es("codeViewer.unsavedConfirm"),{danger:!0,confirmText:es("codeViewer.discardChanges"),cancelText:es("codeViewer.continueEditing")}))&&q?.(tM())},[ea,q,tM]);(0,s.useEffect)(()=>{if(!W)return;let e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&(e.preventDefault(),tE())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[W,tE]);let tR=(0,s.useCallback)(()=>{let e=tv();J?.(e);let t=eg.current,n=t?L(t):null,r=tM();if(tu.enterNormal(),n){tu.setCursorLine(n.line);let t=e.split("\n")[n.line]??"";tu.setCursorCol(Math.max(0,Math.min(n.offset,Math.max(0,t.length-1))))}else tu.setCursorLine(Math.max(0,r-1));q?.(r)},[tv,J,tM,q,tu]);(0,s.useEffect)(()=>{if(!W)return;let e=e=>{let t="Escape"===e.key,n=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;(t||X&&n)&&(e.preventDefault(),e.stopPropagation(),X?eo.current?(0,N.lJ)(es("codeViewer.unsavedExitConfirm"),{danger:!0,confirmText:es("codeViewer.discardChanges"),cancelText:es("codeViewer.continueEditing")}).then(e=>{e&&tR()}):tR():tT())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[W,X,tT,tR]),(0,s.useImperativeHandle)(er,()=>({save:tE,close:tT,get isDirty(){return ea},get isSaving(){return ec}}),[tE,tT,ea,ec]);let t$=!!(F&&F.length>0),tP=(0,s.useMemo)(()=>{if(!F)return new Map;let e=[...new Set(F.map(e=>e.author))],t=new Map;return e.forEach((e,n)=>{t.set(e,x[n%x.length])}),t},[F]),[tI,tA]=(0,s.useState)(null),[tD,tO]=(0,s.useState)(null);(0,s.useEffect)(()=>{tA(null),tO(null)},[F]);let tK=(0,s.useCallback)((e,t)=>{tA(e.author);let n=t.currentTarget.getBoundingClientRect();tO({line:e,x:n.right+8,y:n.top})},[]),tB=(0,s.useCallback)(()=>{tA(null),tO(null)},[]),tF=(0,s.useCallback)(e=>{z&&(z({hash:e.hashFull,shortHash:e.hash,author:e.author,authorEmail:e.authorEmail,date:new Date(1e3*e.time).toISOString(),subject:e.message.split("\n")[0]||"",body:e.message.split("\n").slice(1).join("\n").trim(),time:e.time}),tO(null))},[z]),tH=`${tp+2}ch`;return(0,r.jsxs)("div",{ref:eC,className:`h-full flex flex-col outline-none ${f}`,tabIndex:0,onClick:th,onDoubleClick:tf,children:[W&&ef.show&&(0,r.jsxs)("div",{className:"px-4 py-2 bg-amber-500/15 border-b border-amber-500/30 flex items-center gap-3 flex-shrink-0",children:[(0,r.jsx)("svg",{className:"w-5 h-5 text-amber-500 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),(0,r.jsx)("span",{className:"text-sm text-foreground flex-1",children:es("codeViewer.fileModifiedExternally")}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:tS,className:"px-3 py-1 text-sm rounded border border-border hover:bg-accent transition-colors",children:es("codeViewer.useDiskVersion")}),(0,r.jsx)("button",{onClick:tL,className:"px-3 py-1 text-sm rounded bg-amber-500 text-white hover:bg-amber-600 transition-colors",children:es("codeViewer.forceOverwrite")})]})]}),!W&&h&&eP&&(0,r.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border",children:[(0,r.jsx)("input",{ref:ej,type:"text",value:eI,onChange:e=>eG(e.target.value),onKeyDown:e8,placeholder:es("codeViewer.searchPlaceholder"),className:"flex-1 max-w-xs px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,r.jsx)("button",{onClick:()=>eQ(!eA),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${eA?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:es("codeViewer.caseSensitive"),children:"Aa"}),(0,r.jsx)("button",{onClick:()=>e0(!eD),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${eD?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:es("codeViewer.wholeWordMatch"),children:"[ab]"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:eV.length>0?`${eO+1}/${eV.length}`:es("common.noMatch")}),(0,r.jsx)("button",{onClick:e4,disabled:0===eV.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:es("common.previous"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,r.jsx)("button",{onClick:e3,disabled:0===eV.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:es("common.next"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,r.jsx)("button",{onClick:()=>{eZ(!1),eG("")},className:"p-1 rounded hover:bg-accent",title:es("common.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),W?(0,r.jsx)("div",{ref:ep,className:"flex-1 overflow-auto bg-secondary",children:(0,r.jsxs)("div",{className:"flex",style:{minHeight:"100%"},children:[(0,r.jsx)("div",{className:"flex-shrink-0 font-mono text-sm select-none sticky left-0 z-[2] bg-secondary",style:{width:tH},children:Array.from({length:eu},(e,t)=>(0,r.jsx)("div",{className:"text-right text-muted-foreground/50 pr-3",style:{height:20,lineHeight:"20px"},children:t+1},t))}),(0,r.jsx)("div",{ref:eg,contentEditable:!0,suppressContentEditableWarning:!0,onInput:tk,onKeyDown:tC,onPaste:tj,onCompositionStart:()=>{ew.current=!0},onCompositionEnd:()=>{ew.current=!1,tk()},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",className:"flex-1 font-mono text-sm outline-none",style:{caretColor:"var(--foreground)",tabSize:2}})]})}):(0,r.jsx)("div",{ref:ek,className:`flex-1 overflow-auto font-mono text-sm bg-secondary${eR?" cmd-held-container":""}`,children:(0,r.jsx)("div",{style:{height:`${eX.getTotalSize()}px`,minWidth:"100%",width:t$?`calc(${tp+tb+10}ch + 13rem)`:`${tp+tb+10}ch`,position:"relative"},children:eX.getVirtualItems().map(e=>{let t=eU[e.index];if("code"!==t.type)return null;let s=t.lineIndex,l=s+1,o=eM[s]||(0,d.ZD)(eq[s]||""),a=tr(s,o,I),i=eY.has(l),c=eJ.get(l),u=c?.[0],m=!!(eB&&l>=eB.range.start&&l<=eB.range.end),h=to>=0?tl.current:null,f=!W&&H&&h===l?H[s]??null:null,x=t$?F[s]:void 0,g=t$&&s>0?F[s-1]:void 0,b=!!x&&(!g||g.hash!==x.hash),v=x?tP.get(x.author):void 0;return(0,r.jsx)(p,{virtualKey:e.key,lineNum:l,highlightedHtml:a,hasComments:i,firstComment:u,lineCommentsCount:c?.length,isInRange:m,showLineNumbers:n,lineNumChars:tp,commentsEnabled:ez,virtualItemSize:e.size,virtualItemStart:e.start,onCommentBubbleClick:e6,onCmdClick:tg,onTokenHover:tx,onTokenHoverLeave:K,flashLine:e$,blameLine:x,showBlameInfo:b,blameAuthorColor:v,isBlameHovered:!!(x&&tI===x.author),onBlameClick:tF,onBlameMouseEnter:tK,onBlameMouseLeave:tB,inlineBlameData:f,onInlineBlameClick:tF,isCursorLine:X&&!W&&tu.state.cursorLine===s,cursorCol:X&&!W&&tu.state.cursorLine===s?tu.state.cursorCol:void 0},e.key)})})}),X&&(0,r.jsxs)("div",{className:"vi-status-bar flex-shrink-0 h-6 bg-card border-t border-border flex items-center px-3 text-xs font-mono select-none",children:["normal"===tu.state.mode&&(0,r.jsx)("span",{className:"text-green-11 font-medium",children:"NORMAL"}),"insert"===tu.state.mode&&(0,r.jsx)("span",{className:"text-blue-11 font-medium",children:"INSERT"}),"command"===tu.state.mode&&(0,r.jsxs)("div",{className:"flex items-center flex-1",children:[(0,r.jsx)("span",{className:"text-foreground",children:":"}),(0,r.jsx)("input",{ref:ti,value:tu.state.commandInput,onChange:e=>tu.setCommandInput(e.target.value),onKeyDown:e=>{if(e.nativeEvent.isComposing)return;let t=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;("Enter"===e.key||"Escape"===e.key||t)&&(e.preventDefault(),e.stopPropagation(),tu.handleKeyDown(e.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),"search"===tu.state.mode&&(0,r.jsxs)("div",{className:"flex items-center flex-1",children:[(0,r.jsx)("span",{className:"text-foreground",children:"/"}),(0,r.jsx)("input",{ref:tc,value:tu.state.searchInput,onChange:e=>tu.setSearchInput(e.target.value),onKeyDown:e=>{if(e.nativeEvent.isComposing)return;let t=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;("Enter"===e.key||"Escape"===e.key||t)&&(e.preventDefault(),e.stopPropagation(),tu.handleKeyDown(e.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),tu.state.keyBuffer&&"normal"===tu.state.mode&&(0,r.jsx)("span",{className:"ml-2 text-muted-foreground",children:tu.state.keyBuffer}),tu.state.isDirty&&("normal"===tu.state.mode||"command"===tu.state.mode)&&(0,r.jsx)("span",{className:"ml-2 text-amber-11",children:"[+]"}),(0,r.jsxs)("span",{className:"ml-auto text-muted-foreground",children:[tu.state.cursorLine+1,":",tu.state.cursorCol+1]})]}),eT&&ta&&(0,o.createPortal)((0,r.jsxs)(r.Fragment,{children:[!W&&(0,r.jsx)(u.f,{floatingToolbarRef:eN,bumpRef:eL,container:ta,onAddComment:e9,onSendToAI:e7,onSearch:en?te:void 0,isChatLoading:eH?.isLoading}),!W&&eB&&(0,r.jsx)(i.t,{x:eB.x,y:eB.y,range:eB.range,codeContent:eB.codeContent,container:ta,onSubmit:tt,onClose:()=>e2(null)}),!W&&eF&&(0,r.jsx)(i.G,{x:eF.x,y:eF.y,range:eF.range,filePath:t,codeContent:eF.codeContent,container:ta,onSubmit:tn,onClose:()=>e5(null),isChatLoading:eH?.isLoading}),!W&&eK&&(0,r.jsx)(m.t,{x:eK.x,y:eK.y,comment:eK.comment,container:ta,onClose:()=>e1(null),onUpdateComment:eW,onDeleteComment:e_}),tD&&(0,r.jsxs)("div",{className:"fixed z-50 bg-card border border-border rounded-lg shadow-lg p-3 max-w-lg",style:{left:Math.min(tD.x,window.innerWidth-450),top:Math.max(8,Math.min(tD.y,window.innerHeight-200))},children:[(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("div",{className:"px-2 py-0.5 rounded text-xs font-mono font-medium text-white flex-shrink-0",style:{backgroundColor:tP.get(tD.line.author)?.border||"#666"},children:tD.line.hash}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:tD.line.author}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:tD.line.authorEmail})]})]}),(0,r.jsx)("div",{className:"mt-2 text-sm text-foreground whitespace-pre-wrap max-h-48 overflow-y-auto",children:tD.line.message}),(0,r.jsxs)("div",{className:"mt-2 text-xs text-muted-foreground border-t border-border pt-2",children:[(0,j.fw)(tD.line.time)," \xb7 ",new Date(1e3*tD.line.time).toLocaleString(),(0,r.jsx)("span",{className:"ml-2 text-brand",children:es("codeViewer.clickToViewDetails")})]})]})]}),ta)]})});function R({content:e,filePath:t,className:n=""}){let l=(0,s.useMemo)(()=>e.split("\n"),[e]),o=(0,c.C)(l,t),a=Math.max(4,String(l.length).length);return(0,r.jsx)("pre",{className:`overflow-auto text-sm font-mono bg-secondary p-2 ${n}`,children:l.map((e,t)=>(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"text-slate-9 select-none pr-4 text-right",style:{minWidth:`${a+2}ch`},children:t+1}),(0,r.jsx)("span",{className:"flex-1",dangerouslySetInnerHTML:{__html:o[t]||(0,d.ZD)(e||" ")}})]},t))})}},91694:(e,t,n)=>{n.d(t,{G:()=>a,t:()=>o});var r=n(95155),s=n(12115),l=n(79114);function o({x:e,y:t,range:n,codeContent:a,container:i,onSubmit:c,onClose:d}){let{t:u}=(0,l.Bd)(),[m,h]=(0,s.useState)(""),[f,x]=(0,s.useState)(!1),g=(0,s.useRef)(null),p=(0,s.useRef)(null),[b,v]=(0,s.useState)({x:0,y:0}),y=a?.split("\n").slice(0,5).join("\n"),w=!!a&&a.split("\n").length>5;return(0,s.useEffect)(()=>{if(g.current&&i){let n=i.getBoundingClientRect(),r=g.current.getBoundingClientRect(),s=e-n.left,l=t-n.top;s+r.width>n.width-16&&(s=n.width-r.width-16),s<16&&(s=16),l+r.height>n.height-16&&(l=l-r.height-8),l<16&&(l=16),queueMicrotask(()=>v({x:s,y:l}))}},[e,t,i]),(0,s.useEffect)(()=>{p.current?.focus()},[]),(0,s.useEffect)(()=>{let e=e=>{f||!g.current||g.current.contains(e.target)||d()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[d,f]),(0,r.jsxs)("div",{ref:g,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:b.x,top:b.y},children:[(0,r.jsx)("div",{className:"px-3 py-2 bg-amber-9/10 border-b border-border",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-amber-11",children:u("comments.addComment")}),(n.start>0||n.end>0)&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:u("comments.lineRange",{start:n.start,end:n.end})})]})}),a&&(0,r.jsx)("div",{className:"px-3 py-2 bg-secondary/50 border-b border-border max-h-24 overflow-hidden",children:(0,r.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[y,w&&(0,r.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,r.jsxs)("div",{className:"p-2",children:[(0,r.jsx)("textarea",{ref:p,value:m,onChange:e=>h(e.target.value),placeholder:u("comments.inputPlaceholder"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:f,onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),!f&&m.trim()&&(x(!0),c(m.trim()))),"Escape"!==e.key||f||d()}}),(0,r.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:u(f?"comments.submitting":"comments.enterSubmit")})]})]})}function a({x:e,y:t,range:n,filePath:o,codeContent:i,container:c,onSubmit:d,onClose:u,isChatLoading:m}){let{t:h}=(0,l.Bd)(),[f,x]=(0,s.useState)(""),g=(0,s.useRef)(null),p=(0,s.useRef)(null),[b,v]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(g.current&&c){let n=c.getBoundingClientRect(),r=g.current.getBoundingClientRect(),s=e-n.left,l=t-n.top;s+r.width>n.width-16&&(s=n.width-r.width-16),s<16&&(s=16),l+r.height>n.height-16&&(l=l-r.height-8),l<16&&(l=16),queueMicrotask(()=>v({x:s,y:l}))}},[e,t,c]),(0,s.useEffect)(()=>{p.current?.focus()},[]),(0,s.useEffect)(()=>{let e=e=>{g.current&&!g.current.contains(e.target)&&u()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[u]);let y=i?.split("\n").slice(0,5).join("\n"),w=!!i&&i.split("\n").length>5;return(0,r.jsxs)("div",{ref:g,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:b.x,top:b.y},children:[(0,r.jsxs)("div",{className:"px-3 py-2 bg-brand/10 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-brand",children:h("comments.askAI")}),(n.start>0||n.end>0)&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:h("comments.lineRange",{start:n.start,end:n.end})})]}),o&&(0,r.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:o})]}),i&&(0,r.jsx)("div",{className:"px-3 py-2 bg-secondary/50 border-b border-border max-h-24 overflow-hidden",children:(0,r.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[y,w&&(0,r.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,r.jsxs)("div",{className:"p-2",children:[(0,r.jsx)("textarea",{ref:p,value:f,onChange:e=>x(e.target.value),placeholder:h("comments.inputQuestion"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:m,onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),!m&&f.trim()&&(d(f.trim()),u())),"Escape"===e.key&&u()}}),(0,r.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:h(m?"comments.aiGenerating":"comments.enterSend")})]})]})}},97440:(e,t,n)=>{n.d(t,{r:()=>o});var r=n(95155),s=n(12115),l=n(79114);function o({isOpen:e,onClose:t,onSelectSession:n,onAddProject:a}){let{t:i}=(0,l.Bd)(),[c,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)([]),[h,f]=(0,s.useState)({}),[x,g]=(0,s.useState)(!1),[p,b]=(0,s.useState)(null),[v,y]=(0,s.useState)(""),w=(0,s.useRef)(null),k=(0,s.useCallback)(async()=>{g(!0),b(null),f({});try{let e=await fetch("/api/sessions/projects");if(!e.ok)throw Error("Failed to load projects");let t=await e.json();m(t)}catch(e){b(e instanceof Error?e.message:"Unknown error")}finally{g(!1)}},[]),C=(0,s.useCallback)(async e=>{f(t=>({...t,[e]:{...t[e],isExpanded:!0,isLoading:!0,sessions:[],error:null}}));try{let t=await fetch(`/api/sessions/projects/${encodeURIComponent(e)}`);if(!t.ok)throw Error("Failed to load sessions");let n=await t.json();f(t=>({...t,[e]:{...t[e],isLoading:!1,sessions:n}}))}catch(t){f(n=>({...n,[e]:{...n[e],isLoading:!1,error:t instanceof Error?t.message:"Unknown error"}}))}},[]),j=(0,s.useCallback)(e=>{let t=h[e];t?.isExpanded?f(t=>({...t,[e]:{...t[e],isExpanded:!1}})):t?.sessions?.length?f(t=>({...t,[e]:{...t[e],isExpanded:!0}})):C(e)},[h,C]);(0,s.useEffect)(()=>{e&&(k(),setTimeout(()=>{w.current?.focus()},100))},[e,k]);let N=(0,s.useCallback)(async()=>{if(!c){d(!0);try{let e=await fetch("/api/pick-folder"),n=await e.json();n.folder&&a&&(a(n.folder),t())}catch{}finally{d(!1)}}},[c,a,t]);return((0,s.useEffect)(()=>{let n=n=>{"Escape"===n.key&&e&&t()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,t]),e)?(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:t}),(0,r.jsxs)("div",{className:"relative w-full max-w-6xl h-[90vh] mx-4 bg-card rounded-lg shadow-xl flex flex-col overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-foreground",children:i("sessions.projectList")}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("input",{ref:w,type:"text",placeholder:i("workspace.searchProjectPath"),value:v,onChange:e=>y(e.target.value),className:"px-2 py-1 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),a&&(0,r.jsxs)("button",{onClick:N,disabled:c,className:"flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50",title:i("sessions.openFolder"),children:[(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 10v6m3-3H9m-4 7h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),c?i("sessions.selectingFolder"):i("sessions.openFolder")]}),(0,r.jsx)("button",{onClick:t,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[x&&(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,r.jsx)("span",{children:i("workspace.loadingProjects")})]})}),p&&(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("div",{className:"text-xs text-red-11",children:p})}),!x&&!p&&0===u.length&&(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:i("workspace.projectNotFound")})}),!x&&!p&&u.filter(e=>e.fullPath.toLowerCase().includes(v.toLowerCase())).map(e=>{let t=h[e.encodedPath]||{isExpanded:!1,isLoading:!1,sessions:[],error:null};return(0,r.jsxs)("div",{className:"mb-3",children:[(0,r.jsxs)("button",{onClick:()=>j(e.encodedPath),className:"w-full flex items-center gap-2 p-2 rounded hover:bg-accent transition-colors text-left",children:[(0,r.jsx)("svg",{className:`w-3 h-3 text-muted-foreground transition-transform ${t.isExpanded?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,r.jsx)("svg",{className:"w-4 h-4 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,r.jsx)("span",{className:"flex-1 text-xs font-medium text-foreground truncate",title:e.fullPath,children:e.fullPath}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",e.sessionCount,")"]})]}),t.isExpanded&&(0,r.jsxs)("div",{className:"ml-6 mt-2",children:[t.isLoading&&(0,r.jsxs)("div",{className:"flex items-center gap-2 p-3 text-xs text-muted-foreground",children:[(0,r.jsxs)("svg",{className:"animate-spin h-3 w-3",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,r.jsx)("span",{children:i("sessions.loadingSessions")})]}),t.error&&(0,r.jsx)("div",{className:"p-3 text-xs text-red-11",children:t.error}),!t.isLoading&&!t.error&&(0,r.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:t.sessions.map(t=>(0,r.jsxs)("div",{onClick:()=>{var r;let s;return r=e.fullPath,s=(t.path.split("/").pop()||"").replace(".jsonl",""),void(n?n(r,s):window.parent.postMessage({type:"OPEN_PROJECT",cwd:r,sessionId:s},"*"))},className:"p-3 bg-secondary rounded border border-border hover:border-brand hover:shadow-md cursor-pointer transition-all",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[t.engine&&"claude"!==t.engine&&(0,r.jsx)("span",{className:`shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded ${"claude2"===t.engine?"bg-orange-500/15 text-orange-11":"ollama"===t.engine?"bg-blue-500/15 text-blue-11":"codex"===t.engine?"bg-green-500/15 text-green-11":"kimi"===t.engine?"bg-purple-500/15 text-purple-11":"bg-muted text-muted-foreground"}`,children:t.engine}),(0,r.jsx)("h4",{className:"text-xs font-medium text-foreground truncate",title:t.title,children:t.title})]}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(t.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(0,r.jsxs)("div",{className:"space-y-0.5 text-xs",children:[t.firstMessages.map((e,t)=>(0,r.jsxs)("div",{className:"text-foreground truncate",title:e,children:[(0,r.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),e]},`first-${t}`)),t.lastMessages.length>0&&(0,r.jsx)("div",{className:"text-slate-9 text-center py-0.5",children:"\xb7\xb7\xb7"}),t.lastMessages.map((e,t)=>(0,r.jsxs)("div",{className:"text-foreground truncate",title:e,children:[(0,r.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),e]},`last-${t}`))]})]},t.path))})]})]},e.encodedPath)})]})]})]}):null}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9062],{24750:(e,t,r)=>{r.d(t,{_:()=>d});var n=r(95155),o=r(12115),s=r(79114),l=r(44810),i=r(38093),a=r(87918);function c(e,t,r){let n=(e,r)=>t[e]||r,o=[],s=null!=r?`[${r+1}] `:"",l=e.anchor.selectedText.length>200?e.anchor.selectedText.slice(0,197)+"...":e.anchor.selectedText;for(let t of(o.push(`${s}${a.A.t("review.quoteRef",{text:l})}`),o.push(a.A.t("review.commentAuthor",{author:n(e.authorId,e.author),content:e.content})),e.replies))o.push(a.A.t("review.replyAuthor",{author:n(t.authorId,t.author),content:t.content}));return o.join("\n")}function d({isOpen:e,onClose:t,comments:r,reviewTitle:h,userNameMap:x,onCommentClick:p}){let{t:m}=(0,s.Bd)(),[f,g]=(0,o.useState)(null),[v,b]=(0,o.useState)(!1);if(!e)return null;let j=[...r].sort((e,t)=>e.anchor.startOffset-t.anchor.startOffset),w=(e,t)=>x[e]||t,y=async e=>{g(e.id);try{let t=c(e,x);await navigator.clipboard.writeText(t),(0,i.oR)(m("toast.copiedComment"))}catch{(0,i.oR)(m("toast.copyFailed"),"error")}finally{g(null)}},N=async()=>{if(0!==r.length){b(!0);try{let e=function(e,t,r){if(0===e.length)return"";let n=[...e].sort((e,t)=>e.anchor.startOffset-t.anchor.startOffset),o=[a.A.t("review.reviewSummary",{title:t}),""];return n.forEach((e,t)=>{o.push(c(e,r,t)),o.push("")}),o.push(a.A.t("review.totalNComments",{count:e.length})),o.join("\n").trim()}(r,h,x);await navigator.clipboard.writeText(e),(0,i.oR)(m("toast.copiedAllComments"))}catch{(0,i.oR)(m("toast.copyFailed"),"error")}finally{b(!1)}}},k=e=>{p?.(e),t()},C=j.filter(e=>!e.closed),L=j.filter(e=>e.closed),A=(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:t,children:(0,n.jsxs)("div",{className:"w-full max-w-2xl max-h-[80vh] bg-card border border-border rounded-lg shadow-xl flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-secondary",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:m("review.allCommentsTitle")}),(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:[m("review.commentsCountBrief",{count:r.length}),L.length>0&&` (${m("review.closedCount",{count:L.length})})`]}),r.length>0&&(0,n.jsx)("button",{onClick:N,disabled:v,className:"p-1 rounded hover:bg-accent text-muted-foreground disabled:opacity-50",title:m("review.copyAllComments"),children:v?(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,n.jsx)("button",{onClick:t,className:"p-1 rounded hover:bg-accent text-muted-foreground",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-3",children:0===r.length?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,n.jsx)("div",{className:"text-2xl mb-2",children:"\uD83D\uDCAC"}),(0,n.jsx)("span",{className:"text-sm",children:m("review.noComments")})]}):(0,n.jsxs)("div",{className:"space-y-2",children:[C.map((e,t)=>(0,n.jsx)(u,{comment:e,index:t,resolveAuthor:w,copyingId:f,onCopy:y,onClick:k},e.id)),L.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"text-[11px] text-muted-foreground/60 pt-2 pb-1 px-1",children:m("review.closedComments",{count:L.length})}),L.map((e,t)=>(0,n.jsx)(u,{comment:e,index:C.length+t,resolveAuthor:w,copyingId:f,onCopy:y,onClick:k,closed:!0},e.id))]})]})})]})});return(0,n.jsx)(l.Z,{children:A})}function u({comment:e,index:t,resolveAuthor:r,copyingId:o,onCopy:s,onClick:l,closed:i}){let c=e.anchor.selectedText.length>100?e.anchor.selectedText.slice(0,97)+"...":e.anchor.selectedText;return(0,n.jsxs)("div",{className:`rounded-lg border border-border hover:border-muted-foreground/30 transition-all cursor-pointer group ${i?"opacity-50":""}`,onClick:()=>l(e.id),children:[(0,n.jsx)("div",{className:"px-3 pt-2.5 pb-1",children:(0,n.jsx)("div",{className:"text-xs bg-yellow-500/10 border-l-2 border-yellow-500 px-2 py-1 rounded-r text-muted-foreground truncate",children:c})}),(0,n.jsxs)("div",{className:"px-3 pt-1.5 pb-2 flex items-start gap-2",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,n.jsx)("span",{className:"w-4 h-4 rounded-full bg-brand/20 text-brand flex items-center justify-center text-[9px] font-bold flex-shrink-0",children:r(e.authorId,e.author).charAt(0)}),(0,n.jsx)("span",{className:"text-xs font-medium",children:r(e.authorId,e.author)}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground",children:new Date(e.createdAt).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}),i&&(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground/60",children:a.A.t("review.closedLabel")})]}),(0,n.jsx)("p",{className:"text-sm text-foreground line-clamp-2 pl-6",children:e.content}),e.replies.length>0&&(0,n.jsxs)("div",{className:"pl-6 mt-1 space-y-0.5",children:[e.replies.slice(0,3).map(e=>(0,n.jsxs)("div",{className:"text-xs text-muted-foreground truncate",children:[(0,n.jsx)("span",{className:"font-medium",children:r(e.authorId,e.author)}),": ",e.content]},e.id)),e.replies.length>3&&(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground/60",children:a.A.t("review.moreReplies",{count:e.replies.length-3})})]})]}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),s(e)},disabled:o===e.id,className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-accent text-muted-foreground transition-opacity disabled:opacity-50 flex-shrink-0 mt-0.5",title:a.A.t("review.copyComment"),children:o===e.id?(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}},44810:(e,t,r)=>{r.d(t,{Z:()=>a});var n=r(12115),o=r(47650);let s=()=>()=>{},l=()=>document.body,i=()=>null;function a({children:e}){let t=(0,n.useSyncExternalStore)(s,l,i);return t?(0,o.createPortal)(e,t):null}},80777:(e,t,r)=>{r.d(t,{m:()=>l});var n=r(95155),o=r(12115),s=r(47650);function l({content:e,children:t,delay:r=300,className:i=""}){let[a,c]=(0,o.useState)(!1),[d,u]=(0,o.useState)({top:0,left:0}),h=(0,o.useRef)(null),x=(0,o.useRef)({x:0,y:0}),p=(0,o.useRef)(null);return(0,o.useEffect)(()=>{if(a&&p.current){let e=p.current.getBoundingClientRect(),t=d.left,r=d.top;e.right>window.innerWidth-8&&(t=window.innerWidth-e.width-8),e.left<8&&(t=8),e.bottom>window.innerHeight-8&&(r=x.current.y-e.height-8),(t!==d.left||r!==d.top)&&queueMicrotask(()=>u({top:r,left:t}))}},[a,d.left,d.top]),(0,o.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{onMouseEnter:()=>{h.current=setTimeout(()=>{let{x:e,y:t}=x.current;u({top:t+12,left:e}),c(!0)},r)},onMouseMove:e=>{x.current={x:e.clientX,y:e.clientY}},onMouseLeave:()=>{h.current&&(clearTimeout(h.current),h.current=null),c(!1)},className:i,children:t}),a&&(0,s.createPortal)((0,n.jsx)("div",{ref:p,className:"fixed z-[9999] px-2 py-1 text-xs text-foreground bg-accent rounded shadow-lg max-w-md break-words pointer-events-none",style:{top:d.top,left:d.left},children:e}),document.body)]})}},94002:(e,t,r)=>{r.d(t,{l:()=>a});var n=r(95155),o=r(12115),s=r(79114),l=r(80777);let i=e=>`h1[data-source-start="${e}"], h2[data-source-start="${e}"], h3[data-source-start="${e}"], h4[data-source-start="${e}"], h5[data-source-start="${e}"], h6[data-source-start="${e}"]`;function a({content:e,containerRef:t,width:r="w-80"}){let{t:c}=(0,s.Bd)(),d=(0,o.useMemo)(()=>(function(e){let t=[],r=e.split("\n"),n=!1;for(let e=0;e<r.length;e++){let o=r[e];if(o.trimStart().startsWith("```")){n=!n;continue}if(n)continue;let s=/^(#{1,6})\s+(.+)$/.exec(o);s&&t.push({level:s[1].length,text:s[2].replace(/\s*#+\s*$/,""),sourceLine:e+1})}return t})(e),[e]),[u,h]=(0,o.useState)(!1),[x,p]=(0,o.useState)(null),m=(0,o.useCallback)(e=>{let r=t.current;if(!r)return;let n=r.querySelector(i(e));n&&n.scrollIntoView({behavior:"smooth",block:"start"})},[t]);return((0,o.useEffect)(()=>{let e=t.current;if(!e||0===d.length)return;let r=()=>{let t=[];for(let r of d){let n=e.querySelector(i(r.sourceLine));if(n){let o=n.getBoundingClientRect().top-e.getBoundingClientRect().top;t.push({line:r.sourceLine,top:o})}}let r=null;for(let e of t)e.top<=60&&(r=e.line);null===r&&t.length>0&&(r=t[0].line),p(r)},n=setTimeout(r,150);return e.addEventListener("scroll",r,{passive:!0}),()=>{clearTimeout(n),e.removeEventListener("scroll",r)}},[d,e,t]),0===d.length)?null:(0,n.jsxs)("div",{className:`border-r border-border flex-shrink-0 flex flex-col transition-[width] duration-200 ${u?"w-8":r}`,children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-border flex-shrink-0",children:[!u&&(0,n.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:c("editor.toc")}),(0,n.jsx)("button",{onClick:()=>h(e=>!e),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:c(u?"editor.expandToc":"editor.collapseToc"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u?(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"}):(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),!u&&(0,n.jsx)("nav",{className:"flex-1 overflow-y-auto py-1",children:d.map((e,t)=>(0,n.jsx)(l.m,{content:e.text,delay:400,children:(0,n.jsx)("button",{onClick:()=>m(e.sourceLine),className:`block w-full text-left text-sm py-1 px-2 truncate transition-colors hover:bg-accent ${x===e.sourceLine?"text-brand font-medium bg-brand/5":"text-muted-foreground"}`,style:{paddingLeft:`${(e.level-1)*12+8}px`},children:e.text})},t))})]})}},95766:(e,t,r)=>{r.d(t,{W:()=>s});var n=r(48250);let o=new Set(["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre","table","tr","hr","div","ul","ol"]);function s(){return e=>{(0,n.YR)(e,"element",e=>{if(o.has(e.tagName)&&e.position&&(e.properties||(e.properties={}),e.properties["data-source-start"]=e.position.start.line,e.properties["data-source-end"]=e.position.end.line,"pre"===e.tagName)){let t=e.children?.find(e=>"element"===e.type&&"code"===e.tagName);t&&(t.properties||(t.properties={}),t.properties["data-source-start"]=e.position.start.line,t.properties["data-source-end"]=e.position.end.line)}})}}}}]);