@markus-global/cli 0.12.3-rc.3 → 0.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/markus.mjs +31 -8
  2. package/dist/web-ui/assets/{AsyncState-D2omBzdj.js → AsyncState-BTLUPIr1.js} +1 -1
  3. package/dist/web-ui/assets/{ChatComponents-lSVBiM5B.js → ChatComponents-DTB3H_n2.js} +1 -1
  4. package/dist/web-ui/assets/{ContentRenderer-DxgRNOd1.js → ContentRenderer-BZXRiKE3.js} +2 -2
  5. package/dist/web-ui/assets/{DeliverableShareModal-DU0PupsS.js → DeliverableShareModal-BwZP39nd.js} +1 -1
  6. package/dist/web-ui/assets/{Deliverables-BYacAH8w.js → Deliverables-3Y3zjT_1.js} +1 -1
  7. package/dist/web-ui/assets/{MarkdownMessage-DwxvYN4X.js → MarkdownMessage-DVfFMzM9.js} +1 -1
  8. package/dist/web-ui/assets/{Search-jBc36ZOH.js → Search-BI3hk-5j.js} +1 -1
  9. package/dist/web-ui/assets/{SendToChat-13m2h7gu.js → SendToChat-D_5zHO-k.js} +1 -1
  10. package/dist/web-ui/assets/{Settings-BkKMrBt2.js → Settings-DTUjLhJY.js} +1 -1
  11. package/dist/web-ui/assets/{Store-dLubNc0P.js → Store-B8ksRjHF.js} +1 -1
  12. package/dist/web-ui/assets/{Switch-CXRQn2gn.js → Switch-RmZHA47D.js} +1 -1
  13. package/dist/web-ui/assets/{Team-zVv87kaX.js → Team-BRgI1zM9.js} +4 -4
  14. package/dist/web-ui/assets/{Work-DbPgRas-.js → Work-nah0UYFz.js} +1 -1
  15. package/dist/web-ui/assets/{arc-C6rhmRdi.js → arc-VmvI7TpW.js} +1 -1
  16. package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-BvaRSMDl.js → architectureDiagram-3BPJPVTR-CTUtPasm.js} +1 -1
  17. package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-DP7IwNLE.js → blockDiagram-GPEHLZMM-xeYAqtZJ.js} +1 -1
  18. package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-CEQJBqku.js → c4Diagram-AAUBKEIU-BiFgoGY5.js} +1 -1
  19. package/dist/web-ui/assets/channel-s7K3KXLr.js +1 -0
  20. package/dist/web-ui/assets/{chunk-2J33WTMH-BtGwhrHv.js → chunk-2J33WTMH-DueHBqOn.js} +1 -1
  21. package/dist/web-ui/assets/{chunk-4BX2VUAB-DNKfs4jy.js → chunk-4BX2VUAB-B8zgDfSV.js} +1 -1
  22. package/dist/web-ui/assets/{chunk-55IACEB6-Bd4eMlUg.js → chunk-55IACEB6-DieD55CP.js} +1 -1
  23. package/dist/web-ui/assets/{chunk-727SXJPM-CHmRT5rY.js → chunk-727SXJPM-Do4Z9LQ0.js} +1 -1
  24. package/dist/web-ui/assets/{chunk-AQP2D5EJ-CmoWgw5d.js → chunk-AQP2D5EJ-qrYsW5ml.js} +1 -1
  25. package/dist/web-ui/assets/{chunk-FMBD7UC4-Csafnaj6.js → chunk-FMBD7UC4-BSz3QT1q.js} +1 -1
  26. package/dist/web-ui/assets/{chunk-ND2GUHAM-Cip_3Llj.js → chunk-ND2GUHAM-utDWSydt.js} +1 -1
  27. package/dist/web-ui/assets/{chunk-QZHKN3VN-C0WlO578.js → chunk-QZHKN3VN-Cd86CYHV.js} +1 -1
  28. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-B2mHhFY8.js +1 -0
  29. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-B2mHhFY8.js +1 -0
  30. package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-ByhHiryW.js → cose-bilkent-S5V4N54A-Dc6cP9WW.js} +1 -1
  31. package/dist/web-ui/assets/{dagre-BM42HDAG-B5-K3iqP.js → dagre-BM42HDAG-4b0Wf_6D.js} +1 -1
  32. package/dist/web-ui/assets/{diagram-2AECGRRQ-Ci16wMOI.js → diagram-2AECGRRQ-zS_j1Kf4.js} +1 -1
  33. package/dist/web-ui/assets/{diagram-5GNKFQAL-Dfnzu_xA.js → diagram-5GNKFQAL-CPo-_Ime.js} +1 -1
  34. package/dist/web-ui/assets/{diagram-KO2AKTUF-K9NvC1S4.js → diagram-KO2AKTUF-CjHOA4_j.js} +1 -1
  35. package/dist/web-ui/assets/{diagram-LMA3HP47-CaKq8BY-.js → diagram-LMA3HP47-CalZRF6K.js} +1 -1
  36. package/dist/web-ui/assets/{diagram-OG6HWLK6-DqY8Y9OR.js → diagram-OG6HWLK6-DnLAhsLX.js} +1 -1
  37. package/dist/web-ui/assets/{docx-preview-DS9aOywt.js → docx-preview-uRVPnxwM.js} +1 -1
  38. package/dist/web-ui/assets/{erDiagram-TEJ5UH35-iW17lrM1.js → erDiagram-TEJ5UH35-L0nzlMSn.js} +1 -1
  39. package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-BBkXZBPV.js → flowDiagram-I6XJVG4X-Bdc3UwtW.js} +1 -1
  40. package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-J2QuVqg4.js → ganttDiagram-6RSMTGT7-CFRmj_qc.js} +1 -1
  41. package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-EhZa3sGY.js → gitGraphDiagram-PVQCEYII-B5hZwcoJ.js} +1 -1
  42. package/dist/web-ui/assets/{index-BHu6brRf.js → index-TPf50ZeO.js} +6 -6
  43. package/dist/web-ui/assets/{infoDiagram-5YYISTIA-BaiNGDG7.js → infoDiagram-5YYISTIA-DVT4RgPd.js} +1 -1
  44. package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-BYN0gLmP.js → ishikawaDiagram-YF4QCWOH-Bf7pvUY_.js} +1 -1
  45. package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-CKUGXjL8.js → journeyDiagram-JHISSGLW-NVRjJlnd.js} +1 -1
  46. package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-iKb5H8rf.js → kanban-definition-UN3LZRKU-Co7BKMut.js} +1 -1
  47. package/dist/web-ui/assets/{mermaid.core-BSghRCEC.js → mermaid.core-CCf28Hq6.js} +5 -5
  48. package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-JjtDu_0Z.js → mindmap-definition-RKZ34NQL-DepMhVEb.js} +1 -1
  49. package/dist/web-ui/assets/{pieDiagram-4H26LBE5-BDXCI_g9.js → pieDiagram-4H26LBE5-Cq9ANaI0.js} +1 -1
  50. package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-bATU3F6v.js → quadrantDiagram-W4KKPZXB-CUY0BWhQ.js} +1 -1
  51. package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-BNJWpDxg.js → requirementDiagram-4Y6WPE33-D9fU5rCm.js} +1 -1
  52. package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-C3B8NPUe.js → sankeyDiagram-5OEKKPKP-CMHhuSQF.js} +1 -1
  53. package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-DhGwy4UV.js → sequenceDiagram-3UESZ5HK-Bjx53SID.js} +1 -1
  54. package/dist/web-ui/assets/{stateDiagram-AJRCARHV-BtfcmNhI.js → stateDiagram-AJRCARHV-DVvatKnO.js} +1 -1
  55. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-92MmE2MZ.js +1 -0
  56. package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-BpY3qMyG.js → timeline-definition-PNZ67QCA-9I80LG9m.js} +1 -1
  57. package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-S0f15t2D.js → vennDiagram-CIIHVFJN-B82Deutq.js} +1 -1
  58. package/dist/web-ui/assets/{wardley-L42UT6IY-BdcJNPNt.js → wardley-L42UT6IY-BKXtp57W.js} +1 -1
  59. package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-mR-gwtcd.js → wardleyDiagram-YWT4CUSO-DzqTzfYa.js} +1 -1
  60. package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-Dq0PtvdL.js → xychartDiagram-2RQKCTM6-TowyDWYu.js} +1 -1
  61. package/dist/web-ui/index.html +1 -1
  62. package/package.json +1 -1
  63. package/dist/web-ui/assets/channel-pUJ_pqAp.js +0 -1
  64. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-Cs9dF-hf.js +0 -1
  65. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-Cs9dF-hf.js +0 -1
  66. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-BOaSwLIS.js +0 -1
