@surething/cockpit 1.0.211 → 1.0.212

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 (36) 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 +2 -2
  4. package/.next-prod/prerender-manifest.json +3 -3
  5. package/.next-prod/server/app/_global-error.html +1 -1
  6. package/.next-prod/server/app/_global-error.rsc +1 -1
  7. package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  9. package/.next-prod/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  10. package/.next-prod/server/app/_global-error.segments/_head.segment.rsc +1 -1
  11. package/.next-prod/server/app/_global-error.segments/_index.segment.rsc +1 -1
  12. package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next-prod/server/app/_not-found.html +1 -1
  14. package/.next-prod/server/app/_not-found.rsc +2 -2
  15. package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +2 -2
  16. package/.next-prod/server/app/_not-found.segments/_head.segment.rsc +1 -1
  17. package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +1 -1
  18. package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  19. package/.next-prod/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  20. package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  21. package/.next-prod/server/app/manifest.webmanifest/route.js +1 -1
  22. package/.next-prod/server/app/manifest.webmanifest.body +1 -1
  23. package/.next-prod/server/app-paths-manifest.json +3 -3
  24. package/.next-prod/server/chunks/9658.js +1 -1
  25. package/.next-prod/server/middleware-build-manifest.js +1 -1
  26. package/.next-prod/server/pages/404.html +1 -1
  27. package/.next-prod/server/pages/500.html +1 -1
  28. package/.next-prod/server/server-reference-manifest.json +1 -1
  29. package/.next-prod/trace +12 -12
  30. package/.next-prod/trace-build +1 -1
  31. package/README.md +14 -30
  32. package/README.zh.md +14 -30
  33. package/chrome-extension/manifest.json +2 -2
  34. package/package.json +3 -3
  35. /package/.next-prod/static/{pS6D6oF2RLyDG-MzgFWGm → IVZ8ReZv3wH9JQhz4PDC2}/_buildManifest.js +0 -0
  36. /package/.next-prod/static/{pS6D6oF2RLyDG-MzgFWGm → IVZ8ReZv3wH9JQhz4PDC2}/_ssgManifest.js +0 -0
