@konglx/rotom 2.21.0

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 (189) hide show
  1. package/README.md +417 -0
  2. package/bin/mesh-master.sh +439 -0
  3. package/bin/rotom +29 -0
  4. package/bin/rotom-link.sh +136 -0
  5. package/bin/rotom-send-with-status +57 -0
  6. package/bin/rotom-up.sh +428 -0
  7. package/dist/cli/ask.js +62 -0
  8. package/dist/cli/common.js +321 -0
  9. package/dist/cli/config.js +65 -0
  10. package/dist/cli/directory.js +17 -0
  11. package/dist/cli/executor.js +58 -0
  12. package/dist/cli/fed.js +91 -0
  13. package/dist/cli/group.js +273 -0
  14. package/dist/cli/identity.js +62 -0
  15. package/dist/cli/init.js +268 -0
  16. package/dist/cli/issue.js +202 -0
  17. package/dist/cli/join.js +170 -0
  18. package/dist/cli/link.js +47 -0
  19. package/dist/cli/master.js +51 -0
  20. package/dist/cli/memory.js +307 -0
  21. package/dist/cli/note.js +68 -0
  22. package/dist/cli/repo.js +77 -0
  23. package/dist/cli/rotom.js +277 -0
  24. package/dist/cli/routes.js +118 -0
  25. package/dist/cli/run.js +45 -0
  26. package/dist/cli/schedule.js +237 -0
  27. package/dist/cli/skill.js +173 -0
  28. package/dist/cli/team.js +106 -0
  29. package/dist/executor/claude-code-hook.cjs +80 -0
  30. package/dist/executor/cli-executor.js +8 -0
  31. package/dist/executor/executors/claude-code.js +780 -0
  32. package/dist/executor/executors/codex.js +719 -0
  33. package/dist/executor/executors/hermes-cli.js +855 -0
  34. package/dist/executor/executors/openclaw.js +467 -0
  35. package/dist/executor/executors/pi.js +514 -0
  36. package/dist/executor/index.js +269 -0
  37. package/dist/executor/jsonrpc-transport.js +125 -0
  38. package/dist/executor/process-runner.js +101 -0
  39. package/dist/executor/reasoning-status.js +83 -0
  40. package/dist/executor/repo-cache.js +502 -0
  41. package/dist/executor/session-store.js +188 -0
  42. package/dist/executor/worker-chat.js +257 -0
  43. package/dist/executor/worker-connection.js +89 -0
  44. package/dist/executor/worker-issue.js +264 -0
  45. package/dist/executor/worker.js +877 -0
  46. package/dist/link/pending-requests.js +72 -0
  47. package/dist/link/server.js +233 -0
  48. package/dist/link/visibility-store.js +58 -0
  49. package/dist/master/api/agents.js +333 -0
  50. package/dist/master/api/artifacts.js +271 -0
  51. package/dist/master/api/domains.js +64 -0
  52. package/dist/master/api/groups.js +635 -0
  53. package/dist/master/api/guidance-templates.js +147 -0
  54. package/dist/master/api/index.js +89 -0
  55. package/dist/master/api/issues-patrol.js +172 -0
  56. package/dist/master/api/issues.js +663 -0
  57. package/dist/master/api/links-patrol.js +168 -0
  58. package/dist/master/api/links.js +114 -0
  59. package/dist/master/api/memory.js +259 -0
  60. package/dist/master/api/messages.js +157 -0
  61. package/dist/master/api/notes.js +77 -0
  62. package/dist/master/api/schedule-patterns.js +133 -0
  63. package/dist/master/api/schedules.js +272 -0
  64. package/dist/master/api/sessions.js +158 -0
  65. package/dist/master/api/share.js +269 -0
  66. package/dist/master/api/skills.js +190 -0
  67. package/dist/master/api/teams.js +122 -0
  68. package/dist/master/api/uploads.js +245 -0
  69. package/dist/master/auth.js +134 -0
  70. package/dist/master/dashboard/animations/calico-dozing.apng +0 -0
  71. package/dist/master/dashboard/animations/calico-error.apng +0 -0
  72. package/dist/master/dashboard/animations/calico-happy.apng +0 -0
  73. package/dist/master/dashboard/animations/calico-notification.apng +0 -0
  74. package/dist/master/dashboard/animations/calico-sleeping.apng +0 -0
  75. package/dist/master/dashboard/animations/calico-thinking.apng +0 -0
  76. package/dist/master/dashboard/animations/calico-waking.apng +0 -0
  77. package/dist/master/dashboard/assets/ApprovalCard-C38VV6ko.css +1 -0
  78. package/dist/master/dashboard/assets/ApprovalCard-CHPh2dmE.js +17 -0
  79. package/dist/master/dashboard/assets/ArtifactPanel-P_2gAP7v.js +1 -0
  80. package/dist/master/dashboard/assets/ArtifactPanel-aGHySny5.css +1 -0
  81. package/dist/master/dashboard/assets/css.worker-DaIe3gwK.js +84 -0
  82. package/dist/master/dashboard/assets/editor.worker-BCzxt1at.js +12 -0
  83. package/dist/master/dashboard/assets/html.worker-CKrFyw_2.js +461 -0
  84. package/dist/master/dashboard/assets/index-CChrTn81.css +32 -0
  85. package/dist/master/dashboard/assets/index-Dhu4SN1z.js +181 -0
  86. package/dist/master/dashboard/assets/json.worker-B7c_PmGb.js +49 -0
  87. package/dist/master/dashboard/assets/markdown-CeN5IgdF.js +29 -0
  88. package/dist/master/dashboard/assets/monaco-core-DyX1CsEw.css +1 -0
  89. package/dist/master/dashboard/assets/monaco-core-oQiQUisy.js +833 -0
  90. package/dist/master/dashboard/assets/monaco-setup-CiOPQdmo.js +1 -0
  91. package/dist/master/dashboard/assets/react-vendor-C8IxlyCR.js +67 -0
  92. package/dist/master/dashboard/assets/ts.worker-BhkL8olL.js +51334 -0
  93. package/dist/master/dashboard/assets/useMonaco-ILb4vyPh.js +12 -0
  94. package/dist/master/dashboard/assets/vite-preload-CxJPbCTl.js +1 -0
  95. package/dist/master/dashboard/debug-auth.html +197 -0
  96. package/dist/master/dashboard/favicon.ico +0 -0
  97. package/dist/master/dashboard/index.html +20 -0
  98. package/dist/master/dashboard/rotom-avatar.png +0 -0
  99. package/dist/master/db/agent-sessions.js +60 -0
  100. package/dist/master/db/agent-visibility.js +64 -0
  101. package/dist/master/db/agents.js +119 -0
  102. package/dist/master/db/ask-bridges.js +157 -0
  103. package/dist/master/db/build-update.js +59 -0
  104. package/dist/master/db/core.js +82 -0
  105. package/dist/master/db/domains.js +80 -0
  106. package/dist/master/db/groups.js +316 -0
  107. package/dist/master/db/guidance-templates.js +58 -0
  108. package/dist/master/db/index.js +12 -0
  109. package/dist/master/db/internal.js +45 -0
  110. package/dist/master/db/issues-patrol.js +81 -0
  111. package/dist/master/db/issues.js +373 -0
  112. package/dist/master/db/links.js +221 -0
  113. package/dist/master/db/master-node.js +43 -0
  114. package/dist/master/db/memory.js +272 -0
  115. package/dist/master/db/messages.js +210 -0
  116. package/dist/master/db/notes.js +55 -0
  117. package/dist/master/db/schedule-patterns.js +56 -0
  118. package/dist/master/db/schedules.js +135 -0
  119. package/dist/master/db/skills.js +144 -0
  120. package/dist/master/db/team.js +88 -0
  121. package/dist/master/db/types.js +10 -0
  122. package/dist/master/db.js +12 -0
  123. package/dist/master/embedded.js +133 -0
  124. package/dist/master/federation/client.js +283 -0
  125. package/dist/master/federation/identity.js +133 -0
  126. package/dist/master/federation/manager.js +267 -0
  127. package/dist/master/federation/publisher.js +87 -0
  128. package/dist/master/federation/self-publisher.js +69 -0
  129. package/dist/master/federation/server.js +487 -0
  130. package/dist/master/group-paths.js +208 -0
  131. package/dist/master/offline-queue.js +38 -0
  132. package/dist/master/opc-bootstrap.js +245 -0
  133. package/dist/master/patrol-terminal.js +275 -0
  134. package/dist/master/repo-scan.js +188 -0
  135. package/dist/master/router.js +214 -0
  136. package/dist/master/scheduler-handlers.js +510 -0
  137. package/dist/master/scheduler.js +201 -0
  138. package/dist/master/server.js +203 -0
  139. package/dist/master/services/link-collector.js +82 -0
  140. package/dist/master/services/link-patrol-bootstrap.js +50 -0
  141. package/dist/master/services/memory-extract-prompt.js +34 -0
  142. package/dist/master/services/patrol-bootstrap.js +63 -0
  143. package/dist/master/share-tokens.js +56 -0
  144. package/dist/master/terminal-hub.js +300 -0
  145. package/dist/master/uploads.js +108 -0
  146. package/dist/master/util/fs.js +100 -0
  147. package/dist/master/util/paths.js +50 -0
  148. package/dist/master/util/persona.js +10 -0
  149. package/dist/master/ws-hub/connection.js +928 -0
  150. package/dist/master/ws-hub/conversation.js +290 -0
  151. package/dist/master/ws-hub/directory.js +70 -0
  152. package/dist/master/ws-hub/dispatch-enrich.js +34 -0
  153. package/dist/master/ws-hub/hub.js +136 -0
  154. package/dist/master/ws-hub/index.js +9 -0
  155. package/dist/master/ws-hub/internal.js +35 -0
  156. package/dist/master/ws-hub/routing.js +295 -0
  157. package/dist/master/ws-hub/sessions.js +130 -0
  158. package/dist/master/ws-hub.js +11 -0
  159. package/dist/shared/agent-profile.js +44 -0
  160. package/dist/shared/constants.js +55 -0
  161. package/dist/shared/dedup.js +33 -0
  162. package/dist/shared/group-context.js +62 -0
  163. package/dist/shared/json-codec.js +33 -0
  164. package/dist/shared/logger.js +136 -0
  165. package/dist/shared/mention.js +22 -0
  166. package/dist/shared/network.js +40 -0
  167. package/dist/shared/parse.js +18 -0
  168. package/dist/shared/prompt-composer.js +171 -0
  169. package/dist/shared/protocol/client-messages.js +8 -0
  170. package/dist/shared/protocol/enums.js +6 -0
  171. package/dist/shared/protocol/federation.js +62 -0
  172. package/dist/shared/protocol/guards.js +87 -0
  173. package/dist/shared/protocol/server-messages.js +8 -0
  174. package/dist/shared/protocol/types.js +8 -0
  175. package/dist/shared/protocol.js +19 -0
  176. package/dist/shared/readonly-allowlist.js +122 -0
  177. package/dist/shared/rotom-cli-prompt.js +23 -0
  178. package/dist/shared/skill-context.js +19 -0
  179. package/dist/shared/skill-md.js +43 -0
  180. package/dist/shared/slash-commands.js +50 -0
  181. package/dist/shared/time.js +80 -0
  182. package/dist/shared/title.js +46 -0
  183. package/dist/shared/url-extractor.js +99 -0
  184. package/migrations/001-schema.sql +942 -0
  185. package/package.json +68 -0
  186. package/scripts/fix-node-pty-perms.mjs +46 -0
  187. package/skill/rotom-a2a-communicate/SKILL.md +257 -0
  188. package/skill/rotom-bus-host/SKILL.md +78 -0
  189. package/skill/rotom-bus-host/scripts/poll-replies.sh +148 -0
@@ -0,0 +1,181 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ApprovalCard-C38VV6ko.css","assets/ArtifactPanel-aGHySny5.css"])))=>i.map(i=>d[i]);
2
+ var ji=Object.defineProperty;var ki=(t,o,m)=>o in t?ji(t,o,{enumerable:!0,configurable:!0,writable:!0,value:m}):t[o]=m;var Zs=(t,o,m)=>ki(t,typeof o!="symbol"?o+"":o,m);import{r as g,u as Ut,j as e,a as Ei,N as Hr,b as Fr,c as zr,d as Ps,L as Ni,e as Wr,O as Ri,R as Li,f as Oe,h as Ft,i as Ti,B as Ii}from"./react-vendor-C8IxlyCR.js";import{_ as fs}from"./vite-preload-CxJPbCTl.js";import{M as Ys,r as Qs}from"./markdown-CeN5IgdF.js";function Ai(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("share")}class Di{constructor(o="/api"){Zs(this,"baseUrl");this.baseUrl=o}resolveUrl(o){const m=Ai(),S=o.startsWith("/")?o:`/${o}`;return m?`${this.baseUrl}/share/${m}${S}`:`${this.baseUrl}${S}`}async request(o,m={}){const S={"Content-Type":"application/json",...m.headers};try{const j=await fetch(this.resolveUrl(o),{...m,headers:S});let E;const b=await j.text();if(b)try{E=JSON.parse(b)}catch{throw new Error(`Server returned non-JSON response (HTTP ${j.status})`)}if(!j.ok)throw new Error((E==null?void 0:E.error)||`HTTP ${j.status}: ${j.statusText}`);return E}catch(j){throw j instanceof Error?j:new Error("Network error: Failed to connect to the server")}}async get(o){return this.request(o,{method:"GET"})}async post(o,m){return this.request(o,{method:"POST",body:m?JSON.stringify(m):void 0})}async put(o,m){return this.request(o,{method:"PUT",body:m?JSON.stringify(m):void 0})}async patch(o,m){return this.request(o,{method:"PATCH",body:m?JSON.stringify(m):void 0})}async delete(o,m){return this.request(o,{method:"DELETE",body:m?JSON.stringify(m):void 0})}}const ne=new Di,Os={async list(){return ne.get("/agents")},async listOnline(){return ne.get("/agents/online")},async getById(t){return ne.get(`/agents/${t}`)},async create(t){return ne.post("/agents",t)},async update(t,o){return ne.put(`/agents/${t}`,o)},async delete(t){return ne.delete(`/agents/${t}`)},async refreshToken(t){return ne.post(`/agents/${t}/refresh-token`)},async uploadAvatar(t,o,m){return ne.post("/agents/avatar",{agentId:t,dataBase64:o,mimeType:m})},async sendMessage(t,o,m){return ne.post("/messages/send",{from:t,to:o,message:m})}},Re={async list(){return ne.get("/groups")},async getById(t){return ne.get(`/groups/${t}`)},async create(t){return ne.post("/groups",t)},async updateWorkingDir(t,o){return ne.patch(`/groups/${t}`,{workingDir:o})},async setPinned(t,o){return ne.patch(`/groups/${t}`,{pinned:o})},async setArchived(t,o){return ne.patch(`/groups/${t}`,{archived:o})},async setStarred(t,o){return ne.patch(`/groups/${t}`,{starred:o})},async updateName(t,o){return ne.patch(`/groups/${t}`,{name:o})},async updateGuidancePrompt(t,o){return ne.patch(`/groups/${t}`,{guidancePrompt:o})},async updateRepo(t,o){return ne.patch(`/groups/${t}`,o)},async delete(t){return ne.delete(`/groups/${t}`)},async addMembers(t,o){return ne.post(`/groups/${t}/members`,{agentNames:o})},async removeMembers(t,o){return ne.delete(`/groups/${t}/members`,{agentNames:o})},async setMemberWorkingDir(t,o,m){return ne.put(`/groups/${t}/members/${encodeURIComponent(o)}/working-dir`,{workingDir:m})},async clearMemberWorkingDir(t,o){return ne.delete(`/groups/${t}/members/${encodeURIComponent(o)}/working-dir`)},async setMemberProfile(t,o,m){return ne.put(`/groups/${t}/members/${encodeURIComponent(o)}/profile`,m)},async getMessages(t){return ne.get(`/groups/${t}/messages`)},async sendMessage(t,o,m,S){return ne.post(`/groups/${t}/messages`,{sender:o,content:m,mentions:S})}},es={async listByGroup(t){return ne.get(`/schedules?group_id=${encodeURIComponent(t)}`)},async create(t){return ne.post("/schedules",t)}},ts="__dm__:";function er(t){return t.startsWith(ts)&&t.slice(ts.length).split(":")[0]||null}function Bi(t,o){return`${ts}${t}:${o+1}`}function Hs(t){const o=t.match(/@([\w一-鿿][\w.一-鿿-]*)/g);return o?o.map(m=>m.slice(1)):[]}const Ur=g.createContext(null);function Mi({children:t}){const o=Ut(),[m,S]=g.useState([]),[j,E]=g.useState(!0),[b,n]=g.useState(null),[a,d]=g.useState([]),[h,c]=g.useState(()=>localStorage.getItem("chat_agent_name")??""),[f]=g.useState(()=>localStorage.getItem("chat_agent_token")??""),[v,y]=g.useState(!1),[u,i]=g.useState(!1),[r,s]=g.useState(""),l=g.useCallback(async(O=!1)=>{O||E(!0),n(null);try{const X=await Os.list();S(X),c(F=>{if(F)return F;if(X.length===0)return"";const re=X.find(ae=>{var ee;return((ee=ae.profile)==null?void 0:ee.category)==="真人"})??X[0];return localStorage.setItem("chat_agent_name",re.name),re.name})}catch(X){const F=X instanceof Error?X.message:"Failed to load agents";n(F),console.error("Failed to load agents:",X)}finally{E(!1)}},[]),_=g.useCallback(async()=>{try{const O=await Re.list();d(O)}catch(O){console.error("Failed to load groups:",O)}},[]);g.useEffect(()=>{l(),_()},[l,_]);const x=g.useRef(0);g.useEffect(()=>{const X=()=>{if(document.visibilityState!=="visible")return;const F=Date.now();F-x.current<3e4||(x.current=F,l(!0))};return document.addEventListener("visibilitychange",X),()=>document.removeEventListener("visibilitychange",X)},[l]);const C=g.useCallback(O=>{c(O),y(!1)},[]),k=g.useCallback(()=>{y(!0)},[]),p=g.useCallback(()=>y(!1),[]),w=g.useCallback(()=>i(!0),[]),R=g.useCallback(()=>i(!1),[]),T=g.useCallback(O=>{s(O),O&&localStorage.setItem("dm_active_target",O)},[]),M=g.useMemo(()=>m.filter(O=>O.status==="online"&&O.name!==h),[m,h]),N=g.useMemo(()=>a.filter(O=>{var X;return O.name.startsWith(ts)&&((X=O.members)==null?void 0:X.some(F=>F.agent_name===h))}).map(O=>({...O,dmTarget:er(O.name)||""})).sort((O,X)=>O.created_at.localeCompare(X.created_at)),[a,h]),I=g.useCallback(O=>{s(""),localStorage.removeItem("dm_active_target"),localStorage.removeItem("dm_active_group"),O?(localStorage.setItem("group_selected_id",O),o(`/dashboard/groups/${O}`)):o("/dashboard/groups")},[o]),z=g.useCallback((O,X)=>{s(X),localStorage.setItem("dm_active_target",X),localStorage.setItem("dm_active_group",O),localStorage.setItem("group_selected_id",O),o(`/dashboard/groups/${O}`)},[o]),G=g.useCallback(async(O,X,F,W,re,ae,ee)=>{var ce;if(h)try{const he=await Re.create({name:O,memberNames:W==="patrol"?X:[...X,h],workingDir:F,type:W}),pe=[];re&&pe.push(Re.updateGuidancePrompt(he.id,re)),ee&&(ee.repoUrl||(ce=ee.extraRepos)!=null&&ce.length)&&pe.push(Re.updateRepo(he.id,ee)),ae&&pe.push(es.create({name:`${O}-${new Date().toLocaleTimeString("zh-CN",{hour12:!1})}`,group_id:he.id,mode:ae.mode,agent_name:ae.agent_name,schedule_kind:ae.schedule_kind,interval_sec:ae.interval_sec,run_at:ae.run_at,prompt:ae.prompt,repeat_times:ae.repeat_times??null,enabled:!0})),pe.length>0&&await Promise.all(pe).catch(Ne=>{console.error("Failed to apply guidance template after group creation:",Ne),window.alert(`群已创建,但模板落地失败: ${Ne instanceof Error?Ne.message:String(Ne)}`)}),i(!1),await _(),o(`/dashboard/groups/${he.id}`)}catch(he){console.error("Failed to create group:",he);const pe=he instanceof Error?he.message:String(he);throw window.alert(`创建群失败:${pe}`),he}},[h,_]),H=g.useCallback(async(O,X)=>{try{await Re.updateWorkingDir(O,X),await _()}catch(F){console.error("Failed to update group workingDir:",F);const W=F instanceof Error?F.message:String(F);throw window.alert(`修改工作目录失败:${W}`),F}},[_]),V=g.useCallback(async(O,X,F)=>{const W=a;d(re=>re.map(ae=>{if(ae.id!==O)return ae;const ee=(ae.members||[]).map(ce=>ce.agent_name===X?{...ce,working_dir:F}:ce);return{...ae,members:ee}}));try{await Re.setMemberWorkingDir(O,X,F)}catch(re){console.error("Failed to set member workingDir:",re),d(W);const ae=re instanceof Error?re.message:String(re);throw window.alert(`设置成员工作目录失败:${ae}`),re}},[a]),L=g.useCallback(async(O,X)=>{const F=a;d(W=>W.map(re=>{if(re.id!==O)return re;const ae=(re.members||[]).map(ee=>ee.agent_name===X?{...ee,working_dir:null}:ee);return{...re,members:ae}}));try{await Re.clearMemberWorkingDir(O,X)}catch(W){console.error("Failed to clear member workingDir:",W),d(F);const re=W instanceof Error?W.message:String(W);throw window.alert(`清除成员工作目录失败:${re}`),W}},[a]),A=g.useCallback(async(O,X)=>{d(F=>F.map(W=>W.id===O?{...W,name:X}:W));try{await Re.updateName(O,X),await _()}catch(F){console.error("Failed to update group name:",F),await _();const W=F instanceof Error?F.message:String(F);window.alert(`更新群名称失败:${W}`)}},[_]),B=g.useCallback(async(O,X)=>{const F=X?new Date().toISOString():null;d(W=>W.map(re=>re.id===O?{...re,pinned_at:F}:re));try{await Re.setPinned(O,X),await _()}catch(W){console.error("Failed to toggle group pin:",W),await _();const re=W instanceof Error?W.message:String(W);window.alert(`置顶操作失败:${re}`)}},[_]),P=g.useCallback(async(O,X)=>{try{await Re.updateGuidancePrompt(O,X),await _()}catch(F){console.error("Failed to update group guidance prompt:",F);const W=F instanceof Error?F.message:String(F);throw window.alert(`更新群指导 prompt 失败:${W}`),F}},[_]),U=g.useCallback(async(O,X)=>{try{await Re.updateRepo(O,X),await _()}catch(F){console.error("Failed to update group repo:",F);const W=F instanceof Error?F.message:String(F);throw window.alert(`更新群 repo 配置失败:${W}`),F}},[_]),Z=g.useCallback(async(O,X)=>{d(F=>F.map(W=>W.id===O?{...W,archived:X}:W));try{await Re.setArchived(O,X),await _()}catch(F){console.error("Failed to toggle group archive:",F),await _();const W=F instanceof Error?F.message:String(F);window.alert(`归档操作失败:${W}`)}},[_]),oe=g.useCallback(async(O,X)=>{d(F=>F.map(W=>W.id===O?{...W,starred_at:X?new Date().toISOString():null}:W));try{await Re.setStarred(O,X),await _()}catch(F){console.error("Failed to toggle group star:",F),await _();const W=F instanceof Error?F.message:String(F);window.alert(`标记重要少用失败:${W}`)}},[_]),K=g.useCallback(async O=>{if(window.confirm("确定要删除这个群吗?所有消息将被清除。")){d(X=>X.filter(F=>F.id!==O));try{await Re.delete(O),await _()}catch(X){console.error("Failed to delete group:",X),await _();const F=X instanceof Error?X.message:String(X);window.alert(`删除群失败:${F}`)}}},[_]),$=g.useCallback(async O=>{if(!h)return;const X=N.filter(W=>W.dmTarget===O),F=Bi(O,X.length);try{const W=await Re.create({name:F,memberNames:[h,O]});await _(),z(W.id,O)}catch(W){console.error("Failed to create DM group:",W)}},[h,N,_,z]),D=g.useCallback(async O=>{if(!h){y(!0);return}const X=N.filter(F=>F.dmTarget===O);if(X.length>0){const F=X[X.length-1];z(F.id,O);return}await $(O)},[h,N,z,$]),q=g.useRef(!1);g.useEffect(()=>{if(q.current||a.length===0||!h)return;q.current=!0;const O=localStorage.getItem("dm_active_target"),X=localStorage.getItem("dm_active_group");if(!O)return;if(X&&a.find(re=>re.id===X)){s(O);return}a.find(W=>{var re;return W.name.startsWith(ts)&&er(W.name)===O&&((re=W.members)==null?void 0:re.some(ae=>ae.agent_name===h))})&&s(O)},[a,h]);const J={agents:m,agentsLoading:j,agentsError:b,groups:a,dmGroups:N,onlineAgents:M,myAgentName:h,myAgentToken:f,setMyAgentConfig:C,showConfigModal:v,openConfigModal:k,closeConfigModal:p,showCreateGroupModal:u,openCreateGroupModal:w,closeCreateGroupModal:R,directTarget:r,setDirectTarget:T,loadAgents:l,loadGroups:_,handleDirectChat:D,handleNewDmConversation:$,activateDmGroup:z,selectGroup:I,createGroup:G,updateGroupName:A,updateGroupGuidancePrompt:P,updateGroupRepo:U,updateGroupWorkingDir:H,setGroupMemberWorkingDir:V,clearGroupMemberWorkingDir:L,toggleGroupPinned:B,toggleGroupArchived:Z,toggleGroupStarred:oe,deleteGroup:K};return e.jsx(Ur.Provider,{value:J,children:t})}function nt(){const t=g.useContext(Ur);if(!t)throw new Error("useChatContext must be used inside <ChatProvider>");return t}const $i="_button_q3xxg_1",Pi="_xs_q3xxg_44",Oi="_sm_q3xxg_51",Hi="_md_q3xxg_58",Fi="_lg_q3xxg_65",zi="_iconOnly_q3xxg_72",Wi="_primary_q3xxg_78",Ui="_secondary_q3xxg_89",qi="_ghost_q3xxg_99",Vi="_success_q3xxg_110",Gi="_danger_q3xxg_120",Ki="_outline_q3xxg_131",Vt={button:$i,xs:Pi,sm:Oi,md:Hi,lg:Fi,iconOnly:zi,primary:Wi,secondary:Ui,ghost:qi,success:Vi,danger:Gi,outline:Ki};function ie({variant:t="secondary",size:o="md",outline:m=!1,iconOnly:S=!1,loading:j=!1,disabled:E,className:b="",children:n,...a}){const d=[Vt.button,Vt[t],Vt[o],m&&(t==="primary"||t==="success"||t==="danger")&&Vt.outline,S&&Vt.iconOnly,b].filter(Boolean).join(" ");return e.jsx("button",{className:d,disabled:E||j,...a,children:n})}const Ji="_overlay_mthac_1",Xi="_fadeIn_mthac_1",Zi="_content_mthac_14",Yi="_slideUp_mthac_1",Qi="_titleRow_mthac_45",en="_title_mthac_45",tn="_closeBtn_mthac_64",sn="_scrollContent_mthac_93",rn="_footer_mthac_99",St={overlay:Ji,fadeIn:Xi,content:Zi,slideUp:Yi,"size-sm":"_size-sm_mthac_29","size-md":"_size-md_mthac_33","size-lg":"_size-lg_mthac_37","size-xl":"_size-xl_mthac_41",titleRow:Qi,title:en,closeBtn:tn,scrollContent:sn,footer:rn};function De({open:t,title:o,onClose:m,children:S,scrollable:j=!0,footer:E,size:b="md",closeOnEsc:n=!0,closeOnBackdrop:a=!0}){if(g.useEffect(()=>{if(!t||!n||!m)return;const h=c=>{c.key==="Escape"&&(c.stopPropagation(),m())};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[t,n,m]),g.useEffect(()=>{if(!t)return;const h=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=h}},[t]),!t)return null;const d=()=>{a&&(m==null||m())};return e.jsx("div",{className:St.overlay,onClick:d,children:e.jsxs("div",{className:`${St.content} ${St[`size-${b}`]??""}`,onClick:h=>h.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":o,children:[e.jsxs("div",{className:St.titleRow,children:[e.jsx("h2",{className:St.title,children:o}),m&&e.jsx("button",{type:"button",className:St.closeBtn,onClick:m,"aria-label":"关闭",children:"✕"})]}),j?e.jsx("div",{className:St.scrollContent,children:S}):S,E&&e.jsx("div",{className:St.footer,children:E})]})})}const nn="_container_1cdq8_2",on="_workspace_1cdq8_12",an="_modeSidebar_1cdq8_22",ln="_modeStatusDot_1cdq8_34",cn="_modeStatus_connected_1cdq8_42",dn="_modeStatus_connecting_1cdq8_47",hn="_modeStatus_disconnected_1cdq8_51",un="_modeStatus_conflict_1cdq8_55",_n="_modeStatusPulse_1cdq8_1",fn="_modeSidebarDivider_1cdq8_66",pn="_modeBtn_1cdq8_73",mn="_modeBtnActive_1cdq8_97",gn="_modeBtnIcons_1cdq8_108",vn="_modeBtnLabel_1cdq8_115",yn="_modeSidebarSpacer_1cdq8_123",xn="_modeClock_1cdq8_130",bn="_modeClockRow_1cdq8_155",Sn="_modeClockIcon_1cdq8_163",Cn="_modeClockValue_1cdq8_168",wn="_modeClockUrgent_1cdq8_175",jn="_modeClockOverdue_1cdq8_186",kn="_modeClockPulse_1cdq8_1",En="_modeClockBreak_1cdq8_203",Nn="_panelsRow_1cdq8_215",Rn="_panel_1cdq8_215",Ln="_splitter_1cdq8_244",Tn="_panelsEmpty_1cdq8_262",In="_panelPlaceholder_1cdq8_273",An="_processWrap_1cdq8_286",Dn="_processTabs_1cdq8_298",Bn="_processTabsLeft_1cdq8_310",Mn="_processTab_1cdq8_296",$n="_processTabActive_1cdq8_333",Pn="_processCreateBtn_1cdq8_296",On="_processBody_1cdq8_343",Hn="_formField_1cdq8_368",Fn="_formLabel_1cdq8_372",zn="_agentCheckList_1cdq8_381",Wn="_existingMemberList_1cdq8_389",Un="_existingMemberTag_1cdq8_395",qn="_agentCheckItem_1cdq8_408",Vn="_agentCheckStatus_1cdq8_428",Gn="_online_1cdq8_438",Kn="_offline_1cdq8_443",Jn="_modalActions_1cdq8_448",Xn="_hint_1cdq8_459",Zn="_hintSub_1cdq8_467",Yn="_sessionPanel_1cdq8_473",Qn="_sessionRow_1cdq8_480",eo="_sessionCliTag_1cdq8_490",to="_sessionCliSubTag_1cdq8_506",so="_sessionOnlineDot_1cdq8_519",ro="_sessionOnlineDotOn_1cdq8_526",io="_sessionOnlineDotOff_1cdq8_531",no="_sessionRowInvalidated_1cdq8_536",oo="_sessionInvalidatedTag_1cdq8_540",ao="_sessionId_1cdq8_550",lo="_sessionActions_1cdq8_561",co="_sessionUsage_1cdq8_566",ho="_sessionUsageEmpty_1cdq8_583",uo="_sessionUsageModel_1cdq8_590",_o="_sessionUsageSep_1cdq8_595",fo="_sessionUsageTokenIn_1cdq8_600",po="_sessionUsageTokenOut_1cdq8_604",mo="_sessionUsageCost_1cdq8_608",go="_sessionUsageCostCum_1cdq8_613",vo="_sessionUsageArrow_1cdq8_619",yo="_sessionContent_1cdq8_624",Q={container:nn,workspace:on,modeSidebar:an,modeStatusDot:ln,modeStatus_connected:cn,modeStatus_connecting:dn,modeStatus_disconnected:hn,modeStatus_conflict:un,modeStatusPulse:_n,modeSidebarDivider:fn,modeBtn:pn,modeBtnActive:mn,modeBtnIcons:gn,modeBtnLabel:vn,modeSidebarSpacer:yn,modeClock:xn,modeClockRow:bn,modeClockIcon:Sn,modeClockValue:Cn,modeClockUrgent:wn,modeClockOverdue:jn,modeClockPulse:kn,modeClockBreak:En,panelsRow:Nn,panel:Rn,splitter:Ln,panelsEmpty:Tn,panelPlaceholder:In,processWrap:An,processTabs:Dn,processTabsLeft:Bn,processTab:Mn,processTabActive:$n,processCreateBtn:Pn,processBody:On,formField:Hn,formLabel:Fn,agentCheckList:zn,existingMemberList:Wn,existingMemberTag:Un,agentCheckItem:qn,agentCheckStatus:Vn,online:Gn,offline:Kn,modalActions:Jn,hint:Xn,hintSub:Zn,sessionPanel:Yn,sessionRow:Qn,sessionCliTag:eo,sessionCliSubTag:to,sessionOnlineDot:so,sessionOnlineDotOn:ro,sessionOnlineDotOff:io,sessionRowInvalidated:no,sessionInvalidatedTag:oo,sessionId:ao,sessionActions:lo,sessionUsage:co,sessionUsageEmpty:ho,sessionUsageModel:uo,sessionUsageSep:_o,sessionUsageTokenIn:fo,sessionUsageTokenOut:po,sessionUsageCost:mo,sessionUsageCostCum:go,sessionUsageArrow:vo,sessionContent:yo};function xo({open:t,onCancel:o,onTakeover:m}){return e.jsx(De,{open:t,title:"连接冲突",footer:e.jsxs("div",{className:Q.modalActions,children:[e.jsx(ie,{variant:"secondary",size:"md",onClick:o,children:"取消"}),e.jsx(ie,{variant:"primary",size:"md",onClick:m,children:"接管连接"})]}),children:e.jsx("p",{style:{color:"var(--color-slate)",fontSize:14,lineHeight:1.6},children:"该 Agent 已在其他页面连接,接管后原页面的连接将断开。"})})}const bo=1e4,So=1e3,Co=3e4,wo=3e4,qr=g.createContext(null);function jo(){return crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const o=Math.random()*16|0;return(t==="x"?o:o&3|8).toString(16)})}function ko({children:t}){const{myAgentName:o,myAgentToken:m,loadAgents:S}=nt(),[j,E]=g.useState("disconnected"),[b,n]=g.useState(!1),[a,d]=g.useState(null),[h,c]=g.useState(null),f=g.useRef(null),v=g.useRef(new Set),y=g.useRef(null),u=g.useRef(null),i=g.useRef(0),r=g.useRef(jo()),s=g.useRef(null),l=g.useRef(S);g.useEffect(()=>{l.current=S},[S]);const _=g.useCallback(()=>{y.current&&(clearInterval(y.current),y.current=null),u.current&&(clearTimeout(u.current),u.current=null)},[]),x=g.useCallback(H=>{y.current&&clearInterval(y.current),y.current=setInterval(()=>{if(H.readyState===WebSocket.OPEN){H.send(JSON.stringify({type:"heartbeat"}));try{const V=localStorage.getItem("ws_active_tab");if(!V)return;const L=JSON.parse(V);L.tabId===r.current&&(L.timestamp=Date.now(),localStorage.setItem("ws_active_tab",JSON.stringify(L)))}catch{}}},bo)},[]),C=g.useRef(()=>{}),k=g.useRef(()=>{}),p=g.useCallback(()=>{if(!o)return;const H=window.location.protocol==="https:"?"wss:":"ws:",V=window.location.hostname==="localhost"?"localhost:28800":`${window.location.hostname}:28800`,L=`${H}//${V}/ws`,A=new WebSocket(L);f.current=A,A.onopen=()=>{E("connecting"),A.send(JSON.stringify({type:"auth",name:o,token:m||"",version:"2"}))},A.onmessage=B=>{if(f.current!==A)return;let P;try{P=JSON.parse(B.data)}catch(U){console.error("Failed to parse WebSocket message:",U);return}if(P.type==="auth_ok"){E("connected"),i.current=0,localStorage.setItem("ws_active_tab",JSON.stringify({tabId:r.current,timestamp:Date.now()})),x(A);const U=s.current;U&&A.send(JSON.stringify({type:"subscribe_issue_detail",issueId:U}))}else P.type==="auth_fail"?(E("disconnected"),_()):P.type==="issue_changed"?P.groupId&&P.issueId&&d({groupId:P.groupId,issueId:P.issueId,kind:P.kind,ts:Date.now()}):P.type==="issue_usage_progress"?P.issueId&&P.usage&&c({issueId:P.issueId,usage:P.usage,ts:Date.now()}):P.type==="directory_update"&&l.current(!0);v.current.forEach(U=>{try{U(P)}catch(Z){console.error("socket handler error:",Z)}})},A.onerror=()=>E("disconnected"),A.onclose=B=>{_();try{const P=localStorage.getItem("ws_active_tab");P&&JSON.parse(P).tabId===r.current&&localStorage.removeItem("ws_active_tab")}catch{}if(B.reason==="Replaced by new connection"){E("conflict");return}E("disconnected"),f.current===A&&o&&C.current()}},[o,_,x]),w=g.useCallback(()=>{const H=i.current,V=Math.random()*.3,L=Math.min(So*Math.pow(2,H)*(1+V),Co);i.current=H+1,u.current=setTimeout(()=>{k.current()},L)},[]),R=g.useCallback(()=>{if(o){try{const H=localStorage.getItem("ws_active_tab");if(H){const V=JSON.parse(H);if(V.tabId!==r.current&&Date.now()-V.timestamp<wo){n(!0);return}}}catch{}p()}},[o,p]);g.useEffect(()=>{C.current=w},[w]),g.useEffect(()=>{k.current=R},[R]),g.useEffect(()=>{const H=()=>{try{const V=localStorage.getItem("ws_active_tab");V&&JSON.parse(V).tabId===r.current&&localStorage.removeItem("ws_active_tab")}catch{}};return window.addEventListener("beforeunload",H),()=>window.removeEventListener("beforeunload",H)},[]),g.useEffect(()=>{if(o)return R(),()=>{var H;_(),(H=f.current)==null||H.close(),f.current=null}},[o,R,_]);const T=g.useCallback(H=>{const V=f.current;return!V||V.readyState!==WebSocket.OPEN?!1:(V.send(typeof H=="string"?H:JSON.stringify(H)),!0)},[]),M=g.useCallback(H=>(v.current.add(H),()=>{v.current.delete(H)}),[]),N=g.useCallback(()=>{n(!1),p()},[p]),I=g.useCallback(H=>{const V=s.current;V&&V!==H&&T({type:"unsubscribe_issue_detail",issueId:V}),s.current=H,T({type:"subscribe_issue_detail",issueId:H})},[T]),z=g.useCallback(H=>{s.current===H&&(s.current=null,T({type:"unsubscribe_issue_detail",issueId:H}))},[T]),G={status:j,send:T,subscribe:M,lastIssueChange:a,lastIssueUsageProgress:h,subscribeIssueDetail:I,unsubscribeIssueDetail:z,reconnect:N};return e.jsxs(qr.Provider,{value:G,children:[t,e.jsx(xo,{open:b,onCancel:()=>{n(!1),E("disconnected")},onTakeover:N})]})}function wt(){const t=g.useContext(qr);if(!t)throw new Error("useSocket must be used inside <SocketProvider>");return t}const Be={async listByGroup(t,o,m){const S=new URLSearchParams;o&&S.set("status",o),m&&S.set("type",m);const j=S.toString();return ne.get(`/groups/${t}/issues${j?`?${j}`:""}`)},async listAll(t){const o=t?`?status=${encodeURIComponent(t)}`:"";return ne.get(`/issues${o}`)},async listPage(t,o,m){const S=new URLSearchParams;return t&&S.set("status",t),S.set("limit",String(o)),S.set("offset",String(m)),ne.get(`/issues?${S.toString()}`)},async create(t,o){return ne.post(`/groups/${t}/issues`,o)},async getById(t){return ne.get(`/issues/${t}`)},async update(t,o){return ne.put(`/issues/${t}`,o)},async cancel(t,o){return ne.post(`/issues/${t}/cancel`,{cancelledBy:o})},async interrupt(t,o){return ne.post(`/issues/${t}/interrupt`,{interruptedBy:o})},async respondApproval(t,o,m,S,j){const E={decision:m};return S&&(E.resolvedBy=S),m==="deny"&&j&&j.trim()&&(E.feedback=j.trim()),ne.post(`/issues/${t}/approvals/${o}`,E)},async getEvents(t){return ne.get(`/issues/${t}/events`)},async getMessages(t){return ne.get(`/issues/${t}/messages`)},async complete(t,o){return ne.post(`/issues/${t}/complete`,{completedBy:o})},async continue(t,o,m){return ne.post(`/issues/${t}/continue`,{prompt:o,continuedBy:m})},async append(t,o,m){return ne.post(`/issues/${t}/append`,{prompt:o,appendedBy:m})},async delete(t){return ne.delete(`/issues/${t}`)},async extractMemory(t,o){return ne.post(`/issues/${t}/extract-memory`,{agentName:o})}};function Eo({open:t,elapsedMs:o,breakLengthMin:m,postponeCount:S,onStartBreak:j,onPostpone:E}){return e.jsxs(De,{open:t,title:"该休息一下啦 🌿",size:"sm",closeOnEsc:!1,closeOnBackdrop:!1,footer:e.jsxs("div",{className:Q.modalActions,children:[e.jsx(ie,{variant:"secondary",size:"md",onClick:E,children:"推迟 5 分钟"}),e.jsxs(ie,{variant:"primary",size:"md",onClick:j,children:["开始 ",m," 分钟休息"]})]}),children:[e.jsxs("p",{style:{color:"var(--color-ink)",fontSize:14,lineHeight:1.6,margin:0},children:["你已经连续工作了 ",e.jsx("strong",{children:hs(o)}),"。 站起来走走、看远处,眼睛和肩膀会感谢你。"]}),S>0&&e.jsxs("p",{style:{color:"var(--color-warning)",fontSize:12,marginTop:12},children:["已推迟 ",S," 次。长时间不休息容易疲劳,建议这次真的歇一下。"]})]})}const No="_overlay_1pym9_4",Ro="_sprite_1pym9_36",Lo="_label_1pym9_50",To="_timer_1pym9_58",Io="_timerUrgent_1pym9_68",Ao="_endBtn_1pym9_78",$t={overlay:No,sprite:Ro,label:Lo,timer:To,timerUrgent:Io,endBtn:Ao},Do=1e4,tr="/dashboard/animations/";function Bo(){const{isOnBreak:t,msUntilBreakEnd:o,endBreakEarly:m}=Fs();if(!t)return null;const S=o<=Do,j=S?`${tr}calico-waking.apng`:`${tr}calico-sleeping.apng`,E=S?"快要醒了的小猫":"正在睡觉的小猫";return e.jsxs("div",{className:$t.overlay,role:"status","aria-label":`休息中,剩余 ${zt(o)}`,children:[e.jsx("img",{className:$t.sprite,src:j,alt:E}),e.jsx("div",{className:$t.label,children:"休息中"}),e.jsx("div",{className:`${$t.timer} ${S?$t.timerUrgent:""}`,children:zt(o)}),e.jsx("button",{type:"button",className:$t.endBtn,onClick:m,children:"⚡ 开始工作"})]})}const Gt={soundEnabled:!0,soundVolume:.6,breakIntervalMin:45,breakLengthMin:10},Mo=5,$o=6e4,mt={soundEnabled:"work_session_sound_enabled",soundVolume:"work_session_sound_volume",breakInterval:"work_session_break_interval_min",breakLength:"work_session_break_length_min"},Pt=6e4;function Po(t,o){try{const m=localStorage.getItem(t);return m===null?o:m==="1"}catch{return o}}function is(t,o){try{const m=localStorage.getItem(t);if(m===null)return o;const S=Number(m);return Number.isFinite(S)?S:o}catch{return o}}function Oo(t,o){try{localStorage.setItem(t,o?"1":"0")}catch{}}function vs(t,o){try{localStorage.setItem(t,String(o))}catch{}}function Ho(t){if(typeof window>"u")return;const o=window.AudioContext||window.webkitAudioContext;if(!o)return;let m;try{m=new o}catch{return}const S=m.currentTime,j=[{freq:659.25,start:0,dur:.18},{freq:987.77,start:.14,dur:.28}],E=m.createGain();E.gain.value=Math.max(0,Math.min(1,t)),E.connect(m.destination);for(const b of j){const n=m.createOscillator();n.type="sine",n.frequency.value=b.freq;const a=m.createGain();a.gain.setValueAtTime(0,S+b.start),a.gain.linearRampToValueAtTime(.8,S+b.start+.012),a.gain.exponentialRampToValueAtTime(.001,S+b.start+b.dur),n.connect(a),a.connect(E),n.start(S+b.start),n.stop(S+b.start+b.dur+.05)}window.setTimeout(()=>{try{m.close()}catch{}},700)}const sr=new Set(["completed","failed","cancelled"]),Vr=g.createContext(null);function Fo({children:t}){const{lastIssueChange:o,subscribe:m}=wt(),{myAgentName:S}=nt(),[j,E]=g.useState(()=>Date.now()),[b,n]=g.useState(()=>Po(mt.soundEnabled,Gt.soundEnabled)),[a,d]=g.useState(()=>is(mt.soundVolume,Gt.soundVolume)),[h,c]=g.useState(()=>is(mt.breakInterval,Gt.breakIntervalMin)),[f,v]=g.useState(()=>is(mt.breakLength,Gt.breakLengthMin)),[y,u]=g.useState(()=>Date.now()+is(mt.breakInterval,Gt.breakIntervalMin)*Pt),[i,r]=g.useState(!1),[s,l]=g.useState(null),[_,x]=g.useState(0),[C,k]=g.useState(!1);g.useEffect(()=>{const oe=window.setInterval(()=>E(Date.now()),1e3);return()=>window.clearInterval(oe)},[]);const p=g.useCallback(()=>{b&&Ho(a)},[b,a]),w=g.useRef(new Map);g.useEffect(()=>{if(!o)return;const{issueId:oe}=o;let K=!1;return Be.getById(oe).then($=>{if(K)return;const D=w.current.get(oe),q=$.status;w.current.set(oe,q),D&&!sr.has(D)&&sr.has(q)&&p()}).catch(()=>{}),()=>{K=!0}},[o,p]);const R=g.useRef(S);g.useEffect(()=>{R.current=S},[S]),g.useEffect(()=>m(oe=>{var $;if(oe.type!=="a2a_stream_end"&&oe.type!=="a2a_message")return;const K=(($=oe.from)==null?void 0:$.name)||"";!K||K===R.current||p()}),[m,p]);const T=g.useRef(null);g.useEffect(()=>{if(i||j<y){T.current=null;return}T.current===null&&(T.current=j),k(!0),j-T.current<$o&&p()},[j,y,i,p]),g.useEffect(()=>{!i||s==null||j>=s&&(r(!1),l(null),u(Date.now()+h*Pt),p())},[j,i,s,h,p]);const M=g.useCallback(oe=>{n(oe),Oo(mt.soundEnabled,oe)},[]),N=g.useCallback(oe=>{const K=Math.max(0,Math.min(1,oe));d(K),vs(mt.soundVolume,K)},[]),I=g.useCallback(oe=>{const K=Math.max(1,Math.min(180,Math.round(oe)));c(K),vs(mt.breakInterval,K)},[]),z=g.useCallback(oe=>{const K=Math.max(1,Math.min(60,Math.round(oe)));v(K),vs(mt.breakLength,K)},[]),G=g.useCallback(()=>{r(!0),l(Date.now()+f*Pt),k(!1),x(0)},[f]),H=g.useCallback((oe=Mo)=>{k(!1),x(K=>K+1),u(Date.now()+oe*Pt)},[]),V=g.useCallback(()=>{r(!1),l(null),u(Date.now()+h*Pt),x(0)},[h]),L=g.useCallback(()=>{r(!1),l(null),x(0),u(Date.now()+h*Pt),A.current=Date.now()},[h]),A=g.useRef(Date.now()),B=i?0:Math.max(0,j-A.current),P=i?0:Math.max(0,y-j),U=i&&s!=null?Math.max(0,s-j):0,Z=g.useMemo(()=>({elapsedMs:B,nextBreakAt:y,msUntilBreak:P,isOnBreak:i,breakEndsAt:s,msUntilBreakEnd:U,postponeCount:_,soundEnabled:b,soundVolume:a,breakIntervalMin:h,breakLengthMin:f,setSoundEnabled:M,setSoundVolume:N,setBreakIntervalMin:I,setBreakLengthMin:z,playSound:p,triggerBreakNow:G,postponeBreak:H,endBreakEarly:V,resetSession:L}),[B,y,P,i,s,U,_,b,a,h,f,M,N,I,z,p,G,H,V,L]);return e.jsxs(Vr.Provider,{value:Z,children:[t,e.jsx(Eo,{open:C,elapsedMs:B,breakLengthMin:f,postponeCount:_,onStartBreak:G,onPostpone:()=>H()}),e.jsx(Bo,{})]})}function Fs(){const t=g.useContext(Vr);if(!t)throw new Error("useWorkSession must be used inside <WorkSessionProvider>");return t}function hs(t){const o=Math.floor(t/1e3),m=Math.floor(o/3600),S=Math.floor(o%3600/60);return`${m}:${String(S).padStart(2,"0")}`}function zt(t){const o=Math.max(0,Math.floor(t/1e3)),m=Math.floor(o/60),S=o%60;return`${String(m).padStart(2,"0")}:${String(S).padStart(2,"0")}`}const Gr=g.createContext({zenMode:!0,toggleZenMode:()=>{}});function zo({children:t}){const[o,m]=g.useState(!1),S=()=>m(j=>!j);return e.jsx(Gr.Provider,{value:{zenMode:o,toggleZenMode:S},children:t})}function Kr(){return g.useContext(Gr)}const Jr=g.createContext(null);function Wo(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("share")}function Uo({children:t}){const o=g.useMemo(()=>Wo(),[]),[m,S]=g.useState({token:o,groupId:null,error:null}),j=g.useCallback(async n=>{if(!o)return!1;try{return(await fetch(`/api/share/${o}/groups/${n}`,{headers:{"Content-Type":"application/json"}})).ok?(S({token:o,groupId:n,error:null}),!0):(S({token:o,groupId:null,error:"分享链接无效或已过期"}),!1)}catch{return S({token:o,groupId:null,error:"验证分享链接失败"}),!1}},[o]),E=g.useCallback(()=>{S({token:null,groupId:null,error:null})},[]),b={...m,isVisitor:!!m.token&&!m.error,validate:j,reset:E};return e.jsx(Jr.Provider,{value:b,children:t})}function qt(){const t=g.useContext(Jr);if(!t)throw new Error("useVisitorMode must be used within a VisitorProvider");return t}const rr=["ff6b6b","ffd93d","6bcf7f","4d96ff","9b59b6","ff8a65","4dd0e1","aed581","f06292","7986cb"];function Xr(t){let o=0;for(let m=0;m<t.length;m++)o=t.charCodeAt(m)+((o<<5)-o);return o}function qo(t){const o=rr[Math.abs(Xr(t))%rr.length];return`https://api.dicebear.com/7.x/avataaars/svg?seed=${encodeURIComponent(t)}&backgroundColor=${o}`}function Zr(t){const o=["#4285f4","#34a853","#fbbc05","#ea4335","#9c27b0","#00bcd4","#ff5722","#607d8b"];return o[Math.abs(Xr(t))%o.length]}const Vo="_avatar_1qts7_1",Go="_fallback_1qts7_8",ir={avatar:Vo,fallback:Go};function At({name:t,src:o,size:m=36,className:S}){const[j,E]=g.useState(!1);return j?e.jsx("div",{className:`${ir.fallback} ${S||""}`,style:{width:m,height:m,background:Zr(t),fontSize:m*.4},title:t,children:t.charAt(0).toUpperCase()}):e.jsx("img",{src:o??qo(t),alt:t,className:`${ir.avatar} ${S||""}`,style:{width:m,height:m},onError:()=>E(!0)})}const Ko="_wrapper_12v54_1",Jo="_disabled_12v54_14",Xo="_box_12v54_19",Zo="_boxChecked_12v54_37",Yo="_boxIndeterminate_12v54_38",Qo="_input_12v54_48",ea="_label_12v54_69",Et={wrapper:Ko,disabled:Jo,box:Xo,boxChecked:Zo,boxIndeterminate:Yo,input:Qo,label:ea};function Dt({checked:t,onChange:o,label:m,disabled:S,indeterminate:j,id:E,className:b="",...n}){const a=g.useId(),d=E??a,h=g.useRef(null);return g.useEffect(()=>{h.current&&(h.current.indeterminate=!!j)},[j]),e.jsxs("label",{className:[Et.wrapper,S&&Et.disabled,b].filter(Boolean).join(" "),htmlFor:d,children:[e.jsxs("span",{className:[Et.box,t&&Et.boxChecked,j&&Et.boxIndeterminate].filter(Boolean).join(" "),children:[t&&!j&&e.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:e.jsx("polyline",{points:"3 8 7 12 13 4",fill:"none",stroke:"var(--color-dark-green)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),j&&e.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:e.jsx("line",{x1:"4",y1:"8",x2:"12",y2:"8",stroke:"var(--color-dark-green)",strokeWidth:"2.5",strokeLinecap:"round"})})]}),m&&e.jsx("span",{className:Et.label,children:m}),e.jsx("input",{ref:h,id:d,type:"checkbox",className:Et.input,checked:t,disabled:S,onChange:c=>o(c.target.checked),...n})]})}const ta="_container_11ylg_1",sa="_label_11ylg_7",ra="_required_11ylg_15",ia="_helperText_11ylg_20",na="_errorText_11ylg_26",Kt={container:ta,label:sa,required:ra,helperText:ia,errorText:na};function zs({label:t,required:o,helperText:m,error:S,htmlFor:j,children:E,className:b=""}){const n=[Kt.container,b].filter(Boolean).join(" ");return e.jsxs("div",{className:n,"data-field":S?"error":void 0,children:[t&&e.jsxs("label",{className:Kt.label,htmlFor:j,children:[t,o&&e.jsx("span",{className:Kt.required,"aria-hidden":"true",children:" *"})]}),E,S?e.jsx("span",{className:Kt.errorText,children:S}):m?e.jsx("span",{className:Kt.helperText,children:m}):null]})}const oa="_input_egtpw_1",aa="_error_egtpw_44",la="_sm_egtpw_52",ca="_md_egtpw_58",ys={input:oa,error:aa,sm:la,md:ca},ge=g.forwardRef(function({label:o,required:m,error:S,helperText:j,size:E="md",id:b,className:n="",...a},d){const h=g.useId(),c=b??h,f=[ys.input,ys[E],S&&ys.error,n].filter(Boolean).join(" ");return e.jsx(zs,{label:o,required:m,error:S,helperText:j,htmlFor:c,children:e.jsx("input",{id:c,ref:d,className:f,...a})})}),da="_select_1c65p_1",ha="_error_1c65p_46",ua="_sm_1c65p_54",_a="_md_1c65p_60",xs={select:da,error:ha,sm:ua,md:_a},Fe=g.forwardRef(function({label:o,required:m,error:S,helperText:j,size:E="md",options:b,children:n,id:a,className:d="",...h},c){const f=g.useId(),v=a??f,y=[xs.select,xs[E],S&&xs.error,d].filter(Boolean).join(" ");return e.jsx(zs,{label:o,required:m,error:S,helperText:j,htmlFor:v,children:e.jsx("select",{id:v,ref:c,className:y,...h,children:b?b.map(u=>e.jsx("option",{value:u.value,children:u.label},u.value)):n})})}),fa="_textarea_1f92i_1",pa="_error_1f92i_42",ma="_sm_1f92i_50",ga="_md_1f92i_56",bs={textarea:fa,error:pa,sm:ma,md:ga},xt=g.forwardRef(function({label:o,required:m,error:S,helperText:j,size:E="md",id:b,className:n="",...a},d){const h=g.useId(),c=b??h,f=[bs.textarea,bs[E],S&&bs.error,n].filter(Boolean).join(" ");return e.jsx(zs,{label:o,required:m,error:S,helperText:j,htmlFor:c,children:e.jsx("textarea",{id:c,ref:d,className:f,...a})})}),Qt={async list(){return ne.get("/guidance-templates")},async create(t){return ne.post("/guidance-templates",t)},async update(t,o){return ne.patch(`/guidance-templates/${t}`,o)},async remove(t){await ne.delete(`/guidance-templates/${t}`)}},Ds=/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g;function nr(t){const o=new Set,m=[];let S;for(Ds.lastIndex=0;(S=Ds.exec(t))!==null;){const j=S[1];o.has(j)||(o.add(j),m.push(j))}return m}function Ss(t,o){return t.replace(Ds,(m,S)=>Object.prototype.hasOwnProperty.call(o,S)&&o[S]!==""?o[S]:m)}const va={teacher:"老师 agent",student:"学生 agent",topic:"讨论话题"};function Ws({open:t,mode:o="apply",groupId:m,groupName:S,memberAgentNames:j,onPromptApplied:E,onScheduleCreated:b,onResolved:n,onClose:a}){const[d,h]=g.useState([]),[c,f]=g.useState(!1),[v,y]=g.useState(null),[u,i]=g.useState(null),[r,s]=g.useState({}),[l,_]=g.useState(!1),[x,C]=g.useState(null);g.useEffect(()=>{t&&(f(!0),y(null),C(null),i(null),Qt.list().then(h).catch(R=>y((R==null?void 0:R.message)??"加载失败")).finally(()=>f(!1)))},[t]);const k=R=>{i(R),C(null);const T=R.prompt_text+(R.schedule_config??""),M=nr(T),N={};M.forEach(I=>{I==="teacher"&&j[0]?N[I]=j[0]:I==="student"&&j[1]?N[I]=j[1]:N[I]=""}),s(N)},p=g.useMemo(()=>{if(!u)return[];const R=u.prompt_text+(u.schedule_config??"");return nr(R)},[u]),w=async()=>{if(u){_(!0),C(null);try{const R=Ss(u.prompt_text,r);let T=null;if(u.schedule_config){const M=JSON.parse(u.schedule_config);T={...M,agent_name:M.agent_name?Ss(M.agent_name,r):void 0,prompt:Ss(M.prompt,r)}}if(o==="select"){n==null||n(R,T,u.name),a();return}if(E==null||E(R),T&&m){const M=`${u.name}-${S??""}-${new Date().toLocaleTimeString("zh-CN",{hour12:!1})}`,N=await es.create({name:M,group_id:m,mode:T.mode,agent_name:T.agent_name,schedule_kind:T.schedule_kind,interval_sec:T.interval_sec,run_at:T.run_at,prompt:T.prompt,repeat_times:T.repeat_times??null,enabled:!0});C(`已应用模板,并创建定时任务 #${N.id} (${T.schedule_kind==="interval"?`每 ${T.interval_sec}s`:"once"},重复 ${T.repeat_times??"∞"} 次)`),b==null||b()}else C("已应用模板到群指导 prompt,记得点「保存」生效。");a()}catch(R){C(`应用失败: ${(R==null?void 0:R.message)??String(R)}`)}finally{_(!1)}}};return e.jsx(De,{open:t,title:"选择群指导模板",onClose:a,size:"md",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,padding:"4px 0"},children:[c&&e.jsx("div",{style:{fontSize:13,color:"var(--color-slate)"},children:"加载中..."}),v&&e.jsx("div",{style:{fontSize:13,color:"rgb(220,38,38)"},children:v}),!c&&!v&&!u&&e.jsxs(e.Fragment,{children:[d.length===0&&e.jsx("div",{style:{fontSize:13,color:"var(--color-slate)"},children:"暂无模板"}),d.map(R=>e.jsxs("button",{type:"button",onClick:()=>k(R),style:{textAlign:"left",border:"1px solid rgba(0,0,0,0.1)",borderRadius:6,padding:"8px 10px",background:"var(--color-surface, #fff)",cursor:"pointer"},children:[e.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--color-navy)"},children:[R.name,R.schedule_config&&e.jsx("span",{style:{marginLeft:6,fontSize:11,color:"rgb(99,102,241)"},children:"·带定时任务"})]}),e.jsx("div",{style:{fontSize:11,color:"var(--color-slate)",marginTop:2},children:R.description})]},R.id))]}),u&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--color-navy)"},children:u.name}),e.jsx("div",{style:{fontSize:12,color:"var(--color-slate)",background:"rgba(0,0,0,0.03)",padding:8,borderRadius:6,whiteSpace:"pre-wrap"},children:u.prompt_text}),u.schedule_config&&e.jsx("div",{style:{fontSize:11,color:"rgb(99,102,241)"},children:"含定时任务配置,确认后会自动创建。"}),p.length>0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,marginTop:4},children:[e.jsx("div",{style:{fontSize:12,color:"var(--color-slate)"},children:"填充占位符:"}),p.map(R=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12},children:[e.jsx("span",{style:{minWidth:80,color:"var(--color-navy)"},children:va[R]??R}),e.jsx(ge,{type:"text",size:"sm",value:r[R]??"",onChange:T=>s(M=>({...M,[R]:T.target.value})),placeholder:`{{${R}}}`,style:{flex:1,fontSize:12}})]},R))]}),x&&e.jsx("div",{style:{fontSize:12,color:x.startsWith("应用失败")?"rgb(220,38,38)":"rgb(22,163,74)"},children:x}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[e.jsx("button",{type:"button",onClick:()=>i(null),disabled:l,style:{border:"1px solid rgba(0,0,0,0.12)",background:"transparent",borderRadius:6,padding:"4px 12px",fontSize:12,cursor:"pointer"},children:"返回列表"}),e.jsx("button",{type:"button",onClick:w,disabled:l,style:{border:"none",background:"var(--color-primary, #4f46e5)",color:"#fff",borderRadius:6,padding:"4px 12px",fontSize:12,cursor:l?"not-allowed":"pointer",opacity:l?.6:1},children:l?"应用中...":"应用模板"})]})]})]})})}const tt={async list(t){const o=t?`?category=${encodeURIComponent(t)}`:"";return ne.get(`/skills${o}`)},async search(t){return ne.get(`/skills/search?q=${encodeURIComponent(t)}`)},async getByName(t){return ne.get(`/skills/${encodeURIComponent(t)}`)},async create(t){return ne.post("/skills",t)},async update(t,o){return ne.patch(`/skills/${encodeURIComponent(t)}`,o)},async remove(t){return ne.delete(`/skills/${encodeURIComponent(t)}`)},async listForAgent(t,o){return ne.get(`/groups/${encodeURIComponent(t)}/skills/${encodeURIComponent(o)}`)},async bind(t,o,m,S){return ne.post(`/groups/${encodeURIComponent(t)}/skills/${encodeURIComponent(o)}/bind`,{skillName:m,createdBy:S})},async unbind(t,o,m){return ne.delete(`/groups/${encodeURIComponent(t)}/skills/${encodeURIComponent(o)}/bind/${encodeURIComponent(m)}`)},async listBindings(t){return ne.get(`/groups/${encodeURIComponent(t)}/skill-bindings`)},async listAllBindings(t={}){const o=new URLSearchParams;t.groupId&&o.set("groupId",t.groupId),t.agentName&&o.set("agentName",t.agentName);const m=o.toString();return ne.get(`/skills/bindings/all${m?`?${m}`:""}`)},async promoteMemory(t,o){return ne.post(`/memory/${encodeURIComponent(t)}/promote-to-skill`,o)}},ya="_body_e6g56_1",xa="_field_e6g56_5",ba="_label_e6g56_9",Sa="_nameInputWrap_e6g56_18",Ca="_dirInputWrap_e6g56_19",wa="_inputPrefix_e6g56_36",ja="_nameInput_e6g56_18",ka="_dirInput_e6g56_19",Ea="_clearBtn_e6g56_101",Na="_hint_e6g56_123",Ra="_hintIcon_e6g56_133",La="_summary_e6g56_150",Ta="_summaryRow_e6g56_158",Ia="_summaryLabel_e6g56_171",Aa="_summaryValue_e6g56_178",Da="_summaryValueEmpty_e6g56_186",Ba="_footerActions_e6g56_192",Ma="_footerRight_e6g56_202",be={body:ya,field:xa,label:ba,nameInputWrap:Sa,dirInputWrap:Ca,inputPrefix:wa,nameInput:ja,dirInput:ka,clearBtn:Ea,hint:Na,hintIcon:Ra,summary:La,summaryRow:Ta,summaryLabel:Ia,summaryValue:Aa,summaryValueEmpty:Da,footerActions:Ba,footerRight:Ma};function Cs(t){if(!t)return[];try{const o=JSON.parse(t);return Array.isArray(o)?o.filter(m=>!!m&&typeof m=="object"&&typeof m.id=="string"&&typeof m.url=="string"&&typeof m.mountPath=="string"):[]}catch{return[]}}function $a({open:t,groupId:o,groupName:m,groupWorkingDir:S,groupGuidancePrompt:j,groupRepoUrl:E,groupRepoDefaultBranch:b,groupExtraRepos:n,groupWorktreeMode:a,memberAgentNames:d,onClose:h,onSaveName:c,onSaveWorkingDir:f,onSaveGuidancePrompt:v,onSaveRepo:y}){const[u,i]=g.useState(m),[r,s]=g.useState(S||""),[l,_]=g.useState(j||""),[x,C]=g.useState(E||""),[k,p]=g.useState(b||""),[w,R]=g.useState(Cs(n).map(ee=>({id:ee.id,url:ee.url,branch:ee.branch||""}))),[T,M]=g.useState(a==="issue"?"issue":"group"),[N,I]=g.useState(!1),z=g.useRef(null),G=(ee,ce,he)=>{R(pe=>pe.map((Ne,Ue)=>Ue===ee?{...Ne,[ce]:he}:Ne))},H=()=>R(ee=>[...ee,{id:"",url:"",branch:""}]),V=ee=>R(ce=>ce.filter((he,pe)=>pe!==ee));g.useEffect(()=>{t&&(i(m),s(S||""),_(j||""),C(E||""),p(b||""),R(Cs(n).map(ee=>({id:ee.id,url:ee.url,branch:ee.branch||""}))),M(a==="issue"?"issue":"group"),requestAnimationFrame(()=>{var ee,ce;(ee=z.current)==null||ee.focus(),(ce=z.current)==null||ce.select()}))},[t,m,S,j,E,b,n,a]);const L=u.trim(),A=L!==m.trim(),B=r.trim(),P=B!==(S||"").trim(),U=l.trim(),Z=U!==(j||"").trim(),oe=x.trim(),K=k.trim(),$=(E||"").trim(),D=(b||"").trim(),q=Cs(n),J=a==="issue"?"issue":"group",O=JSON.stringify(w.map(ee=>({id:ee.id.trim(),url:ee.url.trim(),branch:ee.branch.trim()}))),X=JSON.stringify(q.map(ee=>({id:ee.id,url:ee.url,branch:ee.branch||""}))),F=oe!==$||K!==D||O!==X||T!==J,W=A||P||Z||F,re=()=>{if(A&&L&&c(L),P&&f(B||null),Z&&v(U||null),F){const ce=w.filter(he=>he.id.trim()&&he.url.trim()).map(he=>({id:he.id.trim(),url:he.url.trim(),branch:he.branch.trim()||void 0,mountPath:`__repos/${he.id.trim()}`}));y({repoUrl:oe||null,repoDefaultBranch:K||null,extraRepos:ce.length>0?ce:null,worktreeMode:T})}(A||P||Z||F)&&h()},ae=ee=>{ee.key==="Enter"&&!ee.shiftKey?(ee.preventDefault(),re()):ee.key==="Escape"&&(ee.preventDefault(),h())};return e.jsxs(De,{open:t,title:"群设置",onClose:h,footer:e.jsxs("div",{className:be.footerActions,children:[e.jsx("div",{}),e.jsxs("div",{className:be.footerRight,children:[e.jsx(ie,{variant:"secondary",size:"md",onClick:h,children:"取消"}),e.jsx(ie,{variant:"primary",size:"md",onClick:re,disabled:!W,children:"保存"})]})]}),children:[e.jsxs("div",{className:be.body,children:[e.jsxs("div",{className:be.field,children:[e.jsx("label",{className:be.label,htmlFor:"group-settings-name",children:"群名称"}),e.jsxs("div",{className:be.nameInputWrap,children:[e.jsx("span",{className:be.inputPrefix,children:"💬"}),e.jsx("input",{id:"group-settings-name",ref:z,type:"text",value:u,onChange:ee=>i(ee.target.value),onKeyDown:ae,placeholder:"输入群名称",className:be.nameInput,spellCheck:!1,autoComplete:"off"}),u&&e.jsx("button",{type:"button",className:be.clearBtn,onClick:()=>{var ee;i(""),(ee=z.current)==null||ee.focus()},title:"清空","aria-label":"清空",children:"✕"})]})]}),e.jsxs("div",{className:be.field,children:[e.jsx("label",{className:be.label,htmlFor:"group-settings-dir",children:"工作目录"}),e.jsxs("div",{className:be.dirInputWrap,children:[e.jsx("span",{className:be.inputPrefix,children:"📂"}),e.jsx("input",{id:"group-settings-dir",type:"text",value:r,onChange:ee=>s(ee.target.value),onKeyDown:ae,placeholder:"例如 ~/code/my-repo 或 /Users/me/work",className:be.dirInput,spellCheck:!1,autoComplete:"off"}),r&&e.jsx("button",{type:"button",className:be.clearBtn,onClick:()=>{var ee;s(""),(ee=z.current)==null||ee.focus()},title:"清空","aria-label":"清空",children:"✕"})]}),e.jsxs("p",{className:be.hint,children:[e.jsx("span",{className:be.hintIcon,children:"💡"}),e.jsxs("span",{children:["支持 ",e.jsx("code",{children:"~/"})," 展开;必须是已存在的目录。留空保存等同于清除设置。"]})]})]}),e.jsxs("div",{className:be.field,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("label",{className:be.label,htmlFor:"group-settings-guidance",children:"群指导 prompt"}),e.jsx("button",{type:"button",onClick:()=>I(!0),style:{border:"1px solid rgba(0,0,0,0.12)",background:"transparent",color:"var(--color-navy)",borderRadius:6,padding:"2px 10px",fontSize:12,cursor:"pointer"},children:"📚 从模板选择"})]}),e.jsx(xt,{value:l,onChange:ee=>_(ee.target.value),onKeyDown:ae,placeholder:"全群一份,群内所有 agent 被唤起时拼到 prompt 上。例:本群讨论 VR 需求,所有回复聚焦用户场景;提问其他 agent 必须用 scripts/rotom-ask-with-timeout.mjs。",rows:4,spellCheck:!1,autoComplete:"off"}),e.jsxs("p",{className:be.hint,children:[e.jsx("span",{className:be.hintIcon,children:"💡"}),e.jsx("span",{children:"群级别硬约定,所有成员都会看到。留空保存等同于清除。不支持 per-member 覆盖。"})]})]}),e.jsxs("div",{className:be.field,children:[e.jsx("label",{className:be.label,htmlFor:"group-settings-repo-url",children:"内置 repo(可选)"}),e.jsx("input",{id:"group-settings-repo-url",type:"text",value:x,onChange:ee=>C(ee.target.value),onKeyDown:ae,placeholder:"如 git@github.com:org/repo.git 或 https://github.com/org/repo.git,留空则关闭 worktree 模式",className:be.dirInput,spellCheck:!1,autoComplete:"off"}),e.jsx("input",{type:"text",value:k,onChange:ee=>p(ee.target.value),onKeyDown:ae,placeholder:"默认分支(如 main/master);留空用仓库默认",className:be.dirInput,style:{marginTop:6},spellCheck:!1,autoComplete:"off"}),e.jsxs("div",{style:{marginTop:6,display:"flex",alignItems:"center",gap:8},children:[e.jsx("label",{style:{fontSize:12,color:"var(--color-slate, #888)",whiteSpace:"nowrap"},children:"worktree 模式"}),e.jsx(Fe,{value:T,onChange:ee=>M(ee.target.value),className:be.dirInput,style:{flex:1},options:[{value:"group",label:"group(群共享一个 worktree,轻量,适合单分支线性开发)"},{value:"issue",label:"issue(每 issue 独立 worktree,多分支并行)"}]})]}),e.jsxs("div",{style:{marginTop:8},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4},children:[e.jsx("span",{style:{fontSize:12,color:"var(--color-slate, #888)"},children:"额外仓库(可选)"}),e.jsx("button",{type:"button",onClick:H,style:{border:"1px solid rgba(0,0,0,0.12)",background:"transparent",color:"var(--color-navy)",borderRadius:4,padding:"2px 10px",fontSize:11,cursor:"pointer"},children:"+ 添加"})]}),w.map((ee,ce)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"110px 1fr 110px 28px",gap:6,marginBottom:6},children:[e.jsx(ge,{type:"text",size:"sm",value:ee.id,onChange:he=>G(ce,"id",he.target.value),onKeyDown:ae,placeholder:"id(如 deposit-home)",style:{fontSize:11},spellCheck:!1,autoComplete:"off"}),e.jsx(ge,{type:"text",size:"sm",value:ee.url,onChange:he=>G(ce,"url",he.target.value),onKeyDown:ae,placeholder:"URL",style:{fontSize:11},spellCheck:!1,autoComplete:"off"}),e.jsx(ge,{type:"text",size:"sm",value:ee.branch,onChange:he=>G(ce,"branch",he.target.value),onKeyDown:ae,placeholder:"分支(可空)",style:{fontSize:11},spellCheck:!1,autoComplete:"off"}),e.jsx("button",{type:"button",onClick:()=>V(ce),style:{border:"1px solid rgba(0,0,0,0.12)",background:"transparent",borderRadius:4,cursor:"pointer",fontSize:12,color:"#c00"},title:"删除",children:"✕"})]},ce)),e.jsxs("p",{style:{fontSize:11,color:"var(--color-slate, #888)",margin:"4px 2px 0"},children:["mountPath 自动 = ",e.jsx("code",{children:"repos/<id>"}),";agent 在 primary worktree 里通过该路径访问额外仓库。"]})]}),e.jsxs("p",{className:be.hint,children:[e.jsx("span",{className:be.hintIcon,children:"💡"}),e.jsxs("span",{children:["配 repo 后,该群每个 issue 在 executor 本机起独立 worktree(",e.jsx("code",{children:"<groupId>/<issueId>/repos/primary/"}),"),多分支天然隔离。同 URL 跨 group/issue 全局复用 bare clone。仅与 master 同机器的 agent 生效。"]})]})]}),e.jsxs("div",{className:be.summary,children:[e.jsxs("div",{className:be.summaryRow,children:[e.jsx("span",{className:be.summaryLabel,children:"当前名称"}),e.jsx("span",{className:be.summaryValue,children:m})]}),e.jsxs("div",{className:be.summaryRow,children:[e.jsx("span",{className:be.summaryLabel,children:"当前目录"}),e.jsx("span",{className:`${be.summaryValue} ${S?"":be.summaryValueEmpty}`,children:S||"未设置"})]}),e.jsxs("div",{className:be.summaryRow,children:[e.jsx("span",{className:be.summaryLabel,children:"当前指导"}),e.jsx("span",{className:`${be.summaryValue} ${j?"":be.summaryValueEmpty}`,children:j?`${j.slice(0,60)}${j.length>60?"…":""}`:"未设置"})]})]})]}),e.jsx(Pa,{groupId:o,memberAgentNames:d??[]}),N&&e.jsx(Ws,{open:N,groupId:o,groupName:m,memberAgentNames:d??[],onPromptApplied:ee=>_(ee),onClose:()=>I(!1)})]})}function Pa({groupId:t,memberAgentNames:o}){const{myAgentName:m,agents:S}=nt(),[j,E]=g.useState([]),[b,n]=g.useState([]),[a,d]=g.useState(null),[h,c]=g.useState(""),f=g.useMemo(()=>{const u=new Map(S.map(i=>[i.name,i]));return o.filter(i=>{var s;const r=u.get(i);return((s=r==null?void 0:r.profile)==null?void 0:s.category)!=="真人"})},[o,S]),v=()=>{Promise.all([tt.list(),tt.listBindings(t)]).then(([u,i])=>{E(u),n(i)}).catch(u=>d(u.message))};g.useEffect(()=>{v()},[t]);const y=async(u,i)=>{const r=`${u}:${i.id}`;if(!h){c(r);try{b.some(l=>l.agent_name===u&&l.skill_id===i.id)?await tt.unbind(t,u,i.name):await tt.bind(t,u,i.name,m),await v()}catch(s){d(s.message)}finally{c("")}}};return f.length===0?null:e.jsxs("div",{className:be.summary,style:{marginTop:12},children:[e.jsxs("div",{style:{marginBottom:10},children:[e.jsx("div",{className:be.summaryLabel,children:"⚡ 技能绑定(per agent)"}),e.jsx("div",{style:{fontSize:11,color:"var(--color-slate, #888)",marginTop:2,lineHeight:1.4},children:"勾选的 skill 会在该 agent 执行时注入 prompt 指针。全局 skill 在工具箱管理。"})]}),a&&e.jsx("div",{style:{color:"#c00",fontSize:12,marginBottom:6},children:a}),j.length===0?e.jsx("div",{style:{fontSize:12,color:"var(--color-slate, #888)",padding:"8px 0"},children:"暂无 skill。去工具箱「技能」tab 新建,或 `rotom memory promote-to-skill` 沉淀。"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:f.map(u=>e.jsxs("div",{style:{padding:"6px 0",borderTop:"1px solid var(--border-color-light, #eee)"},children:[e.jsx("div",{style:{fontSize:12,fontWeight:700,marginBottom:6,color:"var(--color-navy, #1a365d)"},children:u}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:j.map(i=>{const r=b.some(l=>l.agent_name===u&&l.skill_id===i.id),s=`${u}:${i.id}`;return e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,padding:"4px 10px",border:`1px solid ${r?"var(--color-wise-green, #2f7a2f)":"var(--border-color-light, #ddd)"}`,borderRadius:6,cursor:h===s?"wait":"pointer",userSelect:"none",lineHeight:1.2,background:r?"rgba(47, 122, 47, 0.08)":"transparent",color:r?"var(--color-wise-green, #2f7a2f)":"var(--color-navy, #1a365d)",opacity:h===s?.5:1,transition:"background 0.15s, border-color 0.15s, color 0.15s"},children:[e.jsx(Dt,{checked:r,onChange:()=>y(u,i),disabled:h===s,name:i.name}),e.jsx("span",{onClick:()=>y(u,i),style:{cursor:h===s?"wait":"pointer"},children:i.name})]},i.id)})})]},u))})]})}const Oa="_sidebarWrap_wghl5_1",Ha="_sidebar_wghl5_1",Fa="_resizer_wghl5_21",za="_resizerActive_wghl5_35",Wa="_topBar_wghl5_43",Ua="_sidebarZen_wghl5_53",qa="_brand_wghl5_61",Va="_logoImg_wghl5_74",Ga="_logoText_wghl5_88",Ka="_nav_wghl5_98",Ja="_navItem_wghl5_111",Xa="_navItemActive_wghl5_141",Za="_navIcon_wghl5_147",Ya="_navLabel_wghl5_152",Qa="_navCompact_wghl5_157",el="_navToggleBtn_wghl5_177",tl="_navDivider_wghl5_211",sl="_section_wghl5_219",rl="_sectionGroup_wghl5_224",il="_sectionHeader_wghl5_230",nl="_sectionTitle_wghl5_238",ol="_divider_wghl5_249",al="_hint_wghl5_255",ll="_createBtn_wghl5_263",cl="_groupList_wghl5_286",dl="_groupItem_wghl5_294",hl="_active_wghl5_310",ul="_pinned_wghl5_314",_l="_groupBody_wghl5_322",fl="_groupName_wghl5_327",pl="_groupNameText_wghl5_338",ml="_memberCount_wghl5_345",gl="_moreDropdown_wghl5_356",vl="_pinnedMark_wghl5_361",yl="_typeBadge_wghl5_367",xl="_typePatrol_wghl5_379",bl="_typeUnicast_wghl5_385",Sl="_typeDirect_wghl5_391",Cl="_pinBtn_wghl5_397",wl="_pinBtnActive_wghl5_423",jl="_archivedMark_wghl5_429",kl="_archived_wghl5_429",El="_groupMeta_wghl5_450",Nl="_directList_wghl5_457",Rl="_directItem_wghl5_465",Ll="_directInfo_wghl5_484",Tl="_directName_wghl5_489",Il="_directStatusDot_wghl5_503",Al="_newConvBtn_wghl5_512",Dl="_showMoreBtn_wghl5_538",Bl="_directSubtext_wghl5_562",Ml="_convThreadList_wghl5_569",$l="_convThreadItem_wghl5_575",Pl="_convThreadLabel_wghl5_599",Ol="_convThreadTime_wghl5_603",Hl="_userInfo_wghl5_609",Fl="_userName_wghl5_627",zl="_footerBtn_wghl5_639",Wl="_zenBtn_wghl5_655",Ul="_zenBody_wghl5_677",ql="_zenList_wghl5_696",Vl="_zenDivider_wghl5_707",Gl="_zenItem_wghl5_715",Kl="_zenItemActive_wghl5_739",Jl="_zenLetterAvatar_wghl5_743",Xl="_archiveBtn_wghl5_785",Zl="_archiveBtnActive_wghl5_811",Yl="_tabBar_wghl5_818",Ql="_tab_wghl5_818",ec="_tabActive_wghl5_871",tc="_tabCount_wghl5_877",sc="_starredMark_wghl5_897",rc="_starBtn_wghl5_903",ic="_starBtnActive_wghl5_929",nc="_starred_wghl5_897",oc="_dmAvatarRow_wghl5_940",ac="_dmAvatarItem_wghl5_948",lc="_dmAvatarActive_wghl5_967",cc="_dmAvatarDot_wghl5_976",dc="_dmAvatarBadge_wghl5_988",hc="_dmAvatars_wghl5_1007",uc="_moreWrap_wghl5_1020",_c="_moreBtn_wghl5_1027",fc="_moreItem_wghl5_1075",pc="_moreItemDanger_wghl5_1096",mc="_moreDivider_wghl5_1104",_e={sidebarWrap:Oa,sidebar:Ha,resizer:Fa,resizerActive:za,topBar:Wa,sidebarZen:Ua,brand:qa,logoImg:Va,logoText:Ga,nav:Ka,navItem:Ja,navItemActive:Xa,navIcon:Za,navLabel:Ya,navCompact:Qa,navToggleBtn:el,navDivider:tl,section:sl,sectionGroup:rl,sectionHeader:il,sectionTitle:nl,divider:ol,hint:al,createBtn:ll,groupList:cl,groupItem:dl,active:hl,pinned:ul,groupBody:_l,groupName:fl,groupNameText:pl,memberCount:ml,moreDropdown:gl,pinnedMark:vl,typeBadge:yl,typePatrol:xl,typeUnicast:bl,typeDirect:Sl,pinBtn:Cl,pinBtnActive:wl,archivedMark:jl,archived:kl,groupMeta:El,directList:Nl,directItem:Rl,directInfo:Ll,directName:Tl,directStatusDot:Il,newConvBtn:Al,showMoreBtn:Dl,directSubtext:Bl,convThreadList:Ml,convThreadItem:$l,convThreadLabel:Pl,convThreadTime:Ol,userInfo:Hl,userName:Fl,footerBtn:zl,zenBtn:Wl,zenBody:Ul,zenList:ql,zenDivider:Vl,zenItem:Gl,zenItemActive:Kl,zenLetterAvatar:Jl,archiveBtn:Xl,archiveBtnActive:Zl,tabBar:Yl,tab:Ql,tabActive:ec,tabCount:tc,starredMark:sc,starBtn:rc,starBtnActive:ic,starred:nc,dmAvatarRow:oc,dmAvatarItem:ac,dmAvatarActive:lc,dmAvatarDot:cc,dmAvatarBadge:dc,dmAvatars:hc,moreWrap:uc,moreBtn:_c,moreItem:fc,moreItemDanger:pc,moreDivider:mc},gc=[{id:"agents",label:"员工管理",icon:"👥",path:"/dashboard/agents"},{id:"groups",label:"对话",icon:"💬",path:"/dashboard/groups"},{id:"kanban",label:"看板",icon:"📋",path:"/dashboard/kanban"},{id:"teams",label:"团队",icon:"🌐",path:"/dashboard/teams"},{id:"toolbox",label:"工具箱",icon:"🧰",path:"/dashboard/toolbox"}],or=56,vc=280,yc=200,xc=520;function bc(t){return t?t==="patrol"?{label:"巡检",title:"巡检群:定时自动派单",cls:"typePatrol"}:t==="patrol-link"?{label:"链接",title:"链接分类巡检群:定时自动归类采集到的链接",cls:"typePatrol"}:t==="a2a_direct"?{label:"单播",title:"单播群(unicast):消息只入库不广播,需 --need-reply 点名",cls:"typeUnicast"}:t==="direct"?{label:"单聊",title:"1 对 1 对话",cls:"typeDirect"}:null:null}function ws(t){return t.type==="patrol"||t.type==="patrol-link"||t.type==="a2a_direct"}const Sc={normal:"普通",functional:"功能",starred:"标记",archived:"已归档"},Cc={normal:"暂无对话,点击「创建对话」开始",functional:"暂无功能型群",starred:"暂无标记群",archived:"暂无已归档对话"};function wc({width:t,onWidthChange:o}){var F;const{zenMode:m,toggleZenMode:S}=Kr(),j=Ei("/dashboard/groups/:groupId/*"),E=j==null?void 0:j.params.groupId,{agents:b,groups:n,myAgentName:a,selectGroup:d,openCreateGroupModal:h,openConfigModal:c,updateGroupName:f,updateGroupGuidancePrompt:v,updateGroupRepo:y,updateGroupWorkingDir:u,toggleGroupPinned:i,toggleGroupArchived:r,toggleGroupStarred:s,deleteGroup:l}=nt(),[_,x]=g.useState(!1),[C,k]=g.useState(()=>{try{const W=localStorage.getItem("rotom-nav-compact");return W===null?(localStorage.setItem("rotom-nav-compact","1"),!0):W==="1"}catch{return!1}}),[p,w]=g.useState(null),R=g.useRef({}),T=g.useRef(null),[M,N]=g.useState(!1),[I,z]=g.useState(null),[G,H]=g.useState(null),V=g.useRef(null),[L,A]=g.useState("normal");g.useEffect(()=>{const W=T.current;if(!W)return;const re=()=>{N(W.scrollWidth-W.clientWidth-W.scrollLeft>1)};re(),W.addEventListener("scroll",re,{passive:!0});const ae=new ResizeObserver(re);ae.observe(W);const ee=window.setTimeout(re,50);return()=>{W.removeEventListener("scroll",re),ae.disconnect(),window.clearTimeout(ee)}},[L,n.length]),g.useEffect(()=>{if(!p)return;const W=()=>{w(null),z(null)},re=setTimeout(()=>document.addEventListener("mousedown",W),0);return()=>{clearTimeout(re),document.removeEventListener("mousedown",W)}},[p]),g.useEffect(()=>{if(!p)return;const W=()=>{w(null),z(null)};return window.addEventListener("scroll",W,!0),window.addEventListener("resize",W),()=>{window.removeEventListener("scroll",W,!0),window.removeEventListener("resize",W)}},[p]);const B=()=>{k(W=>{const re=!W;try{localStorage.setItem("rotom-nav-compact",re?"1":"0")}catch{}return re})},P=E||"",U=m,Z=n.filter(W=>!W.name.startsWith("__dm__:")&&!W.archived_at&&!W.starred_at&&!ws(W)).slice().sort((W,re)=>W.pinned_at&&re.pinned_at?re.pinned_at.localeCompare(W.pinned_at):W.pinned_at?-1:re.pinned_at?1:(re.last_message_at||re.created_at).localeCompare(W.last_message_at||W.created_at)),oe=n.filter(W=>!W.name.startsWith("__dm__:")&&!W.archived_at&&ws(W)).slice().sort((W,re)=>{const ae=he=>he==="patrol"?0:he==="patrol-link"?1:he==="a2a_direct"?2:9,ee=ae(W.type),ce=ae(re.type);return ee!==ce?ee-ce:(re.created_at||"").localeCompare(W.created_at||"")}),K=n.filter(W=>!W.name.startsWith("__dm__:")&&W.starred_at&&!W.archived_at&&!ws(W)).slice().sort((W,re)=>(re.starred_at||"").localeCompare(W.starred_at||"")),$=n.filter(W=>W.archived_at).slice().sort((W,re)=>(re.created_at||"").localeCompare(W.created_at||"")),D=Z,q={normal:Z.length,functional:oe.length,starred:K.length,archived:$.length},J=(()=>{switch(L){case"normal":return Z;case"functional":return oe;case"starred":return K;case"archived":return $}})(),O=q.normal===0&&q.functional===0&&q.starred===0&&q.archived===0;g.useEffect(()=>{if(!_)return;const W=U?or:yc,re=ee=>{const ce=V.current;if(!ce)return;const he=Math.min(xc,Math.max(W,ce.w+(ee.clientX-ce.x)));o(he)},ae=()=>x(!1);return window.addEventListener("mousemove",re),window.addEventListener("mouseup",ae),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{window.removeEventListener("mousemove",re),window.removeEventListener("mouseup",ae),document.body.style.cursor="",document.body.style.userSelect=""}},[_,U,o]);const X=U?or:vc;return e.jsxs("div",{className:_e.sidebarWrap,style:{width:`${t}px`},children:[e.jsxs("aside",{className:`${_e.sidebar} ${U?_e.sidebarZen:""}`,style:{width:`${t}px`},children:[e.jsxs("div",{className:_e.topBar,children:[!U&&a?e.jsxs("button",{className:_e.userInfo,onClick:c,title:"切换身份",children:[e.jsx(At,{name:a,src:((F=b.find(W=>W.name===a))==null?void 0:F.avatar_url)??void 0,size:28}),e.jsx("span",{className:_e.userName,children:a})]}):e.jsxs("div",{className:_e.brand,children:[e.jsx("img",{src:"/dashboard/rotom-avatar.png",alt:"Rotom",className:_e.logoImg}),!U&&e.jsx("span",{className:_e.logoText,children:"Rotom"})]}),e.jsx("button",{className:_e.zenBtn,onClick:S,title:U?"展开侧边栏":"禅模式",children:U?"▶":"◀"})]}),e.jsxs("nav",{className:`${_e.nav} ${!U&&C?_e.navCompact:""}`,children:[gc.map(W=>e.jsxs(Hr,{to:W.path,title:W.label,className:({isActive:re})=>`${_e.navItem} ${re?_e.navItemActive:""}`,children:[e.jsx("span",{className:_e.navIcon,children:W.icon}),!U&&!C&&e.jsx("span",{className:_e.navLabel,children:W.label})]},W.id)),!U&&e.jsx("button",{type:"button",className:_e.navToggleBtn,onClick:B,title:C?"展开导航":"收起导航为一行",children:C?"⇲":"⇱"})]}),!U&&e.jsx("hr",{className:_e.navDivider}),U?e.jsx("div",{className:_e.zenBody,children:D.length>0&&e.jsx("ul",{className:_e.zenList,children:D.map(W=>e.jsx("li",{children:e.jsx("button",{type:"button",className:`${_e.zenItem} ${P===W.id?_e.zenItemActive:""}`,onClick:()=>d(W.id),title:W.name,children:e.jsx("span",{className:_e.zenLetterAvatar,style:{background:Zr(W.name)},children:(W.name.charAt(0)||"#").toUpperCase()})})},W.id))})}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:`${_e.section} ${_e.sectionGroup}`,children:[e.jsxs("div",{className:_e.sectionHeader,children:[e.jsx("div",{ref:T,className:_e.tabBar,"data-has-more":M||void 0,children:["normal","functional","starred","archived"].map(W=>e.jsxs("button",{type:"button",className:`${_e.tab} ${L===W?_e.tabActive:""}`,onClick:()=>A(W),children:[Sc[W],e.jsx("span",{className:_e.tabCount,children:q[W]})]},W))}),e.jsx("button",{onClick:h,className:_e.createBtn,children:"+ 创建"})]}),O?e.jsx("div",{className:_e.hint,children:"暂无对话,点击「创建对话」开始"}):J.length===0?e.jsx("div",{className:_e.hint,children:Cc[L]}):e.jsx("ul",{className:_e.groupList,children:J.map(W=>{const re=!!W.pinned_at,ae=!!W.starred_at,ee=!!W.archived_at,ce=bc(W.type),he=ee?{emoji:"🗄️",cls:"archivedMark",title:"已归档"}:ae?{emoji:"⭐",cls:"starredMark",title:"标记"}:re?{emoji:"📌",cls:"pinnedMark",title:"已置顶"}:null;return e.jsxs("li",{className:`${_e.groupItem} ${P===W.id?_e.active:""} ${re?_e.pinned:""} ${ae?_e.starred:""} ${ee?_e.archived:""}`,onClick:()=>d(W.id),children:[e.jsx("div",{className:_e.groupBody,children:e.jsxs("div",{className:_e.groupName,children:[he&&e.jsx("span",{className:_e[he.cls],title:he.title,children:he.emoji}),e.jsx("span",{className:_e.groupNameText,children:W.name}),ce&&e.jsx("span",{className:`${_e.typeBadge} ${_e[ce.cls]}`,title:ce.title,children:ce.label}),W.type!=="direct"&&e.jsx("span",{className:_e.memberCount,children:`· ${W.member_count||0} 位`})]})}),L==="starred"&&e.jsx("button",{type:"button",className:_e.starBtn,onClick:pe=>{pe.stopPropagation(),s(W.id,!1)},title:"取消标记",children:"取消标记"}),L==="archived"&&e.jsx("button",{type:"button",className:`${_e.archiveBtn} ${_e.archiveBtnActive}`,onClick:pe=>{pe.stopPropagation(),r(W.id,!1)},title:"取消归档",children:"取消归档"}),e.jsxs("div",{className:_e.moreWrap,children:[e.jsx("button",{ref:pe=>{R.current[W.id]=pe},type:"button",className:_e.moreBtn,onClick:pe=>{if(pe.stopPropagation(),p===W.id){w(null),z(null);return}const Ne=R.current[W.id];if(Ne){const Ue=Ne.getBoundingClientRect();z({top:Ue.bottom+4,left:Math.max(8,Ue.right-140)})}w(W.id)},title:"更多操作",children:"···"}),p===W.id&&I&&Fr.createPortal(e.jsxs("div",{className:_e.moreDropdown,style:{position:"fixed",top:I.top,left:I.left},onMouseDown:pe=>pe.stopPropagation(),children:[e.jsx("button",{type:"button",className:_e.moreItem,onClick:pe=>{pe.stopPropagation(),w(null),z(null),H(W.id)},children:"⚙️ 设置"}),e.jsx("button",{type:"button",className:_e.moreItem,onClick:pe=>{pe.stopPropagation(),i(W.id,!re),w(null),z(null)},children:re?"📌 取消置顶":"📌 置顶"}),e.jsx("button",{type:"button",className:_e.moreItem,onClick:pe=>{pe.stopPropagation(),s(W.id,!ae),w(null),z(null)},children:ae?"⭐ 取消标记":"⭐ 标记"}),e.jsx("button",{type:"button",className:_e.moreItem,onClick:pe=>{pe.stopPropagation(),r(W.id,!ee),w(null),z(null)},children:ee?"🗄️ 取消归档":"🗄️ 归档"}),e.jsx("div",{className:_e.moreDivider}),e.jsx("button",{type:"button",className:`${_e.moreItem} ${_e.moreItemDanger}`,onClick:pe=>{pe.stopPropagation(),w(null),z(null),l(W.id)},children:"🗑️ 删除对话"})]}),document.body)]})]},W.id)})})]})})]}),G&&(()=>{const W=n.find(re=>re.id===G);return W?e.jsx($a,{open:!0,groupId:W.id,groupName:W.name,groupWorkingDir:W.working_dir,groupGuidancePrompt:W.guidance_prompt,groupRepoUrl:W.repo_url,groupRepoDefaultBranch:W.repo_default_branch,groupExtraRepos:W.extra_repos,groupWorktreeMode:W.worktree_mode,memberAgentNames:(W.members??[]).map(re=>re.agent_name),onClose:()=>H(null),onSaveName:re=>f(W.id,re),onSaveWorkingDir:re=>u(W.id,re),onSaveGuidancePrompt:re=>v(W.id,re),onSaveRepo:re=>y(W.id,re)}):null})(),e.jsx("div",{className:`${_e.resizer} ${_?_e.resizerActive:""}`,onMouseDown:W=>{V.current={x:W.clientX,w:t},x(!0)},onDoubleClick:()=>o(X),title:"拖拽调整宽度,双击恢复默认"})]})}const jc="_visitorBanner_zw5tn_1",kc="_visitorIcon_zw5tn_12",Ec="_visitorTitle_zw5tn_16",Nc="_visitorText_zw5tn_22",ns={visitorBanner:jc,visitorIcon:kc,visitorTitle:Ec,visitorText:Nc};function Rc({groupName:t}){return e.jsxs("div",{role:"status",className:ns.visitorBanner,children:[e.jsx("span",{className:ns.visitorIcon,"aria-hidden":!0,children:"👁"}),e.jsx("span",{className:ns.visitorTitle,children:"访客模式"}),e.jsxs("span",{className:ns.visitorText,children:[t?`正在只读查看「${t}」`:"正在只读查看分享内容",",无法发送消息或修改任何内容"]})]})}const Lc="_shell_9m7rq_1",Tc="_shellInner_9m7rq_11",Ic="_identityBanner_9m7rq_20",Ac="_identityBannerTitle_9m7rq_33",Dc="_identityBannerText_9m7rq_40",Bc="_identityBannerBtn_9m7rq_45",Mc="_main_9m7rq_163",$c="_mainZen_9m7rq_172",Pc="_mainFullBleed_9m7rq_176",gt={shell:Lc,shellInner:Tc,identityBanner:Ic,identityBannerTitle:Ac,identityBannerText:Dc,identityBannerBtn:Bc,main:Mc,mainZen:$c,mainFullBleed:Pc},os=56,ar=280;function Oc({children:t}){const{zenMode:o}=Kr(),{myAgentName:m,openConfigModal:S}=nt(),{isVisitor:j}=qt(),E=zr(),b=E.pathname.startsWith("/dashboard/groups"),n=E.pathname.startsWith("/dashboard/toolbox"),a=/^\/dashboard\/groups\/[^/]+\/issues-single(\/|$)/.test(E.pathname),d=o?"sidebar_width_zen":"sidebar_width_normal",[h,c]=g.useState(()=>{const y=localStorage.getItem(d);if(y!==null){const u=Number(y);if(Number.isFinite(u))return Math.max(o?os:0,u)}return o?os:ar});g.useEffect(()=>{const y=localStorage.getItem(d);if(y!==null){const u=Number(y);if(Number.isFinite(u)){c(Math.max(o?os:0,u));return}}c(o?os:ar)},[o,d]);const f=g.useCallback(y=>{c(y),localStorage.setItem(d,String(y))},[d]),v=!m&&!j;return e.jsxs("div",{className:gt.shell,children:[j&&e.jsx(Rc,{}),v&&e.jsxs("div",{role:"status",className:gt.identityBanner,children:[e.jsx("span",{className:gt.identityBannerTitle,children:"⚠️ 还没绑定身份"}),e.jsx("span",{className:gt.identityBannerText,children:"你现在是匿名访问,需要先挑一个员工身份才能用。"}),e.jsx("button",{type:"button",onClick:S,className:gt.identityBannerBtn,children:"选择身份"})]}),e.jsxs("div",{className:gt.shellInner,children:[!j&&!a&&e.jsx(wc,{width:h,onWidthChange:f}),e.jsx("main",{className:`${gt.main} ${o?gt.mainZen:""} ${b||n?gt.mainFullBleed:""}`,children:t})]})]})}const us={async list(){return ne.get("/domains")},async create(t){return ne.post("/domains",t)},async update(t,o){return ne.put(`/domains/${t}`,o)},async delete(t){return ne.delete(`/domains/${t}`)}},js={async list(){return ne.get("/cross-domain")},async create(t){return ne.post("/cross-domain",t)},async delete(t,o){return ne.delete(`/cross-domain?from=${encodeURIComponent(t)}&to=${encodeURIComponent(o)}`)}};function Hc(){const[t,o]=g.useState(null);return g.useEffect(()=>{let m=!1;return Promise.all([fetch("/api/identity").then(S=>S.json()),fetch("/api/teams").then(S=>S.json())]).then(([S,j])=>{var a;if(m||S.role!=="member")return;const E=j[0];if(!E||!((a=E.coordEndpoints)!=null&&a.length))return;const n=E.coordEndpoints[0].replace(/^wss:/,"https:").replace(/^ws:/,"http:").replace(/\/$/,"")+"/dashboard/agents";o({teamName:E.name,coordDashboardUrl:n})}).catch(()=>{}),()=>{m=!0}},[]),t?e.jsxs("a",{href:t.coordDashboardUrl,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:8,padding:"8px 16px",marginBottom:12,background:"var(--color-primary-bg, #eef2ff)",border:"1px solid var(--color-primary, #6366f1)",borderRadius:6,color:"var(--color-primary, #6366f1)",textDecoration:"none",fontSize:13,fontWeight:500},children:[e.jsx("span",{style:{fontSize:16},children:"🌐"}),e.jsxs("span",{children:["已接入「",t.teamName,"」大团队"]}),e.jsx("span",{style:{marginLeft:"auto",opacity:.8},children:"查看大团队 dashboard →"})]}):null}function Yr({data:t,loading:o,error:m,isEmpty:S,onRetry:j,loadingFallback:E,errorFallback:b,emptyFallback:n,children:a}){if(o)return e.jsx(e.Fragment,{children:E??e.jsx(Fc,{})});if(m){const d=j??(()=>{});return e.jsx(e.Fragment,{children:b?b(m,d):e.jsx(zc,{error:m,onRetry:d})})}return t==null?e.jsx(e.Fragment,{children:n??e.jsx(lr,{})}):S&&S(t)?e.jsx(e.Fragment,{children:n??e.jsx(lr,{})}):e.jsx(e.Fragment,{children:a(t)})}function Fc(){return e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--color-ink-muted, #666)"},children:"Loading…"})}function zc({error:t,onRetry:o}){const m=typeof t=="string"?t:t.message;return e.jsxs("div",{style:{padding:"24px",textAlign:"center"},children:[e.jsx("div",{style:{color:"var(--color-error, #c33)",marginBottom:"12px"},children:m}),e.jsx("button",{type:"button",onClick:o,children:"重试"})]})}function lr(){return e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--color-ink-muted, #666)"},children:"暂无数据"})}function Wc(){const{agents:t,agentsLoading:o,agentsError:m,loadAgents:S}=nt();return{agents:t,loading:o,error:m,refetch:()=>S(!0)}}function Uc(){const{agents:t,loading:o,error:m,refetch:S}=Wc(),[j,E]=g.useState("all"),[b,n]=g.useState("all"),[a,d]=g.useState(""),h=t.filter(f=>{var v,y;if(j==="online"&&f.status!=="online"||b!=="all"&&f.domain!==b)return!1;if(a){const u=a.toLowerCase();return f.name.toLowerCase().includes(u)||((v=f.description)==null?void 0:v.toLowerCase().includes(u))||((y=f.domain)==null?void 0:y.toLowerCase().includes(u))}return!0}),c=[...new Set(t.map(f=>f.domain).filter(Boolean))].sort();return{agents:h,filteredAgents:h,allAgents:t,loading:o,error:m,refetch:S,filters:{filter:j,setFilter:E,domainFilter:b,setDomainFilter:n,searchQuery:a,setSearchQuery:d},domains:c}}const qc="_container_nyca5_1",Vc="_group_nyca5_10",Gc="_chip_nyca5_17",Kc="_active_nyca5_39",Jc="_search_nyca5_48",Xc="_viewBtn_nyca5_77",rt={container:qc,group:Vc,chip:Gc,active:Kc,search:Jc,viewBtn:Xc};function Zc({filter:t,onFilterChange:o,searchQuery:m,onSearchChange:S,domains:j,selectedDomain:E,onSelectDomain:b,onAddDomain:n,onEditDomain:a,onDeleteDomain:d,onSelectRules:h,isRulesView:c,viewMode:f,onViewModeChange:v,onAddAgent:y}){return e.jsxs("div",{className:rt.container,children:[e.jsxs("div",{className:rt.group,children:[e.jsx("button",{className:`${rt.chip} ${t==="all"?rt.active:""}`,onClick:()=>o("all"),children:"全部"}),e.jsx("button",{className:`${rt.chip} ${t==="online"?rt.active:""}`,onClick:()=>o("online"),children:"在线"})]}),e.jsx("div",{className:rt.group,children:e.jsx(ge,{type:"search",value:m,onChange:u=>S(u.target.value),placeholder:"搜索员工...",className:rt.search})}),e.jsxs("div",{className:rt.group,children:[e.jsx("button",{className:`${rt.viewBtn} ${f==="table"?rt.active:""}`,onClick:()=>v("table"),title:"表格视图",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M0 3h16v2H0V3zm0 4h16v2H0V7zm0 4h16v2H0v-2z"})})}),e.jsx("button",{className:`${rt.viewBtn} ${f==="topology"?rt.active:""}`,onClick:()=>v("topology"),title:"拓扑视图",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:[e.jsx("circle",{cx:"8",cy:"4",r:"2"}),e.jsx("circle",{cx:"3",cy:"12",r:"2"}),e.jsx("circle",{cx:"13",cy:"12",r:"2"}),e.jsx("path",{d:"M8 6v3M4.5 10.5l2.5-2.5M8.5 8l2.5 2.5",stroke:"currentColor",strokeWidth:"1",fill:"none"})]})})]}),y&&e.jsx("div",{className:rt.group,children:e.jsxs(ie,{variant:"primary",size:"sm",onClick:y,title:"添加员工",children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"6",cy:"5",r:"2.5"}),e.jsx("path",{d:"M1.5 13.5c0-2.2 2-4 4.5-4s4.5 1.8 4.5 4"}),e.jsx("line",{x1:"13",y1:"5",x2:"13",y2:"9"}),e.jsx("line",{x1:"11",y1:"7",x2:"15",y2:"7"})]}),"添加员工"]})})]})}const Yc="_container_gkj88_1",Qc="_card_gkj88_8",ed="_value_gkj88_31",td="_online_gkj88_40",sd="_offline_gkj88_44",rd="_error_gkj88_48",id="_label_gkj88_52",We={container:Yc,card:Qc,value:ed,online:td,offline:sd,error:rd,label:id};function nd({agents:t}){const o=t.filter(b=>b.status==="online").length,m=t.length-o,S=t.reduce((b,n)=>{var a;return b+(((a=n.message_stats)==null?void 0:a.sent)||0)},0),j=t.reduce((b,n)=>{var a;return b+(((a=n.message_stats)==null?void 0:a.received)||0)},0),E=t.reduce((b,n)=>{var a;return b+(((a=n.message_stats)==null?void 0:a.failed)||0)},0);return e.jsxs("div",{className:We.container,children:[e.jsxs("div",{className:We.card,children:[e.jsx("div",{className:We.value,children:t.length}),e.jsx("div",{className:We.label,children:"总员工数"})]}),e.jsxs("div",{className:We.card,children:[e.jsx("div",{className:`${We.value} ${We.online}`,children:o}),e.jsx("div",{className:We.label,children:"在线"})]}),e.jsxs("div",{className:We.card,children:[e.jsx("div",{className:`${We.value} ${We.offline}`,children:m}),e.jsx("div",{className:We.label,children:"离线"})]}),e.jsxs("div",{className:We.card,children:[e.jsx("div",{className:We.value,children:S}),e.jsx("div",{className:We.label,children:"总发送"})]}),e.jsxs("div",{className:We.card,children:[e.jsx("div",{className:We.value,children:j}),e.jsx("div",{className:We.label,children:"总接收"})]}),E>0&&e.jsxs("div",{className:We.card,children:[e.jsx("div",{className:`${We.value} ${We.error}`,children:E}),e.jsx("div",{className:We.label,children:"失败"})]})]})}const od="_container_1kch4_1",ad="_empty_1kch4_5",ld="_hint_1kch4_14",cd="_tableWrapper_1kch4_20",dd="_table_1kch4_20",hd="_detailCell_1kch4_69",ud="_online_1kch4_81",_d="_offline_1kch4_85",fd="_name_1kch4_90",pd="_avatar_1kch4_96",md="_badge_1kch4_110",gd="_status_1kch4_120",vd="_description_1kch4_140",yd="_endpoint_1kch4_145",xd="_truncate_1kch4_149",bd="_deleteBtn_1kch4_157",Sd="_editBtn_1kch4_177",Cd="_actions_1kch4_195",wd="_detailRow_1kch4_223",jd="_detailTag_1kch4_230",kd="_detailDesc_1kch4_241",Xe={container:od,empty:ad,hint:ld,tableWrapper:cd,table:dd,detailCell:hd,online:ud,offline:_d,name:fd,avatar:pd,badge:md,status:gd,description:vd,endpoint:yd,truncate:xd,deleteBtn:bd,editBtn:Sd,actions:Cd,detailRow:wd,detailTag:jd,detailDesc:kd};function Ed({agents:t,onDelete:o,onEditProfile:m}){const[S,j]=g.useState("name"),[E,b]=g.useState("asc"),n=[...t].sort((d,h)=>{const c=d[S]||"",f=h[S]||"",v=String(c).localeCompare(String(f));return E==="asc"?v:-v}),a=d=>{S===d?b(E==="asc"?"desc":"asc"):(j(d),b("asc"))};return t.length===0?e.jsxs("div",{className:Xe.empty,children:[e.jsx("p",{children:"暂无员工数据"}),e.jsx("p",{className:Xe.hint,children:"请调整筛选条件或注册新员工"})]}):e.jsx("div",{className:Xe.container,children:e.jsx("div",{className:Xe.tableWrapper,children:e.jsxs("table",{className:Xe.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsxs("th",{onClick:()=>a("name"),children:["名称 ",S==="name"&&(E==="asc"?"↑":"↓")]}),e.jsxs("th",{onClick:()=>a("status"),children:["状态 ",S==="status"&&(E==="asc"?"↑":"↓")]}),e.jsx("th",{children:"类型"}),e.jsx("th",{children:"详情"}),(o||m)&&e.jsx("th",{children:"操作"})]})}),e.jsx("tbody",{children:n.map(d=>{var h,c,f,v,y,u,i,r,s;return e.jsxs("tr",{className:d.status==="online"?Xe.online:Xe.offline,children:[e.jsxs("td",{className:Xe.name,children:[e.jsx(At,{name:d.name,src:d.avatar_url,size:32}),e.jsx("span",{children:d.name})]}),e.jsx("td",{children:e.jsx("span",{className:`${Xe.status} ${Xe[d.status]}`,children:d.status==="online"?"在线":"离线"})}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx("span",{children:(h=d.profile)!=null&&h.category?(d.profile.category==="真人"?"👤 ":"🚀 ")+d.profile.category:"🚀 Agent"}),d.cliTool&&e.jsxs("span",{style:{fontSize:11,color:"#6b7280"},children:["🔧 ",d.cliTool]})]})}),e.jsxs("td",{className:Xe.detailCell,children:[e.jsxs("div",{className:Xe.detailRow,children:[((c=d.profile)==null?void 0:c.position)&&e.jsxs("span",{className:Xe.detailTag,children:["💼 ",d.profile.position]}),((f=d.profile)==null?void 0:f.bio)&&e.jsxs("span",{className:Xe.detailTag,children:["📝 ",d.profile.bio]}),!((v=d.profile)!=null&&v.position)&&!((y=d.profile)!=null&&y.bio)&&d.description&&e.jsx("span",{className:Xe.detailDesc,children:d.description})]}),d.description&&(((u=d.profile)==null?void 0:u.position)||((i=d.profile)==null?void 0:i.bio))&&e.jsx("div",{className:Xe.detailDesc,children:d.description}),!d.description&&!((r=d.profile)!=null&&r.position)&&!((s=d.profile)!=null&&s.bio)&&e.jsx("span",{className:Xe.detailDesc,children:"-"})]}),(o||m)&&e.jsx("td",{children:e.jsxs("div",{className:Xe.actions,children:[m&&e.jsx(ie,{variant:"secondary",size:"sm",onClick:()=>m(d),children:"编辑"}),o&&e.jsx(ie,{variant:"danger",outline:!0,size:"sm",onClick:()=>o(d),children:"删除"})]})})]},d.id)})})]})})})}const Nd="_container_1jjag_1",Rd="_header_1jjag_10",Ld="_stats_1jjag_17",Td="_stat_1jjag_17",Id="_statValue_1jjag_28",Ad="_statLabel_1jjag_34",Dd="_controls_1jjag_41",Bd="_zoomLevel_1jjag_70",Md="_legend_1jjag_78",$d="_legendItem_1jjag_88",Pd="_legendDot_1jjag_96",Od="_legendDotOnline_1jjag_103",Hd="_legendDotOffline_1jjag_108",Fd="_canvasContainer_1jjag_113",zd="_canvas_1jjag_113",Pe={container:Nd,header:Rd,stats:Ld,stat:Td,statValue:Id,statLabel:Ad,controls:Dd,zoomLevel:Bd,legend:Md,legendItem:$d,legendDot:Pd,legendDotOnline:Od,legendDotOffline:Hd,canvasContainer:Fd,canvas:zd},cr=["#6c8cff","#22c55e","#f59e0b","#a78bfa","#2dd4bf","#f472b6","#84cc16","#06b6d4","#fb923c","#e879f9","#fbbf24","#64748b"];function Wd({agents:t,statusFilter:o,domainFilter:m,onAgentClick:S}){const j=g.useRef(null),E=g.useRef(null),[b,n]=g.useState({deptCount:0,agentCount:0,messageCount:0}),[a,d]=g.useState([]),[h,c]=g.useState(100),[f,v]=g.useState(!1),y=g.useRef({nodes:[],clusters:[],particles:[],scale:1,contentCx:0,contentCy:0,hovered:null,hoveredCluster:null,glowPhase:0,animId:null,showNames:!1}),u=t.filter(N=>!(o!=="all"&&N.status!==o||m!=="all"&&(N.domain||"")!==m)),i=u.reduce((N,I)=>{const z=I.domain||"未分组";return N[z]||(N[z]=[]),N[z].push(I),N},{}),r=Object.keys(i).sort();g.useEffect(()=>{const N=j.current,I=E.current;if(!N||!I)return;const z=N.getContext("2d");if(!z)return;const G=window.devicePixelRatio||1,H=I.clientWidth,V=f?I.clientHeight:Math.max(500,Math.min(900,480+r.length*22+u.length*.6));N.width=H*G,N.height=V*G,N.style.width=H+"px",N.style.height=V+"px",z.scale(G,G),s(N,z,H,V);const L=y.current;L.animId&&cancelAnimationFrame(L.animId);function A(){L.glowPhase+=.012,l(N,z,H,V),L.animId=requestAnimationFrame(A)}return A(),()=>{L.animId&&cancelAnimationFrame(L.animId)}},[u,r,f]);function s(N,I,z,G){const H=y.current,V=r.length,L=u.length,A=z/2,B=G/2,P=L>120?5:L>60?6:L>30?7:L>12?8:10,U=P*2.8,Z=L<=20;let oe=U,K;if(Z){I.save(),I.font="500 10px Inter, system-ui";let ce=0;for(const he of u){const pe=I.measureText(he.name).width;pe>ce&&(ce=pe)}I.restore(),oe=Math.max(U,ce+14),K=P*2+32}const $=30,D={name:"调度中心",x:A,y:B,r:$,isMaster:!0,status:"online"};H.nodes=[D],H.clusters=[];for(let ce=0;ce<V;ce++){const he=r[ce],pe=i[he],Ne=V===1?0:V===2?ce===0?Math.PI:0:-Math.PI/2+ce/V*Math.PI*2,Ue=x(pe.length,0,0,oe,K),Me=C(Ue,0,0,P+(Z?26:18)),$e=Math.max(Me+$+65,150),Le=A+Math.cos(Ne)*$e,qe=B+Math.sin(Ne)*$e,ot=Ue.map(Ee=>({x:Ee.x+Le,y:Ee.y+qe})),Qe=cr[ce%cr.length],at=pe.filter(Ee=>Ee.status==="online").length;H.clusters.push({name:he,color:Qe,cx:Le,cy:qe,clR:Me,members:pe,positions:ot,onlineCount:at,totalCount:pe.length});for(let Ee=0;Ee<pe.length;Ee++){const Ze=pe[Ee];H.nodes.push({name:Ze.name,x:ot[Ee].x,y:ot[Ee].y,r:P,color:Ze.status==="online"?"#22c55e":"#4a4f5a",status:Ze.status,domain:Ze.domain,endpoint:Ze.endpoint,deptColor:Qe,description:Ze.description})}}let q=A-$,J=A+$,O=B-$,X=B+$;for(const ce of H.clusters)q=Math.min(q,ce.cx-ce.clR-20),J=Math.max(J,ce.cx+ce.clR+20),O=Math.min(O,ce.cy-ce.clR-40),X=Math.max(X,ce.cy+ce.clR+30);const F=J-q||1,W=X-O||1;H.contentCx=(q+J)/2,H.contentCy=(O+X)/2;const re=60,ae=Math.min((z-re)/F,(G-re)/W,1.5);H.scale=ae,n({deptCount:V,agentCount:L,messageCount:0}),d(H.clusters),c(Math.round(ae*100)),H.showNames=Z,H.particles=[];const ee=50;for(const ce of H.clusters){if(H.particles.length>=ee)break;const he=Math.min(3,Math.max(1,Math.ceil(ce.totalCount/6)));for(let pe=0;pe<he&&H.particles.length<ee;pe++)H.particles.push({fx:A,fy:B,tx:ce.cx,ty:ce.cy,t:Math.random(),speed:7e-4+Math.random()*.001,color:ce.color+"70",size:2.5})}N.onmousemove=ce=>{const he=N.getBoundingClientRect(),pe=ce.clientX-he.left,Ne=ce.clientY-he.top,Ue=(pe-z/2)/H.scale+H.contentCx,Me=(Ne-G/2)/H.scale+H.contentCy;H.hovered=null,H.hoveredCluster=null;for(let $e=H.nodes.length-1;$e>=0;$e--){const Le=H.nodes[$e],qe=Z?Le.r+6:Le.r+4;if((Ue-Le.x)**2+(Me-Le.y)**2<qe*qe){H.hovered=Le;break}}if(!H.hovered){for(const $e of H.clusters)if((Ue-$e.cx)**2+(Me-$e.cy)**2<$e.clR*$e.clR){H.hoveredCluster=$e;break}}N.style.cursor=H.hovered&&!H.hovered.isMaster||H.hoveredCluster?"pointer":"default",N._lastSx=pe,N._lastSy=Ne},N.onclick=()=>{H.hovered&&!H.hovered.isMaster&&S&&S(H.hovered.name)},N.onwheel=ce=>{ce.preventDefault();const he=ce.deltaY<0?.08:-.08;H.scale=Math.max(.1,Math.min(3,H.scale+he)),c(Math.round(H.scale*100))}}function l(N,I,z,G){const H=y.current;I.clearRect(0,0,z,G),I.fillStyle="#ffffff06";for(let K=25;K<z;K+=40)for(let $=25;$<G;$+=40)I.fillRect(K-.5,$-.5,1,1);I.save(),I.translate(z/2,G/2),I.scale(H.scale,H.scale),I.translate(-H.contentCx,-H.contentCy);const V=H.nodes[0];if(!V)return I.restore();const L=I.createRadialGradient(V.x,V.y,0,V.x,V.y,Math.max(z,G)*.55);L.addColorStop(0,"#7c6cff08"),L.addColorStop(.4,"#7c6cff03"),L.addColorStop(1,"transparent"),I.fillStyle=L,I.fillRect(V.x-z,V.y-G,z*2,G*2);for(const K of H.clusters){const $=I.createLinearGradient(V.x,V.y,K.cx,K.cy);$.addColorStop(0,"#7c6cff40"),$.addColorStop(.5,K.color+"25"),$.addColorStop(1,K.color+"10"),I.beginPath(),I.moveTo(V.x,V.y),I.lineTo(K.cx,K.cy),I.strokeStyle=$,I.lineWidth=1.5,I.stroke()}for(const K of H.clusters){const $=H.hoveredCluster===K,D=K.clR,q=I.createRadialGradient(K.cx,K.cy,D*.3,K.cx,K.cy,D+20);q.addColorStop(0,K.color+($?"18":"0c")),q.addColorStop(.7,K.color+($?"0a":"05")),q.addColorStop(1,"transparent"),I.beginPath(),I.arc(K.cx,K.cy,D+20,0,Math.PI*2),I.fillStyle=q,I.fill(),I.beginPath(),I.arc(K.cx,K.cy,D,0,Math.PI*2),I.fillStyle=K.color+($?"12":"08"),I.fill(),I.strokeStyle=K.color+($?"40":"20"),I.lineWidth=$?1.5:1,I.stroke();const J=K.name.length>12?K.name.slice(0,11)+"…":K.name;I.font="600 12px Inter, system-ui";const O=I.measureText(J).width+16,X=K.cx-O/2,F=K.cy-D-28;p(I,X,F,O,22,6),I.fillStyle=K.color+"20",I.fill(),I.strokeStyle=K.color+"35",I.lineWidth=.8,p(I,X,F,O,22,6),I.stroke(),I.textAlign="center",I.fillStyle=K.color,I.fillText(J,K.cx,F+15);const W=K.onlineCount+" / "+K.totalCount,re=K.totalCount?K.onlineCount/K.totalCount:0,ae=re>=1?"#22c55e":re>0?"#f59e0b":"#ef4444";I.font='600 10px "JetBrains Mono", monospace';const ee=I.measureText(W).width+14,ce=K.cx-ee/2,he=K.cy+D+8;p(I,ce,he,ee,18,5),I.fillStyle=ae+"25",I.fill(),I.strokeStyle=ae+"40",I.lineWidth=1,p(I,ce,he,ee,18,5),I.stroke(),I.textAlign="center",I.fillStyle=ae,I.fillText(W,K.cx,he+13)}for(const K of H.particles){K.t+=K.speed,K.t>1&&(K.t-=1);const $=K.fx+(K.tx-K.fx)*K.t,D=K.fy+(K.ty-K.fy)*K.t;I.beginPath(),I.arc($,D,K.size+1.5,0,Math.PI*2),I.fillStyle=K.color.replace(/[\da-f]{2}$/i,"15"),I.fill(),I.beginPath(),I.arc($,D,K.size,0,Math.PI*2),I.fillStyle=K.color,I.fill()}for(let K=1;K<H.nodes.length;K++){const $=H.nodes[K];if($.isMaster||$.status==="online")continue;const D=H.hovered===$,q=D?$.r+2:$.r;I.beginPath(),I.arc($.x,$.y,q,0,Math.PI*2),I.fillStyle="#1e2228",I.fill(),I.strokeStyle=D?"#ef4444":"#4a5060",I.lineWidth=D?2:1.2,I.stroke(),I.beginPath(),I.arc($.x,$.y,q*.35,0,Math.PI*2),I.fillStyle="#ef444440",I.fill()}for(let K=1;K<H.nodes.length;K++){const $=H.nodes[K];if($.isMaster||$.status!=="online")continue;const D=H.hovered===$,q=D?$.r+2:$.r,J=I.createRadialGradient($.x,$.y,q*.2,$.x,$.y,q+8);J.addColorStop(0,"#22c55e30"),J.addColorStop(1,"transparent"),I.beginPath(),I.arc($.x,$.y,q+8,0,Math.PI*2),I.fillStyle=J,I.fill();const O=I.createRadialGradient($.x-q*.25,$.y-q*.25,0,$.x,$.y,q);O.addColorStop(0,"#4ade80"),O.addColorStop(1,"#16a34a"),I.beginPath(),I.arc($.x,$.y,q,0,Math.PI*2),I.fillStyle=O,I.fill(),I.strokeStyle=D?"#86efac":"#22c55e80",I.lineWidth=D?2:1,I.stroke()}if(H.showNames){I.textAlign="center",I.font="500 10px Inter, system-ui";for(let K=1;K<H.nodes.length;K++){const $=H.nodes[K];$.isMaster||(I.fillStyle=$.status==="online"?"#15803d":"#475569",I.fillText($.name,$.x,$.y+$.r+12))}}const A=V,B=A.r,P=.6+.4*Math.sin(H.glowPhase);for(let K=3;K>=1;K--){const $=I.createRadialGradient(A.x,A.y,B,A.x,A.y,B+K*18);$.addColorStop(0,"rgba(124,108,255,"+.06*P/K+")"),$.addColorStop(1,"transparent"),I.beginPath(),I.arc(A.x,A.y,B+K*18,0,Math.PI*2),I.fillStyle=$,I.fill()}const U=I.createRadialGradient(A.x-B*.2,A.y-B*.2,0,A.x,A.y,B);U.addColorStop(0,"#2a2050"),U.addColorStop(1,"#151025"),k(I,A.x,A.y,B),I.fillStyle=U,I.fill();const Z=I.createLinearGradient(A.x-B,A.y-B,A.x+B,A.y+B);Z.addColorStop(0,"#7c6cffc0"),Z.addColorStop(1,"#a78bfac0"),k(I,A.x,A.y,B),I.strokeStyle=Z,I.lineWidth=H.hovered===A?3:2,I.stroke(),I.textAlign="center",I.fillStyle="#c4b5fd",I.font="700 13px Inter, system-ui",I.fillText(A.name,A.x,A.y+B+20),I.restore();const oe=H.hovered||H.hoveredCluster;if(oe){const K=N._lastSx||z/2,$=N._lastSy||G/2;_(I,oe,K,$,z,G)}}function _(N,I,z,G,H,V){const L=y.current;let A=[];if(I.isMaster)A=["调度中心","管理所有数字员工通信",L.clusters.length+" 个分组 · "+(L.nodes.length-1)+" 名员工"];else if(I.clR!==void 0){A=[I.name+" 分组","在线 "+I.onlineCount+" / 共 "+I.totalCount+" 名"];const $=I.members.slice(0,8).map(D=>(D.status==="online"?"● ":"○ ")+D.name);I.members.length>8&&$.push("… 还有 "+(I.members.length-8)+" 名"),A=A.concat($)}else A=[I.name,"分组: "+(I.domain||"—")],I.endpoint&&A.push("EP: "+I.endpoint),I.description&&A.push(I.description.slice(0,24)),A.push(I.status==="online"?"● 在线":"○ 离线");const B=18,P=Math.min(240,Math.max(150,...A.map($=>$.length*7.5+28))),U=A.length*B+14;let Z=z+14,oe=G-A.length*9;Z+P>H-8&&(Z=z-P-10),oe<6&&(oe=6),oe+U>V-6&&(oe=V-U-6),N.shadowColor="rgba(0,0,0,0.5)",N.shadowBlur=16,N.shadowOffsetY=4,N.fillStyle="#111820f5",p(N,Z,oe,P,U,10),N.fill(),N.shadowColor="transparent",N.shadowBlur=0,N.shadowOffsetY=0;const K=I.deptColor||I.color||"#6c8cff";N.strokeStyle=K+"40",N.lineWidth=1,p(N,Z,oe,P,U,10),N.stroke(),N.fillStyle=K,N.fillRect(Z+1,oe+8,3,U-16),N.textAlign="left";for(let $=0;$<A.length;$++){const D=A[$];$===0?(N.fillStyle="#fff",N.font="700 12px Inter, system-ui"):$===1&&I.clR!==void 0?(N.fillStyle=I.color||"#8492a6",N.font='600 11px "JetBrains Mono", monospace'):D.startsWith("●")?(N.fillStyle="#4ade80",N.font="400 11px Inter, system-ui"):D.startsWith("○")?(N.fillStyle="#6b7280",N.font="400 11px Inter, system-ui"):(N.fillStyle="#94a3b8",N.font="400 11px Inter, system-ui"),N.fillText(D,Z+12,oe+16+$*B)}}function x(N,I,z,G,H){if(!N)return[];if(N===1)return[{x:I,y:z}];const V=Math.ceil(Math.sqrt(N*1.15)),L=Math.ceil(N/V),A=H??G*.866,B=[];let P=0;for(let U=0;U<L&&P<N;U++){const Z=Math.min(V,N-P),oe=U%2?G*.5:0;for(let K=0;K<Z;K++,P++)B.push({x:I+(K-(Z-1)/2)*G+oe,y:z+(U-(L-1)/2)*A})}return B}function C(N,I,z,G){if(!N.length)return G+10;let H=0;for(const V of N){const L=Math.sqrt((V.x-I)**2+(V.y-z)**2);L>H&&(H=L)}return H+G}function k(N,I,z,G){N.beginPath();for(let H=0;H<6;H++){const V=-Math.PI/2+H*Math.PI/3;N.lineTo(I+Math.cos(V)*G,z+Math.sin(V)*G)}N.closePath()}function p(N,I,z,G,H,V){N.beginPath(),N.moveTo(I+V,z),N.lineTo(I+G-V,z),N.quadraticCurveTo(I+G,z,I+G,z+V),N.lineTo(I+G,z+H-V),N.quadraticCurveTo(I+G,z+H,I+G-V,z+H),N.lineTo(I+V,z+H),N.quadraticCurveTo(I,z+H,I,z+H-V),N.lineTo(I,z+V),N.quadraticCurveTo(I,z,I+V,z),N.closePath()}function w(){var N;document.fullscreenElement?(document.exitFullscreen(),v(!1)):((N=E.current)==null||N.requestFullscreen(),v(!0))}function R(){const N=y.current;N.scale=Math.min(3,N.scale+.1),c(Math.round(N.scale*100))}function T(){const N=y.current;N.scale=Math.max(.1,N.scale-.1),c(Math.round(N.scale*100))}function M(){const N=y.current;N.scale=1,c(100)}return e.jsxs("div",{className:Pe.container,children:[e.jsxs("div",{className:Pe.header,children:[e.jsxs("div",{className:Pe.stats,children:[e.jsxs("div",{className:Pe.stat,children:[e.jsx("span",{className:Pe.statValue,children:b.deptCount}),e.jsx("span",{className:Pe.statLabel,children:"分组"})]}),e.jsxs("div",{className:Pe.stat,children:[e.jsx("span",{className:Pe.statValue,children:b.agentCount}),e.jsx("span",{className:Pe.statLabel,children:"员工"})]}),e.jsxs("div",{className:Pe.stat,children:[e.jsx("span",{className:Pe.statValue,children:b.messageCount}),e.jsx("span",{className:Pe.statLabel,children:"对话"})]})]}),e.jsxs("div",{className:Pe.controls,children:[e.jsx(ie,{variant:"ghost",size:"sm",iconOnly:!0,onClick:T,title:"缩小",children:"−"}),e.jsxs("span",{className:Pe.zoomLevel,children:[h,"%"]}),e.jsx(ie,{variant:"ghost",size:"sm",iconOnly:!0,onClick:R,title:"放大",children:"+"}),e.jsx(ie,{variant:"ghost",size:"sm",iconOnly:!0,onClick:M,title:"重置",children:"⟲"}),e.jsx(ie,{variant:"ghost",size:"sm",iconOnly:!0,onClick:w,title:"全屏",children:"⛶"})]})]}),e.jsxs("div",{className:Pe.legend,children:[e.jsxs("div",{className:Pe.legendItem,children:[e.jsx("div",{className:`${Pe.legendDot} ${Pe.legendDotOnline}`}),"在线"]}),e.jsxs("div",{className:Pe.legendItem,children:[e.jsx("div",{className:`${Pe.legendDot} ${Pe.legendDotOffline}`}),"离线"]}),a.map((N,I)=>e.jsxs("div",{className:Pe.legendItem,children:[e.jsx("div",{className:Pe.legendDot,style:{background:N.color},title:N.name}),N.name]},I))]}),e.jsx("div",{ref:E,className:Pe.canvasContainer,children:e.jsx("canvas",{ref:j,className:Pe.canvas})})]})}const Ud="_warning_1xzqr_77",qd="_field_1xzqr_88",Vd="_actions_1xzqr_145",Gd="_successIcon_1xzqr_153",Kd="_success_1xzqr_153",Jd="_info_1xzqr_241",Xd="_errorMsg_1xzqr_252",et={warning:Ud,field:qd,actions:Vd,successIcon:Gd,success:Kd,info:Jd,errorMsg:Xd};function Zd({open:t,onClose:o,domains:m,onSuccess:S,defaultDomain:j}){const[E,b]=g.useState(""),[n,a]=g.useState(j??""),[d,h]=g.useState(""),[c,f]=g.useState(""),[v,y]=g.useState(""),[u,i]=g.useState(!1),[r,s]=g.useState(null);g.useEffect(()=>{t&&a(j??"")},[t,j]);const l=async x=>{if(x.preventDefault(),!E.trim()||!n){s({success:!1,error:"请填写完整信息"});return}i(!0);try{const C={};d&&(C.category=d),c.trim()&&(C.position=c.trim()),v.trim()&&(C.bio=v.trim());const p=await(await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:E.trim(),domain:n,...Object.keys(C).length>0?{profile:C}:{}})})).json();p.error?s({success:!1,error:p.error}):(s({success:!0}),S())}catch{s({success:!1,error:"网络请求失败"})}finally{i(!1)}},_=()=>{b(""),a(""),h(""),f(""),y(""),s(null),o()};return e.jsxs(De,{open:t,title:"添加数字员工",onClose:_,size:"md",children:[m.length===0&&e.jsx("div",{className:et.warning,children:"请先在「分组」中创建至少一个域。"}),r?e.jsx("div",{className:et.success,children:r.success?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:et.successIcon,children:"✓"}),e.jsx("h4",{children:"已添加"}),e.jsx("div",{className:et.info,style:{textAlign:"center",padding:"8px 0 16px"},children:"员工已创建。本机所有 executor 走 loopback 信任,自动可见 — 无需 token 配置。"}),e.jsx("div",{className:et.actions,children:e.jsx(ie,{variant:"secondary",size:"md",onClick:_,children:"关闭"})})]}):e.jsxs("div",{className:et.errorMsg,children:[r.error,e.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>s(null),children:"重试"})]})}):e.jsxs("form",{onSubmit:l,children:[e.jsx("div",{className:et.field,children:e.jsx(ge,{label:"节点名称",required:!0,value:E,onChange:x=>b(x.target.value),placeholder:"如:小七",disabled:u})}),e.jsx("div",{className:et.field,children:e.jsx(Fe,{label:"所属域",required:!0,value:n,onChange:x=>a(x.target.value),disabled:u||m.length===0,options:[{value:"",label:"选择域"},...m.map(x=>({value:x.name,label:x.description?`${x.name} — ${x.description}`:x.name}))]})}),e.jsx("div",{className:et.field,children:e.jsx(Fe,{label:"员工类型",value:d,onChange:x=>h(x.target.value),disabled:u,options:[{value:"",label:"🚀 Agent(默认)"},{value:"真人",label:"👤 真人 — 真实人类团队成员"}]})}),e.jsx("div",{className:et.field,children:e.jsx(ge,{label:"岗位",value:c,onChange:x=>f(x.target.value),placeholder:"如:前端开发工程师",disabled:u})}),e.jsx("div",{className:et.field,children:e.jsx(ge,{label:"简介",value:v,onChange:x=>y(x.target.value),placeholder:"如:负责保险业务前端架构和核心模块开发",disabled:u})}),e.jsxs("div",{className:et.actions,children:[e.jsx(ie,{type:"button",variant:"secondary",size:"md",onClick:_,children:"取消"}),e.jsx(ie,{type:"submit",variant:"primary",size:"md",disabled:u||m.length===0,children:u?"添加中...":"添加员工"})]})]})]})}function Yd({agent:t,open:o,onClose:m,onSuccess:S}){const[j,E]=g.useState(""),[b,n]=g.useState(""),[a,d]=g.useState(!1),[h,c]=g.useState(""),[f,v]=g.useState(null),[y,u]=g.useState(null),[i,r]=g.useState(null),[s,l]=g.useState(!1),_=g.useRef(null);g.useEffect(()=>{var k,p;t&&(E(((k=t.profile)==null?void 0:k.position)||""),n(((p=t.profile)==null?void 0:p.bio)||""),v(t.avatar_url??null),r(null),u(null),c(""))},[t]);const x=async k=>{if(k.preventDefault(),!t)return;d(!0),c("");const p={};j.trim()&&(p.position=j.trim()),b.trim()&&(p.bio=b.trim());let w=f;if(y){l(!0);try{const R=new FileReader,T=await new Promise((N,I)=>{R.onload=()=>{const G=R.result.split(",")[1];N(G)},R.onerror=I,R.readAsDataURL(y)}),M=await Os.uploadAvatar(t.id,T,y.type);w=M.url,v(M.url),r(null),u(null)}catch{c("头像上传失败"),l(!1);return}finally{l(!1)}}try{const R={profile:p};w!==(t.avatar_url??null)&&(R.avatar_url=w);const M=await(await fetch(`/api/agents/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)})).json();M.error?c(M.error):(S(),m())}catch{c("保存失败")}finally{d(!1)}},C=()=>{c(""),r(null),u(null),m()};return e.jsxs(De,{open:o&&!!t,title:t?`编辑员工介绍 — ${t.name}`:"编辑员工介绍",onClose:C,size:"md",children:[e.jsxs("div",{className:et.field,children:[e.jsx("label",{children:"头像"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[e.jsx("div",{style:{position:"relative"},children:i?e.jsx("img",{src:i,alt:"预览",style:{width:64,height:64,borderRadius:"50%",objectFit:"cover"}}):f?e.jsx("img",{src:f,alt:(t==null?void 0:t.name)??"",style:{width:64,height:64,borderRadius:"50%",objectFit:"cover"},onError:k=>{k.target.style.display="none"}}):t?e.jsx(At,{name:t.name,size:64}):null}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx("input",{ref:_,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",style:{display:"none"},onChange:k=>{var w;const p=(w=k.target.files)==null?void 0:w[0];if(p){u(p);const R=new FileReader;R.onload=()=>r(R.result),R.readAsDataURL(p)}}}),e.jsx(ie,{type:"button",variant:"secondary",size:"sm",onClick:()=>{var k;return(k=_.current)==null?void 0:k.click()},disabled:a||s,children:s?"上传中...":"上传头像"}),(i||f)&&e.jsx(ie,{type:"button",variant:"ghost",size:"sm",onClick:()=>{u(null),r(null),v(null)},disabled:a||s,children:"清除头像"})]})]}),e.jsx("div",{style:{fontSize:11,color:"#9ca3af",marginTop:6},children:"支持 PNG / JPG / GIF / WebP,最大 2MB"})]}),e.jsxs("form",{onSubmit:x,children:[e.jsx("div",{className:et.field,children:e.jsx(ge,{label:"岗位",value:j,onChange:k=>E(k.target.value),placeholder:"如:前端开发工程师",disabled:a||s})}),e.jsxs("div",{className:et.field,children:[e.jsx("label",{children:"简介"}),e.jsx(xt,{value:b,onChange:k=>n(k.target.value),placeholder:"如:负责保险业务前端架构和核心模块开发",rows:3,disabled:a||s,style:{width:"100%",resize:"vertical"}})]}),h&&e.jsx("div",{style:{color:"var(--color-error)",fontSize:"13px",marginBottom:"12px"},children:h}),e.jsxs("div",{className:et.actions,children:[e.jsx(ie,{type:"button",variant:"secondary",size:"md",onClick:C,children:"取消"}),e.jsx(ie,{type:"submit",variant:"primary",size:"md",disabled:a||s,children:a||s?"保存中...":"保存"})]})]})]})}const Qd="_form_1i82t_68",eh="_field_1i82t_72",th="_error_1i82t_104",sh="_actions_1i82t_115",Jt={form:Qd,field:eh,error:th,actions:sh};function rh({open:t,mode:o,domain:m,onClose:S,onSuccess:j}){const[E,b]=g.useState(""),[n,a]=g.useState(""),[d,h]=g.useState(!1),[c,f]=g.useState(null);g.useEffect(()=>{t&&(f(null),h(!1),o==="edit"&&m?(b(m.name),a(m.description??"")):(b(""),a("")))},[t,o,m]);const v=async i=>{i.preventDefault();const r=E.trim();if(!r){f("请输入分组名称");return}h(!0),f(null);try{o==="create"?await us.create({name:r,description:n.trim()||void 0}):m&&await us.update(m.id,{name:r,description:n.trim()||void 0}),j(),S()}catch(s){const l=s instanceof Error?s.message:"操作失败";f(l)}finally{h(!1)}},y=o==="create"?"添加分组":"重命名分组",u=o==="create"?"创建":"保存";return e.jsx(De,{open:t,title:y,onClose:S,size:"sm",children:e.jsxs("form",{onSubmit:v,className:Jt.form,children:[e.jsx("div",{className:Jt.field,children:e.jsx(ge,{label:"分组名称",required:!0,value:E,onChange:i=>b(i.target.value),placeholder:"如:技术部",autoFocus:!0,disabled:d})}),e.jsx("div",{className:Jt.field,children:e.jsx(ge,{label:"描述(可选)",value:n,onChange:i=>a(i.target.value),placeholder:"简要描述该分组的职责",disabled:d})}),c&&e.jsx("div",{className:Jt.error,children:c}),e.jsxs("div",{className:Jt.actions,children:[e.jsx(ie,{type:"button",variant:"secondary",size:"md",onClick:S,disabled:d,children:"取消"}),e.jsx(ie,{type:"submit",variant:"primary",size:"md",disabled:d,children:d?"提交中…":u})]})]})})}const ih="_container_6miy4_1",nh="_sectionHeader_6miy4_8",oh="_subtitle_6miy4_26",ah="_loading_6miy4_61",lh="_empty_6miy4_69",ch="_emptyIcon_6miy4_77",dh="_hint_6miy4_90",hh="_warning_6miy4_97",uh="_rulesTable_6miy4_110",_h="_table_6miy4_116",fh="_arrow_6miy4_152",ph="_domainTag_6miy4_158",mh="_domainTagTo_6miy4_168",gh="_modalOverlay_6miy4_193",vh="_modal_6miy4_193",yh="_modalHeader_6miy4_220",xh="_modalForm_6miy4_260",bh="_field_6miy4_264",Sh="_fieldGroup_6miy4_296",Ch="_modalActions_6miy4_330",He={container:ih,sectionHeader:nh,subtitle:oh,loading:ah,empty:lh,emptyIcon:ch,hint:dh,warning:hh,rulesTable:uh,table:_h,arrow:fh,domainTag:ph,domainTagTo:mh,modalOverlay:gh,modal:vh,modalHeader:yh,modalForm:xh,field:bh,fieldGroup:Sh,modalActions:Ch};function wh({domains:t}){const[o,m]=g.useState([]),[S,j]=g.useState(!0),[E,b]=g.useState(!1),[n,a]=g.useState(""),[d,h]=g.useState(""),[c,f]=g.useState(!0),[v,y]=g.useState(!1),u=async()=>{j(!0);try{const l=await js.list();m(l.rules||[])}catch(l){console.error("Failed to load rules:",l)}finally{j(!1)}};g.useEffect(()=>{u()},[]);const i=()=>{a(""),h(""),f(!0),b(!1)},r=async l=>{if(l.preventDefault(),!n||!d){alert("请选择源域和目标域");return}if(n===d){alert("源域和目标域不能相同");return}y(!0);try{await js.create({from:n,to:d,bidirectional:c}),await u(),i()}catch(_){const x=_ instanceof Error?_.message:"创建规则失败";alert(x)}finally{y(!1)}},s=async(l,_)=>{if(confirm(`确定删除规则 ${l} → ${_} 吗?`))try{await js.delete(l,_),await u()}catch(x){const C=x instanceof Error?x.message:"删除规则失败";alert(C)}};return e.jsxs("div",{className:He.container,children:[e.jsxs("div",{className:He.sectionHeader,children:[e.jsxs("div",{children:[e.jsx("h2",{children:"跨域规则"}),e.jsx("p",{className:He.subtitle,children:"配置不同分组间的数字员工通信权限"})]}),e.jsxs(ie,{type:"button",variant:"primary",size:"md",onClick:()=>b(!0),disabled:t.length<2,children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 3a1 1 0 011 1v3h3a1 1 0 110 2H9v3a1 1 0 11-2 0V9H4a1 1 0 110-2h3V4a1 1 0 011-1z"})}),"添加规则"]})]}),S?e.jsx("div",{className:He.loading,children:"加载中..."}):t.length<2?e.jsx("div",{className:He.warning,children:"当前不足 2 个分组,请先创建多个分组再添加跨域规则"}):o.length===0?e.jsxs("div",{className:He.empty,children:[e.jsx("div",{className:He.emptyIcon,children:"📋"}),e.jsx("p",{children:"暂无跨域规则"}),e.jsx("p",{className:He.hint,children:"添加规则以允许不同分组间的数字员工通信"})]}):e.jsx("div",{className:He.rulesTable,children:e.jsxs("table",{className:He.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"源分组"}),e.jsx("th",{}),e.jsx("th",{children:"目标分组"}),e.jsx("th",{children:"操作"})]})}),e.jsx("tbody",{children:o.map((l,_)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("span",{className:He.domainTag,children:l.from_domain})}),e.jsx("td",{className:He.arrow,children:"→"}),e.jsx("td",{children:e.jsx("span",{className:`${He.domainTag} ${He.domainTagTo}`,children:l.to_domain})}),e.jsx("td",{children:e.jsx(ie,{type:"button",variant:"danger",outline:!0,size:"sm",onClick:()=>s(l.from_domain,l.to_domain),children:"删除"})})]},_))})]})}),E&&e.jsx("div",{className:He.modalOverlay,onClick:i,children:e.jsxs("div",{className:He.modal,onClick:l=>l.stopPropagation(),children:[e.jsxs("div",{className:He.modalHeader,children:[e.jsx("h3",{children:"添加跨域规则"}),e.jsx(ie,{variant:"ghost",size:"sm",iconOnly:!0,onClick:i,title:"关闭",children:"×"})]}),e.jsxs("form",{onSubmit:r,className:He.modalForm,children:[e.jsxs("div",{className:He.fieldGroup,children:[e.jsx("div",{className:He.field,children:e.jsx(Fe,{label:"源分组",value:n,onChange:l=>a(l.target.value),required:!0,options:[{value:"",label:"选择分组"},...t.map(l=>({value:l.name,label:l.name}))]})}),e.jsx("div",{className:He.arrow,children:"→"}),e.jsx("div",{className:He.field,children:e.jsx(Fe,{label:"目标分组",value:d,onChange:l=>h(l.target.value),required:!0,options:[{value:"",label:"选择分组"},...t.map(l=>({value:l.name,label:l.name}))]})})]}),e.jsx("div",{className:He.field,children:e.jsx(Dt,{checked:c,onChange:f,label:"双向(同时创建反向规则)"})}),e.jsxs("div",{className:He.modalActions,children:[e.jsx(ie,{type:"button",variant:"secondary",size:"md",onClick:i,disabled:v,children:"取消"}),e.jsx(ie,{type:"submit",variant:"primary",size:"md",disabled:v||!n||!d||n===d,children:v?"提交中…":"添加"})]})]})]})})]})}const jh="_footer_1pr5n_1",kh="_brandMark_1pr5n_26",Eh="_content_1pr5n_47",Nh="_titleRow_1pr5n_56",Rh="_title_1pr5n_56",Lh="_version_1pr5n_71",Th="_tagline_1pr5n_81",Ih="_highlights_1pr5n_89",Ah="_pill_1pr5n_96",Dh="_dot_1pr5n_116",Bh="_meta_1pr5n_123",Mh="_divider_1pr5n_145",ze={footer:jh,brandMark:kh,content:Eh,titleRow:Nh,title:Rh,version:Lh,tagline:Th,highlights:Ih,pill:Ah,dot:Dh,meta:Bh,divider:Mh};function $h(){return e.jsxs("footer",{className:ze.footer,children:[e.jsx("div",{className:ze.brandMark,children:e.jsx("img",{src:"/dashboard/rotom-avatar.png",alt:"Rotom"})}),e.jsxs("div",{className:ze.content,children:[e.jsxs("div",{className:ze.titleRow,children:[e.jsx("h2",{className:ze.title,children:"Rotom · 个人 OPC + 团队联邦"}),e.jsx("span",{className:ze.version,children:"v2.19.0"})]}),e.jsx("p",{className:ze.tagline,children:"每台机器一个 master + executor,开箱即用、免 token、断网可用(个人 OPC)。 多台机器可联邦成团队 —— 协调 master 星型中转,member 主动接入, 本机 agent 自动发布可见性,跨机消息经协调路由。数据归属本地,移动电脑切网无感。"}),e.jsxs("div",{className:ze.highlights,children:[e.jsxs("span",{className:ze.pill,children:[e.jsx("span",{className:ze.dot}),"个人 OPC"]}),e.jsxs("span",{className:ze.pill,children:[e.jsx("span",{className:ze.dot}),"免 token 本机信任"]}),e.jsxs("span",{className:ze.pill,children:[e.jsx("span",{className:ze.dot}),"CLI 自动注册"]}),e.jsxs("span",{className:ze.pill,children:[e.jsx("span",{className:ze.dot}),"团队联邦"]}),e.jsxs("span",{className:ze.pill,children:[e.jsx("span",{className:ze.dot}),"多 CLI 接入"]}),e.jsxs("span",{className:ze.pill,children:[e.jsx("span",{className:ze.dot}),"抢单执行"]})]}),e.jsxs("div",{className:ze.meta,children:[e.jsxs("span",{children:["© ",new Date().getFullYear()," Rotom Mesh"]}),e.jsx("span",{className:ze.divider,children:"·"}),e.jsx("span",{children:"masterId 持久稳定 · hostname 禁 IP"}),e.jsx("span",{className:ze.divider,children:"·"}),e.jsx("a",{href:"https://github.com",target:"_blank",rel:"noreferrer",children:"Docs"})]})]})]})}const Ph="_layout_1ul9b_1",Oh="_content_1ul9b_10",Hh="_container_1ul9b_18",Fh="_loading_1ul9b_32",zh="_error_1ul9b_33",Wh="_empty_1ul9b_34",Uh="_spinner_1ul9b_49",qh="_hint_1ul9b_91",Ct={layout:Ph,content:Oh,container:Hh,loading:Fh,error:zh,empty:Wh,spinner:Uh,hint:qh};function Vh(){const t=Uc(),[o,m]=g.useState("table"),[S,j]=g.useState(!1),[E,b]=g.useState(null),[n,a]=g.useState([]),[d,h]=g.useState("employees"),[c,f]=g.useState({open:!1}),v=async()=>{try{const y=await us.list();a(y)}catch{}};return g.useEffect(()=>{v()},[]),e.jsx(Yr,{data:t.agents,loading:t.loading,error:t.error,onRetry:t.refetch,loadingFallback:e.jsxs("div",{className:Ct.loading,children:[e.jsx("div",{className:Ct.spinner}),e.jsx("p",{children:"加载员工数据..."})]}),errorFallback:(y,u)=>e.jsxs("div",{className:Ct.error,children:[e.jsxs("p",{children:["❌ 加载失败: ",typeof y=="string"?y:y.message]}),e.jsx(ie,{variant:"ghost",size:"sm",onClick:u,children:"重试"})]}),children:()=>e.jsx(Gh,{result:t,viewMode:o,setViewMode:m,showAddModal:S,setShowAddModal:j,profileAgent:E,setProfileAgent:b,allDomains:n,fetchDomains:v,rightView:d,setRightView:h,deptModal:c,setDeptModal:f})})}function Gh({result:t,viewMode:o,setViewMode:m,showAddModal:S,setShowAddModal:j,profileAgent:E,setProfileAgent:b,allDomains:n,fetchDomains:a,rightView:d,setRightView:h,deptModal:c,setDeptModal:f}){const{agents:v,allAgents:y,refetch:u,filters:i,filteredAgents:r}=t,s=async p=>{if(window.confirm(`确定要删除 ${p.name} 吗?此操作不可恢复。`))try{const w=await Os.delete(p.id);"error"in w?alert("删除失败: "+w.error):(u(),a())}catch{alert("删除失败,请重试")}},l=async p=>{if(window.confirm(`确定删除分组「${p.name}」吗?`))try{await us.delete(p.id),i.domainFilter===p.name&&i.setDomainFilter("all"),a(),u()}catch(w){const R=w instanceof Error?w.message:"删除分组失败";alert(R)}},_=p=>{h("employees"),i.setDomainFilter(p)},x=()=>{h("employees"),i.setDomainFilter("all")},C=()=>{h("rules")},k=i.domainFilter!=="all"&&i.domainFilter?i.domainFilter:void 0;return e.jsxs("div",{className:Ct.layout,children:[e.jsxs("div",{className:Ct.content,children:[e.jsx(Hc,{}),e.jsx(Zc,{filter:i.filter,onFilterChange:i.setFilter,searchQuery:i.searchQuery,onSearchChange:i.setSearchQuery,domains:n,selectedDomain:i.domainFilter,onSelectDomain:p=>p==="all"?x():_(p),onAddDomain:()=>f({open:!0,mode:"create"}),onEditDomain:p=>f({open:!0,mode:"edit",domain:p}),onDeleteDomain:l,onSelectRules:C,isRulesView:d==="rules",viewMode:o,onViewModeChange:m,onAddAgent:()=>j(!0)}),d==="employees"?e.jsxs("div",{className:Ct.container,children:[e.jsx(nd,{agents:y}),o==="table"?e.jsxs(e.Fragment,{children:[e.jsx(Ed,{agents:v,onDelete:s,onEditProfile:b}),v.length===0&&e.jsxs("div",{className:Ct.empty,children:[e.jsx("p",{children:"没有找到匹配的员工"}),e.jsx("p",{className:Ct.hint,children:"请调整筛选条件"})]})]}):e.jsx(Wd,{agents:r,statusFilter:i.filter,domainFilter:i.domainFilter})]}):e.jsx(wh,{domains:n}),e.jsx($h,{})]}),e.jsx(Zd,{open:S,onClose:()=>j(!1),domains:n,defaultDomain:k,onSuccess:()=>{u(),a()}}),e.jsx(Yd,{agent:E,open:!!E,onClose:()=>b(null),onSuccess:u}),e.jsx(rh,{open:c.open,mode:c.open?c.mode:"create",domain:c.open&&c.mode==="edit"?c.domain:null,onClose:()=>f({open:!1}),onSuccess:()=>{a(),u()}})]})}function Kh(){const[t,o]=g.useState(null),[m,S]=g.useState([]),[j,E]=g.useState({}),[b,n]=g.useState(!0),[a,d]=g.useState(""),[h,c]=g.useState(""),[f,v]=g.useState(""),[y,u]=g.useState(!1),[i,r]=g.useState(""),s=async()=>{const[C,k]=await Promise.all([fetch("/api/identity").then(w=>w.json()),fetch("/api/teams").then(w=>w.json())]);o(C),S(k);const p={};for(const w of k){const R=await fetch(`/api/teams/${w.id}/members`);p[w.id]=await R.json()}E(p)};g.useEffect(()=>{s().catch(C=>d(C.message)).finally(()=>n(!1))},[]);const l=async()=>{u(!0),r("");try{const C=await fetch("/api/teams/join",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({coordEndpoint:h.trim(),teamName:f.trim()||void 0})}),k=await C.json();!C.ok||k.error?r(k.error||`HTTP ${C.status}`):(c(""),v(""),await s())}catch(C){r(C.message)}finally{u(!1)}},_=async()=>{if(window.confirm("确定离开当前大团队,切回 standalone 模式?"))try{const C=await fetch("/api/teams/leave",{method:"POST"}),k=await C.json();!C.ok||k.error?alert(k.error||`HTTP ${C.status}`):await s()}catch(C){alert(C.message)}};if(b)return e.jsx("div",{style:{padding:24},children:"加载中..."});if(a)return e.jsxs("div",{style:{padding:24,color:"var(--color-error)"},children:["错误: ",a]});if(!t)return e.jsx("div",{style:{padding:24},children:"无法获取 master 身份"});const x=t.role==="member"||m.some(C=>C.myRole==="member");return e.jsxs("div",{style:{padding:24,maxWidth:900},children:[e.jsx("h2",{style:{marginBottom:16},children:"团队"}),e.jsxs("section",{style:{padding:16,marginBottom:24,border:"1px solid var(--color-border)",borderRadius:8,background:"var(--color-surface)"},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:8},children:"本机 master"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 16px",fontSize:13},children:[e.jsx("span",{style:{color:"var(--color-text-secondary)"},children:"团队名"}),e.jsx("span",{style:{fontWeight:500},children:t.teamName}),e.jsx("span",{style:{color:"var(--color-text-secondary)"},children:"masterId"}),e.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:t.id}),e.jsx("span",{style:{color:"var(--color-text-secondary)"},children:"hostname"}),e.jsx("span",{children:t.hostname}),e.jsx("span",{style:{color:"var(--color-text-secondary)"},children:"role"}),e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:4,background:t.role==="standalone"?"var(--color-tag-bg)":"var(--color-primary-bg)",color:t.role==="standalone"?"var(--color-text-secondary)":"var(--color-primary)",fontSize:12,fontWeight:500},children:t.role}),e.jsx("span",{style:{color:"var(--color-text-secondary)"},children:"federation"}),e.jsx("span",{children:t.federationEnabled?"已启用":"未启用"})]}),t.role==="standalone"&&!x&&e.jsxs("div",{style:{marginTop:12,padding:16,background:"var(--color-warning-bg)",borderRadius:4,fontSize:13},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:8},children:"💡 加入上级团队"}),e.jsx("div",{style:{marginBottom:8,color:"var(--color-text-secondary)"},children:"填入协调 master 的地址(ws://host:port),点击加入。协调 master 需先以 coordination 模式启动。"}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsx("input",{type:"text",placeholder:"ws://192.168.1.5:28800",value:h,onChange:C=>c(C.target.value),style:{flex:1,minWidth:220,padding:"6px 10px",border:"1px solid var(--color-border)",borderRadius:4,fontFamily:"ui-monospace, monospace",fontSize:12}}),e.jsx("input",{type:"text",placeholder:"团队名(可选,默认=本机团队名)",value:f,onChange:C=>v(C.target.value),style:{flex:1,minWidth:180,padding:"6px 10px",border:"1px solid var(--color-border)",borderRadius:4,fontSize:12}}),e.jsx("button",{onClick:l,disabled:!h.trim()||y,style:{padding:"6px 16px",background:!h.trim()||y?"var(--color-text-tertiary)":"var(--color-primary)",color:"white",border:"none",borderRadius:4,cursor:y?"not-allowed":"pointer",fontSize:12,fontWeight:500},children:y?"加入中...":"加入"})]}),i&&e.jsxs("div",{style:{marginTop:8,color:"var(--color-error)",fontSize:12},children:["❌ ",i]})]}),x&&e.jsxs("div",{style:{marginTop:12,padding:12,background:"var(--color-success-bg, #f0fdf4)",borderRadius:4,fontSize:13,display:"flex",alignItems:"center",gap:12},children:[e.jsx("span",{children:"✅ 已接入上级团队"}),e.jsx("button",{onClick:_,style:{marginLeft:"auto",padding:"4px 12px",background:"transparent",color:"var(--color-error)",border:"1px solid var(--color-error)",borderRadius:4,cursor:"pointer",fontSize:12},children:"离开团队"})]})]}),m.length===0?e.jsx("section",{style:{padding:16,color:"var(--color-text-secondary)"},children:"尚未加入任何团队。"}):m.map(C=>e.jsxs("section",{style:{padding:16,marginBottom:16,border:"1px solid var(--color-border)",borderRadius:8},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:8},children:[e.jsx("div",{style:{fontWeight:600},children:C.name}),e.jsx("code",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:C.id})]}),e.jsxs("div",{style:{fontSize:12,color:"var(--color-text-secondary)",marginBottom:12},children:["我在团队里的角色:",e.jsx("strong",{children:C.myRole})," · 协调 master:",C.coordEndpoints.join(", ")]}),e.jsxs("div",{style:{fontWeight:500,fontSize:13,marginBottom:8},children:["团队成员(",(j[C.id]||[]).length,")"]}),(j[C.id]||[]).length===0?e.jsx("div",{style:{fontSize:12,color:"var(--color-text-secondary)"},children:"暂无可见 agent"}):e.jsxs("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{textAlign:"left",color:"var(--color-text-secondary)",fontSize:11},children:[e.jsx("th",{style:{padding:"4px 8px",borderBottom:"1px solid var(--color-border)"},children:"名称"}),e.jsx("th",{style:{padding:"4px 8px",borderBottom:"1px solid var(--color-border)"},children:"hostname"}),e.jsx("th",{style:{padding:"4px 8px",borderBottom:"1px solid var(--color-border)"},children:"masterId"}),e.jsx("th",{style:{padding:"4px 8px",borderBottom:"1px solid var(--color-border)"},children:"类型"}),e.jsx("th",{style:{padding:"4px 8px",borderBottom:"1px solid var(--color-border)"},children:"状态"})]})}),e.jsx("tbody",{children:(j[C.id]||[]).map(k=>e.jsxs("tr",{children:[e.jsxs("td",{style:{padding:"6px 8px"},children:[k.isHuman?"👤 ":"🚀 ",k.displayName||k.name]}),e.jsx("td",{style:{padding:"6px 8px",color:"var(--color-text-secondary)"},children:k.hostname}),e.jsx("td",{style:{padding:"6px 8px"},children:e.jsx("code",{style:{fontSize:11},children:k.masterId})}),e.jsx("td",{style:{padding:"6px 8px"},children:k.isHuman?"真人":"Agent"}),e.jsxs("td",{style:{padding:"6px 8px"},children:[e.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:k.online?"var(--color-success)":"var(--color-text-tertiary)",marginRight:6}}),k.online?"在线":"离线"]})]},`${k.masterId}:${k.name}`))})]})]},C.id))]})}const Bs={async listByGroup(t){return ne.get(`/groups/${t}/notes`)},async create(t,o){return ne.post(`/groups/${t}/notes`,o)},async getById(t){return ne.get(`/notes/${t}`)},async update(t,o){return ne.put(`/notes/${t}`,o)},async delete(t){return ne.delete(`/notes/${t}`)}},Qr={async list(t){const o=new URLSearchParams;t!=null&&t.agent&&o.set("agent",t.agent),t!=null&&t.from&&o.set("from",t.from),t!=null&&t.to&&o.set("to",t.to),t!=null&&t.status&&o.set("status",t.status),t!=null&&t.keyword&&o.set("keyword",t.keyword),t!=null&&t.groupId&&o.set("groupId",t.groupId),(t==null?void 0:t.limit)!==void 0&&o.set("limit",String(t.limit)),(t==null?void 0:t.offset)!==void 0&&o.set("offset",String(t.offset)),t!=null&&t.before&&o.set("before",t.before);const m=o.toString();return ne.get(`/messages${m?`?${m}`:""}`)},async send(t){return ne.post("/messages/send",t)},async cancel(t,o,m){return ne.post("/messages/cancel",{requestId:t,agentName:o,reason:m})}};function Jh({myAgentName:t,selectedGroupId:o,directTarget:m}){const{subscribe:S}=wt(),[j,E]=g.useState([]),b=g.useRef(new Map),n=g.useRef(o),a=g.useRef(m),d=g.useRef(t),h=g.useRef(null),c=g.useRef(new Map),f=()=>{h.current=null;const u=c.current;u.size!==0&&(c.current=new Map,E(i=>{let r=i.filter(l=>!l.isLoading),s=i.some(l=>l.isLoading);for(const[l,{from:_,content:x}]of u){const C=`stream_${l}`,k=r.findIndex(p=>p.id===C);k>=0?(r=r.slice(),r[k]={...r[k],content:r[k].content+x},s=!0):(r=[...r,{id:C,from:_,content:x,timestamp:new Date,isIncoming:!0,streaming:!0}],s=!0)}return s?r:i}))},v=()=>{h.current==null&&(h.current=requestAnimationFrame(f))};g.useEffect(()=>{n.current=o,a.current=m,d.current=t}),g.useEffect(()=>S(u=>{var i,r,s,l,_,x,C,k,p,w,R,T,M;if(u.type==="route_result"){const N=u.requestId||"";if(!N)return;const I=u.delivered?"delivered":u.queued?"queued":"failed";E(z=>z.map(G=>G.isIncoming?G:G.id===N?{...G,status:I,statusError:u.error}:N.startsWith(G.id+"_")?G.status==="delivered"?G:{...G,status:I,statusError:u.error}:G));return}if(u.type==="a2a_message"){const N=((i=u.from)==null?void 0:i.name)||"unknown",I=((r=u.payload)==null?void 0:r.message)||"",z=n.current,G=a.current,H=u.requestId||"";((s=u.conversation)==null?void 0:s.type)==="group"&&u.conversation.groupId===z&&E(V=>V.some(L=>L.id===H||L.id===`stream_${H}`)?V:[...V.filter(L=>!L.isLoading),{id:H||`msg_${Date.now()}`,from:N,content:I,timestamp:new Date,isIncoming:!0,mentions:Hs(I),cwd:u.cwd}]),G&&N===G&&((l=u.conversation)==null?void 0:l.type)==="single"&&((_=u.conversation)==null?void 0:_.groupId)===z&&E(V=>V.some(L=>L.id===H||L.id===`stream_${H}`)?V:[...V.filter(L=>!L.isLoading),{id:H||`dm_${Date.now()}`,from:N,content:I,timestamp:new Date,isIncoming:!0,cwd:u.cwd}]);return}if(u.type==="a2a_stream_chunk"){const N=n.current,I=a.current,z=()=>{var A,B;const G=u.requestId||"",H=u.delta||"",V=b.current.get(G);V?V.content+=H:b.current.set(G,{from:((A=u.from)==null?void 0:A.name)||"unknown",content:H});const L=c.current.get(G);L?L.content+=H:c.current.set(G,{from:((B=u.from)==null?void 0:B.name)||"unknown",content:H}),v()};((x=u.conversation)==null?void 0:x.type)==="group"&&u.conversation.groupId===N&&z(),I&&((C=u.from)==null?void 0:C.name)===I&&((k=u.conversation)==null?void 0:k.type)==="single"&&((p=u.conversation)==null?void 0:p.groupId)===N&&z();return}if(u.type==="a2a_stream_end"){const N=n.current,I=a.current,z=d.current,G=u.requestId||"",H=`stream_${G}`,V=u.cancelled===!0;if(b.current.delete(G),h.current!=null&&cancelAnimationFrame(h.current),f(),V){const A=new Date;E(B=>B.map(P=>P.id===H?{...P,streaming:!1,cancelled:!0,cancelledAt:A,cwd:u.cwd??P.cwd}:P));return}const L=A=>{Re.getMessages(A).then(B=>{E(P=>{const U=P.find(O=>O.id===H),Z=B.map(O=>({id:`gm_${O.id}`,from:O.sender,content:O.content,timestamp:new Date(O.created_at+(O.created_at.includes("Z")||O.created_at.includes("+")?"":"Z")),isIncoming:O.sender!==z,mentions:JSON.parse(O.mentions||"[]"),composedPrompt:O.composed_prompt,...O.cancelled_at?{cancelled:!0,cancelledAt:new Date(O.cancelled_at+(O.cancelled_at.includes("Z")||O.cancelled_at.includes("+")?"":"Z"))}:{},...O.truncated?{truncated:O.truncated}:{}})),oe=new Set(Z.map(O=>O.id)),K=U?Z.find(O=>O.from===U.from&&O.content===U.content):null,$=new Set(Z.map(O=>`${O.from}${O.content}`));let D=P.filter(O=>O.id!==H);D=D.filter(O=>{if(O.id.startsWith("gm_"))return oe.has(O.id);const X=`${O.from}${O.content}`;return!$.has(X)}).map(O=>O),K&&!D.some(O=>O.id===K.id)&&(D=[...D,K]);const q=new Set(D.map(O=>O.id)),J=Z.filter(O=>!q.has(O.id));return D=[...D,...J],D.sort((O,X)=>O.timestamp.getTime()-X.timestamp.getTime())})}).catch(()=>{E(B=>B.map(P=>P.id===H?{...P,streaming:!1,cwd:u.cwd??P.cwd}:P))})};((w=u.conversation)==null?void 0:w.type)==="group"&&u.conversation.groupId===N&&N&&L(N),I&&((R=u.from)==null?void 0:R.name)===I&&((T=u.conversation)==null?void 0:T.type)==="single"&&((M=u.conversation)==null?void 0:M.groupId)===N&&N&&L(N)}}),[S]),g.useEffect(()=>{if(!o){E([]);return}Re.getMessages(o).then(u=>{E(u.map(i=>({id:`gm_${i.id}`,from:i.sender,content:i.content,timestamp:new Date(i.created_at+(i.created_at.includes("Z")||i.created_at.includes("+")?"":"Z")),isIncoming:i.sender!==t,mentions:JSON.parse(i.mentions||"[]"),composedPrompt:i.composed_prompt,...i.cancelled_at?{cancelled:!0,cancelledAt:new Date(i.cancelled_at+(i.cancelled_at.includes("Z")||i.cancelled_at.includes("+")?"":"Z"))}:{},...i.truncated?{truncated:i.truncated}:{}})))}).catch(()=>E([]))},[o,t]),g.useEffect(()=>()=>{h.current!=null&&(cancelAnimationFrame(h.current),h.current=null)},[]);const y=g.useCallback(async(u,i)=>{try{await Qr.cancel(u,i)}catch(r){console.warn("cancelStream failed:",r)}},[]);return{messages:j,setMessages:E,cancelStream:y}}function Xh(t,o){const m=g.useRef(o);m.current=o;const[S,j]=g.useState(()=>{const h={};for(const c of o)h[c.id]=c.width;try{const c=localStorage.getItem(t);if(!c)return h;const f=JSON.parse(c);if(!f.widths)return h;const v={};for(const y of o){const u=f.widths[y.id];v[y.id]=typeof u=="number"&&u>=y.min?u:y.width}return v}catch{return h}}),[E,b]=g.useState(!1),n=g.useRef(null);g.useEffect(()=>{if(!E)return;const h=m.current,c=y=>{var u;return((u=h.find(i=>i.id===y))==null?void 0:u.min)??0},f=y=>{const u=n.current;if(!u)return;const i=y.clientX-u.x,r=c(u.leftId),s=c(u.rightId),l=u.leftWidth+u.rightWidth-s,_=Math.max(r,Math.min(l,u.leftWidth+i)),x=_-u.leftWidth,C=u.rightWidth-x;j(k=>({...k,[u.leftId]:_,[u.rightId]:C}))},v=()=>b(!1);return window.addEventListener("mousemove",f),window.addEventListener("mouseup",v),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",v),document.body.style.cursor="",document.body.style.userSelect=""}},[E]),g.useEffect(()=>{if(!E)try{localStorage.setItem(t,JSON.stringify({widths:S}))}catch{}},[E,S,t]);const a=g.useCallback((h,c)=>f=>{f.preventDefault(),n.current={x:f.clientX,leftId:h,rightId:c,leftWidth:S[h],rightWidth:S[c]},b(!0)},[S]),d=g.useCallback(()=>{const h={};for(const c of m.current)h[c.id]=c.width;j(h)},[]);return{widths:S,dragging:E,onSplitterMouseDown:a,reset:d}}const ei="chat_input_history_v1",Zh=200;function ti(){try{const t=localStorage.getItem(ei);if(!t)return[];const o=JSON.parse(t);return Array.isArray(o)?o.filter(m=>typeof m=="string"):[]}catch{return[]}}function Yh(t){const o=t.trim();if(!o)return;const m=ti();if(m[m.length-1]!==o){for(m.push(o);m.length>Zh;)m.shift();try{localStorage.setItem(ei,JSON.stringify(m))}catch{}}}/**
3
+ * @license lucide-react v1.21.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */const si=(...t)=>t.filter((o,m,S)=>!!o&&o.trim()!==""&&S.indexOf(o)===m).join(" ").trim();/**
8
+ * @license lucide-react v1.21.0 - ISC
9
+ *
10
+ * This source code is licensed under the ISC license.
11
+ * See the LICENSE file in the root directory of this source tree.
12
+ */const Qh=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
13
+ * @license lucide-react v1.21.0 - ISC
14
+ *
15
+ * This source code is licensed under the ISC license.
16
+ * See the LICENSE file in the root directory of this source tree.
17
+ */const eu=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(o,m,S)=>S?S.toUpperCase():m.toLowerCase());/**
18
+ * @license lucide-react v1.21.0 - ISC
19
+ *
20
+ * This source code is licensed under the ISC license.
21
+ * See the LICENSE file in the root directory of this source tree.
22
+ */const dr=t=>{const o=eu(t);return o.charAt(0).toUpperCase()+o.slice(1)};/**
23
+ * @license lucide-react v1.21.0 - ISC
24
+ *
25
+ * This source code is licensed under the ISC license.
26
+ * See the LICENSE file in the root directory of this source tree.
27
+ */var ks={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
28
+ * @license lucide-react v1.21.0 - ISC
29
+ *
30
+ * This source code is licensed under the ISC license.
31
+ * See the LICENSE file in the root directory of this source tree.
32
+ */const tu=t=>{for(const o in t)if(o.startsWith("aria-")||o==="role"||o==="title")return!0;return!1},su=g.createContext({}),ru=()=>g.useContext(su),iu=g.forwardRef(({color:t,size:o,strokeWidth:m,absoluteStrokeWidth:S,className:j="",children:E,iconNode:b,...n},a)=>{const{size:d=24,strokeWidth:h=2,absoluteStrokeWidth:c=!1,color:f="currentColor",className:v=""}=ru()??{},y=S??c?Number(m??h)*24/Number(o??d):m??h;return g.createElement("svg",{ref:a,...ks,width:o??d??ks.width,height:o??d??ks.height,stroke:t??f,strokeWidth:y,className:si("lucide",v,j),...!E&&!tu(n)&&{"aria-hidden":"true"},...n},[...b.map(([u,i])=>g.createElement(u,i)),...Array.isArray(E)?E:[E]])});/**
33
+ * @license lucide-react v1.21.0 - ISC
34
+ *
35
+ * This source code is licensed under the ISC license.
36
+ * See the LICENSE file in the root directory of this source tree.
37
+ */const Bt=(t,o)=>{const m=g.forwardRef(({className:S,...j},E)=>g.createElement(iu,{ref:E,iconNode:o,className:si(`lucide-${Qh(dr(t))}`,`lucide-${t}`,S),...j}));return m.displayName=dr(t),m};/**
38
+ * @license lucide-react v1.21.0 - ISC
39
+ *
40
+ * This source code is licensed under the ISC license.
41
+ * See the LICENSE file in the root directory of this source tree.
42
+ */const nu=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],ou=Bt("chevron-down",nu);/**
43
+ * @license lucide-react v1.21.0 - ISC
44
+ *
45
+ * This source code is licensed under the ISC license.
46
+ * See the LICENSE file in the root directory of this source tree.
47
+ */const au=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],lu=Bt("chevron-up",au);/**
48
+ * @license lucide-react v1.21.0 - ISC
49
+ *
50
+ * This source code is licensed under the ISC license.
51
+ * See the LICENSE file in the root directory of this source tree.
52
+ */const cu=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],du=Bt("copy",cu);/**
53
+ * @license lucide-react v1.21.0 - ISC
54
+ *
55
+ * This source code is licensed under the ISC license.
56
+ * See the LICENSE file in the root directory of this source tree.
57
+ */const hu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],uu=Bt("file-text",hu);/**
58
+ * @license lucide-react v1.21.0 - ISC
59
+ *
60
+ * This source code is licensed under the ISC license.
61
+ * See the LICENSE file in the root directory of this source tree.
62
+ */const _u=[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]],ri=Bt("reply",_u);/**
63
+ * @license lucide-react v1.21.0 - ISC
64
+ *
65
+ * This source code is licensed under the ISC license.
66
+ * See the LICENSE file in the root directory of this source tree.
67
+ */const fu=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Us=Bt("search",fu);/**
68
+ * @license lucide-react v1.21.0 - ISC
69
+ *
70
+ * This source code is licensed under the ISC license.
71
+ * See the LICENSE file in the root directory of this source tree.
72
+ */const pu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ii=Bt("square",pu),mu="_md_yt9tg_1",gu="_lightbox_yt9tg_108",vu="_lightboxImg_yt9tg_133",yu="_lightboxClose_yt9tg_142",xu="_cursor_yt9tg_164",bu="_thinkingBlock_yt9tg_176",Su="_thinkingSummary_yt9tg_184",Cu="_thinkingContent_yt9tg_209",wu="_toolBlock_yt9tg_221",ju="_toolSummary_yt9tg_229",ku="_toolCommand_yt9tg_277",Eu="_toolHint_yt9tg_285",Nu="_toolContent_yt9tg_292",Ru="_toolCommandFull_yt9tg_298",Lu="_toolResult_yt9tg_311",Tu="_groupedToolItem_yt9tg_329",Iu="_groupedCommandRow_yt9tg_333",Au="_expandable_yt9tg_344",Du="_expanded_yt9tg_355",Bu="_groupedCommandText_yt9tg_367",Mu="_groupedToolResult_yt9tg_376",$u="_patchPill_yt9tg_400",Pu="_diffPre_yt9tg_412",Ou="_diffLine_yt9tg_424",Hu="_diffAdd_yt9tg_430",Fu="_diffDel_yt9tg_435",zu="_diffHunk_yt9tg_440",Wu="_diffMeta_yt9tg_445",Uu="_diffStatAdd_yt9tg_450",qu="_diffStatDel_yt9tg_455",Vu="_askPill_yt9tg_460",Gu="_replyTag_yt9tg_476",Ku="_askBody_yt9tg_493",Ju="_askQuestion_yt9tg_500",Xu="_askQuestionTitle_yt9tg_506",Zu="_askHeader_yt9tg_515",Yu="_askOptions_yt9tg_527",Qu="_askOption_yt9tg_527",e_="_askOptionSelected_yt9tg_547",t_="_askOptionLabel_yt9tg_552",s_="_askOptionDesc_yt9tg_563",r_="_askAnswerCustom_yt9tg_569",i_="_askAnswerLabel_yt9tg_578",de={md:mu,lightbox:gu,lightboxImg:vu,lightboxClose:yu,cursor:xu,thinkingBlock:bu,thinkingSummary:Su,thinkingContent:Cu,toolBlock:wu,toolSummary:ju,toolCommand:ku,toolHint:Eu,toolContent:Nu,toolCommandFull:Ru,toolResult:Lu,groupedToolItem:Tu,groupedCommandRow:Iu,expandable:Au,expanded:Du,groupedCommandText:Bu,groupedToolResult:Mu,patchPill:$u,diffPre:Pu,diffLine:Ou,diffAdd:Hu,diffDel:Fu,diffHunk:zu,diffMeta:Wu,diffStatAdd:Uu,diffStatDel:qu,askPill:Vu,replyTag:Gu,askBody:Ku,askQuestion:Ju,askQuestionTitle:Xu,askHeader:Zu,askOptions:Yu,askOption:Qu,askOptionSelected:e_,askOptionLabel:t_,askOptionDesc:s_,askAnswerCustom:r_,askAnswerLabel:i_},n_="_status_7tpw1_1",o_="_statusDone_7tpw1_20",a_="_dot_7tpw1_27",l_="_dotDone_7tpw1_37",c_="_inline_7tpw1_42",d_="_inlineDot_7tpw1_51",h_="_label_7tpw1_56",Nt={status:n_,statusDone:o_,dot:a_,dotDone:l_,inline:c_,inlineDot:d_,label:h_};function Wt({content:t,done:o,variant:m="default"}){return e.jsxs("div",{className:`${Nt.status} ${o?Nt.statusDone:""} ${m==="inline"?Nt.inline:""}`,"aria-live":"polite",children:[e.jsx("span",{className:`${Nt.dot} ${o?Nt.dotDone:""} ${m==="inline"?Nt.inlineDot:""}`}),e.jsx("span",{className:Nt.label,children:t})]})}const u_=/@([\w一-鿿][\w.一-鿿-]*)/g,__=new RegExp("(?<![\\w#])#reply\\b","g");function pt(t){t.stopPropagation()}function f_(t,o,m,S,j,E){const b=[];let n=0,a=!1,d;const h=new RegExp(`(${u_.source})|${__.source}`,"g");for(;(d=h.exec(t))!==null;){let c=!1,f=!1,v="";d[1]!=null?(v=d[2],o(v)&&(c=!0)):f=!0,!(!c&&!f)&&(a=!0,d.index>n&&b.push(t.slice(n,d.index)),c?E.firstDone?b.push(`@${v}`):(E.firstDone=!0,b.push(e.jsxs("span",{className:m,children:["@",v]},`${j}-${d.index}`))):b.push(e.jsx("span",{className:S,children:"🧑‍💼 星期五 等待中"},`${j}-${d.index}`)),n=d.index+d[0].length)}return a?(n<t.length&&b.push(t.slice(n)),e.jsx(e.Fragment,{children:b})):t}function ni(t,o,m,S,j="mention",E={firstDone:!1}){return g.Children.map(t,(b,n)=>{if(typeof b=="string")return f_(b,o,m,S,`${j}-${n}`,E);if(!g.isValidElement(b))return b;const a=b;return a.type==="code"||a.type==="pre"?a:a.props&&a.props.children!=null?g.cloneElement(a,{children:ni(a.props.children,o,m,S,`${j}-${n}`,E)}):a})}const p_=[{open:"[thinking]",close:"[/thinking]",type:"thinking"},{open:"[tool:exec]",close:"[/tool:exec]",type:"tool-exec"},{open:"[tool-result:exec]",close:"[/tool-result:exec]",type:"tool-result-exec"},{open:"[tool:patch]",close:"[/tool:patch]",type:"tool-patch"},{open:"[tool:ask]",close:"[/tool:ask]",type:"tool-ask"},{open:"[tool-result:ask]",close:"[/tool-result:ask]",type:"tool-result-ask"},{open:"[status:thinking]",close:"[/status:thinking]",type:"status-thinking"}];function m_(t){const o=[];let m=0;for(;m<t.length;){let S=-1,j=null;for(const n of p_){const a=t.indexOf(n.open,m);a!==-1&&(S===-1||a<S)&&(S=a,j=n)}if(S===-1||!j){m<t.length&&o.push({type:"text",content:t.slice(m)});break}S>m&&o.push({type:"text",content:t.slice(m,S)});const E=S+j.open.length,b=t.indexOf(j.close,E);if(b===-1){o.push({type:j.type,content:t.slice(E),unclosed:!0});break}o.push({type:j.type,content:t.slice(E,b)}),m=b+j.close.length}return o}function g_(t){const o=[],m=new Set;for(let S=0;S<t.length;S++){const j=t[S];if(j.type==="tool-exec"){let E,b=j.unclosed;for(let n=S+1;n<t.length;n++){const a=t[n];if(a.type==="tool-result-exec"&&!m.has(n)){E=a.content,b=b||a.unclosed,m.add(n);break}if(a.type==="tool-patch"||a.type==="tool-ask"||a.type==="text"&&a.content.trim()!=="")break}o.push({type:"tool-call",command:j.content,result:E,streaming:b})}else if(j.type==="tool-result-exec")m.has(S)||(m.add(S),o.push({type:"tool-call",command:"(已省略命令记录)",result:j.content,streaming:j.unclosed}));else if(j.type==="tool-ask"){let E,b=j.unclosed;for(let n=S+1;n<t.length;n++){const a=t[n];if(a.type==="tool-result-ask"&&!m.has(n)){E=a.content,b=b||a.unclosed,m.add(n);break}if(a.type==="tool-exec"||a.type==="tool-patch"||a.type==="text"&&a.content.trim()!=="")break}o.push({type:"tool-ask",question:j.content,answer:E,streaming:b})}else j.type==="tool-result-ask"?m.has(S)||(m.add(S),o.push({type:"tool-ask",question:"",answer:j.content,streaming:j.unclosed})):j.type==="tool-patch"?o.push({type:"tool-patch",content:j.content}):o.push(j)}return o}function v_(t){let o=null;const m=[];for(const S of t)S.type==="status-thinking"?o=S.content:m.push(S);return{status:o,rest:m}}function y_(t){const o=[];for(const m of t){const S=o[o.length-1];m.type==="text"&&S&&S.type==="text"?S.content+=m.content:o.push(m)}return o}function x_(t){const o=[];let m=[];const S=()=>{m.length!==0&&(m.length===1?o.push({type:"tool-call",...m[0]}):o.push({type:"tool-call-group",calls:m,streaming:m.some(j=>j.streaming)}),m=[])};for(const j of t)j.type==="tool-call"?m.push({command:j.command,result:j.result,streaming:j.streaming}):j.type==="text"&&j.content.trim()===""||(S(),o.push(j));return S(),o}function b_(t){const o=[],m=[];for(const j of t)j.type==="tool-call"?o.push({command:j.command,result:j.result,streaming:j.streaming}):m.push(j);if(o.length===0)return t;const S=[];return o.length===1?S.push({type:"tool-call",...o[0]}):S.push({type:"tool-call-group",calls:o,streaming:o.some(j=>j.streaming)}),S.push(...m),S}const dt=g.memo(function({content:o,streaming:m,mentionMembers:S,mentionClassName:j,hideStatus:E}){const{status:b,rest:n}=g.useMemo(()=>{const d=g_(m_(o)),{status:h,rest:c}=v_(d),f=y_(c);return{status:h,rest:m?x_(f):b_(f)}},[o,m]),a=g.useMemo(()=>{const d=!!S&&S.length>0,h=o.includes("#reply");if(!d&&!h)return;const c=new Set(S??[]),f=u=>c.has(u),v=de.replyTag,y=u=>function({children:r,node:s,...l}){return g.createElement(u,l,ni(r,f,j,v))};return{p:y("p"),li:y("li"),em:y("em"),strong:y("strong"),a:y("a"),td:y("td"),th:y("th"),h1:y("h1"),h2:y("h2"),h3:y("h3"),h4:y("h4"),h5:y("h5"),h6:y("h6"),blockquote:y("blockquote")}},[S,j,o]);return n.length===0&&!b||n.length===1&&n[0].type==="text"&&!b?e.jsxs("div",{className:de.md,children:[b&&!E&&e.jsx(Wt,{content:b,done:!m}),e.jsx(Ys,{remarkPlugins:[Qs],components:{...a,img:ur},children:o}),m&&e.jsx("span",{className:de.cursor,children:"|"})]}):e.jsxs("div",{className:de.md,children:[b&&!E&&e.jsx(Wt,{content:b,done:!m}),n.map((d,h)=>{switch(d.type){case"text":return e.jsx(Ys,{remarkPlugins:[Qs],components:{...a,img:ur},children:d.content},h);case"thinking":return e.jsx(S_,{content:d.content,streaming:m},h);case"tool-call":return e.jsx(C_,{command:d.command,result:d.result,streaming:d.streaming},h);case"tool-call-group":return e.jsx(w_,{calls:d.calls,streaming:d.streaming},h);case"tool-patch":return e.jsx(k_,{content:d.content,streaming:m},h);case"tool-ask":return e.jsx(E_,{question:d.question,answer:d.answer,streaming:d.streaming},h);case"status-thinking":return null}}),m&&e.jsx("span",{className:de.cursor,children:"|"})]})});function S_({content:t,streaming:o}){const[m,S]=g.useState(!1);return g.useEffect(()=>{o||S(!1)},[o]),e.jsxs("details",{className:de.thinkingBlock,open:m,onClick:pt,onToggle:j=>S(j.target.open),children:[e.jsx("summary",{className:de.thinkingSummary,onClick:pt,children:"思考"}),m&&e.jsx("div",{className:de.thinkingContent,children:t})]})}function C_({command:t,result:o,streaming:m}){const[S,j]=g.useState(!1);g.useEffect(()=>{m||j(!1)},[m]);const E=o?o.split(`
73
+ `).length:0,b=o?` ↳ ${E} ${E===1?"line":"lines"}`:m?" …":"";return e.jsxs("details",{className:de.toolBlock,open:S,onClick:pt,onToggle:n=>j(n.target.open),children:[e.jsxs("summary",{className:de.toolSummary,onClick:pt,children:[e.jsx("span",{className:de.toolCommand,children:t.trim()||"(empty command)"}),b&&e.jsx("span",{className:de.toolHint,children:b})]}),S&&e.jsxs("div",{className:de.toolContent,children:[e.jsx("pre",{className:de.toolCommandFull,children:t}),o!==void 0&&e.jsx("pre",{className:de.toolResult,children:o||"(no output)"})]})]})}function w_({calls:t,streaming:o}){const[m,S]=g.useState(!1);g.useEffect(()=>{o||S(!1)},[o]);const j=t.reduce((f,v)=>f+(v.result?v.result.split(`
74
+ `).length:0),0),b=t.some(f=>f.streaming)?" …":j>0?` ↳ output (${j} ${j===1?"line":"lines"} total)`:"",n=2,a=40,d=f=>{const v=f.trim()||"(empty)";return v.length>a?v.slice(0,a-1)+"…":v},h=t.slice(0,n).map(f=>d(f.command)).join(", "),c=t.length>n?` +${t.length-n} more`:"";return e.jsxs("details",{className:de.toolBlock,open:m,onClick:pt,onToggle:f=>S(f.target.open),children:[e.jsxs("summary",{className:de.toolSummary,onClick:pt,children:[e.jsxs("span",{className:de.toolCommand,children:["Ran ",t.length," commands: ",h,c]}),b&&e.jsx("span",{className:de.toolHint,children:b})]}),m&&e.jsx("div",{className:de.toolContent,children:t.map((f,v)=>e.jsx(j_,{call:f,isLast:v===t.length-1},v))})]})}function j_({call:t}){const[o,m]=g.useState(!1),S=t.result!==void 0,j=t.result?t.result.split(`
75
+ `).length:0,E=()=>{S&&m(b=>!b)};return e.jsxs("div",{className:de.groupedToolItem,children:[e.jsxs("div",{className:`${de.groupedCommandRow} ${S?de.expandable:""} ${o?de.expanded:""}`,onClick:S?(b=>{b.stopPropagation(),E()}):void 0,role:S?"button":void 0,children:[e.jsx("span",{className:de.groupedCommandText,children:t.command.trim()||"(empty command)"}),S&&e.jsxs("span",{className:de.toolHint,children:[o?"▾":"▸"," ",j," ",j===1?"line":"lines"]})]}),o&&S&&e.jsx("pre",{className:de.groupedToolResult,children:t.result||"(no output)"})]})}function k_({content:t,streaming:o}){const[m,S]=g.useState(!1);g.useEffect(()=>{o||S(!1)},[o]);const j=t.split(`
76
+ `),E=j.find(h=>h.startsWith("+++ ")),b=E?E.slice(4).trim():"",n=!b&&j.length===1&&j[0].trim().length>0,a=b||(n?j[0].trim():""),d=j.reduce((h,c)=>(c.startsWith("+")&&!c.startsWith("+++")?h.add++:c.startsWith("-")&&!c.startsWith("---")&&h.del++,h),{add:0,del:0});return e.jsxs("details",{className:de.toolBlock,open:m,onClick:pt,onToggle:h=>S(h.target.open),children:[e.jsxs("summary",{className:de.toolSummary,onClick:pt,children:[e.jsx("span",{className:de.patchPill,children:"📝 apply patch"}),a&&e.jsx("span",{className:de.toolCommand,children:a}),e.jsxs("span",{className:de.toolHint,children:[d.add>0&&e.jsxs("span",{className:de.diffStatAdd,children:["+",d.add]}),d.add>0&&d.del>0&&" ",d.del>0&&e.jsxs("span",{className:de.diffStatDel,children:["−",d.del]}),n&&e.jsx("span",{className:de.toolHint,children:" (旧记录无 diff 内容)"})]})]}),m&&!n&&e.jsx("div",{className:de.toolContent,children:e.jsx("pre",{className:de.diffPre,children:j.map((h,c)=>{let f=de.diffLine;return h.startsWith("+++")||h.startsWith("---")?f=`${de.diffLine} ${de.diffMeta}`:h.startsWith("@@")?f=`${de.diffLine} ${de.diffHunk}`:h.startsWith("+")?f=`${de.diffLine} ${de.diffAdd}`:h.startsWith("-")?f=`${de.diffLine} ${de.diffDel}`:h.startsWith("***")&&(f=`${de.diffLine} ${de.diffMeta}`),e.jsxs("span",{className:f,children:[h||" ",`
77
+ `]},c)})})})]})}function hr(t){try{return JSON.parse(t)}catch{return null}}function E_({question:t,answer:o,streaming:m}){var f;const[S,j]=g.useState(!1);g.useEffect(()=>{m||j(!1)},[m]);const E=hr(t),b=(E==null?void 0:E.questions)??[],n=o?hr(o):null,a=(n==null?void 0:n.answers)??null,d=((f=b[0])==null?void 0:f.question)??"询问用户",h=b.length>1?` (+${b.length-1})`:"",c=a?` ↳ ${Object.keys(a).length} 项已回答`:m?" …":" 等待回答";return e.jsxs("details",{className:de.toolBlock,open:S,onClick:pt,onToggle:v=>j(v.target.open),children:[e.jsxs("summary",{className:de.toolSummary,onClick:pt,children:[e.jsx("span",{className:de.askPill,children:"❓ ask"}),e.jsxs("span",{className:de.toolCommand,children:[d,h]}),e.jsx("span",{className:de.toolHint,children:c})]}),S&&e.jsx("div",{className:de.toolContent,children:b.length===0?e.jsx("pre",{className:de.toolResult,children:t||"(empty)"}):e.jsx("div",{className:de.askBody,children:b.map((v,y)=>{var i;const u=a&&v.question?a[v.question]:void 0;return e.jsxs("div",{className:de.askQuestion,children:[e.jsxs("div",{className:de.askQuestionTitle,children:[v.header&&e.jsx("span",{className:de.askHeader,children:v.header}),e.jsx("span",{children:v.question})]}),v.options&&v.options.length>0&&e.jsx("ul",{className:de.askOptions,children:v.options.map((r,s)=>{const l=u===r.label;return e.jsxs("li",{className:l?`${de.askOption} ${de.askOptionSelected}`:de.askOption,children:[e.jsx("span",{className:de.askOptionLabel,children:r.label}),r.description&&e.jsx("span",{className:de.askOptionDesc,children:r.description})]},s)})}),u&&!((i=v.options)!=null&&i.some(r=>r.label===u))&&e.jsxs("div",{className:de.askAnswerCustom,children:[e.jsx("span",{className:de.askAnswerLabel,children:"回答:"}),u]})]},y)})})})]})}function ur({src:t,alt:o}){const m=typeof t=="string"?t:void 0,[S,j]=g.useState(!1);return g.useEffect(()=>{if(!S)return;const E=n=>{n.key==="Escape"&&j(!1)};window.addEventListener("keydown",E);const b=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",E),document.body.style.overflow=b}},[S]),e.jsxs(e.Fragment,{children:[e.jsx("img",{src:m,alt:o??"",loading:"lazy",onClick:()=>m&&j(!0)}),S&&m&&Fr.createPortal(e.jsxs("div",{className:de.lightbox,onClick:()=>j(!1),role:"dialog","aria-modal":"true","aria-label":o??"图片预览",children:[e.jsx("img",{src:m,alt:o??"",className:de.lightboxImg,onClick:E=>E.stopPropagation()}),e.jsx("button",{type:"button",className:de.lightboxClose,onClick:()=>j(!1),"aria-label":"关闭",children:"✕"})]}),document.body)]})}function oi({value:t,setValue:o,textareaRef:m,disabled:S}){const j=g.useRef(-1),E=g.useRef(""),b=g.useRef(null);function n(h){h.style.height="auto",h.style.height=Math.min(h.scrollHeight,160)+"px"}function a(h){o(h),b.current=h,requestAnimationFrame(()=>{const c=m.current;if(!c)return;const f=c.value.length;c.setSelectionRange(f,f),n(c)})}function d(h){if(S||h.key!=="ArrowUp"&&h.key!=="ArrowDown"||h.shiftKey||h.metaKey||h.ctrlKey||h.altKey)return!1;const c=m.current;if(!c)return!1;b.current!==null&&t!==b.current&&(j.current=-1,E.current="",b.current=null);const f=c.selectionStart,v=c.selectionEnd,y=f===0&&v===0,u=f===c.value.length&&v===c.value.length,i=ti();if(i.length===0)return!1;if(h.key==="ArrowUp"){if(!y)return!1;let s;if(j.current===-1)E.current=t,s=i.length-1;else if(j.current>0)s=j.current-1;else return h.preventDefault(),!0;return j.current=s,h.preventDefault(),a(i[s]),!0}if(!u||j.current===-1)return!1;let r;return j.current<i.length-1?(j.current+=1,r=i[j.current]):(j.current=-1,r=E.current,E.current=""),h.preventDefault(),a(r),!0}return{handleKeyDown:d}}const N_={"rotom-cli":"rotom-cli","agent-role":"agent-role","group-basic":"group-basic","group-guidance":"group-guidance",cwd:"cwd",task:"task"};function qs({open:t,messageLabel:o,composedPrompt:m,onClose:S}){return e.jsx(De,{open:t,title:o?`该消息的 prompt 构成 · ${o}`:"该消息的 prompt 构成",onClose:S,children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:"4px 0 12px"},children:[e.jsxs("div",{style:{fontSize:12,color:"var(--color-text-secondary, #666)"},children:["生成时间: ",m.generated_at," · 版本: ",m.prompt_version]}),m.layers.map((j,E)=>e.jsxs("details",{open:E===0,style:{border:"1px solid var(--color-border, #e5e7eb)",borderRadius:6,padding:"8px 12px",background:"var(--color-bg-secondary, #fafafa)"},children:[e.jsxs("summary",{style:{cursor:"pointer",fontSize:13,fontWeight:600,color:"var(--color-navy, #1f2937)",listStyle:"none",userSelect:"none"},children:[e.jsx("span",{style:{marginRight:8},children:"▶"}),"Layer: ",N_[j.layer]||j.layer,j.layer==="rotom-cli"&&e.jsxs("span",{style:{marginLeft:8,color:"var(--color-text-secondary, #6b7280)",fontWeight:400},children:["[",m.prompt_version,"]"]})]}),e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"var(--color-text-secondary, #6b7280)"},children:["source: ",j.source]}),e.jsx("pre",{style:{margin:"8px 0 0",padding:10,background:"#0b1020",color:"#e5e7eb",borderRadius:4,fontSize:12,lineHeight:1.55,maxHeight:320,overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"},children:j.content})]},`${j.layer}-${E}`)),e.jsxs("details",{style:{border:"1px solid var(--color-border, #e5e7eb)",borderRadius:6,padding:"8px 12px",background:"var(--color-bg-secondary, #fafafa)"},children:[e.jsxs("summary",{style:{cursor:"pointer",fontSize:13,fontWeight:600,color:"var(--color-navy, #1f2937)",listStyle:"none",userSelect:"none"},children:[e.jsx("span",{style:{marginRight:8},children:"▶"}),"final (拼好的完整 prompt)"]}),e.jsx("pre",{style:{margin:"8px 0 0",padding:10,background:"#0b1020",color:"#e5e7eb",borderRadius:4,fontSize:12,lineHeight:1.55,maxHeight:480,overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"},children:m.final})]})]})})}const R_="_chatArea_dx40h_1",L_="_chatHeader_dx40h_10",T_="_chatHeaderLeft_dx40h_22",I_="_chatTitle_dx40h_31",A_="_memberAvatars_dx40h_47",D_="_memberAvatar_dx40h_47",B_="_online_dx40h_67",M_="_chatHeaderActions_dx40h_72",$_="_connectionBar_dx40h_78",P_="_statusDot_dx40h_90",O_="_connected_dx40h_96",H_="_connecting_dx40h_97",F_="_disconnected_dx40h_98",z_="_conflict_dx40h_99",W_="_pulse_dx40h_1",U_="_messagesArea_dx40h_107",q_="_truncatedChip_dx40h_114",V_="_emptyChat_dx40h_126",G_="_messageRow_dx40h_136",K_="_messageAvatar_dx40h_144",J_="_avatarPlaceholder_dx40h_150",X_="_continuation_dx40h_157",Z_="_messageBubble_dx40h_163",Y_="_messageActionBtn_dx40h_175",Q_="_stopBtn_dx40h_204",ef="_messageCancelledFooter_dx40h_233",tf="_cancelledIcon_dx40h_244",sf="_incoming_dx40h_248",rf="_mentionMeBubble_dx40h_258",nf="_outgoing_dx40h_163",of="_messageSender_dx40h_276",af="_senderLeft_dx40h_290",lf="_senderMeta_dx40h_298",cf="_senderActions_dx40h_309",df="_senderInfo_dx40h_315",hf="_senderNameOutgoing_dx40h_322",uf="_senderTime_dx40h_327",_f="_systemRow_dx40h_333",ff="_systemBubble_dx40h_334",pf="_systemSummary_dx40h_342",mf="_messageStatus_dx40h_350",gf="_messageCwd_dx40h_356",vf="_status_pending_dx40h_368",yf="_status_delivered_dx40h_372",xf="_status_queued_dx40h_376",bf="_status_failed_dx40h_380",Sf="_messageContent_dx40h_385",Cf="_messageContentWrapper_dx40h_399",wf="_collapsed_dx40h_393",jf="_collapseToggle_dx40h_430",kf="_mention_dx40h_258",Ef="_messageTimestamp_dx40h_231",Nf="_workingDirChip_dx40h_527",Rf="_loadingDots_dx40h_555",Lf="_dot_dx40h_562",Tf="_dotBounce_dx40h_1",If="_inputArea_dx40h_579",Af="_messageInput_dx40h_589",Df="_sendBtn_dx40h_613",Bf="_fileInputHidden_dx40h_644",Mf="_uploadBtn_dx40h_641",$f="_dropOverlay_dx40h_691",Pf="_dropHint_dx40h_704",Of="_mentionDropdown_dx40h_715",Hf="_mentionItem_dx40h_730",Ff="_mentionItemActive_dx40h_747",zf="_mentionOnlineDot_dx40h_753",Wf="_mentionOfflineDot_dx40h_760",Uf="_slashItem_dx40h_768",qf="_slashName_dx40h_775",Vf="_slashArgHint_dx40h_780",Gf="_slashDesc_dx40h_786",Kf="_slashListPanel_dx40h_794",Jf="_slashListHeader_dx40h_810",Xf="_slashListTitle_dx40h_819",Zf="_slashListClose_dx40h_825",Yf="_slashListBody_dx40h_840",Qf="_slashListEmpty_dx40h_845",ep="_slashListRow_dx40h_852",tp="_slashListRowActive_dx40h_865",sp="_slashListRowTitle_dx40h_871",rp="_slashListRowMeta_dx40h_878",ip="_slashListRowDesc_dx40h_887",np="_slashListRowTime_dx40h_897",op="_slashBadge_dx40h_903",ap="_slashToast_dx40h_913",lp="_slashToastError_dx40h_928",cp="_archivedBanner_dx40h_934",dp="_messagesTruncatedBanner_dx40h_945",hp="_messagesTruncatedButton_dx40h_957",up="_archivedNotice_dx40h_974",_p="_banner_dx40h_984",fp="_bannerButton_dx40h_1002",pp="_chatHeaderSub_dx40h_1019",mp="_connectionDot_dx40h_1031",gp="_connectionText_dx40h_1056",vp="_connectionSep_dx40h_1060",yp="_connectionIdentity_dx40h_1065",xp="_chatHeaderCollapsed_dx40h_1071",bp="_chatHeaderBar_dx40h_1075",Sp="_headerCollapseBtn_dx40h_1092",Cp="_contextMenu_dx40h_1119",wp="_contextMenuItem_dx40h_1130",jp="_contextMenuSeparator_dx40h_1151",se={chatArea:R_,chatHeader:L_,chatHeaderLeft:T_,chatTitle:I_,memberAvatars:A_,memberAvatar:D_,online:B_,chatHeaderActions:M_,connectionBar:$_,statusDot:P_,connected:O_,connecting:H_,disconnected:F_,conflict:z_,pulse:W_,messagesArea:U_,truncatedChip:q_,emptyChat:V_,messageRow:G_,messageAvatar:K_,avatarPlaceholder:J_,continuation:X_,messageBubble:Z_,messageActionBtn:Y_,stopBtn:Q_,messageCancelledFooter:ef,cancelledIcon:tf,incoming:sf,mentionMeBubble:rf,outgoing:nf,messageSender:of,senderLeft:af,senderMeta:lf,senderActions:cf,senderInfo:df,senderNameOutgoing:hf,senderTime:uf,systemRow:_f,systemBubble:ff,systemSummary:pf,messageStatus:mf,messageCwd:gf,status_pending:vf,status_delivered:yf,status_queued:xf,status_failed:bf,messageContent:Sf,messageContentWrapper:Cf,collapsed:wf,collapseToggle:jf,mention:kf,messageTimestamp:Ef,workingDirChip:Nf,loadingDots:Rf,dot:Lf,dotBounce:Tf,inputArea:If,messageInput:Af,sendBtn:Df,fileInputHidden:Bf,uploadBtn:Mf,dropOverlay:$f,dropHint:Pf,mentionDropdown:Of,mentionItem:Hf,mentionItemActive:Ff,mentionOnlineDot:zf,mentionOfflineDot:Wf,slashItem:Uf,slashName:qf,slashArgHint:Vf,slashDesc:Gf,slashListPanel:Kf,slashListHeader:Jf,slashListTitle:Xf,slashListClose:Zf,slashListBody:Yf,slashListEmpty:Qf,slashListRow:ep,slashListRowActive:tp,slashListRowTitle:sp,slashListRowMeta:rp,slashListRowDesc:ip,slashListRowTime:np,slashBadge:op,slashToast:ap,slashToastError:lp,archivedBanner:cp,messagesTruncatedBanner:dp,messagesTruncatedButton:hp,archivedNotice:up,banner:_p,bannerButton:fp,chatHeaderSub:pp,connectionDot:mp,connectionText:gp,connectionSep:vp,connectionIdentity:yp,chatHeaderCollapsed:xp,chatHeaderBar:bp,headerCollapseBtn:Sp,contextMenu:Cp,contextMenuItem:wp,contextMenuSeparator:jp};function kp(t){let o=null;const m=/\[status:thinking\]([\s\S]*?)\[\/status:thinking\]/g;let S;for(;(S=m.exec(t))!==null;)o=S[1];return o}function Ep({directTarget:t,myAgentName:o,messages:m,agents:S,connectionStatus:j,onSendMessage:E,onCancelStream:b}){const n=g.useRef(null),a=g.useRef(null),d=g.useRef(null),[h,c]=g.useState(""),[f,v]=g.useState(null),y=g.useRef(!1),u=g.useRef(!0),i=120,r=g.useCallback(()=>{const _=a.current;if(!_)return;const x=_.scrollHeight-_.scrollTop-_.clientHeight;u.current=x<i},[]);g.useEffect(()=>{var _;u.current&&((_=n.current)==null||_.scrollIntoView({behavior:"smooth"}))},[m]),g.useEffect(()=>{u.current=!0},[t]),g.useEffect(()=>{!h&&d.current&&(d.current.style.height="auto")},[h]);const{handleKeyDown:s}=oi({value:h,setValue:c,textareaRef:d}),l=()=>{if(y.current)return;const _=h.trim();!_||j!=="connected"||(y.current=!0,E(_),c(""),u.current=!0,setTimeout(()=>{y.current=!1},250))};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:a,className:se.messagesArea,onScroll:r,children:[m.length===0?e.jsxs("div",{className:se.emptyChat,children:["与 ",t," 开始一对一对话"]}):m.map((_,x)=>{var T,M;if(_.truncated)return e.jsxs("div",{className:se.truncatedChip,children:["已省略 ",_.truncated.omitted," 条较早消息"]},_.id);const C=m[x-1],k=!!C&&!C.truncated&&C.from===_.from,p=!!_.composedPrompt,w=!!(_.streaming&&_.isIncoming&&_.id.startsWith("stream_")&&b),R=()=>{if(!b)return;const N=_.id.startsWith("stream_")?_.id.slice(7):_.id;b(N,_.from)};return e.jsxs("div",{className:`${se.messageRow} ${_.isIncoming?"":se.outgoing} ${k?se.continuation:""}`,children:[k?e.jsx("div",{className:se.avatarPlaceholder,"aria-hidden":"true"}):e.jsx(At,{name:_.isIncoming?_.from:o,src:(T=S.find(N=>N.name===(_.isIncoming?_.from:o)))==null?void 0:T.avatar_url,size:30,className:se.messageAvatar}),e.jsxs("div",{className:`${se.messageBubble} ${_.isIncoming?se.incoming:se.outgoing}`,children:[e.jsxs("div",{className:se.messageSender,children:[e.jsx("div",{className:se.senderLeft,children:_.isIncoming?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:se.senderName,children:_.from}),(()=>{const N=kp(_.content);return N?e.jsx(Wt,{content:N,done:!_.streaming,variant:"inline"}):null})()]}):e.jsx("span",{className:`${se.senderName} ${se.senderNameOutgoing}`,children:o})}),e.jsxs("div",{className:se.senderMeta,children:[e.jsxs("span",{className:se.senderActions,children:[p&&e.jsx("span",{className:se.messageActionBtn,role:"button",tabIndex:0,onClick:()=>v(_),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),v(_))},title:"查看 prompt 组合",children:e.jsx(Us,{size:14})}),w&&e.jsx("button",{type:"button",className:se.stopBtn,onClick:R,title:"中断当前响应","aria-label":"中断当前响应",children:e.jsx(ii,{size:11,fill:"currentColor",stroke:"none"})})]}),e.jsxs("span",{className:se.senderInfo,children:[_.isIncoming&&_.cwd&&e.jsxs("span",{className:se.messageCwd,title:`Agent 实际工作目录:${_.cwd}`,children:["📁 ",_.cwd]}),e.jsx("span",{className:se.senderTime,children:_.timestamp.toLocaleTimeString("zh-CN",{timeZone:"Asia/Shanghai"})})]})]})]}),e.jsx("div",{className:se.messageContent,children:_.isLoading?e.jsxs("div",{className:se.loadingDots,children:[e.jsx("span",{className:se.dot}),e.jsx("span",{className:se.dot}),e.jsx("span",{className:se.dot})]}):e.jsx(dt,{content:_.content,streaming:_.streaming,hideStatus:!0})}),_.cancelled&&e.jsxs("div",{className:se.messageCancelledFooter,children:[e.jsx("span",{className:se.cancelledIcon,children:"⏹"}),e.jsxs("span",{children:["已中断 · ",(M=_.cancelledAt)==null?void 0:M.toLocaleTimeString("zh-CN",{timeZone:"Asia/Shanghai"})]})]})]})]},_.id)}),e.jsx("div",{ref:n})]}),e.jsx(qs,{open:f!==null,messageLabel:f?`${f.from} @ ${f.timestamp.toLocaleTimeString("zh-CN",{timeZone:"Asia/Shanghai"})}`:void 0,composedPrompt:(f==null?void 0:f.composedPrompt)??{layers:[],final:"",generated_at:"",prompt_version:""},onClose:()=>v(null)}),e.jsxs("div",{className:se.inputArea,children:[e.jsx("textarea",{ref:d,rows:1,value:h,onChange:_=>{c(_.target.value),_.target.style.height="auto",_.target.style.height=Math.min(_.target.scrollHeight,160)+"px"},onKeyDown:_=>{s(_)||_.nativeEvent.isComposing||_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),l(),_.currentTarget.style.height="auto")},placeholder:j==="connected"?`向 ${t} 发送消息... (Shift+Enter 换行)`:"等待连接...",disabled:j!=="connected",className:se.messageInput}),e.jsx("button",{onClick:l,disabled:!h.trim()||j!=="connected",className:se.sendBtn,children:"发送"})]})]})}const Np="_badge_5uty0_1",Rp="_tone_priority_5uty0_15",Lp="_tone_category_5uty0_19",Tp="_tone_id_5uty0_27",Ip="_tone_tag_5uty0_34",Ap="_color_blue_5uty0_41",Dp="_color_amber_5uty0_47",Bp="_color_green_5uty0_52",Mp="_color_red_5uty0_57",$p="_color_slate_5uty0_62",Pp="_color_orange_5uty0_67",Op="_color_purple_5uty0_72",Hp="_color_pink_5uty0_77",Es={badge:Np,tone_priority:Rp,tone_category:Lp,tone_id:Tp,tone_tag:Ip,color_blue:Ap,color_amber:Dp,color_green:Bp,color_red:Mp,color_slate:$p,color_orange:Pp,color_purple:Op,color_pink:Hp},Fp={open:"blue",in_progress:"amber",paused:"orange",completed:"green",failed:"red",cancelled:"slate",ok:"green",routed:"green",delivered:"green",queued:"amber",no_target:"red",group_message:"slate"},zp={open:"待处理",in_progress:"执行中",paused:"待继续",completed:"已完成",failed:"失败",cancelled:"已取消"},Wp={low:"slate",medium:"blue",high:"orange",critical:"red"},Up={真人:"green",system:"slate",human:"green"},qp={cli:"purple",ws:"blue",api:"pink",webhook:"amber"};function Vp(t,o){if(!o)return t==="id"?"purple":"slate";switch(t){case"status":return Fp[o]||"slate";case"priority":return Wp[o]||"slate";case"category":return Up[o]||"slate";case"source":return qp[o]||"slate";case"id":return"purple";case"tag":return"slate"}}function ht({tone:t,value:o,children:m,className:S="",title:j,style:E,onClick:b}){const n=Vp(t,o),a=m!==void 0?m:t==="status"&&o&&zp[o]||o,d=[Es.badge,Es[`tone_${t}`],Es[`color_${n}`],S].filter(Boolean).join(" ");return e.jsx("span",{className:d,title:j,style:E,onClick:b,children:a})}const Gp=2400,Kp=48,_r=/\[(?:thinking|status:thinking|tool:exec|tool-result:exec|tool:patch|tool:ask|tool-result:ask)\][\s\S]*?(?:\[\/(?:thinking|status:thinking|tool:exec|tool-result:exec|tool:patch|tool:ask|tool-result:ask)\]|$)/g;function Jp(t){const o=(t.match(_r)??[]).length>0,m=t.replace(_r,"").replace(/\n{3,}/g,`
78
+ `).trim();if(!m)return null;const j=(m.split(`
79
+ `).find(a=>a.trim().length>0)??"").trim();if(!j)return null;const b=m.split(`
80
+ `).filter(a=>a.trim().length>0).length>1||o;return{summary:j.length>120?j.slice(0,120)+"…":j,hasMore:b}}function Xp(t){let o=null;const m=/\[status:thinking\]([\s\S]*?)\[\/status:thinking\]/g;let S;for(;(S=m.exec(t))!==null;)o=S[1];return o}const Zp=g.memo(function({msg:o,agents:m,myAgentName:S,groupMembers:j,onShowPrompt:E,onQuote:b,onCancelStream:n,onContextMenu:a,isContinuation:d}){var C,k;const h=o.from==="system",c=!!o.composedPrompt,f=o.isIncoming?m.find(p=>p.name===o.from):void 0,v=Hs(o.content),y=o.isIncoming&&v.includes(S),u=!!(o.streaming&&o.isIncoming&&o.id.startsWith("stream_")&&n),i=()=>{if(!n)return;const p=o.id.startsWith("stream_")?o.id.slice(7):o.id;n(p,o.from)},r=g.useMemo(()=>{if(o.isLoading||!o.content.trim())return!1;const w=(o.content.match(/\n/g)||[]).length+1;return o.content.length>Gp||w>Kp},[o.content,o.isLoading]),s=g.useMemo(()=>h&&!o.isLoading?Jp(o.content):null,[h,o.isLoading,o.content]),[l,_]=g.useState(!1);g.useEffect(()=>{_(!1)},[o.id]);const x=h?(s==null?void 0:s.hasMore)&&!l&&!o.streaming:r&&!l&&!o.streaming;return e.jsxs("div",{className:`${se.messageRow} ${o.isIncoming?"":se.outgoing} ${h?se.systemRow:""} ${y?se.mentionMeRow:""} ${d?se.continuation:""}`,children:[d?e.jsx("div",{className:se.avatarPlaceholder,"aria-hidden":"true"}):e.jsx(At,{name:o.isIncoming?o.from:S,src:(C=m.find(p=>p.name===(o.isIncoming?o.from:S)))==null?void 0:C.avatar_url,size:30,className:se.messageAvatar}),e.jsxs("div",{className:`${se.messageBubble} ${o.isIncoming?se.incoming:se.outgoing} ${h?se.systemBubble:""} ${y?se.mentionMeBubble:""}`,onContextMenu:a?p=>a(p,o):void 0,children:[e.jsxs("div",{className:se.messageSender,children:[e.jsx("div",{className:se.senderLeft,children:o.isIncoming?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:se.senderName,children:o.from}),h?e.jsx(ht,{tone:"category",value:"system",children:"📣 系统"}):(()=>{var w;const p=(w=f==null?void 0:f.profile)==null?void 0:w.category;return p?e.jsxs(ht,{tone:"category",value:p,children:[p==="真人"?"👤":"🚀"," ",p]}):null})(),(()=>{const p=Xp(o.content);return p?e.jsx(Wt,{content:p,done:!o.streaming,variant:"inline"}):null})()]}):e.jsx("span",{className:`${se.senderName} ${se.senderNameOutgoing}`,children:S})}),e.jsxs("div",{className:se.senderMeta,children:[e.jsxs("span",{className:se.senderActions,children:[b&&e.jsx("button",{type:"button",className:se.messageActionBtn,onClick:()=>b(o),title:"引用","aria-label":"引用",children:e.jsx(ri,{size:14})}),c&&e.jsx("span",{className:se.messageActionBtn,role:"button",tabIndex:0,onClick:()=>E(o),onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),E(o))},title:"查看 prompt 组合",children:e.jsx(Us,{size:14})}),u&&e.jsx("button",{type:"button",className:se.stopBtn,onClick:i,title:"中断当前响应","aria-label":"中断当前响应",children:e.jsx(ii,{size:11,fill:"currentColor",stroke:"none"})})]}),e.jsxs("span",{className:se.senderInfo,children:[o.isIncoming&&o.cwd&&e.jsxs("span",{className:se.messageCwd,title:`Agent 实际工作目录:${o.cwd}`,children:["📁 ",o.cwd]}),!o.isIncoming&&o.status&&e.jsx("span",{className:`${se.messageStatus} ${se[`status_${o.status}`]||""}`,title:o.statusError||(o.status==="delivered"?"已投送":o.status==="queued"?"对方离线,已暂存":o.status==="failed"?`投送失败${o.statusError?": "+o.statusError:""}`:"发送中"),children:o.status==="delivered"?"✓ 已投送":o.status==="queued"?"📭 已暂存":o.status==="failed"?"⚠ 失败":"⏳ 发送中"}),e.jsx("span",{className:se.senderTime,children:o.timestamp.toLocaleTimeString("zh-CN",{timeZone:"Asia/Shanghai"})})]})]})]}),e.jsxs("div",{className:`${se.messageContentWrapper} ${x&&!h?se.collapsed:""}`,children:[e.jsx("div",{className:se.messageContent,children:o.isLoading?e.jsxs("div",{className:se.loadingDots,children:[e.jsx("span",{className:se.dot}),e.jsx("span",{className:se.dot}),e.jsx("span",{className:se.dot})]}):h&&x&&s?e.jsx("span",{className:se.systemSummary,title:s.summary,children:s.summary}):e.jsx(dt,{content:o.content,streaming:o.streaming,mentionMembers:j,mentionClassName:se.mention,hideStatus:!0})}),o.cancelled&&e.jsxs("div",{className:se.messageCancelledFooter,children:[e.jsx("span",{className:se.cancelledIcon,children:"⏹"}),e.jsxs("span",{children:["已中断 · ",(k=o.cancelledAt)==null?void 0:k.toLocaleTimeString("zh-CN",{timeZone:"Asia/Shanghai"})]})]})]}),(r&&!h||h&&(s==null?void 0:s.hasMore))&&!o.streaming&&!o.isLoading&&e.jsx("button",{type:"button",className:se.collapseToggle,onClick:()=>_(p=>!p),"aria-expanded":!x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(ou,{size:12}),e.jsx("span",{children:"展开"})]}):e.jsxs(e.Fragment,{children:[e.jsx(lu,{size:12}),e.jsx("span",{children:"收起"})]})})]})]})});function Yp({x:t,y:o,msg:m,onQuote:S,onCopy:j,onShowPrompt:E,onClose:b}){const n=g.useRef(null),[a,d]=g.useState({left:t,top:o});g.useLayoutEffect(()=>{const f=n.current;if(!f)return;const v=f.getBoundingClientRect(),y=8;let u=t,i=o;u+v.width+y>window.innerWidth&&(u=Math.max(y,window.innerWidth-v.width-y)),i+v.height+y>window.innerHeight&&(i=Math.max(y,window.innerHeight-v.height-y)),d({left:u,top:i})},[t,o]),g.useEffect(()=>{const f=u=>{n.current&&!n.current.contains(u.target)&&b()},v=u=>{u.key==="Escape"&&b()},y=()=>b();return document.addEventListener("mousedown",f),document.addEventListener("keydown",v),window.addEventListener("resize",y),window.addEventListener("scroll",y,!0),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",v),window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0)}},[b]);const h=!!m.composedPrompt,c=f=>()=>{b(),f()};return e.jsxs("div",{ref:n,className:se.contextMenu,style:{left:a.left,top:a.top},role:"menu",children:[e.jsxs("div",{className:se.contextMenuItem,role:"menuitem",onClick:c(()=>S(m)),children:[e.jsx(ri,{size:14})," 引用"]}),e.jsx("div",{className:se.contextMenuSeparator}),e.jsxs("div",{className:se.contextMenuItem,role:"menuitem",onClick:c(()=>j(m,!1)),children:[e.jsx(du,{size:14})," 复制"]}),e.jsxs("div",{className:se.contextMenuItem,role:"menuitem",onClick:c(()=>j(m,!0)),children:[e.jsx(uu,{size:14})," 复制纯文本"]}),h&&E&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:se.contextMenuSeparator}),e.jsxs("div",{className:se.contextMenuItem,role:"menuitem",onClick:c(()=>E(m)),children:[e.jsx(Us,{size:14})," 查看 prompt"]})]})]})}const Qp=2e3,em=.85;function tm(t){const[o,m]=g.useState(!1),[S,j]=g.useState(null);return{upload:g.useCallback(async b=>{if(!t)return j("No group selected"),null;if(!b.type.startsWith("image/"))return j(`${b.name} is not an image`),null;m(!0),j(null);try{const n=b.type==="image/gif"?await sm(b):await rm(b);return n?await ne.post("/uploads",{groupId:t,fileName:b.name,mimeType:n.mimeType,dataBase64:n.dataBase64}):(j(`Failed to process ${b.name}`),null)}catch(n){const a=n instanceof Error?n.message:String(n);return j(a),null}finally{m(!1)}},[t]),uploading:o,error:S,clearError:()=>j(null)}}async function sm(t){const o=await t.arrayBuffer();return{mimeType:"image/gif",dataBase64:ai(o)}}async function rm(t){let o=null;if(typeof createImageBitmap=="function")try{o=await createImageBitmap(t)}catch{o=null}o||(o=await im(t));const{width:m,height:S}=nm(o.width,o.height,Qp),j=document.createElement("canvas");j.width=m,j.height=S;const E=j.getContext("2d");if(!E)throw new Error("Canvas 2d context unavailable");E.drawImage(o,0,0,m,S);const n=j.toDataURL("image/webp").startsWith("data:image/webp")?"image/webp":"image/jpeg",a=await new Promise(h=>j.toBlob(h,n,em));if(!a)throw new Error("Canvas encoding failed");"close"in o&&typeof o.close=="function"&&o.close();const d=await a.arrayBuffer();return{mimeType:n,dataBase64:ai(d)}}function im(t){return new Promise((o,m)=>{const S=URL.createObjectURL(t),j=new Image;j.onload=()=>{URL.revokeObjectURL(S),typeof createImageBitmap=="function"?createImageBitmap(j).then(o,m):m(new Error("Browser lacks both createImageBitmap and Image decode"))},j.onerror=()=>{URL.revokeObjectURL(S),m(new Error("Image decode failed"))},j.src=S})}function nm(t,o,m){if(t<=m&&o<=m)return{width:t,height:o};const S=m/Math.max(t,o);return{width:Math.max(1,Math.round(t*S)),height:Math.max(1,Math.round(o*S))}}function ai(t){const o=new Uint8Array(t),m=32768;let S="";for(let j=0;j<o.length;j+=m)S+=String.fromCharCode(...o.subarray(j,j+m));return btoa(S)}const om=20,fr=[{name:"issue",description:"查看当前群组的 issue 列表(最近 20 条)",requiresArg:!1,run:async(t,o)=>{try{const m=await Be.listByGroup(o.groupId);o.showList({kind:"issue",items:m.slice(0,om)})}catch(m){o.flashToast(`加载 issue 失败: ${m.message}`,"error")}}},{name:"issue-create",description:"直接创建一条 issue(用文本作 description,未指派)",argHint:"<title>",requiresArg:!0,run:async(t,o)=>{const m=t.trim();if(!m){o.flashToast("用法: /issue-create <title>","error");return}try{const S=await Be.create(o.groupId,{description:m,createdBy:o.agentName});o.flashToast(`已创建 issue #${S.id}`)}catch(S){o.flashToast(`创建 issue 失败: ${S.message}`,"error")}}},{name:"schedule",description:"查看当前群组的定时任务列表",requiresArg:!1,run:async(t,o)=>{try{const m=await es.listByGroup(o.groupId);o.showList({kind:"schedule",items:m})}catch(m){o.flashToast(`加载 schedule 失败: ${m.message}`,"error")}}},{name:"schedule-create",description:"60s 后一次性触发一条定时消息(默认值,可后续在面板里改)",argHint:"<name> <prompt>",requiresArg:!0,run:async(t,o)=>{const m=t.trim(),S=m.indexOf(" ");if(S<=0){o.flashToast("用法: /schedule-create <name> <prompt>","error");return}const j=m.slice(0,S).trim(),E=m.slice(S+1).trim();if(!j||!E){o.flashToast("用法: /schedule-create <name> <prompt>","error");return}try{await es.create({name:j,group_id:o.groupId,mode:"message",schedule_kind:"once",run_at:Date.now()+6e4,prompt:E,enabled:!0}),o.flashToast(`已创建定时任务 ${j}`)}catch(b){o.flashToast(`创建 schedule 失败: ${b.message}`,"error")}}},{name:"note",description:"查看当前群组的 note 列表",requiresArg:!1,run:async(t,o)=>{try{const m=await Bs.listByGroup(o.groupId);o.showList({kind:"note",items:m})}catch(m){o.flashToast(`加载 note 失败: ${m.message}`,"error")}}},{name:"note-create",description:"快速落库一条 note(文本作 title,无 description)",argHint:"<text>",requiresArg:!0,run:async(t,o)=>{const m=t.trim();if(!m){o.flashToast("用法: /note-create <text>","error");return}try{await Bs.create(o.groupId,{title:m,createdBy:o.agentName}),o.flashToast("已创建 note")}catch(S){o.flashToast(`创建 note 失败: ${S.message}`,"error")}}}];function am(t){return t?fr.filter(o=>o.name.startsWith(t)):fr}const lm=300,cm=120;function dm({selectedGroup:t,agents:o,myAgentName:m,messages:S,connectionStatus:j,onSendMessage:E,onCancelStream:b}){const n=g.useRef(null),a=g.useRef(null),d=g.useRef(null),h=g.useRef(!0),[c,f]=g.useState(""),[v,y]=g.useState(!1),[u,i]=g.useState(""),[r,s]=g.useState(-1),[l,_]=g.useState(0),[x,C]=g.useState(!1),[k,p]=g.useState(""),[w,R]=g.useState(""),[T,M]=g.useState(0),[N,I]=g.useState(null),[z,G]=g.useState(0),H=g.useRef([]),V=g.useRef([]);g.useEffect(()=>{const te=H.current[T];te&&te.scrollIntoView({block:"nearest"})},[T]),g.useEffect(()=>{const te=V.current[z];te&&te.scrollIntoView({block:"nearest"})},[z]);const[L,A]=g.useState(null),B=g.useRef(null),P=g.useCallback((te,ue="info")=>{A({msg:te,kind:ue}),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>A(null),3e3)},[]);g.useEffect(()=>()=>{B.current&&clearTimeout(B.current)},[]);const[U,Z]=g.useState(null),[oe,K]=g.useState(!1),$=g.useRef(0),{upload:D,uploading:q}=tm(t.id),{isVisitor:J}=qt(),O=g.useCallback(te=>{Z(te)},[]),[X,F]=g.useState(null),W=g.useCallback((te,ue)=>{ue.isLoading||(te.preventDefault(),F({x:te.clientX,y:te.clientY,msg:ue}))},[]),re=/\[(?:thinking|status:thinking|tool:exec|tool-result:exec|tool:patch|tool:ask|tool-result:ask)\][\s\S]*?(?:\[\/(?:thinking|status:thinking|tool:exec|tool-result:exec|tool:patch|tool:ask|tool-result:ask)\]|$)/g,ae=g.useCallback(te=>{const ue=te.timestamp.toLocaleTimeString("zh-CN",{timeZone:"Asia/Shanghai"}),xe=`> **@${te.from}** · ${ue}`,we=(te.content||"").replace(re,"").replace(/\n{3,}/g,`
81
+
82
+ `).trim();if(!we)return"";const fe=we.split(`
83
+ `).map(Ke=>`> ${Ke}`).join(`
84
+ `);return`${xe}
85
+ ${fe}`},[]),ee=g.useCallback(te=>{const ue=ae(te);if(!ue){F(null);return}f(xe=>xe.trim()?`${xe}
86
+
87
+ ${ue}
88
+
89
+ `:`${ue}
90
+
91
+ `),F(null),requestAnimationFrame(()=>{const xe=a.current;xe&&(xe.focus(),xe.selectionStart=xe.selectionEnd=xe.value.length,xe.style.height="auto",xe.style.height=Math.min(xe.scrollHeight,160)+"px")})},[ae]),ce=g.useCallback(async(te,ue)=>{const xe=ue?te.content.replace(/[*_`>~\-\[\]!]/g,""):te.content;try{await navigator.clipboard.writeText(xe)}catch{}F(null)},[]),[he,pe]=g.useState(lm),Ne=g.useMemo(()=>S.length<=he?S:S.slice(S.length-he),[S,he]),Ue=S.length-Ne.length,Me=g.useRef(!1),$e=g.useMemo(()=>{var te;return((te=t.members)==null?void 0:te.map(ue=>ue.agent_name))||[]},[t.members]),Le=o.filter(te=>te.name!==m&&$e.includes(te.name)&&te.name.toLowerCase().includes(u.toLowerCase()));g.useEffect(()=>{_(0)},[u]);const qe=g.useMemo(()=>am(k),[k]);g.useEffect(()=>{M(0)},[k]),g.useEffect(()=>{G(0)},[N]);const ot=g.useMemo(()=>({groupId:t.id,agentName:m,showList:te=>I(te),flashToast:P}),[t.id,m,P]),Qe=g.useCallback(te=>{const ue=te.run(w,ot);ue&&typeof ue.then=="function"&&ue.catch(()=>{}),f(""),C(!1),p(""),R(""),a.current&&(a.current.style.height="auto")},[w,ot]),at=g.useCallback((te,ue)=>{const xe=te.items[ue];if(!xe)return;let we="";if(te.kind==="issue"){const fe=xe,Ke=fe.status,rs=fe.assigned_to??"未指派",wi=fe.title||fe.description.slice(0,80)||"(无标题)";we=`> 📋 #${fe.id} · ${wi}
92
+ > 状态: ${Ke} · 指派: ${rs}
93
+
94
+ `}else if(te.kind==="schedule"){const fe=xe,Ke=fe.schedule_kind==="once"?fe.run_at?new Date(fe.run_at).toLocaleString("zh-CN",{timeZone:"Asia/Shanghai"}):"未排期":`每 ${fe.interval_sec}s`;we=`> ⏰ ${fe.name} · ${fe.mode} · ${Ke}${fe.agent_name?` · → ${fe.agent_name}`:""}
95
+ > ${fe.prompt.replace(/\n/g,`
96
+ > `)}
97
+
98
+ `}else{const fe=xe;we=`> 📝 ${fe.title}${fe.created_by?` · @${fe.created_by}`:""}
99
+ ${fe.description?`> ${fe.description.replace(/\n/g,`
100
+ > `)}
101
+ `:""}
102
+ `}f(fe=>fe.trim()?`${fe}
103
+
104
+ ${we}`:we),I(null),requestAnimationFrame(()=>{const fe=a.current;fe&&(fe.focus(),fe.selectionStart=fe.selectionEnd=fe.value.length,fe.style.height="auto",fe.style.height=Math.min(fe.scrollHeight,160)+"px")})},[]),Ee=g.useRef(null);g.useEffect(()=>{if(Me.current){Me.current=!1;return}Ee.current!=null&&cancelAnimationFrame(Ee.current),h.current&&(Ee.current=requestAnimationFrame(()=>{if(Ee.current=null,!h.current)return;const te=n.current;te&&(te.scrollTop=te.scrollHeight)}))},[Ne]),g.useEffect(()=>()=>{Ee.current!=null&&cancelAnimationFrame(Ee.current)},[]);const Ze=g.useCallback(()=>{const te=n.current;if(!te)return;const ue=te.scrollHeight-te.scrollTop-te.clientHeight;h.current=ue<cm},[]);g.useEffect(()=>{h.current=!0},[t.id]);const le=g.useCallback(()=>{Me.current=!0,pe(S.length)},[S.length]);g.useEffect(()=>{!c&&a.current&&(a.current.style.height="auto")},[c]);const Ce=te=>{var Ke;f(te);const ue=((Ke=a.current)==null?void 0:Ke.selectionStart)??te.length,xe=te.slice(0,ue),we=xe.match(/@([\w一-鿿]*)$/);if(we){y(!0),i(we[1]),s(xe.lastIndexOf("@")),C(!1);return}const fe=xe.match(/(^|\s)(\/[\w-]*)(?:\s+([\s\S]*))?$/);fe?(y(!1),C(!0),p(fe[2].slice(1)),R(fe[3]??""),I(null)):(y(!1),C(!1))},ut=te=>{var we,fe;const ue=c.slice(0,r),xe=c.slice(((we=a.current)==null?void 0:we.selectionStart)??c.length);f(`${ue}@${te} ${xe}`),y(!1),_(0),(fe=a.current)==null||fe.focus()},{handleKeyDown:jt}=oi({value:c,setValue:f,textareaRef:a,disabled:v||x}),bt=()=>{const te=c.trim();!te||j!=="connected"||(E(te),f(""),h.current=!0)},_t=g.useCallback(async te=>{const ue=await D(te);if(!ue)return;const xe=`
105
+ ![${te.name.replace(/[!\[\]()]/g,"")}](${ue.url})
106
+ `;f(we=>{const fe=a.current,Ke=fe?fe.selectionStart??we.length:we.length;return`${we.slice(0,Ke)}${xe}${we.slice(Ke)}`}),requestAnimationFrame(()=>{const we=a.current;if(!we)return;we.focus();const fe=we.value.length;we.selectionStart=we.selectionEnd=fe,we.style.height="auto",we.style.height=Math.min(we.scrollHeight,160)+"px"})},[D]),ms=g.useCallback(te=>{const ue=te.target.files;!ue||ue.length===0||(Array.from(ue).reduce((xe,we)=>xe.then(()=>_t(we)),Promise.resolve()),te.target.value="")},[_t]),Ge=g.useCallback(te=>{var we;const ue=(we=te.clipboardData)==null?void 0:we.items;if(!ue)return;const xe=[];for(let fe=0;fe<ue.length;fe++){const Ke=ue[fe];if(Ke.kind==="file"&&Ke.type.startsWith("image/")){const rs=Ke.getAsFile();rs&&xe.push(rs)}}xe.length!==0&&(te.preventDefault(),xe.reduce((fe,Ke)=>fe.then(()=>_t(Ke)),Promise.resolve()))},[_t]),gs=g.useCallback(te=>{var ue;Array.from(((ue=te.dataTransfer)==null?void 0:ue.types)??[]).includes("Files")&&(te.preventDefault(),$.current+=1,K(!0))},[]),Mt=g.useCallback(te=>{te.preventDefault(),$.current-=1,$.current<=0&&($.current=0,K(!1))},[]),Si=g.useCallback(te=>{var ue;Array.from(((ue=te.dataTransfer)==null?void 0:ue.types)??[]).includes("Files")&&te.preventDefault()},[]),Ci=g.useCallback(te=>{var xe,we;if(!Array.from(((xe=te.dataTransfer)==null?void 0:xe.types)??[]).includes("Files"))return;te.preventDefault(),$.current=0,K(!1);const ue=Array.from(((we=te.dataTransfer)==null?void 0:we.files)??[]).filter(fe=>fe.type.startsWith("image/"));ue.length!==0&&ue.reduce((fe,Ke)=>fe.then(()=>_t(Ke)),Promise.resolve())},[_t]),kt=!!t.archived_at;return e.jsxs(e.Fragment,{children:[kt&&e.jsx("div",{className:se.archivedBanner,children:"🗄️ 该群已归档,只读模式"}),e.jsx(qs,{open:U!==null,messageLabel:U?`${U.from} @ ${U.timestamp.toLocaleTimeString("zh-CN",{timeZone:"Asia/Shanghai"})}`:void 0,composedPrompt:(U==null?void 0:U.composedPrompt)??{layers:[],final:"",generated_at:"",prompt_version:""},onClose:()=>Z(null)}),Ue>0&&e.jsxs("div",{className:se.messagesTruncatedBanner,children:[e.jsxs("span",{children:["已折叠 ",Ue," 条较早消息,仅显示最近 ",Ne.length," 条(共 ",S.length," 条)"]}),e.jsx("button",{type:"button",className:se.messagesTruncatedButton,onClick:le,children:"查看全部"})]}),e.jsxs("div",{ref:n,className:se.messagesArea,onScroll:Ze,onDragEnter:gs,onDragLeave:Mt,onDragOver:Si,onDrop:Ci,children:[S.length===0?e.jsxs("div",{className:se.emptyChat,children:["在群 ",t.name," 中开始对话吧"]}):Ne.map((te,ue)=>{const xe=Ne[ue-1],we=!!xe&&!xe.truncated&&!te.truncated&&xe.from===te.from;return te.truncated?e.jsxs("div",{className:se.truncatedChip,children:["已省略 ",te.truncated.omitted," 条较早消息"]},te.id):e.jsx(Zp,{msg:te,agents:o,myAgentName:m,groupMembers:$e,onShowPrompt:O,onQuote:ee,onCancelStream:b,onContextMenu:W,isContinuation:we},te.id)}),oe&&e.jsx("div",{className:se.dropOverlay,children:e.jsx("div",{className:se.dropHint,children:"松手即可上传图片到群聊"})})]}),!J&&e.jsxs("div",{className:se.inputArea,children:[e.jsx("input",{ref:d,type:"file",accept:"image/*",multiple:!0,className:se.fileInputHidden,onChange:ms,disabled:kt||q||j!=="connected"}),e.jsx("textarea",{ref:a,rows:1,value:c,onChange:te=>{kt||(Ce(te.target.value),te.target.style.height="auto",te.target.style.height=Math.min(te.target.scrollHeight,160)+"px")},onPaste:Ge,onKeyDown:te=>{if(!kt){if(N&&N.items.length>0){if(te.key==="ArrowDown"){te.preventDefault(),G(ue=>Math.min(ue+1,N.items.length-1));return}if(te.key==="ArrowUp"){te.preventDefault(),G(ue=>Math.max(ue-1,0));return}if(te.key==="Enter"&&!te.shiftKey&&!te.nativeEvent.isComposing){te.preventDefault(),at(N,z);return}if(te.key==="Escape"){te.preventDefault(),I(null);return}}if(v&&Le.length>0){if(te.key==="ArrowDown"){te.preventDefault(),_(ue=>(ue+1)%Le.length);return}if(te.key==="ArrowUp"){te.preventDefault(),_(ue=>(ue-1+Le.length)%Le.length);return}if(te.key==="Enter"&&!te.shiftKey){te.preventDefault(),ut(Le[l].name);return}if(te.key==="Escape"){te.preventDefault(),y(!1);return}}if(x&&qe.length>0){if(te.key==="ArrowDown"){te.preventDefault(),M(ue=>(ue+1)%qe.length);return}if(te.key==="ArrowUp"){te.preventDefault(),M(ue=>(ue-1+qe.length)%qe.length);return}if(te.key==="Enter"&&!te.shiftKey&&!te.nativeEvent.isComposing){te.preventDefault(),Qe(qe[T]);return}if(te.key==="Escape"){te.preventDefault(),C(!1);return}}jt(te)||te.key==="Enter"&&!te.shiftKey&&(te.preventDefault(),bt(),te.currentTarget.style.height="auto")}},placeholder:j==="connected"&&!t.archived_at?"输入消息... (Shift+Enter 换行, @ 提及成员, 粘贴/拖入图片自动上传)":"等待连接...",disabled:j!=="connected",className:se.messageInput}),e.jsx("button",{type:"button",onClick:()=>{var te;return(te=d.current)==null?void 0:te.click()},disabled:kt||q||j!=="connected",className:se.uploadBtn,title:"上传图片","aria-label":"上传图片",children:q?"…":"📎"}),e.jsx("button",{onClick:bt,disabled:kt||!c.trim()||j!=="connected",className:se.sendBtn,children:"发送"}),kt&&e.jsx("div",{className:se.archivedNotice,children:"🗄️ 已归档"}),v&&Le.length>0&&e.jsx("div",{className:se.mentionDropdown,children:Le.map((te,ue)=>e.jsxs("div",{className:`${se.mentionItem} ${ue===l?se.mentionItemActive:""}`,onMouseEnter:()=>_(ue),onClick:()=>ut(te.name),children:[e.jsx("div",{className:te.status==="online"?se.mentionOnlineDot:se.mentionOfflineDot}),te.name]},te.id))}),x&&qe.length>0&&e.jsx("div",{className:se.mentionDropdown,children:qe.map((te,ue)=>e.jsxs("div",{ref:xe=>{H.current[ue]=xe},className:`${se.mentionItem} ${se.slashItem} ${ue===T?se.mentionItemActive:""}`,onMouseEnter:()=>M(ue),onClick:()=>{Qe(te)},children:[e.jsxs("span",{className:se.slashName,children:["/",te.name]}),te.argHint&&e.jsx("span",{className:se.slashArgHint,children:te.argHint}),e.jsx("span",{className:se.slashDesc,children:te.description})]},te.name))})]}),N&&e.jsx(um,{data:N,selectedIndex:z,setSelectedIndex:G,onSelect:te=>at(N,te),onClose:()=>I(null)}),L&&e.jsx("div",{className:`${se.slashToast} ${L.kind==="error"?se.slashToastError:""}`,children:L.msg}),X&&e.jsx(Yp,{x:X.x,y:X.y,msg:X.msg,onQuote:ee,onCopy:ce,onShowPrompt:O,onClose:()=>F(null)})]})}function hm(t){return new Date(t).toLocaleString("zh-CN",{timeZone:"Asia/Shanghai"})}function um({data:t,selectedIndex:o,setSelectedIndex:m,onSelect:S,onClose:j}){const E=t.kind==="issue"?"Issues":t.kind==="schedule"?"Schedules":"Notes",b=g.useRef([]);g.useEffect(()=>{const a=b.current[o];a&&a.scrollIntoView({block:"nearest"})},[o]);const n=(a,d,h)=>e.jsx("div",{ref:c=>{b.current[d]=c},className:`${se.slashListRow} ${d===o?se.slashListRowActive:""}`,onMouseEnter:()=>m(d),onClick:()=>S(d),children:h},a);return e.jsxs("div",{className:se.slashListPanel,children:[e.jsxs("div",{className:se.slashListHeader,children:[e.jsxs("span",{className:se.slashListTitle,children:[E," (",t.items.length,") · Enter 引用 · Esc 关闭"]}),e.jsx("button",{type:"button",className:se.slashListClose,onClick:j,"aria-label":"关闭",children:"✕"})]}),e.jsx("div",{className:se.slashListBody,children:t.items.length===0?e.jsxs("div",{className:se.slashListEmpty,children:["暂无",t.kind==="issue"?" issue":t.kind==="schedule"?"定时任务":" note"]}):t.kind==="issue"?t.items.map((a,d)=>n(a.id,d,e.jsxs(e.Fragment,{children:[e.jsx("div",{className:se.slashListRowTitle,children:a.title||a.description.slice(0,60)||"(无标题)"}),e.jsxs("div",{className:se.slashListRowMeta,children:[e.jsx("span",{className:se.slashBadge,children:a.status}),a.assigned_to&&e.jsxs("span",{children:["→ ",a.assigned_to]}),e.jsx("span",{className:se.slashListRowTime,children:new Date(a.created_at).toLocaleString("zh-CN",{timeZone:"Asia/Shanghai"})})]})]}))):t.kind==="schedule"?t.items.map((a,d)=>n(String(a.id),d,e.jsxs(e.Fragment,{children:[e.jsx("div",{className:se.slashListRowTitle,children:a.name}),e.jsxs("div",{className:se.slashListRowMeta,children:[e.jsx("span",{className:se.slashBadge,children:a.mode}),e.jsx("span",{children:a.schedule_kind==="once"?a.run_at?hm(a.run_at):"未排期":`每 ${a.interval_sec}s`}),a.agent_name&&e.jsxs("span",{children:["→ ",a.agent_name]}),e.jsx("span",{className:se.slashListRowTime,children:a.enabled?"on":"off"})]}),e.jsx("div",{className:se.slashListRowDesc,children:a.prompt})]}))):t.items.map((a,d)=>n(a.id,d,e.jsxs(e.Fragment,{children:[e.jsx("div",{className:se.slashListRowTitle,children:a.title}),a.description&&e.jsx("div",{className:se.slashListRowDesc,children:a.description}),e.jsxs("div",{className:se.slashListRowMeta,children:[e.jsx("span",{className:se.slashBadge,children:"note"}),e.jsx("span",{children:a.created_by}),e.jsx("span",{className:se.slashListRowTime,children:new Date(a.created_at).toLocaleString("zh-CN",{timeZone:"Asia/Shanghai"})})]})]})))})]})}function ps(t,o){const[m,S]=g.useState(()=>Date.now());return g.useEffect(()=>{if(!t||o)return;const j=setInterval(()=>S(Date.now()),1e3);return()=>clearInterval(j)},[t,o]),t?o?Math.max(0,new Date(o).getTime()-new Date(t).getTime()):Math.max(0,m-new Date(t).getTime()):null}function Vs(t){if(t<0||!Number.isFinite(t))return"—";const o=Math.floor(t/1e3);if(o<60)return`${o} 秒`;const m=Math.floor(o/60);if(m<60)return`${m} 分 ${o%60} 秒`;const S=Math.floor(m/60);return S<24?`${S} 小时 ${m%60} 分`:`${Math.floor(S/24)} 天 ${S%24} 小时`}function _m(t){const o=Math.floor(t/1e3);if(o<60)return`${o} 秒`;const m=Math.floor(o/60);return m<60?`${m}:${String(o%60).padStart(2,"0")}`:`${Math.floor(m/60)}:${String(m%60).padStart(2,"0")}`}const fm="_issueEventItem_1pub6_2",pm="_issueEventTime_1pub6_9",mm="_issueEventAgent_1pub6_34",gm="_artifactsSection_1pub6_41",vm="_artifactsTitle_1pub6_46",Tt={issueEventItem:fm,issueEventTime:pm,issueEventAgent:mm,artifactsSection:gm,artifactsTitle:vm},ym="_issueDetail_ndjs3_1",xm="_issueBody_ndjs3_12",bm="_todosSticky_ndjs3_20",Sm="_issueEmpty_ndjs3_27",Cm="_issueDescription_ndjs3_38",wm="_artifactItem_ndjs3_45",jm="_bottomDock_ndjs3_59",km="_bottomDockFixed_ndjs3_67",Em="_artifactDrawer_ndjs3_78",Nm="_drawerHeader_ndjs3_93",Rm="_drawerTitle_ndjs3_103",Lm="_drawerClose_ndjs3_109",Tm="_drawerBody_ndjs3_127",Im="_drawerLoading_ndjs3_135",Je={issueDetail:ym,issueBody:xm,todosSticky:bm,issueEmpty:Sm,issueDescription:Cm,artifactItem:wm,bottomDock:jm,bottomDockFixed:km,artifactDrawer:Em,drawerHeader:Nm,drawerTitle:Rm,drawerClose:Lm,drawerBody:Tm,drawerLoading:Im},Am="_continueInputBar_1lue6_1",Dm="_continueInputTextarea_1lue6_6",Bm="_continueInputActions_1lue6_32",Mm="_continueInputHint_1lue6_40",$m="_continueInputError_1lue6_50",Xt={continueInputBar:Am,continueInputTextarea:Dm,continueInputActions:Bm,continueInputHint:Mm,continueInputError:$m};function Pm({items:t,onRemove:o}){return t.length===0?null:e.jsxs("div",{className:"pendingQueuePreview",children:[e.jsxs("span",{className:"pendingQueueLabel",children:["待处理 (",t.length,"):"]}),t.map((m,S)=>e.jsxs("span",{className:"pendingQueueChip",title:m,children:[e.jsx("span",{className:"pendingQueueChipText",children:Om(m,40)}),e.jsx("button",{type:"button",className:"pendingQueueChipRemove",onClick:()=>o(S),"aria-label":"移除该待处理消息",children:"×"})]},S)),e.jsx("style",{children:`
107
+ .pendingQueuePreview {
108
+ display: flex;
109
+ flex-wrap: wrap;
110
+ align-items: center;
111
+ gap: 6px;
112
+ padding: 4px 0 6px;
113
+ font-size: 11px;
114
+ color: var(--color-slate, #666);
115
+ }
116
+ .pendingQueueLabel {
117
+ font-weight: 600;
118
+ flex-shrink: 0;
119
+ }
120
+ .pendingQueueChip {
121
+ display: inline-flex;
122
+ align-items: center;
123
+ gap: 4px;
124
+ max-width: 220px;
125
+ padding: 2px 4px 2px 8px;
126
+ background: rgba(99, 102, 241, 0.1);
127
+ border: 1px solid rgba(99, 102, 241, 0.25);
128
+ border-radius: 10px;
129
+ color: #4f46e5;
130
+ font-size: 11px;
131
+ }
132
+ .pendingQueueChipText {
133
+ overflow: hidden;
134
+ text-overflow: ellipsis;
135
+ white-space: nowrap;
136
+ }
137
+ .pendingQueueChipRemove {
138
+ display: inline-flex;
139
+ align-items: center;
140
+ justify-content: center;
141
+ width: 14px;
142
+ height: 14px;
143
+ padding: 0;
144
+ border: none;
145
+ background: transparent;
146
+ color: #6366f1;
147
+ font-size: 13px;
148
+ line-height: 1;
149
+ cursor: pointer;
150
+ border-radius: 50%;
151
+ }
152
+ .pendingQueueChipRemove:hover {
153
+ background: rgba(99, 102, 241, 0.2);
154
+ }
155
+ `})]})}function Om(t,o){return t.length>o?t.slice(0,o)+"…":t}function Hm({issueId:t,continuedBy:o,status:m,assignedTo:S,initialPrompt:j,onSubmitted:E,pendingQueue:b,onPushPending:n,onRemovePending:a}){const[d,h]=g.useState(""),[c,f]=g.useState(!1),[v,y]=g.useState(null),u=m==="open",i=m==="in_progress",r=m==="paused",s=!!S,l=u&&!s,_=u&&s,x=g.useRef(null);g.useEffect(()=>{if(!_){x.current=null;return}const R=`${t}:${S}`;x.current!==R&&(x.current=R,!d&&j&&h(j))},[_,t,S,j,d]);const C=async()=>{const R=d.trim();if(!(!R||c||l)){f(!0),y(null);try{if(m==="open"||m==="paused")await Be.append(t,R,o);else if(i)n==null||n(R);else if(m==="completed"||m==="failed")await Be.continue(t,R,o);else return;h(""),await E()}catch(T){y(T.message||"提交失败")}finally{f(!1)}}},k=(()=>{if(u&&s)return"Enter 开始任务 · Shift+Enter 换行";if(i){const R=(b==null?void 0:b.length)??0;return R>0?`Esc 立即处理队列 · ${R} 条待处理 · Enter 加入队列`:"Esc 中断当前步骤 · Enter 加入队列 · Shift+Enter 换行"}return r?"中断后待继续 · Enter 用上一轮 session 续跑 · Shift+Enter 换行":m==="completed"||m==="failed"?"Enter 继续执行(基于上次 session) · Shift+Enter 换行":null})(),p=l?"请先在上方指派 Agent,再发送指令":_?`确认或编辑给 ${S} 的 prompt,点下方「开始任务」`:i?"输入追加指令(Enter 入草稿队列,Esc 统一发送并中断当前步骤)…":r?"中断后待继续。输入指令后 worker 会用上一轮 session 续跑…":m==="completed"?"执行完成。补充新指令继续对话(基于上次 session)…":m==="failed"?"上次执行失败。在这里告诉 Agent 怎么修后继续…":"",w=c?"提交中…":_?"开始任务":i?"加入队列":"继续执行";return e.jsxs("div",{className:Xt.continueInputBar,children:[i&&b&&b.length>0&&e.jsx(Pm,{items:b,onRemove:R=>a==null?void 0:a(R)}),e.jsx(xt,{className:Xt.continueInputTextarea,value:d,onChange:R=>h(R.target.value),onKeyDown:R=>{R.key==="Enter"&&!R.shiftKey&&R.keyCode!==229&&(R.preventDefault(),C())},placeholder:p,disabled:c||l,rows:_?4:2}),e.jsxs("div",{className:Xt.continueInputActions,children:[k&&e.jsx("span",{className:Xt.continueInputHint,children:k}),v&&e.jsx("span",{className:Xt.continueInputError,children:v}),e.jsx(ie,{variant:"primary",size:"sm",onClick:C,disabled:c||l||!d.trim(),children:w})]})]})}const Fm="_issueDetailHeader_11v3m_1",zm="_headerPrimaryRow_11v3m_10",Wm="_headerPrimaryMeta_11v3m_17",Um="_headerTitle_11v3m_25",qm="_headerTitlePreview_11v3m_38",Vm="_headerTitlePreviewLabel_11v3m_53",Gm="_headerTitlePreviewText_11v3m_58",Km="_headerSecondary_11v3m_68",Jm="_metaCluster_11v3m_76",Xm="_controlsRow_11v3m_85",Zm="_settingsCluster_11v3m_94",Ym="_actionsCluster_11v3m_103",Qm="_fieldGroup_11v3m_112",eg="_fieldLabel_11v3m_119",tg="_inlineSelect_11v3m_127",sg="_inlinePending_11v3m_133",rg="_fieldHint_11v3m_142",ig="_issueWorkingDir_11v3m_151",ng="_issueWorkingDirPath_11v3m_161",Te={issueDetailHeader:Fm,headerPrimaryRow:zm,headerPrimaryMeta:Wm,headerTitle:Um,headerTitlePreview:qm,headerTitlePreviewLabel:Vm,headerTitlePreviewText:Gm,headerSecondary:Km,metaCluster:Jm,controlsRow:Xm,settingsCluster:Zm,actionsCluster:Ym,fieldGroup:Qm,fieldLabel:eg,inlineSelect:tg,inlinePending:sg,fieldHint:rg,issueWorkingDir:ig,issueWorkingDirPath:ng},Ns=40;function li(t){const o=(t||"").trim().replace(/\s+/g," ");if(o.length<=Ns)return o;const m=o.slice(0,Ns),S=m.lastIndexOf(" ");return(S>Ns*.5?m.slice(0,S):m).trim()+"…"}function ss(t){return t.slash_command==="/plan"&&t.title.startsWith("/plan")&&t.title.slice(5).trim()||t.title}function og(t){const o=t.description||"";return t.slash_command==="/plan"&&o.startsWith("/plan")?o.slice(5).trim():o}const ag=[{value:"rw_allow",label:"读写默认通过"},{value:"r_allow",label:"读默认通过"}];function lg({issue:t,agents:o,groupMembers:m,onBack:S,edit:j,reload:E,onComplete:b,onCancel:n,onDelete:a,onInterrupted:d,pendingQueue:h,readOnly:c=!1}){const[f,v]=g.useState(null),[y,u]=g.useState(!1),[i,r]=g.useState(!1),[s,l]=g.useState(!1),[_,x]=g.useState(!1),[C,k]=g.useState(!1),[p,w]=g.useState(!1),R=t.status==="completed"||t.status==="failed"||t.status==="cancelled",T=t.status==="open"||t.status==="in_progress"||t.status==="paused",M=t.status==="in_progress",N=async()=>{if(!p){w(!0);try{if(h&&h.length>0)for(const A of h)await Be.append(t.id,A,t.created_by);await Be.interrupt(t.id,t.created_by),d==null||d(),await E()}catch(A){console.error("Failed to interrupt issue:",A)}finally{w(!1)}}};g.useEffect(()=>{const A=B=>{if(B.key==="Escape"){if(j.editing){B.preventDefault(),j.cancelEdit();return}M&&(B.preventDefault(),N())}};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[j.editing,M,t.id,h]);const I=new Set(m),z=o.filter(A=>{var B;return I.has(A.name)&&((B=A.profile)==null?void 0:B.category)!=="真人"}).map(A=>A.name);t.assigned_to&&!z.includes(t.assigned_to)&&z.unshift(t.assigned_to);const G=async A=>{if((t.assigned_to||"")!==A){u(!0);try{await Be.update(t.id,{assignedTo:A}),v(null),await E()}catch(B){console.error("Failed to assign issue:",B)}finally{u(!1)}}},H=t.approval_policy??"rw_allow",V=async A=>{if(H!==A){l(!0);try{await Be.update(t.id,{approvalPolicy:A}),await E()}catch(B){console.error("Failed to update approval policy:",B)}finally{l(!1)}}},L=i||j.editing;return e.jsxs("div",{className:Te.issueDetailHeader,children:[e.jsxs("div",{className:Te.headerPrimaryRow,children:[S&&e.jsx(ie,{variant:"ghost",size:"xs",onClick:S,children:"← 返回"}),j.editing?e.jsxs("div",{className:Te.headerTitlePreview,title:"标题由内容前 40 字符自动生成,保存时后端会更新",children:[e.jsx("span",{className:Te.headerTitlePreviewLabel,children:"标题预览:"}),e.jsx("span",{className:Te.headerTitlePreviewText,children:j.editTitlePreview})]}):e.jsx("h4",{className:Te.headerTitle,title:ss(t),children:ss(t)}),e.jsxs("div",{className:Te.headerPrimaryMeta,children:[e.jsx(ht,{tone:"status",value:t.status}),!c&&M&&e.jsx(ie,{variant:"danger",outline:!0,size:"xs",onClick:N,disabled:p,title:"中断当前步骤(快捷键:ESC)。保留 session,队列消息会自动续跑。",children:p?"中断中…":"■ 中断"}),!c&&e.jsx(ie,{variant:"ghost",size:"xs",onClick:()=>r(A=>!A),title:i?"收起更多信息":"展开优先级 / ID / 工作目录 / 指派 / 操作",disabled:j.editing,children:L?"收起 ▴":"更多 ▾"})]})]}),L&&e.jsxs("div",{className:Te.headerSecondary,children:[e.jsxs("div",{className:Te.metaCluster,children:[e.jsx(ht,{tone:"priority",value:t.priority}),e.jsx(ht,{tone:"id",style:{cursor:"pointer"},onClick:()=>{navigator.clipboard.writeText(t.id).then(()=>{x(!0),setTimeout(()=>x(!1),1500)})},title:_?"已复制":`点击复制: ${t.id}`,children:_?"✓ 已复制":`#${t.id.slice(0,8)}`}),t.working_dir&&e.jsxs("div",{className:Te.issueWorkingDir,title:t.working_dir,children:[e.jsx("span",{className:Te.fieldLabel,children:"工作目录"}),e.jsx("code",{className:Te.issueWorkingDirPath,children:t.working_dir})]}),t.session_id&&e.jsxs("div",{className:Te.issueWorkingDir,title:`该 issue 执行时绑定的 ${t.cli_tool??"?"} session:
156
+ ${t.session_id}
157
+ 注意:issue session 与 Debug Sessions 视图里的 chat session 是两个独立 session。点击复制。`,style:{cursor:"pointer"},onClick:()=>{navigator.clipboard.writeText(t.session_id).then(()=>{k(!0),setTimeout(()=>k(!1),1500)}).catch(()=>{})},children:[e.jsx("span",{className:Te.fieldLabel,children:t.cli_tool??"session"}),e.jsx("code",{className:Te.issueWorkingDirPath,children:C?"✓ 已复制":t.session_id})]})]}),!c&&e.jsxs("div",{className:Te.controlsRow,children:[e.jsxs("div",{className:Te.settingsCluster,children:[e.jsxs("div",{className:Te.fieldGroup,children:[e.jsx("label",{className:Te.fieldLabel,children:"指派给"}),e.jsxs(Fe,{size:"sm",className:Te.inlineSelect,value:f??(t.assigned_to||""),disabled:y||R,onChange:A=>{const B=A.target.value;v(B===(t.assigned_to||"")?null:B)},children:[e.jsx("option",{value:"",children:"-- 未指派 --"}),z.map(A=>e.jsx("option",{value:A,children:A},A))]}),f!==null&&!y&&e.jsxs("div",{className:Te.inlinePending,children:[e.jsx(ie,{variant:"primary",size:"xs",onClick:()=>G(f),disabled:R,children:"确认指派"}),e.jsx(ie,{variant:"secondary",size:"xs",onClick:()=>v(null),children:"取消"})]}),y&&e.jsx("span",{className:Te.fieldHint,children:"更新中..."}),!y&&f===null&&z.length===0&&e.jsx("span",{className:Te.fieldHint,children:"群内暂无可指派的 Agent"})]}),e.jsxs("div",{className:Te.fieldGroup,children:[e.jsx("label",{className:Te.fieldLabel,title:"读类工具始终放行;此处控制写类工具是否需要人工审批(claudecode 与 codex 共用)",children:"审批策略"}),e.jsx(Fe,{size:"sm",className:Te.inlineSelect,value:H,disabled:s||R,onChange:A=>{V(A.target.value)},options:ag}),s&&e.jsx("span",{className:Te.fieldHint,children:"保存中..."})]})]}),e.jsxs("div",{className:Te.actionsCluster,children:[!j.editing&&e.jsx(ie,{variant:"secondary",size:"xs",onClick:j.startEdit,title:"编辑标题与描述",children:"编辑"}),T&&e.jsxs(e.Fragment,{children:[e.jsx(ie,{variant:"success",size:"xs",onClick:b,children:"完成"}),e.jsx(ie,{variant:"danger",outline:!0,size:"xs",onClick:n,children:"取消"})]}),R&&e.jsx(ie,{variant:"secondary",size:"xs",onClick:a,children:"删除"}),t.status==="completed"&&e.jsx(cg,{issueId:t.id,agentName:t.assigned_to??void 0})]})]})]})]})}function cg({issueId:t,agentName:o}){const[m,S]=g.useState(!1),[j,E]=g.useState(null),b=async()=>{if(!m&&window.confirm("生成记忆?会创建一个提取任务 Issue,push 给原 Issue 的 assignee 执行。提取出的记忆进入「待审核」,需在 Memory 面板审核。")){S(!0),E(null);try{const n=await Be.extractMemory(t,o);E(n.pushed?`已派给 ${n.agentName}`:`已建任务,但 ${n.agentName} 离线,上线后自动抢单`)}catch(n){E(`失败:${n.message}`)}finally{S(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsx(ie,{variant:"secondary",size:"xs",onClick:b,disabled:m,title:"从本次 Issue 产出提炼记忆,写入待审核池",children:m?"生成中...":"🧠 生成记忆"}),j&&e.jsx("span",{className:Te.fieldHint,children:j})]})}const dg="_issueEditForm_11bht_1",hg="_issueEditError_11bht_34",ug="_issueEditActions_11bht_39",Rs={issueEditForm:dg,issueEditError:hg,issueEditActions:ug};function _g({edit:t}){return e.jsxs("div",{className:Rs.issueEditForm,children:[e.jsx(xt,{label:"描述 (支持 Markdown)",value:t.editDescription,onChange:o=>t.setEditDescription(o.target.value),disabled:t.savingEdit,placeholder:"描述(可留空)",rows:8}),t.editError&&e.jsx("div",{className:Rs.issueEditError,children:t.editError}),e.jsxs("div",{className:Rs.issueEditActions,children:[e.jsx(ie,{variant:"secondary",size:"md",onClick:t.cancelEdit,disabled:t.savingEdit,children:"取消"}),e.jsx(ie,{variant:"primary",size:"md",onClick:t.saveEdit,loading:t.savingEdit,children:t.savingEdit?"保存中…":"保存"})]})]})}const fg="_issueEvents_1552k_1",pg="_bubbleRow_1552k_10",mg="_bubbleRowAgent_1552k_17",gg="_bubbleRowUser_1552k_18",vg="_bubble_1552k_10",yg="_bubbleAppend_1552k_46",xg="_bubbleMeta_1552k_53",bg="_bubbleAgent_1552k_60",Sg="_bubbleTime_1552k_66",Cg="_bubbleContent_1552k_73",wg="_systemChip_1552k_92",jg="_systemChipTag_1552k_104",kg="_systemChipAgent_1552k_111",Eg="_progressBody_1552k_117",Ng="_loadingDots_1552k_122",Rg="_dot_1552k_129",Lg="_promptButton_1552k_148",ye={issueEvents:fg,bubbleRow:pg,bubbleRowAgent:mg,bubbleRowUser:gg,bubble:vg,bubbleAppend:yg,bubbleMeta:xg,bubbleAgent:bg,bubbleTime:Sg,bubbleContent:Cg,systemChip:wg,systemChipTag:jg,systemChipAgent:kg,progressBody:Eg,loadingDots:Ng,dot:Rg,promptButton:Lg},Tg=g.lazy(()=>fs(()=>import("./ApprovalCard-CHPh2dmE.js"),__vite__mapDeps([0])).then(t=>({default:t.ApprovalCard})));function pr(t){let o=null;const m=/\[status:thinking\]([\s\S]*?)\[\/status:thinking\]/g;let S;for(;(S=m.exec(t))!==null;)o=S[1];return o}const Ig=new Set(["appended","continued","comment"]);function Ag(t){const o=[];let m=null;const S=()=>{m&&(o.push({kind:"progress",agent:m.agent,firstAt:m.firstAt,content:m.parts.join(""),events:m.events}),m=null)};for(const j of t){if(j.event_type==="approval_request"){S(),o.push({kind:"approval",event:j});continue}if(j.event_type==="appended"){S(),o.push({kind:"append",event:j});continue}if(j.event_type==="progress_truncated"){S(),o.push({kind:"truncation",event:j});continue}if(j.event_type==="todos"){S();const b=Dg(j.metadata);b&&o.push({kind:"todos",event:j,todos:b});continue}if(!(j.event_type==="progress"||j.event_type==="output")){S();const b=o[o.length-1],n=(j.event_type==="completed"||j.event_type==="failed")&&!!b&&b.kind==="progress"&&b.agent===j.agent_name;o.push({kind:"single",event:n?{...j,content:""}:j});continue}m&&m.agent===j.agent_name?(m.parts.push(j.content||""),m.events.push(j)):(S(),m={agent:j.agent_name,firstAt:j.created_at,parts:[j.content||""],events:[j]})}return S(),o}function Zt(t){var o,m;if(!t)return null;try{const S=JSON.parse(t);if((o=S==null?void 0:S.composed_prompt)!=null&&o.layers&&((m=S.composed_prompt)!=null&&m.final)){const j=S.composed_prompt;return{layers:j.layers,final:j.final,generated_at:j.generatedAt??j.generated_at??"",prompt_version:j.promptVersion??j.prompt_version??"unknown"}}}catch{}return null}function Dg(t){if(!t)return null;try{const o=JSON.parse(t);if(!Array.isArray(o.todos))return null;const m=[];for(const S of o.todos){if(!S||typeof S!="object")continue;const j=S,E=typeof j.content=="string"?j.content:"";if(!E)continue;const b=j.status==="in_progress"?"in_progress":j.status==="completed"?"completed":"pending",n=typeof j.activeForm=="string"&&j.activeForm?j.activeForm:void 0;m.push({content:E,status:b,...n?{activeForm:n}:{}})}return m.length>0?m:null}catch{return null}}function vt(t){const o=t+(t.includes("Z")||t.includes("+")?"":"Z");return new Date(o).toLocaleTimeString("zh-CN",{timeZone:"Asia/Shanghai",hour:"2-digit",minute:"2-digit"})}function Bg({events:t,issueId:o,inProgress:m,onApprovalResolved:S}){const j=Ag(t),E=(()=>{for(let a=j.length-1;a>=0;a--){const d=j[a];if(d.kind==="progress"||d.kind==="single"&&d.event.content)return a}return-1})(),[b,n]=g.useState(null);return e.jsxs("div",{className:ye.issueEvents,children:[j.map((a,d)=>{if(a.kind==="approval")return e.jsxs("div",{className:Tt.issueEventItem,children:[e.jsx("span",{className:Tt.issueEventTime,children:vt(a.event.created_at)}),e.jsxs("div",{className:ye.progressBody,children:[e.jsx("span",{className:Tt.issueEventAgent,children:a.event.agent_name}),e.jsx(g.Suspense,{fallback:e.jsx("div",{className:ye.progressBody,children:"加载中..."}),children:e.jsx(Tg,{event:a.event,issueId:o,onResolved:S})})]})]},a.event.id);if(a.kind==="append"){const u=a.event;return e.jsx("div",{className:`${ye.bubbleRow} ${ye.bubbleRowUser}`,children:e.jsxs("div",{className:`${ye.bubble} ${ye.bubbleAppend}`,children:[e.jsxs("div",{className:ye.bubbleMeta,children:[e.jsxs("span",{className:ye.bubbleAgent,children:["追加指令 · ",u.agent_name]}),e.jsx("span",{className:ye.bubbleTime,children:vt(u.created_at)})]}),e.jsx("div",{className:ye.bubbleContent,children:e.jsx(dt,{content:u.content,hideStatus:!0})})]})},u.id)}if(a.kind==="truncation"){const u=a.event,i=(()=>{try{return JSON.parse(u.metadata||"{}").omitted??0}catch{return 0}})();return e.jsxs("div",{className:ye.systemChip,children:[e.jsx("span",{className:ye.systemChipTag,children:"…"}),e.jsxs("span",{className:ye.systemChipAgent,children:["已省略 ",i," 条早期进展"]})]},`trunc-${d}`)}if(a.kind==="todos"){const u=a.event,i=a.todos.reduce((r,s)=>(r[s.status]=(r[s.status]??0)+1,r),{});return e.jsxs("div",{className:ye.systemChip,children:[e.jsx("span",{className:ye.systemChipTag,children:"📋 todo"}),e.jsxs("span",{className:ye.systemChipAgent,children:[i.completed??0," 完成 · ",i.in_progress??0," 进行 · ",i.pending??0," 待办"]}),e.jsx("span",{className:ye.bubbleTime,children:vt(u.created_at)})]},u.id)}if(a.kind==="progress"){if(!a.content.trim())return null;const i=pr(a.content),r=m&&d===E;return e.jsx("div",{className:`${ye.bubbleRow} ${ye.bubbleRowAgent}`,children:e.jsxs("div",{className:ye.bubble,children:[e.jsxs("div",{className:ye.bubbleMeta,children:[e.jsx("span",{className:ye.bubbleAgent,children:a.agent}),e.jsx("span",{className:ye.bubbleTime,children:vt(a.firstAt)}),i&&e.jsx(Wt,{content:i,done:!r,variant:"inline"}),a.events.length>0&&Zt(a.events[a.events.length-1].metadata)&&e.jsx("span",{className:ye.promptButton,onClick:()=>{const s=Zt(a.events[a.events.length-1].metadata);s&&n({prompt:s,label:`${a.agent} @ ${vt(a.firstAt)}`})},title:"查看 prompt 组合",children:"🔍 prompt"})]}),e.jsx("div",{className:ye.bubbleContent,children:e.jsx(dt,{content:a.content,hideStatus:!0})})]})},`prog-${a.events[0].id}-${d}`)}const h=a.event,c=Ig.has(h.event_type);if(!h.content){const u=Zt(h.metadata),i=!!h.agent_name&&h.agent_name!=="system";return e.jsxs("div",{className:ye.systemChip,children:[e.jsx("span",{className:ye.systemChipTag,children:h.event_type}),i&&e.jsx("span",{className:ye.systemChipAgent,children:h.agent_name}),e.jsx("span",{className:ye.bubbleTime,children:vt(h.created_at)}),u&&e.jsx("span",{className:ye.promptButton,onClick:()=>n({prompt:u,label:`${h.agent_name} @ ${vt(h.created_at)}`}),title:"查看 prompt 组合",children:"🔍"})]},h.id)}const v=pr(h.content),y=m&&d===E;return e.jsx("div",{className:`${ye.bubbleRow} ${c?ye.bubbleRowUser:ye.bubbleRowAgent}`,children:e.jsxs("div",{className:ye.bubble,children:[e.jsxs("div",{className:ye.bubbleMeta,children:[e.jsx("span",{className:ye.bubbleAgent,children:h.agent_name}),e.jsx("span",{className:ye.bubbleTime,children:vt(h.created_at)}),v&&e.jsx(Wt,{content:v,done:!y,variant:"inline"}),Zt(h.metadata)&&e.jsx("span",{className:ye.promptButton,onClick:()=>{const u=Zt(h.metadata);u&&n({prompt:u,label:`${h.agent_name} @ ${vt(h.created_at)}`})},title:"查看 prompt 组合",children:"🔍 prompt"})]}),e.jsx("div",{className:ye.bubbleContent,children:e.jsx(dt,{content:h.content,hideStatus:!0})})]})},h.id)}),m&&e.jsx("div",{className:`${ye.bubbleRow} ${ye.bubbleRowAgent}`,children:e.jsx("div",{className:ye.bubble,children:e.jsxs("div",{className:ye.loadingDots,children:[e.jsx("span",{className:ye.dot}),e.jsx("span",{className:ye.dot}),e.jsx("span",{className:ye.dot})]})})}),e.jsx(qs,{open:b!==null,messageLabel:b==null?void 0:b.label,composedPrompt:(b==null?void 0:b.prompt)??{layers:[],final:"",generated_at:"",prompt_version:""},onClose:()=>n(null)})]})}const Mg="_statusBar_142cf_4",$g="_left_142cf_19",Pg="_right_142cf_26",Og="_statusDot_142cf_36",Hg="_dot_idle_142cf_44",Fg="_dot_running_142cf_45",zg="_dotPulse_142cf_1",Wg="_dot_paused_142cf_46",Ug="_dot_done_142cf_47",qg="_dot_failed_142cf_48",Vg="_statusLabel_142cf_55",Gg="_activity_142cf_66",Kg="_activityFresh_142cf_75",Jg="_activityWarn_142cf_76",Xg="_activityDanger_142cf_77",Zg="_activityPulse_142cf_1",Yg="_agentName_142cf_84",Qg="_sep_142cf_96",ev="_model_142cf_102",tv="_tokens_142cf_108",sv="_tokenIn_142cf_114",rv="_tokenOut_142cf_115",iv="_arrow_142cf_125",nv="_tokenValue_142cf_132",ov="_tokenTick_142cf_1",av="_cost_142cf_143",lv="_elapsed_142cf_149",cv="_elapsedIcon_142cf_157",dv="_elapsedValue_142cf_162",Ae={statusBar:Mg,left:$g,right:Pg,statusDot:Og,dot_idle:Hg,dot_running:Fg,dotPulse:zg,dot_paused:Wg,dot_done:Ug,dot_failed:qg,statusLabel:Vg,activity:Gg,activityFresh:Kg,activityWarn:Jg,activityDanger:Xg,activityPulse:Zg,agentName:Yg,sep:Qg,model:ev,tokens:tv,tokenIn:sv,tokenOut:rv,arrow:iv,tokenValue:nv,tokenTick:ov,cost:av,elapsed:lv,elapsedIcon:cv,elapsedValue:dv};function hv(t){switch(t){case"open":return{label:"待处理",dotClass:"idle",spin:!1};case"in_progress":return{label:"执行中",dotClass:"running",spin:!0};case"paused":return{label:"待继续",dotClass:"paused",spin:!1};case"completed":return{label:"已完成",dotClass:"done",spin:!1};case"failed":return{label:"失败",dotClass:"failed",spin:!1};case"cancelled":return{label:"已取消",dotClass:"idle",spin:!1}}}function uv({issue:t,liveUsage:o,activity:m}){const S=ps(t.started_at,t.completed_at),j=S==null?"—":_m(S),E=hv(t.status),b=t.status==="in_progress"||t.status==="paused",n=_v(b?m==null?void 0:m.lastAt:null),a=n==null?null:mv(n),d=n==null?"":n>=6e4?Ae.activityDanger:n>=3e4?Ae.activityWarn:Ae.activityFresh,h=b&&(m!=null&&m.statusLabel)?m.statusLabel:E.label,c=g.useMemo(()=>{if(!t.usage)return null;try{const i=JSON.parse(t.usage);return i&&typeof i=="object"?i:null}catch{return null}},[t.usage]),f=o??c,v=t.model??null,y=!!f&&(f.inputTokens!=null||f.outputTokens!=null||f.cacheReadTokens!=null||f.cacheCreationTokens!=null||f.totalCostUsd!=null),u=S==null?"尚未开始(等待 worker 认领)":t.status==="completed"||t.status==="failed"||t.status==="cancelled"?"总耗时":"当前区间耗时(实时刷新)";return e.jsxs("div",{className:Ae.statusBar,children:[e.jsxs("div",{className:Ae.left,children:[e.jsx("span",{className:`${Ae.statusDot} ${Ae[`dot_${E.dotClass}`]}`,"data-spin":E.spin}),e.jsx("span",{className:Ae.statusLabel,children:h}),t.assigned_to&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:Ae.sep,children:"·"}),e.jsx("code",{className:Ae.agentName,title:`当前指派: ${t.assigned_to}`,children:t.assigned_to})]}),a&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:Ae.sep,children:"·"}),e.jsx("span",{className:`${Ae.activity} ${d}`,title:`距上次 CLI 输出: ${a}
158
+ > 30s 疑似卡住,> 60s 建议中断检查`,children:a})]})]}),e.jsxs("div",{className:Ae.right,children:[v&&e.jsx("span",{className:Ae.model,children:pv(v)}),y&&f&&e.jsxs(e.Fragment,{children:[v&&e.jsx("span",{className:Ae.sep,children:"·"}),e.jsxs("span",{className:Ae.tokens,children:[f.inputTokens!=null&&e.jsxs("span",{className:Ae.tokenIn,title:"输入 tokens",children:[e.jsx("span",{className:Ae.arrow,children:"↑"}),e.jsx("span",{className:Ae.tokenValue,children:mr(f.inputTokens)},f.inputTokens)]}),f.outputTokens!=null&&e.jsxs("span",{className:Ae.tokenOut,title:"输出 tokens",children:[e.jsx("span",{className:Ae.arrow,children:"↓"}),e.jsx("span",{className:Ae.tokenValue,children:mr(f.outputTokens)},f.outputTokens)]})]}),f.totalCostUsd!=null&&f.totalCostUsd>0&&e.jsxs("span",{className:Ae.cost,title:"总成本 (USD)",children:["$",e.jsx("span",{className:Ae.tokenValue,children:fv(f.totalCostUsd)},f.totalCostUsd)]})]}),e.jsx("span",{className:Ae.sep,children:"·"}),e.jsxs("span",{className:Ae.elapsed,title:u,children:[e.jsx("span",{className:Ae.elapsedIcon,children:"⏱"}),e.jsx("code",{className:Ae.elapsedValue,children:j})]})]})]})}function _v(t){const[o,m]=g.useState(()=>Date.now());return g.useEffect(()=>{if(!t)return;const S=setInterval(()=>m(Date.now()),1e3);return()=>clearInterval(S)},[t]),t?Math.max(0,o-new Date(t).getTime()):null}function mr(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function fv(t){return t>=.01?t.toFixed(2):t>=1e-4?t.toFixed(4):t.toFixed(6)}function pv(t){const o=t.replace(/^(claude|anthropic|openai|gpt|gemini)-/i,"");return o.length<=22?o:o.slice(0,21)+"…"}function mv(t){const o=Math.floor(t/1e3);if(o<60)return`${o}s 前`;const m=Math.floor(o/60);return m<60?`${m}m 前`:`${Math.floor(m/60)}h 前`}const gv="_pendingApprovalsBar_18bzy_1",vv="_pendingApprovalsHeader_18bzy_9",yv="_pendingApprovalItem_18bzy_19",xv="_pendingApprovalKind_18bzy_27",bv="_pendingApprovalSummary_18bzy_37",Sv="_pendingApprovalError_18bzy_48",It={pendingApprovalsBar:gv,pendingApprovalsHeader:vv,pendingApprovalItem:yv,pendingApprovalKind:xv,pendingApprovalSummary:bv,pendingApprovalError:Sv},Cv=g.lazy(()=>fs(()=>import("./ApprovalCard-CHPh2dmE.js"),__vite__mapDeps([0])).then(t=>({default:t.ApprovalCard})));function Ms(t){try{return JSON.parse(t.metadata||"{}")}catch{return{}}}function wv({issueId:t,approvals:o,onResolved:m}){const[S,j]=g.useState(!1),[E,b]=g.useState(null),n=o.map(d=>{const h=Ms(d);return h.kind==="ask"?"":typeof h.approvalId=="string"?h.approvalId:""}).filter(Boolean),a=async()=>{if(!(S||n.length<2)){j(!0),b(null);try{const h=(await Promise.allSettled(n.map(c=>Be.respondApproval(t,c,"accept")))).filter(c=>c.status==="rejected").length;h>0&&b(`${h}/${n.length} 接受失败`),await m()}catch(d){b(d.message||"accept-all failed")}finally{j(!1)}}};return e.jsxs("div",{className:It.pendingApprovalsBar,children:[e.jsxs("div",{className:It.pendingApprovalsHeader,children:[e.jsxs("span",{children:["⚠️ 待确认 (",o.length,")"]}),n.length>=2&&e.jsx(ie,{variant:"success",size:"sm",disabled:S,onClick:a,children:S?"接受中...":`全部接受 (${n.length})`}),E&&e.jsx("span",{className:It.pendingApprovalError,children:E})]}),o.map(d=>Ms(d).kind==="ask"?e.jsx(g.Suspense,{fallback:e.jsx("div",{children:"加载中..."}),children:e.jsx(Cv,{issueId:t,event:d,onResolved:m})},d.id):e.jsx(jv,{issueId:t,event:d,disabled:S,onResolved:m},d.id))]})}function jv({issueId:t,event:o,disabled:m,onResolved:S}){const[j,E]=g.useState(null),[b,n]=g.useState(null),a=Ms(o),d=a.kind??"exec",h=a.approvalId??"",c=a.command,f=a.files??[],v=a.plan,y=d==="exec"?"命令":d==="plan"?"方案":"文件",u=d==="exec"?c||o.content||"(无命令)":d==="file_change"?f.length>0?f.join("、"):o.content||"(无文件)":d==="plan"?((v||"").split(`
159
+ `).map(l=>l.trim()).find(l=>l.length>0)??"").replace(/^#+\s*/,"")||o.content||"(无方案)":o.content||"",i=async s=>{if(!(!h||j)){E(s),n(null);try{await Be.respondApproval(t,h,s),await S()}catch(l){n(l.message||`${s} failed`),E(null)}}},r=j!==null||m===!0;return e.jsxs("div",{className:It.pendingApprovalItem,children:[e.jsx("span",{className:It.pendingApprovalKind,children:y}),e.jsx("span",{className:It.pendingApprovalSummary,title:u,children:u}),e.jsx(ie,{variant:"success",size:"sm",disabled:r,onClick:()=>i("accept"),children:j==="accept"?"...":"Accept"}),e.jsx(ie,{variant:"danger",outline:!0,size:"sm",disabled:r,onClick:()=>i("deny"),children:j==="deny"?"...":"Deny"}),b&&e.jsx("span",{className:It.pendingApprovalError,children:b})]})}const kv="_panel_15bt1_5",Ev="_header_15bt1_17",Nv="_title_15bt1_26",Rv="_summary_15bt1_33",Lv="_chevron_15bt1_40",Tv="_chevronCollapsed_15bt1_47",Iv="_list_15bt1_51",Av="_listCollapsed_15bt1_62",Dv="_item_15bt1_66",Bv="_badge_15bt1_76",Mv="_text_15bt1_86",$v="_completed_15bt1_94",Pv="_inProgress_15bt1_105",Ov="_pending_15bt1_119",it={panel:kv,header:Ev,title:Nv,summary:Rv,chevron:Lv,chevronCollapsed:Tv,list:Iv,listCollapsed:Av,item:Dv,badge:Bv,text:Mv,completed:$v,inProgress:Pv,pending:Ov},Hv={pending:"待办",in_progress:"进行中",completed:"已完成"};function Fv({todos:t,agentName:o,active:m}){const[S,j]=g.useState(!1);if(t.length===0)return null;const E=t.reduce((d,h)=>(d[h.status]=(d[h.status]??0)+1,d),{}),b=E.completed??0,n=E.in_progress??0,a=E.pending??0;return!m&&b===t.length?null:e.jsxs("div",{className:it.panel,children:[e.jsxs("div",{className:it.header,onClick:()=>j(d=>!d),role:"button",tabIndex:0,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),j(h=>!h))},children:[e.jsxs("span",{className:it.title,children:["📋 ",o?`${o} 的 Todo`:"Todo 列表"]}),e.jsxs("span",{className:it.summary,children:[b," 完成 · ",n," 进行 · ",a," 待办"]}),e.jsx("span",{className:it.chevron+" "+(S?it.chevronCollapsed:""),children:"▼"})]}),e.jsx("ul",{className:it.list+" "+(S?it.listCollapsed:""),children:t.map((d,h)=>e.jsxs("li",{className:`${it.item} ${zv(d.status)}`,children:[e.jsx("span",{className:it.badge,children:Hv[d.status]}),e.jsx("span",{className:it.text,children:d.content})]},h))})]})}function zv(t){return t==="completed"?it.completed:t==="in_progress"?it.inProgress:it.pending}function Wv(t,o){const[m,S]=g.useState(null),[j,E]=g.useState([]),[b,n]=g.useState(!0),a=g.useCallback(async()=>{try{const d=await Be.getById(t);S(d),E(d.events||[])}catch(d){console.error("Failed to load issue:",d)}finally{n(!1)}},[t]);return g.useEffect(()=>{a()},[a]),g.useEffect(()=>{o===void 0||o===0||a()},[o,a]),{issue:m,events:j,loading:b,reload:a}}function Uv(t,o){const[m,S]=g.useState(!1),[j,E]=g.useState(""),[b,n]=g.useState(!1),[a,d]=g.useState(null);g.useEffect(()=>{S(!1),d(null)},[t==null?void 0:t.id]);const h=()=>{t&&(E(t.description||""),d(null),S(!0))},c=()=>{S(!1),d(null)},f=async()=>{if(!t)return;if(!j.trim()){d("内容不能为空");return}if(!(j!==(t.description||""))){S(!1);return}n(!0),d(null);try{await Be.update(t.id,{description:j}),S(!1),await o()}catch(u){d(u.message||"保存失败")}finally{n(!1)}};return{editing:m,editDescription:j,setEditDescription:E,editTitlePreview:li(j),savingEdit:b,editError:a,startEdit:h,cancelEdit:c,saveEdit:f}}function Gs({issueId:t,refreshSignal:o,agents:m,groupMembers:S,onBack:j,standalone:E=!1,readOnly:b=!1,onArtifactClick:n}){const{issue:a,events:d,loading:h,reload:c}=Wv(t,o),f=Uv(a,c);return e.jsx(Yr,{data:a,loading:h,emptyFallback:e.jsx("div",{className:Je.issueEmpty,children:"Issue 未找到"}),loadingFallback:e.jsx("div",{className:Je.issueEmpty,children:"加载中..."}),children:v=>e.jsx(qv,{issue:v,events:d,edit:f,reload:c,issueId:t,agents:m,groupMembers:S,onBack:j,standalone:E,readOnly:b,onArtifactClick:n})})}function qv({issue:t,events:o,edit:m,reload:S,issueId:j,agents:E,groupMembers:b,onBack:n,standalone:a,readOnly:d,onArtifactClick:h}){const{lastIssueUsageProgress:c,status:f,subscribeIssueDetail:v,unsubscribeIssueDetail:y}=wt();g.useEffect(()=>{if(!(!j||d)&&f==="connected")return v(j),()=>{y(j)}},[j,f,d,v,y]);const u=c&&c.issueId===j?c.usage:void 0,i=g.useMemo(()=>Vv(o),[o]),[r,s]=g.useState([]),l=g.useRef(void 0),_=g.useRef([]);_.current=r,g.useEffect(()=>{const U=l.current;if(l.current=t==null?void 0:t.status,!!t&&U==="in_progress"&&t.status!=="in_progress"){const Z=_.current;if(s([]),_.current=[],Z.length===0)return;const oe=Z.join(`
160
+
161
+ `);t.status==="completed"||t.status==="failed"?Be.continue(t.id,oe,t.created_by).then(()=>S()).catch(K=>console.error("Failed to auto-continue pending drafts:",K)):t.status==="paused"&&Be.append(t.id,oe,t.created_by).then(()=>S()).catch(K=>console.error("Failed to auto-append pending drafts:",K))}},[t==null?void 0:t.status]);const x=g.useCallback(U=>{s(Z=>[...Z,U])},[]),C=g.useCallback(U=>{s(Z=>Z.filter((oe,K)=>K!==U))},[]),k=g.useCallback(()=>s([]),[]),p=g.useMemo(()=>o.filter(U=>{if(U.event_type!=="approval_request")return!1;try{return(JSON.parse(U.metadata||"{}").status??"pending")==="pending"}catch{return!1}}),[o]),w=g.useRef(null),R=g.useRef(null),T=g.useRef(null),[M,N]=g.useState(0),I=g.useRef(!0),z=80,G=g.useCallback(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const U=w.current;U&&(U.scrollTop=U.scrollHeight)})})},[]);g.useEffect(()=>{const U=w.current;if(!U)return;const Z=()=>{const oe=U.scrollHeight-U.scrollTop-U.clientHeight;I.current=oe<=z};return U.addEventListener("scroll",Z,{passive:!0}),()=>U.removeEventListener("scroll",Z)},[]),g.useEffect(()=>{const U=R.current;if(!U)return;const Z=new ResizeObserver(()=>{I.current&&G()});return Z.observe(U),G(),()=>Z.disconnect()},[G]),g.useEffect(()=>{if(!a){N(0);return}const U=T.current;if(!U){N(0);return}const Z=()=>N(U.getBoundingClientRect().height);Z();const oe=new ResizeObserver(Z);return oe.observe(U),()=>oe.disconnect()},[a,p.length,t==null?void 0:t.status]);const H=g.useCallback(async()=>{await S(),G()},[S,G]),V=(()=>{try{return JSON.parse(t.artifacts||"[]")}catch{return[]}})(),L=t.status!=="cancelled",A=async()=>{if(confirm("确定要取消这个 Issue 吗?"))try{await Be.cancel(t.id,t.created_by),await S()}catch(U){console.error("Failed to cancel issue:",U)}},B=async()=>{if(confirm("确定要删除这个 Issue 吗?此操作不可恢复。"))try{await Be.delete(t.id),n==null||n()}catch(U){console.error("Failed to delete issue:",U)}},P=async()=>{if(confirm("确定将此 Issue 标记为已完成吗?"))try{await Be.complete(t.id,t.created_by),await S()}catch(U){console.error("Failed to complete issue:",U)}};return e.jsxs("div",{className:Je.issueDetail,children:[e.jsx(lg,{issue:t,agents:E,groupMembers:b,onBack:n,edit:m,reload:S,onComplete:P,onCancel:A,onDelete:B,onInterrupted:k,pendingQueue:r,readOnly:d}),t.latest_todos&&t.latest_todos.length>0&&e.jsx("div",{className:Je.todosSticky,children:e.jsx(Fv,{todos:t.latest_todos,agentName:t.assigned_to||"",active:t.status==="in_progress"||t.status==="paused"})}),e.jsx("div",{ref:w,className:Je.issueBody,style:a&&M?{paddingBottom:M}:void 0,children:e.jsxs("div",{ref:R,children:[m.editing?e.jsx(_g,{edit:m}):t.description&&e.jsx("div",{className:Je.issueDescription,children:e.jsx(dt,{content:og(t)})}),e.jsx(Bg,{events:o,issueId:j,inProgress:t.status==="in_progress",onApprovalResolved:S}),V.length>0&&e.jsxs("div",{className:Tt.artifactsSection,children:[e.jsxs("div",{className:Tt.artifactsTitle,children:["产物 (",V.length,")"]}),V.map((U,Z)=>e.jsx("a",{className:Je.artifactItem,onClick:()=>h==null?void 0:h(U),title:h?`点击在 Artifacts 中查看: ${U}`:U,children:U},Z))]}),t.result&&e.jsxs("div",{className:Tt.artifactsSection,children:[e.jsx("div",{className:Tt.artifactsTitle,children:"执行结果"}),e.jsx("div",{className:Je.issueDescription,children:e.jsx(dt,{content:t.result})})]})]})}),!d&&(p.length>0?e.jsx("div",{ref:T,className:`${Je.bottomDock} ${a?Je.bottomDockFixed:""}`,children:e.jsx(wv,{issueId:j,approvals:p,onResolved:S})}):L?e.jsxs("div",{ref:T,className:`${Je.bottomDock} ${a?Je.bottomDockFixed:""}`,children:[e.jsx(uv,{issue:t,liveUsage:u,activity:i}),e.jsx(Hm,{issueId:j,continuedBy:t.created_by,status:t.status,assignedTo:t.assigned_to,initialPrompt:t.description||t.title,onSubmitted:H,pendingQueue:r,onPushPending:x,onRemovePending:C})]}):null)]})}function Vv(t){for(let o=t.length-1;o>=0;o--){const m=t[o];if(m.event_type!=="progress")continue;const S=Gv(m.content);return{lastAt:m.created_at,statusLabel:S}}return null}function Gv(t){const o=t.match(/\[status:thinking\]([^\]]+)\[\/status:thinking\]/);return o?Kv(o[1]):null}function Kv(t){return{Working:"思考中",Running:"执行命令",Patching:"编辑文件",Asking:"询问中",Answered:"已回答",Done:"完成",Failed:"失败"}[t]??t}function ci(t,o){if(!t)return null;const m=o.find(S=>S.name===t);return(m==null?void 0:m.name)??t}const di="未认领",Jv="_issuePanel_pfl82_1",Xv="_issuePanelHeader_pfl82_10",Zv="_issuePanelTitle_pfl82_20",Yv="_issueList_pfl82_32",Qv="_issueItem_pfl82_40",ey="_active_pfl82_52",ty="_issueTitleRow_pfl82_57",sy="_issueTitle_pfl82_57",ry="_issueTypeLabel_pfl82_78",iy="_taskLabel_pfl82_89",ny="_issueMeta_pfl82_94",oy="_issueCreatedBy_pfl82_100",ay="_issueAssignee_pfl82_106",ly="_issueElapsed_pfl82_120",cy="_issueElapsedIdle_pfl82_133",dy="_issueElapsedRunning_pfl82_138",hy="_issueElapsedDone_pfl82_144",uy="_issueAssigneeClaimed_pfl82_154",_y="_issueAssigneeUnclaimed_pfl82_159",fy="_issueEmpty_pfl82_165",je={issuePanel:Jv,issuePanelHeader:Xv,issuePanelTitle:Zv,issueList:Yv,issueItem:Qv,active:ey,issueTitleRow:ty,issueTitle:sy,issueTypeLabel:ry,taskLabel:iy,issueMeta:ny,issueCreatedBy:oy,issueAssignee:ay,issueElapsed:ly,issueElapsedIdle:cy,issueElapsedRunning:dy,issueElapsedDone:hy,issueAssigneeClaimed:uy,issueAssigneeUnclaimed:_y,issueEmpty:fy};function py({issue:t,agents:o,selectedIssueId:m,onSelect:S}){const j=ci(t.assigned_to,o),E=ps(t.started_at,t.completed_at),b=t.status==="completed"||t.status==="failed"||t.status==="cancelled",n=b?je.issueElapsedDone:t.status==="in_progress"?je.issueElapsedRunning:je.issueElapsedIdle,a=b?"✓":t.status==="in_progress"?"⏱":"—",d=E==null?"—":Vs(E);return e.jsxs("li",{className:`${je.issueItem} ${m===t.id?je.active:""}`,onClick:S,children:[e.jsxs("div",{className:je.issueTitleRow,children:[e.jsx("span",{className:`${je.issueTypeLabel} ${je.taskLabel}`,children:"任务"}),t.slash_command&&e.jsx("span",{title:"此 issue 以计划模式执行:先输出方案,等待审批后落盘",style:{fontSize:10,fontWeight:600,padding:"1px 6px",borderRadius:4,background:"rgba(99, 102, 241, 0.15)",color:"#6366f1"},children:t.slash_command}),e.jsx("span",{className:je.issueTitle,children:ss(t)})]}),e.jsxs("div",{className:je.issueMeta,children:[e.jsx(ht,{tone:"status",value:t.status,children:t.status==="open"?"待处理":t.status==="in_progress"?"执行中":t.status==="paused"?"待继续":t.status==="completed"?"已完成":t.status==="failed"?"失败":"已取消"}),e.jsxs("span",{className:`${je.issueElapsed} ${n}`,title:E==null?"尚未开始":b?"总耗时":"当前区间耗时(实时刷新)",children:[a," ",d]}),e.jsx("span",{className:`${je.issueAssignee} ${j?je.issueAssigneeClaimed:je.issueAssigneeUnclaimed}`,title:j?`执行 agent: ${j}`:"尚未认领",children:j?`👤 ${j}`:di}),e.jsx("span",{className:je.issueCreatedBy,children:t.created_by})]})]})}function my({selectedIssueId:t,selectedIssueVersion:o,issues:m,agents:S,groupMembers:j,setSelectedIssueId:E,readOnly:b=!1,onArtifactClick:n}){return e.jsx("div",{className:je.issuePanel,children:t?e.jsx(Gs,{issueId:t,refreshSignal:o,agents:S,groupMembers:j,onBack:()=>E(""),readOnly:b,onArtifactClick:n}):m.length===0?e.jsxs("div",{className:je.issueEmpty,children:["暂无 Issue",!b&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),"点击上方按钮创建"]})]}):e.jsx("ul",{className:je.issueList,children:m.map(a=>e.jsx(py,{issue:a,agents:S,selectedIssueId:t,onSelect:()=>E(a.id)},a.id))})})}const gy="_schedulePanel_ccz3r_1",vy="_scheduleList_ccz3r_29",yy="_scheduleItem_ccz3r_37",xy="_disabled_ccz3r_49",by="_scheduleItemHeader_ccz3r_53",Sy="_scheduleName_ccz3r_60",Cy="_schedulePersona_ccz3r_71",wy="_schedulePersonaName_ccz3r_79",jy="_scheduleBadge_ccz3r_85",ky="_modeAgent_ccz3r_94",Ey="_modeMessage_ccz3r_99",Ny="_scheduleMeta_ccz3r_109",Ry="_scheduleMetaItem_ccz3r_119",Ly="_schedulePrompt_ccz3r_123",Ty="_schedulePromptCollapsed_ccz3r_135",Iy="_schedulePromptToggle_ccz3r_143",Ay="_scheduleLastRun_ccz3r_157",Dy="_error_ccz3r_163",By="_skipped_ccz3r_167",My="_scheduleEmpty_ccz3r_171",$y="_scheduleHelp_ccz3r_185",Ie={schedulePanel:gy,scheduleList:vy,scheduleItem:yy,disabled:xy,scheduleItemHeader:by,scheduleName:Sy,schedulePersona:Cy,schedulePersonaName:wy,scheduleBadge:jy,modeAgent:ky,modeMessage:Ey,scheduleMeta:Ny,scheduleMetaItem:Ry,schedulePrompt:Ly,schedulePromptCollapsed:Ty,schedulePromptToggle:Iy,scheduleLastRun:Ay,error:Dy,skipped:By,scheduleEmpty:My,scheduleHelp:$y};function $s(t){if(t==null)return"-";try{return new Date(t).toLocaleString("zh-CN",{timeZone:"Asia/Shanghai"})}catch{return String(t)}}function Py(t){if(t.schedule_kind==="once")return`once · ${$s(t.run_at)}`;const o=t.interval_sec??0;return o>=86400?`every ${Math.floor(o/86400)}d`:o>=3600?`every ${Math.floor(o/3600)}h`:o>=60?`every ${Math.floor(o/60)}m`:`every ${o}s`}function Oy({selectedGroupId:t}){const[o,m]=g.useState([]),[S,j]=g.useState(null),E=()=>{t&&(j(null),es.listByGroup(t).then(m).catch(b=>j((b==null?void 0:b.message)??"加载失败")))};return g.useEffect(()=>{m([]),E()},[t]),g.useEffect(()=>{if(!t)return;const b=setInterval(E,3e4);return()=>clearInterval(b)},[t]),e.jsx("div",{className:Ie.schedulePanel,children:S?e.jsx("div",{className:Ie.scheduleEmpty,children:S}):o.length===0?e.jsxs("div",{className:Ie.scheduleEmpty,children:["暂无定时任务",e.jsxs("div",{className:Ie.scheduleHelp,children:["通过 CLI 创建: ",e.jsx("code",{children:"rotom schedule add --group <id> --mode agent|message ..."})]})]}):e.jsx("ul",{className:Ie.scheduleList,children:o.map(b=>e.jsx(zy,{schedule:b},b.id))})})}const Hy=200,gr="星期五";function Fy(t){if(t.handler_key!=="ask-bridge-check"||!t.handler_payload)return null;try{const o=JSON.parse(t.handler_payload);return{asker:o.asker,target:o.target}}catch{return null}}function zy({schedule:t}){const[o,m]=g.useState(!1),S=!t.enabled,j=t.last_status==="error"?Ie.error:t.last_status==="skipped"?Ie.skipped:"",E=t.prompt.length>Hy,b=Fy(t),n=b!=null&&b.target?`等待 ${b.target} 回复`:t.name;return e.jsxs("li",{className:`${Ie.scheduleItem} ${S?Ie.disabled:""}`,children:[e.jsxs("div",{className:Ie.scheduleItemHeader,children:[e.jsxs("span",{className:Ie.schedulePersona,"aria-label":gr,children:["🧑‍💼 ",e.jsx("span",{className:Ie.schedulePersonaName,children:gr})]}),e.jsx("span",{className:Ie.scheduleName,children:n}),e.jsx("span",{className:`${Ie.scheduleBadge} ${t.mode==="agent"?Ie.modeAgent:Ie.modeMessage}`,children:t.mode}),S&&e.jsx("span",{className:`${Ie.scheduleBadge} ${Ie.disabled}`,children:"disabled"})]}),e.jsxs("div",{className:Ie.scheduleMeta,children:[e.jsx("span",{className:Ie.scheduleMetaItem,children:Py(t)}),t.schedule_kind==="interval"&&t.repeat_times!==null&&e.jsxs("span",{className:Ie.scheduleMetaItem,children:["repeat ",t.repeat_count,"/",t.repeat_times]}),t.schedule_kind==="interval"&&t.repeat_times===null&&e.jsxs("span",{className:Ie.scheduleMetaItem,children:["ran ×",t.repeat_count]}),e.jsxs("span",{className:Ie.scheduleMetaItem,children:["next: ",$s(t.next_run_at)]})]}),e.jsx("div",{className:`${Ie.schedulePrompt} ${E&&!o?Ie.schedulePromptCollapsed:""}`,children:t.prompt}),E&&e.jsx("button",{type:"button",className:Ie.schedulePromptToggle,onClick:()=>m(a=>!a),children:o?"收起":"展开"}),t.mode==="agent"&&e.jsx("div",{className:Ie.scheduleMeta,children:e.jsxs("span",{className:Ie.scheduleMetaItem,children:["→ ",t.agent_name??"(unset)"]})}),t.last_status&&e.jsxs("div",{className:`${Ie.scheduleLastRun} ${j}`,children:["last: ",t.last_status,t.last_status==="error"&&t.last_error?` · ${t.last_error}`:"",t.last_status==="skipped"&&t.last_error?` · ${t.last_error}`:""," · ",$s(t.last_run_at)]})]})}const Wy="_wrapper_752p7_1",Uy="_header_752p7_7",qy="_label_752p7_13",Vy="_toggleBtn_752p7_18",Gy="_textarea_752p7_39",Ky="_preview_752p7_65",Jy="_emptyHint_752p7_73",Rt={wrapper:Wy,header:Uy,label:qy,toggleBtn:Vy,textarea:Gy,preview:Ky,emptyHint:Jy};function Ks({value:t,onChange:o,placeholder:m,label:S,rows:j=6,disabled:E=!1}){const[b,n]=g.useState("edit");return e.jsxs("div",{className:Rt.wrapper,children:[e.jsxs("div",{className:Rt.header,children:[S&&e.jsx("span",{className:Rt.label,children:S}),e.jsx("button",{type:"button",className:Rt.toggleBtn,onClick:()=>n(b==="edit"?"preview":"edit"),disabled:E,children:b==="edit"?"预览":"编辑"})]}),b==="edit"?e.jsx("textarea",{className:Rt.textarea,value:t,onChange:a=>o(a.target.value),placeholder:m,rows:j,disabled:E}):e.jsx("div",{className:Rt.preview,children:t.trim()?e.jsx(dt,{content:t}):e.jsx("span",{className:Rt.emptyHint,children:"暂无内容"})})]})}function Xy({open:t,agents:o,onClose:m,onCreateIssue:S}){const[j,E]=g.useState(""),[b,n]=g.useState("medium"),[a,d]=g.useState(""),h=o.filter(i=>{var r;return((r=i.profile)==null?void 0:r.category)!=="真人"}),c=()=>{E(""),n("medium"),d("")},f=()=>{c(),m()},v=()=>{const i=j.trim();i&&(S({description:i,priority:b!=="medium"?b:void 0,assignedTo:a||void 0}),f())},y=!!j.trim(),u=li(j);return e.jsxs(De,{open:t,title:"创建 Issue",scrollable:!0,footer:e.jsxs("div",{className:Q.modalActions,children:[e.jsx(ie,{variant:"secondary",size:"md",onClick:f,children:"取消"}),e.jsx(ie,{variant:"primary",size:"md",onClick:v,disabled:!y,children:"创建"})]}),children:[e.jsxs("div",{className:Q.formField,children:[e.jsx(Ks,{value:j,onChange:E,label:"任务内容",placeholder:'描述任务,或以 "/plan ..." 开头进入计划模式(标题会自动从内容前 40 字符生成)',rows:8}),j.trim()&&e.jsxs("div",{style:{marginTop:6,fontSize:12,color:"var(--color-slate, #888)",padding:"4px 8px",background:"var(--color-background, #f6f6f6)",borderRadius:"var(--radius-sm, 4px)"},children:["生成标题预览:",e.jsx("span",{style:{fontFamily:"var(--font-mono, monospace)",marginLeft:6,color:"var(--text-1, #333)"},children:u})]})]}),e.jsx("div",{className:Q.formField,children:e.jsx(Fe,{label:"优先级",value:b,onChange:i=>n(i.target.value),options:[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"critical",label:"Critical"}]})}),e.jsx("div",{className:Q.formField,children:e.jsx(Fe,{label:"指派 Agent (可选)",value:a,onChange:i=>d(i.target.value),options:[{value:"",label:"-- 暂不分配,稍后指派 --"},...h.map(i=>({value:i.name,label:i.name}))]})})]})}function Zy({open:t,onClose:o,onCreate:m}){const[S,j]=g.useState(""),[E,b]=g.useState(""),n=()=>{j(""),b(""),o()},a=()=>{S.trim()&&(m({title:S.trim(),description:E.trim()||void 0}),n())},d=!!S.trim();return e.jsxs(De,{open:t,title:"创建 Note",scrollable:!0,footer:e.jsxs("div",{className:Q.modalActions,children:[e.jsx(ie,{variant:"secondary",size:"md",onClick:n,children:"取消"}),e.jsx(ie,{variant:"primary",size:"md",onClick:a,disabled:!d,children:"创建"})]}),children:[e.jsx("div",{className:Q.formField,children:e.jsx(ge,{label:"标题:",type:"text",value:S,onChange:h=>j(h.target.value),placeholder:"一句话概括这条记录",autoFocus:!0})}),e.jsx("div",{className:Q.formField,children:e.jsx(Ks,{value:E,onChange:b,label:"内容 (Markdown)",placeholder:"纯文字记录,会议纪要、想法、参考资料等",rows:12})})]})}function Yy({open:t,groupMemberNames:o,agents:m,onClose:S,onAdd:j}){const[E,b]=g.useState([]),n=new Set(o),a=m.filter(c=>!n.has(c.name)),d=()=>{b([]),S()},h=()=>{E.length!==0&&(j(E),b([]))};return e.jsxs(De,{open:t,title:"添加成员",footer:e.jsxs("div",{className:Q.modalActions,children:[e.jsx(ie,{variant:"secondary",size:"md",onClick:d,children:"取消"}),e.jsx(ie,{variant:"primary",size:"md",onClick:h,disabled:E.length===0,children:"添加"})]}),children:[o.length>0&&e.jsxs("div",{className:Q.formField,children:[e.jsx("label",{className:Q.formLabel,children:"当前成员:"}),e.jsx("div",{className:Q.existingMemberList,children:o.map(c=>{const f=m.find(v=>v.name===c);return e.jsxs("span",{className:Q.existingMemberTag,children:[c,f&&e.jsx("span",{className:`${Q.agentCheckStatus} ${f.status==="online"?Q.online:Q.offline}`,children:f.status==="online"?"在线":"离线"})]},c)})})]}),e.jsxs("div",{className:Q.formField,children:[e.jsx("label",{className:Q.formLabel,children:"选择要添加的 Agent:"}),e.jsxs("div",{className:Q.agentCheckList,children:[a.map(c=>e.jsxs("div",{className:Q.agentCheckItem,children:[e.jsx(Dt,{checked:E.includes(c.name),onChange:f=>{b(f?v=>[...v,c.name]:v=>v.filter(y=>y!==c.name))},label:c.name}),e.jsx("span",{className:`${Q.agentCheckStatus} ${c.status==="online"?Q.online:Q.offline}`,children:c.status==="online"?"在线":"离线"})]},c.id)),a.length===0&&e.jsx("div",{style:{padding:16,color:"var(--color-slate)",textAlign:"center",fontSize:13},children:"所有 Agent 都已在群中"})]})]})]})}const Qy="_header_1q8fz_1",ex="_iconBadge_1q8fz_8",tx="_headerText_1q8fz_21",sx="_headerTitle_1q8fz_26",rx="_headerSubtitle_1q8fz_34",ix="_headerSubtitleEmpty_1q8fz_42",nx="_field_1q8fz_47",ox="_label_1q8fz_51",ax="_inputWrap_1q8fz_60",lx="_inputPrefix_1q8fz_76",cx="_input_1q8fz_60",dx="_clearBtn_1q8fz_102",hx="_hint_1q8fz_124",ux="_hintIcon_1q8fz_134",_x="_actions_1q8fz_150",fx="_actionsLeft_1q8fz_160",px="_actionsRight_1q8fz_165",Ye={header:Qy,iconBadge:ex,headerText:tx,headerTitle:sx,headerSubtitle:rx,headerSubtitleEmpty:ix,field:nx,label:ox,inputWrap:ax,inputPrefix:lx,input:cx,clearBtn:dx,hint:hx,hintIcon:ux,actions:_x,actionsLeft:fx,actionsRight:px};function mx({open:t,scope:o,scopeName:m,currentDir:S,fallbackDir:j,onClose:E,onSubmit:b}){const[n,a]=g.useState(S||""),d=g.useRef(null);g.useEffect(()=>{t&&(a(S||""),requestAnimationFrame(()=>{var s,l;(s=d.current)==null||s.focus(),(l=d.current)==null||l.select()}))},[t,S]);const h=o==="group"?"群":o==="direct"?"对话":"成员",c=n.trim(),f=c!==(S||"").trim(),v=!!S,y=o==="member"&&j?`当前未设置(将使用群工作目录:${j})`:"当前未设置(将使用 Agent 默认目录)",u=()=>{b(c||null)},i=()=>{b(null)},r=s=>{s.key==="Enter"?(s.preventDefault(),u()):s.key==="Escape"&&(s.preventDefault(),E())};return e.jsxs(De,{open:t,title:"设置工作目录",onClose:E,footer:e.jsxs("div",{className:Ye.actions,children:[e.jsx("div",{className:Ye.actionsLeft,children:e.jsx(ie,{variant:"ghost",size:"sm",onClick:i,disabled:!v,title:v?"清除当前的工作目录设置":"当前未设置工作目录",children:"清除设置"})}),e.jsxs("div",{className:Ye.actionsRight,children:[e.jsx(ie,{variant:"secondary",size:"md",onClick:E,children:"取消"}),e.jsx(ie,{variant:"primary",size:"md",onClick:u,disabled:!f,children:"保存"})]})]}),children:[e.jsxs("div",{className:Ye.header,children:[e.jsx("div",{className:Ye.iconBadge,children:"📁"}),e.jsxs("div",{className:Ye.headerText,children:[e.jsxs("h4",{className:Ye.headerTitle,children:[h,":",m]}),e.jsx("p",{className:`${Ye.headerSubtitle} ${S?"":Ye.headerSubtitleEmpty}`,title:S||void 0,children:S?`当前:${S}`:y})]})]}),e.jsxs("div",{className:Ye.field,children:[e.jsx("label",{className:Ye.label,htmlFor:"working-dir-input",children:"目录路径"}),e.jsxs("div",{className:Ye.inputWrap,children:[e.jsx("span",{className:Ye.inputPrefix,children:"📂"}),e.jsx("input",{id:"working-dir-input",ref:d,type:"text",value:n,onChange:s=>a(s.target.value),onKeyDown:r,placeholder:"例如 ~/code/my-repo 或 /Users/me/work",className:Ye.input,spellCheck:!1,autoComplete:"off"}),n&&e.jsx("button",{type:"button",className:Ye.clearBtn,onClick:()=>{var s;a(""),(s=d.current)==null||s.focus()},title:"清空输入","aria-label":"清空输入",children:"✕"})]}),e.jsxs("p",{className:Ye.hint,children:[e.jsx("span",{className:Ye.hintIcon,children:"💡"}),e.jsxs("span",{children:["支持 ",e.jsx("code",{children:"~/"})," 自动展开为用户主目录;必须是已存在的目录。留空保存等同于清除设置。"]})]})]})]})}function gx({open:t,agentName:o,currentProfile:m,globalProfile:S,onClose:j,onSubmit:E}){const[b,n]=g.useState(""),[a,d]=g.useState(""),[h,c]=g.useState(!1);g.useEffect(()=>{t&&(n((m==null?void 0:m.position)??""),d((m==null?void 0:m.bio)??""))},[t,m]);const f=async y=>{y.preventDefault();const u={};b.trim()&&(u.position=b.trim()),a.trim()&&(u.bio=a.trim()),c(!0);try{await E(u)}finally{c(!1)}},v=y=>{const u=S==null?void 0:S[y];return u?`未覆盖时使用全局值:${u}`:"未覆盖时无全局值"};return e.jsx(De,{open:t,title:`群内角色覆盖 — ${o}`,onClose:j,size:"md",children:e.jsxs("form",{onSubmit:f,children:[e.jsx("div",{style:{marginBottom:12,padding:"8px 12px",background:"rgba(0,0,0,0.03)",borderRadius:6,fontSize:12,color:"var(--color-slate)"},children:"群级别覆盖优先于 agent 全局 profile。留空字段不写入覆盖,沿用全局值。 提交时所有字段都为空 = 清除覆盖。"}),e.jsx("div",{className:"field",style:{marginBottom:12},children:e.jsx(ge,{label:"岗位",value:b,onChange:y=>n(y.target.value),placeholder:v("position"),disabled:h})}),e.jsx("div",{className:"field",style:{marginBottom:16},children:e.jsx(xt,{label:"简介",value:a,onChange:y=>d(y.target.value),placeholder:v("bio"),rows:3,disabled:h})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(ie,{type:"button",variant:"secondary",size:"md",onClick:j,disabled:h,children:"取消"}),e.jsx(ie,{type:"submit",variant:"primary",size:"md",disabled:h,children:h?"保存中...":"保存"})]})]})})}function vr(t){if(!t)return null;try{const o=JSON.parse(t),m={};return typeof o.position=="string"&&(m.position=o.position),typeof o.bio=="string"&&(m.bio=o.bio),typeof o.category=="string"&&(m.category=o.category),m}catch{return null}}function vx({open:t,members:o,agents:m,groupId:S,groupName:j,groupWorkingDir:E,groupGuidancePrompt:b,onUpdateGuidancePrompt:n,onClose:a,onUpdateMemberWorkingDir:d,onProfilesChanged:h}){var R;const[c,f]=g.useState(null),[v,y]=g.useState(null),[u,i]=g.useState(b||""),[r,s]=g.useState(!1),[l,_]=g.useState(!1),x=()=>f(null),C=()=>y(null),k=u.trim()!==(b||"").trim(),p=async()=>{if(!(!n||!k)){s(!0);try{await n(S,u.trim()||null)}finally{s(!1)}}},w=g.useMemo(()=>{const T=new Map;for(const M of m)T.set(M.name,M);return T},[m]);return e.jsxs(e.Fragment,{children:[e.jsxs(De,{open:t,title:"群成员",onClose:a,children:[e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"8px 0"},children:o.map(T=>{var V,L;const M=T.agent_name,N=w.get(M),I=(N==null?void 0:N.status)==="online",z=!!T.working_dir,G=vr(T.profile),H=!!(G&&Object.keys(G).length>0);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"8px 4px",borderBottom:"1px solid rgba(0,0,0,0.05)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(At,{name:M,src:N==null?void 0:N.avatar_url,size:32}),e.jsx("span",{style:{fontSize:14,color:"var(--color-navy)",fontWeight:500},children:M}),e.jsx("span",{title:T.working_dir||E||void 0,style:{fontSize:11,padding:"2px 8px",borderRadius:10,background:z?"rgba(99, 102, 241, 0.1)":"rgba(0,0,0,0.04)",color:z?"rgb(99, 102, 241)":"var(--color-slate)",maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z?`📁 ${T.working_dir}`:"↩ 继承群"}),e.jsx("span",{style:{marginLeft:"auto",fontSize:12,padding:"2px 10px",borderRadius:10,background:I?"rgba(52, 168, 83, 0.1)":"rgba(0,0,0,0.05)",color:I?"var(--color-success)":"var(--color-slate)"},children:I?"在线":"离线"}),e.jsx("button",{type:"button",onClick:()=>f(T),title:"设置该成员的工作目录",style:{border:"1px solid rgba(0,0,0,0.1)",background:"var(--color-surface)",borderRadius:6,padding:"4px 8px",fontSize:12,cursor:"pointer",color:"var(--color-navy)"},children:"📁 目录"}),e.jsx("button",{type:"button",onClick:()=>y(T),title:"设置该成员在群内的岗位/简介覆盖",style:{border:"1px solid rgba(0,0,0,0.1)",background:H?"rgba(99, 102, 241, 0.1)":"var(--color-surface)",color:H?"rgb(99, 102, 241)":"var(--color-navy)",borderRadius:6,padding:"4px 8px",fontSize:12,cursor:"pointer"},children:H?"📝 角色(已覆盖)":"📝 角色"})]}),(G||(N==null?void 0:N.profile))&&e.jsxs("div",{style:{paddingLeft:42,fontSize:11,color:"var(--color-slate)",display:"flex",gap:8,flexWrap:"wrap"},children:[H&&e.jsx("span",{style:{color:"rgb(99, 102, 241)",fontWeight:500},children:"群内覆盖:"}),e.jsxs("span",{children:["岗位: ",((G==null?void 0:G.position)??((V=N==null?void 0:N.profile)==null?void 0:V.position))||"-"]}),e.jsxs("span",{children:["简介: ",((G==null?void 0:G.bio)??((L=N==null?void 0:N.profile)==null?void 0:L.bio))||"-"]})]})]},M)})}),n&&e.jsxs("div",{style:{borderTop:"1px solid rgba(0,0,0,0.08)",marginTop:12,paddingTop:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:6},children:[e.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--color-navy)"},children:"📋 群指导 prompt"}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",onClick:()=>_(!0),style:{border:"1px solid rgba(0,0,0,0.12)",background:"transparent",color:"var(--color-navy)",borderRadius:6,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"📚 从模板选择"}),k&&e.jsx("button",{type:"button",onClick:p,disabled:r,style:{border:"none",background:"var(--color-primary, #4f46e5)",color:"#fff",borderRadius:6,padding:"4px 12px",fontSize:12,cursor:r?"not-allowed":"pointer",opacity:r?.6:1},children:r?"保存中...":"保存"})]})]}),e.jsx(xt,{value:u,onChange:T=>i(T.target.value),placeholder:"全群一份,群内所有 agent 被唤起时拼到 prompt 上。例:本群讨论 VR 需求,回复聚焦用户场景;提问加 #reply。",rows:3,helperText:"留空保存 = 清除。群级别硬约定,所有成员都会看到。",spellCheck:!1})]}),e.jsx(yx,{groupId:S,memberAgentNames:o.map(T=>T.agent_name)})]}),c&&e.jsx(mx,{open:!!c,scope:"member",scopeName:c.agent_name,currentDir:c.working_dir,fallbackDir:E,onClose:x,onSubmit:T=>{d(S,c.agent_name,T),x()}}),v&&e.jsx(gx,{open:!!v,agentName:v.agent_name,currentProfile:vr(v.profile),globalProfile:((R=w.get(v.agent_name))==null?void 0:R.profile)??null,onClose:C,onSubmit:async T=>{await Re.setMemberProfile(S,v.agent_name,T),h==null||h(),C()}}),l&&e.jsx(Ws,{open:l,groupId:S,groupName:j,memberAgentNames:o.map(T=>T.agent_name),onPromptApplied:T=>i(T),onClose:()=>_(!1)})]})}function yx({groupId:t,memberAgentNames:o}){const{myAgentName:m,agents:S}=nt(),[j,E]=g.useState([]),[b,n]=g.useState([]),[a,d]=g.useState(null),[h,c]=g.useState(""),f=g.useMemo(()=>{const u=new Map(S.map(i=>[i.name,i]));return o.filter(i=>{var l;const r=u.get(i);let s;return(l=r==null?void 0:r.profile)!=null&&l.category&&(s=r.profile.category),s!=="真人"})},[o,S]),v=()=>{Promise.all([tt.list(),tt.listBindings(t)]).then(([u,i])=>{E(u),n(i)}).catch(u=>d(u.message))};g.useEffect(()=>{v()},[t]);const y=async(u,i)=>{const r=`${u}:${i.id}`;if(!h){c(r);try{b.some(l=>l.agent_name===u&&l.skill_id===i.id)?await tt.unbind(t,u,i.name):await tt.bind(t,u,i.name,m),await v()}catch(s){d(s.message)}finally{c("")}}};return f.length===0?null:e.jsxs("div",{style:{marginTop:16,padding:14,border:"1px solid var(--border-color-light, rgba(0,0,0,0.08))",borderRadius:8,background:"var(--color-surface, #fff)"},children:[e.jsxs("div",{style:{marginBottom:10},children:[e.jsx("div",{style:{fontSize:13,fontWeight:700,color:"var(--color-navy, #1a365d)"},children:"⚡ 技能绑定(per agent)"}),e.jsx("div",{style:{fontSize:11,color:"var(--color-slate, #888)",marginTop:2,lineHeight:1.4},children:"勾选的 skill 在该 agent 执行时注入 prompt 指针;全局 skill 在工具箱管理"})]}),a&&e.jsx("div",{style:{color:"#c00",fontSize:12,marginBottom:6},children:a}),j.length===0?e.jsxs("div",{style:{fontSize:12,color:"var(--color-slate, #888)",padding:"8px 0"},children:["暂无 skill。去工具箱「技能」tab 新建,或 ",e.jsx("code",{children:"rotom memory promote-to-skill"})," 沉淀。"]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:f.map(u=>e.jsxs("div",{style:{padding:"6px 0",borderTop:"1px solid var(--border-color-light, #eee)"},children:[e.jsx("div",{style:{fontSize:12,fontWeight:700,marginBottom:6,color:"var(--color-navy, #1a365d)"},children:u}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:j.map(i=>{const r=b.some(l=>l.agent_name===u&&l.skill_id===i.id),s=`${u}:${i.id}`;return e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,padding:"4px 10px",border:`1px solid ${r?"var(--color-wise-green, #2f7a2f)":"var(--border-color-light, #ddd)"}`,borderRadius:6,cursor:h===s?"wait":"pointer",userSelect:"none",lineHeight:1.2,background:r?"rgba(47, 122, 47, 0.08)":"transparent",color:r?"var(--color-wise-green, #2f7a2f)":"var(--color-navy, #1a365d)",opacity:h===s?.5:1,transition:"background 0.15s, border-color 0.15s, color 0.15s"},children:[e.jsx(Dt,{checked:r,onChange:()=>y(u,i),disabled:h===s,name:i.name}),e.jsx("span",{onClick:()=>y(u,i),style:{cursor:h===s?"wait":"pointer"},children:i.name})]},i.id)})})]},u))})]})}async function yr(t,o){const m=localStorage.getItem("chat_agent_token")||"",S={"Content-Type":"application/json",...o.headers??{}};m&&(S.Authorization=`Bearer ${m}`);const j=await fetch(`/api${t}`,{...o,headers:S}),E=await j.text(),b=E?JSON.parse(E):void 0;if(!j.ok)throw new Error((b==null?void 0:b.error)||`HTTP ${j.status}`);return b}const xr={async create(t){return yr(`/groups/${t}/shares`,{method:"POST"})},async revoke(t){return yr(`/shares/${t}`,{method:"DELETE"})}};function xx({open:t,groupId:o,groupName:m,onClose:S}){const[j,E]=g.useState(null),[b,n]=g.useState(null),[a,d]=g.useState(!1),[h,c]=g.useState(!1),[f,v]=g.useState(!1),y=j?`${window.location.origin}/dashboard/groups/${o}?share=${j}`:null,u=async()=>{d(!0),n(null);try{const s=await xr.create(o);E(s.token)}catch(s){n(s instanceof Error?s.message:"生成链接失败")}finally{d(!1)}},i=async()=>{if(y)try{await navigator.clipboard.writeText(y),v(!0),setTimeout(()=>v(!1),1500)}catch{}},r=async()=>{if(j){c(!0);try{await xr.revoke(j),E(null)}catch(s){n(s instanceof Error?s.message:"撤销失败")}finally{c(!1)}}};return e.jsxs(De,{open:t,title:`分享「${m}」`,onClose:S,size:"md",children:[e.jsx("p",{style:{margin:"0 0 16px",fontSize:13,color:"var(--color-warm-dark, #64748b)",lineHeight:1.6},children:"访客通过该链接可以查看群内的全部消息、Issue、产物和笔记,但无法发送消息或修改任何内容。 链接仅存于内存,重启 Master 后失效;可随时撤销。"}),b&&e.jsx("div",{style:{padding:8,background:"#fef2f2",color:"#b91c1c",borderRadius:6,marginBottom:12,fontSize:13},children:b}),j?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[e.jsx(ge,{readOnly:!0,value:y??"",onFocus:s=>s.currentTarget.select(),size:"sm",style:{flex:1,fontFamily:"ui-monospace, SFMono-Regular, monospace",minWidth:0}}),e.jsx(ie,{variant:"primary",size:"sm",onClick:i,style:{background:f?"#dcfce7":void 0,color:f?"#166534":void 0,whiteSpace:"nowrap"},children:f?"✓ 已复制":"复制"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ie,{variant:"ghost",size:"sm",onClick:r,disabled:h,style:{color:"#b91c1c",border:"1px solid #fecaca"},children:h?"撤销中…":"撤销链接"}),e.jsx("span",{style:{fontSize:12,color:"#94a3b8"},children:"重启 Master 后此链接自动失效"})]})]}):e.jsx(ie,{variant:"primary",size:"md",onClick:u,disabled:a,style:{width:"100%"},children:a?"生成中…":"生成分享链接"})]})}const bx="_container_17o04_1",Sx="_filters_17o04_16",Cx="_filter_17o04_16",wx="_filterInput_17o04_41",jx="_filterSelect_17o04_42",kx="_table_17o04_82",Ex="_tableWrap_17o04_94",Nx="_row_17o04_118",Rx="_rowSelected_17o04_127",Lx="_tsCell_17o04_131",Tx="_tsParts_17o04_138",Ix="_payloadCell_17o04_144",Ax="_detailOverlay_17o04_152",Dx="_detailPanel_17o04_160",Bx="_detailHeader_17o04_181",Mx="_detailTitle_17o04_190",$x="_detailBody_17o04_223",Px="_detailGrid_17o04_229",Ox="_detailLabel_17o04_237",Hx="_detailValue_17o04_245",Fx="_payloadPre_17o04_251",zx="_empty_17o04_267",Wx="_pagination_17o04_302",Ux="_mentionChip_17o04_362",qx="_mentionHas_17o04_375",Vx="_mentionNone_17o04_380",Gx="_filteredNotice_17o04_385",ve={container:bx,filters:Sx,filter:Cx,filterInput:wx,filterSelect:jx,table:kx,tableWrap:Ex,row:Nx,rowSelected:Rx,tsCell:Lx,tsParts:Tx,payloadCell:Ix,detailOverlay:Ax,detailPanel:Dx,detailHeader:Bx,detailTitle:Mx,detailBody:$x,detailGrid:Px,detailLabel:Ox,detailValue:Hx,payloadPre:Fx,empty:zx,pagination:Wx,mentionChip:Ux,mentionHas:qx,mentionNone:Vx,filteredNotice:Gx},Yt=50,Kx=["","routed","queued","delivered","failed","no_target","ok","group_message"],Jx=[{value:"",label:"全部"},{value:"mentioned",label:"有提及"},{value:"not_mentioned",label:"无提及"}];function br(t){try{const o=t.includes("Z")||t.includes("+")?t:t+"Z",m=new Date(o);return{date:m.toLocaleDateString("zh-CN",{timeZone:"Asia/Shanghai"}),time:m.toLocaleTimeString("zh-CN",{timeZone:"Asia/Shanghai",hour12:!1})}}catch{return{date:t,time:""}}}function hi(t){try{return JSON.parse(t)}catch{return t}}function Xx(t){const o=hi(t);if(typeof o=="string")return o;if(o&&typeof o=="object"){const m=o.message;return typeof m=="string"?m:JSON.stringify(o)}return String(t)}function Zx(t){try{const o=JSON.parse(t);if(Array.isArray(o.mentions))return o.mentions.length>0;if(o.message&&typeof o.message=="string")return/@[\w一-鿿][\w.一-鿿-]*/.test(o.message)}catch{}}function ui({lockGroupId:t,groups:o}){const[m,S]=g.useState([]),[j,E]=g.useState([]),[b,n]=g.useState(!1),[a,d]=g.useState(0),[h,c]=g.useState(!1),[f,v]=g.useState(0),[y,u]=g.useState(null),i=o??j,[r,s]=g.useState({from:"",to:"",status:"",keyword:"",groupId:t??"",mentionFilter:""});g.useEffect(()=>{o||Re.list().then(E).catch(()=>E([]))},[o]),g.useEffect(()=>{t!==void 0&&s(w=>w.groupId===t?w:{...w,groupId:t})},[t]);const l=g.useCallback(async()=>{n(!0);try{const w=await Qr.list({from:r.from||void 0,to:r.to||void 0,status:r.status||void 0,keyword:r.keyword||void 0,groupId:r.groupId||void 0,limit:Yt+1,offset:a*Yt});c(w.messages.length>Yt),S(w.messages.slice(0,Yt)),v(w.total)}catch(w){console.error("Failed to load messages:",w),S([]),c(!1),v(0)}finally{n(!1)}},[r,a]),_=r.mentionFilter==="all"||!r.mentionFilter?m:m.filter(w=>{const R=Zx(w.payload);return R===void 0?r.mentionFilter==="not_mentioned":r.mentionFilter==="mentioned"?R:!R});g.useEffect(()=>{l()},[l]);const x=(w,R)=>{w==="groupId"&&t!==void 0||(s(T=>({...T,[w]:R})),d(0))},C=()=>{s({from:"",to:"",status:"",keyword:"",groupId:t??"",mentionFilter:""}),d(0)},k=w=>{if(!w)return"";const R=i.find(T=>T.id===w);return(R==null?void 0:R.name)||w.slice(0,8)},p=m.find(w=>w.id===y);return e.jsxs("div",{className:ve.container,children:[e.jsxs("div",{className:ve.filters,children:[e.jsx("div",{className:ve.filter,children:e.jsx(ge,{className:ve.filterInput,size:"sm",label:"发送方",value:r.from,onChange:w=>x("from",w.target.value),placeholder:"agent 名"})}),e.jsx("div",{className:ve.filter,children:e.jsx(ge,{className:ve.filterInput,size:"sm",label:"接收方",value:r.to,onChange:w=>x("to",w.target.value),placeholder:"agent 名"})}),e.jsx("div",{className:ve.filter,children:e.jsx(Fe,{className:ve.filterSelect,size:"sm",label:"状态",value:r.status,onChange:w=>x("status",w.target.value),options:Kx.map(w=>({value:w,label:w||"全部"}))})}),t===void 0&&e.jsx("div",{className:ve.filter,children:e.jsx(Fe,{className:ve.filterSelect,size:"sm",label:"群",value:r.groupId,onChange:w=>x("groupId",w.target.value),options:[{value:"",label:"全部"},...i.map(w=>({value:w.id,label:w.name}))]})}),e.jsx("div",{className:ve.filter,children:e.jsx(Fe,{className:ve.filterSelect,size:"sm",label:"提及",value:r.mentionFilter,onChange:w=>x("mentionFilter",w.target.value),options:[...Jx]})}),e.jsx("div",{className:ve.filter,children:e.jsx(ge,{className:ve.filterInput,size:"sm",label:"关键字",value:r.keyword,onChange:w=>x("keyword",w.target.value),placeholder:"payload 包含"})}),e.jsx(ie,{variant:"ghost",size:"sm",onClick:C,children:"重置"})]}),e.jsx("div",{className:ve.tableWrap,children:e.jsxs("table",{className:ve.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{width:100},children:"时间"}),e.jsx("th",{style:{width:140},children:"发送方"}),e.jsx("th",{style:{width:140},children:"接收方"}),e.jsx("th",{style:{width:140},children:"群"}),e.jsx("th",{style:{width:60},children:"方向"}),e.jsx("th",{style:{width:60},children:"来源"}),e.jsx("th",{style:{width:100},children:"状态"}),e.jsx("th",{children:"内容"})]})}),e.jsx("tbody",{children:b?e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:ve.empty,children:"加载中..."})}):_.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:ve.empty,children:"没有匹配的消息"})}):_.map(w=>{const R=(()=>{try{const T=JSON.parse(w.payload);return Array.isArray(T.mentions)?T.mentions:[]}catch{return[]}})();return e.jsxs("tr",{className:`${ve.row} ${y===w.id?ve.rowSelected:""}`,onClick:()=>u(y===w.id?null:w.id),children:[e.jsx("td",{className:ve.tsCell,children:(()=>{const{date:T,time:M}=br(w.timestamp);return e.jsxs("div",{className:ve.tsParts,children:[e.jsx("span",{children:T}),e.jsx("span",{children:M})]})})()}),e.jsx("td",{children:w.from_name||"—"}),e.jsx("td",{children:w.to_name||"—"}),e.jsx("td",{children:w.group_id?k(w.group_id):"—"}),e.jsx("td",{children:w.direction||"—"}),e.jsx("td",{children:w.source?e.jsx(ht,{tone:"source",value:w.source,children:w.source==="cli"?"CLI":w.source==="ws"?"WS":w.source==="api"?"API":w.source}):"—"}),e.jsxs("td",{children:[w.status&&e.jsx(ht,{tone:"status",value:w.status,children:w.status.replace("_"," ")}),R.length>0&&e.jsx("span",{className:`${ve.mentionChip} ${ve.mentionHas}`,children:"@"}),w.group_id&&R.length===0&&w.status==="group_message"&&e.jsx("span",{className:`${ve.mentionChip} ${ve.mentionNone}`,children:"-"})]}),e.jsx("td",{className:ve.payloadCell,children:Xx(w.payload)})]},w.id)})})]})}),r.mentionFilter&&_.length<m.length&&e.jsxs("div",{className:ve.filteredNotice,children:["已筛选: 显示 ",_.length,"/",m.length," 条"]}),e.jsxs("div",{className:ve.pagination,children:[e.jsxs("div",{children:["第 ",a+1," / ",Math.max(1,Math.ceil(f/Yt))," 页 · 共 ",f," 条"]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(ie,{variant:"ghost",size:"sm",disabled:a===0,onClick:()=>d(w=>Math.max(0,w-1)),children:"上一页"}),e.jsx(ie,{variant:"ghost",size:"sm",disabled:!h,onClick:()=>d(w=>w+1),children:"下一页"})]})]}),p&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:ve.detailOverlay,onClick:()=>u(null)}),e.jsxs("div",{className:ve.detailPanel,children:[e.jsxs("div",{className:ve.detailHeader,children:[e.jsx("h3",{className:ve.detailTitle,children:"消息详情"}),e.jsx(ie,{variant:"ghost",size:"sm",iconOnly:!0,onClick:()=>u(null),title:"关闭",children:"×"})]}),e.jsxs("div",{className:ve.detailBody,children:[e.jsxs("div",{className:ve.detailGrid,children:[e.jsx("div",{className:ve.detailLabel,children:"requestId"}),e.jsx("div",{className:ve.detailValue,children:p.request_id||"—"}),e.jsx("div",{className:ve.detailLabel,children:"时间"}),e.jsx("div",{className:ve.detailValue,children:(()=>{const{date:w,time:R}=br(p.timestamp);return R?`${w} ${R}`:w})()}),e.jsx("div",{className:ve.detailLabel,children:"发送方"}),e.jsxs("div",{className:ve.detailValue,children:[p.from_name||"—"," ",p.from_domain?`(${p.from_domain})`:""]}),e.jsx("div",{className:ve.detailLabel,children:"接收方"}),e.jsxs("div",{className:ve.detailValue,children:[p.to_name||"—"," ",p.to_domain?`(${p.to_domain})`:""]}),e.jsx("div",{className:ve.detailLabel,children:"来源"}),e.jsx("div",{className:ve.detailValue,children:p.source||"—"}),e.jsx("div",{className:ve.detailLabel,children:"路由类型"}),e.jsx("div",{className:ve.detailValue,children:p.route_type}),e.jsx("div",{className:ve.detailLabel,children:"群"}),e.jsx("div",{className:ve.detailValue,children:p.group_id?`${k(p.group_id)} (${p.group_id})`:"—"}),e.jsx("div",{className:ve.detailLabel,children:"方向 / 状态"}),e.jsxs("div",{className:ve.detailValue,children:[p.direction||"—"," / ",p.status||"—"]}),e.jsx("div",{className:ve.detailLabel,children:"延迟"}),e.jsx("div",{className:ve.detailValue,children:p.latency_ms!==void 0&&p.latency_ms!==null?`${p.latency_ms} ms`:"—"})]}),e.jsx("pre",{className:ve.payloadPre,children:(()=>{const w=hi(p.payload);return typeof w=="string"?w:JSON.stringify(w,null,2)})()})]})]})]})]})}function Yx({open:t,groupId:o,groupName:m,groups:S,onClose:j}){return e.jsx(De,{open:t,title:m?`群消息流 · ${m}`:"群消息流",onClose:j,size:"xl",children:e.jsx(ui,{lockGroupId:o,groups:S})})}const Ve={async listGroup(t,o={}){const m=new URLSearchParams;o.type&&o.type!=="all"&&m.set("type",o.type),o.category&&m.set("category",o.category),o.includePending&&m.set("includePending","true");const S=m.toString();return ne.get(`/groups/${t}/memory${S?`?${S}`:""}`)},async listGlobal(t={}){const o=new URLSearchParams;t.type&&t.type!=="all"&&o.set("type",t.type),t.category&&o.set("category",t.category),t.includePending&&o.set("includePending","true");const m=o.toString();return ne.get(`/memory/global${m?`?${m}`:""}`)},async search(t,o){if(o)return ne.get(`/groups/${o}/memory/search?q=${encodeURIComponent(t)}`);const m=await ne.get(`/memory/search?q=${encodeURIComponent(t)}`);return{group:[],global:m}},async getById(t){return ne.get(`/memory/${t}`)},async createGroup(t,o){return ne.post(`/groups/${t}/memory`,o)},async createGlobal(t){return ne.post("/memory/global",t)},async update(t,o){return ne.patch(`/memory/${t}`,o)},async remove(t){return ne.delete(`/memory/${t}`)},async promote(t,o){return ne.post(`/memory/${t}/promote`,{visibility:o})},async expire(t){return ne.post(`/memory/${t}/expire`)},async listPending(t){return ne.get(`/groups/${t}/memory/pending`)},async listAllPending(){return ne.get("/memory/pending")},async approve(t){return ne.post(`/memory/${t}/approve`)},async reject(t){return ne.post(`/memory/${t}/reject`)},async stats(t){return ne.get(`/groups/${t}/memory/stats`)},async count(t){return ne.get(`/groups/${t}/memory/count`)}},Qx="_memoryPanel_oudd0_3",eb="_header_oudd0_13",tb="_filterSelect_oudd0_24",sb="_headerRight_oudd0_30",rb="_searchInput_oudd0_36",ib="_clearBtn_oudd0_51",nb="_body_oudd0_65",ob="_empty_oudd0_71",ab="_error_oudd0_83",lb="_list_oudd0_92",cb="_item_oudd0_98",db="_itemTitleRow_oudd0_111",hb="_itemKey_oudd0_119",ub="_catChip_oudd0_133",_b="_catFact_oudd0_148",fb="_catDecision_oudd0_149",pb="_catConvention_oudd0_150",mb="_catPitfall_oudd0_151",gb="_catTodo_oudd0_152",vb="_catPlaybook_oudd0_153",yb="_catNote_oudd0_154",xb="_scopeChip_oudd0_156",bb="_scopeGlobal_oudd0_170",Sb="_scopeNote_oudd0_171",Cb="_noteHumanOnly_oudd0_173",wb="_itemPending_oudd0_176",jb="_pendingCorner_oudd0_185",kb="_itemSummary_oudd0_200",Eb="_itemMeta_oudd0_208",Nb="_detail_oudd0_218",Rb="_detailHeader_oudd0_225",Lb="_backBtn_oudd0_234",Tb="_detailTitle_oudd0_249",Ib="_detailActions_oudd0_266",Ab="_detailMeta_oudd0_271",Db="_detailBody_oudd0_279",Bb="_detailSummary_oudd0_285",Mb="_detailTags_oudd0_295",$b="_tagChip_oudd0_304",Pb="_editor_oudd0_313",Ob="_editorHeader_oudd0_320",Hb="_editorTitle_oudd0_326",Fb="_editorBody_oudd0_333",zb="_field_oudd0_342",Wb="_fieldLabel_oudd0_348",Ub="_fieldRow_oudd0_354",qb="_editorActions_oudd0_362",Vb="_fieldHint_oudd0_372",me={memoryPanel:Qx,header:eb,filterSelect:tb,headerRight:sb,searchInput:rb,clearBtn:ib,body:nb,empty:ob,error:ab,list:lb,item:cb,itemTitleRow:db,itemKey:hb,catChip:ub,catFact:_b,catDecision:fb,catConvention:pb,catPitfall:mb,catTodo:gb,catPlaybook:vb,catNote:yb,scopeChip:xb,scopeGlobal:bb,scopeNote:Sb,noteHumanOnly:Cb,itemPending:wb,pendingCorner:jb,itemSummary:kb,itemMeta:Eb,detail:Nb,detailHeader:Rb,backBtn:Lb,detailTitle:Tb,detailActions:Ib,detailMeta:Ab,detailBody:Db,detailSummary:Bb,detailTags:Mb,tagChip:$b,editor:Pb,editorHeader:Ob,editorTitle:Hb,editorBody:Fb,field:zb,fieldLabel:Wb,fieldRow:Ub,editorActions:qb,fieldHint:Vb},Gb=["fact","decision","convention","pitfall","todo","playbook","note"],Js={fact:"事实",decision:"决策",convention:"约定",pitfall:"踩坑",todo:"待办",playbook:"工作流",note:"便签"},Kb={fact:"catFact",decision:"catDecision",convention:"catConvention",pitfall:"catPitfall",todo:"catTodo",playbook:"catPlaybook",note:"catNote"},Jb={all:"全部",memory:"记忆",note:"便签",global:"全局",pending:"待审核"};function Sr(t,o){return t.pending_review===1?o==="all"||o==="pending":o==="pending"?!1:o==="global"?t.scope==="global":o==="note"?t.category==="note":o==="memory"?t.category!=="note"&&t.scope!=="global":!0}function Xb({selectedGroupId:t,myAgentName:o}){const[m,S]=g.useState("all"),[j,E]=g.useState([]),[b,n]=g.useState(!1),[a,d]=g.useState(null),[h,c]=g.useState(""),[f,v]=g.useState(!1),[y,u]=g.useState(""),[i,r]=g.useState(null),s=g.useCallback(async()=>{n(!0),d(null);try{const[R,T,M]=await Promise.all([Ve.listGroup(t,{type:"all"}),Ve.listGlobal({type:"all"}),Ve.listPending(t).catch(()=>[])]),N=M.map(z=>({...z,pending_review:1})),I=new Map;for(const z of[...R,...T])I.set(z.id,z);for(const z of N)I.set(z.id,z);E(Array.from(I.values()))}catch(R){d(R.message??"加载失败")}finally{n(!1)}},[t]);g.useEffect(()=>{c(""),v(!1),s()},[t]);const l=async()=>{if(!y.trim()){r(null);return}try{const{group:R,global:T}=await Ve.search(y.trim(),t);r([...R,...T])}catch(R){d(R.message)}},_=i!==null,x=_?i:j,C=g.useMemo(()=>x.filter(R=>Sr(R,m)),[x,m]),k=g.useMemo(()=>{const R={all:0,memory:0,note:0,global:0,pending:0};for(const T of x)for(const M of Object.keys(R))Sr(T,M)&&(R[M]+=1);return R},[x]),p=g.useMemo(()=>x.find(R=>R.id===h),[x,h]),w=(p==null?void 0:p.pending_review)===1;return e.jsxs("div",{className:me.memoryPanel,children:[e.jsxs("div",{className:me.header,children:[e.jsx(Fe,{size:"sm",className:me.filterSelect,value:m,disabled:_,onChange:R=>{const T=R.target.value;S(T),r(null),u("")},children:["all","memory","note","global","pending"].map(R=>e.jsxs("option",{value:R,children:[Jb[R],_?"":` (${k[R]})`]},R))}),e.jsxs("div",{className:me.headerRight,children:[e.jsx(ge,{size:"sm",className:me.searchInput,placeholder:"搜索记忆",value:y,onChange:R=>u(R.target.value),onKeyDown:R=>{R.key==="Enter"&&l()}}),_&&e.jsx("button",{className:me.clearBtn,onClick:()=>{r(null),u("")},children:"清除"}),!_&&!h&&e.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>v(!0),children:"+ 新建"})]})]}),a&&e.jsx("div",{className:me.error,children:a}),e.jsx("div",{className:me.body,children:h?e.jsx(Zb,{id:h,isPending:w,onBack:()=>c(""),onChanged:s}):f?e.jsx(_i,{mode:"create",onCancel:()=>v(!1),onSaved:async R=>{try{const T={key:R.key,value:R.value,category:R.category,summary:R.summary,tags:R.tags,createdBy:o};R.scope==="global"?await Ve.createGlobal({...T,visibility:"global",agentVisible:!0}):R.scope==="note"?await Ve.createGroup(t,{...T,visibility:"group",agentVisible:!1}):await Ve.createGroup(t,{...T,visibility:"group",agentVisible:!0}),v(!1),s()}catch(T){d(T.message)}}}):b?e.jsx("div",{className:me.empty,children:"加载中..."}):C.length===0?e.jsx("div",{className:me.empty,children:_?"没有匹配的记忆":"暂无记忆条目"}):e.jsx("ul",{className:me.list,children:C.map(R=>{const T=R.pending_review===1,M=R.scope==="global";return e.jsxs("li",{className:`${me.item} ${T?me.itemPending:""}`,onClick:()=>c(R.id),children:[e.jsxs("div",{className:me.itemTitleRow,children:[e.jsx("span",{className:`${me.catChip} ${me[Kb[R.category]]}`,children:Js[R.category]}),e.jsx("span",{className:me.itemKey,children:R.key}),!T&&M&&e.jsx("span",{className:`${me.scopeChip} ${me.scopeGlobal}`,children:"全局"}),!T&&R.category==="note"&&R.agent_visible===0&&e.jsx("span",{className:`${me.scopeChip} ${me.noteHumanOnly}`,children:"📝 仅人类"}),T&&e.jsx("span",{className:me.pendingCorner,children:"待审核"})]}),R.summary&&e.jsx("div",{className:me.itemSummary,children:R.summary}),e.jsxs("div",{className:me.itemMeta,children:[e.jsx("span",{children:R.created_by??""}),e.jsx("span",{children:"·"}),e.jsx("span",{children:R.created_at.slice(0,16).replace("T"," ")}),R.group_id&&!M&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:["群 ",R.group_id.slice(0,8)]})]})]})]},R.id)})})})]})}function Zb({id:t,isPending:o,onBack:m,onChanged:S}){const[j,E]=g.useState(null),[b,n]=g.useState(!0),[a,d]=g.useState(null),[h,c]=g.useState(!1),f=()=>{n(!0),d(null),Ve.getById(t).then(r=>{E(r),n(!1)}).catch(r=>{d(r.message),n(!1)})};g.useEffect(()=>{f()},[t]);const v=async()=>{if(window.confirm("确认删除这条记录?(软删除)"))try{await Ve.remove(t),S(),m()}catch(r){d(r.message)}},y=async()=>{try{await Ve.approve(t),S(),m()}catch(r){d(r.message)}},u=async()=>{if(window.confirm("拒绝这条候选?(软删除)"))try{await Ve.reject(t),S(),m()}catch(r){d(r.message)}},i=async()=>{if(window.confirm("提升为全局共享?(所有群的 agent 可见)"))try{await Ve.promote(t,"global"),f()}catch(r){d(r.message)}};return b?e.jsx("div",{className:me.empty,children:"加载中..."}):a||!j?e.jsx("div",{className:me.empty,children:a??"加载失败"}):e.jsxs("div",{className:me.detail,children:[e.jsxs("div",{className:me.detailHeader,children:[e.jsx("button",{className:me.backBtn,onClick:m,children:"← 返回"}),e.jsx("span",{className:me.detailTitle,onClick:()=>c(!0),title:"点击编辑",children:j.key}),e.jsx("div",{className:me.detailActions,children:o?e.jsxs(e.Fragment,{children:[e.jsx(ie,{variant:"success",size:"sm",onClick:y,children:"通过"}),e.jsx(ie,{variant:"danger",size:"sm",onClick:u,children:"拒绝"})]}):e.jsxs(e.Fragment,{children:[j.scope==="group"&&j.agent_visible===1&&e.jsx(ie,{variant:"ghost",size:"sm",onClick:i,children:"提升全局"}),e.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>c(!0),children:"编辑"}),e.jsx(ie,{variant:"ghost",size:"sm",onClick:v,children:"删除"})]})})]}),e.jsxs("div",{className:me.detailMeta,children:[Js[j.category]," · ",j.scope==="global"?"全局":"群内"," · ",j.agent_visible?"🧠 记忆(agent 可见)":"📝 便签(纯人看)"," · 创建者:",j.created_by??""," · 更新:",j.updated_at.slice(0,16).replace("T"," ")]}),a&&e.jsx("div",{className:me.error,children:a}),h?e.jsx(_i,{mode:"edit",row:j,onCancel:()=>c(!1),onSaved:async r=>{try{await Ve.update(t,r),c(!1),f(),S()}catch(s){d(s.message)}}}):e.jsxs("div",{className:me.detailBody,children:[j.summary&&e.jsx("div",{className:me.detailSummary,children:j.summary}),j.value.trim()?e.jsx(dt,{content:j.value}):e.jsx("span",{style:{color:"var(--color-gray)",fontSize:13},children:"(暂无内容,点击右上角编辑)"}),j.tags&&JSON.parse(j.tags).length>0&&e.jsx("div",{className:me.detailTags,children:JSON.parse(j.tags).map(r=>e.jsx("span",{className:me.tagChip,children:r},r))})]})]})}const Cr={memory:"记忆(群内,agent 可见)",note:"便签(群内,纯人看)",global:"全局(跨群共享,agent 可见)"};function _i({mode:t,row:o,onCancel:m,onSaved:S}){const j=o?o.scope==="global"?"global":o.agent_visible===0?"note":"memory":"memory",[E,b]=g.useState({key:(o==null?void 0:o.key)??"",value:(o==null?void 0:o.value)??"",summary:(o==null?void 0:o.summary)??"",category:(o==null?void 0:o.category)??"note",tags:o!=null&&o.tags?Yb(o.tags):[],scope:j}),[n,a]=g.useState(null),d=()=>{if(!E.key.trim()){a("key 不能为空");return}S(E)};return e.jsxs("div",{className:me.editor,children:[e.jsx("div",{className:me.editorHeader,children:e.jsx("span",{className:me.editorTitle,children:t==="create"?"新建":"编辑"})}),n&&e.jsx("div",{className:me.error,children:n}),e.jsxs("div",{className:me.editorBody,children:[e.jsxs("div",{className:me.field,children:[e.jsx("span",{className:me.fieldLabel,children:"作用域(scope)"}),e.jsx(Fe,{size:"sm",value:E.scope,disabled:t==="edit",onChange:h=>b({...E,scope:h.target.value}),options:Object.keys(Cr).map(h=>({value:h,label:Cr[h]}))}),t==="edit"&&e.jsx("span",{className:me.fieldHint,children:"编辑模式下不可改 scope,如需变更请删除后重建。"})]}),e.jsxs("div",{className:me.field,children:[e.jsx("span",{className:me.fieldLabel,children:"key (主题)"}),e.jsx(ge,{size:"sm",value:E.key,onChange:h=>b({...E,key:h.target.value})})]}),e.jsxs("div",{className:me.field,children:[e.jsx("span",{className:me.fieldLabel,children:"summary (一句话摘要,留空自动取 value 前 80 字)"}),e.jsx(ge,{size:"sm",value:E.summary,onChange:h=>b({...E,summary:h.target.value})})]}),e.jsxs("div",{className:me.field,children:[e.jsx("span",{className:me.fieldLabel,children:"category"}),e.jsx(Fe,{size:"sm",value:E.category,onChange:h=>b({...E,category:h.target.value}),options:Gb.map(h=>({value:h,label:`${Js[h]} (${h})`}))})]}),e.jsxs("div",{className:me.field,children:[e.jsx("span",{className:me.fieldLabel,children:"value (内容,Markdown)"}),e.jsx(xt,{rows:10,value:E.value,onChange:h=>b({...E,value:h.target.value}),spellCheck:!1})]}),e.jsxs("div",{className:me.field,children:[e.jsx("span",{className:me.fieldLabel,children:"tags (逗号分隔)"}),e.jsx(ge,{size:"sm",value:E.tags.join(", "),onChange:h=>b({...E,tags:h.target.value.split(",").map(c=>c.trim()).filter(Boolean)})})]})]}),e.jsxs("div",{className:me.editorActions,children:[e.jsx(ie,{variant:"secondary",size:"sm",onClick:m,children:"取消"}),e.jsx(ie,{variant:"primary",size:"sm",onClick:d,children:t==="create"?"创建":"保存"})]})]})}function Yb(t){try{const o=JSON.parse(t);return Array.isArray(o)?o.map(String):[]}catch{return[]}}function Qb({open:t,onClose:o}){const{soundEnabled:m,soundVolume:S,breakIntervalMin:j,breakLengthMin:E,isOnBreak:b,setSoundEnabled:n,setSoundVolume:a,setBreakIntervalMin:d,setBreakLengthMin:h,playSound:c,resetSession:f,triggerBreakNow:v,endBreakEarly:y}=Fs();return e.jsxs(De,{open:t,title:"工作节奏与提醒",size:"sm",onClose:o,footer:e.jsx("div",{className:Q.modalActions,children:e.jsx(ie,{variant:"primary",size:"md",onClick:o,children:"完成"})}),children:[e.jsxs("div",{className:Q.formField,children:[e.jsx("label",{className:Q.formLabel,children:"任务完成声音"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(Dt,{checked:m,onChange:n,label:"启用"}),e.jsx("input",{type:"range",min:0,max:1,step:.05,value:S,onChange:u=>a(Number(u.target.value)),disabled:!m,style:{flex:1},"aria-label":"音量"}),e.jsxs("span",{style:{fontSize:12,color:"var(--color-slate)",width:36,textAlign:"right"},children:[Math.round(S*100),"%"]}),e.jsx(ie,{variant:"secondary",size:"sm",onClick:c,disabled:!m,children:"试听"})]})]}),e.jsx("div",{className:Q.formField,children:e.jsx(ge,{label:"工作节奏(分钟)",type:"number",min:1,max:180,size:"sm",value:j,onChange:u=>{const i=Number(u.target.value);Number.isFinite(i)&&d(i)},helperText:"连续工作这么久后弹出休息提醒。"})}),e.jsx("div",{className:Q.formField,children:e.jsx(ge,{label:"休息时长(分钟)",type:"number",min:1,max:60,size:"sm",value:E,onChange:u=>{const i=Number(u.target.value);Number.isFinite(i)&&h(i)}})}),e.jsxs("div",{className:Q.formField,children:[e.jsx("label",{className:Q.formLabel,children:"快速操作"}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsx(ie,{variant:"secondary",size:"sm",onClick:v,disabled:b,children:"☕ 立刻开始休息"}),e.jsx(ie,{variant:"secondary",size:"sm",onClick:y,disabled:!b,children:"⚡ 立刻开始工作"})]}),e.jsx("div",{style:{fontSize:11,color:"var(--color-slate)",marginTop:4},children:b?"正在休息中。「立刻开始工作」会结束当前休息,重新计时工作节奏。":`工作中。「立刻开始休息」会跳过剩余 ${j} 分钟节奏中的等待,马上进入 ${E} 分钟休息。`})]}),e.jsxs("div",{className:Q.formField,children:[e.jsx(ie,{variant:"ghost",size:"sm",onClick:f,children:"重置当前会话计时"}),e.jsx("div",{style:{fontSize:11,color:"var(--color-slate)",marginTop:4},children:"把工作时长清零,并重新开始本轮休息倒计时。偏好不会被清除。"})]})]})}const e0=10*6e4;function t0(){const{elapsedMs:t,msUntilBreak:o,isOnBreak:m,msUntilBreakEnd:S,breakLengthMin:j,postponeCount:E}=Fs(),[b,n]=g.useState(!1),a=!m&&o>0&&o<=e0,d=!m&&o<=0,h=[Q.modeClock,a?Q.modeClockUrgent:"",d?Q.modeClockOverdue:"",m?Q.modeClockBreak:""].filter(Boolean).join(" "),c=m?`休息中 · 剩余 ${zt(S)}(共 ${j}min)`:d?`已连续工作 ${hs(t)},早该休息啦${E>0?`(已推迟 ${E} 次)`:""}`:`已工作 ${hs(t)} · 下次休息还有 ${zt(o)}${E>0?`(已推迟 ${E} 次)`:""} · 点击打开工作设置`;return e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:h,onClick:()=>n(!0),title:c,"aria-label":c,children:[e.jsxs("span",{className:Q.modeClockRow,children:[e.jsx("span",{className:Q.modeClockIcon,children:"⏱"}),e.jsx("span",{className:Q.modeClockValue,children:hs(t)})]}),e.jsxs("span",{className:Q.modeClockRow,children:[e.jsx("span",{className:Q.modeClockIcon,children:m?"☕":"🌿"}),e.jsx("span",{className:Q.modeClockValue,children:zt(m?S:o)})]})]}),e.jsx(Qb,{open:b,onClose:()=>n(!1)})]})}const _s={async list(t){return ne.get(`/sessions?groupId=${encodeURIComponent(t)}`)},async view(t,o,m,S=200){return ne.get(`/sessions/${encodeURIComponent(t)}/${encodeURIComponent(o)}/${encodeURIComponent(m)}?tail=${S}`)},async delete(t,o,m){return ne.delete(`/sessions/${encodeURIComponent(t)}/${encodeURIComponent(o)}/${encodeURIComponent(m)}`)},async usage(t,o,m){return ne.get(`/sessions/${encodeURIComponent(t)}/${encodeURIComponent(o)}/${encodeURIComponent(m)}/usage`)}};function s0({groupId:t,onChange:o}){const[m,S]=g.useState({kind:"loading"}),[j,E]=g.useState(null),[b,n]=g.useState(null),a=g.useRef(o);a.current=o;const d=g.useCallback(async()=>{var c,f;S({kind:"loading"});try{const{sessions:v}=await _s.list(t);S({kind:"ready",sessions:v}),(c=a.current)==null||c.call(a,v.length)}catch(v){const y=v instanceof Error?v.message:String(v);S({kind:"error",message:y}),(f=a.current)==null||f.call(a,null)}},[t]);g.useEffect(()=>{d()},[d]);const h=g.useCallback(async c=>{const f=c.agentName??c.cliTool;if(window.confirm(`确定删除 ${f} 在该群的 session?
162
+ ${c.cliTool} · ${c.sessionId}
163
+
164
+ 下次对话将重新开始。`)){n(`${c.cliTool}:${c.sessionId}`);try{await _s.delete(c.cliTool,c.groupId,c.sessionId),await d()}catch(y){const u=y instanceof Error?y.message:String(y);window.alert(`删除失败:${u}`)}finally{n(null)}}},[d]);return m.kind==="loading"?e.jsx("div",{className:Q.hint,children:"加载中…"}):m.kind==="error"?e.jsxs("div",{className:Q.hint,children:["加载失败:",m.message,e.jsx("div",{style:{marginTop:8},children:e.jsx(ie,{variant:"ghost",size:"sm",onClick:d,children:"重试"})})]}):m.sessions.length===0?e.jsxs("div",{className:Q.hint,children:["暂无 session",e.jsx("div",{className:Q.hintSub,children:"触发一次对话后,各后端(claude / codex / hermes / openclaw)会自动登记 sessionId。"})]}):e.jsxs("div",{className:Q.sessionPanel,children:[m.sessions.map(c=>{const f=`${c.cliTool}:${c.sessionId}`,v=b===f,y=!!c.invalidatedAt;return e.jsxs("div",{className:`${Q.sessionRow} ${y?Q.sessionRowInvalidated:""}`,children:[e.jsx("div",{className:Q.sessionCliTag,title:c.agentName?`${c.agentName} · ${c.cliTool}`:c.cliTool,children:c.agentName??c.cliTool}),c.agentName&&e.jsx("div",{className:Q.sessionCliSubTag,title:c.cliTool,children:c.cliTool}),e.jsx("span",{className:`${Q.sessionOnlineDot} ${c.online?Q.sessionOnlineDotOn:Q.sessionOnlineDotOff}`,title:c.online?"worker 在线":"worker 离线"}),e.jsx("div",{className:Q.sessionId,title:c.sessionId,children:c.sessionId.length>14?`${c.sessionId.slice(0,6)}…${c.sessionId.slice(-4)}`:c.sessionId}),e.jsx(r0,{entry:c}),y&&e.jsx("span",{className:Q.sessionInvalidatedTag,title:`失效于 ${c.invalidatedAt}`,children:"已失效"}),e.jsxs("div",{className:Q.sessionActions,children:[e.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>E(c),disabled:v,children:"查看"}),e.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>h(c),disabled:v,children:v?"删除中…":"删除"})]})]},f)}),e.jsx(o0,{entry:j,onClose:()=>E(null)})]})}function r0({entry:t}){const[o,m]=g.useState(null);if(g.useEffect(()=>{let h=!1;return _s.usage(t.cliTool,t.groupId,t.sessionId).then(c=>{h||m(c)}).catch(()=>{h||m(null)}),()=>{h=!0}},[t.cliTool,t.groupId,t.sessionId]),!o||!o.usage&&!o.model)return e.jsx("span",{className:`${Q.sessionUsage} ${Q.sessionUsageEmpty}`,children:"—"});const S=o.usage,j=!!S&&(S.inputTokens!=null||S.outputTokens!=null||S.cacheReadTokens!=null||S.cacheCreationTokens!=null||S.totalCostUsd!=null),E=o.cumulativeCostUsd,b=typeof E=="number"&&E>0,n=o.cumulativeInputTokens,a=o.cumulativeOutputTokens,d=typeof n=="number"&&n>0||typeof a=="number"&&a>0;return e.jsxs("span",{className:Q.sessionUsage,title:i0(o),children:[o.model&&e.jsx("span",{className:Q.sessionUsageModel,children:n0(o.model)}),j&&S&&e.jsxs(e.Fragment,{children:[o.model&&e.jsx("span",{className:Q.sessionUsageSep,children:"·"}),S.totalCostUsd!=null&&S.totalCostUsd>0&&e.jsxs("span",{className:Q.sessionUsageCost,title:"本次 turn 成本 (USD)",children:["$",jr(S.totalCostUsd)]})]}),d&&e.jsxs(e.Fragment,{children:[(j&&S&&S.totalCostUsd!=null&&S.totalCostUsd>0||o.model)&&e.jsx("span",{className:Q.sessionUsageSep,children:"·"}),typeof n=="number"&&n>0&&e.jsxs("span",{className:Q.sessionUsageTokenIn,title:"累计输入 tokens (跨该 session 所有 turn)",children:[e.jsx("span",{className:Q.sessionUsageArrow,children:"↑"}),wr(n)]}),typeof a=="number"&&a>0&&e.jsxs("span",{className:Q.sessionUsageTokenOut,title:"累计输出 tokens (跨该 session 所有 turn)",children:[e.jsx("span",{className:Q.sessionUsageArrow,children:"↓"}),wr(a)]})]}),b&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:Q.sessionUsageSep,children:"·"}),e.jsxs("span",{className:Q.sessionUsageCostCum,title:"累计成本 (USD, 跨该 session 所有 turn)",children:["Σ$",jr(E)]})]})]})}function i0(t){const o=[];t.model&&o.push(`模型: ${t.model}`);const m=t.usage;return m&&(m.inputTokens!=null&&o.push(`输入(本次): ${m.inputTokens.toLocaleString()}`),m.outputTokens!=null&&o.push(`输出(本次): ${m.outputTokens.toLocaleString()}`),m.cacheReadTokens!=null&&o.push(`缓存读(本次): ${m.cacheReadTokens.toLocaleString()}`),m.cacheCreationTokens!=null&&o.push(`缓存写(本次): ${m.cacheCreationTokens.toLocaleString()}`),m.totalCostUsd!=null&&o.push(`本次成本: $${m.totalCostUsd.toFixed(6)}`)),typeof t.cumulativeInputTokens=="number"&&t.cumulativeInputTokens>0&&o.push(`累计输入: ${t.cumulativeInputTokens.toLocaleString()}`),typeof t.cumulativeOutputTokens=="number"&&t.cumulativeOutputTokens>0&&o.push(`累计输出: ${t.cumulativeOutputTokens.toLocaleString()}`),typeof t.cumulativeCacheReadTokens=="number"&&t.cumulativeCacheReadTokens>0&&o.push(`累计缓存读: ${t.cumulativeCacheReadTokens.toLocaleString()}`),typeof t.cumulativeCacheCreationTokens=="number"&&t.cumulativeCacheCreationTokens>0&&o.push(`累计缓存写: ${t.cumulativeCacheCreationTokens.toLocaleString()}`),typeof t.cumulativeCostUsd=="number"&&t.cumulativeCostUsd>0&&o.push(`累计成本: $${t.cumulativeCostUsd.toFixed(6)}`),o.join(" · ")||"无 usage 数据"}function wr(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function jr(t){return t>=.01?t.toFixed(2):t>=1e-4?t.toFixed(4):t.toFixed(6)}function n0(t){const o=t.replace(/^(claude|anthropic|openai|gpt|gemini)-/i,"");return o.length<=22?o:o.slice(0,21)+"…"}function o0({entry:t,onClose:o}){const[m,S]=g.useState({kind:"loading"});if(g.useEffect(()=>{t&&(S({kind:"loading"}),_s.view(t.cliTool,t.groupId,t.sessionId,200).then(E=>{S({kind:"ready",content:E.content,error:E.error})}).catch(E=>{const b=E instanceof Error?E.message:String(E);S({kind:"error",message:b})}))},[t]),!t)return null;const j=()=>{m.kind==="ready"&&navigator.clipboard.writeText(m.content).catch(()=>{})};return e.jsxs(De,{open:!!t,title:`${t.agentName??t.cliTool} · ${t.sessionId.slice(0,8)}…`,onClose:o,footer:e.jsxs(e.Fragment,{children:[e.jsx(ie,{variant:"ghost",size:"sm",onClick:j,disabled:m.kind!=="ready",children:"复制"}),e.jsx(ie,{variant:"primary",size:"sm",onClick:o,children:"关闭"})]}),children:[m.kind==="loading"&&e.jsx("div",{className:Q.hint,children:"读取中…"}),m.kind==="error"&&e.jsxs("div",{className:Q.hint,children:["读取失败:",m.message]}),m.kind==="ready"&&e.jsxs(e.Fragment,{children:[m.error&&e.jsx("div",{className:Q.hint,style:{marginBottom:8},children:m.error}),e.jsx("pre",{className:Q.sessionContent,children:m.content||"(空)"})]})]})}const a0=g.lazy(()=>fs(()=>import("./ArtifactPanel-P_2gAP7v.js"),__vite__mapDeps([1])).then(t=>({default:t.ArtifactPanel}))),l0=["chat","process","artifact"],c0={"chat-process":["chat","process"],"chat-artifact":["chat","artifact"],"process-artifact":["process","artifact"]},fi=[{id:"chat",width:720,min:360},{id:"process",width:480,min:320},{id:"artifact",width:560,min:360}],d0=Object.fromEntries(fi.map(t=>[t.id,t.min])),pi="rotom-panel-mode",mi="rotom-process-tab";function h0(){try{const t=localStorage.getItem(pi);return t==="chat-process"||t==="chat-artifact"||t==="process-artifact"?t:"chat-process"}catch{return"chat-process"}}function u0(){try{const t=localStorage.getItem(mi);return t==="issues"||t==="notes"||t==="schedules"?t:"issues"}catch{return"issues"}}function Ls(){var Ze;const t=Ut(),{groupId:o,issueId:m}=Ps(),{agents:S,groups:j,myAgentName:E,directTarget:b,setDirectTarget:n,openConfigModal:a,loadGroups:d,setGroupMemberWorkingDir:h,clearGroupMemberWorkingDir:c,updateGroupGuidancePrompt:f}=nt(),{status:v,send:y,lastIssueChange:u}=wt(),{isVisitor:i,error:r,validate:s,token:l,groupId:_}=qt(),x=o||"",C=m||"",[k,p]=g.useState([]),[w,R]=g.useState(0),[T,M]=g.useState(h0),[N,I]=g.useState(u0),{widths:z,onSplitterMouseDown:G}=Xh("rotom-panel-widths",fi),[H,V]=g.useState(null),[L,A]=g.useState(!1),[B,P]=g.useState(!1),[U,Z]=g.useState(!1),[oe,K]=g.useState(!1),[$,D]=g.useState(!1),[q,J]=g.useState(null),[O,X]=g.useState(null),F=c0[T];g.useEffect(()=>{l&&x&&_!==x&&s(x)},[l,x,_,s]),g.useEffect(()=>{l&&!x&&t("/dashboard/agents",{replace:!0})},[l,x,t]);const W=le=>{x&&t(le?`/dashboard/groups/${x}/issues/${le}`:`/dashboard/groups/${x}`)},re=g.useCallback(async()=>{if(x)try{const le=await Be.listByGroup(x);p(le)}catch(le){console.error("Failed to load issues:",le)}},[x]);g.useEffect(()=>{if(!x){p([]),W("");return}re()},[x,re]),g.useEffect(()=>{if(o)return;const le=localStorage.getItem("group_selected_id");le&&t(`/dashboard/groups/${le}`,{replace:!0})},[]);const ae=j.find(le=>le.id===x),ee=b!==""||(ae==null?void 0:ae.type)==="direct",ce=((Ze=ae==null?void 0:ae.members)==null?void 0:Ze.map(le=>le.agent_name))||[],he=b||ce.find(le=>le!==E)||"",{messages:pe,setMessages:Ne,cancelStream:Ue}=Jh({myAgentName:E,selectedGroupId:x,directTarget:he});g.useEffect(()=>{u&&u.groupId===x&&(re(),u.issueId===C&&R(le=>le+1))},[u,x,C,re]);const Me=async le=>{if(!le||v!=="connected")return;const Ce=le;if(Yh(Ce),ee&&x){const Ge=`dm_${Date.now()}`;if(!y({type:"a2a_send",requestId:Ge,target:he,payload:{message:Ce},conversation:{type:"single",groupId:x,groupName:ae==null?void 0:ae.name}}))return;Ne(Mt=>[...Mt,{id:Ge,from:E,content:Ce,timestamp:new Date,isIncoming:!1,status:"pending"},{id:`${Ge}_loading`,from:he,content:"",timestamp:new Date,isIncoming:!0,isLoading:!0}]);return}if(!x)return;try{await Re.addMembers(x,[E]),(q==null?void 0:q.groupId)===x&&J(null)}catch(Ge){J({groupId:x,message:"入群失败,可能影响实时消息"}),console.error("Self-join failed; chunks may not stream live:",Ge)}await d();const ut=new Set(ce),jt=Hs(Ce).filter(Ge=>ut.has(Ge)),bt=jt.filter(Ge=>Ge!==E),_t=`grp_${Date.now()}`,ms={type:"group",groupId:x,groupName:ae==null?void 0:ae.name};Re.sendMessage(x,E,Ce,jt).catch(Ge=>{console.error("Failed to persist group message:",Ge)});for(let Ge=0;Ge<bt.length;Ge++)y({type:"a2a_send",requestId:`${_t}_${Ge}`,target:bt[Ge],payload:{message:Ce},conversation:ms});Ne(Ge=>[...Ge,{id:_t,from:E,content:Ce,timestamp:new Date,isIncoming:!1,mentions:jt,status:bt.length>0?"pending":"delivered"},...bt.map((gs,Mt)=>({id:`${_t}_loading_${Mt}`,from:bt[Mt],content:"",timestamp:new Date,isIncoming:!0,isLoading:!0}))])},$e=g.useRef("");g.useEffect(()=>{$e.current&&$e.current!==x&&Ne([]),$e.current=x},[x]);const Le=async le=>{if(x)try{await Re.addMembers(x,le),A(!1),d()}catch(Ce){console.error("Failed to add members:",Ce)}},qe=g.useCallback(async()=>{if(!q)return;const le=q.groupId;J(null);try{await Re.addMembers(le,[E]),await d()}catch{J({groupId:le,message:"入群仍然失败,请刷新页面"})}},[q,E,d]),ot=async()=>{const le=localStorage.getItem("dm_active_group");if(le&&confirm(`确定删除与 ${he} 的对话吗?该对话的所有消息会被清除。`))try{await Re.delete(le),localStorage.removeItem("dm_active_group"),localStorage.removeItem("dm_active_target"),localStorage.removeItem("group_selected_id"),n(""),t("/dashboard/groups"),d()}catch(Ce){console.error("Failed to delete DM:",Ce),window.alert(`删除失败:${Ce instanceof Error?Ce.message:String(Ce)}`)}},Qe=async le=>{if(x)try{const Ce=await Be.create(x,{description:le.description,title:le.title,priority:le.priority,createdBy:E});le.assignedTo&&Ce.id&&await Be.update(Ce.id,{assignedTo:le.assignedTo}),re()}catch(Ce){console.error("Failed to create issue:",Ce)}};g.useEffect(()=>{try{localStorage.setItem(pi,T)}catch{}},[T]),g.useEffect(()=>{try{localStorage.setItem(mi,N)}catch{}},[N]);const at=g.useCallback(le=>{V(le),M(Ce=>Ce==="chat-artifact"||Ce==="process-artifact"?Ce:"process-artifact")},[]),Ee=l0.filter(le=>F.includes(le));return e.jsxs("div",{className:Q.container,children:[l&&r&&e.jsx("div",{className:se.centerFill,children:e.jsxs("div",{style:{textAlign:"center",padding:40},children:[e.jsx("div",{style:{fontSize:48,marginBottom:16},children:"🔗"}),e.jsx("div",{style:{fontSize:16,fontWeight:600,color:"#0f172a",marginBottom:8},children:"分享链接无效"}),e.jsxs("div",{style:{fontSize:13,color:"#64748b"},children:[r,"。请联系分享者重新生成链接。"]})]})}),l&&!r&&!i&&e.jsx("div",{className:se.centerFill,children:e.jsx("span",{style:{color:"#64748b"},children:"正在验证分享链接…"})}),(!l||i)&&e.jsxs("div",{className:Q.workspace,children:[e.jsx(Yy,{open:L,groupMemberNames:ce,agents:S,onClose:()=>A(!1),onAdd:Le},(ae==null?void 0:ae.id)??"no-group"),ae&&!ee&&e.jsx(vx,{open:B,members:ae.members||[],agents:S,groupId:ae.id,groupName:ae.name,groupWorkingDir:ae.working_dir??null,groupGuidancePrompt:ae.guidance_prompt??null,onUpdateGuidancePrompt:f,onClose:()=>P(!1),onUpdateMemberWorkingDir:async(le,Ce,ut)=>{ut===null?await c(le,Ce):await h(le,Ce,ut)},onProfilesChanged:d},ae.id),U&&ae&&!ee&&e.jsx(xx,{open:!0,groupId:ae.id,groupName:ae.name,onClose:()=>Z(!1)},ae.id),oe&&ae&&e.jsx(De,{open:!0,title:`🔧 Sessions · ${ae.name}`,onClose:()=>K(!1),size:"lg",children:e.jsx(s0,{groupId:ae.id})}),$&&ae&&!ee&&e.jsx(Yx,{open:!0,groupId:ae.id,groupName:ae.name,groups:j,onClose:()=>D(!1)}),(O==null?void 0:O.kind)==="issue"&&x&&e.jsx(Xy,{open:!0,agents:S,onClose:()=>X(null),onCreateIssue:le=>{Qe(le),X(null)}}),(O==null?void 0:O.kind)==="note"&&x&&e.jsx(Zy,{open:!0,onClose:()=>X(null),onCreate:async le=>{try{await Bs.create(x,{title:le.title,description:le.description,createdBy:E}),X(null)}catch(Ce){console.error("Failed to create note:",Ce),window.alert(`创建失败:${Ce instanceof Error?Ce.message:String(Ce)}`)}}}),e.jsxs("div",{className:Q.modeSidebar,children:[e.jsx("div",{className:`${Q.modeStatusDot} ${Q[`modeStatus_${v}`]}`,title:v==="connected"?`已连接 · ${E}`:v==="connecting"?"连接中...":v==="conflict"?"连接冲突":"未连接"}),e.jsx("button",{type:"button",className:`${Q.modeBtn} ${T==="chat-process"?Q.modeBtnActive:""}`,onClick:()=>M("chat-process"),title:"对话 + 过程(Issues/Notes/定时任务)",children:e.jsxs("span",{className:Q.modeBtnIcons,children:["💬",e.jsx("br",{}),"📋"]})}),e.jsx("button",{type:"button",className:`${Q.modeBtn} ${T==="chat-artifact"?Q.modeBtnActive:""}`,onClick:()=>M("chat-artifact"),title:"对话 + Artifacts",children:e.jsxs("span",{className:Q.modeBtnIcons,children:["💬",e.jsx("br",{}),"📦"]})}),e.jsx("button",{type:"button",className:`${Q.modeBtn} ${T==="process-artifact"?Q.modeBtnActive:""}`,onClick:()=>M("process-artifact"),title:"过程 + Artifacts",children:e.jsxs("span",{className:Q.modeBtnIcons,children:["📋",e.jsx("br",{}),"📦"]})}),e.jsx("div",{className:Q.modeSidebarDivider}),ae&&e.jsx("button",{type:"button",className:Q.modeBtn,onClick:()=>K(!0),title:"Sessions 调试",children:e.jsx("span",{className:Q.modeBtnIcons,children:"🔧"})}),ae&&!ee&&e.jsx("button",{type:"button",className:Q.modeBtn,onClick:()=>D(!0),title:"当前群消息流",children:e.jsx("span",{className:Q.modeBtnIcons,children:"💬"})}),ee?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:Q.modeBtn,onClick:ot,title:`删除与 ${he} 的对话`,children:e.jsx("span",{className:Q.modeBtnIcons,children:"🗑️"})}),e.jsx("button",{type:"button",className:Q.modeBtn,onClick:a,title:"设置",children:e.jsx("span",{className:Q.modeBtnIcons,children:"⚙️"})})]}):ae&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:Q.modeBtn,onClick:()=>P(!0),title:"成员",children:e.jsx("span",{className:Q.modeBtnIcons,children:"👥"})}),!i&&e.jsx("button",{type:"button",className:Q.modeBtn,onClick:()=>A(!0),title:"拉人",children:e.jsx("span",{className:Q.modeBtnIcons,children:"➕"})}),e.jsx("button",{type:"button",className:Q.modeBtn,onClick:()=>Z(!0),title:"分享",children:e.jsx("span",{className:Q.modeBtnIcons,children:"🔗"})}),!i&&e.jsx("button",{type:"button",className:Q.modeBtn,onClick:a,title:"设置",children:e.jsx("span",{className:Q.modeBtnIcons,children:"⚙️"})})]}),e.jsx("div",{className:Q.modeSidebarSpacer}),e.jsx(t0,{})]}),e.jsx("div",{className:Q.panelsRow,children:Ee.length===0?e.jsx("div",{className:Q.panelsEmpty,children:"所有面板已隐藏,点击顶部按钮恢复"}):Ee.map((le,Ce)=>{const ut=Ee[Ce-1],jt=Ce===Ee.length-1;return e.jsxs(g.Fragment,{children:[Ce>0&&ut&&e.jsx("div",{className:Q.splitter,onMouseDown:G(ut,le),title:"拖拽调整宽度"}),e.jsxs("div",{className:Q.panel,style:{width:`${z[le]}px`,flex:jt?`1 1 ${z[le]}px`:`0 1 ${z[le]}px`,minWidth:`${d0[le]??0}px`},children:[le==="chat"&&e.jsx("div",{className:se.chatArea,children:ee?e.jsx(Ep,{directTarget:b,myAgentName:E,messages:pe,agents:S,connectionStatus:v,onSendMessage:Me,onCancelStream:Ue}):ae?e.jsxs(e.Fragment,{children:[q&&q.groupId===x&&e.jsxs("div",{className:se.banner,role:"alert",children:[e.jsx("span",{children:q.message}),e.jsx("button",{onClick:qe,className:se.bannerButton,children:"重试"}),e.jsx("button",{onClick:()=>J(null),className:se.bannerButton,"aria-label":"忽略",children:"忽略"})]}),e.jsx(dm,{selectedGroup:ae,agents:S,myAgentName:E,messages:pe,connectionStatus:v,onSendMessage:Me,onCancelStream:Ue})]}):e.jsx("div",{className:se.emptyChat,children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("p",{style:{fontSize:16,color:"var(--color-navy)",marginBottom:8},children:"选择在线 Agent 或群开始对话"}),e.jsx("p",{style:{fontSize:13,color:"var(--color-slate)"},children:"左侧「一对一」直接聊天,或创建群聊 @ 成员"})]})})}),le==="process"&&e.jsxs("div",{className:Q.processWrap,children:[e.jsxs("div",{className:Q.processTabs,children:[e.jsxs("div",{className:Q.processTabsLeft,children:[e.jsx("button",{type:"button",className:`${Q.processTab} ${N==="issues"?Q.processTabActive:""}`,onClick:()=>I("issues"),children:"Issues"}),e.jsx("button",{type:"button",className:`${Q.processTab} ${N==="notes"?Q.processTabActive:""}`,onClick:()=>I("notes"),children:"Memory"}),e.jsx("button",{type:"button",className:`${Q.processTab} ${N==="schedules"?Q.processTabActive:""}`,onClick:()=>I("schedules"),children:"Schedules"})]}),!i&&N==="issues"&&e.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>X({kind:"issue"}),className:Q.processCreateBtn,children:"+ 创建"})]}),e.jsx("div",{className:Q.processBody,children:ae?N==="issues"?e.jsx(my,{selectedGroupId:x,selectedIssueId:C,selectedIssueVersion:w,issues:k,agents:S,groupMembers:ce,myAgentName:E,setSelectedIssueId:W,readOnly:i,onArtifactClick:at}):N==="notes"?e.jsx(Xb,{selectedGroupId:x,myAgentName:E}):e.jsx(Oy,{selectedGroupId:x}):e.jsx("div",{className:Q.panelPlaceholder,children:"选择群后查看过程"})})]}),le==="artifact"&&(ae?e.jsx(g.Suspense,{fallback:e.jsx("div",{className:Q.panelPlaceholder,children:"加载中..."}),children:e.jsx(a0,{groupId:x,selectedPath:H,onSelectedPathChange:V})}):e.jsx("div",{className:Q.panelPlaceholder,children:"选择群后查看 Artifacts"}))]})]},le)})})]})]})}const _0=g.lazy(()=>fs(()=>import("./ArtifactPanel-P_2gAP7v.js"),__vite__mapDeps([1])).then(t=>({default:t.ArtifactPanel})));function f0(){const{groupId:t="",issueId:o=""}=Ps(),m=Ut(),{agents:S,groups:j}=nt(),{lastIssueChange:E}=wt(),{isVisitor:b,validate:n,error:a,token:d,groupId:h}=qt(),[c,f]=g.useState(null),[v,y]=g.useState(0),[u,i]=g.useState(null),r=g.useMemo(()=>j.find(l=>l.id===t),[j,t]);g.useEffect(()=>{!d||!t||h!==t&&n(t)},[d,t,h,n]),g.useEffect(()=>{if(!t||r)return;let l=!1;return Re.getById(t).then(_=>{l||f(_)}).catch(()=>{}),()=>{l=!0}},[t,r]);const s=g.useMemo(()=>{var _;const l=r||c;return((_=l==null?void 0:l.members)==null?void 0:_.map(x=>x.agent_name))||[]},[r,c]);return g.useEffect(()=>{E&&E.issueId===o&&y(l=>l+1)},[E,o]),d&&a?e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:e.jsxs("div",{style:{textAlign:"center",padding:40},children:[e.jsx("div",{style:{fontSize:48,marginBottom:16},children:"🔗"}),e.jsx("div",{style:{fontSize:16,fontWeight:600,color:"#0f172a",marginBottom:8},children:"分享链接无效"}),e.jsxs("div",{style:{fontSize:13,color:"#64748b"},children:[a,"。请联系分享者重新生成链接。"]})]})}):d&&!b?e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:e.jsx("span",{style:{color:"#64748b"},children:"正在验证分享链接…"})}):o?e.jsxs(e.Fragment,{children:[e.jsx(Gs,{issueId:o,refreshSignal:v,agents:S,groupMembers:s,onBack:()=>m(`/dashboard/groups/${t}/issues-single`),standalone:!0,readOnly:b,onArtifactClick:i}),u!==null&&e.jsxs("div",{className:Je.artifactDrawer,children:[e.jsxs("div",{className:Je.drawerHeader,children:[e.jsxs("span",{className:Je.drawerTitle,children:["📦"," Artifacts"]}),e.jsx("button",{type:"button",className:Je.drawerClose,onClick:()=>i(null),title:"关闭","aria-label":"关闭 Artifacts 抽屉",children:"×"})]}),e.jsx("div",{className:Je.drawerBody,children:e.jsx(g.Suspense,{fallback:e.jsx("div",{className:Je.drawerLoading,children:"加载中..."}),children:e.jsx(_0,{groupId:t,selectedPath:u,onSelectedPathChange:i})})})]})]}):e.jsx("div",{className:Je.issueEmpty,children:"Issue 未找到"})}const p0={open:"待处理",in_progress:"执行中",paused:"待继续",completed:"已完成",failed:"失败",cancelled:"已取消"};function m0({issue:t,groupId:o}){const m=ps(t.started_at,t.completed_at),S=t.status==="completed"||t.status==="failed"||t.status==="cancelled",j=S?je.issueElapsedDone:t.status==="in_progress"?je.issueElapsedRunning:je.issueElapsedIdle,E=S?"✓":t.status==="in_progress"?"⏱":"—",b=m==null?"—":Vs(m);return e.jsx("li",{className:je.issueItem,children:e.jsxs(Ni,{to:`/dashboard/groups/${o}/issues-single/${t.id}`,style:{display:"block",color:"inherit",textDecoration:"none"},children:[e.jsxs("div",{className:je.issueTitleRow,children:[e.jsx("span",{className:`${je.issueTypeLabel} ${je.taskLabel}`,children:"任务"}),t.slash_command&&e.jsx("span",{title:"此 issue 以计划模式执行:先输出方案,等待审批后落盘",style:{fontSize:10,fontWeight:600,padding:"1px 6px",borderRadius:4,background:"rgba(99, 102, 241, 0.15)",color:"#6366f1"},children:t.slash_command}),e.jsx("span",{className:je.issueTitle,children:ss(t)})]}),e.jsxs("div",{className:je.issueMeta,children:[e.jsx(ht,{tone:"status",value:t.status,children:p0[t.status]}),e.jsxs("span",{className:`${je.issueElapsed} ${j}`,title:m==null?"尚未开始":S?"总耗时":"当前区间耗时(实时刷新)",children:[E," ",b]}),e.jsx("span",{className:je.issueCreatedBy,children:t.created_by})]})]})})}function g0(){const{groupId:t=""}=Ps(),{groups:o}=nt(),{lastIssueChange:m}=wt(),{isVisitor:S,validate:j,error:E,token:b,groupId:n}=qt(),[a,d]=g.useState([]),[h,c]=g.useState(!0),[f,v]=g.useState(null),[y,u]=g.useState(null),i=g.useMemo(()=>o.find(l=>l.id===t),[o,t]),r=i||y;g.useEffect(()=>{!b||!t||n!==t&&j(t)},[b,t,n,j]),g.useEffect(()=>{if(!t||i)return;let l=!1;return Re.getById(t).then(_=>{l||u(_)}).catch(()=>{}),()=>{l=!0}},[t,i]);const s=g.useCallback(async()=>{if(t)try{const l=await Be.listByGroup(t);d(l),v(null)}catch{v("加载 Issue 列表失败")}},[t]);return g.useEffect(()=>{if(!t)return;let l=!1;return c(!0),s().finally(()=>{l||c(!1)}),()=>{l=!0}},[t,s]),g.useEffect(()=>{m&&m.groupId===t&&s()},[m,t,s]),e.jsxs("div",{className:je.issuePanel,children:[e.jsx("div",{className:je.issuePanelHeader,children:e.jsx("h3",{className:je.issuePanelTitle,children:r!=null&&r.name?`${r.name} · SubSessions`:"SubSessions"})}),b&&E&&e.jsxs("div",{className:je.issueEmpty,style:{textAlign:"center",padding:40},children:[e.jsx("div",{style:{fontSize:48,marginBottom:16},children:"🔗"}),e.jsx("div",{style:{fontSize:16,fontWeight:600,color:"#0f172a",marginBottom:8},children:"分享链接无效"}),e.jsxs("div",{style:{fontSize:13,color:"#64748b"},children:[E,"。请联系分享者重新生成链接。"]})]}),b&&!E&&!S&&e.jsx("div",{className:je.issueEmpty,children:"正在验证分享链接…"}),(!b||S)&&(h?e.jsx("div",{className:je.issueEmpty,children:"加载中..."}):f?e.jsx("div",{className:je.issueEmpty,children:f}):a.length===0?e.jsx("div",{className:je.issueEmpty,children:"暂无 Issue"}):e.jsx("ul",{className:je.issueList,children:a.map(l=>e.jsx(m0,{issue:l,groupId:t},l.id))}))]})}const v0="_page_eu3i9_1",y0="_header_eu3i9_10",x0="_title_eu3i9_17",b0="_subtitle_eu3i9_26",S0="_board_eu3i9_38",C0="_column_eu3i9_49",w0="_count_eu3i9_66",j0="_columnHeader_eu3i9_70",k0="_headerLeft_eu3i9_76",E0="_collapseIcon_eu3i9_82",N0="_collapseIconCollapsed_eu3i9_134",R0="_cards_eu3i9_138",L0="_empty_eu3i9_167",T0="_loadMoreHint_eu3i9_175",I0="_card_eu3i9_138",A0="_cardTopRow_eu3i9_207",D0="_typeTag_eu3i9_215",B0="_typeTask_eu3i9_223",M0="_slashTag_eu3i9_233",$0="_cardTitle_eu3i9_243",P0="_cardMeta_eu3i9_256",O0="_groupName_eu3i9_266",H0="_assignee_eu3i9_275",F0="_assigneeClaimed_eu3i9_286",z0="_assigneeUnclaimed_eu3i9_291",W0="_cardFoot_eu3i9_297",U0="_cardElapsed_eu3i9_314",q0="_cardElapsedIdle_eu3i9_328",V0="_cardElapsedRunning_eu3i9_333",G0="_cardElapsedDone_eu3i9_339",K0="_drawerBackdrop_eu3i9_351",J0="_drawer_eu3i9_351",X0="_drawerClose_eu3i9_375",Z0="_drawerBody_eu3i9_399",ke={page:v0,header:y0,title:x0,subtitle:b0,board:S0,column:C0,count:w0,columnHeader:j0,headerLeft:k0,collapseIcon:E0,collapseIconCollapsed:N0,cards:R0,empty:L0,loadMoreHint:T0,card:I0,cardTopRow:A0,typeTag:D0,typeTask:B0,slashTag:M0,cardTitle:$0,cardMeta:P0,groupName:O0,assignee:H0,assigneeClaimed:F0,assigneeUnclaimed:z0,cardFoot:W0,cardElapsed:U0,cardElapsedIdle:q0,cardElapsedRunning:V0,cardElapsedDone:G0,drawerBackdrop:K0,drawer:J0,drawerClose:X0,drawerBody:Z0},Y0=[{status:"open",label:"待处理"},{status:"in_progress",label:"执行中"},{status:"paused",label:"待继续"},{status:"completed",label:"已完成"},{status:"failed",label:"失败"},{status:"cancelled",label:"已取消"}];function Q0(t){if(!t)return"";const o=new Date(t.includes("T")?t:t.replace(" ","T")+"Z").getTime();if(Number.isNaN(o))return"";const m=Date.now()-o,S=Math.floor(m/1e3);if(S<60)return"刚刚";const j=Math.floor(S/60);if(j<60)return`${j} 分钟前`;const E=Math.floor(j/60);if(E<24)return`${E} 小时前`;const b=Math.floor(E/24);if(b===1)return"昨天";if(b<7)return`${b} 天前`;const n=new Date(o);return`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`}function e1({issue:t,groupName:o,agents:m,onOpen:S}){const j=ci(t.assigned_to,m),E=ps(t.started_at,t.completed_at),b=t.status==="completed"||t.status==="failed"||t.status==="cancelled",n=b?ke.cardElapsedDone:t.status==="in_progress"?ke.cardElapsedRunning:ke.cardElapsedIdle,a=b?"✓":t.status==="in_progress"?"⏱":"—",d=E==null?"—":Vs(E);return e.jsxs("button",{type:"button",className:ke.card,onClick:S,children:[e.jsxs("div",{className:ke.cardTopRow,children:[e.jsx("span",{className:`${ke.typeTag} ${ke.typeTask}`,children:"任务"}),t.slash_command&&e.jsx("span",{className:ke.slashTag,title:"计划模式",children:t.slash_command}),e.jsx(ht,{tone:"priority",value:t.priority,children:t.priority})]}),e.jsx("div",{className:ke.cardTitle,children:ss(t)}),e.jsxs("div",{className:ke.cardMeta,children:[e.jsxs("span",{className:ke.groupName,title:`群: ${o}`,children:["# ",o]}),e.jsx("span",{className:`${ke.assignee} ${j?ke.assigneeClaimed:ke.assigneeUnclaimed}`,title:j?`执行 agent: ${j}`:"尚未认领",children:j?`👤 ${j}`:di})]}),e.jsxs("div",{className:ke.cardFoot,children:[e.jsx("span",{className:ke.time,title:t.created_at,children:Q0(t.created_at)}),e.jsxs("span",{className:`${ke.cardElapsed} ${n}`,title:E==null?"尚未开始":b?"总耗时":"当前区间耗时(实时刷新)",children:[a," ",d]})]})]})}const kr=50;function t1({status:t,label:o,groupNameMap:m,agents:S,onOpenIssue:j,refreshSignal:E}){const[b,n]=g.useState([]),[a,d]=g.useState(0),[h,c]=g.useState(0),[f,v]=g.useState(!1),[y,u]=g.useState(null),[i,r]=g.useState(!1),[s,l]=g.useState(!1),_=g.useRef(!1);g.useEffect(()=>{let p=!1;return v(!0),u(null),Be.listPage(t,kr,0).then(w=>{p||(n(w.items),d(w.total),c(w.items.length),r(w.items.length<w.total),_.current?w.total>0&&l(!1):(_.current=!0,l(w.total===0)))}).catch(()=>{p||u("加载 Issue 失败")}).finally(()=>{p||v(!1)}),()=>{p=!0}},[t,E]);const x=g.useCallback(async()=>{if(!(f||!i)){v(!0);try{const p=await Be.listPage(t,kr,h);n(w=>[...w,...p.items]),c(w=>w+p.items.length),r(h+p.items.length<p.total)}catch{u("加载 Issue 失败")}finally{v(!1)}}},[t,h,f,i]),C=g.useCallback(p=>{const w=p.currentTarget;w.scrollTop+w.clientHeight>=w.scrollHeight-64&&x()},[x]),k=a-b.length;return e.jsxs("section",{className:ke.column,"data-status":t,"data-collapsed":s||void 0,children:[e.jsxs("header",{className:ke.columnHeader,onClick:()=>l(p=>!p),role:"button","aria-expanded":!s,title:s?"点击展开":"点击收起",children:[e.jsxs("span",{className:ke.headerLeft,children:[e.jsx("span",{className:`${ke.collapseIcon} ${s?ke.collapseIconCollapsed:""}`,children:"▸"}),e.jsx(ht,{tone:"status",value:t,children:o})]}),e.jsx("span",{className:ke.count,children:a})]}),!s&&e.jsx("div",{className:ke.cards,onScroll:C,children:y?e.jsx("div",{className:ke.empty,children:y}):b.length===0&&!f?e.jsx("div",{className:ke.empty,children:"暂无"}):e.jsxs(e.Fragment,{children:[b.map(p=>{const w=m.get(p.group_id)||p.group_id.slice(0,6);return e.jsx(e1,{issue:p,groupName:w,agents:S,onOpen:()=>j(p.id,p.group_id)},p.id)}),f&&e.jsx("div",{className:ke.loadMoreHint,children:"加载中…"}),!f&&i&&e.jsxs("div",{className:ke.loadMoreHint,children:["向下滚动加载更多(还剩 ",k," / ",a,")"]})]})})]})}function s1(){const{groups:t,agents:o}=nt(),{lastIssueChange:m}=wt(),[S,j]=g.useState(0),[E,b]=g.useState(null),[n,a]=g.useState(null),[d,h]=g.useState(0),[c,f]=Wr(),v=c.get("issue"),y=g.useMemo(()=>{const s=new Map;for(const l of t)s.set(l.id,l.name);return s},[t]);g.useEffect(()=>{m&&j(s=>s+1)},[m]),g.useEffect(()=>{!m||!E||m.issueId===E.id&&h(s=>s+1)},[m,E]),g.useEffect(()=>{if(!v){b(null);return}if(E&&E.id===v)return;let s=!1;return Be.getById(v).then(l=>{s||b({id:l.id,groupId:l.group_id})}).catch(()=>{s||b(null)}),()=>{s=!0}},[v,E]);const u=g.useCallback((s,l)=>{f(_=>{const x=new URLSearchParams(_);return x.set("issue",s),x},{replace:!0}),b({id:s,groupId:l})},[f]),i=g.useCallback(()=>{f(s=>{const l=new URLSearchParams(s);return l.delete("issue"),l},{replace:!0}),b(null)},[f]);g.useEffect(()=>{if(!E){a(null);return}const s=t.find(_=>_.id===E.groupId);if(s){a(s);return}let l=!1;return Re.getById(E.groupId).then(_=>{l||a(_)}).catch(()=>{l||a(null)}),()=>{l=!0}},[E,t]),g.useEffect(()=>{if(!E)return;const s=l=>{l.key==="Escape"&&i()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[E,i]);const r=g.useMemo(()=>{var s;return((s=n==null?void 0:n.members)==null?void 0:s.map(l=>l.agent_name))||[]},[n]);return e.jsxs("div",{className:ke.page,children:[e.jsxs("div",{className:ke.header,children:[e.jsx("h2",{className:ke.title,children:"看板"}),e.jsx("span",{className:ke.subtitle,children:"看板视图 · 每列默认加载 50 条,滚动加载更多"})]}),e.jsx("div",{className:ke.board,children:Y0.map(({status:s,label:l})=>e.jsx(t1,{status:s,label:l,groupNameMap:y,agents:o,onOpenIssue:u,refreshSignal:S},s))}),E&&e.jsx("div",{className:ke.drawerBackdrop,onClick:i,children:e.jsxs("aside",{className:ke.drawer,onClick:s=>s.stopPropagation(),role:"dialog","aria-modal":"true",children:[e.jsx("button",{type:"button",className:ke.drawerClose,onClick:i,"aria-label":"关闭",children:"✕"}),e.jsx("div",{className:ke.drawerBody,children:e.jsx(Gs,{issueId:E.id,refreshSignal:d,agents:o,groupMembers:r,onBack:i})})]})})]})}function r1(){return e.jsx(ui,{})}var Ts={exports:{}},Er;function i1(){return Er||(Er=1,(function(t,o){(function(m,S){t.exports=S()})(globalThis,(()=>(()=>{var m={4567:function(b,n,a){var d=this&&this.__decorate||function(s,l,_,x){var C,k=arguments.length,p=k<3?l:x===null?x=Object.getOwnPropertyDescriptor(l,_):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")p=Reflect.decorate(s,l,_,x);else for(var w=s.length-1;w>=0;w--)(C=s[w])&&(p=(k<3?C(p):k>3?C(l,_,p):C(l,_))||p);return k>3&&p&&Object.defineProperty(l,_,p),p},h=this&&this.__param||function(s,l){return function(_,x){l(_,x,s)}};Object.defineProperty(n,"__esModule",{value:!0}),n.AccessibilityManager=void 0;const c=a(9042),f=a(9924),v=a(844),y=a(4725),u=a(2585),i=a(3656);let r=n.AccessibilityManager=class extends v.Disposable{constructor(s,l,_,x){super(),this._terminal=s,this._coreBrowserService=_,this._renderService=x,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new f.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((C=>this._handleResize(C.rows)))),this.register(this._terminal.onRender((C=>this._refreshRows(C.start,C.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((C=>this._handleChar(C)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
165
+ `)))),this.register(this._terminal.onA11yTab((C=>this._handleTab(C)))),this.register(this._terminal.onKey((C=>this._handleKey(C.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,i.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,v.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(s){for(let l=0;l<s;l++)this._handleChar(" ")}_handleChar(s){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==s&&(this._charsToAnnounce+=s):this._charsToAnnounce+=s,s===`
166
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=c.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(s){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(s)||this._charsToConsume.push(s)}_refreshRows(s,l){this._liveRegionDebouncer.refresh(s,l,this._terminal.rows)}_renderRows(s,l){const _=this._terminal.buffer,x=_.lines.length.toString();for(let C=s;C<=l;C++){const k=_.lines.get(_.ydisp+C),p=[],w=(k==null?void 0:k.translateToString(!0,void 0,void 0,p))||"",R=(_.ydisp+C+1).toString(),T=this._rowElements[C];T&&(w.length===0?(T.innerText=" ",this._rowColumns.set(T,[0,1])):(T.textContent=w,this._rowColumns.set(T,p)),T.setAttribute("aria-posinset",R),T.setAttribute("aria-setsize",x))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(s,l){const _=s.target,x=this._rowElements[l===0?1:this._rowElements.length-2];if(_.getAttribute("aria-posinset")===(l===0?"1":`${this._terminal.buffer.lines.length}`)||s.relatedTarget!==x)return;let C,k;if(l===0?(C=_,k=this._rowElements.pop(),this._rowContainer.removeChild(k)):(C=this._rowElements.shift(),k=_,this._rowContainer.removeChild(C)),C.removeEventListener("focus",this._topBoundaryFocusListener),k.removeEventListener("focus",this._bottomBoundaryFocusListener),l===0){const p=this._createAccessibilityTreeNode();this._rowElements.unshift(p),this._rowContainer.insertAdjacentElement("afterbegin",p)}else{const p=this._createAccessibilityTreeNode();this._rowElements.push(p),this._rowContainer.appendChild(p)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(l===0?-1:1),this._rowElements[l===0?1:this._rowElements.length-2].focus(),s.preventDefault(),s.stopImmediatePropagation()}_handleSelectionChange(){var w;if(this._rowElements.length===0)return;const s=document.getSelection();if(!s)return;if(s.isCollapsed)return void(this._rowContainer.contains(s.anchorNode)&&this._terminal.clearSelection());if(!s.anchorNode||!s.focusNode)return void console.error("anchorNode and/or focusNode are null");let l={node:s.anchorNode,offset:s.anchorOffset},_={node:s.focusNode,offset:s.focusOffset};if((l.node.compareDocumentPosition(_.node)&Node.DOCUMENT_POSITION_PRECEDING||l.node===_.node&&l.offset>_.offset)&&([l,_]=[_,l]),l.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(l={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(l.node))return;const x=this._rowElements.slice(-1)[0];if(_.node.compareDocumentPosition(x)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(_={node:x,offset:((w=x.textContent)==null?void 0:w.length)??0}),!this._rowContainer.contains(_.node))return;const C=({node:R,offset:T})=>{const M=R instanceof Text?R.parentNode:R;let N=parseInt(M==null?void 0:M.getAttribute("aria-posinset"),10)-1;if(isNaN(N))return console.warn("row is invalid. Race condition?"),null;const I=this._rowColumns.get(M);if(!I)return console.warn("columns is null. Race condition?"),null;let z=T<I.length?I[T]:I.slice(-1)[0]+1;return z>=this._terminal.cols&&(++N,z=0),{row:N,column:z}},k=C(l),p=C(_);if(k&&p){if(k.row>p.row||k.row===p.row&&k.column>=p.column)throw new Error("invalid range");this._terminal.select(k.column,k.row,(p.row-k.row)*this._terminal.cols-k.column+p.column)}}_handleResize(s){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let l=this._rowContainer.children.length;l<this._terminal.rows;l++)this._rowElements[l]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[l]);for(;this._rowElements.length>s;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const s=this._coreBrowserService.mainDocument.createElement("div");return s.setAttribute("role","listitem"),s.tabIndex=-1,this._refreshRowDimensions(s),s}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let s=0;s<this._terminal.rows;s++)this._refreshRowDimensions(this._rowElements[s])}}_refreshRowDimensions(s){s.style.height=`${this._renderService.dimensions.css.cell.height}px`}};n.AccessibilityManager=r=d([h(1,u.IInstantiationService),h(2,y.ICoreBrowserService),h(3,y.IRenderService)],r)},3614:(b,n)=>{function a(f){return f.replace(/\r?\n/g,"\r")}function d(f,v){return v?"\x1B[200~"+f+"\x1B[201~":f}function h(f,v,y,u){f=d(f=a(f),y.decPrivateModes.bracketedPasteMode&&u.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(f,!0),v.value=""}function c(f,v,y){const u=y.getBoundingClientRect(),i=f.clientX-u.left-10,r=f.clientY-u.top-10;v.style.width="20px",v.style.height="20px",v.style.left=`${i}px`,v.style.top=`${r}px`,v.style.zIndex="1000",v.focus()}Object.defineProperty(n,"__esModule",{value:!0}),n.rightClickHandler=n.moveTextAreaUnderMouseCursor=n.paste=n.handlePasteEvent=n.copyHandler=n.bracketTextForPaste=n.prepareTextForTerminal=void 0,n.prepareTextForTerminal=a,n.bracketTextForPaste=d,n.copyHandler=function(f,v){f.clipboardData&&f.clipboardData.setData("text/plain",v.selectionText),f.preventDefault()},n.handlePasteEvent=function(f,v,y,u){f.stopPropagation(),f.clipboardData&&h(f.clipboardData.getData("text/plain"),v,y,u)},n.paste=h,n.moveTextAreaUnderMouseCursor=c,n.rightClickHandler=function(f,v,y,u,i){c(f,v,y),i&&u.rightClickSelect(f),v.value=u.selectionText,v.select()}},7239:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorContrastCache=void 0;const d=a(1505);n.ColorContrastCache=class{constructor(){this._color=new d.TwoKeyMap,this._css=new d.TwoKeyMap}setCss(h,c,f){this._css.set(h,c,f)}getCss(h,c){return this._css.get(h,c)}setColor(h,c,f){this._color.set(h,c,f)}getColor(h,c){return this._color.get(h,c)}clear(){this._color.clear(),this._css.clear()}}},3656:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.addDisposableDomListener=void 0,n.addDisposableDomListener=function(a,d,h,c){a.addEventListener(d,h,c);let f=!1;return{dispose:()=>{f||(f=!0,a.removeEventListener(d,h,c))}}}},3551:function(b,n,a){var d=this&&this.__decorate||function(r,s,l,_){var x,C=arguments.length,k=C<3?s:_===null?_=Object.getOwnPropertyDescriptor(s,l):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(r,s,l,_);else for(var p=r.length-1;p>=0;p--)(x=r[p])&&(k=(C<3?x(k):C>3?x(s,l,k):x(s,l))||k);return C>3&&k&&Object.defineProperty(s,l,k),k},h=this&&this.__param||function(r,s){return function(l,_){s(l,_,r)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Linkifier=void 0;const c=a(3656),f=a(8460),v=a(844),y=a(2585),u=a(4725);let i=n.Linkifier=class extends v.Disposable{get currentLink(){return this._currentLink}constructor(r,s,l,_,x){super(),this._element=r,this._mouseService=s,this._renderService=l,this._bufferService=_,this._linkProviderService=x,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new f.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new f.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,v.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,v.toDisposable)((()=>{var C;this._lastMouseEvent=void 0,(C=this._activeProviderReplies)==null||C.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,c.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,c.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(r){this._lastMouseEvent=r;const s=this._positionFromMouseEvent(r,this._element,this._mouseService);if(!s)return;this._isMouseOut=!1;const l=r.composedPath();for(let _=0;_<l.length;_++){const x=l[_];if(x.classList.contains("xterm"))break;if(x.classList.contains("xterm-hover"))return}this._lastBufferCell&&s.x===this._lastBufferCell.x&&s.y===this._lastBufferCell.y||(this._handleHover(s),this._lastBufferCell=s)}_handleHover(r){if(this._activeLine!==r.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(r,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,r)||(this._clearCurrentLink(),this._askForLink(r,!0))}_askForLink(r,s){var _,x;this._activeProviderReplies&&s||((_=this._activeProviderReplies)==null||_.forEach((C=>{C==null||C.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=r.y);let l=!1;for(const[C,k]of this._linkProviderService.linkProviders.entries())s?(x=this._activeProviderReplies)!=null&&x.get(C)&&(l=this._checkLinkProviderResult(C,r,l)):k.provideLinks(r.y,(p=>{var R,T;if(this._isMouseOut)return;const w=p==null?void 0:p.map((M=>({link:M})));(R=this._activeProviderReplies)==null||R.set(C,w),l=this._checkLinkProviderResult(C,r,l),((T=this._activeProviderReplies)==null?void 0:T.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(r.y,this._activeProviderReplies)}))}_removeIntersectingLinks(r,s){const l=new Set;for(let _=0;_<s.size;_++){const x=s.get(_);if(x)for(let C=0;C<x.length;C++){const k=x[C],p=k.link.range.start.y<r?0:k.link.range.start.x,w=k.link.range.end.y>r?this._bufferService.cols:k.link.range.end.x;for(let R=p;R<=w;R++){if(l.has(R)){x.splice(C--,1);break}l.add(R)}}}}_checkLinkProviderResult(r,s,l){var C;if(!this._activeProviderReplies)return l;const _=this._activeProviderReplies.get(r);let x=!1;for(let k=0;k<r;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(x=!0);if(!x&&_){const k=_.find((p=>this._linkAtPosition(p.link,s)));k&&(l=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!l)for(let k=0;k<this._activeProviderReplies.size;k++){const p=(C=this._activeProviderReplies.get(k))==null?void 0:C.find((w=>this._linkAtPosition(w.link,s)));if(p){l=!0,this._handleNewLink(p);break}}return l}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(r){if(!this._currentLink)return;const s=this._positionFromMouseEvent(r,this._element,this._mouseService);s&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,s)&&this._currentLink.link.activate(r,this._currentLink.link.text)}_clearCurrentLink(r,s){this._currentLink&&this._lastMouseEvent&&(!r||!s||this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=s)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,v.disposeArray)(this._linkCacheDisposables))}_handleNewLink(r){if(!this._lastMouseEvent)return;const s=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);s&&this._linkAtPosition(r.link,s)&&(this._currentLink=r,this._currentLink.state={decorations:{underline:r.link.decorations===void 0||r.link.decorations.underline,pointerCursor:r.link.decorations===void 0||r.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,r.link,this._lastMouseEvent),r.link.decorations={},Object.defineProperties(r.link.decorations,{pointerCursor:{get:()=>{var l,_;return(_=(l=this._currentLink)==null?void 0:l.state)==null?void 0:_.decorations.pointerCursor},set:l=>{var _;(_=this._currentLink)!=null&&_.state&&this._currentLink.state.decorations.pointerCursor!==l&&(this._currentLink.state.decorations.pointerCursor=l,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",l))}},underline:{get:()=>{var l,_;return(_=(l=this._currentLink)==null?void 0:l.state)==null?void 0:_.decorations.underline},set:l=>{var _,x,C;(_=this._currentLink)!=null&&_.state&&((C=(x=this._currentLink)==null?void 0:x.state)==null?void 0:C.decorations.underline)!==l&&(this._currentLink.state.decorations.underline=l,this._currentLink.state.isHovered&&this._fireUnderlineEvent(r.link,l))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((l=>{if(!this._currentLink)return;const _=l.start===0?0:l.start+1+this._bufferService.buffer.ydisp,x=this._bufferService.buffer.ydisp+1+l.end;if(this._currentLink.link.range.start.y>=_&&this._currentLink.link.range.end.y<=x&&(this._clearCurrentLink(_,x),this._lastMouseEvent)){const C=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);C&&this._askForLink(C,!1)}}))))}_linkHover(r,s,l){var _;(_=this._currentLink)!=null&&_.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(s,!0),this._currentLink.state.decorations.pointerCursor&&r.classList.add("xterm-cursor-pointer")),s.hover&&s.hover(l,s.text)}_fireUnderlineEvent(r,s){const l=r.range,_=this._bufferService.buffer.ydisp,x=this._createLinkUnderlineEvent(l.start.x-1,l.start.y-_-1,l.end.x,l.end.y-_-1,void 0);(s?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(x)}_linkLeave(r,s,l){var _;(_=this._currentLink)!=null&&_.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(s,!1),this._currentLink.state.decorations.pointerCursor&&r.classList.remove("xterm-cursor-pointer")),s.leave&&s.leave(l,s.text)}_linkAtPosition(r,s){const l=r.range.start.y*this._bufferService.cols+r.range.start.x,_=r.range.end.y*this._bufferService.cols+r.range.end.x,x=s.y*this._bufferService.cols+s.x;return l<=x&&x<=_}_positionFromMouseEvent(r,s,l){const _=l.getCoords(r,s,this._bufferService.cols,this._bufferService.rows);if(_)return{x:_[0],y:_[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(r,s,l,_,x){return{x1:r,y1:s,x2:l,y2:_,cols:this._bufferService.cols,fg:x}}};n.Linkifier=i=d([h(1,u.IMouseService),h(2,u.IRenderService),h(3,y.IBufferService),h(4,u.ILinkProviderService)],i)},9042:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.tooMuchOutput=n.promptLabel=void 0,n.promptLabel="Terminal input",n.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(b,n,a){var d=this&&this.__decorate||function(u,i,r,s){var l,_=arguments.length,x=_<3?i:s===null?s=Object.getOwnPropertyDescriptor(i,r):s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(u,i,r,s);else for(var C=u.length-1;C>=0;C--)(l=u[C])&&(x=(_<3?l(x):_>3?l(i,r,x):l(i,r))||x);return _>3&&x&&Object.defineProperty(i,r,x),x},h=this&&this.__param||function(u,i){return function(r,s){i(r,s,u)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkProvider=void 0;const c=a(511),f=a(2585);let v=n.OscLinkProvider=class{constructor(u,i,r){this._bufferService=u,this._optionsService=i,this._oscLinkService=r}provideLinks(u,i){var w;const r=this._bufferService.buffer.lines.get(u-1);if(!r)return void i(void 0);const s=[],l=this._optionsService.rawOptions.linkHandler,_=new c.CellData,x=r.getTrimmedLength();let C=-1,k=-1,p=!1;for(let R=0;R<x;R++)if(k!==-1||r.hasContent(R)){if(r.loadCell(R,_),_.hasExtendedAttrs()&&_.extended.urlId){if(k===-1){k=R,C=_.extended.urlId;continue}p=_.extended.urlId!==C}else k!==-1&&(p=!0);if(p||k!==-1&&R===x-1){const T=(w=this._oscLinkService.getLinkData(C))==null?void 0:w.uri;if(T){const M={start:{x:k+1,y:u},end:{x:R+(p||R!==x-1?0:1),y:u}};let N=!1;if(!(l!=null&&l.allowNonHttpProtocols))try{const I=new URL(T);["http:","https:"].includes(I.protocol)||(N=!0)}catch{N=!0}N||s.push({text:T,range:M,activate:(I,z)=>l?l.activate(I,z,M):y(0,z),hover:(I,z)=>{var G;return(G=l==null?void 0:l.hover)==null?void 0:G.call(l,I,z,M)},leave:(I,z)=>{var G;return(G=l==null?void 0:l.leave)==null?void 0:G.call(l,I,z,M)}})}p=!1,_.hasExtendedAttrs()&&_.extended.urlId?(k=R,C=_.extended.urlId):(k=-1,C=-1)}}i(s)}};function y(u,i){if(confirm(`Do you want to navigate to ${i}?
167
+
168
+ WARNING: This link could potentially be dangerous`)){const r=window.open();if(r){try{r.opener=null}catch{}r.location.href=i}else console.warn("Opening link blocked as opener could not be cleared")}}n.OscLinkProvider=v=d([h(0,f.IBufferService),h(1,f.IOptionsService),h(2,f.IOscLinkService)],v)},6193:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RenderDebouncer=void 0,n.RenderDebouncer=class{constructor(a,d){this._renderCallback=a,this._coreBrowserService=d,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(a){return this._refreshCallbacks.push(a),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(a,d,h){this._rowCount=h,a=a!==void 0?a:0,d=d!==void 0?d:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,a):a,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,d):d,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const a=Math.max(this._rowStart,0),d=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(a,d),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const a of this._refreshCallbacks)a(0);this._refreshCallbacks=[]}}},3236:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Terminal=void 0;const d=a(3614),h=a(3656),c=a(3551),f=a(9042),v=a(3730),y=a(1680),u=a(3107),i=a(5744),r=a(2950),s=a(1296),l=a(428),_=a(4269),x=a(5114),C=a(8934),k=a(3230),p=a(9312),w=a(4725),R=a(6731),T=a(8055),M=a(8969),N=a(8460),I=a(844),z=a(6114),G=a(8437),H=a(2584),V=a(7399),L=a(5941),A=a(9074),B=a(2585),P=a(5435),U=a(4567),Z=a(779);class oe extends M.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor($={}){super($),this.browser=z,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new I.MutableDisposable),this._onCursorMove=this.register(new N.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new N.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new N.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new N.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new N.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new N.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new N.EventEmitter),this._onBlur=this.register(new N.EventEmitter),this._onA11yCharEmitter=this.register(new N.EventEmitter),this._onA11yTabEmitter=this.register(new N.EventEmitter),this._onWillOpen=this.register(new N.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(A.DecorationService),this._instantiationService.setService(B.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Z.LinkProviderService),this._instantiationService.setService(w.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(v.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((D,q)=>this.refresh(D,q)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((D=>this._reportWindowsOptions(D)))),this.register(this._inputHandler.onColor((D=>this._handleColorEvent(D)))),this.register((0,N.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,N.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,N.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,N.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((D=>this._afterResize(D.cols,D.rows)))),this.register((0,I.toDisposable)((()=>{var D,q;this._customKeyEventHandler=void 0,(q=(D=this.element)==null?void 0:D.parentNode)==null||q.removeChild(this.element)})))}_handleColorEvent($){if(this._themeService)for(const D of $){let q,J="";switch(D.index){case 256:q="foreground",J="10";break;case 257:q="background",J="11";break;case 258:q="cursor",J="12";break;default:q="ansi",J="4;"+D.index}switch(D.type){case 0:const O=T.color.toColorRGB(q==="ansi"?this._themeService.colors.ansi[D.index]:this._themeService.colors[q]);this.coreService.triggerDataEvent(`${H.C0.ESC}]${J};${(0,L.toRgbString)(O)}${H.C1_ESCAPED.ST}`);break;case 1:if(q==="ansi")this._themeService.modifyColors((X=>X.ansi[D.index]=T.channels.toColor(...D.color)));else{const X=q;this._themeService.modifyColors((F=>F[X]=T.channels.toColor(...D.color)))}break;case 2:this._themeService.restoreColor(D.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange($){$?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(U.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus($){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(H.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var $;return($=this.textarea)==null?void 0:$.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(H.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const $=this.buffer.ybase+this.buffer.y,D=this.buffer.lines.get($);if(!D)return;const q=Math.min(this.buffer.x,this.cols-1),J=this._renderService.dimensions.css.cell.height,O=D.getWidth(q),X=this._renderService.dimensions.css.cell.width*O,F=this.buffer.y*this._renderService.dimensions.css.cell.height,W=q*this._renderService.dimensions.css.cell.width;this.textarea.style.left=W+"px",this.textarea.style.top=F+"px",this.textarea.style.width=X+"px",this.textarea.style.height=J+"px",this.textarea.style.lineHeight=J+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,h.addDisposableDomListener)(this.element,"copy",(D=>{this.hasSelection()&&(0,d.copyHandler)(D,this._selectionService)})));const $=D=>(0,d.handlePasteEvent)(D,this.textarea,this.coreService,this.optionsService);this.register((0,h.addDisposableDomListener)(this.textarea,"paste",$)),this.register((0,h.addDisposableDomListener)(this.element,"paste",$)),z.isFirefox?this.register((0,h.addDisposableDomListener)(this.element,"mousedown",(D=>{D.button===2&&(0,d.rightClickHandler)(D,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,h.addDisposableDomListener)(this.element,"contextmenu",(D=>{(0,d.rightClickHandler)(D,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),z.isLinux&&this.register((0,h.addDisposableDomListener)(this.element,"auxclick",(D=>{D.button===1&&(0,d.moveTextAreaUnderMouseCursor)(D,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,h.addDisposableDomListener)(this.textarea,"keyup",($=>this._keyUp($)),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"keydown",($=>this._keyDown($)),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"keypress",($=>this._keyPress($)),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionupdate",($=>this._compositionHelper.compositionupdate($)))),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,h.addDisposableDomListener)(this.textarea,"input",($=>this._inputEvent($)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open($){var q;if(!$)throw new Error("Terminal requires a parent element.");if($.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((q=this.element)==null?void 0:q.ownerDocument.defaultView)&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=$.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),$.appendChild(this.element);const D=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),D.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this.register((0,h.addDisposableDomListener)(this.screenElement,"mousemove",(J=>this.updateCursorStyle(J)))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),D.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",f.promptLabel),z.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this.register(this._instantiationService.createInstance(x.CoreBrowserService,this.textarea,$.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(w.ICoreBrowserService,this._coreBrowserService),this.register((0,h.addDisposableDomListener)(this.textarea,"focus",(J=>this._handleTextAreaFocus(J)))),this.register((0,h.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(l.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(w.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(R.ThemeService),this._instantiationService.setService(w.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(_.CharacterJoinerService),this._instantiationService.setService(w.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(k.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(w.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((J=>this._onRender.fire(J)))),this.onResize((J=>this._renderService.resize(J.cols,J.rows))),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(r.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(C.MouseService),this._instantiationService.setService(w.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(c.Linkifier,this.screenElement)),this.element.appendChild(D);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(y.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((J=>this.scrollLines(J.amount,J.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(p.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(w.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((J=>this.scrollLines(J.amount,J.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((J=>this._renderService.handleSelectionChanged(J.start,J.end,J.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((J=>{this.textarea.value=J,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((J=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,h.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(u.BufferDecorationRenderer,this.screenElement)),this.register((0,h.addDisposableDomListener)(this.element,"mousedown",(J=>this._selectionService.handleMouseDown(J)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(U.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(J=>this._handleScreenReaderModeOptionChange(J)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(i.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(J=>{!this._overviewRulerRenderer&&J&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(i.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(s.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const $=this,D=this.element;function q(X){const F=$._mouseService.getMouseReportCoords(X,$.screenElement);if(!F)return!1;let W,re;switch(X.overrideType||X.type){case"mousemove":re=32,X.buttons===void 0?(W=3,X.button!==void 0&&(W=X.button<3?X.button:3)):W=1&X.buttons?0:4&X.buttons?1:2&X.buttons?2:3;break;case"mouseup":re=0,W=X.button<3?X.button:3;break;case"mousedown":re=1,W=X.button<3?X.button:3;break;case"wheel":if($._customWheelEventHandler&&$._customWheelEventHandler(X)===!1||$.viewport.getLinesScrolled(X)===0)return!1;re=X.deltaY<0?0:1,W=4;break;default:return!1}return!(re===void 0||W===void 0||W>4)&&$.coreMouseService.triggerMouseEvent({col:F.col,row:F.row,x:F.x,y:F.y,button:W,action:re,ctrl:X.ctrlKey,alt:X.altKey,shift:X.shiftKey})}const J={mouseup:null,wheel:null,mousedrag:null,mousemove:null},O={mouseup:X=>(q(X),X.buttons||(this._document.removeEventListener("mouseup",J.mouseup),J.mousedrag&&this._document.removeEventListener("mousemove",J.mousedrag)),this.cancel(X)),wheel:X=>(q(X),this.cancel(X,!0)),mousedrag:X=>{X.buttons&&q(X)},mousemove:X=>{X.buttons||q(X)}};this.register(this.coreMouseService.onProtocolChange((X=>{X?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(X)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&X?J.mousemove||(D.addEventListener("mousemove",O.mousemove),J.mousemove=O.mousemove):(D.removeEventListener("mousemove",J.mousemove),J.mousemove=null),16&X?J.wheel||(D.addEventListener("wheel",O.wheel,{passive:!1}),J.wheel=O.wheel):(D.removeEventListener("wheel",J.wheel),J.wheel=null),2&X?J.mouseup||(J.mouseup=O.mouseup):(this._document.removeEventListener("mouseup",J.mouseup),J.mouseup=null),4&X?J.mousedrag||(J.mousedrag=O.mousedrag):(this._document.removeEventListener("mousemove",J.mousedrag),J.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,h.addDisposableDomListener)(D,"mousedown",(X=>{if(X.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(X))return q(X),J.mouseup&&this._document.addEventListener("mouseup",J.mouseup),J.mousedrag&&this._document.addEventListener("mousemove",J.mousedrag),this.cancel(X)}))),this.register((0,h.addDisposableDomListener)(D,"wheel",(X=>{if(!J.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(X)===!1)return!1;if(!this.buffer.hasScrollback){const F=this.viewport.getLinesScrolled(X);if(F===0)return;const W=H.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(X.deltaY<0?"A":"B");let re="";for(let ae=0;ae<Math.abs(F);ae++)re+=W;return this.coreService.triggerDataEvent(re,!0),this.cancel(X,!0)}return this.viewport.handleWheel(X)?this.cancel(X):void 0}}),{passive:!1})),this.register((0,h.addDisposableDomListener)(D,"touchstart",(X=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(X),this.cancel(X)}),{passive:!0})),this.register((0,h.addDisposableDomListener)(D,"touchmove",(X=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(X)?void 0:this.cancel(X)}),{passive:!1}))}refresh($,D){var q;(q=this._renderService)==null||q.refreshRows($,D)}updateCursorStyle($){var D;(D=this._selectionService)!=null&&D.shouldColumnSelect($)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines($,D,q=0){var J;q===1?(super.scrollLines($,D,q),this.refresh(0,this.rows-1)):(J=this.viewport)==null||J.scrollLines($)}paste($){(0,d.paste)($,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler($){this._customKeyEventHandler=$}attachCustomWheelEventHandler($){this._customWheelEventHandler=$}registerLinkProvider($){return this._linkProviderService.registerLinkProvider($)}registerCharacterJoiner($){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const D=this._characterJoinerService.register($);return this.refresh(0,this.rows-1),D}deregisterCharacterJoiner($){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister($)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker($){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+$)}registerDecoration($){return this._decorationService.registerDecoration($)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select($,D,q){this._selectionService.setSelection($,D,q)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var $;($=this._selectionService)==null||$.clearSelection()}selectAll(){var $;($=this._selectionService)==null||$.selectAll()}selectLines($,D){var q;(q=this._selectionService)==null||q.selectLines($,D)}_keyDown($){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler($)===!1)return!1;const D=this.browser.isMac&&this.options.macOptionIsMeta&&$.altKey;if(!D&&!this._compositionHelper.keydown($))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;D||$.key!=="Dead"&&$.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const q=(0,V.evaluateKeyboardEvent)($,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle($),q.type===3||q.type===2){const J=this.rows-1;return this.scrollLines(q.type===2?-J:J),this.cancel($,!0)}return q.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,$)||(q.cancel&&this.cancel($,!0),!q.key||!!($.key&&!$.ctrlKey&&!$.altKey&&!$.metaKey&&$.key.length===1&&$.key.charCodeAt(0)>=65&&$.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(q.key!==H.C0.ETX&&q.key!==H.C0.CR||(this.textarea.value=""),this._onKey.fire({key:q.key,domEvent:$}),this._showCursor(),this.coreService.triggerDataEvent(q.key,!0),!this.optionsService.rawOptions.screenReaderMode||$.altKey||$.ctrlKey?this.cancel($,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift($,D){const q=$.isMac&&!this.options.macOptionIsMeta&&D.altKey&&!D.ctrlKey&&!D.metaKey||$.isWindows&&D.altKey&&D.ctrlKey&&!D.metaKey||$.isWindows&&D.getModifierState("AltGraph");return D.type==="keypress"?q:q&&(!D.keyCode||D.keyCode>47)}_keyUp($){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler($)===!1||((function(D){return D.keyCode===16||D.keyCode===17||D.keyCode===18})($)||this.focus(),this.updateCursorStyle($),this._keyPressHandled=!1)}_keyPress($){let D;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler($)===!1)return!1;if(this.cancel($),$.charCode)D=$.charCode;else if($.which===null||$.which===void 0)D=$.keyCode;else{if($.which===0||$.charCode===0)return!1;D=$.which}return!(!D||($.altKey||$.ctrlKey||$.metaKey)&&!this._isThirdLevelShift(this.browser,$)||(D=String.fromCharCode(D),this._onKey.fire({key:D,domEvent:$}),this._showCursor(),this.coreService.triggerDataEvent(D,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent($){if($.data&&$.inputType==="insertText"&&(!$.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const D=$.data;return this.coreService.triggerDataEvent(D,!0),this.cancel($),!0}return!1}resize($,D){$!==this.cols||D!==this.rows?super.resize($,D):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize($,D){var q,J;(q=this._charSizeService)==null||q.measure(),(J=this.viewport)==null||J.syncScrollArea(!0)}clear(){var $;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let D=1;D<this.rows;D++)this.buffer.lines.push(this.buffer.getBlankLine(G.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),($=this.viewport)==null||$.reset(),this.refresh(0,this.rows-1)}}reset(){var D,q;this.options.rows=this.rows,this.options.cols=this.cols;const $=this._customKeyEventHandler;this._setup(),super.reset(),(D=this._selectionService)==null||D.reset(),this._decorationService.reset(),(q=this.viewport)==null||q.reset(),this._customKeyEventHandler=$,this.refresh(0,this.rows-1)}clearTextureAtlas(){var $;($=this._renderService)==null||$.clearTextureAtlas()}_reportFocus(){var $;($=this.element)!=null&&$.classList.contains("focus")?this.coreService.triggerDataEvent(H.C0.ESC+"[I"):this.coreService.triggerDataEvent(H.C0.ESC+"[O")}_reportWindowsOptions($){if(this._renderService)switch($){case P.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const D=this._renderService.dimensions.css.canvas.width.toFixed(0),q=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${H.C0.ESC}[4;${q};${D}t`);break;case P.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const J=this._renderService.dimensions.css.cell.width.toFixed(0),O=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${H.C0.ESC}[6;${O};${J}t`)}}cancel($,D){if(this.options.cancelEvents||D)return $.preventDefault(),$.stopPropagation(),!1}}n.Terminal=oe},9924:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TimeBasedDebouncer=void 0,n.TimeBasedDebouncer=class{constructor(a,d=1e3){this._renderCallback=a,this._debounceThresholdMS=d,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(a,d,h){this._rowCount=h,a=a!==void 0?a:0,d=d!==void 0?d:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,a):a,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,d):d;const c=Date.now();if(c-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=c,this._innerRefresh();else if(!this._additionalRefreshRequested){const f=c-this._lastRefreshMs,v=this._debounceThresholdMS-f;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),v)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const a=Math.max(this._rowStart,0),d=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(a,d)}}},1680:function(b,n,a){var d=this&&this.__decorate||function(r,s,l,_){var x,C=arguments.length,k=C<3?s:_===null?_=Object.getOwnPropertyDescriptor(s,l):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(r,s,l,_);else for(var p=r.length-1;p>=0;p--)(x=r[p])&&(k=(C<3?x(k):C>3?x(s,l,k):x(s,l))||k);return C>3&&k&&Object.defineProperty(s,l,k),k},h=this&&this.__param||function(r,s){return function(l,_){s(l,_,r)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Viewport=void 0;const c=a(3656),f=a(4725),v=a(8460),y=a(844),u=a(2585);let i=n.Viewport=class extends y.Disposable{constructor(r,s,l,_,x,C,k,p){super(),this._viewportElement=r,this._scrollArea=s,this._bufferService=l,this._optionsService=_,this._charSizeService=x,this._renderService=C,this._coreBrowserService=k,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new v.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,c.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((w=>this._activeBuffer=w.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((w=>this._renderDimensions=w))),this._handleThemeChange(p.colors),this.register(p.onChangeColors((w=>this._handleThemeChange(w)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(r){this._viewportElement.style.backgroundColor=r.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(r){if(r)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const s=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==s&&(this._lastRecordedBufferHeight=s,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const r=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==r&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=r),this._refreshAnimationFrame=null}syncScrollArea(r=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(r);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(r)}_handleScroll(r){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const s=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:s,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const r=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(r*(this._smoothScrollState.target-this._smoothScrollState.origin)),r<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(r,s){const l=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(s<0&&this._viewportElement.scrollTop!==0||s>0&&l<this._lastRecordedBufferHeight)||(r.cancelable&&r.preventDefault(),!1)}handleWheel(r){const s=this._getPixelsScrolled(r);return s!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+s:this._smoothScrollState.target+=s,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=s,this._bubbleScroll(r,s))}scrollLines(r){if(r!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const s=r*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+s,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:r,suppressScrollEvent:!1})}_getPixelsScrolled(r){if(r.deltaY===0||r.shiftKey)return 0;let s=this._applyScrollModifier(r.deltaY,r);return r.deltaMode===WheelEvent.DOM_DELTA_LINE?s*=this._currentRowHeight:r.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(s*=this._currentRowHeight*this._bufferService.rows),s}getBufferElements(r,s){var p;let l,_="";const x=[],C=s??this._bufferService.buffer.lines.length,k=this._bufferService.buffer.lines;for(let w=r;w<C;w++){const R=k.get(w);if(!R)continue;const T=(p=k.get(w+1))==null?void 0:p.isWrapped;if(_+=R.translateToString(!T),!T||w===k.length-1){const M=document.createElement("div");M.textContent=_,x.push(M),_.length>0&&(l=M),_=""}}return{bufferElements:x,cursorElement:l}}getLinesScrolled(r){if(r.deltaY===0||r.shiftKey)return 0;let s=this._applyScrollModifier(r.deltaY,r);return r.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(s/=this._currentRowHeight+0,this._wheelPartialScroll+=s,s=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):r.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(s*=this._bufferService.rows),s}_applyScrollModifier(r,s){const l=this._optionsService.rawOptions.fastScrollModifier;return l==="alt"&&s.altKey||l==="ctrl"&&s.ctrlKey||l==="shift"&&s.shiftKey?r*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:r*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(r){this._lastTouchY=r.touches[0].pageY}handleTouchMove(r){const s=this._lastTouchY-r.touches[0].pageY;return this._lastTouchY=r.touches[0].pageY,s!==0&&(this._viewportElement.scrollTop+=s,this._bubbleScroll(r,s))}};n.Viewport=i=d([h(2,u.IBufferService),h(3,u.IOptionsService),h(4,f.ICharSizeService),h(5,f.IRenderService),h(6,f.ICoreBrowserService),h(7,f.IThemeService)],i)},3107:function(b,n,a){var d=this&&this.__decorate||function(u,i,r,s){var l,_=arguments.length,x=_<3?i:s===null?s=Object.getOwnPropertyDescriptor(i,r):s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(u,i,r,s);else for(var C=u.length-1;C>=0;C--)(l=u[C])&&(x=(_<3?l(x):_>3?l(i,r,x):l(i,r))||x);return _>3&&x&&Object.defineProperty(i,r,x),x},h=this&&this.__param||function(u,i){return function(r,s){i(r,s,u)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferDecorationRenderer=void 0;const c=a(4725),f=a(844),v=a(2585);let y=n.BufferDecorationRenderer=class extends f.Disposable{constructor(u,i,r,s,l){super(),this._screenElement=u,this._bufferService=i,this._coreBrowserService=r,this._decorationService=s,this._renderService=l,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((_=>this._removeDecoration(_)))),this.register((0,f.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const u of this._decorationService.decorations)this._renderDecoration(u);this._dimensionsChanged=!1}_renderDecoration(u){this._refreshStyle(u),this._dimensionsChanged&&this._refreshXPosition(u)}_createElement(u){var s;const i=this._coreBrowserService.mainDocument.createElement("div");i.classList.add("xterm-decoration"),i.classList.toggle("xterm-decoration-top-layer",((s=u==null?void 0:u.options)==null?void 0:s.layer)==="top"),i.style.width=`${Math.round((u.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=(u.options.height||1)*this._renderService.dimensions.css.cell.height+"px",i.style.top=(u.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const r=u.options.x??0;return r&&r>this._bufferService.cols&&(i.style.display="none"),this._refreshXPosition(u,i),i}_refreshStyle(u){const i=u.marker.line-this._bufferService.buffers.active.ydisp;if(i<0||i>=this._bufferService.rows)u.element&&(u.element.style.display="none",u.onRenderEmitter.fire(u.element));else{let r=this._decorationElements.get(u);r||(r=this._createElement(u),u.element=r,this._decorationElements.set(u,r),this._container.appendChild(r),u.onDispose((()=>{this._decorationElements.delete(u),r.remove()}))),r.style.top=i*this._renderService.dimensions.css.cell.height+"px",r.style.display=this._altBufferIsActive?"none":"block",u.onRenderEmitter.fire(r)}}_refreshXPosition(u,i=u.element){if(!i)return;const r=u.options.x??0;(u.options.anchor||"left")==="right"?i.style.right=r?r*this._renderService.dimensions.css.cell.width+"px":"":i.style.left=r?r*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(u){var i;(i=this._decorationElements.get(u))==null||i.remove(),this._decorationElements.delete(u),u.dispose()}};n.BufferDecorationRenderer=y=d([h(1,v.IBufferService),h(2,c.ICoreBrowserService),h(3,v.IDecorationService),h(4,c.IRenderService)],y)},5871:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorZoneStore=void 0,n.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(a){if(a.options.overviewRulerOptions){for(const d of this._zones)if(d.color===a.options.overviewRulerOptions.color&&d.position===a.options.overviewRulerOptions.position){if(this._lineIntersectsZone(d,a.marker.line))return;if(this._lineAdjacentToZone(d,a.marker.line,a.options.overviewRulerOptions.position))return void this._addLineToZone(d,a.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=a.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=a.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=a.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=a.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:a.options.overviewRulerOptions.color,position:a.options.overviewRulerOptions.position,startBufferLine:a.marker.line,endBufferLine:a.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(a){this._linePadding=a}_lineIntersectsZone(a,d){return d>=a.startBufferLine&&d<=a.endBufferLine}_lineAdjacentToZone(a,d,h){return d>=a.startBufferLine-this._linePadding[h||"full"]&&d<=a.endBufferLine+this._linePadding[h||"full"]}_addLineToZone(a,d){a.startBufferLine=Math.min(a.startBufferLine,d),a.endBufferLine=Math.max(a.endBufferLine,d)}}},5744:function(b,n,a){var d=this&&this.__decorate||function(l,_,x,C){var k,p=arguments.length,w=p<3?_:C===null?C=Object.getOwnPropertyDescriptor(_,x):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(l,_,x,C);else for(var R=l.length-1;R>=0;R--)(k=l[R])&&(w=(p<3?k(w):p>3?k(_,x,w):k(_,x))||w);return p>3&&w&&Object.defineProperty(_,x,w),w},h=this&&this.__param||function(l,_){return function(x,C){_(x,C,l)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OverviewRulerRenderer=void 0;const c=a(5871),f=a(4725),v=a(844),y=a(2585),u={full:0,left:0,center:0,right:0},i={full:0,left:0,center:0,right:0},r={full:0,left:0,center:0,right:0};let s=n.OverviewRulerRenderer=class extends v.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(l,_,x,C,k,p,w){var T;super(),this._viewportElement=l,this._screenElement=_,this._bufferService=x,this._decorationService=C,this._renderService=k,this._optionsService=p,this._coreBrowserService=w,this._colorZoneStore=new c.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(T=this._viewportElement.parentElement)==null||T.insertBefore(this._canvas,this._viewportElement);const R=this._canvas.getContext("2d");if(!R)throw new Error("Ctx cannot be null");this._ctx=R,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,v.toDisposable)((()=>{var M;(M=this._canvas)==null||M.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const l=Math.floor(this._canvas.width/3),_=Math.ceil(this._canvas.width/3);i.full=this._canvas.width,i.left=l,i.center=_,i.right=l,this._refreshDrawHeightConstants(),r.full=0,r.left=0,r.center=i.left,r.right=i.left+i.center}_refreshDrawHeightConstants(){u.full=Math.round(2*this._coreBrowserService.dpr);const l=this._canvas.height/this._bufferService.buffer.lines.length,_=Math.round(Math.max(Math.min(l,12),6)*this._coreBrowserService.dpr);u.left=_,u.center=_,u.right=_}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*u.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*u.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*u.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*u.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const _ of this._decorationService.decorations)this._colorZoneStore.addDecoration(_);this._ctx.lineWidth=1;const l=this._colorZoneStore.zones;for(const _ of l)_.position!=="full"&&this._renderColorZone(_);for(const _ of l)_.position==="full"&&this._renderColorZone(_);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(l){this._ctx.fillStyle=l.color,this._ctx.fillRect(r[l.position||"full"],Math.round((this._canvas.height-1)*(l.startBufferLine/this._bufferService.buffers.active.lines.length)-u[l.position||"full"]/2),i[l.position||"full"],Math.round((this._canvas.height-1)*((l.endBufferLine-l.startBufferLine)/this._bufferService.buffers.active.lines.length)+u[l.position||"full"]))}_queueRefresh(l,_){this._shouldUpdateDimensions=l||this._shouldUpdateDimensions,this._shouldUpdateAnchor=_||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};n.OverviewRulerRenderer=s=d([h(2,y.IBufferService),h(3,y.IDecorationService),h(4,f.IRenderService),h(5,y.IOptionsService),h(6,f.ICoreBrowserService)],s)},2950:function(b,n,a){var d=this&&this.__decorate||function(u,i,r,s){var l,_=arguments.length,x=_<3?i:s===null?s=Object.getOwnPropertyDescriptor(i,r):s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(u,i,r,s);else for(var C=u.length-1;C>=0;C--)(l=u[C])&&(x=(_<3?l(x):_>3?l(i,r,x):l(i,r))||x);return _>3&&x&&Object.defineProperty(i,r,x),x},h=this&&this.__param||function(u,i){return function(r,s){i(r,s,u)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CompositionHelper=void 0;const c=a(4725),f=a(2585),v=a(2584);let y=n.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(u,i,r,s,l,_){this._textarea=u,this._compositionView=i,this._bufferService=r,this._optionsService=s,this._coreService=l,this._renderService=_,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(u){this._compositionView.textContent=u.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(u){if(this._isComposing||this._isSendingComposition){if(u.keyCode===229||u.keyCode===16||u.keyCode===17||u.keyCode===18)return!1;this._finalizeComposition(!1)}return u.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(u){if(this._compositionView.classList.remove("active"),this._isComposing=!1,u){const i={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let r;this._isSendingComposition=!1,i.start+=this._dataAlreadySent.length,r=this._isComposing?this._textarea.value.substring(i.start,i.end):this._textarea.value.substring(i.start),r.length>0&&this._coreService.triggerDataEvent(r,!0)}}),0)}else{this._isSendingComposition=!1;const i=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(i,!0)}}_handleAnyTextareaChanges(){const u=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const i=this._textarea.value,r=i.replace(u,"");this._dataAlreadySent=r,i.length>u.length?this._coreService.triggerDataEvent(r,!0):i.length<u.length?this._coreService.triggerDataEvent(`${v.C0.DEL}`,!0):i.length===u.length&&i!==u&&this._coreService.triggerDataEvent(i,!0)}}),0)}updateCompositionElements(u){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const i=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),r=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,l=i*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=l+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const _=this._compositionView.getBoundingClientRect();this._textarea.style.left=l+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(_.width,1)+"px",this._textarea.style.height=Math.max(_.height,1)+"px",this._textarea.style.lineHeight=_.height+"px"}u||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};n.CompositionHelper=y=d([h(2,f.IBufferService),h(3,f.IOptionsService),h(4,f.ICoreService),h(5,c.IRenderService)],y)},9806:(b,n)=>{function a(d,h,c){const f=c.getBoundingClientRect(),v=d.getComputedStyle(c),y=parseInt(v.getPropertyValue("padding-left")),u=parseInt(v.getPropertyValue("padding-top"));return[h.clientX-f.left-y,h.clientY-f.top-u]}Object.defineProperty(n,"__esModule",{value:!0}),n.getCoords=n.getCoordsRelativeToElement=void 0,n.getCoordsRelativeToElement=a,n.getCoords=function(d,h,c,f,v,y,u,i,r){if(!y)return;const s=a(d,h,c);return s?(s[0]=Math.ceil((s[0]+(r?u/2:0))/u),s[1]=Math.ceil(s[1]/i),s[0]=Math.min(Math.max(s[0],1),f+(r?1:0)),s[1]=Math.min(Math.max(s[1],1),v),s):void 0}},9504:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.moveToCellSequence=void 0;const d=a(2584);function h(i,r,s,l){const _=i-c(i,s),x=r-c(r,s),C=Math.abs(_-x)-(function(k,p,w){let R=0;const T=k-c(k,w),M=p-c(p,w);for(let N=0;N<Math.abs(T-M);N++){const I=f(k,p)==="A"?-1:1,z=w.buffer.lines.get(T+I*N);z!=null&&z.isWrapped&&R++}return R})(i,r,s);return u(C,y(f(i,r),l))}function c(i,r){let s=0,l=r.buffer.lines.get(i),_=l==null?void 0:l.isWrapped;for(;_&&i>=0&&i<r.rows;)s++,l=r.buffer.lines.get(--i),_=l==null?void 0:l.isWrapped;return s}function f(i,r){return i>r?"A":"B"}function v(i,r,s,l,_,x){let C=i,k=r,p="";for(;C!==s||k!==l;)C+=_?1:-1,_&&C>x.cols-1?(p+=x.buffer.translateBufferLineToString(k,!1,i,C),C=0,i=0,k++):!_&&C<0&&(p+=x.buffer.translateBufferLineToString(k,!1,0,i+1),C=x.cols-1,i=C,k--);return p+x.buffer.translateBufferLineToString(k,!1,i,C)}function y(i,r){const s=r?"O":"[";return d.C0.ESC+s+i}function u(i,r){i=Math.floor(i);let s="";for(let l=0;l<i;l++)s+=r;return s}n.moveToCellSequence=function(i,r,s,l){const _=s.buffer.x,x=s.buffer.y;if(!s.buffer.hasScrollback)return(function(p,w,R,T,M,N){return h(w,T,M,N).length===0?"":u(v(p,w,p,w-c(w,M),!1,M).length,y("D",N))})(_,x,0,r,s,l)+h(x,r,s,l)+(function(p,w,R,T,M,N){let I;I=h(w,T,M,N).length>0?T-c(T,M):w;const z=T,G=(function(H,V,L,A,B,P){let U;return U=h(L,A,B,P).length>0?A-c(A,B):V,H<L&&U<=A||H>=L&&U<A?"C":"D"})(p,w,R,T,M,N);return u(v(p,I,R,z,G==="C",M).length,y(G,N))})(_,x,i,r,s,l);let C;if(x===r)return C=_>i?"D":"C",u(Math.abs(_-i),y(C,l));C=x>r?"D":"C";const k=Math.abs(x-r);return u((function(p,w){return w.cols-p})(x>r?i:_,s)+(k-1)*s.cols+1+((x>r?_:i)-1),y(C,l))}},1296:function(b,n,a){var d=this&&this.__decorate||function(N,I,z,G){var H,V=arguments.length,L=V<3?I:G===null?G=Object.getOwnPropertyDescriptor(I,z):G;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(N,I,z,G);else for(var A=N.length-1;A>=0;A--)(H=N[A])&&(L=(V<3?H(L):V>3?H(I,z,L):H(I,z))||L);return V>3&&L&&Object.defineProperty(I,z,L),L},h=this&&this.__param||function(N,I){return function(z,G){I(z,G,N)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRenderer=void 0;const c=a(3787),f=a(2550),v=a(2223),y=a(6171),u=a(6052),i=a(4725),r=a(8055),s=a(8460),l=a(844),_=a(2585),x="xterm-dom-renderer-owner-",C="xterm-rows",k="xterm-fg-",p="xterm-bg-",w="xterm-focus",R="xterm-selection";let T=1,M=n.DomRenderer=class extends l.Disposable{constructor(N,I,z,G,H,V,L,A,B,P,U,Z,oe){super(),this._terminal=N,this._document=I,this._element=z,this._screenElement=G,this._viewportElement=H,this._helperContainer=V,this._linkifier2=L,this._charSizeService=B,this._optionsService=P,this._bufferService=U,this._coreBrowserService=Z,this._themeService=oe,this._terminalClass=T++,this._rowElements=[],this._selectionRenderModel=(0,u.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new s.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(C),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(R),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,y.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((K=>this._injectCss(K)))),this._injectCss(this._themeService.colors),this._rowFactory=A.createInstance(c.DomRendererRowFactory,document),this._element.classList.add(x+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((K=>this._handleLinkHover(K)))),this.register(this._linkifier2.onHideLinkUnderline((K=>this._handleLinkLeave(K)))),this.register((0,l.toDisposable)((()=>{this._element.classList.remove(x+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new f.WidthCache(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const N=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*N,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*N),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/N),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/N),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const z of this._rowElements)z.style.width=`${this.dimensions.css.canvas.width}px`,z.style.height=`${this.dimensions.css.cell.height}px`,z.style.lineHeight=`${this.dimensions.css.cell.height}px`,z.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const I=`${this._terminalSelector} .${C} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=I,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(N){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let I=`${this._terminalSelector} .${C} { color: ${N.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;I+=`${this._terminalSelector} .${C} .xterm-dim { color: ${r.color.multiplyOpacity(N.foreground,.5).css};}`,I+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;const z=`blink_underline_${this._terminalClass}`,G=`blink_bar_${this._terminalClass}`,H=`blink_block_${this._terminalClass}`;I+=`@keyframes ${z} { 50% { border-bottom-style: hidden; }}`,I+=`@keyframes ${G} { 50% { box-shadow: none; }}`,I+=`@keyframes ${H} { 0% { background-color: ${N.cursor.css}; color: ${N.cursorAccent.css}; } 50% { background-color: inherit; color: ${N.cursor.css}; }}`,I+=`${this._terminalSelector} .${C}.${w} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${z} 1s step-end infinite;}${this._terminalSelector} .${C}.${w} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${G} 1s step-end infinite;}${this._terminalSelector} .${C}.${w} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${H} 1s step-end infinite;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-block { background-color: ${N.cursor.css}; color: ${N.cursorAccent.css};}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${N.cursor.css} !important; color: ${N.cursorAccent.css} !important;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${N.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${N.cursor.css} inset;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${N.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,I+=`${this._terminalSelector} .${R} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${R} div { position: absolute; background-color: ${N.selectionBackgroundOpaque.css};}${this._terminalSelector} .${R} div { position: absolute; background-color: ${N.selectionInactiveBackgroundOpaque.css};}`;for(const[V,L]of N.ansi.entries())I+=`${this._terminalSelector} .${k}${V} { color: ${L.css}; }${this._terminalSelector} .${k}${V}.xterm-dim { color: ${r.color.multiplyOpacity(L,.5).css}; }${this._terminalSelector} .${p}${V} { background-color: ${L.css}; }`;I+=`${this._terminalSelector} .${k}${v.INVERTED_DEFAULT_COLOR} { color: ${r.color.opaque(N.background).css}; }${this._terminalSelector} .${k}${v.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${r.color.multiplyOpacity(r.color.opaque(N.background),.5).css}; }${this._terminalSelector} .${p}${v.INVERTED_DEFAULT_COLOR} { background-color: ${N.foreground.css}; }`,this._themeStyleElement.textContent=I}_setDefaultSpacing(){const N=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${N}px`,this._rowFactory.defaultSpacing=N}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(N,I){for(let z=this._rowElements.length;z<=I;z++){const G=this._document.createElement("div");this._rowContainer.appendChild(G),this._rowElements.push(G)}for(;this._rowElements.length>I;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(N,I){this._refreshRowElements(N,I),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(w),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(w),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(N,I,z){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(N,I,z),this.renderRows(0,this._bufferService.rows-1),!N||!I)return;this._selectionRenderModel.update(this._terminal,N,I,z);const G=this._selectionRenderModel.viewportStartRow,H=this._selectionRenderModel.viewportEndRow,V=this._selectionRenderModel.viewportCappedStartRow,L=this._selectionRenderModel.viewportCappedEndRow;if(V>=this._bufferService.rows||L<0)return;const A=this._document.createDocumentFragment();if(z){const B=N[0]>I[0];A.appendChild(this._createSelectionElement(V,B?I[0]:N[0],B?N[0]:I[0],L-V+1))}else{const B=G===V?N[0]:0,P=V===H?I[0]:this._bufferService.cols;A.appendChild(this._createSelectionElement(V,B,P));const U=L-V-1;if(A.appendChild(this._createSelectionElement(V+1,0,this._bufferService.cols,U)),V!==L){const Z=H===L?I[0]:this._bufferService.cols;A.appendChild(this._createSelectionElement(L,0,Z))}}this._selectionContainer.appendChild(A)}_createSelectionElement(N,I,z,G=1){const H=this._document.createElement("div"),V=I*this.dimensions.css.cell.width;let L=this.dimensions.css.cell.width*(z-I);return V+L>this.dimensions.css.canvas.width&&(L=this.dimensions.css.canvas.width-V),H.style.height=G*this.dimensions.css.cell.height+"px",H.style.top=N*this.dimensions.css.cell.height+"px",H.style.left=`${V}px`,H.style.width=`${L}px`,H}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const N of this._rowElements)N.replaceChildren()}renderRows(N,I){const z=this._bufferService.buffer,G=z.ybase+z.y,H=Math.min(z.x,this._bufferService.cols-1),V=this._optionsService.rawOptions.cursorBlink,L=this._optionsService.rawOptions.cursorStyle,A=this._optionsService.rawOptions.cursorInactiveStyle;for(let B=N;B<=I;B++){const P=B+z.ydisp,U=this._rowElements[B],Z=z.lines.get(P);if(!U||!Z)break;U.replaceChildren(...this._rowFactory.createRow(Z,P,P===G,L,A,H,V,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${x}${this._terminalClass}`}_handleLinkHover(N){this._setCellUnderline(N.x1,N.x2,N.y1,N.y2,N.cols,!0)}_handleLinkLeave(N){this._setCellUnderline(N.x1,N.x2,N.y1,N.y2,N.cols,!1)}_setCellUnderline(N,I,z,G,H,V){z<0&&(N=0),G<0&&(I=0);const L=this._bufferService.rows-1;z=Math.max(Math.min(z,L),0),G=Math.max(Math.min(G,L),0),H=Math.min(H,this._bufferService.cols);const A=this._bufferService.buffer,B=A.ybase+A.y,P=Math.min(A.x,H-1),U=this._optionsService.rawOptions.cursorBlink,Z=this._optionsService.rawOptions.cursorStyle,oe=this._optionsService.rawOptions.cursorInactiveStyle;for(let K=z;K<=G;++K){const $=K+A.ydisp,D=this._rowElements[K],q=A.lines.get($);if(!D||!q)break;D.replaceChildren(...this._rowFactory.createRow(q,$,$===B,Z,oe,P,U,this.dimensions.css.cell.width,this._widthCache,V?K===z?N:0:-1,V?(K===G?I:H)-1:-1))}}};n.DomRenderer=M=d([h(7,_.IInstantiationService),h(8,i.ICharSizeService),h(9,_.IOptionsService),h(10,_.IBufferService),h(11,i.ICoreBrowserService),h(12,i.IThemeService)],M)},3787:function(b,n,a){var d=this&&this.__decorate||function(C,k,p,w){var R,T=arguments.length,M=T<3?k:w===null?w=Object.getOwnPropertyDescriptor(k,p):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(C,k,p,w);else for(var N=C.length-1;N>=0;N--)(R=C[N])&&(M=(T<3?R(M):T>3?R(k,p,M):R(k,p))||M);return T>3&&M&&Object.defineProperty(k,p,M),M},h=this&&this.__param||function(C,k){return function(p,w){k(p,w,C)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRendererRowFactory=void 0;const c=a(2223),f=a(643),v=a(511),y=a(2585),u=a(8055),i=a(4725),r=a(4269),s=a(6171),l=a(3734);let _=n.DomRendererRowFactory=class{constructor(C,k,p,w,R,T,M){this._document=C,this._characterJoinerService=k,this._optionsService=p,this._coreBrowserService=w,this._coreService=R,this._decorationService=T,this._themeService=M,this._workCell=new v.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(C,k,p){this._selectionStart=C,this._selectionEnd=k,this._columnSelectMode=p}createRow(C,k,p,w,R,T,M,N,I,z,G){const H=[],V=this._characterJoinerService.getJoinedCharacters(k),L=this._themeService.colors;let A,B=C.getNoBgTrimmedLength();p&&B<T+1&&(B=T+1);let P=0,U="",Z=0,oe=0,K=0,$=!1,D=0,q=!1,J=0;const O=[],X=z!==-1&&G!==-1;for(let F=0;F<B;F++){C.loadCell(F,this._workCell);let W=this._workCell.getWidth();if(W===0)continue;let re=!1,ae=F,ee=this._workCell;if(V.length>0&&F===V[0][0]){re=!0;const le=V.shift();ee=new r.JoinedCellData(this._workCell,C.translateToString(!0,le[0],le[1]),le[1]-le[0]),ae=le[1]-1,W=ee.getWidth()}const ce=this._isCellInSelection(F,k),he=p&&F===T,pe=X&&F>=z&&F<=G;let Ne=!1;this._decorationService.forEachDecorationAtCell(F,k,void 0,(le=>{Ne=!0}));let Ue=ee.getChars()||f.WHITESPACE_CELL_CHAR;if(Ue===" "&&(ee.isUnderline()||ee.isOverline())&&(Ue=" "),J=W*N-I.get(Ue,ee.isBold(),ee.isItalic()),A){if(P&&(ce&&q||!ce&&!q&&ee.bg===Z)&&(ce&&q&&L.selectionForeground||ee.fg===oe)&&ee.extended.ext===K&&pe===$&&J===D&&!he&&!re&&!Ne){ee.isInvisible()?U+=f.WHITESPACE_CELL_CHAR:U+=Ue,P++;continue}P&&(A.textContent=U),A=this._document.createElement("span"),P=0,U=""}else A=this._document.createElement("span");if(Z=ee.bg,oe=ee.fg,K=ee.extended.ext,$=pe,D=J,q=ce,re&&T>=F&&T<=ae&&(T=F),!this._coreService.isCursorHidden&&he&&this._coreService.isCursorInitialized){if(O.push("xterm-cursor"),this._coreBrowserService.isFocused)M&&O.push("xterm-cursor-blink"),O.push(w==="bar"?"xterm-cursor-bar":w==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(R)switch(R){case"outline":O.push("xterm-cursor-outline");break;case"block":O.push("xterm-cursor-block");break;case"bar":O.push("xterm-cursor-bar");break;case"underline":O.push("xterm-cursor-underline")}}if(ee.isBold()&&O.push("xterm-bold"),ee.isItalic()&&O.push("xterm-italic"),ee.isDim()&&O.push("xterm-dim"),U=ee.isInvisible()?f.WHITESPACE_CELL_CHAR:ee.getChars()||f.WHITESPACE_CELL_CHAR,ee.isUnderline()&&(O.push(`xterm-underline-${ee.extended.underlineStyle}`),U===" "&&(U=" "),!ee.isUnderlineColorDefault()))if(ee.isUnderlineColorRGB())A.style.textDecorationColor=`rgb(${l.AttributeData.toColorRGB(ee.getUnderlineColor()).join(",")})`;else{let le=ee.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&ee.isBold()&&le<8&&(le+=8),A.style.textDecorationColor=L.ansi[le].css}ee.isOverline()&&(O.push("xterm-overline"),U===" "&&(U=" ")),ee.isStrikethrough()&&O.push("xterm-strikethrough"),pe&&(A.style.textDecoration="underline");let Me=ee.getFgColor(),$e=ee.getFgColorMode(),Le=ee.getBgColor(),qe=ee.getBgColorMode();const ot=!!ee.isInverse();if(ot){const le=Me;Me=Le,Le=le;const Ce=$e;$e=qe,qe=Ce}let Qe,at,Ee,Ze=!1;switch(this._decorationService.forEachDecorationAtCell(F,k,void 0,(le=>{le.options.layer!=="top"&&Ze||(le.backgroundColorRGB&&(qe=50331648,Le=le.backgroundColorRGB.rgba>>8&16777215,Qe=le.backgroundColorRGB),le.foregroundColorRGB&&($e=50331648,Me=le.foregroundColorRGB.rgba>>8&16777215,at=le.foregroundColorRGB),Ze=le.options.layer==="top")})),!Ze&&ce&&(Qe=this._coreBrowserService.isFocused?L.selectionBackgroundOpaque:L.selectionInactiveBackgroundOpaque,Le=Qe.rgba>>8&16777215,qe=50331648,Ze=!0,L.selectionForeground&&($e=50331648,Me=L.selectionForeground.rgba>>8&16777215,at=L.selectionForeground)),Ze&&O.push("xterm-decoration-top"),qe){case 16777216:case 33554432:Ee=L.ansi[Le],O.push(`xterm-bg-${Le}`);break;case 50331648:Ee=u.channels.toColor(Le>>16,Le>>8&255,255&Le),this._addStyle(A,`background-color:#${x((Le>>>0).toString(16),"0",6)}`);break;default:ot?(Ee=L.foreground,O.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):Ee=L.background}switch(Qe||ee.isDim()&&(Qe=u.color.multiplyOpacity(Ee,.5)),$e){case 16777216:case 33554432:ee.isBold()&&Me<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Me+=8),this._applyMinimumContrast(A,Ee,L.ansi[Me],ee,Qe,void 0)||O.push(`xterm-fg-${Me}`);break;case 50331648:const le=u.channels.toColor(Me>>16&255,Me>>8&255,255&Me);this._applyMinimumContrast(A,Ee,le,ee,Qe,at)||this._addStyle(A,`color:#${x(Me.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(A,Ee,L.foreground,ee,Qe,at)||ot&&O.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}O.length&&(A.className=O.join(" "),O.length=0),he||re||Ne?A.textContent=U:P++,J!==this.defaultSpacing&&(A.style.letterSpacing=`${J}px`),H.push(A),F=ae}return A&&P&&(A.textContent=U),H}_applyMinimumContrast(C,k,p,w,R,T){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,s.treatGlyphAsBackgroundColor)(w.getCode()))return!1;const M=this._getContrastCache(w);let N;if(R||T||(N=M.getColor(k.rgba,p.rgba)),N===void 0){const I=this._optionsService.rawOptions.minimumContrastRatio/(w.isDim()?2:1);N=u.color.ensureContrastRatio(R||k,T||p,I),M.setColor((R||k).rgba,(T||p).rgba,N??null)}return!!N&&(this._addStyle(C,`color:${N.css}`),!0)}_getContrastCache(C){return C.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(C,k){C.setAttribute("style",`${C.getAttribute("style")||""}${k};`)}_isCellInSelection(C,k){const p=this._selectionStart,w=this._selectionEnd;return!(!p||!w)&&(this._columnSelectMode?p[0]<=w[0]?C>=p[0]&&k>=p[1]&&C<w[0]&&k<=w[1]:C<p[0]&&k>=p[1]&&C>=w[0]&&k<=w[1]:k>p[1]&&k<w[1]||p[1]===w[1]&&k===p[1]&&C>=p[0]&&C<w[0]||p[1]<w[1]&&k===w[1]&&C<w[0]||p[1]<w[1]&&k===p[1]&&C>=p[0])}};function x(C,k,p){for(;C.length<p;)C=k+C;return C}n.DomRendererRowFactory=_=d([h(1,i.ICharacterJoinerService),h(2,y.IOptionsService),h(3,i.ICoreBrowserService),h(4,y.ICoreService),h(5,y.IDecorationService),h(6,i.IThemeService)],_)},2550:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WidthCache=void 0,n.WidthCache=class{constructor(a,d){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=a.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const h=a.createElement("span");h.classList.add("xterm-char-measure-element");const c=a.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold";const f=a.createElement("span");f.classList.add("xterm-char-measure-element"),f.style.fontStyle="italic";const v=a.createElement("span");v.classList.add("xterm-char-measure-element"),v.style.fontWeight="bold",v.style.fontStyle="italic",this._measureElements=[h,c,f,v],this._container.appendChild(h),this._container.appendChild(c),this._container.appendChild(f),this._container.appendChild(v),d.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(a,d,h,c){a===this._font&&d===this._fontSize&&h===this._weight&&c===this._weightBold||(this._font=a,this._fontSize=d,this._weight=h,this._weightBold=c,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${h}`,this._measureElements[1].style.fontWeight=`${c}`,this._measureElements[2].style.fontWeight=`${h}`,this._measureElements[3].style.fontWeight=`${c}`,this.clear())}get(a,d,h){let c=0;if(!d&&!h&&a.length===1&&(c=a.charCodeAt(0))<256){if(this._flat[c]!==-9999)return this._flat[c];const y=this._measure(a,0);return y>0&&(this._flat[c]=y),y}let f=a;d&&(f+="B"),h&&(f+="I");let v=this._holey.get(f);if(v===void 0){let y=0;d&&(y|=1),h&&(y|=2),v=this._measure(a,y),v>0&&this._holey.set(f,v)}return v}_measure(a,d){const h=this._measureElements[d];return h.textContent=a.repeat(32),h.offsetWidth/32}}},2223:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TEXT_BASELINE=n.DIM_OPACITY=n.INVERTED_DEFAULT_COLOR=void 0;const d=a(6114);n.INVERTED_DEFAULT_COLOR=257,n.DIM_OPACITY=.5,n.TEXT_BASELINE=d.isFirefox||d.isLegacyEdge?"bottom":"ideographic"},6171:(b,n)=>{function a(h){return 57508<=h&&h<=57558}function d(h){return h>=128512&&h<=128591||h>=127744&&h<=128511||h>=128640&&h<=128767||h>=9728&&h<=9983||h>=9984&&h<=10175||h>=65024&&h<=65039||h>=129280&&h<=129535||h>=127462&&h<=127487}Object.defineProperty(n,"__esModule",{value:!0}),n.computeNextVariantOffset=n.createRenderDimensions=n.treatGlyphAsBackgroundColor=n.allowRescaling=n.isEmoji=n.isRestrictedPowerlineGlyph=n.isPowerlineGlyph=n.throwIfFalsy=void 0,n.throwIfFalsy=function(h){if(!h)throw new Error("value must not be falsy");return h},n.isPowerlineGlyph=a,n.isRestrictedPowerlineGlyph=function(h){return 57520<=h&&h<=57527},n.isEmoji=d,n.allowRescaling=function(h,c,f,v){return c===1&&f>Math.ceil(1.5*v)&&h!==void 0&&h>255&&!d(h)&&!a(h)&&!(function(y){return 57344<=y&&y<=63743})(h)},n.treatGlyphAsBackgroundColor=function(h){return a(h)||(function(c){return 9472<=c&&c<=9631})(h)},n.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},n.computeNextVariantOffset=function(h,c,f=0){return(h-(2*Math.round(c)-f))%(2*Math.round(c))}},6052:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createSelectionRenderModel=void 0;class a{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(h,c,f,v=!1){if(this.selectionStart=c,this.selectionEnd=f,!c||!f||c[0]===f[0]&&c[1]===f[1])return void this.clear();const y=h.buffers.active.ydisp,u=c[1]-y,i=f[1]-y,r=Math.max(u,0),s=Math.min(i,h.rows-1);r>=h.rows||s<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=v,this.viewportStartRow=u,this.viewportEndRow=i,this.viewportCappedStartRow=r,this.viewportCappedEndRow=s,this.startCol=c[0],this.endCol=f[0])}isCellSelected(h,c,f){return!!this.hasSelection&&(f-=h.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?c>=this.startCol&&f>=this.viewportCappedStartRow&&c<this.endCol&&f<=this.viewportCappedEndRow:c<this.startCol&&f>=this.viewportCappedStartRow&&c>=this.endCol&&f<=this.viewportCappedEndRow:f>this.viewportStartRow&&f<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&f===this.viewportStartRow&&c>=this.startCol&&c<this.endCol||this.viewportStartRow<this.viewportEndRow&&f===this.viewportEndRow&&c<this.endCol||this.viewportStartRow<this.viewportEndRow&&f===this.viewportStartRow&&c>=this.startCol)}}n.createSelectionRenderModel=function(){return new a}},456:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionModel=void 0,n.SelectionModel=class{constructor(a){this._bufferService=a,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const a=this.selectionStart[0]+this.selectionStartLength;return a>this._bufferService.cols?a%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(a/this._bufferService.cols)-1]:[a%this._bufferService.cols,this.selectionStart[1]+Math.floor(a/this._bufferService.cols)]:[a,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const a=this.selectionStart[0]+this.selectionStartLength;return a>this._bufferService.cols?[a%this._bufferService.cols,this.selectionStart[1]+Math.floor(a/this._bufferService.cols)]:[Math.max(a,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const a=this.selectionStart,d=this.selectionEnd;return!(!a||!d)&&(a[1]>d[1]||a[1]===d[1]&&a[0]>d[0])}handleTrim(a){return this.selectionStart&&(this.selectionStart[1]-=a),this.selectionEnd&&(this.selectionEnd[1]-=a),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(b,n,a){var d=this&&this.__decorate||function(s,l,_,x){var C,k=arguments.length,p=k<3?l:x===null?x=Object.getOwnPropertyDescriptor(l,_):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")p=Reflect.decorate(s,l,_,x);else for(var w=s.length-1;w>=0;w--)(C=s[w])&&(p=(k<3?C(p):k>3?C(l,_,p):C(l,_))||p);return k>3&&p&&Object.defineProperty(l,_,p),p},h=this&&this.__param||function(s,l){return function(_,x){l(_,x,s)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharSizeService=void 0;const c=a(2585),f=a(8460),v=a(844);let y=n.CharSizeService=class extends v.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(s,l,_){super(),this._optionsService=_,this.width=0,this.height=0,this._onCharSizeChange=this.register(new f.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new r(this._optionsService))}catch{this._measureStrategy=this.register(new i(s,l,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const s=this._measureStrategy.measure();s.width===this.width&&s.height===this.height||(this.width=s.width,this.height=s.height,this._onCharSizeChange.fire())}};n.CharSizeService=y=d([h(2,c.IOptionsService)],y);class u extends v.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(l,_){l!==void 0&&l>0&&_!==void 0&&_>0&&(this._result.width=l,this._result.height=_)}}class i extends u{constructor(l,_,x){super(),this._document=l,this._parentElement=_,this._optionsService=x,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}}class r extends u{constructor(l){super(),this._optionsService=l,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");const _=this._ctx.measureText("W");if(!("width"in _&&"fontBoundingBoxAscent"in _&&"fontBoundingBoxDescent"in _))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;const l=this._ctx.measureText("W");return this._validateAndSet(l.width,l.fontBoundingBoxAscent+l.fontBoundingBoxDescent),this._result}}},4269:function(b,n,a){var d=this&&this.__decorate||function(r,s,l,_){var x,C=arguments.length,k=C<3?s:_===null?_=Object.getOwnPropertyDescriptor(s,l):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(r,s,l,_);else for(var p=r.length-1;p>=0;p--)(x=r[p])&&(k=(C<3?x(k):C>3?x(s,l,k):x(s,l))||k);return C>3&&k&&Object.defineProperty(s,l,k),k},h=this&&this.__param||function(r,s){return function(l,_){s(l,_,r)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharacterJoinerService=n.JoinedCellData=void 0;const c=a(3734),f=a(643),v=a(511),y=a(2585);class u extends c.AttributeData{constructor(s,l,_){super(),this.content=0,this.combinedData="",this.fg=s.fg,this.bg=s.bg,this.combinedData=l,this._width=_}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(s){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.JoinedCellData=u;let i=n.CharacterJoinerService=class gi{constructor(s){this._bufferService=s,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new v.CellData}register(s){const l={id:this._nextCharacterJoinerId++,handler:s};return this._characterJoiners.push(l),l.id}deregister(s){for(let l=0;l<this._characterJoiners.length;l++)if(this._characterJoiners[l].id===s)return this._characterJoiners.splice(l,1),!0;return!1}getJoinedCharacters(s){if(this._characterJoiners.length===0)return[];const l=this._bufferService.buffer.lines.get(s);if(!l||l.length===0)return[];const _=[],x=l.translateToString(!0);let C=0,k=0,p=0,w=l.getFg(0),R=l.getBg(0);for(let T=0;T<l.getTrimmedLength();T++)if(l.loadCell(T,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==w||this._workCell.bg!==R){if(T-C>1){const M=this._getJoinedRanges(x,p,k,l,C);for(let N=0;N<M.length;N++)_.push(M[N])}C=T,p=k,w=this._workCell.fg,R=this._workCell.bg}k+=this._workCell.getChars().length||f.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-C>1){const T=this._getJoinedRanges(x,p,k,l,C);for(let M=0;M<T.length;M++)_.push(T[M])}return _}_getJoinedRanges(s,l,_,x,C){const k=s.substring(l,_);let p=[];try{p=this._characterJoiners[0].handler(k)}catch(w){console.error(w)}for(let w=1;w<this._characterJoiners.length;w++)try{const R=this._characterJoiners[w].handler(k);for(let T=0;T<R.length;T++)gi._mergeRanges(p,R[T])}catch(R){console.error(R)}return this._stringRangesToCellRanges(p,x,C),p}_stringRangesToCellRanges(s,l,_){let x=0,C=!1,k=0,p=s[x];if(p){for(let w=_;w<this._bufferService.cols;w++){const R=l.getWidth(w),T=l.getString(w).length||f.WHITESPACE_CELL_CHAR.length;if(R!==0){if(!C&&p[0]<=k&&(p[0]=w,C=!0),p[1]<=k){if(p[1]=w,p=s[++x],!p)break;p[0]<=k?(p[0]=w,C=!0):C=!1}k+=T}}p&&(p[1]=this._bufferService.cols)}}static _mergeRanges(s,l){let _=!1;for(let x=0;x<s.length;x++){const C=s[x];if(_){if(l[1]<=C[0])return s[x-1][1]=l[1],s;if(l[1]<=C[1])return s[x-1][1]=Math.max(l[1],C[1]),s.splice(x,1),s;s.splice(x,1),x--}else{if(l[1]<=C[0])return s.splice(x,0,l),s;if(l[1]<=C[1])return C[0]=Math.min(l[0],C[0]),s;l[0]<C[1]&&(C[0]=Math.min(l[0],C[0]),_=!0)}}return _?s[s.length-1][1]=l[1]:s.push(l),s}};n.CharacterJoinerService=i=d([h(0,y.IBufferService)],i)},5114:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreBrowserService=void 0;const d=a(844),h=a(8460),c=a(3656);class f extends d.Disposable{constructor(u,i,r){super(),this._textarea=u,this._window=i,this.mainDocument=r,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new v(this._window),this._onDprChange=this.register(new h.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new h.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((s=>this._screenDprMonitor.setWindow(s)))),this.register((0,h.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get window(){return this._window}set window(u){this._window!==u&&(this._window=u,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}n.CoreBrowserService=f;class v extends d.Disposable{constructor(u){super(),this._parentWindow=u,this._windowResizeListener=this.register(new d.MutableDisposable),this._onDprChange=this.register(new h.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,d.toDisposable)((()=>this.clearListener())))}setWindow(u){this._parentWindow=u,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,c.addDisposableDomListener)(this._parentWindow,"resize",(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var u;this._outerListener&&((u=this._resolutionMediaMatchList)==null||u.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}}},779:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.LinkProviderService=void 0;const d=a(844);class h extends d.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,d.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(f){return this.linkProviders.push(f),{dispose:()=>{const v=this.linkProviders.indexOf(f);v!==-1&&this.linkProviders.splice(v,1)}}}}n.LinkProviderService=h},8934:function(b,n,a){var d=this&&this.__decorate||function(y,u,i,r){var s,l=arguments.length,_=l<3?u:r===null?r=Object.getOwnPropertyDescriptor(u,i):r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(y,u,i,r);else for(var x=y.length-1;x>=0;x--)(s=y[x])&&(_=(l<3?s(_):l>3?s(u,i,_):s(u,i))||_);return l>3&&_&&Object.defineProperty(u,i,_),_},h=this&&this.__param||function(y,u){return function(i,r){u(i,r,y)}};Object.defineProperty(n,"__esModule",{value:!0}),n.MouseService=void 0;const c=a(4725),f=a(9806);let v=n.MouseService=class{constructor(y,u){this._renderService=y,this._charSizeService=u}getCoords(y,u,i,r,s){return(0,f.getCoords)(window,y,u,i,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,s)}getMouseReportCoords(y,u){const i=(0,f.getCoordsRelativeToElement)(window,y,u);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};n.MouseService=v=d([h(0,c.IRenderService),h(1,c.ICharSizeService)],v)},3230:function(b,n,a){var d=this&&this.__decorate||function(s,l,_,x){var C,k=arguments.length,p=k<3?l:x===null?x=Object.getOwnPropertyDescriptor(l,_):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")p=Reflect.decorate(s,l,_,x);else for(var w=s.length-1;w>=0;w--)(C=s[w])&&(p=(k<3?C(p):k>3?C(l,_,p):C(l,_))||p);return k>3&&p&&Object.defineProperty(l,_,p),p},h=this&&this.__param||function(s,l){return function(_,x){l(_,x,s)}};Object.defineProperty(n,"__esModule",{value:!0}),n.RenderService=void 0;const c=a(6193),f=a(4725),v=a(8460),y=a(844),u=a(7226),i=a(2585);let r=n.RenderService=class extends y.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(s,l,_,x,C,k,p,w){super(),this._rowCount=s,this._charSizeService=x,this._renderer=this.register(new y.MutableDisposable),this._pausedResizeTask=new u.DebouncedIdleTask,this._observerDisposable=this.register(new y.MutableDisposable),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new v.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new v.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new v.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new v.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new c.RenderDebouncer(((R,T)=>this._renderRows(R,T)),p),this.register(this._renderDebouncer),this.register(p.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(k.onResize((()=>this._fullRefresh()))),this.register(k.buffers.onBufferActivate((()=>{var R;return(R=this._renderer.value)==null?void 0:R.clear()}))),this.register(_.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(C.onDecorationRegistered((()=>this._fullRefresh()))),this.register(C.onDecorationRemoved((()=>this._fullRefresh()))),this.register(_.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(k.cols,k.rows),this._fullRefresh()}))),this.register(_.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(k.buffer.y,k.buffer.y,!0)))),this.register(w.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(p.window,l),this.register(p.onWindowChange((R=>this._registerIntersectionObserver(R,l))))}_registerIntersectionObserver(s,l){if("IntersectionObserver"in s){const _=new s.IntersectionObserver((x=>this._handleIntersectionChange(x[x.length-1])),{threshold:0});_.observe(l),this._observerDisposable.value=(0,y.toDisposable)((()=>_.disconnect()))}}_handleIntersectionChange(s){this._isPaused=s.isIntersecting===void 0?s.intersectionRatio===0:!s.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(s,l,_=!1){this._isPaused?this._needsFullRefresh=!0:(_||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(s,l,this._rowCount))}_renderRows(s,l){this._renderer.value&&(s=Math.min(s,this._rowCount-1),l=Math.min(l,this._rowCount-1),this._renderer.value.renderRows(s,l),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:s,end:l}),this._onRender.fire({start:s,end:l}),this._isNextRenderRedrawOnly=!0)}resize(s,l){this._rowCount=l,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(s){this._renderer.value=s,this._renderer.value&&(this._renderer.value.onRequestRedraw((l=>this.refreshRows(l.start,l.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(s){return this._renderDebouncer.addRefreshCallback(s)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var s,l;this._renderer.value&&((l=(s=this._renderer.value).clearTextureAtlas)==null||l.call(s),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(s,l){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>{var _;return(_=this._renderer.value)==null?void 0:_.handleResize(s,l)})):this._renderer.value.handleResize(s,l),this._fullRefresh())}handleCharSizeChanged(){var s;(s=this._renderer.value)==null||s.handleCharSizeChanged()}handleBlur(){var s;(s=this._renderer.value)==null||s.handleBlur()}handleFocus(){var s;(s=this._renderer.value)==null||s.handleFocus()}handleSelectionChanged(s,l,_){var x;this._selectionState.start=s,this._selectionState.end=l,this._selectionState.columnSelectMode=_,(x=this._renderer.value)==null||x.handleSelectionChanged(s,l,_)}handleCursorMove(){var s;(s=this._renderer.value)==null||s.handleCursorMove()}clear(){var s;(s=this._renderer.value)==null||s.clear()}};n.RenderService=r=d([h(2,i.IOptionsService),h(3,f.ICharSizeService),h(4,i.IDecorationService),h(5,i.IBufferService),h(6,f.ICoreBrowserService),h(7,f.IThemeService)],r)},9312:function(b,n,a){var d=this&&this.__decorate||function(p,w,R,T){var M,N=arguments.length,I=N<3?w:T===null?T=Object.getOwnPropertyDescriptor(w,R):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(p,w,R,T);else for(var z=p.length-1;z>=0;z--)(M=p[z])&&(I=(N<3?M(I):N>3?M(w,R,I):M(w,R))||I);return N>3&&I&&Object.defineProperty(w,R,I),I},h=this&&this.__param||function(p,w){return function(R,T){w(R,T,p)}};Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionService=void 0;const c=a(9806),f=a(9504),v=a(456),y=a(4725),u=a(8460),i=a(844),r=a(6114),s=a(4841),l=a(511),_=a(2585),x=" ",C=new RegExp(x,"g");let k=n.SelectionService=class extends i.Disposable{constructor(p,w,R,T,M,N,I,z,G){super(),this._element=p,this._screenElement=w,this._linkifier=R,this._bufferService=T,this._coreService=M,this._mouseService=N,this._optionsService=I,this._renderService=z,this._coreBrowserService=G,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new l.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new u.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new u.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new u.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new u.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=H=>this._handleMouseMove(H),this._mouseUpListener=H=>this._handleMouseUp(H),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((H=>this._handleTrim(H))),this.register(this._bufferService.buffers.onBufferActivate((H=>this._handleBufferActivate(H)))),this.enable(),this._model=new v.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,i.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const p=this._model.finalSelectionStart,w=this._model.finalSelectionEnd;return!(!p||!w||p[0]===w[0]&&p[1]===w[1])}get selectionText(){const p=this._model.finalSelectionStart,w=this._model.finalSelectionEnd;if(!p||!w)return"";const R=this._bufferService.buffer,T=[];if(this._activeSelectionMode===3){if(p[0]===w[0])return"";const M=p[0]<w[0]?p[0]:w[0],N=p[0]<w[0]?w[0]:p[0];for(let I=p[1];I<=w[1];I++){const z=R.translateBufferLineToString(I,!0,M,N);T.push(z)}}else{const M=p[1]===w[1]?w[0]:void 0;T.push(R.translateBufferLineToString(p[1],!0,p[0],M));for(let N=p[1]+1;N<=w[1]-1;N++){const I=R.lines.get(N),z=R.translateBufferLineToString(N,!0);I!=null&&I.isWrapped?T[T.length-1]+=z:T.push(z)}if(p[1]!==w[1]){const N=R.lines.get(w[1]),I=R.translateBufferLineToString(w[1],!0,0,w[0]);N&&N.isWrapped?T[T.length-1]+=I:T.push(I)}}return T.map((M=>M.replace(C," "))).join(r.isWindows?`\r
169
+ `:`
170
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(p){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),r.isLinux&&p&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(p){const w=this._getMouseBufferCoords(p),R=this._model.finalSelectionStart,T=this._model.finalSelectionEnd;return!!(R&&T&&w)&&this._areCoordsInSelection(w,R,T)}isCellInSelection(p,w){const R=this._model.finalSelectionStart,T=this._model.finalSelectionEnd;return!(!R||!T)&&this._areCoordsInSelection([p,w],R,T)}_areCoordsInSelection(p,w,R){return p[1]>w[1]&&p[1]<R[1]||w[1]===R[1]&&p[1]===w[1]&&p[0]>=w[0]&&p[0]<R[0]||w[1]<R[1]&&p[1]===R[1]&&p[0]<R[0]||w[1]<R[1]&&p[1]===w[1]&&p[0]>=w[0]}_selectWordAtCursor(p,w){var M,N;const R=(N=(M=this._linkifier.currentLink)==null?void 0:M.link)==null?void 0:N.range;if(R)return this._model.selectionStart=[R.start.x-1,R.start.y-1],this._model.selectionStartLength=(0,s.getRangeLength)(R,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const T=this._getMouseBufferCoords(p);return!!T&&(this._selectWordAt(T,w),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(p,w){this._model.clearSelection(),p=Math.max(p,0),w=Math.min(w,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,p],this._model.selectionEnd=[this._bufferService.cols,w],this.refresh(),this._onSelectionChange.fire()}_handleTrim(p){this._model.handleTrim(p)&&this.refresh()}_getMouseBufferCoords(p){const w=this._mouseService.getCoords(p,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(w)return w[0]--,w[1]--,w[1]+=this._bufferService.buffer.ydisp,w}_getMouseEventScrollAmount(p){let w=(0,c.getCoordsRelativeToElement)(this._coreBrowserService.window,p,this._screenElement)[1];const R=this._renderService.dimensions.css.canvas.height;return w>=0&&w<=R?0:(w>R&&(w-=R),w=Math.min(Math.max(w,-50),50),w/=50,w/Math.abs(w)+Math.round(14*w))}shouldForceSelection(p){return r.isMac?p.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:p.shiftKey}handleMouseDown(p){if(this._mouseDownTimeStamp=p.timeStamp,(p.button!==2||!this.hasSelection)&&p.button===0){if(!this._enabled){if(!this.shouldForceSelection(p))return;p.stopPropagation()}p.preventDefault(),this._dragScrollAmount=0,this._enabled&&p.shiftKey?this._handleIncrementalClick(p):p.detail===1?this._handleSingleClick(p):p.detail===2?this._handleDoubleClick(p):p.detail===3&&this._handleTripleClick(p),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(p){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(p))}_handleSingleClick(p){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(p)?3:0,this._model.selectionStart=this._getMouseBufferCoords(p),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const w=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);w&&w.length!==this._model.selectionStart[0]&&w.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(p){this._selectWordAtCursor(p,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(p){const w=this._getMouseBufferCoords(p);w&&(this._activeSelectionMode=2,this._selectLineAt(w[1]))}shouldColumnSelect(p){return p.altKey&&!(r.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(p){if(p.stopImmediatePropagation(),!this._model.selectionStart)return;const w=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(p),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(p),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const R=this._bufferService.buffer;if(this._model.selectionEnd[1]<R.lines.length){const T=R.lines.get(this._model.selectionEnd[1]);T&&T.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}w&&w[0]===this._model.selectionEnd[0]&&w[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const p=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(p.ydisp+this._bufferService.rows,p.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=p.ydisp),this.refresh()}}_handleMouseUp(p){const w=p.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&w<500&&p.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const R=this._mouseService.getCoords(p,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(R&&R[0]!==void 0&&R[1]!==void 0){const T=(0,f.moveToCellSequence)(R[0]-1,R[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(T,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const p=this._model.finalSelectionStart,w=this._model.finalSelectionEnd,R=!(!p||!w||p[0]===w[0]&&p[1]===w[1]);R?p&&w&&(this._oldSelectionStart&&this._oldSelectionEnd&&p[0]===this._oldSelectionStart[0]&&p[1]===this._oldSelectionStart[1]&&w[0]===this._oldSelectionEnd[0]&&w[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(p,w,R)):this._oldHasSelection&&this._fireOnSelectionChange(p,w,R)}_fireOnSelectionChange(p,w,R){this._oldSelectionStart=p,this._oldSelectionEnd=w,this._oldHasSelection=R,this._onSelectionChange.fire()}_handleBufferActivate(p){this.clearSelection(),this._trimListener.dispose(),this._trimListener=p.activeBuffer.lines.onTrim((w=>this._handleTrim(w)))}_convertViewportColToCharacterIndex(p,w){let R=w;for(let T=0;w>=T;T++){const M=p.loadCell(T,this._workCell).getChars().length;this._workCell.getWidth()===0?R--:M>1&&w!==T&&(R+=M-1)}return R}setSelection(p,w,R){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[p,w],this._model.selectionStartLength=R,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(p){this._isClickInSelection(p)||(this._selectWordAtCursor(p,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(p,w,R=!0,T=!0){if(p[0]>=this._bufferService.cols)return;const M=this._bufferService.buffer,N=M.lines.get(p[1]);if(!N)return;const I=M.translateBufferLineToString(p[1],!1);let z=this._convertViewportColToCharacterIndex(N,p[0]),G=z;const H=p[0]-z;let V=0,L=0,A=0,B=0;if(I.charAt(z)===" "){for(;z>0&&I.charAt(z-1)===" ";)z--;for(;G<I.length&&I.charAt(G+1)===" ";)G++}else{let Z=p[0],oe=p[0];N.getWidth(Z)===0&&(V++,Z--),N.getWidth(oe)===2&&(L++,oe++);const K=N.getString(oe).length;for(K>1&&(B+=K-1,G+=K-1);Z>0&&z>0&&!this._isCharWordSeparator(N.loadCell(Z-1,this._workCell));){N.loadCell(Z-1,this._workCell);const $=this._workCell.getChars().length;this._workCell.getWidth()===0?(V++,Z--):$>1&&(A+=$-1,z-=$-1),z--,Z--}for(;oe<N.length&&G+1<I.length&&!this._isCharWordSeparator(N.loadCell(oe+1,this._workCell));){N.loadCell(oe+1,this._workCell);const $=this._workCell.getChars().length;this._workCell.getWidth()===2?(L++,oe++):$>1&&(B+=$-1,G+=$-1),G++,oe++}}G++;let P=z+H-V+A,U=Math.min(this._bufferService.cols,G-z+V+L-A-B);if(w||I.slice(z,G).trim()!==""){if(R&&P===0&&N.getCodePoint(0)!==32){const Z=M.lines.get(p[1]-1);if(Z&&N.isWrapped&&Z.getCodePoint(this._bufferService.cols-1)!==32){const oe=this._getWordAt([this._bufferService.cols-1,p[1]-1],!1,!0,!1);if(oe){const K=this._bufferService.cols-oe.start;P-=K,U+=K}}}if(T&&P+U===this._bufferService.cols&&N.getCodePoint(this._bufferService.cols-1)!==32){const Z=M.lines.get(p[1]+1);if(Z!=null&&Z.isWrapped&&Z.getCodePoint(0)!==32){const oe=this._getWordAt([0,p[1]+1],!1,!1,!0);oe&&(U+=oe.length)}}return{start:P,length:U}}}_selectWordAt(p,w){const R=this._getWordAt(p,w);if(R){for(;R.start<0;)R.start+=this._bufferService.cols,p[1]--;this._model.selectionStart=[R.start,p[1]],this._model.selectionStartLength=R.length}}_selectToWordAt(p){const w=this._getWordAt(p,!0);if(w){let R=p[1];for(;w.start<0;)w.start+=this._bufferService.cols,R--;if(!this._model.areSelectionValuesReversed())for(;w.start+w.length>this._bufferService.cols;)w.length-=this._bufferService.cols,R++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?w.start:w.start+w.length,R]}}_isCharWordSeparator(p){return p.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(p.getChars())>=0}_selectLineAt(p){const w=this._bufferService.buffer.getWrappedRangeForLine(p),R={start:{x:0,y:w.first},end:{x:this._bufferService.cols-1,y:w.last}};this._model.selectionStart=[0,w.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,s.getRangeLength)(R,this._bufferService.cols)}};n.SelectionService=k=d([h(3,_.IBufferService),h(4,_.ICoreService),h(5,y.IMouseService),h(6,_.IOptionsService),h(7,y.IRenderService),h(8,y.ICoreBrowserService)],k)},4725:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ILinkProviderService=n.IThemeService=n.ICharacterJoinerService=n.ISelectionService=n.IRenderService=n.IMouseService=n.ICoreBrowserService=n.ICharSizeService=void 0;const d=a(8343);n.ICharSizeService=(0,d.createDecorator)("CharSizeService"),n.ICoreBrowserService=(0,d.createDecorator)("CoreBrowserService"),n.IMouseService=(0,d.createDecorator)("MouseService"),n.IRenderService=(0,d.createDecorator)("RenderService"),n.ISelectionService=(0,d.createDecorator)("SelectionService"),n.ICharacterJoinerService=(0,d.createDecorator)("CharacterJoinerService"),n.IThemeService=(0,d.createDecorator)("ThemeService"),n.ILinkProviderService=(0,d.createDecorator)("LinkProviderService")},6731:function(b,n,a){var d=this&&this.__decorate||function(k,p,w,R){var T,M=arguments.length,N=M<3?p:R===null?R=Object.getOwnPropertyDescriptor(p,w):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(k,p,w,R);else for(var I=k.length-1;I>=0;I--)(T=k[I])&&(N=(M<3?T(N):M>3?T(p,w,N):T(p,w))||N);return M>3&&N&&Object.defineProperty(p,w,N),N},h=this&&this.__param||function(k,p){return function(w,R){p(w,R,k)}};Object.defineProperty(n,"__esModule",{value:!0}),n.ThemeService=n.DEFAULT_ANSI_COLORS=void 0;const c=a(7239),f=a(8055),v=a(8460),y=a(844),u=a(2585),i=f.css.toColor("#ffffff"),r=f.css.toColor("#000000"),s=f.css.toColor("#ffffff"),l=f.css.toColor("#000000"),_={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};n.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const k=[f.css.toColor("#2e3436"),f.css.toColor("#cc0000"),f.css.toColor("#4e9a06"),f.css.toColor("#c4a000"),f.css.toColor("#3465a4"),f.css.toColor("#75507b"),f.css.toColor("#06989a"),f.css.toColor("#d3d7cf"),f.css.toColor("#555753"),f.css.toColor("#ef2929"),f.css.toColor("#8ae234"),f.css.toColor("#fce94f"),f.css.toColor("#729fcf"),f.css.toColor("#ad7fa8"),f.css.toColor("#34e2e2"),f.css.toColor("#eeeeec")],p=[0,95,135,175,215,255];for(let w=0;w<216;w++){const R=p[w/36%6|0],T=p[w/6%6|0],M=p[w%6];k.push({css:f.channels.toCss(R,T,M),rgba:f.channels.toRgba(R,T,M)})}for(let w=0;w<24;w++){const R=8+10*w;k.push({css:f.channels.toCss(R,R,R),rgba:f.channels.toRgba(R,R,R)})}return k})());let x=n.ThemeService=class extends y.Disposable{get colors(){return this._colors}constructor(k){super(),this._optionsService=k,this._contrastCache=new c.ColorContrastCache,this._halfContrastCache=new c.ColorContrastCache,this._onChangeColors=this.register(new v.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:i,background:r,cursor:s,cursorAccent:l,selectionForeground:void 0,selectionBackgroundTransparent:_,selectionBackgroundOpaque:f.color.blend(r,_),selectionInactiveBackgroundTransparent:_,selectionInactiveBackgroundOpaque:f.color.blend(r,_),ansi:n.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(k={}){const p=this._colors;if(p.foreground=C(k.foreground,i),p.background=C(k.background,r),p.cursor=C(k.cursor,s),p.cursorAccent=C(k.cursorAccent,l),p.selectionBackgroundTransparent=C(k.selectionBackground,_),p.selectionBackgroundOpaque=f.color.blend(p.background,p.selectionBackgroundTransparent),p.selectionInactiveBackgroundTransparent=C(k.selectionInactiveBackground,p.selectionBackgroundTransparent),p.selectionInactiveBackgroundOpaque=f.color.blend(p.background,p.selectionInactiveBackgroundTransparent),p.selectionForeground=k.selectionForeground?C(k.selectionForeground,f.NULL_COLOR):void 0,p.selectionForeground===f.NULL_COLOR&&(p.selectionForeground=void 0),f.color.isOpaque(p.selectionBackgroundTransparent)&&(p.selectionBackgroundTransparent=f.color.opacity(p.selectionBackgroundTransparent,.3)),f.color.isOpaque(p.selectionInactiveBackgroundTransparent)&&(p.selectionInactiveBackgroundTransparent=f.color.opacity(p.selectionInactiveBackgroundTransparent,.3)),p.ansi=n.DEFAULT_ANSI_COLORS.slice(),p.ansi[0]=C(k.black,n.DEFAULT_ANSI_COLORS[0]),p.ansi[1]=C(k.red,n.DEFAULT_ANSI_COLORS[1]),p.ansi[2]=C(k.green,n.DEFAULT_ANSI_COLORS[2]),p.ansi[3]=C(k.yellow,n.DEFAULT_ANSI_COLORS[3]),p.ansi[4]=C(k.blue,n.DEFAULT_ANSI_COLORS[4]),p.ansi[5]=C(k.magenta,n.DEFAULT_ANSI_COLORS[5]),p.ansi[6]=C(k.cyan,n.DEFAULT_ANSI_COLORS[6]),p.ansi[7]=C(k.white,n.DEFAULT_ANSI_COLORS[7]),p.ansi[8]=C(k.brightBlack,n.DEFAULT_ANSI_COLORS[8]),p.ansi[9]=C(k.brightRed,n.DEFAULT_ANSI_COLORS[9]),p.ansi[10]=C(k.brightGreen,n.DEFAULT_ANSI_COLORS[10]),p.ansi[11]=C(k.brightYellow,n.DEFAULT_ANSI_COLORS[11]),p.ansi[12]=C(k.brightBlue,n.DEFAULT_ANSI_COLORS[12]),p.ansi[13]=C(k.brightMagenta,n.DEFAULT_ANSI_COLORS[13]),p.ansi[14]=C(k.brightCyan,n.DEFAULT_ANSI_COLORS[14]),p.ansi[15]=C(k.brightWhite,n.DEFAULT_ANSI_COLORS[15]),k.extendedAnsi){const w=Math.min(p.ansi.length-16,k.extendedAnsi.length);for(let R=0;R<w;R++)p.ansi[R+16]=C(k.extendedAnsi[R],n.DEFAULT_ANSI_COLORS[R+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(k){this._restoreColor(k),this._onChangeColors.fire(this.colors)}_restoreColor(k){if(k!==void 0)switch(k){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[k]=this._restoreColors.ansi[k]}else for(let p=0;p<this._restoreColors.ansi.length;++p)this._colors.ansi[p]=this._restoreColors.ansi[p]}modifyColors(k){k(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function C(k,p){if(k!==void 0)try{return f.css.toColor(k)}catch{}return p}n.ThemeService=x=d([h(0,u.IOptionsService)],x)},6349:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CircularList=void 0;const d=a(8460),h=a(844);class c extends h.Disposable{constructor(v){super(),this._maxLength=v,this.onDeleteEmitter=this.register(new d.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new d.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new d.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(v){if(this._maxLength===v)return;const y=new Array(v);for(let u=0;u<Math.min(v,this.length);u++)y[u]=this._array[this._getCyclicIndex(u)];this._array=y,this._maxLength=v,this._startIndex=0}get length(){return this._length}set length(v){if(v>this._length)for(let y=this._length;y<v;y++)this._array[y]=void 0;this._length=v}get(v){return this._array[this._getCyclicIndex(v)]}set(v,y){this._array[this._getCyclicIndex(v)]=y}push(v){this._array[this._getCyclicIndex(this._length)]=v,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(v,y,...u){if(y){for(let i=v;i<this._length-y;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+y)];this._length-=y,this.onDeleteEmitter.fire({index:v,amount:y})}for(let i=this._length-1;i>=v;i--)this._array[this._getCyclicIndex(i+u.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<u.length;i++)this._array[this._getCyclicIndex(v+i)]=u[i];if(u.length&&this.onInsertEmitter.fire({index:v,amount:u.length}),this._length+u.length>this._maxLength){const i=this._length+u.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=u.length}trimStart(v){v>this._length&&(v=this._length),this._startIndex+=v,this._length-=v,this.onTrimEmitter.fire(v)}shiftElements(v,y,u){if(!(y<=0)){if(v<0||v>=this._length)throw new Error("start argument out of range");if(v+u<0)throw new Error("Cannot shift elements in list beyond index 0");if(u>0){for(let r=y-1;r>=0;r--)this.set(v+r+u,this.get(v+r));const i=v+y+u-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<y;i++)this.set(v+i+u,this.get(v+i))}}_getCyclicIndex(v){return(this._startIndex+v)%this._maxLength}}n.CircularList=c},1439:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.clone=void 0,n.clone=function a(d,h=5){if(typeof d!="object")return d;const c=Array.isArray(d)?[]:{};for(const f in d)c[f]=h<=1?d[f]:d[f]&&a(d[f],h-1);return c}},8055:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.contrastRatio=n.toPaddedHex=n.rgba=n.rgb=n.css=n.color=n.channels=n.NULL_COLOR=void 0;let a=0,d=0,h=0,c=0;var f,v,y,u,i;function r(l){const _=l.toString(16);return _.length<2?"0"+_:_}function s(l,_){return l<_?(_+.05)/(l+.05):(l+.05)/(_+.05)}n.NULL_COLOR={css:"#00000000",rgba:0},(function(l){l.toCss=function(_,x,C,k){return k!==void 0?`#${r(_)}${r(x)}${r(C)}${r(k)}`:`#${r(_)}${r(x)}${r(C)}`},l.toRgba=function(_,x,C,k=255){return(_<<24|x<<16|C<<8|k)>>>0},l.toColor=function(_,x,C,k){return{css:l.toCss(_,x,C,k),rgba:l.toRgba(_,x,C,k)}}})(f||(n.channels=f={})),(function(l){function _(x,C){return c=Math.round(255*C),[a,d,h]=i.toChannels(x.rgba),{css:f.toCss(a,d,h,c),rgba:f.toRgba(a,d,h,c)}}l.blend=function(x,C){if(c=(255&C.rgba)/255,c===1)return{css:C.css,rgba:C.rgba};const k=C.rgba>>24&255,p=C.rgba>>16&255,w=C.rgba>>8&255,R=x.rgba>>24&255,T=x.rgba>>16&255,M=x.rgba>>8&255;return a=R+Math.round((k-R)*c),d=T+Math.round((p-T)*c),h=M+Math.round((w-M)*c),{css:f.toCss(a,d,h),rgba:f.toRgba(a,d,h)}},l.isOpaque=function(x){return(255&x.rgba)==255},l.ensureContrastRatio=function(x,C,k){const p=i.ensureContrastRatio(x.rgba,C.rgba,k);if(p)return f.toColor(p>>24&255,p>>16&255,p>>8&255)},l.opaque=function(x){const C=(255|x.rgba)>>>0;return[a,d,h]=i.toChannels(C),{css:f.toCss(a,d,h),rgba:C}},l.opacity=_,l.multiplyOpacity=function(x,C){return c=255&x.rgba,_(x,c*C/255)},l.toColorRGB=function(x){return[x.rgba>>24&255,x.rgba>>16&255,x.rgba>>8&255]}})(v||(n.color=v={})),(function(l){let _,x;try{const C=document.createElement("canvas");C.width=1,C.height=1;const k=C.getContext("2d",{willReadFrequently:!0});k&&(_=k,_.globalCompositeOperation="copy",x=_.createLinearGradient(0,0,1,1))}catch{}l.toColor=function(C){if(C.match(/#[\da-f]{3,8}/i))switch(C.length){case 4:return a=parseInt(C.slice(1,2).repeat(2),16),d=parseInt(C.slice(2,3).repeat(2),16),h=parseInt(C.slice(3,4).repeat(2),16),f.toColor(a,d,h);case 5:return a=parseInt(C.slice(1,2).repeat(2),16),d=parseInt(C.slice(2,3).repeat(2),16),h=parseInt(C.slice(3,4).repeat(2),16),c=parseInt(C.slice(4,5).repeat(2),16),f.toColor(a,d,h,c);case 7:return{css:C,rgba:(parseInt(C.slice(1),16)<<8|255)>>>0};case 9:return{css:C,rgba:parseInt(C.slice(1),16)>>>0}}const k=C.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(k)return a=parseInt(k[1]),d=parseInt(k[2]),h=parseInt(k[3]),c=Math.round(255*(k[5]===void 0?1:parseFloat(k[5]))),f.toColor(a,d,h,c);if(!_||!x)throw new Error("css.toColor: Unsupported css format");if(_.fillStyle=x,_.fillStyle=C,typeof _.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(_.fillRect(0,0,1,1),[a,d,h,c]=_.getImageData(0,0,1,1).data,c!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:f.toRgba(a,d,h,c),css:C}}})(y||(n.css=y={})),(function(l){function _(x,C,k){const p=x/255,w=C/255,R=k/255;return .2126*(p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4))+.7152*(w<=.03928?w/12.92:Math.pow((w+.055)/1.055,2.4))+.0722*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))}l.relativeLuminance=function(x){return _(x>>16&255,x>>8&255,255&x)},l.relativeLuminance2=_})(u||(n.rgb=u={})),(function(l){function _(C,k,p){const w=C>>24&255,R=C>>16&255,T=C>>8&255;let M=k>>24&255,N=k>>16&255,I=k>>8&255,z=s(u.relativeLuminance2(M,N,I),u.relativeLuminance2(w,R,T));for(;z<p&&(M>0||N>0||I>0);)M-=Math.max(0,Math.ceil(.1*M)),N-=Math.max(0,Math.ceil(.1*N)),I-=Math.max(0,Math.ceil(.1*I)),z=s(u.relativeLuminance2(M,N,I),u.relativeLuminance2(w,R,T));return(M<<24|N<<16|I<<8|255)>>>0}function x(C,k,p){const w=C>>24&255,R=C>>16&255,T=C>>8&255;let M=k>>24&255,N=k>>16&255,I=k>>8&255,z=s(u.relativeLuminance2(M,N,I),u.relativeLuminance2(w,R,T));for(;z<p&&(M<255||N<255||I<255);)M=Math.min(255,M+Math.ceil(.1*(255-M))),N=Math.min(255,N+Math.ceil(.1*(255-N))),I=Math.min(255,I+Math.ceil(.1*(255-I))),z=s(u.relativeLuminance2(M,N,I),u.relativeLuminance2(w,R,T));return(M<<24|N<<16|I<<8|255)>>>0}l.blend=function(C,k){if(c=(255&k)/255,c===1)return k;const p=k>>24&255,w=k>>16&255,R=k>>8&255,T=C>>24&255,M=C>>16&255,N=C>>8&255;return a=T+Math.round((p-T)*c),d=M+Math.round((w-M)*c),h=N+Math.round((R-N)*c),f.toRgba(a,d,h)},l.ensureContrastRatio=function(C,k,p){const w=u.relativeLuminance(C>>8),R=u.relativeLuminance(k>>8);if(s(w,R)<p){if(R<w){const N=_(C,k,p),I=s(w,u.relativeLuminance(N>>8));if(I<p){const z=x(C,k,p);return I>s(w,u.relativeLuminance(z>>8))?N:z}return N}const T=x(C,k,p),M=s(w,u.relativeLuminance(T>>8));if(M<p){const N=_(C,k,p);return M>s(w,u.relativeLuminance(N>>8))?T:N}return T}},l.reduceLuminance=_,l.increaseLuminance=x,l.toChannels=function(C){return[C>>24&255,C>>16&255,C>>8&255,255&C]}})(i||(n.rgba=i={})),n.toPaddedHex=r,n.contrastRatio=s},8969:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreTerminal=void 0;const d=a(844),h=a(2585),c=a(4348),f=a(7866),v=a(744),y=a(7302),u=a(6975),i=a(8460),r=a(1753),s=a(1480),l=a(7994),_=a(9282),x=a(5435),C=a(5981),k=a(2660);let p=!1;class w extends d.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new i.EventEmitter),this._onScroll.event((T=>{var M;(M=this._onScrollApi)==null||M.fire(T.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(T){for(const M in T)this.optionsService.options[M]=T[M]}constructor(T){super(),this._windowsWrappingHeuristics=this.register(new d.MutableDisposable),this._onBinary=this.register(new i.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new i.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new i.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new i.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new i.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new i.EventEmitter),this._instantiationService=new c.InstantiationService,this.optionsService=this.register(new y.OptionsService(T)),this._instantiationService.setService(h.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(v.BufferService)),this._instantiationService.setService(h.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(f.LogService)),this._instantiationService.setService(h.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(u.CoreService)),this._instantiationService.setService(h.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(r.CoreMouseService)),this._instantiationService.setService(h.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(s.UnicodeService)),this._instantiationService.setService(h.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(l.CharsetService),this._instantiationService.setService(h.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(k.OscLinkService),this._instantiationService.setService(h.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new x.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,i.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,i.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,i.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,i.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((M=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((M=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new C.WriteBuffer(((M,N)=>this._inputHandler.parse(M,N)))),this.register((0,i.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(T,M){this._writeBuffer.write(T,M)}writeSync(T,M){this._logService.logLevel<=h.LogLevelEnum.WARN&&!p&&(this._logService.warn("writeSync is unreliable and will be removed soon."),p=!0),this._writeBuffer.writeSync(T,M)}input(T,M=!0){this.coreService.triggerDataEvent(T,M)}resize(T,M){isNaN(T)||isNaN(M)||(T=Math.max(T,v.MINIMUM_COLS),M=Math.max(M,v.MINIMUM_ROWS),this._bufferService.resize(T,M))}scroll(T,M=!1){this._bufferService.scroll(T,M)}scrollLines(T,M,N){this._bufferService.scrollLines(T,M,N)}scrollPages(T){this.scrollLines(T*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(T){const M=T-this._bufferService.buffer.ydisp;M!==0&&this.scrollLines(M)}registerEscHandler(T,M){return this._inputHandler.registerEscHandler(T,M)}registerDcsHandler(T,M){return this._inputHandler.registerDcsHandler(T,M)}registerCsiHandler(T,M){return this._inputHandler.registerCsiHandler(T,M)}registerOscHandler(T,M){return this._inputHandler.registerOscHandler(T,M)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let T=!1;const M=this.optionsService.rawOptions.windowsPty;M&&M.buildNumber!==void 0&&M.buildNumber!==void 0?T=M.backend==="conpty"&&M.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(T=!0),T?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const T=[];T.push(this.onLineFeed(_.updateWindowsModeWrappedState.bind(null,this._bufferService))),T.push(this.registerCsiHandler({final:"H"},(()=>((0,_.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,d.toDisposable)((()=>{for(const M of T)M.dispose()}))}}}n.CoreTerminal=w},8460:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.runAndSubscribe=n.forwardEvent=n.EventEmitter=void 0,n.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=a=>(this._listeners.push(a),{dispose:()=>{if(!this._disposed){for(let d=0;d<this._listeners.length;d++)if(this._listeners[d]===a)return void this._listeners.splice(d,1)}}})),this._event}fire(a,d){const h=[];for(let c=0;c<this._listeners.length;c++)h.push(this._listeners[c]);for(let c=0;c<h.length;c++)h[c].call(void 0,a,d)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},n.forwardEvent=function(a,d){return a((h=>d.fire(h)))},n.runAndSubscribe=function(a,d){return d(void 0),a((h=>d(h)))}},5435:function(b,n,a){var d=this&&this.__decorate||function(V,L,A,B){var P,U=arguments.length,Z=U<3?L:B===null?B=Object.getOwnPropertyDescriptor(L,A):B;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Z=Reflect.decorate(V,L,A,B);else for(var oe=V.length-1;oe>=0;oe--)(P=V[oe])&&(Z=(U<3?P(Z):U>3?P(L,A,Z):P(L,A))||Z);return U>3&&Z&&Object.defineProperty(L,A,Z),Z},h=this&&this.__param||function(V,L){return function(A,B){L(A,B,V)}};Object.defineProperty(n,"__esModule",{value:!0}),n.InputHandler=n.WindowsOptionsReportType=void 0;const c=a(2584),f=a(7116),v=a(2015),y=a(844),u=a(482),i=a(8437),r=a(8460),s=a(643),l=a(511),_=a(3734),x=a(2585),C=a(1480),k=a(6242),p=a(6351),w=a(5941),R={"(":0,")":1,"*":2,"+":3,"-":1,".":2},T=131072;function M(V,L){if(V>24)return L.setWinLines||!1;switch(V){case 1:return!!L.restoreWin;case 2:return!!L.minimizeWin;case 3:return!!L.setWinPosition;case 4:return!!L.setWinSizePixels;case 5:return!!L.raiseWin;case 6:return!!L.lowerWin;case 7:return!!L.refreshWin;case 8:return!!L.setWinSizeChars;case 9:return!!L.maximizeWin;case 10:return!!L.fullscreenWin;case 11:return!!L.getWinState;case 13:return!!L.getWinPosition;case 14:return!!L.getWinSizePixels;case 15:return!!L.getScreenSizePixels;case 16:return!!L.getCellSizePixels;case 18:return!!L.getWinSizeChars;case 19:return!!L.getScreenSizeChars;case 20:return!!L.getIconTitle;case 21:return!!L.getWinTitle;case 22:return!!L.pushTitle;case 23:return!!L.popTitle;case 24:return!!L.setWinLines}return!1}var N;(function(V){V[V.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",V[V.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(N||(n.WindowsOptionsReportType=N={}));let I=0;class z extends y.Disposable{getAttrData(){return this._curAttrData}constructor(L,A,B,P,U,Z,oe,K,$=new v.EscapeSequenceParser){super(),this._bufferService=L,this._charsetService=A,this._coreService=B,this._logService=P,this._optionsService=U,this._oscLinkService=Z,this._coreMouseService=oe,this._unicodeService=K,this._parser=$,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new u.StringToUtf32,this._utf8Decoder=new u.Utf8ToUtf32,this._workCell=new l.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=i.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=i.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new r.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new r.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new r.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new r.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new r.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new r.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new r.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new r.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new r.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new r.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new r.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new r.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new r.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new G(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((D=>this._activeBuffer=D.activeBuffer))),this._parser.setCsiHandlerFallback(((D,q)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(D),params:q.toArray()})})),this._parser.setEscHandlerFallback((D=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(D)})})),this._parser.setExecuteHandlerFallback((D=>{this._logService.debug("Unknown EXECUTE code: ",{code:D})})),this._parser.setOscHandlerFallback(((D,q,J)=>{this._logService.debug("Unknown OSC code: ",{identifier:D,action:q,data:J})})),this._parser.setDcsHandlerFallback(((D,q,J)=>{q==="HOOK"&&(J=J.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(D),action:q,payload:J})})),this._parser.setPrintHandler(((D,q,J)=>this.print(D,q,J))),this._parser.registerCsiHandler({final:"@"},(D=>this.insertChars(D))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(D=>this.scrollLeft(D))),this._parser.registerCsiHandler({final:"A"},(D=>this.cursorUp(D))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(D=>this.scrollRight(D))),this._parser.registerCsiHandler({final:"B"},(D=>this.cursorDown(D))),this._parser.registerCsiHandler({final:"C"},(D=>this.cursorForward(D))),this._parser.registerCsiHandler({final:"D"},(D=>this.cursorBackward(D))),this._parser.registerCsiHandler({final:"E"},(D=>this.cursorNextLine(D))),this._parser.registerCsiHandler({final:"F"},(D=>this.cursorPrecedingLine(D))),this._parser.registerCsiHandler({final:"G"},(D=>this.cursorCharAbsolute(D))),this._parser.registerCsiHandler({final:"H"},(D=>this.cursorPosition(D))),this._parser.registerCsiHandler({final:"I"},(D=>this.cursorForwardTab(D))),this._parser.registerCsiHandler({final:"J"},(D=>this.eraseInDisplay(D,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(D=>this.eraseInDisplay(D,!0))),this._parser.registerCsiHandler({final:"K"},(D=>this.eraseInLine(D,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(D=>this.eraseInLine(D,!0))),this._parser.registerCsiHandler({final:"L"},(D=>this.insertLines(D))),this._parser.registerCsiHandler({final:"M"},(D=>this.deleteLines(D))),this._parser.registerCsiHandler({final:"P"},(D=>this.deleteChars(D))),this._parser.registerCsiHandler({final:"S"},(D=>this.scrollUp(D))),this._parser.registerCsiHandler({final:"T"},(D=>this.scrollDown(D))),this._parser.registerCsiHandler({final:"X"},(D=>this.eraseChars(D))),this._parser.registerCsiHandler({final:"Z"},(D=>this.cursorBackwardTab(D))),this._parser.registerCsiHandler({final:"`"},(D=>this.charPosAbsolute(D))),this._parser.registerCsiHandler({final:"a"},(D=>this.hPositionRelative(D))),this._parser.registerCsiHandler({final:"b"},(D=>this.repeatPrecedingCharacter(D))),this._parser.registerCsiHandler({final:"c"},(D=>this.sendDeviceAttributesPrimary(D))),this._parser.registerCsiHandler({prefix:">",final:"c"},(D=>this.sendDeviceAttributesSecondary(D))),this._parser.registerCsiHandler({final:"d"},(D=>this.linePosAbsolute(D))),this._parser.registerCsiHandler({final:"e"},(D=>this.vPositionRelative(D))),this._parser.registerCsiHandler({final:"f"},(D=>this.hVPosition(D))),this._parser.registerCsiHandler({final:"g"},(D=>this.tabClear(D))),this._parser.registerCsiHandler({final:"h"},(D=>this.setMode(D))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(D=>this.setModePrivate(D))),this._parser.registerCsiHandler({final:"l"},(D=>this.resetMode(D))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(D=>this.resetModePrivate(D))),this._parser.registerCsiHandler({final:"m"},(D=>this.charAttributes(D))),this._parser.registerCsiHandler({final:"n"},(D=>this.deviceStatus(D))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(D=>this.deviceStatusPrivate(D))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(D=>this.softReset(D))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(D=>this.setCursorStyle(D))),this._parser.registerCsiHandler({final:"r"},(D=>this.setScrollRegion(D))),this._parser.registerCsiHandler({final:"s"},(D=>this.saveCursor(D))),this._parser.registerCsiHandler({final:"t"},(D=>this.windowOptions(D))),this._parser.registerCsiHandler({final:"u"},(D=>this.restoreCursor(D))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(D=>this.insertColumns(D))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(D=>this.deleteColumns(D))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(D=>this.selectProtected(D))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(D=>this.requestMode(D,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(D=>this.requestMode(D,!1))),this._parser.setExecuteHandler(c.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(c.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(c.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(c.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(c.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(c.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(c.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(c.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(c.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((D=>(this.setTitle(D),this.setIconName(D),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((D=>this.setIconName(D)))),this._parser.registerOscHandler(2,new k.OscHandler((D=>this.setTitle(D)))),this._parser.registerOscHandler(4,new k.OscHandler((D=>this.setOrReportIndexedColor(D)))),this._parser.registerOscHandler(8,new k.OscHandler((D=>this.setHyperlink(D)))),this._parser.registerOscHandler(10,new k.OscHandler((D=>this.setOrReportFgColor(D)))),this._parser.registerOscHandler(11,new k.OscHandler((D=>this.setOrReportBgColor(D)))),this._parser.registerOscHandler(12,new k.OscHandler((D=>this.setOrReportCursorColor(D)))),this._parser.registerOscHandler(104,new k.OscHandler((D=>this.restoreIndexedColor(D)))),this._parser.registerOscHandler(110,new k.OscHandler((D=>this.restoreFgColor(D)))),this._parser.registerOscHandler(111,new k.OscHandler((D=>this.restoreBgColor(D)))),this._parser.registerOscHandler(112,new k.OscHandler((D=>this.restoreCursorColor(D)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const D in f.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:D},(()=>this.selectCharset("("+D))),this._parser.registerEscHandler({intermediates:")",final:D},(()=>this.selectCharset(")"+D))),this._parser.registerEscHandler({intermediates:"*",final:D},(()=>this.selectCharset("*"+D))),this._parser.registerEscHandler({intermediates:"+",final:D},(()=>this.selectCharset("+"+D))),this._parser.registerEscHandler({intermediates:"-",final:D},(()=>this.selectCharset("-"+D))),this._parser.registerEscHandler({intermediates:".",final:D},(()=>this.selectCharset("."+D))),this._parser.registerEscHandler({intermediates:"/",final:D},(()=>this.selectCharset("/"+D)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((D=>(this._logService.error("Parsing error: ",D),D))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new p.DcsHandler(((D,q)=>this.requestStatusString(D,q))))}_preserveStack(L,A,B,P){this._parseStack.paused=!0,this._parseStack.cursorStartX=L,this._parseStack.cursorStartY=A,this._parseStack.decodedLength=B,this._parseStack.position=P}_logSlowResolvingAsync(L){this._logService.logLevel<=x.LogLevelEnum.WARN&&Promise.race([L,new Promise(((A,B)=>setTimeout((()=>B("#SLOW_TIMEOUT")),5e3)))]).catch((A=>{if(A!=="#SLOW_TIMEOUT")throw A;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(L,A){let B,P=this._activeBuffer.x,U=this._activeBuffer.y,Z=0;const oe=this._parseStack.paused;if(oe){if(B=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,A))return this._logSlowResolvingAsync(B),B;P=this._parseStack.cursorStartX,U=this._parseStack.cursorStartY,this._parseStack.paused=!1,L.length>T&&(Z=this._parseStack.position+T)}if(this._logService.logLevel<=x.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof L=="string"?` "${L}"`:` "${Array.prototype.map.call(L,(D=>String.fromCharCode(D))).join("")}"`),typeof L=="string"?L.split("").map((D=>D.charCodeAt(0))):L),this._parseBuffer.length<L.length&&this._parseBuffer.length<T&&(this._parseBuffer=new Uint32Array(Math.min(L.length,T))),oe||this._dirtyRowTracker.clearRange(),L.length>T)for(let D=Z;D<L.length;D+=T){const q=D+T<L.length?D+T:L.length,J=typeof L=="string"?this._stringDecoder.decode(L.substring(D,q),this._parseBuffer):this._utf8Decoder.decode(L.subarray(D,q),this._parseBuffer);if(B=this._parser.parse(this._parseBuffer,J))return this._preserveStack(P,U,J,D),this._logSlowResolvingAsync(B),B}else if(!oe){const D=typeof L=="string"?this._stringDecoder.decode(L,this._parseBuffer):this._utf8Decoder.decode(L,this._parseBuffer);if(B=this._parser.parse(this._parseBuffer,D))return this._preserveStack(P,U,D,0),this._logSlowResolvingAsync(B),B}this._activeBuffer.x===P&&this._activeBuffer.y===U||this._onCursorMove.fire();const K=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),$=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);$<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min($,this._bufferService.rows-1),Math.min(K,this._bufferService.rows-1))}print(L,A,B){let P,U;const Z=this._charsetService.charset,oe=this._optionsService.rawOptions.screenReaderMode,K=this._bufferService.cols,$=this._coreService.decPrivateModes.wraparound,D=this._coreService.modes.insertMode,q=this._curAttrData;let J=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&B-A>0&&J.getWidth(this._activeBuffer.x-1)===2&&J.setCellFromCodepoint(this._activeBuffer.x-1,0,1,q);let O=this._parser.precedingJoinState;for(let X=A;X<B;++X){if(P=L[X],P<127&&Z){const ae=Z[String.fromCharCode(P)];ae&&(P=ae.charCodeAt(0))}const F=this._unicodeService.charProperties(P,O);U=C.UnicodeService.extractWidth(F);const W=C.UnicodeService.extractShouldJoin(F),re=W?C.UnicodeService.extractWidth(O):0;if(O=F,oe&&this._onA11yChar.fire((0,u.stringFromCodePoint)(P)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+U-re>K){if($){const ae=J;let ee=this._activeBuffer.x-re;for(this._activeBuffer.x=re,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),J=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),re>0&&J instanceof i.BufferLine&&J.copyCellsFrom(ae,ee,0,re,!1);ee<K;)ae.setCellFromCodepoint(ee++,0,1,q)}else if(this._activeBuffer.x=K-1,U===2)continue}if(W&&this._activeBuffer.x){const ae=J.getWidth(this._activeBuffer.x-1)?1:2;J.addCodepointToCell(this._activeBuffer.x-ae,P,U);for(let ee=U-re;--ee>=0;)J.setCellFromCodepoint(this._activeBuffer.x++,0,0,q)}else if(D&&(J.insertCells(this._activeBuffer.x,U-re,this._activeBuffer.getNullCell(q)),J.getWidth(K-1)===2&&J.setCellFromCodepoint(K-1,s.NULL_CELL_CODE,s.NULL_CELL_WIDTH,q)),J.setCellFromCodepoint(this._activeBuffer.x++,P,U,q),U>0)for(;--U;)J.setCellFromCodepoint(this._activeBuffer.x++,0,0,q)}this._parser.precedingJoinState=O,this._activeBuffer.x<K&&B-A>0&&J.getWidth(this._activeBuffer.x)===0&&!J.hasContent(this._activeBuffer.x)&&J.setCellFromCodepoint(this._activeBuffer.x,0,1,q),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(L,A){return L.final!=="t"||L.prefix||L.intermediates?this._parser.registerCsiHandler(L,A):this._parser.registerCsiHandler(L,(B=>!M(B.params[0],this._optionsService.rawOptions.windowOptions)||A(B)))}registerDcsHandler(L,A){return this._parser.registerDcsHandler(L,new p.DcsHandler(A))}registerEscHandler(L,A){return this._parser.registerEscHandler(L,A)}registerOscHandler(L,A){return this._parser.registerOscHandler(L,new k.OscHandler(A))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var L;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&L.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);A.hasWidth(this._activeBuffer.x)&&!A.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const L=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-L),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(L=this._bufferService.cols-1){this._activeBuffer.x=Math.min(L,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(L,A){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=L,this._activeBuffer.y=this._activeBuffer.scrollTop+A):(this._activeBuffer.x=L,this._activeBuffer.y=A),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(L,A){this._restrictCursor(),this._setCursor(this._activeBuffer.x+L,this._activeBuffer.y+A)}cursorUp(L){const A=this._activeBuffer.y-this._activeBuffer.scrollTop;return A>=0?this._moveCursor(0,-Math.min(A,L.params[0]||1)):this._moveCursor(0,-(L.params[0]||1)),!0}cursorDown(L){const A=this._activeBuffer.scrollBottom-this._activeBuffer.y;return A>=0?this._moveCursor(0,Math.min(A,L.params[0]||1)):this._moveCursor(0,L.params[0]||1),!0}cursorForward(L){return this._moveCursor(L.params[0]||1,0),!0}cursorBackward(L){return this._moveCursor(-(L.params[0]||1),0),!0}cursorNextLine(L){return this.cursorDown(L),this._activeBuffer.x=0,!0}cursorPrecedingLine(L){return this.cursorUp(L),this._activeBuffer.x=0,!0}cursorCharAbsolute(L){return this._setCursor((L.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(L){return this._setCursor(L.length>=2?(L.params[1]||1)-1:0,(L.params[0]||1)-1),!0}charPosAbsolute(L){return this._setCursor((L.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(L){return this._moveCursor(L.params[0]||1,0),!0}linePosAbsolute(L){return this._setCursor(this._activeBuffer.x,(L.params[0]||1)-1),!0}vPositionRelative(L){return this._moveCursor(0,L.params[0]||1),!0}hVPosition(L){return this.cursorPosition(L),!0}tabClear(L){const A=L.params[0];return A===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:A===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(L){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let A=L.params[0]||1;for(;A--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(L){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let A=L.params[0]||1;for(;A--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(L){const A=L.params[0];return A===1&&(this._curAttrData.bg|=536870912),A!==2&&A!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(L,A,B,P=!1,U=!1){const Z=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);Z.replaceCells(A,B,this._activeBuffer.getNullCell(this._eraseAttrData()),U),P&&(Z.isWrapped=!1)}_resetBufferLine(L,A=!1){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);B&&(B.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),A),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+L),B.isWrapped=!1)}eraseInDisplay(L,A=!1){let B;switch(this._restrictCursor(this._bufferService.cols),L.params[0]){case 0:for(B=this._activeBuffer.y,this._dirtyRowTracker.markDirty(B),this._eraseInBufferLine(B++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,A);B<this._bufferService.rows;B++)this._resetBufferLine(B,A);this._dirtyRowTracker.markDirty(B);break;case 1:for(B=this._activeBuffer.y,this._dirtyRowTracker.markDirty(B),this._eraseInBufferLine(B,0,this._activeBuffer.x+1,!0,A),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(B+1).isWrapped=!1);B--;)this._resetBufferLine(B,A);this._dirtyRowTracker.markDirty(0);break;case 2:for(B=this._bufferService.rows,this._dirtyRowTracker.markDirty(B-1);B--;)this._resetBufferLine(B,A);this._dirtyRowTracker.markDirty(0);break;case 3:const P=this._activeBuffer.lines.length-this._bufferService.rows;P>0&&(this._activeBuffer.lines.trimStart(P),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-P,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-P,0),this._onScroll.fire(0))}return!0}eraseInLine(L,A=!1){switch(this._restrictCursor(this._bufferService.cols),L.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,A);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,A);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,A)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(L){this._restrictCursor();let A=L.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const B=this._activeBuffer.ybase+this._activeBuffer.y,P=this._bufferService.rows-1-this._activeBuffer.scrollBottom,U=this._bufferService.rows-1+this._activeBuffer.ybase-P+1;for(;A--;)this._activeBuffer.lines.splice(U-1,1),this._activeBuffer.lines.splice(B,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(L){this._restrictCursor();let A=L.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const B=this._activeBuffer.ybase+this._activeBuffer.y;let P;for(P=this._bufferService.rows-1-this._activeBuffer.scrollBottom,P=this._bufferService.rows-1+this._activeBuffer.ybase-P;A--;)this._activeBuffer.lines.splice(B,1),this._activeBuffer.lines.splice(P,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(L){this._restrictCursor();const A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return A&&(A.insertCells(this._activeBuffer.x,L.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(L){this._restrictCursor();const A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return A&&(A.deleteCells(this._activeBuffer.x,L.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(L){let A=L.params[0]||1;for(;A--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(L){let A=L.params[0]||1;for(;A--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(i.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(L){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const A=L.params[0]||1;for(let B=this._activeBuffer.scrollTop;B<=this._activeBuffer.scrollBottom;++B){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+B);P.deleteCells(0,A,this._activeBuffer.getNullCell(this._eraseAttrData())),P.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(L){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const A=L.params[0]||1;for(let B=this._activeBuffer.scrollTop;B<=this._activeBuffer.scrollBottom;++B){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+B);P.insertCells(0,A,this._activeBuffer.getNullCell(this._eraseAttrData())),P.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(L){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const A=L.params[0]||1;for(let B=this._activeBuffer.scrollTop;B<=this._activeBuffer.scrollBottom;++B){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+B);P.insertCells(this._activeBuffer.x,A,this._activeBuffer.getNullCell(this._eraseAttrData())),P.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(L){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const A=L.params[0]||1;for(let B=this._activeBuffer.scrollTop;B<=this._activeBuffer.scrollBottom;++B){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+B);P.deleteCells(this._activeBuffer.x,A,this._activeBuffer.getNullCell(this._eraseAttrData())),P.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(L){this._restrictCursor();const A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return A&&(A.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(L.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(L){const A=this._parser.precedingJoinState;if(!A)return!0;const B=L.params[0]||1,P=C.UnicodeService.extractWidth(A),U=this._activeBuffer.x-P,Z=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(U),oe=new Uint32Array(Z.length*B);let K=0;for(let D=0;D<Z.length;){const q=Z.codePointAt(D)||0;oe[K++]=q,D+=q>65535?2:1}let $=K;for(let D=1;D<B;++D)oe.copyWithin($,0,K),$+=K;return this.print(oe,0,$),!0}sendDeviceAttributesPrimary(L){return L.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(c.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(c.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(L){return L.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(c.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(c.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(L.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(L){return(this._optionsService.rawOptions.termName+"").indexOf(L)===0}setMode(L){for(let A=0;A<L.length;A++)switch(L.params[A]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(L){for(let A=0;A<L.length;A++)switch(L.params[A]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,f.DEFAULT_CHARSET),this._charsetService.setgCharset(1,f.DEFAULT_CHARSET),this._charsetService.setgCharset(2,f.DEFAULT_CHARSET),this._charsetService.setgCharset(3,f.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(L){for(let A=0;A<L.length;A++)switch(L.params[A]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(L){for(let A=0;A<L.length;A++)switch(L.params[A]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),L.params[A]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(L,A){const B=this._coreService.decPrivateModes,{activeProtocol:P,activeEncoding:U}=this._coreMouseService,Z=this._coreService,{buffers:oe,cols:K}=this._bufferService,{active:$,alt:D}=oe,q=this._optionsService.rawOptions,J=W=>W?1:2,O=L.params[0];return X=O,F=A?O===2?4:O===4?J(Z.modes.insertMode):O===12?3:O===20?J(q.convertEol):0:O===1?J(B.applicationCursorKeys):O===3?q.windowOptions.setWinLines?K===80?2:K===132?1:0:0:O===6?J(B.origin):O===7?J(B.wraparound):O===8?3:O===9?J(P==="X10"):O===12?J(q.cursorBlink):O===25?J(!Z.isCursorHidden):O===45?J(B.reverseWraparound):O===66?J(B.applicationKeypad):O===67?4:O===1e3?J(P==="VT200"):O===1002?J(P==="DRAG"):O===1003?J(P==="ANY"):O===1004?J(B.sendFocus):O===1005?4:O===1006?J(U==="SGR"):O===1015?4:O===1016?J(U==="SGR_PIXELS"):O===1048?1:O===47||O===1047||O===1049?J($===D):O===2004?J(B.bracketedPasteMode):0,Z.triggerDataEvent(`${c.C0.ESC}[${A?"":"?"}${X};${F}$y`),!0;var X,F}_updateAttrColor(L,A,B,P,U){return A===2?(L|=50331648,L&=-16777216,L|=_.AttributeData.fromColorRGB([B,P,U])):A===5&&(L&=-50331904,L|=33554432|255&B),L}_extractColor(L,A,B){const P=[0,0,-1,0,0,0];let U=0,Z=0;do{if(P[Z+U]=L.params[A+Z],L.hasSubParams(A+Z)){const oe=L.getSubParams(A+Z);let K=0;do P[1]===5&&(U=1),P[Z+K+1+U]=oe[K];while(++K<oe.length&&K+Z+1+U<P.length);break}if(P[1]===5&&Z+U>=2||P[1]===2&&Z+U>=5)break;P[1]&&(U=1)}while(++Z+A<L.length&&Z+U<P.length);for(let oe=2;oe<P.length;++oe)P[oe]===-1&&(P[oe]=0);switch(P[0]){case 38:B.fg=this._updateAttrColor(B.fg,P[1],P[3],P[4],P[5]);break;case 48:B.bg=this._updateAttrColor(B.bg,P[1],P[3],P[4],P[5]);break;case 58:B.extended=B.extended.clone(),B.extended.underlineColor=this._updateAttrColor(B.extended.underlineColor,P[1],P[3],P[4],P[5])}return Z}_processUnderline(L,A){A.extended=A.extended.clone(),(!~L||L>5)&&(L=1),A.extended.underlineStyle=L,A.fg|=268435456,L===0&&(A.fg&=-268435457),A.updateExtended()}_processSGR0(L){L.fg=i.DEFAULT_ATTR_DATA.fg,L.bg=i.DEFAULT_ATTR_DATA.bg,L.extended=L.extended.clone(),L.extended.underlineStyle=0,L.extended.underlineColor&=-67108864,L.updateExtended()}charAttributes(L){if(L.length===1&&L.params[0]===0)return this._processSGR0(this._curAttrData),!0;const A=L.length;let B;const P=this._curAttrData;for(let U=0;U<A;U++)B=L.params[U],B>=30&&B<=37?(P.fg&=-50331904,P.fg|=16777216|B-30):B>=40&&B<=47?(P.bg&=-50331904,P.bg|=16777216|B-40):B>=90&&B<=97?(P.fg&=-50331904,P.fg|=16777224|B-90):B>=100&&B<=107?(P.bg&=-50331904,P.bg|=16777224|B-100):B===0?this._processSGR0(P):B===1?P.fg|=134217728:B===3?P.bg|=67108864:B===4?(P.fg|=268435456,this._processUnderline(L.hasSubParams(U)?L.getSubParams(U)[0]:1,P)):B===5?P.fg|=536870912:B===7?P.fg|=67108864:B===8?P.fg|=1073741824:B===9?P.fg|=2147483648:B===2?P.bg|=134217728:B===21?this._processUnderline(2,P):B===22?(P.fg&=-134217729,P.bg&=-134217729):B===23?P.bg&=-67108865:B===24?(P.fg&=-268435457,this._processUnderline(0,P)):B===25?P.fg&=-536870913:B===27?P.fg&=-67108865:B===28?P.fg&=-1073741825:B===29?P.fg&=2147483647:B===39?(P.fg&=-67108864,P.fg|=16777215&i.DEFAULT_ATTR_DATA.fg):B===49?(P.bg&=-67108864,P.bg|=16777215&i.DEFAULT_ATTR_DATA.bg):B===38||B===48||B===58?U+=this._extractColor(L,U,P):B===53?P.bg|=1073741824:B===55?P.bg&=-1073741825:B===59?(P.extended=P.extended.clone(),P.extended.underlineColor=-1,P.updateExtended()):B===100?(P.fg&=-67108864,P.fg|=16777215&i.DEFAULT_ATTR_DATA.fg,P.bg&=-67108864,P.bg|=16777215&i.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",B);return!0}deviceStatus(L){switch(L.params[0]){case 5:this._coreService.triggerDataEvent(`${c.C0.ESC}[0n`);break;case 6:const A=this._activeBuffer.y+1,B=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[${A};${B}R`)}return!0}deviceStatusPrivate(L){if(L.params[0]===6){const A=this._activeBuffer.y+1,B=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[?${A};${B}R`)}return!0}softReset(L){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=i.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(L){const A=L.params[0]||1;switch(A){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const B=A%2==1;return this._optionsService.options.cursorBlink=B,!0}setScrollRegion(L){const A=L.params[0]||1;let B;return(L.length<2||(B=L.params[1])>this._bufferService.rows||B===0)&&(B=this._bufferService.rows),B>A&&(this._activeBuffer.scrollTop=A-1,this._activeBuffer.scrollBottom=B-1,this._setCursor(0,0)),!0}windowOptions(L){if(!M(L.params[0],this._optionsService.rawOptions.windowOptions))return!0;const A=L.length>1?L.params[1]:0;switch(L.params[0]){case 14:A!==2&&this._onRequestWindowsOptionsReport.fire(N.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(N.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${c.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:A!==0&&A!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),A!==0&&A!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:A!==0&&A!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),A!==0&&A!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(L){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(L){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(L){return this._windowTitle=L,this._onTitleChange.fire(L),!0}setIconName(L){return this._iconName=L,!0}setOrReportIndexedColor(L){const A=[],B=L.split(";");for(;B.length>1;){const P=B.shift(),U=B.shift();if(/^\d+$/.exec(P)){const Z=parseInt(P);if(H(Z))if(U==="?")A.push({type:0,index:Z});else{const oe=(0,w.parseColor)(U);oe&&A.push({type:1,index:Z,color:oe})}}}return A.length&&this._onColor.fire(A),!0}setHyperlink(L){const A=L.split(";");return!(A.length<2)&&(A[1]?this._createHyperlink(A[0],A[1]):!A[0]&&this._finishHyperlink())}_createHyperlink(L,A){this._getCurrentLinkId()&&this._finishHyperlink();const B=L.split(":");let P;const U=B.findIndex((Z=>Z.startsWith("id=")));return U!==-1&&(P=B[U].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:P,uri:A}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(L,A){const B=L.split(";");for(let P=0;P<B.length&&!(A>=this._specialColors.length);++P,++A)if(B[P]==="?")this._onColor.fire([{type:0,index:this._specialColors[A]}]);else{const U=(0,w.parseColor)(B[P]);U&&this._onColor.fire([{type:1,index:this._specialColors[A],color:U}])}return!0}setOrReportFgColor(L){return this._setOrReportSpecialColor(L,0)}setOrReportBgColor(L){return this._setOrReportSpecialColor(L,1)}setOrReportCursorColor(L){return this._setOrReportSpecialColor(L,2)}restoreIndexedColor(L){if(!L)return this._onColor.fire([{type:2}]),!0;const A=[],B=L.split(";");for(let P=0;P<B.length;++P)if(/^\d+$/.exec(B[P])){const U=parseInt(B[P]);H(U)&&A.push({type:2,index:U})}return A.length&&this._onColor.fire(A),!0}restoreFgColor(L){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(L){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(L){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,f.DEFAULT_CHARSET),!0}selectCharset(L){return L.length!==2?(this.selectDefaultCharset(),!0):(L[0]==="/"||this._charsetService.setgCharset(R[L[0]],f.CHARSETS[L[1]]||f.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const L=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,L,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=i.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=i.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(L){return this._charsetService.setgLevel(L),!0}screenAlignmentPattern(){const L=new l.CellData;L.content=4194373,L.fg=this._curAttrData.fg,L.bg=this._curAttrData.bg,this._setCursor(0,0);for(let A=0;A<this._bufferService.rows;++A){const B=this._activeBuffer.ybase+this._activeBuffer.y+A,P=this._activeBuffer.lines.get(B);P&&(P.fill(L),P.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(L,A){const B=this._bufferService.buffer,P=this._optionsService.rawOptions;return(U=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${U}${c.C0.ESC}\\`),!0))(L==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:L==='"p'?'P1$r61;1"p':L==="r"?`P1$r${B.scrollTop+1};${B.scrollBottom+1}r`:L==="m"?"P1$r0m":L===" q"?`P1$r${{block:2,underline:4,bar:6}[P.cursorStyle]-(P.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(L,A){this._dirtyRowTracker.markRangeDirty(L,A)}}n.InputHandler=z;let G=class{constructor(V){this._bufferService=V,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(V){V<this.start?this.start=V:V>this.end&&(this.end=V)}markRangeDirty(V,L){V>L&&(I=V,V=L,L=I),V<this.start&&(this.start=V),L>this.end&&(this.end=L)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function H(V){return 0<=V&&V<256}G=d([h(0,x.IBufferService)],G)},844:(b,n)=>{function a(d){for(const h of d)h.dispose();d.length=0}Object.defineProperty(n,"__esModule",{value:!0}),n.getDisposeArrayDisposable=n.disposeArray=n.toDisposable=n.MutableDisposable=n.Disposable=void 0,n.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const d of this._disposables)d.dispose();this._disposables.length=0}register(d){return this._disposables.push(d),d}unregister(d){const h=this._disposables.indexOf(d);h!==-1&&this._disposables.splice(h,1)}},n.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(d){var h;this._isDisposed||d===this._value||((h=this._value)==null||h.dispose(),this._value=d)}clear(){this.value=void 0}dispose(){var d;this._isDisposed=!0,(d=this._value)==null||d.dispose(),this._value=void 0}},n.toDisposable=function(d){return{dispose:d}},n.disposeArray=a,n.getDisposeArrayDisposable=function(d){return{dispose:()=>a(d)}}},1505:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.FourKeyMap=n.TwoKeyMap=void 0;class a{constructor(){this._data={}}set(h,c,f){this._data[h]||(this._data[h]={}),this._data[h][c]=f}get(h,c){return this._data[h]?this._data[h][c]:void 0}clear(){this._data={}}}n.TwoKeyMap=a,n.FourKeyMap=class{constructor(){this._data=new a}set(d,h,c,f,v){this._data.get(d,h)||this._data.set(d,h,new a),this._data.get(d,h).set(c,f,v)}get(d,h,c,f){var v;return(v=this._data.get(d,h))==null?void 0:v.get(c,f)}clear(){this._data.clear()}}},6114:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.isChromeOS=n.isLinux=n.isWindows=n.isIphone=n.isIpad=n.isMac=n.getSafariVersion=n.isSafari=n.isLegacyEdge=n.isFirefox=n.isNode=void 0,n.isNode=typeof process<"u"&&"title"in process;const a=n.isNode?"node":navigator.userAgent,d=n.isNode?"node":navigator.platform;n.isFirefox=a.includes("Firefox"),n.isLegacyEdge=a.includes("Edge"),n.isSafari=/^((?!chrome|android).)*safari/i.test(a),n.getSafariVersion=function(){if(!n.isSafari)return 0;const h=a.match(/Version\/(\d+)/);return h===null||h.length<2?0:parseInt(h[1])},n.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(d),n.isIpad=d==="iPad",n.isIphone=d==="iPhone",n.isWindows=["Windows","Win16","Win32","WinCE"].includes(d),n.isLinux=d.indexOf("Linux")>=0,n.isChromeOS=/\bCrOS\b/.test(a)},6106:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SortedList=void 0;let a=0;n.SortedList=class{constructor(d){this._getKey=d,this._array=[]}clear(){this._array.length=0}insert(d){this._array.length!==0?(a=this._search(this._getKey(d)),this._array.splice(a,0,d)):this._array.push(d)}delete(d){if(this._array.length===0)return!1;const h=this._getKey(d);if(h===void 0||(a=this._search(h),a===-1)||this._getKey(this._array[a])!==h)return!1;do if(this._array[a]===d)return this._array.splice(a,1),!0;while(++a<this._array.length&&this._getKey(this._array[a])===h);return!1}*getKeyIterator(d){if(this._array.length!==0&&(a=this._search(d),!(a<0||a>=this._array.length)&&this._getKey(this._array[a])===d))do yield this._array[a];while(++a<this._array.length&&this._getKey(this._array[a])===d)}forEachByKey(d,h){if(this._array.length!==0&&(a=this._search(d),!(a<0||a>=this._array.length)&&this._getKey(this._array[a])===d))do h(this._array[a]);while(++a<this._array.length&&this._getKey(this._array[a])===d)}values(){return[...this._array].values()}_search(d){let h=0,c=this._array.length-1;for(;c>=h;){let f=h+c>>1;const v=this._getKey(this._array[f]);if(v>d)c=f-1;else{if(!(v<d)){for(;f>0&&this._getKey(this._array[f-1])===d;)f--;return f}h=f+1}}return h}}},7226:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DebouncedIdleTask=n.IdleTaskQueue=n.PriorityTaskQueue=void 0;const d=a(6114);class h{constructor(){this._tasks=[],this._i=0}enqueue(v){this._tasks.push(v),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(v){this._idleCallback=void 0;let y=0,u=0,i=v.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),u=Math.max(y,u),r=v.timeRemaining(),1.5*u>r)return i-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-y))}ms`),void this._start();i=r}this.clear()}}class c extends h{_requestCallback(v){return setTimeout((()=>v(this._createDeadline(16))))}_cancelCallback(v){clearTimeout(v)}_createDeadline(v){const y=Date.now()+v;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}n.PriorityTaskQueue=c,n.IdleTaskQueue=!d.isNode&&"requestIdleCallback"in window?class extends h{_requestCallback(f){return requestIdleCallback(f)}_cancelCallback(f){cancelIdleCallback(f)}}:c,n.DebouncedIdleTask=class{constructor(){this._queue=new n.IdleTaskQueue}set(f){this._queue.clear(),this._queue.enqueue(f)}flush(){this._queue.flush()}}},9282:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.updateWindowsModeWrappedState=void 0;const d=a(643);n.updateWindowsModeWrappedState=function(h){const c=h.buffer.lines.get(h.buffer.ybase+h.buffer.y-1),f=c==null?void 0:c.get(h.cols-1),v=h.buffer.lines.get(h.buffer.ybase+h.buffer.y);v&&f&&(v.isWrapped=f[d.CHAR_DATA_CODE_INDEX]!==d.NULL_CELL_CODE&&f[d.CHAR_DATA_CODE_INDEX]!==d.WHITESPACE_CELL_CODE)}},3734:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ExtendedAttrs=n.AttributeData=void 0;class a{constructor(){this.fg=0,this.bg=0,this.extended=new d}static toColorRGB(c){return[c>>>16&255,c>>>8&255,255&c]}static fromColorRGB(c){return(255&c[0])<<16|(255&c[1])<<8|255&c[2]}clone(){const c=new a;return c.fg=this.fg,c.bg=this.bg,c.extended=this.extended.clone(),c}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}n.AttributeData=a;class d{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(c){this._ext=c}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(c){this._ext&=-469762049,this._ext|=c<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(c){this._ext&=-67108864,this._ext|=67108863&c}get urlId(){return this._urlId}set urlId(c){this._urlId=c}get underlineVariantOffset(){const c=(3758096384&this._ext)>>29;return c<0?4294967288^c:c}set underlineVariantOffset(c){this._ext&=536870911,this._ext|=c<<29&3758096384}constructor(c=0,f=0){this._ext=0,this._urlId=0,this._ext=c,this._urlId=f}clone(){return new d(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}n.ExtendedAttrs=d},9092:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Buffer=n.MAX_BUFFER_SIZE=void 0;const d=a(6349),h=a(7226),c=a(3734),f=a(8437),v=a(4634),y=a(511),u=a(643),i=a(4863),r=a(7116);n.MAX_BUFFER_SIZE=4294967295,n.Buffer=class{constructor(s,l,_){this._hasScrollback=s,this._optionsService=l,this._bufferService=_,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=f.DEFAULT_ATTR_DATA.clone(),this.savedCharset=r.DEFAULT_CHARSET,this.markers=[],this._nullCell=y.CellData.fromCharData([0,u.NULL_CELL_CHAR,u.NULL_CELL_WIDTH,u.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,u.WHITESPACE_CELL_CHAR,u.WHITESPACE_CELL_WIDTH,u.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new h.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new d.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(s){return s?(this._nullCell.fg=s.fg,this._nullCell.bg=s.bg,this._nullCell.extended=s.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new c.ExtendedAttrs),this._nullCell}getWhitespaceCell(s){return s?(this._whitespaceCell.fg=s.fg,this._whitespaceCell.bg=s.bg,this._whitespaceCell.extended=s.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new c.ExtendedAttrs),this._whitespaceCell}getBlankLine(s,l){return new f.BufferLine(this._bufferService.cols,this.getNullCell(s),l)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const s=this.ybase+this.y-this.ydisp;return s>=0&&s<this._rows}_getCorrectBufferLength(s){if(!this._hasScrollback)return s;const l=s+this._optionsService.rawOptions.scrollback;return l>n.MAX_BUFFER_SIZE?n.MAX_BUFFER_SIZE:l}fillViewportRows(s){if(this.lines.length===0){s===void 0&&(s=f.DEFAULT_ATTR_DATA);let l=this._rows;for(;l--;)this.lines.push(this.getBlankLine(s))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new d.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(s,l){const _=this.getNullCell(f.DEFAULT_ATTR_DATA);let x=0;const C=this._getCorrectBufferLength(l);if(C>this.lines.maxLength&&(this.lines.maxLength=C),this.lines.length>0){if(this._cols<s)for(let p=0;p<this.lines.length;p++)x+=+this.lines.get(p).resize(s,_);let k=0;if(this._rows<l)for(let p=this._rows;p<l;p++)this.lines.length<l+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new f.BufferLine(s,_)):this.ybase>0&&this.lines.length<=this.ybase+this.y+k+1?(this.ybase--,k++,this.ydisp>0&&this.ydisp--):this.lines.push(new f.BufferLine(s,_)));else for(let p=this._rows;p>l;p--)this.lines.length>l+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(C<this.lines.maxLength){const p=this.lines.length-C;p>0&&(this.lines.trimStart(p),this.ybase=Math.max(this.ybase-p,0),this.ydisp=Math.max(this.ydisp-p,0),this.savedY=Math.max(this.savedY-p,0)),this.lines.maxLength=C}this.x=Math.min(this.x,s-1),this.y=Math.min(this.y,l-1),k&&(this.y+=k),this.savedX=Math.min(this.savedX,s-1),this.scrollTop=0}if(this.scrollBottom=l-1,this._isReflowEnabled&&(this._reflow(s,l),this._cols>s))for(let k=0;k<this.lines.length;k++)x+=+this.lines.get(k).resize(s,_);this._cols=s,this._rows=l,this._memoryCleanupQueue.clear(),x>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let s=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,s=!1);let l=0;for(;this._memoryCleanupPosition<this.lines.length;)if(l+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),l>100)return!0;return s}get _isReflowEnabled(){const s=this._optionsService.rawOptions.windowsPty;return s&&s.buildNumber?this._hasScrollback&&s.backend==="conpty"&&s.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(s,l){this._cols!==s&&(s>this._cols?this._reflowLarger(s,l):this._reflowSmaller(s,l))}_reflowLarger(s,l){const _=(0,v.reflowLargerGetLinesToRemove)(this.lines,this._cols,s,this.ybase+this.y,this.getNullCell(f.DEFAULT_ATTR_DATA));if(_.length>0){const x=(0,v.reflowLargerCreateNewLayout)(this.lines,_);(0,v.reflowLargerApplyNewLayout)(this.lines,x.layout),this._reflowLargerAdjustViewport(s,l,x.countRemoved)}}_reflowLargerAdjustViewport(s,l,_){const x=this.getNullCell(f.DEFAULT_ATTR_DATA);let C=_;for(;C-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<l&&this.lines.push(new f.BufferLine(s,x))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-_,0)}_reflowSmaller(s,l){const _=this.getNullCell(f.DEFAULT_ATTR_DATA),x=[];let C=0;for(let k=this.lines.length-1;k>=0;k--){let p=this.lines.get(k);if(!p||!p.isWrapped&&p.getTrimmedLength()<=s)continue;const w=[p];for(;p.isWrapped&&k>0;)p=this.lines.get(--k),w.unshift(p);const R=this.ybase+this.y;if(R>=k&&R<k+w.length)continue;const T=w[w.length-1].getTrimmedLength(),M=(0,v.reflowSmallerGetNewLineLengths)(w,this._cols,s),N=M.length-w.length;let I;I=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+N):Math.max(0,this.lines.length-this.lines.maxLength+N);const z=[];for(let B=0;B<N;B++){const P=this.getBlankLine(f.DEFAULT_ATTR_DATA,!0);z.push(P)}z.length>0&&(x.push({start:k+w.length+C,newLines:z}),C+=z.length),w.push(...z);let G=M.length-1,H=M[G];H===0&&(G--,H=M[G]);let V=w.length-N-1,L=T;for(;V>=0;){const B=Math.min(L,H);if(w[G]===void 0)break;if(w[G].copyCellsFrom(w[V],L-B,H-B,B,!0),H-=B,H===0&&(G--,H=M[G]),L-=B,L===0){V--;const P=Math.max(V,0);L=(0,v.getWrappedLineTrimmedLength)(w,P,this._cols)}}for(let B=0;B<w.length;B++)M[B]<s&&w[B].setCell(M[B],_);let A=N-I;for(;A-- >0;)this.ybase===0?this.y<l-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+C)-l&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+N,this.ybase+l-1)}if(x.length>0){const k=[],p=[];for(let G=0;G<this.lines.length;G++)p.push(this.lines.get(G));const w=this.lines.length;let R=w-1,T=0,M=x[T];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+C);let N=0;for(let G=Math.min(this.lines.maxLength-1,w+C-1);G>=0;G--)if(M&&M.start>R+N){for(let H=M.newLines.length-1;H>=0;H--)this.lines.set(G--,M.newLines[H]);G++,k.push({index:R+1,amount:M.newLines.length}),N+=M.newLines.length,M=x[++T]}else this.lines.set(G,p[R--]);let I=0;for(let G=k.length-1;G>=0;G--)k[G].index+=I,this.lines.onInsertEmitter.fire(k[G]),I+=k[G].amount;const z=Math.max(0,w+C-this.lines.maxLength);z>0&&this.lines.onTrimEmitter.fire(z)}}translateBufferLineToString(s,l,_=0,x){const C=this.lines.get(s);return C?C.translateToString(l,_,x):""}getWrappedRangeForLine(s){let l=s,_=s;for(;l>0&&this.lines.get(l).isWrapped;)l--;for(;_+1<this.lines.length&&this.lines.get(_+1).isWrapped;)_++;return{first:l,last:_}}setupTabStops(s){for(s!=null?this.tabs[s]||(s=this.prevStop(s)):(this.tabs={},s=0);s<this._cols;s+=this._optionsService.rawOptions.tabStopWidth)this.tabs[s]=!0}prevStop(s){for(s==null&&(s=this.x);!this.tabs[--s]&&s>0;);return s>=this._cols?this._cols-1:s<0?0:s}nextStop(s){for(s==null&&(s=this.x);!this.tabs[++s]&&s<this._cols;);return s>=this._cols?this._cols-1:s<0?0:s}clearMarkers(s){this._isClearing=!0;for(let l=0;l<this.markers.length;l++)this.markers[l].line===s&&(this.markers[l].dispose(),this.markers.splice(l--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let s=0;s<this.markers.length;s++)this.markers[s].dispose(),this.markers.splice(s--,1);this._isClearing=!1}addMarker(s){const l=new i.Marker(s);return this.markers.push(l),l.register(this.lines.onTrim((_=>{l.line-=_,l.line<0&&l.dispose()}))),l.register(this.lines.onInsert((_=>{l.line>=_.index&&(l.line+=_.amount)}))),l.register(this.lines.onDelete((_=>{l.line>=_.index&&l.line<_.index+_.amount&&l.dispose(),l.line>_.index&&(l.line-=_.amount)}))),l.register(l.onDispose((()=>this._removeMarker(l)))),l}_removeMarker(s){this._isClearing||this.markers.splice(this.markers.indexOf(s),1)}}},8437:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLine=n.DEFAULT_ATTR_DATA=void 0;const d=a(3734),h=a(511),c=a(643),f=a(482);n.DEFAULT_ATTR_DATA=Object.freeze(new d.AttributeData);let v=0;class y{constructor(i,r,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*i);const l=r||h.CellData.fromCharData([0,c.NULL_CELL_CHAR,c.NULL_CELL_WIDTH,c.NULL_CELL_CODE]);for(let _=0;_<i;++_)this.setCell(_,l);this.length=i}get(i){const r=this._data[3*i+0],s=2097151&r;return[this._data[3*i+1],2097152&r?this._combined[i]:s?(0,f.stringFromCodePoint)(s):"",r>>22,2097152&r?this._combined[i].charCodeAt(this._combined[i].length-1):s]}set(i,r){this._data[3*i+1]=r[c.CHAR_DATA_ATTR_INDEX],r[c.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[i]=r[1],this._data[3*i+0]=2097152|i|r[c.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*i+0]=r[c.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|r[c.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(i){return this._data[3*i+0]>>22}hasWidth(i){return 12582912&this._data[3*i+0]}getFg(i){return this._data[3*i+1]}getBg(i){return this._data[3*i+2]}hasContent(i){return 4194303&this._data[3*i+0]}getCodePoint(i){const r=this._data[3*i+0];return 2097152&r?this._combined[i].charCodeAt(this._combined[i].length-1):2097151&r}isCombined(i){return 2097152&this._data[3*i+0]}getString(i){const r=this._data[3*i+0];return 2097152&r?this._combined[i]:2097151&r?(0,f.stringFromCodePoint)(2097151&r):""}isProtected(i){return 536870912&this._data[3*i+2]}loadCell(i,r){return v=3*i,r.content=this._data[v+0],r.fg=this._data[v+1],r.bg=this._data[v+2],2097152&r.content&&(r.combinedData=this._combined[i]),268435456&r.bg&&(r.extended=this._extendedAttrs[i]),r}setCell(i,r){2097152&r.content&&(this._combined[i]=r.combinedData),268435456&r.bg&&(this._extendedAttrs[i]=r.extended),this._data[3*i+0]=r.content,this._data[3*i+1]=r.fg,this._data[3*i+2]=r.bg}setCellFromCodepoint(i,r,s,l){268435456&l.bg&&(this._extendedAttrs[i]=l.extended),this._data[3*i+0]=r|s<<22,this._data[3*i+1]=l.fg,this._data[3*i+2]=l.bg}addCodepointToCell(i,r,s){let l=this._data[3*i+0];2097152&l?this._combined[i]+=(0,f.stringFromCodePoint)(r):2097151&l?(this._combined[i]=(0,f.stringFromCodePoint)(2097151&l)+(0,f.stringFromCodePoint)(r),l&=-2097152,l|=2097152):l=r|4194304,s&&(l&=-12582913,l|=s<<22),this._data[3*i+0]=l}insertCells(i,r,s){if((i%=this.length)&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i-1,0,1,s),r<this.length-i){const l=new h.CellData;for(let _=this.length-i-r-1;_>=0;--_)this.setCell(i+r+_,this.loadCell(i+_,l));for(let _=0;_<r;++_)this.setCell(i+_,s)}else for(let l=i;l<this.length;++l)this.setCell(l,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(i,r,s){if(i%=this.length,r<this.length-i){const l=new h.CellData;for(let _=0;_<this.length-i-r;++_)this.setCell(i+_,this.loadCell(i+r+_,l));for(let _=this.length-r;_<this.length;++_)this.setCell(_,s)}else for(let l=i;l<this.length;++l)this.setCell(l,s);i&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i-1,0,1,s),this.getWidth(i)!==0||this.hasContent(i)||this.setCellFromCodepoint(i,0,1,s)}replaceCells(i,r,s,l=!1){if(l)for(i&&this.getWidth(i-1)===2&&!this.isProtected(i-1)&&this.setCellFromCodepoint(i-1,0,1,s),r<this.length&&this.getWidth(r-1)===2&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,s);i<r&&i<this.length;)this.isProtected(i)||this.setCell(i,s),i++;else for(i&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i-1,0,1,s),r<this.length&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r,0,1,s);i<r&&i<this.length;)this.setCell(i++,s)}resize(i,r){if(i===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const s=3*i;if(i>this.length){if(this._data.buffer.byteLength>=4*s)this._data=new Uint32Array(this._data.buffer,0,s);else{const l=new Uint32Array(s);l.set(this._data),this._data=l}for(let l=this.length;l<i;++l)this.setCell(l,r)}else{this._data=this._data.subarray(0,s);const l=Object.keys(this._combined);for(let x=0;x<l.length;x++){const C=parseInt(l[x],10);C>=i&&delete this._combined[C]}const _=Object.keys(this._extendedAttrs);for(let x=0;x<_.length;x++){const C=parseInt(_[x],10);C>=i&&delete this._extendedAttrs[C]}}return this.length=i,4*s*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const i=new Uint32Array(this._data.length);return i.set(this._data),this._data=i,1}return 0}fill(i,r=!1){if(r)for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,i);else{this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,i)}}copyFrom(i){this.length!==i.length?this._data=new Uint32Array(i._data):this._data.set(i._data),this.length=i.length,this._combined={};for(const r in i._combined)this._combined[r]=i._combined[r];this._extendedAttrs={};for(const r in i._extendedAttrs)this._extendedAttrs[r]=i._extendedAttrs[r];this.isWrapped=i.isWrapped}clone(){const i=new y(0);i._data=new Uint32Array(this._data),i.length=this.length;for(const r in this._combined)i._combined[r]=this._combined[r];for(const r in this._extendedAttrs)i._extendedAttrs[r]=this._extendedAttrs[r];return i.isWrapped=this.isWrapped,i}getTrimmedLength(){for(let i=this.length-1;i>=0;--i)if(4194303&this._data[3*i+0])return i+(this._data[3*i+0]>>22);return 0}getNoBgTrimmedLength(){for(let i=this.length-1;i>=0;--i)if(4194303&this._data[3*i+0]||50331648&this._data[3*i+2])return i+(this._data[3*i+0]>>22);return 0}copyCellsFrom(i,r,s,l,_){const x=i._data;if(_)for(let k=l-1;k>=0;k--){for(let p=0;p<3;p++)this._data[3*(s+k)+p]=x[3*(r+k)+p];268435456&x[3*(r+k)+2]&&(this._extendedAttrs[s+k]=i._extendedAttrs[r+k])}else for(let k=0;k<l;k++){for(let p=0;p<3;p++)this._data[3*(s+k)+p]=x[3*(r+k)+p];268435456&x[3*(r+k)+2]&&(this._extendedAttrs[s+k]=i._extendedAttrs[r+k])}const C=Object.keys(i._combined);for(let k=0;k<C.length;k++){const p=parseInt(C[k],10);p>=r&&(this._combined[p-r+s]=i._combined[p])}}translateToString(i,r,s,l){r=r??0,s=s??this.length,i&&(s=Math.min(s,this.getTrimmedLength())),l&&(l.length=0);let _="";for(;r<s;){const x=this._data[3*r+0],C=2097151&x,k=2097152&x?this._combined[r]:C?(0,f.stringFromCodePoint)(C):c.WHITESPACE_CELL_CHAR;if(_+=k,l)for(let p=0;p<k.length;++p)l.push(r);r+=x>>22||1}return l&&l.push(r),_}}n.BufferLine=y},4841:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getRangeLength=void 0,n.getRangeLength=function(a,d){if(a.start.y>a.end.y)throw new Error(`Buffer range end (${a.end.x}, ${a.end.y}) cannot be before start (${a.start.x}, ${a.start.y})`);return d*(a.end.y-a.start.y)+(a.end.x-a.start.x+1)}},4634:(b,n)=>{function a(d,h,c){if(h===d.length-1)return d[h].getTrimmedLength();const f=!d[h].hasContent(c-1)&&d[h].getWidth(c-1)===1,v=d[h+1].getWidth(0)===2;return f&&v?c-1:c}Object.defineProperty(n,"__esModule",{value:!0}),n.getWrappedLineTrimmedLength=n.reflowSmallerGetNewLineLengths=n.reflowLargerApplyNewLayout=n.reflowLargerCreateNewLayout=n.reflowLargerGetLinesToRemove=void 0,n.reflowLargerGetLinesToRemove=function(d,h,c,f,v){const y=[];for(let u=0;u<d.length-1;u++){let i=u,r=d.get(++i);if(!r.isWrapped)continue;const s=[d.get(u)];for(;i<d.length&&r.isWrapped;)s.push(r),r=d.get(++i);if(f>=u&&f<i){u+=s.length-1;continue}let l=0,_=a(s,l,h),x=1,C=0;for(;x<s.length;){const p=a(s,x,h),w=p-C,R=c-_,T=Math.min(w,R);s[l].copyCellsFrom(s[x],C,_,T,!1),_+=T,_===c&&(l++,_=0),C+=T,C===p&&(x++,C=0),_===0&&l!==0&&s[l-1].getWidth(c-1)===2&&(s[l].copyCellsFrom(s[l-1],c-1,_++,1,!1),s[l-1].setCell(c-1,v))}s[l].replaceCells(_,c,v);let k=0;for(let p=s.length-1;p>0&&(p>l||s[p].getTrimmedLength()===0);p--)k++;k>0&&(y.push(u+s.length-k),y.push(k)),u+=s.length-1}return y},n.reflowLargerCreateNewLayout=function(d,h){const c=[];let f=0,v=h[f],y=0;for(let u=0;u<d.length;u++)if(v===u){const i=h[++f];d.onDeleteEmitter.fire({index:u-y,amount:i}),u+=i-1,y+=i,v=h[++f]}else c.push(u);return{layout:c,countRemoved:y}},n.reflowLargerApplyNewLayout=function(d,h){const c=[];for(let f=0;f<h.length;f++)c.push(d.get(h[f]));for(let f=0;f<c.length;f++)d.set(f,c[f]);d.length=h.length},n.reflowSmallerGetNewLineLengths=function(d,h,c){const f=[],v=d.map(((r,s)=>a(d,s,h))).reduce(((r,s)=>r+s));let y=0,u=0,i=0;for(;i<v;){if(v-i<c){f.push(v-i);break}y+=c;const r=a(d,u,h);y>r&&(y-=r,u++);const s=d[u].getWidth(y-1)===2;s&&y--;const l=s?c-1:c;f.push(l),i+=l}return f},n.getWrappedLineTrimmedLength=a},5295:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferSet=void 0;const d=a(8460),h=a(844),c=a(9092);class f extends h.Disposable{constructor(y,u){super(),this._optionsService=y,this._bufferService=u,this._onBufferActivate=this.register(new d.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new c.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new c.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(y){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(y),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(y,u){this._normal.resize(y,u),this._alt.resize(y,u),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}n.BufferSet=f},511:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CellData=void 0;const d=a(482),h=a(643),c=a(3734);class f extends c.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new c.ExtendedAttrs,this.combinedData=""}static fromCharData(y){const u=new f;return u.setFromCharData(y),u}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,d.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(y){this.fg=y[h.CHAR_DATA_ATTR_INDEX],this.bg=0;let u=!1;if(y[h.CHAR_DATA_CHAR_INDEX].length>2)u=!0;else if(y[h.CHAR_DATA_CHAR_INDEX].length===2){const i=y[h.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=i&&i<=56319){const r=y[h.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=r&&r<=57343?this.content=1024*(i-55296)+r-56320+65536|y[h.CHAR_DATA_WIDTH_INDEX]<<22:u=!0}else u=!0}else this.content=y[h.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[h.CHAR_DATA_WIDTH_INDEX]<<22;u&&(this.combinedData=y[h.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[h.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.CellData=f},643:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WHITESPACE_CELL_CODE=n.WHITESPACE_CELL_WIDTH=n.WHITESPACE_CELL_CHAR=n.NULL_CELL_CODE=n.NULL_CELL_WIDTH=n.NULL_CELL_CHAR=n.CHAR_DATA_CODE_INDEX=n.CHAR_DATA_WIDTH_INDEX=n.CHAR_DATA_CHAR_INDEX=n.CHAR_DATA_ATTR_INDEX=n.DEFAULT_EXT=n.DEFAULT_ATTR=n.DEFAULT_COLOR=void 0,n.DEFAULT_COLOR=0,n.DEFAULT_ATTR=256|n.DEFAULT_COLOR<<9,n.DEFAULT_EXT=0,n.CHAR_DATA_ATTR_INDEX=0,n.CHAR_DATA_CHAR_INDEX=1,n.CHAR_DATA_WIDTH_INDEX=2,n.CHAR_DATA_CODE_INDEX=3,n.NULL_CELL_CHAR="",n.NULL_CELL_WIDTH=1,n.NULL_CELL_CODE=0,n.WHITESPACE_CELL_CHAR=" ",n.WHITESPACE_CELL_WIDTH=1,n.WHITESPACE_CELL_CODE=32},4863:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Marker=void 0;const d=a(8460),h=a(844);class c{get id(){return this._id}constructor(v){this.line=v,this.isDisposed=!1,this._disposables=[],this._id=c._nextId++,this._onDispose=this.register(new d.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,h.disposeArray)(this._disposables),this._disposables.length=0)}register(v){return this._disposables.push(v),v}}n.Marker=c,c._nextId=1},7116:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DEFAULT_CHARSET=n.CHARSETS=void 0,n.CHARSETS={},n.DEFAULT_CHARSET=n.CHARSETS.B,n.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},n.CHARSETS.A={"#":"£"},n.CHARSETS.B=void 0,n.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},n.CHARSETS.C=n.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},n.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},n.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},n.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},n.CHARSETS.E=n.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},n.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},n.CHARSETS.H=n.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(b,n)=>{var a,d,h;Object.defineProperty(n,"__esModule",{value:!0}),n.C1_ESCAPED=n.C1=n.C0=void 0,(function(c){c.NUL="\0",c.SOH="",c.STX="",c.ETX="",c.EOT="",c.ENQ="",c.ACK="",c.BEL="\x07",c.BS="\b",c.HT=" ",c.LF=`
171
+ `,c.VT="\v",c.FF="\f",c.CR="\r",c.SO="",c.SI="",c.DLE="",c.DC1="",c.DC2="",c.DC3="",c.DC4="",c.NAK="",c.SYN="",c.ETB="",c.CAN="",c.EM="",c.SUB="",c.ESC="\x1B",c.FS="",c.GS="",c.RS="",c.US="",c.SP=" ",c.DEL=""})(a||(n.C0=a={})),(function(c){c.PAD="€",c.HOP="",c.BPH="‚",c.NBH="ƒ",c.IND="„",c.NEL="…",c.SSA="†",c.ESA="‡",c.HTS="ˆ",c.HTJ="‰",c.VTS="Š",c.PLD="‹",c.PLU="Œ",c.RI="",c.SS2="Ž",c.SS3="",c.DCS="",c.PU1="‘",c.PU2="’",c.STS="“",c.CCH="”",c.MW="•",c.SPA="–",c.EPA="—",c.SOS="˜",c.SGCI="™",c.SCI="š",c.CSI="›",c.ST="œ",c.OSC="",c.PM="ž",c.APC="Ÿ"})(d||(n.C1=d={})),(function(c){c.ST=`${a.ESC}\\`})(h||(n.C1_ESCAPED=h={}))},7399:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.evaluateKeyboardEvent=void 0;const d=a(2584),h={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};n.evaluateKeyboardEvent=function(c,f,v,y){const u={type:0,cancel:!1,key:void 0},i=(c.shiftKey?1:0)|(c.altKey?2:0)|(c.ctrlKey?4:0)|(c.metaKey?8:0);switch(c.keyCode){case 0:c.key==="UIKeyInputUpArrow"?u.key=f?d.C0.ESC+"OA":d.C0.ESC+"[A":c.key==="UIKeyInputLeftArrow"?u.key=f?d.C0.ESC+"OD":d.C0.ESC+"[D":c.key==="UIKeyInputRightArrow"?u.key=f?d.C0.ESC+"OC":d.C0.ESC+"[C":c.key==="UIKeyInputDownArrow"&&(u.key=f?d.C0.ESC+"OB":d.C0.ESC+"[B");break;case 8:u.key=c.ctrlKey?"\b":d.C0.DEL,c.altKey&&(u.key=d.C0.ESC+u.key);break;case 9:if(c.shiftKey){u.key=d.C0.ESC+"[Z";break}u.key=d.C0.HT,u.cancel=!0;break;case 13:u.key=c.altKey?d.C0.ESC+d.C0.CR:d.C0.CR,u.cancel=!0;break;case 27:u.key=d.C0.ESC,c.altKey&&(u.key=d.C0.ESC+d.C0.ESC),u.cancel=!0;break;case 37:if(c.metaKey)break;i?(u.key=d.C0.ESC+"[1;"+(i+1)+"D",u.key===d.C0.ESC+"[1;3D"&&(u.key=d.C0.ESC+(v?"b":"[1;5D"))):u.key=f?d.C0.ESC+"OD":d.C0.ESC+"[D";break;case 39:if(c.metaKey)break;i?(u.key=d.C0.ESC+"[1;"+(i+1)+"C",u.key===d.C0.ESC+"[1;3C"&&(u.key=d.C0.ESC+(v?"f":"[1;5C"))):u.key=f?d.C0.ESC+"OC":d.C0.ESC+"[C";break;case 38:if(c.metaKey)break;i?(u.key=d.C0.ESC+"[1;"+(i+1)+"A",v||u.key!==d.C0.ESC+"[1;3A"||(u.key=d.C0.ESC+"[1;5A")):u.key=f?d.C0.ESC+"OA":d.C0.ESC+"[A";break;case 40:if(c.metaKey)break;i?(u.key=d.C0.ESC+"[1;"+(i+1)+"B",v||u.key!==d.C0.ESC+"[1;3B"||(u.key=d.C0.ESC+"[1;5B")):u.key=f?d.C0.ESC+"OB":d.C0.ESC+"[B";break;case 45:c.shiftKey||c.ctrlKey||(u.key=d.C0.ESC+"[2~");break;case 46:u.key=i?d.C0.ESC+"[3;"+(i+1)+"~":d.C0.ESC+"[3~";break;case 36:u.key=i?d.C0.ESC+"[1;"+(i+1)+"H":f?d.C0.ESC+"OH":d.C0.ESC+"[H";break;case 35:u.key=i?d.C0.ESC+"[1;"+(i+1)+"F":f?d.C0.ESC+"OF":d.C0.ESC+"[F";break;case 33:c.shiftKey?u.type=2:c.ctrlKey?u.key=d.C0.ESC+"[5;"+(i+1)+"~":u.key=d.C0.ESC+"[5~";break;case 34:c.shiftKey?u.type=3:c.ctrlKey?u.key=d.C0.ESC+"[6;"+(i+1)+"~":u.key=d.C0.ESC+"[6~";break;case 112:u.key=i?d.C0.ESC+"[1;"+(i+1)+"P":d.C0.ESC+"OP";break;case 113:u.key=i?d.C0.ESC+"[1;"+(i+1)+"Q":d.C0.ESC+"OQ";break;case 114:u.key=i?d.C0.ESC+"[1;"+(i+1)+"R":d.C0.ESC+"OR";break;case 115:u.key=i?d.C0.ESC+"[1;"+(i+1)+"S":d.C0.ESC+"OS";break;case 116:u.key=i?d.C0.ESC+"[15;"+(i+1)+"~":d.C0.ESC+"[15~";break;case 117:u.key=i?d.C0.ESC+"[17;"+(i+1)+"~":d.C0.ESC+"[17~";break;case 118:u.key=i?d.C0.ESC+"[18;"+(i+1)+"~":d.C0.ESC+"[18~";break;case 119:u.key=i?d.C0.ESC+"[19;"+(i+1)+"~":d.C0.ESC+"[19~";break;case 120:u.key=i?d.C0.ESC+"[20;"+(i+1)+"~":d.C0.ESC+"[20~";break;case 121:u.key=i?d.C0.ESC+"[21;"+(i+1)+"~":d.C0.ESC+"[21~";break;case 122:u.key=i?d.C0.ESC+"[23;"+(i+1)+"~":d.C0.ESC+"[23~";break;case 123:u.key=i?d.C0.ESC+"[24;"+(i+1)+"~":d.C0.ESC+"[24~";break;default:if(!c.ctrlKey||c.shiftKey||c.altKey||c.metaKey)if(v&&!y||!c.altKey||c.metaKey)!v||c.altKey||c.ctrlKey||c.shiftKey||!c.metaKey?c.key&&!c.ctrlKey&&!c.altKey&&!c.metaKey&&c.keyCode>=48&&c.key.length===1?u.key=c.key:c.key&&c.ctrlKey&&(c.key==="_"&&(u.key=d.C0.US),c.key==="@"&&(u.key=d.C0.NUL)):c.keyCode===65&&(u.type=1);else{const r=h[c.keyCode],s=r==null?void 0:r[c.shiftKey?1:0];if(s)u.key=d.C0.ESC+s;else if(c.keyCode>=65&&c.keyCode<=90){const l=c.ctrlKey?c.keyCode-64:c.keyCode+32;let _=String.fromCharCode(l);c.shiftKey&&(_=_.toUpperCase()),u.key=d.C0.ESC+_}else if(c.keyCode===32)u.key=d.C0.ESC+(c.ctrlKey?d.C0.NUL:" ");else if(c.key==="Dead"&&c.code.startsWith("Key")){let l=c.code.slice(3,4);c.shiftKey||(l=l.toLowerCase()),u.key=d.C0.ESC+l,u.cancel=!0}}else c.keyCode>=65&&c.keyCode<=90?u.key=String.fromCharCode(c.keyCode-64):c.keyCode===32?u.key=d.C0.NUL:c.keyCode>=51&&c.keyCode<=55?u.key=String.fromCharCode(c.keyCode-51+27):c.keyCode===56?u.key=d.C0.DEL:c.keyCode===219?u.key=d.C0.ESC:c.keyCode===220?u.key=d.C0.FS:c.keyCode===221&&(u.key=d.C0.GS)}return u}},482:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Utf8ToUtf32=n.StringToUtf32=n.utf32ToString=n.stringFromCodePoint=void 0,n.stringFromCodePoint=function(a){return a>65535?(a-=65536,String.fromCharCode(55296+(a>>10))+String.fromCharCode(a%1024+56320)):String.fromCharCode(a)},n.utf32ToString=function(a,d=0,h=a.length){let c="";for(let f=d;f<h;++f){let v=a[f];v>65535?(v-=65536,c+=String.fromCharCode(55296+(v>>10))+String.fromCharCode(v%1024+56320)):c+=String.fromCharCode(v)}return c},n.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(a,d){const h=a.length;if(!h)return 0;let c=0,f=0;if(this._interim){const v=a.charCodeAt(f++);56320<=v&&v<=57343?d[c++]=1024*(this._interim-55296)+v-56320+65536:(d[c++]=this._interim,d[c++]=v),this._interim=0}for(let v=f;v<h;++v){const y=a.charCodeAt(v);if(55296<=y&&y<=56319){if(++v>=h)return this._interim=y,c;const u=a.charCodeAt(v);56320<=u&&u<=57343?d[c++]=1024*(y-55296)+u-56320+65536:(d[c++]=y,d[c++]=u)}else y!==65279&&(d[c++]=y)}return c}},n.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(a,d){const h=a.length;if(!h)return 0;let c,f,v,y,u=0,i=0,r=0;if(this.interim[0]){let _=!1,x=this.interim[0];x&=(224&x)==192?31:(240&x)==224?15:7;let C,k=0;for(;(C=63&this.interim[++k])&&k<4;)x<<=6,x|=C;const p=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,w=p-k;for(;r<w;){if(r>=h)return 0;if(C=a[r++],(192&C)!=128){r--,_=!0;break}this.interim[k++]=C,x<<=6,x|=63&C}_||(p===2?x<128?r--:d[u++]=x:p===3?x<2048||x>=55296&&x<=57343||x===65279||(d[u++]=x):x<65536||x>1114111||(d[u++]=x)),this.interim.fill(0)}const s=h-4;let l=r;for(;l<h;){for(;!(!(l<s)||128&(c=a[l])||128&(f=a[l+1])||128&(v=a[l+2])||128&(y=a[l+3]));)d[u++]=c,d[u++]=f,d[u++]=v,d[u++]=y,l+=4;if(c=a[l++],c<128)d[u++]=c;else if((224&c)==192){if(l>=h)return this.interim[0]=c,u;if(f=a[l++],(192&f)!=128){l--;continue}if(i=(31&c)<<6|63&f,i<128){l--;continue}d[u++]=i}else if((240&c)==224){if(l>=h)return this.interim[0]=c,u;if(f=a[l++],(192&f)!=128){l--;continue}if(l>=h)return this.interim[0]=c,this.interim[1]=f,u;if(v=a[l++],(192&v)!=128){l--;continue}if(i=(15&c)<<12|(63&f)<<6|63&v,i<2048||i>=55296&&i<=57343||i===65279)continue;d[u++]=i}else if((248&c)==240){if(l>=h)return this.interim[0]=c,u;if(f=a[l++],(192&f)!=128){l--;continue}if(l>=h)return this.interim[0]=c,this.interim[1]=f,u;if(v=a[l++],(192&v)!=128){l--;continue}if(l>=h)return this.interim[0]=c,this.interim[1]=f,this.interim[2]=v,u;if(y=a[l++],(192&y)!=128){l--;continue}if(i=(7&c)<<18|(63&f)<<12|(63&v)<<6|63&y,i<65536||i>1114111)continue;d[u++]=i}}return u}}},225:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeV6=void 0;const d=a(1480),h=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],c=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let f;n.UnicodeV6=class{constructor(){if(this.version="6",!f){f=new Uint8Array(65536),f.fill(1),f[0]=0,f.fill(0,1,32),f.fill(0,127,160),f.fill(2,4352,4448),f[9001]=2,f[9002]=2,f.fill(2,11904,42192),f[12351]=1,f.fill(2,44032,55204),f.fill(2,63744,64256),f.fill(2,65040,65050),f.fill(2,65072,65136),f.fill(2,65280,65377),f.fill(2,65504,65511);for(let v=0;v<h.length;++v)f.fill(0,h[v][0],h[v][1]+1)}}wcwidth(v){return v<32?0:v<127?1:v<65536?f[v]:(function(y,u){let i,r=0,s=u.length-1;if(y<u[0][0]||y>u[s][1])return!1;for(;s>=r;)if(i=r+s>>1,y>u[i][1])r=i+1;else{if(!(y<u[i][0]))return!0;s=i-1}return!1})(v,c)?0:v>=131072&&v<=196605||v>=196608&&v<=262141?2:1}charProperties(v,y){let u=this.wcwidth(v),i=u===0&&y!==0;if(i){const r=d.UnicodeService.extractWidth(y);r===0?i=!1:r>u&&(u=r)}return d.UnicodeService.createPropertyValue(0,u,i)}}},5981:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WriteBuffer=void 0;const d=a(8460),h=a(844);class c extends h.Disposable{constructor(v){super(),this._action=v,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new d.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(v,y){if(y!==void 0&&this._syncCalls>y)return void(this._syncCalls=0);if(this._pendingData+=v.length,this._writeBuffer.push(v),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let u;for(this._isSyncWriting=!0;u=this._writeBuffer.shift();){this._action(u);const i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(v,y){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=v.length,this._writeBuffer.push(v),this._callbacks.push(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=v.length,this._writeBuffer.push(v),this._callbacks.push(y)}_innerWrite(v=0,y=!0){const u=v||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const i=this._writeBuffer[this._bufferOffset],r=this._action(i,y);if(r){const l=_=>Date.now()-u>=12?setTimeout((()=>this._innerWrite(0,_))):this._innerWrite(u,_);return void r.catch((_=>(queueMicrotask((()=>{throw _})),Promise.resolve(!1)))).then(l)}const s=this._callbacks[this._bufferOffset];if(s&&s(),this._bufferOffset++,this._pendingData-=i.length,Date.now()-u>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}n.WriteBuffer=c},5941:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.toRgbString=n.parseColor=void 0;const a=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,d=/^[\da-f]+$/;function h(c,f){const v=c.toString(16),y=v.length<2?"0"+v:v;switch(f){case 4:return v[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}n.parseColor=function(c){if(!c)return;let f=c.toLowerCase();if(f.indexOf("rgb:")===0){f=f.slice(4);const v=a.exec(f);if(v){const y=v[1]?15:v[4]?255:v[7]?4095:65535;return[Math.round(parseInt(v[1]||v[4]||v[7]||v[10],16)/y*255),Math.round(parseInt(v[2]||v[5]||v[8]||v[11],16)/y*255),Math.round(parseInt(v[3]||v[6]||v[9]||v[12],16)/y*255)]}}else if(f.indexOf("#")===0&&(f=f.slice(1),d.exec(f)&&[3,6,9,12].includes(f.length))){const v=f.length/3,y=[0,0,0];for(let u=0;u<3;++u){const i=parseInt(f.slice(v*u,v*u+v),16);y[u]=v===1?i<<4:v===2?i:v===3?i>>4:i>>8}return y}},n.toRgbString=function(c,f=16){const[v,y,u]=c;return`rgb:${h(v,f)}/${h(y,f)}/${h(u,f)}`}},5770:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.PAYLOAD_LIMIT=void 0,n.PAYLOAD_LIMIT=1e7},6351:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DcsHandler=n.DcsParser=void 0;const d=a(482),h=a(8742),c=a(5770),f=[];n.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=f,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=f}registerHandler(y,u){this._handlers[y]===void 0&&(this._handlers[y]=[]);const i=this._handlers[y];return i.push(u),{dispose:()=>{const r=i.indexOf(u);r!==-1&&i.splice(r,1)}}}clearHandler(y){this._handlers[y]&&delete this._handlers[y]}setHandlerFallback(y){this._handlerFb=y}reset(){if(this._active.length)for(let y=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;y>=0;--y)this._active[y].unhook(!1);this._stack.paused=!1,this._active=f,this._ident=0}hook(y,u){if(this.reset(),this._ident=y,this._active=this._handlers[y]||f,this._active.length)for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(u);else this._handlerFb(this._ident,"HOOK",u)}put(y,u,i){if(this._active.length)for(let r=this._active.length-1;r>=0;r--)this._active[r].put(y,u,i);else this._handlerFb(this._ident,"PUT",(0,d.utf32ToString)(y,u,i))}unhook(y,u=!0){if(this._active.length){let i=!1,r=this._active.length-1,s=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,i=u,s=this._stack.fallThrough,this._stack.paused=!1),!s&&i===!1){for(;r>=0&&(i=this._active[r].unhook(y),i!==!0);r--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,i;r--}for(;r>=0;r--)if(i=this._active[r].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,i}else this._handlerFb(this._ident,"UNHOOK",y);this._active=f,this._ident=0}};const v=new h.Params;v.addParam(0),n.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=v,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():v,this._data="",this._hitLimit=!1}put(y,u,i){this._hitLimit||(this._data+=(0,d.utf32ToString)(y,u,i),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let u=!1;if(this._hitLimit)u=!1;else if(y&&(u=this._handler(this._data,this._params),u instanceof Promise))return u.then((i=>(this._params=v,this._data="",this._hitLimit=!1,i)));return this._params=v,this._data="",this._hitLimit=!1,u}}},2015:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.EscapeSequenceParser=n.VT500_TRANSITION_TABLE=n.TransitionTable=void 0;const d=a(844),h=a(8742),c=a(6242),f=a(6351);class v{constructor(r){this.table=new Uint8Array(r)}setDefault(r,s){this.table.fill(r<<4|s)}add(r,s,l,_){this.table[s<<8|r]=l<<4|_}addMany(r,s,l,_){for(let x=0;x<r.length;x++)this.table[s<<8|r[x]]=l<<4|_}}n.TransitionTable=v;const y=160;n.VT500_TRANSITION_TABLE=(function(){const i=new v(4095),r=Array.apply(null,Array(256)).map(((k,p)=>p)),s=(k,p)=>r.slice(k,p),l=s(32,127),_=s(0,24);_.push(25),_.push.apply(_,s(28,32));const x=s(0,14);let C;for(C in i.setDefault(1,0),i.addMany(l,0,2,0),x)i.addMany([24,26,153,154],C,3,0),i.addMany(s(128,144),C,3,0),i.addMany(s(144,152),C,3,0),i.add(156,C,0,0),i.add(27,C,11,1),i.add(157,C,4,8),i.addMany([152,158,159],C,0,7),i.add(155,C,11,3),i.add(144,C,11,9);return i.addMany(_,0,3,0),i.addMany(_,1,3,1),i.add(127,1,0,1),i.addMany(_,8,0,8),i.addMany(_,3,3,3),i.add(127,3,0,3),i.addMany(_,4,3,4),i.add(127,4,0,4),i.addMany(_,6,3,6),i.addMany(_,5,3,5),i.add(127,5,0,5),i.addMany(_,2,3,2),i.add(127,2,0,2),i.add(93,1,4,8),i.addMany(l,8,5,8),i.add(127,8,5,8),i.addMany([156,27,24,26,7],8,6,0),i.addMany(s(28,32),8,0,8),i.addMany([88,94,95],1,0,7),i.addMany(l,7,0,7),i.addMany(_,7,0,7),i.add(156,7,0,0),i.add(127,7,0,7),i.add(91,1,11,3),i.addMany(s(64,127),3,7,0),i.addMany(s(48,60),3,8,4),i.addMany([60,61,62,63],3,9,4),i.addMany(s(48,60),4,8,4),i.addMany(s(64,127),4,7,0),i.addMany([60,61,62,63],4,0,6),i.addMany(s(32,64),6,0,6),i.add(127,6,0,6),i.addMany(s(64,127),6,0,0),i.addMany(s(32,48),3,9,5),i.addMany(s(32,48),5,9,5),i.addMany(s(48,64),5,0,6),i.addMany(s(64,127),5,7,0),i.addMany(s(32,48),4,9,5),i.addMany(s(32,48),1,9,2),i.addMany(s(32,48),2,9,2),i.addMany(s(48,127),2,10,0),i.addMany(s(48,80),1,10,0),i.addMany(s(81,88),1,10,0),i.addMany([89,90,92],1,10,0),i.addMany(s(96,127),1,10,0),i.add(80,1,11,9),i.addMany(_,9,0,9),i.add(127,9,0,9),i.addMany(s(28,32),9,0,9),i.addMany(s(32,48),9,9,12),i.addMany(s(48,60),9,8,10),i.addMany([60,61,62,63],9,9,10),i.addMany(_,11,0,11),i.addMany(s(32,128),11,0,11),i.addMany(s(28,32),11,0,11),i.addMany(_,10,0,10),i.add(127,10,0,10),i.addMany(s(28,32),10,0,10),i.addMany(s(48,60),10,8,10),i.addMany([60,61,62,63],10,0,11),i.addMany(s(32,48),10,9,12),i.addMany(_,12,0,12),i.add(127,12,0,12),i.addMany(s(28,32),12,0,12),i.addMany(s(32,48),12,9,12),i.addMany(s(48,64),12,0,11),i.addMany(s(64,127),12,12,13),i.addMany(s(64,127),10,12,13),i.addMany(s(64,127),9,12,13),i.addMany(_,13,13,13),i.addMany(l,13,13,13),i.add(127,13,0,13),i.addMany([27,156,24,26],13,14,0),i.add(y,0,2,0),i.add(y,8,5,8),i.add(y,6,0,6),i.add(y,11,0,11),i.add(y,13,13,13),i})();class u extends d.Disposable{constructor(r=n.VT500_TRANSITION_TABLE){super(),this._transitions=r,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new h.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(s,l,_)=>{},this._executeHandlerFb=s=>{},this._csiHandlerFb=(s,l)=>{},this._escHandlerFb=s=>{},this._errorHandlerFb=s=>s,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,d.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new c.OscParser),this._dcsParser=this.register(new f.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(r,s=[64,126]){let l=0;if(r.prefix){if(r.prefix.length>1)throw new Error("only one byte as prefix supported");if(l=r.prefix.charCodeAt(0),l&&60>l||l>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(r.intermediates){if(r.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let x=0;x<r.intermediates.length;++x){const C=r.intermediates.charCodeAt(x);if(32>C||C>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");l<<=8,l|=C}}if(r.final.length!==1)throw new Error("final must be a single byte");const _=r.final.charCodeAt(0);if(s[0]>_||_>s[1])throw new Error(`final must be in range ${s[0]} .. ${s[1]}`);return l<<=8,l|=_,l}identToString(r){const s=[];for(;r;)s.push(String.fromCharCode(255&r)),r>>=8;return s.reverse().join("")}setPrintHandler(r){this._printHandler=r}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(r,s){const l=this._identifier(r,[48,126]);this._escHandlers[l]===void 0&&(this._escHandlers[l]=[]);const _=this._escHandlers[l];return _.push(s),{dispose:()=>{const x=_.indexOf(s);x!==-1&&_.splice(x,1)}}}clearEscHandler(r){this._escHandlers[this._identifier(r,[48,126])]&&delete this._escHandlers[this._identifier(r,[48,126])]}setEscHandlerFallback(r){this._escHandlerFb=r}setExecuteHandler(r,s){this._executeHandlers[r.charCodeAt(0)]=s}clearExecuteHandler(r){this._executeHandlers[r.charCodeAt(0)]&&delete this._executeHandlers[r.charCodeAt(0)]}setExecuteHandlerFallback(r){this._executeHandlerFb=r}registerCsiHandler(r,s){const l=this._identifier(r);this._csiHandlers[l]===void 0&&(this._csiHandlers[l]=[]);const _=this._csiHandlers[l];return _.push(s),{dispose:()=>{const x=_.indexOf(s);x!==-1&&_.splice(x,1)}}}clearCsiHandler(r){this._csiHandlers[this._identifier(r)]&&delete this._csiHandlers[this._identifier(r)]}setCsiHandlerFallback(r){this._csiHandlerFb=r}registerDcsHandler(r,s){return this._dcsParser.registerHandler(this._identifier(r),s)}clearDcsHandler(r){this._dcsParser.clearHandler(this._identifier(r))}setDcsHandlerFallback(r){this._dcsParser.setHandlerFallback(r)}registerOscHandler(r,s){return this._oscParser.registerHandler(r,s)}clearOscHandler(r){this._oscParser.clearHandler(r)}setOscHandlerFallback(r){this._oscParser.setHandlerFallback(r)}setErrorHandler(r){this._errorHandler=r}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(r,s,l,_,x){this._parseStack.state=r,this._parseStack.handlers=s,this._parseStack.handlerPos=l,this._parseStack.transition=_,this._parseStack.chunkPos=x}parse(r,s,l){let _,x=0,C=0,k=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,k=this._parseStack.chunkPos+1;else{if(l===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const p=this._parseStack.handlers;let w=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(l===!1&&w>-1){for(;w>=0&&(_=p[w](this._params),_!==!0);w--)if(_ instanceof Promise)return this._parseStack.handlerPos=w,_}this._parseStack.handlers=[];break;case 4:if(l===!1&&w>-1){for(;w>=0&&(_=p[w](),_!==!0);w--)if(_ instanceof Promise)return this._parseStack.handlerPos=w,_}this._parseStack.handlers=[];break;case 6:if(x=r[this._parseStack.chunkPos],_=this._dcsParser.unhook(x!==24&&x!==26,l),_)return _;x===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(x=r[this._parseStack.chunkPos],_=this._oscParser.end(x!==24&&x!==26,l),_)return _;x===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,k=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let p=k;p<s;++p){switch(x=r[p],C=this._transitions.table[this.currentState<<8|(x<160?x:y)],C>>4){case 2:for(let N=p+1;;++N){if(N>=s||(x=r[N])<32||x>126&&x<y){this._printHandler(r,p,N),p=N-1;break}if(++N>=s||(x=r[N])<32||x>126&&x<y){this._printHandler(r,p,N),p=N-1;break}if(++N>=s||(x=r[N])<32||x>126&&x<y){this._printHandler(r,p,N),p=N-1;break}if(++N>=s||(x=r[N])<32||x>126&&x<y){this._printHandler(r,p,N),p=N-1;break}}break;case 3:this._executeHandlers[x]?this._executeHandlers[x]():this._executeHandlerFb(x),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:p,code:x,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const w=this._csiHandlers[this._collect<<8|x];let R=w?w.length-1:-1;for(;R>=0&&(_=w[R](this._params),_!==!0);R--)if(_ instanceof Promise)return this._preserveStack(3,w,R,C,p),_;R<0&&this._csiHandlerFb(this._collect<<8|x,this._params),this.precedingJoinState=0;break;case 8:do switch(x){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(x-48)}while(++p<s&&(x=r[p])>47&&x<60);p--;break;case 9:this._collect<<=8,this._collect|=x;break;case 10:const T=this._escHandlers[this._collect<<8|x];let M=T?T.length-1:-1;for(;M>=0&&(_=T[M](),_!==!0);M--)if(_ instanceof Promise)return this._preserveStack(4,T,M,C,p),_;M<0&&this._escHandlerFb(this._collect<<8|x),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|x,this._params);break;case 13:for(let N=p+1;;++N)if(N>=s||(x=r[N])===24||x===26||x===27||x>127&&x<y){this._dcsParser.put(r,p,N),p=N-1;break}break;case 14:if(_=this._dcsParser.unhook(x!==24&&x!==26),_)return this._preserveStack(6,[],0,C,p),_;x===27&&(C|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let N=p+1;;N++)if(N>=s||(x=r[N])<32||x>127&&x<y){this._oscParser.put(r,p,N),p=N-1;break}break;case 6:if(_=this._oscParser.end(x!==24&&x!==26),_)return this._preserveStack(5,[],0,C,p),_;x===27&&(C|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&C}}}n.EscapeSequenceParser=u},6242:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OscHandler=n.OscParser=void 0;const d=a(5770),h=a(482),c=[];n.OscParser=class{constructor(){this._state=0,this._active=c,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(f,v){this._handlers[f]===void 0&&(this._handlers[f]=[]);const y=this._handlers[f];return y.push(v),{dispose:()=>{const u=y.indexOf(v);u!==-1&&y.splice(u,1)}}}clearHandler(f){this._handlers[f]&&delete this._handlers[f]}setHandlerFallback(f){this._handlerFb=f}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=c}reset(){if(this._state===2)for(let f=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;f>=0;--f)this._active[f].end(!1);this._stack.paused=!1,this._active=c,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||c,this._active.length)for(let f=this._active.length-1;f>=0;f--)this._active[f].start();else this._handlerFb(this._id,"START")}_put(f,v,y){if(this._active.length)for(let u=this._active.length-1;u>=0;u--)this._active[u].put(f,v,y);else this._handlerFb(this._id,"PUT",(0,h.utf32ToString)(f,v,y))}start(){this.reset(),this._state=1}put(f,v,y){if(this._state!==3){if(this._state===1)for(;v<y;){const u=f[v++];if(u===59){this._state=2,this._start();break}if(u<48||57<u)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+u-48}this._state===2&&y-v>0&&this._put(f,v,y)}}end(f,v=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,u=this._active.length-1,i=!1;if(this._stack.paused&&(u=this._stack.loopPosition-1,y=v,i=this._stack.fallThrough,this._stack.paused=!1),!i&&y===!1){for(;u>=0&&(y=this._active[u].end(f),y!==!0);u--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=u,this._stack.fallThrough=!1,y;u--}for(;u>=0;u--)if(y=this._active[u].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=u,this._stack.fallThrough=!0,y}else this._handlerFb(this._id,"END",f);this._active=c,this._id=-1,this._state=0}}},n.OscHandler=class{constructor(f){this._handler=f,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(f,v,y){this._hitLimit||(this._data+=(0,h.utf32ToString)(f,v,y),this._data.length>d.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(f){let v=!1;if(this._hitLimit)v=!1;else if(f&&(v=this._handler(this._data),v instanceof Promise))return v.then((y=>(this._data="",this._hitLimit=!1,y)));return this._data="",this._hitLimit=!1,v}}},8742:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Params=void 0;const a=2147483647;class d{static fromArray(c){const f=new d;if(!c.length)return f;for(let v=Array.isArray(c[0])?1:0;v<c.length;++v){const y=c[v];if(Array.isArray(y))for(let u=0;u<y.length;++u)f.addSubParam(y[u]);else f.addParam(y)}return f}constructor(c=32,f=32){if(this.maxLength=c,this.maxSubParamsLength=f,f>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(c),this.length=0,this._subParams=new Int32Array(f),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(c),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const c=new d(this.maxLength,this.maxSubParamsLength);return c.params.set(this.params),c.length=this.length,c._subParams.set(this._subParams),c._subParamsLength=this._subParamsLength,c._subParamsIdx.set(this._subParamsIdx),c._rejectDigits=this._rejectDigits,c._rejectSubDigits=this._rejectSubDigits,c._digitIsSub=this._digitIsSub,c}toArray(){const c=[];for(let f=0;f<this.length;++f){c.push(this.params[f]);const v=this._subParamsIdx[f]>>8,y=255&this._subParamsIdx[f];y-v>0&&c.push(Array.prototype.slice.call(this._subParams,v,y))}return c}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(c){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=c>a?a:c}}addSubParam(c){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=c>a?a:c,this._subParamsIdx[this.length-1]++}}hasSubParams(c){return(255&this._subParamsIdx[c])-(this._subParamsIdx[c]>>8)>0}getSubParams(c){const f=this._subParamsIdx[c]>>8,v=255&this._subParamsIdx[c];return v-f>0?this._subParams.subarray(f,v):null}getSubParamsAll(){const c={};for(let f=0;f<this.length;++f){const v=this._subParamsIdx[f]>>8,y=255&this._subParamsIdx[f];y-v>0&&(c[f]=this._subParams.slice(v,y))}return c}addDigit(c){let f;if(this._rejectDigits||!(f=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const v=this._digitIsSub?this._subParams:this.params,y=v[f-1];v[f-1]=~y?Math.min(10*y+c,a):c}}n.Params=d},5741:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.AddonManager=void 0,n.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let a=this._addons.length-1;a>=0;a--)this._addons[a].instance.dispose()}loadAddon(a,d){const h={instance:d,dispose:d.dispose,isDisposed:!1};this._addons.push(h),d.dispose=()=>this._wrappedAddonDispose(h),d.activate(a)}_wrappedAddonDispose(a){if(a.isDisposed)return;let d=-1;for(let h=0;h<this._addons.length;h++)if(this._addons[h]===a){d=h;break}if(d===-1)throw new Error("Could not dispose an addon that has not been loaded");a.isDisposed=!0,a.dispose.apply(a.instance),this._addons.splice(d,1)}}},8771:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferApiView=void 0;const d=a(3785),h=a(511);n.BufferApiView=class{constructor(c,f){this._buffer=c,this.type=f}init(c){return this._buffer=c,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(c){const f=this._buffer.lines.get(c);if(f)return new d.BufferLineApiView(f)}getNullCell(){return new h.CellData}}},3785:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLineApiView=void 0;const d=a(511);n.BufferLineApiView=class{constructor(h){this._line=h}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(h,c){if(!(h<0||h>=this._line.length))return c?(this._line.loadCell(h,c),c):this._line.loadCell(h,new d.CellData)}translateToString(h,c,f){return this._line.translateToString(h,c,f)}}},8285:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferNamespaceApi=void 0;const d=a(8771),h=a(8460),c=a(844);class f extends c.Disposable{constructor(y){super(),this._core=y,this._onBufferChange=this.register(new h.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new d.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new d.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}n.BufferNamespaceApi=f},7975:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ParserApi=void 0,n.ParserApi=class{constructor(a){this._core=a}registerCsiHandler(a,d){return this._core.registerCsiHandler(a,(h=>d(h.toArray())))}addCsiHandler(a,d){return this.registerCsiHandler(a,d)}registerDcsHandler(a,d){return this._core.registerDcsHandler(a,((h,c)=>d(h,c.toArray())))}addDcsHandler(a,d){return this.registerDcsHandler(a,d)}registerEscHandler(a,d){return this._core.registerEscHandler(a,d)}addEscHandler(a,d){return this.registerEscHandler(a,d)}registerOscHandler(a,d){return this._core.registerOscHandler(a,d)}addOscHandler(a,d){return this.registerOscHandler(a,d)}}},7090:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeApi=void 0,n.UnicodeApi=class{constructor(a){this._core=a}register(a){this._core.unicodeService.register(a)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(a){this._core.unicodeService.activeVersion=a}}},744:function(b,n,a){var d=this&&this.__decorate||function(i,r,s,l){var _,x=arguments.length,C=x<3?r:l===null?l=Object.getOwnPropertyDescriptor(r,s):l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(i,r,s,l);else for(var k=i.length-1;k>=0;k--)(_=i[k])&&(C=(x<3?_(C):x>3?_(r,s,C):_(r,s))||C);return x>3&&C&&Object.defineProperty(r,s,C),C},h=this&&this.__param||function(i,r){return function(s,l){r(s,l,i)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferService=n.MINIMUM_ROWS=n.MINIMUM_COLS=void 0;const c=a(8460),f=a(844),v=a(5295),y=a(2585);n.MINIMUM_COLS=2,n.MINIMUM_ROWS=1;let u=n.BufferService=class extends f.Disposable{get buffer(){return this.buffers.active}constructor(i){super(),this.isUserScrolling=!1,this._onResize=this.register(new c.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new c.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(i.rawOptions.cols||0,n.MINIMUM_COLS),this.rows=Math.max(i.rawOptions.rows||0,n.MINIMUM_ROWS),this.buffers=this.register(new v.BufferSet(i,this))}resize(i,r){this.cols=i,this.rows=r,this.buffers.resize(i,r),this._onResize.fire({cols:i,rows:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(i,r=!1){const s=this.buffer;let l;l=this._cachedBlankLine,l&&l.length===this.cols&&l.getFg(0)===i.fg&&l.getBg(0)===i.bg||(l=s.getBlankLine(i,r),this._cachedBlankLine=l),l.isWrapped=r;const _=s.ybase+s.scrollTop,x=s.ybase+s.scrollBottom;if(s.scrollTop===0){const C=s.lines.isFull;x===s.lines.length-1?C?s.lines.recycle().copyFrom(l):s.lines.push(l.clone()):s.lines.splice(x+1,0,l.clone()),C?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{const C=x-_+1;s.lines.shiftElements(_+1,C-1,-1),s.lines.set(x,l.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(i,r,s){const l=this.buffer;if(i<0){if(l.ydisp===0)return;this.isUserScrolling=!0}else i+l.ydisp>=l.ybase&&(this.isUserScrolling=!1);const _=l.ydisp;l.ydisp=Math.max(Math.min(l.ydisp+i,l.ybase),0),_!==l.ydisp&&(r||this._onScroll.fire(l.ydisp))}};n.BufferService=u=d([h(0,y.IOptionsService)],u)},7994:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CharsetService=void 0,n.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(a){this.glevel=a,this.charset=this._charsets[a]}setgCharset(a,d){this._charsets[a]=d,this.glevel===a&&(this.charset=d)}}},1753:function(b,n,a){var d=this&&this.__decorate||function(l,_,x,C){var k,p=arguments.length,w=p<3?_:C===null?C=Object.getOwnPropertyDescriptor(_,x):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(l,_,x,C);else for(var R=l.length-1;R>=0;R--)(k=l[R])&&(w=(p<3?k(w):p>3?k(_,x,w):k(_,x))||w);return p>3&&w&&Object.defineProperty(_,x,w),w},h=this&&this.__param||function(l,_){return function(x,C){_(x,C,l)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreMouseService=void 0;const c=a(2585),f=a(8460),v=a(844),y={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:l=>l.button!==4&&l.action===1&&(l.ctrl=!1,l.alt=!1,l.shift=!1,!0)},VT200:{events:19,restrict:l=>l.action!==32},DRAG:{events:23,restrict:l=>l.action!==32||l.button!==3},ANY:{events:31,restrict:l=>!0}};function u(l,_){let x=(l.ctrl?16:0)|(l.shift?4:0)|(l.alt?8:0);return l.button===4?(x|=64,x|=l.action):(x|=3&l.button,4&l.button&&(x|=64),8&l.button&&(x|=128),l.action===32?x|=32:l.action!==0||_||(x|=3)),x}const i=String.fromCharCode,r={DEFAULT:l=>{const _=[u(l,!1)+32,l.col+32,l.row+32];return _[0]>255||_[1]>255||_[2]>255?"":`\x1B[M${i(_[0])}${i(_[1])}${i(_[2])}`},SGR:l=>{const _=l.action===0&&l.button!==4?"m":"M";return`\x1B[<${u(l,!0)};${l.col};${l.row}${_}`},SGR_PIXELS:l=>{const _=l.action===0&&l.button!==4?"m":"M";return`\x1B[<${u(l,!0)};${l.x};${l.y}${_}`}};let s=n.CoreMouseService=class extends v.Disposable{constructor(l,_){super(),this._bufferService=l,this._coreService=_,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new f.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const x of Object.keys(y))this.addProtocol(x,y[x]);for(const x of Object.keys(r))this.addEncoding(x,r[x]);this.reset()}addProtocol(l,_){this._protocols[l]=_}addEncoding(l,_){this._encodings[l]=_}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(l){if(!this._protocols[l])throw new Error(`unknown protocol "${l}"`);this._activeProtocol=l,this._onProtocolChange.fire(this._protocols[l].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(l){if(!this._encodings[l])throw new Error(`unknown encoding "${l}"`);this._activeEncoding=l}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(l){if(l.col<0||l.col>=this._bufferService.cols||l.row<0||l.row>=this._bufferService.rows||l.button===4&&l.action===32||l.button===3&&l.action!==32||l.button!==4&&(l.action===2||l.action===3)||(l.col++,l.row++,l.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,l,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(l))return!1;const _=this._encodings[this._activeEncoding](l);return _&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(_):this._coreService.triggerDataEvent(_,!0)),this._lastEvent=l,!0}explainEvents(l){return{down:!!(1&l),up:!!(2&l),drag:!!(4&l),move:!!(8&l),wheel:!!(16&l)}}_equalEvents(l,_,x){if(x){if(l.x!==_.x||l.y!==_.y)return!1}else if(l.col!==_.col||l.row!==_.row)return!1;return l.button===_.button&&l.action===_.action&&l.ctrl===_.ctrl&&l.alt===_.alt&&l.shift===_.shift}};n.CoreMouseService=s=d([h(0,c.IBufferService),h(1,c.ICoreService)],s)},6975:function(b,n,a){var d=this&&this.__decorate||function(s,l,_,x){var C,k=arguments.length,p=k<3?l:x===null?x=Object.getOwnPropertyDescriptor(l,_):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")p=Reflect.decorate(s,l,_,x);else for(var w=s.length-1;w>=0;w--)(C=s[w])&&(p=(k<3?C(p):k>3?C(l,_,p):C(l,_))||p);return k>3&&p&&Object.defineProperty(l,_,p),p},h=this&&this.__param||function(s,l){return function(_,x){l(_,x,s)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreService=void 0;const c=a(1439),f=a(8460),v=a(844),y=a(2585),u=Object.freeze({insertMode:!1}),i=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let r=n.CoreService=class extends v.Disposable{constructor(s,l,_){super(),this._bufferService=s,this._logService=l,this._optionsService=_,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new f.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new f.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new f.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new f.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,c.clone)(u),this.decPrivateModes=(0,c.clone)(i)}reset(){this.modes=(0,c.clone)(u),this.decPrivateModes=(0,c.clone)(i)}triggerDataEvent(s,l=!1){if(this._optionsService.rawOptions.disableStdin)return;const _=this._bufferService.buffer;l&&this._optionsService.rawOptions.scrollOnUserInput&&_.ybase!==_.ydisp&&this._onRequestScrollToBottom.fire(),l&&this._onUserInput.fire(),this._logService.debug(`sending data "${s}"`,(()=>s.split("").map((x=>x.charCodeAt(0))))),this._onData.fire(s)}triggerBinaryEvent(s){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${s}"`,(()=>s.split("").map((l=>l.charCodeAt(0))))),this._onBinary.fire(s))}};n.CoreService=r=d([h(0,y.IBufferService),h(1,y.ILogService),h(2,y.IOptionsService)],r)},9074:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DecorationService=void 0;const d=a(8055),h=a(8460),c=a(844),f=a(6106);let v=0,y=0;class u extends c.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new f.SortedList((s=>s==null?void 0:s.marker.line)),this._onDecorationRegistered=this.register(new h.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new h.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,c.toDisposable)((()=>this.reset())))}registerDecoration(s){if(s.marker.isDisposed)return;const l=new i(s);if(l){const _=l.marker.onDispose((()=>l.dispose()));l.onDispose((()=>{l&&(this._decorations.delete(l)&&this._onDecorationRemoved.fire(l),_.dispose())})),this._decorations.insert(l),this._onDecorationRegistered.fire(l)}return l}reset(){for(const s of this._decorations.values())s.dispose();this._decorations.clear()}*getDecorationsAtCell(s,l,_){let x=0,C=0;for(const k of this._decorations.getKeyIterator(l))x=k.options.x??0,C=x+(k.options.width??1),s>=x&&s<C&&(!_||(k.options.layer??"bottom")===_)&&(yield k)}forEachDecorationAtCell(s,l,_,x){this._decorations.forEachByKey(l,(C=>{v=C.options.x??0,y=v+(C.options.width??1),s>=v&&s<y&&(!_||(C.options.layer??"bottom")===_)&&x(C)}))}}n.DecorationService=u;class i extends c.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=d.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=d.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(s){super(),this.options=s,this.onRenderEmitter=this.register(new h.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new h.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=s.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.InstantiationService=n.ServiceCollection=void 0;const d=a(2585),h=a(8343);class c{constructor(...v){this._entries=new Map;for(const[y,u]of v)this.set(y,u)}set(v,y){const u=this._entries.get(v);return this._entries.set(v,y),u}forEach(v){for(const[y,u]of this._entries.entries())v(y,u)}has(v){return this._entries.has(v)}get(v){return this._entries.get(v)}}n.ServiceCollection=c,n.InstantiationService=class{constructor(){this._services=new c,this._services.set(d.IInstantiationService,this)}setService(f,v){this._services.set(f,v)}getService(f){return this._services.get(f)}createInstance(f,...v){const y=(0,h.getServiceDependencies)(f).sort(((r,s)=>r.index-s.index)),u=[];for(const r of y){const s=this._services.get(r.id);if(!s)throw new Error(`[createInstance] ${f.name} depends on UNKNOWN service ${r.id}.`);u.push(s)}const i=y.length>0?y[0].index:v.length;if(v.length!==i)throw new Error(`[createInstance] First service dependency of ${f.name} at position ${i+1} conflicts with ${v.length} static arguments`);return new f(...v,...u)}}},7866:function(b,n,a){var d=this&&this.__decorate||function(i,r,s,l){var _,x=arguments.length,C=x<3?r:l===null?l=Object.getOwnPropertyDescriptor(r,s):l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(i,r,s,l);else for(var k=i.length-1;k>=0;k--)(_=i[k])&&(C=(x<3?_(C):x>3?_(r,s,C):_(r,s))||C);return x>3&&C&&Object.defineProperty(r,s,C),C},h=this&&this.__param||function(i,r){return function(s,l){r(s,l,i)}};Object.defineProperty(n,"__esModule",{value:!0}),n.traceCall=n.setTraceLogger=n.LogService=void 0;const c=a(844),f=a(2585),v={trace:f.LogLevelEnum.TRACE,debug:f.LogLevelEnum.DEBUG,info:f.LogLevelEnum.INFO,warn:f.LogLevelEnum.WARN,error:f.LogLevelEnum.ERROR,off:f.LogLevelEnum.OFF};let y,u=n.LogService=class extends c.Disposable{get logLevel(){return this._logLevel}constructor(i){super(),this._optionsService=i,this._logLevel=f.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),y=this}_updateLogLevel(){this._logLevel=v[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(i){for(let r=0;r<i.length;r++)typeof i[r]=="function"&&(i[r]=i[r]())}_log(i,r,s){this._evalLazyOptionalParams(s),i.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+r,...s)}trace(i,...r){var s;this._logLevel<=f.LogLevelEnum.TRACE&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,i,r)}debug(i,...r){var s;this._logLevel<=f.LogLevelEnum.DEBUG&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,i,r)}info(i,...r){var s;this._logLevel<=f.LogLevelEnum.INFO&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,i,r)}warn(i,...r){var s;this._logLevel<=f.LogLevelEnum.WARN&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,i,r)}error(i,...r){var s;this._logLevel<=f.LogLevelEnum.ERROR&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,i,r)}};n.LogService=u=d([h(0,f.IOptionsService)],u),n.setTraceLogger=function(i){y=i},n.traceCall=function(i,r,s){if(typeof s.value!="function")throw new Error("not supported");const l=s.value;s.value=function(..._){if(y.logLevel!==f.LogLevelEnum.TRACE)return l.apply(this,_);y.trace(`GlyphRenderer#${l.name}(${_.map((C=>JSON.stringify(C))).join(", ")})`);const x=l.apply(this,_);return y.trace(`GlyphRenderer#${l.name} return`,x),x}}},7302:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OptionsService=n.DEFAULT_OPTIONS=void 0;const d=a(8460),h=a(844),c=a(6114);n.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:c.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const f=["normal","bold","100","200","300","400","500","600","700","800","900"];class v extends h.Disposable{constructor(u){super(),this._onOptionChange=this.register(new d.EventEmitter),this.onOptionChange=this._onOptionChange.event;const i={...n.DEFAULT_OPTIONS};for(const r in u)if(r in i)try{const s=u[r];i[r]=this._sanitizeAndValidateOption(r,s)}catch(s){console.error(s)}this.rawOptions=i,this.options={...i},this._setupOptions(),this.register((0,h.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(u,i){return this.onOptionChange((r=>{r===u&&i(this.rawOptions[u])}))}onMultipleOptionChange(u,i){return this.onOptionChange((r=>{u.indexOf(r)!==-1&&i()}))}_setupOptions(){const u=r=>{if(!(r in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${r}"`);return this.rawOptions[r]},i=(r,s)=>{if(!(r in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${r}"`);s=this._sanitizeAndValidateOption(r,s),this.rawOptions[r]!==s&&(this.rawOptions[r]=s,this._onOptionChange.fire(r))};for(const r in this.rawOptions){const s={get:u.bind(this,r),set:i.bind(this,r)};Object.defineProperty(this.options,r,s)}}_sanitizeAndValidateOption(u,i){switch(u){case"cursorStyle":if(i||(i=n.DEFAULT_OPTIONS[u]),!(function(r){return r==="block"||r==="underline"||r==="bar"})(i))throw new Error(`"${i}" is not a valid value for ${u}`);break;case"wordSeparator":i||(i=n.DEFAULT_OPTIONS[u]);break;case"fontWeight":case"fontWeightBold":if(typeof i=="number"&&1<=i&&i<=1e3)break;i=f.includes(i)?i:n.DEFAULT_OPTIONS[u];break;case"cursorWidth":i=Math.floor(i);case"lineHeight":case"tabStopWidth":if(i<1)throw new Error(`${u} cannot be less than 1, value: ${i}`);break;case"minimumContrastRatio":i=Math.max(1,Math.min(21,Math.round(10*i)/10));break;case"scrollback":if((i=Math.min(i,4294967295))<0)throw new Error(`${u} cannot be less than 0, value: ${i}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(i<=0)throw new Error(`${u} cannot be less than or equal to 0, value: ${i}`);break;case"rows":case"cols":if(!i&&i!==0)throw new Error(`${u} must be numeric, value: ${i}`);break;case"windowsPty":i=i??{}}return i}}n.OptionsService=v},2660:function(b,n,a){var d=this&&this.__decorate||function(v,y,u,i){var r,s=arguments.length,l=s<3?y:i===null?i=Object.getOwnPropertyDescriptor(y,u):i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(v,y,u,i);else for(var _=v.length-1;_>=0;_--)(r=v[_])&&(l=(s<3?r(l):s>3?r(y,u,l):r(y,u))||l);return s>3&&l&&Object.defineProperty(y,u,l),l},h=this&&this.__param||function(v,y){return function(u,i){y(u,i,v)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkService=void 0;const c=a(2585);let f=n.OscLinkService=class{constructor(v){this._bufferService=v,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(v){const y=this._bufferService.buffer;if(v.id===void 0){const _=y.addMarker(y.ybase+y.y),x={data:v,id:this._nextId++,lines:[_]};return _.onDispose((()=>this._removeMarkerFromLink(x,_))),this._dataByLinkId.set(x.id,x),x.id}const u=v,i=this._getEntryIdKey(u),r=this._entriesWithId.get(i);if(r)return this.addLineToLink(r.id,y.ybase+y.y),r.id;const s=y.addMarker(y.ybase+y.y),l={id:this._nextId++,key:this._getEntryIdKey(u),data:u,lines:[s]};return s.onDispose((()=>this._removeMarkerFromLink(l,s))),this._entriesWithId.set(l.key,l),this._dataByLinkId.set(l.id,l),l.id}addLineToLink(v,y){const u=this._dataByLinkId.get(v);if(u&&u.lines.every((i=>i.line!==y))){const i=this._bufferService.buffer.addMarker(y);u.lines.push(i),i.onDispose((()=>this._removeMarkerFromLink(u,i)))}}getLinkData(v){var y;return(y=this._dataByLinkId.get(v))==null?void 0:y.data}_getEntryIdKey(v){return`${v.id};;${v.uri}`}_removeMarkerFromLink(v,y){const u=v.lines.indexOf(y);u!==-1&&(v.lines.splice(u,1),v.lines.length===0&&(v.data.id!==void 0&&this._entriesWithId.delete(v.key),this._dataByLinkId.delete(v.id)))}};n.OscLinkService=f=d([h(0,c.IBufferService)],f)},8343:(b,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createDecorator=n.getServiceDependencies=n.serviceRegistry=void 0;const a="di$target",d="di$dependencies";n.serviceRegistry=new Map,n.getServiceDependencies=function(h){return h[d]||[]},n.createDecorator=function(h){if(n.serviceRegistry.has(h))return n.serviceRegistry.get(h);const c=function(f,v,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(u,i,r){i[a]===i?i[d].push({id:u,index:r}):(i[d]=[{id:u,index:r}],i[a]=i)})(c,f,y)};return c.toString=()=>h,n.serviceRegistry.set(h,c),c}},2585:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IDecorationService=n.IUnicodeService=n.IOscLinkService=n.IOptionsService=n.ILogService=n.LogLevelEnum=n.IInstantiationService=n.ICharsetService=n.ICoreService=n.ICoreMouseService=n.IBufferService=void 0;const d=a(8343);var h;n.IBufferService=(0,d.createDecorator)("BufferService"),n.ICoreMouseService=(0,d.createDecorator)("CoreMouseService"),n.ICoreService=(0,d.createDecorator)("CoreService"),n.ICharsetService=(0,d.createDecorator)("CharsetService"),n.IInstantiationService=(0,d.createDecorator)("InstantiationService"),(function(c){c[c.TRACE=0]="TRACE",c[c.DEBUG=1]="DEBUG",c[c.INFO=2]="INFO",c[c.WARN=3]="WARN",c[c.ERROR=4]="ERROR",c[c.OFF=5]="OFF"})(h||(n.LogLevelEnum=h={})),n.ILogService=(0,d.createDecorator)("LogService"),n.IOptionsService=(0,d.createDecorator)("OptionsService"),n.IOscLinkService=(0,d.createDecorator)("OscLinkService"),n.IUnicodeService=(0,d.createDecorator)("UnicodeService"),n.IDecorationService=(0,d.createDecorator)("DecorationService")},1480:(b,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeService=void 0;const d=a(8460),h=a(225);class c{static extractShouldJoin(v){return(1&v)!=0}static extractWidth(v){return v>>1&3}static extractCharKind(v){return v>>3}static createPropertyValue(v,y,u=!1){return(16777215&v)<<3|(3&y)<<1|(u?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new d.EventEmitter,this.onChange=this._onChange.event;const v=new h.UnicodeV6;this.register(v),this._active=v.version,this._activeProvider=v}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(v){if(!this._providers[v])throw new Error(`unknown Unicode version "${v}"`);this._active=v,this._activeProvider=this._providers[v],this._onChange.fire(v)}register(v){this._providers[v.version]=v}wcwidth(v){return this._activeProvider.wcwidth(v)}getStringCellWidth(v){let y=0,u=0;const i=v.length;for(let r=0;r<i;++r){let s=v.charCodeAt(r);if(55296<=s&&s<=56319){if(++r>=i)return y+this.wcwidth(s);const x=v.charCodeAt(r);56320<=x&&x<=57343?s=1024*(s-55296)+x-56320+65536:y+=this.wcwidth(x)}const l=this.charProperties(s,u);let _=c.extractWidth(l);c.extractShouldJoin(l)&&(_-=c.extractWidth(u)),y+=_,u=l}return y}charProperties(v,y){return this._activeProvider.charProperties(v,y)}}n.UnicodeService=c}},S={};function j(b){var n=S[b];if(n!==void 0)return n.exports;var a=S[b]={exports:{}};return m[b].call(a.exports,a,a.exports,j),a.exports}var E={};return(()=>{var b=E;Object.defineProperty(b,"__esModule",{value:!0}),b.Terminal=void 0;const n=j(9042),a=j(3236),d=j(844),h=j(5741),c=j(8285),f=j(7975),v=j(7090),y=["cols","rows"];class u extends d.Disposable{constructor(r){super(),this._core=this.register(new a.Terminal(r)),this._addonManager=this.register(new h.AddonManager),this._publicOptions={...this._core.options};const s=_=>this._core.options[_],l=(_,x)=>{this._checkReadonlyOptions(_),this._core.options[_]=x};for(const _ in this._core.options){const x={get:s.bind(this,_),set:l.bind(this,_)};Object.defineProperty(this._publicOptions,_,x)}}_checkReadonlyOptions(r){if(y.includes(r))throw new Error(`Option "${r}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new f.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new v.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new c.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const r=this._core.coreService.decPrivateModes;let s="none";switch(this._core.coreMouseService.activeProtocol){case"X10":s="x10";break;case"VT200":s="vt200";break;case"DRAG":s="drag";break;case"ANY":s="any"}return{applicationCursorKeysMode:r.applicationCursorKeys,applicationKeypadMode:r.applicationKeypad,bracketedPasteMode:r.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:s,originMode:r.origin,reverseWraparoundMode:r.reverseWraparound,sendFocusMode:r.sendFocus,wraparoundMode:r.wraparound}}get options(){return this._publicOptions}set options(r){for(const s in r)this._publicOptions[s]=r[s]}blur(){this._core.blur()}focus(){this._core.focus()}input(r,s=!0){this._core.input(r,s)}resize(r,s){this._verifyIntegers(r,s),this._core.resize(r,s)}open(r){this._core.open(r)}attachCustomKeyEventHandler(r){this._core.attachCustomKeyEventHandler(r)}attachCustomWheelEventHandler(r){this._core.attachCustomWheelEventHandler(r)}registerLinkProvider(r){return this._core.registerLinkProvider(r)}registerCharacterJoiner(r){return this._checkProposedApi(),this._core.registerCharacterJoiner(r)}deregisterCharacterJoiner(r){this._checkProposedApi(),this._core.deregisterCharacterJoiner(r)}registerMarker(r=0){return this._verifyIntegers(r),this._core.registerMarker(r)}registerDecoration(r){return this._checkProposedApi(),this._verifyPositiveIntegers(r.x??0,r.width??0,r.height??0),this._core.registerDecoration(r)}hasSelection(){return this._core.hasSelection()}select(r,s,l){this._verifyIntegers(r,s,l),this._core.select(r,s,l)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(r,s){this._verifyIntegers(r,s),this._core.selectLines(r,s)}dispose(){super.dispose()}scrollLines(r){this._verifyIntegers(r),this._core.scrollLines(r)}scrollPages(r){this._verifyIntegers(r),this._core.scrollPages(r)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(r){this._verifyIntegers(r),this._core.scrollToLine(r)}clear(){this._core.clear()}write(r,s){this._core.write(r,s)}writeln(r,s){this._core.write(r),this._core.write(`\r
172
+ `,s)}paste(r){this._core.paste(r)}refresh(r,s){this._verifyIntegers(r,s),this._core.refresh(r,s)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(r){this._addonManager.loadAddon(this,r)}static get strings(){return n}_verifyIntegers(...r){for(const s of r)if(s===1/0||isNaN(s)||s%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...r){for(const s of r)if(s&&(s===1/0||isNaN(s)||s%1!=0||s<0))throw new Error("This API only accepts positive integers")}}b.Terminal=u})(),E})()))})(Ts)),Ts.exports}var n1=i1(),Is={exports:{}},Nr;function o1(){return Nr||(Nr=1,(function(t,o){(function(m,S){t.exports=S()})(self,(()=>(()=>{var m={};return(()=>{var S=m;Object.defineProperty(S,"__esModule",{value:!0}),S.FitAddon=void 0,S.FitAddon=class{activate(j){this._terminal=j}dispose(){}fit(){const j=this.proposeDimensions();if(!j||!this._terminal||isNaN(j.cols)||isNaN(j.rows))return;const E=this._terminal._core;this._terminal.rows===j.rows&&this._terminal.cols===j.cols||(E._renderService.clear(),this._terminal.resize(j.cols,j.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const j=this._terminal._core,E=j._renderService.dimensions;if(E.css.cell.width===0||E.css.cell.height===0)return;const b=this._terminal.options.scrollback===0?0:j.viewport.scrollBarWidth,n=window.getComputedStyle(this._terminal.element.parentElement),a=parseInt(n.getPropertyValue("height")),d=Math.max(0,parseInt(n.getPropertyValue("width"))),h=window.getComputedStyle(this._terminal.element),c=a-(parseInt(h.getPropertyValue("padding-top"))+parseInt(h.getPropertyValue("padding-bottom"))),f=d-(parseInt(h.getPropertyValue("padding-right"))+parseInt(h.getPropertyValue("padding-left")))-b;return{cols:Math.max(2,Math.floor(f/E.css.cell.width)),rows:Math.max(1,Math.floor(c/E.css.cell.height))}}}})(),m})()))})(Is)),Is.exports}var a1=o1(),As={exports:{}},Rr;function l1(){return Rr||(Rr=1,(function(t,o){(function(m,S){t.exports=S()})(self,(()=>(()=>{var m={6:(b,n)=>{function a(h){try{const c=new URL(h),f=c.password&&c.username?`${c.protocol}//${c.username}:${c.password}@${c.host}`:c.username?`${c.protocol}//${c.username}@${c.host}`:`${c.protocol}//${c.host}`;return h.toLocaleLowerCase().startsWith(f.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(n,"__esModule",{value:!0}),n.LinkComputer=n.WebLinkProvider=void 0,n.WebLinkProvider=class{constructor(h,c,f,v={}){this._terminal=h,this._regex=c,this._handler=f,this._options=v}provideLinks(h,c){const f=d.computeLink(h,this._regex,this._terminal,this._handler);c(this._addCallbacks(f))}_addCallbacks(h){return h.map((c=>(c.leave=this._options.leave,c.hover=(f,v)=>{if(this._options.hover){const{range:y}=c;this._options.hover(f,v,y)}},c)))}};class d{static computeLink(c,f,v,y){const u=new RegExp(f.source,(f.flags||"")+"g"),[i,r]=d._getWindowedLineStrings(c-1,v),s=i.join("");let l;const _=[];for(;l=u.exec(s);){const x=l[0];if(!a(x))continue;const[C,k]=d._mapStrIdx(v,r,0,l.index),[p,w]=d._mapStrIdx(v,C,k,x.length);if(C===-1||k===-1||p===-1||w===-1)continue;const R={start:{x:k+1,y:C+1},end:{x:w,y:p+1}};_.push({range:R,text:x,activate:y})}return _}static _getWindowedLineStrings(c,f){let v,y=c,u=c,i=0,r="";const s=[];if(v=f.buffer.active.getLine(c)){const l=v.translateToString(!0);if(v.isWrapped&&l[0]!==" "){for(i=0;(v=f.buffer.active.getLine(--y))&&i<2048&&(r=v.translateToString(!0),i+=r.length,s.push(r),v.isWrapped&&r.indexOf(" ")===-1););s.reverse()}for(s.push(l),i=0;(v=f.buffer.active.getLine(++u))&&v.isWrapped&&i<2048&&(r=v.translateToString(!0),i+=r.length,s.push(r),r.indexOf(" ")===-1););}return[s,y]}static _mapStrIdx(c,f,v,y){const u=c.buffer.active,i=u.getNullCell();let r=v;for(;y;){const s=u.getLine(f);if(!s)return[-1,-1];for(let l=r;l<s.length;++l){s.getCell(l,i);const _=i.getChars();if(i.getWidth()&&(y-=_.length||1,l===s.length-1&&_==="")){const x=u.getLine(f+1);x&&x.isWrapped&&(x.getCell(0,i),i.getWidth()===2&&(y+=1))}if(y<0)return[f,l]}f++,r=0}return[f,r]}}n.LinkComputer=d}},S={};function j(b){var n=S[b];if(n!==void 0)return n.exports;var a=S[b]={exports:{}};return m[b](a,a.exports,j),a.exports}var E={};return(()=>{var b=E;Object.defineProperty(b,"__esModule",{value:!0}),b.WebLinksAddon=void 0;const n=j(6),a=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function d(h,c){const f=window.open();if(f){try{f.opener=null}catch{}f.location.href=c}else console.warn("Opening link blocked as opener could not be cleared")}b.WebLinksAddon=class{constructor(h=d,c={}){this._handler=h,this._options=c}activate(h){this._terminal=h;const c=this._options,f=c.urlRegex||a;this._linkProvider=this._terminal.registerLinkProvider(new n.WebLinkProvider(this._terminal,f,this._handler,c))}dispose(){var h;(h=this._linkProvider)==null||h.dispose()}}})(),E})()))})(As)),As.exports}var c1=l1();const d1="_term_v32yd_1",h1={term:d1};function u1({url:t,connectToken:o,onStatusChange:m,className:S,style:j}){const E=g.useRef(null),b=g.useRef(null),n=g.useRef(null),a=g.useRef(null);return g.useEffect(()=>{if(!E.current)return;const d=new n1.Terminal({fontFamily:'"SF Mono", Menlo, Monaco, "Courier New", monospace',fontSize:12,cursorBlink:!0,convertEol:!0,scrollback:5e3,theme:{background:"#1e1e1e",foreground:"#e4e4e4",cursor:"#9fe870",selectionBackground:"rgba(159, 232, 112, 0.35)"}}),h=new a1.FitAddon;d.loadAddon(h),d.loadAddon(new c1.WebLinksAddon),d.open(E.current);try{h.fit()}catch{}return b.current=d,n.current=h,()=>{d.dispose(),b.current=null,n.current=null}},[]),g.useEffect(()=>{const d=b.current;if(!d)return;m==null||m("connecting"),d.writeln("\x1B[90m[正在连接终端…]\x1B[0m");const h=new WebSocket(t);a.current=h,h.onopen=()=>{m==null||m("open");const f=n.current;try{f==null||f.fit();const v=f==null?void 0:f.proposeDimensions();v&&h.send(JSON.stringify({type:"resize",cols:v.cols,rows:v.rows}))}catch{}},h.onmessage=f=>{let v;try{v=JSON.parse(f.data)}catch{return}v.type==="output"&&typeof v.data=="string"?d.write(v.data):v.type==="exit"?d.writeln(`\r
173
+ \x1B[90m[shell 已退出 code=${v.code??"?"}]\x1B[0m`):v.type==="error"&&typeof v.message=="string"&&d.writeln(`\r
174
+ \x1B[31m[错误] ${v.message}\x1B[0m`)},h.onclose=()=>{m==null||m("closed"),d.writeln(`\r
175
+ \x1B[90m[连接已断开 — 点「重连」恢复]\x1B[0m`)},h.onerror=()=>{};const c=d.onData(f=>{h.readyState===WebSocket.OPEN&&h.send(JSON.stringify({type:"input",data:f}))});return()=>{c.dispose();try{h.close()}catch{}a.current=null}},[t,o,m]),g.useEffect(()=>{if(!E.current)return;const d=new ResizeObserver(()=>{const h=b.current,c=n.current,f=a.current;if(!(!c||!h))try{c.fit(),h.scrollToBottom();const v=c.proposeDimensions();v&&f&&f.readyState===WebSocket.OPEN&&f.send(JSON.stringify({type:"resize",cols:v.cols,rows:v.rows}))}catch{}});return d.observe(E.current),()=>d.disconnect()},[]),e.jsx("div",{ref:E,className:`${h1.term} ${S??""}`,style:j})}function vi(){const t=window.location.protocol==="https:"?"wss:":"ws:",o=window.location.hostname==="localhost"?"localhost:28800":`${window.location.hostname}:28800`;return`${t}//${o}/api/terminal`}function gw(t){return`${vi()}?groupId=${encodeURIComponent(t)}`}function _1(t){return`${vi()}?cwd=${encodeURIComponent(t)}`}const f1="_page_17xbm_1",p1="_toolbar_17xbm_9",m1="_title_17xbm_19",g1="_cwdInput_17xbm_28",v1="_status_17xbm_47",y1="_statusOk_17xbm_53",x1="_statusPending_17xbm_57",b1="_statusBad_17xbm_61",S1="_term_17xbm_65",C1="_empty_17xbm_70",w1="_emptyHint_17xbm_82",lt={page:f1,toolbar:p1,title:m1,cwdInput:g1,status:v1,statusOk:y1,statusPending:x1,statusBad:b1,term:S1,empty:C1,emptyHint:w1},yi="terminal_page_cwd";function j1(){try{return localStorage.getItem(yi)??""}catch{return""}}function k1(t){try{localStorage.setItem(yi,t)}catch{}}function E1(){const[t,o]=Wr(),m=t.get("cwd")??"",S=g.useMemo(()=>m||j1(),[m]),[j,E]=g.useState(S),[b,n]=g.useState(S),[a,d]=g.useState(0),[h,c]=g.useState("connecting");g.useEffect(()=>{m&&m!==j&&E(m)},[m]);const f=g.useCallback(()=>{const r=j.trim();r&&(k1(r),o(s=>{const l=new URLSearchParams(s);return l.set("cwd",r),l},{replace:!0}),n(r),d(s=>s+1))},[j,o]),v=g.useMemo(()=>b?_1(b):null,[b]),y=h==="open"?"● 已连接":h==="connecting"?"○ 连接中":"× 已断开",u=h==="open"?lt.statusOk:h==="connecting"?lt.statusPending:lt.statusBad,i=b?h==="open"?"切换目录":"重连":"连接";return e.jsxs("div",{className:lt.page,children:[e.jsxs("div",{className:lt.toolbar,children:[e.jsx("span",{className:lt.title,children:"终端"}),e.jsx(ge,{type:"text",size:"sm",placeholder:"/绝对/路径/到/工作目录",value:j,onChange:r=>E(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),f())},spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",className:lt.cwdInput}),e.jsx(ie,{variant:"primary",size:"sm",onClick:f,disabled:!j.trim(),children:i}),b&&e.jsx("span",{className:`${lt.status} ${u}`,children:y})]}),v?e.jsx(u1,{url:v,connectToken:a,onStatusChange:c,className:lt.term}):e.jsxs("div",{className:lt.empty,children:[e.jsx("p",{children:"输入一个绝对路径并点「连接」打开 shell。"}),e.jsx("p",{className:lt.emptyHint,children:"shell 会以 master 进程的身份在该目录启动。"})]})]})}const N1="_page_mt86d_1",R1="_sidebar_mt86d_9",L1="_sidebarHeader_mt86d_19",T1="_sidebarHeaderIcon_mt86d_31",I1="_sidebarHeaderText_mt86d_35",A1="_nav_mt86d_39",D1="_navGroup_mt86d_46",B1="_navGroupTitle_mt86d_58",M1="_navItem_mt86d_68",$1="_navItemActive_mt86d_84",P1="_navItemIcon_mt86d_91",O1="_navItemBody_mt86d_97",H1="_navItemLabel_mt86d_104",F1="_navItemDesc_mt86d_111",z1="_body_mt86d_127",st={page:N1,sidebar:R1,sidebarHeader:L1,sidebarHeaderIcon:T1,sidebarHeaderText:I1,nav:A1,navGroup:D1,navGroupTitle:B1,navItem:M1,navItemActive:$1,navItemIcon:P1,navItemBody:O1,navItemLabel:H1,navItemDesc:F1,body:z1},W1=[{title:"观察 & 监控",items:[{to:"messages",label:"消息流",icon:"📜",desc:"A2A 消息日志"},{to:"issue-patrol",label:"Issue 巡检",icon:"🔍",desc:"定时巡检任务"},{to:"link-patrol",label:"Link 分类",icon:"🔗",desc:"链接智能分类巡检"},{to:"terminal",label:"终端",icon:"⌨️",desc:"执行器终端"}]},{title:"资产 & 配置",items:[{to:"prompts",label:"Prompt 管理",icon:"📝",desc:"指导模板"},{to:"schedule-patterns",label:"定时任务模板",icon:"⏰",desc:"调度模板"},{to:"memory",label:"记忆",icon:"🧠",desc:"长期记忆"},{to:"skills",label:"技能",icon:"⚡",desc:"技能包"}]},{title:"资源",items:[{to:"gallery",label:"图册",icon:"🖼️",desc:"图片素材"},{to:"worktrees",label:"Worktrees",icon:"🌿",desc:"Git 仓库 & worktree"}]}];function U1(){return e.jsxs("div",{className:st.page,children:[e.jsxs("aside",{className:st.sidebar,children:[e.jsxs("div",{className:st.sidebarHeader,children:[e.jsx("span",{className:st.sidebarHeaderIcon,children:"🧰"}),e.jsx("span",{className:st.sidebarHeaderText,children:"工具箱"})]}),e.jsx("nav",{className:st.nav,children:W1.map(t=>e.jsxs("div",{className:st.navGroup,children:[e.jsx("div",{className:st.navGroupTitle,children:t.title}),t.items.map(o=>e.jsxs(Hr,{to:o.to,className:({isActive:m})=>`${st.navItem} ${m?st.navItemActive:""}`,children:[e.jsx("span",{className:st.navItemIcon,children:o.icon}),e.jsxs("span",{className:st.navItemBody,children:[e.jsx("span",{className:st.navItemLabel,children:o.label}),o.desc&&e.jsx("span",{className:st.navItemDesc,children:o.desc})]})]},o.to))]},t.title))})]}),e.jsx("div",{className:st.body,children:e.jsx(Ri,{})})]})}const q1="_wrap_1axit_1",V1="_fields_1axit_25",G1="_fieldRow_1axit_31",yt={wrap:q1,fields:V1,fieldRow:G1},Lr={mode:"agent",schedule_kind:"interval",interval_sec:60,prompt:""};function xi({value:t,onChange:o}){const[m,S]=g.useState(t!==null);g.useEffect(()=>{S(t!==null)},[t]);const j=()=>{m?(o(null),S(!1)):(o({...Lr}),S(!0))},E=n=>{t&&o({...t,...n})},b=t??Lr;return e.jsxs("div",{className:yt.wrap,children:[e.jsx(Dt,{checked:m,onChange:j,label:"带定时任务配置"}),m&&e.jsxs("div",{className:yt.fields,children:[e.jsx("div",{className:yt.fieldRow,children:e.jsx(Fe,{label:"模式",size:"sm",value:b.mode,onChange:n=>E({mode:n.target.value}),options:[{value:"agent",label:"agent (触发 agent 执行)"},{value:"message",label:"message (发送消息)"}]})}),b.mode==="agent"&&e.jsx("div",{className:yt.fieldRow,children:e.jsx(ge,{label:"agent_name",size:"sm",value:b.agent_name??"",onChange:n=>E({agent_name:n.target.value||void 0}),placeholder:"agent 名,支持 {{teacher}} 等占位符"})}),e.jsx("div",{className:yt.fieldRow,children:e.jsx(Fe,{label:"调度类型",size:"sm",value:b.schedule_kind,onChange:n=>E({schedule_kind:n.target.value}),options:[{value:"interval",label:"interval (周期)"},{value:"once",label:"once (单次)"}]})}),b.schedule_kind==="interval"&&e.jsx("div",{className:yt.fieldRow,children:e.jsx(ge,{label:"interval_sec",type:"number",min:30,size:"sm",value:b.interval_sec??60,onChange:n=>E({interval_sec:Number(n.target.value)||void 0})})}),b.schedule_kind==="once"&&e.jsx("div",{className:yt.fieldRow,children:e.jsx(ge,{label:"run_at (ms 时间戳)",type:"number",size:"sm",value:b.run_at??0,onChange:n=>E({run_at:Number(n.target.value)||void 0}),placeholder:"0 = 立即"})}),e.jsx("div",{className:yt.fieldRow,children:e.jsx(ge,{label:"repeat_times",type:"number",min:1,size:"sm",value:b.repeat_times??"",placeholder:"留空 = 无限",onChange:n=>{const a=n.target.value;E({repeat_times:a===""?void 0:Number(a)})}})}),e.jsx("div",{className:yt.fieldRow,children:e.jsx(xt,{label:"prompt",rows:4,value:b.prompt,onChange:n=>E({prompt:n.target.value}),placeholder:"定时任务触发时的 prompt,支持占位符"})})]})]})}const K1="_container_s7yj4_1",J1="_header_s7yj4_8",X1="_headerText_s7yj4_15",Z1="_heading_s7yj4_21",Y1="_subheading_s7yj4_30",Q1="_empty_s7yj4_38",eS="_error_s7yj4_45",tS="_list_s7yj4_50",sS="_card_s7yj4_56",rS="_cardHeader_s7yj4_66",iS="_cardName_s7yj4_73",nS="_catChip_s7yj4_82",oS="_catFact_s7yj4_96",aS="_catDecision_s7yj4_97",lS="_catConvention_s7yj4_98",cS="_catPitfall_s7yj4_99",dS="_catTodo_s7yj4_100",hS="_catPlaybook_s7yj4_101",uS="_catNote_s7yj4_102",_S="_scopeChip_s7yj4_105",fS="_scopeGlobal_s7yj4_119",pS="_scopeNote_s7yj4_120",mS="_pendingCorner_s7yj4_123",gS="_cardPending_s7yj4_139",vS="_cardDesc_s7yj4_145",yS="_cardPrompt_s7yj4_150",xS="_cardSchedule_s7yj4_161",bS="_cardActions_s7yj4_167",SS="_form_s7yj4_174",CS="_fieldRow_s7yj4_181",wS="_fieldLabel_s7yj4_187",jS="_modalFooter_s7yj4_195",kS="_note_s7yj4_202",ES="_tabs_s7yj4_212",NS="_tab_s7yj4_212",RS="_tabActive_s7yj4_241",LS="_tabCount_s7yj4_247",TS="_cardMeta_s7yj4_268",Y={container:K1,header:J1,headerText:X1,heading:Z1,subheading:Y1,empty:Q1,error:eS,list:tS,card:sS,cardHeader:rS,cardName:iS,catChip:nS,catFact:oS,catDecision:aS,catConvention:lS,catPitfall:cS,catTodo:dS,catPlaybook:hS,catNote:uS,scopeChip:_S,scopeGlobal:fS,scopeNote:pS,pendingCorner:mS,cardPending:gS,cardDesc:vS,cardPrompt:yS,cardSchedule:xS,cardActions:bS,form:SS,fieldRow:CS,fieldLabel:wS,modalFooter:jS,note:kS,tabs:ES,tab:NS,tabActive:RS,tabCount:LS,cardMeta:TS};function Tr(t){if(!t)return null;try{return JSON.parse(t)}catch{return null}}const IS={id:null,name:"",description:"",prompt_text:"",schedule_config:null};function AS(){const[t,o]=g.useState([]),[m,S]=g.useState(!1),[j,E]=g.useState(null),[b,n]=g.useState(null),[a,d]=g.useState(!1),[h,c]=g.useState(null),f=g.useCallback(async()=>{S(!0),E(null);try{o(await Qt.list())}catch(r){E((r==null?void 0:r.message)??"加载失败")}finally{S(!1)}},[]);g.useEffect(()=>{f()},[f]);const v=()=>{c(null),n({...IS})},y=r=>{c(null),n({id:r.id,name:r.name,description:r.description,prompt_text:r.prompt_text,schedule_config:Tr(r.schedule_config)})},u=async()=>{if(b){if(!b.name.trim()){c("名称不能为空");return}if(!b.prompt_text.trim()){c("prompt_text 不能为空");return}d(!0),c(null);try{const r=b.schedule_config?JSON.stringify(b.schedule_config):null;b.id===null?await Qt.create({name:b.name.trim(),description:b.description,prompt_text:b.prompt_text,schedule_config:r}):await Qt.update(b.id,{name:b.name.trim(),description:b.description,prompt_text:b.prompt_text,schedule_config:r}),n(null),await f()}catch(r){c((r==null?void 0:r.message)??"保存失败")}finally{d(!1)}}},i=async r=>{if(r.is_default!==1&&confirm(`确认删除模板「${r.name}」?`))try{await Qt.remove(r.id),await f()}catch(s){alert(`删除失败: ${(s==null?void 0:s.message)??String(s)}`)}};return e.jsxs("div",{className:Y.container,children:[e.jsxs("div",{className:Y.header,children:[e.jsxs("div",{className:Y.headerText,children:[e.jsx("h2",{className:Y.heading,children:"群指导 Prompt 模板"}),e.jsx("p",{className:Y.subheading,children:"管理可复用的群指导 prompt 模板。选模板建群时,prompt 与调度配置会一并应用。 种子模板不可删除。"})]}),e.jsx(ie,{variant:"primary",size:"sm",onClick:v,children:"+ 新建模板"})]}),m&&e.jsx("div",{className:Y.empty,children:"加载中..."}),j&&e.jsx("div",{className:Y.error,children:j}),!m&&!j&&t.length===0&&e.jsx("div",{className:Y.empty,children:"暂无模板,点「+ 新建模板」创建。"}),e.jsx("div",{className:Y.list,children:t.map(r=>{const s=Tr(r.schedule_config);return e.jsxs("div",{className:Y.card,children:[e.jsxs("div",{className:Y.cardHeader,children:[e.jsx("span",{className:Y.cardName,children:r.name}),r.is_default===1&&e.jsx("span",{className:Y.badgeDefault,children:"种子"}),s&&e.jsx("span",{className:Y.badgeSchedule,children:"·带定时任务"})]}),r.description&&e.jsx("div",{className:Y.cardDesc,children:r.description}),e.jsx("div",{className:Y.cardPrompt,children:r.prompt_text}),s&&e.jsxs("div",{className:Y.cardSchedule,children:[s.schedule_kind==="interval"?`每 ${s.interval_sec}s`+(s.repeat_times?` · 重复 ${s.repeat_times} 次`:" · 无限"):`once · ${s.run_at??0}`,s.mode==="agent"&&s.agent_name?` · agent: ${s.agent_name}`:""]}),e.jsxs("div",{className:Y.cardActions,children:[e.jsx(ie,{variant:"ghost",size:"xs",onClick:()=>y(r),children:"编辑"}),e.jsx(ie,{variant:"danger",size:"xs",outline:!0,disabled:r.is_default===1,onClick:()=>i(r),title:r.is_default===1?"种子模板不可删除":"删除",children:"删除"})]})]},r.id)})}),e.jsx(De,{open:b!==null,title:(b==null?void 0:b.id)===null?"新建 Prompt 模板":"编辑 Prompt 模板",onClose:()=>n(null),size:"lg",footer:e.jsxs("div",{className:Y.modalFooter,children:[h&&e.jsx("span",{className:Y.error,children:h}),e.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>n(null),disabled:a,children:"取消"}),e.jsx(ie,{variant:"primary",size:"sm",onClick:u,loading:a,children:"保存"})]}),children:b&&e.jsxs("div",{className:Y.form,children:[e.jsxs("div",{className:Y.fieldRow,children:[e.jsx("label",{className:Y.fieldLabel,children:"名称"}),e.jsx(ge,{type:"text",value:b.name,onChange:r=>n({...b,name:r.target.value}),placeholder:"模板名称"})]}),e.jsxs("div",{className:Y.fieldRow,children:[e.jsx("label",{className:Y.fieldLabel,children:"描述"}),e.jsx(ge,{type:"text",value:b.description,onChange:r=>n({...b,description:r.target.value}),placeholder:"一句话说明用途"})]}),e.jsxs("div",{className:Y.fieldRow,children:[e.jsx("label",{className:Y.fieldLabel,children:"prompt_text"}),e.jsx(Ks,{value:b.prompt_text,onChange:r=>n({...b,prompt_text:r}),rows:8,placeholder:"支持 {{teacher}}/{{student}}/{{topic}} 占位符"})]}),e.jsxs("div",{className:Y.fieldRow,children:[e.jsx("label",{className:Y.fieldLabel,children:"调度配置"}),e.jsx(xi,{value:b.schedule_config,onChange:r=>n({...b,schedule_config:r})})]})]})})]})}const as={async list(){return ne.get("/schedule-patterns")},async create(t){return ne.post("/schedule-patterns",t)},async update(t,o){return ne.patch(`/schedule-patterns/${t}`,o)},async remove(t){await ne.delete(`/schedule-patterns/${t}`)}};function Ir(t){if(!t)return null;try{return JSON.parse(t)}catch{return null}}const DS={id:null,name:"",description:"",schedule_config:null};function BS(){const[t,o]=g.useState([]),[m,S]=g.useState(!1),[j,E]=g.useState(null),[b,n]=g.useState(null),[a,d]=g.useState(!1),[h,c]=g.useState(null),f=g.useCallback(async()=>{S(!0),E(null);try{o(await as.list())}catch(r){E((r==null?void 0:r.message)??"加载失败")}finally{S(!1)}},[]);g.useEffect(()=>{f()},[f]);const v=()=>{c(null),n({...DS})},y=r=>{c(null),n({id:r.id,name:r.name,description:r.description,schedule_config:Ir(r.schedule_config)})},u=async()=>{if(b){if(!b.name.trim()){c("名称不能为空");return}d(!0),c(null);try{const r=b.schedule_config?JSON.stringify(b.schedule_config):null;b.id===null?await as.create({name:b.name.trim(),description:b.description,schedule_config:r}):await as.update(b.id,{name:b.name.trim(),description:b.description,schedule_config:r}),n(null),await f()}catch(r){c((r==null?void 0:r.message)??"保存失败")}finally{d(!1)}}},i=async r=>{if(r.is_default!==1&&confirm(`确认删除模式「${r.name}」?`))try{await as.remove(r.id),await f()}catch(s){alert(`删除失败: ${(s==null?void 0:s.message)??String(s)}`)}};return e.jsxs("div",{className:Y.container,children:[e.jsxs("div",{className:Y.header,children:[e.jsxs("div",{className:Y.headerText,children:[e.jsx("h2",{className:Y.heading,children:"定时任务模板(调度模式参考库)"}),e.jsx("p",{className:Y.subheading,children:"常见定时任务模式的样板,供学习与引用。不直接管理群内生产任务。 种子模式不可删除。"})]}),e.jsx(ie,{variant:"primary",size:"sm",onClick:v,children:"+ 新建模式"})]}),e.jsx("div",{className:Y.note,children:"💡 这是一个参考库,汇总常见调度模式。要为某个群实际创建定时任务, 请到「对话 → 群设置 → 群指导 prompt → 📚 从模板选择」,或在 Prompt 管理 里给模板配上调度配置后引用。"}),m&&e.jsx("div",{className:Y.empty,children:"加载中..."}),j&&e.jsx("div",{className:Y.error,children:j}),!m&&!j&&t.length===0&&e.jsx("div",{className:Y.empty,children:"暂无模式,点「+ 新建模式」创建。"}),e.jsx("div",{className:Y.list,children:t.map(r=>{const s=Ir(r.schedule_config);return e.jsxs("div",{className:Y.card,children:[e.jsxs("div",{className:Y.cardHeader,children:[e.jsx("span",{className:Y.cardName,children:r.name}),r.is_default===1&&e.jsx("span",{className:Y.badgeDefault,children:"种子"})]}),r.description&&e.jsx("div",{className:Y.cardDesc,children:r.description}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:Y.cardSchedule,children:[s.mode==="agent"?"agent":"message"," · "," ",s.schedule_kind==="interval"?`每 ${s.interval_sec}s`+(s.repeat_times?` · 重复 ${s.repeat_times} 次`:" · 无限"):`once · run_at ${s.run_at??0}`,s.mode==="agent"&&s.agent_name?` · agent: ${s.agent_name}`:""]}),s.prompt&&e.jsx("div",{className:Y.cardPrompt,children:s.prompt})]}),e.jsxs("div",{className:Y.cardActions,children:[e.jsx(ie,{variant:"ghost",size:"xs",onClick:()=>y(r),children:"编辑"}),e.jsx(ie,{variant:"danger",size:"xs",outline:!0,disabled:r.is_default===1,onClick:()=>i(r),title:r.is_default===1?"种子模式不可删除":"删除",children:"删除"})]})]},r.id)})}),e.jsx(De,{open:b!==null,title:(b==null?void 0:b.id)===null?"新建调度模式":"编辑调度模式",onClose:()=>n(null),size:"lg",footer:e.jsxs("div",{className:Y.modalFooter,children:[h&&e.jsx("span",{className:Y.error,children:h}),e.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>n(null),disabled:a,children:"取消"}),e.jsx(ie,{variant:"primary",size:"sm",onClick:u,loading:a,children:"保存"})]}),children:b&&e.jsxs("div",{className:Y.form,children:[e.jsxs("div",{className:Y.fieldRow,children:[e.jsx("label",{className:Y.fieldLabel,children:"名称"}),e.jsx(ge,{type:"text",value:b.name,onChange:r=>n({...b,name:r.target.value}),placeholder:"模式名称"})]}),e.jsxs("div",{className:Y.fieldRow,children:[e.jsx("label",{className:Y.fieldLabel,children:"描述"}),e.jsx(ge,{type:"text",value:b.description,onChange:r=>n({...b,description:r.target.value}),placeholder:"说明这个模式的适用场景"})]}),e.jsxs("div",{className:Y.fieldRow,children:[e.jsx("label",{className:Y.fieldLabel,children:"调度配置"}),e.jsx(xi,{value:b.schedule_config,onChange:r=>n({...b,schedule_config:r})})]})]})})]})}const MS={all:"全部",memory:"记忆",note:"便签",global:"全局",pending:"待审核"},$S={fact:"事实",decision:"决策",convention:"约定",pitfall:"踩坑",todo:"待办",playbook:"工作流",note:"便签"},PS={fact:"catFact",decision:"catDecision",convention:"catConvention",pitfall:"catPitfall",todo:"catTodo",playbook:"catPlaybook",note:"catNote"};function Ar(t,o){return t.pending_review===1?o==="all"||o==="pending":o==="pending"?!1:o==="global"?t.scope==="global":o==="note"?t.agent_visible===0:o==="memory"?t.agent_visible===1&&t.scope!=="global":!0}function OS(){const[t,o]=g.useState([]),[m,S]=g.useState(""),[j,E]=g.useState([]),[b,n]=g.useState([]),[a,d]=g.useState(!1),[h,c]=g.useState(null),[f,v]=g.useState(null),[y,u]=g.useState("all");g.useEffect(()=>{Re.list().then(p=>o((p??[]).map(w=>({id:w.id,name:w.name})))).catch(()=>{})},[]);const i=g.useCallback(async()=>{d(!0),c(null);try{const[p,w,R]=await Promise.all([Ve.listGlobal({type:"all"}),m?Ve.listGroup(m,{type:"all"}):Promise.resolve([]),Ve.listAllPending().catch(()=>[])]),T=R.map(M=>({...M,pending_review:1}));E([...w,...p]),n(T)}catch(p){c(p.message??"加载失败")}finally{d(!1)}},[m]);g.useEffect(()=>{i()},[i]);const r=async p=>{try{v(await Ve.getById(p))}catch(w){c(w.message)}},s=async p=>{await Ve.approve(p),await i()},l=async p=>{confirm("拒绝?软删除")&&(await Ve.reject(p),await i())},_=async p=>{confirm("删除?软删除")&&(await Ve.remove(p),await i())},x=g.useMemo(()=>{const p=new Map;for(const w of j)p.set(w.id,w);for(const w of b)p.set(w.id,w);return Array.from(p.values())},[j,b]),C=g.useMemo(()=>x.filter(p=>Ar(p,y)),[x,y]),k=g.useMemo(()=>{const p={all:0,memory:0,note:0,global:0,pending:0};for(const w of x)for(const R of Object.keys(p))Ar(w,R)&&(p[R]+=1);return p},[x]);return e.jsxs("div",{className:Y.container,children:[e.jsxs("div",{className:Y.header,children:[e.jsxs("div",{className:Y.headerText,children:[e.jsx("h2",{className:Y.heading,children:"记忆(Memory)"}),e.jsx("p",{className:Y.subheading,children:"全局视角:选择群后只显示该群 + 全局共享;不选群时显示全部。 群内新建/编辑请进群的 Memory tab。这里用于跨群审计与审核。"})]}),e.jsx(Fe,{size:"sm",style:{width:220},value:m,onChange:p=>S(p.target.value),options:[{value:"",label:"— 全部群 —"},...t.map(p=>({value:p.id,label:p.name}))]})]}),h&&e.jsx("div",{className:Y.error,children:h}),e.jsx("div",{className:Y.tabs,children:["all","memory","note","global","pending"].map(p=>e.jsxs("button",{type:"button",className:`${Y.tab} ${y===p?Y.tabActive:""}`,onClick:()=>u(p),children:[MS[p],e.jsx("span",{className:Y.tabCount,children:k[p]})]},p))}),a?e.jsx("div",{className:Y.empty,children:"加载中..."}):C.length===0?e.jsx("div",{className:Y.empty,children:"暂无记忆条目"}):e.jsx("div",{className:Y.list,children:C.map(p=>{const w=p.pending_review===1,R=p.scope==="global";return e.jsxs("div",{className:`${Y.card} ${w?Y.cardPending:""}`,children:[e.jsxs("div",{className:Y.cardHeader,children:[e.jsx("span",{className:`${Y.catChip} ${Y[PS[p.category]]}`,children:$S[p.category]}),e.jsx("span",{className:Y.cardName,children:p.key}),!w&&R&&e.jsx("span",{className:`${Y.scopeChip} ${Y.scopeGlobal}`,children:"全局"}),w&&e.jsx("span",{className:Y.pendingCorner,children:"待审核"})]}),p.summary&&e.jsx("div",{className:Y.cardDesc,children:p.summary}),e.jsxs("div",{className:Y.cardMeta,children:[e.jsx("span",{children:p.created_by??""}),e.jsx("span",{children:"·"}),e.jsx("span",{children:p.created_at.slice(0,16).replace("T"," ")}),p.group_id&&!R&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:["群 ",p.group_id.slice(0,8)]})]})]}),e.jsxs("div",{className:Y.cardActions,children:[e.jsx(ie,{variant:"ghost",size:"xs",onClick:()=>r(p.id),children:"查看"}),w?e.jsxs(e.Fragment,{children:[e.jsx(ie,{variant:"success",size:"xs",onClick:()=>s(p.id),children:"通过"}),e.jsx(ie,{variant:"danger",size:"xs",onClick:()=>l(p.id),children:"拒绝"})]}):!R&&e.jsx(ie,{variant:"ghost",size:"xs",onClick:()=>_(p.id),children:"删除"})]})]},p.id)})}),f&&e.jsxs(De,{open:!0,title:`记忆 · ${f.key}`,onClose:()=>v(null),size:"lg",children:[e.jsx("div",{className:Y.cardDesc,children:f.summary}),e.jsx("div",{className:Y.cardPrompt,style:{marginTop:8},children:e.jsx(dt,{content:f.value})})]})]})}const HS={isCreate:!0,originalName:"",name:"",description:"",content:"",category:""},FS=/^[a-z0-9][a-z0-9-]{0,63}$/;function zS(t){return t.name.trim()?FS.test(t.name.trim())?t.description.trim()?t.description.trim().length>1024?"description 过长(>1024)":t.isCreate&&!t.content.trim()?"content 不能为空":null:"description 不能为空(说明「做什么 + 何时用」)":"name 只能用小写字母/数字/短横线,首字符非短横线(禁中文/空格/斜杠)":"name 不能为空"}function WS(){const{myAgentName:t}=nt(),[o,m]=g.useState([]),[S,j]=g.useState([]),[E,b]=g.useState(!1),[n,a]=g.useState(null),[d,h]=g.useState(null),[c,f]=g.useState(null),[v,y]=g.useState(!1),u=g.useCallback(async()=>{b(!0),a(null);try{const[_,x]=await Promise.all([tt.list(),tt.listAllBindings()]);m(_),j(x)}catch(_){a(_.message??"加载失败")}finally{b(!1)}},[]);g.useEffect(()=>{u()},[u]);const i=new Map;for(const _ of S){const x=i.get(_.skill_id)??[];x.push(_),i.set(_.skill_id,x)}const r=async _=>{a(null);try{const x=await tt.getByName(_);h({isCreate:!1,originalName:_,name:x.name,description:x.description,content:x.content,category:x.category??""})}catch(x){a(x.message)}},s=async()=>{if(!d)return;const _=zS(d);if(_){a(_);return}a(null);try{if(d.isCreate)await tt.create({name:d.name.trim(),description:d.description.trim(),content:d.content,category:d.category||void 0,createdBy:t});else{const x={name:d.name.trim(),description:d.description.trim(),category:d.category||null};d.content.trim()&&(x.content=d.content),await tt.update(d.originalName,x)}h(null),await u()}catch(x){a(x.message)}},l=async _=>{if(window.confirm(`删除 skill "${_}"?(软删除,绑定关系保留但不再生效)`))try{await tt.remove(_),await u()}catch(x){a(x.message)}};return e.jsxs("div",{className:Y.container,children:[e.jsxs("div",{className:Y.header,children:[e.jsxs("div",{className:Y.headerText,children:[e.jsx("h2",{className:Y.heading,children:"技能(Skills)"}),e.jsx("p",{className:Y.subheading,children:"全局 skill 知识库。skill 本身无可见性 —— 在「群设置」里给某个 agent 勾选 skill 才会注入该 agent 的 prompt。 playbook 类记忆可「从记忆沉淀」成 skill。"})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>y(!0),children:"从记忆沉淀"}),e.jsx(ie,{variant:"primary",size:"sm",onClick:()=>h({...HS}),children:"+ 新建技能"})]})]}),n&&e.jsx("div",{className:Y.error,children:n}),E&&e.jsx("div",{className:Y.empty,children:"加载中..."}),!E&&o.length===0&&e.jsx("div",{className:Y.empty,children:"暂无技能,点击右上角新建"}),e.jsx("div",{className:Y.list,children:o.map(_=>{const x=i.get(_.id)??[];return e.jsxs("div",{className:Y.card,children:[e.jsxs("div",{className:Y.cardHeader,children:[e.jsx("span",{className:Y.cardName,children:_.name}),_.category&&e.jsx("span",{className:Y.badgeDefault,children:_.category}),_.source_type==="promoted"&&e.jsx("span",{className:Y.badgeSchedule,children:"promoted"}),e.jsxs("span",{className:Y.badgeSchedule,children:["查阅 ",_.view_count]}),e.jsxs("span",{className:Y.cardDesc,children:["· 绑定 ",x.length," 个(群,agent)"]})]}),e.jsx("div",{className:Y.cardDesc,children:_.description}),x.length>0&&e.jsxs("div",{className:Y.cardSchedule,children:["绑定:",x.map(C=>`${C.group_id.slice(0,8)}/${C.agent_name}`).join(", ")]}),e.jsxs("div",{className:Y.cardActions,children:[e.jsx(ie,{variant:"ghost",size:"xs",onClick:()=>tt.getByName(_.name).then(f).catch(C=>a(C.message)),children:"查看"}),e.jsx(ie,{variant:"ghost",size:"xs",onClick:()=>r(_.name),children:"编辑"}),e.jsx(ie,{variant:"ghost",size:"xs",onClick:()=>l(_.name),children:"删除"})]})]},_.id)})}),d&&e.jsx(De,{open:!0,title:d.isCreate?"新建技能":`编辑 ${d.originalName}`,onClose:()=>h(null),size:"lg",children:e.jsxs("div",{className:Y.form,children:[e.jsxs("div",{className:Y.fieldRow,children:[e.jsx("label",{className:Y.fieldLabel,children:"name (小写字母/数字/短横线,禁中文)"}),e.jsx(ge,{value:d.name,onChange:_=>h({...d,name:_.target.value}),placeholder:"如 release-flow"})]}),e.jsxs("div",{className:Y.fieldRow,children:[e.jsx("label",{className:Y.fieldLabel,children:"description (一句话描述)"}),e.jsx(ge,{value:d.description,onChange:_=>h({...d,description:_.target.value})})]}),e.jsxs("div",{className:Y.fieldRow,children:[e.jsx("label",{className:Y.fieldLabel,children:"category (可选)"}),e.jsx(ge,{value:d.category,onChange:_=>h({...d,category:_.target.value})})]}),e.jsxs("div",{className:Y.fieldRow,children:[e.jsx("label",{className:Y.fieldLabel,children:"content (markdown 正文)"}),e.jsx(xt,{style:{minHeight:240,fontFamily:"SF Mono, Menlo, monospace",lineHeight:1.5},value:d.content,onChange:_=>h({...d,content:_.target.value})}),!d.isCreate&&e.jsx("div",{className:Y.note,children:"编辑模式:content 留空 = 不改原有内容;改了才填新内容。"})]}),n&&e.jsx("div",{className:Y.error,children:n}),e.jsxs("div",{className:Y.modalFooter,children:[e.jsx(ie,{variant:"secondary",size:"sm",onClick:()=>h(null),children:"取消"}),e.jsx(ie,{variant:"primary",size:"sm",onClick:s,children:d.isCreate?"创建":"保存"})]})]})}),c&&e.jsxs(De,{open:!0,title:`技能 · ${c.name}`,onClose:()=>f(null),size:"lg",children:[e.jsx("div",{className:Y.cardDesc,children:c.description}),e.jsx("div",{className:Y.cardPrompt,style:{marginTop:8},children:e.jsx(dt,{content:c.content})})]}),v&&e.jsx(US,{myAgentName:t,onClose:()=>y(!1),onDone:async()=>{y(!1),await u()}})]})}function US({myAgentName:t,onClose:o,onDone:m}){const[S,j]=g.useState([]),[E,b]=g.useState(""),[n,a]=g.useState(""),[d,h]=g.useState(""),[c,f]=g.useState(null);g.useEffect(()=>{Ve.listGlobal({category:"playbook"}).then(j).catch(y=>f(y.message))},[]);const v=async()=>{if(!E){f("选一条 playbook memory");return}try{await tt.promoteMemory(E,{name:n||void 0,description:d||void 0,createdBy:t}),m()}catch(y){f(y.message)}};return e.jsx(De,{open:!0,title:"从 playbook 记忆沉淀为 skill",onClose:o,size:"md",children:e.jsxs("div",{className:Y.form,children:[e.jsx("div",{className:Y.note,children:"选一条 category=playbook 的全局记忆,其 value 作为 skill content,生成全局 skill。 原 memory 保留。"}),e.jsxs("div",{className:Y.fieldRow,children:[e.jsx("label",{className:Y.fieldLabel,children:"选择 playbook memory"}),e.jsx(Fe,{value:E,onChange:y=>b(y.target.value),options:[{value:"",label:"— 选择 —"},...S.map(y=>({value:y.id,label:`${y.key} — ${y.summary??""}`}))]}),S.length===0&&e.jsx("div",{className:Y.error,children:"没有全局 playbook 记忆。先 `rotom memory add --scope global --category playbook` 创建。"})]}),e.jsxs("div",{className:Y.fieldRow,children:[e.jsx("label",{className:Y.fieldLabel,children:"skill name (留空用 memory.key)"}),e.jsx(ge,{value:n,onChange:y=>a(y.target.value)})]}),e.jsxs("div",{className:Y.fieldRow,children:[e.jsx("label",{className:Y.fieldLabel,children:"description (留空用 memory.summary)"}),e.jsx(ge,{value:d,onChange:y=>h(y.target.value)})]}),c&&e.jsx("div",{className:Y.error,children:c}),e.jsxs("div",{className:Y.modalFooter,children:[e.jsx(ie,{variant:"secondary",size:"sm",onClick:o,children:"取消"}),e.jsx(ie,{variant:"primary",size:"sm",onClick:v,children:"沉淀"})]})]})})}const Ot={async state(){return ne.get("/issues-patrol/state")},async updateConfig(t){return ne.patch("/issues-patrol/config",t)},async listRuns(t=50){return(await ne.get(`/issues-patrol/runs?limit=${t}`)).runs},async listRunLogs(t){return(await ne.get(`/issues-patrol/runs/${encodeURIComponent(t)}/logs`)).logs},async listLogs(t){const o=new URLSearchParams;t!=null&&t.limit&&o.set("limit",String(t.limit)),t!=null&&t.verdict&&o.set("verdict",t.verdict),t!=null&&t.candidateGroupId&&o.set("candidateGroupId",t.candidateGroupId);const m=o.toString();return(await ne.get(`/issues-patrol/logs${m?`?${m}`:""}`)).logs},async trigger(t){return ne.post(`/schedules/${t}/trigger`)}},qS={ready:"✅ 可认领",not_ready:"⛔ 不建议",uncertain:"❓ 不确定",skipped:"⏭ 跳过"},VS={dispatched:"已派发",completed:"已完成",skipped_quota:"跳过(配额)",skipped_overlap:"跳过(重叠)",agent_offline:"跳过(离线)",error:"错误"};function ls(t){if(!t)return"-";const o=typeof t=="number"?t:Date.parse(t);return Number.isFinite(o)?new Date(o).toLocaleString("zh-CN",{hour12:!1}):String(t)}function GS(){const t=Ut(),[o,m]=g.useState(null),[S,j]=g.useState([]),[E,b]=g.useState(null),[n,a]=g.useState([]),[d,h]=g.useState(!1),[c,f]=g.useState(null),[v,y]=g.useState(!1),[u,i]=g.useState(3),[r,s]=g.useState(3),[l,_]=g.useState(10),[x,C]=g.useState(7200),k=g.useCallback(async()=>{h(!0),f(null);try{const[T,M]=await Promise.all([Ot.state(),Ot.listRuns(50)]);m(T),j(M),T.throughputCap&&i(T.throughputCap),T.candidateCap&&s(T.candidateCap),T.scanBatch&&_(T.scanBatch),T.intervalSec&&C(T.intervalSec),!E&&M.length>0&&b(M[0].run_id)}catch(T){f(T instanceof Error?T.message:String(T))}finally{h(!1)}},[E]);g.useEffect(()=>{k()},[k]),g.useEffect(()=>{if(!E){a([]);return}Ot.listRunLogs(E).then(a).catch(T=>{f(T instanceof Error?T.message:String(T)),a([])})},[E]);const p=async()=>{if(o!=null&&o.taskId){y(!0);try{const T=!o.enabled;await Ot.updateConfig({enabled:T}),await k()}catch(T){f(T instanceof Error?T.message:String(T))}finally{y(!1)}}},w=async()=>{if(o!=null&&o.taskId){y(!0);try{await Ot.trigger(o.taskId),await k()}catch(T){f(T instanceof Error?T.message:String(T))}finally{y(!1)}}},R=async()=>{y(!0);try{await Ot.updateConfig({throughputCap:u,candidateCap:r,scanBatch:l,intervalSec:x}),await k()}catch(T){f(T instanceof Error?T.message:String(T))}finally{y(!1)}};return d&&!o?e.jsx("div",{className:Y.container,children:"加载中..."}):o!=null&&o.hasPatrolGroup?e.jsxs("div",{className:Y.container,children:[e.jsxs("div",{className:Y.header,children:[e.jsxs("div",{className:Y.headerText,children:[e.jsx("h2",{className:Y.heading,children:"Issue 巡检"}),e.jsxs("p",{className:Y.subheading,children:["巡检群「",o.patrolGroupName,"」· 巡检员 ",o.patrolAgentName||"(未设置)",o.lastRunAt?` · 上次 ${ls(o.lastRunAt)}`:"",o.lastStatus?` · ${o.lastStatus}`:""]})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(ie,{variant:o.enabled?"danger":"primary",size:"md",onClick:p,disabled:v||!o.taskId,children:o.enabled?"关闭巡检":"开启巡检"}),e.jsx(ie,{variant:"secondary",size:"md",onClick:w,disabled:v||!o.taskId||!o.enabled,children:"立即巡检"})]})]}),c&&e.jsx("div",{style:{padding:12,background:"rgba(255,80,80,0.08)",color:"#c33",borderRadius:8,fontSize:13},children:c}),o.lastError&&e.jsxs("div",{style:{padding:10,background:"rgba(255,180,0,0.08)",color:"#a80",borderRadius:8,fontSize:12},children:["上次错误: ",o.lastError]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{style:{padding:16,background:"rgba(0,0,0,0.03)",borderRadius:8},children:[e.jsx("h3",{style:{margin:"0 0 12px",fontSize:14,fontWeight:700},children:"调度"}),e.jsxs("div",{style:{fontSize:13,lineHeight:1.8},children:[e.jsxs("div",{children:["状态: ",e.jsx("strong",{children:o.enabled?"已启用":"已关闭"})]}),e.jsxs("div",{children:["间隔(秒): ",e.jsx("strong",{children:o.intervalSec??"-"})]}),e.jsxs("div",{children:["下次巡检: ",ls(o.nextRunAt)]})]})]}),e.jsxs("div",{style:{padding:16,background:"rgba(0,0,0,0.03)",borderRadius:8},children:[e.jsx("h3",{style:{margin:"0 0 12px",fontSize:14,fontWeight:700},children:"节流参数"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,fontSize:13},children:[e.jsxs("label",{children:["吞吐上限 throughputCap:"," ",e.jsx(ge,{type:"number",min:1,max:20,size:"sm",value:u,onChange:T=>i(Number(T.target.value)||3),style:{width:60}})]}),e.jsxs("label",{children:["候选上限 candidateCap:"," ",e.jsx(ge,{type:"number",min:1,max:20,size:"sm",value:r,onChange:T=>s(Number(T.target.value)||3),style:{width:60}})]}),e.jsxs("label",{children:["扫描批大小 scanBatch:"," ",e.jsx(ge,{type:"number",min:1,max:50,size:"sm",value:l,onChange:T=>_(Number(T.target.value)||10),style:{width:60}})]}),e.jsxs("label",{children:["间隔 intervalSec:"," ",e.jsx(ge,{type:"number",min:60,size:"sm",value:x,onChange:T=>C(Number(T.target.value)||7200),style:{width:80}})]}),e.jsx(ie,{variant:"secondary",size:"sm",onClick:R,disabled:v,children:"保存参数"})]})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1.2fr)",gap:16,alignItems:"start"},children:[e.jsxs("div",{children:[e.jsx("h3",{style:{fontSize:14,fontWeight:700,margin:"0 0 8px"},children:"最近巡检"}),e.jsx("div",{style:{overflowX:"auto",maxHeight:"60vh",overflowY:"auto",border:"1px solid rgba(0,0,0,0.06)",borderRadius:8},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{style:{position:"sticky",top:0,background:"#fff",zIndex:1},children:e.jsxs("tr",{style:{textAlign:"left",borderBottom:"2px solid rgba(0,0,0,0.1)"},children:[e.jsx("th",{style:{padding:"6px 8px"},children:"开始时间"}),e.jsx("th",{style:{padding:"6px 8px"},children:"状态"}),e.jsx("th",{style:{padding:"6px 8px"},children:"in_progress"}),e.jsx("th",{style:{padding:"6px 8px"},children:"扫描"}),e.jsx("th",{style:{padding:"6px 8px"},children:"可认领"}),e.jsx("th",{style:{padding:"6px 8px"},children:"备注"})]})}),e.jsxs("tbody",{children:[S.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,style:{padding:16,textAlign:"center",color:"#888"},children:"还没有巡检记录"})}),S.map(T=>e.jsxs("tr",{onClick:()=>b(T.run_id),style:{cursor:"pointer",background:T.run_id===E?"rgba(99,102,241,0.08)":"transparent",borderBottom:"1px solid rgba(0,0,0,0.05)"},children:[e.jsx("td",{style:{padding:"6px 8px",whiteSpace:"pre-line",fontSize:12},children:ls(T.started_at).replace(" ",`
176
+ `)}),e.jsx("td",{style:{padding:"6px 8px"},children:VS[T.status]}),e.jsx("td",{style:{padding:"6px 8px"},children:T.in_progress_count}),e.jsx("td",{style:{padding:"6px 8px"},children:T.candidates_scanned}),e.jsx("td",{style:{padding:"6px 8px"},children:T.candidates_ready}),e.jsx("td",{style:{padding:"6px 8px",color:"#888",fontSize:12},children:T.note??""})]},T.run_id))]})]})})]}),e.jsxs("div",{children:[e.jsxs("h3",{style:{fontSize:14,fontWeight:700,margin:"0 0 8px"},children:["日志 ",E?`· 选中 run ${E.slice(0,8)}`:""]}),e.jsx("div",{style:{overflowX:"auto",maxHeight:"60vh",overflowY:"auto",border:"1px solid rgba(0,0,0,0.06)",borderRadius:8},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{style:{position:"sticky",top:0,background:"#fff",zIndex:1},children:e.jsxs("tr",{style:{textAlign:"left",borderBottom:"2px solid rgba(0,0,0,0.1)"},children:[e.jsx("th",{style:{padding:"6px 8px"},children:"时间"}),e.jsx("th",{style:{padding:"6px 8px"},children:"verdict"}),e.jsx("th",{style:{padding:"6px 8px"},children:"issue"}),e.jsx("th",{style:{padding:"6px 8px"},children:"命中规则"}),e.jsx("th",{style:{padding:"6px 8px"},children:"理由"})]})}),e.jsxs("tbody",{children:[n.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,style:{padding:16,textAlign:"center",color:"#888"},children:E?"该轮无日志":"请选择左侧某次巡检"})}),n.map(T=>{const M=T.issue_id;return e.jsxs("tr",{style:{borderBottom:"1px solid rgba(0,0,0,0.05)"},children:[e.jsx("td",{style:{padding:"6px 8px",whiteSpace:"nowrap"},children:ls(T.created_at)}),e.jsx("td",{style:{padding:"6px 8px"},children:qS[T.verdict]}),e.jsx("td",{style:{padding:"6px 8px",fontFamily:"monospace",fontSize:11},children:M?e.jsx("a",{style:{color:"#4f46e5",cursor:"pointer",textDecoration:"underline"},title:"在看板中打开该 Issue",onClick:N=>{N.preventDefault(),t(`/dashboard/kanban?issue=${encodeURIComponent(M)}`)},href:`/dashboard/kanban?issue=${encodeURIComponent(M)}`,children:M.slice(0,8)}):"-"}),e.jsx("td",{style:{padding:"6px 8px"},children:T.rule_matched??"-"}),e.jsx("td",{style:{padding:"6px 8px",color:"#666",maxWidth:400},children:T.rationale??"-"})]},T.id)})]})]})})]})]})]}):e.jsx("div",{className:Y.container,children:e.jsx("div",{className:Y.header,children:e.jsxs("div",{className:Y.headerText,children:[e.jsx("h2",{className:Y.heading,children:"Issue 巡检"}),e.jsx("p",{className:Y.subheading,children:"还未创建巡检群。去「群」页面创建一个 type=巡检群 的群,选 1 个 agent 作为巡检员,建群后会自动创建每小时巡检任务。"})]})})})}const ft={async state(){return ne.get("/links-patrol/state")},async updateConfig(t){return ne.patch("/links-patrol/config",t)},async stats(){return ne.get("/links-patrol/stats")},async listRuns(t=50){return(await ne.get(`/links-patrol/runs?limit=${t}`)).runs},async listRunLogs(t){return(await ne.get(`/links-patrol/runs/${encodeURIComponent(t)}/logs`)).logs},async listLinks(t){const o=new URLSearchParams;t!=null&&t.category&&o.set("category",t.category),t!=null&&t.tag&&o.set("tag",t.tag),t!=null&&t.search&&o.set("search",t.search),t!=null&&t.groupId&&o.set("group_id",t.groupId),t!=null&&t.host&&o.set("host",t.host),t!=null&&t.limit&&o.set("limit",String(t.limit)),t!=null&&t.offset&&o.set("offset",String(t.offset));const m=o.toString();return ne.get(`/links${m?`?${m}`:""}`)},async getLink(t){return ne.get(`/links/${encodeURIComponent(t)}`)},async updateLink(t,o){return ne.patch(`/links/${encodeURIComponent(t)}`,o)},async trigger(t){return ne.post(`/schedules/${t}/trigger`)}},Dr=["reference","code","tool","article","paper","discussion","issue-tracker","media","other"],KS={dispatched:"已派发",completed:"已完成",skipped:"跳过",agent_offline:"跳过(离线)",error:"错误"};function Ht(t){if(!t)return"-";const o=typeof t=="number"?t:Date.parse(t);return Number.isFinite(o)?new Date(o).toLocaleString("zh-CN",{hour12:!1}):String(t)}function JS(){const[t,o]=g.useState(null),[m,S]=g.useState(null),[j,E]=g.useState([]),[b,n]=g.useState([]),[a,d]=g.useState(0),[h,c]=g.useState(null),[f,v]=g.useState([]),[y,u]=g.useState(!1),[i,r]=g.useState(null),[s,l]=g.useState(null),[_,x]=g.useState(!1),[C,k]=g.useState(20),[p,w]=g.useState(3600),[R,T]=g.useState(""),[M,N]=g.useState(""),[I,z]=g.useState(""),[G,H]=g.useState(""),[V,L]=g.useState(null),[A,B]=g.useState(""),[P,U]=g.useState(""),[Z,oe]=g.useState(""),K=g.useCallback(async()=>{u(!0),r(null);try{const[F,W,re]=await Promise.all([ft.state(),ft.stats(),ft.listRuns(50)]);o(F),S(W),E(re),F.scanBatch&&k(F.scanBatch),F.intervalSec&&w(F.intervalSec),!h&&re.length>0&&c(re[0].run_id)}catch(F){r(F instanceof Error?F.message:String(F))}finally{u(!1)}},[h]),$=g.useCallback(async()=>{try{const F=await ft.listLinks({category:R||void 0,tag:M||void 0,search:I||void 0,host:G||void 0,limit:100});n(F.items),d(F.total)}catch(F){r(F instanceof Error?F.message:String(F))}},[R,M,I,G]);g.useEffect(()=>{K()},[K]),g.useEffect(()=>{$()},[$]),g.useEffect(()=>{if(!h){v([]);return}ft.listRunLogs(h).then(v).catch(F=>{r(F instanceof Error?F.message:String(F)),v([])})},[h]),g.useEffect(()=>{if(!s)return;const F=setTimeout(()=>l(null),4e3);return()=>clearTimeout(F)},[s]);const D=async()=>{if(t!=null&&t.taskId){x(!0);try{const F=!t.enabled;await ft.updateConfig({enabled:F}),await K(),l(F?"已开启分类":"已关闭分类")}catch(F){r(F instanceof Error?F.message:String(F))}finally{x(!1)}}},q=async()=>{if(t!=null&&t.taskId){x(!0);try{await ft.trigger(t.taskId),await K(),l("已触发立即巡检,稍后刷新查看结果")}catch(F){r(F instanceof Error?F.message:String(F))}finally{x(!1)}}},J=async()=>{x(!0);try{await ft.updateConfig({scanBatch:C,intervalSec:p}),await K(),l("参数已保存")}catch(F){r(F instanceof Error?F.message:String(F))}finally{x(!1)}},O=F=>{L(F),B(F.category??""),U(F.title??""),ft.getLink(F.id).then(W=>{oe(W.tags.join(", "))}).catch(()=>{oe("")})},X=async()=>{if(V){x(!0);try{const F=Z.split(/[,\s]+/).map(W=>W.trim()).filter(Boolean);await ft.updateLink(V.id,{category:A||void 0,title:P||void 0,tags:F}),L(null),await $(),l("链接已更新,host 规则已写入 memory")}catch(F){r(F instanceof Error?F.message:String(F))}finally{x(!1)}}};return y&&!t?e.jsx("div",{className:Y.container,children:"加载中..."}):t!=null&&t.hasPatrolGroup?e.jsxs("div",{className:Y.container,children:[e.jsxs("div",{className:Y.header,children:[e.jsxs("div",{className:Y.headerText,children:[e.jsx("h2",{className:Y.heading,children:"🔗 Link 智能分类"}),e.jsxs("p",{className:Y.subheading,children:["群「",t.patrolGroupName,"」· 巡检员 ",t.patrolAgentName||"(未设置)",t.lastRunAt?` · 上次 ${Ht(t.lastRunAt)}`:"",t.lastStatus?` · ${t.lastStatus}`:""]})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(ie,{variant:t.enabled?"danger":"primary",size:"md",onClick:D,disabled:_||!t.taskId,children:t.enabled?"关闭分类":"开启分类"}),e.jsx(ie,{variant:"secondary",size:"md",onClick:q,disabled:_||!t.taskId||!t.enabled,children:"立即巡检"})]})]}),i&&e.jsx("div",{style:{padding:12,background:"rgba(255,80,80,0.08)",color:"#c33",borderRadius:8,fontSize:13},children:i}),s&&e.jsxs("div",{style:{padding:12,background:"rgba(34,197,94,0.08)",color:"#0a7a32",borderRadius:8,fontSize:13},children:["✓ ",s]}),t.lastError&&e.jsxs("div",{style:{padding:10,background:"rgba(255,180,0,0.08)",color:"#a80",borderRadius:8,fontSize:12},children:["上次错误: ",t.lastError]}),m&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12},children:[e.jsx(cs,{label:"总链接",value:m.totalLinks,hint:"links.url_norm UNIQUE"}),e.jsx(cs,{label:"未分类",value:m.unclassified,hint:"待巡检处理",highlight:m.unclassified>0}),e.jsx(cs,{label:"出现次数",value:m.totalOccurrences,hint:"含 dedup 后累加"}),e.jsx(cs,{label:"已分类 host",value:m.classifiedHosts,hint:"unique host"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{style:{padding:16,background:"rgba(0,0,0,0.03)",borderRadius:8},children:[e.jsx("h3",{style:{margin:"0 0 12px",fontSize:14,fontWeight:700},children:"调度"}),e.jsxs("div",{style:{fontSize:13,lineHeight:1.8},children:[e.jsxs("div",{children:["状态: ",e.jsx("strong",{children:t.enabled?"已启用":"已关闭"})]}),e.jsxs("div",{children:["间隔(秒): ",e.jsx("strong",{children:t.intervalSec??"-"})]}),e.jsxs("div",{children:["下次巡检: ",Ht(t.nextRunAt)]}),(m==null?void 0:m.lastRun)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["上次跑: ",Ht(m.lastRun.started_at)]}),e.jsxs("div",{children:["上次状态: ",m.lastRun.status," · 扫描 ",m.lastRun.candidates_scanned," / 分类 ",m.lastRun.candidates_classified]}),m.lastRun.note&&e.jsx("div",{style:{color:"#888",fontSize:12},children:m.lastRun.note})]})]})]}),e.jsxs("div",{style:{padding:16,background:"rgba(0,0,0,0.03)",borderRadius:8},children:[e.jsx("h3",{style:{margin:"0 0 12px",fontSize:14,fontWeight:700},children:"节流参数"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,fontSize:13},children:[e.jsxs("label",{children:["每轮扫描上限 scanBatch:"," ",e.jsx(ge,{type:"number",min:1,max:100,size:"sm",value:C,onChange:F=>k(Number(F.target.value)||20),style:{width:60}})]}),e.jsxs("label",{children:["间隔 intervalSec:"," ",e.jsx(ge,{type:"number",min:60,size:"sm",value:p,onChange:F=>w(Number(F.target.value)||3600),style:{width:80}})]}),e.jsx(ie,{variant:"secondary",size:"sm",onClick:J,disabled:_,children:"保存参数"})]})]})]}),e.jsxs("div",{children:[e.jsxs("h3",{style:{fontSize:14,fontWeight:700,margin:"0 0 8px"},children:["链接列表(",a," 条,展示前 ",b.length,")"]}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginBottom:8,fontSize:12},children:[e.jsxs("label",{children:["分类:",e.jsx(Fe,{size:"sm",value:R,onChange:F=>T(F.target.value),style:{marginLeft:4,width:"auto"},options:[{value:"",label:"全部"},...Dr.map(F=>({value:F,label:F})),{value:"__unclassified__",label:"未分类"}]})]}),e.jsxs("label",{children:["tag:",e.jsx(ge,{size:"sm",value:M,onChange:F=>N(F.target.value),style:{marginLeft:4,width:80}})]}),e.jsxs("label",{children:["host:",e.jsx(ge,{size:"sm",value:G,onChange:F=>H(F.target.value),style:{marginLeft:4,width:100}})]}),e.jsxs("label",{children:["搜索:",e.jsx(ge,{size:"sm",value:I,onChange:F=>z(F.target.value),style:{marginLeft:4,width:120},placeholder:"url / title"})]}),e.jsx(ie,{size:"sm",variant:"secondary",onClick:$,disabled:_,children:"刷新"})]}),V&&e.jsxs("div",{style:{padding:12,background:"rgba(99,102,241,0.06)",borderRadius:8,marginBottom:8,fontSize:13},children:[e.jsxs("div",{style:{marginBottom:8,fontWeight:700},children:["编辑: ",V.url_raw]}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:8,alignItems:"center"},children:[e.jsxs("label",{children:["category:",e.jsx(Fe,{size:"sm",value:A,onChange:F=>B(F.target.value),style:{marginLeft:4,width:"auto"},options:[{value:"",label:"未分类"},...Dr.map(F=>({value:F,label:F}))]})]}),e.jsxs("label",{children:["title:",e.jsx(ge,{size:"sm",value:P,onChange:F=>U(F.target.value),style:{marginLeft:4,width:220}})]}),e.jsxs("label",{style:{flex:1,minWidth:220},children:["tags(逗号分隔):",e.jsx(ge,{size:"sm",value:Z,onChange:F=>oe(F.target.value),style:{marginLeft:4,width:"70%"}})]}),e.jsx(ie,{size:"sm",variant:"primary",onClick:X,disabled:_,children:"保存"}),e.jsx(ie,{size:"sm",variant:"secondary",onClick:()=>L(null),disabled:_,children:"取消"}),e.jsx("span",{style:{color:"#888",fontSize:11},children:"保存会同时把 host 规则写入 memory(link_classification + manual)"})]})]}),e.jsx("div",{style:{overflowX:"auto",maxHeight:"50vh",overflowY:"auto",border:"1px solid rgba(0,0,0,0.06)",borderRadius:8},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[e.jsx("thead",{style:{position:"sticky",top:0,background:"#fff",zIndex:1},children:e.jsxs("tr",{style:{textAlign:"left",borderBottom:"2px solid rgba(0,0,0,0.1)"},children:[e.jsx("th",{style:{padding:"6px 8px"},children:"host"}),e.jsx("th",{style:{padding:"6px 8px"},children:"url"}),e.jsx("th",{style:{padding:"6px 8px"},children:"category"}),e.jsx("th",{style:{padding:"6px 8px"},children:"tags"}),e.jsx("th",{style:{padding:"6px 8px"},children:"title"}),e.jsx("th",{style:{padding:"6px 8px"},children:"last_seen"}),e.jsx("th",{style:{padding:"6px 8px"}})]})}),e.jsxs("tbody",{children:[b.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,style:{padding:16,textAlign:"center",color:"#888"},children:"没有符合条件的链接"})}),b.map(F=>e.jsxs("tr",{onClick:()=>O(F),style:{cursor:"pointer",background:F.id===(V==null?void 0:V.id)?"rgba(99,102,241,0.08)":"transparent",borderBottom:"1px solid rgba(0,0,0,0.05)"},children:[e.jsx("td",{style:{padding:"6px 8px",fontFamily:"monospace",fontSize:11},children:F.host}),e.jsx("td",{style:{padding:"6px 8px",maxWidth:280,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.jsx("a",{href:F.url_raw,target:"_blank",rel:"noreferrer",onClick:W=>W.stopPropagation(),style:{color:"#4f46e5",textDecoration:"underline"},children:F.url_raw})}),e.jsx("td",{style:{padding:"6px 8px"},children:F.category?e.jsx("span",{style:{padding:"1px 6px",background:"rgba(99,102,241,0.12)",color:"#4f46e5",borderRadius:4,fontSize:11,fontWeight:600},children:F.category}):e.jsx("span",{style:{color:"#aaa",fontSize:11},children:"—"})}),e.jsx("td",{style:{padding:"6px 8px",color:"#666",fontSize:11},children:F.title?`📝 ${F.title}`:"—"}),e.jsx("td",{style:{padding:"6px 8px",whiteSpace:"nowrap"},children:Ht(F.last_seen_at).replace(" ",`
177
+ `)}),e.jsx("td",{style:{padding:"6px 8px",color:"#4f46e5",fontSize:11},children:"编辑"})]},F.id))]})]})})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1.2fr)",gap:16,alignItems:"start"},children:[e.jsxs("div",{children:[e.jsx("h3",{style:{fontSize:14,fontWeight:700,margin:"0 0 8px"},children:"最近巡检"}),e.jsx("div",{style:{overflowX:"auto",maxHeight:"50vh",overflowY:"auto",border:"1px solid rgba(0,0,0,0.06)",borderRadius:8},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[e.jsx("thead",{style:{position:"sticky",top:0,background:"#fff",zIndex:1},children:e.jsxs("tr",{style:{textAlign:"left",borderBottom:"2px solid rgba(0,0,0,0.1)"},children:[e.jsx("th",{style:{padding:"6px 8px"},children:"开始"}),e.jsx("th",{style:{padding:"6px 8px"},children:"状态"}),e.jsx("th",{style:{padding:"6px 8px"},children:"扫描"}),e.jsx("th",{style:{padding:"6px 8px"},children:"分类"}),e.jsx("th",{style:{padding:"6px 8px"},children:"备注"})]})}),e.jsxs("tbody",{children:[j.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,style:{padding:16,textAlign:"center",color:"#888"},children:"还没有巡检记录"})}),j.map(F=>e.jsxs("tr",{onClick:()=>c(F.run_id),style:{cursor:"pointer",background:F.run_id===h?"rgba(99,102,241,0.08)":"transparent",borderBottom:"1px solid rgba(0,0,0,0.05)"},children:[e.jsx("td",{style:{padding:"6px 8px",whiteSpace:"pre-line",fontSize:11},children:Ht(F.started_at).replace(" ",`
178
+ `)}),e.jsx("td",{style:{padding:"6px 8px"},children:KS[F.status]}),e.jsx("td",{style:{padding:"6px 8px"},children:F.candidates_scanned}),e.jsx("td",{style:{padding:"6px 8px"},children:F.candidates_classified}),e.jsx("td",{style:{padding:"6px 8px",color:"#888",fontSize:11},children:F.note??""})]},F.run_id))]})]})})]}),e.jsxs("div",{children:[e.jsxs("h3",{style:{fontSize:14,fontWeight:700,margin:"0 0 8px"},children:["日志 ",h?`· 选中 run ${h.slice(0,8)}`:""]}),e.jsx("div",{style:{overflowX:"auto",maxHeight:"50vh",overflowY:"auto",border:"1px solid rgba(0,0,0,0.06)",borderRadius:8},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[e.jsx("thead",{style:{position:"sticky",top:0,background:"#fff",zIndex:1},children:e.jsxs("tr",{style:{textAlign:"left",borderBottom:"2px solid rgba(0,0,0,0.1)"},children:[e.jsx("th",{style:{padding:"6px 8px"},children:"时间"}),e.jsx("th",{style:{padding:"6px 8px"},children:"category"}),e.jsx("th",{style:{padding:"6px 8px"},children:"tags"}),e.jsx("th",{style:{padding:"6px 8px"},children:"title"}),e.jsx("th",{style:{padding:"6px 8px"},children:"rationale"})]})}),e.jsxs("tbody",{children:[f.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,style:{padding:16,textAlign:"center",color:"#888"},children:h?"该轮无日志":"请选择左侧某次巡检"})}),f.map(F=>{let W=[];if(F.tags)try{const re=JSON.parse(F.tags);Array.isArray(re)&&(W=re)}catch{}return e.jsxs("tr",{style:{borderBottom:"1px solid rgba(0,0,0,0.05)"},children:[e.jsx("td",{style:{padding:"6px 8px",whiteSpace:"nowrap"},children:Ht(F.created_at)}),e.jsx("td",{style:{padding:"6px 8px"},children:e.jsx("span",{style:{padding:"1px 6px",background:"rgba(99,102,241,0.12)",color:"#4f46e5",borderRadius:4,fontSize:11,fontWeight:600},children:F.category})}),e.jsx("td",{style:{padding:"6px 8px",color:"#666",fontSize:11},children:W.join(", ")||"—"}),e.jsx("td",{style:{padding:"6px 8px",color:"#666"},children:F.title??"—"}),e.jsx("td",{style:{padding:"6px 8px",color:"#666",maxWidth:360,fontSize:11},children:F.rationale??"—"})]},F.id)})]})]})})]})]})]}):e.jsx("div",{className:Y.container,children:e.jsx("div",{className:Y.header,children:e.jsxs("div",{className:Y.headerText,children:[e.jsx("h2",{className:Y.heading,children:"Link 智能分类"}),e.jsx("p",{className:Y.subheading,children:"还未创建链接归纳群。去「群」页面创建一个 type=巡检群 的群并选 1 个 agent 作为巡检员,建群后会自动创建每小时分类任务。"})]})})})}function cs({label:t,value:o,hint:m,highlight:S}){return e.jsxs("div",{style:{padding:"12px 16px",background:S?"rgba(255,180,0,0.08)":"rgba(0,0,0,0.03)",borderRadius:8,border:S?"1px solid rgba(255,180,0,0.3)":"1px solid transparent"},children:[e.jsx("div",{style:{fontSize:11,color:"#888",textTransform:"uppercase",letterSpacing:.5},children:t}),e.jsx("div",{style:{fontSize:24,fontWeight:700,marginTop:4},children:o}),m&&e.jsx("div",{style:{fontSize:11,color:"#888",marginTop:2},children:m})]})}const Br={async list(t){const o=new URLSearchParams;t!=null&&t.groupId&&o.set("groupId",t.groupId),t!=null&&t.limit&&o.set("limit",String(t.limit)),t!=null&&t.cursor&&o.set("cursor",t.cursor);const m=o.toString();return ne.get(`/uploads${m?`?${m}`:""}`)}};function Mr(t){const o=Date.parse(t);return Number.isFinite(o)?new Date(o).toLocaleString("zh-CN",{hour12:!1}):t}function $r(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(2)} MB`}function XS(){const[t,o]=g.useState([]),[m,S]=g.useState(""),[j,E]=g.useState([]),[b,n]=g.useState(null),[a,d]=g.useState(!1),[h,c]=g.useState(!1),[f,v]=g.useState(null),[y,u]=g.useState(null),[i,r]=g.useState("");g.useEffect(()=>{Re.list().then(x=>o(x??[])).catch(()=>{})},[]);const s=g.useCallback(async()=>{d(!0),v(null);try{const x=await Br.list({groupId:m||void 0,limit:60});E(x.items),n(x.nextCursor)}catch(x){v(x instanceof Error?x.message:String(x)),E([]),n(null)}finally{d(!1)}},[m]);g.useEffect(()=>{s()},[s]);const l=async()=>{if(!(!b||h)){c(!0),v(null);try{const x=await Br.list({groupId:m||void 0,limit:60,cursor:b});E(C=>[...C,...x.items]),n(x.nextCursor)}catch(x){v(x instanceof Error?x.message:String(x))}finally{c(!1)}}},_=async x=>{const C=`${window.location.origin}${x.url}`;try{await navigator.clipboard.writeText(C),r("已复制 ✓"),setTimeout(()=>r(""),1500)}catch{r("复制失败,请手动选中地址栏"),setTimeout(()=>r(""),2500)}};return a&&j.length===0?e.jsx("div",{className:Y.container,children:"加载中..."}):e.jsxs("div",{className:Y.container,children:[e.jsxs("div",{className:Y.header,children:[e.jsxs("div",{className:Y.headerText,children:[e.jsx("h2",{className:Y.heading,children:"图册"}),e.jsx("p",{className:Y.subheading,children:"跨群汇总所有上传过的图片。点击预览大图,可复制链接。 上传请在群聊里完成(粘贴/拖拽/选择文件),这里只做查看。"})]}),e.jsx(Fe,{size:"sm",style:{width:220},value:m,onChange:x=>S(x.target.value),options:[{value:"",label:"— 全部群 —"},...t.map(x=>({value:x.id,label:`${x.name}${x.archived_at?" (已归档)":""}`}))]})]}),f&&e.jsx("div",{style:{padding:12,background:"rgba(255,80,80,0.08)",color:"#c33",borderRadius:8,fontSize:13},children:f}),j.length===0&&!a&&!f&&e.jsx("div",{className:Y.empty,children:"还没有上传过图片"}),j.length>0&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:12},children:j.map(x=>e.jsxs("button",{onClick:()=>u(x),style:{display:"flex",flexDirection:"column",padding:0,border:"1px solid rgba(0,0,0,0.08)",borderRadius:8,background:"#fff",cursor:"pointer",textAlign:"left",overflow:"hidden"},children:[e.jsx("div",{style:{width:"100%",aspectRatio:"1 / 1",background:"rgba(0,0,0,0.04)",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},children:e.jsx("img",{src:x.url,alt:x.fileName,loading:"lazy",style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"}})}),e.jsxs("div",{style:{padding:"6px 8px",fontSize:11,color:"#666",lineHeight:1.4},children:[e.jsx("div",{style:{fontWeight:600,color:"#333",marginBottom:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.groupName}),e.jsxs("div",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[Mr(x.createdAt).split(" ")[0]," · ",$r(x.size)]})]})]},`${x.groupId}/${x.fileName}`))}),b&&e.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:12},children:e.jsx(ie,{variant:"secondary",size:"sm",onClick:l,disabled:h,children:h?"加载中...":"加载更多"})}),e.jsx(De,{open:!!y,title:y?y.fileName:"",onClose:()=>u(null),size:"xl",children:y&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) 240px",gap:16,alignItems:"start"},children:[e.jsx("div",{style:{background:"rgba(0,0,0,0.03)",borderRadius:8,padding:12,display:"flex",alignItems:"center",justifyContent:"center",minHeight:300},children:e.jsx("img",{src:y.url,alt:y.fileName,style:{maxWidth:"100%",maxHeight:"70vh",objectFit:"contain"}})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,fontSize:13,lineHeight:1.6},children:[e.jsxs("div",{children:[e.jsx("strong",{children:"群"}),e.jsx("br",{}),y.groupName]}),e.jsxs("div",{children:[e.jsx("strong",{children:"上传时间"}),e.jsx("br",{}),Mr(y.createdAt)]}),e.jsxs("div",{children:[e.jsx("strong",{children:"大小"}),e.jsx("br",{}),$r(y.size)]}),e.jsxs("div",{children:[e.jsx("strong",{children:"类型"}),e.jsx("br",{}),y.mimeType]}),e.jsxs("div",{style:{wordBreak:"break-all"},children:[e.jsx("strong",{children:"文件名"}),e.jsx("br",{}),e.jsx("code",{style:{fontSize:11},children:y.fileName})]}),e.jsxs("div",{style:{wordBreak:"break-all"},children:[e.jsx("strong",{children:"链接"}),e.jsx("br",{}),e.jsxs("code",{style:{fontSize:11},children:[window.location.origin,y.url]})]}),e.jsx(ie,{variant:"secondary",size:"sm",onClick:()=>_(y),children:"复制链接"}),i&&e.jsx("div",{style:{fontSize:12,color:"#2f7a2f"},children:i})]})]})})]})}const Pr={async listWorktrees(){return ne.get("/repos/worktrees")},async removeWorktree(t){return ne.delete("/repos/worktrees",{path:t})},async getGroupWorktree(t){try{return await ne.get(`/groups/${t}/worktree`)}catch{return null}}},ZS="_page_1gli4_1",YS="_header_1gli4_7",QS="_title_1gli4_14",eC="_subtitle_1gli4_21",tC="_stats_1gli4_28",sC="_statCard_1gli4_35",rC="_statValue_1gli4_42",iC="_statLabel_1gli4_50",nC="_repoCard_1gli4_56",oC="_repoHeader_1gli4_64",aC="_repoIcon_1gli4_74",lC="_repoName_1gli4_76",cC="_repoIdShort_1gli4_83",dC="_repoMeta_1gli4_92",hC="_repoMetaItem_1gli4_100",uC="_wtList_1gli4_106",_C="_wtRow_1gli4_110",fC="_wtRowOrphan_1gli4_121",pC="_wtType_1gli4_124",mC="_wtBranch_1gli4_129",gC="_wtPath_1gli4_139",vC="_wtHead_1gli4_149",yC="_wtGroupBtn_1gli4_156",xC="_wtRemoveBtn_1gli4_169",bC="_wtNoGroup_1gli4_183",SC="_wtEmpty_1gli4_189",CC="_empty_1gli4_196",wC="_emptyIcon_1gli4_202",jC="_emptyText_1gli4_204",kC="_emptyHint_1gli4_206",EC="_error_1gli4_208",Se={page:ZS,header:YS,title:QS,subtitle:eC,stats:tC,statCard:sC,statValue:rC,statLabel:iC,repoCard:nC,repoHeader:oC,repoIcon:aC,repoName:lC,repoIdShort:cC,repoMeta:dC,repoMetaItem:hC,wtList:uC,wtRow:_C,wtRowOrphan:fC,wtType:pC,wtBranch:mC,wtPath:gC,wtHead:vC,wtGroupBtn:yC,wtRemoveBtn:xC,wtNoGroup:bC,wtEmpty:SC,empty:CC,emptyIcon:wC,emptyText:jC,emptyHint:kC,error:EC};function Or(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}K`:t<1024*1024*1024?`${(t/1024/1024).toFixed(1)}M`:`${(t/1024/1024/1024).toFixed(2)}G`}function NC(t){const o=t.split("/"),m=o.findIndex(S=>S.endsWith("-wt"));return m<0||m+1>=o.length?null:o[m+1]}function RC(t){return t&&t.startsWith("group-")?t.slice(6):null}function LC(){const t=Ut(),[o,m]=g.useState([]),[S,j]=g.useState(!0),[E,b]=g.useState(null),[n,a]=g.useState({}),d=async()=>{j(!0),b(null);try{const[y,u]=await Promise.all([Pr.listWorktrees(),Re.list()]);m(y);const i={};for(const r of u)i[r.id.slice(0,8)]={id:r.id,name:r.name};a(i)}catch(y){b(y.message)}finally{j(!1)}};g.useEffect(()=>{d()},[]);const[h,c]=g.useState(null),f=async y=>{if(window.confirm(`确认删除 worktree?
179
+ ${y}
180
+
181
+ bare clone 保留,只删这个工作树。`)){c(y);try{await Pr.removeWorktree(y),await d()}catch(u){window.alert(`删除失败: ${u instanceof Error?u.message:String(u)}`)}finally{c(null)}}},v=g.useMemo(()=>{const y=o.length,u=o.reduce((r,s)=>r+s.worktrees.length,0),i=o.reduce((r,s)=>r+s.sizeBytes,0);return{repoCount:y,wtCount:u,totalBytes:i}},[o]);return S?e.jsx("div",{className:Se.page,children:"加载中..."}):E?e.jsxs("div",{className:Se.page,children:[e.jsx("div",{className:Se.error,children:E}),e.jsx(ie,{variant:"secondary",size:"sm",onClick:d,children:"重试"})]}):o.length===0?e.jsx("div",{className:Se.page,children:e.jsxs("div",{className:Se.empty,children:[e.jsx("div",{className:Se.emptyIcon,children:"📦"}),e.jsx("p",{className:Se.emptyText,children:"本机还没有任何 repo 缓存"}),e.jsx("p",{className:Se.emptyHint,children:"给 group 配置 repo_url 后,首次执行 issue/chat 会自动克隆"})]})}):e.jsxs("div",{className:Se.page,children:[e.jsxs("div",{className:Se.header,children:[e.jsx("h2",{className:Se.title,children:"🌿 Worktrees"}),e.jsx(ie,{variant:"ghost",size:"sm",onClick:d,children:"刷新"})]}),e.jsxs("p",{className:Se.subtitle,children:["本机所有 repo 的 bare clone + worktree。bare clone(",e.jsx("code",{children:".git"})," 对象库)全局共享;worktree 各自一份 checkout,改的是各自工作树。"]}),e.jsxs("div",{className:Se.stats,children:[e.jsxs("div",{className:Se.statCard,children:[e.jsx("div",{className:Se.statValue,children:v.repoCount}),e.jsx("div",{className:Se.statLabel,children:"📦 repos(bare clone)"})]}),e.jsxs("div",{className:Se.statCard,children:[e.jsx("div",{className:Se.statValue,children:v.wtCount}),e.jsx("div",{className:Se.statLabel,children:"🌿 worktrees"})]}),e.jsxs("div",{className:Se.statCard,children:[e.jsx("div",{className:Se.statValue,children:Or(v.totalBytes)}),e.jsx("div",{className:Se.statLabel,children:"💾 总磁盘(bare clone)"})]})]}),o.map(y=>{const u=y.repoKey.split("-").pop()||"";return e.jsxs("div",{className:Se.repoCard,children:[e.jsxs("div",{className:Se.repoHeader,children:[e.jsx("span",{className:Se.repoIcon,children:"📦"}),e.jsx("span",{className:Se.repoName,children:y.repoName}),e.jsx("span",{className:Se.repoIdShort,children:u}),e.jsxs("span",{className:Se.repoMeta,children:[e.jsxs("span",{className:Se.repoMetaItem,children:["💾 ",Or(y.sizeBytes)]}),e.jsxs("span",{className:Se.repoMetaItem,children:["🌿 ",y.worktrees.length]})]})]}),y.worktrees.length===0?e.jsx("div",{className:Se.wtEmpty,children:"暂无 worktree(首次执行 issue/chat 时创建)"}):e.jsx("div",{className:Se.wtList,children:y.worktrees.map(i=>{const r=NC(i.path),s=RC(r),l=s?n[s]:null,_=r!=null&&!r.startsWith("group-"),x=!_&&s!=null&&!l;return e.jsxs("div",{className:`${Se.wtRow} ${x?Se.wtRowOrphan:""}`,title:i.path,children:[e.jsx("span",{className:Se.wtType,children:_?"🔧":"🌿"}),e.jsx("span",{className:Se.wtBranch,children:i.branch||"detached"}),e.jsx("span",{className:Se.wtPath,children:i.path}),e.jsx("span",{className:Se.wtHead,children:i.head}),l?e.jsxs("button",{type:"button",className:Se.wtGroupBtn,onClick:()=>t(`/dashboard/groups/${l.id}`),title:`跳转到群「${l.name}」`,children:["→ ",l.name]}):x?e.jsx("button",{type:"button",className:Se.wtRemoveBtn,onClick:()=>f(i.path),disabled:h===i.path,title:"群已删除,清理孤儿 worktree",children:h===i.path?"删除中...":"🗑 群已删 · 清理"}):e.jsx("span",{className:Se.wtNoGroup,children:"(无群关联)"})]},i.path)})})]},y.repoKey)})]})}function TC({open:t,onConfigured:o,onClose:m}){const[S,j]=g.useState([]),[E,b]=g.useState(!1),[n,a]=g.useState("");return g.useEffect(()=>{t&&(b(!0),a(""),fetch("/api/agents").then(d=>d.json()).then(d=>j(d)).catch(()=>a("加载员工列表失败")).finally(()=>b(!1)))},[t]),e.jsxs(De,{open:t,title:"选择我的身份",footer:e.jsx("div",{className:Q.modalActions,children:e.jsx(ie,{variant:"secondary",size:"md",onClick:m,children:"取消"})}),children:[e.jsx("p",{style:{color:"var(--color-slate)",fontSize:14,marginBottom:16},children:"Dashboard 这边的你是「真人」。挑一个员工作为你的操作身份 —— 本机/局域网免 token,直接绑定。"}),E&&e.jsx("div",{style:{fontSize:13,color:"var(--color-slate)"},children:"加载中…"}),n&&e.jsx("div",{style:{fontSize:13,color:"var(--color-danger, #dc2626)"},children:n}),!E&&!n&&S.length===0&&e.jsx("div",{style:{fontSize:13,color:"var(--color-slate)"},children:"暂无员工。先在「员工管理」页添加一个。"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,maxHeight:360,overflowY:"auto"},children:S.map(d=>{var h;return e.jsxs("button",{onClick:()=>{localStorage.setItem("chat_agent_name",d.name),o(d.name)},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",background:"var(--color-surface)",border:"1px solid var(--color-border)",borderRadius:6,cursor:"pointer",textAlign:"left"},children:[e.jsx(At,{name:d.name,src:d.avatar_url??void 0,size:28}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:d.name}),e.jsx("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:((h=d.profile)==null?void 0:h.position)||d.description||d.status})]}),e.jsx("span",{style:{fontSize:11,padding:"1px 6px",borderRadius:3,background:d.status==="online"?"var(--color-success-bg, #f0fdf4)":"var(--color-tag-bg)",color:d.status==="online"?"var(--color-success, #16a34a)":"var(--color-text-tertiary)"},children:d.status==="online"?"在线":"离线"})]},d.id)})})]})}function IC({open:t,agents:o,myAgentName:m,onClose:S,onCreate:j}){const[E,b]=g.useState(""),[n,a]=g.useState(""),[d,h]=g.useState(""),[c,f]=g.useState("group"),[v,y]=g.useState([]),[u,i]=g.useState(!1),[r,s]=g.useState(!1),[l,_]=g.useState(null),[x,C]=g.useState(null),[k,p]=g.useState(null),[w,R]=g.useState(""),[T,M]=g.useState(""),[N,I]=g.useState([{id:"",url:"",branch:""}]),[z,G]=g.useState("group"),H=()=>{b(""),a(""),h(""),f("group"),y([]),_(null),C(null),p(null),R(""),M(""),I([{id:"",url:"",branch:""}]),G("group"),S()},V=(q,J,O)=>{I(X=>X.map((F,W)=>W===q?{...F,[J]:O}:F))},L=()=>I(q=>[...q,{id:"",url:"",branch:""}]),A=q=>I(J=>J.filter((O,X)=>X!==q)),B=async()=>{if(!E.trim()||u)return;if(U&&v.length!==1){window.alert("巡检群必须且只能选 1 个 agent 作为巡检员");return}if(Z&&v.length!==1){window.alert("单聊必须且只能选 1 个 agent");return}let q=null;const J=N.filter(X=>X.id.trim()&&X.url.trim());J.length>0&&(q=J.map(X=>({id:X.id.trim(),url:X.url.trim(),branch:X.branch.trim()||void 0,mountPath:`__repos/${X.id.trim()}`})));const O=w.trim()||q?{repoUrl:w.trim()||null,repoDefaultBranch:T.trim()||null,extraRepos:q,worktreeMode:z}:void 0;i(!0);try{const X=Z?"direct":d||void 0;await j(E.trim(),v,n.trim()||void 0,X,l??void 0,x??void 0,O),b(""),a(""),h(""),f("group"),y([]),_(null),C(null),p(null),R(""),M(""),I([{id:"",url:"",branch:""}]),G("group")}catch{}finally{i(!1)}},P=o.filter(q=>q.name!==m),U=c==="group"&&d==="patrol",Z=c==="direct",oe=Z||U?1:1/0,K=q=>{y(J=>J.includes(q)?J.filter(O=>O!==q):[...J,q])},$=q=>{q!==c&&(y([]),(q==="direct"||E.startsWith("我和 "))&&b(""),f(q))},D=async q=>{if(Z){if(u)return;i(!0);try{await j(q,[q],void 0,"direct",void 0,void 0,void 0),H()}catch{}finally{i(!1)}return}K(q)};return e.jsxs(De,{open:t,title:Z?"发起单聊":"创建对话",footer:e.jsxs("div",{className:Q.modalActions,children:[e.jsx(ie,{variant:"secondary",size:"md",onClick:H,disabled:u,children:"取消"}),!Z&&e.jsx(ie,{variant:"primary",size:"md",onClick:B,disabled:!E.trim()||u,children:u?"创建中...":"创建"})]}),children:[e.jsxs("div",{className:Q.formField,children:[e.jsx("label",{className:Q.formLabel,children:"聊天类型:"}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{type:"button",onClick:()=>$("group"),style:{flex:1,padding:"8px 12px",fontSize:13,cursor:"pointer",borderRadius:6,border:`1px solid ${c==="group"?"var(--color-wise-green, #9fe870)":"var(--border-color-light, #ddd)"}`,background:c==="group"?"rgba(159, 232, 112, 0.18)":"transparent",fontWeight:c==="group"?700:500,color:c==="group"?"var(--color-dark-green, #1f4d1a)":"inherit"},children:"💬 群聊(多人)"}),e.jsx("button",{type:"button",onClick:()=>$("direct"),style:{flex:1,padding:"8px 12px",fontSize:13,cursor:"pointer",borderRadius:6,border:`1px solid ${c==="direct"?"var(--color-wise-green, #9fe870)":"var(--border-color-light, #ddd)"}`,background:c==="direct"?"rgba(159, 232, 112, 0.18)":"transparent",fontWeight:c==="direct"?700:500,color:c==="direct"?"var(--color-dark-green, #1f4d1a)":"inherit"},children:"👤 单聊(1 对 1)"})]}),Z&&e.jsx("p",{style:{fontSize:11,color:"var(--color-info)",margin:"6px 2px 0"},children:"点击下方任意 agent 立即发起 1 对 1 对话,在对话列表里会带 👤 标志。"})]}),!Z&&e.jsxs("div",{className:Q.formField,children:[e.jsx("label",{className:Q.formLabel,children:"群名称:"}),e.jsx(ge,{type:"text",value:E,onChange:q=>b(q.target.value),placeholder:"输入群名称"})]}),!Z&&e.jsxs("div",{className:Q.formField,children:[e.jsx("label",{className:Q.formLabel,children:"群类型:"}),e.jsx(Fe,{value:d,onChange:q=>{const J=q.target.value;h(J),J==="patrol"&&!E.trim()&&b("全局issue巡检群")},options:[{value:"",label:"普通群"},{value:"patrol",label:"巡检群"}]}),U&&e.jsx("p",{style:{fontSize:11,color:"var(--color-info)",margin:"6px 2px 0"},children:"巡检群全局限 1 个(归档/删除后才能再建),只选 1 个 agent 作为巡检员。 建群后自动创建每小时巡检任务,可在工具箱「Issue 巡检」开关。"})]}),e.jsxs("div",{className:Q.formField,children:[e.jsxs("label",{className:Q.formLabel,children:[Z?"选择对方(点击立即发起):":"选择成员:",(Z||U)&&!Z&&e.jsxs("span",{style:{fontWeight:400,fontSize:11,marginLeft:8,color:"var(--color-info)"},children:["限选 ",oe," 人"]})]}),e.jsxs("div",{className:Q.agentCheckList,children:[P.map(q=>{const J=v.includes(q.name),O=(Z||U)&&!J&&v.length>=oe;return e.jsxs("div",{className:Q.agentCheckItem,style:O?{opacity:.4,cursor:"not-allowed"}:{cursor:"pointer"},onClick:()=>{O||D(q.name)},children:[e.jsx(Dt,{checked:J,disabled:O,onChange:()=>D(q.name),onClick:X=>X.stopPropagation()}),q.name,e.jsx("span",{className:`${Q.agentCheckStatus} ${q.status==="online"?Q.online:Q.offline}`,children:q.status==="online"?"在线":"离线"})]},q.id)}),P.length===0&&e.jsx("div",{style:{padding:16,color:"var(--color-slate)",textAlign:"center",fontSize:13},children:"暂无其他 Agent"})]}),Z&&u&&e.jsx("p",{style:{fontSize:11,color:"var(--color-info)",margin:"6px 2px 0"},children:"创建中..."})]}),!Z&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:Q.formField,children:[e.jsx("label",{className:Q.formLabel,children:"工作目录(可选):"}),e.jsx(ge,{type:"text",value:n,onChange:q=>a(q.target.value),placeholder:"例如: /Users/me/code/my-repo 或 ~/code/my-repo"}),e.jsx("p",{style:{fontSize:11,color:"var(--color-slate)",margin:"6px 2px 0"},children:"支持 ~/ 自动展开。必须是已存在的目录;不填则默认使用 ~/.rotom/artifacts/<群id>(自动创建)。"})]}),e.jsxs("div",{className:Q.formField,children:[e.jsx("label",{className:Q.formLabel,children:"内置 repo(可选):"}),e.jsx(ge,{type:"text",value:w,onChange:q=>R(q.target.value),placeholder:"主仓库 URL,如 git@github.com:org/repo.git;留空则不启用 worktree"}),e.jsx(ge,{type:"text",value:T,onChange:q=>M(q.target.value),placeholder:"默认分支(如 main);留空用仓库默认",style:{marginTop:6}}),e.jsx(Fe,{value:z,onChange:q=>G(q.target.value),style:{marginTop:6},options:[{value:"group",label:"worktree 策略:group(群共享一个 worktree,轻量)"},{value:"issue",label:"worktree 策略:issue(每 issue 独立 worktree,多分支并行)"}]}),e.jsxs("div",{style:{marginTop:8},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-slate)"},children:"额外仓库(可选)"}),e.jsx("button",{type:"button",onClick:L,style:{border:"1px solid var(--border-color-light, #ddd)",background:"transparent",color:"var(--color-navy, #1a365d)",borderRadius:4,padding:"2px 10px",fontSize:11,cursor:"pointer"},children:"+ 添加"})]}),N.map((q,J)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"110px 1fr 110px 28px",gap:6,marginBottom:6},children:[e.jsx(ge,{type:"text",size:"sm",value:q.id,onChange:O=>V(J,"id",O.target.value),placeholder:"id(如 deposit-home)",style:{fontSize:11}}),e.jsx(ge,{type:"text",size:"sm",value:q.url,onChange:O=>V(J,"url",O.target.value),placeholder:"URL",style:{fontSize:11}}),e.jsx(ge,{type:"text",size:"sm",value:q.branch,onChange:O=>V(J,"branch",O.target.value),placeholder:"分支(可空)",style:{fontSize:11}}),e.jsx("button",{type:"button",onClick:()=>A(J),style:{border:"1px solid var(--border-color-light, #ddd)",background:"transparent",borderRadius:4,cursor:"pointer",fontSize:12,color:"#c00"},title:"删除",children:"✕"})]},J)),e.jsxs("p",{style:{fontSize:11,color:"var(--color-slate)",margin:"4px 2px 0"},children:["mountPath 自动 = ",e.jsx("code",{children:"repos/<id>"}),";agent 在 primary worktree 里通过该路径访问额外仓库。"]})]}),e.jsxs("p",{style:{fontSize:11,color:"var(--color-slate)",margin:"6px 2px 0"},children:["配 repo 后,群内 issue/chat 在 worktree 里跑(agent cwd = ",e.jsx("code",{children:"~/.rotom/repos/<repoName>-<id8>-wt/group-<groupId8>/"}),")。bare clone 全局共享,只克隆一次。"]})]}),e.jsxs("div",{className:Q.formField,children:[e.jsx("label",{className:Q.formLabel,children:"群指导模板(可选):"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("button",{type:"button",onClick:()=>s(!0),style:{border:"1px solid rgba(0,0,0,0.12)",background:"transparent",color:"var(--color-navy)",borderRadius:6,padding:"4px 12px",fontSize:12,cursor:"pointer"},children:"📚 从模板选择"}),k&&e.jsxs("span",{style:{fontSize:12,color:"var(--color-slate)"},children:["已选: ",e.jsx("strong",{style:{color:"var(--color-navy)"},children:k}),x&&e.jsx("span",{style:{marginLeft:6,color:"rgb(99,102,241)"},children:"·带定时任务"})]})]}),l&&e.jsx("div",{style:{marginTop:6,padding:8,fontSize:11,color:"var(--color-slate)",background:"rgba(0,0,0,0.03)",borderRadius:6,whiteSpace:"pre-wrap",maxHeight:80,overflow:"auto"},children:l}),e.jsx("p",{style:{fontSize:11,color:"var(--color-slate)",margin:"6px 2px 0"},children:"建群时一并应用群指导 prompt;若模板含定时任务,建群后自动创建。"})]}),r&&e.jsx(Ws,{open:r,mode:"select",memberAgentNames:v,onResolved:(q,J,O)=>{_(q),C(J),p(O),s(!1)},onClose:()=>s(!1)})]})]})}const AC={success:5e3,info:7e3,warning:8e3,error:0},DC=3,Xs=g.createContext(null),BC=50,MC=600;function $C(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`n-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function bi(t){try{return JSON.parse(t.metadata||"{}")}catch{return{}}}function PC(t){if(t.event_type!=="approval_request")return!1;const o=bi(t);return!o.resolvedAt&&!o.resolvedBy}function OC({children:t}){const[o,m]=g.useState([]),S=g.useRef(new Map),j=g.useRef(new Set),E=g.useRef(new Map),b=g.useRef(new Map),n=g.useRef(new Map),a=g.useCallback(k=>{const p=S.current.get(k);p&&(clearTimeout(p),S.current.delete(k))},[]),d=g.useCallback(k=>{a(k),m(p=>p.filter(w=>w.id!==k))},[a]),h=g.useCallback((k,p,w)=>{const R=$C(),T={id:R,kind:k,title:p,description:w==null?void 0:w.description,duration:(w==null?void 0:w.duration)??AC[k],actions:w==null?void 0:w.actions,createdAt:Date.now()};if(m(M=>{const N=[...M,T];if(N.length>BC){const I=N.shift();I&&a(I.id)}return N}),T.duration&&T.duration>0){const M=setTimeout(()=>d(R),T.duration);S.current.set(R,M)}return R},[a,d]),c=g.useCallback(()=>{S.current.forEach(k=>clearTimeout(k)),S.current.clear(),m([])},[]),f=g.useMemo(()=>({success:(k,p)=>h("success",k,p),error:(k,p)=>h("error",k,p),warning:(k,p)=>h("warning",k,p),info:(k,p)=>h("info",k,p),dismiss:d,clear:c}),[h,d,c]);g.useEffect(()=>{const k=S.current,p=n.current,w=b.current;return()=>{k.forEach(R=>clearTimeout(R)),k.clear(),p.forEach(R=>clearTimeout(R)),p.clear(),w.clear()}},[]);const{subscribe:v}=wt(),y=Ut(),u=zr(),i=g.useRef(u.pathname);g.useEffect(()=>{i.current=u.pathname},[u.pathname]);const r=g.useRef(f);g.useEffect(()=>{r.current=f},[f]);function s(k){return i.current.includes(`/issues/${k}`)||i.current.includes("/issues-single/")}const l=g.useCallback(async k=>{let p;try{p=await Be.getById(k)}catch{return}const w=E.current.get(k),R=p.status;if(w&&w!==R){const M=`/dashboard/groups/${p.group_id}/issues/${k}`;R==="completed"?r.current.success(`Issue「${p.title}」已完成`,{actions:[{label:"查看详情",primary:!0,onClick:()=>y(M)}]}):R==="failed"&&r.current.error(`Issue「${p.title}」执行失败`,{description:p.error_message||void 0,actions:[{label:"查看详情",primary:!0,onClick:()=>y(M)}]})}if(E.current.set(k,R),!s(k))for(const M of p.events){if(!PC(M))continue;const N=bi(M),I=typeof N.approvalId=="string"?N.approvalId:"";if(!I||j.current.has(I))continue;j.current.add(I);const z=typeof N.summary=="string"&&N.summary?N.summary:"需要确认",G=typeof N.kind=="string"?N.kind:"",H=G==="exec"&&typeof N.command=="string"?N.command:G==="file_change"&&Array.isArray(N.files)?N.files.join(", "):void 0;r.current.warning(`需要审批:${z}`,{description:H,actions:[{label:"去审批",primary:!0,onClick:()=>y(`/dashboard/groups/${p.group_id}/issues/${k}`)}]})}},[y]),_=g.useCallback(k=>{if(b.current.has(k))return;const p=n.current.get(k);p&&clearTimeout(p);const w=setTimeout(()=>{n.current.delete(k);const R=l(k).finally(()=>{b.current.delete(k)});b.current.set(k,R)},MC);n.current.set(k,w)},[l]);g.useEffect(()=>v(k=>{var p,w;switch(k.type){case"a2a_stream_end":{const R=(()=>{try{return localStorage.getItem("group_selected_id")}catch{return null}})(),T=(p=k.conversation)==null?void 0:p.groupId;if(!T||T!==R)return;const M=((w=k.from)==null?void 0:w.name)||"Agent";r.current.info(`${M} 回复完成`,{actions:[{label:"查看",primary:!0,onClick:()=>y(`/dashboard/groups/${T}`)}]});break}case"issue_changed":{if(!k.issueId||k.kind==="deleted")return;_(k.issueId);break}}}),[v,y,_]);const x=o.slice(0,DC),C=g.useMemo(()=>({...f,visible:x}),[f,x]);return e.jsx(Xs.Provider,{value:C,children:t})}function HC(){const t=g.useContext(Xs);if(!t)throw new Error("useNotificationQueue must be used within NotificationProvider");return t.visible}function FC(){const t=g.useContext(Xs);if(!t)throw new Error("useNotificationDismiss must be used within NotificationProvider");return t.dismiss}const zC="_card_1tgtk_4",WC="_slideIn_1tgtk_1",UC="_leaving_1tgtk_36",qC="_success_1tgtk_42",VC="_error_1tgtk_43",GC="_warning_1tgtk_44",KC="_info_1tgtk_45",JC="_sprite_1tgtk_49",XC="_float_1tgtk_1",ZC="_body_1tgtk_65",YC="_title_1tgtk_75",QC="_description_1tgtk_84",ew="_closeBtn_1tgtk_92",tw="_actions_1tgtk_121",sw="_action_1tgtk_121",rw="_primary_1tgtk_151",ct={card:zC,slideIn:WC,leaving:UC,success:qC,error:VC,warning:GC,info:KC,sprite:JC,float:XC,body:ZC,title:YC,description:QC,closeBtn:ew,actions:tw,action:sw,primary:rw},ds="/dashboard/animations/",iw={success:`${ds}calico-happy.apng`,error:`${ds}calico-error.apng`,warning:`${ds}calico-notification.apng`,info:`${ds}calico-thinking.apng`},nw={success:"开心的猫",error:"出错的猫",warning:"警觉的猫",info:"思考的猫"},ow={success:"成功",error:"错误",warning:"警告",info:"信息"};function aw({notification:t,onDismiss:o}){const[m,S]=g.useState(!1),{id:j,kind:E,title:b,description:n,actions:a}=t,d=g.useCallback(()=>{S(!0),setTimeout(()=>o(j),200)},[j,o]),h=c=>{try{c.onClick()}finally{d()}};return e.jsxs("div",{className:`${ct.card} ${ct[E]} ${m?ct.leaving:""}`,role:"status","aria-live":"polite","aria-label":`${ow[E]}:${b}`,children:[e.jsx("button",{type:"button",className:ct.closeBtn,onClick:d,"aria-label":"关闭通知",children:"×"}),e.jsx("img",{className:ct.sprite,src:iw[E],alt:nw[E],"aria-hidden":!0}),e.jsxs("div",{className:ct.body,children:[e.jsx("div",{className:ct.title,children:b}),n&&e.jsx("div",{className:ct.description,children:n})]}),a&&a.length>0&&e.jsx("div",{className:ct.actions,children:a.map((c,f)=>e.jsx("button",{type:"button",className:`${ct.action} ${c.primary?ct.primary:""}`,onClick:()=>h(c),children:c.label},f))})]})}const lw="_host_1xay0_4",cw={host:lw};function dw(){const t=HC(),o=FC();return t.length===0?null:e.jsx("div",{className:cw.host,"aria-label":"通知区域",children:t.map(m=>e.jsx(aw,{notification:m,onDismiss:o},m.id))})}function hw(){const{showConfigModal:t,setMyAgentConfig:o,closeConfigModal:m,showCreateGroupModal:S,closeCreateGroupModal:j,createGroup:E,agents:b,myAgentName:n}=nt();return e.jsxs(e.Fragment,{children:[e.jsx(TC,{open:t,onConfigured:o,onClose:m}),e.jsx(IC,{open:S,agents:b,myAgentName:n,onClose:j,onCreate:E})]})}function Lt({children:t}){const{myAgentName:o}=nt(),{isVisitor:m}=qt();return m?e.jsx(e.Fragment,{children:t}):o?e.jsx(e.Fragment,{children:t}):e.jsx(Ft,{to:"/dashboard/agents",replace:!0})}function uw(){return e.jsx(zo,{children:e.jsx(Uo,{children:e.jsx(Mi,{children:e.jsx(ko,{children:e.jsxs(OC,{children:[e.jsxs(Fo,{children:[e.jsx(Oc,{children:e.jsxs(Li,{children:[e.jsx(Oe,{path:"/dashboard/agents",element:e.jsx("div",{className:"container-full",children:e.jsx(Vh,{})})}),e.jsx(Oe,{path:"/dashboard/teams",element:e.jsx("div",{className:"container-full",children:e.jsx(Kh,{})})}),e.jsx(Oe,{path:"/dashboard/kanban",element:e.jsx(Lt,{children:e.jsx("div",{className:"container-full",children:e.jsx(s1,{})})})}),e.jsx(Oe,{path:"/dashboard/groups",element:e.jsx(Lt,{children:e.jsx("div",{className:"container-full",children:e.jsx(Ls,{})})})}),e.jsx(Oe,{path:"/dashboard/groups/:groupId",element:e.jsx(Lt,{children:e.jsx("div",{className:"container-full",children:e.jsx(Ls,{})})})}),e.jsx(Oe,{path:"/dashboard/groups/:groupId/issues/:issueId",element:e.jsx(Lt,{children:e.jsx("div",{className:"container-full",children:e.jsx(Ls,{})})})}),e.jsx(Oe,{path:"/dashboard/groups/:groupId/issues-single",element:e.jsx(Lt,{children:e.jsx("div",{className:"container-full",style:{display:"flex",flexDirection:"column"},children:e.jsx(g0,{})})})}),e.jsx(Oe,{path:"/dashboard/groups/:groupId/issues-single/:issueId",element:e.jsx(Lt,{children:e.jsx("div",{className:"container-full",style:{display:"flex",flexDirection:"column"},children:e.jsx(f0,{})})})}),e.jsxs(Oe,{path:"/dashboard/toolbox",element:e.jsx(Lt,{children:e.jsx("div",{className:"container-full",children:e.jsx(U1,{})})}),children:[e.jsx(Oe,{index:!0,element:e.jsx(Ft,{to:"messages",replace:!0})}),e.jsx(Oe,{path:"terminal",element:e.jsx(E1,{})}),e.jsx(Oe,{path:"messages",element:e.jsx(r1,{})}),e.jsx(Oe,{path:"prompts",element:e.jsx(AS,{})}),e.jsx(Oe,{path:"schedule-patterns",element:e.jsx(BS,{})}),e.jsx(Oe,{path:"memory",element:e.jsx(OS,{})}),e.jsx(Oe,{path:"skills",element:e.jsx(WS,{})}),e.jsx(Oe,{path:"issue-patrol",element:e.jsx(GS,{})}),e.jsx(Oe,{path:"link-patrol",element:e.jsx(JS,{})}),e.jsx(Oe,{path:"gallery",element:e.jsx(XS,{})}),e.jsx(Oe,{path:"worktrees",element:e.jsx(LC,{})})]}),e.jsx(Oe,{path:"/dashboard/messages",element:e.jsx(Ft,{to:"/dashboard/toolbox/messages",replace:!0})}),e.jsx(Oe,{path:"/dashboard/terminal",element:e.jsx(Ft,{to:"/dashboard/toolbox/terminal",replace:!0})}),e.jsx(Oe,{path:"/dashboard",element:e.jsx(Ft,{to:"/dashboard/agents",replace:!0})}),e.jsx(Oe,{path:"*",element:e.jsx(Ft,{to:"/dashboard/agents",replace:!0})})]})}),e.jsx(hw,{})]}),e.jsx(dw,{})]})})})})})}Ti.createRoot(document.getElementById("root")).render(e.jsx(g.StrictMode,{children:e.jsx(Ii,{children:e.jsx(uw,{})})}));export{ie as B,Dt as C,ge as I,dt as M,Fe as S,xt as T,u1 as X,ne as a,gw as g,Be as i};