package/dist/markus.mjs CHANGED
@@ -12655,7 +12655,16 @@ var init_capability_packs = __esm({
12655
12655
  "memory_search",
12656
12656
  "memory_save",
12657
12657
  "notify_user",
12658
- "agent_send_message"
12658
+ "agent_send_message",
12659
+ // The prompt tells the agent to ask the human with `request_user_input` when
12660
+ // it disagrees about a frozen fact. The allow-list is authoritative, so
12661
+ // omitting it made that instruction impossible to follow (the agent would
12662
+ // fall back to prose — which is not visible in a comment thread).
12663
+ "request_user_input",
12664
+ // The prompt tells the model to call `end_turn` when no reply is warranted.
12665
+ // The allow-list is authoritative (agent.ts filters the tool schema by it),
12666
+ // so leaving it out made that instruction impossible to follow.
12667
+ "end_turn"
12659
12668
  ];
12660
12669
  REQUIREMENT_ACTION_ALLOWED_TOOLS = [
12661
12670
  "requirement_get",
@@ -12679,7 +12688,9 @@ var init_capability_packs = __esm({
12679
12688
  "memory_save",
12680
12689
  "notebook_upsert",
12681
12690
  "notify_user",
12682
- "agent_send_message"
12691
+ "agent_send_message",
12692
+ // Same as comment_response: "nothing needs to change" must be expressible.
12693
+ "end_turn"
12683
12694
  ];
12684
12695
  WORKFLOW_ACTION_ALLOWED_TOOLS = [
12685
12696
  "workflow_list",
@@ -12702,7 +12713,9 @@ var init_capability_packs = __esm({
12702
12713
  "memory_search",
12703
12714
  "memory_save",
12704
12715
  "notify_user",
12705
- "agent_send_message"
12716
+ "agent_send_message",
12717
+ // Same principle: a workflow that needs no action still has to be closed out.
12718
+ "end_turn"
12706
12719
  ];
12707
12720
  SCENARIO_ALLOWED_TOOLS = {
12708
12721
  comment_response: COMMENT_RESPONSE_ALLOWED_TOOLS,
@@ -14044,19 +14057,29 @@ ${ctx.mergedContent.slice(0, SYSTEM_MAILBOX_MERGED_CHARS)}`);
14044
14057
  lines.push("");
14045
14058
  lines.push("**Communication channel**: Your text output is **NOT visible** to any human or agent. You MUST use tools to take action and communicate. Simply writing text and ending your turn accomplishes nothing.");
14046
14059
  lines.push("");
14047
- lines.push("**Required actions** \u2014 you MUST do at least one of the following:");
14060
+ lines.push('**Step 0 \u2014 define the completion criterion**: before acting, state in one line the **checkable state** that means this requirement is done (e.g. "status is completed" / "N tasks exist, each with assignee + reviewer" / "a human was notified and is deciding").');
14061
+ lines.push("");
14062
+ lines.push('**Stop condition (same weight as the actions below)**: the moment that criterion holds, **stop** \u2014 call no further tools and end the turn. "It is already done" is expressed exactly this way.');
14063
+ lines.push("");
14064
+ lines.push('**Action budget**: within one turn, on this requirement \u2014 at most **2 status writes** and **2 comments**. When the budget is spent the point has been made: go to the stop condition. **Never post self-referential follow-ups** ("correcting my previous comment", "one last note", "going silent now") \u2014 if something needs correcting, correct the object itself (requirement description / plan document), not the thread.');
14065
+ lines.push("");
14066
+ lines.push('**Candidate actions** (not "you must do at least one", but "the minimum set needed to reach the criterion"):');
14048
14067
  lines.push("1. **Update requirement status**: `requirement_update_status` to mark the requirement as completed, or keep it active if more work is needed.");
14049
14068
  lines.push("2. **Create follow-up tasks**: `task_create` with the `requirement_id` if additional work is needed to fulfill the requirement.");
14050
14069
  lines.push("3. **Post a comment**: `requirement_comment` to leave notes or reasoning visible in the requirement thread.");
14051
14070
  lines.push("4. **Notify a human**: `notify_user` if the requirement outcome needs human attention or decision.");
14071
+ lines.push('5. **Nothing needs to change**: call `end_turn` \u2014 this is a recorded, legitimate disposition, and it is the right choice when the requirement is already in the right state. Do not post a "nothing to do" comment in place of it.');
14052
14072
  lines.push("");
14053
14073
  lines.push("**MANDATORY**: Before deciding, call `requirement_get` to understand the full current state of the requirement, including linked tasks, status, and comments.");
14054
14074
  lines.push("");
14055
- lines.push("**CRITICAL**: You MUST call at least one action tool before finishing. Do NOT just output text \u2014 it will be lost.");
14075
+ lines.push("**How this turn ends**: text is not delivered, so anything that must be communicated has to land on an object (status / tasks / comment). But once the criterion holds, **call no further tools** \u2014 ending here is the correct terminal state of the turn.");
14056
14076
  break;
14057
14077
  case "workflow_action":
14058
14078
  lines.push("You are processing a **workflow update that requires action** (e.g., a workflow run completed, failed, or a step failed).");
14059
14079
  lines.push("");
14080
+ lines.push('**Define the completion criterion and the stop condition first**: state the checkable "done" state up front; once it holds, **stop immediately** \u2014 do not keep calling tools to "do a bit more".');
14081
+ lines.push('**Action budget**: within one turn, at most 2 status writes and 2 comments on the same object; correct the object itself instead of posting "correcting my previous comment" follow-ups.');
14082
+ lines.push("");
14060
14083
  lines.push("**Communication channel**: Your text output is **NOT visible** to any human or agent. You MUST use tools to take action.");
14061
14084
  lines.push("");
14062
14085
  lines.push("**Typical actions**:");
@@ -60746,7 +60769,7 @@ ${report}`);
60746
60769
  if (tc.name === "task_comment" || tc.name === "requirement_comment") {
60747
60770
  commentToolUsed.add(tc.name);
60748
60771
  }
60749
- const REQ_ACTION_TOOLS = ["requirement_update_status", "requirement_comment", "task_create", "notify_user", "request_user_input", "request_user_approval"];
60772
+ const REQ_ACTION_TOOLS = ["requirement_update_status", "requirement_comment", "task_create", "notify_user", "request_user_input", "request_user_approval", "end_turn"];
60750
60773
  if (REQ_ACTION_TOOLS.includes(tc.name)) {
60751
60774
  requirementActionToolUsed.add(tc.name);
60752
60775
  }
@@ -60939,7 +60962,7 @@ ${turnContentOf(chatYield.item)}`;
60939
60962
  });
60940
60963
  this.memory.appendMessage(sessionId, {
60941
60964
  role: "user",
60942
- content: "[SYSTEM] You are about to end your turn WITHOUT taking any action. In requirement_action mode your text output is NOT visible to anyone. You MUST call at least one action tool: requirement_update_status, requirement_comment, task_create, or notify_user. Call requirement_get first if you need context, then take action."
60965
+ content: "[SYSTEM] You are about to end your turn WITHOUT taking any action. In requirement_action mode your text output is NOT visible to anyone. You MUST call at least one action tool: requirement_update_status, requirement_comment, task_create, or notify_user. Call requirement_get first if you need context, then take action. If you have determined that nothing needs to change, call `end_turn` instead \u2014 that ends the turn and records the decision."
60943
60966
  });
60944
60967
  const reminderMessages = this.requestHistory(sessionId);
60945
60968
  const preparedReminder = await this.contextEngine.prepareMessages({
@@ -379295,7 +379318,7 @@ var init_requirement_service = __esm({
379295
379318
  this.requirementRepo.updateStatus(id, newStatus, req.blockedReason ?? null).catch(persistErr);
379296
379319
  }
379297
379320
  }
379298
- if (req.createdBy && this.agentManager) {
379321
+ if (req.createdBy && this.agentManager && userId2 !== req.createdBy) {
379299
379322
  try {
379300
379323
  const agent = this.agentManager.getAgent(req.createdBy);
379301
379324
  if (agent) {
@@ -1 +1 @@
1
- import{u as c,j as e}from"./index-BHu6brRf.js";function a(...t){return t.filter(Boolean).join(" ")}function d({className:t}){return e.jsxs("svg",{className:a("animate-spin shrink-0",t??"w-3.5 h-3.5"),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2.5",opacity:"0.2"}),e.jsx("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})]})}function u({label:t,className:r}){const{t:n}=c("common");return e.jsxs("div",{className:a("flex-1 flex flex-col items-center justify-center gap-2.5 py-10 text-fg-tertiary",r),role:"status","aria-live":"polite",children:[e.jsx(d,{className:"w-5 h-5 text-brand-400"}),e.jsx("span",{className:"text-xs",children:t??n("loading")})]})}function p({rows:t=3,label:r,variant:n="skeleton",className:s}){const{t:i}=c("common");return n==="text"?e.jsxs("div",{className:a("flex items-center gap-2 px-1 py-2 text-xs text-fg-tertiary",s),role:"status","aria-live":"polite",children:[e.jsx(d,{className:"w-3 h-3"}),e.jsx("span",{children:r??i("loading")})]}):e.jsx("div",{className:a("space-y-2.5 p-1",s),role:"status","aria-live":"polite","aria-label":r??i("loading"),children:Array.from({length:t}).map((o,l)=>e.jsxs("div",{className:"animate-pulse space-y-1.5",children:[e.jsx("div",{className:"h-3.5 bg-surface-elevated rounded w-2/3"}),e.jsx("div",{className:"h-2.5 bg-surface-elevated/70 rounded w-1/3"})]},l))})}function f({icon:t,title:r,hint:n,action:s,size:i="md",className:o}){const l=i==="sm"?"py-6":i==="lg"?"py-16":"py-10",x=i==="sm"?"text-xs":"text-sm";return e.jsxs("div",{className:a("flex flex-col items-center justify-center text-center px-4",l,o),children:[t&&e.jsx("div",{className:"mb-2.5 text-fg-muted",children:t}),e.jsx("div",{className:a("font-medium text-fg-secondary",x),children:r}),n&&e.jsx("div",{className:"mt-1 text-xs text-fg-tertiary max-w-xs leading-relaxed",children:n}),s&&e.jsx("button",{onClick:s.onClick,className:a("mt-3 px-3 py-1.5 rounded-md text-xs font-medium transition-colors",s.variant==="secondary"?"border border-border-default text-fg-secondary hover:bg-surface-elevated":"bg-brand-600 hover:bg-brand-500 text-on-brand"),children:s.label})]})}export{f as E,p as L,u as P,d as S};
1
+ import{u as c,j as e}from"./index-TPf50ZeO.js";function a(...t){return t.filter(Boolean).join(" ")}function d({className:t}){return e.jsxs("svg",{className:a("animate-spin shrink-0",t??"w-3.5 h-3.5"),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2.5",opacity:"0.2"}),e.jsx("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})]})}function u({label:t,className:r}){const{t:n}=c("common");return e.jsxs("div",{className:a("flex-1 flex flex-col items-center justify-center gap-2.5 py-10 text-fg-tertiary",r),role:"status","aria-live":"polite",children:[e.jsx(d,{className:"w-5 h-5 text-brand-400"}),e.jsx("span",{className:"text-xs",children:t??n("loading")})]})}function p({rows:t=3,label:r,variant:n="skeleton",className:s}){const{t:i}=c("common");return n==="text"?e.jsxs("div",{className:a("flex items-center gap-2 px-1 py-2 text-xs text-fg-tertiary",s),role:"status","aria-live":"polite",children:[e.jsx(d,{className:"w-3 h-3"}),e.jsx("span",{children:r??i("loading")})]}):e.jsx("div",{className:a("space-y-2.5 p-1",s),role:"status","aria-live":"polite","aria-label":r??i("loading"),children:Array.from({length:t}).map((o,l)=>e.jsxs("div",{className:"animate-pulse space-y-1.5",children:[e.jsx("div",{className:"h-3.5 bg-surface-elevated rounded w-2/3"}),e.jsx("div",{className:"h-2.5 bg-surface-elevated/70 rounded w-1/3"})]},l))})}function f({icon:t,title:r,hint:n,action:s,size:i="md",className:o}){const l=i==="sm"?"py-6":i==="lg"?"py-16":"py-10",x=i==="sm"?"text-xs":"text-sm";return e.jsxs("div",{className:a("flex flex-col items-center justify-center text-center px-4",l,o),children:[t&&e.jsx("div",{className:"mb-2.5 text-fg-muted",children:t}),e.jsx("div",{className:a("font-medium text-fg-secondary",x),children:r}),n&&e.jsx("div",{className:"mt-1 text-xs text-fg-tertiary max-w-xs leading-relaxed",children:n}),s&&e.jsx("button",{onClick:s.onClick,className:a("mt-3 px-3 py-1.5 rounded-md text-xs font-medium transition-colors",s.variant==="secondary"?"border border-border-default text-fg-secondary hover:bg-surface-elevated":"bg-brand-600 hover:bg-brand-500 text-on-brand"),children:s.label})]})}export{f as E,p as L,u as P,d as S};
@@ -1,4 +1,4 @@
1
- import{u as E,r as x,j as t,a2 as J,a3 as he,k as P,U as qe,a4 as re,n as Oe,P as Be,l as ee,A as Pe,a5 as at}from"./index-BHu6brRf.js";import{MarkdownMessage as O}from"./MarkdownMessage-DwxvYN4X.js";import{n as ot}from"./chatChips-DVIRVTpT.js";const pe=6e4,Ue=60*pe,it=24*Ue;function pn(e,n){const s=new Date(e).getTime();if(!Number.isFinite(s))return"";const r=Date.now()-s;if(r<pe)return n("common:time.now");const a=Math.floor(r/pe);if(a<60)return n("common:time.minutesAgo",{count:a});const o=Math.floor(r/Ue);return o<24?n("common:time.hoursAgo",{count:o}):n("common:time.daysAgo",{count:Math.floor(r/it)})}function mn(e,n){if(!e)return"";const s=new Date(e);if(Number.isNaN(s.getTime()))return"";try{return new Intl.DateTimeFormat(n||void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(s)}catch{return s.toLocaleString()}}const me={suppressAdjustUntil:0};function Y(e=2500){const n=typeof performance<"u"?performance.now():Date.now();me.suppressAdjustUntil=Math.max(me.suppressAdjustUntil,n+e)}function gn(){return(typeof performance<"u"?performance.now():Date.now())<me.suppressAdjustUntil}const je={shell_execute:{label:"Running command",icon:"⌨"},list_terminals:{label:"Listing terminals",icon:"⌨"},new_terminal:{label:"Opening terminal",icon:"⌨"},select_terminal:{label:"Selecting terminal",icon:"⌨"},close_terminal:{label:"Closing terminal",icon:"⌨"},read_terminal:{label:"Reading terminal",icon:"⌨"},write_terminal:{label:"Writing terminal",icon:"⌨"},exec_terminal:{label:"Running in terminal",icon:"⌨"},file_read:{label:"Reading file",icon:"📄"},file_write:{label:"Writing file",icon:"✏"},file_edit:{label:"Editing file",icon:"✏"},apply_patch:{label:"Applying patch",icon:"🔀"},list_directory:{label:"Listing directory",icon:"📂"},glob_find:{label:"Finding files",icon:"🔍"},grep_search:{label:"Searching code",icon:"🔍"},web_fetch:{label:"Fetching page",icon:"🌐"},web_search:{label:"Searching web",icon:"🔍"},web_extract:{label:"Extracting content",icon:"📑"},create_task:{label:"Creating task",icon:"📌"},task_create:{label:"Creating task",icon:"📌"},create_subtask:{label:"Adding subtask",icon:"📌"},update_task:{label:"Updating task",icon:"✅"},task_update:{label:"Updating task",icon:"✅"},add_task_note:{label:"Adding note",icon:"📝"},task_add_note:{label:"Adding note",icon:"📝"},task_list:{label:"Listing tasks",icon:"📋"},task_get:{label:"Getting task",icon:"📋"},task_note:{label:"Adding note",icon:"📝"},task_assign:{label:"Assigning task",icon:"👥"},task_submit_review:{label:"Submitting for review",icon:"✅"},task_comment:{label:"Commenting task",icon:"💬"},subtask_create:{label:"Adding subtask",icon:"📌"},subtask_complete:{label:"Completing subtask",icon:"✅"},subtask_cancel:{label:"Cancelling subtask",icon:"🚫"},subtask_list:{label:"Listing subtasks",icon:"📋"},requirement_propose:{label:"Proposing requirement",icon:"📋"},requirement_list:{label:"Listing requirements",icon:"📋"},requirement_get:{label:"Getting requirement",icon:"📋"},requirement_update:{label:"Updating requirement",icon:"📋"},requirement_update_status:{label:"Updating req status",icon:"✅"},requirement_resubmit:{label:"Resubmitting requirement",icon:"📋"},requirement_comment:{label:"Commenting requirement",icon:"💬"},list_projects:{label:"Listing projects",icon:"🗂"},get_project:{label:"Getting project",icon:"🗂"},create_project:{label:"Creating project",icon:"🗂"},update_project:{label:"Updating project",icon:"🗂"},deliverable_create:{label:"Creating deliverable",icon:"📦"},deliverable_search:{label:"Searching deliverables",icon:"🔍"},deliverable_list:{label:"Listing deliverables",icon:"📦"},deliverable_update:{label:"Updating deliverable",icon:"📦"},agent_ask_agent:{label:"Asking another agent",icon:"💬"},git_status:{label:"Git status",icon:"🔀"},git_diff:{label:"Git diff",icon:"🔀"},git_log:{label:"Git log",icon:"📜"},git_branch:{label:"Git branch",icon:"🌿"},git_add:{label:"Git add",icon:"➕"},git_commit:{label:"Git commit",icon:"💾"},project_structure:{label:"Project structure",icon:"🗂"},code_stats:{label:"Code stats",icon:"📊"},navigate_page:{label:"Opening page",icon:"🌐"},new_page:{label:"Opening new tab",icon:"🌐"},close_page:{label:"Closing tab",icon:"🌐"},select_page:{label:"Switching tab",icon:"🌐"},list_pages:{label:"Listing tabs",icon:"🌐"},click:{label:"Clicking element",icon:"👆"},hover:{label:"Hovering element",icon:"👆"},fill:{label:"Filling field",icon:"⌨"},fill_form:{label:"Filling form",icon:"⌨"},type_text:{label:"Typing text",icon:"⌨"},press_key:{label:"Pressing key",icon:"⌨"},take_screenshot:{label:"Screenshot",icon:"📸"},take_snapshot:{label:"Page snapshot",icon:"📋"},evaluate_script:{label:"Running script",icon:"⚙"},wait_for:{label:"Waiting",icon:"⏳"},list_console_messages:{label:"Console logs",icon:"🔍"},list_network_requests:{label:"Network requests",icon:"🔍"},lighthouse_audit:{label:"Running audit",icon:"📊"},agent_send_message:{label:"Messaging colleague",icon:"💬"},agent_list_colleagues:{label:"Checking team",icon:"👥"},memory_save:{label:"Saving memory",icon:"💾"},memory_search:{label:"Searching memory",icon:"🔍"},memory_list:{label:"Listing memory",icon:"💾"},memory_update:{label:"Updating memory",icon:"💾"},recall_activity:{label:"Recalling activity",icon:"📜"},notebook_upsert:{label:"Updating notebook",icon:"📝"},kb_search:{label:"Searching knowledge base",icon:"📚"},kb_list:{label:"Listing knowledge base",icon:"📚"},kb_read:{label:"Reading knowledge base",icon:"📚"},notify_user:{label:"Notifying user",icon:"🔔"},request_user_input:{label:"Requesting input",icon:"❓"},request_user_approval:{label:"Requesting approval",icon:"❓"},schedule_wakeup:{label:"Scheduling wakeup",icon:"⏰"},cancel_wakeup:{label:"Cancelling wakeup",icon:"⏰"},set_heartbeat_interval:{label:"Setting heartbeat",icon:"⏱"},discover_tools:{label:"Discovering tools",icon:"🧰"},check_mailbox:{label:"Checking mailbox",icon:"📥"},goal_create:{label:"Creating goal",icon:"🎯"},goal_update:{label:"Updating goal",icon:"🎯"},goal_status:{label:"Goal status",icon:"🎯"},background_exec:{label:"Background command",icon:"⌨"},process:{label:"Managing process",icon:"⚙"},feishu_send_message:{label:"Sending Feishu msg",icon:"✉"},feishu_search_docs:{label:"Searching Feishu",icon:"🔍"},spawn_subagent:{label:"Spawn Subagent",icon:"◎"},spawn_subagents:{label:"Spawn Subagents",icon:"◎"},invoke_coding_tool:{label:"Invoke Coding Tool",icon:"🛠"},coding_tool_apply:{label:"Apply Coding Result",icon:"🔀"},generate_image:{label:"Generating image",icon:"🖼"},text_to_speech:{label:"Generating speech",icon:"🔊"},speech_to_text:{label:"Transcribing audio",icon:"🎙"},generate_video:{label:"Generating video",icon:"🎬"},llm_list_providers:{label:"Listing providers",icon:"⚙"},llm_switch_model:{label:"Switching model",icon:"⚙"},llm_switch_default_provider:{label:"Switching provider",icon:"⚙"},llm_add_provider:{label:"Adding provider",icon:"⚙"},llm_edit_provider:{label:"Editing provider",icon:"⚙"},llm_add_model:{label:"Adding model",icon:"⚙"},llm_get_capability_routing:{label:"Checking capability routing",icon:"⚙"},llm_set_capability_routing:{label:"Setting capability routing",icon:"⚙"},team_list:{label:"Listing teams",icon:"👥"},team_status:{label:"Team status",icon:"👥"},team_start:{label:"Starting team",icon:"👥"},team_stop:{label:"Stopping team",icon:"👥"},team_update:{label:"Updating team",icon:"👥"},agent_start:{label:"Starting agent",icon:"◎"},agent_stop:{label:"Stopping agent",icon:"◎"},agent_update:{label:"Updating agent",icon:"◎"},agent_delegate_task:{label:"Delegating task",icon:"📌"},agent_broadcast_status:{label:"Broadcasting status",icon:"📣"},agent_create_group_chat:{label:"Creating group chat",icon:"💬"},agent_list_group_chats:{label:"Listing group chats",icon:"💬"},agent_send_group_message:{label:"Sending group message",icon:"💬"},delete_project:{label:"Deleting project",icon:"🗂"},project_stats:{label:"Project stats",icon:"📊"},hub_search:{label:"Searching Hub",icon:"🔍"},hub_install:{label:"Installing from Hub",icon:"📦"},package_list:{label:"Listing packages",icon:"📦"},package_install:{label:"Installing package",icon:"📦"},memory_delete:{label:"Deleting memory",icon:"💾"},memory_update_longterm:{label:"Updating long-term memory",icon:"💾"},notebook_clear:{label:"Clearing notebook",icon:"📝"},notebook_read:{label:"Reading notebook",icon:"📝"},recall_context:{label:"Recalling context",icon:"📜"},defer_mailbox_item:{label:"Deferring mailbox item",icon:"📥"},drop_mailbox_item:{label:"Dropping mailbox item",icon:"📥"},prioritize_mailbox_item:{label:"Prioritizing mailbox",icon:"📥"},delegate_message:{label:"Delegating message",icon:"💬"},task_board_health:{label:"Checking task board",icon:"📋"},task_check_duplicates:{label:"Checking duplicates",icon:"📋"},task_cleanup_duplicates:{label:"Cleaning duplicates",icon:"📋"},workflow_list:{label:"Listing workflows",icon:"🔄"},workflow_create:{label:"Creating workflow",icon:"🔄"},workflow_update:{label:"Updating workflow",icon:"🔄"},workflow_delete:{label:"Deleting workflow",icon:"🔄"},workflow_run:{label:"Running workflow",icon:"🔄"},workflow_status:{label:"Workflow status",icon:"🔄"},workflow_cancel:{label:"Cancelling workflow",icon:"🔄"},open_page:{label:"Opening page",icon:"🌐"},resize_page:{label:"Resizing page",icon:"🌐"},drag:{label:"Dragging element",icon:"👆"},upload_file:{label:"Uploading file",icon:"📎"},emulate:{label:"Emulating device",icon:"📱"},handle_dialog:{label:"Handling dialog",icon:"💬"},get_console_message:{label:"Console message",icon:"🔍"},get_network_request:{label:"Network request",icon:"🔍"}},ke={shell_execute:"square-terminal",background_exec:"square-terminal",process:"settings",list_terminals:"square-terminal",new_terminal:"square-terminal",select_terminal:"square-terminal",close_terminal:"square-terminal",read_terminal:"square-terminal",write_terminal:"square-terminal",exec_terminal:"square-terminal",file_read:"file-text",file_write:"edit",file_edit:"edit",apply_patch:"git-branch",list_directory:"folder",glob_find:"search",grep_search:"search",web_fetch:"globe",web_search:"search",web_extract:"file-text",create_task:"clipboard",task_create:"clipboard",create_subtask:"clipboard",update_task:"check-circle",task_update:"check-circle",add_task_note:"edit",task_add_note:"edit",task_note:"edit",task_list:"clipboard",task_get:"clipboard",task_assign:"users",task_submit_review:"check-circle",task_comment:"message-square",subtask_create:"clipboard",subtask_complete:"check-circle",subtask_cancel:"alert-circle",subtask_list:"clipboard",requirement_propose:"clipboard",requirement_list:"clipboard",requirement_get:"clipboard",requirement_update:"clipboard",requirement_update_status:"check-circle",requirement_resubmit:"clipboard",requirement_comment:"message-square",list_projects:"layers",get_project:"layers",create_project:"layers",update_project:"layers",deliverable_create:"package",deliverable_search:"search",deliverable_list:"package",deliverable_update:"edit",git_status:"git-branch",git_diff:"git-branch",git_log:"book-open",git_branch:"git-branch",git_add:"git-branch",git_commit:"save",project_structure:"layers",code_stats:"bar-chart",navigate_page:"globe",new_page:"globe",close_page:"globe",select_page:"globe",list_pages:"globe",click:"target",hover:"target",fill:"terminal",fill_form:"terminal",type_text:"terminal",press_key:"terminal",take_screenshot:"camera",take_snapshot:"camera",evaluate_script:"code",wait_for:"clock",list_console_messages:"terminal",list_network_requests:"globe",lighthouse_audit:"bar-chart",agent_send_message:"message-square",agent_list_colleagues:"users",memory_save:"database",memory_search:"search",memory_list:"database",memory_update:"database",recall_activity:"book-open",notebook_upsert:"edit",kb_search:"book-open",kb_list:"book-open",kb_read:"book-open",notify_user:"megaphone",request_user_input:"message-square",request_user_approval:"check-circle",schedule_wakeup:"clock",cancel_wakeup:"clock",set_heartbeat_interval:"clock",discover_tools:"wrench",check_mailbox:"message-square",goal_create:"target",goal_update:"target",goal_status:"target",feishu_send_message:"message-square",feishu_search_docs:"search",spawn_subagent:"bot",spawn_subagents:"bot",invoke_coding_tool:"wrench",coding_tool_apply:"git-branch",generate_image:"camera",text_to_speech:"headphones",speech_to_text:"headphones",generate_video:"camera",llm_list_providers:"settings",llm_switch_model:"settings",llm_switch_default_provider:"settings",llm_add_provider:"settings",llm_edit_provider:"settings",llm_add_model:"settings",llm_get_capability_routing:"settings",llm_set_capability_routing:"settings",team_list:"users",team_status:"users",team_start:"users",team_stop:"users",team_update:"users",agent_start:"bot",agent_stop:"bot",agent_update:"bot",agent_delegate_task:"clipboard",agent_broadcast_status:"megaphone",agent_create_group_chat:"message-square",agent_list_group_chats:"message-square",agent_send_group_message:"message-square",delete_project:"layers",project_stats:"bar-chart",hub_search:"search",hub_install:"package",package_list:"package",package_install:"package",memory_delete:"database",memory_update_longterm:"database",notebook_clear:"edit",notebook_read:"edit",recall_context:"book-open",defer_mailbox_item:"message-square",drop_mailbox_item:"message-square",prioritize_mailbox_item:"message-square",delegate_message:"message-square",task_board_health:"clipboard",task_check_duplicates:"clipboard",task_cleanup_duplicates:"clipboard",workflow_list:"git-branch",workflow_create:"git-branch",workflow_update:"git-branch",workflow_delete:"git-branch",workflow_run:"git-branch",workflow_status:"git-branch",workflow_cancel:"git-branch",open_page:"globe",resize_page:"globe",drag:"target",upload_file:"file-text",emulate:"settings",handle_dialog:"message-square",get_console_message:"terminal",get_network_request:"globe"};function U(e){const n=e.includes("__")?e.split("__").pop():e,s=je[n]??je[e],r=ke[n]??ke[e]??"settings";return s?{...s,iconName:r,key:n}:{label:n.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase()),icon:"⚙",iconName:r,key:n}}function K(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function lt(e){const n=new Date(e);if(isNaN(n.getTime()))return e;const s=String(n.getMonth()+1).padStart(2,"0"),r=String(n.getDate()).padStart(2,"0"),a=String(n.getHours()).padStart(2,"0"),o=String(n.getMinutes()).padStart(2,"0"),i=String(n.getSeconds()).padStart(2,"0");return`${s}-${r} ${a}:${o}:${i}`}function ge(e,n){return e.length<=n?e:e.slice(0,n)+"…"}function _e(e){try{const n=JSON.parse(e);return JSON.stringify(n,null,2)}catch{return e}}function Ke(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,s])=>s!=null).map(([s,r])=>({key:s,value:typeof r=="string"?r:JSON.stringify(r,null,2)}))}function ct(e){if(e.tool!=="shell_execute"||!e.args||typeof e.args!="object")return null;const n=e.args.command;return typeof n=="string"?n:null}function xe(e){const n=new Set;for(let s=0;s<e.length;s++){const r=e[s];if(r.type==="tool"&&(r.info.status==="done"||r.info.status==="error"))for(let a=s-1;a>=0;a--){const o=e[a];if(o.type==="tool"&&o.info.status==="running"&&o.info.tool===r.info.tool&&!n.has(a)){n.add(a);break}}}return e.filter((s,r)=>!n.has(r))}function be(e){const n=lt(e.createdAt),s=e.createdAt,r=e.metadata;switch(e.type){case"text":return r?.isThinking?{type:"thinking",content:e.content,time:n,timestamp:s}:{type:"text",content:e.content,time:n,timestamp:s};case"status":{const a=r?.action;return a&&["chat","chat_stream","task_execution","respond_in_session"].includes(a)?null:{type:"status",content:e.content,time:n,timestamp:s}}case"error":return{type:"error",content:e.content,time:n,timestamp:s};case"tool_start":return{type:"tool",time:n,timestamp:s,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:r?.arguments,subagentLogs:r?.subagentLogs}};case"tool_end":return{type:"tool",time:n,timestamp:s,key:`ee_${e.seq}`,info:{tool:e.content,status:r?.success===!1?"error":"done",args:r?.arguments,result:r?.result,error:r?.error,durationMs:r?.durationMs,subagentLogs:r?.subagentLogs}};default:return null}}function Fe(e,n){if(e!=="task_create"&&e!=="create_task"||!n)return null;try{const s=JSON.parse(n);if(!s.task)return null;const r=s.task;return{taskId:r.id,title:r.title,description:r.description,assignedAgentId:r.assignedAgentId,priority:r.priority}}catch{return null}}function We(e,n){if(e!=="requirement_propose"||!n)return null;try{const s=JSON.parse(n);if(s.status!=="success"||!s.requirement)return null;const r=s.requirement;return r.status!=="pending"?null:{requirementId:r.id,title:r.title,description:r.description,priority:r.priority}}catch{return null}}function dt(e){const n=[];for(const s of e)if(s.phase!=="output"){if(s.phase==="start"){const r=`${s.tool}_${s.ts}`;n.push({key:r,tool:s.tool,status:"running"})}else for(let r=n.length-1;r>=0;r--)if(n[r].tool===s.tool&&n[r].status==="running"){n[r]={...n[r],status:s.success===!1?"error":"done"};break}}return n}function ze(){return t.jsxs("svg",{className:"w-3 h-3 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function ut(){return t.jsx("span",{className:"flex items-center gap-0.5",children:[0,150,300].map(e=>t.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${e}ms`,animationDuration:"1s"}},e))})}function we({item:e}){const{t:n}=E("common"),s=U(e.tool);return t.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[t.jsx(J,{name:s.iconName,size:15,className:`shrink-0 ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500":"text-green-500"}`}),t.jsxs("span",{className:`text-xs ${e.status==="running"?"activity-text-shimmer":e.status==="error"?"text-fg-tertiary":"text-fg-secondary"}`,children:[n(`execution.tools.${s.key}`,{defaultValue:s.label}),e.status==="running"?"…":""]}),e.status==="running"&&t.jsx(ze,{})]})}function Ne({activities:e,isActive:n,persistent:s}){const{t:r}=E("common"),a=dt(e),[o,i]=x.useState(!1),l=a.length>0,d=l&&a.every(p=>p.status!=="running");if(s&&d){const p=a.filter(_=>_.status==="error").length,k=a.filter(_=>_.status==="done").length;return t.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[t.jsxs("button",{onClick:()=>i(_=>!_),className:"flex items-center gap-1.5 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors select-none",children:[t.jsx("span",{className:`transition-transform duration-150 ${o?"rotate-90":""}`,children:"▶"}),t.jsx("span",{className:"font-medium",children:r("activity.step",{count:k})}),p>0&&t.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",r("activity.failed",{count:p})]}),!o&&t.jsxs("span",{className:"ml-1 flex items-center gap-1",children:[a.slice(0,5).map(_=>{const b=U(_.tool);return t.jsx(J,{name:b.iconName,size:13,className:`shrink-0 ${_.status==="error"?"text-red-500":"text-green-500"}`},_.key)}),a.length>5&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",a.length-5]})]})]}),o&&t.jsx("div",{className:"mt-2 space-y-0.5",children:a.map((_,b)=>t.jsx(we,{item:_,idx:b,total:a.length},_.key))})]})}if(!l)return t.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[t.jsx("span",{className:"mr-0.5 activity-text-shimmer",children:r("activity.thinking")}),t.jsx(ut,{})]});const c=a.filter(p=>p.status==="error").length;let u=null;for(let p=a.length-1;p>=0;p--)if(a[p].status==="running"){u=a[p];break}const h=a[a.length-1];let f;if(u){const p=U(u.tool);f=`${r(`execution.tools.${p.key}`,{defaultValue:p.label})}…`}else if(n&&d)f=r("activity.writingResponse");else{const p=U(h.tool);f=r(`execution.tools.${p.key}`,{defaultValue:p.label})}const g=!!u||n&&d;return t.jsxs("div",{className:"mb-1",children:[t.jsxs("button",{onClick:p=>{p.stopPropagation(),i(k=>!k)},className:"flex items-center gap-1.5 text-xs w-full min-w-0 select-none text-fg-tertiary hover:text-fg-secondary transition-colors",children:[t.jsx("span",{className:`shrink-0 transition-transform duration-150 ${o?"rotate-90":""}`,children:"▶"}),t.jsx("span",{className:`truncate font-medium ${g?"activity-text-shimmer":"text-fg-secondary"}`,children:f}),t.jsxs("span",{className:"shrink-0",children:["· ",r("activity.step",{count:a.length})]}),c>0&&t.jsxs("span",{className:"text-red-500 shrink-0",children:["· ",r("activity.failed",{count:c})]}),g&&t.jsx(ze,{})]}),o&&t.jsx("div",{className:"mt-1 space-y-0.5",children:a.map((p,k)=>t.jsx(we,{item:p,idx:k,total:a.length},p.key))})]})}const pt=1920,mt=10*1024*1024,Ce=5,gt=.8;function xt(e,n,s){return new Promise((r,a)=>{const o=new Image;o.onload=()=>{let{width:i,height:l}=o;if(i<=n&&l<=n){r(e);return}i>l?(l=Math.round(l*(n/i)),i=n):(i=Math.round(i*(n/l)),l=n);const d=document.createElement("canvas");d.width=i,d.height=l;const c=d.getContext("2d");if(!c){a(new Error("Failed to get canvas context"));return}c.drawImage(o,0,0,i,l),r(d.toDataURL("image/jpeg",s))},o.onerror=()=>a(new Error("Failed to load image")),o.src=e})}function ft({candidates:e,filter:n,anchorRef:s,onSelect:r,selectedIndex:a,onIndexChange:o}){const{t:i}=E("common"),[l,d]=x.useState(null),c=x.useRef(null),u=e.filter(h=>h.name.toLowerCase().includes(n));return x.useEffect(()=>{const h=s.current;if(!h)return;const f=h.getBoundingClientRect();d({top:f.top+window.scrollY-4,left:f.left+window.scrollX+8})},[s,n]),x.useEffect(()=>{if(!c.current||!l)return;if(c.current.getBoundingClientRect().top<8){const f=s.current;if(!f)return;const g=f.getBoundingClientRect();d({top:g.bottom+window.scrollY+4,left:l.left})}},[l,s]),x.useEffect(()=>{a>=u.length&&o(Math.max(0,u.length-1))},[u.length,a,o]),x.useEffect(()=>{if(!c.current)return;c.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[a]),!l||u.length===0?null:he.createPortal(t.jsxs("div",{ref:c,style:{position:"absolute",top:l.top,left:l.left,transform:"translateY(-100%)"},className:"w-60 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-[9999] max-h-48 overflow-y-auto",children:[t.jsx("div",{className:"px-2.5 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:i("commentInput.mentionHeading")}),u.map((h,f)=>t.jsxs("button",{"data-selected":f===a,onMouseDown:g=>{g.preventDefault(),r(h)},onMouseEnter:()=>o(f),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${f===a?"bg-brand-500/15 text-brand-500":"hover:bg-surface-elevated"}`,children:[t.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${h.type==="human"?"bg-green-500/20 text-green-500":"bg-brand-500/20 text-brand-500"}`,children:h.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-fg-primary font-medium",children:h.name}),t.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:h.subtitle??h.type})]}),h.type==="agent"&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${h.online?"bg-green-400":"bg-gray-500"}`})]},h.id))]}),document.body)}function ht(e){return/^\w+$/.test(e)?`@${e}`:`@[${e}]`}const Se=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function xn(e){const n=[];let s;for(Se.lastIndex=0;(s=Se.exec(e))!==null;)n.push(s[1]??s[2]);return n}function fn(e,n,s){const r=[];let a=0;const o=n.map(l=>l.name).sort((l,d)=>d.length-l.length);let i=0;for(;i<e.length;){const l=e.indexOf("@",i);if(l<0){r.push(t.jsx("span",{children:e.slice(i)},a++));break}if(l>i&&r.push(t.jsx("span",{children:e.slice(i,l)},a++)),e[l+1]==="["){const g=e.indexOf("]",l+2);if(g>l+2){const p=e.slice(l+2,g),k=n.find(_=>_.name.toLowerCase()===p.toLowerCase());r.push(t.jsxs("span",{className:`text-brand-500 font-medium ${s&&k?"cursor-pointer hover:underline":""}`,onClick:s&&k?_=>s(k,_):void 0,title:k?`${k.name} (${k.role})`:void 0,children:["@",p]},a++)),i=g+1;continue}}const d=e.slice(l+1),c=d.toLowerCase(),u=o.find(g=>c.startsWith(g.toLowerCase()));if(u){const g=n.find(p=>p.name.toLowerCase()===u.toLowerCase());r.push(t.jsxs("span",{className:`text-brand-500 font-medium ${s&&g?"cursor-pointer hover:underline":""}`,onClick:s&&g?p=>s(g,p):void 0,title:g?`${g.name} (${g.role})`:void 0,children:["@",u]},a++)),i=l+1+u.length;continue}const h=/^([\w\p{L}\p{N}]+)/u,f=d.match(h);if(f){const g=f[1],p=n.find(k=>k.name.toLowerCase()===g.toLowerCase());r.push(t.jsxs("span",{className:`text-brand-500 font-medium ${s&&p?"cursor-pointer hover:underline":""}`,onClick:s&&p?k=>s(p,k):void 0,title:p?`${p.name} (${p.role})`:void 0,children:["@",g]},a++)),i=l+1+g.length;continue}r.push(t.jsx("span",{children:"@"},a++)),i=l+1}return r.length>0?r:[t.jsx("span",{children:e},0)]}function hn({agents:e,humans:n,onSubmit:s,placeholder:r,replyTo:a,onCancelReply:o}){const{t:i}=E("common"),[l,d]=x.useState(""),[c,u]=x.useState(!1),[h,f]=x.useState(null),[g,p]=x.useState(!1),[k,_]=x.useState(""),[b,m]=x.useState([]),[v,j]=x.useState(0),[C,R]=x.useState([]),[z,D]=x.useState(!1),A=x.useRef(null),L=x.useRef(null),B=x.useRef(null),G=x.useMemo(()=>{const y=(n??[]).map(w=>({id:w.id,name:w.name,type:"human",subtitle:w.role}));for(const w of e)y.push({id:w.id,name:w.name,type:"agent",subtitle:w.role,online:w.status==="idle"||w.status==="working"});return y},[e,n]),q=G.filter(y=>y.name.toLowerCase().includes(k)),I=x.useCallback(y=>{const w=Array.from(y).filter(S=>S.type.startsWith("image/"));if(w.length!==0)for(const S of w){if(S.size>mt)continue;const M=new FileReader;M.onload=()=>{const Z=M.result;xt(Z,pt,gt).then($=>{R(de=>de.length>=Ce?de:[...de,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:$,name:S.name}])})},M.readAsDataURL(S)}},[]),oe=x.useCallback(y=>{R(w=>w.filter(S=>S.id!==y))},[]),ie=x.useCallback(y=>{const w=y.clipboardData?.files;if(w&&w.length>0){const S=Array.from(w).filter(M=>M.type.startsWith("image/"));S.length>0&&(y.preventDefault(),I(S))}},[I]),Q=x.useCallback(y=>{y.preventDefault(),D(!1);const w=y.dataTransfer?.files;w&&w.length>0&&I(Array.from(w).filter(S=>S.type.startsWith("image/")))},[I]),le=x.useCallback(y=>{y.preventDefault(),D(!0)},[]),ce=x.useCallback(()=>{D(!1)},[]),H=async()=>{if(!(!l.trim()&&C.length===0)){u(!0),f(null),B.current={content:l,mentions:[...b],images:[...C]};try{await s(l,b,[...C],a?.id),d(""),m([]),R([]),B.current=null,o?.()}catch(y){f(String(y instanceof Error?y.message:y)||i("commentInput.sendFailed"))}u(!1)}},F=async()=>{if(!B.current)return;const{content:y,mentions:w,images:S}=B.current;u(!0),f(null);try{await s(y,w,S),d(""),m([]),R([]),B.current=null}catch(M){f(String(M instanceof Error?M.message:M)||i("commentInput.sendFailed"))}u(!1)},N=x.useCallback(y=>{d(w=>{const S=w.lastIndexOf("@"),M=ht(y.name);return S>=0?w.slice(0,S)+M+" ":w+M+" "}),b.includes(y.id)||m(w=>[...w,y.id]),p(!1),_(""),j(0),A.current?.focus()},[b]),V=y=>{d(y),f(null);const w=y.lastIndexOf("@");if(w>=0&&(w===0||y[w-1]===" ")){const M=y.slice(w+1).toLowerCase();if(G.some($=>$.name.toLowerCase().includes(M))){_(M),p(!0),j(0);return}}p(!1)},X=y=>{if(g&&q.length>0){const w=y.key==="ArrowUp"||y.ctrlKey&&y.key==="p",S=y.key==="ArrowDown"||y.ctrlKey&&y.key==="n",M=y.key==="Enter"||y.key==="Tab",Z=y.key==="Escape";if(w){y.preventDefault(),j($=>($-1+q.length)%q.length);return}if(S){y.preventDefault(),j($=>($+1)%q.length);return}if(M){y.preventDefault();const $=q[v];$&&N($);return}if(Z){y.preventDefault(),p(!1);return}}y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),H())},rt=x.useCallback(()=>{setTimeout(()=>p(!1),200)},[]);return t.jsxs("div",{className:"relative",onDragOver:le,onDragLeave:ce,onDrop:Q,children:[z&&t.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-brand-500/10 rounded-lg border-2 border-dashed border-brand-500",children:t.jsx("span",{className:"text-sm text-brand-500 font-medium",children:i("commentInput.dragDropHint")})}),g&&t.jsx(ft,{candidates:G,filter:k,anchorRef:A,onSelect:N,selectedIndex:v,onIndexChange:j}),t.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[a&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:a.authorName}),t.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:a.content})]}),t.jsx("button",{onClick:o,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),b.length>0&&t.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:b.map(y=>{const w=G.find(S=>S.id===y);return t.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded-full ${w?.type==="human"?"bg-green-500/15 text-green-500":"bg-brand-500/15 text-brand-500"}`,children:["@",w?.name??y,t.jsx("button",{onClick:()=>m(S=>S.filter(M=>M!==y)),className:"hover:text-red-400",children:"×"})]},y)})}),t.jsx("textarea",{ref:A,value:l,onChange:y=>V(y.target.value),onKeyDown:X,onBlur:rt,onPaste:ie,placeholder:r??i("commentInput.placeholder"),rows:2,className:"w-full px-2.5 py-2 text-xs bg-transparent text-fg-primary placeholder-fg-tertiary outline-none resize-none"}),C.length>0&&t.jsx("div",{className:"flex items-center gap-1.5 px-2.5 pb-1.5 overflow-x-auto",children:C.map(y=>t.jsxs("div",{className:"relative group/img shrink-0",children:[t.jsx("img",{src:y.dataUrl,alt:y.name,className:"w-12 h-12 rounded-lg object-cover border border-border-default"}),t.jsx("button",{onClick:()=>oe(y.id),className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-[10px] opacity-0 group-hover/img:opacity-100 transition-opacity",title:i("commentInput.removeImage"),children:"×"})]},y.id))}),h&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[t.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:h}),t.jsxs("button",{onClick:F,disabled:c,className:"text-[11px] text-amber-500 hover:text-amber-400 font-medium transition-colors flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),i("commentInput.retry")]})]}),t.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2",children:[t.jsx("button",{type:"button",onClick:()=>L.current?.click(),disabled:c||C.length>=Ce,className:"p-1 text-fg-tertiary hover:text-brand-500 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:i("commentInput.attachImage"),children:t.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),t.jsx("input",{ref:L,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:y=>{y.target.files&&I(y.target.files),y.target.value=""}}),t.jsx("button",{onClick:H,disabled:!l.trim()&&C.length===0||c,className:"px-3 py-1 text-[11px] font-medium bg-brand-500 text-on-brand rounded-md hover:bg-brand-600 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:i(c?"commentInput.sending":"commentInput.submit")})]})]}),l.trim()&&!c&&t.jsx("div",{className:"mt-0.5 -mb-0.5 flex justify-end px-2.5 pointer-events-none select-none",children:t.jsx("span",{className:"text-[10px] text-fg-tertiary/80",children:i("common:shiftEnterHint")})}),t.jsx("p",{className:"mt-1 text-center text-[10px] text-fg-tertiary/80 select-none",children:i("aiDisclaimer")})]})}function bn(e){const n={id:e.id,sender:"user",text:e.text,time:e.time,rawCreatedAt:e.rawCreatedAt};return e.chips&&e.chips.length>0&&(n.chips=e.chips),e.images&&e.images.length>0&&(n.images=e.images),e.replyTo&&(n.replyToId=e.replyTo.id,n.replyToSender=e.replyTo.sender,n.replyToText=e.replyTo.text),n}function bt(e,n){return!!e&&n==="agent"}const yt=24e3,vt=200;function yn(e,n,s=yt){const r=(e??"")+n;return r.length<=s?r:r.slice(r.length-s)}function vn(e,n,s=vt){const r=[...e??[],n];return r.length<=s?r:r.slice(r.length-s)}function Ge(e){return!!e.text?.trim()||(e.segments??[]).some(n=>n.type==="text"&&(n.content||n.thinking)||n.type==="tool")}function jn(e,n){return!!(e.sender==="user"||Ge(e)||(e.activities?.length??0)>0||(e.images?.length??0)>0||e.emptyReply===!0||n&&!e.isStopped)}function jt(e,n=8){for(let s=e.length-1;s>=Math.max(0,e.length-n);s--){const r=e[s];if(r.isStreaming&&!r.isStopped)return!0}return!1}function ye(e){if(!e||e.length===0)return e;let n=!1;const s=e.map(r=>r.type==="tool"&&r.status==="running"?(n=!0,{...r,status:"stopped"}):r);return n?s:e}function He(e,n){if(!Ge(e)&&n!=="done")return null;const r={...e,isStreaming:!1,segments:ye(e.segments)};switch(n){case"done":return{...r,isStopped:!1,isError:!1};case"stopped":return{...r,isStopped:!0,isError:!1};case"error":return{...r,isStopped:!0,isError:!0}}}function kn(e){const n=[...e];for(let s=n.length-1;s>=0;s--)if(n[s].sender==="agent"&&!n[s].isStopped&&!n[s].isError){const r=He(n[s],"stopped");r===null?n.splice(s,1):n[s]=r;break}return n}function _n(e,n){if(n){const s=e.findIndex(r=>r.id===n);if(s>=0){const r=e[s],a=ye(r.segments);if(!r.isStreaming&&a===r.segments)return e;const o=[...e];return o[s]={...r,isStreaming:!1,segments:a},o}}return kt(e)}function kt(e){return jt(e)?e.map(n=>n.sender!=="agent"||!n.isStreaming||n.isStopped?n:{...n,isStreaming:!1,segments:ye(n.segments)}):e}function wn(e,n,s){return!n||!s||n===s?e:e.some(r=>r.id===s)?e.filter(r=>r.id!==n):e.map(r=>r.id===n?{...r,id:s}:r)}function Nn(e){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.sender==="agent"&&s.isStreaming)return n}return-1}function Cn(e){if(!e.sendSessionId)return!1;const n=e.liveSessions;return!n||n.size===0?!1:n.has(e.sendSessionId)}function Sn(e){const n=e.liveSessions;return!n||n.size===0||!e.sessionId?!0:!n.has(e.sessionId)&&!n.has(e.placeholderId)}function Tn(e,n="stopped"){for(let s=e.length-1;s>=0;s--){const r=e[s];if(r.sender==="agent"&&r.isStreaming&&!r.isStopped){const a=He(r,n);if(a===null)return e.filter((i,l)=>l!==s);const o=[...e];return o[s]=a,o}}return e}function En(e,n){if(e.some(o=>o.id===n.id))return e;const s=n.rawCreatedAt?Date.parse(n.rawCreatedAt):NaN;if(!Number.isFinite(s)||e.length===0)return[...e,n];let r=e.length;for(;r>0;){const o=e[r-1],i=o.rawCreatedAt?Date.parse(o.rawCreatedAt):NaN;if(!Number.isFinite(i)||i<=s)break;r--}if(r===e.length)return[...e,n];const a=e.slice();return a.splice(r,0,n),a}function Mn(e,n){if(!n)return e;const s=e[e.length-1];return s?.type==="text"?[...e.slice(0,-1),{...s,thinking:(s.thinking??"")+n}]:[...e,{type:"text",content:"",thinking:n,createdAt:new Date().toISOString()}]}function An(e,n){if(!n)return e;const s=e[e.length-1];return s?.type==="text"?[...e.slice(0,-1),{...s,content:s.content+n}]:[...e,{type:"text",content:n,createdAt:new Date().toISOString()}]}const _t=/\n*<!--\s*notify_context:\s*([\s\S]*?)-->/g;function ve(e){if(!e.includes("notify_context"))return{cleaned:e};let n;const s=e.match(/<!--\s*notify_context:\s*([\s\S]*?)-->/);if(s?.[1]){const r=s[1].match(/priority\s*=\s*(\w+)/i);r&&(n=r[1])}return{cleaned:e.replace(_t,"").trimEnd(),priority:n}}const wt=/(?:<thinking>| thinking)[\s\S]*?<\/thinking>/g,Nt=/(?:<thinking>| thinking| thinking| think)[\s\S]*?<\/think>/g;function Ln(e){return e.replace(wt,"").replace(Nt,"")}function Ct(e,n,s){if(e.type!=="tool"){const{cleaned:l}=ve(e.content??"");return{type:"text",content:l,thinking:e.thinking,createdAt:e.createdAt}}const r=s?.type==="tool"&&s.tool===e.tool?s:void 0,a=e.subagentLogs?.length??0,o=r?.subagentLogs?.length??0,i=a>=o?e.subagentLogs:r?.subagentLogs;return{type:"tool",key:`${e.tool}_${n}`,tool:e.tool,status:e.status,args:e.arguments,result:e.result,error:e.error,durationMs:e.durationMs,createdAt:e.createdAt,...i?.length?{subagentLogs:i}:{}}}function Ve(e,n){const s=(n??[]).filter(a=>a.type==="tool");let r=0;return e.map((a,o)=>{const i=a.type==="tool"?s[r++]:void 0;return Ct(a,o,i)})}const te=new Map,St=2e3;function Xe(e){if(!e)return"";const n=te.get(e);if(n!==void 0)return n;const s=new Date(e),r=isNaN(s.getTime())?"":s.toLocaleTimeString();return te.size>=St&&te.clear(),te.set(e,r),r}function Rn(e){const n={id:e.id,sender:e.role==="user"?"user":"agent",text:e.content,time:Xe(e.createdAt),rawCreatedAt:e.createdAt,agentId:e.role!=="user"?e.agentId:void 0,sessionId:e.sessionId};if(e.metadata?.segmentsTruncated===!0&&(n.needsDetail=!0),e.role!=="user"&&e.metadata?.segments&&e.metadata.segments.length>0&&(n.segments=Ve(e.metadata.segments)),e.role==="assistant"&&(e.content==="[cancelled]"||e.content==="[Stream cancelled]")&&(n.text=""),(e.metadata?.isError||e.role==="assistant"&&e.content.startsWith("⚠"))&&(n.isError=!0),e.metadata?.emptyReply===!0&&(n.emptyReply=!0,n.isStopped||(n.isError=!0)),e.metadata?.isStreaming&&(n.isStreaming=!0),e.metadata?.isStopped&&!e.metadata?.isStreaming&&(n.isStopped=!0),e.metadata?.images?.length&&(n.images=e.metadata.images),e.metadata?.notifyUser&&(n.isNotification=!0,n.notifyPriority=e.metadata.priority,e.metadata.taskId&&(n.taskId=e.metadata.taskId),e.metadata.requirementId&&(n.requirementId=e.metadata.requirementId)),n.text.includes("<!-- notify_context:")){const{cleaned:s,priority:r}=ve(n.text);n.text=s,r&&!n.notifyPriority&&(n.notifyPriority=r),n.isNotification=!0}if(e.metadata?.activityLog&&(n.isActivityLog=!0,n.activityType=e.metadata.activityType,n.outcome=e.metadata.outcome,n.mailboxItemId=e.metadata.mailboxItemId,n.taskId=e.metadata.taskId,n.requirementId=e.metadata.requirementId,!n.outcome&&n.text.startsWith("[ACTIVITY:"))){const s=n.text.lastIndexOf(" → ");s!==-1&&(n.outcome=n.text.slice(s+3)),n.text=n.text.replace(/^\[ACTIVITY:\s*\w+\]\s*/,"")}if(e.metadata?.replyToId&&(n.replyToId=e.metadata.replyToId,n.replyToSender=e.metadata.replyToSender,n.replyToText=e.metadata.replyToText,n.text=Ye(n.text,n.replyToSender,n.replyToText)),e.role==="user"){const s=ot(e.metadata?.chips);s&&(n.chips=s)}return n}function Ye(e,n,s){if(!e||!n||!s)return e;const r=`> **${n}**: ${s}
1
+ import{u as E,r as x,j as t,a2 as J,a3 as he,k as P,U as qe,a4 as re,n as Oe,P as Be,l as ee,A as Pe,a5 as at}from"./index-TPf50ZeO.js";import{MarkdownMessage as O}from"./MarkdownMessage-DVfFMzM9.js";import{n as ot}from"./chatChips-DVIRVTpT.js";const pe=6e4,Ue=60*pe,it=24*Ue;function pn(e,n){const s=new Date(e).getTime();if(!Number.isFinite(s))return"";const r=Date.now()-s;if(r<pe)return n("common:time.now");const a=Math.floor(r/pe);if(a<60)return n("common:time.minutesAgo",{count:a});const o=Math.floor(r/Ue);return o<24?n("common:time.hoursAgo",{count:o}):n("common:time.daysAgo",{count:Math.floor(r/it)})}function mn(e,n){if(!e)return"";const s=new Date(e);if(Number.isNaN(s.getTime()))return"";try{return new Intl.DateTimeFormat(n||void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(s)}catch{return s.toLocaleString()}}const me={suppressAdjustUntil:0};function Y(e=2500){const n=typeof performance<"u"?performance.now():Date.now();me.suppressAdjustUntil=Math.max(me.suppressAdjustUntil,n+e)}function gn(){return(typeof performance<"u"?performance.now():Date.now())<me.suppressAdjustUntil}const je={shell_execute:{label:"Running command",icon:"⌨"},list_terminals:{label:"Listing terminals",icon:"⌨"},new_terminal:{label:"Opening terminal",icon:"⌨"},select_terminal:{label:"Selecting terminal",icon:"⌨"},close_terminal:{label:"Closing terminal",icon:"⌨"},read_terminal:{label:"Reading terminal",icon:"⌨"},write_terminal:{label:"Writing terminal",icon:"⌨"},exec_terminal:{label:"Running in terminal",icon:"⌨"},file_read:{label:"Reading file",icon:"📄"},file_write:{label:"Writing file",icon:"✏"},file_edit:{label:"Editing file",icon:"✏"},apply_patch:{label:"Applying patch",icon:"🔀"},list_directory:{label:"Listing directory",icon:"📂"},glob_find:{label:"Finding files",icon:"🔍"},grep_search:{label:"Searching code",icon:"🔍"},web_fetch:{label:"Fetching page",icon:"🌐"},web_search:{label:"Searching web",icon:"🔍"},web_extract:{label:"Extracting content",icon:"📑"},create_task:{label:"Creating task",icon:"📌"},task_create:{label:"Creating task",icon:"📌"},create_subtask:{label:"Adding subtask",icon:"📌"},update_task:{label:"Updating task",icon:"✅"},task_update:{label:"Updating task",icon:"✅"},add_task_note:{label:"Adding note",icon:"📝"},task_add_note:{label:"Adding note",icon:"📝"},task_list:{label:"Listing tasks",icon:"📋"},task_get:{label:"Getting task",icon:"📋"},task_note:{label:"Adding note",icon:"📝"},task_assign:{label:"Assigning task",icon:"👥"},task_submit_review:{label:"Submitting for review",icon:"✅"},task_comment:{label:"Commenting task",icon:"💬"},subtask_create:{label:"Adding subtask",icon:"📌"},subtask_complete:{label:"Completing subtask",icon:"✅"},subtask_cancel:{label:"Cancelling subtask",icon:"🚫"},subtask_list:{label:"Listing subtasks",icon:"📋"},requirement_propose:{label:"Proposing requirement",icon:"📋"},requirement_list:{label:"Listing requirements",icon:"📋"},requirement_get:{label:"Getting requirement",icon:"📋"},requirement_update:{label:"Updating requirement",icon:"📋"},requirement_update_status:{label:"Updating req status",icon:"✅"},requirement_resubmit:{label:"Resubmitting requirement",icon:"📋"},requirement_comment:{label:"Commenting requirement",icon:"💬"},list_projects:{label:"Listing projects",icon:"🗂"},get_project:{label:"Getting project",icon:"🗂"},create_project:{label:"Creating project",icon:"🗂"},update_project:{label:"Updating project",icon:"🗂"},deliverable_create:{label:"Creating deliverable",icon:"📦"},deliverable_search:{label:"Searching deliverables",icon:"🔍"},deliverable_list:{label:"Listing deliverables",icon:"📦"},deliverable_update:{label:"Updating deliverable",icon:"📦"},agent_ask_agent:{label:"Asking another agent",icon:"💬"},git_status:{label:"Git status",icon:"🔀"},git_diff:{label:"Git diff",icon:"🔀"},git_log:{label:"Git log",icon:"📜"},git_branch:{label:"Git branch",icon:"🌿"},git_add:{label:"Git add",icon:"➕"},git_commit:{label:"Git commit",icon:"💾"},project_structure:{label:"Project structure",icon:"🗂"},code_stats:{label:"Code stats",icon:"📊"},navigate_page:{label:"Opening page",icon:"🌐"},new_page:{label:"Opening new tab",icon:"🌐"},close_page:{label:"Closing tab",icon:"🌐"},select_page:{label:"Switching tab",icon:"🌐"},list_pages:{label:"Listing tabs",icon:"🌐"},click:{label:"Clicking element",icon:"👆"},hover:{label:"Hovering element",icon:"👆"},fill:{label:"Filling field",icon:"⌨"},fill_form:{label:"Filling form",icon:"⌨"},type_text:{label:"Typing text",icon:"⌨"},press_key:{label:"Pressing key",icon:"⌨"},take_screenshot:{label:"Screenshot",icon:"📸"},take_snapshot:{label:"Page snapshot",icon:"📋"},evaluate_script:{label:"Running script",icon:"⚙"},wait_for:{label:"Waiting",icon:"⏳"},list_console_messages:{label:"Console logs",icon:"🔍"},list_network_requests:{label:"Network requests",icon:"🔍"},lighthouse_audit:{label:"Running audit",icon:"📊"},agent_send_message:{label:"Messaging colleague",icon:"💬"},agent_list_colleagues:{label:"Checking team",icon:"👥"},memory_save:{label:"Saving memory",icon:"💾"},memory_search:{label:"Searching memory",icon:"🔍"},memory_list:{label:"Listing memory",icon:"💾"},memory_update:{label:"Updating memory",icon:"💾"},recall_activity:{label:"Recalling activity",icon:"📜"},notebook_upsert:{label:"Updating notebook",icon:"📝"},kb_search:{label:"Searching knowledge base",icon:"📚"},kb_list:{label:"Listing knowledge base",icon:"📚"},kb_read:{label:"Reading knowledge base",icon:"📚"},notify_user:{label:"Notifying user",icon:"🔔"},request_user_input:{label:"Requesting input",icon:"❓"},request_user_approval:{label:"Requesting approval",icon:"❓"},schedule_wakeup:{label:"Scheduling wakeup",icon:"⏰"},cancel_wakeup:{label:"Cancelling wakeup",icon:"⏰"},set_heartbeat_interval:{label:"Setting heartbeat",icon:"⏱"},discover_tools:{label:"Discovering tools",icon:"🧰"},check_mailbox:{label:"Checking mailbox",icon:"📥"},goal_create:{label:"Creating goal",icon:"🎯"},goal_update:{label:"Updating goal",icon:"🎯"},goal_status:{label:"Goal status",icon:"🎯"},background_exec:{label:"Background command",icon:"⌨"},process:{label:"Managing process",icon:"⚙"},feishu_send_message:{label:"Sending Feishu msg",icon:"✉"},feishu_search_docs:{label:"Searching Feishu",icon:"🔍"},spawn_subagent:{label:"Spawn Subagent",icon:"◎"},spawn_subagents:{label:"Spawn Subagents",icon:"◎"},invoke_coding_tool:{label:"Invoke Coding Tool",icon:"🛠"},coding_tool_apply:{label:"Apply Coding Result",icon:"🔀"},generate_image:{label:"Generating image",icon:"🖼"},text_to_speech:{label:"Generating speech",icon:"🔊"},speech_to_text:{label:"Transcribing audio",icon:"🎙"},generate_video:{label:"Generating video",icon:"🎬"},llm_list_providers:{label:"Listing providers",icon:"⚙"},llm_switch_model:{label:"Switching model",icon:"⚙"},llm_switch_default_provider:{label:"Switching provider",icon:"⚙"},llm_add_provider:{label:"Adding provider",icon:"⚙"},llm_edit_provider:{label:"Editing provider",icon:"⚙"},llm_add_model:{label:"Adding model",icon:"⚙"},llm_get_capability_routing:{label:"Checking capability routing",icon:"⚙"},llm_set_capability_routing:{label:"Setting capability routing",icon:"⚙"},team_list:{label:"Listing teams",icon:"👥"},team_status:{label:"Team status",icon:"👥"},team_start:{label:"Starting team",icon:"👥"},team_stop:{label:"Stopping team",icon:"👥"},team_update:{label:"Updating team",icon:"👥"},agent_start:{label:"Starting agent",icon:"◎"},agent_stop:{label:"Stopping agent",icon:"◎"},agent_update:{label:"Updating agent",icon:"◎"},agent_delegate_task:{label:"Delegating task",icon:"📌"},agent_broadcast_status:{label:"Broadcasting status",icon:"📣"},agent_create_group_chat:{label:"Creating group chat",icon:"💬"},agent_list_group_chats:{label:"Listing group chats",icon:"💬"},agent_send_group_message:{label:"Sending group message",icon:"💬"},delete_project:{label:"Deleting project",icon:"🗂"},project_stats:{label:"Project stats",icon:"📊"},hub_search:{label:"Searching Hub",icon:"🔍"},hub_install:{label:"Installing from Hub",icon:"📦"},package_list:{label:"Listing packages",icon:"📦"},package_install:{label:"Installing package",icon:"📦"},memory_delete:{label:"Deleting memory",icon:"💾"},memory_update_longterm:{label:"Updating long-term memory",icon:"💾"},notebook_clear:{label:"Clearing notebook",icon:"📝"},notebook_read:{label:"Reading notebook",icon:"📝"},recall_context:{label:"Recalling context",icon:"📜"},defer_mailbox_item:{label:"Deferring mailbox item",icon:"📥"},drop_mailbox_item:{label:"Dropping mailbox item",icon:"📥"},prioritize_mailbox_item:{label:"Prioritizing mailbox",icon:"📥"},delegate_message:{label:"Delegating message",icon:"💬"},task_board_health:{label:"Checking task board",icon:"📋"},task_check_duplicates:{label:"Checking duplicates",icon:"📋"},task_cleanup_duplicates:{label:"Cleaning duplicates",icon:"📋"},workflow_list:{label:"Listing workflows",icon:"🔄"},workflow_create:{label:"Creating workflow",icon:"🔄"},workflow_update:{label:"Updating workflow",icon:"🔄"},workflow_delete:{label:"Deleting workflow",icon:"🔄"},workflow_run:{label:"Running workflow",icon:"🔄"},workflow_status:{label:"Workflow status",icon:"🔄"},workflow_cancel:{label:"Cancelling workflow",icon:"🔄"},open_page:{label:"Opening page",icon:"🌐"},resize_page:{label:"Resizing page",icon:"🌐"},drag:{label:"Dragging element",icon:"👆"},upload_file:{label:"Uploading file",icon:"📎"},emulate:{label:"Emulating device",icon:"📱"},handle_dialog:{label:"Handling dialog",icon:"💬"},get_console_message:{label:"Console message",icon:"🔍"},get_network_request:{label:"Network request",icon:"🔍"}},ke={shell_execute:"square-terminal",background_exec:"square-terminal",process:"settings",list_terminals:"square-terminal",new_terminal:"square-terminal",select_terminal:"square-terminal",close_terminal:"square-terminal",read_terminal:"square-terminal",write_terminal:"square-terminal",exec_terminal:"square-terminal",file_read:"file-text",file_write:"edit",file_edit:"edit",apply_patch:"git-branch",list_directory:"folder",glob_find:"search",grep_search:"search",web_fetch:"globe",web_search:"search",web_extract:"file-text",create_task:"clipboard",task_create:"clipboard",create_subtask:"clipboard",update_task:"check-circle",task_update:"check-circle",add_task_note:"edit",task_add_note:"edit",task_note:"edit",task_list:"clipboard",task_get:"clipboard",task_assign:"users",task_submit_review:"check-circle",task_comment:"message-square",subtask_create:"clipboard",subtask_complete:"check-circle",subtask_cancel:"alert-circle",subtask_list:"clipboard",requirement_propose:"clipboard",requirement_list:"clipboard",requirement_get:"clipboard",requirement_update:"clipboard",requirement_update_status:"check-circle",requirement_resubmit:"clipboard",requirement_comment:"message-square",list_projects:"layers",get_project:"layers",create_project:"layers",update_project:"layers",deliverable_create:"package",deliverable_search:"search",deliverable_list:"package",deliverable_update:"edit",git_status:"git-branch",git_diff:"git-branch",git_log:"book-open",git_branch:"git-branch",git_add:"git-branch",git_commit:"save",project_structure:"layers",code_stats:"bar-chart",navigate_page:"globe",new_page:"globe",close_page:"globe",select_page:"globe",list_pages:"globe",click:"target",hover:"target",fill:"terminal",fill_form:"terminal",type_text:"terminal",press_key:"terminal",take_screenshot:"camera",take_snapshot:"camera",evaluate_script:"code",wait_for:"clock",list_console_messages:"terminal",list_network_requests:"globe",lighthouse_audit:"bar-chart",agent_send_message:"message-square",agent_list_colleagues:"users",memory_save:"database",memory_search:"search",memory_list:"database",memory_update:"database",recall_activity:"book-open",notebook_upsert:"edit",kb_search:"book-open",kb_list:"book-open",kb_read:"book-open",notify_user:"megaphone",request_user_input:"message-square",request_user_approval:"check-circle",schedule_wakeup:"clock",cancel_wakeup:"clock",set_heartbeat_interval:"clock",discover_tools:"wrench",check_mailbox:"message-square",goal_create:"target",goal_update:"target",goal_status:"target",feishu_send_message:"message-square",feishu_search_docs:"search",spawn_subagent:"bot",spawn_subagents:"bot",invoke_coding_tool:"wrench",coding_tool_apply:"git-branch",generate_image:"camera",text_to_speech:"headphones",speech_to_text:"headphones",generate_video:"camera",llm_list_providers:"settings",llm_switch_model:"settings",llm_switch_default_provider:"settings",llm_add_provider:"settings",llm_edit_provider:"settings",llm_add_model:"settings",llm_get_capability_routing:"settings",llm_set_capability_routing:"settings",team_list:"users",team_status:"users",team_start:"users",team_stop:"users",team_update:"users",agent_start:"bot",agent_stop:"bot",agent_update:"bot",agent_delegate_task:"clipboard",agent_broadcast_status:"megaphone",agent_create_group_chat:"message-square",agent_list_group_chats:"message-square",agent_send_group_message:"message-square",delete_project:"layers",project_stats:"bar-chart",hub_search:"search",hub_install:"package",package_list:"package",package_install:"package",memory_delete:"database",memory_update_longterm:"database",notebook_clear:"edit",notebook_read:"edit",recall_context:"book-open",defer_mailbox_item:"message-square",drop_mailbox_item:"message-square",prioritize_mailbox_item:"message-square",delegate_message:"message-square",task_board_health:"clipboard",task_check_duplicates:"clipboard",task_cleanup_duplicates:"clipboard",workflow_list:"git-branch",workflow_create:"git-branch",workflow_update:"git-branch",workflow_delete:"git-branch",workflow_run:"git-branch",workflow_status:"git-branch",workflow_cancel:"git-branch",open_page:"globe",resize_page:"globe",drag:"target",upload_file:"file-text",emulate:"settings",handle_dialog:"message-square",get_console_message:"terminal",get_network_request:"globe"};function U(e){const n=e.includes("__")?e.split("__").pop():e,s=je[n]??je[e],r=ke[n]??ke[e]??"settings";return s?{...s,iconName:r,key:n}:{label:n.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase()),icon:"⚙",iconName:r,key:n}}function K(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function lt(e){const n=new Date(e);if(isNaN(n.getTime()))return e;const s=String(n.getMonth()+1).padStart(2,"0"),r=String(n.getDate()).padStart(2,"0"),a=String(n.getHours()).padStart(2,"0"),o=String(n.getMinutes()).padStart(2,"0"),i=String(n.getSeconds()).padStart(2,"0");return`${s}-${r} ${a}:${o}:${i}`}function ge(e,n){return e.length<=n?e:e.slice(0,n)+"…"}function _e(e){try{const n=JSON.parse(e);return JSON.stringify(n,null,2)}catch{return e}}function Ke(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,s])=>s!=null).map(([s,r])=>({key:s,value:typeof r=="string"?r:JSON.stringify(r,null,2)}))}function ct(e){if(e.tool!=="shell_execute"||!e.args||typeof e.args!="object")return null;const n=e.args.command;return typeof n=="string"?n:null}function xe(e){const n=new Set;for(let s=0;s<e.length;s++){const r=e[s];if(r.type==="tool"&&(r.info.status==="done"||r.info.status==="error"))for(let a=s-1;a>=0;a--){const o=e[a];if(o.type==="tool"&&o.info.status==="running"&&o.info.tool===r.info.tool&&!n.has(a)){n.add(a);break}}}return e.filter((s,r)=>!n.has(r))}function be(e){const n=lt(e.createdAt),s=e.createdAt,r=e.metadata;switch(e.type){case"text":return r?.isThinking?{type:"thinking",content:e.content,time:n,timestamp:s}:{type:"text",content:e.content,time:n,timestamp:s};case"status":{const a=r?.action;return a&&["chat","chat_stream","task_execution","respond_in_session"].includes(a)?null:{type:"status",content:e.content,time:n,timestamp:s}}case"error":return{type:"error",content:e.content,time:n,timestamp:s};case"tool_start":return{type:"tool",time:n,timestamp:s,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:r?.arguments,subagentLogs:r?.subagentLogs}};case"tool_end":return{type:"tool",time:n,timestamp:s,key:`ee_${e.seq}`,info:{tool:e.content,status:r?.success===!1?"error":"done",args:r?.arguments,result:r?.result,error:r?.error,durationMs:r?.durationMs,subagentLogs:r?.subagentLogs}};default:return null}}function Fe(e,n){if(e!=="task_create"&&e!=="create_task"||!n)return null;try{const s=JSON.parse(n);if(!s.task)return null;const r=s.task;return{taskId:r.id,title:r.title,description:r.description,assignedAgentId:r.assignedAgentId,priority:r.priority}}catch{return null}}function We(e,n){if(e!=="requirement_propose"||!n)return null;try{const s=JSON.parse(n);if(s.status!=="success"||!s.requirement)return null;const r=s.requirement;return r.status!=="pending"?null:{requirementId:r.id,title:r.title,description:r.description,priority:r.priority}}catch{return null}}function dt(e){const n=[];for(const s of e)if(s.phase!=="output"){if(s.phase==="start"){const r=`${s.tool}_${s.ts}`;n.push({key:r,tool:s.tool,status:"running"})}else for(let r=n.length-1;r>=0;r--)if(n[r].tool===s.tool&&n[r].status==="running"){n[r]={...n[r],status:s.success===!1?"error":"done"};break}}return n}function ze(){return t.jsxs("svg",{className:"w-3 h-3 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function ut(){return t.jsx("span",{className:"flex items-center gap-0.5",children:[0,150,300].map(e=>t.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${e}ms`,animationDuration:"1s"}},e))})}function we({item:e}){const{t:n}=E("common"),s=U(e.tool);return t.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[t.jsx(J,{name:s.iconName,size:15,className:`shrink-0 ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500":"text-green-500"}`}),t.jsxs("span",{className:`text-xs ${e.status==="running"?"activity-text-shimmer":e.status==="error"?"text-fg-tertiary":"text-fg-secondary"}`,children:[n(`execution.tools.${s.key}`,{defaultValue:s.label}),e.status==="running"?"…":""]}),e.status==="running"&&t.jsx(ze,{})]})}function Ne({activities:e,isActive:n,persistent:s}){const{t:r}=E("common"),a=dt(e),[o,i]=x.useState(!1),l=a.length>0,d=l&&a.every(p=>p.status!=="running");if(s&&d){const p=a.filter(_=>_.status==="error").length,k=a.filter(_=>_.status==="done").length;return t.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[t.jsxs("button",{onClick:()=>i(_=>!_),className:"flex items-center gap-1.5 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors select-none",children:[t.jsx("span",{className:`transition-transform duration-150 ${o?"rotate-90":""}`,children:"▶"}),t.jsx("span",{className:"font-medium",children:r("activity.step",{count:k})}),p>0&&t.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",r("activity.failed",{count:p})]}),!o&&t.jsxs("span",{className:"ml-1 flex items-center gap-1",children:[a.slice(0,5).map(_=>{const b=U(_.tool);return t.jsx(J,{name:b.iconName,size:13,className:`shrink-0 ${_.status==="error"?"text-red-500":"text-green-500"}`},_.key)}),a.length>5&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",a.length-5]})]})]}),o&&t.jsx("div",{className:"mt-2 space-y-0.5",children:a.map((_,b)=>t.jsx(we,{item:_,idx:b,total:a.length},_.key))})]})}if(!l)return t.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[t.jsx("span",{className:"mr-0.5 activity-text-shimmer",children:r("activity.thinking")}),t.jsx(ut,{})]});const c=a.filter(p=>p.status==="error").length;let u=null;for(let p=a.length-1;p>=0;p--)if(a[p].status==="running"){u=a[p];break}const h=a[a.length-1];let f;if(u){const p=U(u.tool);f=`${r(`execution.tools.${p.key}`,{defaultValue:p.label})}…`}else if(n&&d)f=r("activity.writingResponse");else{const p=U(h.tool);f=r(`execution.tools.${p.key}`,{defaultValue:p.label})}const g=!!u||n&&d;return t.jsxs("div",{className:"mb-1",children:[t.jsxs("button",{onClick:p=>{p.stopPropagation(),i(k=>!k)},className:"flex items-center gap-1.5 text-xs w-full min-w-0 select-none text-fg-tertiary hover:text-fg-secondary transition-colors",children:[t.jsx("span",{className:`shrink-0 transition-transform duration-150 ${o?"rotate-90":""}`,children:"▶"}),t.jsx("span",{className:`truncate font-medium ${g?"activity-text-shimmer":"text-fg-secondary"}`,children:f}),t.jsxs("span",{className:"shrink-0",children:["· ",r("activity.step",{count:a.length})]}),c>0&&t.jsxs("span",{className:"text-red-500 shrink-0",children:["· ",r("activity.failed",{count:c})]}),g&&t.jsx(ze,{})]}),o&&t.jsx("div",{className:"mt-1 space-y-0.5",children:a.map((p,k)=>t.jsx(we,{item:p,idx:k,total:a.length},p.key))})]})}const pt=1920,mt=10*1024*1024,Ce=5,gt=.8;function xt(e,n,s){return new Promise((r,a)=>{const o=new Image;o.onload=()=>{let{width:i,height:l}=o;if(i<=n&&l<=n){r(e);return}i>l?(l=Math.round(l*(n/i)),i=n):(i=Math.round(i*(n/l)),l=n);const d=document.createElement("canvas");d.width=i,d.height=l;const c=d.getContext("2d");if(!c){a(new Error("Failed to get canvas context"));return}c.drawImage(o,0,0,i,l),r(d.toDataURL("image/jpeg",s))},o.onerror=()=>a(new Error("Failed to load image")),o.src=e})}function ft({candidates:e,filter:n,anchorRef:s,onSelect:r,selectedIndex:a,onIndexChange:o}){const{t:i}=E("common"),[l,d]=x.useState(null),c=x.useRef(null),u=e.filter(h=>h.name.toLowerCase().includes(n));return x.useEffect(()=>{const h=s.current;if(!h)return;const f=h.getBoundingClientRect();d({top:f.top+window.scrollY-4,left:f.left+window.scrollX+8})},[s,n]),x.useEffect(()=>{if(!c.current||!l)return;if(c.current.getBoundingClientRect().top<8){const f=s.current;if(!f)return;const g=f.getBoundingClientRect();d({top:g.bottom+window.scrollY+4,left:l.left})}},[l,s]),x.useEffect(()=>{a>=u.length&&o(Math.max(0,u.length-1))},[u.length,a,o]),x.useEffect(()=>{if(!c.current)return;c.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[a]),!l||u.length===0?null:he.createPortal(t.jsxs("div",{ref:c,style:{position:"absolute",top:l.top,left:l.left,transform:"translateY(-100%)"},className:"w-60 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-[9999] max-h-48 overflow-y-auto",children:[t.jsx("div",{className:"px-2.5 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:i("commentInput.mentionHeading")}),u.map((h,f)=>t.jsxs("button",{"data-selected":f===a,onMouseDown:g=>{g.preventDefault(),r(h)},onMouseEnter:()=>o(f),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${f===a?"bg-brand-500/15 text-brand-500":"hover:bg-surface-elevated"}`,children:[t.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${h.type==="human"?"bg-green-500/20 text-green-500":"bg-brand-500/20 text-brand-500"}`,children:h.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-fg-primary font-medium",children:h.name}),t.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:h.subtitle??h.type})]}),h.type==="agent"&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${h.online?"bg-green-400":"bg-gray-500"}`})]},h.id))]}),document.body)}function ht(e){return/^\w+$/.test(e)?`@${e}`:`@[${e}]`}const Se=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function xn(e){const n=[];let s;for(Se.lastIndex=0;(s=Se.exec(e))!==null;)n.push(s[1]??s[2]);return n}function fn(e,n,s){const r=[];let a=0;const o=n.map(l=>l.name).sort((l,d)=>d.length-l.length);let i=0;for(;i<e.length;){const l=e.indexOf("@",i);if(l<0){r.push(t.jsx("span",{children:e.slice(i)},a++));break}if(l>i&&r.push(t.jsx("span",{children:e.slice(i,l)},a++)),e[l+1]==="["){const g=e.indexOf("]",l+2);if(g>l+2){const p=e.slice(l+2,g),k=n.find(_=>_.name.toLowerCase()===p.toLowerCase());r.push(t.jsxs("span",{className:`text-brand-500 font-medium ${s&&k?"cursor-pointer hover:underline":""}`,onClick:s&&k?_=>s(k,_):void 0,title:k?`${k.name} (${k.role})`:void 0,children:["@",p]},a++)),i=g+1;continue}}const d=e.slice(l+1),c=d.toLowerCase(),u=o.find(g=>c.startsWith(g.toLowerCase()));if(u){const g=n.find(p=>p.name.toLowerCase()===u.toLowerCase());r.push(t.jsxs("span",{className:`text-brand-500 font-medium ${s&&g?"cursor-pointer hover:underline":""}`,onClick:s&&g?p=>s(g,p):void 0,title:g?`${g.name} (${g.role})`:void 0,children:["@",u]},a++)),i=l+1+u.length;continue}const h=/^([\w\p{L}\p{N}]+)/u,f=d.match(h);if(f){const g=f[1],p=n.find(k=>k.name.toLowerCase()===g.toLowerCase());r.push(t.jsxs("span",{className:`text-brand-500 font-medium ${s&&p?"cursor-pointer hover:underline":""}`,onClick:s&&p?k=>s(p,k):void 0,title:p?`${p.name} (${p.role})`:void 0,children:["@",g]},a++)),i=l+1+g.length;continue}r.push(t.jsx("span",{children:"@"},a++)),i=l+1}return r.length>0?r:[t.jsx("span",{children:e},0)]}function hn({agents:e,humans:n,onSubmit:s,placeholder:r,replyTo:a,onCancelReply:o}){const{t:i}=E("common"),[l,d]=x.useState(""),[c,u]=x.useState(!1),[h,f]=x.useState(null),[g,p]=x.useState(!1),[k,_]=x.useState(""),[b,m]=x.useState([]),[v,j]=x.useState(0),[C,R]=x.useState([]),[z,D]=x.useState(!1),A=x.useRef(null),L=x.useRef(null),B=x.useRef(null),G=x.useMemo(()=>{const y=(n??[]).map(w=>({id:w.id,name:w.name,type:"human",subtitle:w.role}));for(const w of e)y.push({id:w.id,name:w.name,type:"agent",subtitle:w.role,online:w.status==="idle"||w.status==="working"});return y},[e,n]),q=G.filter(y=>y.name.toLowerCase().includes(k)),I=x.useCallback(y=>{const w=Array.from(y).filter(S=>S.type.startsWith("image/"));if(w.length!==0)for(const S of w){if(S.size>mt)continue;const M=new FileReader;M.onload=()=>{const Z=M.result;xt(Z,pt,gt).then($=>{R(de=>de.length>=Ce?de:[...de,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:$,name:S.name}])})},M.readAsDataURL(S)}},[]),oe=x.useCallback(y=>{R(w=>w.filter(S=>S.id!==y))},[]),ie=x.useCallback(y=>{const w=y.clipboardData?.files;if(w&&w.length>0){const S=Array.from(w).filter(M=>M.type.startsWith("image/"));S.length>0&&(y.preventDefault(),I(S))}},[I]),Q=x.useCallback(y=>{y.preventDefault(),D(!1);const w=y.dataTransfer?.files;w&&w.length>0&&I(Array.from(w).filter(S=>S.type.startsWith("image/")))},[I]),le=x.useCallback(y=>{y.preventDefault(),D(!0)},[]),ce=x.useCallback(()=>{D(!1)},[]),H=async()=>{if(!(!l.trim()&&C.length===0)){u(!0),f(null),B.current={content:l,mentions:[...b],images:[...C]};try{await s(l,b,[...C],a?.id),d(""),m([]),R([]),B.current=null,o?.()}catch(y){f(String(y instanceof Error?y.message:y)||i("commentInput.sendFailed"))}u(!1)}},F=async()=>{if(!B.current)return;const{content:y,mentions:w,images:S}=B.current;u(!0),f(null);try{await s(y,w,S),d(""),m([]),R([]),B.current=null}catch(M){f(String(M instanceof Error?M.message:M)||i("commentInput.sendFailed"))}u(!1)},N=x.useCallback(y=>{d(w=>{const S=w.lastIndexOf("@"),M=ht(y.name);return S>=0?w.slice(0,S)+M+" ":w+M+" "}),b.includes(y.id)||m(w=>[...w,y.id]),p(!1),_(""),j(0),A.current?.focus()},[b]),V=y=>{d(y),f(null);const w=y.lastIndexOf("@");if(w>=0&&(w===0||y[w-1]===" ")){const M=y.slice(w+1).toLowerCase();if(G.some($=>$.name.toLowerCase().includes(M))){_(M),p(!0),j(0);return}}p(!1)},X=y=>{if(g&&q.length>0){const w=y.key==="ArrowUp"||y.ctrlKey&&y.key==="p",S=y.key==="ArrowDown"||y.ctrlKey&&y.key==="n",M=y.key==="Enter"||y.key==="Tab",Z=y.key==="Escape";if(w){y.preventDefault(),j($=>($-1+q.length)%q.length);return}if(S){y.preventDefault(),j($=>($+1)%q.length);return}if(M){y.preventDefault();const $=q[v];$&&N($);return}if(Z){y.preventDefault(),p(!1);return}}y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),H())},rt=x.useCallback(()=>{setTimeout(()=>p(!1),200)},[]);return t.jsxs("div",{className:"relative",onDragOver:le,onDragLeave:ce,onDrop:Q,children:[z&&t.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-brand-500/10 rounded-lg border-2 border-dashed border-brand-500",children:t.jsx("span",{className:"text-sm text-brand-500 font-medium",children:i("commentInput.dragDropHint")})}),g&&t.jsx(ft,{candidates:G,filter:k,anchorRef:A,onSelect:N,selectedIndex:v,onIndexChange:j}),t.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[a&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:a.authorName}),t.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:a.content})]}),t.jsx("button",{onClick:o,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),b.length>0&&t.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:b.map(y=>{const w=G.find(S=>S.id===y);return t.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded-full ${w?.type==="human"?"bg-green-500/15 text-green-500":"bg-brand-500/15 text-brand-500"}`,children:["@",w?.name??y,t.jsx("button",{onClick:()=>m(S=>S.filter(M=>M!==y)),className:"hover:text-red-400",children:"×"})]},y)})}),t.jsx("textarea",{ref:A,value:l,onChange:y=>V(y.target.value),onKeyDown:X,onBlur:rt,onPaste:ie,placeholder:r??i("commentInput.placeholder"),rows:2,className:"w-full px-2.5 py-2 text-xs bg-transparent text-fg-primary placeholder-fg-tertiary outline-none resize-none"}),C.length>0&&t.jsx("div",{className:"flex items-center gap-1.5 px-2.5 pb-1.5 overflow-x-auto",children:C.map(y=>t.jsxs("div",{className:"relative group/img shrink-0",children:[t.jsx("img",{src:y.dataUrl,alt:y.name,className:"w-12 h-12 rounded-lg object-cover border border-border-default"}),t.jsx("button",{onClick:()=>oe(y.id),className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-[10px] opacity-0 group-hover/img:opacity-100 transition-opacity",title:i("commentInput.removeImage"),children:"×"})]},y.id))}),h&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[t.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:h}),t.jsxs("button",{onClick:F,disabled:c,className:"text-[11px] text-amber-500 hover:text-amber-400 font-medium transition-colors flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),i("commentInput.retry")]})]}),t.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2",children:[t.jsx("button",{type:"button",onClick:()=>L.current?.click(),disabled:c||C.length>=Ce,className:"p-1 text-fg-tertiary hover:text-brand-500 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:i("commentInput.attachImage"),children:t.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),t.jsx("input",{ref:L,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:y=>{y.target.files&&I(y.target.files),y.target.value=""}}),t.jsx("button",{onClick:H,disabled:!l.trim()&&C.length===0||c,className:"px-3 py-1 text-[11px] font-medium bg-brand-500 text-on-brand rounded-md hover:bg-brand-600 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:i(c?"commentInput.sending":"commentInput.submit")})]})]}),l.trim()&&!c&&t.jsx("div",{className:"mt-0.5 -mb-0.5 flex justify-end px-2.5 pointer-events-none select-none",children:t.jsx("span",{className:"text-[10px] text-fg-tertiary/80",children:i("common:shiftEnterHint")})}),t.jsx("p",{className:"mt-1 text-center text-[10px] text-fg-tertiary/80 select-none",children:i("aiDisclaimer")})]})}function bn(e){const n={id:e.id,sender:"user",text:e.text,time:e.time,rawCreatedAt:e.rawCreatedAt};return e.chips&&e.chips.length>0&&(n.chips=e.chips),e.images&&e.images.length>0&&(n.images=e.images),e.replyTo&&(n.replyToId=e.replyTo.id,n.replyToSender=e.replyTo.sender,n.replyToText=e.replyTo.text),n}function bt(e,n){return!!e&&n==="agent"}const yt=24e3,vt=200;function yn(e,n,s=yt){const r=(e??"")+n;return r.length<=s?r:r.slice(r.length-s)}function vn(e,n,s=vt){const r=[...e??[],n];return r.length<=s?r:r.slice(r.length-s)}function Ge(e){return!!e.text?.trim()||(e.segments??[]).some(n=>n.type==="text"&&(n.content||n.thinking)||n.type==="tool")}function jn(e,n){return!!(e.sender==="user"||Ge(e)||(e.activities?.length??0)>0||(e.images?.length??0)>0||e.emptyReply===!0||n&&!e.isStopped)}function jt(e,n=8){for(let s=e.length-1;s>=Math.max(0,e.length-n);s--){const r=e[s];if(r.isStreaming&&!r.isStopped)return!0}return!1}function ye(e){if(!e||e.length===0)return e;let n=!1;const s=e.map(r=>r.type==="tool"&&r.status==="running"?(n=!0,{...r,status:"stopped"}):r);return n?s:e}function He(e,n){if(!Ge(e)&&n!=="done")return null;const r={...e,isStreaming:!1,segments:ye(e.segments)};switch(n){case"done":return{...r,isStopped:!1,isError:!1};case"stopped":return{...r,isStopped:!0,isError:!1};case"error":return{...r,isStopped:!0,isError:!0}}}function kn(e){const n=[...e];for(let s=n.length-1;s>=0;s--)if(n[s].sender==="agent"&&!n[s].isStopped&&!n[s].isError){const r=He(n[s],"stopped");r===null?n.splice(s,1):n[s]=r;break}return n}function _n(e,n){if(n){const s=e.findIndex(r=>r.id===n);if(s>=0){const r=e[s],a=ye(r.segments);if(!r.isStreaming&&a===r.segments)return e;const o=[...e];return o[s]={...r,isStreaming:!1,segments:a},o}}return kt(e)}function kt(e){return jt(e)?e.map(n=>n.sender!=="agent"||!n.isStreaming||n.isStopped?n:{...n,isStreaming:!1,segments:ye(n.segments)}):e}function wn(e,n,s){return!n||!s||n===s?e:e.some(r=>r.id===s)?e.filter(r=>r.id!==n):e.map(r=>r.id===n?{...r,id:s}:r)}function Nn(e){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.sender==="agent"&&s.isStreaming)return n}return-1}function Cn(e){if(!e.sendSessionId)return!1;const n=e.liveSessions;return!n||n.size===0?!1:n.has(e.sendSessionId)}function Sn(e){const n=e.liveSessions;return!n||n.size===0||!e.sessionId?!0:!n.has(e.sessionId)&&!n.has(e.placeholderId)}function Tn(e,n="stopped"){for(let s=e.length-1;s>=0;s--){const r=e[s];if(r.sender==="agent"&&r.isStreaming&&!r.isStopped){const a=He(r,n);if(a===null)return e.filter((i,l)=>l!==s);const o=[...e];return o[s]=a,o}}return e}function En(e,n){if(e.some(o=>o.id===n.id))return e;const s=n.rawCreatedAt?Date.parse(n.rawCreatedAt):NaN;if(!Number.isFinite(s)||e.length===0)return[...e,n];let r=e.length;for(;r>0;){const o=e[r-1],i=o.rawCreatedAt?Date.parse(o.rawCreatedAt):NaN;if(!Number.isFinite(i)||i<=s)break;r--}if(r===e.length)return[...e,n];const a=e.slice();return a.splice(r,0,n),a}function Mn(e,n){if(!n)return e;const s=e[e.length-1];return s?.type==="text"?[...e.slice(0,-1),{...s,thinking:(s.thinking??"")+n}]:[...e,{type:"text",content:"",thinking:n,createdAt:new Date().toISOString()}]}function An(e,n){if(!n)return e;const s=e[e.length-1];return s?.type==="text"?[...e.slice(0,-1),{...s,content:s.content+n}]:[...e,{type:"text",content:n,createdAt:new Date().toISOString()}]}const _t=/\n*<!--\s*notify_context:\s*([\s\S]*?)-->/g;function ve(e){if(!e.includes("notify_context"))return{cleaned:e};let n;const s=e.match(/<!--\s*notify_context:\s*([\s\S]*?)-->/);if(s?.[1]){const r=s[1].match(/priority\s*=\s*(\w+)/i);r&&(n=r[1])}return{cleaned:e.replace(_t,"").trimEnd(),priority:n}}const wt=/(?:<thinking>| thinking)[\s\S]*?<\/thinking>/g,Nt=/(?:<thinking>| thinking| thinking| think)[\s\S]*?<\/think>/g;function Ln(e){return e.replace(wt,"").replace(Nt,"")}function Ct(e,n,s){if(e.type!=="tool"){const{cleaned:l}=ve(e.content??"");return{type:"text",content:l,thinking:e.thinking,createdAt:e.createdAt}}const r=s?.type==="tool"&&s.tool===e.tool?s:void 0,a=e.subagentLogs?.length??0,o=r?.subagentLogs?.length??0,i=a>=o?e.subagentLogs:r?.subagentLogs;return{type:"tool",key:`${e.tool}_${n}`,tool:e.tool,status:e.status,args:e.arguments,result:e.result,error:e.error,durationMs:e.durationMs,createdAt:e.createdAt,...i?.length?{subagentLogs:i}:{}}}function Ve(e,n){const s=(n??[]).filter(a=>a.type==="tool");let r=0;return e.map((a,o)=>{const i=a.type==="tool"?s[r++]:void 0;return Ct(a,o,i)})}const te=new Map,St=2e3;function Xe(e){if(!e)return"";const n=te.get(e);if(n!==void 0)return n;const s=new Date(e),r=isNaN(s.getTime())?"":s.toLocaleTimeString();return te.size>=St&&te.clear(),te.set(e,r),r}function Rn(e){const n={id:e.id,sender:e.role==="user"?"user":"agent",text:e.content,time:Xe(e.createdAt),rawCreatedAt:e.createdAt,agentId:e.role!=="user"?e.agentId:void 0,sessionId:e.sessionId};if(e.metadata?.segmentsTruncated===!0&&(n.needsDetail=!0),e.role!=="user"&&e.metadata?.segments&&e.metadata.segments.length>0&&(n.segments=Ve(e.metadata.segments)),e.role==="assistant"&&(e.content==="[cancelled]"||e.content==="[Stream cancelled]")&&(n.text=""),(e.metadata?.isError||e.role==="assistant"&&e.content.startsWith("⚠"))&&(n.isError=!0),e.metadata?.emptyReply===!0&&(n.emptyReply=!0,n.isStopped||(n.isError=!0)),e.metadata?.isStreaming&&(n.isStreaming=!0),e.metadata?.isStopped&&!e.metadata?.isStreaming&&(n.isStopped=!0),e.metadata?.images?.length&&(n.images=e.metadata.images),e.metadata?.notifyUser&&(n.isNotification=!0,n.notifyPriority=e.metadata.priority,e.metadata.taskId&&(n.taskId=e.metadata.taskId),e.metadata.requirementId&&(n.requirementId=e.metadata.requirementId)),n.text.includes("<!-- notify_context:")){const{cleaned:s,priority:r}=ve(n.text);n.text=s,r&&!n.notifyPriority&&(n.notifyPriority=r),n.isNotification=!0}if(e.metadata?.activityLog&&(n.isActivityLog=!0,n.activityType=e.metadata.activityType,n.outcome=e.metadata.outcome,n.mailboxItemId=e.metadata.mailboxItemId,n.taskId=e.metadata.taskId,n.requirementId=e.metadata.requirementId,!n.outcome&&n.text.startsWith("[ACTIVITY:"))){const s=n.text.lastIndexOf(" → ");s!==-1&&(n.outcome=n.text.slice(s+3)),n.text=n.text.replace(/^\[ACTIVITY:\s*\w+\]\s*/,"")}if(e.metadata?.replyToId&&(n.replyToId=e.metadata.replyToId,n.replyToSender=e.metadata.replyToSender,n.replyToText=e.metadata.replyToText,n.text=Ye(n.text,n.replyToSender,n.replyToText)),e.role==="user"){const s=ot(e.metadata?.chips);s&&(n.chips=s)}return n}function Ye(e,n,s){if(!e||!n||!s)return e;const r=`> **${n}**: ${s}
2
2
 
3
3
  `;return e.startsWith(r)?e.slice(r.length):e}function In(e,n={}){if(n.expectedMessageId)for(let r=e.length-1;r>=0;r--){const a=e[r];if(a.id===n.expectedMessageId&&a.sender==="agent"&&!a.isError)return a}let s=-1;for(let r=e.length-1;r>=0;r--)if(e[r].sender==="user"){s=r;break}for(let r=e.length-1;r>=0;r--){const a=e[r];if(a.sender!=="agent")continue;return a.isStreaming?a:a.isError?void 0:!(a.text?.trim()||(a.segments??[]).some(i=>i.type==="text"&&((i.content??"").trim()||i.thinking)||i.type==="tool"))||n.allowCurrentTurnPartial&&s>=0&&r>s?a:void 0}}function $n(e){const n=e?.messageId||e?.streamId;return n?`reattach_${n}`:null}function Dn(e,n){const s=e.senderType==="system"||e.senderType==="agent"&&e.text.startsWith("⚠"),r=e.senderType==="human"&&(!n||e.senderId===n);let a=e.text;r&&e.replyToId&&e.replyToSender&&e.replyToText&&(a=Ye(a,e.replyToSender,e.replyToText));const o={id:e.id,sender:r?"user":"agent",text:a,time:Xe(e.createdAt),rawCreatedAt:e.createdAt,agentName:r?void 0:e.senderName,agentId:r?void 0:e.senderId,isError:s,replyToId:e.replyToId,replyToSender:e.replyToSender,replyToText:e.replyToText},i=e.metadata;if(i?.images?.length&&(o.images=i.images),i&&e.senderType==="agent"){const l=[];if(i.thinking?.length&&l.push({type:"text",content:"",thinking:i.thinking.join(`
4
4
 
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownMessage-DwxvYN4X.js","assets/index-BHu6brRf.js","assets/index-CzHSs0Vd.css"])))=>i.map(i=>d[i]);
2
- import{j as a,r as i,_ as f}from"./index-BHu6brRf.js";const x=i.lazy(()=>f(()=>import("./MarkdownMessage-DwxvYN4X.js"),__vite__mapDeps([0,1,2])).then(e=>({default:e.MarkdownMessage}))),b=new Set(["ts","tsx","js","jsx","mjs","cjs","py","go","rs","java","kt","kts","c","cc","cpp","cxx","h","hpp","hxx","cs","rb","php","swift","scala","sh","bash","zsh","fish","ps1","sql","yaml","yml","toml","xml","css","scss","less","vue","svelte","graphql","gql","proto","dockerfile","makefile","cmake","rsx","r","lua","pl","pm","ex","exs","erl","hs","clj","zig","nim","dart","gradle","tf","hcl"]);function v(e){const t=e.split(/[/\\]/).pop()?.toLowerCase()||"";if(t==="dockerfile"||t==="makefile")return"code";const r=t.includes(".")?t.split(".").pop():"";switch(r){case"md":case"markdown":return"markdown";case"html":case"htm":return"html";case"json":case"jsonc":return"json";case"csv":case"tsv":return"csv";default:return r&&b.has(r)?"code":r?"text":void 0}}function w(e){const t=e.trimStart();if(/^<!doctype\s+html/i.test(t)||/^<html[\s>]/i.test(t))return"html";if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(e),"json"}catch{}}function S(e){if(e.format)return e.format;if(e.reference){const t=v(e.reference);if(t)return t}if(e.content){const t=w(e.content);if(t)return t}return e.reference?"text":"markdown"}function y({content:e,className:t,onSelection:r}){const c=i.useRef(null),[l,h]=i.useState(null);i.useEffect(()=>{const o=d=>{d.data?.type==="__htmlpreview_height"&&typeof d.data.height=="number"&&h(d.data.height),d.data?.type==="__htmlpreview_selection"&&r&&r(d.data)};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[r]);const m=`<script>
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownMessage-DVfFMzM9.js","assets/index-TPf50ZeO.js","assets/index-CzHSs0Vd.css"])))=>i.map(i=>d[i]);
2
+ import{j as a,r as i,_ as f}from"./index-TPf50ZeO.js";const x=i.lazy(()=>f(()=>import("./MarkdownMessage-DVfFMzM9.js"),__vite__mapDeps([0,1,2])).then(e=>({default:e.MarkdownMessage}))),b=new Set(["ts","tsx","js","jsx","mjs","cjs","py","go","rs","java","kt","kts","c","cc","cpp","cxx","h","hpp","hxx","cs","rb","php","swift","scala","sh","bash","zsh","fish","ps1","sql","yaml","yml","toml","xml","css","scss","less","vue","svelte","graphql","gql","proto","dockerfile","makefile","cmake","rsx","r","lua","pl","pm","ex","exs","erl","hs","clj","zig","nim","dart","gradle","tf","hcl"]);function v(e){const t=e.split(/[/\\]/).pop()?.toLowerCase()||"";if(t==="dockerfile"||t==="makefile")return"code";const r=t.includes(".")?t.split(".").pop():"";switch(r){case"md":case"markdown":return"markdown";case"html":case"htm":return"html";case"json":case"jsonc":return"json";case"csv":case"tsv":return"csv";default:return r&&b.has(r)?"code":r?"text":void 0}}function w(e){const t=e.trimStart();if(/^<!doctype\s+html/i.test(t)||/^<html[\s>]/i.test(t))return"html";if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(e),"json"}catch{}}function S(e){if(e.format)return e.format;if(e.reference){const t=v(e.reference);if(t)return t}if(e.content){const t=w(e.content);if(t)return t}return e.reference?"text":"markdown"}function y({content:e,className:t,onSelection:r}){const c=i.useRef(null),[l,h]=i.useState(null);i.useEffect(()=>{const o=d=>{d.data?.type==="__htmlpreview_height"&&typeof d.data.height=="number"&&h(d.data.height),d.data?.type==="__htmlpreview_selection"&&r&&r(d.data)};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[r]);const m=`<script>
3
3
  (function(){
4
4
  function getXPath(el){
5
5
  if(!el||el.nodeType!==1)return'';
@@ -1 +1 @@
1
- import{u as de,r as u,h as R,V as ue,$ as fe,k as N,j as r}from"./index-BHu6brRf.js";const G=50*1024*1024,q=new Set(["markdown","html"]);function be(e){return e||"markdown"}function he(e){return q.has(be(e))}class S extends Error{constructor(t){super(t),this.name="DeliverableShareError"}}class Q extends S{constructor(){super("需要登录 Markus Hub 账号后才能分享产出物。"),this.name="NotLoggedIntoHubError"}}class pe extends S{bytes;limit;constructor(t,a){super(`产出物文件大小 ${t} 字节超过上限 ${a} 字节(50MB),请压缩或拒绝分享。`),this.name="DeliverableTooLargeError",this.bytes=t,this.limit=a}}class me extends S{status;constructor(t,a){super(`Hub 请求失败 (HTTP ${t}): ${a}`),this.name="HubApiError",this.status=t}}function ge(e){const t=e.replace(/\s+/g,"");if(!t)return 0;let a=0;return t.endsWith("==")?a=2:t.endsWith("=")&&(a=1),Math.floor(t.length*3/4)-a}function C(e,t){const a=e&&typeof e=="object"?e:{},l=a.share??a.deliverable??{},s=m=>a[m]??l[m],i=s("id")??s("shareId")??"",c=s("slug"),o=c!=null?String(c):void 0,d=s("url")??s("shareUrl");let b=null;d!=null?b=String(d):o&&t&&(b=`${t.replace(/\/+$/,"")}/deliverable/${encodeURIComponent(o)}`);const f=s("reason")??s("rejectNote"),p=s("localDeliverableId")??s("localId");return{id:String(i),slug:o,visibility:s("visibility")??"public",status:s("status")??"pending_review",url:b,reason:f!=null?String(f):null,localId:p!=null?String(p):null}}class xe{basePath;fetchImpl;hubOrigin;constructor(t){this.getHubToken=t.getHubToken,this.hubOrigin=t.hubUrl,this.basePath=(t.proxyBasePath??"/api/hub").replace(/\/+$/,""),this.fetchImpl=t.fetch??(globalThis.fetch?globalThis.fetch.bind(globalThis):(()=>{throw new Error("fetch unavailable")}))}getHubToken;isHubLoggedIn(){return!!this.getHubToken()}assertHubLoggedIn(){if(!this.getHubToken())throw new Q}async doFetch(t,a){const l=this.getHubToken(),s={"Content-Type":"application/json",...a.headers};l&&(s.Authorization=`Bearer ${l}`);const i=await this.fetchImpl(`${this.basePath}${t}`,{...a,headers:s,credentials:"include"});let c=null;try{c=await i.json()}catch{c=null}if(!i.ok){const o=c&&typeof c=="object"&&"error"in c?String(c.error):i.statusText||`HTTP ${i.status}`;throw new me(i.status,o)}return{status:i.status,data:c}}async publish(t){this.assertHubLoggedIn();const a=t.fileSizeBytes??(t.fileBase64?ge(t.fileBase64):0);if(a>G)throw new pe(a,G);const l={localDeliverableId:t.localId,visibility:t.visibility,title:t.title,summary:t.summary,tags:t.tags,filename:t.filename,format:t.format,producerAgent:{id:t.producerAgent.id,name:t.producerAgent.name,source:t.producerAgent.source}};t.content&&(l.content=t.content),t.fileBase64&&(l.fileBase64=t.fileBase64);const{data:s}=await this.doFetch("/deliverables/publish",{method:"POST",body:JSON.stringify(l)});return C(s,this.hubOrigin)}async pollStatus(t){this.assertHubLoggedIn();const{data:a}=await this.doFetch(`/deliverables/status?localId=${encodeURIComponent(t)}`,{method:"GET"});return C(a,this.hubOrigin)}async listMine(){this.assertHubLoggedIn();const{data:t}=await this.doFetch("/deliverables/mine",{method:"GET"}),a=t&&typeof t=="object"?t:{};return(Array.isArray(a.shares)?a.shares:[]).map(s=>C(s,this.hubOrigin))}async revoke(t){this.assertHubLoggedIn();const{data:a}=await this.doFetch("/deliverables/revoke",{method:"POST",body:JSON.stringify({localId:t})});return{...C(a,this.hubOrigin),status:"revoked",url:null}}}function ye(e,t){return new xe({getHubToken:e,hubUrl:t,proxyBasePath:"/api/hub"})}const ve=/\.(png|jpe?g|gif|webp|svg|bmp|avif|ico)$/i,ke=/\.(mp4|webm|mp3|wav|ogg|m4a|mov|avi|mkv|flac)$/i;function X(e){return ve.test(e)?"image":ke.test(e)?"media":"other"}function je(e){return e.replace(/^file:\/\//i,"").replace(/^file:/i,"")}function J(e){const t=e.match(/!?\[[^\]]*\]\(([^)]+)\)/);if(t)return t[1].trim().split(/\s+(?="|')/)[0].trim()||null;const a=e.match(/(?:src|href|poster)\s*=\s*["']([^"']+)["']/i);return a?a[1]:null}function Z(e){return!e||/^(https?:|data:|mailto:|tel:|#)/i.test(e)||e.startsWith("//")?!1:(e.startsWith("/api/files/"),!0)}function Y(e,t){if(!e)return null;const a=e.trim(),l=a.match(/^\/api\/files\/(?:image|stream|preview)\?path=([^&]+)/i);if(l)try{return decodeURIComponent(l[1])||null}catch{return l[1]||null}return/^file:\/\//i.test(a)?je(a).replace(/\\/g,"/"):/^[a-zA-Z]:[\\/]/.test(a)?a.replace(/\\/g,"/"):a.startsWith("/")?a:t&&(a.startsWith("./")||a.startsWith("../")||!a.includes("://"))?`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${a.replace(/^\.\//,"").replace(/\\/g,"/")}`:null}function we(e,t){const a=[],l=new Set,s=/!?\[[^\]]*\]\(([^)\s]+(?:\s+["'][^"']*["'])?)\)/g;for(const c of e.matchAll(s)){const o=c[0],d=J(o);if(!d||!Z(d))continue;const b=Y(d,t);!b||l.has(o)||(l.add(o),a.push({raw:o,localPath:b,kind:X(b.split("?")[0])}))}const i=/<[a-zA-Z][^>]*(?:src|href|poster)\s*=\s*["'][^"']+["'][^>]*>/gi;for(const c of e.matchAll(i)){const o=c[0],d=J(o);if(!d||!Z(d))continue;const b=Y(d,t);!b||l.has(o)||(l.add(o),a.push({raw:o,localPath:b,kind:X(b.split("?")[0])}))}return{refs:a,baseDir:t??""}}function Ne(e,t){let a=e;for(const[l,s]of t){const i=Se(l,s);a=a.split(l).join(i)}return a}function Se(e,t){const a=e.match(/^(!?\[[^\]]*\])\([^)]*\)$/);if(a)return`${a[1]}(${t})`;const l=e.match(/(src|href|poster)(\s*=\s*)(["'])[^"']*\3/i);return l?e.replace(/(src|href|poster)(\s*=\s*)(["'])[^"']*\3/i,`${l[1]}${l[2]}${l[3]}${t}${l[3]}`):t}function Ve(e,t){return/^https?:\/\//i.test(e)?e:`${t.replace(/\/+$/,"")}${e.startsWith("/")?"":"/"}${e}`}function He(e,t,a){const l=new Map,s=new Map(e.map(i=>[i.localPath,i]));for(const i of t){if(!i.key)continue;const c=s.get(i.key);!c||!i.url||l.set(c.raw,Ve(i.url,a))}return l}async function Ie(e){try{const t=N.files.streamUrl(e),a=await fetch(t).then(d=>d.ok?d.blob():null);if(!a)return null;const l=await a.arrayBuffer(),s=new Uint8Array(l);let i="";const c=32768;for(let d=0;d<s.length;d+=c)i+=String.fromCharCode.apply(null,Array.from(s.subarray(d,d+c)));const o=e.split("/").pop()||"media";return{base64:btoa(i),filename:o}}catch{return null}}async function Te(e,t){const a=new Map;if(e.length===0)return a;const l=[];for(const c of e){const o=await Ie(c.localPath);o&&l.push({key:c.localPath,filename:o.filename,base64:o.base64})}if(l.length===0)return a;const{files:s,errors:i}=await R.uploadMediaBatch(l);return i.length>0&&console.warn("[deliverable-share] media upload errors:",i),He(e,s,t)}async function $e(e,t,a){if(!e||t==="directory"||e.startsWith("http://")||e.startsWith("https://"))return{};try{const l=await N.files.preview(e);if((l.type==="text"||l.type==="markdown"||l.type==="html"||l.type==="json"||l.type==="csv")&&typeof l.content=="string"){if(!(l.type==="markdown"||l.type==="html"))return{content:l.content};const i=e.replace(/[/\\]/g,"/").split("/").slice(0,-1).join("/"),{refs:c}=we(l.content,i);if(c.length===0)return{content:l.content};const o=await Te(c,a);return o.size===0?{content:l.content}:{content:Ne(l.content,o),uploadedMedia:o.size}}if(l.type==="image"||l.type==="audio"||l.type==="video"||l.type==="binary"){const s=l.streamUrl||(l.path?N.files.streamUrl(l.path):N.files.streamUrl(e)),c=await(await fetch(s).then(f=>f.blob())).arrayBuffer(),o=new Uint8Array(c);let d="";const b=32768;for(let f=0;f<o.length;f+=b)d+=String.fromCharCode.apply(null,Array.from(o.subarray(f,f+b)));return{fileBase64:btoa(d)}}return{}}catch{return{}}}function Ee({item:e,onClose:t,onShared:a,service:l}){const{t:s}=de(["deliverables","common"]),i=u.useMemo(()=>l??ye(ue,R.getUrl()),[l]),[c,o]=u.useState(()=>i?i.isHubLoggedIn():null),[d,b]=u.useState(!1),[f,p]=u.useState(()=>{const n=e.shareStatus;return n==="published"?"published":n==="pending_review"?"pending_review":n==="rejected"?"rejected":"form"}),[m,M]=u.useState("public"),[V,ee]=u.useState(e.title||""),[E,te]=u.useState(e.summary||""),[x,L]=u.useState(Array.isArray(e.tags)?[...e.tags]:[]),[k,P]=u.useState(""),[A,re]=u.useState(null),[H,U]=u.useState(!1),[I,g]=u.useState(null),F=u.useRef(a);F.current=a;const y=u.useCallback(n=>{re(n);const h=n.status;p(h==="published"?"published":h==="rejected"?"rejected":h==="revoked"?"revoked":h==="pending_review"?"pending_review":"form"),F.current?.(n)},[]);u.useEffect(()=>{o(i.isHubLoggedIn())},[i]);const se=u.useCallback(async()=>{b(!0),g(null);try{await fe({force:!0}),o(i.isHubLoggedIn())}catch{o(i.isHubLoggedIn())}finally{b(!1)}},[i]),B=u.useCallback(()=>{const n=k.trim().replace(/^#/,"");n&&!x.includes(n)&&L(h=>[...h,n]),P("")},[k,x]),ae=u.useCallback(n=>{L(h=>h.filter(v=>v!==n))},[]),le=u.useCallback(n=>{n.key==="Enter"||n.key===","?(n.preventDefault(),B()):n.key==="Backspace"&&!k&&x.length&&L(h=>h.slice(0,-1))},[B,k,x.length]),D=u.useCallback(()=>{const n=A?.url??e.shareUrl;n&&navigator.clipboard?.writeText(n).then(()=>{U(!0),setTimeout(()=>U(!1),1500)}).catch(()=>{})},[A,e.shareUrl]),ne=u.useCallback(async()=>{if(!he(e.format)){g(`分享仅支持 ${[...q].join(" / ")} 格式`);return}g(null),p("busy");try{const n=e.reference.replace(/[/\\]/g,"/").split("/").pop()||"deliverable",h=R.getUrl(),{content:v,fileBase64:ie,uploadedMedia:z}=await $e(e.reference,e.type,h);z&&console.info(`[deliverable-share] uploaded ${z} local media reference(s) to Hub`);const j=e.agentId??"";let O=j;if(j)try{const{agents:oe}=await N.agents.list({lean:!0}),K=oe.find(ce=>ce.id===j);K&&(O=K.name||j)}catch{}const w=await i.publish({localId:e.id,title:V.trim()||e.title,summary:E.trim(),tags:x,visibility:m,filename:n,format:e.format||"markdown",content:v,fileBase64:ie,producerAgent:{id:j,name:O,source:"local"}});y(w),w.status==="rejected"?g(typeof w.reason=="string"&&w.reason?w.reason:"分享被拒绝"):t()}catch(n){if(p("form"),n instanceof Q){o(!1);return}g(n instanceof S||n instanceof Error?n.message:String(n))}},[i,e,V,E,x,m,y]),_=u.useCallback(async()=>{g(null);try{const n=await i.revoke(e.id);y({...n,status:"revoked",url:null})}catch(n){g(n instanceof S?n.message:String(n))}},[i,e.id,y]),W=u.useCallback(()=>{p("form"),g(null)},[]);u.useEffect(()=>{if(f!=="pending_review")return;let n=!1;const h=setInterval(async()=>{try{const v=await i.pollStatus(e.id);if(n)return;v.status!=="pending_review"&&y(v)}catch{}},8e3);return()=>{n=!0,clearInterval(h)}},[f,i,e.id,y]),u.useEffect(()=>{const n=h=>{h.key==="Escape"&&t()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t]);const T=m==="link",$=A?.url??e.shareUrl;return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[r.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-surface-primary rounded-2xl shadow-2xl border border-border-default w-full max-w-md max-h-[85vh] overflow-y-auto",onClick:n=>n.stopPropagation(),children:[r.jsxs("div",{className:"sticky top-0 bg-surface-primary/95 backdrop-blur-sm border-b border-border-default px-5 py-4 flex items-center justify-between rounded-t-2xl z-10",children:[r.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:s("deliverables:share.title",{defaultValue:"分享到 Markus Hub"})}),r.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsx("div",{className:"px-5 py-4 space-y-4",children:c===!1?r.jsxs("div",{className:"space-y-4 py-2",children:[r.jsxs("div",{className:"flex items-start gap-3 rounded-xl bg-amber-500/10 border border-amber-500/25 p-3",children:[r.jsx("span",{className:"text-lg",children:"🔑"}),r.jsx("p",{className:"text-sm text-fg-secondary",children:s("deliverables:share.needHubLogin",{defaultValue:"需登录 Markus Hub 账号后才能分享产出物。"})})]}),r.jsx("button",{onClick:()=>{se()},disabled:d,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-on-brand hover:bg-brand-500 transition-colors disabled:opacity-60",children:d?s("deliverables:share.loggingIn",{defaultValue:"正在打开登录…"}):s("deliverables:share.loginHub",{defaultValue:"登录 Markus Hub 账号"})}),r.jsx("p",{className:"text-[11px] text-fg-tertiary",children:s("deliverables:share.loginHint",{defaultValue:"解锁后将支持一键公开/链接分享产出物。"})})]}):r.jsx(r.Fragment,{children:f==="published"?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-green-500/15 text-green-500 font-medium",children:s("deliverables:share.published",{defaultValue:"已发布"})}),r.jsx("span",{className:"text-[11px] text-fg-tertiary",children:m==="link"?s("deliverables:share.linkVisibility",{defaultValue:"有链接可见"}):s("deliverables:share.publicVisibility",{defaultValue:"公开"})})]}),$?r.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[r.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:$}),r.jsx("button",{onClick:D,className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${H?"bg-green-500/20 text-green-500":"bg-brand-600/20 text-brand-500 hover:bg-brand-600/30"}`,children:H?s("common:copied",{defaultValue:"已复制"}):s("common:copy",{defaultValue:"复制链接"})})]}):r.jsx("p",{className:"text-xs text-fg-tertiary",children:s("deliverables:share.urlPending",{defaultValue:"链接生成中,稍后刷新查看…"})}),r.jsx("button",{onClick:()=>{_()},className:"w-full px-3 py-2 text-xs font-medium rounded-lg text-red-500 border border-red-500/30 hover:bg-red-500/10 transition-colors",children:s("deliverables:share.revoke",{defaultValue:"取消分享"})})]}):f==="pending_review"?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-amber-500 animate-pulse"}),r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-amber-500/15 text-amber-500 font-medium",children:s("deliverables:share.pendingReview",{defaultValue:"审核中"})}),r.jsx("span",{className:"text-[11px] text-fg-tertiary",children:m==="link"?s("deliverables:share.linkVisibility",{defaultValue:"有链接可见"}):s("deliverables:share.publicVisibility",{defaultValue:"公开"})})]}),r.jsx("p",{className:"text-sm text-fg-secondary",children:s("deliverables:share.pendingHint",{defaultValue:"你的产出物已公开,其他人现在就能通过链接访问。管理员审核通过后,内容将进入搜索引擎收录。"})}),$?r.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[r.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:$}),r.jsx("button",{onClick:D,className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${H?"bg-green-500/20 text-green-500":"bg-brand-600/20 text-brand-500 hover:bg-brand-600/30"}`,children:H?s("common:copied",{defaultValue:"已复制"}):s("common:copy",{defaultValue:"复制链接"})})]}):null,r.jsx("button",{onClick:()=>{_()},className:"w-full px-3 py-2 text-xs font-medium rounded-lg text-red-500 border border-red-500/30 hover:bg-red-500/10 transition-colors",children:s("deliverables:share.revoke",{defaultValue:"取消分享"})})]}):f==="rejected"?r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-red-500/15 text-red-500 font-medium",children:s("deliverables:share.rejected",{defaultValue:"已拒绝"})})}),I&&r.jsx("div",{className:"rounded-lg bg-red-500/10 border border-red-500/25 px-3 py-2 text-xs text-red-500",children:I}),r.jsx("button",{onClick:W,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-on-brand hover:bg-brand-500 transition-colors",children:s("deliverables:share.resubmit",{defaultValue:"重新提交"})})]}):f==="revoked"?r.jsxs("div",{className:"space-y-3",children:[r.jsx("p",{className:"text-sm text-fg-secondary",children:s("deliverables:share.revoked",{defaultValue:"已取消分享,该产出物不再公开可访问。"})}),r.jsx("button",{onClick:W,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-on-brand hover:bg-brand-500 transition-colors",children:s("deliverables:share.shareAgain",{defaultValue:"重新分享"})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.visibility",{defaultValue:"可见性"})}),r.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 cursor-pointer transition-colors ${T?"border-border-default hover:bg-surface-elevated":"border-brand-500/50 bg-brand-500/5"}`,children:[r.jsx("input",{type:"radio",name:"visibility",checked:!T,onChange:()=>M("public"),className:"mt-0.5 accent-brand-500"}),r.jsxs("span",{className:"space-y-0.5",children:[r.jsx("span",{className:"block text-sm font-medium text-fg-primary",children:s("deliverables:share.public",{defaultValue:"公开(所有人可见 + 搜索引擎)"})}),r.jsx("span",{className:"block text-[11px] text-fg-tertiary",children:s("deliverables:share.publicHint",{defaultValue:"公开产出物需经 Hub 审核后发布,发布后所有人可见并参与搜索"})})]})]}),r.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 cursor-pointer transition-colors ${T?"border-brand-500/50 bg-brand-500/5":"border-border-default hover:bg-surface-elevated"}`,children:[r.jsx("input",{type:"radio",name:"visibility",checked:T,onChange:()=>M("link"),className:"mt-0.5 accent-brand-500"}),r.jsxs("span",{className:"space-y-0.5",children:[r.jsx("span",{className:"block text-sm font-medium text-fg-primary",children:s("deliverables:share.link",{defaultValue:"有链接可见"})}),r.jsx("span",{className:"block text-[11px] text-fg-tertiary",children:s("deliverables:share.linkHint",{defaultValue:"仅获得链接的人可查看,不参与搜索引擎;同样需经 Hub 审核"})})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.titleField",{defaultValue:"标题"})}),r.jsx("input",{value:V,onChange:n=>ee(n.target.value),placeholder:s("deliverables:share.titlePlaceholder",{defaultValue:"清晰、可检索的标题"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.summary",{defaultValue:"摘要"})}),r.jsx("textarea",{value:E,onChange:n=>te(n.target.value),rows:3,placeholder:s("deliverables:share.summaryPlaceholder",{defaultValue:"简要描述该产出物…"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none resize-y"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.tags",{defaultValue:"标签"})}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:x.map(n=>r.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-secondary",children:[n,r.jsx("button",{onClick:()=>ae(n),className:"text-fg-tertiary hover:text-red-500","aria-label":"remove",children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},n))}),r.jsx("input",{value:k,onChange:n=>P(n.target.value),onKeyDown:le,onBlur:B,placeholder:s("deliverables:share.tagsPlaceholder",{defaultValue:"输入标签后回车添加"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none"})]}),I&&r.jsx("div",{className:"rounded-lg bg-red-500/10 border border-red-500/25 px-3 py-2 text-xs text-red-500",children:I}),r.jsxs("button",{type:"button",onClick:()=>{ne()},disabled:f==="busy"||!V.trim(),className:"w-full px-3 py-2.5 text-sm font-medium rounded-lg bg-brand-600 text-on-brand hover:bg-brand-500 transition-colors disabled:opacity-60 flex items-center justify-center gap-2",children:[f==="busy"&&r.jsxs("svg",{className:"animate-spin",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",opacity:"0.25"}),r.jsx("path",{d:"M22 12a10 10 0 0 0-10-10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]}),f==="busy"?s("deliverables:share.sharing",{defaultValue:"分享中…"}):s("deliverables:share.shareToHub",{defaultValue:"分享到 Hub"})]})]})})})]})]})}export{Ee as D,he as a,ye as c};
1
+ import{u as de,r as u,h as R,V as ue,$ as fe,k as N,j as r}from"./index-TPf50ZeO.js";const G=50*1024*1024,q=new Set(["markdown","html"]);function be(e){return e||"markdown"}function he(e){return q.has(be(e))}class S extends Error{constructor(t){super(t),this.name="DeliverableShareError"}}class Q extends S{constructor(){super("需要登录 Markus Hub 账号后才能分享产出物。"),this.name="NotLoggedIntoHubError"}}class pe extends S{bytes;limit;constructor(t,a){super(`产出物文件大小 ${t} 字节超过上限 ${a} 字节(50MB),请压缩或拒绝分享。`),this.name="DeliverableTooLargeError",this.bytes=t,this.limit=a}}class me extends S{status;constructor(t,a){super(`Hub 请求失败 (HTTP ${t}): ${a}`),this.name="HubApiError",this.status=t}}function ge(e){const t=e.replace(/\s+/g,"");if(!t)return 0;let a=0;return t.endsWith("==")?a=2:t.endsWith("=")&&(a=1),Math.floor(t.length*3/4)-a}function C(e,t){const a=e&&typeof e=="object"?e:{},l=a.share??a.deliverable??{},s=m=>a[m]??l[m],i=s("id")??s("shareId")??"",c=s("slug"),o=c!=null?String(c):void 0,d=s("url")??s("shareUrl");let b=null;d!=null?b=String(d):o&&t&&(b=`${t.replace(/\/+$/,"")}/deliverable/${encodeURIComponent(o)}`);const f=s("reason")??s("rejectNote"),p=s("localDeliverableId")??s("localId");return{id:String(i),slug:o,visibility:s("visibility")??"public",status:s("status")??"pending_review",url:b,reason:f!=null?String(f):null,localId:p!=null?String(p):null}}class xe{basePath;fetchImpl;hubOrigin;constructor(t){this.getHubToken=t.getHubToken,this.hubOrigin=t.hubUrl,this.basePath=(t.proxyBasePath??"/api/hub").replace(/\/+$/,""),this.fetchImpl=t.fetch??(globalThis.fetch?globalThis.fetch.bind(globalThis):(()=>{throw new Error("fetch unavailable")}))}getHubToken;isHubLoggedIn(){return!!this.getHubToken()}assertHubLoggedIn(){if(!this.getHubToken())throw new Q}async doFetch(t,a){const l=this.getHubToken(),s={"Content-Type":"application/json",...a.headers};l&&(s.Authorization=`Bearer ${l}`);const i=await this.fetchImpl(`${this.basePath}${t}`,{...a,headers:s,credentials:"include"});let c=null;try{c=await i.json()}catch{c=null}if(!i.ok){const o=c&&typeof c=="object"&&"error"in c?String(c.error):i.statusText||`HTTP ${i.status}`;throw new me(i.status,o)}return{status:i.status,data:c}}async publish(t){this.assertHubLoggedIn();const a=t.fileSizeBytes??(t.fileBase64?ge(t.fileBase64):0);if(a>G)throw new pe(a,G);const l={localDeliverableId:t.localId,visibility:t.visibility,title:t.title,summary:t.summary,tags:t.tags,filename:t.filename,format:t.format,producerAgent:{id:t.producerAgent.id,name:t.producerAgent.name,source:t.producerAgent.source}};t.content&&(l.content=t.content),t.fileBase64&&(l.fileBase64=t.fileBase64);const{data:s}=await this.doFetch("/deliverables/publish",{method:"POST",body:JSON.stringify(l)});return C(s,this.hubOrigin)}async pollStatus(t){this.assertHubLoggedIn();const{data:a}=await this.doFetch(`/deliverables/status?localId=${encodeURIComponent(t)}`,{method:"GET"});return C(a,this.hubOrigin)}async listMine(){this.assertHubLoggedIn();const{data:t}=await this.doFetch("/deliverables/mine",{method:"GET"}),a=t&&typeof t=="object"?t:{};return(Array.isArray(a.shares)?a.shares:[]).map(s=>C(s,this.hubOrigin))}async revoke(t){this.assertHubLoggedIn();const{data:a}=await this.doFetch("/deliverables/revoke",{method:"POST",body:JSON.stringify({localId:t})});return{...C(a,this.hubOrigin),status:"revoked",url:null}}}function ye(e,t){return new xe({getHubToken:e,hubUrl:t,proxyBasePath:"/api/hub"})}const ve=/\.(png|jpe?g|gif|webp|svg|bmp|avif|ico)$/i,ke=/\.(mp4|webm|mp3|wav|ogg|m4a|mov|avi|mkv|flac)$/i;function X(e){return ve.test(e)?"image":ke.test(e)?"media":"other"}function je(e){return e.replace(/^file:\/\//i,"").replace(/^file:/i,"")}function J(e){const t=e.match(/!?\[[^\]]*\]\(([^)]+)\)/);if(t)return t[1].trim().split(/\s+(?="|')/)[0].trim()||null;const a=e.match(/(?:src|href|poster)\s*=\s*["']([^"']+)["']/i);return a?a[1]:null}function Z(e){return!e||/^(https?:|data:|mailto:|tel:|#)/i.test(e)||e.startsWith("//")?!1:(e.startsWith("/api/files/"),!0)}function Y(e,t){if(!e)return null;const a=e.trim(),l=a.match(/^\/api\/files\/(?:image|stream|preview)\?path=([^&]+)/i);if(l)try{return decodeURIComponent(l[1])||null}catch{return l[1]||null}return/^file:\/\//i.test(a)?je(a).replace(/\\/g,"/"):/^[a-zA-Z]:[\\/]/.test(a)?a.replace(/\\/g,"/"):a.startsWith("/")?a:t&&(a.startsWith("./")||a.startsWith("../")||!a.includes("://"))?`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${a.replace(/^\.\//,"").replace(/\\/g,"/")}`:null}function we(e,t){const a=[],l=new Set,s=/!?\[[^\]]*\]\(([^)\s]+(?:\s+["'][^"']*["'])?)\)/g;for(const c of e.matchAll(s)){const o=c[0],d=J(o);if(!d||!Z(d))continue;const b=Y(d,t);!b||l.has(o)||(l.add(o),a.push({raw:o,localPath:b,kind:X(b.split("?")[0])}))}const i=/<[a-zA-Z][^>]*(?:src|href|poster)\s*=\s*["'][^"']+["'][^>]*>/gi;for(const c of e.matchAll(i)){const o=c[0],d=J(o);if(!d||!Z(d))continue;const b=Y(d,t);!b||l.has(o)||(l.add(o),a.push({raw:o,localPath:b,kind:X(b.split("?")[0])}))}return{refs:a,baseDir:t??""}}function Ne(e,t){let a=e;for(const[l,s]of t){const i=Se(l,s);a=a.split(l).join(i)}return a}function Se(e,t){const a=e.match(/^(!?\[[^\]]*\])\([^)]*\)$/);if(a)return`${a[1]}(${t})`;const l=e.match(/(src|href|poster)(\s*=\s*)(["'])[^"']*\3/i);return l?e.replace(/(src|href|poster)(\s*=\s*)(["'])[^"']*\3/i,`${l[1]}${l[2]}${l[3]}${t}${l[3]}`):t}function Ve(e,t){return/^https?:\/\//i.test(e)?e:`${t.replace(/\/+$/,"")}${e.startsWith("/")?"":"/"}${e}`}function He(e,t,a){const l=new Map,s=new Map(e.map(i=>[i.localPath,i]));for(const i of t){if(!i.key)continue;const c=s.get(i.key);!c||!i.url||l.set(c.raw,Ve(i.url,a))}return l}async function Ie(e){try{const t=N.files.streamUrl(e),a=await fetch(t).then(d=>d.ok?d.blob():null);if(!a)return null;const l=await a.arrayBuffer(),s=new Uint8Array(l);let i="";const c=32768;for(let d=0;d<s.length;d+=c)i+=String.fromCharCode.apply(null,Array.from(s.subarray(d,d+c)));const o=e.split("/").pop()||"media";return{base64:btoa(i),filename:o}}catch{return null}}async function Te(e,t){const a=new Map;if(e.length===0)return a;const l=[];for(const c of e){const o=await Ie(c.localPath);o&&l.push({key:c.localPath,filename:o.filename,base64:o.base64})}if(l.length===0)return a;const{files:s,errors:i}=await R.uploadMediaBatch(l);return i.length>0&&console.warn("[deliverable-share] media upload errors:",i),He(e,s,t)}async function $e(e,t,a){if(!e||t==="directory"||e.startsWith("http://")||e.startsWith("https://"))return{};try{const l=await N.files.preview(e);if((l.type==="text"||l.type==="markdown"||l.type==="html"||l.type==="json"||l.type==="csv")&&typeof l.content=="string"){if(!(l.type==="markdown"||l.type==="html"))return{content:l.content};const i=e.replace(/[/\\]/g,"/").split("/").slice(0,-1).join("/"),{refs:c}=we(l.content,i);if(c.length===0)return{content:l.content};const o=await Te(c,a);return o.size===0?{content:l.content}:{content:Ne(l.content,o),uploadedMedia:o.size}}if(l.type==="image"||l.type==="audio"||l.type==="video"||l.type==="binary"){const s=l.streamUrl||(l.path?N.files.streamUrl(l.path):N.files.streamUrl(e)),c=await(await fetch(s).then(f=>f.blob())).arrayBuffer(),o=new Uint8Array(c);let d="";const b=32768;for(let f=0;f<o.length;f+=b)d+=String.fromCharCode.apply(null,Array.from(o.subarray(f,f+b)));return{fileBase64:btoa(d)}}return{}}catch{return{}}}function Ee({item:e,onClose:t,onShared:a,service:l}){const{t:s}=de(["deliverables","common"]),i=u.useMemo(()=>l??ye(ue,R.getUrl()),[l]),[c,o]=u.useState(()=>i?i.isHubLoggedIn():null),[d,b]=u.useState(!1),[f,p]=u.useState(()=>{const n=e.shareStatus;return n==="published"?"published":n==="pending_review"?"pending_review":n==="rejected"?"rejected":"form"}),[m,M]=u.useState("public"),[V,ee]=u.useState(e.title||""),[E,te]=u.useState(e.summary||""),[x,L]=u.useState(Array.isArray(e.tags)?[...e.tags]:[]),[k,P]=u.useState(""),[A,re]=u.useState(null),[H,U]=u.useState(!1),[I,g]=u.useState(null),F=u.useRef(a);F.current=a;const y=u.useCallback(n=>{re(n);const h=n.status;p(h==="published"?"published":h==="rejected"?"rejected":h==="revoked"?"revoked":h==="pending_review"?"pending_review":"form"),F.current?.(n)},[]);u.useEffect(()=>{o(i.isHubLoggedIn())},[i]);const se=u.useCallback(async()=>{b(!0),g(null);try{await fe({force:!0}),o(i.isHubLoggedIn())}catch{o(i.isHubLoggedIn())}finally{b(!1)}},[i]),B=u.useCallback(()=>{const n=k.trim().replace(/^#/,"");n&&!x.includes(n)&&L(h=>[...h,n]),P("")},[k,x]),ae=u.useCallback(n=>{L(h=>h.filter(v=>v!==n))},[]),le=u.useCallback(n=>{n.key==="Enter"||n.key===","?(n.preventDefault(),B()):n.key==="Backspace"&&!k&&x.length&&L(h=>h.slice(0,-1))},[B,k,x.length]),D=u.useCallback(()=>{const n=A?.url??e.shareUrl;n&&navigator.clipboard?.writeText(n).then(()=>{U(!0),setTimeout(()=>U(!1),1500)}).catch(()=>{})},[A,e.shareUrl]),ne=u.useCallback(async()=>{if(!he(e.format)){g(`分享仅支持 ${[...q].join(" / ")} 格式`);return}g(null),p("busy");try{const n=e.reference.replace(/[/\\]/g,"/").split("/").pop()||"deliverable",h=R.getUrl(),{content:v,fileBase64:ie,uploadedMedia:z}=await $e(e.reference,e.type,h);z&&console.info(`[deliverable-share] uploaded ${z} local media reference(s) to Hub`);const j=e.agentId??"";let O=j;if(j)try{const{agents:oe}=await N.agents.list({lean:!0}),K=oe.find(ce=>ce.id===j);K&&(O=K.name||j)}catch{}const w=await i.publish({localId:e.id,title:V.trim()||e.title,summary:E.trim(),tags:x,visibility:m,filename:n,format:e.format||"markdown",content:v,fileBase64:ie,producerAgent:{id:j,name:O,source:"local"}});y(w),w.status==="rejected"?g(typeof w.reason=="string"&&w.reason?w.reason:"分享被拒绝"):t()}catch(n){if(p("form"),n instanceof Q){o(!1);return}g(n instanceof S||n instanceof Error?n.message:String(n))}},[i,e,V,E,x,m,y]),_=u.useCallback(async()=>{g(null);try{const n=await i.revoke(e.id);y({...n,status:"revoked",url:null})}catch(n){g(n instanceof S?n.message:String(n))}},[i,e.id,y]),W=u.useCallback(()=>{p("form"),g(null)},[]);u.useEffect(()=>{if(f!=="pending_review")return;let n=!1;const h=setInterval(async()=>{try{const v=await i.pollStatus(e.id);if(n)return;v.status!=="pending_review"&&y(v)}catch{}},8e3);return()=>{n=!0,clearInterval(h)}},[f,i,e.id,y]),u.useEffect(()=>{const n=h=>{h.key==="Escape"&&t()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t]);const T=m==="link",$=A?.url??e.shareUrl;return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[r.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-surface-primary rounded-2xl shadow-2xl border border-border-default w-full max-w-md max-h-[85vh] overflow-y-auto",onClick:n=>n.stopPropagation(),children:[r.jsxs("div",{className:"sticky top-0 bg-surface-primary/95 backdrop-blur-sm border-b border-border-default px-5 py-4 flex items-center justify-between rounded-t-2xl z-10",children:[r.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:s("deliverables:share.title",{defaultValue:"分享到 Markus Hub"})}),r.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsx("div",{className:"px-5 py-4 space-y-4",children:c===!1?r.jsxs("div",{className:"space-y-4 py-2",children:[r.jsxs("div",{className:"flex items-start gap-3 rounded-xl bg-amber-500/10 border border-amber-500/25 p-3",children:[r.jsx("span",{className:"text-lg",children:"🔑"}),r.jsx("p",{className:"text-sm text-fg-secondary",children:s("deliverables:share.needHubLogin",{defaultValue:"需登录 Markus Hub 账号后才能分享产出物。"})})]}),r.jsx("button",{onClick:()=>{se()},disabled:d,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-on-brand hover:bg-brand-500 transition-colors disabled:opacity-60",children:d?s("deliverables:share.loggingIn",{defaultValue:"正在打开登录…"}):s("deliverables:share.loginHub",{defaultValue:"登录 Markus Hub 账号"})}),r.jsx("p",{className:"text-[11px] text-fg-tertiary",children:s("deliverables:share.loginHint",{defaultValue:"解锁后将支持一键公开/链接分享产出物。"})})]}):r.jsx(r.Fragment,{children:f==="published"?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-green-500/15 text-green-500 font-medium",children:s("deliverables:share.published",{defaultValue:"已发布"})}),r.jsx("span",{className:"text-[11px] text-fg-tertiary",children:m==="link"?s("deliverables:share.linkVisibility",{defaultValue:"有链接可见"}):s("deliverables:share.publicVisibility",{defaultValue:"公开"})})]}),$?r.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[r.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:$}),r.jsx("button",{onClick:D,className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${H?"bg-green-500/20 text-green-500":"bg-brand-600/20 text-brand-500 hover:bg-brand-600/30"}`,children:H?s("common:copied",{defaultValue:"已复制"}):s("common:copy",{defaultValue:"复制链接"})})]}):r.jsx("p",{className:"text-xs text-fg-tertiary",children:s("deliverables:share.urlPending",{defaultValue:"链接生成中,稍后刷新查看…"})}),r.jsx("button",{onClick:()=>{_()},className:"w-full px-3 py-2 text-xs font-medium rounded-lg text-red-500 border border-red-500/30 hover:bg-red-500/10 transition-colors",children:s("deliverables:share.revoke",{defaultValue:"取消分享"})})]}):f==="pending_review"?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-amber-500 animate-pulse"}),r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-amber-500/15 text-amber-500 font-medium",children:s("deliverables:share.pendingReview",{defaultValue:"审核中"})}),r.jsx("span",{className:"text-[11px] text-fg-tertiary",children:m==="link"?s("deliverables:share.linkVisibility",{defaultValue:"有链接可见"}):s("deliverables:share.publicVisibility",{defaultValue:"公开"})})]}),r.jsx("p",{className:"text-sm text-fg-secondary",children:s("deliverables:share.pendingHint",{defaultValue:"你的产出物已公开,其他人现在就能通过链接访问。管理员审核通过后,内容将进入搜索引擎收录。"})}),$?r.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[r.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:$}),r.jsx("button",{onClick:D,className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${H?"bg-green-500/20 text-green-500":"bg-brand-600/20 text-brand-500 hover:bg-brand-600/30"}`,children:H?s("common:copied",{defaultValue:"已复制"}):s("common:copy",{defaultValue:"复制链接"})})]}):null,r.jsx("button",{onClick:()=>{_()},className:"w-full px-3 py-2 text-xs font-medium rounded-lg text-red-500 border border-red-500/30 hover:bg-red-500/10 transition-colors",children:s("deliverables:share.revoke",{defaultValue:"取消分享"})})]}):f==="rejected"?r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-red-500/15 text-red-500 font-medium",children:s("deliverables:share.rejected",{defaultValue:"已拒绝"})})}),I&&r.jsx("div",{className:"rounded-lg bg-red-500/10 border border-red-500/25 px-3 py-2 text-xs text-red-500",children:I}),r.jsx("button",{onClick:W,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-on-brand hover:bg-brand-500 transition-colors",children:s("deliverables:share.resubmit",{defaultValue:"重新提交"})})]}):f==="revoked"?r.jsxs("div",{className:"space-y-3",children:[r.jsx("p",{className:"text-sm text-fg-secondary",children:s("deliverables:share.revoked",{defaultValue:"已取消分享,该产出物不再公开可访问。"})}),r.jsx("button",{onClick:W,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-on-brand hover:bg-brand-500 transition-colors",children:s("deliverables:share.shareAgain",{defaultValue:"重新分享"})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.visibility",{defaultValue:"可见性"})}),r.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 cursor-pointer transition-colors ${T?"border-border-default hover:bg-surface-elevated":"border-brand-500/50 bg-brand-500/5"}`,children:[r.jsx("input",{type:"radio",name:"visibility",checked:!T,onChange:()=>M("public"),className:"mt-0.5 accent-brand-500"}),r.jsxs("span",{className:"space-y-0.5",children:[r.jsx("span",{className:"block text-sm font-medium text-fg-primary",children:s("deliverables:share.public",{defaultValue:"公开(所有人可见 + 搜索引擎)"})}),r.jsx("span",{className:"block text-[11px] text-fg-tertiary",children:s("deliverables:share.publicHint",{defaultValue:"公开产出物需经 Hub 审核后发布,发布后所有人可见并参与搜索"})})]})]}),r.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 cursor-pointer transition-colors ${T?"border-brand-500/50 bg-brand-500/5":"border-border-default hover:bg-surface-elevated"}`,children:[r.jsx("input",{type:"radio",name:"visibility",checked:T,onChange:()=>M("link"),className:"mt-0.5 accent-brand-500"}),r.jsxs("span",{className:"space-y-0.5",children:[r.jsx("span",{className:"block text-sm font-medium text-fg-primary",children:s("deliverables:share.link",{defaultValue:"有链接可见"})}),r.jsx("span",{className:"block text-[11px] text-fg-tertiary",children:s("deliverables:share.linkHint",{defaultValue:"仅获得链接的人可查看,不参与搜索引擎;同样需经 Hub 审核"})})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.titleField",{defaultValue:"标题"})}),r.jsx("input",{value:V,onChange:n=>ee(n.target.value),placeholder:s("deliverables:share.titlePlaceholder",{defaultValue:"清晰、可检索的标题"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.summary",{defaultValue:"摘要"})}),r.jsx("textarea",{value:E,onChange:n=>te(n.target.value),rows:3,placeholder:s("deliverables:share.summaryPlaceholder",{defaultValue:"简要描述该产出物…"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none resize-y"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.tags",{defaultValue:"标签"})}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:x.map(n=>r.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-secondary",children:[n,r.jsx("button",{onClick:()=>ae(n),className:"text-fg-tertiary hover:text-red-500","aria-label":"remove",children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},n))}),r.jsx("input",{value:k,onChange:n=>P(n.target.value),onKeyDown:le,onBlur:B,placeholder:s("deliverables:share.tagsPlaceholder",{defaultValue:"输入标签后回车添加"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none"})]}),I&&r.jsx("div",{className:"rounded-lg bg-red-500/10 border border-red-500/25 px-3 py-2 text-xs text-red-500",children:I}),r.jsxs("button",{type:"button",onClick:()=>{ne()},disabled:f==="busy"||!V.trim(),className:"w-full px-3 py-2.5 text-sm font-medium rounded-lg bg-brand-600 text-on-brand hover:bg-brand-500 transition-colors disabled:opacity-60 flex items-center justify-center gap-2",children:[f==="busy"&&r.jsxs("svg",{className:"animate-spin",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",opacity:"0.25"}),r.jsx("path",{d:"M22 12a10 10 0 0 0-10-10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]}),f==="busy"?s("deliverables:share.sharing",{defaultValue:"分享中…"}):s("deliverables:share.shareToHub",{defaultValue:"分享到 Hub"})]})]})})})]})]})}export{Ee as D,he as a,ye as c};