@fgbg/mdocs 1.3.14 → 1.3.16

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 (77) hide show
  1. package/README.md +6 -6
  2. package/agent-skills/changelog/SKILL.md +28 -1
  3. package/agent-skills/core-concepts-all-files/SKILL.md +3 -3
  4. package/agent-skills/core-concepts-domain/SKILL.md +49 -46
  5. package/agent-skills/core-concepts-invitation/SKILL.md +9 -9
  6. package/agent-skills/core-concepts-no-account/SKILL.md +1 -1
  7. package/agent-skills/deployment-requirements/SKILL.md +2 -2
  8. package/agent-skills/faq/SKILL.md +2 -2
  9. package/agent-skills/getting-started-first-kb/SKILL.md +2 -2
  10. package/agent-skills/getting-started-installation/SKILL.md +3 -3
  11. package/agent-skills/index/SKILL.md +2 -2
  12. package/agent-skills/index.json +8 -8
  13. package/agent-skills/usage-bookmarks/SKILL.md +5 -5
  14. package/agent-skills/usage-cli-token/SKILL.md +6 -6
  15. package/agent-skills/usage-comments/SKILL.md +1 -1
  16. package/agent-skills/usage-domain-members/SKILL.md +27 -27
  17. package/agent-skills/usage-html-documents/SKILL.md +1 -1
  18. package/agent-skills/usage-knowledge-graph/SKILL.md +5 -5
  19. package/agent-skills/usage-my-documents/SKILL.md +8 -8
  20. package/agent-skills/usage-onboarding-ai/SKILL.md +6 -6
  21. package/agent-skills/usage-search/SKILL.md +2 -2
  22. package/agent-skills/usage-settings/SKILL.md +8 -8
  23. package/bin/mdocs.js +0 -0
  24. package/dist/server/agent/Agent/system-prompt.js +3 -3
  25. package/dist/server/agent/Agent/system-prompt.js.map +1 -1
  26. package/dist/server/agent/Agent/tool-ui-effects.js +1 -1
  27. package/dist/server/agent/Agent/tools-documents.js +12 -12
  28. package/dist/server/agent/Agent/tools-documents.js.map +1 -1
  29. package/dist/server/agent/Agent/tools-domains.js +14 -14
  30. package/dist/server/agent/Agent/tools-domains.js.map +1 -1
  31. package/dist/server/agent/Agent/tools-visitors.js +1 -1
  32. package/dist/server/agent/Agent/tools-visitors.js.map +1 -1
  33. package/dist/server/cli/self-update.js +12 -0
  34. package/dist/server/cli/self-update.js.map +1 -1
  35. package/dist/server/cli/self-update.test.js +17 -1
  36. package/dist/server/cli/self-update.test.js.map +1 -1
  37. package/dist/server/documents/document.service.js +6 -6
  38. package/dist/server/documents/document.service.js.map +1 -1
  39. package/dist/server/documents/graph-task.js +1 -1
  40. package/dist/server/documents/graph-task.js.map +1 -1
  41. package/dist/server/documents/graph.service.js +1 -1
  42. package/dist/server/documents/graph.service.js.map +1 -1
  43. package/dist/server/domains/change-domain-permission.js +1 -1
  44. package/dist/server/domains/change-domain-permission.js.map +1 -1
  45. package/dist/server/routes/assets.routes.js +9 -7
  46. package/dist/server/routes/assets.routes.js.map +1 -1
  47. package/dist/server/routes/assets.routes.upload.test.js +2 -2
  48. package/dist/server/routes/assets.routes.upload.test.js.map +1 -1
  49. package/dist/server/routes/folders.routes.js +4 -4
  50. package/dist/server/routes/folders.routes.js.map +1 -1
  51. package/dist/web/assets/AgentChatPanel-Bsx3DwQ7.js +22 -0
  52. package/dist/web/assets/{AgentSkillFormCard-53eZ84xO.js → AgentSkillFormCard-TFpdC5LM.js} +3 -3
  53. package/dist/web/assets/AiWriteWorkbench-Jl0I9eM9.js +7 -0
  54. package/dist/web/assets/{DiagramEditor-NtNY3sZL-YvQa1xOq.js → DiagramEditor-NtNY3sZL-CAEe_iNQ.js} +1 -1
  55. package/dist/web/assets/DocChrome-BWMgRxlr.js +21 -0
  56. package/dist/web/assets/DocumentEditor-DALklXO2.js +1 -0
  57. package/dist/web/assets/HtmlEditor-CX0e0ifD.js +1 -0
  58. package/dist/web/assets/{MergeView-DP-WJuEH.js → MergeView-DNu_ac5f.js} +2 -2
  59. package/dist/web/assets/{PlaygroundPage-BNBySSOX.js → PlaygroundPage-mv9P6czE.js} +1 -1
  60. package/dist/web/assets/{SettingsPage-B45LFCCd.js → SettingsPage-nT9hvcPA.js} +2 -2
  61. package/dist/web/assets/{Toolbar-PNBoGf83.js → Toolbar-Hsam79hu.js} +1 -1
  62. package/dist/web/assets/{VisitorPickerModal-Dxgj3Y61.js → VisitorPickerModal-CqHzml8s.js} +1 -1
  63. package/dist/web/assets/{check-BCinw6C1.js → check-soiTDN2u.js} +2 -2
  64. package/dist/web/assets/{copy-B4T4wJbp.js → copy-B4fvX0p8.js} +2 -2
  65. package/dist/web/assets/{index-B3TBoi2p.css → index-CuXb3X2-.css} +1 -1
  66. package/dist/web/assets/index-OmOf_og0.js +283 -0
  67. package/dist/web/assets/{meta2dEngine-BD2XbzaV-CvZrtSgN.js → meta2dEngine-BD2XbzaV-Bq3HuUfD.js} +1 -1
  68. package/dist/web/assets/{plus-C5AB-V4P.js → plus-DKKQ-AoS.js} +2 -2
  69. package/dist/web/assets/{react-DKdyUY61.js → react-CI5PDFXT.js} +3 -3
  70. package/dist/web/index.html +2 -2
  71. package/package.json +1 -1
  72. package/dist/web/assets/AgentChatPanel-wBPfD1N6.js +0 -22
  73. package/dist/web/assets/AiWriteWorkbench-2tZtS8zc.js +0 -7
  74. package/dist/web/assets/DocChrome-Bp7n7acp.js +0 -21
  75. package/dist/web/assets/DocumentEditor-DmwHDhjB.js +0 -1
  76. package/dist/web/assets/HtmlEditor-DIZ-8-go.js +0 -1
  77. package/dist/web/assets/index-7ZIkBACf.js +0 -283
