@piagent/platform 1.44.3 → 1.44.4

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 (83) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +1 -1
  3. package/README.vi.md +1 -1
  4. package/docs/command-reference-vietnamese.md +2 -2
  5. package/docs/distribution-standard.md +6 -6
  6. package/docs/en/windows.md +2 -0
  7. package/docs/herdr-workflow.md +13 -1
  8. package/docs/languages.json +4 -4
  9. package/docs/operator-manual-vietnamese.md +7 -7
  10. package/docs/publishing-for-teams.md +1 -0
  11. package/docs/quickstart-vietnamese.md +1 -1
  12. package/docs/release-install-policy.md +2 -2
  13. package/docs/team-onboarding.md +2 -2
  14. package/docs/vi/windows.md +2 -0
  15. package/docs-site/architecture.html +1 -1
  16. package/docs-site/assets/search-en.json +1 -1
  17. package/docs-site/assets/search-vi.json +1 -1
  18. package/docs-site/benchmark.html +1 -1
  19. package/docs-site/commands.html +1 -1
  20. package/docs-site/content/en/quickstart.html +1 -1
  21. package/docs-site/content/quickstart.html +1 -1
  22. package/docs-site/context-engine.html +1 -1
  23. package/docs-site/ecosystem.html +1 -1
  24. package/docs-site/en/architecture.html +1 -1
  25. package/docs-site/en/benchmark.html +1 -1
  26. package/docs-site/en/commands.html +1 -1
  27. package/docs-site/en/context-engine.html +1 -1
  28. package/docs-site/en/ecosystem.html +1 -1
  29. package/docs-site/en/index.html +9 -9
  30. package/docs-site/en/mcp-approval.html +1 -1
  31. package/docs-site/en/mcp-auth.html +1 -1
  32. package/docs-site/en/mcp-servers.html +1 -1
  33. package/docs-site/en/mcp.html +1 -1
  34. package/docs-site/en/permissions.html +1 -1
  35. package/docs-site/en/profiles.html +1 -1
  36. package/docs-site/en/quickstart.html +2 -2
  37. package/docs-site/en/runtime.html +1 -1
  38. package/docs-site/en/scope.html +1 -1
  39. package/docs-site/en/security.html +1 -1
  40. package/docs-site/en/team.html +1 -1
  41. package/docs-site/en/update.html +3 -3
  42. package/docs-site/en/whats-new.html +27 -16
  43. package/docs-site/en/windows.html +1 -1
  44. package/docs-site/en/workflows.html +1 -1
  45. package/docs-site/index.html +9 -9
  46. package/docs-site/mcp-approval.html +1 -1
  47. package/docs-site/mcp-auth.html +1 -1
  48. package/docs-site/mcp-servers.html +1 -1
  49. package/docs-site/mcp.html +1 -1
  50. package/docs-site/permissions.html +1 -1
  51. package/docs-site/profiles.html +1 -1
  52. package/docs-site/quickstart.html +2 -2
  53. package/docs-site/releases.json +31 -0
  54. package/docs-site/runtime.html +1 -1
  55. package/docs-site/scope.html +1 -1
  56. package/docs-site/security.html +1 -1
  57. package/docs-site/team.html +1 -1
  58. package/docs-site/update.html +3 -3
  59. package/docs-site/whats-new.html +27 -16
  60. package/docs-site/windows.html +1 -1
  61. package/docs-site/workflows.html +1 -1
  62. package/evals/private-holdout-v1/public-exposure.v2.json +2 -2
  63. package/package.json +1 -1
  64. package/packages/piagent-core/extensions/company-session-guard.ts +4 -2
  65. package/packages/piagent-core/managed/herdr-reporter.mjs +85 -0
  66. package/packages/piagent-core/managed/store.d.mts +1 -0
  67. package/packages/piagent-core/managed/store.mjs +13 -0
  68. package/packages/piagent-core/package.json +1 -1
  69. package/packages/piagent-webui/dist/client/assets/{App-DcaqK-_s.js → App-CiwY9VpU.js} +1 -1
  70. package/packages/piagent-webui/dist/client/assets/{GatewayApp-5DVdNIyr.js → GatewayApp-DrNJW3v_.js} +3 -3
  71. package/packages/piagent-webui/dist/client/assets/{InspectionApp-CBPHxuqj.js → InspectionApp-BBiwSaV0.js} +1 -1
  72. package/packages/piagent-webui/dist/client/assets/{SessionAgentWorkspace-DmD9Qt4f.js → SessionAgentWorkspace-DwyPebIX.js} +1 -1
  73. package/packages/piagent-webui/dist/client/assets/{SessionInspectorDrawer-CK5ujmH3.js → SessionInspectorDrawer-CpVzaf_G.js} +2 -2
  74. package/packages/piagent-webui/dist/client/assets/SettingsNavigation-C-tO5iXn.js +3 -0
  75. package/packages/piagent-webui/dist/client/assets/{SettingsPage-Dda8GW2a.js → SettingsPage-Ca-qRSZa.js} +1 -1
  76. package/packages/piagent-webui/dist/client/assets/{TerminalPanel-X2389XHl.js → TerminalPanel-B8j_r6-y.js} +1 -1
  77. package/packages/piagent-webui/dist/client/assets/{WorkspaceCodeEditor-Dt3dS_QG.js → WorkspaceCodeEditor-BDTPvq-0.js} +1 -1
  78. package/packages/piagent-webui/dist/client/assets/{WorkspaceExplorer-CBHwY4BN.js → WorkspaceExplorer-DVsNU0eu.js} +3 -3
  79. package/packages/piagent-webui/dist/client/assets/{index-BMQo9OEq.js → index-uhJMXxqD.js} +2 -2
  80. package/packages/piagent-webui/dist/client/index.html +1 -1
  81. package/packages/piagent-webui/shared/company-copy.ts +1 -0
  82. package/scripts/piagent-studio.mjs +16 -6
  83. package/packages/piagent-webui/dist/client/assets/SettingsNavigation-BnorH-l_.js +0 -3
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,A as n,At as r,B as i,Bt as a,C as o,Ct as s,D as c,Dn as l,F as u,Fn as d,Ft as f,G as p,Gt as m,H as h,Ht as g,I as _,J as v,Jt as y,K as b,L as x,Lt as S,M as ee,N as C,Ot as w,P as T,Q as E,Qt as D,R as O,S as k,St as A,T as j,U as M,Ut as N,V as P,Vt as F,W as I,Wt as L,X as R,Y as z,Yt as B,Z as V,_ as te,_t as ne,at as H,b as re,bt as ie,ct as U,dt as ae,et as oe,f as se,ft as ce,g as le,gt as W,h as ue,it as de,k as fe,kt as pe,lt as me,m as he,mt as G,nt as ge,ot as K,p as _e,pt as ve,q as ye,rt as q,st as be,tt as xe,ut as Se,v as Ce,vt as we,w as Te,wt as Ee,x as De,xt as Oe,y as ke,yn as Ae,yt as je,z as Me}from"./vendor-CSDKB7mU.js";import{i as Ne,n as J}from"./ui-preferences-0waeSO-S.js";import{i as Pe,n as Fe,o as Ie,r as Le,t as Re}from"./bootstrap-CedkNtRG.js";import{I as ze,S as Be,T as Ve,i as He,l as Ue,mt as We,t as Ge}from"./api-BQS4Dtrr.js";import{r as Ke}from"./view-model-CWNiS4JN.js";var Y=e(d(),1),X=l();function qe({size:e=28}){return(0,X.jsxs)(F,{component:`svg`,viewBox:`0 0 64 64`,"aria-hidden":`true`,className:`brand-logo`,sx:{width:e,height:e,flexShrink:0,display:`block`,borderRadius:`${Math.round(e*.24)}px`},children:[(0,X.jsx)(`rect`,{width:`64`,height:`64`,rx:`15`,fill:`#141612`}),(0,X.jsx)(`rect`,{x:`.75`,y:`.75`,width:`62.5`,height:`62.5`,rx:`14.25`,fill:`none`,stroke:`#ffffff`,strokeOpacity:`.12`,strokeWidth:`1.5`}),(0,X.jsx)(`path`,{d:`M13 21.5h27M21 22v22M32.5 22v17.5c0 3 1.6 4.5 4.5 4.5`,fill:`none`,stroke:`#f2f2ed`,strokeWidth:`5.5`,strokeLinecap:`round`}),(0,X.jsx)(`rect`,{x:`44`,y:`19.5`,width:`6.5`,height:`25`,rx:`1.8`,fill:`#c6f432`})]})}var Je=(e,[t,n])=>e===`vi`?t:n,Ye={"managed-config-missing":[`Chưa nhập cấu hình công ty. Mở Agent Watch → Studio → Nhập cấu hình cho Piagent (trên Windows: Kết nối Piagent trong WSL).`,`Company configuration is not imported. Open Agent Watch → Studio and import it for Piagent (on Windows: Connect Piagent in WSL).`],"managed-keychain-approval-required":[`macOS chưa cho Agent Watch đọc key. Chọn “Luôn cho phép” khi được hỏi rồi kết nối lại.`,`macOS did not let Agent Watch read the key. Choose “Always Allow” when asked, then connect again.`],"managed-key-unavailable":[`Agent Watch không đọc được key công ty trên máy này. Mở Agent Watch, dán lại mã kết nối, bấm Kết nối Piagent trong WSL rồi kết nối lại.`,`Agent Watch cannot read the company key on this computer. Open Agent Watch, paste the connection code again, choose Connect Piagent in WSL, then connect again.`],"managed-profile-disconnected":[`Cấu hình Piagent đang thuộc key công ty đã ngắt kết nối. Nhập lại cấu hình cho Piagent trong Agent Watch (trên Windows: Kết nối Piagent trong WSL).`,`The Piagent configuration belongs to a disconnected company key. Import it again in Agent Watch (on Windows: Connect Piagent in WSL).`],"managed-launch-binding-changed":[`Agent Watch hoặc Piagent vừa cập nhật. Nhập lại cấu hình cho Piagent trong Agent Watch (trên Windows: Kết nối Piagent trong WSL).`,`Agent Watch or Piagent changed. Import the Piagent configuration again in Agent Watch (on Windows: Connect Piagent in WSL).`],"managed-project-contains-config":[`Không mở Piagent công ty ở thư mục này (thường là thư mục home ~) vì nó chứa cấu hình công ty. Vào thư mục dự án rồi chạy lại: cd ~/đường-dẫn-dự-án && piagent studio, hoặc piagent studio --project ~/đường-dẫn-dự-án.`,`The company Piagent cannot open this folder (usually your home folder ~) because it holds the company configuration. Go to a project folder and run it again: cd ~/your-project && piagent studio, or piagent studio --project ~/your-project.`],"managed-binding-update-pending":[`Agent Watch đang chạy nhưng chưa cập nhật cấu hình sau bản Piagent hoặc Agent Watch mới. Mở Agent Watch → Studio, bấm Áp dụng cho Piagent rồi mở lại.`,`Agent Watch is running but has not updated the configuration after the Piagent or Agent Watch update yet. Open Agent Watch → Studio, apply for Piagent, then open it again.`],"managed-binding-watch-not-running":[`Piagent hoặc Agent Watch vừa cập nhật nhưng Agent Watch không chạy nên chưa cập nhật cấu hình. Mở Agent Watch, chờ vài giây rồi mở lại.`,`Piagent or Agent Watch was updated but Agent Watch is not running, so the configuration was not updated. Open Agent Watch, wait a few seconds, then open it again.`],"managed-launch-version-mismatch":[`Agent Watch đang dùng một bản Piagent khác với dashboard này. Mở Agent Watch → Studio, bấm Áp dụng cho Piagent rồi kết nối lại.`,`Agent Watch points at another Piagent install than this dashboard. Open Agent Watch → Studio, apply for Piagent, then connect again.`],"managed-launch-stale-runtime":[`Phiên công ty của bản Piagent cũ chưa dừng được. Thử kết nối lại sau ít giây.`,`The company runtime from the previous Piagent did not stop yet. Connect again in a few seconds.`],"managed-launch-timeout":[`Phiên công ty khởi động quá lâu. Kết nối lại.`,`The company runtime took too long to start. Connect again.`],"company-gateway-timeout":["Phiên công ty đang chạy nhưng không trả lời. Đóng Piagent, chạy `pkill -f piagent-studio.mjs` trong Terminal (Windows: trong Ubuntu), rồi mở lại.","The company runtime is running but does not answer. Close Piagent, run `pkill -f piagent-studio.mjs` in a terminal (Windows: in Ubuntu), then open it again."]},Xe={"company-quota":{title:[`Hết hạn mức token`,`Token quota used up`],text:[`Hạn mức token của key này đã hết. Chờ kỳ hạn mức mới hoặc liên hệ quản trị viên để tăng hạn mức.`,`This key's token quota is used up. Wait for the next quota period or ask an administrator to raise it.`]},"company-provider-limit":{title:[`Tài khoản model của công ty hết lượt`,`Company model account limited`],text:[`Nhà cung cấp đang giới hạn tài khoản model của công ty (hết lượt dùng hoặc quá tải). Thử lại sau; quản trị viên có thể đổi model trong Harness.`,`The provider is limiting the company's model account (out of usage or overloaded). Try again later; an administrator can switch the harness model.`]},"company-account":{title:[`Tài khoản model cần đăng nhập lại`,`Model account must sign in again`],text:[`Tài khoản model của công ty đã hết phiên đăng nhập. Quản trị viên cần đăng nhập lại trong Studio (Tài khoản AI).`,`The company's model account is signed out. An administrator has to sign it in again in Studio (AI accounts).`]},"company-busy":{title:[`Đang quá tải`,`Busy`],text:[`Studio đang xử lý quá nhiều request của key này, hoặc tài khoản model đang bận. Chờ vài giây rồi gửi lại.`,`Studio is handling too many requests for this key, or the model account is busy. Wait a few seconds and send again.`]},"company-trial-limit":{title:[`Studio hết lượt thử nghiệm`,`Studio live-test limit reached`],text:[`Studio đã dùng hết số request thử nghiệm được cấp. Quản trị viên cần nâng trần trước khi chạy tiếp.`,`Studio has used up its live-test request ceiling. An administrator has to raise it before anything runs.`]},"company-key":{title:[`Key công ty không dùng được`,`Company key unusable`],text:[`Key công ty đã hết hạn, bị thu hồi, hoặc Agent Watch không đọc được. Nhập lại key trong Agent Watch.`,`The company key expired, was revoked, or Agent Watch cannot read it. Import the key again in Agent Watch.`]},"company-policy":{title:[`Không được phép`,`Not allowed`],text:[`Key này không được dùng model, mức suy luận hoặc độ dài trả lời đang chọn. Nếu Harness vừa đổi, gửi lại để dùng cấu hình mới; nếu vẫn lỗi, kiểm tra Harness trong Studio.`,`This key may not use this model, thinking level or answer length. If the harness just changed, send again to use the new one; otherwise check the harness in Studio.`]},"company-new-session":{title:[`Cần cuộc trò chuyện mới`,`New conversation needed`],text:[`Cuộc trò chuyện này không tiếp tục được với tài khoản model hiện tại. Nội dung cũ vẫn đọc được; tạo cuộc trò chuyện mới để làm tiếp.`,`This conversation cannot continue with the current model account. It stays readable; start a new conversation to go on.`]},"company-rejected":{title:[`Yêu cầu bị từ chối`,`Request rejected`],text:[`Model từ chối yêu cầu này, thường vì cuộc trò chuyện đã dài hơn model hiện tại nhận được. Bấm Tiếp tục: phần cũ được tóm tắt rồi mới gửi. Nếu vẫn bị từ chối, rút gọn tin nhắn hoặc tạo cuộc trò chuyện mới.`,`The model rejected this request, usually because the conversation grew longer than the current model accepts. Press Continue: the older part is summarised before sending. If it is still rejected, shorten the message or start a new conversation.`]},"company-refused":{title:[`Model từ chối yêu cầu này`,`The model declined this request`],text:[`Nhà cung cấp model từ chối yêu cầu này theo chính sách sử dụng của họ (ví dụ: in, mã hoá hoặc gửi ra ngoài thông tin bí mật). Gửi lại nguyên văn sẽ bị từ chối tiếp; hãy viết lại yêu cầu theo cách khác.`,`The model's provider declined this request under its usage policy (for example, printing, encoding or sending out secrets). The same request is declined again; ask in a different way.`]},"company-unreachable":{title:[`Lỗi kết nối`,`Connection error`],text:[`Không kết nối được tới Studio. Kiểm tra mạng hoặc VPN rồi gửi lại.`,`Studio could not be reached. Check the network or VPN and send again.`]},"company-service":{title:[`Dịch vụ model lỗi`,`Model service error`],text:[`Studio đã nhận yêu cầu nhưng dịch vụ model phía sau không trả lời. Gửi lại; nếu lặp lại, báo quản trị viên kèm mã bên dưới.`,`Studio took the request but its model service did not answer. Send again; if it repeats, give an administrator the code below.`]},"company-config-changed":{title:[`Cấu hình vừa thay đổi`,`Configuration changed`],text:[`Key hoặc Harness vừa thay đổi trong Studio. Gửi lại để chạy với cấu hình mới.`,`The key or harness just changed in Studio. Send again to run with the new one.`]},"company-update":{title:[`Cần cập nhật Piagent`,`Piagent update needed`],text:[`Harness dùng model mà bản Piagent này chưa biết. Cập nhật Piagent rồi gửi lại.`,`The harness uses a model this Piagent does not know. Update Piagent and send again.`]},"company-tool":{title:[`Công cụ lỗi`,`Tool error`],text:[`Công cụ này không chạy được ở bước này (ví dụ subagent đã chạy đủ 8 lần cho tin nhắn này).`,`This tool could not run at this step (for example, the subagent already ran 8 times for this message).`]},"company-failed":{title:[`Lỗi chưa phân loại`,`Unclassified error`],text:[`Yêu cầu không hoàn tất. Gửi lại; nếu lặp lại, báo quản trị viên kèm mã bên dưới.`,`The request did not complete. Send again; if it repeats, give an administrator the code below.`]}},Ze=[`Cuộc trò chuyện này thuộc thành viên hoặc Studio khác với key đang nhập trong Agent Watch. Nội dung cũ vẫn đọc được; tạo cuộc trò chuyện mới để làm tiếp.`,`This conversation belongs to another member or Studio than the key Agent Watch holds. It stays readable; start a new conversation to go on.`],Qe={harness_route_unavailable:{title:[`Không có tài khoản AI cho vai trò này`,`No AI account for this role`],text:[`Không tài khoản AI nào của công ty đang phục vụ model của vai trò này cho team (tài khoản bị ngắt, tắt cho team hoặc hết lượt). Quản trị viên cần gắn hoặc bật tài khoản trong Studio (Tài khoản AI), hoặc đổi model của vai trò trong Harness.`,`No company AI account serves this role's model for the team right now (disconnected, off for the team or out of usage). An administrator has to link or enable one in Studio (AI accounts), or change the role's model in the harness.`]},harness_profile_unavailable:{title:[`Harness không có model cho vai trò này`,`Harness has no model for this role`],text:[`Lượt này bắt đầu khi Harness của team không có model dùng được cho vai trò này. Quản trị viên kiểm tra Harness và tài khoản AI của team trong Studio, rồi gửi lại.`,`This run started while the team's harness had no usable model for this role. An administrator checks the team's harness and AI accounts in Studio; then send again.`]}};function $e(e,t,n){let r=(t?Qe[t]:void 0)??Xe[e]??(e.startsWith(`company-`)?Xe[`company-failed`]:void 0);return r?{title:Je(n,r.title),text:Je(n,t===`managed-session-scope-changed`?Ze:r.text)}:null}function et(e,t){return e===`main`?`Main agent`:e===`scout`?Je(t,[`Subagent scout`,`Scout subagent`]):e===`research`?Je(t,[`Subagent research`,`Research subagent`]):e===`verify`?Je(t,[`Subagent verify`,`Verify subagent`]):Je(t,[`Subagent review`,`Review subagent`])}var tt={anthropic:`#d97757`,claude:`#d97757`,context7:`#7456f1`,chrome:`#4285f4`,deepseek:`#4d6bfe`,figma:`#1e1e1e`,gemini:`#4285f4`,github:`#24292f`,google:`#4285f4`,groq:`#f55036`,linear:`#5e6ad2`,mistral:`#f7a000`,notion:`#111111`,openai:`#10a37f`,slack:`#611f69`};function nt(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`1em`,height:`1em`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{fill:`#f24e1e`,d:`M5 2h7v7H8.5A3.5 3.5 0 0 1 5 5.5V2Z`}),(0,X.jsx)(`path`,{fill:`#ff7262`,d:`M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2Z`}),(0,X.jsx)(`path`,{fill:`#a259ff`,d:`M5 9h7v7H8.5A3.5 3.5 0 0 1 5 12.5V9Z`}),(0,X.jsx)(`circle`,{cx:`15.5`,cy:`12.5`,r:`3.5`,fill:`#1abcfe`}),(0,X.jsx)(`path`,{fill:`#0acf83`,d:`M5 16h7v3.5A3.5 3.5 0 1 1 5 16Z`})]})}function rt(e){let n=e.toLowerCase();return n.includes(`figma`)?(0,X.jsx)(nt,{}):n.includes(`github`)?(0,X.jsx)(z,{fontSize:`inherit`}):n.includes(`chrome`)||n.includes(`devtools`)?(0,X.jsx)(V,{fontSize:`inherit`}):n.includes(`anthropic`)||n.includes(`claude`)?(0,X.jsx)(oe,{fontSize:`inherit`}):n.includes(`file`)||n.includes(`folder`)?(0,X.jsx)(R,{fontSize:`inherit`}):n.includes(`postgres`)||n.includes(`database`)||n.includes(`supabase`)?(0,X.jsx)(v,{fontSize:`inherit`}):n.includes(`code`)||n.includes(`context7`)?(0,X.jsx)(E,{fontSize:`inherit`}):n.includes(`google`)||n.includes(`drive`)||n.includes(`cloud`)?(0,X.jsx)(t,{fontSize:`inherit`}):(0,X.jsx)(ae,{fontSize:`inherit`})}function it({name:e,size:t=34}){let n=e.toLowerCase(),r=Object.keys(tt).find(e=>n.includes(e));return(0,X.jsx)(F,{"aria-hidden":`true`,sx:{width:t,height:t,flex:`0 0 ${t}px`,display:`grid`,placeItems:`center`,borderRadius:t>30?2:1.4,bgcolor:r?tt[r]:`action.selected`,color:r?`#fff`:`text.secondary`,fontSize:Math.round(t*.52),border:1,borderColor:r?`transparent`:`divider`},children:rt(e)})}function at(e,t){let n=e.name.toLowerCase();return n===`figma-desktop`?J(t,`Cần bật MCP trong Figma Desktop`,`Enable MCP in Figma Desktop`):n===`figma`?e.state===`disabled`?J(t,`Remote OAuth · chưa được Figma duyệt`,`Remote OAuth · not approved by Figma`):`Remote OAuth`:`${e.transport} · ${e.scope}`}function ot(e,t,n){return e===`mcp-oauth-client-not-approved`&&t.toLowerCase()===`figma`?J(n,`Figma Remote chưa cho phép Piagent đăng ký OAuth. Có thể dùng kết nối Figma Desktop bên dưới.`,`Figma Remote has not approved Piagent as an OAuth client. You can use the Figma Desktop connection below.`):e===`mcp-oauth-client-not-approved`?J(n,`Nhà cung cấp chưa cho phép client OAuth này.`,`The provider has not approved this OAuth client.`):e===`mcp-oauth-registration-rejected`?J(n,`Nhà cung cấp từ chối đăng ký OAuth.`,`The provider rejected OAuth client registration.`):e===`mcp-oauth-cancelled`||e===`cancelled-by-user`?J(n,`Đã hủy đăng nhập.`,`Sign in cancelled.`):J(n,`Không thể kết nối OAuth. Vui lòng thử lại.`,`Could not connect OAuth. Please try again.`)}function st({sessionRef:e,connection:t,onChanged:n,compact:r=!1}){let{locale:i}=Ne(),[o,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(),[d,f]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!l||l.state!==`running`)return;let e=new AbortController,t=window.setTimeout(()=>void Be(l.jobRef,e.signal).then(e=>{u(e),e.state===`completed`&&n()}).catch(()=>f(J(i,`Mất kết nối OAuth`,`OAuth flow disconnected`))),750);return()=>{e.abort(),window.clearTimeout(t)}},[l?.jobRef,l?.generatedAt,l?.state,i,n]);let m=async r=>{c(!0),f(null);try{let i=await Ue({action:r?`mcp.enable`:`mcp.disable`,sessionRef:e,connectionRef:t.connectionRef});`connections`in i?n(i):n()}catch{f(J(i,`Không thể cập nhật MCP`,`Could not update MCP`))}finally{c(!1)}},g=async()=>{c(!0),f(null);try{let n=await Ue({action:`mcp.oauth`,sessionRef:e,connectionRef:t.connectionRef});if(`jobRef`in n)u(n);else throw Error(`mcp-oauth-job-missing`)}catch{f(J(i,`Không thể bắt đầu OAuth`,`Could not start OAuth`))}finally{c(!1)}},_=async()=>{l?.state===`running`&&await He(l.jobRef).catch(()=>void 0),u(void 0),f(null)};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(A,{direction:`row`,spacing:.75,sx:{alignItems:`center`,flexWrap:`wrap`,justifyContent:`flex-end`},children:[t.authState===`connected`&&(0,X.jsx)(Ee,{size:`small`,color:`success`,variant:`outlined`,icon:(0,X.jsx)(ye,{}),label:J(i,`Đã kết nối`,`Connected`)}),t.oauthSupported&&t.authState!==`connected`&&t.state!==`disabled`&&(0,X.jsx)(a,{size:`small`,variant:`outlined`,disabled:o,onClick:()=>void g(),children:`OAuth`}),t.toggleSupported&&(0,X.jsx)(G,{title:t.state===`disabled`?J(i,`Bật ${t.name}`,`Enable ${t.name}`):J(i,`Tắt ${t.name}`,`Disable ${t.name}`),arrow:!0,children:(0,X.jsx)(`span`,{children:(0,X.jsx)(h,{size:r?`small`:`medium`,checked:t.state!==`disabled`,disabled:o,onChange:(e,t)=>void m(t),slotProps:{input:{"aria-label":t.state===`disabled`?J(i,`Bật ${t.name}`,`Enable ${t.name}`):J(i,`Tắt ${t.name}`,`Disable ${t.name}`)}}})})})]}),d&&(0,X.jsx)(S,{role:`status`,color:`error`,variant:`caption`,children:d}),(0,X.jsxs)(s,{open:!!l,onClose:()=>void _(),fullWidth:!0,maxWidth:`xs`,children:[(0,X.jsxs)(M,{children:[t.name,` · OAuth`]}),(0,X.jsx)(I,{children:(0,X.jsxs)(A,{spacing:1.25,sx:{pt:.5},children:[l?.state===`running`&&!l.authorizationUrl&&(0,X.jsx)(S,{color:`text.secondary`,children:J(i,`Đang chuẩn bị đăng nhập…`,`Preparing sign in…`)}),l?.authorizationUrl&&(0,X.jsx)(a,{component:`a`,href:l.authorizationUrl,target:`_blank`,rel:`noopener noreferrer`,variant:`contained`,endIcon:(0,X.jsx)(b,{}),children:J(i,`Mở trang đăng nhập`,`Open sign in`)}),l?.state===`completed`&&(0,X.jsx)(S,{color:`success.main`,children:J(i,`Đã kết nối MCP`,`MCP connected`)}),l&&[`failed`,`cancelled`].includes(l.state)&&(0,X.jsx)(S,{color:`error`,children:ot(l.reasonCode,t.name,i)})]})}),(0,X.jsx)(p,{children:(0,X.jsx)(a,{color:`inherit`,onClick:()=>void _(),children:l?.state===`running`?J(i,`Hủy`,`Cancel`):J(i,`Đóng`,`Close`)})})]})]})}function ct({open:e,title:t,description:n,confirmLabel:r,cancelLabel:o,onConfirm:c,onCancel:l}){return(0,X.jsxs)(s,{open:e,onClose:l,fullWidth:!0,maxWidth:`xs`,"aria-describedby":`piagent-confirm-dialog-description`,slotProps:{paper:{sx:{borderRadius:1,p:.5}}},children:[(0,X.jsxs)(M,{sx:{display:`flex`,alignItems:`center`,gap:1.25,pb:1},children:[(0,X.jsx)(F,{sx:{width:36,height:36,borderRadius:1,display:`grid`,placeItems:`center`,bgcolor:`warning.main`,color:`warning.contrastText`},children:(0,X.jsx)(P,{fontSize:`small`})}),(0,X.jsx)(S,{component:`span`,sx:{fontSize:`1.08rem`,fontWeight:650},children:t})]}),(0,X.jsx)(I,{children:(0,X.jsx)(i,{id:`piagent-confirm-dialog-description`,sx:{color:`text.secondary`,lineHeight:1.65},children:n})}),(0,X.jsxs)(p,{sx:{px:2.5,pb:2,gap:.75},children:[(0,X.jsx)(a,{color:`inherit`,onClick:l,autoFocus:!0,children:o}),(0,X.jsx)(a,{variant:`contained`,color:`warning`,onClick:c,children:r})]})]})}function lt({name:e,value:t}){return(0,X.jsxs)(A,{direction:`row`,sx:{justifyContent:`space-between`,gap:3,py:.65},children:[(0,X.jsx)(S,{variant:`body2`,color:`text.secondary`,children:e}),(0,X.jsx)(S,{variant:`body2`,sx:{fontWeight:600},children:t})]})}var ut=(e,t)=>e?J(t,`Fast: bật`,`Fast: on`):J(t,`Fast: tắt`,`Fast: off`),dt=e=>J(e,`Fast: main agent trả lời nhanh hơn trên model GPT (Codex); token tính vào quota gấp 2,5 lần. Model và mức suy luận không đổi.`,`Fast: the main agent answers faster on GPT (Codex) models; its tokens count 2.5 times toward the quota. Model and thinking level are unchanged.`),ft={borderColor:`warning.main`,color:`warning.main`,fontWeight:650,bgcolor:e=>Ae(e.palette.warning.main,.14),"&:hover":{bgcolor:e=>Ae(e.palette.warning.main,.22),color:`warning.main`}};function pt({title:e,label:t,icon:n,active:r,badge:i,tone:o,onClick:s,compact:c=!1}){let l=c?void 0:t,u={border:1,borderColor:r?e=>Ae(e.palette.primary.main,.45):`transparent`,bgcolor:r?e=>Ae(e.palette.primary.main,.12):`action.hover`,color:r?`primary.main`:`text.secondary`,borderRadius:999,fontWeight:500,"&:hover":{bgcolor:`action.selected`,color:`text.primary`},...r&&o===`warning`?ft:{}},d=l?(0,X.jsx)(a,{size:`small`,"aria-label":e,onClick:s,startIcon:n,sx:{...u,minHeight:30,minWidth:{xs:30,md:64},maxWidth:260,px:{xs:.75,md:1.15},"& .MuiButton-startIcon":{mr:{xs:0,md:.65},ml:0},"& .MuiButton-startIcon svg":{fontSize:16}},children:(0,X.jsx)(F,{component:`span`,sx:{display:{xs:`none`,md:`inline`},overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:l})}):(0,X.jsx)(N,{size:`small`,"aria-label":e,onClick:s,sx:{...u,width:30,height:30},children:n});return(0,X.jsx)(G,{title:e,children:i?(0,X.jsx)(U,{badgeContent:i,color:`primary`,max:9999,sx:{"& .MuiBadge-badge":{height:16,minWidth:16,px:.4,fontSize:9,fontWeight:650}},children:d}):d})}function mt({session:e,snapshot:t,connections:n,locale:r,onOpenChanges:i,canSetModel:o,canSetThinking:s,canSetPermission:c,onSetModel:l,onSetThinking:u,onSetPermission:d,onSetFast:f,onConnectionsChanged:p,placement:m=`composer`,compact:h=!1}){let[_,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null),[x,ee]=(0,Y.useState)(),[C,T]=(0,Y.useState)(!1),[E,D]=(0,Y.useState)(null),[O,k]=(0,Y.useState)(null),[j,M]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(m!==`header`)return;let e=new AbortController;return ze(e.signal).then(ee).catch(()=>void 0),()=>e.abort()},[m]);let N=e=>t=>{v(e),b(t.currentTarget)},P=()=>{v(null),b(null)},I=t?.sourceChanges,L=I?.workingTree.counts.files??0,R=t?.session.permissionProfile,[z,B]=(0,Y.useState)(R?.state===`known`?R.value??null:null);(0,Y.useEffect)(()=>{B(e.managedPermission??(R?.state===`known`?R.value??null:null))},[e.sessionRef,e.managedPermission,R?.state,R?.value]);let V=t?.usage.context,te=V?.state===`known`,ne=te?V.tokens:e.contextUsage.usedTokens,re=te?V.contextWindow:e.contextUsage.contextWindow,U=te?V.percent:e.contextUsage.ratio===null?null:e.contextUsage.ratio*100,oe=U==null?`—`:`${Math.round(U)}%`,se=t?.session.model.state===`known`&&t.session.model.value?t.session.model.value.modelRef:``,le=x?.models.find(e=>e.modelRef===se)??(x?.models.length===1?x.models[0]:void 0),W=e.modelLabel===`agent-watch-auto`||x?.models.length===1&&x.models[0].provider===`agent_watch_managed`,ue=(0,Y.useMemo)(()=>e.managedThinkingLevels??le?.thinkingLevels??(W?[]:[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`]),[le,e.managedThinkingLevels,W]),fe=async e=>{if(!(!e||!l)){T(!0),D(null);try{await l(e)}catch{D(J(r,`Chưa thể đổi model lúc này`,`Could not change the model right now`))}finally{T(!1)}}},pe=async e=>{if(u){T(!0),D(null);try{await u(e)}catch{D(J(r,`Chưa thể đổi thinking lúc này`,`Could not change thinking right now`))}finally{T(!1)}}},he=e.managedFast===`on`,G=async()=>{if(!(!f||C)){T(!0);try{await f(!he),M({tone:`success`,text:he?J(r,`Đã tắt Fast. Các lượt sau chạy tốc độ thường.`,`Fast is off. The next calls run at standard speed.`):J(r,`Đã bật Fast: main agent trả lời nhanh hơn trên model GPT, token tính vào quota gấp 2,5 lần. Model và mức suy luận không đổi.`,`Fast is on: the main agent answers faster on GPT models, and its tokens count 2.5 times toward the quota. Model and thinking level are unchanged.`)})}catch(e){let t=e instanceof Error&&/managed-fast-unavailable|unavailable/.test(e.message);M({tone:`error`,text:t?J(r,`Harness của team không cho phép Fast.`,`The team's Harness does not allow Fast.`):J(r,`Chưa đổi được Fast. Thử lại.`,`Fast not changed. Try again.`)})}finally{T(!1)}}},K=async t=>{if(!d)return;T(!0),D(null);let n=W?ht(t,r):Ke(t,r);try{await d(t),B(t),M(W&&e.liveState===`waiting-approval`?{tone:`info`,text:J(r,`Đã chuyển sang ${n}. Lệnh đang chờ vẫn cần bạn bấm Cho phép hoặc Từ chối; các lệnh sau theo ${n}.`,`Switched to ${n}. The command already waiting still needs Allow or Deny; the next ones follow ${n}.`)}:{tone:`success`,text:J(r,`Đã chuyển sang ${n}.`,`Switched to ${n}.`)})}catch(e){let t=e instanceof Error&&e.message===`session-runtime-busy`?J(r,`Chưa đổi được quyền: lượt này đang chạy. Đổi lại sau khi lượt xong.`,`Access not changed: this turn is running. Change it after the turn ends.`):J(r,`Chưa đổi được quyền. Thử lại.`,`Access not changed. Try again.`);D(t),M({tone:`error`,text:t})}finally{T(!1)}},_e=e=>{if(e===`trusted-full-access`||e===`bypass`){P(),k(e);return}K(e)},ye=_===`model`?`Model & thinking`:_===`context`?`Context`:_===`connections`?J(r,`MCP & kết nối`,`MCP & connections`):_===`permission`?J(r,`Quyền`,`Access`):J(r,`Source Changes`,`Source Changes`);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(F,{sx:{display:`flex`,gap:.65,mb:m===`composer`?.8:0,px:.1,flexWrap:m===`header`?`nowrap`:`wrap`,flexShrink:0,alignItems:`center`,justifyContent:m===`header`?`flex-end`:`flex-start`},children:[m===`header`&&W&&(e.managedHelpers?.maximum??2)>0&&(0,X.jsxs)(S,{variant:`caption`,color:`text.secondary`,title:J(r,`Subagent đang chạy trong phiên này; Studio giới hạn tổng số theo thành viên.`,`Subagents running in this session; Studio caps the total per member.`),sx:{whiteSpace:`nowrap`,display:{xs:`none`,sm:`block`},mr:.5},children:[J(r,`Subagent`,`Subagents`),` `,e.managedHelpers?.active??0,`/`,e.managedHelpers?.maximum??2]}),m===`header`&&(0,X.jsx)(pt,{compact:h,active:_===`model`,onClick:N(`model`),icon:(0,X.jsx)(Se,{fontSize:`small`}),label:`${(W?`agent-watch-auto`:e.modelLabel)??J(r,`Model session`,`Session model`)} · ${e.thinkingLevel===`unknown`||ue.length>0&&!ue.includes(e.thinkingLevel)?`—`:Ke(e.thinkingLevel,r)}`,title:W?`agent-watch-auto · Thinking`:J(r,`Đổi model và mức suy luận`,`Change model and thinking level`)}),m===`header`&&(0,X.jsx)(pt,{compact:h,active:_===`permission`,onClick:N(`permission`),icon:(0,X.jsx)(me,{fontSize:`small`}),label:W?ht(z,r):z?Ke(z,r):J(r,`Quyền`,`Access`),title:J(r,`Đổi quyền truy cập`,`Change access level`)}),m===`header`&&W&&e.managedFast&&f&&(0,X.jsx)(pt,{compact:h,active:he,tone:`warning`,onClick:()=>void G(),icon:(0,X.jsx)(ve,{fontSize:`small`}),label:ut(he,r),title:he?J(r,`Fast đang bật: bấm để tắt (về tốc độ thường). Token tính vào quota gấp 2,5 lần.`,`Fast is on: click to turn it off (standard speed). Tokens count 2.5 times toward the quota.`):J(r,`Bật Fast: trả lời nhanh hơn, token tính vào quota gấp 2,5 lần`,`Turn Fast on: faster answers, tokens count 2.5 times toward the quota`)}),m===`composer`&&(0,X.jsx)(pt,{active:_===`context`,onClick:N(`context`),icon:(0,X.jsx)(ce,{fontSize:`small`}),title:`Context · ${oe}`}),m===`composer`&&(0,X.jsx)(pt,{active:_===`connections`,onClick:N(`connections`),icon:(0,X.jsx)(ae,{fontSize:`small`}),badge:n?.summary.configured??0,title:(n?.summary.configured??0)>0?J(r,`MCP & kết nối · ${n?.summary.configured}`,`MCP & connections · ${n?.summary.configured}`):J(r,`MCP & kết nối`,`MCP & connections`)}),m===`composer`&&(0,X.jsx)(pt,{active:_===`changes`,onClick:N(`changes`),icon:(0,X.jsx)(w,{fontSize:`small`}),badge:L,title:`Source Changes${L?` · ${L}`:``}`})]}),(0,X.jsxs)(ie,{open:_!==null,anchorEl:y,onClose:P,anchorOrigin:{vertical:m===`header`?`bottom`:`top`,horizontal:`left`},transformOrigin:{vertical:m===`header`?`top`:`bottom`,horizontal:`left`},slotProps:{paper:{sx:{width:330,maxWidth:`calc(100vw - 24px)`,borderRadius:1,p:1.5,mt:+(m===`header`)}}},children:[(0,X.jsx)(S,{sx:{px:.5,pb:1,fontWeight:600},children:ye}),(0,X.jsx)(be,{}),_===`model`&&(0,X.jsxs)(A,{sx:{px:.5,pt:1},spacing:1.25,children:[W?(0,X.jsxs)(F,{children:[(0,X.jsx)(S,{children:`agent-watch-auto`}),(0,X.jsx)(lt,{name:`Context`,value:re?new Intl.NumberFormat().format(re):`—`})]}):(0,X.jsxs)(F,{children:[(0,X.jsx)(S,{variant:`caption`,color:`text.secondary`,children:`Model`}),(0,X.jsx)(we,{fullWidth:!0,size:`small`,value:se,disabled:!o||C||e.liveState===`running`,onChange:e=>void fe(e.target.value),sx:{mt:.5},children:(x?.models??[]).map(e=>(0,X.jsx)(ge,{value:e.modelRef,children:e.displayName},e.modelRef))})]}),(0,X.jsxs)(F,{children:[(0,X.jsx)(S,{variant:`caption`,color:`text.secondary`,children:`Thinking`}),(0,X.jsx)(we,{fullWidth:!0,size:`small`,inputProps:{"aria-label":`Thinking`},value:e.thinkingLevel===`unknown`?``:e.thinkingLevel,disabled:!s||C||e.liveState===`running`,onChange:e=>void pe(e.target.value),sx:{mt:.5},children:ue.map(e=>(0,X.jsx)(ge,{value:e,children:Ke(e,r)},e))})]}),E&&(0,X.jsx)(S,{role:`status`,color:`error`,variant:`caption`,children:E})]}),_===`context`&&(0,X.jsxs)(F,{sx:{px:.5,pt:.75},children:[(0,X.jsx)(lt,{name:J(r,`Đã dùng`,`Used`),value:oe}),(0,X.jsx)(lt,{name:`Tokens`,value:ne===null?`—`:new Intl.NumberFormat().format(ne)}),(0,X.jsx)(lt,{name:`Window`,value:re===null?`—`:new Intl.NumberFormat().format(re)})]}),_===`connections`&&(0,X.jsxs)(Oe,{dense:!0,disablePadding:!0,sx:{pt:.5},children:[(n?.connections??[]).map(t=>(0,X.jsxs)(H,{sx:{alignItems:`center`,gap:.5},children:[(0,X.jsx)(de,{sx:{minWidth:38},children:(0,X.jsx)(it,{name:t.name,size:28})}),(0,X.jsx)(q,{primary:t.name,secondary:at(t,r)}),(0,X.jsx)(st,{compact:!0,sessionRef:e.sessionRef,connection:t,onChanged:e=>p?.(e)})]},t.connectionRef)),n&&n.connections.length===0&&(0,X.jsx)(H,{children:(0,X.jsx)(q,{primary:J(r,`Chưa có MCP`,`No MCP configured`)})}),!n&&(0,X.jsx)(H,{children:(0,X.jsx)(q,{primary:J(r,`Đang đọc…`,`Loading…`)})})]}),_===`permission`&&(0,X.jsxs)(A,{sx:{px:.5,pt:1},spacing:.75,children:[(W?[`workspace-write`,`trusted-full-access`,...e.managedBypass?[`bypass`]:[]]:[`read-only`,`workspace-write`,`trusted-full-access`,`bypass`]).map(t=>(0,X.jsx)(a,{variant:z===t?`contained`:`outlined`,color:t===`bypass`?`error`:t===`trusted-full-access`?`warning`:`primary`,disabled:!c||C||!W&&e.liveState===`running`,onClick:()=>_e(t),sx:{justifyContent:`flex-start`},children:W?ht(t,r):Ke(t,r)},t)),E&&(0,X.jsx)(S,{role:`status`,color:`error`,variant:`caption`,children:E})]}),_===`changes`&&(0,X.jsxs)(F,{sx:{px:.5,pt:.75},children:[(0,X.jsx)(lt,{name:J(r,`Task changes`,`Task changes`),value:String(I?.task?.counts.files??0)}),(0,X.jsx)(lt,{name:J(r,`Working tree`,`Working tree`),value:String(I?.workingTree.counts.files??0)}),(0,X.jsx)(lt,{name:J(r,`Staged`,`Staged`),value:String(I?.staged.counts.files??0)}),(0,X.jsx)(a,{fullWidth:!0,variant:`outlined`,startIcon:(0,X.jsx)(w,{}),sx:{mt:1},onClick:()=>{P(),i()},children:J(r,`Mở Source Changes`,`Open Source Changes`)})]})]}),(0,X.jsx)(ct,{open:O!==null,title:O===`bypass`?J(r,`Bật Bypass?`,`Turn on Bypass?`):J(r,`Bật toàn quyền?`,`Enable full access?`),description:O===`bypass`?W?_t(r):gt(r):W?vt(r):J(r,`Session này sẽ được phép đọc, sửa file và chạy command trong phạm vi runtime. Các thao tác xóa hoặc gửi dữ liệu ra ngoài vẫn cần xác nhận riêng.`,`This session will be allowed to read and edit files and run commands within the runtime. Destructive actions and external data transfers still require separate confirmation.`),cancelLabel:J(r,`Hủy`,`Cancel`),confirmLabel:O===`bypass`?J(r,`Bật Bypass`,`Turn on Bypass`):J(r,`Bật toàn quyền`,`Enable full access`),onCancel:()=>k(null),onConfirm:()=>{let e=O;k(null),e&&K(e)}}),(0,X.jsx)(xe,{open:j!==null,autoHideDuration:j?.tone===`success`?4e3:12e3,onClose:()=>M(null),anchorOrigin:{vertical:`top`,horizontal:`center`},children:(0,X.jsx)(g,{severity:j?.tone??`info`,variant:`filled`,onClose:()=>M(null),role:j?.tone===`error`?`alert`:`status`,children:j?.text})})]})}function ht(e,t){return e===`bypass`?`Bypass`:e===`trusted-full-access`?J(t,`Toàn quyền`,`Full access`):J(t,`Hỏi trước`,`Ask first`)}function gt(e){return J(e,`Không hỏi, không chặn gì trong cuộc trò chuyện personal này: xoá, push, gửi ra ngoài, file được bảo vệ đều chạy luôn, như chế độ bypass của Codex. Output vẫn được che secret và /undo vẫn hoàn tác được từng lượt. Cuộc trò chuyện company theo công tắc Bypass trong Harness của Studio.`,`Nothing is asked or blocked in this personal conversation: deletes, pushes, external sends and protected files all run, as with Codex's bypass mode. Output is still redacted and /undo can still revert each turn. Company conversations follow the Bypass switch of the Studio Harness.`)}function _t(e){return J(e,`Không hỏi gì nữa trong cuộc trò chuyện này: lệnh cần internet, Docker, chạy trên máy, push, deploy, migration đều chạy luôn, như bypass của Codex. Lệnh thường vẫn chạy trong sandbox, output vẫn che secret và /undo vẫn hoàn tác được. Admin Studio có thể tắt Bypass trong Harness.`,`Nothing is asked in this conversation any more: commands that need the internet, Docker or this machine, pushes, deploys and migrations all run, as with Codex's bypass. Plain commands still run in the sandbox, output is still redacted and /undo still works. A Studio administrator can turn Bypass off in the Harness.`)}function vt(e){return J(e,`Lệnh cần internet (cài package, tải file, git pull, test có server hay browser) chạy luôn, không hỏi. Vẫn hỏi trước khi đẩy hoặc gửi dữ liệu ra ngoài (git push, publish, deploy, upload, ssh), chạy migration database, xóa mà không rõ đích hoặc dùng sudo.`,`Commands that need the internet (package installs, downloads, git pull, tests with a server or browser) run without asking. You are still asked before anything that pushes or sends data out (git push, publish, deploy, uploads, ssh), database migrations, deletes whose target is unknown, and sudo.`)}var yt=class extends Error{status;constructor(e,t){super(t),this.status=e}};async function bt(e,t){let n;if(t?.method===`POST`){let r=Fe();if(!r)throw new yt(403,`mutation-authority-rejected`);n=await Pe(e,{...t,credentials:`same-origin`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":r}})}else n=await fetch(e,{...t,credentials:`same-origin`,headers:{Accept:`application/json`}});n.status===401&&Ie();let r=await n.json().catch(()=>null);if(!n.ok)throw new yt(n.status,typeof r?.error?.code==`string`?r.error.code:`request-${n.status}`);return r}var xt=e=>bt(`/api/v1/updates`,{signal:e}),St=()=>bt(`/api/v1/updates/check`,{method:`POST`,body:`{}`}),Ct=e=>bt(`/api/v1/updates/apply`,{method:`POST`,body:JSON.stringify({version:e})}),wt=e=>e?.job?.state===`starting`||e?.job?.state===`running`,Tt=(0,Y.createContext)(null);function Et({children:e}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(!0),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),d=(0,Y.useRef)(!0),f=(0,Y.useCallback)(async()=>{try{if(await Re(),Le())return;let e=await xt();d.current&&(n(e),i(!0))}catch(e){d.current&&e instanceof yt&&e.status===404&&i(!1)}},[]),p=wt(t),m=t!==null||!r;(0,Y.useEffect)(()=>{d.current=!0,f();let e=setInterval(()=>void f(),m?p?3e3:6e4:2e3);return()=>{clearInterval(e)}},[f,p,m]),(0,Y.useEffect)(()=>()=>{d.current=!1},[]);let h=(0,Y.useCallback)(async()=>{o(!0),u(null);try{n(await St())}catch(e){u(e instanceof Error?e.message:`update-unavailable`)}finally{o(!1)}},[]),g=(0,Y.useCallback)(async()=>{let e=t?.piagent.latest;if(e){c(!0),u(null);try{await Ct(e),await f()}catch(e){u(e instanceof Error?e.message:`update-unavailable`),await f()}finally{c(!1)}}},[t?.piagent.latest,f]),_=(0,Y.useMemo)(()=>({status:t,supported:r,checking:a||!!t?.checking,applying:s,error:l,refresh:f,check:h,apply:g}),[t,r,a,s,l,f,h,g]);return(0,X.jsx)(Tt.Provider,{value:_,children:e})}function Dt(){let e=(0,Y.useContext)(Tt);if(!e)throw Error(`Piagent update state is missing`);return e}var Ot=`~/.pi/piagent-update-job.log`;function kt(e,t){let n={"update-blocked-running":[`Đang có cuộc trò chuyện chạy. Cập nhật khi chúng xong, hoặc bấm Dừng.`,`A conversation is running. Update when it finishes, or stop it.`],"update-already-running":[`Một lần cập nhật khác đang chạy.`,`Another update is running.`],"update-version-changed":[`Đã có bản mới hơn bản bạn thấy. Kiểm tra lại rồi cập nhật.`,`A newer release appeared. Check again, then update.`],"update-not-available":[`Máy này đã ở bản mới nhất.`,`This machine is already up to date.`],"update-not-installable":[`Bản Piagent này không tự cập nhật được từ dashboard.`,`This Piagent cannot update itself from the dashboard.`]}[t];return n?J(e,n[0],n[1]):J(e,`Chưa cập nhật được. Thử lại sau.`,`The update could not start. Try again later.`)}function At(e,t){return t.state===`succeeded`?t.reason===`dashboard-restart-failed`?{severity:`warning`,text:J(e,`Đã cập nhật lên ${t.installed??t.to}, nhưng dashboard chưa tự mở lại. Chạy \`piagent dashboard restart\`.`,`Updated to ${t.installed??t.to}, but the dashboard did not restart. Run \`piagent dashboard restart\`.`)}:{severity:`success`,text:J(e,`Đã cập nhật Piagent ${t.from} → ${t.installed??t.to}.`,`Updated Piagent ${t.from} → ${t.installed??t.to}.`)}:t.state===`failed`?{severity:`error`,text:`${t.reason===`update-interrupted`?J(e,`Lần cập nhật bị ngắt giữa chừng.`,`The update was interrupted.`):t.reason===`update-version-mismatch`?J(e,`Bản cài xong không đúng bản đã chọn.`,`The installed release is not the one chosen.`):J(e,`Lệnh cập nhật báo lỗi.`,`The update command failed.`)} ${J(e,`Chi tiết trong ${Ot}.`,`Details are in ${Ot}.`)}`}:null}function jt(e,t){if(!t)return J(e,`chưa kiểm tra`,`not checked yet`);let n=Math.max(0,Math.round((Date.now()-Date.parse(t))/6e4));if(n<1)return J(e,`vừa xong`,`just now`);if(n<60)return J(e,`${n} phút trước`,`${n} min ago`);let r=Math.round(n/60);return r<48?J(e,`${r} giờ trước`,`${r} h ago`):J(e,`${Math.round(r/24)} ngày trước`,`${Math.round(r/24)} days ago`)}function Mt({name:e,detail:t,chip:n,tone:r}){return(0,X.jsxs)(A,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},justifyContent:`space-between`,gap:1.5,p:2.25},children:[(0,X.jsxs)(F,{sx:{minWidth:0},children:[(0,X.jsx)(S,{sx:{fontWeight:650},children:e}),(0,X.jsx)(S,{variant:`body2`,color:`text.secondary`,children:t})]}),(0,X.jsx)(Ee,{size:`small`,label:n,color:r,variant:r==="default"?`outlined`:`filled`,sx:{alignSelf:{xs:`flex-start`,sm:`center`}}})]})}function Nt(e,t){let n=[];return t.piagent.updateAvailable&&n.push(J(e,`Piagent ${t.piagent.installed} → ${t.piagent.latest}`,`Piagent ${t.piagent.installed} → ${t.piagent.latest}`)),t.pi.updateAvailable&&n.push(J(e,`Pi ${t.pi.installed??`?`} → ${t.pi.required} (bản Piagent ${t.piagent.latest} yêu cầu)`,`Pi ${t.pi.installed??`?`} → ${t.pi.required} (the version Piagent ${t.piagent.latest} requires)`)),n.push(J(e,`Dashboard khởi động lại và mở trong tab mới; tab này có thể đóng.`,`The dashboard restarts and opens in a new tab; this tab can be closed.`)),n}function Pt(){let{locale:e}=Ne(),{status:t,supported:n,checking:r,applying:i,error:o,check:c,apply:l}=Dt(),[u,d]=(0,Y.useState)(!1),f=(0,Y.useRef)(null),m=wt(t);if((0,Y.useEffect)(()=>{m&&!f.current?.closest(`[role=dialog]`)?.contains(document.activeElement)&&f.current?.focus()},[m]),!n)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(S,{component:`h1`,variant:`h1`,sx:{mb:3},children:J(e,`Cập nhật`,`Updates`)}),(0,X.jsx)(g,{severity:`info`,children:J(e,`Gateway này chưa hỗ trợ kiểm tra cập nhật.`,`This Gateway does not check for updates.`)})]});let h=t?.job,_=h?At(e,h):null,v=(t?.runningConversations??0)>0,y=t?[J(e,`Đang dùng ${t.pi.installed??`—`}`,`Using ${t.pi.installed??`—`}`),t.pi.required?J(e,`Piagent ${t.piagent.latest} cần ${t.pi.required}`,`Piagent ${t.piagent.latest} needs ${t.pi.required}`):null].filter(Boolean).join(` · `):`—`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(S,{component:`h1`,variant:`h1`,ref:f,tabIndex:-1,sx:{mb:1},children:J(e,`Cập nhật`,`Updates`)}),(0,X.jsx)(S,{color:`text.secondary`,sx:{mb:3},children:J(e,`Piagent và Pi được cập nhật cùng nhau: Pi luôn lên đúng bản mà Piagent mới đã kiểm chứng.`,`Piagent and Pi update together: Pi always moves to the version the new Piagent is qualified on.`)}),(0,X.jsxs)(B,{variant:`outlined`,sx:{borderRadius:1,overflow:`hidden`},children:[(0,X.jsx)(Mt,{name:`Piagent`,detail:J(e,`Đang dùng ${t?.piagent.installed??`—`}`,`Using ${t?.piagent.installed??`—`}`),chip:t?.piagent.updateAvailable?J(e,`Có bản ${t.piagent.latest}`,`${t.piagent.latest} available`):t?.piagent.latest?J(e,`Mới nhất`,`Up to date`):J(e,`Chưa rõ`,`Unknown`),tone:t?.piagent.updateAvailable?`primary`:`default`}),(0,X.jsx)(be,{}),(0,X.jsx)(Mt,{name:`Pi`,detail:y,chip:t?.pi.updateAvailable?J(e,`Lên ${t.pi.required}`,`To ${t.pi.required}`):J(e,`Đúng bản`,`Matches`),tone:t?.pi.updateAvailable?`primary`:`default`}),t?.pi.newerUntested&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(be,{}),(0,X.jsx)(F,{sx:{px:2.25,py:1.5},children:(0,X.jsx)(S,{variant:`body2`,color:`text.secondary`,children:J(e,`Pi đã có bản ${t.pi.latest}, nhưng Piagent chưa kiểm chứng bản đó (chưa tương thích). Pi sẽ được nâng khi một bản Piagent hỗ trợ nó.`,`Pi ${t.pi.latest} is out, but Piagent is not qualified on it yet (not compatible). Pi moves when a Piagent release supports it.`)})})]}),(0,X.jsx)(be,{}),(0,X.jsxs)(A,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},justifyContent:`space-between`,gap:1.5,p:2.25},children:[(0,X.jsx)(S,{variant:`body2`,color:`text.secondary`,children:J(e,`Kiểm tra lần cuối: ${jt(e,t?.checkedAt??null)} · tự kiểm tra ${(t?.checkEveryHours??1)===1?`mỗi giờ`:`mỗi ${t?.checkEveryHours} giờ`}`,`Last checked: ${jt(e,t?.checkedAt??null)} · checks every ${(t?.checkEveryHours??1)===1?`hour`:`${t?.checkEveryHours} hours`}`)}),(0,X.jsx)(a,{variant:`outlined`,disabled:r||m||!t?.installable,onClick:()=>void c(),startIcon:r?(0,X.jsx)(L,{size:14}):void 0,children:J(e,`Kiểm tra ngay`,`Check now`)})]})]}),(0,X.jsxs)(F,{sx:{mt:2.5,display:`grid`,gap:1.5},children:[t&&!t.installable&&(0,X.jsx)(g,{severity:`info`,children:t.reason===`company-runtime`?J(e,`Đây là runtime công ty; cập nhật từ dashboard Piagent.`,`This is the company runtime; update from the Piagent dashboard.`):J(e,`Piagent này chạy từ mã nguồn (git). Cập nhật bằng git pull rồi cài lại.`,`This Piagent runs from a source checkout. Update it with git pull and reinstall.`)}),m&&(0,X.jsx)(g,{severity:`info`,icon:(0,X.jsx)(L,{size:18}),children:J(e,`Đang cập nhật lên Piagent ${h?.to}… Xong, dashboard mở lại trong tab mới; tab này có thể đóng.`,`Updating to Piagent ${h?.to}… When done, the dashboard opens in a new tab; this tab can be closed.`)}),!m&&_&&(0,X.jsx)(g,{severity:_.severity,children:_.text}),!m&&h?.bindingChanged&&(0,X.jsx)(g,{severity:`warning`,children:J(e,`Bản mới đổi trình khởi chạy công ty: Agent Watch tự cập nhật cấu hình trong vài phút (cần Agent Watch đang chạy), rồi chế độ công ty dùng lại được.`,`The new release changed the company launcher: Agent Watch updates the configuration within a few minutes (it must be running), then company mode works again.`)}),o&&(0,X.jsx)(g,{severity:`error`,role:`alert`,children:kt(e,o)}),t?.installable&&t.updateAvailable&&!m&&(0,X.jsxs)(A,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},gap:1.5},children:[(0,X.jsx)(a,{variant:`contained`,size:`large`,startIcon:i?(0,X.jsx)(L,{size:16,color:`inherit`}):(0,X.jsx)(C,{}),disabled:i||v,onClick:()=>d(!0),children:J(e,`Cập nhật lên Piagent ${t.piagent.latest}`,`Update to Piagent ${t.piagent.latest}`)}),v&&(0,X.jsx)(S,{variant:`body2`,color:`text.secondary`,children:J(e,`${t.runningConversations} cuộc trò chuyện đang chạy; nút mở lại khi chúng xong.`,`${t.runningConversations} conversation(s) running; available once they finish.`)})]})]}),(0,X.jsxs)(s,{open:u&&!!t,onClose:()=>d(!1),fullWidth:!0,maxWidth:`xs`,"aria-labelledby":`piagent-update-confirm`,children:[(0,X.jsx)(M,{id:`piagent-update-confirm`,children:J(e,`Cập nhật Piagent?`,`Update Piagent?`)}),(0,X.jsx)(I,{children:(0,X.jsx)(F,{component:`ul`,sx:{m:0,pl:2.5,display:`grid`,gap:.75},children:t&&Nt(e,t).map(e=>(0,X.jsx)(S,{component:`li`,variant:`body2`,children:e},e))})}),(0,X.jsxs)(p,{children:[(0,X.jsx)(a,{onClick:()=>d(!1),children:J(e,`Để sau`,`Later`)}),(0,X.jsx)(a,{variant:`contained`,onClick:()=>{d(!1),l()},children:J(e,`Cập nhật`,`Update`)})]})]})]})}var Ft={main:0,scout:1,research:2,verify:3,review:4},It=e=>Ft[e]??5;function Lt(e){return[...e].sort((e,t)=>It(e.role)-It(t.role)||Date.parse(e.askedAt)-Date.parse(t.askedAt))}function Rt(e){return!!(e&&!e.complete&&e.activities.some(e=>e.toolLabel===`ask_user`&&e.state===`running`))}function zt(e,t){return Rt(t)?`question`:e.liveState===`waiting-approval`?`approval`:e.needsAttention&&(e.liveState===`running`||e.liveState===`idle`)?`question`:null}function Bt(e,t){let n={};for(let r of e){if(r.archived)continue;let e=t[r.sessionRef];n[r.sessionRef]={running:!!(e&&!e.complete),need:zt(r,e),operationRef:e?.operationRef??null}}return n}function Vt(e,t,n,r){let i=[];for(let a of n){let n=e[a.sessionRef],o=t[a.sessionRef];if(!n||!o)continue;let s=r[a.sessionRef],c=o.operationRef??n.operationRef??`turn`;if(o.need&&o.need!==n.need&&i.push({id:`${a.sessionRef}:${c}:${o.need}:${Date.now()}`,sessionRef:a.sessionRef,title:a.title,kind:o.need}),n.running&&!o.running){let e=s?.settlement===`aborted`?`stopped`:s?.error||s?.settlement===`error`||s?.settlement===`blocked`?`failed`:`done`;i.push({id:`${a.sessionRef}:${c}:${e}`,sessionRef:a.sessionRef,title:a.title,kind:e})}}return i}function Z(e){return{color:`${e}.dark`,'html[data-piagent-color-mode="dark"] &':{color:`${e}.main`}}}var Q=(e,t,n)=>e===`vi`?t:n,Ht={blocking:[`blocking`,`blocking`],major:[`major`,`major`],minor:[`minor`,`minor`]},Ut={wrong_premise:[`sai giả định`,`wrong premise`],conflicts_with_request:[`conflict với yêu cầu`,`conflicts with the request`],ambiguous:[`chưa rõ ràng`,`ambiguous`],out_of_scope:[`out of scope`,`out of scope`]},Wt={too_large:[`patch quá lớn`,`the patch is too large`],not_git:[`thư mục không phải git`,`not a git repository`],limit:[`subagent đã hết lượt gọi`,`the subagent ran out of calls`],failed:[`subagent lỗi`,`the subagent failed`]};function Gt(e,t){let n=[];return e.outcome===`interrupted`?Q(t,`Lượt bị dừng trước khi check xong`,`The turn stopped before its checks finished`):(e.outcome===`disputed`&&n.push((e.disputes??1)>1?Q(t,`${e.disputes} conflict giữa main agent và subagent, bạn quyết định`,`${e.disputes} disagreements between the main agent and a subagent; your call`):Q(t,`Main agent và subagent conflict, bạn quyết định`,`The main agent and a subagent disagree; your call`)),e.unchanged?n.join(` · `)||Q(t,`Không đổi code`,`No code changed`):(e.verified?n.push(Q(t,`Check đã pass trên code cuối`,`A check passed on the final code`)):e.verifyPolicy!==`off`&&n.push(Q(t,`Chưa có check pass trên code cuối`,`No check passed on the final code`)),e.reviewed?n.push(e.blockingOpen?Q(t,`Còn ${e.blockingOpen} lỗi blocking chưa fix`,`${e.blockingOpen} blocking issue(s) still open`):Q(t,`Review không có lỗi blocking`,`Review found no blocking issue`)):e.reviewPolicy!==`off`&&n.push(e.outcome===`review_unavailable`?Q(t,`Không chạy được review`,`The review could not run`)+(e.reviewUnavailable&&Wt[e.reviewUnavailable]?` (${Q(t,...Wt[e.reviewUnavailable])})`:``):Q(t,`Chưa review`,`Not reviewed`)),e.planSkipped&&n.push(Q(t,`Đã sửa code khi chưa có plan`,`Code was changed before a plan existed`)),e.planOpen&&n.push(Q(t,`Plan còn ${e.planOpen} bước chưa xong`,`${e.planOpen} plan step(s) not completed`)),n.join(` · `)||Q(t,`Đã đổi code`,`Code changed`)))}function Kt(e,t){let n=e.loop&&e.maxLoops?Q(t,` (vòng ${e.loop}/${e.maxLoops})`,` (round ${e.loop}/${e.maxLoops})`):``,r=et(e.role??`review`,t),i=(e.findings??e.claims??e.issues??[]).length;switch(e.phase){case`continue`:return Q(t,`Harness: checklist còn ${e.planOpen??0} bước (${e.planDone??0}/${e.planSteps??0} xong), cho main agent làm tiếp · vòng ${e.round??1}${e.idle?` (vòng trước không xong thêm bước nào)`:``}`,`Harness: the checklist has ${e.planOpen??0} open step(s) (${e.planDone??0}/${e.planSteps??0} done); sent the main agent on · round ${e.round??1}${e.idle?` (the previous round finished no step)`:``}`);case`plan`:return Q(t,`Harness: plan còn ${e.planOpen??0} bước chưa đánh dấu xong, yêu cầu agent cập nhật`,`Harness: ${e.planOpen??0} plan step(s) not marked completed; asked the agent to update the plan`);case`verify`:return Q(t,`Harness: chưa có check nào pass trên code hiện tại, yêu cầu agent chạy check${n}`,`Harness: no check has passed on the current code; asked the agent to run checks${n}`);case`review`:return Q(t,`Harness: review tìm thấy ${i} lỗi blocking, gửi lại agent để fix hoặc giải thích${n}`,`Harness: the review found ${i} blocking issue(s); sent back to the agent to fix or answer${n}`);case`objection`:return Q(t,`${r} phản biện brief của main agent`,`${r} objected to the main agent's brief`);case`answer`:return Q(t,`Harness: yêu cầu main agent nói rõ đã quyết định gì với phản biện của subagent`,`Harness: asked the main agent to say what it decided about the subagent's objection`);case`claims`:return Q(t,`Harness: ${r} đánh fail ${i} claim, gửi lại main agent`,`Harness: ${r} marked ${i} claim(s) as failed; sent back to the main agent`);case`rejudge`:return e.role===`verify`?Q(t,`Harness: ${r} check lại các claim cùng câu trả lời của main agent`,`Harness: ${r} checks the claims again with the main agent's answer`):Q(t,`Harness: main agent giải thích thay vì fix, ${r} xem xét lại lời giải thích`,`Harness: the main agent answered instead of fixing; ${r} judges the answer`);case`undo`:{let n=e.undo,r=n?.files?.length?` (${n.files.join(`, `)})`:``;return n?.result===`done`?Q(t,`Đã hoàn tác lượt trước: ${n.restored} file trả về như trước, ${n.removed} file lượt đó tạo đã xoá${r}.${n.more?` Gửi /undo lần nữa để hoàn tác lượt trước nữa.`:``} Commit trong lượt đó vẫn giữ.`,`Undid the last turn: ${n.restored} file(s) restored, ${n.removed} file(s) it created removed${r}.${n.more?` Send /undo again to undo the turn before.`:``} Commits made in that turn stay.`):n?.result===`refused`?Q(t,`Không hoàn tác: file lượt trước đã sửa lại bị đổi tiếp sau đó${r}; hoàn tác sẽ ghi đè thay đổi đó.`,`Not undone: a file the last turn changed was changed again since${r}; undoing would overwrite that change.`):n?.result===`busy`?Q(t,`Đang có một lượt chạy: chờ nó xong (hoặc dừng nó) rồi /undo.`,`A turn is running: wait for it (or stop it), then /undo.`):n?.result===`none`?Q(t,`Không có lượt nào để hoàn tác (chỉ áp dụng cho project là git repository, từ khi mở cuộc trò chuyện).`,`There is no turn to undo (git repositories only, since the conversation opened).`):Q(t,`Không đọc được trạng thái project; không hoàn tác.`,`The project's state could not be read; nothing was undone.`)}case`dispute`:return Q(t,`Main agent và ${r} vẫn conflict sau 2 lượt, bạn quyết định`,`The main agent and the ${r} still disagree after two rounds; your call`);default:return``}}function qt(e,t){return(e.findings??[]).map(e=>({tag:Q(t,...Ht[e.severity]??[e.severity,e.severity]),tone:e.severity===`blocking`?`error`:`warning`,location:e.file?`${e.file}${e.line?`:${e.line}`:``}`:null,text:e.issue})).concat((e.claims??[]).map(e=>({tag:`fail`,tone:`error`,location:null,text:e.claim}))).concat((e.issues??[]).map(e=>({tag:Q(t,...Ut[e.kind]??[e.kind,e.kind]),tone:`warning`,location:null,text:e.detail})))}var Jt={clean:`success`,disputed:`warning`,blocking_open:`error`,unverified:`warning`,unreviewed:`warning`,review_unavailable:`warning`,interrupted:`warning`,no_change:`info`};function Yt(e,t){return Gt(e,t)}var Xt=e=>e?Jt[e]:`info`,Zt=e=>{let t=Xt(e.outcome);return t===`success`&&(e.planSkipped||e.planOpen)?`warning`:t},Qt={fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,fontSize:12.5};function $t({process:e,locale:t}){let n=qt(e,t).map(e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(F,{component:`span`,sx:{fontWeight:600,...Z(e.tone)},children:[`[`,e.tag,`]`]}),e.location&&(0,X.jsxs)(F,{component:`span`,sx:Qt,children:[` `,e.location]}),e.location?` — `:` `,e.text]}));return n.length>0?(0,X.jsx)(F,{component:`ol`,sx:{m:0,pl:3.5},children:n.map((e,t)=>(0,X.jsx)(S,{component:`li`,variant:`body2`,sx:{overflowWrap:`anywhere`},children:e},t))}):null}function en({process:e,locale:t}){if(e.phase===`final`){let n=Zt(e),r=n===`success`?ye:n===`error`?ee:P;return(0,X.jsxs)(A,{direction:`row`,role:`status`,"aria-label":J(t,`Tiến trình của lượt`,`Turn process`),sx:{alignItems:`flex-start`,gap:.75},children:[(0,X.jsx)(r,{sx:{fontSize:16,mt:.2,...Z(n)}}),(0,X.jsx)(S,{variant:`body2`,sx:Z(n),children:Yt(e,t)})]})}let n=e.phase===`dispute`||e.phase===`objection`,r=e.phase===`dispute`?P:e.phase===`objection`?j:Te,i=e.phase===`dispute`?`warning`:null;return(0,X.jsxs)(A,{spacing:.5,role:n?`status`:void 0,sx:{borderLeft:2,borderColor:i?`warning.main`:`divider`,pl:1.25},children:[(0,X.jsxs)(A,{direction:`row`,sx:{alignItems:`flex-start`,gap:.75},children:[(0,X.jsx)(r,{sx:{fontSize:16,mt:.2,...i?Z(i):{color:`text.secondary`}}}),(0,X.jsx)(S,{variant:`body2`,sx:i?{fontWeight:600,...Z(i)}:n?{fontWeight:600}:{color:`text.secondary`},children:Kt(e,t)})]}),(0,X.jsx)($t,{process:e,locale:t})]})}var $=(e,t,n)=>e===`vi`?t:n;function tn(e,t){let n=e.planDeferred??0,r=e.planSteps-e.planDone-n,i=e.rounds?$(t,` Harness đã cho agent làm tiếp ${e.rounds} vòng.`,` The harness sent the agent back ${e.rounds} time(s).`):``;if(e.state===`cancelled`)return{tone:`info`,continuable:!0,title:$(t,`Bạn đã dừng lượt này`,`You stopped this turn`),text:$(t,`Task chưa xong${e.planSteps?` (${e.planDone}/${e.planSteps} bước)`:``}. Bấm Tiếp tục để agent làm tiếp từ chỗ dừng.`,`The task is not finished${e.planSteps?` (${e.planDone}/${e.planSteps} steps)`:``}. Choose Continue to pick up where it stopped.`)};if(e.state===`failed`)return{tone:`error`,continuable:!0,title:$(t,`Lượt dừng vì lỗi · ${et(e.role??`main`,t)}`,`Turn stopped by a failure · ${et(e.role??`main`,t)}`),text:$(t,`Task chưa xong${e.planSteps?`: còn ${r}/${e.planSteps} bước`:``}. Xem lỗi phía trên; khi đã xử lý, bấm Tiếp tục để chạy lại từ chỗ dừng.`,`The task is not finished${e.planSteps?`: ${r} of ${e.planSteps} steps open`:``}. See the failure above; once it is resolved, choose Continue.`)+(e.code?` [${e.code}]`:``)};if(e.state===`midway`){let n=e.reason===`idle`?$(t,`Main agent dừng 2 vòng liên tiếp mà không xong thêm bước nào: đọc câu trả lời cuối để biết vướng gì.`,`The main agent stopped 2 rounds in a row without finishing a step: its last answer says what is in the way.`):e.reason===`limit`?$(t,`Đã tới giới hạn 30 vòng tự làm tiếp cho một tin nhắn.`,`The limit of 30 automatic rounds for one message was reached.`):$(t,`Harness của team không bắt buộc plan nên không tự làm tiếp.`,`The team's Harness does not require a plan, so it does not continue on its own.`);return{tone:`warning`,continuable:!0,title:$(t,`Dừng giữa chừng · còn ${r}/${e.planSteps} bước`,`Stopped midway · ${r} of ${e.planSteps} steps open`),text:`${n}${i} ${$(t,`Bấm Tiếp tục để làm tiếp.`,`Choose Continue to go on.`)}`}}return n?{tone:`info`,continuable:!0,title:$(t,`Dừng theo yêu cầu · ${e.planDone}/${e.planSteps} bước xong, ${n} bước để sau`,`Stopped as asked · ${e.planDone} of ${e.planSteps} steps done, ${n} left for later`),text:$(t,`Các bước còn lại được để sau theo yêu cầu hoặc vì không cần nữa: câu trả lời cuối nói lý do. Bấm Tiếp tục khi muốn làm nốt.`,`The other steps were left for later as asked, or are no longer needed: the last answer says why. Choose Continue to do them.`)+i}:{tone:`success`,continuable:!1,title:e.planSteps?$(t,`Hoàn thành · ${e.planSteps}/${e.planSteps} bước`,`Done · ${e.planSteps}/${e.planSteps} steps`):$(t,`Xong lượt`,`Turn finished`),text:(e.planSteps?$(t,`Mọi bước trong checklist đã xong.`,`Every checklist step is completed.`):$(t,`Main agent đã trả lời xong; lượt này không có checklist.`,`The main agent finished its answer; this turn had no checklist.`))+i}}function nn(e,t){return e.state===`done`&&e.planDeferred?$(t,`Xong ${e.planDone}/${e.planSteps}, để sau ${e.planDeferred}`,`Done ${e.planDone}/${e.planSteps}, ${e.planDeferred} later`):e.state===`midway`?$(t,`Dừng giữa chừng ${e.planDone}/${e.planSteps}`,`Stopped ${e.planDone}/${e.planSteps}`):e.state===`failed`?$(t,`Lỗi, chưa xong`,`Failed`):e.state===`cancelled`?$(t,`Đã dừng`,`Stopped`):e.planSteps?$(t,`Xong ${e.planSteps}/${e.planSteps}`,`Done ${e.planSteps}/${e.planSteps}`):$(t,`Xong`,`Done`)}function rn({end:e,locale:t,onContinue:r}){let i=tn(e,t),o=r&&i.continuable?(0,X.jsx)(a,{color:`inherit`,size:`small`,onClick:r,children:J(t,`Tiếp tục`,`Continue`)}):void 0;return(0,X.jsxs)(g,{severity:i.tone,variant:`outlined`,role:`status`,"aria-label":J(t,`Kết quả của lượt`,`How the turn ended`),action:o,sx:{alignSelf:`stretch`},children:[(0,X.jsx)(n,{sx:{fontSize:`inherit`,fontWeight:650,mb:.25},children:i.title}),i.text]})}var an={done:`success`,midway:`warning`,failed:`error`,cancelled:`info`},on=e=>e.state===`done`&&e.planDeferred?`info`:an[e.state];function sn(e,t){return nn(e,t)}function cn(e){return(0,X.jsx)(y,{viewBox:`0 0 16 16`,...e,children:(0,X.jsx)(`path`,{d:`M5 3.25a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Zm0 2.122a2.25 2.25 0 1 0-1.5 0v5.256a2.25 2.25 0 1 0 1.5 0V9.5h3.25a2.75 2.75 0 0 0 2.75-2.75v-1.378a2.25 2.25 0 1 0-1.5 0V6.75c0 .69-.56 1.25-1.25 1.25H5V5.372ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm7.5-9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z`})})}function ln(e,t){return e.detached?J(t,`Git không ở nhánh nào (detached HEAD tại ${e.name})`,`Git is not on a branch (detached HEAD at ${e.name})`):J(t,`Nhánh Git của project: ${e.name}`,`The project's Git branch: ${e.name}`)}function un({branch:e,locale:t,maxWidth:n=220,tooltip:r=!0}){if(!e)return null;let i=(0,X.jsxs)(F,{component:`span`,"aria-label":r?ln(e,t):void 0,sx:{display:`inline-flex`,alignItems:`center`,gap:.4,minWidth:0,maxWidth:n,verticalAlign:`bottom`,color:e.detached?`warning.main`:`inherit`},children:[(0,X.jsx)(cn,{sx:{fontSize:`1.1em`,flexShrink:0}}),(0,X.jsx)(F,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:`.95em`},children:e.name})]});return r?(0,X.jsx)(G,{describeChild:!0,title:ln(e,t),children:i}):i}var dn={"branch-switch-blocked-running":[`Có cuộc trò chuyện đang chạy trong folder này. Chờ chạy xong hoặc Dừng rồi chuyển nhánh.`,`A conversation is running in this folder. Wait for it to finish, or stop it, then switch.`],"branch-switch-local-changes":[`Git không chuyển được: thay đổi chưa commit sẽ bị ghi đè. Commit hoặc stash trước.`,`Git refused: uncommitted changes would be overwritten. Commit or stash them first.`],"branch-switch-unfinished-merge":[`Repo đang dở merge hoặc rebase. Xử lý xong rồi chuyển nhánh.`,`The repository is in the middle of a merge or rebase. Finish it first.`],"branch-exists":[`Đã có nhánh tên này.`,`A branch with this name already exists.`],"branch-name-invalid":[`Tên nhánh không hợp lệ với Git.`,`Git does not accept this branch name.`],"branch-not-found":[`Không còn nhánh này.`,`This branch no longer exists.`],"not-a-git-repository":[`Folder này không phải repo Git.`,`This folder is not a Git repository.`],"branch-switch-timeout":[`Git chạy quá lâu nên đã dừng.`,`Git took too long and was stopped.`]};function fn({projectRef:e,projectLabel:n,branch:r,repositories:i,locale:a,onSwitched:o,maxWidth:s=220}){let[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(null),[h,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(``),[b,x]=(0,Y.useState)(null),[ee,C]=(0,Y.useState)(null),w=(0,Y.useRef)(null),E=(0,Y.useRef)(null),[D,O]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{O(null)},[r?.name,r?.detached,e]);let k=D??r,A=!!c,j=()=>{w.current?.abort();let t=new AbortController;w.current=t,_(!1),Ve(e,u,t.signal).then(e=>{t.signal.aborted||p(e)},()=>{t.signal.aborted||_(!0)})};(0,Y.useEffect)(()=>(A&&j(),()=>w.current?.abort()),[A,e,u]);let M=()=>{b||(w.current?.abort(),l(null),y(``),C(null),p(null),_(!1),d(null))},P=e=>{w.current?.abort(),p(null),y(``),C(null),d(e)},I=async t=>{x(t.branch),C(null);try{let n=await We(e,u===null?t:{...t,repository:u});n.head&&u===null&&O(n.head),o?.(),l(null),y(``),p(null),d(null)}catch(e){C(e instanceof Ge?{code:e.code,detail:e.detail}:{code:`branch-switch-failed`,detail:null}),j()}finally{x(null)}},R=f?.repository?f:null;(0,Y.useEffect)(()=>{A&&R&&requestAnimationFrame(()=>E.current?.focus())},[A,R]);let z=v.trim(),B=(0,Y.useMemo)(()=>(R?.branches??[]).filter(e=>!z||e.name.toLowerCase().includes(z.toLowerCase())),[R,z]),V=B.filter(e=>!e.remote),H=B.filter(e=>e.remote),re=(R?.branches??[]).some(e=>e.name===z),U=(f?.running??0)>0,ae=e=>(0,X.jsxs)(K,{dense:!0,disabled:!e.current&&(U||!!b),selected:e.current,"aria-current":e.current||void 0,onClick:()=>e.current?M():void I({branch:e.name,remote:e.remote}),sx:{borderRadius:1,py:.4},children:[(0,X.jsx)(de,{sx:{minWidth:26},children:b===e.name?(0,X.jsx)(L,{size:14}):e.current?(0,X.jsx)(fe,{sx:{fontSize:16}}):e.remote?(0,X.jsx)(t,{sx:{fontSize:15,color:`text.disabled`}}):null}),(0,X.jsx)(q,{primary:e.name,secondary:[e.remote,e.committedAt?_n(e.committedAt,a):null].filter(Boolean).join(` · `)||void 0,slotProps:{primary:{noWrap:!0,sx:{fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:12.5}},secondary:{noWrap:!0,sx:{fontSize:11}}}})]},`${e.remote??``}/${e.name}`),oe=f&&!f.repository?f.repositories??[]:[],se=!k&&!!i?.length;if(!k&&!se)return null;let ce={minWidth:0,maxWidth:s,borderRadius:.75,px:.4,mx:-.4,font:`inherit`,color:`inherit`,justifyContent:`flex-start`,"&:hover":{bgcolor:`action.hover`,color:`text.primary`},"&.Mui-focusVisible":{outline:`2px solid`,outlineColor:`primary.main`}},le=e=>{e.stopPropagation(),l(e.currentTarget)};return(0,X.jsxs)(X.Fragment,{children:[k?(0,X.jsx)(G,{describeChild:!0,title:`${ln(k,a)} · ${J(a,`bấm để đổi nhánh`,`click to switch`)}`,children:(0,X.jsx)(m,{onClick:le,"aria-haspopup":`dialog`,"aria-expanded":A,"aria-label":k.detached?J(a,`Đổi nhánh Git của ${n} (detached HEAD tại ${k.name})`,`Switch ${n}'s Git branch (detached HEAD at ${k.name})`):J(a,`Đổi nhánh Git của ${n} (đang ở ${k.name})`,`Switch ${n}'s Git branch (on ${k.name})`),sx:ce,children:(0,X.jsx)(un,{branch:k,locale:a,maxWidth:`100%`,tooltip:!1})})}):(0,X.jsx)(G,{describeChild:!0,title:i.map(e=>`${e.name} · ${e.branch?.name??`?`}`).join(`
2
- `),children:(0,X.jsx)(m,{onClick:le,"aria-haspopup":`dialog`,"aria-expanded":A,"aria-label":J(a,`${i.length} repo Git trong ${n}`,`${i.length} Git repositories in ${n}`),sx:ce,children:(0,X.jsxs)(F,{component:`span`,sx:{display:`inline-flex`,alignItems:`center`,gap:.4,whiteSpace:`nowrap`},children:[(0,X.jsx)(cn,{sx:{fontSize:`1.1em`}}),J(a,`${i.length} repo`,`${i.length} repos`)]})})}),(0,X.jsxs)(ie,{open:A,anchorEl:c,onClose:M,anchorOrigin:{vertical:`bottom`,horizontal:`left`},slotProps:{paper:{role:`dialog`,"aria-label":J(a,`Nhánh Git`,`Git branches`),sx:{width:`min(360px, calc(100vw - 32px))`,maxHeight:`min(520px, 70vh)`,display:`flex`,flexDirection:`column`,p:1.25,gap:1}}},children:[(0,X.jsxs)(F,{sx:{display:`flex`,alignItems:`center`,gap:.5,minWidth:0},children:[u!==null&&(0,X.jsx)(N,{size:`small`,"aria-label":J(a,`Về danh sách repo`,`Back to the repositories`),onClick:()=>P(null),children:(0,X.jsx)(Me,{sx:{fontSize:18}})}),(0,X.jsxs)(F,{sx:{minWidth:0},children:[(0,X.jsx)(S,{variant:`subtitle2`,sx:{fontWeight:650},children:se&&u===null?J(a,`Repo Git`,`Git repositories`):J(a,`Nhánh Git`,`Git branches`)}),(0,X.jsx)(S,{variant:`caption`,color:`text.secondary`,noWrap:!0,component:`div`,children:u===null?n:`${n} / ${u}`})]})]}),U&&(0,X.jsx)(g,{severity:`warning`,sx:{py:0,fontSize:12.5},children:J(a,`${f.running} cuộc trò chuyện đang chạy trong folder này. Chờ chạy xong hoặc Dừng rồi mới chuyển nhánh.`,`${f.running} conversation(s) running in this folder. Wait for them to finish, or stop them, before switching.`)}),R&&R.changedFiles>0&&!U&&(0,X.jsx)(S,{variant:`caption`,color:`text.secondary`,children:J(a,`${R.changedFiles} file đang sửa dở sẽ đi theo sang nhánh mới; Git từ chối nếu chúng bị ghi đè.`,`${R.changedFiles} changed file(s) come along to the new branch; Git refuses if they would be overwritten.`)}),ee&&(0,X.jsxs)(g,{severity:`error`,sx:{py:0,fontSize:12.5},children:[J(a,...dn[ee.code]??[`Không chuyển được nhánh.`,`The branch could not be switched.`]),ee.detail&&(0,X.jsx)(F,{component:`pre`,sx:{m:0,mt:.5,whiteSpace:`pre-wrap`,font:`11px ui-monospace, monospace`,opacity:.85},children:ee.detail})]}),!(f&&!f.repository)&&(0,X.jsx)(ne,{inputRef:E,size:`small`,value:v,onChange:e=>y(e.target.value),disabled:!R||!!b,placeholder:J(a,`Tìm hoặc đặt tên nhánh mới`,`Find a branch or name a new one`),slotProps:{htmlInput:{maxLength:200,"aria-label":J(a,`Tìm nhánh`,`Find a branch`)}},onKeyDown:e=>{if(e.key===`Enter`&&z&&!U&&!b){let e=R?.branches.find(e=>e.name===z);I(e?{branch:e.name,remote:e.remote}:{branch:z,create:!0})}}}),(0,X.jsxs)(F,{sx:{overflowY:`auto`,minHeight:0,mx:-.5},children:[!f&&!h&&(0,X.jsx)(F,{sx:{display:`flex`,justifyContent:`center`,py:2},children:(0,X.jsx)(L,{size:18})}),h&&(0,X.jsx)(g,{severity:`error`,sx:{py:0,fontSize:12.5},children:J(a,`Không đọc được danh sách nhánh.`,`The branches could not be read.`)}),f&&!f.repository&&oe.length>0&&(0,X.jsx)(Oe,{dense:!0,disablePadding:!0,"aria-label":J(a,`Repo trong folder`,`Repositories in the folder`),children:oe.map(e=>(0,X.jsxs)(K,{dense:!0,onClick:()=>P(e.name),sx:{borderRadius:1,py:.4},children:[(0,X.jsx)(q,{primary:e.name,secondary:(0,X.jsxs)(F,{component:`span`,sx:{display:`flex`,alignItems:`center`,gap:.5,minWidth:0,width:`100%`},children:[e.head?(0,X.jsx)(un,{branch:e.head,locale:a,maxWidth:`100%`,tooltip:!1}):J(a,`chưa có commit`,`no commits`),e.changedFiles>0&&(0,X.jsxs)(F,{component:`span`,sx:{flexShrink:0},children:[`· `,J(a,`${e.changedFiles} file đang sửa`,`${e.changedFiles} changed`)]})]}),slotProps:{primary:{noWrap:!0,sx:{fontSize:13,fontWeight:600}},secondary:{component:`div`,sx:{fontSize:11.5,minWidth:0}}},sx:{minWidth:0}}),(0,X.jsx)(te,{sx:{fontSize:18,color:`text.disabled`}})]},e.name))}),f&&!f.repository&&oe.length===0&&(0,X.jsx)(S,{variant:`body2`,color:`text.secondary`,sx:{px:1},children:J(a,...dn[`not-a-git-repository`])}),R&&(0,X.jsxs)(Oe,{dense:!0,disablePadding:!0,children:[z&&!re&&(0,X.jsxs)(K,{dense:!0,disabled:U||!!b,onClick:()=>void I({branch:z,create:!0}),sx:{borderRadius:1},children:[(0,X.jsx)(de,{sx:{minWidth:26},children:b===z?(0,X.jsx)(L,{size:14}):(0,X.jsx)(pe,{sx:{fontSize:16}})}),(0,X.jsx)(q,{primary:J(a,`Tạo nhánh mới “${z}”`,`Create branch “${z}”`),secondary:J(a,`từ ${R.head?.name??`HEAD`}`,`from ${R.head?.name??`HEAD`}`),slotProps:{primary:{noWrap:!0,sx:{fontSize:12.5}},secondary:{sx:{fontSize:11}}}})]}),V.map(ae),H.length>0&&(0,X.jsx)(T,{disableSticky:!0,sx:{lineHeight:`26px`,fontSize:11,bgcolor:`transparent`},children:J(a,`Trên remote`,`On a remote`)}),H.map(ae),B.length===0&&!z&&(0,X.jsx)(S,{variant:`body2`,color:`text.secondary`,sx:{px:1},children:J(a,`Chưa có nhánh nào.`,`No branches yet.`)}),R.truncated&&(0,X.jsx)(S,{variant:`caption`,color:`text.disabled`,sx:{px:1},children:J(a,`Chỉ hiện 200 nhánh có commit mới nhất.`,`Showing the 200 most recently committed branches.`)})]})]})]})]})}var pn=()=>typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)?`⌘`:`Ctrl`,mn={height:28,px:1,gap:.75,fontSize:12,color:`text.secondary`,alignItems:`center`},hn={...mn,borderRadius:0,"&:hover":{bgcolor:`action.hover`,color:`text.primary`},"&.Mui-focusVisible":{outline:`2px solid`,outlineColor:`primary.main`,outlineOffset:-2}};function gn({locale:e,connection:t,running:n,session:i,onBranchSwitched:a,onUpdates:o,onPalette:s}){let{status:c,supported:l}=Dt(),u=r(e=>e.breakpoints.up(`md`)),d=wt(c),f=!!(c?.updateAvailable&&c.installable),p=c?.piagent.installed?`Piagent ${c.piagent.installed}${c.pi.installed?` · Pi ${c.pi.installed}`:``}`:`Piagent`;return u?(0,X.jsxs)(F,{component:`footer`,"aria-label":J(e,`Thanh trạng thái`,`Status bar`),sx:{position:`fixed`,left:0,right:0,bottom:0,height:28,display:`flex`,alignItems:`stretch`,borderTop:1,borderColor:`divider`,bgcolor:`background.paper`,zIndex:e=>e.zIndex.drawer+1,whiteSpace:`nowrap`},children:[(0,X.jsxs)(A,{direction:`row`,sx:mn,children:[(0,X.jsx)(F,{sx:{width:7,height:7,borderRadius:`50%`,bgcolor:t===`connected`?`success.main`:`warning.main`}}),(0,X.jsx)(`span`,{children:t===`connected`?`Gateway live`:t}),(0,X.jsx)(F,{component:`span`,sx:{color:`text.disabled`},children:`local`})]}),(i?.gitBranch||!!i?.gitRepositories?.length)&&(0,X.jsx)(A,{direction:`row`,sx:{...mn,minWidth:0},children:(0,X.jsx)(fn,{projectRef:i.projectRef,projectLabel:i.projectLabel,branch:i.gitBranch,repositories:i.gitRepositories,locale:e,maxWidth:320,onSwitched:a})}),n>0&&(0,X.jsxs)(A,{direction:`row`,sx:mn,children:[(0,X.jsx)(F,{sx:{width:7,height:7,borderRadius:`50%`,bgcolor:`primary.main`}}),(0,X.jsx)(`span`,{children:J(e,`${n} đang chạy`,`${n} running`)})]}),(0,X.jsx)(F,{sx:{flex:1}}),l&&(0,X.jsx)(G,{describeChild:!0,title:f?J(e,`Mở Cập nhật trong Cài đặt`,`Open Updates in Settings`):J(e,`Phiên bản và cập nhật`,`Version and updates`),children:(0,X.jsx)(m,{onClick:o,sx:{...hn,...f&&{color:`primary.contrastText`,bgcolor:`primary.main`,fontWeight:650,"&:hover":{bgcolor:`primary.dark`,color:`primary.contrastText`}}},children:d?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{size:11,thickness:6,color:`inherit`}),J(e,`Đang cập nhật lên ${c?.job?.to}…`,`Updating to ${c?.job?.to}…`)]}):f?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(C,{sx:{fontSize:15}}),J(e,`Cập nhật Piagent ${c?.piagent.latest}`,`Update Piagent ${c?.piagent.latest}`)]}):(0,X.jsx)(`span`,{children:p})})}),(0,X.jsxs)(m,{onClick:s,"aria-label":J(e,`Mở bảng lệnh`,`Open command palette`),sx:hn,children:[(0,X.jsxs)(F,{component:`kbd`,sx:{font:`inherit`,fontSize:11,px:.6,border:1,borderColor:`divider`,borderRadius:.75},children:[pn(),` K`]}),(0,X.jsx)(`span`,{children:J(e,`Lệnh`,`Commands`)})]})]}):null}function _n(e,t){let n=Math.max(0,Math.floor((Date.now()-Date.parse(e))/1e3));if(n<60)return J(t,`Vừa mới`,`Just now`);let r=Math.floor(n/60);if(r<60)return J(t,`${r} phút`,`${r}m`);let i=Math.floor(r/60);if(i<24)return J(t,`${i} giờ`,`${i}h`);let a=Math.floor(i/24);return J(t,`${a} ngày`,`${a}d`)}function vn(e,t){return zt(e,t)?`attention`:t&&!t.complete?`running`:e.state===`terminal-owned`?`elsewhere`:e.state===`recovery-required`?`recovery`:e.needsAttention?`attention`:t?.complete&&t.error?`failed`:e.liveState===`running`?`running`:`idle`}function yn({activity:e,locale:t,fresh:n=!1,question:r=!1,calm:i=!1}){let a={running:`primary.main`,elsewhere:`info.main`,attention:`warning.main`,recovery:`error.main`,failed:`error.main`,idle:n?`success.main`:`transparent`}[e],o={running:J(t,`Đang chạy`,`Running`),elsewhere:J(t,`Đang chạy ở Terminal hoặc tiến trình khác`,`Running in Terminal or another process`),attention:r?J(t,`Cần bạn trả lời`,`Needs your answer`):J(t,`Cần duyệt`,`Needs approval`),recovery:J(t,`Cần khôi phục`,`Needs recovery`),failed:J(t,`Lượt cuối lỗi`,`Last turn failed`),idle:n?J(t,`Xong, chưa xem`,`Done, not seen`):``}[e];return(0,X.jsx)(F,{role:e===`idle`&&!n?void 0:`img`,"aria-label":o||void 0,title:o,sx:{width:8,height:8,mt:.9,ml:.75,flexShrink:0,borderRadius:`50%`,bgcolor:a,animation:!i&&(e===`running`||e===`elsewhere`||e===`attention`)?`piagent-pulse 1.4s ease-in-out infinite`:`none`}})}var bn={clean:[`Đủ bước`,`All steps`],unverified:[`Chưa verify`,`Unverified`],unreviewed:[`Chưa review`,`Not reviewed`],blocking_open:[`Còn lỗi blocking`,`Blocking open`],review_unavailable:[`Không review được`,`Review unavailable`],interrupted:[`Bị dừng`,`Stopped`],disputed:[`Cần bạn quyết`,`Needs your call`]};function xn({session:e,live:t,selected:n,locale:r,onSelect:i,onAction:a,showProject:o=!1,fresh:s=!1}){let[c,l]=(0,Y.useState)(null),u=e=>{l(null),a(e)},d=e.modelLabel===`agent-watch-auto`,f=vn(e,t),p=f===`running`?J(r,`Đang chạy`,`Running`):f===`elsewhere`?J(r,`Đang chạy ở nơi khác`,`Running elsewhere`):f===`attention`?zt(e,t)===`question`?J(r,`Cần bạn trả lời`,`Needs your answer`):J(r,`Cần duyệt`,`Needs approval`):s?f===`failed`?J(r,`Lỗi · chưa xem`,`Failed · not seen`):J(r,`Xong · chưa xem`,`Done · not seen`):null,m=d&&!s&&f!==`running`&&f!==`elsewhere`?e.managedTurnEnd??null:null,h=!m&&d&&e.managedProcess&&e.managedProcess.outcome!==`no_change`?e.managedProcess.outcome:null;return(0,X.jsxs)(F,{sx:{display:`flex`,alignItems:`center`,pr:.5,"@media (hover: hover)":{"& .session-item-menu":{opacity:c||n?1:0,transition:`opacity .12s`},"&:hover .session-item-menu, & .session-item-menu:focus-visible":{opacity:1}}},className:f===`attention`?`session-item attention`:s?`session-item fresh`:`session-item`,children:[(0,X.jsxs)(K,{selected:n,onClick:i,sx:{minWidth:0,alignItems:`flex-start`,py:.7,px:1.25},children:[(0,X.jsx)(q,{primary:(0,X.jsxs)(X.Fragment,{children:[e.pinned&&(0,X.jsx)(re,{sx:{fontSize:13,mr:.5,verticalAlign:`-2px`,color:`text.disabled`}}),e.title]}),secondary:(0,X.jsxs)(X.Fragment,{children:[d&&(0,X.jsxs)(F,{component:`span`,sx:{fontWeight:650,color:`primary.main`},children:[J(r,`Công ty`,`Company`),(0,X.jsx)(`span`,{children:` · `})]}),p??_n(e.updatedAt,r),o&&(0,X.jsxs)(`span`,{children:[` · `,e.projectLabel]}),m&&(0,X.jsxs)(F,{component:`span`,sx:Z(on(m)),children:[` · `,sn(m,r)]}),h&&(0,X.jsxs)(F,{component:`span`,sx:Z(Xt(h)),children:[` · `,J(r,...bn[h])]})]}),slotProps:{primary:{noWrap:!0,sx:{fontSize:13.25,fontWeight:n?600:500}},secondary:{noWrap:!0,sx:{mt:.25,fontSize:11.25,...f===`attention`?{color:`warning.main`,fontWeight:650}:s?{color:f===`failed`?`error.main`:`success.main`,fontWeight:650}:{}}}}}),(0,X.jsx)(yn,{activity:f,locale:r,fresh:s,calm:n,question:zt(e,t)===`question`})]}),(0,X.jsx)(N,{size:`small`,className:`session-item-menu`,"aria-label":J(r,`Tùy chọn cuộc trò chuyện`,`Chat options`),onClick:e=>l(e.currentTarget),children:(0,X.jsx)(De,{fontSize:`small`})}),(0,X.jsxs)(je,{anchorEl:c,open:!!c,onClose:()=>l(null),onClick:e=>e.stopPropagation(),children:[!e.archived&&(0,X.jsx)(ge,{onClick:()=>u(`rename`),children:J(r,`Đổi tên`,`Rename`)}),!e.archived&&(0,X.jsx)(ge,{onClick:()=>u(`pin`),children:e.pinned?J(r,`Bỏ ghim`,`Unpin`):J(r,`Ghim`,`Pin`)}),!e.archived&&(0,X.jsx)(ge,{onClick:()=>u(`fork`),children:J(r,`Tạo nhánh`,`Fork`)}),(0,X.jsx)(ge,{onClick:()=>u(e.archived?`unarchive`:`archive`),children:e.archived?J(r,`Bỏ lưu trữ`,`Unarchive`):J(r,`Lưu trữ`,`Archive`)})]})]})}var Sn=5,Cn=`piagent.sidebar.collapsed`;function wn(e){try{let t=JSON.parse(window.localStorage.getItem(e)??`[]`);return new Set(Array.isArray(t)?t.filter(e=>typeof e==`string`).slice(0,500):[])}catch{return new Set}}function Tn(e,t){try{window.localStorage.setItem(e,JSON.stringify([...t].slice(0,500)))}catch{}}var En=new Set,Dn={attention:0,recovery:1,failed:2,idle:3,running:4,elsewhere:5};function On({locale:e,canCreate:t,query:n,onQuery:i,groups:s,count:l,selectedRef:u,showArchived:d,archivedCount:f,settingsOpen:p,connection:h,live:g,unseen:_=En,onNew:v,onSelect:y,onAction:b,onToggleArchived:ee,onSettings:C,updateDot:w=!1}){let T=r(e=>e.breakpoints.down(`md`)),[E,D]=(0,Y.useState)(`all`),[j,M]=(0,Y.useState)(()=>wn(Cn)),[N,P]=(0,Y.useState)(()=>new Set),I=n.trim().length>0,L=e=>e.modelLabel===`agent-watch-auto`,R=s.flatMap(e=>e.sessions),z={company:R.filter(L).length,personal:R.filter(e=>!L(e)).length},B=(0,Y.useMemo)(()=>s.map(e=>({...e,sessions:e.sessions.filter(e=>E===`all`||E===`company`===L(e))})).filter(e=>e.sessions.length>0),[s,E]),V=B.reduce((e,t)=>e+t.sessions.length,0),te=d?[]:B.flatMap(e=>e.sessions).filter(e=>vn(e,g[e.sessionRef])!==`idle`||_.has(e.sessionRef)).sort((e,t)=>Dn[vn(e,g[e.sessionRef])]-Dn[vn(t,g[t.sessionRef])]),H=(e,t,n)=>e(e=>{let r=new Set(e);return r.has(t)?r.delete(t):r.add(t),n&&Tn(Cn,r),r});return(0,X.jsxs)(F,{sx:{height:`100%`,display:`flex`,flexDirection:`column`,bgcolor:`background.paper`},children:[(0,X.jsxs)(W,{sx:{minHeight:`52px !important`,px:`16px !important`,gap:1.1},children:[(0,X.jsx)(qe,{size:28}),(0,X.jsxs)(F,{sx:{minWidth:0},children:[(0,X.jsx)(S,{sx:{fontWeight:650,fontSize:14.5,letterSpacing:`-0.01em`,lineHeight:1.2},children:`Piagent`}),(0,X.jsx)(S,{variant:`caption`,color:`text.disabled`,sx:{lineHeight:1.2},children:J(e,`Coding agent`,`Coding agent`)})]})]}),(0,X.jsxs)(F,{sx:{px:1.25},children:[(0,X.jsx)(G,{title:t?J(e,`Tạo cuộc trò chuyện mới`,`Create a new chat`):J(e,`Gateway hiện chưa cho phép tạo cuộc trò chuyện`,`The Gateway cannot create chats right now`),children:(0,X.jsx)(`span`,{children:(0,X.jsxs)(a,{fullWidth:!0,disabled:!t,variant:`outlined`,onClick:v,startIcon:(0,X.jsx)(pe,{}),sx:{justifyContent:`flex-start`,minHeight:36,color:`text.primary`},children:[J(e,`Cuộc trò chuyện mới`,`New chat`),(0,X.jsxs)(F,{component:`kbd`,"aria-hidden":`true`,sx:{ml:`auto`,font:`inherit`,fontSize:11,color:`text.disabled`,letterSpacing:`.04em`},children:[pn(),`⇧O`]})]})})}),(0,X.jsx)(ne,{value:n,onChange:e=>i(e.target.value),fullWidth:!0,size:`small`,placeholder:J(e,`Tìm cuộc trò chuyện`,`Search chats`),sx:{mt:1,"& .MuiInputBase-root":{height:34,fontSize:13.5}},slotProps:{input:{startAdornment:(0,X.jsx)(Ce,{position:`start`,children:(0,X.jsx)(c,{sx:{fontSize:17,color:`text.disabled`}})})}}})]}),(0,X.jsxs)(A,{direction:`row`,sx:{alignItems:`center`,justifyContent:`space-between`,px:2,pt:2,pb:.4},children:[(0,X.jsx)(S,{variant:`caption`,color:`text.disabled`,sx:{fontWeight:600,textTransform:`uppercase`,letterSpacing:`.08em`},children:d?J(e,`Đã lưu trữ`,`Archived`):J(e,`Cuộc trò chuyện`,`Chats`)}),(0,X.jsx)(S,{variant:`caption`,color:`text.disabled`,children:V})]}),z.company>0&&z.personal>0&&(0,X.jsx)(A,{direction:`row`,role:`group`,"aria-label":J(e,`Lọc theo loại`,`Filter by kind`),sx:{px:1.75,pb:.5,gap:.5,flexWrap:`wrap`},children:[`all`,`company`,`personal`].map(t=>(0,X.jsx)(Ee,{size:`small`,clickable:!0,"aria-pressed":E===t,onClick:()=>D(t),color:E===t?`primary`:`default`,variant:E===t?`filled`:`outlined`,label:t===`all`?J(e,`Tất cả`,`All`):t===`company`?J(e,`Công ty · ${z.company}`,`Company · ${z.company}`):J(e,`Cá nhân · ${z.personal}`,`Personal · ${z.personal}`)},t))}),(0,X.jsxs)(Oe,{component:`div`,sx:{flex:1,minHeight:0,overflowY:`auto`,py:.25},children:[te.length>0&&(0,X.jsxs)(F,{component:`section`,"aria-label":J(e,`Đang chạy hoặc cần chú ý`,`Running or needing attention`),sx:{mt:.5},children:[(0,X.jsx)(S,{component:`div`,variant:`caption`,color:`text.secondary`,sx:{px:2,py:.55,fontWeight:600},children:J(e,`Đang chạy · cần chú ý`,`Running · needs attention`)}),te.map(t=>(0,X.jsx)(xn,{session:t,live:g[t.sessionRef],showProject:!0,fresh:_.has(t.sessionRef),selected:u===t.sessionRef,locale:e,onSelect:()=>y(t.sessionRef),onAction:e=>b(t,e)},t.sessionRef)),(0,X.jsx)(be,{sx:{mx:2,mt:.75}})]}),B.map(t=>{let n=t.sessions.some(e=>e.sessionRef===u),r=I||n||!j.has(t.projectRef),i=I||N.has(t.projectRef),o=i?t.sessions:t.sessions.filter((e,t)=>t<Sn||e.sessionRef===u);return(0,X.jsxs)(F,{component:`section`,"aria-label":t.label,sx:{mt:.5},children:[(0,X.jsxs)(m,{onClick:()=>H(M,t.projectRef,!0),"aria-expanded":r,sx:{width:`100%`,justifyContent:`flex-start`,gap:.7,px:2,py:.55,borderRadius:1},children:[(0,X.jsx)(O,{sx:{fontSize:16,color:`text.disabled`,transform:r?`none`:`rotate(-90deg)`,transition:`transform .15s`}}),(0,X.jsx)(x,{sx:{fontSize:15,color:`text.disabled`}}),(0,X.jsx)(S,{component:`div`,variant:`caption`,color:`text.secondary`,noWrap:!0,sx:{flexShrink:1,minWidth:0,fontWeight:600,textAlign:`left`},children:t.label}),(0,X.jsx)(S,{component:`div`,variant:`caption`,color:`text.disabled`,sx:{flex:1,minWidth:0,display:`flex`,textAlign:`left`},children:t.gitBranch?(0,X.jsx)(un,{branch:t.gitBranch,locale:e,maxWidth:`100%`}):t.gitRepositories?.length?(0,X.jsxs)(F,{component:`span`,title:t.gitRepositories.map(e=>`${e.name} · ${e.branch?.name??`?`}`).join(`
3
- `),sx:{display:`inline-flex`,alignItems:`center`,gap:.4,whiteSpace:`nowrap`},children:[(0,X.jsx)(cn,{sx:{fontSize:`1.1em`}}),J(e,`${t.gitRepositories.length} repo`,`${t.gitRepositories.length} repos`)]}):null}),(0,X.jsx)(S,{variant:`caption`,color:`text.disabled`,children:t.sessions.length})]}),r&&o.map(t=>(0,X.jsx)(xn,{session:t,live:g[t.sessionRef],fresh:_.has(t.sessionRef),selected:u===t.sessionRef,locale:e,onSelect:()=>y(t.sessionRef),onAction:e=>b(t,e)},t.sessionRef)),r&&!I&&t.sessions.length>Sn&&(0,X.jsx)(a,{size:`small`,onClick:()=>H(P,t.projectRef,!1),sx:{ml:1.5,mb:.25,fontSize:12},children:i?J(e,`Thu gọn`,`Show less`):J(e,`Xem thêm ${t.sessions.length-Sn}`,`Show ${t.sessions.length-Sn} more`)})]},t.projectRef)}),V===0&&(0,X.jsxs)(A,{sx:{alignItems:`center`,textAlign:`center`,px:3,py:5},spacing:1,children:[(0,X.jsx)(k,{color:`disabled`}),(0,X.jsx)(S,{variant:`body2`,color:`text.secondary`,children:J(e,`Không tìm thấy cuộc trò chuyện`,`No conversations found`)})]})]}),(0,X.jsxs)(F,{sx:{p:1.25},children:[(0,X.jsx)(be,{sx:{mb:1}}),(0,X.jsx)(a,{fullWidth:!0,startIcon:(0,X.jsx)(o,{}),disabled:!d&&f===0,onClick:ee,sx:{justifyContent:`flex-start`},children:d?J(e,`Quay lại cuộc trò chuyện`,`Back to chats`):J(e,`Đã lưu trữ (${f})`,`Archived (${f})`)}),(0,X.jsxs)(a,{fullWidth:!0,startIcon:(0,X.jsx)(ke,{}),onClick:C,sx:{justifyContent:`flex-start`,mt:.25},color:p?`primary`:`inherit`,children:[J(e,`Cài đặt`,`Settings`),w&&(0,X.jsx)(F,{component:`span`,role:`img`,"aria-label":J(e,`Có bản cập nhật`,`Update available`),sx:{ml:`auto`,width:8,height:8,borderRadius:`50%`,bgcolor:`primary.main`}})]}),T&&(0,X.jsxs)(A,{direction:`row`,sx:{px:1.25,pt:1,alignItems:`center`,gap:1},children:[(0,X.jsx)(F,{sx:{width:7,height:7,borderRadius:`50%`,bgcolor:h===`connected`?`success.main`:`warning.main`}}),(0,X.jsx)(S,{variant:`caption`,color:`text.secondary`,sx:{flex:1},children:h===`connected`?`Gateway live`:h}),(0,X.jsx)(S,{variant:`caption`,color:`text.disabled`,children:`local`})]})]})]})}var kn=e=>e.normalize(`NFD`).replace(/\p{M}/gu,``).replace(/đ/g,`d`).replace(/Đ/g,`D`).toLowerCase();function An(e,t){let n=kn(t).split(/\s+/).filter(Boolean),r=kn(e).split(/[^\p{L}\p{N}]+/u).filter(Boolean);return n.every(e=>r.some(t=>t.startsWith(e)))}function jn(e,t,n=40){return t.trim()?e.filter(e=>An(`${e.label} ${e.keywords??``} ${e.group}`,t)).slice(0,n):e.slice(0,n)}function Mn(e){let t=(0,Y.useRef)(e);t.current=e,(0,Y.useEffect)(()=>{let e=e=>{if(!(e.isComposing||!(e.metaKey||e.ctrlKey)||e.altKey)){if(e.shiftKey){e.key.toLowerCase()===`o`&&t.current.newChat&&(e.preventDefault(),t.current.newChat());return}e.key.toLowerCase()===`k`?(e.preventDefault(),t.current.palette()):e.key===`,`&&(e.preventDefault(),t.current.settings())}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[])}function Nn({open:e,onClose:t,commands:n,locale:r}){let[i,a]=(0,Y.useState)(``),[o,l]=(0,Y.useState)(0),u=(0,Y.useMemo)(()=>jn(n,i),[n,i]),d=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{e&&(a(``),l(0))},[e]),(0,Y.useEffect)(()=>{l(0)},[i]),(0,Y.useEffect)(()=>{d.current?.querySelector(`[data-index="${o}"]`)?.scrollIntoView({block:`nearest`})},[o]);let f=e=>{e&&(t(),setTimeout(()=>e.run(),0))},p=e=>{e.nativeEvent.isComposing||(e.key===`ArrowDown`?(e.preventDefault(),l(e=>Math.min(e+1,u.length-1))):e.key===`ArrowUp`?(e.preventDefault(),l(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),f(u[o])))},m=``;return(0,X.jsxs)(s,{open:e,onClose:t,fullWidth:!0,maxWidth:`sm`,slotProps:{paper:{"aria-label":J(r,`Bảng lệnh`,`Command palette`),sx:{alignSelf:`flex-start`,mt:{xs:2,sm:`12vh`},borderRadius:1,overflow:`hidden`}}},children:[(0,X.jsxs)(F,{sx:{display:`flex`,alignItems:`center`,gap:1,px:2,py:1.25,borderBottom:1,borderColor:`divider`},children:[(0,X.jsx)(c,{fontSize:`small`,color:`action`}),(0,X.jsx)(D,{autoFocus:!0,fullWidth:!0,value:i,onChange:e=>a(e.target.value),onKeyDown:p,placeholder:J(r,`Gõ lệnh hoặc tên cuộc trò chuyện…`,`Type a command or a conversation name…`),inputProps:{role:`combobox`,"aria-expanded":!0,"aria-controls":`piagent-palette-list`,"aria-activedescendant":u[o]?`palette-${u[o].id}`:void 0,"aria-label":J(r,`Tìm lệnh`,`Search commands`)}})]}),(0,X.jsxs)(Oe,{component:`div`,id:`piagent-palette-list`,role:`listbox`,"aria-label":J(r,`Lệnh`,`Commands`),ref:d,dense:!0,sx:{maxHeight:`min(60vh, 460px)`,overflowY:`auto`,py:.5},children:[u.map((e,t)=>{let n=e.group===m?null:e.group;return m=e.group,(0,X.jsxs)(Y.Fragment,{children:[n&&(0,X.jsx)(T,{component:`div`,"aria-hidden":!0,disableSticky:!0,sx:{lineHeight:`28px`,fontSize:11,fontWeight:650,letterSpacing:`.04em`,textTransform:`uppercase`},children:n}),(0,X.jsxs)(K,{id:`palette-${e.id}`,role:`option`,"aria-selected":t===o,"data-index":t,selected:t===o,onMouseMove:()=>l(t),onClick:()=>f(e),sx:{mx:.5,borderRadius:1,gap:2},children:[(0,X.jsx)(S,{sx:{flex:1,minWidth:0,fontSize:14},noWrap:!0,children:e.label}),e.hint&&(0,X.jsx)(S,{variant:`caption`,color:`text.secondary`,noWrap:!0,children:e.hint})]})]},e.id)}),!u.length&&(0,X.jsx)(S,{sx:{px:2.5,py:3},color:`text.secondary`,children:J(r,`Không có lệnh nào khớp.`,`No matching command.`)})]})]})}function Pn(e){let t=J(e,`Chung`,`General`),n=`Agent`,r=J(e,`Công cụ`,`Tools`),i=J(e,`Thông tin`,`Information`);return[{id:`general`,group:t,label:J(e,`Giao diện`,`Appearance`),icon:(0,X.jsx)(u,{}),keywords:`ngôn ngữ language chủ đề theme sáng tối light dark tiếng việt english`},{id:`updates`,group:t,label:J(e,`Cập nhật`,`Updates`),icon:(0,X.jsx)(C,{}),keywords:`update phiên bản version pi piagent npm nâng cấp upgrade`},{id:`shortcuts`,group:t,label:J(e,`Phím tắt`,`Shortcuts`),icon:(0,X.jsx)(he,{}),keywords:`keyboard bàn phím shortcut lệnh command palette enter`},{id:`models`,group:n,label:J(e,`Nhà cung cấp & model`,`Providers & models`),icon:(0,X.jsx)(se,{}),keywords:`model provider thinking đăng nhập login oauth tài khoản account công ty company`},{id:`controls`,group:n,label:J(e,`Điều khiển project`,`Project controls`),icon:(0,X.jsx)(le,{}),keywords:`project runtime khởi động lại restart session`},{id:`permissions`,group:n,label:J(e,`Quyền truy cập`,`Access`),icon:(0,X.jsx)(_,{}),keywords:`permission quyền sandbox đọc ghi read write network mạng`},{id:`connections`,group:r,label:J(e,`MCP & kết nối`,`MCP & connections`),icon:(0,X.jsx)(ae,{}),keywords:`mcp server tool công cụ oauth kết nối connection`},{id:`usage`,group:i,label:J(e,`Sử dụng & context`,`Usage & context`),icon:(0,X.jsx)(_e,{}),keywords:`token usage context ngữ cảnh input output`},{id:`about`,group:i,label:`Piagent`,icon:(0,X.jsx)(ue,{}),keywords:`gateway protocol runtime giới thiệu about`}]}function Fn(e,t){return t.trim()?e.filter(e=>An(`${e.label} ${e.group} ${e.keywords}`,t)):e}function In({section:e,onSection:t,onBack:n}){let{locale:r}=Ne(),{status:i}=Dt(),[a,o]=(0,Y.useState)(``),s=(0,Y.useMemo)(()=>Fn(Pn(r),a),[r,a]),l=!!(i?.updateAvailable&&i.installable),u=``;return(0,X.jsxs)(F,{component:`nav`,"aria-label":J(r,`Mục cài đặt`,`Settings sections`),sx:{borderRight:{sm:1},borderBottom:{xs:1,sm:0},borderColor:`divider`,bgcolor:`background.paper`,p:1.25,minHeight:0,overflow:`auto`,display:`flex`,flexDirection:`column`},children:[(0,X.jsxs)(A,{direction:`row`,sx:{minHeight:48,alignItems:`center`,justifyContent:`space-between`,px:1},children:[(0,X.jsx)(S,{id:`piagent-settings-title`,sx:{fontWeight:650},children:J(r,`Cài đặt`,`Settings`)}),(0,X.jsx)(N,{"aria-label":J(r,`Đóng cài đặt`,`Close settings`),onClick:n,children:(0,X.jsx)(f,{})})]}),(0,X.jsxs)(B,{variant:`outlined`,sx:{display:`flex`,alignItems:`center`,gap:.75,px:1,mx:.5,mb:1,borderRadius:1},children:[(0,X.jsx)(c,{fontSize:`small`,color:`action`}),(0,X.jsx)(D,{value:a,onChange:e=>o(e.target.value),placeholder:J(r,`Tìm cài đặt`,`Search settings`),inputProps:{"aria-label":J(r,`Tìm cài đặt`,`Search settings`)},onKeyDown:e=>{e.key===`Enter`&&s[0]&&(e.preventDefault(),t(s[0].id))},sx:{flex:1,fontSize:13,py:.5}})]}),(0,X.jsxs)(Oe,{component:`div`,disablePadding:!0,sx:{display:{xs:`flex`,sm:`block`},minWidth:{xs:`max-content`,sm:0},overflowX:`auto`,flex:1},children:[s.map(n=>{let i=n.group===u?null:n.group;return u=n.group,(0,X.jsxs)(F,{sx:{display:{xs:`contents`,sm:`block`}},children:[i&&(0,X.jsx)(T,{component:`div`,disableSticky:!0,sx:{display:{xs:`none`,sm:`block`},bgcolor:`transparent`,lineHeight:`30px`,fontSize:11,fontWeight:650,letterSpacing:`.04em`,textTransform:`uppercase`,mt:.5},children:i}),(0,X.jsxs)(K,{selected:e===n.id,onClick:()=>t(n.id),children:[(0,X.jsx)(de,{sx:{minWidth:36,color:`inherit`,"& .MuiSvgIcon-root":{fontSize:19}},children:n.icon}),(0,X.jsx)(q,{primary:n.label,slotProps:{primary:{sx:{fontSize:13,fontWeight:e===n.id?800:650}}}}),n.id===`updates`&&l&&(0,X.jsx)(F,{"aria-label":J(r,`Có bản cập nhật`,`Update available`),role:`img`,sx:{width:8,height:8,borderRadius:`50%`,bgcolor:`primary.main`,flexShrink:0}})]})]},n.id)}),!s.length&&(0,X.jsx)(S,{variant:`body2`,color:`text.secondary`,sx:{px:1.5,py:2},children:J(r,`Không có mục nào khớp.`,`No matching setting.`)})]}),i?.piagent.installed&&(0,X.jsx)(S,{variant:`caption`,color:`text.disabled`,sx:{display:{xs:`none`,sm:`block`},px:1.5,pt:1},children:`Piagent ${i.piagent.installed}${i.pi.installed?` · Pi ${i.pi.installed}`:``}`})]})}function Ln(){let{locale:e}=Ne(),t=pn(),n=[[`${t} K`,J(e,`Mở bảng lệnh: mọi thao tác và cuộc trò chuyện theo tên`,`Open the command palette: every action and conversation by name`)],[`${t} ,`,J(e,`Mở Cài đặt`,`Open Settings`)],[`Enter`,J(e,`Gửi tin nhắn`,`Send the message`)],[`Shift Enter`,J(e,`Xuống dòng trong tin nhắn`,`New line in the message`)],[`1 – 5`,J(e,`Chọn đáp án khi main agent hỏi; Enter để gửi câu trả lời`,`Pick an answer when the main agent asks; Enter sends it`)],[`Esc`,J(e,`Đóng hộp thoại hoặc bảng lệnh`,`Close a dialog or the palette`)]];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(S,{component:`h1`,variant:`h1`,sx:{mb:3},children:J(e,`Phím tắt`,`Shortcuts`)}),(0,X.jsx)(B,{variant:`outlined`,sx:{borderRadius:1,overflow:`hidden`},children:n.map(([e,t],n)=>(0,X.jsxs)(A,{direction:`row`,sx:{px:2.25,py:1.5,gap:2,alignItems:`center`,justifyContent:`space-between`,borderTop:+!!n,borderColor:`divider`},children:[(0,X.jsx)(S,{children:t}),(0,X.jsx)(F,{component:`kbd`,sx:{px:.9,py:.2,border:1,borderColor:`divider`,borderRadius:1,fontSize:12,fontFamily:`inherit`,whiteSpace:`nowrap`,bgcolor:`action.hover`},children:e})]},e))})]})}export{vt as A,$e as B,Nt as C,mt as D,Dt as E,ct as F,qe as H,st as I,at as L,ut as M,ft as N,ht as O,gt as P,it as R,kt as S,wt as T,et as V,Bt as _,Mn as a,Rt as b,gn as c,rn as d,en as f,Vt as g,Z as h,Nn as i,dt as j,_t as k,pn as l,Zt as m,Ln as n,On as o,Yt as p,Pn as r,vn as s,In as t,fn as u,Lt as v,Et as w,Pt as x,zt as y,Ye as z};