@@ -29,7 +29,7 @@ ${f}`),ai(g,c)}else ai(P("chat.executedCommandFailed",{command:e,error:i.cause})
29
29
  ${a.skillPath}`;break}let d=`${a.name} `;if(c.startsWith(d)){let e=c.slice(d.length).trimStart();b=`${t("chat.skillExpansionPrompt")}
30
30
  ${a.skillPath}
31
31
 
32
- ${e}`;break}}a(b,w.length>0?w:void 0),v(""),x([]),I.current&&(I.current.style.height="auto")}},[u,w,b,a,A,t]),Q=(0,f.useCallback)(a=>{v(a.name+" "),I.current?.focus()},[]),R=(0,f.useCallback)(a=>{if(!a.nativeEvent.isComposing){if(N&&M.length>0){if("ArrowDown"===a.key){a.preventDefault(),F(a=>(a+1)%M.length);return}if("ArrowUp"===a.key){a.preventDefault(),F(a=>(a-1+M.length)%M.length);return}if("Enter"===a.key){a.preventDefault(),Q(M[E]);return}if("Escape"===a.key){a.preventDefault(),H(!0);return}if("Tab"===a.key){a.preventDefault(),Q(M[E]);return}}"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),P())}},[N,M,E,Q,P]),S=(0,f.useCallback)(a=>{let b=a.clipboardData?.items;if(!b)return;let c=["image/png","image/jpeg","image/webp","image/gif"];for(let d of Array.from(b)){let b=c.find(a=>d.type===a);if(b){a.preventDefault();let c=d.getAsFile();if(!c)continue;if(c.size>5242880){alert(t("chat.imageSizeLimit",{size:(c.size/1024/1024).toFixed(2)}));continue}let e=new FileReader;e.onload=a=>{let c=a.target?.result;if(!c)return;let d=c.replace(/^data:image\/\w+;base64,/,""),e={id:`img-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,data:d,preview:c,media_type:b};x(a=>[...a,e])},e.readAsDataURL(c)}}},[t]),T=(0,f.useCallback)(a=>{x(b=>b.filter(b=>b.id!==a))},[]);return(0,e.jsxs)("div",{className:"border-t border-border bg-card relative",children:[(0,e.jsx)(i.k,{images:w,onRemove:T,disabled:b}),N&&M.length>0&&(0,e.jsx)("div",{ref:J,className:"absolute bottom-full left-0 right-0 mx-4 mb-2 max-h-64 overflow-y-auto bg-card border border-border rounded-lg shadow-lg",children:M.map((a,b)=>{let c=b>0?M[b-1]:null,d="skill"===a.source&&(!c||"skill"!==c.source),f="skill"!==a.source&&0===b;return(0,e.jsxs)("div",{children:[f&&(0,e.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Commands"}),d&&(0,e.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Skills"}),(0,e.jsxs)("div",{onClick:()=>Q(a),className:`px-4 py-2 cursor-pointer ${b===E?"bg-brand/10":"hover:bg-accent"}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("span",{className:"font-mono text-sm font-medium text-foreground",children:a.name}),(0,e.jsx)("span",{className:"flex-1 text-sm text-muted-foreground truncate",children:a.description}),(0,e.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${(a=>{switch(a){case"builtin":return"bg-brand/15 text-brand dark:bg-brand/25 dark:text-teal-11";case"global":return"bg-green-9/15 text-green-11 dark:bg-green-9/25 dark:text-green-11";case"project":return"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25 dark:text-amber-11";case"skill":return"bg-purple-9/15 text-purple-11 dark:bg-purple-9/25 dark:text-purple-11"}})(a.source)}`,children:(a=>{switch(a){case"builtin":return t("common.builtin");case"global":return t("common.global");case"project":return t("common.project");case"skill":return"Skill"}})(a.source)})]}),"skill"===a.source&&a.argumentHint&&(0,e.jsx)("div",{className:"font-mono text-xs text-muted-foreground mt-0.5 pl-0 truncate",children:a.argumentHint})]})]},a.name)})}),(0,e.jsxs)("div",{className:"flex gap-2 items-end p-4",children:[(0,e.jsx)("button",{onClick:async()=>{if(!c)return;let a=await l.t4.runPromiseExit((0,m.Iz)(c,["."]));"Success"===a._tag?((0,g.oR)(t("toast.stagedAllFiles"),"success"),window.dispatchEvent(new CustomEvent("git-status-changed"))):(console.error("Error staging files:",a.cause),(0,g.oR)(t("toast.stageFailed"),"error"))},className:"p-2 text-green-11 hover:text-green-10 hover:bg-green-9/10 active:bg-green-9/20 active:scale-95 rounded-lg transition-all",title:t("chat.stageAll"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),o&&(0,e.jsx)("button",{onClick:o,className:"p-2 text-brand hover:text-teal-10 hover:bg-brand/10 active:bg-brand/20 active:scale-95 rounded-lg transition-all",title:t("chat.viewGitChanges"),children:(0,e.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"6",cy:"6",r:"2",strokeWidth:2}),(0,e.jsx)("circle",{cx:"18",cy:"6",r:"2",strokeWidth:2}),(0,e.jsx)("circle",{cx:"6",cy:"18",r:"2",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 8v10M18 8v4c0 2-2 4-6 4"})]})}),p&&(0,e.jsx)("button",{onClick:p,className:"p-2 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 active:bg-amber-9/20 active:scale-95 rounded-lg transition-all",title:t("chat.viewAllComments"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),q&&(0,e.jsx)("button",{onClick:q,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:t("chat.userMessages"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),r&&(0,e.jsx)("button",{onClick:r,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:t("chat.projectNotes"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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"})})}),s&&(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("button",{onClick:()=>D(!C),className:`p-2 rounded-lg transition-all ${C?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95"}`,title:t("chat.scheduledTasks"),children:(0,e.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]})}),C&&(0,e.jsx)(j.E,{onClose:()=>D(!1),onCreate:s})]}),(0,e.jsx)("textarea",{ref:I,value:u,onChange:a=>v(a.target.value),onKeyDown:R,onPaste:S,placeholder:b?t("chat.placeholderDisabled"):t("chat.placeholder"),rows:1,className:"flex-1 resize-none px-4 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-ring bg-card text-foreground placeholder-slate-9"})]})]})});d()}catch(a){d(a)}})},62473:(a,b,c)=>{"use strict";c.d(b,{g:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({tokenUsage:a,rateLimitInfo:b}){let{t:c}=(0,f.Bd)(),[h,i]=(0,e.useState)(()=>Date.now()),j=b?.status==="rejected"?"text-red-500":b?.status==="allowed_warning"?"text-yellow-500":"text-muted-foreground",k=b?.status==="rejected"?c("chat.rateLimitRejected","Rate Limited"):b?.status==="allowed_warning"?c("chat.rateLimitWarning","Approaching Limit"):null,l=a=>{if(!a)return"";let b=(a<1e12?1e3*a:a)-h;if(b<=0)return"";let c=Math.ceil(b/6e4);if(c<60)return`${c}m`;let d=Math.floor(c/60),e=c%60;return e>0?`${d}h${e}m`:`${d}h`},m=a=>a?a.replace(/_/g," "):"";return(0,d.jsx)("div",{className:"px-4 py-1.5 border-t border-border bg-secondary",children:(0,d.jsxs)("div",{className:"flex items-center justify-end gap-4 text-xs text-muted-foreground",children:[b&&k&&(0,d.jsxs)("span",{className:`flex items-center gap-1 ${j}`,title:[b.rateLimitType&&`Type: ${m(b.rateLimitType)}`,null!=b.utilization&&`Usage: ${(100*b.utilization).toFixed(0)}%`,b.resetsAt&&`Resets in: ${l(b.resetsAt)}`,b.isUsingOverage&&"Using overage"].filter(Boolean).join(" \xb7 "),children:["rejected"===b.status?(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}):(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:[(0,d.jsx)("strong",{children:k}),null!=b.utilization&&` ${(100*b.utilization).toFixed(0)}%`,b.resetsAt&&` \xb7 ${l(b.resetsAt)}`]})]}),b&&!k&&b.resetsAt&&(0,d.jsxs)("span",{className:"flex items-center gap-1.5",title:[b.rateLimitType&&m(b.rateLimitType),null!=b.utilization&&`Usage: ${(100*b.utilization).toFixed(0)}%`,`Resets in: ${l(b.resetsAt)}`].filter(Boolean).join(" \xb7 "),children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),null!=b.utilization?(0,d.jsxs)("span",{children:[(100*b.utilization).toFixed(0),"%"]}):(0,d.jsx)("span",{children:l(b.resetsAt)})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,d.jsxs)("span",{children:[c("chat.context"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens).toLocaleString()})]})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),(0,d.jsxs)("span",{children:[c("chat.output"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:a.outputTokens.toLocaleString()})]})]}),(a.cacheReadInputTokens>0||a.cacheCreationInputTokens>0)&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-brand",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4"})}),(0,d.jsxs)("span",{children:["Cache: ",(a.cacheReadInputTokens/(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens)*100).toFixed(0),"%"]})]}),a.totalCostUsd>0&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-green-11",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:["$",a.totalCostUsd.toFixed(4)]})]})]})})}},62751:(a,b,c)=>{"use strict";function d(){}function e(a){return()=>{}}c.d(b,{U:()=>e,k:()=>d})},63041:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({cwd:a,sessionId:b,onOpenProjectSessions:c,onOpenSessionBrowser:h,onOpenSettings:i}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1);return(0,d.jsx)("div",{className:"border-b border-border px-4 py-3 bg-card",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6"}),(0,d.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,d.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"One seat. One AI. Everything under control."})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[a&&(0,d.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help",title:`CWD: ${a}`,children:a}),!a&&b&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Session: ",b.slice(0,8),"..."]}),a&&(0,d.jsx)("button",{onClick:c,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:j("sessions.projectSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),(0,d.jsx)("button",{onClick:h,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:j("sessions.browseAllSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),b&&(0,d.jsx)("button",{onClick:()=>{let a=`claude -r ${b}`;navigator.clipboard.writeText(a).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},className:`p-2 rounded-lg transition-colors ${k?"text-green-500 bg-green-500/10":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:k?j("chat.copiedCommandTooltip"):j("chat.copyCommandTooltip",{sessionId:b}),children:k?(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),(0,d.jsx)("button",{onClick:i,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:j("settings.title"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]})]})})}},63913:(a,b,c)=>{"use strict";c.a(a,async(a,b)=>{try{var d=c(48249),e=c(3560),f=c(56696),g=c(74493),h=a([f]);f=(h.then?(await h)():h)[0],(0,e.Aq)({type:"database",idPrefix:"db",match(a){let b=a.trim().toLowerCase();return b.startsWith("postgresql://")||b.startsWith("postgres://")},parse(a){let b=a.trim(),c=b;try{let a=new URL(b),d=a.pathname.replace(/^\//,"")||"postgres";c=`${d}@${a.hostname}${a.port?":"+a.port:""}`}catch{}return{connectionString:b,displayName:c}},fromHistory:a=>({connectionString:a.connectionString,displayName:a.displayName||a.connectionString}),toHistory:a=>({connectionString:a.connectionString,displayName:a.displayName}),Component:function({item:a,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l}){return(0,d.jsx)(f.M,{id:a.id,connectionString:a.connectionString,displayName:a.displayName,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l})},async onClose(a){await (0,g.ax)("db",a.id)}}),b()}catch(a){b(a)}})},63963:(a,b,c)=>{"use strict";c.d(b,{AS:()=>w,HV:()=>t,If:()=>u,RS:()=>p,TN:()=>q,mO:()=>s,tr:()=>r});let d=null,e="",f=0,g=null,h=!1,i=new Map,j=null,k=null;function l(a){let b;try{b=JSON.parse(a.data)}catch{return}let c=b.type;if("ping"===c)return;if("running"===c){j&&(j(b.commands),j=null);return}let d=b.commandId;if(!d)return;let e=i.get(d);if(e){if("error"===c)e.onError(b.error);else{let{commandId:a,type:d,...f}=b;e.onData(c,f)}("exit"===c||"error"===c)&&i.delete(d)}}function m(a){d?.readyState===WebSocket.OPEN&&d.send(JSON.stringify(a))}function n(a){let b,c=(b="https:"===window.location.protocol?"wss:":"ws:",`${b}//${window.location.host}/ws/terminal?projectCwd=${encodeURIComponent(a)}`);e===c&&d||(w(),h=!1,e=c,function a(){if(h||!e)return;let b=new WebSocket(e);d=b,b.onopen=()=>{for(let a of(f=0,i.keys()))b.send(JSON.stringify({type:"attach",commandId:a}))},b.onmessage=l,b.onclose=()=>{if(d!==b||(d=null,h))return;g&&clearTimeout(g);let c=Math.min(1e3*Math.pow(1.5,f),1e4);f++,g=setTimeout(a,c)},b.onerror=()=>{}}())}function o(){return new Promise((a,b)=>{if(d?.readyState===WebSocket.OPEN)return void a();let c=setInterval(()=>{d?.readyState===WebSocket.OPEN&&(clearInterval(c),clearTimeout(e),a())},50),e=setTimeout(()=>{clearInterval(c),b(Error("WebSocket connection timeout"))},5e3)})}async function p(a){let{cwd:b,command:c,commandId:d,tabId:e,projectCwd:f,env:g,usePty:h,cols:j,rows:k,onData:l,onError:p}=a;n(f);try{await o()}catch{p("WebSocket connection failed");return}i.delete(d),i.set(d,{onData:l,onError:p}),m({type:"exec",commandId:d,command:c,cwd:b,tabId:e,env:g,...h?{usePty:!0}:{},...j?{cols:j,rows:k}:{}})}async function q(a){let{commandId:b,projectCwd:c,onData:d,onError:e}=a;n(c);try{await o()}catch{e("WebSocket connection failed");return}i.set(b,{onData:d,onError:e}),m({type:"attach",commandId:b})}function r(a,b){m({type:"stdin",commandId:a,data:b})}function s(a,b,c){m({type:"resize",commandId:a,cols:b,rows:c})}function t(a){m({type:"interrupt",pid:a})}function u(a){return k||(k=v(a))}async function v(a){try{n(a);try{await o()}catch{return[]}return await new Promise(a=>{j=b=>{a(b)},m({type:"running"}),setTimeout(()=>{j&&(j=null,a([]))},3e3)})}finally{k=null}}function w(){if(h=!0,g&&(clearTimeout(g),g=null),d){let a=d;d=null,a.close()}i.clear(),j&&(j([]),j=null),k=null,e="",f=0}},65395:(a,b,c)=>{"use strict";c.d(b,{useTabState:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call useTabState() from the server but useTabState is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/useTabState.ts","useTabState")},65484:(a,b,c)=>{"use strict";c.d(b,{Cq:()=>n,D0:()=>q,DZ:()=>i,H7:()=>o,It:()=>s,Kl:()=>w,M5:()=>h,Or:()=>k,Q1:()=>u,QW:()=>p,Wr:()=>j,Yn:()=>r,b2:()=>v,em:()=>t,zF:()=>m});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=()=>f("/api/settings"),i=a=>f("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),j=()=>f("/api/version"),k=()=>f("/api/extension/version"),l=a=>a?`/api/note?cwd=${encodeURIComponent(a)}`:"/api/note",m=a=>f(l(a)),n=(a,b)=>g(l(a),{content:b}),o=()=>f("/api/sessions/projects"),p=a=>f(`/api/sessions/projects/${encodeURIComponent(a)}`),q=a=>f(`/api/project-settings?cwd=${encodeURIComponent(a)}`),r=a=>g("/api/project-settings",a),s=()=>f("/api/pick-folder"),t=a=>g("/api/open-vscode",{cwd:a}),u=a=>g("/api/open-cursor",{cwd:a}),v=a=>f(`/api/git/worktree?cwd=${encodeURIComponent(a)}`),w=a=>g("/api/git/worktree",a)},65543:(a,b,c)=>{"use strict";c.d(b,{_:()=>e});let d=new Set(["function","class","method"]);function e(a){return d.has(a.kind)}},67045:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(48249);function e({error:a,reset:b}){return(0,d.jsx)("html",{children:(0,d.jsx)("body",{children:(0,d.jsxs)("div",{style:{padding:"2rem",fontFamily:"system-ui, sans-serif"},children:[(0,d.jsx)("h2",{children:"Something went wrong"}),(0,d.jsx)("p",{style:{color:"#666"},children:a.message}),(0,d.jsx)("button",{onClick:b,style:{marginTop:"1rem",padding:"0.5rem 1rem",cursor:"pointer",borderRadius:"0.375rem",border:"1px solid #ccc",background:"#fff"},children:"Try again"})]})})})}},67115:(a,b,c)=>{"use strict";c.d(b,{Q:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(57031),h=c(88214),i=c(33281),j=c(41224);function k({isOpen:a,onClose:b,cwd:c,onSelectSession:l}){let{t:m}=(0,f.Bd)(),[n,o]=(0,e.useState)([]),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(null),[t,u]=(0,e.useState)(""),v=(0,e.useRef)(null);(0,e.useCallback)(async()=>{if(!c)return;q(!0),s(null);let a=c.replace(/\//g,"-"),b=await i.t4.runPromiseExit((0,j.QW)(a));"Success"===b._tag?o(b.value):s("Failed to load sessions"),q(!1)},[c]);let w=n.filter(a=>{if(!t)return!0;let b=t.toLowerCase();return a.title.toLowerCase().includes(b)||a.firstMessages.some(a=>a.toLowerCase().includes(b))||a.lastMessages.some(a=>a.toLowerCase().includes(b))});return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:b}),(0,d.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,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:m("sessions.sessionList")}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:c,children:c})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,d.jsx)("input",{ref:v,type:"text",placeholder:m("sessions.searchSessions"),value:t,onChange:a=>u(a.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"}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[p&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:m("sessions.loadingSessions")})]})}),r&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-red-11",children:r})}),!p&&!r&&0===w.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:m(t?"sessions.noMatchingSessions":"sessions.noSessionsYet")})}),!p&&!r&&w.length>0&&(0,d.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:w.map(a=>(0,d.jsxs)("div",{onClick:()=>{let d;return d=(a.path.split("/").pop()||"").replace(".jsonl",""),void(l?(l(d,a.title),b()):(0,g.F)(h.n.OpenProject,{cwd:c,sessionId:d}))},className:"p-3 bg-secondary rounded border border-border hover:border-brand hover:shadow-md cursor-pointer transition-all",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[a.engine&&"claude"!==a.engine&&(0,d.jsx)("span",{className:`shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded ${"claude2"===a.engine?"bg-orange-500/15 text-orange-11":"ollama"===a.engine?"bg-blue-500/15 text-blue-11":"codex"===a.engine?"bg-green-500/15 text-green-11":"kimi"===a.engine?"bg-purple-500/15 text-purple-11":"bg-muted text-muted-foreground"}`,children:a.engine}),(0,d.jsx)("h4",{className:"text-xs font-medium text-foreground truncate",title:a.title,children:a.title})]}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(a.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(0,d.jsxs)("div",{className:"space-y-0.5 text-xs",children:[a.firstMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`first-${b}`)),a.lastMessages.length>0&&(0,d.jsx)("div",{className:"text-slate-9 text-center py-0.5",children:"\xb7\xb7\xb7"}),a.lastMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`last-${b}`))]})]},a.path))})]})]})]}):null}},69424:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{$:()=>q});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(44256),j=c(15273),k=c(46674),l=c(99941),m=c(44643),n=c(32026),o=c(11732);function p(a){let b=a.input?.questions||[],c=a.input?.answers||{},d={};if(a.result)try{let b=JSON.parse(a.result);b?.answers&&(d=b.answers)}catch{}return{questions:b,answers:{...c,...d}}}function q({toolCalls:a,onClose:b}){let{t:c}=(0,g.Bd)(),[d,r]=(0,f.useState)({}),[s,t]=(0,f.useState)({}),[u,v]=(0,f.useState)({}),[w,x]=(0,f.useState)({}),y=a.reduce((a,b)=>{let{questions:c}=p(b);return a+c.length},0),z=Object.values(w).filter(Boolean).length,A=(0,f.useCallback)((a,b)=>{r(c=>({...c,[a]:b})),t(b=>({...b,[a]:!1}))},[]),B=(0,f.useCallback)(a=>{t(b=>{let c=!b[a];if(c){let b=u[a]||"";b&&r(c=>({...c,[a]:b}))}return{...b,[a]:c}})},[u]),C=(0,f.useCallback)((a,b)=>{v(c=>({...c,[a]:b})),b&&r(c=>({...c,[a]:b}))},[]),D=(0,f.useCallback)(a=>{x(b=>({...b,[a]:!b[a]}))},[]),E=(0,f.useCallback)(()=>{let b=z>0,e=[];a.forEach((a,f)=>{let{questions:g}=p(a);g.forEach((a,g)=>{let h=`${f}-${g}`;if(b&&!w[h])return;let i=d[h];e.push(`Q: ${a.question}`),e.push(`A: ${i||c("askQuestion.notSelected")}`),e.push("")})}),navigator.clipboard.writeText(e.join("\n").trim()),(0,h.oR)(b?c("toast.copiedQA",{count:z}):c("toast.copiedAllQA"))},[a,d,w,z,c]),F=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:b,children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-6xl h-[90vh] flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:c("askQuestion.title")}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[c("askQuestion.nQuestions",{count:y}),z>0&&` \xb7 ${c("askQuestion.checkedN",{count:z})}`]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:E,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:z>0?c("askQuestion.copyChecked",{count:z}):c("askQuestion.copyAll"),children:(0,e.jsx)(j.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)(k.A,{className:"w-5 h-5"})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-6",children:a.map((b,f)=>{let{questions:g}=p(b);return g.map((b,h)=>{let i=`${f}-${h}`,j=d[i],k=s[i]||!1,p=w[i]||!1;return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-start gap-2",children:[(0,e.jsx)("button",{onClick:()=>D(i),className:"mt-0.5 flex-shrink-0 p-0.5 rounded hover:bg-accent transition-colors",title:c("askQuestion.checkToCopy"),children:p?(0,e.jsx)(l.A,{className:"w-4 h-4 text-brand"}):(0,e.jsx)(m.A,{className:"w-4 h-4 text-muted-foreground"})}),b.header&&(0,e.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-brand/10 text-brand flex-shrink-0 mt-0.5",children:b.header}),(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:b.question})]}),(0,e.jsxs)("div",{className:"space-y-1 ml-7",children:[b.options.map((a,b)=>{let c=j===a.label&&!k;return(0,e.jsxs)("button",{onClick:()=>A(i,a.label),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-accent/50 ${c?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,e.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:c?(0,e.jsx)(n.A,{className:"w-3.5 h-3.5 text-brand"}):(0,e.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("div",{className:`text-sm ${c?"text-foreground font-medium":"text-foreground"}`,children:a.label}),a.description&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.description})]})]},b)}),(0,e.jsxs)("button",{onClick:()=>B(i),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-accent/50 ${k?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,e.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:k?(0,e.jsx)(n.A,{className:"w-3.5 h-3.5 text-brand"}):(0,e.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(o.A,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:c("askQuestion.custom")})]})]}),k&&(0,e.jsx)("div",{className:"ml-6 mt-1",children:(0,e.jsx)("input",{type:"text",autoFocus:!0,value:u[i]||"",onChange:a=>C(i,a.target.value),placeholder:c("askQuestion.customPlaceholder"),className:"w-full px-3 py-1.5 text-sm bg-background border border-border rounded-md focus:outline-none focus:ring-1 focus:ring-brand text-foreground placeholder:text-muted-foreground"})})]}),(f!==a.length-1||h!==g.length-1)&&(0,e.jsx)("div",{className:"border-b border-border/50 mt-3"})]},i)})})})]})});return(0,e.jsx)(i.ZL,{children:F})}d()}catch(a){d(a)}})},70151:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>Q});var e=c(48249),f=c(67484),g=c(74429),h=c(44256),i=c(33281),j=c(87808),k=c(85655),l=c(21538),m=c(35208),n=c(7833),o=c(24724),p=c(20586),q=c(7122),r=c(55287),s=c(60591),t=c(9804),u=c(73887),v=c(94239),w=c(29939),x=c(23860),y=c(90018),z=c(57014),A=c(94308),B=c(53036),C=c(6662),D=c(20291),E=c(58904),F=c(61632),G=c(76855),H=c(4857),I=c(44384),J=c(18921),K=c(28797),L=c(23881),M=c(21672),N=c(21482),O=c(94192),P=a([E,F,p,o,l,y,r,z,m,u,v,N,M]);function Q({onClose:a,cwd:b,initialTab:c="tree",tabSwitchTrigger:d,initialSearchQuery:P,searchQueryTrigger:R}){let{t:S}=(0,I.Bd)(),{activeView:T}=(0,O.R8)(),[U,V]=(0,f.useState)(c),[W,X]=(0,f.useState)("code"),Y=(0,f.useRef)(null),Z=(0,f.useRef)(!1),[$,_]=(0,f.useState)(null),[aa,ab]=(0,f.useState)(null),[ac,ad]=(0,f.useState)(!1),ae=(0,f.useRef)(1),af=(0,f.useRef)(null),[ag,ah]=(0,f.useState)(null),ai=(0,f.useRef)(null),[aj,ak]=(0,f.useState)({isDirty:!1,isSaving:!1}),[al,am]=(0,f.useState)(!1),[an,ao]=(0,f.useState)(!1),[ap,aq]=(0,f.useState)(null),ar=(0,f.useRef)(null),as=(0,J.o)(ar),at=(0,f.useRef)(null),au=(0,J.o)(at),av=(0,G.Sn)(b),aw=(0,G.Xm)(b),ax=(0,G.po)(b),ay=(0,H.Q)(),az=(0,x.F)(),aA=(0,C.W)({cwd:b});(0,G.JL)(b,aA.selectedPath);let aB=(0,D.p)({cwd:b,onSearchComplete:()=>am(!0)}),aC=(0,E.e)({cwd:b,addToRecentFiles:aA.addToRecentFiles}),aD=(0,f.useMemo)(()=>{let a=new Set;if(aC.status){for(let b of aC.status.staged)a.add(b.path);for(let b of aC.status.unstaged)a.add(b.path)}return a},[aC.status]),aE=(0,f.useMemo)(()=>{let a=new Map;if(aC.status){for(let b of aC.status.staged)a.set(b.path,"staged");for(let b of aC.status.unstaged)a.set(b.path,"unstaged")}return a},[aC.status]),aF=(0,F.y)({cwd:b,addToRecentFiles:aA.addToRecentFiles}),aG=(0,f.useRef)(!1),aH=(0,f.useCallback)(a=>{aA.setFileContent(b=>b?.type==="text"?{...b,content:a}:b),aA.showEditor||(aG.current=!0,aA.setShowEditor(!0))},[aA]),aI=(0,f.useCallback)(a=>{aA.setShowEditor(!0)},[aA]),aJ=(0,f.useCallback)(async()=>{if(!aA.fileContent||"text"!==aA.fileContent.type||!aA.fileContent.content)return;let a=await i.t4.runPromiseExit((0,j.OJ)({cwd:b,path:aA.selectedPath,content:aA.fileContent.content}));try{if("Failure"===a._tag||!a.value.ok)throw Error("Failed to save file");let b=a.value.data?.mtime;b&&aA.setFileContent(a=>a?.type==="text"?{...a,mtime:b}:a),(0,n.oR)(S("toast.savedSuccess"),"success")}catch{(0,n.oR)(S("toast.saveFailed"),"error")}},[b,aA]),aK=(0,f.useCallback)(()=>{if(!aA.selectedPath)return;let a=ae.current,b=af.current;a>0&&aA.updateRecentFilePosition(aA.selectedPath,a,b?b.cursorLine+1:a,b?b.cursorCol+1:1)},[aA]),aL=(0,f.useCallback)(async(a,b)=>{let c=a!==aA.selectedPath;if(c&&aA.showEditor){if(aj.isDirty&&(!await (0,n.lJ)(S("fileBrowser.saveBeforeSwitch"),{confirmText:S("fileBrowser.saveAndSwitch"),cancelText:S("common.cancel")})||(await ai.current?.save(),ai.current?.isDirty)))return;aA.setShowEditor(!1)}c&&aK(),aA.handleSelectFile(a,b)},[aA,aK,aj.isDirty,S]),aM=(0,f.useMemo)(()=>{let a=aB.contentSearchResults;if(0===a.length)return{files:[],expandDirs:new Set,matchMap:new Map};let b=new Map,c=[];for(let d of a)b.set(d.path,d),c.push(d.path);let d=(0,t.v3)(c),e=new Set((0,t.tW)(d));return{files:d,expandDirs:e,matchMap:b}},[aB.contentSearchResults]),[aN,aO]=(0,f.useState)(new Set),aP=(0,f.useCallback)(a=>{aO(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),aQ=(0,f.useCallback)(a=>{if(a.isDirectory)return null;let b=aM.matchMap.get(a.path);return b?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:b.matches.length}):null},[aM.matchMap]),aR=al&&aB.contentSearchResults.length>0,aS=!!aA.selectedPath&&null!==(0,K.c)(aA.selectedPath),aT=(0,f.useCallback)(async(a,c)=>{if(!aA.selectedPath||!aS)return;let d=await av.goToDefinition(aA.selectedPath,a,c);if(0===d.length)return;let e=d[0],f=b.endsWith("/")?b:b+"/",g=e.file.startsWith(f)?e.file.slice(f.length):e.file;ay.push({filePath:aA.selectedPath,lineNumber:ae.current}),g===aA.selectedPath?aA.setTargetLineNumber(e.line):aL(g,e.line)},[aA,b,aS,av,ay]),aU=(0,f.useCallback)((a,b,c)=>{aA.selectedPath&&aS&&aw.onTokenMouseEnter(aA.selectedPath,a,b,c)},[aA.selectedPath,aS,aw]),aV=(0,f.useCallback)(a=>{let c=b.endsWith("/")?b:b+"/",d=a.file.startsWith(c)?a.file.slice(c.length):a.file;aA.selectedPath&&ay.push({filePath:aA.selectedPath,lineNumber:ae.current}),d===aA.selectedPath?aA.setTargetLineNumber(a.line):aL(d,a.line)},[aA,b,ay]),aW=(0,f.useMemo)(()=>{if(!aC.status)return null;let a=new Map,b=a=>{switch(a){case"modified":default:return"M";case"added":return"A";case"deleted":return"D";case"renamed":return"R";case"untracked":return"?"}};for(let c of aC.status.staged)a.set(c.path,b(c.status));for(let c of aC.status.unstaged)a.set(c.path,b(c.status));return a},[aC.status]),aX=(0,f.useCallback)(a=>{V(a),aA.setBlameSelectedCommit(null),"history"===a&&aF.selectedBranch&&aF.loadCommits(aF.selectedBranch)},[aA,aF.selectedBranch,aF.loadCommits]);(0,f.useCallback)(()=>{if(!aA.selectedPath)return;let a={filePath:aA.selectedPath,lineNumber:ae.current},b=ay.goBack(a);b&&(b.filePath===aA.selectedPath?aA.setTargetLineNumber(b.lineNumber):aL(b.filePath,b.lineNumber))},[aA,ay]),(0,f.useCallback)(()=>{if(!aA.selectedPath)return;let a={filePath:aA.selectedPath,lineNumber:ae.current},b=ay.goForward(a);b&&(b.filePath===aA.selectedPath?aA.setTargetLineNumber(b.lineNumber):aL(b.filePath,b.lineNumber))},[aA,ay]);let aY=(0,f.useCallback)(async a=>{let c=a.split("/").pop()||a,d=await i.t4.runPromiseExit((0,j.__)({cwd:b,paths:[a],op:"copy"}));"Success"===d._tag?(0,n.oR)(S("toast.copiedName",{name:c}),"success"):(0,n.oR)(S("toast.copyFailed"),"error")},[b,S]),aZ=(0,f.useCallback)(async a=>{let c=await i.t4.runPromiseExit((0,j.dt)());if("Success"!==c._tag||!c.value.path)return void(0,n.oR)(S("toast.noFileToPaste"),"info");let d=c.value.path,e=await i.t4.runPromiseExit((0,j.Nn)({cwd:b,targetDir:a,sourceAbsPath:d}));if("Success"===e._tag)(0,n.oR)(S("toast.pastedFile",{name:e.value.newName}),"success"),aA.loadDirectory(a),aA.loadFileIndex();else{let a="Fail"===e.cause._tag?e.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:S("toast.pasteFailed");(0,n.oR)(c,"error")}},[b,aA,S]);(0,f.useRef)(0),(0,f.useRef)(az),(0,f.useRef)(U);let a$=(0,f.useRef)(aF.selectedBranch);a$.current=aF.selectedBranch;let a_=(0,f.useRef)(aA.selectedPath);a_.current=aA.selectedPath;let a0=(0,f.useRef)(aA.fileContent?.type);a0.current=aA.fileContent?.type;let a1=(0,f.useCallback)(async a=>{try{let{data:c}=a;if(!c)return;let d=c.some(a=>"git"===a.type),e=c.some(a=>"file"===a.type),f=[];if((e||d)&&(f.push(i.t4.runPromise((0,j.mP)(b)).then(a=>{a.error||aA.setFiles(b=>(0,t.HR)(a.files??[],b))}).catch(()=>{})),f.push(i.t4.runPromise((0,j.DZ)(b)).then(a=>{a.paths&&aA.setFileIndex(a.paths)}).catch(()=>{})),f.push(i.t4.runPromise((0,j.r9)(b)).then(a=>{aA.setRecentFiles(a.files??[])}).catch(()=>{}))),d||e){f.push(i.t4.runPromise((0,k.lv)(b)).then(a=>{aC.setStatus(a);let b=(0,p.Do)(a.staged),c=(0,p.Do)(a.unstaged);aC.setStagedTree(b),aC.setUnstagedTree(c)}).catch(()=>{})),aC.refreshDiff(),d&&aF.loadBranches();let a=a$.current;a&&f.push(i.t4.runPromise((0,k.Bj)(b,a,t.B_)).then(a=>{let b=a.commits??[];aF.setCommits(b),aF.setHasMoreCommits(b.length>=t.B_)}).catch(()=>{}))}let g=a_.current,h=a0.current;g&&"text"===h&&f.push(i.t4.runPromise((0,j.K9)(b,g)).then(a=>{let b=a.ok?a.data:null;b&&"string"==typeof b.content&&aA.setFileContent({type:"text",content:b.content,size:b.size,mtime:b.mtimeMs,...b.isSymlink?{isSymlink:!0,symlinkTarget:b.symlinkTarget}:{}})}).catch(()=>{})),await Promise.all(f)}catch(a){console.error("File watch handler error:",a)}},[b]);(0,w.h)({url:`/ws/watch?cwd=${encodeURIComponent(b)}`,onMessage:a1,enabled:az});let a2=(0,f.useCallback)(a=>{let b=a.split("/");if(b.length>1){let a=[];for(let c=1;c<b.length;c++)a.push(b.slice(0,c).join("/"));aA.setExpandedPaths(b=>{let c=new Set(b);for(let b of a)c.add(b);return aA.saveExpandedPaths(c),c})}aA.setSelectedPath(a),aA.setShouldScrollToSelected(!0),V("tree")},[aA]);return(0,e.jsxs)(q.SU,{container:$,children:[(0,e.jsxs)("div",{ref:Y,className:"bg-card w-full h-full flex flex-col relative",children:[(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsxs)("div",{className:"w-80 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex border-b border-border",children:[(0,e.jsx)("button",{onClick:()=>aX("tree"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"tree"===U?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:S("fileBrowser.directoryTree")}),(0,e.jsx)("button",{onClick:()=>aX("search"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"search"===U?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:S("fileBrowser.searchTab")}),(0,e.jsx)("button",{onClick:()=>aX("recent"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"recent"===U?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:S("fileBrowser.recentTab")}),(0,e.jsx)("button",{onClick:()=>aX("status"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"status"===U?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:S("fileBrowser.changesTab")}),(0,e.jsx)("button",{onClick:()=>aX("history"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"history"===U?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:S("fileBrowser.historyTab")})]}),"tree"===U&&(0,e.jsxs)("div",{className:"p-2 border-b border-border flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:aA.searchInputRef,type:"text",value:aA.searchQuery,onChange:a=>aA.setSearchQuery(a.target.value),placeholder:S("fileBrowser.searchFiles"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),aA.searchQuery&&(0,e.jsx)("button",{onClick:()=>aA.setSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:S("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>aA.setSearchDirExact(a=>!a),className:`px-1 py-0.5 rounded transition-colors text-xs font-mono font-bold border ${aA.searchExactMatch?"border-brand text-brand bg-brand/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:aA.searchExactMatch?S("fileBrowser.exactMatchOn"):S("fileBrowser.exactMatchOff"),children:"ab"}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:()=>aA.loadFiles(),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:S("fileBrowser.refreshTree"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,e.jsx)("button",{onClick:()=>aA.searchTreeExpandedPaths?aA.setSearchTreeExpandedPaths(new Set):aA.setExpandedPaths(new Set),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:S("fileBrowser.collapseAll"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})]})]}),"search"===U&&(0,e.jsxs)("div",{className:"p-2 border-b border-border space-y-2",children:[(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:aB.contentSearchInputRef,type:"text",value:aB.contentSearchQuery,onChange:a=>aB.setContentSearchQuery(a.target.value),onKeyDown:a=>{"Enter"===a.key&&aB.performContentSearch(aB.contentSearchQuery)},placeholder:S("fileBrowser.searchFileContent"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),aB.contentSearchQuery&&(0,e.jsx)("button",{onClick:()=>aB.setContentSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:S("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>aB.performContentSearch(aB.contentSearchQuery),disabled:aB.isSearching||!aB.contentSearchQuery.trim(),className:"px-3 py-1.5 text-sm bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed",children:aB.isSearching?"...":S("common.search")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:aB.searchOptions.caseSensitive,onChange:a=>aB.setSearchOptions(b=>({...b,caseSensitive:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:S("fileBrowser.caseSensitive")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:aB.searchOptions.wholeWord,onChange:a=>aB.setSearchOptions(b=>({...b,wholeWord:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:S("fileBrowser.wholeWord")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:aB.searchOptions.regex,onChange:a=>aB.setSearchOptions(b=>({...b,regex:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:S("fileBrowser.regex")})]}),(0,e.jsx)("input",{type:"text",value:aB.searchOptions.fileType,onChange:a=>aB.setSearchOptions(b=>({...b,fileType:a.target.value})),placeholder:S("fileBrowser.fileTypes"),className:"w-24 px-2 py-0.5 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9"})]})]}),"history"===U&&(0,e.jsx)("div",{className:"p-3 border-b border-border",children:aF.compareMode?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0 px-3 py-1.5 text-sm border border-border rounded bg-secondary text-foreground flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),(0,e.jsx)("span",{className:"truncate",children:aF.branches?.current||"HEAD"}),(0,e.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:"HEAD"})]}),(0,e.jsx)("button",{onClick:()=>aF.toggleCompareMode(!1),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors bg-brand text-white",title:S("fileBrowser.compareModeOff"),children:S("fileBrowser.compareMode")})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0 pl-1",children:"vs"}),(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(A.e,{branches:aF.branches,selectedBranch:aF.compareBaseBranch,onSelect:a=>{aF.setCompareBaseBranch(a),aF.loadCompareFiles(a)},isLoading:aF.isLoadingBranches,pinnedBranches:["origin/main",...aF.upstreamBranch&&"origin/main"!==aF.upstreamBranch?[aF.upstreamBranch]:[]]})})]})]}):(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(A.e,{branches:aF.branches,selectedBranch:aF.selectedBranch,onSelect:a=>{aF.setSelectedBranch(a)},isLoading:aF.isLoadingBranches,pinnedBranches:["origin/main",...aF.upstreamBranch&&"origin/main"!==aF.upstreamBranch?[aF.upstreamBranch]:[]]})}),(0,e.jsx)("button",{onClick:()=>aF.toggleCompareMode(!0),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors text-muted-foreground hover:text-foreground hover:bg-accent border border-border",title:S("fileBrowser.compareModeOn"),children:S("fileBrowser.compareMode")})]})}),(0,e.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,e.jsxs)("div",{className:`flex-1 flex flex-col min-h-0 ${"tree"===U?"":"hidden"}`,children:[aA.creatingItem&&(0,e.jsxs)("div",{className:"px-2 py-1.5 border-b border-border bg-secondary flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:aA.creatingItem.parentPath?S("fileBrowser.createFileIn",{path:aA.creatingItem.parentPath}):S("fileBrowser.createFile")}),(0,e.jsx)("input",{type:"text",autoFocus:!0,placeholder:S("fileBrowser.fileName"),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring",onCompositionStart:()=>{Z.current=!0},onCompositionEnd:()=>{Z.current=!1},onKeyDown:async a=>{if("Enter"===a.key){if(Z.current)return;let c=a.target.value.trim();if(!c)return;let d=aA.creatingItem.parentPath,e=d?`${d}/${c}`:c,f=await i.t4.runPromiseExit((0,j.OJ)({cwd:b,path:e,content:""}));if("Success"===f._tag&&f.value.ok)(0,n.oR)(S("toast.createdFile",{name:c}),"success"),aA.setCreatingItem(null),aA.loadDirectory(d),aA.loadFileIndex(),d&&aA.setExpandedPaths(a=>new Set([...a,d])),aL(e);else if("Success"===f._tag){let a=f.value.data?.error;(0,n.oR)(a||S("toast.createFailed"),"error")}else(0,n.oR)(S("toast.createFailed"),"error")}else"Escape"===a.key&&aA.setCreatingItem(null)},onBlur:()=>aA.setCreatingItem(null)})]}),aA.isLoadingFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:S("common.loading")}):aA.fileError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:aA.fileError}):(0,e.jsx)(o.h,{files:aA.files,selectedPath:aA.selectedPath,expandedPaths:aA.effectiveExpandedPaths,matchedPaths:aA.matchedPaths,gitStatusMap:aW,loadingDirs:aA.loadingDirs,onSelect:a=>{aA.setShouldScrollToSelected(!1),aL(a)},onToggle:aA.handleToggle,cwd:b,shouldScrollToSelected:aA.shouldScrollToSelected,onScrolledToSelected:()=>aA.setShouldScrollToSelected(!1),onCreateFile:a=>aA.setCreatingItem({type:"file",parentPath:a}),onDelete:(a,b,c)=>ab({path:a,isDirectory:b,name:c}),onRefresh:()=>aA.loadFiles(),onCopyFile:aY,onPaste:aZ})]}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"search"===U?"":"hidden"}`,children:aB.isSearching?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):aB.searchError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:aB.searchError}):0===aB.contentSearchResults.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:aB.contentSearchQuery?S("fileBrowser.noContentSearchResults"):S("fileBrowser.enterKeywordToSearch")}):(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[aB.searchStats&&(0,e.jsxs)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-secondary border-b border-border flex-shrink-0",children:[S("fileBrowser.nFilesNMatches",{files:aB.searchStats.totalFiles,matches:aB.searchStats.totalMatches}),aB.searchStats.truncated&&(0,e.jsxs)("span",{className:"text-amber-11 ml-1",children:["(",S("fileBrowser.resultsTruncated"),")"]})]}),(0,e.jsx)(o.h,{files:aM.files,selectedPath:aA.selectedPath,expandedPaths:aN,onSelect:a=>{let b=aM.matchMap.get(a);aL(a,b?.matches[0]?.lineNumber),al||am(!0)},onToggle:aP,cwd:b,renderActions:aQ,className:"flex-1 overflow-y-auto py-1 min-w-max"})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"recent"===U?"":"hidden"}`,children:0===aA.recentFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:S("fileBrowser.noRecentFiles")}):(0,e.jsx)(o.h,{files:aA.recentFilesTree,selectedPath:aA.selectedPath,expandedPaths:aA.recentTreeDirPaths,onSelect:aL,onToggle:t.tE,cwd:b})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"status"===U?"":"hidden"}`,children:aC.statusLoading?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):aC.statusError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center p-4",children:(0,e.jsx)("span",{className:"text-red-11 text-sm",children:aC.statusError})}):(0,e.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[(0,e.jsxs)("div",{className:"border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:S("fileBrowser.stagingArea",{count:aC.status?.staged.length||0})}),(0,e.jsx)("button",{onClick:()=>aC.fetchStatus(),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:S("fileBrowser.refreshChanges"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),(aC.status?.staged.length||0)>0&&(0,e.jsx)("button",{onClick:aC.handleUnstageAll,className:"text-sm text-amber-11 hover:text-amber-10 hover:underline",children:S("fileBrowser.unstageAll")})]}),(0,e.jsx)(p.VO,{files:aC.stagedTree,selectedPath:aC.statusSelectedFile?.type==="staged"?aC.statusSelectedFile.file.path:null,expandedPaths:aC.stagedExpandedPaths,onSelect:a=>a.file&&aC.handleStatusFileSelect(a.file,"staged"),onToggle:aC.handleStagedToggle,cwd:b,emptyMessage:S("fileBrowser.noStagedFiles"),className:"py-1",renderActions:a=>{if(a.isDirectory){let b=(0,p.wI)(a);return 0===b.length?null:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),aC.handleUnstageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:S("fileBrowser.unstageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}return(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),aC.handleUnstage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:S("fileBrowser.unstageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:S("fileBrowser.workspace",{count:aC.status?.unstaged.length||0})}),(aC.status?.unstaged.length||0)>0&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:aC.handleDiscardAll,className:"text-sm text-red-11 hover:text-red-10 hover:underline",children:S("fileBrowser.discardAll")}),(0,e.jsx)("button",{onClick:aC.handleStageAll,className:"text-sm text-green-11 hover:text-green-10 hover:underline",children:S("fileBrowser.stageAll")})]})]}),(0,e.jsx)(p.VO,{files:aC.unstagedTree,selectedPath:aC.statusSelectedFile?.type==="unstaged"?aC.statusSelectedFile.file.path:null,expandedPaths:aC.unstagedExpandedPaths,onSelect:a=>a.file&&aC.handleStatusFileSelect(a.file,"unstaged"),onToggle:aC.handleUnstagedToggle,cwd:b,emptyMessage:S("fileBrowser.noUnstagedChanges"),className:"py-1",renderActions:a=>{if(a.isDirectory){let b=(0,p.wI)(a);if(0===b.length)return null;let c=b.map(a=>a.file).filter(Boolean);return(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),aC.handleDiscardFiles(c)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:S("fileBrowser.discardNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),aC.handleStageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:S("fileBrowser.stageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})}return a.file?(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),aC.handleDiscardFile(a.file)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:S("fileBrowser.discardChanges"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),aC.handleStage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:S("fileBrowser.stageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]}):null}})]})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"history"===U?"":"hidden"}`,children:aF.historyError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,e.jsx)("p",{className:"text-muted-foreground",children:aF.historyError})]})}):aF.compareMode?(0,e.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:aF.isLoadingCompareFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:S("fileBrowser.loadingDiff")}):0===aF.compareFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:S("fileBrowser.noDiffFiles")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"px-3 py-2 border-b border-border",children:(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:S("fileBrowser.nFilesChanged",{count:aF.compareFiles.length,branch:aF.compareBaseBranch})})}),(0,e.jsx)(p.VO,{files:aF.compareFileTree,expandedPaths:aF.compareExpandedPaths,onToggle:aF.handleCompareToggle,selectedPath:aF.compareSelectedFile?.path||null,onSelect:a=>{a.file&&aF.handleSelectCompareFile(a.file)},cwd:b,showChanges:!0})]})}):(0,e.jsx)("div",{ref:aF.commitListRef,className:"flex-1 overflow-y-auto",onScroll:aF.handleCommitListScroll,children:aF.isLoadingCommits?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:S("fileBrowser.loadingCommits")}):0===aF.commits.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:S("fileBrowser.noCommits")}):(0,e.jsxs)(e.Fragment,{children:[aF.commits.map(a=>(0,e.jsxs)("div",{onClick:()=>aF.handleSelectCommit(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-accent ${aF.selectedCommit?.hash===a.hash?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"font-mono text-xs text-brand",children:a.shortHash}),(0,e.jsxs)("span",{className:"text-xs text-slate-9",title:a.date,children:[a.relativeDate," \xb7 ",(0,t.r6)(a.date)]})]}),(0,e.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5","data-tooltip":a.subject,children:a.subject}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.author})]},a.hash)),aF.isLoadingMore&&(0,e.jsx)("div",{className:"p-3 text-center",children:(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),!aF.hasMoreCommits&&aF.commits.length>0&&(0,e.jsx)("div",{className:"p-3 text-center text-xs text-slate-9",children:S("fileBrowser.allLoaded",{count:aF.commits.length})})]})})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[("tree"===U||"search"===U||"recent"===U)&&(aA.blameSelectedCommit?(0,e.jsx)(l.n,{isOpen:!0,onClose:()=>aA.setBlameSelectedCommit(null),commit:aA.blameSelectedCommit,cwd:b,embedded:!0,initialFilePath:aA.selectedPath||void 0,onContentSearch:a=>{V("search"),aB.setContentSearchQuery(a),aB.performContentSearch(a)}}):"map"===W?(0,e.jsx)(y.O,{cwd:b,highlightedFilePath:aA.selectedPath,changedFiles:aD,onSwitchToCode:()=>X("code"),enableComments:!0,onContentSearch:a=>{V("search"),aB.setContentSearchQuery(a),aB.performContentSearch(a)},headerExtraLeft:({focalFile:a})=>a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${b}/${a}`),(0,n.oR)(S("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:S("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:b=>{b.stopPropagation(),a2(a)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:S("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]})}):aA.selectedPath?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex-shrink-0 flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground truncate",children:aA.selectedPath}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(`${b}/${aA.selectedPath}`),(0,n.oR)(S("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:S("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:a=>{a.stopPropagation(),a2(aA.selectedPath)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:S("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),(0,e.jsx)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:aA.showEditor?(0,e.jsxs)(e.Fragment,{children:[aj.isDirty&&(0,e.jsx)("span",{className:"text-xs text-amber-11",children:S("fileBrowser.unsaved")}),(0,e.jsx)("button",{onClick:()=>ai.current?.save(),disabled:!aj.isDirty||aj.isSaving,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aj.isDirty&&!aj.isSaving?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:aj.isSaving?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):S("common.save")}),(0,e.jsx)("button",{onClick:()=>ai.current?.close(),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:S("fileBrowser.closeEdit"),children:S("fileBrowser.closeBtn")})]}):(0,e.jsxs)(e.Fragment,{children:[aA.fileContent?.type==="text"&&aA.fileContent.content&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(aA.fileContent.content),(0,n.oR)(S("toast.copiedFileContent"))},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:S("fileBrowser.copyFileContent"),children:S("common.copy")}),aA.selectedPath?.endsWith(".json")&&aA.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:()=>ao(a=>!a),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${an?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,title:S("fileBrowser.toggleJsonReadable"),children:S("common.readable")}),aA.fileContent?.type==="text"&&(0,s.e$)(aA.selectedPath)&&(0,e.jsx)("button",{onClick:()=>aA.setShowMarkdownPreview(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:S("fileBrowser.previewMarkdown"),children:S("common.preview")}),aA.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:aA.handleToggleBlame,disabled:aA.isLoadingBlame,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aA.showBlame?"bg-brand text-white":"text-muted-foreground hover:bg-accent"} disabled:opacity-50`,title:S("fileBrowser.viewBlame"),children:aA.isLoadingBlame?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):"Blame"}),aA.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:()=>X("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:S("blockViewer.viewerToggle.toBlock"),children:S("common.codeMap")}),aA.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:()=>aA.setShowEditor(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:S("fileBrowser.editFile"),children:S("common.edit")})]})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:aA.isLoadingContent?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):aA.fileContent?"text"===aA.fileContent.type&&"string"==typeof aA.fileContent.content?aA.showBlame&&aA.blameError?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("p",{className:"text-red-11",children:aA.blameError}),(0,e.jsx)("button",{onClick:()=>aA.setShowBlame(!1),className:"mt-2 text-brand hover:underline text-sm",children:S("fileBrowser.backToPreview")})]})}):aA.showBlame&&0===aA.blameLines.length&&aA.isLoadingBlame?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):an&&aA.selectedPath?.endsWith(".json")?(0,e.jsxs)("div",{className:"h-full flex flex-col bg-[#0d1117]",children:[(0,e.jsx)(J._,{search:as}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,e.jsx)("pre",{ref:ar,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,s.xb)(aA.fileContent.content)})})]}):(0,e.jsx)(r.Cv,{ref:ai,content:aA.fileContent.content,filePath:aA.selectedPath,cwd:b,enableComments:!0,scrollToLine:ag??aA.targetLineNumber,scrollToLineAlign:null!=ag?"start":aA.targetScrollAlign,onScrollToLineComplete:()=>{ah(null),aA.setTargetLineNumber(null)},highlightKeyword:"search"===U?aB.contentSearchQuery:null,visibleLineRef:ae,viStateRef:af,initialCursorLine:aA.initialCursorLine,initialCursorCol:aA.initialCursorCol,onInitialCursorSet:()=>{aA.setInitialCursorLine(null),aA.setInitialCursorCol(null)},onCmdClick:aS?aT:void 0,onTokenHover:aS?aU:void 0,onTokenHoverLeave:aS?aw.onTokenMouseLeave:void 0,onTokenHoverCancel:aS?aw.clearHover:void 0,blameLines:aA.showBlame&&aA.blameLines.length>0?aA.blameLines:void 0,inlineBlameLines:aA.blameLines.length>0?aA.blameLines:void 0,onSelectCommit:aA.setBlameSelectedCommit,editable:aA.showEditor,initialMtime:aA.fileContent.mtime,onEditorClose:a=>{aA.setShowEditor(!1),ah(a)},onSaved:()=>{let a=ae.current??1;aA.loadFileContent(aA.selectedPath),aA.setShowEditor(!1),ah(a)},onEditorStateChange:ak,viMode:!0,onContentMutate:aH,onEnterInsertMode:aI,onViSave:aJ,onContentSearch:a=>{V("search"),aB.setContentSearchQuery(a),aB.performContentSearch(a)}}):"image"===aA.fileContent.type&&aA.selectedPath?(0,e.jsx)(B.I,{cwd:b,path:aA.selectedPath,refreshKey:aA.fileContent.mtime,alt:aA.selectedPath}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,e.jsx)("p",{children:aA.fileContent.message||S("fileBrowser.cannotPreview")})]})}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:S("fileBrowser.selectFileToPreview")})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,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,e.jsx)("p",{children:S("fileBrowser.selectFileToPreview")})]})})),"status"===U&&(aC.statusSelectedFile&&aC.statusDiff?(0,e.jsx)(z.m,{cwd:b,selected:aC.statusSelectedFile,diff:aC.statusDiff,showMarkdownPreview:aC.showStatusDiffPreview,setShowMarkdownPreview:aC.setShowStatusDiffPreview,changedFiles:aD,fileGitStatusMap:aE,onContentSearch:a=>{V("search"),aB.setContentSearchQuery(a),aB.performContentSearch(a)},locateInTree:a2,jsonPreview:ap,setJsonPreview:aq,jsonPreviewSearch:au,jsonPreviewPreRef:at}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:S("fileBrowser.selectFileToViewDiff")})})),"history"===U&&!aF.historyError&&(aF.compareMode?aF.isLoadingCompareDiff?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:S("fileBrowser.loadingDiffContent")}):aF.compareFileDiff?(0,e.jsx)(m.xZ,{oldContent:aF.compareFileDiff.oldContent,newContent:aF.compareFileDiff.newContent,filePath:aF.compareFileDiff.filePath,isNew:aF.compareFileDiff.isNew,isDeleted:aF.compareFileDiff.isDeleted,cwd:b,enableComments:!0,onPreview:!aF.compareFileDiff.isDeleted&&aF.compareFileDiff.filePath.endsWith(".json")?()=>aq({content:aF.compareFileDiff.newContent,filePath:aF.compareFileDiff.filePath}):void 0,previewLabel:S("common.readable"),onContentSearch:a=>{V("search"),aB.setContentSearchQuery(a),aB.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:aF.compareFiles.length>0?S("fileBrowser.selectFileToViewDiff"):S("fileBrowser.clickCompareToLoad")})}):aF.selectedCommit?(0,e.jsx)(l.n,{isOpen:!0,onClose:()=>aF.setSelectedCommit(null),commit:aF.selectedCommit,cwd:b,embedded:!0,onContentSearch:a=>{V("search"),aB.setContentSearchQuery(a),aB.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:S("fileBrowser.selectCommitToView")})}))]})]}),aA.showMarkdownPreview&&aA.fileContent?.type==="text"&&aA.selectedPath&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>aA.setShowMarkdownPreview(!1),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(u.M,{content:aA.fileContent.content||"",filePath:aA.selectedPath,cwd:b,onClose:()=>aA.setShowMarkdownPreview(!1)})})}),ac&&(0,e.jsx)(v.c,{files:aA.files,fileIndex:aA.fileIndex,recentFiles:aA.recentFilePaths,onSelectFile:a=>{aL(a),aA.setShouldScrollToSelected(!0),V("tree")},onClose:()=>ad(!1)}),(aR||ax.visible)&&(0,e.jsxs)("div",{className:`flex ${ax.visible&&aR?"":"flex-col"}`,children:[aR&&(0,e.jsx)("div",{className:ax.visible?"flex-1 min-w-0 border-r border-border":"",children:(0,e.jsx)(N.D,{results:aB.contentSearchResults,loading:aB.isSearching,totalMatches:aB.searchStats?.totalMatches??0,onSelect:(a,b)=>{aA.selectedPath&&ay.push({filePath:aA.selectedPath,lineNumber:ae.current}),aL(a,b)},onClose:()=>am(!1)})}),ax.visible&&(0,e.jsx)("div",{className:aR?"flex-1 min-w-0":"",children:(0,e.jsx)(M.D,{references:ax.references,loading:ax.loading,onSelect:aV,onClose:ax.closeReferences})})]})]}),aa&&(0,e.jsx)(h.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-black/50",onClick:()=>ab(null),children:(0,e.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground mb-2",children:S("fileBrowser.confirmDelete")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:S("fileBrowser.confirmDeleteMessage",{name:aa.name}).split(/<\/?file>/g).map((a,b)=>1===b?(0,e.jsx)("span",{className:"font-mono text-foreground",children:a},b):a)}),(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)("button",{onClick:()=>ab(null),className:"px-3 py-1.5 text-sm rounded border border-border hover:bg-accent transition-colors",children:S("common.cancel")}),(0,e.jsx)("button",{onClick:async()=>{let{path:a,name:c}=aa;ab(null);let d=await i.t4.runPromiseExit((0,j.VK)({cwd:b,path:a}));if("Success"===d._tag){(0,n.oR)(S("toast.movedToTrash",{name:c}),"success");let b=a.includes("/")?a.substring(0,a.lastIndexOf("/")):"";aA.loadDirectory(b),aA.loadFileIndex(),aA.selectedPath===a&&aL("")}else{let a="Fail"===d.cause._tag?d.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:S("toast.deleteFailed");(0,n.oR)(c,"error")}},className:"px-3 py-1.5 text-sm rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:S("common.delete")})]})]})})}),aw.hoverInfo&&$&&(0,g.createPortal)((0,e.jsx)(L.s,{ref:aw.setTooltipEl,displayString:aw.hoverInfo.displayString,documentation:aw.hoverInfo.documentation,x:aw.hoverInfo.x,y:aw.hoverInfo.y,container:$,onMouseEnter:aw.onCardMouseEnter,onMouseLeave:aw.onCardMouseLeave,onFindReferences:()=>{let{filePath:a,line:b,column:c}=aw.hoverInfo;aw.clearHover(),ax.findReferences(a,b,c)},onSearch:a=>{aw.clearHover(),V("search"),aB.setContentSearchQuery(a),aB.performContentSearch(a)}}),$)]})}[E,F,p,o,l,y,r,z,m,u,v,N,M]=P.then?(await P)():P,d()}catch(a){d(a)}})},70404:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484);function f(a,b){for(let c=0;c<a.blocks.length;c++){let d=a.blocks[c];if(b>=d.startLine&&b<=d.endLine)return a.prefix[c]+(b-d.startLine)}return null}function g({addedLines:a,blockRanges:b,viewportRange:c,onJumpToLine:h}){let i,j=(0,e.useRef)(null),k=(0,e.useMemo)(()=>(function(a){let b=[...a].sort((a,b)=>a.startLine-b.startLine),c=[0];for(let a of b){let b=Math.max(0,a.endLine-a.startLine+1);c.push(c[c.length-1]+b)}return{blocks:b,prefix:c,total:c[c.length-1]}})(b),[b]),l=(0,e.useMemo)(()=>{if(k.total<=0||0===a.size)return[];let b=[];for(let c of a){let a=k.blocks.find(a=>c>=a.startLine&&c<=a.endLine);a&&b.push({line:c,qname:a.qname})}b.sort((a,b)=>a.line-b.line);let c=[],d=null;for(let a of b)d&&a.line===d.end+1&&a.qname===d.qname?d.end=a.line:(d&&c.push(d),d={start:a.line,end:a.line,qname:a.qname});return d&&c.push(d),c},[a,k]);if(k.total<=0)return null;let m=(a,b)=>{let c=f(k,a),d=f(k,b);return null===c||null===d?null:{top:c/k.total*100,heightPct:(d-c+1)/k.total*100}};return(0,d.jsxs)("div",{ref:j,onClick:a=>{let b=j.current;if(!b)return;let c=b.getBoundingClientRect();if(c.height<=0)return;let d=function(a,b){if(a.total<=0)return null;let c=Math.max(0,Math.min(a.total-1,b));for(let b=0;b<a.blocks.length;b++){let d=a.prefix[b],e=a.prefix[b+1];if(c>=d&&c<e){let e=a.blocks[b];return{qname:e.qname,line:e.startLine+Math.round(c-d)}}}return null}(k,(a.clientY-c.top)/c.height*k.total);if(!d)return;let e=d.line,g=l.find(a=>a.qname===d.qname&&e>=a.start&&e<=a.end);if(g)return void h(g.qname,e);if(l.length>0){let a=Math.max(2,Math.round(.05*k.total)),b=f(k,e);if(null!==b){let c=null,d=1/0;for(let a of l){let e=f(k,a.start),g=f(k,a.end);if(null===e||null===g)continue;let h=b<e?e-b:b>g?b-g:0;h<d&&(c=a,d=h)}if(c&&d<=a){let a=e<c.start?c.start:e>c.end?c.end:e;h(c.qname,a);return}}}let i=k.blocks.find(a=>a.qname===d.qname);i&&h(i.qname,i.startLine)},className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",title:"Diff minimap — click to jump",children:[l.map(a=>{let b=m(a.start,a.end);return b?(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-green-9 pointer-events-none",style:{top:`${b.top}%`,height:`${b.heightPct}%`,minHeight:"2px"}},`run:${a.qname}:${a.start}-${a.end}`):null}),c&&c.end>=c.start&&((i=m(c.start,c.end))?(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border pointer-events-none",style:{top:`${i.top}%`,height:`${Math.max(1.2,i.heightPct)}%`}}):null)]})}},70440:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(88868);let e=async a=>[{type:"image/x-icon",sizes:"16x16",url:(0,d.fillMetadataSegment)(".",await a.params,"favicon.ico",!0)+"?603d046c9a6fdfbb"}]},70596:(a,b,c)=>{"use strict";c.d(b,{t:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({x:a,y:b,comment:c,container:h,onClose:i,onUpdateComment:j,onDeleteComment:k}){let{t:l}=(0,f.Bd)(),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(c.content),q=(0,e.useRef)(null),[r,s]=(0,e.useState)({x:0,y:0}),t=async()=>{o.trim()&&(await j(c.id,o.trim()),n(!1))},u=async()=>{await k(c.id),i()};return(0,d.jsx)("div",{ref:q,className:"absolute z-[200] w-96 bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:r.x,top:r.y},children:(0,d.jsx)("div",{className:"p-3",children:m?(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("textarea",{value:o,onChange:a=>p(a.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:a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),t()),"Escape"===a.key&&(n(!1),p(c.content))}}),(0,d.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,d.jsx)("button",{onClick:()=>{n(!1),p(c.content)},className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground",children:l("common.cancel")}),(0,d.jsx)("button",{onClick:t,className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90",children:l("common.save")})]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:c.content}),(0,d.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:l("comments.lineRange",{start:c.startLine,end:c.endLine})}),(0,d.jsxs)("div",{className:"flex gap-1",children:[(0,d.jsx)("button",{onClick:()=>n(!0),className:"p-1 rounded hover:bg-accent text-muted-foreground",title:l("common.edit"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:u,className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-red-9",title:l("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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"})})})]})]})]})})})}},71192:(a,b,c)=>{"use strict";c.d(b,{m_:()=>f,uV:()=>e});var d=c(81218);class e extends d.rN("AppError"){}d.rN("DBError"),d.rN("WSError"),d.rN("FSError"),d.rN("AgentError"),d.rN("ValidationError");class f extends d.rN("NotFoundError"){}d.rN("PermissionError")},72399:(a,b,c)=>{"use strict";c.d(b,{ProjectSidebar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectSidebar() from the server but ProjectSidebar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/ProjectSidebar.tsx","ProjectSidebar")},72529:(a,b,c)=>{"use strict";c.d(b,{m:()=>f});var d=c(48249),e=c(67484);function f({content:a,children:b,className:c}){if(c)return(0,d.jsx)("div",{"data-tooltip":a,className:c,children:b});let g=e.Children.toArray(b);if(1===g.length&&(0,e.isValidElement)(g[0])){let b=g[0];return(0,e.cloneElement)(b,{"data-tooltip":a})}return(0,d.jsx)("div",{"data-tooltip":a,style:{display:"contents"},children:b})}},73414:(a,b,c)=>{"use strict";c.d(b,{YO:()=>d,pU:()=>e});let d=20;function e(a,b,c,f=[]){let g=a.length,h=c=>"unchanged"!==a[c].type||"unchanged"!==b[c].type,i=new Set;for(let a=0;a<g;a++){if(!h(a))continue;let b=Math.max(0,a-3),c=Math.min(g-1,a+3);for(let a=b;a<=c;a++)i.add(a)}let j=[];for(let a=0;a<g;a++){if(i.has(a))continue;let b=a;for(;a<g&&!i.has(a);)a++;j.push({id:j.length,startIdx:b,endIdx:a-1}),a--}for(let a of j){let b=c.get(a.id)??{topRevealed:0,bottomRevealed:0},d=a.endIdx-a.startIdx+1,e=Math.max(0,Math.min(b.topRevealed,d)),f=Math.max(0,Math.min(b.bottomRevealed,d-e));for(let b=a.startIdx;b<a.startIdx+e;b++)i.add(b);for(let b=a.endIdx-f+1;b<=a.endIdx;b++)i.add(b)}let k=[];for(let a=0;a<g;a++){let c;if(i.has(a)){k.push({kind:"diff",idx:a});continue}let e=a;for(;a<g&&!i.has(a);)a++;let h=a-1;a--;let l=j.find(a=>a.startIdx<=e&&h<=a.endIdx);if(!l)continue;let m=h-e+1,n=Math.min(d,m);if(f.length>0&&h+1<g)for(let a=h+1;a<g;a++){let d=b[a].lineNum;if(!(d<=0)){c=function(a,b){let c=null;for(let d of a)d.startLine<=b&&b<=d.endLine&&(!c||d.endLine-d.startLine<c.endLine-c.startLine)&&(c=d);return c}(f,d)??void 0;break}}k.push({kind:"gap-expand",gapId:l.id,direction:"up",revealCount:n}),k.push({kind:"gap-label",gapId:l.id,hiddenCount:m,enclosingFn:c}),k.push({kind:"gap-expand",gapId:l.id,direction:"down",revealCount:n})}return{rows:k,gaps:j}}},73887:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>v});var e=c(48249),f=c(67484),g=c(44384),h=c(74429),i=c(7122),j=c(41051),k=c(42140),l=c(70596),m=c(74754),n=c(7031),o=c(91579),p=c(87844),q=c(84835),r=c(24680),s=c(25465),t=c(37690),u=a([s]);s=(u.then?(await u)():u)[0];let w=[q.W];function v({content:a,filePath:b,cwd:c,onClose:d,sourceFile:q}){let u=q||(c&&b.startsWith(c)?b.slice(c.endsWith("/")?c.length:c.length+1):b),{t:x}=(0,g.Bd)(),y=(0,i.iN)(),z=(0,n.r)(),{comments:A,addComment:B,updateComment:C,deleteComment:D,refresh:E}=(0,m._)({cwd:c,filePath:b}),[F,G]=(0,f.useState)(!1),[H,I]=(0,f.useState)(null),[J,K]=(0,f.useState)(null),[L,M]=(0,f.useState)(null),N=(0,f.useMemo)(()=>a.split("\n"),[a]),[O,P]=(0,f.useState)(null),Q=(0,f.useRef)(null),{toolbarRef:R,bumpRef:S,clearToolbar:T}=(0,t.L)({enabled:!0,container:O,resolveLineRange:a=>{let b=function(a){let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a;if(!b||!("closest"in b))return null;let c=b.closest("[data-source-start]");if(!c)return null;let d=c.getAttribute("data-source-start"),e=c.getAttribute("data-source-end");return d&&e?{start:parseInt(d,10),end:parseInt(e,10)}:null}(a);return b?{start:b.start,end:b.end}:null},buildLineSnapshot:({start:a,end:b})=>{let c=Math.max(0,a-1),d=Math.min(N.length,b);return N.slice(c,d).join("\n")}}),U=(0,f.useCallback)(()=>{let a=R.current;a&&(I({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),T())},[T,R]),V=(0,f.useCallback)(()=>{let a=R.current;a&&(K({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),T())},[T,R]),W=(0,f.useCallback)(async a=>{H&&(await B(H.range.start,H.range.end,a,H.selectedText),I(null))},[H,B]),X=(0,f.useCallback)(async a=>{if(J&&z)try{let d=await (0,o.$3)(c),e=[];for(let a of d)e.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});e.push({filePath:b,startLine:J.range.start,endLine:J.range.end,codeContent:J.lineSnapshot});let f=(0,o.Gw)(e,a);z.sendMessage(f),await (0,o.RP)(c),E(),K(null)}catch(a){console.error("Failed to send to AI:",a)}},[J,z,b,c,E]);(0,f.useMemo)(()=>{if(0===A.length)return[];let a=new Map;for(let b of A){let c=`${b.startLine}-${b.endLine}`;a.has(c)||a.set(c,[]),a.get(c).push(b)}return Array.from(a.entries()).map(([a,b])=>({key:a,startLine:b[0].startLine,endLine:b[0].endLine,comments:b}))},[A]);let[Y,Z]=(0,f.useState)([]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:b}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(s.ShareReviewToggle,{content:a,sourceFile:u}),(0,e.jsx)("button",{onClick:d,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:x("common.close"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsx)(r.l,{content:a,containerRef:Q}),(0,e.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:Q,children:[(0,e.jsx)("div",{className:"p-6",children:(0,e.jsx)(p.T,{content:a,rehypePlugins:w})}),Y.map(({key:a,top:b,comments:c})=>(0,e.jsx)("div",{className:"absolute right-3 cursor-pointer z-10",style:{top:b},onClick:a=>{a.stopPropagation(),M({comment:c[0],x:a.clientX,y:a.clientY})},children:(0,e.jsx)("div",{className:"w-5 h-5 rounded-full bg-amber-500/80 text-white text-xs flex items-center justify-center shadow-sm hover:bg-amber-500 transition-colors",children:c.length})},a))]})]}),F&&y&&(0,h.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(j.f,{floatingToolbarRef:R,bumpRef:S,container:y,onAddComment:U,onSendToAI:V,isChatLoading:z?.isLoading}),H&&(0,e.jsx)(k.t,{x:H.x,y:H.y,range:H.range,lineSnapshot:H.lineSnapshot,container:y,onSubmit:W,onClose:()=>I(null)}),J&&(0,e.jsx)(k.G,{x:J.x,y:J.y,range:J.range,filePath:b,lineSnapshot:J.lineSnapshot,container:y,onSubmit:X,onClose:()=>K(null),isChatLoading:z?.isLoading}),L&&(0,e.jsx)(l.t,{x:L.x,y:L.y,comment:L.comment,container:y,onClose:()=>M(null),onUpdateComment:C,onDeleteComment:D})]}),y)]})}d()}catch(a){d(a)}})},74493:(a,b,c)=>{"use strict";c.d(b,{Ey:()=>n,GW:()=>m,HS:()=>o,Hj:()=>i,ax:()=>h,qM:()=>j});var d=c(79606),e=c(33281),f=c(71192);let g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:b=>new f.uV({message:`POST ${a} failed`,cause:b})}),h=(a,b)=>e.t4.runPromise(g(`/api/${a}/disconnect`,{id:b}).pipe(d.orElse(()=>d.void))),i=a=>e.t4.runPromise(g("/api/jupyter/shutdown",{bubbleId:a}).pipe(d.orElse(()=>d.void))),j=a=>e.t4.runPromise(g("/api/browser/unregister",{id:a}).pipe(d.orElse(()=>d.void))),k=a=>e.t4.runPromise(a.pipe(d.catchAll(a=>d.sync(()=>{if(a.cause instanceof Error)throw a.cause;throw Error(a.message)})))),l=(a,b)=>{if(a&&"object"==typeof a&&"error"in a){let b=a.error;if("string"==typeof b&&b.length>0)return b;if(b&&"object"==typeof b){let a=b.message;if("string"==typeof a&&a.length>0)return a;let c=b._tag;if("string"==typeof c&&c.length>0)return c}}return`HTTP ${b}`},m=(a,b)=>k(d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),d=await c.json();if(!c.ok)throw Error(l(d,c.status));return d},catch:b=>new f.uV({message:`POST ${a} failed`,cause:b})})),n=(a,b)=>k(d.tryPromise({try:async()=>{let c=new URLSearchParams(b),d=await fetch(`${a}?${c}`),e=await d.json();if(!d.ok)throw Error(l(e,d.status));return e},catch:b=>new f.uV({message:`GET ${a} failed`,cause:b})})),o=(a,b)=>k(d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`);return c.blob()},catch:b=>new f.uV({message:`POST blob ${a} failed`,cause:b})}))},74542:(a,b,c)=>{"use strict";c.d(b,{b:()=>f});var d=c(48249),e=c(67484);function f({lines:a,containerRef:b}){let c=(0,e.useRef)(null),[g,h]=(0,e.useState)({top:0,height:0});if(0===a.length)return null;let i=100/a.length;return(0,d.jsxs)("div",{ref:c,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:a=>{let d=b.current,e=c.current;if(!d||!e)return;let f=e.getBoundingClientRect(),g=(a.clientY-f.top)/f.height*d.scrollHeight-d.clientHeight/2;d.scrollTo({top:Math.max(0,g),behavior:"smooth"})},children:[a.map((a,b)=>"unchanged"!==a.type&&(0,d.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===a.type?"bg-red-9":"bg-green-9"}`,style:{top:`${b*i}%`,height:`${Math.max(i,.5)}%`,minHeight:"2px"}},b)),(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border",style:{top:`${g.top}px`,height:`${Math.max(g.height,10)}px`}})]})}},74754:(a,b,c)=>{"use strict";c.d(b,{_:()=>g});var d=c(67484);c(91579);var e=c(33281),f=c(89800);function g({cwd:a,filePath:b}){let[c,h]=(0,d.useState)([]),[i,j]=(0,d.useState)(!1),[k,l]=(0,d.useState)(null),m=(0,d.useCallback)(async()=>{if(!a||!b)return;j(!0),l(null);let c=await e.t4.runPromiseExit((0,f.lb)(a,b));if("Success"===c._tag)h(c.value.comments??[]);else{let a="Fail"===c.cause._tag?c.cause.error:null,b=a?.cause;l(b instanceof Error?b.message:"Failed to load comments")}j(!1)},[a,b]),n=(0,d.useCallback)(async(c,d,g,i)=>{let j=await e.t4.runPromiseExit((0,f.BC)({cwd:a,filePath:b,startLine:c,endLine:d,content:g,...i?{selectedText:i}:{}}));if("Success"===j._tag&&j.value.comment){let a=j.value.comment;return h(b=>[...b,a]),a}return"Failure"===j._tag&&console.error("Failed to add comment:",j.cause),null},[a,b]),o=(0,d.useCallback)(async(b,c)=>{let d=await e.t4.runPromiseExit((0,f.vv)(a,b,c));if("Success"===d._tag&&d.value.comment){let a=d.value.comment;return h(c=>c.map(c=>c.id===b?a:c)),!0}return"Failure"===d._tag&&console.error("Failed to update comment:",d.cause),!1},[a]),p=(0,d.useCallback)(async b=>{let c=await e.t4.runPromiseExit((0,f.Tu)(a,b));return"Success"===c._tag?(h(a=>a.filter(a=>a.id!==b)),!0):(console.error("Failed to delete comment:",c.cause),!1)},[a]),q=(0,d.useCallback)(a=>c.filter(b=>a>=b.startLine&&a<=b.endLine),[c]);return{comments:c,isLoading:i,error:k,addComment:n,updateComment:o,deleteComment:p,refresh:m,getCommentsForLine:q}}},74837:(a,b,c)=>{"use strict";c.d(b,{NoteToolbar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call NoteToolbar() from the server but NoteToolbar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/NoteToolbar.tsx","NoteToolbar")},74991:(a,b,c)=>{"use strict";c.d(b,{I:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(30458);function h(a,b){if("once"===a.type)return b("scheduledTasks.onceType",{minutes:a.delayMinutes});if("interval"===a.type){let c=b("scheduledTasks.everyNMinutes",{minutes:a.intervalMinutes});return a.activeFrom&&a.activeTo?`${c} (${a.activeFrom}-${a.activeTo})`:c}return"cron"===a.type?a.cron||"cron":a.type}function i(a){return a.unread?"bg-red-500":a.completed?"bg-muted-foreground":a.paused?"bg-yellow-500":"error"===a.lastResult?"bg-red-500":"bg-green-500"}function j({collapsed:a,tasks:b,unreadCount:c,onSwitchProject:k,onPause:l,onResume:m,onTrigger:n,onDelete:o,onMarkRead:p,onUpdateTask:q,onReorder:r}){let{t:s}=(0,f.Bd)(),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(null),x=(0,e.useRef)(null),y=b.filter(a=>!a.completed),z=y.filter(a=>!a.paused).length,A=b.filter(a=>a.completed),[B,C]=(0,e.useState)(null),[D,E]=(0,e.useState)(null),F=(0,e.useCallback)(a=>{C(a)},[]),G=(0,e.useCallback)((a,b)=>{a.preventDefault(),E(b)},[]),H=(0,e.useCallback)(a=>{if(null===B||B===a){C(null),E(null);return}let b=[...y],[c]=b.splice(B,1);b.splice(a,0,c),r([...b,...A].map(a=>a.id)),C(null),E(null)},[B,y,A,r]),I=(0,e.useCallback)(()=>{C(null),E(null)},[]),[,J]=(0,e.useState)(0);return(0,d.jsxs)("div",{className:"relative",ref:x,children:[(0,d.jsxs)("button",{onClick:()=>u(!t),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${a?"w-full justify-center":"w-full"}`,title:s("scheduledTasks.title"),children:[(0,d.jsxs)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]}),!a&&(0,d.jsx)("span",{className:"text-sm flex-1 text-left",children:s("scheduledTasks.title")}),c>0?(0,d.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-white text-xs font-medium rounded-full flex items-center justify-center bg-red-500 ${a?"absolute -top-1 -right-1":""}`,children:c}):a&&b.length>0?(0,d.jsx)("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 text-muted-foreground text-xs font-medium rounded-full flex items-center justify-center bg-accent",children:b.length}):null]}),t&&(0,d.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-96 max-h-[500px] bg-popover border border-border rounded-lg shadow-lg z-50 flex flex-col",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm font-medium",children:s("scheduledTasks.title")}),y.length>0&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:[s("scheduledTasks.activeCount",{running:z}),y.length-z>0?` \xb7 ${s("scheduledTasks.pausedCount",{paused:y.length-z})}`:""]})]}),(0,d.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===b.length?(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:s("scheduledTasks.noScheduledTasks")}):(0,d.jsxs)(d.Fragment,{children:[y.map((a,b)=>{var c;return(0,d.jsx)("div",{draggable:!0,onDragStart:()=>F(b),onDragOver:a=>G(a,b),onDrop:()=>H(b),onDragEnd:I,className:`group px-3 py-2 hover:bg-accent transition-colors border-b border-border/50 cursor-pointer ${a.unread?"bg-brand/5":""} ${B===b?"opacity-50":""} ${D===b?"border-t-2 border-brand":""}`,onClick:()=>{k(a.cwd,a.sessionId),a.unread&&p(a.id),u(!1)},children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${i(a)}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:(c=a.cwd).split("/").pop()||c}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"\xb7"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:a.completed?s("scheduledTasks.completed"):a.paused?s("scheduledTasks.paused"):s("common.running")})]}),(0,d.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5",title:a.message,children:a.message}),(0,d.jsxs)("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{children:h(a,s)}),(0,d.jsx)("span",{children:"\xb7"}),(0,d.jsx)("span",{children:a.paused?s("scheduledTasks.paused"):function(a,b){if(!a)return"-";let c=a-Date.now();if(c<=0)return b("scheduledTasks.aboutToTrigger");if(c<6e4)return b("scheduledTasks.secondsLater",{count:Math.ceil(c/1e3)});if(c<36e5)return b("scheduledTasks.minutesLater",{count:Math.ceil(c/6e4)});if(c<864e5){let a=Math.floor(c/36e5),d=Math.ceil(c%36e5/6e4);return d>0?b("scheduledTasks.hoursMinutesLater",{h:a,m:d}):b("scheduledTasks.hoursLater",{h:a})}return new Date(a).toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(a.nextFireTime,s)}),a.lastFiredAt&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{children:"\xb7"}),(0,d.jsxs)("span",{children:[s("scheduledTasks.lastResult"),": ","success"===a.lastResult?"✓":"✗"]})]})]})]}),(0,d.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),n(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-brand",title:s("scheduledTasks.runNow"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{d:"M8 5v14l11-7z"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),w(a)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:s("common.edit"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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"})})}),a.paused?(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),m(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-green-500",title:s("scheduledTasks.resume"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"})})}):(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),l(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-yellow-500",title:s("scheduledTasks.pause"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 9v6m4-6v6"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),o(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:s("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})},a.id)}),A.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-muted/30 border-b border-border/50",children:s("scheduledTasks.completedCount",{count:A.length})}),A.map(a=>(0,d.jsx)("div",{className:"group px-3 py-2 hover:bg-accent transition-colors border-b border-border/50 opacity-60 cursor-pointer",onClick:()=>{k(a.cwd,a.sessionId),u(!1)},children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${i(a)}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-sm text-foreground truncate",children:a.message}),(0,d.jsxs)("div",{className:"text-xs text-muted-foreground mt-0.5",children:[h(a,s)," \xb7 ","success"===a.lastResult?s("scheduledTasks.success"):s("scheduledTasks.failure")]})]}),(0,d.jsx)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),o(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:s("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})})]})},a.id))]})]})})]}),v&&(0,d.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/30",onClick:()=>w(null)}),(0,d.jsx)("div",{className:"relative",children:(0,d.jsx)(g.E,{onClose:()=>w(null),onCreate:()=>{},editTask:{id:v.id,message:v.message,type:v.type,delayMinutes:v.delayMinutes,intervalMinutes:v.intervalMinutes,activeFrom:v.activeFrom,activeTo:v.activeTo,cron:v.cron},onUpdate:(a,b)=>{q(a,b),w(null)}})})]})]})}},75513:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{k_:()=>h,nH:()=>i});var e=c(48249),f=c(67484),g=c(7031);let a=(0,f.createContext)(null);function h({children:b}){let c=(0,f.useRef)(new Map),d=(0,f.useRef)(null),[i,j]=(0,f.useState)(!1),k=(0,f.useCallback)((a,b)=>{c.current.set(b,a)},[]),l=(0,f.useCallback)(a=>{c.current.delete(a)},[]),m=(0,f.useCallback)(a=>{d.current=a},[]),n=(0,f.useCallback)(a=>{let b=d.current;if(!b)return void console.warn("No active tab to send message");let e=c.current.get(b);e?e(a):console.warn(`No chat sender registered for tab ${b}`)},[]),o=(0,f.useMemo)(()=>({sendMessage:n,isLoading:i,registerChat:k,unregisterChat:l,setActiveTab:m,setIsLoading:j}),[n,i,k,l,m]),p=(0,f.useMemo)(()=>({sendMessage:n,isLoading:i}),[n,i]);return(0,e.jsx)(a.Provider,{value:o,children:(0,e.jsx)(g.H,{value:p,children:b})})}function i(){return(0,f.useContext)(a)}d()}catch(a){d(a)}})},76334:(a,b,c)=>{"use strict";function d(a){let b=function(a){let b=0xffffffff;for(let c=0;c<a.length;c++){b^=a.charCodeAt(c);for(let a=0;a<8;a++)b=b>>>1^(1&b?0xedb88320:0)}return(0xffffffff^b)>>>0}(a),c="",d=b;for(let a=0;a<4;a++)c+=String.fromCharCode(97+d%26),d=Math.floor(d/26);return c}c.d(b,{p:()=>d})},76537:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>n,metadata:()=>l,viewport:()=>m});var d=c(5735),e=c(45864),f=c.n(e),g=c(87764),h=c.n(g),i=c(76055),j=c.n(i);c(61135);var k=c(25702);let l={title:"Cockpit",description:"Cockpit is a local-first AI development hub with chat agents, a file explorer, terminals, and browser bubbles in one swipeable workspace. One seat. One AI.",manifest:"/manifest.json",appleWebApp:{capable:!0,statusBarStyle:"default",title:"Cockpit"},icons:{icon:"/icons/icon-192x192.png",apple:"/icons/icon-192x192.png"}},m={themeColor:[{media:"(prefers-color-scheme: light)",color:"#f9f9fb"},{media:"(prefers-color-scheme: dark)",color:"#111113"}]};function n({children:a}){return(0,d.jsxs)("html",{lang:"en",suppressHydrationWarning:!0,className:"overflow-hidden",children:[(0,d.jsx)("head",{children:(0,d.jsx)("script",{src:"/boot.js"})}),(0,d.jsx)("body",{className:`${f().variable} ${h().variable} ${j().variable} antialiased overflow-hidden`,children:(0,d.jsx)(k.Providers,{children:a})})]})}},76552:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Providers:()=>j});var e=c(48249),f=c(29491),g=c(83768),h=c(7833),i=c(34102);function j({children:a}){return(0,e.jsx)(f.I18nProvider,{children:(0,e.jsx)(g.N,{children:(0,e.jsxs)(h.tE,{children:[a,(0,e.jsx)(i.B,{})]})})})}d()}catch(a){d(a)}})},76855:(a,b,c)=>{"use strict";c.d(b,{Sn:()=>i,Xm:()=>j,po:()=>k,JL:()=>l});var d=c(67484);c(28797);var e=c(79606),f=c(33281),g=c(71192);let h=(a,b)=>e.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:b=>new g.uV({message:`${a} failed`,cause:b})});function i(a){let[b,c]=(0,d.useState)(!1);return{goToDefinition:(0,d.useCallback)(async(b,d,e)=>{c(!0);let g=await f.t4.runPromiseExit(h("/api/lsp/definition",{cwd:a,filePath:b,line:d,column:e}));return(c(!1),"Success"===g._tag)?g.value.definitions??[]:(console.error("[useLSP] definition error:",g.cause),[])},[a]),loading:b}}function j(a){let[b,c]=(0,d.useState)(null),e=(0,d.useRef)(null),g=(0,d.useRef)(null),i=(0,d.useRef)(0),j=(0,d.useRef)(!1),k=(0,d.useRef)(null),l=(0,d.useRef)({x:0,y:0}),m=(0,d.useCallback)(a=>{k.current=a},[]),n=(0,d.useRef)(!1),o=(0,d.useRef)(null),p=(0,d.useCallback)(()=>{let a=k.current;a&&n.current&&(a.style.pointerEvents="none"),n.current=!1,o.current&&(k.current?.removeEventListener("mouseleave",o.current),o.current=null)},[]),q=(0,d.useCallback)(()=>{let a=k.current;if(!a||n.current)return;n.current=!0,j.current=!0,a.style.pointerEvents="auto";let b=()=>{j.current=!1,p(),i.current++,c(null)};o.current=b,a.addEventListener("mouseleave",b)},[p]),r=(0,d.useCallback)((b,d,j,k)=>{e.current&&clearTimeout(e.current),g.current&&clearTimeout(g.current);let l=++i.current;e.current=setTimeout(async()=>{let e=await f.t4.runPromiseExit(h("/api/lsp/hover",{cwd:a,filePath:b,line:d,column:j}));if(l!==i.current||"Success"!==e._tag)return;let g=e.value.hover;g&&g.displayString&&c({...g,x:k.x,y:k.y,filePath:b,line:d,column:j})},300)},[a]),s=(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),i.current++,g.current=setTimeout(function(){if(j.current)return;let a=k.current;if(a){let b=a.getBoundingClientRect(),{x:c,y:d}=l.current;if(c>=b.left&&c<=b.right&&d>=b.top&&d<=b.bottom)return void q()}c(null)},150)},[q]),t=(0,d.useCallback)(()=>{j.current=!0,g.current&&clearTimeout(g.current)},[]);return{hoverInfo:b,onTokenMouseEnter:r,onTokenMouseLeave:s,onCardMouseEnter:t,onCardMouseLeave:(0,d.useCallback)(()=>{j.current=!1,i.current++,c(null)},[]),clearHover:(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),g.current&&clearTimeout(g.current),j.current=!1,p(),i.current++,c(null)},[p]),setTooltipEl:m}}function k(a){let[b,c]=(0,d.useState)([]),[e,g]=(0,d.useState)(!1),[i,j]=(0,d.useState)(!1);return{references:b,loading:e,visible:i,findReferences:(0,d.useCallback)(async(b,d,e)=>{g(!0),j(!0);let i=await f.t4.runPromiseExit(h("/api/lsp/references",{cwd:a,filePath:b,line:d,column:e}));"Success"===i._tag?c(i.value.references??[]):(console.error("[useLSP] references error:",i.cause),c([])),g(!1)},[a]),closeReferences:(0,d.useCallback)(()=>{j(!1),c([])},[])}}function l(a,b){(0,d.useRef)(null)}},77016:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{b:()=>s});var e=c(48249),f=c(67484),g=c(44256),h=c(36295),i=c(7833),j=c(28602),k=c(44384),l=c(74493),m=a([h]);h=(m.then?(await m)():m)[0];let x=[{value:"=",label:"="},{value:"!=",label:"!="},{value:">",label:">"},{value:"<",label:"<"},{value:">=",label:">="},{value:"<=",label:"<="},{value:"LIKE",label:"LIKE"},{value:"NOT LIKE",label:"NOT LIKE"},{value:"IN",label:"IN"},{value:"IS NULL",label:"IS NULL"},{value:"IS NOT NULL",label:"IS NOT NULL"}];function n(a){if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`}function o(a){return`\`${a.replace(/`/g,"``")}\``}function p(a){try{let b=a.match(/\/\/[^/]+\/([^?]+)/);if(b)return b[1]}catch{}return""}function q(a){return null==a?"":"object"==typeof a?JSON.stringify(a):String(a)}function r({text:a}){let[b,c]=(0,f.useState)(!1),[d,h]=(0,f.useState)({x:0,y:0,maxW:600,maxH:300,above:!0}),i=(0,f.useRef)(null),j=(0,f.useRef)(null),k=(0,f.useRef)(!1),l=(0,g.F2)(),m=(0,f.useCallback)(()=>{j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{k.current||c(!1)},80)},[]),n=(0,f.useCallback)(()=>{j.current&&clearTimeout(j.current),k.current=!1,j.current=setTimeout(()=>{let a=i.current;if(!a||a.scrollWidth<=a.clientWidth)return;let b=a.getBoundingClientRect(),d=l?.getBoundingClientRect(),e=d?.left??0,f=d?.top??0,g=d?.width??window.innerWidth,j=d?.height??window.innerHeight,k=b.left-e,m=b.top-f,n=b.bottom-f,o=Math.min(600,g-k-8),p=o<200?Math.max(8,g-600-8):k,q=o<200?Math.min(600,g-16):o,r=m-8,s=j-n-8,t=r>s&&r>80,u=t?r-4:s-4;h({x:p,y:t?m-4:n+4,maxW:q,maxH:Math.max(60,u),above:t}),c(!0)},350)},[l]),o=(0,f.useCallback)(()=>{m()},[m]),p=(0,f.useCallback)(()=>{k.current=!0,j.current&&clearTimeout(j.current)},[]),q=(0,f.useCallback)(()=>{k.current=!1,m()},[m]);return(0,e.jsxs)("span",{ref:i,className:"block truncate",onMouseEnter:n,onMouseLeave:o,children:[a,b&&(0,e.jsx)(g.ZL,{children:(0,e.jsx)("div",{className:"fixed z-[9999] overflow-y-auto px-2 py-1.5 text-xs font-mono bg-popover text-popover-foreground border border-border rounded shadow-lg whitespace-pre-wrap break-all select-text cursor-text",style:{left:d.x,top:d.y,maxWidth:d.maxW,maxHeight:d.maxH,transform:d.above?"translateY(-100%)":void 0},onMouseEnter:p,onMouseLeave:q,children:function(a){try{let b=JSON.parse(a);if("object"==typeof b&&null!==b)return JSON.stringify(b,null,2)}catch{}return a}(a)})})]})}function s({id:a,connectionString:b,displayName:c,selected:d,maximized:g,expandedHeight:m,bubbleContentHeight:u,onSelect:x,onClose:y,onToggleMaximize:z,timestamp:A,onTitleMouseDown:B}){let{t:C}=(0,k.Bd)(),{showToast:D}=(0,i.dj)(),[E,F]=(0,f.useState)("connecting"),[G,H]=(0,f.useState)(""),[I,J]=(0,f.useState)([]),[K,L]=(0,f.useState)(()=>p(b)),[M,N]=(0,f.useState)([]),[O,P]=(0,f.useState)(null),[Q,R]=(0,f.useState)("table"),[S,T]=(0,f.useState)("data"),[U,V]=(0,f.useState)([]),[W,X]=(0,f.useState)([]),[Y,Z]=(0,f.useState)([]),[$,_]=(0,f.useState)([]),[aa,ab]=(0,f.useState)(null),[ac,ad]=(0,f.useState)(0),[ae,af]=(0,f.useState)(!1),[ag,ah]=(0,f.useState)(0),[ai,aj]=(0,f.useState)(new Set),[ak,al]=(0,f.useState)(!1),[am,an]=(0,f.useState)(null),[ao,ap]=(0,f.useState)({}),[aq,ar]=(0,f.useState)(!1),[as,at]=(0,f.useState)({}),[au,av]=(0,f.useState)({}),[aw,ax]=(0,f.useState)(null),[ay,az]=(0,f.useState)(""),[aA,aB]=(0,f.useState)(null),[aC,aD]=(0,f.useState)(""),[aE,aF]=(0,f.useState)(!1),aG=(0,f.useRef)(null),aH=(0,f.useCallback)(async()=>{F("connecting"),H("");try{let c=await (0,l.GW)("/api/mysql/connect",{id:a,connectionString:b});J(c.schemas||[]);let d=p(b);c.schemas?.length>0&&d&&c.schemas.includes(d)?L(d):c.schemas?.length>0&&L(c.schemas[0]),F("connected")}catch(a){H(a instanceof Error?a.message:String(a)),F("error")}},[a,b]),aI=(0,f.useCallback)(async()=>{if("connected"===E)try{let c=await (0,l.Ey)("/api/mysql/schemas",{id:a,connectionString:b,schema:K});N(c.tables||[])}catch{}},[a,b,K,E]),aJ=(0,f.useCallback)(async(c,d,e,f)=>{af(!0);let g=e??au,h=void 0!==f?f:aw;try{let e=`${o(K)}.${o(c)}`,{where:f,params:i}=function(a){let b=[],c=[];for(let[d,e]of Object.entries(a)){if(!e.enabled)continue;let a=o(d);if("IS NULL"===e.op)b.push(`${a} IS NULL`);else if("IS NOT NULL"===e.op)b.push(`${a} IS NOT NULL`);else if("IN"===e.op){let d=e.value.split(",").map(a=>a.trim()).filter(Boolean);if(0===d.length)continue;let f=d.map(a=>(c.push(a),"?"));b.push(`${a} IN (${f.join(", ")})`)}else"LIKE"===e.op||e.op,b.push(`${a} ${e.op} ?`),c.push(e.value)}return{where:b.length>0?` WHERE ${b.join(" AND ")}`:"",params:c}}(g),j=h?` ORDER BY ${o(h.column)} ${h.dir}`:"",k=`SELECT * FROM ${e}${f}${j} LIMIT 50 OFFSET ${50*d}`,m=await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:k,params:i});ab(m);let n=`SELECT count(*) AS cnt FROM ${e}${f}`,p=await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:n,params:i});ah(p.rows?.[0]?.cnt??0)}catch{}af(!1)},[a,b,K,au,aw]),aK=(0,f.useCallback)(async c=>{P(c),ad(0),an(null),ar(!1),aj(new Set),al(!1),av({}),ax(null);try{let d=await (0,l.Ey)("/api/mysql/columns",{id:a,connectionString:b,schema:K,table:c});V(d.columns||[]),X(d.primaryKeys||[]),Z(d.foreignKeys||[]),_(d.indexes||[])}catch{}aJ(c,0,{},null)},[a,b,K,aJ]),aL=(0,f.useCallback)(async()=>{if(ay.trim()){aF(!0),aD(""),aB(null);try{let c=await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:ay});aB(c)}catch(a){aD(a instanceof Error?a.message:String(a))}aF(!1)}},[a,b,ay]),aM=(0,f.useCallback)(async()=>{if(null===am||!aa||!O)return;let c=aa.rows[am],d=[],e=[];for(let a of U)void 0!==ao[a.name]&&ao[a.name]!==q(c[a.name]??"")&&(d.push(`${o(a.name)} = ?`),e.push(""===ao[a.name]&&a.nullable?null:ao[a.name]));if(0===d.length)return void an(null);let f=W.length>0?W:U.map(a=>a.name),g=[];for(let a of f)null===c[a]||void 0===c[a]?g.push(`${o(a)} IS NULL`):(g.push(`${o(a)} = ?`),e.push(c[a]));let h=`UPDATE ${o(K)}.${o(O)} SET ${d.join(", ")} WHERE ${g.join(" AND ")}`;try{await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:h,params:e}),an(null),aJ(O,ac,au,aw)}catch(a){alert(`Update failed: ${a instanceof Error?a.message:String(a)}`)}},[am,aa,O,U,W,ao,a,b,K,aJ,ac,au,aw]),aN=(0,f.useCallback)(async()=>{if(!O)return;let c=[],d=[],e=[];for(let a of U)void 0!==as[a.name]&&""!==as[a.name]&&(c.push(o(a.name)),d.push(as[a.name]),e.push("?"));if(0===c.length)return;let f=`INSERT INTO ${o(K)}.${o(O)} (${c.join(", ")}) VALUES (${e.join(", ")})`;try{await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:f,params:d}),ar(!1),at({}),aJ(O,ac,au,aw)}catch(a){alert(`Insert failed: ${a instanceof Error?a.message:String(a)}`)}},[O,U,as,a,b,K,aJ,ac,au,aw]),aO=(0,f.useCallback)(async()=>{if(0===ai.size||!aa||!O)return;let c=W.length>0?W:U.map(a=>a.name),d=0;for(let e of Array.from(ai).sort((a,b)=>b-a)){let f=aa.rows[e];if(!f)continue;let g=[],h=[];for(let a of c)null===f[a]||void 0===f[a]?g.push(`${o(a)} IS NULL`):(g.push(`${o(a)} = ?`),h.push(f[a]));let i=`DELETE FROM ${o(K)}.${o(O)} WHERE ${g.join(" AND ")} LIMIT 1`;try{await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:i,params:h})}catch{d++}}aj(new Set),al(!1),aJ(O,ac,au,aw),d>0&&alert(C("mysql.deleteRowsFailed",{count:d}))},[ai,aa,O,W,U,a,b,K,aJ,ac,au,aw]),aP=(0,f.useCallback)(async c=>{if(!O)return;if(ai.size>0&&aa){let a,b=aa.fields.map(a=>a.name),d=Array.from(ai).sort((a,b)=>a-b).map(a=>aa.rows[a]).filter(Boolean);if("json"===c)a=JSON.stringify(d,null,2);else{let c=[b.join(",")];for(let a of d)c.push(b.map(b=>{let c=a[b];if(null==c)return"";let d="object"==typeof c?JSON.stringify(c):String(c);return d.includes(",")||d.includes('"')||d.includes("\n")?`"${d.replace(/"/g,'""')}"`:d}).join(","));a=c.join("\n")}navigator.clipboard.writeText(a);return}let d=`SELECT * FROM ${o(K)}.${o(O)}`;try{let e=await (0,l.HS)("/api/mysql/export",{id:a,connectionString:b,sql:d,format:c}),f=URL.createObjectURL(e),g=document.createElement("a");g.href=f,g.download=`${O}.${c}`,g.click(),URL.revokeObjectURL(f)}catch(a){alert(`Export failed: ${a instanceof Error?a.message:String(a)}`)}},[O,a,b,K,ai,aa]),aQ=(0,f.useCallback)(a=>{(a.metaKey||a.ctrlKey)&&"Enter"===a.key&&(a.preventDefault(),aL())},[aL]),aR=g&&m?m-41:u??h.p,aS=Math.max(1,Math.ceil(ag/50)),aT=(0,f.useCallback)(a=>{O&&(ad(a),aJ(O,a,au,aw))},[O,aJ,au,aw]),aU=(0,f.useCallback)((a,b)=>{let c={...au};b?c[a]=b:delete c[a],av(c),ad(0),aj(new Set),O&&aJ(O,0,c,aw)},[au,aw,O,aJ]),aV=(0,f.useCallback)(()=>{av({}),ad(0),aj(new Set),O&&aJ(O,0,{},aw)},[aw,O,aJ]),aW=(0,f.useCallback)(a=>{ax(a),ad(0),aj(new Set),O&&aJ(O,0,au,a)},[au,O,aJ]);return(0,e.jsx)("div",{className:"flex flex-col items-start",children:(0,e.jsxs)("div",{className:`w-full bg-accent text-foreground
32
+ ${e}`;break}}a(b,w.length>0?w:void 0),v(""),x([]),I.current&&(I.current.style.height="auto")}},[u,w,b,a,A,t]),Q=(0,f.useCallback)(a=>{v(a.name+" "),I.current?.focus()},[]),R=(0,f.useCallback)(a=>{if(!a.nativeEvent.isComposing){if(N&&M.length>0){if("ArrowDown"===a.key){a.preventDefault(),F(a=>(a+1)%M.length);return}if("ArrowUp"===a.key){a.preventDefault(),F(a=>(a-1+M.length)%M.length);return}if("Enter"===a.key){a.preventDefault(),Q(M[E]);return}if("Escape"===a.key){a.preventDefault(),H(!0);return}if("Tab"===a.key){a.preventDefault(),Q(M[E]);return}}"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),P())}},[N,M,E,Q,P]),S=(0,f.useCallback)(a=>{let b=a.clipboardData?.items;if(!b)return;let c=["image/png","image/jpeg","image/webp","image/gif"];for(let d of Array.from(b)){let b=c.find(a=>d.type===a);if(b){a.preventDefault();let c=d.getAsFile();if(!c)continue;if(c.size>5242880){alert(t("chat.imageSizeLimit",{size:(c.size/1024/1024).toFixed(2)}));continue}let e=new FileReader;e.onload=a=>{let c=a.target?.result;if(!c)return;let d=c.replace(/^data:image\/\w+;base64,/,""),e={id:`img-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,data:d,preview:c,media_type:b};x(a=>[...a,e])},e.readAsDataURL(c)}}},[t]),T=(0,f.useCallback)(a=>{x(b=>b.filter(b=>b.id!==a))},[]);return(0,e.jsxs)("div",{className:"border-t border-border bg-card relative",children:[(0,e.jsx)(i.k,{images:w,onRemove:T,disabled:b}),N&&M.length>0&&(0,e.jsx)("div",{ref:J,className:"absolute bottom-full left-0 right-0 mx-4 mb-2 max-h-64 overflow-y-auto bg-card border border-border rounded-lg shadow-lg",children:M.map((a,b)=>{let c=b>0?M[b-1]:null,d="skill"===a.source&&(!c||"skill"!==c.source),f="skill"!==a.source&&0===b;return(0,e.jsxs)("div",{children:[f&&(0,e.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Commands"}),d&&(0,e.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Skills"}),(0,e.jsxs)("div",{onClick:()=>Q(a),className:`px-4 py-2 cursor-pointer ${b===E?"bg-brand/10":"hover:bg-accent"}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("span",{className:"font-mono text-sm font-medium text-foreground",children:a.name}),(0,e.jsx)("span",{className:"flex-1 text-sm text-muted-foreground truncate",children:a.description}),(0,e.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${(a=>{switch(a){case"builtin":return"bg-brand/15 text-brand dark:bg-brand/25 dark:text-teal-11";case"global":return"bg-green-9/15 text-green-11 dark:bg-green-9/25 dark:text-green-11";case"project":return"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25 dark:text-amber-11";case"skill":return"bg-purple-9/15 text-purple-11 dark:bg-purple-9/25 dark:text-purple-11"}})(a.source)}`,children:(a=>{switch(a){case"builtin":return t("common.builtin");case"global":return t("common.global");case"project":return t("common.project");case"skill":return"Skill"}})(a.source)})]}),"skill"===a.source&&a.argumentHint&&(0,e.jsx)("div",{className:"font-mono text-xs text-muted-foreground mt-0.5 pl-0 truncate",children:a.argumentHint})]})]},a.name)})}),(0,e.jsxs)("div",{className:"flex gap-2 items-end p-4",children:[(0,e.jsx)("button",{onClick:async()=>{if(!c)return;let a=await l.t4.runPromiseExit((0,m.Iz)(c,["."]));"Success"===a._tag?((0,g.oR)(t("toast.stagedAllFiles"),"success"),window.dispatchEvent(new CustomEvent("git-status-changed"))):(console.error("Error staging files:",a.cause),(0,g.oR)(t("toast.stageFailed"),"error"))},className:"p-2 text-green-11 hover:text-green-10 hover:bg-green-9/10 active:bg-green-9/20 active:scale-95 rounded-lg transition-all",title:t("chat.stageAll"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),o&&(0,e.jsx)("button",{onClick:o,className:"p-2 text-brand hover:text-teal-10 hover:bg-brand/10 active:bg-brand/20 active:scale-95 rounded-lg transition-all",title:t("chat.viewGitChanges"),children:(0,e.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"6",cy:"6",r:"2",strokeWidth:2}),(0,e.jsx)("circle",{cx:"18",cy:"6",r:"2",strokeWidth:2}),(0,e.jsx)("circle",{cx:"6",cy:"18",r:"2",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 8v10M18 8v4c0 2-2 4-6 4"})]})}),p&&(0,e.jsx)("button",{onClick:p,className:"p-2 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 active:bg-amber-9/20 active:scale-95 rounded-lg transition-all",title:t("chat.viewAllComments"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),q&&(0,e.jsx)("button",{onClick:q,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:t("chat.userMessages"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),r&&(0,e.jsx)("button",{onClick:r,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:t("chat.projectNotes"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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"})})}),s&&(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("button",{onClick:()=>D(!C),className:`p-2 rounded-lg transition-all ${C?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95"}`,title:t("chat.scheduledTasks"),children:(0,e.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]})}),C&&(0,e.jsx)(j.E,{onClose:()=>D(!1),onCreate:s})]}),(0,e.jsx)("textarea",{ref:I,value:u,onChange:a=>v(a.target.value),onKeyDown:R,onPaste:S,placeholder:b?t("chat.placeholderDisabled"):t("chat.placeholder"),rows:1,className:"flex-1 resize-none px-4 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-ring bg-card text-foreground placeholder-slate-9"})]})]})});d()}catch(a){d(a)}})},62473:(a,b,c)=>{"use strict";c.d(b,{g:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({tokenUsage:a,rateLimitInfo:b}){let{t:c}=(0,f.Bd)(),[h,i]=(0,e.useState)(()=>Date.now()),j=b?.status==="rejected"?"text-red-500":b?.status==="allowed_warning"?"text-yellow-500":"text-muted-foreground",k=b?.status==="rejected"?c("chat.rateLimitRejected","Rate Limited"):b?.status==="allowed_warning"?c("chat.rateLimitWarning","Approaching Limit"):null,l=a=>{if(!a)return"";let b=(a<1e12?1e3*a:a)-h;if(b<=0)return"";let c=Math.ceil(b/6e4);if(c<60)return`${c}m`;let d=Math.floor(c/60),e=c%60;return e>0?`${d}h${e}m`:`${d}h`},m=a=>a?a.replace(/_/g," "):"";return(0,d.jsx)("div",{className:"px-4 py-1.5 border-t border-border bg-secondary",children:(0,d.jsxs)("div",{className:"flex items-center justify-end gap-4 text-xs text-muted-foreground",children:[b&&k&&(0,d.jsxs)("span",{className:`flex items-center gap-1 ${j}`,title:[b.rateLimitType&&`Type: ${m(b.rateLimitType)}`,null!=b.utilization&&`Usage: ${(100*b.utilization).toFixed(0)}%`,b.resetsAt&&`Resets in: ${l(b.resetsAt)}`,b.isUsingOverage&&"Using overage"].filter(Boolean).join(" \xb7 "),children:["rejected"===b.status?(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}):(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:[(0,d.jsx)("strong",{children:k}),null!=b.utilization&&` ${(100*b.utilization).toFixed(0)}%`,b.resetsAt&&` \xb7 ${l(b.resetsAt)}`]})]}),b&&!k&&b.resetsAt&&(0,d.jsxs)("span",{className:"flex items-center gap-1.5",title:[b.rateLimitType&&m(b.rateLimitType),null!=b.utilization&&`Usage: ${(100*b.utilization).toFixed(0)}%`,`Resets in: ${l(b.resetsAt)}`].filter(Boolean).join(" \xb7 "),children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),null!=b.utilization?(0,d.jsxs)("span",{children:[(100*b.utilization).toFixed(0),"%"]}):(0,d.jsx)("span",{children:l(b.resetsAt)})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,d.jsxs)("span",{children:[c("chat.context"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens).toLocaleString()})]})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),(0,d.jsxs)("span",{children:[c("chat.output"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:a.outputTokens.toLocaleString()})]})]}),(a.cacheReadInputTokens>0||a.cacheCreationInputTokens>0)&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-brand",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4"})}),(0,d.jsxs)("span",{children:["Cache: ",(a.cacheReadInputTokens/(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens)*100).toFixed(0),"%"]})]}),a.totalCostUsd>0&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-green-11",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:["$",a.totalCostUsd.toFixed(4)]})]})]})})}},62751:(a,b,c)=>{"use strict";function d(){}function e(a){return()=>{}}c.d(b,{U:()=>e,k:()=>d})},63041:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({cwd:a,sessionId:b,onOpenProjectSessions:c,onOpenSessionBrowser:h,onOpenSettings:i}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1);return(0,d.jsx)("div",{className:"border-b border-border px-4 py-3 bg-card",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6"}),(0,d.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,d.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"One seat. One AI. Everything under control."})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[a&&(0,d.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help",title:`CWD: ${a}`,children:a}),!a&&b&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Session: ",b.slice(0,8),"..."]}),a&&(0,d.jsx)("button",{onClick:c,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:j("sessions.projectSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),(0,d.jsx)("button",{onClick:h,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:j("sessions.browseAllSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),b&&(0,d.jsx)("button",{onClick:()=>{let a=`claude -r ${b}`;navigator.clipboard.writeText(a).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},className:`p-2 rounded-lg transition-colors ${k?"text-green-500 bg-green-500/10":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:k?j("chat.copiedCommandTooltip"):j("chat.copyCommandTooltip",{sessionId:b}),children:k?(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),(0,d.jsx)("button",{onClick:i,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:j("settings.title"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]})]})})}},63913:(a,b,c)=>{"use strict";c.a(a,async(a,b)=>{try{var d=c(48249),e=c(3560),f=c(56696),g=c(74493),h=a([f]);f=(h.then?(await h)():h)[0],(0,e.Aq)({type:"database",idPrefix:"db",match(a){let b=a.trim().toLowerCase();return b.startsWith("postgresql://")||b.startsWith("postgres://")},parse(a){let b=a.trim(),c=b;try{let a=new URL(b),d=a.pathname.replace(/^\//,"")||"postgres";c=`${d}@${a.hostname}${a.port?":"+a.port:""}`}catch{}return{connectionString:b,displayName:c}},fromHistory:a=>({connectionString:a.connectionString,displayName:a.displayName||a.connectionString}),toHistory:a=>({connectionString:a.connectionString,displayName:a.displayName}),Component:function({item:a,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l}){return(0,d.jsx)(f.M,{id:a.id,connectionString:a.connectionString,displayName:a.displayName,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l})},async onClose(a){await (0,g.ax)("db",a.id)}}),b()}catch(a){b(a)}})},63963:(a,b,c)=>{"use strict";c.d(b,{AS:()=>w,HV:()=>t,If:()=>u,RS:()=>p,TN:()=>q,mO:()=>s,tr:()=>r});let d=null,e="",f=0,g=null,h=!1,i=new Map,j=null,k=null;function l(a){let b;try{b=JSON.parse(a.data)}catch{return}let c=b.type;if("ping"===c)return;if("running"===c){j&&(j(b.commands),j=null);return}let d=b.commandId;if(!d)return;let e=i.get(d);if(e){if("error"===c)e.onError(b.error);else{let{commandId:a,type:d,...f}=b;e.onData(c,f)}("exit"===c||"error"===c)&&i.delete(d)}}function m(a){d?.readyState===WebSocket.OPEN&&d.send(JSON.stringify(a))}function n(a){let b,c=(b="https:"===window.location.protocol?"wss:":"ws:",`${b}//${window.location.host}/ws/terminal?projectCwd=${encodeURIComponent(a)}`);e===c&&d||(w(),h=!1,e=c,function a(){if(h||!e)return;let b=new WebSocket(e);d=b,b.onopen=()=>{for(let a of(f=0,i.keys()))b.send(JSON.stringify({type:"attach",commandId:a}))},b.onmessage=l,b.onclose=()=>{if(d!==b||(d=null,h))return;g&&clearTimeout(g);let c=Math.min(1e3*Math.pow(1.5,f),1e4);f++,g=setTimeout(a,c)},b.onerror=()=>{}}())}function o(){return new Promise((a,b)=>{if(d?.readyState===WebSocket.OPEN)return void a();let c=setInterval(()=>{d?.readyState===WebSocket.OPEN&&(clearInterval(c),clearTimeout(e),a())},50),e=setTimeout(()=>{clearInterval(c),b(Error("WebSocket connection timeout"))},5e3)})}async function p(a){let{cwd:b,command:c,commandId:d,tabId:e,projectCwd:f,env:g,usePty:h,cols:j,rows:k,onData:l,onError:p}=a;n(f);try{await o()}catch{p("WebSocket connection failed");return}i.delete(d),i.set(d,{onData:l,onError:p}),m({type:"exec",commandId:d,command:c,cwd:b,tabId:e,env:g,...h?{usePty:!0}:{},...j?{cols:j,rows:k}:{}})}async function q(a){let{commandId:b,projectCwd:c,onData:d,onError:e}=a;n(c);try{await o()}catch{e("WebSocket connection failed");return}i.set(b,{onData:d,onError:e}),m({type:"attach",commandId:b})}function r(a,b){m({type:"stdin",commandId:a,data:b})}function s(a,b,c){m({type:"resize",commandId:a,cols:b,rows:c})}function t(a){m({type:"interrupt",pid:a})}function u(a){return k||(k=v(a))}async function v(a){try{n(a);try{await o()}catch{return[]}return await new Promise(a=>{j=b=>{a(b)},m({type:"running"}),setTimeout(()=>{j&&(j=null,a([]))},3e3)})}finally{k=null}}function w(){if(h=!0,g&&(clearTimeout(g),g=null),d){let a=d;d=null,a.close()}i.clear(),j&&(j([]),j=null),k=null,e="",f=0}},65395:(a,b,c)=>{"use strict";c.d(b,{useTabState:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call useTabState() from the server but useTabState is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/useTabState.ts","useTabState")},65484:(a,b,c)=>{"use strict";c.d(b,{Cq:()=>n,D0:()=>q,DZ:()=>i,H7:()=>o,It:()=>s,Kl:()=>w,M5:()=>h,Or:()=>k,Q1:()=>u,QW:()=>p,Wr:()=>j,Yn:()=>r,b2:()=>v,em:()=>t,zF:()=>m});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=()=>f("/api/settings"),i=a=>f("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),j=()=>f("/api/version"),k=()=>f("/api/extension/version"),l=a=>a?`/api/note?cwd=${encodeURIComponent(a)}`:"/api/note",m=a=>f(l(a)),n=(a,b)=>g(l(a),{content:b}),o=()=>f("/api/sessions/projects"),p=a=>f(`/api/sessions/projects/${encodeURIComponent(a)}`),q=a=>f(`/api/project-settings?cwd=${encodeURIComponent(a)}`),r=a=>g("/api/project-settings",a),s=()=>f("/api/pick-folder"),t=a=>g("/api/open-vscode",{cwd:a}),u=a=>g("/api/open-cursor",{cwd:a}),v=a=>f(`/api/git/worktree?cwd=${encodeURIComponent(a)}`),w=a=>g("/api/git/worktree",a)},65543:(a,b,c)=>{"use strict";c.d(b,{_:()=>e});let d=new Set(["function","class","method"]);function e(a){return d.has(a.kind)}},67045:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(48249);function e({error:a,reset:b}){return(0,d.jsx)("html",{children:(0,d.jsx)("body",{children:(0,d.jsxs)("div",{style:{padding:"2rem",fontFamily:"system-ui, sans-serif"},children:[(0,d.jsx)("h2",{children:"Something went wrong"}),(0,d.jsx)("p",{style:{color:"#666"},children:a.message}),(0,d.jsx)("button",{onClick:b,style:{marginTop:"1rem",padding:"0.5rem 1rem",cursor:"pointer",borderRadius:"0.375rem",border:"1px solid #ccc",background:"#fff"},children:"Try again"})]})})})}},67115:(a,b,c)=>{"use strict";c.d(b,{Q:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(57031),h=c(88214),i=c(33281),j=c(41224);function k({isOpen:a,onClose:b,cwd:c,onSelectSession:l}){let{t:m}=(0,f.Bd)(),[n,o]=(0,e.useState)([]),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(null),[t,u]=(0,e.useState)(""),v=(0,e.useRef)(null);(0,e.useCallback)(async()=>{if(!c)return;q(!0),s(null);let a=c.replace(/\//g,"-"),b=await i.t4.runPromiseExit((0,j.QW)(a));"Success"===b._tag?o(b.value):s("Failed to load sessions"),q(!1)},[c]);let w=n.filter(a=>{if(!t)return!0;let b=t.toLowerCase();return a.title.toLowerCase().includes(b)||a.firstMessages.some(a=>a.toLowerCase().includes(b))||a.lastMessages.some(a=>a.toLowerCase().includes(b))});return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:b}),(0,d.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,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:m("sessions.sessionList")}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:c,children:c})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,d.jsx)("input",{ref:v,type:"text",placeholder:m("sessions.searchSessions"),value:t,onChange:a=>u(a.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"}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[p&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:m("sessions.loadingSessions")})]})}),r&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-red-11",children:r})}),!p&&!r&&0===w.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:m(t?"sessions.noMatchingSessions":"sessions.noSessionsYet")})}),!p&&!r&&w.length>0&&(0,d.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:w.map(a=>(0,d.jsxs)("div",{onClick:()=>{let d;return d=(a.path.split("/").pop()||"").replace(".jsonl",""),void(l?(l(d,a.title),b()):(0,g.F)(h.n.OpenProject,{cwd:c,sessionId:d}))},className:"p-3 bg-secondary rounded border border-border hover:border-brand hover:shadow-md cursor-pointer transition-all",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[a.engine&&"claude"!==a.engine&&(0,d.jsx)("span",{className:`shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded ${"claude2"===a.engine?"bg-orange-500/15 text-orange-11":"ollama"===a.engine?"bg-blue-500/15 text-blue-11":"codex"===a.engine?"bg-green-500/15 text-green-11":"kimi"===a.engine?"bg-purple-500/15 text-purple-11":"bg-muted text-muted-foreground"}`,children:a.engine}),(0,d.jsx)("h4",{className:"text-xs font-medium text-foreground truncate",title:a.title,children:a.title})]}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(a.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(0,d.jsxs)("div",{className:"space-y-0.5 text-xs",children:[a.firstMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`first-${b}`)),a.lastMessages.length>0&&(0,d.jsx)("div",{className:"text-slate-9 text-center py-0.5",children:"\xb7\xb7\xb7"}),a.lastMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`last-${b}`))]})]},a.path))})]})]})]}):null}},69424:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{$:()=>q});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(44256),j=c(15273),k=c(46674),l=c(99941),m=c(44643),n=c(32026),o=c(11732);function p(a){let b=a.input?.questions||[],c=a.input?.answers||{},d={};if(a.result)try{let b=JSON.parse(a.result);b?.answers&&(d=b.answers)}catch{}return{questions:b,answers:{...c,...d}}}function q({toolCalls:a,onClose:b}){let{t:c}=(0,g.Bd)(),[d,r]=(0,f.useState)({}),[s,t]=(0,f.useState)({}),[u,v]=(0,f.useState)({}),[w,x]=(0,f.useState)({}),y=a.reduce((a,b)=>{let{questions:c}=p(b);return a+c.length},0),z=Object.values(w).filter(Boolean).length,A=(0,f.useCallback)((a,b)=>{r(c=>({...c,[a]:b})),t(b=>({...b,[a]:!1}))},[]),B=(0,f.useCallback)(a=>{t(b=>{let c=!b[a];if(c){let b=u[a]||"";b&&r(c=>({...c,[a]:b}))}return{...b,[a]:c}})},[u]),C=(0,f.useCallback)((a,b)=>{v(c=>({...c,[a]:b})),b&&r(c=>({...c,[a]:b}))},[]),D=(0,f.useCallback)(a=>{x(b=>({...b,[a]:!b[a]}))},[]),E=(0,f.useCallback)(()=>{let b=z>0,e=[];a.forEach((a,f)=>{let{questions:g}=p(a);g.forEach((a,g)=>{let h=`${f}-${g}`;if(b&&!w[h])return;let i=d[h];e.push(`Q: ${a.question}`),e.push(`A: ${i||c("askQuestion.notSelected")}`),e.push("")})}),navigator.clipboard.writeText(e.join("\n").trim()),(0,h.oR)(b?c("toast.copiedQA",{count:z}):c("toast.copiedAllQA"))},[a,d,w,z,c]),F=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:b,children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-6xl h-[90vh] flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:c("askQuestion.title")}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[c("askQuestion.nQuestions",{count:y}),z>0&&` \xb7 ${c("askQuestion.checkedN",{count:z})}`]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:E,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:z>0?c("askQuestion.copyChecked",{count:z}):c("askQuestion.copyAll"),children:(0,e.jsx)(j.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)(k.A,{className:"w-5 h-5"})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-6",children:a.map((b,f)=>{let{questions:g}=p(b);return g.map((b,h)=>{let i=`${f}-${h}`,j=d[i],k=s[i]||!1,p=w[i]||!1;return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-start gap-2",children:[(0,e.jsx)("button",{onClick:()=>D(i),className:"mt-0.5 flex-shrink-0 p-0.5 rounded hover:bg-accent transition-colors",title:c("askQuestion.checkToCopy"),children:p?(0,e.jsx)(l.A,{className:"w-4 h-4 text-brand"}):(0,e.jsx)(m.A,{className:"w-4 h-4 text-muted-foreground"})}),b.header&&(0,e.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-brand/10 text-brand flex-shrink-0 mt-0.5",children:b.header}),(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:b.question})]}),(0,e.jsxs)("div",{className:"space-y-1 ml-7",children:[b.options.map((a,b)=>{let c=j===a.label&&!k;return(0,e.jsxs)("button",{onClick:()=>A(i,a.label),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-accent/50 ${c?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,e.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:c?(0,e.jsx)(n.A,{className:"w-3.5 h-3.5 text-brand"}):(0,e.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("div",{className:`text-sm ${c?"text-foreground font-medium":"text-foreground"}`,children:a.label}),a.description&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.description})]})]},b)}),(0,e.jsxs)("button",{onClick:()=>B(i),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-accent/50 ${k?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,e.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:k?(0,e.jsx)(n.A,{className:"w-3.5 h-3.5 text-brand"}):(0,e.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(o.A,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:c("askQuestion.custom")})]})]}),k&&(0,e.jsx)("div",{className:"ml-6 mt-1",children:(0,e.jsx)("input",{type:"text",autoFocus:!0,value:u[i]||"",onChange:a=>C(i,a.target.value),placeholder:c("askQuestion.customPlaceholder"),className:"w-full px-3 py-1.5 text-sm bg-background border border-border rounded-md focus:outline-none focus:ring-1 focus:ring-brand text-foreground placeholder:text-muted-foreground"})})]}),(f!==a.length-1||h!==g.length-1)&&(0,e.jsx)("div",{className:"border-b border-border/50 mt-3"})]},i)})})})]})});return(0,e.jsx)(i.ZL,{children:F})}d()}catch(a){d(a)}})},70151:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>Q});var e=c(48249),f=c(67484),g=c(74429),h=c(44256),i=c(33281),j=c(87808),k=c(85655),l=c(21538),m=c(35208),n=c(7833),o=c(24724),p=c(20586),q=c(7122),r=c(55287),s=c(60591),t=c(9804),u=c(73887),v=c(94239),w=c(29939),x=c(23860),y=c(90018),z=c(57014),A=c(94308),B=c(53036),C=c(6662),D=c(20291),E=c(58904),F=c(61632),G=c(76855),H=c(4857),I=c(44384),J=c(18921),K=c(28797),L=c(23881),M=c(21672),N=c(21482),O=c(94192),P=a([E,F,p,o,l,y,r,z,m,u,v,N,M]);function Q({onClose:a,cwd:b,initialTab:c="tree",tabSwitchTrigger:d,initialSearchQuery:P,searchQueryTrigger:R}){let{t:S}=(0,I.Bd)(),{activeView:T}=(0,O.R8)(),[U,V]=(0,f.useState)(c),[W,X]=(0,f.useState)("code"),Y=(0,f.useRef)(null),Z=(0,f.useRef)(!1),[$,_]=(0,f.useState)(null),[aa,ab]=(0,f.useState)(null),[ac,ad]=(0,f.useState)(!1),ae=(0,f.useRef)(1),af=(0,f.useRef)(null),[ag,ah]=(0,f.useState)(null),ai=(0,f.useRef)(null),[aj,ak]=(0,f.useState)({isDirty:!1,isSaving:!1}),[al,am]=(0,f.useState)(!1),[an,ao]=(0,f.useState)(!1),[ap,aq]=(0,f.useState)(null),ar=(0,f.useRef)(null),as=(0,J.o)(ar),at=(0,f.useRef)(null),au=(0,J.o)(at),av=(0,G.Sn)(b),aw=(0,G.Xm)(b),ax=(0,G.po)(b),ay=(0,H.Q)(),az=(0,x.F)(),aA=(0,C.W)({cwd:b});(0,G.JL)(b,aA.selectedPath);let aB=(0,D.p)({cwd:b,onSearchComplete:()=>am(!0)}),aC=(0,E.e)({cwd:b,addToRecentFiles:aA.addToRecentFiles}),aD=(0,f.useMemo)(()=>{let a=new Set;if(aC.status){for(let b of aC.status.staged)a.add(b.path);for(let b of aC.status.unstaged)a.add(b.path)}return a},[aC.status]),aE=(0,f.useMemo)(()=>{let a=new Map;if(aC.status){for(let b of aC.status.staged)a.set(b.path,"staged");for(let b of aC.status.unstaged)a.set(b.path,"unstaged")}return a},[aC.status]),aF=(0,F.y)({cwd:b,addToRecentFiles:aA.addToRecentFiles}),aG=(0,f.useRef)(!1),aH=(0,f.useCallback)(a=>{aA.setFileContent(b=>b?.type==="text"?{...b,content:a}:b),aA.showEditor||(aG.current=!0,aA.setShowEditor(!0))},[aA]),aI=(0,f.useCallback)(a=>{aA.setShowEditor(!0)},[aA]),aJ=(0,f.useCallback)(async()=>{if(!aA.fileContent||"text"!==aA.fileContent.type||!aA.fileContent.content)return;let a=await i.t4.runPromiseExit((0,j.OJ)({cwd:b,path:aA.selectedPath,content:aA.fileContent.content}));try{if("Failure"===a._tag||!a.value.ok)throw Error("Failed to save file");let b=a.value.data?.mtime;b&&aA.setFileContent(a=>a?.type==="text"?{...a,mtime:b}:a),(0,n.oR)(S("toast.savedSuccess"),"success")}catch{(0,n.oR)(S("toast.saveFailed"),"error")}},[b,aA]),aK=(0,f.useCallback)(()=>{if(!aA.selectedPath)return;let a=ae.current,b=af.current;a>0&&aA.updateRecentFilePosition(aA.selectedPath,a,b?b.cursorLine+1:a,b?b.cursorCol+1:1)},[aA]),aL=(0,f.useCallback)(async(a,b)=>{let c=a!==aA.selectedPath;if(c&&aA.showEditor){if(aj.isDirty&&(!await (0,n.lJ)(S("fileBrowser.saveBeforeSwitch"),{confirmText:S("fileBrowser.saveAndSwitch"),cancelText:S("common.cancel")})||(await ai.current?.save(),ai.current?.isDirty)))return;aA.setShowEditor(!1)}c&&aK(),aA.handleSelectFile(a,b)},[aA,aK,aj.isDirty,S]),aM=(0,f.useMemo)(()=>{let a=aB.contentSearchResults;if(0===a.length)return{files:[],expandDirs:new Set,matchMap:new Map};let b=new Map,c=[];for(let d of a)b.set(d.path,d),c.push(d.path);let d=(0,t.v3)(c),e=new Set((0,t.tW)(d));return{files:d,expandDirs:e,matchMap:b}},[aB.contentSearchResults]),[aN,aO]=(0,f.useState)(new Set),aP=(0,f.useCallback)(a=>{aO(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),aQ=(0,f.useCallback)(a=>{if(a.isDirectory)return null;let b=aM.matchMap.get(a.path);return b?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:b.matches.length}):null},[aM.matchMap]),aR=al&&aB.contentSearchResults.length>0,aS=!!aA.selectedPath&&null!==(0,K.c)(aA.selectedPath),aT=(0,f.useCallback)(async(a,c)=>{if(!aA.selectedPath||!aS)return;let d=await av.goToDefinition(aA.selectedPath,a,c);if(0===d.length)return;let e=d[0],f=b.endsWith("/")?b:b+"/",g=e.file.startsWith(f)?e.file.slice(f.length):e.file;ay.push({filePath:aA.selectedPath,lineNumber:ae.current}),g===aA.selectedPath?aA.setTargetLineNumber(e.line):aL(g,e.line)},[aA,b,aS,av,ay]),aU=(0,f.useCallback)((a,b,c)=>{aA.selectedPath&&aS&&aw.onTokenMouseEnter(aA.selectedPath,a,b,c)},[aA.selectedPath,aS,aw]),aV=(0,f.useCallback)(a=>{let c=b.endsWith("/")?b:b+"/",d=a.file.startsWith(c)?a.file.slice(c.length):a.file;aA.selectedPath&&ay.push({filePath:aA.selectedPath,lineNumber:ae.current}),d===aA.selectedPath?aA.setTargetLineNumber(a.line):aL(d,a.line)},[aA,b,ay]),aW=(0,f.useMemo)(()=>{if(!aC.status)return null;let a=new Map,b=a=>{switch(a){case"modified":default:return"M";case"added":return"A";case"deleted":return"D";case"renamed":return"R";case"untracked":return"?"}};for(let c of aC.status.staged)a.set(c.path,b(c.status));for(let c of aC.status.unstaged)a.set(c.path,b(c.status));return a},[aC.status]),aX=(0,f.useCallback)(a=>{V(a),aA.setBlameSelectedCommit(null),"history"===a&&aF.selectedBranch&&aF.loadCommits(aF.selectedBranch)},[aA,aF.selectedBranch,aF.loadCommits]);(0,f.useCallback)(()=>{if(!aA.selectedPath)return;let a={filePath:aA.selectedPath,lineNumber:ae.current},b=ay.goBack(a);b&&(b.filePath===aA.selectedPath?aA.setTargetLineNumber(b.lineNumber):aL(b.filePath,b.lineNumber))},[aA,ay]),(0,f.useCallback)(()=>{if(!aA.selectedPath)return;let a={filePath:aA.selectedPath,lineNumber:ae.current},b=ay.goForward(a);b&&(b.filePath===aA.selectedPath?aA.setTargetLineNumber(b.lineNumber):aL(b.filePath,b.lineNumber))},[aA,ay]);let aY=(0,f.useCallback)(async a=>{let c=a.split("/").pop()||a,d=await i.t4.runPromiseExit((0,j.__)({cwd:b,paths:[a],op:"copy"}));"Success"===d._tag?(0,n.oR)(S("toast.copiedName",{name:c}),"success"):(0,n.oR)(S("toast.copyFailed"),"error")},[b,S]),aZ=(0,f.useCallback)(async a=>{let c=await i.t4.runPromiseExit((0,j.dt)());if("Success"!==c._tag||!c.value.path)return void(0,n.oR)(S("toast.noFileToPaste"),"info");let d=c.value.path,e=await i.t4.runPromiseExit((0,j.Nn)({cwd:b,targetDir:a,sourceAbsPath:d}));if("Success"===e._tag)(0,n.oR)(S("toast.pastedFile",{name:e.value.newName}),"success"),aA.loadDirectory(a),aA.loadFileIndex();else{let a="Fail"===e.cause._tag?e.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:S("toast.pasteFailed");(0,n.oR)(c,"error")}},[b,aA,S]);(0,f.useRef)(0),(0,f.useRef)(az),(0,f.useRef)(U);let a$=(0,f.useRef)(aF.selectedBranch);a$.current=aF.selectedBranch;let a_=(0,f.useRef)(aA.selectedPath);a_.current=aA.selectedPath;let a0=(0,f.useRef)(aA.fileContent?.type);a0.current=aA.fileContent?.type;let a1=(0,f.useCallback)(async a=>{try{let{data:c}=a;if(!c)return;let d=c.some(a=>"git"===a.type),e=c.some(a=>"file"===a.type),f=[];if((e||d)&&(f.push(i.t4.runPromise((0,j.mP)(b)).then(a=>{a.error||aA.setFiles(b=>(0,t.HR)(a.files??[],b))}).catch(()=>{})),f.push(i.t4.runPromise((0,j.DZ)(b)).then(a=>{a.paths&&aA.setFileIndex(a.paths)}).catch(()=>{})),f.push(i.t4.runPromise((0,j.r9)(b)).then(a=>{aA.setRecentFiles(a.files??[])}).catch(()=>{}))),d||e){f.push(i.t4.runPromise((0,k.lv)(b)).then(a=>{aC.setStatus(a);let b=(0,p.Do)(a.staged),c=(0,p.Do)(a.unstaged);aC.setStagedTree(b),aC.setUnstagedTree(c)}).catch(()=>{})),aC.refreshDiff(),d&&aF.loadBranches();let a=a$.current;a&&f.push(i.t4.runPromise((0,k.Bj)(b,a,t.B_)).then(a=>{let b=a.commits??[];aF.setCommits(b),aF.setHasMoreCommits(b.length>=t.B_)}).catch(()=>{}))}let g=a_.current,h=a0.current;g&&"text"===h&&f.push(i.t4.runPromise((0,j.K9)(b,g)).then(a=>{let b=a.ok?a.data:null;b&&"string"==typeof b.content&&aA.setFileContent({type:"text",content:b.content,size:b.size,mtime:b.mtimeMs,...b.isSymlink?{isSymlink:!0,symlinkTarget:b.symlinkTarget}:{}})}).catch(()=>{})),await Promise.all(f)}catch(a){console.error("File watch handler error:",a)}},[b]);(0,w.h)({url:`/ws/watch?cwd=${encodeURIComponent(b)}`,onMessage:a1,enabled:az});let a2=(0,f.useCallback)(a=>{let b=a.split("/");if(b.length>1){let a=[];for(let c=1;c<b.length;c++)a.push(b.slice(0,c).join("/"));aA.setExpandedPaths(b=>{let c=new Set(b);for(let b of a)c.add(b);return aA.saveExpandedPaths(c),c})}aA.setSelectedPath(a),aA.setShouldScrollToSelected(!0),V("tree")},[aA]);return(0,e.jsxs)(q.SU,{container:$,children:[(0,e.jsxs)("div",{ref:Y,className:"bg-card w-full h-full flex flex-col relative",children:[(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsxs)("div",{className:"w-80 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex border-b border-border",children:[(0,e.jsx)("button",{onClick:()=>aX("tree"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"tree"===U?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:S("fileBrowser.directoryTree")}),(0,e.jsx)("button",{onClick:()=>aX("search"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"search"===U?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:S("fileBrowser.searchTab")}),(0,e.jsx)("button",{onClick:()=>aX("recent"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"recent"===U?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:S("fileBrowser.recentTab")}),(0,e.jsx)("button",{onClick:()=>aX("status"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"status"===U?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:S("fileBrowser.changesTab")}),(0,e.jsx)("button",{onClick:()=>aX("history"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"history"===U?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:S("fileBrowser.historyTab")})]}),"tree"===U&&(0,e.jsxs)("div",{className:"p-2 border-b border-border flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:aA.searchInputRef,type:"text",value:aA.searchQuery,onChange:a=>aA.setSearchQuery(a.target.value),placeholder:S("fileBrowser.searchFiles"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),aA.searchQuery&&(0,e.jsx)("button",{onClick:()=>aA.setSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:S("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>aA.setSearchDirExact(a=>!a),className:`px-1 py-0.5 rounded transition-colors text-xs font-mono font-bold border ${aA.searchExactMatch?"border-brand text-brand bg-brand/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:aA.searchExactMatch?S("fileBrowser.exactMatchOn"):S("fileBrowser.exactMatchOff"),children:"ab"}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:()=>aA.loadFiles(),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:S("fileBrowser.refreshTree"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,e.jsx)("button",{onClick:()=>aA.searchTreeExpandedPaths?aA.setSearchTreeExpandedPaths(new Set):aA.setExpandedPaths(new Set),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:S("fileBrowser.collapseAll"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})]})]}),"search"===U&&(0,e.jsxs)("div",{className:"p-2 border-b border-border space-y-2",children:[(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:aB.contentSearchInputRef,type:"text",value:aB.contentSearchQuery,onChange:a=>aB.setContentSearchQuery(a.target.value),onKeyDown:a=>{"Enter"===a.key&&aB.performContentSearch(aB.contentSearchQuery)},placeholder:S("fileBrowser.searchFileContent"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),aB.contentSearchQuery&&(0,e.jsx)("button",{onClick:()=>aB.setContentSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:S("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>aB.performContentSearch(aB.contentSearchQuery),disabled:aB.isSearching||!aB.contentSearchQuery.trim(),className:"px-3 py-1.5 text-sm bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed",children:aB.isSearching?"...":S("common.search")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:aB.searchOptions.caseSensitive,onChange:a=>aB.setSearchOptions(b=>({...b,caseSensitive:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:S("fileBrowser.caseSensitive")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:aB.searchOptions.wholeWord,onChange:a=>aB.setSearchOptions(b=>({...b,wholeWord:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:S("fileBrowser.wholeWord")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:aB.searchOptions.regex,onChange:a=>aB.setSearchOptions(b=>({...b,regex:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:S("fileBrowser.regex")})]}),(0,e.jsx)("input",{type:"text",value:aB.searchOptions.fileType,onChange:a=>aB.setSearchOptions(b=>({...b,fileType:a.target.value})),placeholder:S("fileBrowser.fileTypes"),className:"w-24 px-2 py-0.5 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9"})]})]}),"history"===U&&(0,e.jsx)("div",{className:"p-3 border-b border-border",children:aF.compareMode?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0 px-3 py-1.5 text-sm border border-border rounded bg-secondary text-foreground flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),(0,e.jsx)("span",{className:"truncate",children:aF.branches?.current||"HEAD"}),(0,e.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:"HEAD"})]}),(0,e.jsx)("button",{onClick:()=>aF.toggleCompareMode(!1),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors bg-brand text-white",title:S("fileBrowser.compareModeOff"),children:S("fileBrowser.compareMode")})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0 pl-1",children:"vs"}),(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(A.e,{branches:aF.branches,selectedBranch:aF.compareBaseBranch,onSelect:a=>{aF.setCompareBaseBranch(a),aF.loadCompareFiles(a)},isLoading:aF.isLoadingBranches,pinnedBranches:["origin/main",...aF.upstreamBranch&&"origin/main"!==aF.upstreamBranch?[aF.upstreamBranch]:[]]})})]})]}):(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(A.e,{branches:aF.branches,selectedBranch:aF.selectedBranch,onSelect:a=>{aF.setSelectedBranch(a)},isLoading:aF.isLoadingBranches,pinnedBranches:["origin/main",...aF.upstreamBranch&&"origin/main"!==aF.upstreamBranch?[aF.upstreamBranch]:[]]})}),(0,e.jsx)("button",{onClick:()=>aF.toggleCompareMode(!0),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors text-muted-foreground hover:text-foreground hover:bg-accent border border-border",title:S("fileBrowser.compareModeOn"),children:S("fileBrowser.compareMode")})]})}),(0,e.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,e.jsxs)("div",{className:`flex-1 flex flex-col min-h-0 ${"tree"===U?"":"hidden"}`,children:[aA.creatingItem&&(0,e.jsxs)("div",{className:"px-2 py-1.5 border-b border-border bg-secondary flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:aA.creatingItem.parentPath?S("fileBrowser.createFileIn",{path:aA.creatingItem.parentPath}):S("fileBrowser.createFile")}),(0,e.jsx)("input",{type:"text",autoFocus:!0,placeholder:S("fileBrowser.fileName"),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring",onCompositionStart:()=>{Z.current=!0},onCompositionEnd:()=>{Z.current=!1},onKeyDown:async a=>{if("Enter"===a.key){if(Z.current)return;let c=a.target.value.trim();if(!c)return;let d=aA.creatingItem.parentPath,e=d?`${d}/${c}`:c,f=await i.t4.runPromiseExit((0,j.OJ)({cwd:b,path:e,content:""}));if("Success"===f._tag&&f.value.ok)(0,n.oR)(S("toast.createdFile",{name:c}),"success"),aA.setCreatingItem(null),aA.loadDirectory(d),aA.loadFileIndex(),d&&aA.setExpandedPaths(a=>new Set([...a,d])),aL(e);else if("Success"===f._tag){let a=f.value.data?.error;(0,n.oR)(a||S("toast.createFailed"),"error")}else(0,n.oR)(S("toast.createFailed"),"error")}else"Escape"===a.key&&aA.setCreatingItem(null)},onBlur:()=>aA.setCreatingItem(null)})]}),aA.isLoadingFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:S("common.loading")}):aA.fileError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:aA.fileError}):(0,e.jsx)(o.h,{files:aA.files,selectedPath:aA.selectedPath,expandedPaths:aA.effectiveExpandedPaths,matchedPaths:aA.matchedPaths,gitStatusMap:aW,loadingDirs:aA.loadingDirs,onSelect:a=>{aA.setShouldScrollToSelected(!1),aL(a)},onToggle:aA.handleToggle,cwd:b,shouldScrollToSelected:aA.shouldScrollToSelected,onScrolledToSelected:()=>aA.setShouldScrollToSelected(!1),onCreateFile:a=>aA.setCreatingItem({type:"file",parentPath:a}),onDelete:(a,b,c)=>ab({path:a,isDirectory:b,name:c}),onRefresh:()=>aA.loadFiles(),onCopyFile:aY,onPaste:aZ})]}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"search"===U?"":"hidden"}`,children:aB.isSearching?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):aB.searchError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:aB.searchError}):0===aB.contentSearchResults.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:aB.contentSearchQuery?S("fileBrowser.noContentSearchResults"):S("fileBrowser.enterKeywordToSearch")}):(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[aB.searchStats&&(0,e.jsxs)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-secondary border-b border-border flex-shrink-0",children:[S("fileBrowser.nFilesNMatches",{files:aB.searchStats.totalFiles,matches:aB.searchStats.totalMatches}),aB.searchStats.truncated&&(0,e.jsxs)("span",{className:"text-amber-11 ml-1",children:["(",S("fileBrowser.resultsTruncated"),")"]})]}),(0,e.jsx)(o.h,{files:aM.files,selectedPath:aA.selectedPath,expandedPaths:aN,onSelect:a=>{let b=aM.matchMap.get(a);aL(a,b?.matches[0]?.lineNumber),al||am(!0)},onToggle:aP,cwd:b,renderActions:aQ,className:"flex-1 overflow-y-auto py-1 min-w-max"})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"recent"===U?"":"hidden"}`,children:0===aA.recentFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:S("fileBrowser.noRecentFiles")}):(0,e.jsx)(o.h,{files:aA.recentFilesTree,selectedPath:aA.selectedPath,expandedPaths:aA.recentTreeDirPaths,onSelect:aL,onToggle:t.tE,cwd:b})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"status"===U?"":"hidden"}`,children:aC.statusLoading?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):aC.statusError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center p-4",children:(0,e.jsx)("span",{className:"text-red-11 text-sm",children:aC.statusError})}):(0,e.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[(0,e.jsxs)("div",{className:"border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:S("fileBrowser.stagingArea",{count:aC.status?.staged.length||0})}),(0,e.jsx)("button",{onClick:()=>aC.fetchStatus(),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:S("fileBrowser.refreshChanges"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),(aC.status?.staged.length||0)>0&&(0,e.jsx)("button",{onClick:aC.handleUnstageAll,className:"text-sm text-amber-11 hover:text-amber-10 hover:underline",children:S("fileBrowser.unstageAll")})]}),(0,e.jsx)(p.VO,{files:aC.stagedTree,selectedPath:aC.statusSelectedFile?.type==="staged"?aC.statusSelectedFile.file.path:null,expandedPaths:aC.stagedExpandedPaths,onSelect:a=>a.file&&aC.handleStatusFileSelect(a.file,"staged"),onToggle:aC.handleStagedToggle,cwd:b,emptyMessage:S("fileBrowser.noStagedFiles"),className:"py-1",renderActions:a=>{if(a.isDirectory){let b=(0,p.wI)(a);return 0===b.length?null:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),aC.handleUnstageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:S("fileBrowser.unstageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}return(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),aC.handleUnstage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:S("fileBrowser.unstageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:S("fileBrowser.workspace",{count:aC.status?.unstaged.length||0})}),(aC.status?.unstaged.length||0)>0&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:aC.handleDiscardAll,className:"text-sm text-red-11 hover:text-red-10 hover:underline",children:S("fileBrowser.discardAll")}),(0,e.jsx)("button",{onClick:aC.handleStageAll,className:"text-sm text-green-11 hover:text-green-10 hover:underline",children:S("fileBrowser.stageAll")})]})]}),(0,e.jsx)(p.VO,{files:aC.unstagedTree,selectedPath:aC.statusSelectedFile?.type==="unstaged"?aC.statusSelectedFile.file.path:null,expandedPaths:aC.unstagedExpandedPaths,onSelect:a=>a.file&&aC.handleStatusFileSelect(a.file,"unstaged"),onToggle:aC.handleUnstagedToggle,cwd:b,emptyMessage:S("fileBrowser.noUnstagedChanges"),className:"py-1",renderActions:a=>{if(a.isDirectory){let b=(0,p.wI)(a);if(0===b.length)return null;let c=b.map(a=>a.file).filter(Boolean);return(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),aC.handleDiscardFiles(c)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:S("fileBrowser.discardNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),aC.handleStageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:S("fileBrowser.stageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})}return a.file?(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),aC.handleDiscardFile(a.file)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:S("fileBrowser.discardChanges"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),aC.handleStage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:S("fileBrowser.stageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]}):null}})]})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"history"===U?"":"hidden"}`,children:aF.historyError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,e.jsx)("p",{className:"text-muted-foreground",children:aF.historyError})]})}):aF.compareMode?(0,e.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:aF.isLoadingCompareFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:S("fileBrowser.loadingDiff")}):0===aF.compareFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:S("fileBrowser.noDiffFiles")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"px-3 py-2 border-b border-border",children:(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:S("fileBrowser.nFilesChanged",{count:aF.compareFiles.length,branch:aF.compareBaseBranch})})}),(0,e.jsx)(p.VO,{files:aF.compareFileTree,expandedPaths:aF.compareExpandedPaths,onToggle:aF.handleCompareToggle,selectedPath:aF.compareSelectedFile?.path||null,onSelect:a=>{a.file&&aF.handleSelectCompareFile(a.file)},cwd:b,showChanges:!0})]})}):(0,e.jsx)("div",{ref:aF.commitListRef,className:"flex-1 overflow-y-auto",onScroll:aF.handleCommitListScroll,children:aF.isLoadingCommits?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:S("fileBrowser.loadingCommits")}):0===aF.commits.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:S("fileBrowser.noCommits")}):(0,e.jsxs)(e.Fragment,{children:[aF.commits.map(a=>(0,e.jsxs)("div",{onClick:()=>aF.handleSelectCommit(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-accent ${aF.selectedCommit?.hash===a.hash?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"font-mono text-xs text-brand",children:a.shortHash}),(0,e.jsxs)("span",{className:"text-xs text-slate-9",title:a.date,children:[a.relativeDate," \xb7 ",(0,t.r6)(a.date)]})]}),(0,e.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5","data-tooltip":a.subject,children:a.subject}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.author})]},a.hash)),aF.isLoadingMore&&(0,e.jsx)("div",{className:"p-3 text-center",children:(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),!aF.hasMoreCommits&&aF.commits.length>0&&(0,e.jsx)("div",{className:"p-3 text-center text-xs text-slate-9",children:S("fileBrowser.allLoaded",{count:aF.commits.length})})]})})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[("tree"===U||"search"===U||"recent"===U)&&(aA.blameSelectedCommit?(0,e.jsx)(l.n,{isOpen:!0,onClose:()=>aA.setBlameSelectedCommit(null),commit:aA.blameSelectedCommit,cwd:b,embedded:!0,initialFilePath:aA.selectedPath||void 0,onContentSearch:a=>{V("search"),aB.setContentSearchQuery(a),aB.performContentSearch(a)}}):"map"===W?(0,e.jsx)(y.O,{cwd:b,highlightedFilePath:aA.selectedPath,changedFiles:aD,onSwitchToCode:()=>X("code"),enableComments:!0,onContentSearch:a=>{V("search"),aB.setContentSearchQuery(a),aB.performContentSearch(a)},headerExtraLeft:({focalFile:a})=>a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${b}/${a}`),(0,n.oR)(S("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:S("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:b=>{b.stopPropagation(),a2(a)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:S("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]})}):aA.selectedPath?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex-shrink-0 flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground truncate",children:aA.selectedPath}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(`${b}/${aA.selectedPath}`),(0,n.oR)(S("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:S("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:a=>{a.stopPropagation(),a2(aA.selectedPath)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:S("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),(0,e.jsx)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:aA.showEditor?(0,e.jsxs)(e.Fragment,{children:[aj.isDirty&&(0,e.jsx)("span",{className:"text-xs text-amber-11",children:S("fileBrowser.unsaved")}),(0,e.jsx)("button",{onClick:()=>ai.current?.save(),disabled:!aj.isDirty||aj.isSaving,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aj.isDirty&&!aj.isSaving?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:aj.isSaving?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):S("common.save")}),(0,e.jsx)("button",{onClick:()=>ai.current?.close(),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:S("fileBrowser.closeEdit"),children:S("fileBrowser.closeBtn")})]}):(0,e.jsxs)(e.Fragment,{children:[aA.fileContent?.type==="text"&&aA.fileContent.content&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(aA.fileContent.content),(0,n.oR)(S("toast.copiedFileContent"))},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:S("fileBrowser.copyFileContent"),children:S("common.copy")}),aA.selectedPath?.endsWith(".json")&&aA.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:()=>ao(a=>!a),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${an?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,title:S("fileBrowser.toggleJsonReadable"),children:S("common.readable")}),aA.fileContent?.type==="text"&&(0,s.e$)(aA.selectedPath)&&(0,e.jsx)("button",{onClick:()=>aA.setShowMarkdownPreview(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:S("fileBrowser.previewMarkdown"),children:S("common.preview")}),aA.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:aA.handleToggleBlame,disabled:aA.isLoadingBlame,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aA.showBlame?"bg-brand text-white":"text-muted-foreground hover:bg-accent"} disabled:opacity-50`,title:S("fileBrowser.viewBlame"),children:aA.isLoadingBlame?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):"Blame"}),aA.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:()=>X("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:S("blockViewer.viewerToggle.toBlock"),children:S("common.codeMap")}),aA.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:()=>aA.setShowEditor(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:S("fileBrowser.editFile"),children:S("common.edit")})]})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:aA.isLoadingContent?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):aA.fileContent?"text"===aA.fileContent.type&&"string"==typeof aA.fileContent.content?aA.showBlame&&aA.blameError?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("p",{className:"text-red-11",children:aA.blameError}),(0,e.jsx)("button",{onClick:()=>aA.setShowBlame(!1),className:"mt-2 text-brand hover:underline text-sm",children:S("fileBrowser.backToPreview")})]})}):aA.showBlame&&0===aA.blameLines.length&&aA.isLoadingBlame?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):an&&aA.selectedPath?.endsWith(".json")?(0,e.jsxs)("div",{className:"h-full flex flex-col bg-[#0d1117]",children:[(0,e.jsx)(J._,{search:as}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,e.jsx)("pre",{ref:ar,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,s.xb)(aA.fileContent.content)})})]}):(0,e.jsx)(r.Cv,{ref:ai,content:aA.fileContent.content,filePath:aA.selectedPath,cwd:b,enableComments:!0,scrollToLine:ag??aA.targetLineNumber,scrollToLineAlign:null!=ag?"start":aA.targetScrollAlign,onScrollToLineComplete:()=>{ah(null),aA.setTargetLineNumber(null)},highlightKeyword:"search"===U?aB.contentSearchQuery:null,visibleLineRef:ae,viStateRef:af,initialCursorLine:aA.initialCursorLine,initialCursorCol:aA.initialCursorCol,onInitialCursorSet:()=>{aA.setInitialCursorLine(null),aA.setInitialCursorCol(null)},onCmdClick:aS?aT:void 0,onTokenHover:aS?aU:void 0,onTokenHoverLeave:aS?aw.onTokenMouseLeave:void 0,onTokenHoverCancel:aS?aw.clearHover:void 0,blameLines:aA.showBlame&&aA.blameLines.length>0?aA.blameLines:void 0,inlineBlameLines:aA.blameLines.length>0?aA.blameLines:void 0,onSelectCommit:aA.setBlameSelectedCommit,editable:aA.showEditor,initialMtime:aA.fileContent.mtime,onEditorClose:a=>{aA.setShowEditor(!1),ah(a)},onSaved:()=>{let a=ae.current??1;aA.loadFileContent(aA.selectedPath),aA.setShowEditor(!1),ah(a)},onEditorStateChange:ak,viMode:!0,onContentMutate:aH,onEnterInsertMode:aI,onViSave:aJ,onContentSearch:a=>{V("search"),aB.setContentSearchQuery(a),aB.performContentSearch(a)}}):"image"===aA.fileContent.type&&aA.selectedPath?(0,e.jsx)(B.I,{cwd:b,path:aA.selectedPath,refreshKey:aA.fileContent.mtime,alt:aA.selectedPath}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,e.jsx)("p",{children:aA.fileContent.message||S("fileBrowser.cannotPreview")})]})}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:S("fileBrowser.selectFileToPreview")})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,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,e.jsx)("p",{children:S("fileBrowser.selectFileToPreview")})]})})),"status"===U&&(aC.statusSelectedFile&&aC.statusDiff?(0,e.jsx)(z.m,{cwd:b,selected:aC.statusSelectedFile,diff:aC.statusDiff,showMarkdownPreview:aC.showStatusDiffPreview,setShowMarkdownPreview:aC.setShowStatusDiffPreview,changedFiles:aD,fileGitStatusMap:aE,onContentSearch:a=>{V("search"),aB.setContentSearchQuery(a),aB.performContentSearch(a)},locateInTree:a2,jsonPreview:ap,setJsonPreview:aq,jsonPreviewSearch:au,jsonPreviewPreRef:at}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:S("fileBrowser.selectFileToViewDiff")})})),"history"===U&&!aF.historyError&&(aF.compareMode?aF.isLoadingCompareDiff?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:S("fileBrowser.loadingDiffContent")}):aF.compareFileDiff?(0,e.jsx)(m.xZ,{oldContent:aF.compareFileDiff.oldContent,newContent:aF.compareFileDiff.newContent,filePath:aF.compareFileDiff.filePath,isNew:aF.compareFileDiff.isNew,isDeleted:aF.compareFileDiff.isDeleted,cwd:b,enableComments:!0,onPreview:!aF.compareFileDiff.isDeleted&&aF.compareFileDiff.filePath.endsWith(".json")?()=>aq({content:aF.compareFileDiff.newContent,filePath:aF.compareFileDiff.filePath}):void 0,previewLabel:S("common.readable"),onContentSearch:a=>{V("search"),aB.setContentSearchQuery(a),aB.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:aF.compareFiles.length>0?S("fileBrowser.selectFileToViewDiff"):S("fileBrowser.clickCompareToLoad")})}):aF.selectedCommit?(0,e.jsx)(l.n,{isOpen:!0,onClose:()=>aF.setSelectedCommit(null),commit:aF.selectedCommit,cwd:b,embedded:!0,onContentSearch:a=>{V("search"),aB.setContentSearchQuery(a),aB.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:S("fileBrowser.selectCommitToView")})}))]})]}),aA.showMarkdownPreview&&aA.fileContent?.type==="text"&&aA.selectedPath&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>aA.setShowMarkdownPreview(!1),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(u.M,{content:aA.fileContent.content||"",filePath:aA.selectedPath,cwd:b,onClose:()=>aA.setShowMarkdownPreview(!1)})})}),ac&&(0,e.jsx)(v.c,{files:aA.files,fileIndex:aA.fileIndex,recentFiles:aA.recentFilePaths,onSelectFile:a=>{aL(a),aA.setShouldScrollToSelected(!0),V("tree")},onClose:()=>ad(!1)}),(aR||ax.visible)&&(0,e.jsxs)("div",{className:`flex ${ax.visible&&aR?"":"flex-col"}`,children:[aR&&(0,e.jsx)("div",{className:ax.visible?"flex-1 min-w-0 border-r border-border":"",children:(0,e.jsx)(N.D,{results:aB.contentSearchResults,loading:aB.isSearching,totalMatches:aB.searchStats?.totalMatches??0,onSelect:(a,b)=>{aA.selectedPath&&ay.push({filePath:aA.selectedPath,lineNumber:ae.current}),aL(a,b)},onClose:()=>am(!1)})}),ax.visible&&(0,e.jsx)("div",{className:aR?"flex-1 min-w-0":"",children:(0,e.jsx)(M.D,{references:ax.references,loading:ax.loading,onSelect:aV,onClose:ax.closeReferences})})]})]}),aa&&(0,e.jsx)(h.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-black/50",onClick:()=>ab(null),children:(0,e.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground mb-2",children:S("fileBrowser.confirmDelete")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:S("fileBrowser.confirmDeleteMessage",{name:aa.name}).split(/<\/?file>/g).map((a,b)=>1===b?(0,e.jsx)("span",{className:"font-mono text-foreground",children:a},b):a)}),(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)("button",{onClick:()=>ab(null),className:"px-3 py-1.5 text-sm rounded border border-border hover:bg-accent transition-colors",children:S("common.cancel")}),(0,e.jsx)("button",{onClick:async()=>{let{path:a,name:c}=aa;ab(null);let d=await i.t4.runPromiseExit((0,j.VK)({cwd:b,path:a}));if("Success"===d._tag){(0,n.oR)(S("toast.movedToTrash",{name:c}),"success");let b=a.includes("/")?a.substring(0,a.lastIndexOf("/")):"";aA.loadDirectory(b),aA.loadFileIndex(),aA.selectedPath===a&&aL("")}else{let a="Fail"===d.cause._tag?d.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:S("toast.deleteFailed");(0,n.oR)(c,"error")}},className:"px-3 py-1.5 text-sm rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:S("common.delete")})]})]})})}),aw.hoverInfo&&$&&(0,g.createPortal)((0,e.jsx)(L.s,{ref:aw.setTooltipEl,displayString:aw.hoverInfo.displayString,documentation:aw.hoverInfo.documentation,x:aw.hoverInfo.x,y:aw.hoverInfo.y,container:$,onMouseEnter:aw.onCardMouseEnter,onMouseLeave:aw.onCardMouseLeave,onFindReferences:()=>{let{filePath:a,line:b,column:c}=aw.hoverInfo;aw.clearHover(),ax.findReferences(a,b,c)},onSearch:a=>{aw.clearHover(),V("search"),aB.setContentSearchQuery(a),aB.performContentSearch(a)}}),$)]})}[E,F,p,o,l,y,r,z,m,u,v,N,M]=P.then?(await P)():P,d()}catch(a){d(a)}})},70404:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484);function f(a,b){for(let c=0;c<a.blocks.length;c++){let d=a.blocks[c];if(b>=d.startLine&&b<=d.endLine)return a.prefix[c]+(b-d.startLine)}return null}function g({addedLines:a,blockRanges:b,viewportRange:c,onJumpToLine:h}){let i,j=(0,e.useRef)(null),k=(0,e.useMemo)(()=>(function(a){let b=[...a].sort((a,b)=>a.startLine-b.startLine),c=[0];for(let a of b){let b=Math.max(0,a.endLine-a.startLine+1);c.push(c[c.length-1]+b)}return{blocks:b,prefix:c,total:c[c.length-1]}})(b),[b]),l=(0,e.useMemo)(()=>{if(k.total<=0||0===a.size)return[];let b=[];for(let c of a){let a=k.blocks.find(a=>c>=a.startLine&&c<=a.endLine);a&&b.push({line:c,qname:a.qname})}b.sort((a,b)=>a.line-b.line);let c=[],d=null;for(let a of b)d&&a.line===d.end+1&&a.qname===d.qname?d.end=a.line:(d&&c.push(d),d={start:a.line,end:a.line,qname:a.qname});return d&&c.push(d),c},[a,k]);if(k.total<=0)return null;let m=(a,b)=>{let c=f(k,a),d=f(k,b);return null===c||null===d?null:{top:c/k.total*100,heightPct:(d-c+1)/k.total*100}};return(0,d.jsxs)("div",{ref:j,onClick:a=>{let b=j.current;if(!b)return;let c=b.getBoundingClientRect();if(c.height<=0)return;let d=function(a,b){if(a.total<=0)return null;let c=Math.max(0,Math.min(a.total-1,b));for(let b=0;b<a.blocks.length;b++){let d=a.prefix[b],e=a.prefix[b+1];if(c>=d&&c<e){let e=a.blocks[b];return{qname:e.qname,line:e.startLine+Math.round(c-d)}}}return null}(k,(a.clientY-c.top)/c.height*k.total);if(!d)return;let e=d.line,g=l.find(a=>a.qname===d.qname&&e>=a.start&&e<=a.end);if(g)return void h(g.qname,e);if(l.length>0){let a=Math.max(2,Math.round(.05*k.total)),b=f(k,e);if(null!==b){let c=null,d=1/0;for(let a of l){let e=f(k,a.start),g=f(k,a.end);if(null===e||null===g)continue;let h=b<e?e-b:b>g?b-g:0;h<d&&(c=a,d=h)}if(c&&d<=a){let a=e<c.start?c.start:e>c.end?c.end:e;h(c.qname,a);return}}}let i=k.blocks.find(a=>a.qname===d.qname);i&&h(i.qname,i.startLine)},className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",title:"Diff minimap — click to jump",children:[l.map(a=>{let b=m(a.start,a.end);return b?(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-green-9 pointer-events-none",style:{top:`${b.top}%`,height:`${b.heightPct}%`,minHeight:"2px"}},`run:${a.qname}:${a.start}-${a.end}`):null}),c&&c.end>=c.start&&((i=m(c.start,c.end))?(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border pointer-events-none",style:{top:`${i.top}%`,height:`${Math.max(1.2,i.heightPct)}%`}}):null)]})}},70440:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(88868);let e=async a=>[{type:"image/x-icon",sizes:"16x16",url:(0,d.fillMetadataSegment)(".",await a.params,"favicon.ico",!0)+"?603d046c9a6fdfbb"}]},70596:(a,b,c)=>{"use strict";c.d(b,{t:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({x:a,y:b,comment:c,container:h,onClose:i,onUpdateComment:j,onDeleteComment:k}){let{t:l}=(0,f.Bd)(),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(c.content),q=(0,e.useRef)(null),[r,s]=(0,e.useState)({x:0,y:0}),t=async()=>{o.trim()&&(await j(c.id,o.trim()),n(!1))},u=async()=>{await k(c.id),i()};return(0,d.jsx)("div",{ref:q,className:"absolute z-[200] w-96 bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:r.x,top:r.y},children:(0,d.jsx)("div",{className:"p-3",children:m?(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("textarea",{value:o,onChange:a=>p(a.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:a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),t()),"Escape"===a.key&&(n(!1),p(c.content))}}),(0,d.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,d.jsx)("button",{onClick:()=>{n(!1),p(c.content)},className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground",children:l("common.cancel")}),(0,d.jsx)("button",{onClick:t,className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90",children:l("common.save")})]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:c.content}),(0,d.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:l("comments.lineRange",{start:c.startLine,end:c.endLine})}),(0,d.jsxs)("div",{className:"flex gap-1",children:[(0,d.jsx)("button",{onClick:()=>n(!0),className:"p-1 rounded hover:bg-accent text-muted-foreground",title:l("common.edit"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:u,className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-red-9",title:l("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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"})})})]})]})]})})})}},71192:(a,b,c)=>{"use strict";c.d(b,{m_:()=>f,uV:()=>e});var d=c(81218);class e extends d.rN("AppError"){}d.rN("DBError"),d.rN("WSError"),d.rN("FSError"),d.rN("AgentError"),d.rN("ValidationError");class f extends d.rN("NotFoundError"){}d.rN("PermissionError")},72399:(a,b,c)=>{"use strict";c.d(b,{ProjectSidebar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectSidebar() from the server but ProjectSidebar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/ProjectSidebar.tsx","ProjectSidebar")},72529:(a,b,c)=>{"use strict";c.d(b,{m:()=>f});var d=c(48249),e=c(67484);function f({content:a,children:b,className:c}){if(c)return(0,d.jsx)("div",{"data-tooltip":a,className:c,children:b});let g=e.Children.toArray(b);if(1===g.length&&(0,e.isValidElement)(g[0])){let b=g[0];return(0,e.cloneElement)(b,{"data-tooltip":a})}return(0,d.jsx)("div",{"data-tooltip":a,style:{display:"contents"},children:b})}},73414:(a,b,c)=>{"use strict";c.d(b,{YO:()=>d,pU:()=>e});let d=20;function e(a,b,c,f=[]){let g=a.length,h=c=>"unchanged"!==a[c].type||"unchanged"!==b[c].type,i=new Set;for(let a=0;a<g;a++){if(!h(a))continue;let b=Math.max(0,a-3),c=Math.min(g-1,a+3);for(let a=b;a<=c;a++)i.add(a)}let j=[];for(let a=0;a<g;a++){if(i.has(a))continue;let b=a;for(;a<g&&!i.has(a);)a++;j.push({id:j.length,startIdx:b,endIdx:a-1}),a--}for(let a of j){let b=c.get(a.id)??{topRevealed:0,bottomRevealed:0},d=a.endIdx-a.startIdx+1,e=Math.max(0,Math.min(b.topRevealed,d)),f=Math.max(0,Math.min(b.bottomRevealed,d-e));for(let b=a.startIdx;b<a.startIdx+e;b++)i.add(b);for(let b=a.endIdx-f+1;b<=a.endIdx;b++)i.add(b)}let k=[];for(let a=0;a<g;a++){let c;if(i.has(a)){k.push({kind:"diff",idx:a});continue}let e=a;for(;a<g&&!i.has(a);)a++;let h=a-1;a--;let l=j.find(a=>a.startIdx<=e&&h<=a.endIdx);if(!l)continue;let m=h-e+1,n=Math.min(d,m);if(f.length>0&&h+1<g)for(let a=h+1;a<g;a++){let d=b[a].lineNum;if(!(d<=0)){c=function(a,b){let c=null;for(let d of a)d.startLine<=b&&b<=d.endLine&&(!c||d.endLine-d.startLine<c.endLine-c.startLine)&&(c=d);return c}(f,d)??void 0;break}}k.push({kind:"gap-expand",gapId:l.id,direction:"up",revealCount:n}),k.push({kind:"gap-label",gapId:l.id,hiddenCount:m,enclosingFn:c}),k.push({kind:"gap-expand",gapId:l.id,direction:"down",revealCount:n})}return{rows:k,gaps:j}}},73887:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>v});var e=c(48249),f=c(67484),g=c(44384),h=c(74429),i=c(7122),j=c(41051),k=c(42140),l=c(70596),m=c(74754),n=c(7031),o=c(91579),p=c(87844),q=c(84835),r=c(24680),s=c(25465),t=c(37690),u=a([s]);s=(u.then?(await u)():u)[0];let w=[q.W];function v({content:a,filePath:b,cwd:c,onClose:d,sourceFile:q}){let u=q||(c&&b.startsWith(c)?b.slice(c.endsWith("/")?c.length:c.length+1):b),{t:x}=(0,g.Bd)(),y=(0,i.iN)(),z=(0,n.r)(),{comments:A,addComment:B,updateComment:C,deleteComment:D,refresh:E}=(0,m._)({cwd:c,filePath:b}),[F,G]=(0,f.useState)(!1),[H,I]=(0,f.useState)(null),[J,K]=(0,f.useState)(null),[L,M]=(0,f.useState)(null),N=(0,f.useMemo)(()=>a.split("\n"),[a]),[O,P]=(0,f.useState)(null),Q=(0,f.useRef)(null),{toolbarRef:R,bumpRef:S,clearToolbar:T}=(0,t.L)({enabled:!0,container:O,resolveLineRange:a=>{let b=function(a){let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a;if(!b||!("closest"in b))return null;let c=b.closest("[data-source-start]");if(!c)return null;let d=c.getAttribute("data-source-start"),e=c.getAttribute("data-source-end");return d&&e?{start:parseInt(d,10),end:parseInt(e,10)}:null}(a);return b?{start:b.start,end:b.end}:null},buildLineSnapshot:({start:a,end:b})=>{let c=Math.max(0,a-1),d=Math.min(N.length,b);return N.slice(c,d).join("\n")}}),U=(0,f.useCallback)(()=>{let a=R.current;a&&(I({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),T())},[T,R]),V=(0,f.useCallback)(()=>{let a=R.current;a&&(K({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),T())},[T,R]),W=(0,f.useCallback)(async a=>{H&&(await B(H.range.start,H.range.end,a,H.selectedText),I(null))},[H,B]),X=(0,f.useCallback)(async a=>{if(J&&z)try{let d=await (0,o.$3)(c),e=[];for(let a of d)e.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});e.push({filePath:b,startLine:J.range.start,endLine:J.range.end,codeContent:J.lineSnapshot});let f=(0,o.Gw)(e,a);z.sendMessage(f),await (0,o.RP)(c),E(),K(null)}catch(a){console.error("Failed to send to AI:",a)}},[J,z,b,c,E]);(0,f.useMemo)(()=>{if(0===A.length)return[];let a=new Map;for(let b of A){let c=`${b.startLine}-${b.endLine}`;a.has(c)||a.set(c,[]),a.get(c).push(b)}return Array.from(a.entries()).map(([a,b])=>({key:a,startLine:b[0].startLine,endLine:b[0].endLine,comments:b}))},[A]);let[Y,Z]=(0,f.useState)([]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:b}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(s.ShareReviewToggle,{content:a,sourceFile:u}),(0,e.jsx)("button",{onClick:d,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:x("common.close"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsx)(r.l,{content:a,containerRef:Q}),(0,e.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:Q,children:[(0,e.jsx)("div",{className:"p-6",children:(0,e.jsx)(p.T,{content:a,rehypePlugins:w})}),Y.map(({key:a,top:b,comments:c})=>(0,e.jsx)("div",{className:"absolute right-3 cursor-pointer z-10",style:{top:b},onClick:a=>{a.stopPropagation(),M({comment:c[0],x:a.clientX,y:a.clientY})},children:(0,e.jsx)("div",{className:"w-5 h-5 rounded-full bg-amber-500/80 text-white text-xs flex items-center justify-center shadow-sm hover:bg-amber-500 transition-colors",children:c.length})},a))]})]}),F&&y&&(0,h.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(j.f,{floatingToolbarRef:R,bumpRef:S,container:y,onAddComment:U,onSendToAI:V,isChatLoading:z?.isLoading}),H&&(0,e.jsx)(k.t,{x:H.x,y:H.y,range:H.range,lineSnapshot:H.lineSnapshot,container:y,onSubmit:W,onClose:()=>I(null)}),J&&(0,e.jsx)(k.G,{x:J.x,y:J.y,range:J.range,filePath:b,lineSnapshot:J.lineSnapshot,container:y,onSubmit:X,onClose:()=>K(null),isChatLoading:z?.isLoading}),L&&(0,e.jsx)(l.t,{x:L.x,y:L.y,comment:L.comment,container:y,onClose:()=>M(null),onUpdateComment:C,onDeleteComment:D})]}),y)]})}d()}catch(a){d(a)}})},74493:(a,b,c)=>{"use strict";c.d(b,{Ey:()=>n,GW:()=>m,HS:()=>o,Hj:()=>i,ax:()=>h,qM:()=>j});var d=c(79606),e=c(33281),f=c(71192);let g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:b=>new f.uV({message:`POST ${a} failed`,cause:b})}),h=(a,b)=>e.t4.runPromise(g(`/api/${a}/disconnect`,{id:b}).pipe(d.orElse(()=>d.void))),i=a=>e.t4.runPromise(g("/api/jupyter/shutdown",{bubbleId:a}).pipe(d.orElse(()=>d.void))),j=a=>e.t4.runPromise(g("/api/browser/unregister",{id:a}).pipe(d.orElse(()=>d.void))),k=a=>e.t4.runPromise(a.pipe(d.catchAll(a=>d.sync(()=>{if(a.cause instanceof Error)throw a.cause;throw Error(a.message)})))),l=(a,b)=>{if(a&&"object"==typeof a&&"error"in a){let b=a.error;if("string"==typeof b&&b.length>0)return b;if(b&&"object"==typeof b){let a=b.message;if("string"==typeof a&&a.length>0)return a;let c=b._tag;if("string"==typeof c&&c.length>0)return c}}return`HTTP ${b}`},m=(a,b)=>k(d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),d=await c.json();if(!c.ok)throw Error(l(d,c.status));return d},catch:b=>new f.uV({message:`POST ${a} failed`,cause:b})})),n=(a,b)=>k(d.tryPromise({try:async()=>{let c=new URLSearchParams(b),d=await fetch(`${a}?${c}`),e=await d.json();if(!d.ok)throw Error(l(e,d.status));return e},catch:b=>new f.uV({message:`GET ${a} failed`,cause:b})})),o=(a,b)=>k(d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`);return c.blob()},catch:b=>new f.uV({message:`POST blob ${a} failed`,cause:b})}))},74542:(a,b,c)=>{"use strict";c.d(b,{b:()=>f});var d=c(48249),e=c(67484);function f({lines:a,containerRef:b}){let c=(0,e.useRef)(null),[g,h]=(0,e.useState)({top:0,height:0});if(0===a.length)return null;let i=100/a.length;return(0,d.jsxs)("div",{ref:c,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:a=>{let d=b.current,e=c.current;if(!d||!e)return;let f=e.getBoundingClientRect(),g=(a.clientY-f.top)/f.height*d.scrollHeight-d.clientHeight/2;d.scrollTo({top:Math.max(0,g),behavior:"smooth"})},children:[a.map((a,b)=>"unchanged"!==a.type&&(0,d.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===a.type?"bg-red-9":"bg-green-9"}`,style:{top:`${b*i}%`,height:`${Math.max(i,.5)}%`,minHeight:"2px"}},b)),(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border",style:{top:`${g.top}px`,height:`${Math.max(g.height,10)}px`}})]})}},74754:(a,b,c)=>{"use strict";c.d(b,{_:()=>g});var d=c(67484);c(91579);var e=c(33281),f=c(89800);function g({cwd:a,filePath:b}){let[c,h]=(0,d.useState)([]),[i,j]=(0,d.useState)(!1),[k,l]=(0,d.useState)(null),m=(0,d.useCallback)(async()=>{if(!a||!b)return;j(!0),l(null);let c=await e.t4.runPromiseExit((0,f.lb)(a,b));if("Success"===c._tag)h(c.value.comments??[]);else{let a="Fail"===c.cause._tag?c.cause.error:null,b=a?.cause;l(b instanceof Error?b.message:"Failed to load comments")}j(!1)},[a,b]),n=(0,d.useCallback)(async(c,d,g,i)=>{let j=await e.t4.runPromiseExit((0,f.BC)({cwd:a,filePath:b,startLine:c,endLine:d,content:g,...i?{selectedText:i}:{}}));if("Success"===j._tag&&j.value.comment){let a=j.value.comment;return h(b=>[...b,a]),a}return"Failure"===j._tag&&console.error("Failed to add comment:",j.cause),null},[a,b]),o=(0,d.useCallback)(async(b,c)=>{let d=await e.t4.runPromiseExit((0,f.vv)(a,b,c));if("Success"===d._tag&&d.value.comment){let a=d.value.comment;return h(c=>c.map(c=>c.id===b?a:c)),!0}return"Failure"===d._tag&&console.error("Failed to update comment:",d.cause),!1},[a]),p=(0,d.useCallback)(async b=>{let c=await e.t4.runPromiseExit((0,f.Tu)(a,b));return"Success"===c._tag?(h(a=>a.filter(a=>a.id!==b)),!0):(console.error("Failed to delete comment:",c.cause),!1)},[a]),q=(0,d.useCallback)(a=>c.filter(b=>a>=b.startLine&&a<=b.endLine),[c]);return{comments:c,isLoading:i,error:k,addComment:n,updateComment:o,deleteComment:p,refresh:m,getCommentsForLine:q}}},74837:(a,b,c)=>{"use strict";c.d(b,{NoteToolbar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call NoteToolbar() from the server but NoteToolbar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/NoteToolbar.tsx","NoteToolbar")},74991:(a,b,c)=>{"use strict";c.d(b,{I:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(30458);function h(a,b){if("once"===a.type)return b("scheduledTasks.onceType",{minutes:a.delayMinutes});if("interval"===a.type){let c=b("scheduledTasks.everyNMinutes",{minutes:a.intervalMinutes});return a.activeFrom&&a.activeTo?`${c} (${a.activeFrom}-${a.activeTo})`:c}return"cron"===a.type?a.cron||"cron":a.type}function i(a){return a.unread?"bg-red-500":a.completed?"bg-muted-foreground":a.paused?"bg-yellow-500":"error"===a.lastResult?"bg-red-500":"bg-green-500"}function j({collapsed:a,tasks:b,unreadCount:c,onSwitchProject:k,onPause:l,onResume:m,onTrigger:n,onDelete:o,onMarkRead:p,onUpdateTask:q,onReorder:r}){let{t:s}=(0,f.Bd)(),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(null),x=(0,e.useRef)(null),y=b.filter(a=>!a.completed),z=y.filter(a=>!a.paused).length,A=b.filter(a=>a.completed),[B,C]=(0,e.useState)(null),[D,E]=(0,e.useState)(null),F=(0,e.useCallback)(a=>{C(a)},[]),G=(0,e.useCallback)((a,b)=>{a.preventDefault(),E(b)},[]),H=(0,e.useCallback)(a=>{if(null===B||B===a){C(null),E(null);return}let b=[...y],[c]=b.splice(B,1);b.splice(a,0,c),r([...b,...A].map(a=>a.id)),C(null),E(null)},[B,y,A,r]),I=(0,e.useCallback)(()=>{C(null),E(null)},[]),[,J]=(0,e.useState)(0);return(0,d.jsxs)("div",{className:"relative",ref:x,children:[(0,d.jsxs)("button",{onClick:()=>u(!t),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${a?"w-full justify-center":"w-full"}`,title:s("scheduledTasks.title"),children:[(0,d.jsxs)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]}),!a&&(0,d.jsx)("span",{className:"text-sm flex-1 text-left",children:s("scheduledTasks.title")}),c>0?(0,d.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-white text-xs font-medium rounded-full flex items-center justify-center bg-red-500 ${a?"absolute -top-1 -right-1":""}`,children:c}):a&&b.length>0?(0,d.jsx)("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 text-muted-foreground text-xs font-medium rounded-full flex items-center justify-center bg-accent",children:b.length}):null]}),t&&(0,d.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-96 max-h-[500px] bg-popover border border-border rounded-lg shadow-lg z-50 flex flex-col",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm font-medium",children:s("scheduledTasks.title")}),y.length>0&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:[s("scheduledTasks.activeCount",{running:z}),y.length-z>0?` \xb7 ${s("scheduledTasks.pausedCount",{paused:y.length-z})}`:""]})]}),(0,d.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===b.length?(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:s("scheduledTasks.noScheduledTasks")}):(0,d.jsxs)(d.Fragment,{children:[y.map((a,b)=>{var c;return(0,d.jsx)("div",{draggable:!0,onDragStart:()=>F(b),onDragOver:a=>G(a,b),onDrop:()=>H(b),onDragEnd:I,className:`group px-3 py-2 hover:bg-accent transition-colors border-b border-border/50 cursor-pointer ${a.unread?"bg-brand/5":""} ${B===b?"opacity-50":""} ${D===b?"border-t-2 border-brand":""}`,onClick:()=>{k(a.cwd,a.sessionId),a.unread&&p(a.id),u(!1)},children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${i(a)}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:(c=a.cwd).split("/").pop()||c}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"\xb7"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:a.completed?s("scheduledTasks.completed"):a.paused?s("scheduledTasks.paused"):s("common.running")})]}),(0,d.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5",title:a.message,children:a.message}),(0,d.jsxs)("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{children:h(a,s)}),(0,d.jsx)("span",{children:"\xb7"}),(0,d.jsx)("span",{children:a.paused?s("scheduledTasks.paused"):function(a,b){if(!a)return"-";let c=a-Date.now();if(c<=0)return b("scheduledTasks.aboutToTrigger");if(c<6e4)return b("scheduledTasks.secondsLater",{count:Math.ceil(c/1e3)});if(c<36e5)return b("scheduledTasks.minutesLater",{count:Math.ceil(c/6e4)});if(c<864e5){let a=Math.floor(c/36e5),d=Math.ceil(c%36e5/6e4);return d>0?b("scheduledTasks.hoursMinutesLater",{h:a,m:d}):b("scheduledTasks.hoursLater",{h:a})}return new Date(a).toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(a.nextFireTime,s)}),a.lastFiredAt&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{children:"\xb7"}),(0,d.jsxs)("span",{children:[s("scheduledTasks.lastResult"),": ","success"===a.lastResult?"✓":"✗"]})]})]})]}),(0,d.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),n(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-brand",title:s("scheduledTasks.runNow"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{d:"M8 5v14l11-7z"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),w(a)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:s("common.edit"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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"})})}),a.paused?(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),m(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-green-500",title:s("scheduledTasks.resume"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"})})}):(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),l(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-yellow-500",title:s("scheduledTasks.pause"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 9v6m4-6v6"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),o(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:s("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})},a.id)}),A.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-muted/30 border-b border-border/50",children:s("scheduledTasks.completedCount",{count:A.length})}),A.map(a=>(0,d.jsx)("div",{className:"group px-3 py-2 hover:bg-accent transition-colors border-b border-border/50 opacity-60 cursor-pointer",onClick:()=>{k(a.cwd,a.sessionId),u(!1)},children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${i(a)}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-sm text-foreground truncate",children:a.message}),(0,d.jsxs)("div",{className:"text-xs text-muted-foreground mt-0.5",children:[h(a,s)," \xb7 ","success"===a.lastResult?s("scheduledTasks.success"):s("scheduledTasks.failure")]})]}),(0,d.jsx)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),o(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:s("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})})]})},a.id))]})]})})]}),v&&(0,d.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/30",onClick:()=>w(null)}),(0,d.jsx)("div",{className:"relative",children:(0,d.jsx)(g.E,{onClose:()=>w(null),onCreate:()=>{},editTask:{id:v.id,message:v.message,type:v.type,delayMinutes:v.delayMinutes,intervalMinutes:v.intervalMinutes,activeFrom:v.activeFrom,activeTo:v.activeTo,cron:v.cron},onUpdate:(a,b)=>{q(a,b),w(null)}})})]})]})}},75513:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{k_:()=>h,nH:()=>i});var e=c(48249),f=c(67484),g=c(7031);let a=(0,f.createContext)(null);function h({children:b}){let c=(0,f.useRef)(new Map),d=(0,f.useRef)(null),[i,j]=(0,f.useState)(!1),k=(0,f.useCallback)((a,b)=>{c.current.set(b,a)},[]),l=(0,f.useCallback)(a=>{c.current.delete(a)},[]),m=(0,f.useCallback)(a=>{d.current=a},[]),n=(0,f.useCallback)(a=>{let b=d.current;if(!b)return void console.warn("No active tab to send message");let e=c.current.get(b);e?e(a):console.warn(`No chat sender registered for tab ${b}`)},[]),o=(0,f.useMemo)(()=>({sendMessage:n,isLoading:i,registerChat:k,unregisterChat:l,setActiveTab:m,setIsLoading:j}),[n,i,k,l,m]),p=(0,f.useMemo)(()=>({sendMessage:n,isLoading:i}),[n,i]);return(0,e.jsx)(a.Provider,{value:o,children:(0,e.jsx)(g.H,{value:p,children:b})})}function i(){return(0,f.useContext)(a)}d()}catch(a){d(a)}})},76334:(a,b,c)=>{"use strict";function d(a){let b=function(a){let b=0xffffffff;for(let c=0;c<a.length;c++){b^=a.charCodeAt(c);for(let a=0;a<8;a++)b=b>>>1^(1&b?0xedb88320:0)}return(0xffffffff^b)>>>0}(a),c="",d=b;for(let a=0;a<4;a++)c+=String.fromCharCode(97+d%26),d=Math.floor(d/26);return c}c.d(b,{p:()=>d})},76537:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>n,metadata:()=>l,viewport:()=>m});var d=c(5735),e=c(45864),f=c.n(e),g=c(87764),h=c.n(g),i=c(76055),j=c.n(i);c(61135);var k=c(25702);let l={title:"OpenCockpit",description:"OpenCockpit is a local-first AI development hub with chat agents, a file explorer, terminals, and browser bubbles in one swipeable workspace. One seat. One AI.",manifest:"/manifest.json",appleWebApp:{capable:!0,statusBarStyle:"default",title:"Cockpit"},icons:{icon:"/icons/icon-192x192.png",apple:"/icons/icon-192x192.png"}},m={themeColor:[{media:"(prefers-color-scheme: light)",color:"#f9f9fb"},{media:"(prefers-color-scheme: dark)",color:"#111113"}]};function n({children:a}){return(0,d.jsxs)("html",{lang:"en",suppressHydrationWarning:!0,className:"overflow-hidden",children:[(0,d.jsx)("head",{children:(0,d.jsx)("script",{src:"/boot.js"})}),(0,d.jsx)("body",{className:`${f().variable} ${h().variable} ${j().variable} antialiased overflow-hidden`,children:(0,d.jsx)(k.Providers,{children:a})})]})}},76552:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Providers:()=>j});var e=c(48249),f=c(29491),g=c(83768),h=c(7833),i=c(34102);function j({children:a}){return(0,e.jsx)(f.I18nProvider,{children:(0,e.jsx)(g.N,{children:(0,e.jsxs)(h.tE,{children:[a,(0,e.jsx)(i.B,{})]})})})}d()}catch(a){d(a)}})},76855:(a,b,c)=>{"use strict";c.d(b,{Sn:()=>i,Xm:()=>j,po:()=>k,JL:()=>l});var d=c(67484);c(28797);var e=c(79606),f=c(33281),g=c(71192);let h=(a,b)=>e.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:b=>new g.uV({message:`${a} failed`,cause:b})});function i(a){let[b,c]=(0,d.useState)(!1);return{goToDefinition:(0,d.useCallback)(async(b,d,e)=>{c(!0);let g=await f.t4.runPromiseExit(h("/api/lsp/definition",{cwd:a,filePath:b,line:d,column:e}));return(c(!1),"Success"===g._tag)?g.value.definitions??[]:(console.error("[useLSP] definition error:",g.cause),[])},[a]),loading:b}}function j(a){let[b,c]=(0,d.useState)(null),e=(0,d.useRef)(null),g=(0,d.useRef)(null),i=(0,d.useRef)(0),j=(0,d.useRef)(!1),k=(0,d.useRef)(null),l=(0,d.useRef)({x:0,y:0}),m=(0,d.useCallback)(a=>{k.current=a},[]),n=(0,d.useRef)(!1),o=(0,d.useRef)(null),p=(0,d.useCallback)(()=>{let a=k.current;a&&n.current&&(a.style.pointerEvents="none"),n.current=!1,o.current&&(k.current?.removeEventListener("mouseleave",o.current),o.current=null)},[]),q=(0,d.useCallback)(()=>{let a=k.current;if(!a||n.current)return;n.current=!0,j.current=!0,a.style.pointerEvents="auto";let b=()=>{j.current=!1,p(),i.current++,c(null)};o.current=b,a.addEventListener("mouseleave",b)},[p]),r=(0,d.useCallback)((b,d,j,k)=>{e.current&&clearTimeout(e.current),g.current&&clearTimeout(g.current);let l=++i.current;e.current=setTimeout(async()=>{let e=await f.t4.runPromiseExit(h("/api/lsp/hover",{cwd:a,filePath:b,line:d,column:j}));if(l!==i.current||"Success"!==e._tag)return;let g=e.value.hover;g&&g.displayString&&c({...g,x:k.x,y:k.y,filePath:b,line:d,column:j})},300)},[a]),s=(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),i.current++,g.current=setTimeout(function(){if(j.current)return;let a=k.current;if(a){let b=a.getBoundingClientRect(),{x:c,y:d}=l.current;if(c>=b.left&&c<=b.right&&d>=b.top&&d<=b.bottom)return void q()}c(null)},150)},[q]),t=(0,d.useCallback)(()=>{j.current=!0,g.current&&clearTimeout(g.current)},[]);return{hoverInfo:b,onTokenMouseEnter:r,onTokenMouseLeave:s,onCardMouseEnter:t,onCardMouseLeave:(0,d.useCallback)(()=>{j.current=!1,i.current++,c(null)},[]),clearHover:(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),g.current&&clearTimeout(g.current),j.current=!1,p(),i.current++,c(null)},[p]),setTooltipEl:m}}function k(a){let[b,c]=(0,d.useState)([]),[e,g]=(0,d.useState)(!1),[i,j]=(0,d.useState)(!1);return{references:b,loading:e,visible:i,findReferences:(0,d.useCallback)(async(b,d,e)=>{g(!0),j(!0);let i=await f.t4.runPromiseExit(h("/api/lsp/references",{cwd:a,filePath:b,line:d,column:e}));"Success"===i._tag?c(i.value.references??[]):(console.error("[useLSP] references error:",i.cause),c([])),g(!1)},[a]),closeReferences:(0,d.useCallback)(()=>{j(!1),c([])},[])}}function l(a,b){(0,d.useRef)(null)}},77016:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{b:()=>s});var e=c(48249),f=c(67484),g=c(44256),h=c(36295),i=c(7833),j=c(28602),k=c(44384),l=c(74493),m=a([h]);h=(m.then?(await m)():m)[0];let x=[{value:"=",label:"="},{value:"!=",label:"!="},{value:">",label:">"},{value:"<",label:"<"},{value:">=",label:">="},{value:"<=",label:"<="},{value:"LIKE",label:"LIKE"},{value:"NOT LIKE",label:"NOT LIKE"},{value:"IN",label:"IN"},{value:"IS NULL",label:"IS NULL"},{value:"IS NOT NULL",label:"IS NOT NULL"}];function n(a){if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`}function o(a){return`\`${a.replace(/`/g,"``")}\``}function p(a){try{let b=a.match(/\/\/[^/]+\/([^?]+)/);if(b)return b[1]}catch{}return""}function q(a){return null==a?"":"object"==typeof a?JSON.stringify(a):String(a)}function r({text:a}){let[b,c]=(0,f.useState)(!1),[d,h]=(0,f.useState)({x:0,y:0,maxW:600,maxH:300,above:!0}),i=(0,f.useRef)(null),j=(0,f.useRef)(null),k=(0,f.useRef)(!1),l=(0,g.F2)(),m=(0,f.useCallback)(()=>{j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{k.current||c(!1)},80)},[]),n=(0,f.useCallback)(()=>{j.current&&clearTimeout(j.current),k.current=!1,j.current=setTimeout(()=>{let a=i.current;if(!a||a.scrollWidth<=a.clientWidth)return;let b=a.getBoundingClientRect(),d=l?.getBoundingClientRect(),e=d?.left??0,f=d?.top??0,g=d?.width??window.innerWidth,j=d?.height??window.innerHeight,k=b.left-e,m=b.top-f,n=b.bottom-f,o=Math.min(600,g-k-8),p=o<200?Math.max(8,g-600-8):k,q=o<200?Math.min(600,g-16):o,r=m-8,s=j-n-8,t=r>s&&r>80,u=t?r-4:s-4;h({x:p,y:t?m-4:n+4,maxW:q,maxH:Math.max(60,u),above:t}),c(!0)},350)},[l]),o=(0,f.useCallback)(()=>{m()},[m]),p=(0,f.useCallback)(()=>{k.current=!0,j.current&&clearTimeout(j.current)},[]),q=(0,f.useCallback)(()=>{k.current=!1,m()},[m]);return(0,e.jsxs)("span",{ref:i,className:"block truncate",onMouseEnter:n,onMouseLeave:o,children:[a,b&&(0,e.jsx)(g.ZL,{children:(0,e.jsx)("div",{className:"fixed z-[9999] overflow-y-auto px-2 py-1.5 text-xs font-mono bg-popover text-popover-foreground border border-border rounded shadow-lg whitespace-pre-wrap break-all select-text cursor-text",style:{left:d.x,top:d.y,maxWidth:d.maxW,maxHeight:d.maxH,transform:d.above?"translateY(-100%)":void 0},onMouseEnter:p,onMouseLeave:q,children:function(a){try{let b=JSON.parse(a);if("object"==typeof b&&null!==b)return JSON.stringify(b,null,2)}catch{}return a}(a)})})]})}function s({id:a,connectionString:b,displayName:c,selected:d,maximized:g,expandedHeight:m,bubbleContentHeight:u,onSelect:x,onClose:y,onToggleMaximize:z,timestamp:A,onTitleMouseDown:B}){let{t:C}=(0,k.Bd)(),{showToast:D}=(0,i.dj)(),[E,F]=(0,f.useState)("connecting"),[G,H]=(0,f.useState)(""),[I,J]=(0,f.useState)([]),[K,L]=(0,f.useState)(()=>p(b)),[M,N]=(0,f.useState)([]),[O,P]=(0,f.useState)(null),[Q,R]=(0,f.useState)("table"),[S,T]=(0,f.useState)("data"),[U,V]=(0,f.useState)([]),[W,X]=(0,f.useState)([]),[Y,Z]=(0,f.useState)([]),[$,_]=(0,f.useState)([]),[aa,ab]=(0,f.useState)(null),[ac,ad]=(0,f.useState)(0),[ae,af]=(0,f.useState)(!1),[ag,ah]=(0,f.useState)(0),[ai,aj]=(0,f.useState)(new Set),[ak,al]=(0,f.useState)(!1),[am,an]=(0,f.useState)(null),[ao,ap]=(0,f.useState)({}),[aq,ar]=(0,f.useState)(!1),[as,at]=(0,f.useState)({}),[au,av]=(0,f.useState)({}),[aw,ax]=(0,f.useState)(null),[ay,az]=(0,f.useState)(""),[aA,aB]=(0,f.useState)(null),[aC,aD]=(0,f.useState)(""),[aE,aF]=(0,f.useState)(!1),aG=(0,f.useRef)(null),aH=(0,f.useCallback)(async()=>{F("connecting"),H("");try{let c=await (0,l.GW)("/api/mysql/connect",{id:a,connectionString:b});J(c.schemas||[]);let d=p(b);c.schemas?.length>0&&d&&c.schemas.includes(d)?L(d):c.schemas?.length>0&&L(c.schemas[0]),F("connected")}catch(a){H(a instanceof Error?a.message:String(a)),F("error")}},[a,b]),aI=(0,f.useCallback)(async()=>{if("connected"===E)try{let c=await (0,l.Ey)("/api/mysql/schemas",{id:a,connectionString:b,schema:K});N(c.tables||[])}catch{}},[a,b,K,E]),aJ=(0,f.useCallback)(async(c,d,e,f)=>{af(!0);let g=e??au,h=void 0!==f?f:aw;try{let e=`${o(K)}.${o(c)}`,{where:f,params:i}=function(a){let b=[],c=[];for(let[d,e]of Object.entries(a)){if(!e.enabled)continue;let a=o(d);if("IS NULL"===e.op)b.push(`${a} IS NULL`);else if("IS NOT NULL"===e.op)b.push(`${a} IS NOT NULL`);else if("IN"===e.op){let d=e.value.split(",").map(a=>a.trim()).filter(Boolean);if(0===d.length)continue;let f=d.map(a=>(c.push(a),"?"));b.push(`${a} IN (${f.join(", ")})`)}else"LIKE"===e.op||e.op,b.push(`${a} ${e.op} ?`),c.push(e.value)}return{where:b.length>0?` WHERE ${b.join(" AND ")}`:"",params:c}}(g),j=h?` ORDER BY ${o(h.column)} ${h.dir}`:"",k=`SELECT * FROM ${e}${f}${j} LIMIT 50 OFFSET ${50*d}`,m=await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:k,params:i});ab(m);let n=`SELECT count(*) AS cnt FROM ${e}${f}`,p=await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:n,params:i});ah(p.rows?.[0]?.cnt??0)}catch{}af(!1)},[a,b,K,au,aw]),aK=(0,f.useCallback)(async c=>{P(c),ad(0),an(null),ar(!1),aj(new Set),al(!1),av({}),ax(null);try{let d=await (0,l.Ey)("/api/mysql/columns",{id:a,connectionString:b,schema:K,table:c});V(d.columns||[]),X(d.primaryKeys||[]),Z(d.foreignKeys||[]),_(d.indexes||[])}catch{}aJ(c,0,{},null)},[a,b,K,aJ]),aL=(0,f.useCallback)(async()=>{if(ay.trim()){aF(!0),aD(""),aB(null);try{let c=await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:ay});aB(c)}catch(a){aD(a instanceof Error?a.message:String(a))}aF(!1)}},[a,b,ay]),aM=(0,f.useCallback)(async()=>{if(null===am||!aa||!O)return;let c=aa.rows[am],d=[],e=[];for(let a of U)void 0!==ao[a.name]&&ao[a.name]!==q(c[a.name]??"")&&(d.push(`${o(a.name)} = ?`),e.push(""===ao[a.name]&&a.nullable?null:ao[a.name]));if(0===d.length)return void an(null);let f=W.length>0?W:U.map(a=>a.name),g=[];for(let a of f)null===c[a]||void 0===c[a]?g.push(`${o(a)} IS NULL`):(g.push(`${o(a)} = ?`),e.push(c[a]));let h=`UPDATE ${o(K)}.${o(O)} SET ${d.join(", ")} WHERE ${g.join(" AND ")}`;try{await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:h,params:e}),an(null),aJ(O,ac,au,aw)}catch(a){alert(`Update failed: ${a instanceof Error?a.message:String(a)}`)}},[am,aa,O,U,W,ao,a,b,K,aJ,ac,au,aw]),aN=(0,f.useCallback)(async()=>{if(!O)return;let c=[],d=[],e=[];for(let a of U)void 0!==as[a.name]&&""!==as[a.name]&&(c.push(o(a.name)),d.push(as[a.name]),e.push("?"));if(0===c.length)return;let f=`INSERT INTO ${o(K)}.${o(O)} (${c.join(", ")}) VALUES (${e.join(", ")})`;try{await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:f,params:d}),ar(!1),at({}),aJ(O,ac,au,aw)}catch(a){alert(`Insert failed: ${a instanceof Error?a.message:String(a)}`)}},[O,U,as,a,b,K,aJ,ac,au,aw]),aO=(0,f.useCallback)(async()=>{if(0===ai.size||!aa||!O)return;let c=W.length>0?W:U.map(a=>a.name),d=0;for(let e of Array.from(ai).sort((a,b)=>b-a)){let f=aa.rows[e];if(!f)continue;let g=[],h=[];for(let a of c)null===f[a]||void 0===f[a]?g.push(`${o(a)} IS NULL`):(g.push(`${o(a)} = ?`),h.push(f[a]));let i=`DELETE FROM ${o(K)}.${o(O)} WHERE ${g.join(" AND ")} LIMIT 1`;try{await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:i,params:h})}catch{d++}}aj(new Set),al(!1),aJ(O,ac,au,aw),d>0&&alert(C("mysql.deleteRowsFailed",{count:d}))},[ai,aa,O,W,U,a,b,K,aJ,ac,au,aw]),aP=(0,f.useCallback)(async c=>{if(!O)return;if(ai.size>0&&aa){let a,b=aa.fields.map(a=>a.name),d=Array.from(ai).sort((a,b)=>a-b).map(a=>aa.rows[a]).filter(Boolean);if("json"===c)a=JSON.stringify(d,null,2);else{let c=[b.join(",")];for(let a of d)c.push(b.map(b=>{let c=a[b];if(null==c)return"";let d="object"==typeof c?JSON.stringify(c):String(c);return d.includes(",")||d.includes('"')||d.includes("\n")?`"${d.replace(/"/g,'""')}"`:d}).join(","));a=c.join("\n")}navigator.clipboard.writeText(a);return}let d=`SELECT * FROM ${o(K)}.${o(O)}`;try{let e=await (0,l.HS)("/api/mysql/export",{id:a,connectionString:b,sql:d,format:c}),f=URL.createObjectURL(e),g=document.createElement("a");g.href=f,g.download=`${O}.${c}`,g.click(),URL.revokeObjectURL(f)}catch(a){alert(`Export failed: ${a instanceof Error?a.message:String(a)}`)}},[O,a,b,K,ai,aa]),aQ=(0,f.useCallback)(a=>{(a.metaKey||a.ctrlKey)&&"Enter"===a.key&&(a.preventDefault(),aL())},[aL]),aR=g&&m?m-41:u??h.p,aS=Math.max(1,Math.ceil(ag/50)),aT=(0,f.useCallback)(a=>{O&&(ad(a),aJ(O,a,au,aw))},[O,aJ,au,aw]),aU=(0,f.useCallback)((a,b)=>{let c={...au};b?c[a]=b:delete c[a],av(c),ad(0),aj(new Set),O&&aJ(O,0,c,aw)},[au,aw,O,aJ]),aV=(0,f.useCallback)(()=>{av({}),ad(0),aj(new Set),O&&aJ(O,0,{},aw)},[aw,O,aJ]),aW=(0,f.useCallback)(a=>{ax(a),ad(0),aj(new Set),O&&aJ(O,0,au,a)},[au,O,aJ]);return(0,e.jsx)("div",{className:"flex flex-col items-start",children:(0,e.jsxs)("div",{className:`w-full bg-accent text-foreground
33
33
  relative transition-colors cursor-pointer
34
34
  ${g?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
35
35
  ${g?"":d?"border-brand":"border-brand/30"}`,onClick:g?void 0:x,children:[(0,e.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:z,onMouseDown:B,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${g?"bg-card":"bg-card/50"}`,style:g?{height:41}:void 0,children:[(0,e.jsx)("span",{className:"text-sm flex-shrink-0",children:"\uD83D\uDC2C"}),(0,e.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:c}),"connecting"===E&&(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"error"===E&&(0,e.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:C("mysql.connectionFailed")}),"connected"===E&&(0,e.jsx)("span",{className:"text-[10px] text-emerald-500 flex-shrink-0",children:C("mysql.connected")}),(0,e.jsx)("span",{className:"flex-1"}),A&&(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:n(A)}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),z()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:g?C("browser.exitMaximize",{modKey:(0,j.Mu)()}):C("browser.maximize",{modKey:(0,j.Mu)()}),children:g?(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),y()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:C("common.close"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsxs)("div",{style:{height:aR},className:"flex overflow-hidden",children:["connecting"===E&&(0,e.jsxs)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:[(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin mr-2"}),C("mysql.connecting")]}),"error"===E&&(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-4",children:[(0,e.jsx)("span",{className:"text-sm text-destructive text-center break-all",children:G}),(0,e.jsx)("button",{onClick:aH,className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:C("common.retry")})]}),"connected"===E&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"w-52 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"p-1.5 border-b border-border flex items-center gap-1",children:[I.length>1?(0,e.jsx)("select",{value:K,onChange:a=>{L(a.target.value),P(null)},className:"flex-1 min-w-0 text-xs bg-background border border-input rounded px-1.5 py-1",children:I.map(a=>(0,e.jsx)("option",{value:a,children:a},a))}):(0,e.jsx)("span",{className:"flex-1 min-w-0 text-xs text-muted-foreground truncate",children:K}),(0,e.jsx)("button",{onClick:aI,className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent active:bg-accent/50 transition-colors",title:C("mysql.refreshTableList"),children:(0,e.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("path",{d:"M1 1v5h5"}),(0,e.jsx)("path",{d:"M15 15v-5h-5"}),(0,e.jsx)("path",{d:"M13.5 6A6 6 0 0 0 3.2 3.2L1 6"}),(0,e.jsx)("path",{d:"M2.5 10a6 6 0 0 0 10.3 2.8L15 10"})]})})]}),(0,e.jsx)("div",{className:"flex items-center border-b border-border",children:["table","view"].map(a=>(0,e.jsx)("button",{onClick:()=>R(a),className:`flex-1 py-1 text-[10px] font-medium transition-colors ${Q===a?"text-brand border-b border-brand":"text-muted-foreground hover:text-foreground"}`,children:{table:C("mysql.filterTable"),view:C("mysql.filterView")}[a]},a))}),(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[M.filter(a=>"table"===Q?"view"!==a.type:"view"===a.type).map(a=>(0,e.jsxs)("div",{onClick:()=>aK(a.name),className:`flex items-center gap-1.5 px-2 py-1 cursor-pointer truncate transition-colors ${O===a.name?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,e.jsx)("span",{className:"flex-shrink-0 text-[10px] text-muted-foreground",children:"view"===a.type?"V":"T"}),(0,e.jsx)("span",{className:"truncate min-w-0 flex-1",children:(0,e.jsx)(r,{text:a.name})}),(0,e.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.rowEstimate>0?`~${a.rowEstimate}`:""})]},a.name)),0===M.length&&(0,e.jsx)("div",{className:"p-2 text-muted-foreground text-center",children:C("mysql.noTables")})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:[["structure","data","sql"].map(a=>(0,e.jsx)("button",{onClick:()=>T(a),className:`px-3 py-1.5 text-xs transition-colors ${S===a?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{structure:C("mysql.tabStructure"),data:C("mysql.tabData"),sql:"SQL"}[a]},a)),O&&"data"===S&&(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[Object.values(au).some(a=>a.enabled)&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-[10px] text-brand",children:C("mysql.filterActive",{count:Object.values(au).filter(a=>a.enabled).length})}),(0,e.jsx)("button",{onClick:aV,className:"px-1 py-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors",title:C("mysql.clearAllFilters"),children:"✕"}),(0,e.jsx)("span",{className:"text-border",children:"|"})]}),ai.size>0&&!ak&&(0,e.jsx)("button",{onClick:()=>al(!0),className:"px-1.5 py-0.5 text-[10px] text-destructive hover:text-destructive/80 bg-destructive/10 rounded transition-colors",children:C("mysql.deleteNRows",{count:ai.size})}),ak&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-[10px] text-destructive",children:C("mysql.confirmDeleteRows")}),(0,e.jsx)("button",{onClick:aO,className:"px-1.5 py-0.5 text-[10px] text-white bg-destructive rounded transition-colors hover:bg-destructive/80",children:C("common.confirm")}),(0,e.jsx)("button",{onClick:()=>al(!1),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",children:C("common.cancel")})]}),(0,e.jsx)("button",{onClick:()=>aP("csv"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:ai.size>0?C("mysql.copyCsvSelected"):C("mysql.copyCsvAll"),children:ai.size>0?C("mysql.copyCSV"):C("mysql.CSV")}),(0,e.jsx)("button",{onClick:()=>aP("json"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:ai.size>0?C("mysql.copyJsonSelected"):C("mysql.copyJsonAll"),children:ai.size>0?C("mysql.copyJSON"):C("mysql.JSON")})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:O||"sql"===S?"structure"===S?(0,e.jsx)(t,{columns:U,primaryKeys:W,foreignKeys:Y,indexes:$}):"data"===S?(0,e.jsx)(v,{result:aa,loading:ae,columns:U,page:ac,totalPages:aS,totalRows:ag,onPageChange:aT,filters:au,sort:aw,onFilterChange:aU,onSortChange:aW,selectedRows:ai,onSelectedRowsChange:a=>{aj(a),al(!1)},editingRowIdx:am,editValues:ao,onStartEdit:a=>{if(!aa)return;let b=aa.rows[a],c={};for(let a of U)c[a.name]=null==b[a.name]?"":q(b[a.name]);ap(c),an(a)},onEditChange:(a,b)=>ap(c=>({...c,[a]:b})),onSaveEdit:aM,onCancelEdit:()=>an(null),isAddingRow:aq,newRowValues:as,onStartAdd:()=>{ar(!0),at({})},onNewRowChange:(a,b)=>at(c=>({...c,[a]:b})),onSaveNewRow:aN,onCancelAdd:()=>{ar(!1),at({})},onCellCopy:a=>{navigator.clipboard.writeText(a),D(C("common.copied"))}}):(0,e.jsx)(w,{sqlInput:ay,onSqlChange:az,onExecute:aL,onKeyDown:aQ,result:aA,error:aC,loading:aE,sqlRef:aG,onCellCopy:a=>{navigator.clipboard.writeText(a),D(C("common.copied"))}}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:C("mysql.selectTable")})})]})]})]}),!g&&(0,e.jsxs)("div",{className:"border-t border-border px-4 py-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${"connected"===E?"bg-green-500":"error"===E?"bg-red-500":"bg-yellow-500 animate-pulse"}`}),(0,e.jsx)("span",{children:{connecting:C("common.connecting"),connected:C("common.connected"),error:C("common.connectionFailed")}[E]}),"connected"===E&&O&&(0,e.jsx)("span",{className:"text-muted-foreground/70",children:O}),(0,e.jsx)("span",{className:"flex-1"}),A&&(0,e.jsx)("span",{className:"text-[11px] flex-shrink-0",children:n(A)})]})]})})}function t({columns:a,primaryKeys:b,foreignKeys:c,indexes:d}){let{t:f}=(0,k.Bd)();return 0===a.length?(0,e.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:f("mysql.selectTableToView")}):(0,e.jsxs)("div",{className:"p-2 space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:f("mysql.columns")}),(0,e.jsxs)("table",{className:"w-full text-xs",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border",children:[(0,e.jsx)("th",{className:"px-1.5 py-1 font-medium",children:f("mysql.colName")}),(0,e.jsx)("th",{className:"px-1.5 py-1 font-medium",children:f("mysql.colType")}),(0,e.jsx)("th",{className:"px-1.5 py-1 font-medium",children:f("mysql.colNullable")}),(0,e.jsx)("th",{className:"px-1.5 py-1 font-medium",children:f("mysql.colDefault")})]})}),(0,e.jsx)("tbody",{children:a.map(a=>(0,e.jsxs)("tr",{className:"border-b border-border/50 hover:bg-accent/50",children:[(0,e.jsxs)("td",{className:"px-1.5 py-1 font-mono",children:[a.isPrimaryKey&&(0,e.jsx)("span",{className:"text-amber-500 mr-1",title:f("mysql.primaryKey"),children:"\uD83D\uDD11"}),a.name]}),(0,e.jsxs)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono",children:[a.type,a.maxLength?`(${a.maxLength})`:""]}),(0,e.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground",children:a.nullable?"YES":"NO"}),(0,e.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono truncate max-w-[120px]",children:a.default||""})]},a.name))})]})]}),c.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:f("mysql.foreignKeys")}),(0,e.jsx)("div",{className:"space-y-0.5",children:c.map((a,b)=>(0,e.jsxs)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground",children:[a.column," → ",a.refSchema,".",a.refTable,".",a.refColumn]},b))})]}),d.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:f("mysql.indexes")}),(0,e.jsx)("div",{className:"space-y-0.5",children:d.map(a=>(0,e.jsx)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground truncate",title:a.definition,children:a.name},a.name))})]})]})}function u({filter:a,onApply:b,onClear:c,onToggle:d,onClose:h,colName:i,anchorRect:j}){let{t:l}=(0,k.Bd)(),[m,n]=(0,f.useState)(a?.op||"="),[o,p]=(0,f.useState)(a?.value||""),q=(0,f.useRef)(null),r=(0,g.F2)(),s="IS NULL"!==m&&"IS NOT NULL"!==m,t=()=>{(!s||o.trim())&&b({op:m,value:o.trim(),enabled:!0})},v=r?.getBoundingClientRect(),w=v?.left??0,y=v?.top??0,z=v?.width??1e3,A=j.left-w;A+220>z-8&&(A=z-220-8),A<8&&(A=8);let B=j.bottom+2-y;return(0,e.jsx)(g.ZL,{children:(0,e.jsxs)("div",{ref:q,className:"fixed z-[9998] w-[220px] bg-popover border border-border rounded-md shadow-lg p-2 space-y-2",style:{left:A,top:B},onClick:a=>a.stopPropagation(),children:[a&&(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:a.enabled,onChange:a=>d(a.target.checked),className:"w-3 h-3 accent-brand"}),l("mysql.enable")]}),(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono truncate max-w-[120px]",children:i})]}),(0,e.jsx)("select",{value:m,onChange:a=>n(a.target.value),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 focus:outline-none focus:ring-1 focus:ring-ring",children:x.map(a=>(0,e.jsx)("option",{value:a.value,children:a.label},a.value))}),s&&(0,e.jsx)("input",{type:"text",value:o,onChange:a=>p(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),t())},placeholder:l("IN"===m?"mysql.commaValues":"LIKE"===m?"mysql.likePattern":"mysql.valuePlaceholder"),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 font-mono focus:outline-none focus:ring-1 focus:ring-ring",autoFocus:!0}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{onClick:t,disabled:s&&!o.trim(),className:"flex-1 px-2 py-1 text-[10px] bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-40 transition-colors",children:l("mysql.apply")}),a&&(0,e.jsx)("button",{onClick:c,className:"flex-1 px-2 py-1 text-[10px] text-muted-foreground bg-muted rounded hover:text-foreground transition-colors",children:l("mysql.clearFilter")})]})]})})}function v({result:a,loading:b,columns:c,page:d,totalPages:g,totalRows:h,onPageChange:i,filters:j,sort:l,onFilterChange:m,onSortChange:n,selectedRows:o,onSelectedRowsChange:p,editingRowIdx:s,editValues:t,onStartEdit:w,onEditChange:x,onSaveEdit:y,onCancelEdit:z,isAddingRow:A,newRowValues:B,onStartAdd:C,onNewRowChange:D,onSaveNewRow:E,onCancelAdd:F,onCellCopy:G}){let{t:H}=(0,k.Bd)(),[I,J]=(0,f.useState)(null),[K,L]=(0,f.useState)({left:0,bottom:0});if(!a&&!b)return(0,e.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:H("mysql.selectTableForData")});let M=a?.fields||[],N=a?.rows||[],O={};for(let a of c)O[a.name]=a.type+(a.maxLength?`(${a.maxLength})`:"");let P=N.length>0&&o.size===N.length,Q=o.size>0&&!P;return(0,e.jsxs)("div",{className:"flex flex-col h-full",children:[(0,e.jsxs)("div",{className:"flex-1 overflow-auto relative",children:[b&&(0,e.jsx)("div",{className:"absolute inset-0 bg-background/50 flex items-center justify-center z-10",children:(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),(0,e.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,e.jsx)("thead",{className:"sticky top-0 bg-card z-[2]",children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{className:"px-1 py-1 border-b border-border w-8 text-center",children:(0,e.jsx)("input",{type:"checkbox",checked:P,ref:a=>{a&&(a.indeterminate=Q)},onChange:()=>{P?p(new Set):p(new Set(N.map((a,b)=>b)))},className:"w-3 h-3 accent-brand cursor-pointer"})}),M.map(a=>{let b=l?.column===a.name?l.dir:null,c=j[a.name],d=c?.enabled;return(0,e.jsxs)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono relative",children:[(0,e.jsxs)("span",{className:"cursor-pointer select-none hover:text-foreground transition-colors",onClick:()=>{var b;return b=a.name,void(l?.column===b?"ASC"===l.dir?n({column:b,dir:"DESC"}):n(null):n({column:b,dir:"ASC"}))},children:[a.name,O[a.name]&&(0,e.jsx)("span",{className:"ml-1 text-[9px] text-muted-foreground/60 font-normal",children:O[a.name]}),"ASC"===b&&(0,e.jsx)("span",{className:"ml-0.5 text-brand",children:"↑"}),"DESC"===b&&(0,e.jsx)("span",{className:"ml-0.5 text-brand",children:"↓"})]}),(0,e.jsx)("button",{onClick:b=>{if(b.stopPropagation(),I===a.name)return void J(null);let c=b.currentTarget.closest("th").getBoundingClientRect();L({left:c.left,bottom:c.bottom}),J(a.name)},className:`ml-1 inline-flex items-center transition-colors ${d?"text-brand":"text-muted-foreground/40 hover:text-muted-foreground"}`,children:(0,e.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,e.jsx)("path",{d:"M1 2h14l-5.5 6.5V14l-3-2v-3.5z"})})}),I===a.name&&(0,e.jsx)(u,{filter:c||null,onApply:b=>{m(a.name,b),J(null)},onClear:()=>{m(a.name,null),J(null)},onToggle:b=>{c&&m(a.name,{...c,enabled:b})},onClose:()=>J(null),colName:a.name,anchorRect:K})]},a.name)})]})}),(0,e.jsxs)("tbody",{children:[A&&(0,e.jsxs)("tr",{className:"bg-emerald-500/5",children:[(0,e.jsx)("td",{className:"px-1 py-0.5 border-b border-border text-center",children:(0,e.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,e.jsx)("button",{onClick:E,className:"text-[10px] text-emerald-500 hover:text-emerald-400",title:H("common.save"),children:"✓"}),(0,e.jsx)("button",{onClick:F,className:"text-[10px] text-muted-foreground hover:text-foreground",title:H("common.cancel"),children:"✕"})]})}),M.map(a=>(0,e.jsx)("td",{className:"px-0.5 py-0.5 border-b border-border",children:(0,e.jsx)("input",{type:"text",value:B[a.name]??"",onChange:b=>D(a.name,b.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]",placeholder:"NULL"})},a.name))]}),N.map((a,b)=>(0,e.jsxs)("tr",{className:`hover:bg-accent/50 ${o.has(b)?"bg-brand/5":""} ${s===b?"bg-blue-500/5":""}`,children:[(0,e.jsx)("td",{className:"px-1 py-0.5 border-b border-border/50 text-center",children:s===b?(0,e.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,e.jsx)("button",{onClick:y,className:"text-[10px] text-emerald-500 hover:text-emerald-400",title:H("common.save"),children:"✓"}),(0,e.jsx)("button",{onClick:z,className:"text-[10px] text-muted-foreground hover:text-foreground",title:H("common.cancel"),children:"✕"})]}):(0,e.jsx)("input",{type:"checkbox",checked:o.has(b),onChange:()=>{let a;(a=new Set(o)).has(b)?a.delete(b):a.add(b),p(a)},className:"w-3 h-3 accent-brand cursor-pointer"})}),M.map(c=>(0,e.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onDoubleClick:()=>{null===s&&w(b)},onContextMenu:b=>{b.preventDefault(),G(q(a[c.name]))},children:s===b?(0,e.jsx)("input",{type:"text",value:t[c.name]??"",onChange:a=>x(c.name,a.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]"}):null===a[c.name]||void 0===a[c.name]?(0,e.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,e.jsx)(r,{text:q(a[c.name])})},c.name))]},b))]})]}),0===N.length&&!b&&(0,e.jsx)("div",{className:"p-4 text-xs text-muted-foreground text-center",children:H("common.noData")})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 border-t border-border text-[10px] text-muted-foreground bg-card/30 flex-shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:C,disabled:A,className:"px-1.5 py-0.5 text-[10px] text-emerald-500 hover:text-emerald-400 disabled:opacity-30",children:H("mysql.addRow")}),(0,e.jsx)("span",{children:H("mysql.totalRows",{count:h})}),a?.duration!==void 0&&(0,e.jsxs)("span",{children:[a.duration,"ms"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{onClick:()=>i(d-1),disabled:0===d,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"◀"}),(0,e.jsxs)("span",{children:[d+1," / ",g]}),(0,e.jsx)("button",{onClick:()=>i(d+1),disabled:d>=g-1,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"▶"})]})]})]})}function w({sqlInput:a,onSqlChange:b,onExecute:c,onKeyDown:d,result:f,error:g,loading:h,sqlRef:i,onCellCopy:l}){let{t:m}=(0,k.Bd)();return(0,e.jsxs)("div",{className:"flex flex-col h-full",children:[(0,e.jsxs)("div",{className:"flex-shrink-0 p-2 border-b border-border",children:[(0,e.jsx)("textarea",{ref:i,value:a,onChange:a=>b(a.target.value),onKeyDown:d,placeholder:m("mysql.sqlPlaceholder",{modKey:(0,j.Mu)()}),className:"w-full h-20 px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-y focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}),(0,e.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,e.jsx)("button",{onClick:c,disabled:h||!a.trim(),className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 transition-colors",children:m(h?"mysql.executing":"mysql.execute")}),f?.duration!==void 0&&(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[f.command&&!f.fields?m("mysql.rowsAffected",{command:f.command,count:f.rowCount,duration:f.duration}):m("mysql.queryRows",{count:f.rows?.length??0,duration:f.duration}),f.truncated&&` ${m("mysql.resultTruncated")}`]})]})]}),g&&(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-destructive bg-destructive/5 border-b border-border break-all",children:g}),f?.fields&&f.rows&&(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,e.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,e.jsx)("tr",{children:f.fields.map(a=>(0,e.jsx)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono",children:a.name},a.name))})}),(0,e.jsx)("tbody",{children:f.rows.map((a,b)=>(0,e.jsx)("tr",{className:"hover:bg-accent/50",children:f.fields.map(b=>(0,e.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onContextMenu:c=>{c.preventDefault(),l(q(a[b.name]))},children:null===a[b.name]||void 0===a[b.name]?(0,e.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,e.jsx)(r,{text:q(a[b.name])})},b.name))},b))})]})})]})}d()}catch(a){d(a)}})},77120:(a,b,c)=>{"use strict";c.d(b,{SessionBrowser:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(57031),h=c(88214),i=c(33281),j=c(65484);function k({isOpen:a,onClose:b,onSelectSession:c,onAddProject:l}){let{t:m}=(0,f.Bd)(),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)([]),[r,s]=(0,e.useState)({}),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(null),[x,y]=(0,e.useState)(""),z=(0,e.useRef)(null);(0,e.useCallback)(async()=>{u(!0),w(null),s({});let a=await i.t4.runPromiseExit((0,j.H7)());"Success"===a._tag?q(a.value):w("Failed to load projects"),u(!1)},[]);let A=(0,e.useCallback)(async a=>{s(b=>({...b,[a]:{...b[a],isExpanded:!0,isLoading:!0,sessions:[],error:null}}));let b=await i.t4.runPromiseExit((0,j.QW)(a));"Success"===b._tag?s(c=>({...c,[a]:{...c[a],isLoading:!1,sessions:b.value}})):s(b=>({...b,[a]:{...b[a],isLoading:!1,error:"Failed to load sessions"}}))},[]),B=(0,e.useCallback)(a=>{let b=r[a];b?.isExpanded?s(b=>({...b,[a]:{...b[a],isExpanded:!1}})):b?.sessions?.length?s(b=>({...b,[a]:{...b[a],isExpanded:!0}})):A(a)},[r,A]),C=(0,e.useCallback)(async()=>{if(n)return;o(!0);let a=await i.t4.runPromiseExit((0,j.It)());"Success"===a._tag&&a.value.folder&&l&&(l(a.value.folder),b()),o(!1)},[n,l,b]);return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:b}),(0,d.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,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:m("sessions.projectList")}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("input",{ref:z,type:"text",placeholder:m("workspace.searchProjectPath"),value:x,onChange:a=>y(a.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"}),l&&(0,d.jsxs)("button",{onClick:C,disabled:n,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:m("sessions.openFolder"),children:[(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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"})}),n?m("sessions.selectingFolder"):m("sessions.openFolder")]}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[t&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:m("workspace.loadingProjects")})]})}),v&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-red-11",children:v})}),!t&&!v&&0===p.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:m("workspace.projectNotFound")})}),!t&&!v&&p.filter(a=>a.fullPath.toLowerCase().includes(x.toLowerCase())).map(a=>{let b=r[a.encodedPath]||{isExpanded:!1,isLoading:!1,sessions:[],error:null};return(0,d.jsxs)("div",{className:"mb-3",children:[(0,d.jsxs)("button",{onClick:()=>B(a.encodedPath),className:"w-full flex items-center gap-2 p-2 rounded hover:bg-accent transition-colors text-left",children:[(0,d.jsx)("svg",{className:`w-3 h-3 text-muted-foreground transition-transform ${b.isExpanded?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("span",{className:"flex-1 text-xs font-medium text-foreground truncate",title:a.fullPath,children:a.fullPath}),(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",a.sessionCount,")"]})]}),b.isExpanded&&(0,d.jsxs)("div",{className:"ml-6 mt-2",children:[b.isLoading&&(0,d.jsxs)("div",{className:"flex items-center gap-2 p-3 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-3 w-3",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:m("sessions.loadingSessions")})]}),b.error&&(0,d.jsx)("div",{className:"p-3 text-xs text-red-11",children:b.error}),!b.isLoading&&!b.error&&(0,d.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:b.sessions.map(b=>(0,d.jsxs)("div",{onClick:()=>{var d;let e;return d=a.fullPath,e=(b.path.split("/").pop()||"").replace(".jsonl",""),void(c?c(d,e):(0,g.F)(h.n.OpenProject,{cwd:d,sessionId:e}))},className:"p-3 bg-secondary rounded border border-border hover:border-brand hover:shadow-md cursor-pointer transition-all",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[b.engine&&"claude"!==b.engine&&(0,d.jsx)("span",{className:`shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded ${"claude2"===b.engine?"bg-orange-500/15 text-orange-11":"ollama"===b.engine?"bg-blue-500/15 text-blue-11":"codex"===b.engine?"bg-green-500/15 text-green-11":"kimi"===b.engine?"bg-purple-500/15 text-purple-11":"bg-muted text-muted-foreground"}`,children:b.engine}),(0,d.jsx)("h4",{className:"text-xs font-medium text-foreground truncate",title:b.title,children:b.title})]}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(b.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(0,d.jsxs)("div",{className:"space-y-0.5 text-xs",children:[b.firstMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`first-${b}`)),b.lastMessages.length>0&&(0,d.jsx)("div",{className:"text-slate-9 text-center py-0.5",children:"\xb7\xb7\xb7"}),b.lastMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`last-${b}`))]})]},b.path))})]})]},a.encodedPath)})]})]})]}):null}},77220:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{SettingsModal:()=>o});var e=c(48249),f=c(67484),g=c(44384),h=c(83768),i=c(7833),j=c(28602),k=c(15105),l=c(33281),m=c(79606),n=c(65484);function o({isOpen:a,onClose:b}){let{t:c,i18n:d}=(0,g.Bd)(),{theme:p,setTheme:q}=(0,h.D)(),r=(0,k.G)(),[s,t]=(0,f.useState)(""),[u,v]=(0,f.useState)(""),[w,x]=(0,f.useState)("auto"),y=(0,f.useCallback)(a=>{x(a),l.t4.runFork((0,n.DZ)({language:a}).pipe(m.orElse(()=>m.void)));let b="auto"===a?navigator.language.startsWith("zh")?"zh":"en":a;d.changeLanguage(b)},[d]),z=r?"installed":"not-installed",A=r?.version??null;if(!a)return null;let B=[{value:"system",label:c("settings.themeSystem"),icon:"\uD83D\uDCBB"},{value:"light",label:c("settings.themeLight"),icon:"☀️"},{value:"dark",label:c("settings.themeDark"),icon:"\uD83C\uDF19"}];return(0,e.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:b}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-md mx-4 overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground",children:c("settings.title")}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsxs)("div",{className:"p-4 space-y-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.theme")}),(0,e.jsx)("div",{className:"grid grid-cols-3 gap-2",children:B.map(a=>(0,e.jsxs)("button",{onClick:()=>q(a.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${p===a.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,e.jsx)("span",{className:"text-xl",children:a.icon}),(0,e.jsx)("span",{className:"text-xs font-medium",children:a.label})]},a.value))})]}),(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.language")}),(0,e.jsx)("div",{className:"grid grid-cols-3 gap-2",children:[{value:"auto",label:c("settings.languageAuto"),icon:"\uD83C\uDF10"},{value:"en",label:"English",icon:"\uD83C\uDDFA\uD83C\uDDF8"},{value:"zh",label:"中文",icon:"\uD83C\uDDE8\uD83C\uDDF3"}].map(a=>(0,e.jsxs)("button",{onClick:()=>y(a.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${w===a.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,e.jsx)("span",{className:"text-xl",children:a.icon}),(0,e.jsx)("span",{className:"text-xs font-medium",children:a.label})]},a.value))})]}),(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.browserExtension")}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${"installed"===z?"bg-green-500":"bg-slate-400"}`}),(0,e.jsxs)("span",{children:["installed"===z&&`${c("settings.extensionInstalled")}${A?` (v${A})`:""}`,"not-installed"===z&&c("settings.extensionNotInstalled")]})]}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:c("settings.extensionDescription")}),"installed"!==z&&(0,e.jsxs)("div",{className:"text-xs text-muted-foreground bg-muted/50 rounded-md p-2 space-y-1",children:[(0,e.jsx)("p",{className:"font-medium text-foreground",children:c("settings.installSteps")}),(0,e.jsxs)("p",{children:[c("settings.step1")," ",(0,e.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-foreground",children:"chrome://extensions"})]}),(0,e.jsx)("p",{children:c("settings.step2")}),(0,e.jsx)("p",{children:c("settings.step3")}),(0,j.L)()&&(0,e.jsx)("p",{dangerouslySetInnerHTML:{__html:c("settings.step4mac")}})]}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)("button",{onClick:()=>{let a=s||"chrome-extension";navigator.clipboard.writeText(a),(0,i.oR)(c("toast.copiedName",{name:a}))},className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:c("settings.copyExtensionPath")}),"installed"===z&&(0,e.jsx)("button",{onClick:()=>{r?.id&&window.chrome?.runtime?.sendMessage&&(window.chrome.runtime.sendMessage(r.id,{type:"reload"}),(0,i.oR)(c("toast.pluginReloading")))},className:"px-3 py-1.5 text-xs border border-border text-foreground rounded-md hover:bg-muted transition-colors",children:c("settings.reloadExtension")})]}),s&&(0,e.jsx)("p",{className:"text-[11px] text-muted-foreground font-mono truncate",children:s})]})]}),(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.about")}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground space-y-1",children:[(0,e.jsxs)("p",{children:["Cockpit",u?` v${u}`:""]}),(0,e.jsx)("p",{className:"text-muted-foreground/60",children:"One seat. One AI. Everything under control."})]})]})]})]})]})}d()}catch(a){d(a)}})},77396:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{_:()=>h});var e=c(48249),f=c(22341),g=c(72529);function h({comments:a,startLine:b,endLine:c,lineHeight:d,bodyTopOffset:i,onCommentClick:j}){let k=new Map;for(let d of a){if(d.endLine<b||d.endLine>c)continue;let a=k.get(d.endLine);a?a.push(d):k.set(d.endLine,[d])}return 0===k.size?null:(0,e.jsx)("div",{className:"absolute top-0 right-0 bottom-0 w-6 pointer-events-none",children:Array.from(k.entries()).map(([a,c])=>{let h=i+(a-b)*d,k=c[0],l=c.length-1;return(0,e.jsx)(g.m,{content:1===c.length?k.content:`${c.length} comments — click to view`,children:(0,e.jsxs)("button",{onClick:a=>j(k,a),className:"pointer-events-auto absolute right-1 w-4 h-4 rounded-full bg-amber-9/70 hover:bg-amber-11 text-white flex items-center justify-center shadow-sm transition-colors",style:{top:`${h+d/2-8}px`},children:[(0,e.jsx)(f.A,{className:"w-2.5 h-2.5"}),l>0&&(0,e.jsx)("span",{className:"absolute -top-1 -right-1 bg-amber-11 text-white rounded-full text-[8px] leading-none w-3 h-3 flex items-center justify-center",children:l+1})]})},a)})})}d()}catch(a){d(a)}})},77462:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{TabManager:()=>C});var e=c(48249),f=c(67484),g=c(44384),h=c(67115),i=c(70151),j=c(6900),k=c(49950),l=c(32465),m=c(75513),n=c(94192),o=c(44256),p=c(37129),q=c(38878),r=c(3588),s=c(18946),t=c(29939),u=c(98982),v=c(13054),w=c(79606),x=c(23734),y=c(88214),z=c(33281),A=c(65484);c(37388);var B=a([p,m,q,r,s,i,k,j]);function C({initialCwd:a,initialSessionId:b}){let{t:c}=(0,g.Bd)(),[d,B]=(0,f.useState)("agent"),{tabs:D,activeTabId:E,activeTab:F,unreadTabs:G,dragTabIndex:H,dragOverTabIndex:I,closeTab:J,switchTab:K,handleSelectSession:L,handleNewTab:M,handleNewClaude2Tab:N,handleNewCodexTab:O,handleNewKimiTab:P,handleNewOllamaTab:Q,handleNewDeepseekTab:R,handleOpenSession:S,updateTabState:T,updateTabOllamaModel:U,updateTabDeepseekModel:V,handleTabDragStart:W,handleTabDragOver:X,handleTabDrop:Y,handleTabDragEnd:Z}=(0,p.useTabState)({initialCwd:a,initialSessionId:b,activeView:d}),{isPinned:$,pinSession:_,unpinSession:aa}=(0,u.P)(),{createTask:ab}=(0,v.n)(),ac=(0,f.useCallback)(a=>{let b=D.find(b=>b.id===a);return!!b?.sessionId&&$(b.sessionId)},[D,$]),ad=(0,f.useCallback)(b=>{let c=D.find(a=>a.id===b);c?.sessionId&&($(c.sessionId)?aa(c.sessionId):_(c.sessionId,c.cwd||a||"",c.title))},[D,$,_,aa,a]),[ae,af]=(0,f.useState)(!1),[ag,ah]=(0,f.useState)(!1),[ai,aj]=(0,f.useState)(!1),[ak,al]=(0,f.useState)(null),[am,an]=(0,f.useState)(!1),[ao,ap]=(0,f.useState)("tree"),[aq,ar]=(0,f.useState)(0),[as,at]=(0,f.useState)(null),[au,av]=(0,f.useState)(0),[aw,ax]=(0,f.useState)(!1);(0,f.useRef)(null);let ay=(0,f.useCallback)(b=>{B(b),a&&(z.t4.runFork((0,A.Yn)({cwd:a,settings:{activeView:b}}).pipe(w.orElse(()=>w.void))),z.t4.runFork(w.flatMap(x.d,c=>c.publish(y.n.ViewChange,{cwd:a,view:b}))))},[a]),az=(0,f.useCallback)(async()=>{if(!a)return;let b=await z.t4.runPromiseExit((0,A.b2)(a));if("Success"===b._tag){let c=b.value;if(an(!!c.isGitRepo),c.isGitRepo&&c.worktrees&&c.worktrees.length>0){let b=c.worktrees.find(b=>b.path===a);b&&al(b.branch)}}else console.error("Failed to load git info:",b.cause)},[a]),aA=(0,f.useCallback)(a=>{let{data:b}=a;b?.some(a=>"git"===a.type)&&az()},[az]);(0,t.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"")}`,onMessage:aA,enabled:!!a});let aB=(0,f.useCallback)(()=>{ap("status"),ar(a=>a+1),ay("explorer")},[ay]),aC=(0,f.useCallback)(a=>{at(a),av(a=>a+1),ay("explorer")},[ay]),aD=(0,f.useCallback)(()=>{a&&z.t4.runFork(w.flatMap(x.d,b=>b.publish(y.n.OpenNote,{cwd:a})))},[a]);return(0,e.jsx)(m.k_,{children:(0,e.jsx)(n.fY,{activeView:d,onViewChange:ay,children:(0,e.jsxs)("div",{className:"flex h-screen bg-card",children:[(0,e.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[(0,e.jsx)(q.TabManagerTopBar,{initialCwd:a,activeTab:F,isGitRepo:am,currentBranch:ak,onOpenWorktree:()=>ah(!0),onOpenProjectSessions:()=>af(!0),onOpenAliasManager:()=>aj(!0),onBranchSwitched:az}),aw&&(0,e.jsxs)("div",{className:"flex items-center justify-center gap-2 py-1 bg-brand/15 text-brand text-xs font-medium border-b border-brand/20",children:[(0,e.jsx)("span",{className:"animate-pulse",children:"●"}),c("console.screenshotting")]}),a?(0,e.jsxs)(n.c0,{children:[(0,e.jsx)("div",{className:"w-1/3 h-full flex flex-col overflow-hidden",children:(0,e.jsx)(o.a9,{children:(0,e.jsxs)("div",{className:"w-full h-full flex flex-col",children:[(0,e.jsx)(r.TabBar,{tabs:D,activeTabId:E,unreadTabs:G,dragTabIndex:H,dragOverTabIndex:I,isPinned:ac,onTogglePin:ad,onSwitchTab:K,onCloseTab:J,onNewTab:M,onNewClaude2Tab:N,onNewCodexTab:O,onNewKimiTab:P,onNewOllamaTab:Q,onNewDeepseekTab:R,onDragStart:W,onDragOver:X,onDrop:Y,onDragEnd:Z}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden relative",children:D.map(a=>(0,e.jsx)("div",{className:`h-full ${a.id===E?"block":"hidden"}`,children:(0,e.jsx)(s.X,{tabId:a.id,cwd:a.cwd,sessionId:a.sessionId,engine:a.engine,ollamaModel:a.ollamaModel,onOllamaModelChange:U,deepseekModel:a.deepseekModel,onDeepseekModelChange:V,isActive:a.id===E&&"agent"===d,onStateChange:T,onShowGitStatus:aB,onContentSearch:aC,onOpenNote:aD,onCreateScheduledTask:ab,onOpenSession:S})},a.id))})]})})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(o.a9,{children:(0,e.jsx)(i.g,{onClose:()=>ay("agent"),cwd:a,initialTab:ao,tabSwitchTrigger:aq,initialSearchQuery:as,searchQueryTrigger:au})})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(o.a9,{children:(0,e.jsx)(k.J,{cwd:a,tabId:"default",onOpenNote:aD})})})]}):(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsx)(r.TabBar,{tabs:D,activeTabId:E,unreadTabs:G,dragTabIndex:H,dragOverTabIndex:I,isPinned:ac,onTogglePin:ad,onSwitchTab:K,onCloseTab:J,onNewTab:M,onNewClaude2Tab:N,onNewCodexTab:O,onNewKimiTab:P,onNewDeepseekTab:R,onDragStart:W,onDragOver:X,onDrop:Y,onDragEnd:Z}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden relative",children:D.map(a=>(0,e.jsx)("div",{className:`h-full ${a.id===E?"block":"hidden"}`,children:(0,e.jsx)(s.X,{tabId:a.id,cwd:a.cwd,sessionId:a.sessionId,engine:a.engine,ollamaModel:a.ollamaModel,onOllamaModelChange:U,deepseekModel:a.deepseekModel,onDeepseekModelChange:V,isActive:a.id===E,onStateChange:T,onCreateScheduledTask:ab,onOpenSession:S})},a.id))})]})]}),a&&(0,e.jsx)(h.Q,{isOpen:ae,onClose:()=>af(!1),cwd:a,onSelectSession:L}),a&&am&&(0,e.jsx)(j.x,{isOpen:ag,onClose:()=>ah(!1),cwd:a}),ai&&(0,e.jsx)(l.Y,{onClose:()=>aj(!1),onSave:()=>aj(!1)})]})})})}[p,m,q,r,s,i,k,j]=B.then?(await B)():B,d()}catch(a){d(a)}})},78335:()=>{},78684:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{o:()=>m});var e=c(48249),f=c(67484),g=c(36295),h=c(7833),i=c(28602),j=c(39712),k=c(74493),l=a([g,j]);function m({id:a,filePath:b,displayName:c,cwd:d,selected:l,maximized:n,expandedHeight:o,bubbleContentHeight:p,timestamp:q,onSelect:r,onClose:s,onToggleMaximize:t,onTitleMouseDown:u}){let{showToast:v}=(0,h.dj)(),[w,x]=(0,f.useState)([]),[y,z]=(0,f.useState)(!0),[A,B]=(0,f.useState)(null),[C,D]=(0,f.useState)(!1),[E,F]=(0,f.useState)(!1),[G,H]=(0,f.useState)(null),[I,J]=(0,f.useState)(null),[K,L]=(0,f.useState)("disconnected"),[M,N]=(0,f.useState)(null),O=(0,f.useRef)(null),P=(0,f.useRef)(new Map),Q=(0,f.useRef)(null),R=(0,f.useRef)(w);R.current=w;let S=(0,f.useCallback)(async()=>{z(!0),B(null);try{let a=await (0,k.GW)("/api/jupyter/load",{filePath:b,cwd:d});x(a.cells.map((a,b)=>({...a,index:b,isExecuting:!1}))),D(!1)}catch(a){B(a.message)}finally{z(!1)}},[b,d]),T=(0,f.useCallback)(async()=>{if(!E){F(!0);try{await (0,k.GW)("/api/jupyter/save",{filePath:b,cwd:d,cells:w.map(a=>({cell_type:a.cell_type,source:a.source,outputs:a.outputs,execution_count:a.execution_count,metadata:a.metadata}))}),D(!1),v("Saved","success")}catch(a){v(a.message,"error")}finally{F(!1)}}},[b,d,w,E,v]),U=(0,f.useCallback)(()=>{if(O.current&&O.current.readyState<=1)return;L("starting"),N(null);let b="https:"===window.location.protocol?"wss:":"ws:",c=new WebSocket(`${b}//${window.location.host}/ws/jupyter?bubbleId=${encodeURIComponent(a)}&cwd=${encodeURIComponent(d)}`);O.current=c,c.onopen=()=>{},c.onmessage=a=>{let b;try{b=JSON.parse(a.data)}catch{return}let c=b.type;if("ready"===c)L("idle"),N(null);else if("status"===c){let a=b.execution_state;"idle"===a?L("idle"):"busy"===a&&L("busy")}else if("output"===c){let a=b.msg_id,c=b.msg_type,d=b.content,e=P.current.get(a);if(void 0===e)return;x(a=>a.map((a,b)=>{if(b!==e)return a;let f={output_type:"execute_result"===c?"execute_result":"display_data"===c?"display_data":"update_display_data"===c?"update_display_data":"stream"===c?"stream":"error"===c?"error":"display_data"};return"stream"===c?(f.name=d.name,f.text=d.text):"error"===c?(f.ename=d.ename,f.evalue=d.evalue,f.traceback=d.traceback):(f.data=d.data,f.metadata=d.metadata,"execute_result"===c&&(f.execution_count=d.execution_count)),{...a,outputs:[...a.outputs,f]}}))}else if("kernel_error"===c)L("error"),N(b.message);else if("kernel_died"===c){for(let[,a]of(L("dead"),N("Kernel died"),P.current))x(b=>b.map((b,c)=>c===a?{...b,isExecuting:!1}:b));P.current.clear()}},c.onclose=()=>{"error"!==K&&"dead"!==K&&L("disconnected")},c.onerror=()=>{L("error")}},[a,d,K]),V=(0,f.useRef)(null),W=(0,f.useCallback)(a=>{let b=R.current[a];if(!b||"code"!==b.cell_type)return;if(!O.current||O.current.readyState!==WebSocket.OPEN){U();let b=setInterval(()=>{O.current?.readyState===WebSocket.OPEN&&(clearInterval(b),V.current?.(a))},200);setTimeout(()=>clearInterval(b),15e3);return}let c=`cell-${a}-${Date.now()}`;P.current.set(c,a),x(b=>b.map((b,c)=>c===a?{...b,outputs:[],isExecuting:!0,execution_count:null}:b)),O.current.send(JSON.stringify({type:"execute",msg_id:c,code:b.source})),setTimeout(()=>{P.current.has(c)&&(P.current.delete(c),x(b=>b.map((b,c)=>c===a?{...b,isExecuting:!1}:b)))},3e5)},[U]);V.current=W;let X=(0,f.useCallback)(()=>{let a=[...w.map((a,b)=>({cell:a,index:b})).filter(a=>"code"===a.cell.cell_type)],b=()=>{if(0===a.length)return;let{index:c}=a.shift();W(c);let d=setInterval(()=>{let a=R.current[c];a&&!a.isExecuting&&(clearInterval(d),b())},200)};b()},[w,W]),Y=(0,f.useCallback)(()=>{O.current?.send(JSON.stringify({type:"interrupt"}))},[]),Z=(0,f.useCallback)((a,b)=>{x(c=>c.map((c,d)=>d===a?{...c,source:b}:c)),D(!0)},[]),$=(0,f.useCallback)(a=>{x(b=>b.filter((b,c)=>c!==a)),D(!0),G===a&&H(null)},[G]),_=(0,f.useCallback)((a,b)=>{x(c=>{let d=[...c],e="up"===b?a-1:a+1;return e<0||e>=d.length?c:([d[a],d[e]]=[d[e],d[a]],d)}),D(!0),H("up"===b?a-1:a+1)},[]),aa=(0,f.useCallback)(a=>{x(b=>b.map((b,c)=>{if(c!==a)return b;let d="code"===b.cell_type?"markdown":"markdown"===b.cell_type?"raw":"code";return{...b,cell_type:d,outputs:"code"===d?b.outputs:[]}})),D(!0)},[]),ab=(0,f.useCallback)((a,b)=>{let c={index:0,cell_type:a,source:"",outputs:[],execution_count:null,metadata:{},isExecuting:!1};x(a=>{let d=[...a],e=void 0!==b?b+1:d.length;return d.splice(e,0,c),d}),D(!0);let d=void 0!==b?b+1:w.length;H(d),J(d)},[w.length]),ac=n&&o?o-41:p??g.p,ad=(0,f.useMemo)(()=>{switch(K){case"idle":return(0,e.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500 inline-block",title:"Kernel idle"});case"busy":return(0,e.jsx)("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse inline-block",title:"Kernel busy"});case"starting":return(0,e.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin inline-block",title:"Starting kernel"});case"error":return(0,e.jsx)("span",{className:"w-2 h-2 rounded-full bg-red-500 inline-block",title:M||"Kernel error"});case"dead":return(0,e.jsx)("span",{className:"w-2 h-2 rounded-full bg-red-500 inline-block",title:"Kernel died"});default:return(0,e.jsx)("span",{className:"w-2 h-2 rounded-full bg-gray-500 inline-block",title:"Disconnected"})}},[K,M]);return(0,e.jsxs)("div",{className:`w-full bg-accent text-foreground