@@ -1 +1 @@
1
- {"version":3,"file":"assets.routes.upload.test.js","sourceRoot":"","sources":["../../../src/server/routes/assets.routes.upload.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAErF,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAChD,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,CAAC,C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CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC1C,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,aAAa,EAAE,CAAC;QAE/C,MAAM,IAAI,GAAG,yBAAyB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC3D,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QAC1D,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,OAAO,GAAG,yBAAyB,CAAC,MAAM,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QAC/E,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;QACpE,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACvD,MAAM,QAAQ,GAAG,yBAAyB,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QACnE,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -74,11 +74,11 @@ export function createFolder(params) {
74
74
  const db = getDb();
75
75
  const domainRow = findDomainById(db, domainId);
76
76
  if (!domainRow) {
77
- throw new DocumentError("DOMAIN_NOT_FOUND", "域不存在", 404);
77
+ throw new DocumentError("DOMAIN_NOT_FOUND", "工作空间不存在", 404);
78
78
  }
79
79
  const access = resolveDomainAccess(db, domainRow, domainId, params.actorVisitorId);
80
80
  if (access.kind !== "full") {
81
- throw new DocumentError("FORBIDDEN", "无权在该域创建目录", 403);
81
+ throw new DocumentError("FORBIDDEN", "无权在该工作空间创建目录", 403);
82
82
  }
83
83
  // 规范化目录名(空格转下划线等),用于 relative_path
84
84
  const storageName = normalisePathSegmentForStorage(params.name);
@@ -93,7 +93,7 @@ export function createFolder(params) {
93
93
  throw new DocumentError("INVALID_PARENT", "父目录不存在", 404);
94
94
  }
95
95
  if (parent.domain_id !== domainId) {
96
- throw new DocumentError("FORBIDDEN", "不能跨域创建目录", 403);
96
+ throw new DocumentError("FORBIDDEN", "不能跨工作空间创建目录", 403);
97
97
  }
98
98
  normalizedPath = `${parent.relative_path}/${storageName}`;
99
99
  }
@@ -115,7 +115,7 @@ export function createFolder(params) {
115
115
  let permission;
116
116
  if (params.permission !== undefined) {
117
117
  if (!validateDomainPermission(domainRow.permission, params.permission)) {
118
- throw new DocumentError("INVALID_PERMISSION", `域类型不允许该权限值`, 400);
118
+ throw new DocumentError("INVALID_PERMISSION", `工作空间类型不允许该权限值`, 400);
119
119
  }
120
120
  permission = params.permission;
121
121
  }
@@ -1 +1 @@
1
- {"version":3,"file":"folders.routes.js","sourceRoot":"","sources":["../../../src/server/routes/folders.routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA+B,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAClJ,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EACL,aAAa,EACb,UAAU,EACV,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAwB,uBAAuB,E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ets/ui-CvA4pq3d.js","assets/react-vendor-BuABiQkA.js","assets/motion-DFABYlwt.js"])))=>i.map(i=>d[i]);
2
+ import{r as i,j as e,_ as ct,b as dt}from"./react-vendor-BuABiQkA.js";import{o as ae,N as Ke,C as ut,am as Xe,Y as ne,an as qe,ao as mt,q as Fe,ap as Pe,aq as pt,ar as ft,as as ht,at as gt,au as xt,av as yt,aw as Ue,ax as jt,ay as kt,az as Nt}from"./index-OmOf_og0.js";import{H as bt,S as vt,A as wt,a as Ct}from"./AgentSkillFormCard-TFpdC5LM.js";import{C as Ye}from"./check-soiTDN2u.js";import{C as Ge}from"./copy-B4fvX0p8.js";import{P as St}from"./plus-DKKQ-AoS.js";import{ae as _t,af as At}from"./ui-CvA4pq3d.js";import"./diagram-Bk84WZto.js";import"./motion-DFABYlwt.js";/**
3
+ * @license lucide-react v0.562.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */const It=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Mt=ae("maximize-2",It);/**
8
+ * @license lucide-react v0.562.0 - ISC
9
+ *
10
+ * This source code is licensed under the ISC license.
11
+ * See the LICENSE file in the root directory of this source tree.
12
+ */const Et=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Rt=ae("minimize-2",Et);/**
13
+ * @license lucide-react v0.562.0 - ISC
14
+ *
15
+ * This source code is licensed under the ISC license.
16
+ * See the LICENSE file in the root directory of this source tree.
17
+ */const $t=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Tt=ae("zoom-in",$t);/**
18
+ * @license lucide-react v0.562.0 - ISC
19
+ *
20
+ * This source code is licensed under the ISC license.
21
+ * See the LICENSE file in the root directory of this source tree.
22
+ */const zt=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Dt=ae("zoom-out",zt);function je(s){var n;return s==null||typeof s=="boolean"?"":typeof s=="string"||typeof s=="number"?String(s):Array.isArray(s)?s.map(je).join(""):typeof s=="object"&&"props"in s?je((n=s.props)==null?void 0:n.children):""}function qt(s){return s?/\blanguage-mermaid\b|\bmermaid\b/i.test(s):!1}function Ft(s){const n=Array.isArray(s)?s:[s];for(const a of n){if(a==null||typeof a!="object"||!("props"in a))continue;const c=a.props;if(!(!c||!qt(c.className)))return je(c.children).replace(/\n$/,"")}return null}const Pt=.4,Lt=4,se=.2;let xe=null;function Bt(){return xe||(xe=ct(()=>import("./diagram-Bk84WZto.js").then(s=>s.z),__vite__mapDeps([0,1,2,3])).then(s=>{const n=s.default;return n.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral",fontFamily:"ui-sans-serif, system-ui, sans-serif"}),n})),xe}const Ot=32,W=new Map;function Le(s){return W.get(s)??null}function Wt(s,n){for(W.has(s)&&W.delete(s),W.set(s,n);W.size>Ot;){const a=W.keys().next().value;if(a==null)break;W.delete(a)}}function ye(s){return Math.min(Lt,Math.max(Pt,s))}function Ht(s){const[n,a]=i.useState(1),[c,b]=i.useState({x:0,y:0}),h=i.useRef(null),[_,y]=i.useState(!1);i.useEffect(()=>{const u=I=>{I.key==="Escape"&&s.onClose()};window.addEventListener("keydown",u);const m=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",u),document.body.style.overflow=m}},[s.onClose]);function A(u){u.button===0&&(u.currentTarget.setPointerCapture(u.pointerId),h.current={pointerId:u.pointerId,startX:u.clientX,startY:u.clientY,originX:c.x,originY:c.y},y(!0))}function C(u){const m=h.current;!m||m.pointerId!==u.pointerId||b({x:m.originX+(u.clientX-m.startX),y:m.originY+(u.clientY-m.startY)})}function E(u){const m=h.current;if(!(!m||m.pointerId!==u.pointerId)){h.current=null,y(!1);try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}}}function N(u){u.preventDefault();const m=u.deltaY>0?-se:se;a(I=>ye(Number((I+m).toFixed(2))))}return dt.createPortal(e.jsxs("div",{className:"mdocs-agent-mermaid-float",role:"dialog","aria-modal":"true","aria-label":"Mermaid 图预览",children:[e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-backdrop","aria-label":"关闭预览",onClick:s.onClose}),e.jsxs("div",{className:"mdocs-agent-mermaid-float-chrome",children:[e.jsxs("div",{className:"mdocs-agent-mermaid-float-tools",children:[e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:()=>a(u=>ye(Number((u-se).toFixed(2)))),title:"缩小","aria-label":"缩小",children:e.jsx(Dt,{size:16,"aria-hidden":!0})}),e.jsxs("span",{className:"mdocs-agent-mermaid-float-scale",children:[Math.round(n*100),"%"]}),e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:()=>a(u=>ye(Number((u+se).toFixed(2)))),title:"放大","aria-label":"放大",children:e.jsx(Tt,{size:16,"aria-hidden":!0})}),e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:()=>{a(1),b({x:0,y:0})},title:"重置",children:"重置"}),e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:s.onClose,title:"关闭","aria-label":"关闭",children:e.jsx(ne,{size:16,"aria-hidden":!0})})]}),e.jsx("div",{className:_?"mdocs-agent-mermaid-float-stage is-dragging":"mdocs-agent-mermaid-float-stage",onPointerDown:A,onPointerMove:C,onPointerUp:E,onPointerCancel:E,onWheel:N,children:e.jsx("div",{className:"mdocs-agent-mermaid-float-canvas",style:{transform:`translate(calc(-50% + ${c.x}px), calc(-50% + ${c.y}px)) scale(${n})`},dangerouslySetInnerHTML:{__html:s.svg}})}),e.jsx("p",{className:"mdocs-agent-mermaid-float-hint",children:"拖动平移 · 滚轮缩放 · Esc 关闭"})]})]}),document.body)}function Kt(s){const n=i.useId().replace(/:/g,""),[a,c]=i.useState("diagram"),[b,h]=i.useState(()=>Le(s.source.trim())),[_,y]=i.useState(null),[A,C]=i.useState(!1),[E,N]=i.useState(!1),u=i.useRef(null),m=s.source.trim(),I=i.useMemo(()=>m,[m]);i.useEffect(()=>()=>{u.current!=null&&window.clearTimeout(u.current)},[]),i.useEffect(()=>{if(a!=="diagram")return;if(!I){h(null),y(null);return}const j=Le(I);if(j){h(j),y(null);return}let M=!1;const P=window.setTimeout(()=>{(async()=>{try{const F=await Bt();if(M)return;const T=`mdocs-agent-mmd-${n}-${Date.now()}`,{svg:R}=await F.render(T,I);if(M)return;Wt(I,R),h(R),y(null)}catch(F){if(M)return;h(null),y(F instanceof Error?F.message:"Mermaid 渲染失败")}})()},200);return()=>{M=!0,window.clearTimeout(P)}},[a,I,n]);async function H(){!m||!await Xe(m)||(C(!0),u.current!=null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>C(!1),1500))}return e.jsxs("div",{className:"mdocs-agent-mermaid",children:[e.jsxs("div",{className:"mdocs-agent-mermaid-toolbar",children:[e.jsxs("div",{className:"mdocs-agent-mermaid-toggle",role:"group","aria-label":"Mermaid 显示模式",children:[e.jsxs("button",{type:"button",className:a==="diagram"?"mdocs-agent-mermaid-toggle-btn is-active":"mdocs-agent-mermaid-toggle-btn",onClick:()=>c("diagram"),"aria-pressed":a==="diagram",title:"图谱",children:[e.jsx(Ke,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"图谱"})]}),e.jsxs("button",{type:"button",className:a==="code"?"mdocs-agent-mermaid-toggle-btn is-active":"mdocs-agent-mermaid-toggle-btn",onClick:()=>c("code"),"aria-pressed":a==="code",title:"代码",children:[e.jsx(ut,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"代码"})]})]}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-md-copy mdocs-agent-mermaid-copy",onClick:()=>void H(),"aria-label":A?"已复制":"复制代码",title:A?"已复制":"复制",children:A?e.jsx(Ye,{size:14,"aria-hidden":!0}):e.jsx(Ge,{size:14,"aria-hidden":!0})})]}),a==="diagram"?e.jsx("div",{className:"mdocs-agent-mermaid-diagram",children:_?e.jsxs("div",{className:"mdocs-agent-mermaid-error",role:"alert",children:[e.jsx("p",{children:"无法渲染该图,可切换到代码查看源码。"}),e.jsx("pre",{children:_})]}):b?e.jsx("div",{className:"mdocs-agent-mermaid-svg mdocs-agent-mermaid-svg-hit",role:"button",tabIndex:0,onClick:()=>N(!0),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),N(!0))},title:"点击放大预览","aria-label":"点击放大预览 Mermaid 图",children:e.jsx("span",{className:"mdocs-agent-mermaid-svg-inner",dangerouslySetInnerHTML:{__html:b}})}):e.jsx("div",{className:"mdocs-agent-mermaid-loading",children:"渲染中…"})}):e.jsx("div",{className:"mdocs-agent-panel-md-pre-wrap mdocs-agent-mermaid-code",children:e.jsx("pre",{children:s.codeChildren??e.jsx("code",{className:"language-mermaid",children:m})})}),E&&b?e.jsx(Ht,{svg:b,onClose:()=>N(!1)}):null]})}const Xt=i.memo(Kt,(s,n)=>s.source===n.source);function ke(s){var n;return s==null||typeof s=="boolean"?"":typeof s=="string"||typeof s=="number"?String(s):Array.isArray(s)?s.map(ke).join(""):typeof s=="object"&&"props"in s?ke((n=s.props)==null?void 0:n.children):""}function Ut(s){const[n,a]=i.useState(!1),c=i.useRef(null),b=i.useRef(null),h=ke(s.children).replace(/\n$/,"");i.useEffect(()=>()=>{c.current!=null&&window.clearTimeout(c.current)},[]);async function _(y){var N,u,m;y.preventDefault(),y.stopPropagation();const C=(((m=(u=(N=b.current)==null?void 0:N.querySelector("pre"))==null?void 0:u.innerText)==null?void 0:m.replace(/\n$/,""))??"")||h;!C||!await Xe(C)||(a(!0),c.current!=null&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>a(!1),1500))}return e.jsxs("div",{className:"mdocs-agent-panel-md-pre-wrap",ref:b,children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-md-copy",onClick:y=>void _(y),"aria-label":n?"已复制":"复制代码",title:n?"已复制":"复制",children:n?e.jsx(Ye,{size:14,"aria-hidden":!0}):e.jsx(Ge,{size:14,"aria-hidden":!0})}),e.jsx("pre",{children:s.children})]})}function Yt(s){const n=Ft(s.children);return n!=null?e.jsx(Xt,{source:n,codeChildren:s.children}):e.jsx(Ut,{children:s.children})}const Gt={pre:({children:s})=>e.jsx(Yt,{children:s})},Be=i.memo(function(n){return e.jsx("div",{className:"mdocs-agent-panel-md",children:e.jsx(_t,{remarkPlugins:[At],components:Gt,children:n.children})})}),Vt=["如何发布文档?","草稿是什么?","如何创建工作空间?"];function Oe(s,n){return n.map((a,c)=>{const b=a.skillNames&&a.skillNames.length>0?a.skillNames:a.skillIds&&a.skillIds.length>0?a.skillIds:void 0;return{id:`h-${s}-${c}-${a.role}`,role:a.role,content:a.content,skillNames:b}})}function Jt(s,n){const a=s.slice(),c=a[a.length-1];return(c==null?void 0:c.type)==="text"?a[a.length-1]={type:"text",text:c.text+n}:a.push({type:"text",text:n}),a}function Zt(s,n){const a=s.slice(),c=a[a.length-1];return(c==null?void 0:c.type)==="thinking"?a[a.length-1]={type:"thinking",text:c.text+n}:a.push({type:"thinking",text:n}),a}function We(s){return s!=null&&s.length?s.filter(n=>n.type==="text").map(n=>n.text).join(""):""}function Qt(s){return!!(s!=null&&s.some(n=>n.type==="thinking"&&n.text.length>0))}function es(s){const n=new Date(s);if(Number.isNaN(n.getTime()))return"";const a=new Date;return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate()?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})}function He(s){if(s>=1e3){const n=s/1e3;return`${n>=10?Math.round(n):Math.round(n*10)/10}K`}return String(s)}function ts(s){const{block:n,onResolved:a}=s,[c,b]=i.useState(""),[h,_]=i.useState(!1),[y,A]=i.useState(1),C=i.useRef(!1),E=i.useRef(a);E.current=a;const N=n.status==="open",u=i.useRef(0);i.useEffect(()=>{if(!N)return;C.current=!1;const j=new Date(n.expiresAt).getTime(),M=Date.now(),P=Math.max(j-M,1);u.current=P,A(1);const F=()=>{const R=j-Date.now(),p=Math.max(0,Math.min(1,R/P));A(p),R<=0&&!C.current&&(C.current=!0,kt(n.requestId).catch(()=>{}).finally(()=>{E.current(n.requestId,"","expired")}))};F();const T=window.setInterval(F,100);return()=>window.clearInterval(T)},[N,n.expiresAt,n.requestId]);async function m(j){const M=j.trim();if(!(!M||h||!N)){_(!0);try{await Nt(n.requestId,M),a(n.requestId,M,"selected")}catch{a(n.requestId,M,"failed")}finally{_(!1)}}}async function I(){if(!(h||!N)){_(!0),C.current=!0;try{await Ue(n.requestId),a(n.requestId,"","cancelled")}catch{a(n.requestId,"","failed")}finally{_(!1)}}}const H=Math.max(0,Math.ceil(y*u.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card"+(N?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:n.title}),N?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[H,"s"]}):null]}),N?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(y*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${y})`}})}):null,n.status==="selected"&&n.selected?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已选择:",n.selected]}):null,n.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,n.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,选择已失效"}):null,n.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,N?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-agent-choice-options",children:n.options.map(j=>e.jsx("button",{type:"button",className:"mdocs-agent-choice-option",disabled:h,onClick:()=>void m(j),children:j},j))}),e.jsxs("div",{className:"mdocs-agent-choice-custom",children:[e.jsx("input",{value:c,disabled:h,placeholder:"或输入自己的内容…",onChange:j=>b(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),m(c))}}),e.jsx("button",{type:"button",disabled:h||!c.trim(),onClick:()=>void m(c),children:"提交"})]}),e.jsx("div",{className:"mdocs-agent-choice-footer",children:e.jsx("button",{type:"button",className:"mdocs-agent-choice-cancel",disabled:h,onClick:()=>void I(),children:"取消"})})]}):null]})}function ss(s){const b=2*Math.PI*8.75,h=Math.min(100,Math.max(0,s.percent)),_=b*(1-h/100),y=h>=90?"danger":h>=70?"warn":"ok",A=`上下文 ${h}% · 已用 ${He(s.used)} / ${He(s.limit)} tokens`;return e.jsx("span",{className:"mdocs-agent-panel-context mdocs-agent-panel-context-"+y,"data-tooltip":A,"aria-label":A,role:"img",tabIndex:0,children:e.jsxs("svg",{width:20,height:20,viewBox:"0 0 20 20","aria-hidden":!0,children:[e.jsx("circle",{className:"mdocs-agent-panel-context-track",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5}),e.jsx("circle",{className:"mdocs-agent-panel-context-value",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5,strokeLinecap:"round",strokeDasharray:b,strokeDashoffset:_,transform:`rotate(-90 ${20/2} ${20/2})`})]})})}function ns(s){var n;for(const a of s)if(!(a.role!=="assistant"||!((n=a.blocks)!=null&&n.length))){for(const c of a.blocks)if((c.type==="choice_card"||c.type==="skill_form_card")&&c.status==="open")return!0}return!1}const ps=i.forwardRef(function(n,a){const{open:c,onClose:b,visitorName:h,anchorStyle:_,fullscreen:y,onToggleFullscreen:A,domainId:C,documentId:E,documentTitle:N,documentPath:u,graphFileId:m,graphLabel:I,onOpenDocument:H,onTreeChanged:j,onDocumentOverwritten:M,onOpenCoding:P}=n,F=((h==null?void 0:h.trim().charAt(0))||"我").toUpperCase(),[T,R]=i.useState(!1),[p,U]=i.useState(null),[Ve,Y]=i.useState(null),[z,w]=i.useState([]),[re,G]=i.useState(null),[Ne,Je]=i.useState([]),[Ze,be]=i.useState(!1),[V,J]=i.useState(""),[X,ve]=i.useState([]),[we,ie]=i.useState(!1),[v,Z]=i.useState(!1),[Ce,L]=i.useState(null),[Q,Se]=i.useState(null),[oe,O]=i.useState(!1),[B,_e]=i.useState(!1),Qe=i.useRef(null),ee=i.useRef(null),D=i.useRef(null),Ae=i.useRef(0),K=i.useRef(!0),[et,le]=i.useState(!1),ce=i.useRef(z);ce.current=z;const Ie=!!(E!=null&&E.trim())&&!we,tt=(N==null?void 0:N.trim())||"当前文档",Me=(u==null?void 0:u.trim())||"",de=!!(m!=null&&m.trim())&&!we,st=(I==null?void 0:I.trim())||"当前图谱";i.useEffect(()=>{ie(!1)},[E,m]);function Ee(t){return Ae.current+=1,`${t}-${Ae.current}`}const Re=120;function $e(t){return t.scrollHeight-t.scrollTop-t.clientHeight}function te(){const t=ee.current;t&&(t.scrollTop=t.scrollHeight,le(!1))}function q(){K.current&&te()}function nt(){const t=ee.current;if(!t)return;const f=$e(t);K.current=f<=48,le(f>Re)}function at(){K.current=!0,te()}i.useLayoutEffect(()=>{q();const t=ee.current;t&&le($e(t)>Re)},[z]);async function rt(){be(!0);try{const t=await ht();Je(t.sessions),re||G(t.lastOpenedSessionId)}catch{}finally{be(!1)}}async function ue(){try{const t=await ft();Se(t)}catch{}}async function Te(){try{const t=await qe();U(t),Y(null)}catch(t){U(null),Y(t instanceof Error?t.message:String(t))}}i.useEffect(()=>{var f;if(!c){R(!1),(f=D.current)==null||f.abort(),D.current=null,Z(!1);return}let t=!1;return(async()=>{try{const o=await qe();t||(U(o),Y(null))}catch(o){t||(U(null),Y(o instanceof Error?o.message:String(o)))}})(),ue(),()=>{t=!0}},[c]),i.useEffect(()=>{if(!c)return;let t=!1;return(async()=>{try{const f=await mt();if(t)return;G(f.sessionId),w(o=>o.length>0?o:Oe(f.sessionId,f.messages))}catch{}})(),()=>{t=!0}},[c]),i.useEffect(()=>{!c||!T||rt()},[c,T]);function me(){if(!B){if(ns(ce.current)){O(!0);return}O(!1),b()}}async function it(){var o;if(B)return;_e(!0);const t=ce.current,f=[];for(const S of t)if(!(S.role!=="assistant"||!S.blocks))for(const g of S.blocks)g.type==="choice_card"&&g.status==="open"&&f.push(Ue(g.requestId).catch(()=>{})),g.type==="skill_form_card"&&g.status==="open"&&f.push(jt(g.requestId).catch(()=>{}));await Promise.all(f),(o=D.current)==null||o.abort(),w(S=>S.map(g=>g.role!=="assistant"||!g.blocks?g:{...g,blocks:g.blocks.map(x=>x.type==="choice_card"&&x.status==="open"?{...x,status:"cancelled"}:x.type==="skill_form_card"&&x.status==="open"?{...x,status:"cancelled"}:x)})),O(!1),_e(!1),b()}const pe=i.useRef(me);pe.current=me,i.useImperativeHandle(a,()=>({requestClose:()=>pe.current()}),[]),i.useEffect(()=>{if(!c){O(!1);return}const t=f=>{if(f.key==="Escape"){if(oe){B||O(!1);return}if(T){R(!1);return}pe.current()}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[c,T,oe,B]);async function fe(t){var x;const f=t.trim();if(!f||v)return;if(!(p!=null&&p.enabled)){L((p==null?void 0:p.reason)==="missing_api_key"?"请先配置 API Key":(p==null?void 0:p.reason)==="skills_missing"?"手册 skills 未就绪,请确认已构建 agent-skills":"助手暂不可用");return}(x=D.current)==null||x.abort();const o=new AbortController;D.current=o;const S={id:Ee("u"),role:"user",content:f,skillNames:X.length>0?[...X]:void 0},g=Ee("a");K.current=!0,w($=>[...$,S,{id:g,role:"assistant",content:""}]),J(""),Z(!0),L(null),R(!1),requestAnimationFrame(()=>{te(),requestAnimationFrame(te)});try{let $=!1;await yt(f,{skillNames:X.length>0?X:void 0,references:{domainId:(C==null?void 0:C.trim())||void 0,documentId:!de&&Ie?E.trim():void 0,graphFileId:de?m.trim():void 0},signal:o.signal,onEvent:l=>{l.type==="text_delta"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=Jt(r.blocks??[],l.text);return{...r,blocks:d,content:We(d)}})),requestAnimationFrame(()=>q())):l.type==="thinking_delta"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=Zt(r.blocks??[],l.text);return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="sources"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=(r.blocks??[]).slice(),ge=d[d.length-1];return(ge==null?void 0:ge.type)==="sources"?d[d.length-1]={type:"sources",items:l.items}:d.push({type:"sources",items:l.items}),{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="document_table"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"document_table",title:l.title,rows:l.rows}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="document_card"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"document_card",documentId:l.documentId,title:l.title,path:l.path,preview:l.preview}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="tool_notice"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"tool_notice",toolName:l.toolName,text:l.text}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="choice_card"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"choice_card",requestId:l.requestId,title:l.title,options:l.options,expiresAt:l.expiresAt,status:"open"}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="choice_expired"?w(k=>k.map(r=>r.id!==g||!r.blocks?r:{...r,blocks:r.blocks.map(d=>d.type==="choice_card"&&d.requestId===l.requestId&&d.status==="open"?{...d,status:"expired"}:d)})):l.type==="skill_form_card"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"skill_form_card",requestId:l.requestId,mode:l.mode,title:l.title,currentName:l.currentName,initialName:l.initialName,initialDescription:l.initialDescription,initialBody:l.initialBody,expiresAt:l.expiresAt,status:"open"}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="skill_form_expired"?w(k=>k.map(r=>r.id!==g||!r.blocks?r:{...r,blocks:r.blocks.map(d=>d.type==="skill_form_card"&&d.requestId===l.requestId&&d.status==="open"?{...d,status:"expired"}:d)})):l.type==="tree_changed"?j==null||j():l.type==="document_overwritten"?M==null||M({documentId:l.documentId,headCommitId:l.headCommitId}):l.type==="open_coding"?P==null||P({documentId:l.documentId,displayName:l.displayName}):l.type==="context_usage"?Se({percent:l.percent,used:l.used,limit:l.limit}):l.type==="error"&&($=!0,L(l.message))}}),!o.signal.aborted&&!$&&ve([])}catch($){if(o.signal.aborted)return;L($ instanceof Error?$.message:String($))}finally{D.current===o&&(D.current=null),Z(!1)}}async function ot(){var t;if(!v){(t=D.current)==null||t.abort(),L(null),R(!1),Z(!1);try{const f=await gt();G(f.sessionId),w([]),J(""),K.current=!0,ue()}catch(f){L(f instanceof Error?f.message:String(f))}}}async function lt(t){var f;if(!v){if(t===re){R(!1);return}(f=D.current)==null||f.abort(),L(null);try{const o=await xt(t);G(o.sessionId),w(Oe(o.sessionId,o.messages)),J(""),R(!1),K.current=!0,requestAnimationFrame(()=>q()),ue()}catch(o){L(o instanceof Error?o.message:String(o))}}}function ze(t){!t||!H||H(t)}if(!c)return null;const he=(p==null?void 0:p.reason)==="missing_api_key",De=Ve??(p&&!p.enabled&&!he?p.reason==="skills_missing"?"skills 未就绪":"助手暂不可用":null);return e.jsxs("div",{ref:Qe,className:"mdocs-agent-panel"+(y?" mdocs-agent-panel--fullscreen":""),role:"dialog","aria-label":"mdocs 智能助手","aria-modal":y?!0:void 0,style:y?void 0:_,children:[e.jsxs("header",{className:"mdocs-agent-panel-header",children:[e.jsxs("div",{className:"mdocs-agent-panel-title",children:[e.jsx("img",{src:Fe,alt:"",className:"mdocs-agent-panel-title-logo"}),e.jsx("span",{children:"mdocs 智能助手"})]}),e.jsxs("div",{className:"mdocs-agent-panel-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"新会话","aria-label":"新会话",disabled:v,onClick:()=>void ot(),children:e.jsx(St,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn"+(T?" active":""),title:"历史会话","aria-label":"历史会话",onClick:()=>R(t=>!t),children:e.jsx(bt,{size:16,strokeWidth:1.8})}),A?e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:y?"退出全屏":"全屏","aria-label":y?"退出全屏":"全屏",onClick:A,children:y?e.jsx(Rt,{size:16,strokeWidth:1.8}):e.jsx(Mt,{size:16,strokeWidth:1.8})}):null,e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"关闭","aria-label":"关闭",onClick:me,children:e.jsx(ne,{size:16,strokeWidth:1.8})})]})]}),T?e.jsxs("div",{className:"mdocs-agent-panel-history",children:[e.jsxs("div",{className:"mdocs-agent-panel-history-head",children:[e.jsx("span",{children:"历史会话"}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-history-back",onClick:()=>R(!1),children:"返回对话"})]}),Ze?e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"加载中…"}):Ne.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-history-empty",children:"暂无历史会话"}),e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"发一条消息后会出现在这里"})]}):e.jsx("ul",{className:"mdocs-agent-panel-history-list",children:Ne.map(t=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"mdocs-agent-panel-history-item"+(t.id===re?" active":""),disabled:v,onClick:()=>void lt(t.id),children:[e.jsx("span",{className:"mdocs-agent-panel-history-title",children:t.title}),e.jsx("span",{className:"mdocs-agent-panel-history-time",children:es(t.updatedAt)})]})},t.id))})]}):e.jsxs("div",{className:"mdocs-agent-panel-body",children:[e.jsxs("div",{className:"mdocs-agent-panel-scroll-wrap",children:[e.jsx("div",{className:"mdocs-agent-panel-welcome",ref:ee,onScroll:nt,children:z.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-hello",children:"你好,我是 mdocs 智能助手"}),e.jsx("p",{className:"mdocs-agent-panel-desc",children:"我能答疑、搜文档、整理结构,也能帮你写全文;需要精细改稿请点文档顶栏「帮写」。"}),he?e.jsx(Pe,{onConfigured:Te}):De?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:De}):e.jsx("div",{className:"mdocs-agent-panel-chips",children:Vt.map(t=>e.jsx("button",{type:"button",className:"mdocs-agent-panel-chip",onClick:()=>void fe(t),disabled:v||!(p!=null&&p.enabled),children:t},t))})]}):e.jsx("div",{className:"mdocs-agent-panel-messages",children:z.map(t=>{var f;return e.jsxs("div",{className:"mdocs-agent-panel-msg"+(t.role==="user"?" mdocs-agent-panel-msg-user":" mdocs-agent-panel-msg-assistant"),children:[t.role==="assistant"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-ai","aria-hidden":!0,children:e.jsx("img",{src:Fe,alt:""})}):null,e.jsxs("div",{className:"mdocs-agent-panel-msg-bubble",children:[t.role==="user"&&t.skillNames&&t.skillNames.length>0?e.jsxs("div",{className:"mdocs-agent-msg-skills",children:["Skill ×",t.skillNames.length]}):null,t.role==="assistant"?t.blocks&&t.blocks.length>0?e.jsxs("div",{className:"mdocs-agent-panel-timeline",children:[t.blocks.map((o,S)=>{var g;return o.type==="thinking"?o.text?e.jsxs("details",{className:"mdocs-agent-panel-think-fold",open:v&&t.id===((g=z[z.length-1])==null?void 0:g.id),children:[e.jsx("summary",{children:"思考中"}),e.jsx("pre",{className:"mdocs-agent-panel-think-body",children:o.text})]},`${t.id}-th-${S}`):null:o.type==="text"?o.text?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(Be,{children:o.text})},`${t.id}-t-${S}`):null:o.type==="sources"?o.items.length===0?null:e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:["已阅读 ",o.items.length," 个页面"]}),e.jsx("ol",{className:"mdocs-agent-panel-sources-list",children:o.items.map(x=>e.jsx("li",{children:e.jsx("a",{href:x.url,target:"_blank",rel:"noreferrer",children:x.name})},x.id))})]})},`${t.id}-s-${S}`):o.type==="tool_notice"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx("p",{className:"mdocs-agent-panel-tool-notice",children:o.text})},`${t.id}-n-${S}`):o.type==="choice_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(ts,{block:o,onResolved:(x,$,l)=>{w(k=>k.map(r=>r.id!==t.id||!r.blocks?r:{...r,blocks:r.blocks.map(d=>d.type==="choice_card"&&d.requestId===x?{...d,status:l,selected:l==="selected"?$:d.selected}:d)}))}})},`${t.id}-ch-${S}`):o.type==="skill_form_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(vt,{block:o,onResolved:(x,$,l)=>{w(k=>k.map(r=>r.id!==t.id||!r.blocks?r:{...r,blocks:r.blocks.map(d=>d.type==="skill_form_card"&&d.requestId===x?{...d,status:$,submittedName:$==="submitted"?l:d.submittedName}:d)}))}})},`${t.id}-sf-${S}`):o.type==="document_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[e.jsxs("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:x=>{x.preventDefault(),x.stopPropagation(),ze(o.documentId)},children:["《",o.title,"》"]}),e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:"文档预览"})]}),e.jsxs("div",{className:"mdocs-agent-panel-doc-card-body",children:[o.path?e.jsx("p",{className:"mdocs-agent-panel-doc-card-path",children:o.path}):null,o.preview?e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview",children:o.preview}):e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview muted",children:"(无正文预览)"})]})]})},`${t.id}-c-${S}`):e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[o.title,e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:o.rows.length===0?"无结果":`${o.rows.length} 条`})]}),e.jsx("div",{className:"mdocs-agent-panel-doc-table-wrap",children:o.rows.length===0?e.jsx("p",{className:"mdocs-agent-panel-doc-table-empty",children:"无结果"}):e.jsxs("table",{className:"mdocs-agent-panel-doc-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"文章名字"}),e.jsx("th",{children:"文章内容"})]})}),e.jsx("tbody",{children:o.rows.map(x=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:()=>ze(x.documentId),children:x.title})}),e.jsx("td",{children:x.summary||"-"})]},x.documentId))})]})})]})},`${t.id}-d-${S}`)}),v&&t.id===((f=z[z.length-1])==null?void 0:f.id)&&!We(t.blocks)&&!Qt(t.blocks)?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null]}):t.content?e.jsx(Be,{children:t.content}):v?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null:t.content]}),t.role==="user"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-user","aria-hidden":!0,children:F}):null]},t.id)})})}),et?e.jsxs("button",{type:"button",className:"mdocs-chat-jump-bottom",onClick:at,title:"回到底部","aria-label":"回到底部",children:[e.jsx(wt,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:"置底"})]}):null]}),Ce?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:Ce}):null,he&&z.length>0?e.jsx(Pe,{onConfigured:Te}):null,e.jsx(Ct,{selectedNames:X,onChange:ve,disabled:v||!(p!=null&&p.enabled)}),e.jsxs("div",{className:"mdocs-agent-panel-input-wrap",children:[de?e.jsxs("div",{className:"mdocs-agent-doc-ref mdocs-agent-graph-ref",children:[e.jsx(Ke,{size:15,strokeWidth:1.75,className:"mdocs-agent-doc-ref-icon","aria-hidden":!0}),e.jsxs("div",{className:"mdocs-agent-doc-ref-text",children:[e.jsx("span",{className:"mdocs-agent-doc-ref-title",children:st}),e.jsx("span",{className:"mdocs-agent-doc-ref-path",children:"图谱(只读)"})]}),e.jsx("button",{type:"button",className:"mdocs-agent-doc-ref-unlink",title:"取消引用","aria-label":"取消引用当前图谱",disabled:v,onClick:()=>ie(!0),children:e.jsx(ne,{size:14,strokeWidth:2,"aria-hidden":!0})})]}):Ie?e.jsxs("div",{className:"mdocs-agent-doc-ref",children:[e.jsx(pt,{size:15,strokeWidth:1.75,className:"mdocs-agent-doc-ref-icon","aria-hidden":!0}),e.jsxs("div",{className:"mdocs-agent-doc-ref-text",children:[e.jsx("span",{className:"mdocs-agent-doc-ref-title",children:tt}),Me?e.jsx("span",{className:"mdocs-agent-doc-ref-path",children:Me}):null]}),e.jsx("button",{type:"button",className:"mdocs-agent-doc-ref-unlink",title:"取消引用","aria-label":"取消引用当前文档",disabled:v,onClick:()=>ie(!0),children:e.jsx(ne,{size:14,strokeWidth:2,"aria-hidden":!0})})]}):null,e.jsxs("div",{className:"mdocs-agent-panel-input-body",children:[e.jsx("textarea",{className:"mdocs-agent-panel-input",rows:2,placeholder:p!=null&&p.enabled?"把你的问题告诉我…":"请先配置 API Key",value:V,disabled:v||!(p!=null&&p.enabled),onChange:t=>J(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),fe(V))}}),Q?e.jsx(ss,{percent:Q.percent,used:Q.used,limit:Q.limit}):null,e.jsx("button",{type:"button",className:v?"mdocs-agent-panel-send mdocs-agent-panel-send-stop":"mdocs-agent-panel-send",disabled:v?!1:!(p!=null&&p.enabled)||!V.trim(),onClick:()=>{var t;if(v){(t=D.current)==null||t.abort();return}fe(V)},title:v?"停止":"发送","aria-label":v?"停止":"发送",children:v?"■":"↑"})]})]}),e.jsx("p",{className:"mdocs-agent-panel-footnote",children:"内容由 AI 生成,仅供参考"})]}),oe?e.jsx("div",{className:"mdocs-agent-close-confirm-backdrop",role:"presentation",onClick:()=>{B||O(!1)},children:e.jsxs("div",{className:"mdocs-message-dialog mdocs-agent-close-confirm",role:"dialog","aria-modal":"true","aria-labelledby":"mdocs-agent-close-confirm-title",onClick:t=>t.stopPropagation(),children:[e.jsx("h3",{id:"mdocs-agent-close-confirm-title",className:"mdocs-message-dialog-title",children:"有待处理的倒计时"}),e.jsx("p",{className:"mdocs-message-dialog-body",children:"当前还有选择卡或 Skill 表单在倒计时。强制关闭会取消这些操作并退出助手;也可以继续等待完成后再关。"}),e.jsxs("div",{className:"mdocs-message-dialog-actions mdocs-agent-close-confirm-actions",children:[e.jsx("button",{type:"button",className:"secondary",disabled:B,onClick:()=>O(!1),children:"继续等待"}),e.jsx("button",{type:"button",disabled:B,onClick:()=>void it(),children:B?"关闭中…":"强制关闭并退出"})]})]})}):null]})});export{ps as AgentChatPanel};
@@ -1,11 +1,11 @@
1
- import{n as E,a6 as L,az as D,av as _,aA as F}from"./index-7ZIkBACf.js";import{r as a,j as e}from"./react-vendor-BuABiQkA.js";/**
1
+ import{o as E,a8 as L,aB as D,ax as _,aC as B}from"./index-OmOf_og0.js";import{r as a,j as e}from"./react-vendor-BuABiQkA.js";/**
2
2
  * @license lucide-react v0.562.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const $=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],X=E("arrow-down",$);/**
6
+ */const F=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],X=E("arrow-down",F);/**
7
7
  * @license lucide-react v0.562.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const B=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],K=E("history",B),j=5;function P(i){const t=a.useRef(!0),r=a.useRef(null),[d,k]=a.useState([]),[u,p]=a.useState(!1),[h,v]=a.useState(null);a.useEffect(()=>(t.current=!0,()=>{t.current=!1}),[]),a.useEffect(()=>{(async()=>{try{const s=await L();if(!t.current)return;k(s)}catch(s){if(!t.current)return;v(s instanceof Error?s.message:String(s))}})()},[]),a.useEffect(()=>{if(!u)return;function s(o){const g=r.current;!g||g.contains(o.target)||p(!1)}function n(o){o.key==="Escape"&&p(!1)}return document.addEventListener("mousedown",s),document.addEventListener("keydown",n),()=>{document.removeEventListener("mousedown",s),document.removeEventListener("keydown",n)}},[u]);const c=d.filter(s=>i.selectedNames.includes(s.name));function f(s){if(i.disabled)return;const n=new Set(i.selectedNames);if(n.has(s))n.delete(s);else{if(n.size>=j)return;n.add(s)}i.onChange([...n])}return d.length===0&&!h?null:e.jsxs("div",{className:"mdocs-agent-skill-ref",ref:r,children:[e.jsxs("div",{className:"mdocs-agent-skill-ref-bar",children:[e.jsxs("div",{className:"mdocs-agent-skill-ref-anchor",children:[u&&d.length>0?e.jsxs("div",{className:"mdocs-agent-skill-popover",role:"listbox","aria-label":"选择 Skill",children:[e.jsxs("div",{className:"mdocs-agent-skill-popover-hint",children:["选择要引用的 Skill(最多 ",j," 个)"]}),e.jsx("ul",{className:"mdocs-agent-skill-popover-list",children:d.map(s=>{const n=i.selectedNames.includes(s.name),o=!n&&i.selectedNames.length>=j;return e.jsx("li",{children:e.jsxs("button",{type:"button",role:"option","aria-selected":n,className:"mdocs-agent-skill-popover-item"+(n?" mdocs-agent-skill-popover-item-on":""),disabled:i.disabled||o,onClick:()=>f(s.name),children:[e.jsx("span",{className:"mdocs-agent-skill-popover-check","aria-hidden":!0,children:n?"✓":""}),e.jsxs("span",{className:"mdocs-agent-skill-popover-text",children:[e.jsx("span",{className:"mdocs-agent-skill-popover-name",children:s.name}),s.description?e.jsx("span",{className:"mdocs-agent-skill-popover-desc",children:s.description}):e.jsx("span",{className:"mdocs-agent-skill-popover-desc mdocs-agent-skill-popover-desc-muted",children:"无简介"})]})]})},s.id)})})]}):null,e.jsxs("button",{type:"button",className:"mdocs-agent-skill-ref-toggle"+(u?" mdocs-agent-skill-ref-toggle-open":""),disabled:i.disabled||d.length===0,onClick:()=>p(s=>!s),"aria-expanded":u,"aria-haspopup":"listbox",title:"引用 Skill",children:["Skill",c.length>0?` · ${c.length}`:""]})]}),c.map(s=>e.jsxs("button",{type:"button",className:"mdocs-agent-skill-chip mdocs-agent-skill-chip-on",disabled:i.disabled,onClick:()=>f(s.name),title:"移除引用",children:[s.name,e.jsx("span",{"aria-hidden":!0,children:" ×"})]},s.name))]}),h?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:h}):null]})}const z=/^[A-Za-z0-9_]+$/;function T(i){const{block:t,onResolved:r}=i,[d,k]=a.useState(t.initialName),[u,p]=a.useState(t.initialDescription),[h,v]=a.useState(t.initialBody),[c,f]=a.useState(!1),[s,n]=a.useState(null),[o,g]=a.useState(1),x=a.useRef(!1),N=a.useRef(r);N.current=r;const m=t.status==="open",b=a.useRef(0);a.useEffect(()=>{if(!m)return;x.current=!1;const l=new Date(t.expiresAt).getTime(),C=Date.now(),y=Math.max(l-C,1);b.current=y,g(1);const S=()=>{const w=l-Date.now(),q=Math.max(0,Math.min(1,w/y));g(q),w<=0&&!x.current&&(x.current=!0,D(t.requestId).catch(()=>{}).finally(()=>{N.current(t.requestId,"expired")}))};S();const I=window.setInterval(S,100);return()=>window.clearInterval(I)},[m,t.expiresAt,t.requestId]);async function R(){if(c||!m)return;const l=d.trim();if(!l){n("名称不能为空");return}if(!z.test(l)){n("名称仅允许英文、数字、下划线");return}if(!h.trim()){n("正文不能为空");return}f(!0),n(null);try{await F(t.requestId,{name:l,description:u.trim(),body:h}),r(t.requestId,"submitted",l)}catch{r(t.requestId,"failed")}finally{f(!1)}}async function A(){if(!(c||!m)){f(!0),n(null),x.current=!0;try{await _(t.requestId),r(t.requestId,"cancelled")}catch{r(t.requestId,"failed")}finally{f(!1)}}}const M=Math.max(0,Math.ceil(o*b.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card mdocs-agent-skill-form-card"+(m?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:t.title}),m?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[M,"s"]}):null]}),m?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(o*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${o})`}})}):null,t.status==="submitted"?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已提交",t.submittedName?`:${t.submittedName}`:""]}):null,t.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,t.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,表单已失效"}):null,t.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,m?e.jsxs("div",{className:"mdocs-agent-skill-form-fields",children:[e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"名称(英文数字下划线)"}),e.jsx("input",{type:"text",value:d,onChange:l=>k(l.target.value),maxLength:64,disabled:c,autoComplete:"off",spellCheck:!1})]}),e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"简介"}),e.jsx("input",{type:"text",value:u,onChange:l=>p(l.target.value),maxLength:200,disabled:c})]}),e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"正文"}),e.jsx("textarea",{value:h,onChange:l=>v(l.target.value),rows:8,disabled:c})]}),s?e.jsx("p",{className:"mdocs-agent-skill-form-error",children:s}):null,e.jsxs("div",{className:"mdocs-agent-skill-form-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-skill-form-cancel",disabled:c,onClick:()=>void A(),children:"取消"}),e.jsx("button",{type:"button",disabled:c,onClick:()=>void R(),children:c?"提交中…":t.mode==="create"?"创建":"保存"})]})]}):null]})}export{X as A,K as H,T as S,P as a};
11
+ */const $=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],K=E("history",$),j=5;function P(i){const t=a.useRef(!0),r=a.useRef(null),[d,k]=a.useState([]),[u,p]=a.useState(!1),[h,v]=a.useState(null);a.useEffect(()=>(t.current=!0,()=>{t.current=!1}),[]),a.useEffect(()=>{(async()=>{try{const s=await L();if(!t.current)return;k(s)}catch(s){if(!t.current)return;v(s instanceof Error?s.message:String(s))}})()},[]),a.useEffect(()=>{if(!u)return;function s(o){const g=r.current;!g||g.contains(o.target)||p(!1)}function n(o){o.key==="Escape"&&p(!1)}return document.addEventListener("mousedown",s),document.addEventListener("keydown",n),()=>{document.removeEventListener("mousedown",s),document.removeEventListener("keydown",n)}},[u]);const c=d.filter(s=>i.selectedNames.includes(s.name));function f(s){if(i.disabled)return;const n=new Set(i.selectedNames);if(n.has(s))n.delete(s);else{if(n.size>=j)return;n.add(s)}i.onChange([...n])}return d.length===0&&!h?null:e.jsxs("div",{className:"mdocs-agent-skill-ref",ref:r,children:[e.jsxs("div",{className:"mdocs-agent-skill-ref-bar",children:[e.jsxs("div",{className:"mdocs-agent-skill-ref-anchor",children:[u&&d.length>0?e.jsxs("div",{className:"mdocs-agent-skill-popover",role:"listbox","aria-label":"选择 Skill",children:[e.jsxs("div",{className:"mdocs-agent-skill-popover-hint",children:["选择要引用的 Skill(最多 ",j," 个)"]}),e.jsx("ul",{className:"mdocs-agent-skill-popover-list",children:d.map(s=>{const n=i.selectedNames.includes(s.name),o=!n&&i.selectedNames.length>=j;return e.jsx("li",{children:e.jsxs("button",{type:"button",role:"option","aria-selected":n,className:"mdocs-agent-skill-popover-item"+(n?" mdocs-agent-skill-popover-item-on":""),disabled:i.disabled||o,onClick:()=>f(s.name),children:[e.jsx("span",{className:"mdocs-agent-skill-popover-check","aria-hidden":!0,children:n?"✓":""}),e.jsxs("span",{className:"mdocs-agent-skill-popover-text",children:[e.jsx("span",{className:"mdocs-agent-skill-popover-name",children:s.name}),s.description?e.jsx("span",{className:"mdocs-agent-skill-popover-desc",children:s.description}):e.jsx("span",{className:"mdocs-agent-skill-popover-desc mdocs-agent-skill-popover-desc-muted",children:"无简介"})]})]})},s.id)})})]}):null,e.jsxs("button",{type:"button",className:"mdocs-agent-skill-ref-toggle"+(u?" mdocs-agent-skill-ref-toggle-open":""),disabled:i.disabled||d.length===0,onClick:()=>p(s=>!s),"aria-expanded":u,"aria-haspopup":"listbox",title:"引用 Skill",children:["Skill",c.length>0?` · ${c.length}`:""]})]}),c.map(s=>e.jsxs("button",{type:"button",className:"mdocs-agent-skill-chip mdocs-agent-skill-chip-on",disabled:i.disabled,onClick:()=>f(s.name),title:"移除引用",children:[s.name,e.jsx("span",{"aria-hidden":!0,children:" ×"})]},s.name))]}),h?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:h}):null]})}const z=/^[A-Za-z0-9_]+$/;function T(i){const{block:t,onResolved:r}=i,[d,k]=a.useState(t.initialName),[u,p]=a.useState(t.initialDescription),[h,v]=a.useState(t.initialBody),[c,f]=a.useState(!1),[s,n]=a.useState(null),[o,g]=a.useState(1),x=a.useRef(!1),N=a.useRef(r);N.current=r;const m=t.status==="open",b=a.useRef(0);a.useEffect(()=>{if(!m)return;x.current=!1;const l=new Date(t.expiresAt).getTime(),M=Date.now(),y=Math.max(l-M,1);b.current=y,g(1);const S=()=>{const w=l-Date.now(),q=Math.max(0,Math.min(1,w/y));g(q),w<=0&&!x.current&&(x.current=!0,D(t.requestId).catch(()=>{}).finally(()=>{N.current(t.requestId,"expired")}))};S();const I=window.setInterval(S,100);return()=>window.clearInterval(I)},[m,t.expiresAt,t.requestId]);async function R(){if(c||!m)return;const l=d.trim();if(!l){n("名称不能为空");return}if(!z.test(l)){n("名称仅允许英文、数字、下划线");return}if(!h.trim()){n("正文不能为空");return}f(!0),n(null);try{await B(t.requestId,{name:l,description:u.trim(),body:h}),r(t.requestId,"submitted",l)}catch{r(t.requestId,"failed")}finally{f(!1)}}async function A(){if(!(c||!m)){f(!0),n(null),x.current=!0;try{await _(t.requestId),r(t.requestId,"cancelled")}catch{r(t.requestId,"failed")}finally{f(!1)}}}const C=Math.max(0,Math.ceil(o*b.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card mdocs-agent-skill-form-card"+(m?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:t.title}),m?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[C,"s"]}):null]}),m?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(o*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${o})`}})}):null,t.status==="submitted"?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已提交",t.submittedName?`:${t.submittedName}`:""]}):null,t.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,t.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,表单已失效"}):null,t.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,m?e.jsxs("div",{className:"mdocs-agent-skill-form-fields",children:[e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"名称(英文数字下划线)"}),e.jsx("input",{type:"text",value:d,onChange:l=>k(l.target.value),maxLength:64,disabled:c,autoComplete:"off",spellCheck:!1})]}),e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"简介"}),e.jsx("input",{type:"text",value:u,onChange:l=>p(l.target.value),maxLength:200,disabled:c})]}),e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"正文"}),e.jsx("textarea",{value:h,onChange:l=>v(l.target.value),rows:8,disabled:c})]}),s?e.jsx("p",{className:"mdocs-agent-skill-form-error",children:s}):null,e.jsxs("div",{className:"mdocs-agent-skill-form-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-skill-form-cancel",disabled:c,onClick:()=>void A(),children:"取消"}),e.jsx("button",{type:"button",disabled:c,onClick:()=>void R(),children:c?"提交中…":t.mode==="create"?"创建":"保存"})]})]}):null]})}export{X as A,K as H,T as S,P as a};
@@ -0,0 +1,7 @@
1
+ import{r as c,j as e}from"./react-vendor-BuABiQkA.js";import{ay as Se,az as Ie,aw as ve,an as de,ao as Me,q as Ae,ap as ue,a4 as Te,as as Le,aA as Re,at as $e,au as Ee,av as _e}from"./index-OmOf_og0.js";import{H as qe,S as Pe,A as De,a as Be}from"./AgentSkillFormCard-TFpdC5LM.js";import{P as Fe}from"./plus-DKKQ-AoS.js";import{ae as He,af as Ke}from"./ui-CvA4pq3d.js";import"./diagram-Bk84WZto.js";import"./motion-DFABYlwt.js";function Oe(t){const{block:s,onResolved:i}=t,[r,f]=c.useState(""),[g,p]=c.useState(!1),[N,k]=c.useState(1),h=c.useRef(!1),j=c.useRef(i);j.current=i;const u=s.status==="open",E=c.useRef(0);c.useEffect(()=>{if(!u)return;h.current=!1;const m=new Date(s.expiresAt).getTime(),b=Date.now(),P=Math.max(m-b,1);E.current=P,k(1);const $=()=>{const K=m-Date.now(),A=Math.max(0,Math.min(1,K/P));k(A),K<=0&&!h.current&&(h.current=!0,Se(s.requestId).catch(()=>{}).finally(()=>{j.current(s.requestId,"","expired")}))};$();const H=window.setInterval($,100);return()=>window.clearInterval(H)},[u,s.expiresAt,s.requestId]);async function y(m){const b=m.trim();if(!(!b||g||!u)){p(!0);try{await Ie(s.requestId,b),i(s.requestId,b,"selected")}catch{i(s.requestId,b,"failed")}finally{p(!1)}}}async function R(){if(!(g||!u)){p(!0),h.current=!0;try{await ve(s.requestId),i(s.requestId,"","cancelled")}catch{i(s.requestId,"","failed")}finally{p(!1)}}}const F=Math.max(0,Math.ceil(N*E.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card"+(u?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:s.title}),u?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[F,"s"]}):null]}),u?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(N*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${N})`}})}):null,s.status==="selected"&&s.selected?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已选择:",s.selected]}):null,s.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,s.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,选择已失效"}):null,s.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,u?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-agent-choice-options",children:s.options.map(m=>e.jsx("button",{type:"button",className:"mdocs-agent-choice-option",disabled:g,onClick:()=>void y(m),children:m},m))}),e.jsxs("div",{className:"mdocs-agent-choice-custom",children:[e.jsx("input",{value:r,disabled:g,placeholder:"或输入自己的内容…",onChange:m=>f(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),y(r))}}),e.jsx("button",{type:"button",disabled:g||!r.trim(),onClick:()=>void y(r),children:"提交"})]}),e.jsx("div",{className:"mdocs-agent-choice-footer",children:e.jsx("button",{type:"button",className:"mdocs-agent-choice-cancel",disabled:g,onClick:()=>void R(),children:"取消"})})]}):null]})}function te(t){return t===""?[]:t.split(`
2
+ `)}function We(t){return t.join(`
3
+ `)}function ne(t,s){const i=te(t),r=te(s),f=i.length,g=r.length,p=Array.from({length:f+1},()=>Array.from({length:g+1},()=>0));for(let y=f-1;y>=0;y--)for(let R=g-1;R>=0;R--)i[y]===r[R]?p[y][R]=p[y+1][R+1]+1:p[y][R]=Math.max(p[y+1][R],p[y][R+1]);const N=[];let k=0,h=0;for(;k<f||h<g;)if(k<f&&h<g&&i[k]===r[h])N.push({kind:"eq",oi:k,ni:h}),k++,h++;else if(h<g&&(k===f||p[k][h+1]>=p[k+1][h]))N.push({kind:"ins",oi:k,ni:h}),h++;else if(k<f)N.push({kind:"del",oi:k,ni:h}),k++;else break;const j=[];let u=0,E=0;for(;u<N.length;){if(N[u].kind==="eq"){u++;continue}const y=N[u].oi,R=N[u].ni,F=[],m=[];let b=y,P=R;for(;u<N.length&&N[u].kind!=="eq";){const $=N[u];$.kind==="del"?(F.push(i[$.oi]),b=$.oi+1):(m.push(r[$.ni]),P=$.ni+1),u++}j.push({id:`h${E++}`,oldStart:y,oldEnd:b,newStart:R,newEnd:P,oldLines:F,newLines:m})}return j}function ze(t,s){const i=te(t);return We([...i.slice(0,s.oldStart),...s.newLines,...i.slice(s.oldEnd)])}function U(t){return t===""?[]:t.split(`
4
+ `)}function z(t){return t.join(`
5
+ `)}function Je(t,s){const i=U(t),r=[];let f=0;return s.forEach((g,p)=>{g.oldStart>f&&r.push({kind:"same",lines:i.slice(f,g.oldStart),key:`s-${f}-${g.oldStart}`}),r.push({kind:"hunk",hunk:g,hunkIndex:p,key:`h-${g.id}-${p}`}),f=g.oldEnd}),f<i.length?r.push({kind:"same",lines:i.slice(f),key:`s-${f}-end`}):s.length===0&&i.length===0&&r.push({kind:"same",lines:[],key:"s-empty"}),r}function Ge(t){const s=[],i=[];for(const r of t)r.kind==="same"?s.push(z(r.lines)):i.push(z(r.hunk.newLines));return{sameTexts:s,newTexts:i}}function me(t,s){const i=[];let r=0,f=0;for(const g of t)if(g.kind==="same"){const p=s.sameTexts[r++]??"";i.push(...U(p))}else{const p=s.newTexts[f++]??"";i.push(...U(p))}return z(i)}function Ue(t){return t.oldLines.length===0?"add":t.newLines.length===0?"del":"mod"}function he(t){const s=Math.max(1,U(t.value).length);return e.jsxs("div",{className:`mdocs-ai-write-line ${t.className}`,children:[e.jsx("span",{className:"mdocs-ai-write-rail","aria-hidden":!0}),e.jsx("textarea",{className:"mdocs-ai-write-inline-edit",value:t.value,rows:s,spellCheck:!1,"aria-label":t["aria-label"],onChange:i=>t.onChange(i.target.value),onBlur:()=>t.onBlurFlush()})]})}function Ve(t){const s=!!t.sending,[i,r]=c.useState(0),[f,g]=c.useState(null),[p,N]=c.useState({sameTexts:[],newTexts:[]}),[k,h]=c.useState([]),j=c.useRef(!1),u=c.useRef(!1),E=c.useRef([]),y=c.useRef(p);y.current=p,E.current=k;const R=c.useMemo(()=>t.proposedMd==null||t.proposedMd===t.currentMd?[]:ne(t.currentMd,t.proposedMd),[t.currentMd,t.proposedMd]),F=!s&&(k.length>0?k.some(l=>l.kind==="hunk"):R.length>0);c.useEffect(()=>{if(s){h([]),j.current=!1,u.current=!1;return}if(t.proposedMd==null||t.proposedMd===t.currentMd){h([]),j.current=!1,u.current=!1;return}if(u.current){u.current=!1;return}const l=ne(t.currentMd,t.proposedMd);if(l.length===0){h([]);return}const x=Je(t.currentMd,l);h(x),j.current=!1,N(Ge(x))},[s,t.proposedMd,t.currentMd]);const m=c.useMemo(()=>k.filter(l=>l.kind==="hunk").map(l=>l.hunk),[k]);c.useEffect(()=>{if(m.length===0){r(0);return}r(l=>Math.min(l,m.length-1))},[m.length]);const b=f??i;function P(){return me(E.current,y.current)}function $(){if(!F||E.current.length===0)return t.proposedMd;const l=P();return j.current=!1,l===t.currentMd?(u.current=!1,t.onProposedChange(null),null):(l!==t.proposedMd&&(u.current=!0,t.onProposedChange(l)),l)}function H(l){const x=E.current.find(D=>D.kind==="hunk"&&D.hunk.id===l.id);if(!x)return;const S=y.current.newTexts[x.hunkIndex],I={...l,newLines:S!=null?U(S):l.newLines},v=P();if(j.current=!1,u.current=!1,v===t.currentMd){t.onProposedChange(null);return}const T=ze(t.currentMd,I);t.onCurrentChange(T),v===T?t.onProposedChange(null):t.onProposedChange(v)}function K(l){const x=E.current.find(v=>v.kind==="hunk"&&v.hunk.id===l.id);if(!x)return;const S={sameTexts:y.current.sameTexts.slice(),newTexts:y.current.newTexts.slice()};S.newTexts[x.hunkIndex]=z(l.oldLines);const I=me(E.current,S);j.current=!1,u.current=!1,I===t.currentMd?t.onProposedChange(null):t.onProposedChange(I)}function A(){const l=P();j.current=!1,u.current=!1,t.onCurrentChange(l),t.onProposedChange(null)}function J(){j.current=!1,u.current=!1,t.onProposedChange(null)}function C(l){m.length!==0&&r(x=>{const S=(x+l+m.length)%m.length,I=document.getElementById(`mdocs-ai-hunk-${S}`);return I==null||I.scrollIntoView({block:"center",behavior:"smooth"}),S})}function W(l,x){j.current=!0,N(S=>{const I=S.sameTexts.slice();return I[l]=x,{...S,sameTexts:I}})}function V(l,x){j.current=!0,N(S=>{const I=S.newTexts.slice();return I[l]=x,{...S,newTexts:I}})}const _=m[b]??null;let G=0;return e.jsxs("div",{className:"mdocs-ai-write-md-pane",children:[e.jsxs("div",{className:"mdocs-ai-write-diff-toolbar",children:[e.jsx("span",{className:"mdocs-ai-write-diff-count",children:s?"接收中·编辑我的稿":m.length===0?t.proposedMd?"与提案一致(可编辑)":"Markdown 源码(可编辑)":`${m.length} 处变更(可改提案)`}),!s&&m.length>0?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"mdocs-ai-write-diff-accept-all",onClick:A,children:"全部接受"}),e.jsx("button",{type:"button",className:"mdocs-ai-write-diff-reject-all",onClick:J,children:"全部拒绝"})]}):null]}),F&&k.length>0?e.jsxs("div",{className:"mdocs-ai-write-inline",role:"document",children:[k.map(l=>{if(l.kind==="same"){const T=G++,D=p.sameTexts[T]??z(l.lines);return e.jsx("div",{className:"mdocs-ai-write-inline-same",children:e.jsx(he,{className:"ctx",value:D,"aria-label":"提案相同行",onChange:Z=>W(T,Z),onBlurFlush:()=>$()})},l.key)}const x=l.hunk,S=Ue(x),I=l.hunkIndex===b,v=p.newTexts[l.hunkIndex]??z(x.newLines);return e.jsxs("div",{id:`mdocs-ai-hunk-${l.hunkIndex}`,className:`mdocs-ai-write-inline-hunk mdocs-ai-write-inline-hunk-${S}`+(I?" is-active":""),onMouseEnter:()=>g(l.hunkIndex),onMouseLeave:()=>g(null),onClick:()=>r(l.hunkIndex),children:[e.jsxs("div",{className:"mdocs-ai-write-hunk-hover",hidden:f!==l.hunkIndex,children:[e.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-reject",onClick:T=>{T.stopPropagation(),K(x)},children:"拒绝"}),e.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-accept",onClick:T=>{T.stopPropagation(),H(x)},children:"接受"})]}),e.jsx("pre",{className:"mdocs-ai-write-hunk-pre",children:x.oldLines.map((T,D)=>e.jsxs("div",{className:"mdocs-ai-write-line del mdocs-ai-write-line-readonly",children:[e.jsx("span",{className:"mdocs-ai-write-rail","aria-hidden":!0}),e.jsx("span",{className:"mdocs-ai-write-code",children:T||" "})]},`o${D}`))}),x.newLines.length>0||v!==""||S!=="del"?e.jsx(he,{className:"add",value:v,"aria-label":"提案新增行",onChange:T=>V(l.hunkIndex,T),onBlurFlush:()=>$()}):null]},l.key)}),_?e.jsxs("div",{className:"mdocs-ai-write-float-nav",role:"toolbar","aria-label":"变更导航",children:[e.jsx("button",{type:"button","aria-label":"上一段",onClick:()=>C(-1),children:"↑"}),e.jsxs("span",{children:[b+1," / ",m.length]}),e.jsx("button",{type:"button","aria-label":"下一段",onClick:()=>C(1),children:"↓"}),e.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-reject",onClick:()=>K(_),children:"拒绝"}),e.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-accept",onClick:()=>H(_),children:"接受"})]}):null]}):e.jsx("textarea",{className:"mdocs-ai-write-editor",value:t.currentMd,onChange:l=>t.onCurrentChange(l.target.value),spellCheck:!1,placeholder:`# 标题
6
+
7
+ 在此编辑 Markdown 源码…`})]})}let fe=0;function ge(t){return fe+=1,`${t}-${Date.now()}-${fe}`}function Ye(t,s){const i=t.slice(),r=i[i.length-1];return(r==null?void 0:r.type)==="text"?i[i.length-1]={type:"text",text:r.text+s}:i.push({type:"text",text:s}),i}function Xe(t,s){const i=t.slice(),r=i[i.length-1];return(r==null?void 0:r.type)==="thinking"?i[i.length-1]={type:"thinking",text:r.text+s}:i.push({type:"thinking",text:s}),i}function Q(t,s){const i=s.trim();return i?[...t,{type:"tool",text:i}]:t}function Qe(t){return t.some(s=>s.type==="text"||s.type==="thinking"?s.text.length>0:!0)}function Ze(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return"";const i=new Date;return s.getFullYear()===i.getFullYear()&&s.getMonth()===i.getMonth()&&s.getDate()===i.getDate()?s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):s.toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})}function xe(t,s){return s.map((i,r)=>{const f=`h-${t}-${r}-${i.role}`;if(i.role==="user"){const g=i.skillNames&&i.skillNames.length>0?i.skillNames:i.skillIds&&i.skillIds.length>0?i.skillIds:void 0;return{id:f,role:"user",content:i.content,skillNames:g}}return{id:f,role:"assistant",blocks:i.content?[{type:"text",text:i.content}]:[]}})}function rt(t){const[s,i]=c.useState(t.initialMarkdown),[r,f]=c.useState(null),[g]=c.useState(t.initialMarkdown),[p,N]=c.useState(t.displayName||"未命名"),[k,h]=c.useState([]),[j,u]=c.useState(null),[E,y]=c.useState([]),[R,F]=c.useState(!1),[m,b]=c.useState(!1),[P,$]=c.useState(""),[H,K]=c.useState([]),[A,J]=c.useState(!1),[C,W]=c.useState(null),[V,_]=c.useState(null),[G,l]=c.useState(!1),[x,S]=c.useState(null),I=c.useRef(null),v=c.useRef(null),T=c.useRef(null),D=c.useRef(!0),[Z,ee]=c.useState(!1),se=120;function ie(n){return n.scrollHeight-n.scrollTop-n.clientHeight}function Y(){const n=T.current;n&&(n.scrollTop=n.scrollHeight,ee(!1))}function ke(){D.current&&Y()}function pe(){const n=T.current;if(!n)return;const o=ie(n);D.current=o<=48,ee(o>se)}function ye(){D.current=!0,Y()}c.useLayoutEffect(()=>{if(!t.open)return;ke();const n=T.current;n&&ee(ie(n)>se)},[k,t.open]);async function X(){F(!0);try{const n=await Le("coding",t.documentId);y(n.sessions),j||u(n.lastOpenedSessionId)}catch{}finally{F(!1)}}async function ae(){try{const n=await de();W(n)}catch{W({enabled:!1,skillsReady:!1,model:null})}}if(c.useEffect(()=>{var o;if(!t.open){b(!1),(o=v.current)==null||o.abort();return}i(t.initialMarkdown),f(null),N(t.displayName||"未命名"),$(""),_(null),b(!1);let n=!1;return(async()=>{try{const w=await de();n||W(w)}catch{n||W({enabled:!1,skillsReady:!1,model:null})}try{const w=await Me("coding",t.documentId);if(n)return;u(w.sessionId),h(xe(w.sessionId,w.messages))}catch{n||(u(null),h([]))}X()})(),()=>{n=!0}},[t.open,t.initialMarkdown,t.displayName,t.documentId]),c.useEffect(()=>()=>{var n;return(n=v.current)==null?void 0:n.abort()},[]),c.useEffect(()=>{t.open&&m&&X()},[m,t.open,t.documentId]),!t.open)return null;const le=(C==null?void 0:C.reason)==="missing_api_key",we=r!=null&&r!==s?ne(s,r):[];async function je(){var n;if(!A){(n=v.current)==null||n.abort(),_(null),b(!1),J(!1);try{const o=await $e("coding",t.documentId);u(o.sessionId),h([]),$(""),X()}catch(o){_(o instanceof Error?o.message:String(o))}}}async function Ne(n){var o;if(!A){if(n===j){b(!1);return}(o=v.current)==null||o.abort(),_(null);try{const w=await Ee(n,"coding",t.documentId);u(w.sessionId),h(xe(w.sessionId,w.messages)),$(""),b(!1)}catch(w){_(w instanceof Error?w.message:String(w))}}}async function re(){var O;const n=P.trim();if(!n||A)return;if(!(C!=null&&C.enabled)){_("请先配置 API Key");return}(O=v.current)==null||O.abort();const o=new AbortController;v.current=o;const w=ge("u"),M=ge("a");D.current=!0,h(q=>[...q,{id:w,role:"user",content:n,skillNames:H.length>0?[...H]:void 0},{id:M,role:"assistant",blocks:[]}]),$(""),J(!0),_(null),requestAnimationFrame(()=>{Y(),requestAnimationFrame(Y)});const L=q=>{h(a=>a.map(d=>d.id===M&&d.role==="assistant"?{...d,blocks:q(d.blocks)}:d))};try{let q=!1;await _e(n,{mode:"coding",skillNames:H.length>0?H:void 0,documentId:t.documentId,workingMarkdown:s,baseMarkdown:g,signal:o.signal,onEvent:a=>{a.type==="text_delta"?L(d=>Ye(d,a.text)):a.type==="thinking_delta"?L(d=>Xe(d,a.text)):a.type==="markdown_set"?f(a.markdown):a.type==="tool_notice"?L(d=>Q(d,a.text)):a.type==="document_table"?L(d=>Q(d,a.title)):a.type==="document_card"?L(d=>Q(d,`读取文档「${a.title}」`)):a.type==="sources"?a.items.length>0&&L(d=>Q(d,`已阅读 ${a.items.length} 个手册页面`)):a.type==="skill_form_card"?L(d=>[...d,{type:"skill_form_card",requestId:a.requestId,mode:a.mode,title:a.title,currentName:a.currentName,initialName:a.initialName,initialDescription:a.initialDescription,initialBody:a.initialBody,expiresAt:a.expiresAt,status:"open"}]):a.type==="choice_card"?(D.current=!0,L(d=>[...d,{type:"choice_card",requestId:a.requestId,title:a.title,options:a.options,expiresAt:a.expiresAt,status:"open"}])):a.type==="choice_expired"?L(d=>d.map(B=>B.type==="choice_card"&&B.requestId===a.requestId&&B.status==="open"?{...B,status:"expired"}:B)):a.type==="skill_form_expired"?L(d=>d.map(B=>B.type==="skill_form_card"&&B.requestId===a.requestId&&B.status==="open"?{...B,status:"expired"}:B)):a.type==="error"&&(q=!0,_(a.message))}}),!o.signal.aborted&&!q&&K([]),X()}catch(q){o.signal.aborted||_(q instanceof Error?q.message:String(q))}finally{v.current===o&&(v.current=null),J(!1)}}function oe(n){return new Promise(o=>{I.current=o,S({message:n.message,confirmLabel:n.confirmLabel??"确定",cancelLabel:n.cancelLabel??"返回",danger:n.danger??!1})})}function ce(n){const o=I.current;I.current=null,S(null),o==null||o(n)}async function be(){if(!await oe({message:"是否回写",confirmLabel:"确认",cancelLabel:"返回"}))return;let o=s;we.length>0&&(o=r??s,i(o),f(null)),l(!0);const w=!t.documentId;try{const M=await t.onComplete({markdown:o,documentId:t.documentId,displayName:p.trim()||"未命名"}),L=M&&typeof M=="object"&&typeof M.documentId=="string"?M.documentId.trim():"";if(w&&L&&j)try{await Re(j,L)}catch{}t.onClose()}catch(M){if(M!=null&&M.silent||M instanceof Error&&M.message==="cancelled")return;_(M instanceof Error?M.message:String(M))}finally{l(!1)}}async function Ce(){var n;(s!==g||r!=null)&&!await oe({message:"取消帮写?未写回的修改将丢失。",confirmLabel:"放弃修改",danger:!0})||((n=v.current)==null||n.abort(),t.onClose())}return e.jsxs("div",{className:"mdocs-ai-write-overlay",role:"dialog","aria-modal":"true","aria-label":"帮写",children:[e.jsxs("header",{className:"mdocs-ai-write-header",children:[e.jsxs("div",{className:"mdocs-ai-write-header-left",children:[e.jsx("img",{src:Ae,alt:"",className:"mdocs-ai-write-title-logo"}),e.jsx("strong",{children:"帮写"}),e.jsx("input",{className:"mdocs-ai-write-title",value:p,onChange:n=>N(n.target.value),"aria-label":"文档标题"})]}),e.jsxs("div",{className:"mdocs-ai-write-header-actions",children:[e.jsx("button",{type:"button",onClick:()=>void Ce(),disabled:G||x!=null,children:"取消"}),e.jsx("button",{type:"button",className:"mdocs-ai-write-primary",onClick:()=>void be(),disabled:G||x!=null,children:G?"写回中…":"完成并写回"})]})]}),e.jsxs("div",{className:"mdocs-ai-write-body",children:[e.jsxs("section",{className:"mdocs-ai-write-chat",children:[e.jsxs("div",{className:"mdocs-ai-write-chat-toolbar",children:[e.jsx("span",{className:"mdocs-ai-write-chat-toolbar-label",children:"对话"}),e.jsxs("div",{className:"mdocs-ai-write-chat-toolbar-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"新会话","aria-label":"新会话",disabled:A,onClick:()=>void je(),children:e.jsx(Fe,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn"+(m?" active":""),title:"历史会话","aria-label":"历史会话",onClick:()=>b(n=>!n),children:e.jsx(qe,{size:16,strokeWidth:1.8})})]})]}),m?e.jsxs("div",{className:"mdocs-ai-write-history mdocs-agent-panel-history",children:[e.jsxs("div",{className:"mdocs-agent-panel-history-head",children:[e.jsx("span",{children:"历史会话"}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-history-back",onClick:()=>b(!1),children:"返回对话"})]}),R?e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"加载中…"}):E.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-history-empty",children:"暂无历史会话"}),e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"发一条消息后会出现在这里"})]}):e.jsx("ul",{className:"mdocs-agent-panel-history-list",children:E.map(n=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"mdocs-agent-panel-history-item"+(n.id===j?" active":""),disabled:A,onClick:()=>void Ne(n.id),children:[e.jsx("span",{className:"mdocs-agent-panel-history-title",children:n.title}),e.jsx("span",{className:"mdocs-agent-panel-history-time",children:Ze(n.updatedAt)})]})},n.id))})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mdocs-ai-write-chat-scroll-wrap",children:[e.jsx("div",{className:"mdocs-ai-write-chat-messages",ref:T,onScroll:pe,children:k.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-ai-write-hint",children:"描述你想写或改的内容。助手可读取右侧当前稿与进场快照,再更新提案;请按段接受或拒绝后完成写回。"}),le?e.jsx(ue,{onConfigured:ae}):null]}):k.map(n=>e.jsx("div",{className:"mdocs-ai-write-msg"+(n.role==="user"?" mdocs-ai-write-msg-user":""),children:n.role==="user"?e.jsxs(e.Fragment,{children:[n.skillNames&&n.skillNames.length>0?e.jsxs("div",{className:"mdocs-agent-msg-skills",children:["Skill ×",n.skillNames.length]}):null,n.content]}):Qe(n.blocks)?e.jsx("div",{className:"mdocs-ai-write-timeline",children:n.blocks.map((o,w)=>o.type==="thinking"?o.text?e.jsxs("details",{className:"mdocs-ai-write-thinking",open:A,children:[e.jsx("summary",{children:"思考中"}),e.jsx("pre",{className:"mdocs-ai-write-thinking-body",children:o.text})]},`${n.id}-think-${w}`):null:o.type==="tool"?e.jsx("p",{className:"mdocs-agent-panel-tool-notice",children:o.text},`${n.id}-tool-${w}`):o.type==="skill_form_card"?e.jsx(Pe,{block:o,onResolved:(M,L,O)=>{h(q=>q.map(a=>a.id!==n.id||a.role!=="assistant"?a:{...a,blocks:a.blocks.map(d=>d.type==="skill_form_card"&&d.requestId===M?{...d,status:L,submittedName:L==="submitted"?O:d.submittedName}:d)}))}},`${n.id}-sf-${w}`):o.type==="choice_card"?e.jsx(Oe,{block:o,onResolved:(M,L,O)=>{h(q=>q.map(a=>a.id!==n.id||a.role!=="assistant"?a:{...a,blocks:a.blocks.map(d=>d.type==="choice_card"&&d.requestId===M?{...d,status:O,selected:O==="selected"?L:d.selected}:d)}))}},`${n.id}-ch-${w}`):o.type==="text"&&o.text?e.jsx("div",{className:"mdocs-agent-panel-md",children:e.jsx(He,{remarkPlugins:[Ke],children:o.text})},`${n.id}-text-${w}`):null)}):A?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null},n.id))}),Z?e.jsxs("button",{type:"button",className:"mdocs-chat-jump-bottom",onClick:ye,title:"回到底部","aria-label":"回到底部",children:[e.jsx(De,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:"置底"})]}):null]}),V?e.jsx("p",{className:"mdocs-ai-write-error",children:V}):null,le&&k.length>0?e.jsx(ue,{onConfigured:ae}):null,e.jsxs("div",{className:"mdocs-ai-write-input-row",children:[e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[e.jsx(Be,{selectedNames:H,onChange:K,disabled:A||!(C!=null&&C.enabled)}),e.jsx("textarea",{rows:2,value:P,disabled:A||!(C!=null&&C.enabled),placeholder:C!=null&&C.enabled?"说说要写什么…":"请先配置 API Key",onChange:n=>$(n.target.value),onKeyDown:n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),re())}})]}),e.jsx("button",{type:"button",className:A?"mdocs-ai-write-stop":void 0,disabled:A?!1:!(C!=null&&C.enabled),onClick:()=>{var n;if(A){(n=v.current)==null||n.abort();return}re()},children:A?"停止":"发送"})]})]})]}),e.jsx(Ve,{currentMd:s,proposedMd:r,sending:A,onCurrentChange:i,onProposedChange:f})]}),x?e.jsx(Te,{message:x.message,confirmLabel:x.confirmLabel,cancelLabel:x.cancelLabel,danger:x.danger,onConfirm:()=>ce(!0),onCancel:()=>ce(!1)}):null]})}export{rt as AiWriteWorkbench};
@@ -1,2 +1,2 @@
1
- import{Q as I,S as H,T as F,U as O,V as G}from"./react-DKdyUY61.js";import{r as c,j as e}from"./react-vendor-BuABiQkA.js";import{ensureMeta2dShapes as X,generateSvgFromMeta2d as Q,generateSvgFromDiagram as Y}from"./meta2dEngine-BD2XbzaV-CvZrtSgN.js";import{M as _}from"./meta2d-1-g23JOU.js";import"./editor-CL03se2B.js";import"./ui-CvA4pq3d.js";import"./motion-DFABYlwt.js";import"./diagram-Bk84WZto.js";import"./index-7ZIkBACf.js";import"./plus-C5AB-V4P.js";import"./check-BCinw6C1.js";import"./copy-B4T4wJbp.js";let q=0;const P=new Set;function $(n){return P.add(n),()=>{P.delete(n)}}function M(){return q}function J(){q++,P.forEach(n=>n())}function z(n){let t=null;try{const[r]=I();t=r}catch{}const i=t;if(!i)throw new Error("[useEditorLocale] No editor found. Pass an editor instance or use this hook inside an <Editor> tree.");return c.useSyncExternalStore($,M,M),{setLocale:c.useCallback(r=>{i.setLocale(r),J()},[i]),t:c.useCallback((r,u)=>i.t(r,u),[i])}}const K={Activity:"meta2d.palette.groups.activity",Basic:"meta2d.palette.groups.basic","Fault tree":"meta2d.palette.groups.faultTree",Flow:"meta2d.palette.groups.flow","Sequence & class":"meta2d.palette.groups.sequenceClass"};function W(n){return`meta2d.palette.${n}`}const s={background:"#fff",color:"#1f1f1f",height:60,lineWidth:1,textColor:"#1f1f1f",width:120};function U(){return[{group:"Basic",key:"square",label:"Square",pen:{...s,height:100,name:"square",text:"",width:100}},{group:"Basic",key:"rect",label:"Rectangle",pen:{...s,name:"rectangle",text:"Rectangle"}},{group:"Basic",key:"roundRect",label:"Rounded",pen:{...s,borderRadius:.2,name:"rectangle",text:"Rounded"}},{group:"Basic",key:"circle",label:"Circle",pen:{...s,height:80,name:"circle",text:"Circle",width:80}},{group:"Basic",key:"triangle",label:"Triangle",pen:{...s,height:90,name:"triangle",text:"Triangle",width:100}},{group:"Basic",key:"diamond",label:"Diamond",pen:{...s,height:100,name:"diamond",text:"Decision",width:100}},{group:"Basic",key:"pentagon",label:"Pentagon",pen:{...s,height:100,name:"pentagon",text:"Pentagon",width:100}},{group:"Basic",key:"hexagon",label:"Hexagon",pen:{...s,height:100,name:"hexagon",text:"Hexagon",width:100}},{group:"Basic",key:"pentagram",label:"Star",pen:{...s,height:100,name:"pentagram",text:"",width:100}},{group:"Basic",key:"leftArrow",label:"Left arrow",pen:{height:60,name:"leftArrow",width:120}},{group:"Basic",key:"rightArrow",label:"Right arrow",pen:{height:60,name:"rightArrow",width:120}},{group:"Basic",key:"twowayArrow",label:"Two-way",pen:{height:60,name:"twowayArrow",width:150}},{group:"Basic",key:"cloud",label:"Cloud",pen:{height:100,name:"cloud",width:100}},{group:"Basic",key:"message",label:"Message",pen:{height:100,name:"message",textTop:-.1,width:100}},{group:"Basic",key:"file",label:"File",pen:{height:100,name:"file",width:80}},{group:"Basic",key:"cube",label:"Cube",pen:{height:100,name:"cube",width:60,z:.25}},{group:"Basic",key:"people",label:"Actor",pen:{height:100,name:"people",width:70}},{group:"Basic",key:"text",label:"Text",pen:{...s,background:"transparent",color:"transparent",height:32,name:"text",text:"text",width:120}},{group:"Basic",key:"line",label:"Line",pen:{color:"#1f1f1f",height:1,lineWidth:1,name:"line",width:160}},{group:"Flow",key:"flowTerminal",label:"Terminal",pen:{...s,borderRadius:.5,height:40,name:"rectangle",text:"Start / End",width:120}},{group:"Flow",key:"flowProcess",label:"Process",pen:{...s,height:40,name:"rectangle",text:"Process",width:120}},{group:"Flow",key:"flowDecision",label:"Decision",pen:{...s,height:60,name:"diamond",text:"Decision",width:120}},{group:"Flow",key:"flowData",label:"Data",pen:{...s,name:"flowData",offsetX:.14,text:"Data"}},{group:"Flow",key:"flowPrepare",label:"Prepare",pen:{...s,height:50,name:"hexagon",text:"Prepare",width:120}},{group:"Flow",key:"flowSubprocess",label:"Subprocess",pen:{...s,height:50,name:"flowSubprocess",text:"Subprocess",width:120}},{group:"Flow",key:"flowDb",label:"Database",pen:{...s,height:100,name:"flowDb",text:"DB",width:80}},{group:"Flow",key:"flowDocument",label:"Document",pen:{...s,height:100,name:"flowDocument",text:"Document",width:120}},{group:"Flow",key:"flowInternalStorage",label:"Int. storage",pen:{...s,height:80,name:"flowInternalStorage",text:"Internal",width:120}},{group:"Flow",key:"flowExternStorage",label:"Ext. storage",pen:{...s,height:80,name:"flowExternStorage",text:"External",width:120}},{group:"Flow",key:"flowQueue",label:"Queue",pen:{...s,height:100,name:"flowQueue",text:"Queue",width:100}},{group:"Flow",key:"flowManually",label:"Manual input",pen:{...s,height:80,name:"flowManually",text:"Manual",width:120}},{group:"Flow",key:"flowDisplay",label:"Display",pen:{...s,height:80,name:"flowDisplay",text:"Display",width:120}},{group:"Flow",key:"flowParallel",label:"Parallel",pen:{...s,height:50,name:"flowParallel",text:"Parallel",width:120}},{group:"Flow",key:"flowComment",label:"Comment",pen:{...s,height:100,name:"flowComment",text:"Note",width:100}},{group:"Activity",key:"actStart",label:"Start",pen:{background:"#555",height:30,lineWidth:0,name:"circle",text:"",width:30}},{group:"Activity",key:"actFinal",label:"Final",pen:{height:30,name:"activityFinal",width:30}},{group:"Activity",key:"actStep",label:"Action",pen:{...s,borderRadius:.25,height:50,name:"rectangle",text:"Action",width:120}},{group:"Activity",key:"actMerge",label:"Merge",pen:{...s,height:50,name:"diamond",text:"Merge",width:120}},{group:"Activity",key:"swimlaneV",label:"Swimlane V",pen:{height:500,lineTop:.08,name:"swimlaneV",text:"Swimlane",textBaseline:"top",textTop:20,width:200}},{group:"Activity",key:"swimlaneH",label:"Swimlane H",pen:{height:200,lineLeft:.08,name:"swimlaneH",text:"Swimlane",textAlign:"left",textLeft:.04,textWidth:.01,width:500}},{group:"Activity",key:"forkV",label:"Fork V",pen:{fillStyle:"#555",height:150,name:"forkV",strokeStyle:"transparent",text:"",width:10}},{group:"Activity",key:"forkH",label:"Fork H",pen:{fillStyle:"#555",height:10,name:"forkH",strokeStyle:"transparent",text:"",width:150}},{group:"Sequence & class",key:"lifeline",label:"Lifeline",pen:{height:400,name:"lifeline",text:"Object",textHeight:50,width:150}},{group:"Sequence & class",key:"sequenceFocus",label:"Activation",pen:{height:200,name:"sequenceFocus",text:"",width:12}},{group:"Sequence & class",key:"simpleClass",label:"Simple class",pen:{height:200,list:[{text:`- name: string
1
+ import{Q as I,S as H,T as F,U as O,V as G}from"./react-CI5PDFXT.js";import{r as c,j as e}from"./react-vendor-BuABiQkA.js";import{ensureMeta2dShapes as X,generateSvgFromMeta2d as Q,generateSvgFromDiagram as Y}from"./meta2dEngine-BD2XbzaV-Bq3HuUfD.js";import{M as _}from"./meta2d-1-g23JOU.js";import"./editor-CL03se2B.js";import"./ui-CvA4pq3d.js";import"./motion-DFABYlwt.js";import"./diagram-Bk84WZto.js";import"./index-OmOf_og0.js";import"./plus-DKKQ-AoS.js";import"./check-soiTDN2u.js";import"./copy-B4fvX0p8.js";let q=0;const P=new Set;function $(n){return P.add(n),()=>{P.delete(n)}}function M(){return q}function J(){q++,P.forEach(n=>n())}function z(n){let t=null;try{const[r]=I();t=r}catch{}const i=t;if(!i)throw new Error("[useEditorLocale] No editor found. Pass an editor instance or use this hook inside an <Editor> tree.");return c.useSyncExternalStore($,M,M),{setLocale:c.useCallback(r=>{i.setLocale(r),J()},[i]),t:c.useCallback((r,u)=>i.t(r,u),[i])}}const K={Activity:"meta2d.palette.groups.activity",Basic:"meta2d.palette.groups.basic","Fault tree":"meta2d.palette.groups.faultTree",Flow:"meta2d.palette.groups.flow","Sequence & class":"meta2d.palette.groups.sequenceClass"};function W(n){return`meta2d.palette.${n}`}const s={background:"#fff",color:"#1f1f1f",height:60,lineWidth:1,textColor:"#1f1f1f",width:120};function U(){return[{group:"Basic",key:"square",label:"Square",pen:{...s,height:100,name:"square",text:"",width:100}},{group:"Basic",key:"rect",label:"Rectangle",pen:{...s,name:"rectangle",text:"Rectangle"}},{group:"Basic",key:"roundRect",label:"Rounded",pen:{...s,borderRadius:.2,name:"rectangle",text:"Rounded"}},{group:"Basic",key:"circle",label:"Circle",pen:{...s,height:80,name:"circle",text:"Circle",width:80}},{group:"Basic",key:"triangle",label:"Triangle",pen:{...s,height:90,name:"triangle",text:"Triangle",width:100}},{group:"Basic",key:"diamond",label:"Diamond",pen:{...s,height:100,name:"diamond",text:"Decision",width:100}},{group:"Basic",key:"pentagon",label:"Pentagon",pen:{...s,height:100,name:"pentagon",text:"Pentagon",width:100}},{group:"Basic",key:"hexagon",label:"Hexagon",pen:{...s,height:100,name:"hexagon",text:"Hexagon",width:100}},{group:"Basic",key:"pentagram",label:"Star",pen:{...s,height:100,name:"pentagram",text:"",width:100}},{group:"Basic",key:"leftArrow",label:"Left arrow",pen:{height:60,name:"leftArrow",width:120}},{group:"Basic",key:"rightArrow",label:"Right arrow",pen:{height:60,name:"rightArrow",width:120}},{group:"Basic",key:"twowayArrow",label:"Two-way",pen:{height:60,name:"twowayArrow",width:150}},{group:"Basic",key:"cloud",label:"Cloud",pen:{height:100,name:"cloud",width:100}},{group:"Basic",key:"message",label:"Message",pen:{height:100,name:"message",textTop:-.1,width:100}},{group:"Basic",key:"file",label:"File",pen:{height:100,name:"file",width:80}},{group:"Basic",key:"cube",label:"Cube",pen:{height:100,name:"cube",width:60,z:.25}},{group:"Basic",key:"people",label:"Actor",pen:{height:100,name:"people",width:70}},{group:"Basic",key:"text",label:"Text",pen:{...s,background:"transparent",color:"transparent",height:32,name:"text",text:"text",width:120}},{group:"Basic",key:"line",label:"Line",pen:{color:"#1f1f1f",height:1,lineWidth:1,name:"line",width:160}},{group:"Flow",key:"flowTerminal",label:"Terminal",pen:{...s,borderRadius:.5,height:40,name:"rectangle",text:"Start / End",width:120}},{group:"Flow",key:"flowProcess",label:"Process",pen:{...s,height:40,name:"rectangle",text:"Process",width:120}},{group:"Flow",key:"flowDecision",label:"Decision",pen:{...s,height:60,name:"diamond",text:"Decision",width:120}},{group:"Flow",key:"flowData",label:"Data",pen:{...s,name:"flowData",offsetX:.14,text:"Data"}},{group:"Flow",key:"flowPrepare",label:"Prepare",pen:{...s,height:50,name:"hexagon",text:"Prepare",width:120}},{group:"Flow",key:"flowSubprocess",label:"Subprocess",pen:{...s,height:50,name:"flowSubprocess",text:"Subprocess",width:120}},{group:"Flow",key:"flowDb",label:"Database",pen:{...s,height:100,name:"flowDb",text:"DB",width:80}},{group:"Flow",key:"flowDocument",label:"Document",pen:{...s,height:100,name:"flowDocument",text:"Document",width:120}},{group:"Flow",key:"flowInternalStorage",label:"Int. storage",pen:{...s,height:80,name:"flowInternalStorage",text:"Internal",width:120}},{group:"Flow",key:"flowExternStorage",label:"Ext. storage",pen:{...s,height:80,name:"flowExternStorage",text:"External",width:120}},{group:"Flow",key:"flowQueue",label:"Queue",pen:{...s,height:100,name:"flowQueue",text:"Queue",width:100}},{group:"Flow",key:"flowManually",label:"Manual input",pen:{...s,height:80,name:"flowManually",text:"Manual",width:120}},{group:"Flow",key:"flowDisplay",label:"Display",pen:{...s,height:80,name:"flowDisplay",text:"Display",width:120}},{group:"Flow",key:"flowParallel",label:"Parallel",pen:{...s,height:50,name:"flowParallel",text:"Parallel",width:120}},{group:"Flow",key:"flowComment",label:"Comment",pen:{...s,height:100,name:"flowComment",text:"Note",width:100}},{group:"Activity",key:"actStart",label:"Start",pen:{background:"#555",height:30,lineWidth:0,name:"circle",text:"",width:30}},{group:"Activity",key:"actFinal",label:"Final",pen:{height:30,name:"activityFinal",width:30}},{group:"Activity",key:"actStep",label:"Action",pen:{...s,borderRadius:.25,height:50,name:"rectangle",text:"Action",width:120}},{group:"Activity",key:"actMerge",label:"Merge",pen:{...s,height:50,name:"diamond",text:"Merge",width:120}},{group:"Activity",key:"swimlaneV",label:"Swimlane V",pen:{height:500,lineTop:.08,name:"swimlaneV",text:"Swimlane",textBaseline:"top",textTop:20,width:200}},{group:"Activity",key:"swimlaneH",label:"Swimlane H",pen:{height:200,lineLeft:.08,name:"swimlaneH",text:"Swimlane",textAlign:"left",textLeft:.04,textWidth:.01,width:500}},{group:"Activity",key:"forkV",label:"Fork V",pen:{fillStyle:"#555",height:150,name:"forkV",strokeStyle:"transparent",text:"",width:10}},{group:"Activity",key:"forkH",label:"Fork H",pen:{fillStyle:"#555",height:10,name:"forkH",strokeStyle:"transparent",text:"",width:150}},{group:"Sequence & class",key:"lifeline",label:"Lifeline",pen:{height:400,name:"lifeline",text:"Object",textHeight:50,width:150}},{group:"Sequence & class",key:"sequenceFocus",label:"Activation",pen:{height:200,name:"sequenceFocus",text:"",width:12}},{group:"Sequence & class",key:"simpleClass",label:"Simple class",pen:{height:200,list:[{text:`- name: string
2
2
  + setName(name: string): void`}],name:"simpleClass",text:"ClassName",textAlign:"center",textBaseline:"top",textHeight:200,textTop:10,width:270}},{group:"Sequence & class",key:"interfaceClass",label:"Class",pen:{height:200,list:[{text:"- name: string"},{text:"+ setName(name: string): void"}],name:"interfaceClass",text:"ClassName",textAlign:"center",textBaseline:"top",textHeight:200,textTop:10,width:270}},{group:"Fault tree",key:"andGate",label:"AND gate",pen:{height:150,name:"andGate",width:100}},{group:"Fault tree",key:"orGate",label:"OR gate",pen:{height:150,name:"orGate",width:100}},{group:"Fault tree",key:"basicEvent",label:"Basic event",pen:{height:150,name:"basicEvent",width:100}},{group:"Fault tree",key:"xorGate",label:"XOR gate",pen:{height:150,name:"xorGate",width:100}},{group:"Fault tree",key:"votingGate",label:"Voting gate",pen:{height:150,name:"votingGate",width:100}}]}function V(n){return G(structuredClone(n))}function Z(n){const t=new Map;for(const i of n){const r=t.get(i.group)??[];r.push(i),t.set(i.group,r)}return Array.from(t.entries())}function ee({name:n}){const t={fill:"#fff",stroke:"#1f1f1f",strokeWidth:1.2};return n==="circle"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("circle",{cx:"14",cy:"14",r:"10",...t})}):n==="diamond"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,3 25,14 14,25 3,14",...t})}):n==="triangle"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,4 25,24 3,24",...t})}):n==="pentagon"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,3 25,12 21,25 7,25 3,12",...t})}):n==="hexagon"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"8,4 20,4 25,14 20,24 8,24 3,14",...t})}):n==="pentagram"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,3 17,11 26,11 18,16 21,25 14,20 7,25 10,16 2,11 11,11",...t})}):n==="line"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("line",{x1:"4",x2:"24",y1:"14",y2:"14",...t})}):n==="text"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("text",{dominantBaseline:"middle",fill:"#1f1f1f",fontSize:"14",textAnchor:"middle",x:"14",y:"15",children:"T"})}):e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("rect",{height:"14",rx:"2",width:"20",x:"4",y:"7",...t})})}function te({disabled:n,engineRef:t,item:i,t:r}){const u=()=>{const a=t.current;if(!(!a||n))try{a.canvas.addCaches=[V(i.pen)]}catch{}};return e.jsxs("div",{draggable:!n,onClick:a=>{a.stopPropagation(),u()},onDragStart:a=>{if(n){a.preventDefault();return}const f=JSON.stringify(V(i.pen));a.dataTransfer.setData("Meta2d",f),a.dataTransfer.setData("Text",f),a.dataTransfer.effectAllowed="copy"},onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),u())},role:"button",style:{alignItems:"center",border:"1px solid #efefef",borderRadius:6,cursor:n?"not-allowed":"grab",display:"flex",flexDirection:"column",gap:4,justifyContent:"center",minHeight:56,opacity:n?.5:1,outline:"none",padding:6},tabIndex:n?-1:0,title:`${r(W(i.key))||i.label} — drag or click to add`,children:[e.jsx(ee,{name:String(i.pen.name??"rectangle")}),e.jsx("span",{style:{fontSize:11},children:r(W(i.key))||i.label})]})}function ne({disabled:n,engineRef:t}){const{t:i}=z(),r=c.useMemo(()=>Z(U()),[]);return e.jsxs("aside",{style:{borderRight:"1px solid #f0f0f0",flexShrink:0,maxHeight:"100%",overflowX:"hidden",overflowY:"auto",overscrollBehavior:"contain",padding:12,touchAction:"pan-y",width:240},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,marginBottom:4},children:i("meta2d.palette.title")}),e.jsx("div",{style:{color:"#8c8c8c",fontSize:12,marginBottom:12},children:i("meta2d.palette.hint")}),r.map(([u,a])=>e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:{color:"#8c8c8c",fontSize:12,marginBottom:6},children:i(K[u]||u)}),e.jsx("div",{style:{display:"grid",gap:8,gridTemplateColumns:"repeat(2, minmax(0, 1fr))"},children:a.map(f=>e.jsx(te,{disabled:n,engineRef:t,item:f,t:i},f.key))})]},u))]})}const N={borderLeft:"1px solid #f0f0f0",flexShrink:0,maxHeight:"100%",overflowX:"hidden",overflowY:"auto",overscrollBehavior:"contain",touchAction:"pan-y",width:220},A={color:"#8c8c8c",fontSize:12,marginBottom:4},D={borderBottom:"1px solid #f0f0f0",padding:"10px 12px"},y={alignItems:"center",display:"flex",gap:6,marginBottom:6},w={background:"#fafafa",border:"1px solid #e5e5e5",borderRadius:4,fontSize:12,height:28,outline:"none",padding:"0 6px"},b={color:"#8c8c8c",fontSize:11,minWidth:22},T={background:"#fff",border:"1px solid #d9d9d9",borderRadius:4,cursor:"pointer",fontSize:11,minWidth:48,padding:"4px 8px"},le=120;function ie({engine:n}){const{t}=z(),[i,r]=c.useState(null),[u,a]=c.useState(null),[f,v]=c.useState(""),p=c.useRef(null),j=c.useRef(null),B=c.useCallback((l,d)=>{!n||l===null||l===void 0||n.setValue({id:l,text:d},{render:!0})},[n]),k=c.useCallback(l=>{if(!l||l.length!==1){p.current&&(clearTimeout(p.current),p.current=null),r(null),a(null),v(""),j.current=null;return}const d=l[0];if((d.globalAlpha===null||d.globalAlpha===void 0)&&(d.globalAlpha=1),d.id!==j.current&&(p.current&&(clearTimeout(p.current),p.current=null),j.current=d.id,v(d.text??"")),r(d),n)try{a(n.getPenRect(d))}catch{a(null)}},[n]),C=c.useCallback(()=>{p.current&&(clearTimeout(p.current),p.current=null),r(null),a(null),v(""),j.current=null},[]);if(c.useEffect(()=>{if(n)return n.on("active",k),n.on("inactive",C),()=>{n.off("active",k),n.off("inactive",C),p.current&&(clearTimeout(p.current),p.current=null)}},[n,k,C]),!i||!n)return e.jsx("aside",{style:N,children:e.jsx("div",{style:{color:"#bbb",fontSize:12,padding:16,textAlign:"center"},children:t("meta2d.props.empty")})});const h=(l,d)=>{const m={id:i.id};m[l]=d,l==="dash"&&(m.lineDash=[void 0,[5,5]][d]),l!=="text"&&r(S=>S&&{...S,...m}),n.setValue(m,{render:!0})},o=l=>{v(l);const d=i.id;p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{p.current=null,B(d,l)},le)},x=()=>{p.current&&(clearTimeout(p.current),p.current=null),B(i.id,f)},g=(l,d)=>{if(!u)return;const m={id:i.id};m[l]=d,n.setValue(m,{render:!0}),a(S=>S?{...S,[l]:d}:null)},R=l=>{l(n),n.render(!0)};return e.jsxs("aside",{style:N,children:[e.jsxs("div",{style:D,children:[e.jsx("div",{style:A,children:t("meta2d.props.text")}),e.jsx("div",{style:y,children:e.jsx("input",{onBlur:x,onChange:l=>o(l.target.value),onKeyDown:l=>{l.stopPropagation(),l.key==="Enter"&&(l.preventDefault(),l.target.blur())},style:{...w,flex:1,width:"100%"},type:"text",value:f})})]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:{...A,marginBottom:6},children:t("meta2d.props.appearance")}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.color")}),e.jsx("input",{onChange:l=>h("color",l.target.value),style:{...w,flex:1},type:"color",value:i.color||"#1f1f1f"})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.bg")}),e.jsx("input",{onChange:l=>h("background",l.target.value),style:{...w,flex:1},type:"color",value:i.background||"#ffffff"})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.dash")}),e.jsxs("select",{onChange:l=>h("dash",Number(l.target.value)),style:{...w,flex:1},value:String(i.dash??0),children:[e.jsx("option",{value:"0",children:t("meta2d.props.solid")}),e.jsx("option",{value:"1",children:t("meta2d.props.dashLine")})]})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.radius")}),e.jsx("input",{max:1,min:0,onChange:l=>h("borderRadius",Number(l.target.value)),step:.01,style:{...w,flex:1},type:"range",value:String(i.borderRadius??0)}),e.jsx("span",{style:{color:"#8c8c8c",fontSize:11,width:32},children:i.borderRadius??0})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.alpha")}),e.jsx("input",{max:1,min:0,onChange:l=>h("globalAlpha",Number(l.target.value)),step:.01,style:{...w,flex:1},type:"range",value:String(i.globalAlpha??1)}),e.jsx("span",{style:{color:"#8c8c8c",fontSize:11,width:32},children:(i.globalAlpha??1).toFixed(2)})]})]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:{...A,marginBottom:6},children:t("meta2d.props.position")}),[["X","x"],["Y","y"],["W","width"],["H","height"]].map(([l,d])=>e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:l}),e.jsx("input",{onChange:m=>g(d,Number(m.target.value)),style:{...w,flex:1},type:"number",value:u?u[d]:0})]},d))]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:{...A,marginBottom:6},children:t("meta2d.props.textAlign")}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.h")}),e.jsxs("select",{onChange:l=>h("textAlign",l.target.value),style:{...w,flex:1},value:i.textAlign||"center",children:[e.jsx("option",{value:"left",children:t("meta2d.props.left")}),e.jsx("option",{value:"center",children:t("meta2d.props.center")}),e.jsx("option",{value:"right",children:t("meta2d.props.right")})]})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.v")}),e.jsxs("select",{onChange:l=>h("textBaseline",l.target.value),style:{...w,flex:1},value:i.textBaseline||"middle",children:[e.jsx("option",{value:"top",children:t("meta2d.props.topAlign")}),e.jsx("option",{value:"middle",children:t("meta2d.props.middle")}),e.jsx("option",{value:"bottom",children:t("meta2d.props.bottomAlign")})]})]})]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:{...A,marginBottom:6},children:t("meta2d.props.layer")}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[e.jsx("button",{onClick:()=>R(l=>l.top()),style:T,type:"button",children:t("meta2d.props.top")}),e.jsx("button",{onClick:()=>R(l=>l.up()),style:T,type:"button",children:t("meta2d.props.up")}),e.jsx("button",{onClick:()=>R(l=>l.down()),style:T,type:"button",children:t("meta2d.props.down")}),e.jsx("button",{onClick:()=>R(l=>l.bottom()),style:T,type:"button",children:t("meta2d.props.bottom")})]})]})]})}const L={background:"#fff",border:"1px solid #d9d9d9",borderRadius:6,cursor:"pointer",minWidth:68,padding:"6px 12px"},E={...L,fontSize:12,minWidth:52,padding:"4px 10px"};function re(n){c.useEffect(()=>{const t=document.documentElement,i=document.body,r=t.style.overflow,u=i.style.overflow;return t.style.overflow="hidden",i.style.overflow="hidden",()=>{t.style.overflow=r,i.style.overflow=u}},[n])}function ye({diagram:n,onClose:t,onSave:i}){const{t:r}=z(),u=c.useRef(null),a=c.useRef(null),f=c.useRef(n),v=c.useRef(t),[p,j]=c.useState(null),[B,k]=c.useState(!1);re(!0),c.useLayoutEffect(()=>{v.current=t}),c.useEffect(()=>{if(!u.current)return;X();const o=new _(u.current,{grid:!0,rule:!1});a.current=o,j(o);try{const g=f.current;g!=null&&g.trim()?o.open(JSON.parse(g)):o.open(H()),F(o.data()),o.render(!0)}catch{o.open(H()),F(o.data()),o.render(!0)}const x=g=>{g.key==="Escape"&&v.current()};return window.addEventListener("keydown",x),()=>{window.removeEventListener("keydown",x);try{o.destroy()}catch{}a.current=null}},[]);const C=async()=>{const o=a.current;if(o){k(!0);try{F(o.data()),o.render(!0);const x=O(o.data()),g=JSON.stringify(x);i(g,await Q(o)||await Y(g)||'<svg xmlns="http://www.w3.org/2000/svg" width="320" height="180" viewBox="0 0 320 180"><rect width="100%" height="100%" fill="#fafafa" stroke="#eee"/></svg>')}finally{k(!1)}}},h=o=>{const x=a.current;x&&o(x)};return e.jsx("div",{onClick:t,style:{alignItems:"center",background:"rgb(0 0 0 / 35%)",display:"flex",inset:0,justifyContent:"center",overflow:"hidden",position:"fixed",zIndex:1e3},children:e.jsxs("div",{onClick:o=>o.stopPropagation(),onWheel:o=>o.stopPropagation(),style:{background:"#fff",borderRadius:10,boxShadow:"0 12px 30px rgb(0 0 0 / 20%)",display:"flex",flexDirection:"column",height:"86vh",maxHeight:"100%",maxWidth:"1200px",overflow:"hidden",width:"92vw"},children:[e.jsxs("div",{style:{alignItems:"center",borderBottom:"1px solid #f0f0f0",display:"flex",flexWrap:"wrap",gap:8,justifyContent:"space-between",padding:"10px 14px"},children:[e.jsx("span",{style:{fontWeight:600},children:r("meta2d.editor.title")}),e.jsxs("div",{style:{alignItems:"center",display:"flex",flexWrap:"wrap",gap:8},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:[e.jsx("button",{onClick:()=>h(o=>o.undo()),style:E,title:`${r("meta2d.editor.undo")} (Ctrl+Z)`,type:"button",children:r("meta2d.editor.undo")}),e.jsx("button",{onClick:()=>h(o=>o.redo()),style:E,title:`${r("meta2d.editor.redo")} (Ctrl+Y)`,type:"button",children:r("meta2d.editor.redo")}),e.jsx("button",{onClick:()=>h(o=>o.delete()),style:E,title:r("meta2d.editor.delete"),type:"button",children:r("meta2d.editor.delete")}),e.jsx("button",{onClick:()=>h(o=>o.fitView(!0)),style:E,title:r("meta2d.editor.fit"),type:"button",children:r("meta2d.editor.fit")}),e.jsx("button",{onClick:()=>h(o=>{o.scale(1),o.centerView()}),style:E,title:r("meta2d.editor.zoom100"),type:"button",children:r("meta2d.editor.zoom100")})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:t,style:L,type:"button",children:r("meta2d.editor.close")}),e.jsx("button",{disabled:B,onClick:()=>void C(),style:{...L,background:"#1677ff",border:"none",color:"#fff"},type:"button",children:r(B?"meta2d.editor.saving":"meta2d.editor.save")})]})]})]}),e.jsxs("div",{style:{display:"flex",flex:1,minHeight:0,overflow:"hidden"},children:[e.jsx(ne,{engineRef:a}),e.jsx("div",{ref:u,style:{flex:1,minHeight:0,minWidth:0}}),e.jsx(ie,{engine:p})]})]})})}export{ye as DiagramEditor};
@@ -0,0 +1,21 @@
1
+ import{o as d,c as v,F as D,P as M,p as x,l as k,R as j,E as B,q as P,S as E,M as S}from"./index-OmOf_og0.js";import{r as I,j as n}from"./react-vendor-BuABiQkA.js";import{g as W}from"./file-type-policy-GUk904tm.js";/**
2
+ * @license lucide-react v0.562.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const w=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],z=d("chevron-up",w);/**
7
+ * @license lucide-react v0.562.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const A=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M6.376 18.91a6 6 0 0 1 11.249.003",key:"hnjrf2"}],["circle",{cx:"12",cy:"11",r:"4",key:"1gt34v"}]],L=d("shield-user",A);/**
12
+ * @license lucide-react v0.562.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const O=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],R=d("text-align-justify",O);/**
17
+ * @license lucide-react v0.562.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const _=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],$=d("users",_);function q(e){const{t,lang:m}=v(),l=W(e.fileType||"md"),f=!!(l!=null&&l.aiWrite&&e.onAiWrite),C=!!(l!=null&&l.comments&&e.onToggleComments);e.canEdit&&(e.editing||e.actionsAlwaysVisible);const[o,N]=I.useState(!1),r=e.domains.length?e.domains:[D],c="mdocs-editor-toolbar"+(e.readerChrome?e.readerHeaderDocked?" mdocs-editor-toolbar--docked":" mdocs-editor-toolbar--float":""),s=e.readerChrome&&!e.readerHeaderDocked&&e.readerDragOffset?{transform:`translateY(${e.readerDragOffset}px)`}:void 0;if(e.readerChrome){const a=n.jsxs("div",{className:"mdocs-editor-toolbar-leading",onPointerDown:e.onReaderHeaderPointerDown,onPointerMove:e.onReaderHeaderPointerMove,onPointerUp:e.onReaderHeaderPointerUp,onPointerCancel:e.onReaderHeaderPointerUp,children:[n.jsx("button",{type:"button",className:"mdocs-reader-nav-btn",onClick:()=>{var i;return(i=e.onOpenMobileNav)==null?void 0:i.call(e)},"aria-label":t("expandSidebar"),children:n.jsx(M,{size:18,strokeWidth:1.75})}),n.jsx("input",{className:"mdocs-editor-title-input",value:e.displayName,onChange:i=>e.onDisplayNameChange(i.target.value),onBlur:e.onDisplayNameBlur,placeholder:t("displayNamePlaceholder"),disabled:!e.editing,readOnly:!e.editing})]}),u=n.jsx(x,{domains:r,value:e.currentDomainId,onChange:e.onDomainChange,onDomainsChange:e.onDomainsChange,ariaLabel:t("currentDomainAria"),localizeName:i=>k(i,m,t)}),h=e.canEdit&&e.onPublish?n.jsx("button",{type:"button",className:"primary mdocs-reader-action-btn",disabled:e.busy,onClick:()=>{var i,g;e.editing||(i=e.onEnterEdit)==null||i.call(e),(g=e.onPublish)==null||g.call(e)},children:e.busy?t("publishing"):t("publish")}):null,y=e.onSyncClick?n.jsx("button",{type:"button",className:"mdocs-sync-btn mdocs-reader-sync-btn"+(e.syncBehind?" behind":""),"aria-label":e.syncBehind?t("syncBehindHint"):t("syncPull"),onClick:()=>{var i;return void((i=e.onSyncClick)==null?void 0:i.call(e))},children:n.jsx(j,{size:16,strokeWidth:1.75})}):null,b=e.readerMoreMenu!=null?n.jsxs("div",{ref:e.readerMoreMenuRef,className:"mdocs-reader-more-menu",children:[n.jsx("button",{type:"button",className:"mdocs-reader-more-btn","aria-label":"更多","aria-expanded":e.readerMoreOpen,onClick:()=>{var i;return(i=e.onToggleReaderMore)==null?void 0:i.call(e)},children:n.jsx(B,{size:18,strokeWidth:1.75})}),e.readerMoreOpen?n.jsx("div",{className:"mdocs-reader-more-dropdown card",children:e.readerMoreMenu}):null]}):null;return e.readerActionsCollapsible?n.jsxs("div",{className:c+" mdocs-editor-toolbar--stacked",style:s,children:[n.jsxs("div",{className:"mdocs-reader-top-row",children:[a,y,n.jsx("button",{type:"button",className:"mdocs-reader-expand-btn",onClick:()=>N(i=>!i),"aria-label":o?"收起操作栏":"展开操作栏",children:n.jsx(z,{size:16,strokeWidth:2,style:{transform:o?"rotate(0deg)":"rotate(180deg)",transition:"transform 0.2s"}})}),b]}),o&&n.jsxs("div",{className:"mdocs-reader-actions-row",children:[u,e.leadingExtra,h,e.trailingExtra]})]}):n.jsxs("div",{className:c,style:s,children:[a,u,e.leadingExtra,y,h,b,e.trailingExtra]})}return n.jsxs("div",{className:c,style:s,children:[n.jsxs("div",{className:"mdocs-editor-toolbar-leading",children:[n.jsx("input",{className:"mdocs-editor-title-input",value:e.displayName,onChange:a=>e.onDisplayNameChange(a.target.value),onBlur:e.onDisplayNameBlur,placeholder:t("displayNamePlaceholder"),disabled:!e.editing}),n.jsx(x,{domains:r,value:e.currentDomainId,onChange:e.onDomainChange,onDomainsChange:e.onDomainsChange,ariaLabel:t("currentDomainAria"),localizeName:a=>k(a,m,t)}),f?n.jsxs("button",{type:"button",className:"secondary",onClick:()=>{var a;return(a=e.onAiWrite)==null?void 0:a.call(e)},style:{padding:"4px 10px",whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",gap:6},children:[n.jsx("img",{src:P,alt:"",width:16,height:16,style:{display:"block"}}),"帮写"]}):null,e.leadingExtra]}),n.jsx("span",{className:"mdocs-editor-toolbar-spacer","aria-hidden":!0}),n.jsxs("div",{className:"mdocs-editor-toolbar-trailing",children:[e.onToggleBookmark?n.jsxs("button",{type:"button",className:"ghost mdocs-tooltip mdocs-tooltip-bottom",onClick:()=>{var a;return(a=e.onToggleBookmark)==null?void 0:a.call(e)},disabled:e.bookmarkBusy,"data-tooltip":e.isBookmarked?"取消收藏":"收藏",style:{padding:"4px 8px",minWidth:"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:4,opacity:e.bookmarkBusy?.5:1},children:[n.jsx(E,{size:18,strokeWidth:1.5,style:{color:e.isBookmarked?"#faad14":"var(--mdocs-text-secondary, #6b7280)",fill:e.isBookmarked?"#faad14":"none"}}),e.isBookmarked?n.jsx("span",{children:"已收藏"}):null]}):null,n.jsxs("div",{className:"mdocs-editor-toolbar-actions",children:[e.onSyncClick?n.jsxs("button",{type:"button",className:"mdocs-sync-btn mdocs-tooltip mdocs-tooltip-bottom"+(e.syncBehind?" behind":""),"data-tooltip":e.syncBehind?t("syncBehindHint"):t("syncPull"),onClick:()=>{var a;return void((a=e.onSyncClick)==null?void 0:a.call(e))},style:{display:"flex",alignItems:"center",gap:4},children:[n.jsx(j,{size:16,strokeWidth:1.5}),n.jsx("span",{children:t("syncPull")})]}):null,e.editing?n.jsxs(n.Fragment,{children:[localStorage.getItem("mdocs.autoPublish")!=="true"&&n.jsxs("span",{className:"mdocs-save-indicator",children:[n.jsx("span",{className:"mdocs-save-dot "+(e.busy?"saving":e.draftExists?"unsaved":"saved")}),n.jsx("span",{children:e.busy?t("publishing"):e.draftExists?t("unsaved"):t("published")})]}),e.onPublish?n.jsx("button",{type:"button",className:"primary",disabled:e.busy,onClick:()=>{var a;return(a=e.onPublish)==null?void 0:a.call(e)},children:e.busy?t("publishing"):t("publish")}):null,e.onDelete?n.jsx("button",{type:"button",className:"danger",disabled:e.busy,onClick:()=>{var a;return(a=e.onDelete)==null?void 0:a.call(e)},children:t("delete")}):null]}):null,!e.editing&&e.canEdit&&e.onEnterEdit?n.jsx("button",{type:"button",className:"primary",onClick:()=>{var a;return(a=e.onEnterEdit)==null?void 0:a.call(e)},children:t("edit")}):null,e.trailingExtra,C?n.jsxs("button",{type:"button",className:"ghost mdocs-tooltip mdocs-tooltip-bottom",onClick:()=>{var a;return(a=e.onToggleComments)==null?void 0:a.call(e)},"data-tooltip":"评论",style:{padding:"4px 8px",minWidth:"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:4,background:e.commentPanelOpen?"var(--mdocs-hover-bg, #f0f0f0)":void 0},children:[n.jsx(S,{size:18,strokeWidth:1.5,style:{color:"var(--mdocs-text-secondary, #6b7280)"}}),e.commentCount&&e.commentCount>0?n.jsx("span",{style:{fontSize:"0.85rem"},children:e.commentCount}):null]}):null,e.onToggleDocInfo?n.jsxs("div",{ref:e.docInfoMenuRef,className:"mdocs-tooltip mdocs-tooltip-bottom","data-tooltip":t("docInfo"),style:{position:"relative"},children:[n.jsx("button",{type:"button",className:"secondary",onClick:()=>{var a;return(a=e.onToggleDocInfo)==null?void 0:a.call(e)},style:{padding:"4px 8px",minWidth:"auto",display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsx(R,{size:18,strokeWidth:1.5,style:{color:"var(--mdocs-text-secondary, #6b7280)"}})}),e.docInfoOpen?n.jsx("div",{className:"mdocs-doc-info-dropdown",children:e.docInfoMenu}):null]}):null]})]})]})}export{q as D,L as S,$ as U};
@@ -0,0 +1 @@
1
+ import{r as n,j as a}from"./react-vendor-BuABiQkA.js";import{ad as ge}from"./ui-CvA4pq3d.js";import{g as be,u as we,a as ye,s as Ue,d as qe,b as ve,c as Ve,f as We,e as Ye,h as Ge,N as Je,S as $e,l as Ke,r as Xe,i as Qe,j as Ze,D as Z,k as pe,m as et,n as xe}from"./index-OmOf_og0.js";import{z as tt,A as nt,m as se,n as at,o as it,p as rt,r as ot,s as st,t as ct,v as lt,x as ut,B as dt,R as mt,a as ft,b as Ie,c as ht,d as gt,e as yt,f as vt,g as xt,h as It,i as kt,w as ce,j as St,O as Et,E as bt,q as wt,l as Mt,C as Ct,D as Dt}from"./react-CI5PDFXT.js";import{H as Rt,a as jt,b as At,M as Nt,T as Pt,S as Tt,W as Bt,o as Lt,c as ke}from"./Toolbar-Hsam79hu.js";import{D as Ot,U as _t,S as Ht}from"./DocChrome-BWMgRxlr.js";import{V as zt}from"./VisitorPickerModal-CqHzml8s.js";import"./motion-DFABYlwt.js";import"./diagram-Bk84WZto.js";import"./editor-CL03se2B.js";import"./plus-DKKQ-AoS.js";import"./check-soiTDN2u.js";import"./copy-B4fvX0p8.js";import"./file-type-policy-GUk904tm.js";const Ft=48;function p(e){try{const i=e.getDocument("markdown");return typeof i=="string"?i:""}catch{return null}}function Ut(e){try{return JSON.stringify(e.getDocument("json"))}catch{return null}}function qt({editor:e,documentId:i,displayName:c,debounceMs:I=1e3,enabled:g=!0,localBaseCommitIdAtEditStart:R,snapshotMeta:b,seedDraftExists:z=!1}){const[F,L]=n.useState(!1),[ee,j]=n.useState(z),[A,S]=n.useState(null),d=n.useRef(null),f=n.useRef(null),k=n.useRef(!1),x=n.useRef(""),v=n.useRef(!1),O=n.useRef(i),U=n.useRef(c),N=n.useRef(R),J=n.useRef(b);O.current=i,U.current=c,N.current=R,J.current=b;const E=n.useCallback(async()=>{if(!e)return;if(!x.current){console.log("[useAutoSave] performSave blocked: lastContentRef is empty");return}const s=Ut(e);s!=null&&(console.log("[useAutoSave] performSave saving draft, documentId:",O.current,"content preview:",s.slice(0,80)),await be(O.current).execute(()=>we({documentId:O.current,content:s,displayName:U.current,localBaseCommitIdAtEditStart:N.current,snapshotMeta:J.current})),x.current=p(e)??x.current,j(!0),L(!1),S(Date.now()),k.current=!0,v.current=!1)},[e]);n.useEffect(()=>{let s=!1;const m=ve();return ye(i).then(h=>{if(s||ve()!==m)return;const y=!!(h&&!h.published);j(y),y&&h?(S(h.updatedAt),k.current=!0):(S(null),k.current=!1,v.current=!1)}),()=>{s=!0}},[i]),n.useEffect(()=>Ue((s,m)=>{s===O.current&&(j(m),m||(S(null),k.current=!1))}),[]),n.useEffect(()=>{var H,q;if(!g){(H=f.current)==null||H.call(f),f.current=null;return}if(!e)return;const s=e.getLexicalEditor();if(!s)return;(q=f.current)==null||q.call(f);let m=!1,h=0,y=0;const _=()=>{if(m)return;const P=p(e);if(P===null){if(y+=1,y>Ft)return;h=requestAnimationFrame(_);return}x.current=P;const ne=s.registerUpdateListener(()=>{const M=p(e);M!==null&&M!==x.current&&(console.log("[useAutoSave] updateListener dirty, documentId:",i,"oldLen:",x.current.length,"newLen:",M.length),x.current=M,L(!0),v.current=!0,k.current=!1,d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,E()},I))});f.current=()=>{ne(),d.current&&(clearTimeout(d.current),d.current=null)}};return queueMicrotask(()=>{m||(h=requestAnimationFrame(_))}),()=>{var P;m=!0,cancelAnimationFrame(h),(P=f.current)==null||P.call(f)}},[g,e,i,c,I,R,b,E]),n.useEffect(()=>{var h;if(!g||!e)return;const s=(h=e.getLexicalEditor())==null?void 0:h.getRootElement();if(!s)return;const m=()=>{d.current&&(clearTimeout(d.current),d.current=null),v.current&&E()};return s.addEventListener("blur",m),()=>s.removeEventListener("blur",m)},[g,e,E]),n.useEffect(()=>{if(!g)return;const s=()=>{document.visibilityState==="hidden"&&(d.current&&(clearTimeout(d.current),d.current=null),v.current&&E())},m=()=>{v.current&&(d.current&&(clearTimeout(d.current),d.current=null),E())};return document.addEventListener("visibilitychange",s),window.addEventListener("beforeunload",m),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("beforeunload",m)}},[g,E]);async function $(){await qe(i),j(!1),L(!1),v.current=!1,k.current=!1,x.current=""}async function te(){const s=await ye(i);return s?s.content:null}function w(){j(!0),L(!1),v.current=!1,S(Date.now()),k.current=!0,e&&(x.current=p(e)??"")}return{isDirty:F,draftExists:ee,lastSavedAt:A,clearDraft:$,loadDraftContent:te,markDraftSaved:w}}function Vt({isDirty:e,draftExists:i}){const c=e&&!i;n.useEffect(()=>{if(!c)return;const I=g=>{g.preventDefault()};return window.addEventListener("beforeunload",I),()=>window.removeEventListener("beforeunload",I)},[c])}function le(e){try{return JSON.stringify(e.getDocument("json"))}catch{return null}}const Se='{"root":{"direction":"ltr","format":"","indent":0,"version":1,"type":"root","children":[{"direction":"ltr","format":"","indent":0,"version":1,"textFormat":0,"textStyle":"","children":[],"type":"paragraph"}]}}';function Ee(e){const c=(e instanceof Error?e.message:String(e)).trim();return/^File too large$/i.test(c)?"文件过大(单文件上限 55MB)":/^unsupported file type$/i.test(c)?"不支持的文件类型":/^not an image$/i.test(c)?"不是有效的图片文件":c||"上传失败"}function Wt(e,i){if(!e)return i==="json"?Se:e;if(i!=="json")return e;try{const c=JSON.parse(e);if(c!=null&&c.root&&Array.isArray(c.root.children)&&c.root.children.length===0)return Se}catch{}return e}function Yt({editor:e}){const{visible:i}=Ct();return a.jsx("div",{className:"mdocs-outline-siderail",style:{flexShrink:0,overflow:"hidden",transition:"width 0.2s ease",width:i?200:0},children:a.jsx("div",{style:{width:200},children:a.jsx(Dt,{editor:e})})})}function sn(e){const{t:i,lang:c}=Ve(),[I,g]=n.useState(!1),[R,b]=n.useState(!1),z=n.useRef(null),F=n.useRef(null),[L,ee]=n.useState([]),[j,A]=n.useState(!1),[S,d]=n.useState(e.meta.permission),[f,k]=n.useState(!1),[x,v]=n.useState(!1),[O,U]=n.useState(!1),[N,J]=n.useState(new Map),[E,$]=n.useState(!1);n.useEffect(()=>{const t=r=>{z.current&&!z.current.contains(r.target)&&g(!1),F.current&&!F.current.contains(r.target)&&b(!1)};return(I||R)&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[I,R]),n.useEffect(()=>{let t=!0;return We().then(r=>{t&&ee(r)}).catch(()=>{}),()=>{t=!1}},[]);function te(t){const r=L.find(l=>l.visitorId===t);return(r==null?void 0:r.visitorName)??t.slice(0,8)}const[w,s]=n.useState(e.initialDisplayName),[m,h]=n.useState(!1),[y,_]=n.useState(!1),[H,q]=n.useState(!1),[P,ne]=n.useState(()=>localStorage.getItem("mdocs.autoEdit")!=="false"),M=e.canEdit&&P,[u,ue]=n.useState(null),[Me,de]=n.useState(!1),ae=n.useRef(null);n.useLayoutEffect(()=>{de(!1),ue(null),ae.current=null},[e.meta.documentId]),n.useEffect(()=>{const t=requestAnimationFrame(()=>de(!0));return()=>cancelAnimationFrame(t)},[e.meta.documentId]);const C=n.useMemo(()=>{var t;if(!e.initialContent)return"json";try{const r=JSON.parse(e.initialContent);return Array.isArray((t=r==null?void 0:r.root)==null?void 0:t.children)?"json":"markdown"}catch{return"markdown"}},[e.initialContent,e.contentRevision]),V=n.useMemo(()=>Wt(e.initialContent||"",C),[e.initialContent,C,e.contentRevision]),{isDirty:me,draftExists:K,markDraftSaved:Ce}=qt({editor:u,documentId:e.meta.documentId,displayName:w,enabled:e.canEdit,localBaseCommitIdAtEditStart:e.meta.headCommitId??null,snapshotMeta:{permission:e.meta.permission,ownerVisitorId:e.meta.ownerVisitorId,domainId:e.meta.domainId},seedDraftExists:e.hasLocalDraft});n.useEffect(()=>{var t;(t=e.onDraftExistsChange)==null||t.call(e,K)},[K,e.onDraftExistsChange]),Vt({isDirty:me,draftExists:K}),n.useEffect(()=>{if(u)try{u.setDocument(C,V)}catch{}},[u,e.meta.documentId,e.contentRevision,V,C]),n.useEffect(()=>{u==null||u.setLocale(c==="zh"?tt:nt)},[u,c]),n.useEffect(()=>{s(e.initialDisplayName)},[e.initialDisplayName,e.meta.documentId,e.contentRevision]),n.useEffect(()=>{d(e.meta.permission)},[e.meta.permission,e.meta.documentId]),n.useEffect(()=>{let t=!0;return(async()=>{try{const r=await Ye(e.meta.documentId);t&&_(r.bookmarked)}catch{}})(),()=>{t=!1}},[e.meta.documentId]);async function ie(){var t,r;if(!H){q(!0);try{y?(await Xe(e.meta.documentId),_(!1),(t=e.onShowToast)==null||t.call(e,i("bookmarkRemoved"))):(await Qe(e.meta.documentId),_(!0),(r=e.onShowToast)==null||r.call(e,i("bookmarkAdded")))}finally{q(!1)}}}n.useEffect(()=>(e.saveBeforeNavRef&&(e.saveBeforeNavRef.current=Be),()=>{e.saveBeforeNavRef&&(e.saveBeforeNavRef.current=void 0)})),n.useEffect(()=>{if(e.exportMarkdownRef)return e.exportMarkdownRef.current=()=>{const t=ae.current;if(!t)return"";try{const r=t.getDocument("markdown");return typeof r=="string"?r:String(r??"")}catch{return""}},()=>{e.exportMarkdownRef&&(e.exportMarkdownRef.current=void 0)}});function De(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}const Re=n.useCallback(t=>{ae.current=t,ue(t);const r=V;if(!r)return;const l=()=>{try{t.setDocument(C,r)}catch{requestAnimationFrame(()=>{try{t.setDocument(C,r)}catch{}})}};queueMicrotask(()=>{queueMicrotask(l)})},[C,V]);async function fe(){if(!(!u||!e.canEdit)){h(!0);try{const t=le(u);if(!t)return;await e.onPublish(t,w,e.meta.documentId)}catch(t){throw t}finally{h(!1)}}}async function je(){if(!e.canEdit)return;const t=e.initialDisplayName.trim();if(w.trim()!==t)try{await fe()}catch{}}const D=n.useMemo(()=>e.domains.find(t=>t.domainId===e.meta.domainId),[e.domains,e.meta.domainId]),Ae=n.useMemo(()=>{const t=(D==null?void 0:D.permission)??"public";return Ge(t)},[D==null?void 0:D.permission]);function Ne(t){return t===Z.PRIVATE?i("permissionPrivate"):t===Z.DOMAIN_READ?i("permissionInvite"):t===Z.DOMAIN_WRITE?i("permissionDomainWrite"):t===Z.PUBLIC_READ?i("permissionPublicRead"):i("permissionPublicEdit")}async function Pe(){var t;if(f||S===e.meta.permission){A(!1);return}k(!0);try{const l=(u?le(u):null)??e.initialContent;await e.onPublish(l,w,e.meta.documentId,S),A(!1),(t=e.onShowToast)==null||t.call(e,i("docInfoPermissionUpdated"))}finally{k(!1)}}async function Te(t){var r;if(!E){$(!0);try{const l=new Set(t.map(o=>o.visitorId)),B=new Map(t.map(o=>[o.visitorId,o.permission]));for(const[o]of N)l.has(o)||await pe(e.meta.documentId,o);for(const{visitorId:o,permission:Y}of t){const G=N.get(o);(!G||G!==Y)&&await et(e.meta.documentId,o,Y)}v(!1),(r=e.onShowToast)==null||r.call(e,i("docInfoInviteSuccess",{count:t.length}))}finally{$(!1)}}}async function Be(){if(!u||!e.canEdit)return;if(!me){console.log("[DocumentEditor.saveDraft] skipped: not dirty, documentId:",e.meta.documentId);return}const t=le(u);t&&(console.log("[DocumentEditor.saveDraft] saving draft, documentId:",e.meta.documentId,"content preview:",t.slice(0,80)),Ce(),await be(e.meta.documentId).execute(()=>we({documentId:e.meta.documentId,content:t,displayName:w,localBaseCommitIdAtEditStart:e.meta.headCommitId??null,snapshotMeta:{permission:e.meta.permission,ownerVisitorId:e.meta.ownerVisitorId,domainId:e.meta.domainId}})))}const Le=n.useMemo(()=>[{icon:Rt,key:"h1",label:"Heading 1",onSelect:t=>{t.dispatchCommand(se,{tag:"h1"})}},{icon:jt,key:"h2",label:"Heading 2",onSelect:t=>{t.dispatchCommand(se,{tag:"h2"})}},{icon:At,key:"h3",label:"Heading 3",onSelect:t=>{t.dispatchCommand(se,{tag:"h3"})}},{type:"divider"},{icon:Nt,key:"hr",label:"Hr",onSelect:t=>{t.dispatchCommand(at,{})}},{icon:Pt,key:"table",label:"Table",onSelect:t=>{t.dispatchCommand(it,{columns:"3",rows:"3"})}},{icon:Tt,key:"tex",label:"TeX",onSelect:t=>{t.dispatchCommand(rt,{code:"x^2 + y^2 = z^2"}),queueMicrotask(()=>t.focus())}},{type:"divider"},{key:"file",label:"File",onSelect:t=>{Lt(r=>{for(const l of r)t.dispatchCommand(wt,{file:l})},".pdf,.zip,.txt,.md,.csv,.html,.htm,audio/*,*/*")}},{key:"insert-link",label:"Insert Link",onSelect:t=>{t.dispatchCommand(ot,{url:"https://example.com"}),queueMicrotask(()=>t.focus())}},{key:"insert-codeInline",label:"Inline Code",onSelect:t=>{t.dispatchCommand(st,void 0),queueMicrotask(()=>t.focus())}},{key:"insert-codeBlock",label:"Code Block",onSelect:t=>{t.dispatchCommand(ct,void 0),queueMicrotask(()=>t.focus())}},{icon:Bt,key:"meta2d",label:"Meta2d",onSelect:t=>{t.dispatchCommand(lt,void 0),queueMicrotask(()=>t.focus())}},{icon:Je,key:"markmap",label:"Markmap",onSelect:t=>{t.dispatchCommand(ut,void 0),queueMicrotask(()=>t.focus())}}].map(t=>"type"in t&&t.type==="divider"?t:{...t,extra:a.jsx("span",{style:{color:"var(--mdocs-text-muted)",fontFamily:"monospace",fontSize:12},children:t.key})}),[]),Oe=n.useMemo(()=>[dt,mt,ft,Ie,ht,gt,yt,vt,xt,It,kt,ce(St,{children:u?a.jsx(ke,{editor:u,floating:!0,outlineCollapseTitle:i("outlineHide"),outlineExpandTitle:i("outlineShow"),outlineToggle:!0}):null}),ce(Mt,{handleUpload:async t=>{var r;try{return{url:await xe(t,e.meta.documentId)}}catch(l){throw(r=e.onShowError)==null||r.call(e,Ee(l)),l}}}),ce(Ie,{defaultBlockImage:!0,needRehost:t=>t.startsWith("blob:"),handleRehost:async t=>{var r;try{const B=await(await fetch(t)).blob(),o=new File([B],"image.png",{type:B.type});return{url:await xe(o,e.meta.documentId)}}catch(l){throw(r=e.onShowError)==null||r.call(e,Ee(l)),l}}})],[u,i,e.meta.documentId,e.onShowError]),T=!!e.readerChrome,[W,re]=n.useState(!1),X=n.useRef(null),[_e,oe]=n.useState(0);n.useEffect(()=>{if(!T){re(!1),oe(0);return}if(W)return;const t=window.setTimeout(()=>re(!0),2800);return()=>window.clearTimeout(t)},[T,W,e.meta.documentId]),n.useEffect(()=>{b(!1),g(!1)},[e.meta.documentId]);function He(t){!T||W||t.target.closest("button, a, input, textarea, select")||(X.current={startY:t.clientY,dragging:!0},t.currentTarget.setPointerCapture(t.pointerId))}function ze(t){const r=X.current;if(!(r!=null&&r.dragging))return;const l=t.clientY-r.startY;oe(Math.max(-72,Math.min(0,l)))}function Fe(t){const r=X.current;if(!(r!=null&&r.dragging))return;X.current=null;const l=t.clientY-r.startY;oe(0),l<-36&&re(!0);try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}function Q(){g(!1),b(!1)}function he(t,r){const l=(r==null?void 0:r.includeBookmark)??!0,B={width:"100%",textAlign:"left",padding:"8px 16px",background:"none",border:"none",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"8px"};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{padding:"4px 16px",fontSize:"13px"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[a.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:i("docInfoCreator")}),a.jsx("span",{children:te(e.meta.ownerVisitorId)})]}),a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[a.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:i("docInfoCreatedAt")}),a.jsx("span",{children:new Date(e.meta.createdAt).toLocaleString(c==="zh"?"zh-CN":"en-US")})]}),a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[a.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:i("docInfoSize")}),a.jsx("span",{children:De(new Blob([e.initialContent]).size)})]}),a.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[a.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:i("docInfoUpdatedAt")}),a.jsx("span",{children:new Date(e.meta.updatedAt).toLocaleString(c==="zh"?"zh-CN":"en-US")})]})]}),a.jsx("div",{style:{height:"1px",background:"var(--mdocs-border, #e5e5e5)",margin:"8px 0"}}),l?a.jsxs("button",{type:"button",style:B,onMouseEnter:o=>{o.currentTarget.style.background="var(--mdocs-hover-bg, #f5f5f5)"},onMouseLeave:o=>{o.currentTarget.style.background="none"},onClick:()=>{ie(),t()},children:[a.jsx("span",{children:y?"⭐":"☆"}),a.jsx("span",{children:i(y?"bookmarkRemove":"bookmarkAdd")})]}):null,e.canManageInvites?a.jsxs("button",{type:"button",style:B,onMouseEnter:o=>{o.currentTarget.style.background="var(--mdocs-hover-bg, #f5f5f5)"},onMouseLeave:o=>{o.currentTarget.style.background="none"},onClick:()=>{t(),(async()=>{U(!0);try{const o=await Ze(e.meta.documentId),Y=new Map(o.map(G=>[G.visitorId,G.permission]));J(Y),v(!0)}finally{U(!1)}})()},children:[a.jsx(_t,{size:14}),a.jsx("span",{children:i("docInfoInviteMember")})]}):null,a.jsxs("button",{type:"button",style:B,onMouseEnter:o=>{o.currentTarget.style.background="var(--mdocs-hover-bg, #f5f5f5)"},onMouseLeave:o=>{o.currentTarget.style.background="none"},onClick:()=>{t(),d(e.meta.permission),A(!0)},children:[a.jsx(Ht,{size:14}),a.jsx("span",{children:i("docInfoChangePermission")})]})]})}return a.jsxs("div",{className:"mdocs-editor"+(T?" mdocs-editor--reader":"")+(T&&W?" mdocs-editor--reader-docked":""),children:[a.jsx(Ot,{fileType:e.meta.fileType||"md",displayName:w,onDisplayNameChange:s,onDisplayNameBlur:()=>void je(),domains:e.domains,currentDomainId:e.currentDomainId,onDomainChange:e.onDomainChange,onDomainsChange:e.onDomainsChange,canEdit:e.canEdit,editing:M,onEnterEdit:()=>ne(!0),onAiWrite:e.onAiWrite,syncBehind:e.syncBehind,onSyncClick:e.onSyncClick,busy:m,draftExists:K,onPublish:()=>{fe().catch(()=>{})},onDelete:()=>{e.onDelete()},isBookmarked:y,bookmarkBusy:H,onToggleBookmark:()=>void ie(),onToggleComments:e.onToggleComments,commentPanelOpen:e.commentPanelOpen,commentCount:e.commentCount,docInfoMenu:he(Q),docInfoOpen:I,onToggleDocInfo:()=>g(!I),docInfoMenuRef:z,readerChrome:T,onOpenMobileNav:e.onOpenMobileNav,readerHeaderDocked:W,readerDragOffset:_e,onReaderHeaderPointerDown:He,onReaderHeaderPointerMove:ze,onReaderHeaderPointerUp:Fe,readerMoreOpen:R,onToggleReaderMore:()=>b(t=>!t),readerMoreMenuRef:F,readerMoreMenu:a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"mdocs-reader-more-item",disabled:H,onClick:()=>{ie(),Q()},children:[a.jsx($e,{size:16,strokeWidth:1.5,style:{color:y?"#faad14":"var(--mdocs-text-secondary, #6b7280)",fill:y?"#faad14":"none"}}),a.jsx("span",{children:i(y?"bookmarkRemove":"bookmarkAdd")})]}),e.canEdit?a.jsx("button",{type:"button",className:"mdocs-reader-more-item mdocs-reader-more-item--danger",disabled:m,onClick:()=>{Q(),e.onDelete()},children:a.jsx("span",{children:i("delete")})}):null,a.jsx("div",{className:"mdocs-reader-more-divider"}),he(Q,{includeBookmark:!1})]})}),j&&a.jsx("div",{className:"mdocs-dialog-backdrop",style:{position:"fixed",zIndex:9999},onClick:t=>{t.target===t.currentTarget&&A(!1)},children:a.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:480},children:[a.jsx("h1",{style:{fontSize:"1.1rem",marginBottom:12},children:i("docInfoChangePermission")}),a.jsxs("div",{className:"muted",style:{marginBottom:12},children:[i("domainPermission"),":",D?Ke(D.domainName,c,i):e.meta.domainId]}),a.jsx("div",{style:{display:"grid",gap:8},children:Ae.map(t=>a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[a.jsx("input",{type:"radio",name:"doc-permission",value:t,checked:S===t,onChange:()=>d(t)}),a.jsx("span",{children:Ne(t)})]},t))}),a.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:16},children:[a.jsx("button",{type:"button",onClick:()=>A(!1),children:i("cancel")}),a.jsx("button",{type:"button",className:"primary",disabled:f,onClick:()=>void Pe(),children:i(f?"publishing":"saveAndPublish")})]})]})}),e.canManageInvites&&a.jsx(zt,{open:x,title:i("docInfoInviteMember"),initialSelectedIds:[...N.keys()],initialPermissions:N,templates:[],showPermissionSelect:!0,permissionOptions:[{value:"read",label:i("invitePermissionRead")},{value:"edit",label:i("invitePermissionEdit")}],onClose:()=>v(!1),onConfirm:t=>{Te(t)}}),a.jsx(Et,{children:a.jsx(ge,{flex:1,style:{minHeight:0},children:a.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[M&&u&&!T?a.jsx(ke,{editor:u,outlineCollapseTitle:i("outlineHide"),outlineExpandTitle:i("outlineShow"),outlineToggle:!0}):null,a.jsx("div",{className:"mdocs-editor-content-area",style:{flex:1,display:"flex",minHeight:0},children:a.jsxs(ge,{variant:"outlined",horizontal:!0,style:{background:"var(--mdocs-surface)",flex:1,minHeight:0,minWidth:0,borderRadius:0,outline:"none"},children:[a.jsx("div",{className:"mdocs-editor-scroll-host",children:Me?a.jsx(bt,{content:V,type:C,confirmPasteMarkdown:!0,editable:M,onInit:Re,plugins:Oe,lineEmptyPlaceholder:i("displayNamePlaceholder"),placeholder:i("displayNamePlaceholder"),slashOption:{items:Le},className:"mdocs-document-editor-root"},e.meta.documentId):null}),u&&a.jsx(Yt,{editor:u})]})})]})})})]})}export{sn as DocumentEditor};
@@ -0,0 +1 @@
1
+ import{r as i,j as n}from"./react-vendor-BuABiQkA.js";import{c as ue,f as fe,e as he,a as xe,s as ve,g as ge,u as ye,h as be,S as ke,l as je,r as Ce,i as Ie,j as De,D as C,k as we,m as Se,b as q}from"./index-OmOf_og0.js";import{D as Ee,U as Ne,S as Me}from"./DocChrome-BWMgRxlr.js";import{V as Pe}from"./VisitorPickerModal-CqHzml8s.js";import"./ui-CvA4pq3d.js";import"./motion-DFABYlwt.js";import"./diagram-Bk84WZto.js";import"./file-type-policy-GUk904tm.js";function Ue(e){const{t:a,lang:I}=ue(),r=e.meta.documentId,[x,D]=i.useState(e.initialContent),[f,w]=i.useState(e.initialDisplayName),[c,g]=i.useState(!0),[H,$]=i.useState(!1),[J,y]=i.useState(e.hasLocalDraft??!1),[m,S]=i.useState(!1),[E,_]=i.useState(!1),[b,N]=i.useState(!1),[M,P]=i.useState(!1),[X,Z]=i.useState([]),[p,v]=i.useState(!1),[B,A]=i.useState(e.meta.permission),[R,K]=i.useState(!1),[ee,T]=i.useState(!1),[k,te]=i.useState(new Map),z=i.useRef(null),O=i.useRef(null),d=i.useRef(null),V=i.useRef(x),L=i.useRef(f);V.current=x,L.current=f;const ne=e.canEdit&&!c;i.useEffect(()=>{D(e.initialContent),w(e.initialDisplayName),g(!0)},[r]),i.useEffect(()=>{e.contentRevision&&(D(e.initialContent),w(e.initialDisplayName))},[e.contentRevision]),i.useEffect(()=>{let t=!0;return fe().then(s=>{t&&Z(s)}).catch(()=>{}),()=>{t=!1}},[]),i.useEffect(()=>{let t=!0;return he(r).then(s=>{t&&S(s.bookmarked)}).catch(()=>{}),()=>{t=!1}},[r]),i.useEffect(()=>{let t=!1;const s=q();return xe(r).then(o=>{var j;if(t||q()!==s)return;const u=!!(o&&!o.published);y(u),(j=e.onDraftExistsChange)==null||j.call(e,u)}),()=>{t=!0}},[r,e.onDraftExistsChange]),i.useEffect(()=>ve((t,s)=>{var o;t===r&&(y(s),(o=e.onDraftExistsChange)==null||o.call(e,s))}),[r,e.onDraftExistsChange]),i.useEffect(()=>{A(e.meta.permission)},[e.meta.permission,r]),i.useEffect(()=>{const t=s=>{z.current&&!z.current.contains(s.target)&&N(!1),O.current&&!O.current.contains(s.target)&&P(!1)};return(b||M)&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[b,M]);const U=i.useCallback(async()=>{var t;await ge(r).execute(()=>ye({documentId:r,content:V.current,displayName:L.current,contentKind:"html",localBaseCommitIdAtEditStart:e.meta.headCommitId??null,snapshotMeta:{permission:e.meta.permission,ownerVisitorId:e.meta.ownerVisitorId,domainId:e.meta.domainId}})),y(!0),(t=e.onDraftExistsChange)==null||t.call(e,!0)},[r,e]),G=i.useCallback(()=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{U()},1e3)},[U]);i.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);async function F(t){var s;if(e.canEdit){$(!0);try{d.current&&(clearTimeout(d.current),d.current=null),await U(),await e.onPublish(V.current,L.current.trim()||f,r,t),y(!1),(s=e.onDraftExistsChange)==null||s.call(e,!1)}finally{$(!1)}}}async function ie(){if(!e.canEdit)return;const t=e.initialDisplayName.trim();if(f.trim()!==t)try{await F()}catch{}}async function W(){var t,s;if(!E){_(!0);try{m?(await Ce(r),S(!1),(t=e.onShowToast)==null||t.call(e,a("bookmarkRemoved"))):(await Ie(r),S(!0),(s=e.onShowToast)==null||s.call(e,a("bookmarkAdded")))}finally{_(!1)}}}function ae(t){const s=X.find(o=>o.visitorId===t);return(s==null?void 0:s.visitorName)??t.slice(0,8)}function se(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}const l=i.useMemo(()=>e.domains.find(t=>t.domainId===e.meta.domainId),[e.domains,e.meta.domainId]),oe=i.useMemo(()=>{const t=(l==null?void 0:l.permission)??"public";return be(t)},[l==null?void 0:l.permission]);function re(t){return t===C.PRIVATE?a("permissionPrivate"):t===C.DOMAIN_READ?a("permissionInvite"):t===C.DOMAIN_WRITE?a("permissionDomainWrite"):t===C.PUBLIC_READ?a("permissionPublicRead"):a("permissionPublicEdit")}async function de(){if(R||B===e.meta.permission){v(!1);return}K(!0);try{await F(B),v(!1)}finally{K(!1)}}async function le(t){const s=new Set(t.map(o=>o.visitorId));for(const[o]of k)s.has(o)||await we(r,o);for(const o of t)k.get(o.visitorId)!==o.permission&&await Se(r,o.visitorId,o.permission);T(!1)}function h(){N(!1),P(!1)}function Q(t,s){const o=(s==null?void 0:s.includeBookmark)??!0,u={width:"100%",textAlign:"left",padding:"8px 16px",background:"none",border:"none",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"8px"};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{padding:"4px 16px",fontSize:"13px"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[n.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:a("docInfoCreator")}),n.jsx("span",{children:ae(e.meta.ownerVisitorId)})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[n.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:a("docInfoCreatedAt")}),n.jsx("span",{children:new Date(e.meta.createdAt).toLocaleString(I==="zh"?"zh-CN":"en-US")})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[n.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:a("docInfoSize")}),n.jsx("span",{children:se(new Blob([x]).size)})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[n.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:a("docInfoUpdatedAt")}),n.jsx("span",{children:new Date(e.meta.updatedAt).toLocaleString(I==="zh"?"zh-CN":"en-US")})]})]}),n.jsx("div",{style:{height:"1px",background:"var(--mdocs-border, #e5e5e5)",margin:"8px 0"}}),o?n.jsxs("button",{type:"button",style:u,onClick:()=>{W(),t()},children:[n.jsx("span",{children:m?"⭐":"☆"}),n.jsx("span",{children:a(m?"bookmarkRemove":"bookmarkAdd")})]}):null,e.canManageInvites?n.jsxs("button",{type:"button",style:u,onClick:()=>{t(),(async()=>{const j=await De(r);te(new Map(j.map(Y=>[Y.visitorId,Y.permission]))),T(!0)})()},children:[n.jsx(Ne,{size:14}),n.jsx("span",{children:a("docInfoInviteMember")})]}):null,n.jsxs("button",{type:"button",style:u,onClick:()=>{t(),A(e.meta.permission),v(!0)},children:[n.jsx(Me,{size:14}),n.jsx("span",{children:a("docInfoChangePermission")})]})]})}const ce=i.useCallback(t=>{var o;const s=t.target.value;D(s),(o=e.onContentChange)==null||o.call(e,s),G()},[e,G]),me=`<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"></head><body>${x}</body></html>`;return n.jsxs("div",{className:"mdocs-editor"+(e.readerChrome?" mdocs-editor--reader":""),children:[n.jsx(Ee,{fileType:"html",displayName:f,onDisplayNameChange:w,onDisplayNameBlur:()=>void ie(),domains:e.domains,currentDomainId:e.currentDomainId,onDomainChange:e.onDomainChange,onDomainsChange:e.onDomainsChange,canEdit:e.canEdit,editing:ne,onAiWrite:e.onAiWrite,syncBehind:e.syncBehind,onSyncClick:e.onSyncClick,busy:H,draftExists:J,onPublish:()=>{F().catch(()=>{})},onDelete:()=>{e.onDelete()},isBookmarked:m,bookmarkBusy:E,onToggleBookmark:()=>void W(),onToggleComments:e.onToggleComments,commentPanelOpen:e.commentPanelOpen,commentCount:e.commentCount,docInfoMenu:Q(h),docInfoOpen:b,onToggleDocInfo:()=>N(!b),docInfoMenuRef:z,readerChrome:e.readerChrome,readerActionsCollapsible:!0,readerHeaderDocked:e.readerChrome,onOpenMobileNav:e.onOpenMobileNav,readerMoreOpen:M,onToggleReaderMore:()=>P(t=>!t),readerMoreMenuRef:O,readerMoreMenu:n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",className:"mdocs-reader-more-item",disabled:E,onClick:()=>{W(),h()},children:[n.jsx(ke,{size:16,strokeWidth:1.5,style:{color:m?"#faad14":"var(--mdocs-text-secondary, #6b7280)",fill:m?"#faad14":"none"}}),n.jsx("span",{children:a(m?"bookmarkRemove":"bookmarkAdd")})]}),n.jsx("div",{className:"mdocs-reader-more-divider"}),n.jsx("button",{type:"button",className:"mdocs-reader-more-item",disabled:!c,onClick:()=>{g(!1),h()},children:a("edit")}),n.jsx("button",{type:"button",className:"mdocs-reader-more-item",disabled:c,onClick:()=>{g(!0),h()},children:a("preview")}),n.jsx("div",{className:"mdocs-reader-more-divider"}),e.canEdit?n.jsx("button",{type:"button",className:"mdocs-reader-more-item mdocs-reader-more-item--danger",disabled:H,onClick:()=>{h(),e.onDelete()},children:n.jsx("span",{children:a("delete")})}):null,n.jsx("div",{className:"mdocs-reader-more-divider"}),Q(h,{includeBookmark:!1})]}),leadingExtra:e.canEdit&&!e.readerChrome?n.jsxs("label",{className:"mdocs-editor-mode-toggle","aria-label":a(c?"preview":"edit"),children:[n.jsx("input",{type:"checkbox",checked:c,onChange:()=>g(t=>!t)}),n.jsxs("span",{className:"mdocs-editor-mode-toggle-slider",children:[n.jsx("span",{className:"mdocs-editor-mode-toggle-label mdocs-editor-mode-toggle-label--left",children:a("edit")}),n.jsx("span",{className:"mdocs-editor-mode-toggle-label mdocs-editor-mode-toggle-label--right",children:a("preview")})]})]}):null}),n.jsxs("div",{className:"mdocs-html-editor-body",children:[!c&&e.canEdit?n.jsx("textarea",{className:"mdocs-html-editor-textarea",value:x,onChange:ce,spellCheck:!1,placeholder:"在此处编写 HTML 代码"}):null,n.jsx("div",{className:"mdocs-html-editor-preview",style:!c&&e.canEdit?{width:"50%"}:{width:"100%"},children:n.jsx("iframe",{className:"mdocs-html-editor-iframe",srcDoc:me,sandbox:"",title:f})})]}),p&&n.jsx("div",{className:"mdocs-dialog-backdrop",style:{position:"fixed",zIndex:9999},onClick:t=>{t.target===t.currentTarget&&v(!1)},children:n.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:480},children:[n.jsx("h1",{style:{fontSize:"1.1rem",marginBottom:12},children:a("docInfoChangePermission")}),n.jsxs("div",{className:"muted",style:{marginBottom:12},children:[a("domainPermission"),":",l?je(l.domainName,I,a):e.meta.domainId]}),n.jsx("div",{style:{display:"grid",gap:8},children:oe.map(t=>n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[n.jsx("input",{type:"radio",name:"html-doc-permission",value:t,checked:B===t,onChange:()=>A(t)}),n.jsx("span",{children:re(t)})]},t))}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:16},children:[n.jsx("button",{type:"button",onClick:()=>v(!1),children:a("cancel")}),n.jsx("button",{type:"button",className:"primary",disabled:R,onClick:()=>void de(),children:a(R?"publishing":"saveAndPublish")})]})]})}),e.canManageInvites&&n.jsx(Pe,{open:ee,title:a("docInfoInviteMember"),initialSelectedIds:[...k.keys()],initialPermissions:k,templates:[],showPermissionSelect:!0,permissionOptions:[{value:"read",label:a("invitePermissionRead")},{value:"edit",label:a("invitePermissionEdit")}],onClose:()=>T(!1),onConfirm:t=>{le(t)}})]})}export{Ue as HtmlEditor};