@fgbg/mdocs 0.8.19 → 0.8.21
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.
- package/README.md +7 -1
- package/agent-skills/changelog/SKILL.md +13 -1
- package/agent-skills/getting-started-installation/SKILL.md +12 -2
- package/agent-skills/index.json +1 -1
- package/agent-skills/usage-onboarding-ai/SKILL.md +11 -0
- package/agent-skills/usage-settings/SKILL.md +15 -1
- package/bin/mdocs.js +1 -1
- package/dist/server/agent/Agent/choice-pending.js +10 -1
- package/dist/server/agent/Agent/choice-pending.js.map +1 -1
- package/dist/server/agent/Agent/context-usage.js +6 -5
- package/dist/server/agent/Agent/context-usage.js.map +1 -1
- package/dist/server/agent/Agent/hydrate-messages.js +137 -0
- package/dist/server/agent/Agent/hydrate-messages.js.map +1 -0
- package/dist/server/agent/Agent/run-pi-agent.js +115 -0
- package/dist/server/agent/Agent/run-pi-agent.js.map +1 -0
- package/dist/server/agent/Agent/run.js +49 -323
- package/dist/server/agent/Agent/run.js.map +1 -1
- package/dist/server/agent/Agent/session-manager.js +38 -3
- package/dist/server/agent/Agent/session-manager.js.map +1 -1
- package/dist/server/agent/Agent/skill-form-pending.js +77 -0
- package/dist/server/agent/Agent/skill-form-pending.js.map +1 -0
- package/dist/server/agent/Agent/stream-events.js +2 -0
- package/dist/server/agent/Agent/stream-events.js.map +1 -0
- package/dist/server/agent/Agent/system-prompt.js +8 -4
- package/dist/server/agent/Agent/system-prompt.js.map +1 -1
- package/dist/server/agent/Agent/tool-deps.js +7 -0
- package/dist/server/agent/Agent/tool-deps.js.map +1 -0
- package/dist/server/agent/Agent/tool-ui-effects.js +170 -0
- package/dist/server/agent/Agent/tool-ui-effects.js.map +1 -0
- package/dist/server/agent/Agent/tools-choice.js +44 -50
- package/dist/server/agent/Agent/tools-choice.js.map +1 -1
- package/dist/server/agent/Agent/tools-coding.get-working.test.js +10 -8
- package/dist/server/agent/Agent/tools-coding.get-working.test.js.map +1 -1
- package/dist/server/agent/Agent/tools-coding.js +51 -58
- package/dist/server/agent/Agent/tools-coding.js.map +1 -1
- package/dist/server/agent/Agent/tools-documents.get-document.test.js +2 -4
- package/dist/server/agent/Agent/tools-documents.get-document.test.js.map +1 -1
- package/dist/server/agent/Agent/tools-documents.js +192 -187
- package/dist/server/agent/Agent/tools-documents.js.map +1 -1
- package/dist/server/agent/Agent/tools-domains.js +155 -156
- package/dist/server/agent/Agent/tools-domains.js.map +1 -1
- package/dist/server/agent/Agent/tools-overwrite.js +93 -101
- package/dist/server/agent/Agent/tools-overwrite.js.map +1 -1
- package/dist/server/agent/Agent/tools-registry.js +26 -0
- package/dist/server/agent/Agent/tools-registry.js.map +1 -0
- package/dist/server/agent/Agent/tools-registry.test.js +67 -0
- package/dist/server/agent/Agent/tools-registry.test.js.map +1 -0
- package/dist/server/agent/Agent/tools-template.js +45 -0
- package/dist/server/agent/Agent/tools-template.js.map +1 -0
- package/dist/server/agent/Agent/tools-user-skills.js +176 -0
- package/dist/server/agent/Agent/tools-user-skills.js.map +1 -0
- package/dist/server/agent/Agent/tools-visitors.js +15 -22
- package/dist/server/agent/Agent/tools-visitors.js.map +1 -1
- package/dist/server/agent/Agent/tools.js +40 -33
- package/dist/server/agent/Agent/tools.js.map +1 -1
- package/dist/server/agent/Agent/user-skills.js +214 -0
- package/dist/server/agent/Agent/user-skills.js.map +1 -0
- package/dist/server/agent/Agent/user-skills.test.js +53 -0
- package/dist/server/agent/Agent/user-skills.test.js.map +1 -0
- package/dist/server/cli/main.js +10 -0
- package/dist/server/cli/main.js.map +1 -1
- package/dist/server/cli/self-update.js +158 -0
- package/dist/server/cli/self-update.js.map +1 -0
- package/dist/server/cli/self-update.test.js +17 -0
- package/dist/server/cli/self-update.test.js.map +1 -0
- package/dist/server/db/repositories/agent-user-skill.repo.js +78 -0
- package/dist/server/db/repositories/agent-user-skill.repo.js.map +1 -0
- package/dist/server/db/schema.js +11 -0
- package/dist/server/db/schema.js.map +1 -1
- package/dist/server/routes/agent.routes.js +198 -5
- package/dist/server/routes/agent.routes.js.map +1 -1
- package/dist/web/assets/AgentChatPanel-D95hI02c.js +1 -0
- package/dist/web/assets/AgentSkillFormCard-BtJ0QjLG.js +6 -0
- package/dist/web/assets/AiWriteWorkbench-Qam8cfY6.js +6 -0
- package/dist/web/assets/{DiagramEditor-BTRe45TX-DzJEhM4C.js → DiagramEditor-BTRe45TX-Did98cnP.js} +1 -1
- package/dist/web/assets/{DocumentEditor-NPbbAape.js → DocumentEditor-DtSzkl6A.js} +1 -1
- package/dist/web/assets/{MergeView-BnWbq08U.js → MergeView-DgFQHD5_.js} +1 -1
- package/dist/web/assets/{PlaygroundPage-BSGipUkC.js → PlaygroundPage-Dg57Xxpl.js} +1 -1
- package/dist/web/assets/SettingsPage-CkYpe5v7.js +1 -0
- package/dist/web/assets/{Toolbar-DjPuWk5G.js → Toolbar-0Y2wmGwe.js} +1 -1
- package/dist/web/assets/{VisitorPickerModal-BUS-cOq0.js → VisitorPickerModal-COxtOvc4.js} +1 -1
- package/dist/web/assets/{copy-hWOco_4c.js → copy-nOl0d3Th.js} +1 -1
- package/dist/web/assets/{diagram-gfUK8OHx.js → diagram-BJFhx-27.js} +332 -332
- package/dist/web/assets/{index-C46BU1-j.js → index-B-XJ-ScV.js} +22 -22
- package/dist/web/assets/index-CGvsjO9f.css +1 -0
- package/dist/web/assets/{meta2dEngine-BD2XbzaV-D7hJ1H1g.js → meta2dEngine-BD2XbzaV-e28q005B.js} +1 -1
- package/dist/web/assets/{motion-C4pN8CfU.js → motion-D-I76zAi.js} +1 -1
- package/dist/web/assets/{plus-CnKbiP8x.js → plus-DvBbg6jL.js} +1 -1
- package/dist/web/assets/{react-B7vrA7AR.js → react-BsVOIHR8.js} +3 -3
- package/dist/web/assets/{ui-DxdLi_28.js → ui-C3xtW1w8.js} +3 -3
- package/dist/web/index.html +4 -4
- package/package.json +1 -1
- package/dist/web/assets/AgentChatPanel-CLKeiDeR.js +0 -1
- package/dist/web/assets/AiWriteWorkbench-Ecp214S5.js +0 -6
- package/dist/web/assets/SettingsPage-OklrFCx7.js +0 -1
- package/dist/web/assets/history-AMIEbyMc.js +0 -6
- package/dist/web/assets/index-BksNm27A.css +0 -1
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DocumentEditor-
|
|
2
|
-
var
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DocumentEditor-DtSzkl6A.js","assets/react-vendor-BNpqFP9B.js","assets/ui-C3xtW1w8.js","assets/motion-D-I76zAi.js","assets/react-BsVOIHR8.js","assets/editor-ONzd_YnO.js","assets/diagram-BJFhx-27.js","assets/plus-DvBbg6jL.js","assets/copy-nOl0d3Th.js","assets/Toolbar-0Y2wmGwe.js","assets/VisitorPickerModal-COxtOvc4.js","assets/SettingsPage-CkYpe5v7.js","assets/AgentChatPanel-D95hI02c.js","assets/AgentSkillFormCard-BtJ0QjLG.js","assets/AiWriteWorkbench-Qam8cfY6.js","assets/MergeView-DgFQHD5_.js","assets/PlaygroundPage-Dg57Xxpl.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Wn=Object.defineProperty;var zn=(e,t,i)=>t in e?Wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var Ie=(e,t,i)=>zn(e,typeof t!="symbol"?t+"":t,i);import{r as a,j as n,_ as Ce,a9 as qn,aa as Gn,ab as Jn,ac as it,c as Yn,R as Kn,ad as Xn}from"./react-vendor-BNpqFP9B.js";import{C as Qn,T as Zn}from"./ui-C3xtW1w8.js";import{f as eo}from"./motion-D-I76zAi.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const d of s)if(d.type==="childList")for(const l of d.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function i(s){const d={};return s.integrity&&(d.integrity=s.integrity),s.referrerPolicy&&(d.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?d.credentials="include":s.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function r(s){if(s.ep)return;s.ep=!0;const d=i(s);fetch(s.href,d)}})();/**
|
|
3
3
|
* @license lucide-react v0.562.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
6
6
|
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const
|
|
7
|
+
*/const to=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),no=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,i,r)=>r?r.toUpperCase():i.toLowerCase()),Ft=e=>{const t=no(e);return t.charAt(0).toUpperCase()+t.slice(1)},nn=(...e)=>e.filter((t,i,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===i).join(" ").trim(),oo=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/**
|
|
8
8
|
* @license lucide-react v0.562.0 - ISC
|
|
9
9
|
*
|
|
10
10
|
* This source code is licensed under the ISC license.
|
|
11
11
|
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/var
|
|
12
|
+
*/var io={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
13
13
|
* @license lucide-react v0.562.0 - ISC
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the ISC license.
|
|
16
16
|
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/const
|
|
17
|
+
*/const ro=a.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:i=2,absoluteStrokeWidth:r,className:s="",children:d,iconNode:l,...f},h)=>a.createElement("svg",{ref:h,...io,width:t,height:t,stroke:e,strokeWidth:r?Number(i)*24/Number(t):i,className:nn("lucide",s),...!d&&!oo(f)&&{"aria-hidden":"true"},...f},[...l.map(([m,g])=>a.createElement(m,g)),...Array.isArray(d)?d:[d]]));/**
|
|
18
18
|
* @license lucide-react v0.562.0 - ISC
|
|
19
19
|
*
|
|
20
20
|
* This source code is licensed under the ISC license.
|
|
21
21
|
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/const se=(e,t)=>{const i=a.forwardRef(({className:r,...s},d)=>a.createElement(
|
|
22
|
+
*/const se=(e,t)=>{const i=a.forwardRef(({className:r,...s},d)=>a.createElement(ro,{ref:d,iconNode:t,className:nn(`lucide-${to(Ft(e))}`,`lucide-${e}`,r),...s}));return i.displayName=Ft(e),i};/**
|
|
23
23
|
* @license lucide-react v0.562.0 - ISC
|
|
24
24
|
*
|
|
25
25
|
* This source code is licensed under the ISC license.
|
|
26
26
|
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
-
*/const
|
|
27
|
+
*/const ao=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],so=se("book-open",ao);/**
|
|
28
28
|
* @license lucide-react v0.562.0 - ISC
|
|
29
29
|
*
|
|
30
30
|
* This source code is licensed under the ISC license.
|
|
31
31
|
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
-
*/const
|
|
32
|
+
*/const co=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],_t=se("file",co);/**
|
|
33
33
|
* @license lucide-react v0.562.0 - ISC
|
|
34
34
|
*
|
|
35
35
|
* This source code is licensed under the ISC license.
|
|
36
36
|
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
-
*/const
|
|
37
|
+
*/const lo=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Bt=se("folder",lo);/**
|
|
38
38
|
* @license lucide-react v0.562.0 - ISC
|
|
39
39
|
*
|
|
40
40
|
* This source code is licensed under the ISC license.
|
|
41
41
|
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
-
*/const
|
|
42
|
+
*/const mo=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],uo=se("log-out",mo);/**
|
|
43
43
|
* @license lucide-react v0.562.0 - ISC
|
|
44
44
|
*
|
|
45
45
|
* This source code is licensed under the ISC license.
|
|
46
46
|
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
-
*/const
|
|
47
|
+
*/const fo=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],po=se("message-square",fo);/**
|
|
48
48
|
* @license lucide-react v0.562.0 - ISC
|
|
49
49
|
*
|
|
50
50
|
* This source code is licensed under the ISC license.
|
|
51
51
|
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
-
*/const
|
|
52
|
+
*/const ho=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],go=se("panel-left-close",ho);/**
|
|
53
53
|
* @license lucide-react v0.562.0 - ISC
|
|
54
54
|
*
|
|
55
55
|
* This source code is licensed under the ISC license.
|
|
56
56
|
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
-
*/const
|
|
57
|
+
*/const yo=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],vo=se("panel-left-open",yo);/**
|
|
58
58
|
* @license lucide-react v0.562.0 - ISC
|
|
59
59
|
*
|
|
60
60
|
* This source code is licensed under the ISC license.
|
|
61
61
|
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
-
*/const
|
|
62
|
+
*/const bo=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],wo=se("star",bo);/**
|
|
63
63
|
* @license lucide-react v0.562.0 - ISC
|
|
64
64
|
*
|
|
65
65
|
* This source code is licensed under the ISC license.
|
|
66
66
|
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
-
*/const
|
|
67
|
+
*/const xo=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ee=se("x",xo),Io={loading:"loading...",saved:"Saved",saving:"Saving...",unsaved:"Editing...",publish:"Publish",publishing:"Publishing...",published:"Published",cancel:"Cancel",create:"Create",creating:"Creating...",close:"Close",delete:"Delete",save:"Save",gotIt:"got it",error:"error",brand:"mdocs",welcomeTitle:"Welcome to mdocs",welcomeDesc:"Enter a display name to create a visitor identity. A secure token will be stored in this browser to identify you on future visits.",visitorNamePlaceholder:"Your name",createVisitor:"Create visitor",nameRequired:"please enter a name",visitorIdNotice:"your visitor id is {{id}}, save it for recovery",newDocument:"New document",newFolder:"New folder",noDocumentsYet:"no documents yet",collapseFolder:"Collapse folder",expandFolder:"Expand folder",noDocsInDomain:"No documents in this domain yet. Switch domain below or create a document.",createDocToStart:"Create or select a document to start writing.",domainLabel:"Domain",defaultDomain:"Default",displayNamePlaceholder:"Display name",currentDomainAria:"Current domain",insertDiagram:"Insert diagram",outlineHide:"Hide outline",outlineShow:"Show outline",readOnlyNotice:`> You don't have permission to edit
|
|
68
68
|
|
|
69
|
-
`,newDocumentTitle:"New document",newFolderTitle:"New folder",fileNameLabel:"File name",folderNameLabel:"Folder name",fileNameHint:"Names are shown as you type; stored paths are normalised (e.g. spaces → underscores). Use a .md file name.",folderNameHint:"Names are shown as you type; stored paths are normalised (e.g. folder 1 → folder_1).",untitledPlaceholder:"untitled.md",folderExamplePlaceholder:"e.g. research",pathExists:"this path already exists; pick another name",folderExists:"a folder with this name already exists",deleteConfirm:"delete {{name}}?",newDocIn:"New document in {{name}}",newDocAtRoot:"New document at root",newDocBeside:"New document beside this",newFolderIn:"New folder in {{name}}",newFolderAtRoot:"New folder at root",newFolderBeside:"New folder beside this",deleteItem:"Delete {{name}}",deleteFolder:"Delete {{name}}",editDiagram:"Edit diagram",newDiagram:"New diagram",saveAndInsert:"Save and insert",deleteDiagram:"Delete diagram",openFailed:"open failed: {{message}}",components:"Components",dragToCanvas:"drag to canvas",shapeRectangle:"Rectangle",shapeRounded:"Rounded",shapeCircle:"Circle",shapeDiamond:"Diamond",shapeTriangle:"Triangle",shapePentagon:"Pentagon",shapeText:"Text",shapeLine:"Line",shapeData:"Data",shapeDatabase:"Database",shapeDocument:"Document",shapeDisplay:"Display",shapeManual:"Manual",shapeParallel:"Parallel",shapeComment:"Comment",shapeSubprocess:"Subprocess",shapeQueue:"Queue",shapeIntStorage:"Int. Storage",shapeExtStorage:"Ext. Storage",errUnauthenticated:"Please register first",errBadRequest:"Invalid request",errInvalidVisitorName:"Invalid visitor name",errDocExists:"Document already exists",errDocNotFound:"Document not found",errForbidden:"You don't have permission",errInternal:"Internal error",errInvalidPath:"Invalid path",errUnknown:"Unknown error",errUnknownVisitorIds:"Some visitor IDs are invalid or disabled.",errTemplateNotFound:"Member template not found.",errDomainNotRestricted:"Member import only applies to restricted domains.",pathRequired:"relative path is required",pathMustBeRelative:"path must be relative",useForwardSlashes:"use forward slashes",pathNoDotDot:"path must not contain ..",pathMustEndWithMd:"document path must end with .md",pathUnsupportedChars:"path contains unsupported characters",pathEscapesRoot:"path escapes docs root",enterFolderName:"enter a folder name",singleNameNotPath:"use a single name, not a path",invalidFolderName:"invalid folder name",folderNameTooLong:"folder name is too long",enterFileName:"enter a file name",singleFileNameNotPath:"use a file name, not a path",invalidFileName:"invalid file name",fileNameTooLong:"file name is too long",permissionLabel:"Permission",permissionPrivate:"Private",permissionInvite:"Invite",permissionDomainWrite:"Domain write",permissionPublicRead:"Public read",permissionPublicEdit:"Public edit",invitePermissionRead:"Read only",invitePermissionEdit:"Can edit",personalDomainSuffix:"'s workspace",settings:"Settings",general:"General",language:"Language",backToDocs:"Back to documents",saveAndPublish:"Save & Publish",domainManagement:"Domain Management",createDomain:"New domain",domainName:"Domain Name",domainPermission:"Permission",domainPublic:"Public",domainRestricted:"Restricted",domainPrivate:"Private",docCount:"{{count}} documents",rename:"Rename",deleteDomain:"Delete Domain",deleteDomainConfirm:"Delete domain {{name}}?",domainLocked:"Has documents, locked",noDomains:"No domains",domainNameRequired:"Enter a domain name",domainBuiltIn:"Built-in",domainNotCreator:"Only the creator can modify this domain",domainSearchPlaceholder:"Search domain name…",domainFilterAll:"All",domainColName:"Name",domainColType:"Type",domainColDocCount:"Documents",domainColActions:"Actions",domainTypeBuiltinSuffix:"(built-in)",domainChangeType:"Change type",domainNotModifiable:"—",domainTooltipTypeLocked:"This domain has {{count}} document(s); type cannot be changed.",deleteDomainConfirmDetail:"Delete domain «{{name}}»? All {{count}} document(s) in it will be permanently removed.",domainNoMatch:"No matching domains.",memberTemplates:"Member templates",memberTemplateFormNew:"New template",memberTemplateSavedList:"Saved templates",memberTemplateIntro:"Save reusable member lists for restricted domains. Use Choose members… to pick people (left list = everyone, right = selected). You can also apply a template inside that dialog. Then save the template here.",memberTemplateStepName:"1. Name your template",memberTemplateStepMembers:"2. Choose members",memberTemplateStepSave:"3. Save",memberTemplateStep2Hint:"Select at least 1 member to continue",memberTemplateNameLabel:"Template name",memberTemplateNamePlaceholder:"e.g. Core team",memberTemplateIdsLabel:"Members",memberTemplateIdsHint:"Use Choose members… to pick people in the list; you can also apply a template inside that dialog.",memberTemplateCreate:"Save template",memberTemplateUpdate:"Update template",memberTemplateCancelEdit:"Cancel edit",memberTemplateDelete:"Delete",memberTemplateDeleteConfirm:"Delete template «{{name}}»?",memberTemplateConfirmDeleteCancel:"Cancel",memberTemplateConfirmDeleteDesc:"Delete template «{{name}}»? This cannot be undone.",memberTemplateConfirmDeleteSubmit:"Delete",memberTemplateEmpty:"No templates yet. Create one here, then use Members… on a restricted domain in Domain management.",memberTemplateEmptyAction:"Create first template",memberTemplateCount:"{{count}} visitors",memberTemplatePickerTitle:"Choose visitors for this template",memberTemplatePickMembersButton:"Choose members…",memberTemplateSelectedSummary:"{{count}} selected",memberTemplateWizardBack:"Back",memberTemplateWizardNext:"Next",domainMembersManageButton:"Members…",domainMembersPickerTitle:"Restricted domain members",domainMembersSaved:"Saved {{count}} member(s).",visitorPickerSearchPlaceholder:"Search by name or visitor id…",visitorPickerColumnAll:"Everyone",visitorPickerColumnSelected:"Selected",visitorPickerApplyTemplate:"Apply template",visitorPickerPickTemplate:"Pick a template…",visitorPickerConfirm:"Done",visitorPickerLoadError:"Could not load visitor list.",visitorPickerEmptyDirectory:"No visitors yet.",visitorPickerNoSelection:"No one selected yet.",visitorPickerColIdShort:"ID (6)",visitorPickerColName:"Name",visitorPickerColPick:"Pick",visitorPickerColIdFull:"Visitor ID",visitorPickerRemove:"Remove from selection",visitorPickerLockedHint:"This member cannot be removed (domain owner).",visitorPickerUnknownVisitor:"Unknown ID (not in directory)",visitorPickerMemberMissing:"Removed visitor (no longer in database)",visitorPickerDisabledTag:"inactive account",visitorPickerSelfMarker:"(you)",domainMemberImportPickTemplate:"Choose template…",domainMemberImportSection:"Members (from saved template)",domainMgmtRestrictedMemberHint:"For restricted domains you own: click Members… in the Actions column, then pick people in the dialog (or apply a saved template). The domain owner always stays in the list.",domainMemberImportApply:"Import members",domainMemberImportDone:"Added {{count}} member(s).",domainMemberImportHint:"Add templates under “Member templates” first.",shared:"Shared",autoSave:"Auto Save (Local Snapshot)",autoSaveDesc:"When enabled, your content is protected from network outages, crashes, or accidental refreshes. Disabling this feature puts your data at high risk of loss.",autoSaveAlwaysOnDesc:"Always enabled — your content is continuously saved to a local snapshot, so you never lose work.",autoSaveBadge:"Recommended",autoSaveTurnOffTitle:"High Risk Operation",autoSaveTurnOffBody:"Without auto-save, content is only stored when you manually save or publish. If the browser crashes, closes unexpectedly, or refreshes, all unsaved content will be permanently lost.",autoSaveTurnOffConfirm:"Confirm Disable",autoSaveTurnOffCancel:"Keep Enabled",autoPublish:"Auto Sync to Cloud",autoPublishDesc:"Push changes to the server in real time. When network is unstable or multi-device editing conflicts occur, sync will pause to protect data integrity.",viewDrafts:"View Unpublished Drafts",unpublishedDrafts:"Unpublished Drafts",noDrafts:"No unpublished drafts",draftCount:"{{count}} unpublished",publishAll:"Publish all",conflictTitle:"Publish conflict",conflictBody:"Local version conflicts with remote. Please resolve the merge manually and re-publish.",conflictResolve:"Resolve conflict",conflictClose:"Close",syncPull:"Pull update",syncBehindHint:"New version on server",pullConfirmTitle:"Pull remote version",pullConfirmBody:"Updates the editor from the server when there is no local draft.",mergeTitle:"Merge conflict",mergeLocal:"Local",mergeRemote:"Remote",mergeResult:"Merged",mergeSource:"Source",mergePreview:"Preview",mergeComplete:"Merge and publish",mergeLoadRemoteFailed:"Failed to load remote content",mergeLoadLocalFailed:"Failed to load local snapshot",mergeLoadingRemote:"Loading…",mergeConflictsUnresolved:"{{count}} unresolved conflict(s). Resolve all conflicts before publishing.",mergeConflictsPending:"Conflicts pending {{unresolved}} / {{total}}",mergeConflictsResolved:"All conflicts resolved ({{total}})",mergeConflictsPanel:"Conflicts",mergeConflictItem:"Conflict {{index}} / {{total}}",mergeConflictUnresolved:"Pending",mergeConflictResolved:"Resolved",mergeAcceptLocal:"Accept local",mergeAcceptRemote:"Accept remote",mergeAcceptBoth:"Keep both",mergeAcceptManual:"Edit manually",mergeNoConflicts:"Local and remote match — you can publish directly.",mergeResultHint:"Assembled from your choices; you may still edit below",mergeResultInlineHint:"Confirm every change from the merge base inline",mergeBase:"Base",mergeBaseMissing:"Could not load merge base — using two-way diff",pullBlockedConflict:"Unresolved conflict — merge first.",syncHeadMissing:"Cannot publish: reopen the document to refresh version info.",syncPullDone:"Pulled latest from server",unsavedChanges:"You have unsaved changes.",edit:"Edit",autoEdit:"Auto Edit",autoEditDesc:"Automatically enter edit mode when opening a document",saveDraft:"Save Draft",continue:"Continue",draftDeleted:"Draft deleted",confirmDeleteDraft:"Permanently delete this draft? This action cannot be undone.",draftsEmptyState:"All drafts synced — no unpublished content.",localSnapshot:"Local snapshot",unknownTitle:"Untitled document",draftPublishFailedNotice:'Draft "{{name}}" publish failed: document not found',draftPublishFailedSyncHead:'Draft "{{name}}" publish failed: missing version baseline — reopen the document or fix on server',draftPublishFailedGeneric:'Draft "{{name}}" publish failed: {{reason}}',publishFailed:"Publish failed",recoverDraft:"Save As New Document",recoverDraftDesc:'Save the draft of "{{name}}" as a brand new document',recoverTargetFolder:"Target Folder",cliToken:"CLI Token",cliTokenDesc:"Identity token for CLI and Agent tools, inherits all your permissions",cliTokenCreate:"Create",cliTokenReset:"Reset",cliTokenGenerated:"New CLI Token generated",cliTokenCopy:"Copy",cliTokenCopied:"Copied",cliTokenCopyFailed:"Copy failed — select the token above and copy manually",cliTokenResetConfirm:"Resetting will revoke all existing tokens and generate a new one. Confirm?",cliTokenActive:"Active",cliTokenRevoked:"Revoked",docInfo:"Document info",docInfoCreator:"Creator",docInfoCreatedAt:"Created",docInfoSize:"Size",docInfoUpdatedAt:"Last edited",docInfoChangePermission:"Change permission",docInfoInviteMember:"Invite members",docInfoInviteSuccess:"Invited {{count}} member(s)",docInfoPermissionUpdated:"Permission updated",expandSidebar:"Expand sidebar",collapseSidebar:"Collapse sidebar",bookmark:"Bookmarks",bookmarkAdd:"Add to bookmarks",bookmarkRemove:"Remove from bookmarks",bookmarkTitle:"My Bookmarks",bookmarkEmpty:"No bookmarks yet",bookmarkOpen:"Open",bookmarkAdded:"Bookmark added",bookmarkRemoved:"Bookmark removed",bookmarkColTitle:"Title",bookmarkColDomain:"Domain",bookmarkColAuthor:"Author",bookmarkColTime:"Bookmarked",bookmarkSearch:"Search bookmarks",bookmarkFilterAll:"All domains",bookmarkNoMatch:"No matching bookmarks",myDocuments:"My Documents",myDocumentsEmpty:"No documents yet",myDocumentsColTitle:"Title",myDocumentsColDomain:"Domain",myDocumentsColUpdated:"Updated",myDocumentsColCreated:"Created",myDocumentsNoMatch:"No matching documents",agentConfig:"AI",agentConfigDesc:"Configure DeepSeek for mdocs 智能助手. Only you can use this key.",agentConfigName:"Config name",agentConfigNameDefault:"Default: {{name}}'s ds config",agentConfigModel:"Model",agentConfigContextWindow:"Context window",agentConfigContextWindowDesc:"Token budget for the assistant (default 128000). Used for the usage ring.",agentConfigApiKey:"API Key",agentConfigApiKeyPlaceholder:"Paste DeepSeek API Key",agentConfigApiKeyConfigured:"Configured {{masked}}; leave blank to keep",agentConfigId:"Config ID",agentConfigShowKey:"Show API Key",agentConfigHideKey:"Hide API Key",agentFabOpen:"Open mdocs 智能助手",agentFabReset:"Reset position",logout:"Sign out"},Io={loading:"加载中...",saved:"已保存",saving:"保存中...",unsaved:"编辑中...",publish:"发布",publishing:"发布中...",published:"已发布",cancel:"取消",create:"创建",creating:"创建中...",close:"关闭",delete:"删除",save:"保存",gotIt:"知道了",error:"错误",brand:"mdocs",welcomeTitle:"欢迎使用 mdocs",welcomeDesc:"输入一个显示名称以创建访客身份。一个安全令牌将存储在此浏览器中,以便在后续访问时识别您。",visitorNamePlaceholder:"您的名字",createVisitor:"创建访客",nameRequired:"请输入名称",visitorIdNotice:"您的访客 ID 是 {{id}},请保存以便恢复",newDocument:"新建文档",newFolder:"新建文件夹",noDocumentsYet:"暂无文档",collapseFolder:"收起文件夹",expandFolder:"展开文件夹",noDocsInDomain:"此域尚无文档。请在下方切换域或创建文档。",createDocToStart:"创建一个文档或选择一个文档开始写作。",domainLabel:"域",defaultDomain:"默认",displayNamePlaceholder:"显示名称",currentDomainAria:"当前域",insertDiagram:"插入图表",outlineHide:"隐藏大纲",outlineShow:"显示大纲",readOnlyNotice:`> 您无权限编辑
|
|
69
|
+
`,newDocumentTitle:"New document",newFolderTitle:"New folder",fileNameLabel:"File name",folderNameLabel:"Folder name",fileNameHint:"Names are shown as you type; stored paths are normalised (e.g. spaces → underscores). Use a .md file name.",folderNameHint:"Names are shown as you type; stored paths are normalised (e.g. folder 1 → folder_1).",untitledPlaceholder:"untitled.md",folderExamplePlaceholder:"e.g. research",pathExists:"this path already exists; pick another name",folderExists:"a folder with this name already exists",deleteConfirm:"delete {{name}}?",newDocIn:"New document in {{name}}",newDocAtRoot:"New document at root",newDocBeside:"New document beside this",newFolderIn:"New folder in {{name}}",newFolderAtRoot:"New folder at root",newFolderBeside:"New folder beside this",deleteItem:"Delete {{name}}",deleteFolder:"Delete {{name}}",editDiagram:"Edit diagram",newDiagram:"New diagram",saveAndInsert:"Save and insert",deleteDiagram:"Delete diagram",openFailed:"open failed: {{message}}",components:"Components",dragToCanvas:"drag to canvas",shapeRectangle:"Rectangle",shapeRounded:"Rounded",shapeCircle:"Circle",shapeDiamond:"Diamond",shapeTriangle:"Triangle",shapePentagon:"Pentagon",shapeText:"Text",shapeLine:"Line",shapeData:"Data",shapeDatabase:"Database",shapeDocument:"Document",shapeDisplay:"Display",shapeManual:"Manual",shapeParallel:"Parallel",shapeComment:"Comment",shapeSubprocess:"Subprocess",shapeQueue:"Queue",shapeIntStorage:"Int. Storage",shapeExtStorage:"Ext. Storage",errUnauthenticated:"Please register first",errBadRequest:"Invalid request",errInvalidVisitorName:"Invalid visitor name",errDocExists:"Document already exists",errDocNotFound:"Document not found",errForbidden:"You don't have permission",errInternal:"Internal error",errInvalidPath:"Invalid path",errUnknown:"Unknown error",errUnknownVisitorIds:"Some visitor IDs are invalid or disabled.",errTemplateNotFound:"Member template not found.",errDomainNotRestricted:"Member import only applies to restricted domains.",pathRequired:"relative path is required",pathMustBeRelative:"path must be relative",useForwardSlashes:"use forward slashes",pathNoDotDot:"path must not contain ..",pathMustEndWithMd:"document path must end with .md",pathUnsupportedChars:"path contains unsupported characters",pathEscapesRoot:"path escapes docs root",enterFolderName:"enter a folder name",singleNameNotPath:"use a single name, not a path",invalidFolderName:"invalid folder name",folderNameTooLong:"folder name is too long",enterFileName:"enter a file name",singleFileNameNotPath:"use a file name, not a path",invalidFileName:"invalid file name",fileNameTooLong:"file name is too long",permissionLabel:"Permission",permissionPrivate:"Private",permissionInvite:"Invite",permissionDomainWrite:"Domain write",permissionPublicRead:"Public read",permissionPublicEdit:"Public edit",invitePermissionRead:"Read only",invitePermissionEdit:"Can edit",personalDomainSuffix:"'s workspace",settings:"Settings",general:"General",language:"Language",backToDocs:"Back to documents",saveAndPublish:"Save & Publish",domainManagement:"Domain Management",createDomain:"New domain",domainName:"Domain Name",domainPermission:"Permission",domainPublic:"Public",domainRestricted:"Restricted",domainPrivate:"Private",docCount:"{{count}} documents",rename:"Rename",deleteDomain:"Delete Domain",deleteDomainConfirm:"Delete domain {{name}}?",domainLocked:"Has documents, locked",noDomains:"No domains",domainNameRequired:"Enter a domain name",domainBuiltIn:"Built-in",domainNotCreator:"Only the creator can modify this domain",domainSearchPlaceholder:"Search domain name…",domainFilterAll:"All",domainColName:"Name",domainColType:"Type",domainColDocCount:"Documents",domainColActions:"Actions",domainTypeBuiltinSuffix:"(built-in)",domainChangeType:"Change type",domainNotModifiable:"—",domainTooltipTypeLocked:"This domain has {{count}} document(s); type cannot be changed.",deleteDomainConfirmDetail:"Delete domain «{{name}}»? All {{count}} document(s) in it will be permanently removed.",domainNoMatch:"No matching domains.",memberTemplates:"Member templates",memberTemplateFormNew:"New template",memberTemplateSavedList:"Saved templates",memberTemplateIntro:"Save reusable member lists for restricted domains. Use Choose members… to pick people (left list = everyone, right = selected). You can also apply a template inside that dialog. Then save the template here.",memberTemplateStepName:"1. Name your template",memberTemplateStepMembers:"2. Choose members",memberTemplateStepSave:"3. Save",memberTemplateStep2Hint:"Select at least 1 member to continue",memberTemplateNameLabel:"Template name",memberTemplateNamePlaceholder:"e.g. Core team",memberTemplateIdsLabel:"Members",memberTemplateIdsHint:"Use Choose members… to pick people in the list; you can also apply a template inside that dialog.",memberTemplateCreate:"Save template",memberTemplateUpdate:"Update template",memberTemplateCancelEdit:"Cancel edit",memberTemplateDelete:"Delete",memberTemplateDeleteConfirm:"Delete template «{{name}}»?",memberTemplateConfirmDeleteCancel:"Cancel",memberTemplateConfirmDeleteDesc:"Delete template «{{name}}»? This cannot be undone.",memberTemplateConfirmDeleteSubmit:"Delete",memberTemplateEmpty:"No templates yet. Create one here, then use Members… on a restricted domain in Domain management.",memberTemplateEmptyAction:"Create first template",memberTemplateCount:"{{count}} visitors",memberTemplatePickerTitle:"Choose visitors for this template",memberTemplatePickMembersButton:"Choose members…",memberTemplateSelectedSummary:"{{count}} selected",memberTemplateWizardBack:"Back",memberTemplateWizardNext:"Next",domainMembersManageButton:"Members…",domainMembersPickerTitle:"Restricted domain members",domainMembersSaved:"Saved {{count}} member(s).",visitorPickerSearchPlaceholder:"Search by name or visitor id…",visitorPickerColumnAll:"Everyone",visitorPickerColumnSelected:"Selected",visitorPickerApplyTemplate:"Apply template",visitorPickerPickTemplate:"Pick a template…",visitorPickerConfirm:"Done",visitorPickerLoadError:"Could not load visitor list.",visitorPickerEmptyDirectory:"No visitors yet.",visitorPickerNoSelection:"No one selected yet.",visitorPickerColIdShort:"ID (6)",visitorPickerColName:"Name",visitorPickerColPick:"Pick",visitorPickerColIdFull:"Visitor ID",visitorPickerRemove:"Remove from selection",visitorPickerLockedHint:"This member cannot be removed (domain owner).",visitorPickerUnknownVisitor:"Unknown ID (not in directory)",visitorPickerMemberMissing:"Removed visitor (no longer in database)",visitorPickerDisabledTag:"inactive account",visitorPickerSelfMarker:"(you)",domainMemberImportPickTemplate:"Choose template…",domainMemberImportSection:"Members (from saved template)",domainMgmtRestrictedMemberHint:"For restricted domains you own: click Members… in the Actions column, then pick people in the dialog (or apply a saved template). The domain owner always stays in the list.",domainMemberImportApply:"Import members",domainMemberImportDone:"Added {{count}} member(s).",domainMemberImportHint:"Add templates under “Member templates” first.",shared:"Shared",autoSave:"Auto Save (Local Snapshot)",autoSaveDesc:"When enabled, your content is protected from network outages, crashes, or accidental refreshes. Disabling this feature puts your data at high risk of loss.",autoSaveAlwaysOnDesc:"Always enabled — your content is continuously saved to a local snapshot, so you never lose work.",autoSaveBadge:"Recommended",autoSaveTurnOffTitle:"High Risk Operation",autoSaveTurnOffBody:"Without auto-save, content is only stored when you manually save or publish. If the browser crashes, closes unexpectedly, or refreshes, all unsaved content will be permanently lost.",autoSaveTurnOffConfirm:"Confirm Disable",autoSaveTurnOffCancel:"Keep Enabled",autoPublish:"Auto Sync to Cloud",autoPublishDesc:"Push changes to the server in real time. When network is unstable or multi-device editing conflicts occur, sync will pause to protect data integrity.",viewDrafts:"View Unpublished Drafts",unpublishedDrafts:"Unpublished Drafts",noDrafts:"No unpublished drafts",draftCount:"{{count}} unpublished",publishAll:"Publish all",conflictTitle:"Publish conflict",conflictBody:"Local version conflicts with remote. Please resolve the merge manually and re-publish.",conflictResolve:"Resolve conflict",conflictClose:"Close",syncPull:"Pull update",syncBehindHint:"New version on server",pullConfirmTitle:"Pull remote version",pullConfirmBody:"Updates the editor from the server when there is no local draft.",mergeTitle:"Merge conflict",mergeLocal:"Local",mergeRemote:"Remote",mergeResult:"Merged",mergeSource:"Source",mergePreview:"Preview",mergeComplete:"Merge and publish",mergeLoadRemoteFailed:"Failed to load remote content",mergeLoadLocalFailed:"Failed to load local snapshot",mergeLoadingRemote:"Loading…",mergeConflictsUnresolved:"{{count}} unresolved conflict(s). Resolve all conflicts before publishing.",mergeConflictsPending:"Conflicts pending {{unresolved}} / {{total}}",mergeConflictsResolved:"All conflicts resolved ({{total}})",mergeConflictsPanel:"Conflicts",mergeConflictItem:"Conflict {{index}} / {{total}}",mergeConflictUnresolved:"Pending",mergeConflictResolved:"Resolved",mergeAcceptLocal:"Accept local",mergeAcceptRemote:"Accept remote",mergeAcceptBoth:"Keep both",mergeAcceptManual:"Edit manually",mergeNoConflicts:"Local and remote match — you can publish directly.",mergeResultHint:"Assembled from your choices; you may still edit below",mergeResultInlineHint:"Confirm every change from the merge base inline",mergeBase:"Base",mergeBaseMissing:"Could not load merge base — using two-way diff",pullBlockedConflict:"Unresolved conflict — merge first.",syncHeadMissing:"Cannot publish: reopen the document to refresh version info.",syncPullDone:"Pulled latest from server",unsavedChanges:"You have unsaved changes.",edit:"Edit",autoEdit:"Auto Edit",autoEditDesc:"Automatically enter edit mode when opening a document",saveDraft:"Save Draft",continue:"Continue",draftDeleted:"Draft deleted",confirmDeleteDraft:"Permanently delete this draft? This action cannot be undone.",draftsEmptyState:"All drafts synced — no unpublished content.",localSnapshot:"Local snapshot",unknownTitle:"Untitled document",draftPublishFailedNotice:'Draft "{{name}}" publish failed: document not found',draftPublishFailedSyncHead:'Draft "{{name}}" publish failed: missing version baseline — reopen the document or fix on server',draftPublishFailedGeneric:'Draft "{{name}}" publish failed: {{reason}}',publishFailed:"Publish failed",recoverDraft:"Save As New Document",recoverDraftDesc:'Save the draft of "{{name}}" as a brand new document',recoverTargetFolder:"Target Folder",cliToken:"CLI Token",cliTokenDesc:"Identity token for CLI and Agent tools, inherits all your permissions",cliTokenCreate:"Create",cliTokenReset:"Reset",cliTokenGenerated:"New CLI Token generated",cliTokenCopy:"Copy",cliTokenCopied:"Copied",cliTokenCopyFailed:"Copy failed — select the token above and copy manually",cliTokenResetConfirm:"Resetting will revoke all existing tokens and generate a new one. Confirm?",cliTokenActive:"Active",cliTokenRevoked:"Revoked",docInfo:"Document info",docInfoCreator:"Creator",docInfoCreatedAt:"Created",docInfoSize:"Size",docInfoUpdatedAt:"Last edited",docInfoChangePermission:"Change permission",docInfoInviteMember:"Invite members",docInfoInviteSuccess:"Invited {{count}} member(s)",docInfoPermissionUpdated:"Permission updated",expandSidebar:"Expand sidebar",collapseSidebar:"Collapse sidebar",bookmark:"Bookmarks",bookmarkAdd:"Add to bookmarks",bookmarkRemove:"Remove from bookmarks",bookmarkTitle:"My Bookmarks",bookmarkEmpty:"No bookmarks yet",bookmarkOpen:"Open",bookmarkAdded:"Bookmark added",bookmarkRemoved:"Bookmark removed",bookmarkColTitle:"Title",bookmarkColDomain:"Domain",bookmarkColAuthor:"Author",bookmarkColTime:"Bookmarked",bookmarkSearch:"Search bookmarks",bookmarkFilterAll:"All domains",bookmarkNoMatch:"No matching bookmarks",myDocuments:"My Documents",myDocumentsEmpty:"No documents yet",myDocumentsColTitle:"Title",myDocumentsColDomain:"Domain",myDocumentsColUpdated:"Updated",myDocumentsColCreated:"Created",myDocumentsNoMatch:"No matching documents",agentConfig:"AI",agentConfigDesc:"Configure DeepSeek for mdocs 智能助手. Only you can use this key.",agentConfigName:"Config name",agentConfigNameDefault:"Default: {{name}}'s ds config",agentConfigModel:"Model",agentConfigContextWindow:"Context window",agentConfigContextWindowDesc:"Token budget for the assistant (default 128000). Used for the usage ring.",agentConfigApiKey:"API Key",agentConfigApiKeyPlaceholder:"Paste DeepSeek API Key",agentConfigApiKeyConfigured:"Configured {{masked}}; leave blank to keep",agentConfigId:"Config ID",agentConfigShowKey:"Show API Key",agentConfigHideKey:"Hide API Key",agentFabOpen:"Open mdocs 智能助手",agentFabReset:"Reset position",logout:"Sign out"},Do={loading:"加载中...",saved:"已保存",saving:"保存中...",unsaved:"编辑中...",publish:"发布",publishing:"发布中...",published:"已发布",cancel:"取消",create:"创建",creating:"创建中...",close:"关闭",delete:"删除",save:"保存",gotIt:"知道了",error:"错误",brand:"mdocs",welcomeTitle:"欢迎使用 mdocs",welcomeDesc:"输入一个显示名称以创建访客身份。一个安全令牌将存储在此浏览器中,以便在后续访问时识别您。",visitorNamePlaceholder:"您的名字",createVisitor:"创建访客",nameRequired:"请输入名称",visitorIdNotice:"您的访客 ID 是 {{id}},请保存以便恢复",newDocument:"新建文档",newFolder:"新建文件夹",noDocumentsYet:"暂无文档",collapseFolder:"收起文件夹",expandFolder:"展开文件夹",noDocsInDomain:"此域尚无文档。请在下方切换域或创建文档。",createDocToStart:"创建一个文档或选择一个文档开始写作。",domainLabel:"域",defaultDomain:"默认",displayNamePlaceholder:"显示名称",currentDomainAria:"当前域",insertDiagram:"插入图表",outlineHide:"隐藏大纲",outlineShow:"显示大纲",readOnlyNotice:`> 您无权限编辑
|
|
70
70
|
|
|
71
|
-
`,newDocumentTitle:"新建文档",newFolderTitle:"新建文件夹",fileNameLabel:"文件名",folderNameLabel:"文件夹名",fileNameHint:"名称按您输入的方式显示;存储路径会被规范化(例如空格 → 下划线)。请使用 .md 文件名。",folderNameHint:"名称按您输入的方式显示;存储路径会被规范化(例如 folder 1 → folder_1)。",untitledPlaceholder:"未命名.md",folderExamplePlaceholder:"例如 research",pathExists:"此路径已存在,请选择其他名称",folderExists:"此名称的文件夹已存在",deleteConfirm:"删除 {{name}}?",newDocIn:"在 {{name}} 中新建文档",newDocAtRoot:"在根目录新建文档",newDocBeside:"在同级新建文档",newFolderIn:"在 {{name}} 中新建文件夹",newFolderAtRoot:"在根目录新建文件夹",newFolderBeside:"在同级新建文件夹",deleteItem:"删除 {{name}}",deleteFolder:"删除「{{name}}」",editDiagram:"编辑图表",newDiagram:"新建图表",saveAndInsert:"保存并插入",deleteDiagram:"删除图表",openFailed:"打开失败:{{message}}",components:"组件",dragToCanvas:"拖拽到画布",shapeRectangle:"矩形",shapeRounded:"圆角矩形",shapeCircle:"圆形",shapeDiamond:"菱形",shapeTriangle:"三角形",shapePentagon:"五边形",shapeText:"文本",shapeLine:"线条",shapeData:"数据",shapeDatabase:"数据库",shapeDocument:"文档",shapeDisplay:"显示",shapeManual:"手动",shapeParallel:"并行",shapeComment:"注释",shapeSubprocess:"子流程",shapeQueue:"队列",shapeIntStorage:"内部存储",shapeExtStorage:"外部存储",errUnauthenticated:"请先注册",errBadRequest:"请求无效",errInvalidVisitorName:"访客名称无效",errDocExists:"文档已存在",errDocNotFound:"文档不存在",errForbidden:"您没有权限",errInternal:"内部错误",errInvalidPath:"路径无效",errUnknown:"未知错误",errUnknownVisitorIds:"部分访客 ID 无效或已停用。",errTemplateNotFound:"找不到该成员模板。",errDomainNotRestricted:"仅受限域可从模板导入成员。",pathRequired:"需要提供相对路径",pathMustBeRelative:"路径必须是相对路径",useForwardSlashes:"请使用正斜杠",pathNoDotDot:"路径不能包含 ..",pathMustEndWithMd:"文档路径必须以 .md 结尾",pathUnsupportedChars:"路径包含不支持的字符",pathEscapesRoot:"路径超出了文档根目录",enterFolderName:"请输入文件夹名称",singleNameNotPath:"请使用单个名称,而非路径",invalidFolderName:"文件夹名称无效",folderNameTooLong:"文件夹名称过长",enterFileName:"请输入文件名",singleFileNameNotPath:"请使用文件名,而非路径",invalidFileName:"文件名无效",fileNameTooLong:"文件名过长",permissionLabel:"权限",permissionPrivate:"私有",permissionInvite:"邀请",permissionDomainWrite:"域内可编辑",permissionPublicRead:"公开可读",permissionPublicEdit:"公开可编辑",invitePermissionRead:"只读",invitePermissionEdit:"可编辑",personalDomainSuffix:"个人域",settings:"设置",general:"通用",language:"语言",backToDocs:"返回文档",saveAndPublish:"保存与发布",domainManagement:"域管理",createDomain:"创建新域",domainName:"域名称",domainPermission:"权限",domainPublic:"公开",domainRestricted:"受限",domainPrivate:"私有",docCount:"{{count}} 篇文档",rename:"重命名",deleteDomain:"删除域",deleteDomainConfirm:"确定删除域 {{name}}?",domainLocked:"有文档,不可修改",noDomains:"暂无域",domainNameRequired:"请输入域名称",domainBuiltIn:"系统内置",domainNotCreator:"您不是创建者,无权修改域设置",domainSearchPlaceholder:"搜索域名…",domainFilterAll:"全部",domainColName:"域名",domainColType:"类型",domainColDocCount:"文档数",domainColActions:"操作",domainTypeBuiltinSuffix:"(内置)",domainChangeType:"改类型",domainNotModifiable:"—",domainTooltipTypeLocked:"已有 {{count}} 篇文档,不可修改类型",deleteDomainConfirmDetail:"确定删除域「{{name}}」吗?域内 {{count}} 篇文档将被永久删除。",domainNoMatch:"没有匹配的域",memberTemplates:"域成员模板",memberTemplateFormNew:"新建模板",memberTemplateSavedList:"已保存的模板",memberTemplateIntro:"把常用成员存成模板,供受限域复用。点「选择成员…」在弹窗里左侧勾选、右侧为已选,也可在弹窗内应用模板。选好后在此保存模板。",memberTemplateStepName:"1. 填写名称",memberTemplateStepMembers:"2. 选择成员",memberTemplateStepSave:"3. 保存",memberTemplateStep2Hint:"至少选择 1 名成员才能继续",memberTemplateNameLabel:"模板名称",memberTemplateNamePlaceholder:"例如:核心开发组",memberTemplateIdsLabel:"成员",memberTemplateIdsHint:"通过下方「选择成员…」在列表中勾选;支持在弹窗内从模板自动勾选。",memberTemplateCreate:"保存模板",memberTemplateUpdate:"更新模板",memberTemplateCancelEdit:"取消编辑",memberTemplateDelete:"删除",memberTemplateDeleteConfirm:"删除模板「{{name}}」?",memberTemplateConfirmDeleteCancel:"取消",memberTemplateConfirmDeleteDesc:"确定删除模板「{{name}}」?此操作不可恢复。",memberTemplateConfirmDeleteSubmit:"确认删除",memberTemplateEmpty:"尚无模板。先在此创建,再在「域管理」里对受限域管理成员。",memberTemplateEmptyAction:"创建第一个模板",memberTemplateCount:"{{count}} 人",memberTemplatePickerTitle:"本模板包含的成员",memberTemplatePickMembersButton:"选择成员…",memberTemplateSelectedSummary:"已选 {{count}} 人",memberTemplateWizardBack:"上一步",memberTemplateWizardNext:"下一步",domainMembersManageButton:"成员…",domainMembersPickerTitle:"受限域成员",domainMembersSaved:"已保存 {{count}} 名成员。",visitorPickerSearchPlaceholder:"按昵称或 visitor id 搜索…",visitorPickerColumnAll:"全部访客",visitorPickerColumnSelected:"已选成员",visitorPickerApplyTemplate:"套用模板",visitorPickerPickTemplate:"选择模板…",visitorPickerConfirm:"完成",visitorPickerLoadError:"无法加载访客列表。",visitorPickerEmptyDirectory:"暂无访客。",visitorPickerNoSelection:"尚未选择任何人。",visitorPickerColIdShort:"ID 前 6 位",visitorPickerColName:"昵称",visitorPickerColPick:"勾选",visitorPickerColIdFull:"Visitor ID(完整)",visitorPickerRemove:"从已选中移除",visitorPickerLockedHint:"域创建者不可移除。",visitorPickerUnknownVisitor:"未知 ID(不在当前访客列表)",visitorPickerMemberMissing:"已删除的访客(库中无记录)",visitorPickerDisabledTag:"已停用",visitorPickerSelfMarker:"(你)",domainMemberImportPickTemplate:"选择模板…",domainMemberImportSection:"域成员(从模板导入)",domainMgmtRestrictedMemberHint:"对你创建的受限域:在「操作」列点「成员…」,在弹窗中勾选成员或套用模板;创建者会始终保留在已选列表中。",domainMemberImportApply:"导入成员",domainMemberImportDone:"新加入 {{count}} 名成员。",domainMemberImportHint:"请先在「域成员模板」中创建模板。",shared:"共享",autoSave:"自动保存 (本地快照)",autoSaveDesc:"开启后,即使断网、崩溃或误刷新,内容也不会丢失。关闭此功能将面临极高的数据丢失风险。",autoSaveAlwaysOnDesc:"始终开启 — 内容会持续保存到本地快照,永不会丢失。",autoSaveBadge:"强烈推荐",autoSaveTurnOffTitle:"高风险操作",autoSaveTurnOffBody:"关闭自动保存后,编辑内容仅在手动保存或发布时才会被存储。一旦浏览器崩溃、误关闭或刷新页面,所有未保存的内容将永久丢失。",autoSaveTurnOffConfirm:"确认关闭",autoSaveTurnOffCancel:"保持开启",autoPublish:"自动同步至云端",autoPublishDesc:"实时推送到服务器。当网络不稳定或多端编辑冲突时,系统将暂停同步以保护数据完整性。",viewDrafts:"查看未发布草稿",unpublishedDrafts:"未发布草稿",noDrafts:"暂无未发布草稿",draftCount:"{{count}} 篇未发布",publishAll:"全部发布",conflictTitle:"发布冲突",conflictBody:"云端版本与本地版本冲突,请手动处理合并后重新发布。",conflictResolve:"解决冲突",conflictClose:"关闭",syncPull:"拉取更新",syncBehindHint:"云端有新版本",pullConfirmTitle:"拉取远端版本",pullConfirmBody:"无本地草稿时,用云端内容更新编辑区。",mergeTitle:"合并冲突",mergeLocal:"本地",mergeRemote:"远端",mergeResult:"合并结果",mergeSource:"源码",mergePreview:"预览",mergeComplete:"完成合并并发布",mergeLoadRemoteFailed:"加载远端内容失败",mergeLoadLocalFailed:"加载本地快照失败",mergeLoadingRemote:"加载中…",mergeConflictsUnresolved:"仍有 {{count}} 处冲突未解决,请处理后再发布",mergeConflictsPending:"冲突待处理 {{unresolved}} / {{total}}",mergeConflictsResolved:"冲突已全部处理({{total}})",mergeConflictsPanel:"冲突块",mergeConflictItem:"冲突 {{index}} / {{total}}",mergeConflictUnresolved:"待处理",mergeConflictResolved:"已处理",mergeAcceptLocal:"采用本地",mergeAcceptRemote:"采用远端",mergeAcceptBoth:"保留双方",mergeAcceptManual:"手动编辑",mergeNoConflicts:"本地与远端正文一致,可直接发布。",mergeResultHint:"由冲突决议自动拼接,也可直接修改",mergeResultInlineHint:"相对祖先有改动的行均需在正文中点选确认",mergeBase:"祖先",mergeBaseMissing:"无法加载公共祖先,已退化为两方比对",pullBlockedConflict:"存在未解决的冲突,请先合并。",syncHeadMissing:"无法发布:缺少版本基准,请重新打开文档。",syncPullDone:"已拉取云端最新版本",unsavedChanges:"您有未保存的内容。",edit:"编辑",autoEdit:"自动编辑",autoEditDesc:"打开文档时自动进入编辑模式",saveDraft:"保存草稿",continue:"继续",draftDeleted:"草稿已删除",confirmDeleteDraft:"确定要永久删除这篇草稿吗?此操作不可恢复。",draftsEmptyState:"所有草稿已同步,当前无未发布内容。",localSnapshot:"本地快照",unknownTitle:"未命名文档",draftPublishFailedNotice:"草稿「{{name}}」发布失败:文档不存在",draftPublishFailedSyncHead:"草稿「{{name}}」发布失败:缺少版本基准,请重新打开文档",draftPublishFailedGeneric:"草稿「{{name}}」发布失败:{{reason}}",publishFailed:"发布失败",recoverDraft:"另存为新文档",recoverDraftDesc:"将「{{name}}」的草稿内容保存为一篇全新文档",recoverTargetFolder:"目标目录",cliToken:"CLI Token",cliTokenDesc:"用于命令行工具和 Agent 的身份令牌,继承你的所有权限",cliTokenCreate:"创建",cliTokenReset:"重置",cliTokenGenerated:"已生成新的 CLI Token",cliTokenCopy:"复制",cliTokenCopied:"已复制",cliTokenCopyFailed:"复制失败,请手动选中上方内容复制",cliTokenResetConfirm:"重置将吊销当前所有已有 Token,并生成新的 Token。确认重置?",cliTokenActive:"活跃",cliTokenRevoked:"已吊销",docInfo:"文档信息",docInfoCreator:"创建者",docInfoCreatedAt:"创建时间",docInfoSize:"大小",docInfoUpdatedAt:"上次编辑",docInfoChangePermission:"修改文章权限",docInfoInviteMember:"邀请成员",docInfoInviteSuccess:"已邀请 {{count}} 人",docInfoPermissionUpdated:"权限已更新",expandSidebar:"展开侧边栏",collapseSidebar:"收起侧边栏",bookmark:"收藏",bookmarkAdd:"添加收藏",bookmarkRemove:"取消收藏",bookmarkTitle:"我的收藏",bookmarkEmpty:"暂无收藏",bookmarkOpen:"打开",bookmarkAdded:"已添加收藏",bookmarkRemoved:"已取消收藏",bookmarkColTitle:"标题",bookmarkColDomain:"域",bookmarkColAuthor:"作者",bookmarkColTime:"收藏时间",bookmarkSearch:"搜索收藏",bookmarkFilterAll:"全部域",bookmarkNoMatch:"暂无匹配的收藏",myDocuments:"我的文章",myDocumentsEmpty:"暂无文章",myDocumentsColTitle:"标题",myDocumentsColDomain:"域",myDocumentsColUpdated:"更新时间",myDocumentsColCreated:"创建时间",myDocumentsNoMatch:"暂无匹配的文章",agentConfig:"AI",agentConfigDesc:"配置 DeepSeek 用于 mdocs 智能助手。仅本人可用,不会分享给其他访客。",agentConfigName:"配置名称",agentConfigNameDefault:"不填则:{{name}}的 ds 配置",agentConfigModel:"模型",agentConfigContextWindow:"上下文窗口",agentConfigContextWindowDesc:"助手可用的 token 上限(默认 128000),用于占用圆环显示。",agentConfigApiKey:"API Key",agentConfigApiKeyPlaceholder:"粘贴 DeepSeek API Key",agentConfigApiKeyConfigured:"已配置 {{masked}},留空不修改",agentConfigId:"配置 ID",agentConfigShowKey:"显示 API Key",agentConfigHideKey:"隐藏 API Key",agentFabOpen:"打开 mdocs 智能助手",agentFabReset:"重置位置",logout:"退出登录"},nn="mdocs.lang",Do={en:xo,zh:Io};function Co(){const e=window.localStorage.getItem(nn);return e==="zh"||e==="en"?e:navigator.language.toLowerCase().startsWith("zh")?"zh":"en"}const on=a.createContext(null);function So({children:e}){const[t,i]=a.useState(Co);a.useEffect(()=>{document.documentElement.lang=t==="zh"?"zh-CN":"en"},[t]);const r=a.useCallback(d=>{window.localStorage.setItem(nn,d),i(d)},[]),s=a.useCallback((d,l)=>{let p=Do[t][d]??d;if(l)for(const[h,m]of Object.entries(l))p=p.replaceAll(`{{${h}}}`,m);return p},[t]);return n.jsx(on.Provider,{value:{lang:t,setLang:r,t:s},children:e})}function de(){const e=a.useContext(on);if(!e)throw new Error("useI18n must be used within I18nProvider");return e}function je(e){const{content:t,contentHash:i,...r}=e;return r}function ko(){let e=Promise.resolve();return{execute:i=>{const r=e.then(i);return e=r.then(()=>{},()=>{}),r}}}const Bt=new Map;function $t(e){let t=Bt.get(e);return t||(t=ko(),Bt.set(e,t)),t}const te={PRIVATE:0,DOMAIN_READ:1,DOMAIN_WRITE:2,PUBLIC_READ:3,PUBLIC_WRITE:4};function No(e){return e===te.PUBLIC_WRITE}function qi(e){return e==="public"?[te.PUBLIC_READ,te.PUBLIC_WRITE]:e==="restricted"?[te.DOMAIN_READ,te.DOMAIN_WRITE]:[te.PRIVATE,te.DOMAIN_READ,te.DOMAIN_WRITE,te.PUBLIC_READ,te.PUBLIC_WRITE]}const Ht="___desc___.md";function Po(e){const t=e.trim();return t?`${t}/${Ht}`:Ht}class le extends Error{constructor(t){super(t),this.name="DocPathError"}}const To=120,Eo=200;function mt(e){let t=e.trim().replace(/\s+/g,"_");for(t=t.replace(/[^A-Za-z0-9_\-\.\u4e00-\u9fa5]/g,"_"),t=t.replace(/_+/g,"_"),t=t.replace(/^[._]+|[._]+$/g,"");t.includes("..");)t=t.replace(/\.\./g,"_");return t==="."||t===".."||!t?"":t}function Ao(e){const t=e.trim();return t?t.includes("/")||t.includes("\\")?{ok:!1,message:"use a single name, not a path"}:t==="."||t===".."?{ok:!1,message:"invalid folder name"}:t.length>To?{ok:!1,message:"folder name is too long"}:{ok:!0,display:t}:{ok:!1,message:"enter a folder name"}}function jo(e){let t=e.trim();return t?t.includes("/")||t.includes("\\")?{ok:!1,message:"use a file name, not a path"}:t==="."||t===".."?{ok:!1,message:"invalid file name"}:(t.toLowerCase().endsWith(".md")||(t+=".md"),t.length>Eo?{ok:!1,message:"file name is too long"}:{ok:!0,displayFile:t}):{ok:!1,message:"enter a file name"}}function Mo(e){const t=e.trim().replace(/\\/g,"/");if(!t)throw new le("relative path is required");if(t.startsWith("/"))throw new le("path must be relative");if(t.includes(".."))throw new le("path must not contain ..");const i=t.split("/").filter(h=>h.length>0);if(i.length===0)throw new le("relative path is required");const r=[];for(let h=0;h<i.length-1;h+=1){const m=mt(i[h]);if(!m)throw new le("invalid path segment");r.push(m)}const s=i[i.length-1];if(!s.toLowerCase().endsWith(".md"))throw new le("document path must end with .md");const d=s.slice(0,-3),l=s.slice(-3),p=mt(d);if(!p)throw new le("invalid file name");return r.push(p+l),r.join("/")}class oe extends Error{constructor(i,r,s,d){super(s);Ie(this,"code");Ie(this,"status");Ie(this,"details");this.status=i,this.code=r,this.details=d}}const Ro={children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"README",type:"text",version:1,id:"148"}],direction:"ltr",format:"",indent:0,type:"heading",version:1,tag:"h1",id:"147"},{children:[{detail:0,format:2,mode:"normal",style:"",text:"Hi",type:"text",version:1,id:"149"},{detail:0,format:0,mode:"normal",style:"",text:",",type:"text",version:1,id:"150"},{detail:0,format:1,mode:"normal",style:"",text:"你好",type:"text",version:1,id:"151"},{detail:0,format:0,mode:"normal",style:"",text:",欢迎使用 mdocs 文本。下面是一段用来",type:"text",version:1,id:"152"},{detail:0,format:1,mode:"normal",style:"",text:"展示 mdocs 特性",type:"text",version:1,id:"153"},{detail:0,format:0,mode:"normal",style:"",text:"的示例文档,你可以按需删改。",type:"text",version:1,id:"154"}],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:2,textStyle:"",id:"255"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"文本与排版",type:"text",version:1,id:"156"}],direction:"ltr",format:"",indent:0,type:"heading",version:1,tag:"h2",id:"155"},{children:[{detail:0,format:1,mode:"normal",style:"",text:"粗体",type:"text",version:1,id:"157"},{detail:0,format:0,mode:"normal",style:"",text:"、",type:"text",version:1,id:"158"},{detail:0,format:2,mode:"normal",style:"",text:"斜体",type:"text",version:1,id:"159"},{detail:0,format:0,mode:"normal",style:"",text:"、",type:"text",version:1,id:"160"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"162"},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"163"},{detail:0,format:0,mode:"normal",style:"",text:"行内代码",type:"text",version:1,id:"164"}],direction:"ltr",format:"",indent:0,type:"codeInline",version:1,id:"161"},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"165"},{detail:0,format:0,mode:"normal",style:"",text:"、",type:"text",version:1,id:"166"},{detail:0,format:4,mode:"normal",style:"",text:"删除线",type:"text",version:1,id:"167"},{detail:0,format:0,mode:"normal",style:"",text:"。",type:"text",version:1,id:"168"}],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:1,textStyle:"",id:"256"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"引用块:适合写结论、提示或引用原文。",type:"text",version:1,id:"170"}],direction:"ltr",format:"",indent:0,type:"quote",version:1,id:"169"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"有序列表:",type:"text",version:1,id:"171"}],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:"",id:"257"},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"用 Markdown 记笔记",type:"text",version:1,id:"173"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:1,id:"174"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"用侧边栏管文档树",type:"text",version:1,id:"175"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:2,id:"176"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"需要时再发布或同步",type:"text",version:1,id:"177"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:3,id:"178"}],direction:"ltr",format:"",indent:0,type:"list",version:1,listType:"number",start:1,tag:"ol",id:"172"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"无序列表:",type:"text",version:1,id:"179"}],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:"",id:"258"},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"访客身份,无需单独注册账号(自建部署时由服务端配置)",type:"text",version:1,id:"181"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:1,id:"182"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"文档以 ",type:"text",version:1,id:"183"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:2,id:"184"},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"186"},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"187"},{detail:0,format:0,mode:"normal",style:"",text:".md",type:"text",version:1,id:"188"}],direction:"ltr",format:"",indent:0,type:"codeInline",version:1,id:"185"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:3,id:"189"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"190"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:4,id:"191"},{children:[{detail:0,format:0,mode:"normal",style:"",text:" 为主存储,结构清晰",type:"text",version:1,id:"192"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:5,id:"193"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"支持个人域与协作域等能力(视部署与权限而定)",type:"text",version:1,id:"194"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:6,id:"195"}],direction:"ltr",format:"",indent:0,type:"list",version:1,listType:"bullet",start:1,tag:"ul",id:"180"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"代码",type:"text",version:1,id:"197"}],direction:"ltr",format:"",indent:0,type:"heading",version:1,tag:"h2",id:"196"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"行内常量如 ",type:"text",version:1,id:"198"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"200"},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"201"},{detail:0,format:0,mode:"normal",style:"",text:"VITE_DEMO_MODE",type:"text",version:1,id:"202"}],direction:"ltr",format:"",indent:0,type:"codeInline",version:1,id:"199"},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"203"},{detail:0,format:0,mode:"normal",style:"",text:",或小段示例:",type:"text",version:1,id:"204"}],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:"",id:"259"},{type:"code",version:1,code:`// 伪代码:表达「内容即文档」
|
|
71
|
+
`,newDocumentTitle:"新建文档",newFolderTitle:"新建文件夹",fileNameLabel:"文件名",folderNameLabel:"文件夹名",fileNameHint:"名称按您输入的方式显示;存储路径会被规范化(例如空格 → 下划线)。请使用 .md 文件名。",folderNameHint:"名称按您输入的方式显示;存储路径会被规范化(例如 folder 1 → folder_1)。",untitledPlaceholder:"未命名.md",folderExamplePlaceholder:"例如 research",pathExists:"此路径已存在,请选择其他名称",folderExists:"此名称的文件夹已存在",deleteConfirm:"删除 {{name}}?",newDocIn:"在 {{name}} 中新建文档",newDocAtRoot:"在根目录新建文档",newDocBeside:"在同级新建文档",newFolderIn:"在 {{name}} 中新建文件夹",newFolderAtRoot:"在根目录新建文件夹",newFolderBeside:"在同级新建文件夹",deleteItem:"删除 {{name}}",deleteFolder:"删除「{{name}}」",editDiagram:"编辑图表",newDiagram:"新建图表",saveAndInsert:"保存并插入",deleteDiagram:"删除图表",openFailed:"打开失败:{{message}}",components:"组件",dragToCanvas:"拖拽到画布",shapeRectangle:"矩形",shapeRounded:"圆角矩形",shapeCircle:"圆形",shapeDiamond:"菱形",shapeTriangle:"三角形",shapePentagon:"五边形",shapeText:"文本",shapeLine:"线条",shapeData:"数据",shapeDatabase:"数据库",shapeDocument:"文档",shapeDisplay:"显示",shapeManual:"手动",shapeParallel:"并行",shapeComment:"注释",shapeSubprocess:"子流程",shapeQueue:"队列",shapeIntStorage:"内部存储",shapeExtStorage:"外部存储",errUnauthenticated:"请先注册",errBadRequest:"请求无效",errInvalidVisitorName:"访客名称无效",errDocExists:"文档已存在",errDocNotFound:"文档不存在",errForbidden:"您没有权限",errInternal:"内部错误",errInvalidPath:"路径无效",errUnknown:"未知错误",errUnknownVisitorIds:"部分访客 ID 无效或已停用。",errTemplateNotFound:"找不到该成员模板。",errDomainNotRestricted:"仅受限域可从模板导入成员。",pathRequired:"需要提供相对路径",pathMustBeRelative:"路径必须是相对路径",useForwardSlashes:"请使用正斜杠",pathNoDotDot:"路径不能包含 ..",pathMustEndWithMd:"文档路径必须以 .md 结尾",pathUnsupportedChars:"路径包含不支持的字符",pathEscapesRoot:"路径超出了文档根目录",enterFolderName:"请输入文件夹名称",singleNameNotPath:"请使用单个名称,而非路径",invalidFolderName:"文件夹名称无效",folderNameTooLong:"文件夹名称过长",enterFileName:"请输入文件名",singleFileNameNotPath:"请使用文件名,而非路径",invalidFileName:"文件名无效",fileNameTooLong:"文件名过长",permissionLabel:"权限",permissionPrivate:"私有",permissionInvite:"邀请",permissionDomainWrite:"域内可编辑",permissionPublicRead:"公开可读",permissionPublicEdit:"公开可编辑",invitePermissionRead:"只读",invitePermissionEdit:"可编辑",personalDomainSuffix:"个人域",settings:"设置",general:"通用",language:"语言",backToDocs:"返回文档",saveAndPublish:"保存与发布",domainManagement:"域管理",createDomain:"创建新域",domainName:"域名称",domainPermission:"权限",domainPublic:"公开",domainRestricted:"受限",domainPrivate:"私有",docCount:"{{count}} 篇文档",rename:"重命名",deleteDomain:"删除域",deleteDomainConfirm:"确定删除域 {{name}}?",domainLocked:"有文档,不可修改",noDomains:"暂无域",domainNameRequired:"请输入域名称",domainBuiltIn:"系统内置",domainNotCreator:"您不是创建者,无权修改域设置",domainSearchPlaceholder:"搜索域名…",domainFilterAll:"全部",domainColName:"域名",domainColType:"类型",domainColDocCount:"文档数",domainColActions:"操作",domainTypeBuiltinSuffix:"(内置)",domainChangeType:"改类型",domainNotModifiable:"—",domainTooltipTypeLocked:"已有 {{count}} 篇文档,不可修改类型",deleteDomainConfirmDetail:"确定删除域「{{name}}」吗?域内 {{count}} 篇文档将被永久删除。",domainNoMatch:"没有匹配的域",memberTemplates:"域成员模板",memberTemplateFormNew:"新建模板",memberTemplateSavedList:"已保存的模板",memberTemplateIntro:"把常用成员存成模板,供受限域复用。点「选择成员…」在弹窗里左侧勾选、右侧为已选,也可在弹窗内应用模板。选好后在此保存模板。",memberTemplateStepName:"1. 填写名称",memberTemplateStepMembers:"2. 选择成员",memberTemplateStepSave:"3. 保存",memberTemplateStep2Hint:"至少选择 1 名成员才能继续",memberTemplateNameLabel:"模板名称",memberTemplateNamePlaceholder:"例如:核心开发组",memberTemplateIdsLabel:"成员",memberTemplateIdsHint:"通过下方「选择成员…」在列表中勾选;支持在弹窗内从模板自动勾选。",memberTemplateCreate:"保存模板",memberTemplateUpdate:"更新模板",memberTemplateCancelEdit:"取消编辑",memberTemplateDelete:"删除",memberTemplateDeleteConfirm:"删除模板「{{name}}」?",memberTemplateConfirmDeleteCancel:"取消",memberTemplateConfirmDeleteDesc:"确定删除模板「{{name}}」?此操作不可恢复。",memberTemplateConfirmDeleteSubmit:"确认删除",memberTemplateEmpty:"尚无模板。先在此创建,再在「域管理」里对受限域管理成员。",memberTemplateEmptyAction:"创建第一个模板",memberTemplateCount:"{{count}} 人",memberTemplatePickerTitle:"本模板包含的成员",memberTemplatePickMembersButton:"选择成员…",memberTemplateSelectedSummary:"已选 {{count}} 人",memberTemplateWizardBack:"上一步",memberTemplateWizardNext:"下一步",domainMembersManageButton:"成员…",domainMembersPickerTitle:"受限域成员",domainMembersSaved:"已保存 {{count}} 名成员。",visitorPickerSearchPlaceholder:"按昵称或 visitor id 搜索…",visitorPickerColumnAll:"全部访客",visitorPickerColumnSelected:"已选成员",visitorPickerApplyTemplate:"套用模板",visitorPickerPickTemplate:"选择模板…",visitorPickerConfirm:"完成",visitorPickerLoadError:"无法加载访客列表。",visitorPickerEmptyDirectory:"暂无访客。",visitorPickerNoSelection:"尚未选择任何人。",visitorPickerColIdShort:"ID 前 6 位",visitorPickerColName:"昵称",visitorPickerColPick:"勾选",visitorPickerColIdFull:"Visitor ID(完整)",visitorPickerRemove:"从已选中移除",visitorPickerLockedHint:"域创建者不可移除。",visitorPickerUnknownVisitor:"未知 ID(不在当前访客列表)",visitorPickerMemberMissing:"已删除的访客(库中无记录)",visitorPickerDisabledTag:"已停用",visitorPickerSelfMarker:"(你)",domainMemberImportPickTemplate:"选择模板…",domainMemberImportSection:"域成员(从模板导入)",domainMgmtRestrictedMemberHint:"对你创建的受限域:在「操作」列点「成员…」,在弹窗中勾选成员或套用模板;创建者会始终保留在已选列表中。",domainMemberImportApply:"导入成员",domainMemberImportDone:"新加入 {{count}} 名成员。",domainMemberImportHint:"请先在「域成员模板」中创建模板。",shared:"共享",autoSave:"自动保存 (本地快照)",autoSaveDesc:"开启后,即使断网、崩溃或误刷新,内容也不会丢失。关闭此功能将面临极高的数据丢失风险。",autoSaveAlwaysOnDesc:"始终开启 — 内容会持续保存到本地快照,永不会丢失。",autoSaveBadge:"强烈推荐",autoSaveTurnOffTitle:"高风险操作",autoSaveTurnOffBody:"关闭自动保存后,编辑内容仅在手动保存或发布时才会被存储。一旦浏览器崩溃、误关闭或刷新页面,所有未保存的内容将永久丢失。",autoSaveTurnOffConfirm:"确认关闭",autoSaveTurnOffCancel:"保持开启",autoPublish:"自动同步至云端",autoPublishDesc:"实时推送到服务器。当网络不稳定或多端编辑冲突时,系统将暂停同步以保护数据完整性。",viewDrafts:"查看未发布草稿",unpublishedDrafts:"未发布草稿",noDrafts:"暂无未发布草稿",draftCount:"{{count}} 篇未发布",publishAll:"全部发布",conflictTitle:"发布冲突",conflictBody:"云端版本与本地版本冲突,请手动处理合并后重新发布。",conflictResolve:"解决冲突",conflictClose:"关闭",syncPull:"拉取更新",syncBehindHint:"云端有新版本",pullConfirmTitle:"拉取远端版本",pullConfirmBody:"无本地草稿时,用云端内容更新编辑区。",mergeTitle:"合并冲突",mergeLocal:"本地",mergeRemote:"远端",mergeResult:"合并结果",mergeSource:"源码",mergePreview:"预览",mergeComplete:"完成合并并发布",mergeLoadRemoteFailed:"加载远端内容失败",mergeLoadLocalFailed:"加载本地快照失败",mergeLoadingRemote:"加载中…",mergeConflictsUnresolved:"仍有 {{count}} 处冲突未解决,请处理后再发布",mergeConflictsPending:"冲突待处理 {{unresolved}} / {{total}}",mergeConflictsResolved:"冲突已全部处理({{total}})",mergeConflictsPanel:"冲突块",mergeConflictItem:"冲突 {{index}} / {{total}}",mergeConflictUnresolved:"待处理",mergeConflictResolved:"已处理",mergeAcceptLocal:"采用本地",mergeAcceptRemote:"采用远端",mergeAcceptBoth:"保留双方",mergeAcceptManual:"手动编辑",mergeNoConflicts:"本地与远端正文一致,可直接发布。",mergeResultHint:"由冲突决议自动拼接,也可直接修改",mergeResultInlineHint:"相对祖先有改动的行均需在正文中点选确认",mergeBase:"祖先",mergeBaseMissing:"无法加载公共祖先,已退化为两方比对",pullBlockedConflict:"存在未解决的冲突,请先合并。",syncHeadMissing:"无法发布:缺少版本基准,请重新打开文档。",syncPullDone:"已拉取云端最新版本",unsavedChanges:"您有未保存的内容。",edit:"编辑",autoEdit:"自动编辑",autoEditDesc:"打开文档时自动进入编辑模式",saveDraft:"保存草稿",continue:"继续",draftDeleted:"草稿已删除",confirmDeleteDraft:"确定要永久删除这篇草稿吗?此操作不可恢复。",draftsEmptyState:"所有草稿已同步,当前无未发布内容。",localSnapshot:"本地快照",unknownTitle:"未命名文档",draftPublishFailedNotice:"草稿「{{name}}」发布失败:文档不存在",draftPublishFailedSyncHead:"草稿「{{name}}」发布失败:缺少版本基准,请重新打开文档",draftPublishFailedGeneric:"草稿「{{name}}」发布失败:{{reason}}",publishFailed:"发布失败",recoverDraft:"另存为新文档",recoverDraftDesc:"将「{{name}}」的草稿内容保存为一篇全新文档",recoverTargetFolder:"目标目录",cliToken:"CLI Token",cliTokenDesc:"用于命令行工具和 Agent 的身份令牌,继承你的所有权限",cliTokenCreate:"创建",cliTokenReset:"重置",cliTokenGenerated:"已生成新的 CLI Token",cliTokenCopy:"复制",cliTokenCopied:"已复制",cliTokenCopyFailed:"复制失败,请手动选中上方内容复制",cliTokenResetConfirm:"重置将吊销当前所有已有 Token,并生成新的 Token。确认重置?",cliTokenActive:"活跃",cliTokenRevoked:"已吊销",docInfo:"文档信息",docInfoCreator:"创建者",docInfoCreatedAt:"创建时间",docInfoSize:"大小",docInfoUpdatedAt:"上次编辑",docInfoChangePermission:"修改文章权限",docInfoInviteMember:"邀请成员",docInfoInviteSuccess:"已邀请 {{count}} 人",docInfoPermissionUpdated:"权限已更新",expandSidebar:"展开侧边栏",collapseSidebar:"收起侧边栏",bookmark:"收藏",bookmarkAdd:"添加收藏",bookmarkRemove:"取消收藏",bookmarkTitle:"我的收藏",bookmarkEmpty:"暂无收藏",bookmarkOpen:"打开",bookmarkAdded:"已添加收藏",bookmarkRemoved:"已取消收藏",bookmarkColTitle:"标题",bookmarkColDomain:"域",bookmarkColAuthor:"作者",bookmarkColTime:"收藏时间",bookmarkSearch:"搜索收藏",bookmarkFilterAll:"全部域",bookmarkNoMatch:"暂无匹配的收藏",myDocuments:"我的文章",myDocumentsEmpty:"暂无文章",myDocumentsColTitle:"标题",myDocumentsColDomain:"域",myDocumentsColUpdated:"更新时间",myDocumentsColCreated:"创建时间",myDocumentsNoMatch:"暂无匹配的文章",agentConfig:"AI",agentConfigDesc:"配置 DeepSeek 用于 mdocs 智能助手。仅本人可用,不会分享给其他访客。",agentConfigName:"配置名称",agentConfigNameDefault:"不填则:{{name}}的 ds 配置",agentConfigModel:"模型",agentConfigContextWindow:"上下文窗口",agentConfigContextWindowDesc:"助手可用的 token 上限(默认 128000),用于占用圆环显示。",agentConfigApiKey:"API Key",agentConfigApiKeyPlaceholder:"粘贴 DeepSeek API Key",agentConfigApiKeyConfigured:"已配置 {{masked}},留空不修改",agentConfigId:"配置 ID",agentConfigShowKey:"显示 API Key",agentConfigHideKey:"隐藏 API Key",agentFabOpen:"打开 mdocs 智能助手",agentFabReset:"重置位置",logout:"退出登录"},on="mdocs.lang",Co={en:Io,zh:Do};function ko(){const e=window.localStorage.getItem(on);return e==="zh"||e==="en"?e:navigator.language.toLowerCase().startsWith("zh")?"zh":"en"}const rn=a.createContext(null);function So({children:e}){const[t,i]=a.useState(ko);a.useEffect(()=>{document.documentElement.lang=t==="zh"?"zh-CN":"en"},[t]);const r=a.useCallback(d=>{window.localStorage.setItem(on,d),i(d)},[]),s=a.useCallback((d,l)=>{let f=Co[t][d]??d;if(l)for(const[h,m]of Object.entries(l))f=f.replaceAll(`{{${h}}}`,m);return f},[t]);return n.jsx(rn.Provider,{value:{lang:t,setLang:r,t:s},children:e})}function de(){const e=a.useContext(rn);if(!e)throw new Error("useI18n must be used within I18nProvider");return e}function je(e){const{content:t,contentHash:i,...r}=e;return r}function No(){let e=Promise.resolve();return{execute:i=>{const r=e.then(i);return e=r.then(()=>{},()=>{}),r}}}const $t=new Map;function Ht(e){let t=$t.get(e);return t||(t=No(),$t.set(e,t)),t}const te={PRIVATE:0,DOMAIN_READ:1,DOMAIN_WRITE:2,PUBLIC_READ:3,PUBLIC_WRITE:4};function Po(e){return e===te.PUBLIC_WRITE}function Gi(e){return e==="public"?[te.PUBLIC_READ,te.PUBLIC_WRITE]:e==="restricted"?[te.DOMAIN_READ,te.DOMAIN_WRITE]:[te.PRIVATE,te.DOMAIN_READ,te.DOMAIN_WRITE,te.PUBLIC_READ,te.PUBLIC_WRITE]}const Ut="___desc___.md";function To(e){const t=e.trim();return t?`${t}/${Ut}`:Ut}class le extends Error{constructor(t){super(t),this.name="DocPathError"}}const Ao=120,Eo=200;function mt(e){let t=e.trim().replace(/\s+/g,"_");for(t=t.replace(/[^A-Za-z0-9_\-\.\u4e00-\u9fa5]/g,"_"),t=t.replace(/_+/g,"_"),t=t.replace(/^[._]+|[._]+$/g,"");t.includes("..");)t=t.replace(/\.\./g,"_");return t==="."||t===".."||!t?"":t}function jo(e){const t=e.trim();return t?t.includes("/")||t.includes("\\")?{ok:!1,message:"use a single name, not a path"}:t==="."||t===".."?{ok:!1,message:"invalid folder name"}:t.length>Ao?{ok:!1,message:"folder name is too long"}:{ok:!0,display:t}:{ok:!1,message:"enter a folder name"}}function Mo(e){let t=e.trim();return t?t.includes("/")||t.includes("\\")?{ok:!1,message:"use a file name, not a path"}:t==="."||t===".."?{ok:!1,message:"invalid file name"}:(t.toLowerCase().endsWith(".md")||(t+=".md"),t.length>Eo?{ok:!1,message:"file name is too long"}:{ok:!0,displayFile:t}):{ok:!1,message:"enter a file name"}}function Ro(e){const t=e.trim().replace(/\\/g,"/");if(!t)throw new le("relative path is required");if(t.startsWith("/"))throw new le("path must be relative");if(t.includes(".."))throw new le("path must not contain ..");const i=t.split("/").filter(h=>h.length>0);if(i.length===0)throw new le("relative path is required");const r=[];for(let h=0;h<i.length-1;h+=1){const m=mt(i[h]);if(!m)throw new le("invalid path segment");r.push(m)}const s=i[i.length-1];if(!s.toLowerCase().endsWith(".md"))throw new le("document path must end with .md");const d=s.slice(0,-3),l=s.slice(-3),f=mt(d);if(!f)throw new le("invalid file name");return r.push(f+l),r.join("/")}class oe extends Error{constructor(i,r,s,d){super(s);Ie(this,"code");Ie(this,"status");Ie(this,"details");this.status=i,this.code=r,this.details=d}}const Oo={children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"README",type:"text",version:1,id:"148"}],direction:"ltr",format:"",indent:0,type:"heading",version:1,tag:"h1",id:"147"},{children:[{detail:0,format:2,mode:"normal",style:"",text:"Hi",type:"text",version:1,id:"149"},{detail:0,format:0,mode:"normal",style:"",text:",",type:"text",version:1,id:"150"},{detail:0,format:1,mode:"normal",style:"",text:"你好",type:"text",version:1,id:"151"},{detail:0,format:0,mode:"normal",style:"",text:",欢迎使用 mdocs 文本。下面是一段用来",type:"text",version:1,id:"152"},{detail:0,format:1,mode:"normal",style:"",text:"展示 mdocs 特性",type:"text",version:1,id:"153"},{detail:0,format:0,mode:"normal",style:"",text:"的示例文档,你可以按需删改。",type:"text",version:1,id:"154"}],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:2,textStyle:"",id:"255"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"文本与排版",type:"text",version:1,id:"156"}],direction:"ltr",format:"",indent:0,type:"heading",version:1,tag:"h2",id:"155"},{children:[{detail:0,format:1,mode:"normal",style:"",text:"粗体",type:"text",version:1,id:"157"},{detail:0,format:0,mode:"normal",style:"",text:"、",type:"text",version:1,id:"158"},{detail:0,format:2,mode:"normal",style:"",text:"斜体",type:"text",version:1,id:"159"},{detail:0,format:0,mode:"normal",style:"",text:"、",type:"text",version:1,id:"160"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"162"},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"163"},{detail:0,format:0,mode:"normal",style:"",text:"行内代码",type:"text",version:1,id:"164"}],direction:"ltr",format:"",indent:0,type:"codeInline",version:1,id:"161"},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"165"},{detail:0,format:0,mode:"normal",style:"",text:"、",type:"text",version:1,id:"166"},{detail:0,format:4,mode:"normal",style:"",text:"删除线",type:"text",version:1,id:"167"},{detail:0,format:0,mode:"normal",style:"",text:"。",type:"text",version:1,id:"168"}],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:1,textStyle:"",id:"256"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"引用块:适合写结论、提示或引用原文。",type:"text",version:1,id:"170"}],direction:"ltr",format:"",indent:0,type:"quote",version:1,id:"169"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"有序列表:",type:"text",version:1,id:"171"}],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:"",id:"257"},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"用 Markdown 记笔记",type:"text",version:1,id:"173"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:1,id:"174"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"用侧边栏管文档树",type:"text",version:1,id:"175"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:2,id:"176"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"需要时再发布或同步",type:"text",version:1,id:"177"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:3,id:"178"}],direction:"ltr",format:"",indent:0,type:"list",version:1,listType:"number",start:1,tag:"ol",id:"172"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"无序列表:",type:"text",version:1,id:"179"}],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:"",id:"258"},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"访客身份,无需单独注册账号(自建部署时由服务端配置)",type:"text",version:1,id:"181"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:1,id:"182"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"文档以 ",type:"text",version:1,id:"183"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:2,id:"184"},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"186"},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"187"},{detail:0,format:0,mode:"normal",style:"",text:".md",type:"text",version:1,id:"188"}],direction:"ltr",format:"",indent:0,type:"codeInline",version:1,id:"185"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:3,id:"189"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"190"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:4,id:"191"},{children:[{detail:0,format:0,mode:"normal",style:"",text:" 为主存储,结构清晰",type:"text",version:1,id:"192"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:5,id:"193"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"支持个人域与协作域等能力(视部署与权限而定)",type:"text",version:1,id:"194"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:6,id:"195"}],direction:"ltr",format:"",indent:0,type:"list",version:1,listType:"bullet",start:1,tag:"ul",id:"180"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"代码",type:"text",version:1,id:"197"}],direction:"ltr",format:"",indent:0,type:"heading",version:1,tag:"h2",id:"196"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"行内常量如 ",type:"text",version:1,id:"198"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"200"},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"201"},{detail:0,format:0,mode:"normal",style:"",text:"VITE_DEMO_MODE",type:"text",version:1,id:"202"}],direction:"ltr",format:"",indent:0,type:"codeInline",version:1,id:"199"},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1,id:"203"},{detail:0,format:0,mode:"normal",style:"",text:",或小段示例:",type:"text",version:1,id:"204"}],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:"",id:"259"},{type:"code",version:1,code:`// 伪代码:表达「内容即文档」
|
|
72
72
|
const doc = { path: "notes/demo.md", content: "# Hello" };`,codeTheme:"default",language:"typescript",options:{indentWithTabs:!1,lineNumbers:!1,tabSize:2},id:"205"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"表格",type:"text",version:1,id:"207"}],direction:"ltr",format:"",indent:0,type:"heading",version:1,tag:"h2",id:"206"},{children:[{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"能力",type:"text",version:1,id:"211"}],direction:"ltr",format:"",indent:0,type:"tablecell",version:1,backgroundColor:null,colSpan:1,headerState:0,rowSpan:1,id:"210"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"说明",type:"text",version:1,id:"213"}],direction:"ltr",format:"",indent:0,type:"tablecell",version:1,backgroundColor:null,colSpan:1,headerState:0,rowSpan:1,id:"212"}],direction:"ltr",format:"",indent:0,type:"tablerow",version:1,height:33,id:"209"},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"编辑",type:"text",version:1,id:"216"}],direction:"ltr",format:"",indent:0,type:"tablecell",version:1,backgroundColor:null,colSpan:1,headerState:0,rowSpan:1,id:"215"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Markdown / 富文本流程按你们集成",type:"text",version:1,id:"218"}],direction:"ltr",format:"",indent:0,type:"tablecell",version:1,backgroundColor:null,colSpan:1,headerState:0,rowSpan:1,id:"217"}],direction:"ltr",format:"",indent:0,type:"tablerow",version:1,height:33,id:"214"},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"图表",type:"text",version:1,id:"221"}],direction:"ltr",format:"",indent:0,type:"tablecell",version:1,backgroundColor:null,colSpan:1,headerState:0,rowSpan:1,id:"220"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"可按项目支持 Mermaid、meta2 等",type:"text",version:1,id:"223"}],direction:"ltr",format:"",indent:0,type:"tablecell",version:1,backgroundColor:null,colSpan:1,headerState:0,rowSpan:1,id:"222"}],direction:"ltr",format:"",indent:0,type:"tablerow",version:1,height:33,id:"219"},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"草稿与发布",type:"text",version:1,id:"226"}],direction:"ltr",format:"",indent:0,type:"tablecell",version:1,backgroundColor:null,colSpan:1,headerState:0,rowSpan:1,id:"225"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"视前端与自建实例配置而定",type:"text",version:1,id:"228"}],direction:"ltr",format:"",indent:0,type:"tablecell",version:1,backgroundColor:null,colSpan:1,headerState:0,rowSpan:1,id:"227"}],direction:"ltr",format:"",indent:0,type:"tablerow",version:1,height:33,id:"224"}],direction:null,format:"",indent:0,type:"table",version:1,colWidths:[375,375],id:"208"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"链接与任务",type:"text",version:1,id:"230"}],direction:"ltr",format:"",indent:0,type:"heading",version:1,tag:"h2",id:"229"},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"仓库示例:",type:"text",version:1,id:"232"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:1,id:"233"},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"https://github.com/xuhuafeifei/mdocs",type:"text",version:1,id:"235"}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:null,target:null,title:null,url:"https://github.com/xuhuafeifei/mdocs",id:"234"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:2,id:"236"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"站外链接用 Markdown 标注清楚即可,避免裸 URL 不易读。",type:"text",version:1,id:"237"}],direction:null,format:"",indent:0,type:"listitem",version:1,value:3,id:"238"}],direction:"ltr",format:"",indent:0,type:"list",version:1,listType:"bullet",start:1,tag:"ul",id:"231"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"任务清单:",type:"text",version:1,id:"239"}],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:"",id:"260"},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"写好这段 README Demo",type:"text",version:1,id:"241"}],direction:null,format:"",indent:0,type:"listitem",version:1,checked:!1,value:1,id:"242"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"按团队习惯补一页「目录规范」",type:"text",version:1,id:"243"}],direction:null,format:"",indent:0,type:"listitem",version:1,checked:!1,value:2,id:"244"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"需要时再加架构图或流程图",type:"text",version:1,id:"245"}],direction:null,format:"",indent:0,type:"listitem",version:1,checked:!1,value:3,id:"246"}],direction:"ltr",format:"",indent:0,type:"list",version:1,listType:"check",start:1,tag:"ul",id:"240"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"示意图(若编辑器支持 Mermaid)",type:"text",version:1,id:"248"}],direction:"ltr",format:"",indent:0,type:"heading",version:1,tag:"h2",id:"247"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"若当前实例的编辑器打开了 Mermaid,可解开下面代码块使用:",type:"text",version:1,id:"249"}],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:"",id:"261"},{type:"code",version:1,code:`flowchart LR
|
|
73
73
|
A[写 Markdown] --> B[整理知识库]
|
|
74
|
-
B --> C[团队共享 / 自建部署]`,codeTheme:"default",language:"mermaid",options:{indentWithTabs:!1,lineNumbers:!1,tabSize:2},id:"250"},{type:"horizontalrule",version:1,id:"251"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"你以为这就完了?还有呢!",type:"text",version:1,id:"266"}],direction:null,format:"",indent:0,type:"heading",version:1,tag:"h2",id:"264"},{type:"meta2d",version:1,diagram:'{"x":0,"y":0,"scale":1,"pens":[{"background":"#fff","color":"#1f1f1f","height":100,"lineWidth":1,"textColor":"#1f1f1f","width":100,"name":"square","text":"我是一个流程图demo","id":"50d7f95","children":[],"x":279,"y":125,"fontSize":12,"lineHeight":1.5,"anchors":[{"x":0.5,"y":0,"id":"0","penId":"50d7f95"},{"x":1,"y":0.5,"id":"1","penId":"50d7f95"},{"x":0.5,"y":1,"id":"2","penId":"50d7f95"},{"x":0,"y":0.5,"id":"3","penId":"50d7f95"}],"rotate":0,"lineAnimateImages":[],"globalAlpha":1,"connectedLines":[{"lineId":"1a57bb5","lineAnchor":"a9246ca","anchor":"3"}]},{"background":"#fff","color":"#1f1f1f","height":80,"lineWidth":1,"textColor":"#1f1f1f","width":80,"name":"circle","text":"Circle","id":"7fd209d8","children":[],"x":161,"y":244,"fontSize":12,"lineHeight":1.5,"anchors":[{"x":0.5,"y":0,"id":"0","penId":"7fd209d8"},{"x":1,"y":0.5,"id":"1","penId":"7fd209d8"},{"x":0.5,"y":1,"id":"2","penId":"7fd209d8"},{"x":0,"y":0.5,"id":"3","penId":"7fd209d8"}],"rotate":0,"lineAnimateImages":[],"globalAlpha":1,"connectedLines":[{"lineId":"1a57bb5","lineAnchor":"72da2094","anchor":"0"}]},{"id":"1a57bb5","name":"line","lineName":"curve","x":201,"y":175,"type":1,"lineWidth":1,"length":119.98519897460938,"ex":279,"ey":244,"width":78,"height":69,"fontSize":12,"lineHeight":1.5,"anchors":[{"id":"a9246ca","x":1,"y":0,"penId":"1a57bb5","connectTo":"50d7f95","anchorId":"3","next":{"penId":"1a57bb5","connectTo":"50d7f95","x":0.358974358974359,"y":0},"start":true,"lineLength":119.98519897460938,"curvePoints":[{"x":273.46745803928,"y":175.08080907361838,"step":0.037504625891000655},{"x":268.1224860178494,"y":175.325768481332,"step":0.07500925178200131},{"x":262.9669830758521,"y":175.73867650342868,"step":0.11251387767300197},{"x":258.002848353432,"y":176.32333142019604,"step":0.15001850356400262},{"x":253.23198099073284,"y":177.0835315119218,"step":0.18752312945500327},{"x":248.65628012789855,"y":178.0230750588937,"step":0.22502775534600392},{"x":244.277644905073,"y":179.14576034139955,"step":0.26253238123700456},{"x":240.0979744624002,"y":180.45538563972715,"step":0.30003700712800524},{"x":236.11916794002371,"y":181.9557492341639,"step":0.3375416330190059},{"x":232.34312447808767,"y":183.65064940499792,"step":0.3750462589100066},{"x":228.77174321673573,"y":185.54388443251662,"step":0.41255088480100727},{"x":225.40692329611198,"y":187.639252597008,"step":0.45005551069200794},{"x":222.25056385636003,"y":189.94055217875956,"step":0.4875601365830086},{"x":219.304564037624,"y":192.4515814580592,"step":0.5250647624740092},{"x":216.57082298004758,"y":195.17613871519453,"step":0.5625693883650099},{"x":214.05123982377472,"y":198.11802223045333,"step":0.6000740142560106},{"x":211.74771370894916,"y":201.28103028412335,"step":0.6375786401470113},{"x":209.66214377571495,"y":204.6689611564923,"step":0.6750832660380119},{"x":207.79642916421585,"y":208.28561312784788,"step":0.7125878919290126},{"x":206.1524690145957,"y":212.13478447847785,"step":0.7500925178200133},{"x":204.73216246699843,"y":216.22027348866996,"step":0.787597143711014},{"x":203.53740866156784,"y":220.5458784387119,"step":0.8251017696020146},{"x":202.57010673844786,"y":225.11539760889139,"step":0.8626063954930153},{"x":201.83215583778232,"y":229.9326292794962,"step":0.900111021384016},{"x":201.3254550997151,"y":235.00137173081404,"step":0.9376156472750167},{"x":201.05190366439007,"y":240.32542324313266,"step":0.9751202731660173}]},{"x":0,"y":1,"id":"72da2094","penId":"1a57bb5","connectTo":"7fd209d8","prev":{"penId":"1a57bb5","connectTo":"7fd209d8","x":0,"y":0.2753623188405797},"anchorId":"0"}],"globalAlpha":1,"rotate":0,"lineAnimateImages":[]}],"origin":{"x":0,"y":0},"center":{"x":0,"y":0},"paths":{},"template":"a77b626","lineAnimateDraws":{},"iot":{},"version":"1.1.19","dataPoints":[]}',svg:'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="238" height="219"><defs/><g><g transform="translate(-151,-115)"><path fill="none" stroke="none"/><g><path fill="#fff" stroke="none" paint-order="stroke fill markers" d=" M 279 125 L 379 125 L 379 225 L 279 225 L 279 125 Z"/></g><path fill="none" stroke="#1f1f1f" paint-order="fill stroke markers" d=" M 279 125 L 379 125 L 379 225 L 279 225 L 279 125 Z" stroke-linecap="square" stroke-miterlimit="10"/><g><text fill="#1f1f1f" stroke="none" font-family=""Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="287" y="166.9" text-anchor="start" dominant-baseline="central">我是一个流程图</text><text fill="#1f1f1f" stroke="none" font-family=""Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="312.26000213623047" y="184.9" text-anchor="start" dominant-baseline="central">demo</text></g></g><g transform="translate(-151,-115)"><path fill="none" stroke="none"/><g><g transform="translate(-151,-115)"><path fill="none" stroke="none"/><g><path fill="none" stroke="none"/></g><path fill="none" stroke="#222222" paint-order="fill stroke markers" d=" M 279 175 C 229 175 201 194 201 244" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10"/></g></g></g></g></svg>',id:"269"},{children:[],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:"",id:"270"},{children:[],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:"",id:"271"},{children:[],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:"",id:"272"}],direction:"ltr",format:"",type:"root",version:1,id:"root"},
|
|
74
|
+
B --> C[团队共享 / 自建部署]`,codeTheme:"default",language:"mermaid",options:{indentWithTabs:!1,lineNumbers:!1,tabSize:2},id:"250"},{type:"horizontalrule",version:1,id:"251"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"你以为这就完了?还有呢!",type:"text",version:1,id:"266"}],direction:null,format:"",indent:0,type:"heading",version:1,tag:"h2",id:"264"},{type:"meta2d",version:1,diagram:'{"x":0,"y":0,"scale":1,"pens":[{"background":"#fff","color":"#1f1f1f","height":100,"lineWidth":1,"textColor":"#1f1f1f","width":100,"name":"square","text":"我是一个流程图demo","id":"50d7f95","children":[],"x":279,"y":125,"fontSize":12,"lineHeight":1.5,"anchors":[{"x":0.5,"y":0,"id":"0","penId":"50d7f95"},{"x":1,"y":0.5,"id":"1","penId":"50d7f95"},{"x":0.5,"y":1,"id":"2","penId":"50d7f95"},{"x":0,"y":0.5,"id":"3","penId":"50d7f95"}],"rotate":0,"lineAnimateImages":[],"globalAlpha":1,"connectedLines":[{"lineId":"1a57bb5","lineAnchor":"a9246ca","anchor":"3"}]},{"background":"#fff","color":"#1f1f1f","height":80,"lineWidth":1,"textColor":"#1f1f1f","width":80,"name":"circle","text":"Circle","id":"7fd209d8","children":[],"x":161,"y":244,"fontSize":12,"lineHeight":1.5,"anchors":[{"x":0.5,"y":0,"id":"0","penId":"7fd209d8"},{"x":1,"y":0.5,"id":"1","penId":"7fd209d8"},{"x":0.5,"y":1,"id":"2","penId":"7fd209d8"},{"x":0,"y":0.5,"id":"3","penId":"7fd209d8"}],"rotate":0,"lineAnimateImages":[],"globalAlpha":1,"connectedLines":[{"lineId":"1a57bb5","lineAnchor":"72da2094","anchor":"0"}]},{"id":"1a57bb5","name":"line","lineName":"curve","x":201,"y":175,"type":1,"lineWidth":1,"length":119.98519897460938,"ex":279,"ey":244,"width":78,"height":69,"fontSize":12,"lineHeight":1.5,"anchors":[{"id":"a9246ca","x":1,"y":0,"penId":"1a57bb5","connectTo":"50d7f95","anchorId":"3","next":{"penId":"1a57bb5","connectTo":"50d7f95","x":0.358974358974359,"y":0},"start":true,"lineLength":119.98519897460938,"curvePoints":[{"x":273.46745803928,"y":175.08080907361838,"step":0.037504625891000655},{"x":268.1224860178494,"y":175.325768481332,"step":0.07500925178200131},{"x":262.9669830758521,"y":175.73867650342868,"step":0.11251387767300197},{"x":258.002848353432,"y":176.32333142019604,"step":0.15001850356400262},{"x":253.23198099073284,"y":177.0835315119218,"step":0.18752312945500327},{"x":248.65628012789855,"y":178.0230750588937,"step":0.22502775534600392},{"x":244.277644905073,"y":179.14576034139955,"step":0.26253238123700456},{"x":240.0979744624002,"y":180.45538563972715,"step":0.30003700712800524},{"x":236.11916794002371,"y":181.9557492341639,"step":0.3375416330190059},{"x":232.34312447808767,"y":183.65064940499792,"step":0.3750462589100066},{"x":228.77174321673573,"y":185.54388443251662,"step":0.41255088480100727},{"x":225.40692329611198,"y":187.639252597008,"step":0.45005551069200794},{"x":222.25056385636003,"y":189.94055217875956,"step":0.4875601365830086},{"x":219.304564037624,"y":192.4515814580592,"step":0.5250647624740092},{"x":216.57082298004758,"y":195.17613871519453,"step":0.5625693883650099},{"x":214.05123982377472,"y":198.11802223045333,"step":0.6000740142560106},{"x":211.74771370894916,"y":201.28103028412335,"step":0.6375786401470113},{"x":209.66214377571495,"y":204.6689611564923,"step":0.6750832660380119},{"x":207.79642916421585,"y":208.28561312784788,"step":0.7125878919290126},{"x":206.1524690145957,"y":212.13478447847785,"step":0.7500925178200133},{"x":204.73216246699843,"y":216.22027348866996,"step":0.787597143711014},{"x":203.53740866156784,"y":220.5458784387119,"step":0.8251017696020146},{"x":202.57010673844786,"y":225.11539760889139,"step":0.8626063954930153},{"x":201.83215583778232,"y":229.9326292794962,"step":0.900111021384016},{"x":201.3254550997151,"y":235.00137173081404,"step":0.9376156472750167},{"x":201.05190366439007,"y":240.32542324313266,"step":0.9751202731660173}]},{"x":0,"y":1,"id":"72da2094","penId":"1a57bb5","connectTo":"7fd209d8","prev":{"penId":"1a57bb5","connectTo":"7fd209d8","x":0,"y":0.2753623188405797},"anchorId":"0"}],"globalAlpha":1,"rotate":0,"lineAnimateImages":[]}],"origin":{"x":0,"y":0},"center":{"x":0,"y":0},"paths":{},"template":"a77b626","lineAnimateDraws":{},"iot":{},"version":"1.1.19","dataPoints":[]}',svg:'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="238" height="219"><defs/><g><g transform="translate(-151,-115)"><path fill="none" stroke="none"/><g><path fill="#fff" stroke="none" paint-order="stroke fill markers" d=" M 279 125 L 379 125 L 379 225 L 279 225 L 279 125 Z"/></g><path fill="none" stroke="#1f1f1f" paint-order="fill stroke markers" d=" M 279 125 L 379 125 L 379 225 L 279 225 L 279 125 Z" stroke-linecap="square" stroke-miterlimit="10"/><g><text fill="#1f1f1f" stroke="none" font-family=""Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="287" y="166.9" text-anchor="start" dominant-baseline="central">我是一个流程图</text><text fill="#1f1f1f" stroke="none" font-family=""Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="312.26000213623047" y="184.9" text-anchor="start" dominant-baseline="central">demo</text></g></g><g transform="translate(-151,-115)"><path fill="none" stroke="none"/><g><g transform="translate(-151,-115)"><path fill="none" stroke="none"/><g><path fill="none" stroke="none"/></g><path fill="none" stroke="#222222" paint-order="fill stroke markers" d=" M 279 175 C 229 175 201 194 201 244" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10"/></g></g></g></g></svg>',id:"269"},{children:[],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:"",id:"270"},{children:[],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:"",id:"271"},{children:[],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:"",id:"272"}],direction:"ltr",format:"",type:"root",version:1,id:"root"},Lo={root:Oo},Vt=JSON.stringify(Lo),ne="demo-visitor-001",Ji={visitorId:ne,visitorName:"Demo User",createdAt:new Date().toISOString(),lastSeenAt:new Date().toISOString(),disabledAt:null,mergedIntoVisitorId:null};function ze(e){let t=0;for(let i=0;i<e.length;i++){const r=e.charCodeAt(i);t=(t<<5)-t+r,t=t&t}return Math.abs(t).toString(16).padStart(64,"0")}const Wt=`# Markdown 语法指南
|
|
75
75
|
|
|
76
76
|
## 基础格式
|
|
77
77
|
|
|
@@ -123,7 +123,7 @@ function hello(name: string): string {
|
|
|
123
123
|
$$
|
|
124
124
|
\\int_{-\\infty}^{\\infty} e^{-x^2} dx = \\sqrt{\\pi}
|
|
125
125
|
$$
|
|
126
|
-
`,
|
|
126
|
+
`,zt=`# 图表支持示例
|
|
127
127
|
|
|
128
128
|
mdocs 集成了多种图表类型。
|
|
129
129
|
|
|
@@ -164,7 +164,7 @@ gantt
|
|
|
164
164
|
前端开发 :active, dev1, 2024-01-09, 10d
|
|
165
165
|
后端开发 : dev2, 2024-01-09, 10d
|
|
166
166
|
\`\`\`
|
|
167
|
-
`,
|
|
167
|
+
`,qt=`# 个人笔记
|
|
168
168
|
|
|
169
169
|
这是我的私人域中的笔记,只有我能看到。
|
|
170
170
|
|
|
@@ -181,5 +181,5 @@ Demo 模式的核心设计:
|
|
|
181
181
|
2. 数据存储在 IndexedDB
|
|
182
182
|
3. 用户无感知切换
|
|
183
183
|
|
|
184
|
-
`,Yi=[{documentId:"doc-welcome",relativePath:"README.md",displayName:"README",content:
|
|
185
|
-
`);l=k.pop()??"";for(const v of k){const C=v.trim();if(!C.startsWith("data:"))continue;const E=C.slice(5).trim();if(!(!E||E==="[DONE]"))try{t.onEvent(JSON.parse(E))}catch{}}}const p=l.trim();if(p.startsWith("data:")){const m=p.slice(5).trim();if(m&&m!=="[DONE]")try{t.onEvent(JSON.parse(m))}catch{}}}const Zo={domainId:Ge,domainName:"Default",permission:"public",creatorVisitorId:"",docCount:0};async function sn(){try{return await Ho()}catch{return[Zo]}}function ei(e,t){var i,r,s;return((i=e.find(d=>d.domainId===t))==null?void 0:i.domainId)??((r=e.find(d=>d.domainId===Ge))==null?void 0:r.domainId)??((s=e[0])==null?void 0:s.domainId)??Ge}function ti(e){const{t}=de(),[i,r]=a.useState(!1),[s,d]=a.useState(null),[l,p]=a.useState("register"),[h,m]=a.useState(1),[g,k]=a.useState(""),[v,C]=a.useState(""),[E,$]=a.useState("password"),[y,I]=a.useState(""),[b,A]=a.useState(""),[P,T]=a.useState("");function _(N){if(N.preventDefault(),!g.trim()){d(t("nameRequired"));return}d(null),m(2)}async function F(N){N.preventDefault(),r(!0),d(null);try{const M=v.trim();await e.onSubmit(g.trim(),M||void 0)}catch(M){d(M instanceof Error?M.message:String(M)),m(1)}finally{r(!1)}}async function H(N){N.preventDefault();const M=y.trim(),O=b.trim();if(!M||!O){d("请输入用户名和密码");return}r(!0),d(null);try{const J=await $o(M,O);qe(J.visitor.visitorId),await e.onRecover(J.visitor.visitorId)}catch(J){d(J instanceof Error?J.message:String(J))}finally{r(!1)}}async function Y(N){N.preventDefault();const M=P.trim();if(!M){d("请输入恢复码");return}r(!0),d(null);try{const O=await Bo(M);qe(O.visitor.visitorId),await e.onRecover(O.visitor.visitorId)}catch(O){d(O instanceof Error?O.message:String(O))}finally{r(!1)}}const R=s??e.error;function u(N){d(null),p(N)}return n.jsx("div",{className:"mdocs-dialog-backdrop",children:n.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:420},children:[n.jsxs("div",{style:{display:"flex",borderBottom:"1px solid var(--mdocs-border)",marginBottom:16},children:[n.jsx("button",{type:"button",onClick:()=>u("register"),style:{flex:1,padding:"12px",border:"none",background:l==="register"?"var(--mdocs-bg)":"none",color:l==="register"?"var(--mdocs-text)":"var(--mdocs-text-secondary)",cursor:"pointer",fontWeight:l==="register"?600:400,borderBottom:l==="register"?"2px solid var(--mdocs-accent)":"none"},children:"注册"}),n.jsx("button",{type:"button",onClick:()=>u("login"),style:{flex:1,padding:"12px",border:"none",background:l==="login"?"var(--mdocs-bg)":"none",color:l==="login"?"var(--mdocs-text)":"var(--mdocs-text-secondary)",cursor:"pointer",fontWeight:l==="login"?600:400,borderBottom:l==="login"?"2px solid var(--mdocs-accent)":"none"},children:"登录"})]}),l==="register"&&n.jsx(n.Fragment,{children:h===1?n.jsxs(n.Fragment,{children:[n.jsx("h1",{children:t("welcomeTitle")}),n.jsx("p",{children:t("welcomeDesc")}),n.jsxs("form",{onSubmit:_,children:[n.jsx("input",{autoFocus:!0,placeholder:t("visitorNamePlaceholder"),value:g,onChange:N=>k(N.target.value),maxLength:60}),R&&n.jsx("div",{className:"mdocs-dialog-error",children:R}),n.jsx("button",{type:"submit",className:"primary",disabled:i,children:"下一步"})]}),n.jsx("p",{style:{marginTop:16,textAlign:"center"},children:n.jsx("button",{type:"button",style:{background:"none",border:"none",color:"var(--mdocs-accent)",cursor:"pointer",fontSize:"0.875rem",textDecoration:"underline",padding:0},onClick:()=>u("login"),children:"已有账号?点击登录"})})]}):n.jsxs(n.Fragment,{children:[n.jsx("h1",{children:"设置密码(可选)"}),n.jsx("p",{style:{marginBottom:8},children:"设置密码后,你可以在其他浏览器或设备上使用「用户名+密码」登录。"}),n.jsx("p",{style:{color:"var(--mdocs-text-secondary)",fontSize:"0.875rem",marginBottom:16},children:"留空不设置密码也能正常使用,但只能在当前浏览器操作。"}),n.jsxs("form",{onSubmit:F,children:[n.jsx("input",{autoFocus:!0,type:"password",placeholder:"设置密码(至少 4 位)",value:v,onChange:N=>C(N.target.value),minLength:4}),R&&n.jsx("div",{className:"mdocs-dialog-error",children:R}),n.jsx("button",{type:"submit",className:"primary",disabled:i,style:{marginTop:8},children:i?t("creating"):"完成注册"})]}),n.jsx("p",{style:{marginTop:16,textAlign:"center"},children:n.jsx("button",{type:"button",style:{background:"none",border:"none",color:"var(--mdocs-text-secondary)",cursor:"pointer",fontSize:"0.875rem",padding:0},onClick:()=>m(1),children:"← 返回上一步"})})]})}),l==="login"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16,marginBottom:16,fontSize:"0.875rem"},children:[n.jsx("button",{type:"button",onClick:()=>{d(null),$("password")},style:{background:"none",border:"none",color:E==="password"?"var(--mdocs-accent)":"var(--mdocs-text-secondary)",cursor:"pointer",padding:"4px 0",borderBottom:E==="password"?"2px solid var(--mdocs-accent)":"none",fontWeight:E==="password"?600:400},children:"用户名+密码"}),n.jsx("button",{type:"button",onClick:()=>{d(null),$("recovery")},style:{background:"none",border:"none",color:E==="recovery"?"var(--mdocs-accent)":"var(--mdocs-text-secondary)",cursor:"pointer",padding:"4px 0",borderBottom:E==="recovery"?"2px solid var(--mdocs-accent)":"none",fontWeight:E==="recovery"?600:400},children:"恢复码"})]}),E==="password"?n.jsxs(n.Fragment,{children:[n.jsx("h1",{children:"🔑 使用密码登录"}),n.jsx("p",{children:"输入用户名和密码,在其他设备上找回你的身份。"}),n.jsxs("form",{onSubmit:H,children:[n.jsx("input",{autoFocus:!0,placeholder:"用户名",value:y,onChange:N=>I(N.target.value),maxLength:60,style:{marginBottom:8}}),n.jsx("input",{type:"password",placeholder:"密码",value:b,onChange:N=>A(N.target.value)}),R&&n.jsx("div",{className:"mdocs-dialog-error",children:R}),n.jsx("button",{type:"submit",className:"primary",disabled:i,children:i?"验证中…":"登录"})]}),n.jsx("p",{style:{marginTop:16,textAlign:"center"},children:n.jsx("button",{type:"button",style:{background:"none",border:"none",color:"var(--mdocs-accent)",cursor:"pointer",fontSize:"0.875rem",textDecoration:"underline",padding:0},onClick:()=>u("register"),children:"没有账号?去注册"})})]}):n.jsxs(n.Fragment,{children:[n.jsx("h1",{children:"🔑 使用恢复码找回"}),n.jsx("p",{children:"输入注册时保存的恢复码,系统将为您生成新的身份令牌。"}),n.jsxs("form",{onSubmit:Y,children:[n.jsx("input",{autoFocus:!0,placeholder:"ABCD-EFGH-IJKL-MNOP",value:P,onChange:N=>T(N.target.value),style:{fontFamily:"monospace",letterSpacing:"0.1em"},maxLength:30}),R&&n.jsx("div",{className:"mdocs-dialog-error",children:R}),n.jsx("button",{type:"submit",className:"primary",disabled:i,children:i?"验证中…":"找回身份"})]})]})]})]})})}function ni(e){const{t}=de();return n.jsxs("div",{className:"mdocs-notice card",children:[n.jsx("span",{children:t("visitorIdNotice",{id:e.visitorId})}),n.jsx("button",{type:"button",onClick:e.onDismiss,children:t("gotIt")})]})}const dn="application/x-mdocs-document-id",ft="mdocs-doc:";let ve=null;function cn(e,t,i=[]){for(const r of e){if(r.type==="document"){if(r.documentId===t)return{forceOpenFolderIds:i,scrollTreeId:r.documentId};continue}if(r.descDocumentId===t)return{forceOpenFolderIds:i,scrollTreeId:r.documentId};const s=cn(r.children,t,[...i,r.documentId]);if(s)return s}return null}function gt(e){if(ve)return ve;try{const t=e.getData(dn);if(t)return t;const i=e.getData("text/plain")||e.getData("Text");if(i.startsWith(ft))return i.slice(ft.length)}catch{}return""}function ue(e){return!!(e&&ve)}function oi(e){const{t}=de(),i=a.useRef(null),[r,s]=a.useState(null),[d,l]=a.useState(null),p=a.useMemo(()=>{var I;const y=(I=e.activeDocumentId)==null?void 0:I.trim();return y?cn(e.nodes,y):null},[e.nodes,e.activeDocumentId]),h=a.useMemo(()=>new Set((p==null?void 0:p.forceOpenFolderIds)??[]),[p]);a.useEffect(()=>{if(!(p!=null&&p.scrollTreeId))return;const y=p.scrollTreeId,I=()=>{var P;const A=(P=i.current)==null?void 0:P.querySelector(`[data-tree-id="${CSS.escape(y)}"]`);A==null||A.scrollIntoView({block:"nearest",behavior:"smooth"})},b=requestAnimationFrame(()=>{requestAnimationFrame(I)});return()=>cancelAnimationFrame(b)},[p==null?void 0:p.scrollTreeId,h,e.nodes]);function m(){s(null)}function g(){ve=null,l(null),m()}function k(y){ve=y,l(y),m()}function v(y){if(!ue(e.onMoveDocument))return;y.preventDefault(),y.dataTransfer.dropEffect="move",y.target.closest(".mdocs-tree-row")||s({kind:"root"})}function C(y){const I=y.relatedTarget;I&&y.currentTarget.contains(I)||s(b=>(b==null?void 0:b.kind)==="root"?null:b)}function E(y){if(!e.onMoveDocument||!ue(e.onMoveDocument))return;y.preventDefault(),y.stopPropagation();const b=y.target.closest(".mdocs-tree-row"),A=gt(y.dataTransfer);g(),!b&&A&&e.onMoveDocument(A,null)}const $="mdocs-sidebar-list"+((r==null?void 0:r.kind)==="root"?" mdocs-tree-drop-root":"");return e.nodes.length===0?n.jsx("div",{ref:i,className:$,onDragOver:v,onDragLeave:C,onDrop:E,children:n.jsx("div",{className:"muted",style:{padding:"8px 10px",fontSize:12},children:t("noDocumentsYet")})}):n.jsx("div",{ref:i,className:$,onClick:y=>{var b;y.target.closest(".mdocs-tree-row")||(b=e.onDeselect)==null||b.call(e)},onContextMenu:y=>{y.preventDefault(),e.onContextMenu({x:y.clientX,y:y.clientY,node:{type:"folder",name:"",path:"",documentId:"",children:e.nodes},parentPath:""})},onDragOver:v,onDragLeave:C,onDrop:E,children:e.nodes.map(y=>n.jsx(ln,{node:y,depth:0,parentPath:"",parentFolderId:null,activeDocumentId:e.activeDocumentId,selectedParentPath:e.selectedParentPath,forceOpenFolderIds:h,dropHighlight:r,setDropHighlight:s,clearDropHighlight:m,beginDragSession:k,endDragSession:g,draggingId:d,onOpen:e.onOpen,onOpenFolder:e.onOpenFolder,onContextMenu:e.onContextMenu,onMoveDocument:e.onMoveDocument},y.path))})}function ln(e){const t={paddingLeft:8+e.depth*16};return e.node.type==="folder"?n.jsx(ai,{folder:e.node,depth:e.depth,indent:t,activeDocumentId:e.activeDocumentId,selectedParentPath:e.selectedParentPath,forceOpenFolderIds:e.forceOpenFolderIds,dropHighlight:e.dropHighlight,setDropHighlight:e.setDropHighlight,clearDropHighlight:e.clearDropHighlight,beginDragSession:e.beginDragSession,endDragSession:e.endDragSession,draggingId:e.draggingId,onOpen:e.onOpen,onOpenFolder:e.onOpenFolder,onContextMenu:e.onContextMenu,onMoveDocument:e.onMoveDocument}):n.jsx(ii,{doc:e.node,indent:t,parentPath:e.parentPath,parentFolderId:e.parentFolderId,activeDocumentId:e.activeDocumentId,dropHighlight:e.dropHighlight,setDropHighlight:e.setDropHighlight,clearDropHighlight:e.clearDropHighlight,beginDragSession:e.beginDragSession,endDragSession:e.endDragSession,draggingId:e.draggingId,onOpen:e.onOpen,onContextMenu:e.onContextMenu,onMoveDocument:e.onMoveDocument})}function ii(e){var h;const t=e.doc,i=t.documentId===e.activeDocumentId,r=!!e.onMoveDocument,s=e.draggingId===t.documentId,d=((h=e.dropHighlight)==null?void 0:h.kind)==="doc"&&e.dropHighlight.id===t.documentId,[l,p]=a.useState(!1);return n.jsxs("div",{role:"button",tabIndex:0,className:"mdocs-tree-row mdocs-tree-doc"+(i?" active":"")+(s?" mdocs-tree-dragging":"")+(d?" mdocs-tree-drop-target":""),"data-tree-id":t.documentId,style:{...e.indent,cursor:r?"grab":void 0},draggable:r,onDragStart:m=>{e.onMoveDocument&&(p(!0),e.beginDragSession(t.documentId),m.dataTransfer.setData(dn,t.documentId),m.dataTransfer.setData("text/plain",ft+t.documentId),m.dataTransfer.effectAllowed="move")},onDragEnd:()=>{e.endDragSession(),queueMicrotask(()=>p(!1))},onDragEnter:m=>{!ue(e.onMoveDocument)||ve===t.documentId||(m.preventDefault(),m.stopPropagation(),e.setDropHighlight({kind:"doc",id:t.documentId}))},onDragOver:m=>{!ue(e.onMoveDocument)||ve===t.documentId||(m.preventDefault(),m.stopPropagation(),m.dataTransfer.dropEffect="move",e.setDropHighlight({kind:"doc",id:t.documentId}))},onDrop:m=>{if(!e.onMoveDocument||!ue(e.onMoveDocument))return;m.preventDefault(),m.stopPropagation();const g=gt(m.dataTransfer),k=e.parentFolderId;e.endDragSession(),!(!g||g===t.documentId)&&e.onMoveDocument(g,k)},onClick:()=>{l||e.onOpen(t)},onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),e.onOpen(t))},onContextMenu:m=>{m.preventDefault(),m.stopPropagation(),e.onContextMenu({x:m.clientX,y:m.clientY,node:t,parentPath:e.parentPath})},children:[n.jsx("span",{className:"mdocs-tree-caret-spacer","aria-hidden":!0}),n.jsx("span",{className:"mdocs-tree-icon",children:"md"}),n.jsx("span",{className:"mdocs-tree-label",children:t.displayName||t.name})]})}function ri(){return n.jsx("span",{className:"mdocs-tree-icon mdocs-tree-icon-dir","aria-hidden":!0,children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M2 4.5h4.2L7.3 6H14v8.5H2V4.5z",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),n.jsx("path",{d:"M2 4.5V3h4l1.1 1.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]})})}function ai(e){var g,k;const{t}=de(),i=e.forceOpenFolderIds.has(e.folder.documentId),[r,s]=a.useState(e.depth<1||i),d=r;a.useEffect(()=>{i&&s(!0)},[i,e.activeDocumentId]);const l=!!e.folder.descDocumentId&&e.folder.descDocumentId===e.activeDocumentId,p=e.selectedParentPath===e.folder.path,h=((g=e.dropHighlight)==null?void 0:g.kind)==="folder"&&e.dropHighlight.id===e.folder.documentId;function m(){e.onOpenFolder(e.folder.path,e.folder.descDocumentId)}return n.jsxs("div",{children:[n.jsxs("div",{className:"mdocs-tree-row mdocs-tree-folder mdocs-tree-folder-row"+(l?" active":p?" mdocs-tree-select-target":"")+(h?" mdocs-tree-drop-target":""),"data-tree-id":e.folder.documentId,style:e.indent,onClick:m,onContextMenu:v=>{v.preventDefault(),v.stopPropagation(),e.onContextMenu({x:v.clientX,y:v.clientY,node:e.folder,parentPath:e.folder.path})},onDragEnter:v=>{ue(e.onMoveDocument)&&(v.preventDefault(),v.stopPropagation(),e.setDropHighlight({kind:"folder",id:e.folder.documentId}),s(!0))},onDragOver:v=>{ue(e.onMoveDocument)&&(v.preventDefault(),v.stopPropagation(),v.dataTransfer.dropEffect="move",e.setDropHighlight({kind:"folder",id:e.folder.documentId}))},onDrop:v=>{if(!e.onMoveDocument||!ue(e.onMoveDocument))return;v.preventDefault(),v.stopPropagation();const C=gt(v.dataTransfer),E=e.folder.documentId;e.endDragSession(),C&&e.onMoveDocument(C,E)},children:[n.jsx("span",{className:"mdocs-tree-caret",role:"button",tabIndex:0,"aria-expanded":d,"aria-label":t(d?"collapseFolder":"expandFolder"),onClick:v=>{v.stopPropagation(),s(C=>!C),m()},onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),s(C=>!C),m())},children:d?"▾":"▸"}),n.jsx(ri,{}),n.jsx("span",{className:"mdocs-tree-folder-select",children:n.jsx("span",{className:"mdocs-tree-label",children:((k=e.folder.folderDisplayName)==null?void 0:k.trim())||e.folder.name})})]}),d&&e.folder.children.map(v=>n.jsx(ln,{node:v,depth:e.depth+1,parentPath:e.folder.path,parentFolderId:e.folder.documentId,activeDocumentId:e.activeDocumentId,selectedParentPath:e.selectedParentPath,forceOpenFolderIds:e.forceOpenFolderIds,dropHighlight:e.dropHighlight,setDropHighlight:e.setDropHighlight,clearDropHighlight:e.clearDropHighlight,beginDragSession:e.beginDragSession,endDragSession:e.endDragSession,draggingId:e.draggingId,onOpen:e.onOpen,onOpenFolder:e.onOpenFolder,onContextMenu:e.onContextMenu,onMoveDocument:e.onMoveDocument},v.path))]})}function si(e){var p;const{t}=de(),i=a.useRef(null);a.useEffect(()=>{function h(g){i.current&&!i.current.contains(g.target)&&e.onClose()}function m(g){g.key==="Escape"&&e.onClose()}return window.addEventListener("mousedown",h),window.addEventListener("keydown",m),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",m)}},[e.onClose]);const r=e.node.type==="folder";let s="";if(e.node.type==="folder"){const h=e.node;s=((p=h.folderDisplayName)==null?void 0:p.trim())||h.path||""}const d=r?s?t("newDocIn",{name:s}):t("newDocAtRoot"):t("newDocBeside"),l=r?s?t("newFolderIn",{name:s}):t("newFolderAtRoot"):t("newFolderBeside");return n.jsxs("div",{ref:i,className:"mdocs-context-menu card",style:{left:e.x,top:e.y},children:[n.jsx("button",{type:"button",className:"mdocs-context-item",onClick:()=>{const h=r?e.node.path:e.parentPath;e.onCreateChild(h),e.onClose()},children:d}),n.jsx("button",{type:"button",className:"mdocs-context-item",onClick:()=>{const h=r?e.node.path:e.parentPath;e.onCreateFolder(h),e.onClose()},children:l}),n.jsx("button",{type:"button",className:"mdocs-context-item danger",onClick:()=>{e.node.type==="document"?e.onDeleteDocument(e.node):e.onDeleteFolder(e.node),e.onClose()},children:e.node.type==="folder"?t("deleteFolder",{name:s||e.node.name}):t("deleteItem",{name:e.node.name})})]})}function di({domains:e,value:t,onChange:i,ariaLabel:r,localizeName:s,onDomainsChange:d}){const[l,p]=a.useState(!1),[h,m]=a.useState(e),g=a.useRef(null),k=a.useRef(null);a.useEffect(()=>{m(e)},[e]);const v=h.find(y=>y.domainId===t),C=(v==null?void 0:v.permission)==="private";a.useEffect(()=>{if(!l)return;const y=I=>{var b,A;!((b=g.current)!=null&&b.contains(I.target))&&!((A=k.current)!=null&&A.contains(I.target))&&p(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[l]),a.useEffect(()=>{if(!l)return;const y=I=>{var b;I.key==="Escape"&&(p(!1),(b=g.current)==null||b.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[l]);function E(y){i(y),p(!1)}function $(){if(l){p(!1);return}p(!0),sn().then(y=>{m(y),d==null||d(y)})}return n.jsxs("div",{className:"mdocs-domain-select-wrapper",children:[n.jsxs("button",{ref:g,type:"button",className:"mdocs-domain-select-trigger","aria-label":r,"aria-expanded":l,"aria-haspopup":"listbox",onClick:$,children:[n.jsx("span",{className:"mdocs-domain-select-text",children:v?s(v.domainName):""}),C&&n.jsxs("svg",{className:"mdocs-domain-lock",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--mdocs-text-muted)",strokeWidth:"2",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),n.jsx("svg",{className:"mdocs-domain-select-chevron"+(l?" open":""),width:"10",height:"6",viewBox:"0 0 10 6",fill:"none",stroke:"var(--mdocs-text-muted)",strokeWidth:"1.5",children:n.jsx("path",{d:"M1 1l4 4 4-4"})})]}),l&&n.jsx("div",{ref:k,className:"mdocs-domain-select-menu card",role:"listbox","aria-label":r,children:h.map(y=>n.jsxs("button",{type:"button",className:"mdocs-domain-select-option"+(y.domainId===t?" active":""),role:"option","aria-selected":y.domainId===t,onClick:()=>E(y.domainId),children:[n.jsx("span",{children:s(y.domainName)}),y.permission==="private"&&n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--mdocs-text-muted)",strokeWidth:"2",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})]},y.domainId))})]})}const mn="data:image/svg+xml,%3csvg%20fill='%234D6BFE'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDeepSeek%3c/title%3e%3cpath%20d='M23.748%204.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434%201.202-.422%201.84.027%201.436.633%202.58%201.838%203.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526%205.526%200%2001-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365%2011.365%200%2000-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055%203.055%200%2001-.465.137%209.597%209.597%200%2000-2.883-.102c-1.885.21-3.39%201.102-4.497%202.623C.082%208.606-.231%2010.684.152%2012.85c.403%202.284%201.569%204.175%203.36%205.653%201.858%201.533%203.997%202.284%206.438%202.14%201.482-.085%203.133-.284%204.994-1.86.47.234.962.327%201.78.397.63.059%201.236-.03%201.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926%201.096-1.296%202.746-2.642%203.392-7.003.05-.347.007-.565%200-.845-.004-.17.035-.237.23-.256a4.173%204.173%200%20001.545-.475c1.396-.763%201.96-2.015%202.093-3.517.02-.23-.004-.467-.247-.588zM11.581%2018c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696%204.696%200%20011.529-.039c2.132.312%203.946%201.265%205.468%202.774.868.86%201.525%201.887%202.202%202.891.72%201.066%201.494%202.082%202.48%202.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306%200%2001.415-.287.302.302%200%2001.2.288.306.306%200%2001-.31.307.303.303%200%2001-.304-.308zm3.11%201.596c-.2.081-.399.151-.59.16a1.245%201.245%200%2001-.798-.254c-.274-.23-.47-.358-.552-.758a1.73%201.73%200%2001.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559%200%2001-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136%201.146.016.352.144.618.408%201.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z'%3e%3c/path%3e%3c/svg%3e",ae={left:12,bottom:64},yt="mdocs.agentFabPosition",Ye=36,Yt=3;function vt(e){const i=Math.max(8,window.innerWidth-Ye-8),r=Math.max(8,window.innerHeight-Ye-8);return{left:Math.min(i,Math.max(8,e.left)),bottom:Math.min(r,Math.max(8,e.bottom))}}function ci(e,t,i,r){const s=e-i,d=t-r,l=window.innerHeight-d-Ye;return vt({left:s,bottom:l})}function li(){try{const e=localStorage.getItem(yt);if(!e)return ae;const t=JSON.parse(e);return typeof t.left!="number"||typeof t.bottom!="number"?ae:vt({left:t.left,bottom:t.bottom})}catch{return ae}}function Jt(e){localStorage.setItem(yt,JSON.stringify(e))}function mi(e){return e.left===ae.left&&e.bottom===ae.bottom}function ui(e){const i=Math.min(480,window.innerWidth-72);let r=e.left+Ye+8;r+i>window.innerWidth-8&&(r=e.left-8-i),r=Math.max(8,r);const s=Math.max(8,e.bottom-8);return{left:r,bottom:s}}function fi(e){const{t}=de(),[i,r]=a.useState(!1),[s,d]=a.useState(e.position),l=a.useRef(null),p=a.useRef(null),h=a.useRef(s),m=a.useRef(e.onPositionChange),g=a.useRef(e.onToggle);h.current=s,m.current=e.onPositionChange,g.current=e.onToggle;const k=a.useRef(null),v=a.useRef(0),C=a.useRef(null);a.useEffect(()=>{k.current||(d(e.position),h.current=e.position)},[e.position]),a.useEffect(()=>{function I(){const b=vt(h.current);b.left===h.current.left&&b.bottom===h.current.bottom||(h.current=b,d(b),m.current(b),Jt(b))}return window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[]),a.useEffect(()=>{function I(){v.current=0;const P=C.current;if(!P)return;C.current=null,h.current=P,d(P);const T=p.current;T&&(T.style.left=`${P.left}px`,T.style.bottom=`${P.bottom}px`),m.current(P)}function b(P){const T=k.current;if(!T||P.pointerId!==T.pointerId)return;P.preventDefault();const _=P.clientX-T.startX,F=P.clientY-T.startY;!T.didMove&&_*_+F*F>=Yt*Yt&&(T.didMove=!0,r(!0)),T.didMove&&(C.current=ci(P.clientX,P.clientY,T.offsetX,T.offsetY),v.current||(v.current=requestAnimationFrame(I)))}function A(P){var _;const T=k.current;if(!(!T||P.pointerId!==T.pointerId)){k.current=null,r(!1),v.current&&(cancelAnimationFrame(v.current),v.current=0),C.current&&(h.current=C.current,d(C.current),C.current=null);try{(_=l.current)==null||_.releasePointerCapture(P.pointerId)}catch{}if(T.didMove){const F=h.current;m.current(F),Jt(F);return}g.current()}}return window.addEventListener("pointermove",b,{passive:!1}),window.addEventListener("pointerup",A),window.addEventListener("pointercancel",A),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",A),window.removeEventListener("pointercancel",A),v.current&&cancelAnimationFrame(v.current)}},[]);function E(I){if(I.button!==0)return;I.preventDefault();const b=I.currentTarget.getBoundingClientRect();k.current={pointerId:I.pointerId,offsetX:I.clientX-b.left,offsetY:I.clientY-b.top,startX:I.clientX,startY:I.clientY,didMove:!1},I.currentTarget.setPointerCapture(I.pointerId)}function $(){h.current=ae,d(ae),e.onPositionChange(ae),localStorage.removeItem(yt)}const y=!mi(s);return n.jsxs("div",{ref:p,className:"mdocs-agent-fab-wrap"+(i?" dragging":""),style:{left:s.left,bottom:s.bottom},children:[n.jsx("button",{ref:l,type:"button",className:"mdocs-agent-fab"+(e.open?" open":"")+(i?" dragging":""),"aria-label":t("agentFabOpen"),"aria-expanded":e.open,onPointerDown:E,children:n.jsx("img",{src:mn,alt:"",draggable:!1})}),y&&n.jsx("button",{type:"button",className:"mdocs-agent-fab-reset",onClick:$,"aria-label":t("agentFabReset"),children:t("agentFabReset")})]})}function pi(){const[e,t]=a.useState(()=>typeof window>"u"?ae:li());return[e,t]}function hi({title:e,message:t,onClose:i}){const{t:r}=de();return n.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:s=>{s.target===s.currentTarget&&i()},children:n.jsxs("div",{className:"mdocs-dialog card mdocs-message-dialog",role:"alertdialog","aria-modal":"true",children:[e&&n.jsx("h2",{className:"mdocs-message-dialog-title",children:e}),n.jsx("p",{className:"mdocs-message-dialog-body",children:t}),n.jsx("div",{className:"mdocs-message-dialog-actions",children:n.jsx("button",{type:"button",className:"primary",onClick:i,children:r("gotIt")})})]})})}function un({title:e,message:t,confirmLabel:i="确定",cancelLabel:r="取消",onConfirm:s,onCancel:d,busy:l=!1,danger:p=!1}){return n.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:h=>{h.target===h.currentTarget&&!l&&d()},children:n.jsxs("div",{className:"mdocs-dialog card mdocs-message-dialog",role:"alertdialog","aria-modal":"true",children:[e&&n.jsx("h2",{className:"mdocs-message-dialog-title",children:e}),n.jsx("p",{className:"mdocs-message-dialog-body",children:t}),n.jsxs("div",{className:"mdocs-message-dialog-actions",style:{gap:8},children:[n.jsx("button",{type:"button",onClick:d,disabled:l,children:r}),n.jsx("button",{type:"button",className:p?"danger":"primary",onClick:s,disabled:l,children:l?"…":i})]})]})})}const Kt={"relative path is required":"pathRequired","path must be relative":"pathMustBeRelative","use forward slashes":"useForwardSlashes","path must not contain ..":"pathNoDotDot","document path must end with .md":"pathMustEndWithMd","path contains unsupported characters":"pathUnsupportedChars","path escapes docs root":"pathEscapesRoot"},fn={"enter a folder name":"enterFolderName","use a single name, not a path":"singleNameNotPath","invalid folder name":"invalidFolderName","folder name is too long":"folderNameTooLong","enter a file name":"enterFileName","use a file name, not a path":"singleFileNameNotPath","invalid file name":"invalidFileName","file name is too long":"fileNameTooLong"};function me(e,t){if(t instanceof oe)return t.message;if(t instanceof le){const i=Kt[t.message];return i?e(i):t.message}if(t instanceof Error){const i=Kt[t.message]??fn[t.message];return i?e(i):t.message}return String(t)}function gi(e,t,i){if(e==="Default")return i("defaultDomain");const r="个人域";return e.endsWith(r)?e.slice(0,-r.length)+i("personalDomainSuffix"):e}function Or(e,t){return e==="public"?t("domainPublic"):e==="restricted"?t("domainRestricted"):e==="private"?t("domainPrivate"):e}function ze(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function yi(e){return JSON.stringify({root:{children:[{children:[{detail:0,format:0,mode:"normal",text:e,type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"heading",tag:"h1",version:1}],direction:"ltr",type:"root",version:1}})}function Xt(e,t){const i=e.trim(),r=t.trim();return r?i?`${i}/${r}`:r:i}function pn(e,t=new Set){for(const i of e)i.type==="document"?t.add(i.path):(i.descDocumentId&&t.add(Po(i.path)),pn(i.children,t));return t}function pt(e,t){for(const i of e){if(i.type==="folder"&&i.path===t)return i.documentId;if(i.type==="folder"){const r=pt(i.children,t);if(r)return r}}return null}function Qt(e,t){const i=fn[t];return i?e(i):t}function vi(e){const{tree:t,currentDomainId:i,selectedCreateParentPath:r,t:s,onDocCreated:d,refreshTree:l}=e,[p,h]=a.useState(null),[m,g]=a.useState(null),[k,v]=a.useState(!1),C=a.useRef(null);a.useEffect(()=>{if(!p)return;const I=window.setTimeout(()=>{var b;return(b=C.current)==null?void 0:b.focus()},0);return()=>window.clearTimeout(I)},[p]);function E(I){const b=I!==void 0;g(null),h({kind:"document",parentMode:b?"fixed":"selection",parentPath:b?I:"",draft:"untitled.md"})}function $(I){const b=I!==void 0;g(null),h({kind:"folder",parentMode:b?"fixed":"selection",parentPath:b?I:"",draft:""})}async function y(I){if(I.preventDefault(),!p)return;v(!0),g(null);const b=pn(t),A=p.parentMode==="selection"?r:p.parentPath;try{if(p.kind==="document"){const H=jo(p.draft);if(!H.ok){g(Qt(s,H.message));return}const Y=H.displayFile,R=Y.replace(/\.md$/i,"");let u;try{u=Mo(Xt(A,Y))}catch(O){g(me(s,O));return}if(b.has(u)){g(s("pathExists"));return}const N=A?pt(t,A)??void 0:void 0,M=await an({fileName:Y,displayName:R,content:yi(R),domainId:i,parentId:N});await l(),d(M),h(null);return}const P=Ao(p.draft);if(!P.ok){g(Qt(s,P.message));return}const T=mt(P.display);if(!T){g(s("invalidFolderName"));return}const _=Xt(A,T);if(b.has(_)){g(s("folderExists"));return}const F=A?pt(t,A)??void 0:void 0;await qo({name:T,parentId:F,domainId:i}),await l(),h(null)}catch(P){g(me(s,P))}finally{v(!1)}}return{createModal:p,setCreateModal:h,createModalError:m,createModalBusy:k,createModalInputRef:C,openNewDocumentModal:E,openNewFolderModal:$,submitCreateModal:y}}function bi({open:e,onClose:t,onResolve:i}){const{t:r}=de();return e?n.jsx("div",{className:"mdocs-conflict-modal-root",role:"alertdialog","aria-modal":"true",children:n.jsxs("div",{className:"mdocs-conflict-modal-panel",children:[n.jsx("h2",{className:"mdocs-conflict-modal-title",children:r("conflictTitle")}),n.jsx("p",{className:"mdocs-conflict-modal-body",children:r("conflictBody")}),n.jsxs("div",{className:"mdocs-conflict-modal-actions",children:[n.jsx("button",{type:"button",className:"primary",onClick:i,children:r("conflictResolve")}),n.jsx("button",{type:"button",className:"secondary",onClick:t,children:r("conflictClose")})]})]})}):null}function wi({documentId:e,visitorId:t,visitorName:i,documentOwnerId:r,onClose:s}){const[d,l]=a.useState([]),[p,h]=a.useState(""),[m,g]=a.useState(null),[k,v]=a.useState(!0),[C,E]=a.useState(!1),[$,y]=a.useState(null),[I,b]=a.useState(null),[A,P]=a.useState(360),[T,_]=a.useState(80),F=a.useRef(!1),H=a.useRef(!1),Y=300,R=80,u=a.useRef(null);function N(){const D=u.current;if(!D)return;D.style.height="auto";const S=D.scrollHeight,z=Math.min(Math.max(S,R),Y);D.style.height=`${z}px`,_(z)}a.useEffect(()=>{setTimeout(()=>N(),0)},[m]);function M(D){return t?D.visitorId===t||r===t:!1}const{rootComments:O,repliesByParentId:J,totalCount:Je}=a.useMemo(()=>{const D=[],S=new Map;let z=0;for(const B of d)B.isDeleted||(z++,B.parentId?(S.has(B.parentId)||S.set(B.parentId,[]),S.get(B.parentId).push(B)):D.push(B));return{rootComments:D,repliesByParentId:S,totalCount:z}},[d]),ie=a.useRef(e);a.useEffect(()=>{ie.current=e,h(""),g(null),b(null),ce()},[e]);async function ce(){const D=ie.current;v(!0);try{const S=await Ko(e);if(ie.current!==D)return;l(S.comments)}catch(S){if(ie.current!==D)return;b("加载评论失败"),console.error("Failed to load comments:",S)}finally{ie.current===D&&v(!1)}}async function fe(){var D;if(!(!p.trim()||!t)){E(!0),b(null);try{await Xo(e,{content:p,parentId:(m==null?void 0:m.commentId)||null,replyToVisitorId:m?((D=d.find(S=>S.commentId===m.commentId))==null?void 0:D.visitorId)??null:null,replyToVisitorName:(m==null?void 0:m.visitorName)||null}),h(""),g(null),setTimeout(()=>N(),0),await ce()}catch(S){b(S.message||"发表失败,请重试")}finally{E(!1)}}}async function Ke(D){b(null);try{await Qo(e,D),await ce()}catch(S){b(S.message||"删除失败,请重试")}finally{y(null)}}function re(D){const S=Date.now()-new Date(D).getTime(),z=Math.floor(S/6e4),B=Math.floor(S/36e5),he=Math.floor(S/864e5);return z<1?"刚刚":z<60?`${z}分钟前`:B<24?`${B}小时前`:`${he}天前`}function ke(D){F.current=!0,D.preventDefault()}function pe(D){H.current=!0,D.preventDefault(),document.body.style.userSelect="none",document.body.style.cursor="row-resize"}return a.useEffect(()=>{function D(z){if(F.current){const B=Math.max(280,Math.min(600,window.innerWidth-z.clientX));P(B)}if(H.current){const B=-z.movementY;_(he=>Math.max(60,Math.min(600,he+B)))}}function S(){F.current=!1,H.current=!1,document.body.style.userSelect="",document.body.style.cursor=""}return window.addEventListener("mousemove",D),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",D),window.removeEventListener("mouseup",S)}},[]),n.jsxs("div",{className:"mdocs-comments-panel",style:{width:A},children:[n.jsx("div",{className:"mdocs-comments-resize-handle",onMouseDown:ke}),n.jsxs("div",{className:"mdocs-comments-header",children:[n.jsxs("h3",{style:{margin:0,fontSize:"1rem",display:"flex",alignItems:"center",gap:6},children:[n.jsx(fo,{size:18}),"评论 (",Je,")"]}),n.jsx("button",{type:"button",onClick:s,className:"mdocs-comments-close-btn",children:n.jsx(Ae,{size:18})})]}),I&&n.jsxs("div",{className:"mdocs-comments-error",children:[I,n.jsx("button",{type:"button",onClick:()=>b(null),children:n.jsx(Ae,{size:14})})]}),n.jsx("div",{className:"mdocs-comments-list",children:k?n.jsx("div",{className:"mdocs-comments-empty",children:"加载中..."}):O.length===0?n.jsx("div",{className:"mdocs-comments-empty",children:"暂无评论,来发表第一条吧~"}):O.map(D=>n.jsxs("div",{className:"mdocs-comment-root",children:[n.jsxs("div",{className:"mdocs-comment-header",children:[n.jsx("span",{className:"mdocs-comment-avatar",children:D.visitorName.charAt(0).toUpperCase()}),n.jsx("span",{className:"mdocs-comment-author",children:D.visitorName}),n.jsx("span",{className:"mdocs-comment-time",children:re(D.createdAt)}),M(D)&&n.jsx("button",{type:"button",className:"mdocs-comment-delete",onClick:()=>y(D.commentId),title:"删除",children:n.jsx(Ae,{size:14})})]}),n.jsx("div",{className:"mdocs-comment-content",children:D.content}),t&&n.jsx("button",{type:"button",className:"mdocs-comment-reply-btn",onClick:()=>g({commentId:D.commentId,visitorName:D.visitorName}),children:"回复"}),(J.get(D.commentId)??[]).length>0&&n.jsx("div",{className:"mdocs-comment-replies",children:(J.get(D.commentId)??[]).map(S=>n.jsxs("div",{className:"mdocs-comment-reply",children:[n.jsxs("div",{className:"mdocs-comment-header",children:[n.jsx("span",{className:"mdocs-comment-avatar mdocs-comment-avatar-small",children:S.visitorName.charAt(0).toUpperCase()}),n.jsx("span",{className:"mdocs-comment-author",children:S.visitorName}),S.replyToVisitorName&&n.jsxs("span",{className:"mdocs-comment-reply-to",children:["回复 ",S.replyToVisitorName]}),n.jsx("span",{className:"mdocs-comment-time",children:re(S.createdAt)}),M(S)&&n.jsx("button",{type:"button",className:"mdocs-comment-delete",onClick:()=>y(S.commentId),title:"删除",children:n.jsx(Ae,{size:12})})]}),n.jsx("div",{className:"mdocs-comment-content",children:S.content}),t&&n.jsx("button",{type:"button",className:"mdocs-comment-reply-btn",onClick:()=>g({commentId:D.commentId,visitorName:S.visitorName}),children:"回复"})]},S.commentId))})]},D.commentId))}),t?n.jsxs("div",{className:"mdocs-comments-input-wrapper",children:[n.jsx("div",{className:"mdocs-comments-input-drag-handle",onMouseDown:pe}),m&&n.jsxs("div",{className:"mdocs-comment-reply-notice",children:[n.jsxs("span",{children:["回复 ",n.jsx("span",{className:"mdocs-comment-reply-to-name",children:m.visitorName})]}),n.jsxs("button",{type:"button",onClick:()=>g(null),children:[n.jsx(Ae,{size:14})," 取消"]})]}),n.jsx("textarea",{ref:u,value:p,onChange:D=>{h(D.target.value.slice(0,512)),setTimeout(()=>N(),0)},placeholder:m?`回复 ${m.visitorName}...`:"发表评论...",className:"mdocs-comments-input",style:{height:T},maxLength:512,onKeyDown:D=>{D.key==="Enter"&&(D.metaKey||D.ctrlKey)&&fe()}}),n.jsxs("div",{className:`mdocs-comments-char-count${p.length>=460?" mdocs-char-count--warn":""}`,children:[p.length,"/512"]}),n.jsx("div",{className:"mdocs-comments-input-actions",children:n.jsx("button",{type:"button",className:"mdocs-btn-primary",onClick:fe,disabled:C||!p.trim(),children:C?"发表中...":"发表"})})]}):n.jsx("div",{className:"mdocs-comments-input-wrapper",style:{textAlign:"center"},children:n.jsx("div",{style:{color:"#666",fontSize:"0.9rem"},children:"请先创建访客身份以发表评论"})}),$&&n.jsx(un,{title:"删除评论",message:"确定要删除这条评论吗?",confirmLabel:"删除",danger:!0,onConfirm:()=>Ke($),onCancel:()=>y(null)})]})}const xi="mdocs-drafts",Ii=4,W="drafts",De={DOC_NOT_FOUND:"DOC_NOT_FOUND",SYNC_HEAD_MISSING:"SYNC_HEAD_MISSING"};let at=null;function Se(){return at||(at=new Promise((e,t)=>{const i=indexedDB.open(xi,Ii);i.onupgradeneeded=r=>{const s=i.result;s.objectStoreNames.contains(W)||s.createObjectStore(W,{keyPath:"documentId"});const d=r.oldVersion;if(d>0&&d<4){const h=i.transaction.objectStore(W).openCursor();h.onsuccess=()=>{const m=h.result;if(!m)return;const g=m.value;typeof g.baseCommitId=="string"&&!g.localBaseCommitId&&(g.localBaseCommitId=g.baseCommitId,delete g.baseCommitId);const k=g.conflict;k&&(typeof k.baseCommitId=="string"&&!k.localBaseCommitId&&(k.localBaseCommitId=k.baseCommitId,delete k.baseCommitId),typeof k.expectedHeadCommitId=="string"&&!k.remoteCommitId&&(k.remoteCommitId=k.expectedHeadCommitId,delete k.expectedHeadCommitId)),m.update(g),m.continue()}}},i.onsuccess=()=>e(i.result),i.onerror=()=>t(i.error)})),at}async function Di(e){var r;const t=await G(e.documentId),i={documentId:e.documentId,content:e.content,displayName:e.displayName,updatedAt:Date.now(),published:!1};if(t!=null&&t.localBaseCommitId)i.localBaseCommitId=t.localBaseCommitId;else{const s=(r=e.localBaseCommitIdAtEditStart)==null?void 0:r.trim();s&&(i.localBaseCommitId=s)}(t==null?void 0:t.permission)!=null?i.permission=t.permission:e.snapshotMeta&&(i.permission=e.snapshotMeta.permission),t!=null&&t.ownerVisitorId?i.ownerVisitorId=t.ownerVisitorId:e.snapshotMeta&&(i.ownerVisitorId=e.snapshotMeta.ownerVisitorId),t!=null&&t.domainId?i.domainId=t.domainId:e.snapshotMeta&&(i.domainId=e.snapshotMeta.domainId),t!=null&&t.publishError&&(i.publishError=t.publishError,i.publishErrorAt=t.publishErrorAt),t!=null&&t.conflictStatus&&(i.conflictStatus=t.conflictStatus),t!=null&&t.conflict&&(i.conflict=t.conflict),await ye(i)}function bt(e){const t={documentId:e.documentId,content:e.content,displayName:e.displayName,updatedAt:e.updatedAt,published:e.published};return e.permission!=null&&(t.permission=e.permission),e.ownerVisitorId&&(t.ownerVisitorId=e.ownerVisitorId),e.domainId&&(t.domainId=e.domainId),e.publishError!=null&&(t.publishError=e.publishError),e.publishErrorAt!=null&&(t.publishErrorAt=e.publishErrorAt),e.localBaseCommitId&&(t.localBaseCommitId=e.localBaseCommitId),e.conflictStatus!=null&&(t.conflictStatus=e.conflictStatus),e.conflict!=null&&(t.conflict=e.conflict),t}async function ye(e){const t=await Se(),i=bt(e);return new Promise((r,s)=>{const d=t.transaction(W,"readwrite");d.objectStore(W).put(i),d.oncomplete=()=>r(),d.onerror=()=>s(d.error)})}async function G(e){const t=await Se();return new Promise((i,r)=>{const d=t.transaction(W,"readonly").objectStore(W).get(e);d.onsuccess=()=>i(d.result),d.onerror=()=>r(d.error)})}async function st(e){const t=await Se();return new Promise((i,r)=>{const s=t.transaction(W,"readwrite");s.objectStore(W).delete(e),s.oncomplete=()=>i(),s.onerror=()=>r(s.error)})}async function Ci(e){const t=await Se();return new Promise((i,r)=>{const d=t.transaction(W,"readonly").objectStore(W).getAll();d.onsuccess=()=>{let l=d.result;e!=null&&e.skipFailed&&(l=l.filter(p=>!p.publishError)),i(l)},d.onerror=()=>r(d.error)})}async function Si(e,t){const i=await Se();return new Promise((r,s)=>{const l=i.transaction(W,"readwrite").objectStore(W),p=l.get(e);p.onsuccess=()=>{const h=p.result;h&&l.put(bt({...h,publishError:t,publishErrorAt:Date.now()})),r()},p.onerror=()=>s(p.error)})}async function dt(e){const t=await Se();return new Promise((i,r)=>{const d=t.transaction(W,"readwrite").objectStore(W),l=d.get(e);l.onsuccess=()=>{const p=l.result;p&&d.put(bt({...p,publishError:void 0,publishErrorAt:void 0})),i()},l.onerror=()=>r(l.error)})}async function Zt(e,t){const i=await G(e);i&&await ye({...i,localBaseCommitId:t.localBaseCommitId,conflictStatus:t.conflictStatus,conflict:t.conflict})}async function ct(e){const t=await G(e);t&&await ye({...t,conflict:void 0,conflictStatus:"none"})}class Re extends Error{constructor(i,r){super(i);Ie(this,"code");Ie(this,"cause");this.name="DraftPublishAborted",this.code=i,this.cause=r==null?void 0:r.cause}}function ki(e){return e instanceof Re?e.code:e instanceof oe?e.status===404?De.DOC_NOT_FOUND:e.code||`HTTP_${e.status}`:e instanceof Error&&e.message.trim()?e.message.trim().slice(0,120):"UNKNOWN"}function Ni(e,t,i,r){const s=(t==null?void 0:t.displayName)||e("unknownTitle");if(i===De.SYNC_HEAD_MISSING)return e("draftPublishFailedSyncHead",{name:s});if(i===De.DOC_NOT_FOUND)return e("draftPublishFailedNotice",{name:s});const d=r instanceof oe||r instanceof Error&&r.message?r.message:i;return e("draftPublishFailedGeneric",{name:s,reason:d})}async function Pi(e,t,i){const r=ki(t);throw await Si(e,r),t instanceof Re?t:new Re(r,{cause:t})}function Ti(e,t){const i=a.useRef(t);i.current=t,a.useEffect(()=>{if(!e)return;const r=3e4,s=1e4,d=async()=>{const p=await Ci({skipFailed:!0}),h=Date.now();for(const m of p)if(!m.published&&!(h-m.updatedAt<r))try{await i.current(m.documentId)}catch(g){console.log("[autoPublish] scan publish failed:",g)}};d();const l=setInterval(d,s);return()=>clearInterval(l)},[e])}const Ei=1e4;function Ai(e,t){const[i,r]=a.useState(null),[s,d]=a.useState("up_to_date");return a.useEffect(()=>{if(!e){r(null),d("up_to_date");return}let p=!1;const h=e;async function m(){try{const k=await Vo(h,t??void 0);if(p)return;r(k.headCommitId),d(k.status)}catch{}}m();const g=window.setInterval(()=>void m(),Ei);return()=>{p=!0,window.clearInterval(g)}},[e,t]),{remoteCommitId:i,syncStatus:s,syncBehind:!!(t&&i&&t!==i)||s==="behind"}}const ji="/assets/mdocs-logo-Dsv_2t6v.svg",Mi=a.lazy(()=>Ce(()=>import("./DocumentEditor-NPbbAape.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(e=>({default:e.DocumentEditor}))),Ri=a.lazy(()=>Ce(()=>import("./SettingsPage-OklrFCx7.js"),__vite__mapDeps([11,1,10,2,3])).then(e=>({default:e.SettingsPage}))),Oi=a.lazy(()=>Ce(()=>import("./AgentChatPanel-CLKeiDeR.js"),__vite__mapDeps([12,1,7,13,2,3,8])).then(e=>({default:e.AgentChatPanel}))),Li=a.lazy(()=>Ce(()=>import("./AiWriteWorkbench-Ecp214S5.js"),__vite__mapDeps([14,1,7,13,2,3])).then(e=>({default:e.AiWriteWorkbench}))),Fi=a.lazy(()=>Ce(()=>import("./MergeView-BnWbq08U.js"),__vite__mapDeps([15,1,4,5,2,3,6,7,8])).then(e=>({default:e.MergeView})));function _i(e,t){try{const i=new Intl.RelativeTimeFormat(t,{numeric:"auto"}),r=Date.now()-new Date(e).getTime(),s=Math.floor(r/6e4),d=Math.floor(s/60),l=Math.floor(d/24);return l>30?i.format(-Math.floor(l/30),"month"):l>0?i.format(-l,"day"):d>0?i.format(-d,"hour"):s>0?i.format(-s,"minute"):i.format(-Math.floor(r/1e3),"second")}catch{return e.slice(0,10)}}async function lt(e,t,i,r){const s=await sn();t(s);const d=localStorage.getItem("mdocs.currentDomainId"),p=d&&s.some(h=>h.domainId===d)?d:ei(s,e);i(p),await r(p)}function en(){const{t:e,lang:t,setLang:i}=de(),[r,s]=a.useState("loading"),[d,l]=a.useState(()=>localStorage.getItem("mdocs.sidebarCollapsed")==="true"),p=()=>{const o=!d;l(o),localStorage.setItem("mdocs.sidebarCollapsed",String(o))},[h,m]=a.useState(!1),[g,k]=a.useState(0),v=a.useRef(null),[C,E]=a.useState(null),[$,y]=a.useState(null),[I,b]=a.useState(null),[A,P]=a.useState([]),[T,_]=a.useState([]),[F,H]=a.useState("default"),{documentId:Y}=zn(),R=qn(),[u,N]=a.useState(null),[M,O]=a.useState(null),J=a.useRef(M);J.current=M;const[Je,ie]=a.useState(0),[ce,fe]=a.useState(null),[Ke,re]=a.useState(!1),[ke,pe]=a.useState(!1),[D,S]=a.useState(!1),z=(u==null?void 0:u.documentId)??null,{syncBehind:B,remoteCommitId:he}=Ai(z,ce),[wt,Xe]=a.useState(null);a.useEffect(()=>{if(!ke||!u){Xe(null);return}(async()=>{const o=await G(u.documentId);if(o!=null&&o.conflict){Xe(o.conflict);return}if(o&&ce&&he){const f=o.localBaseCommitId??ce;if(!f)return;const c={localBaseCommitId:f,remoteCommitId:he,localSnapshotContent:o.content};await Zt(u.documentId,{localBaseCommitId:c.localBaseCommitId,conflictStatus:"diverged",conflict:c}),Xe(c)}})()},[ke,u,ce,he]),a.useEffect(()=>{!u||!B||!D||G(u.documentId).then(async o=>{!o||o.conflict||o.conflictStatus==="publish_conflict"||o.conflictStatus!=="diverged"&&await ye({...o,conflictStatus:"diverged"})})},[u==null?void 0:u.documentId,B,D]),a.useEffect(()=>{if(!u){fe(null);return}let o=!1;return G(u.documentId).then(f=>{o||(f&&!f.published&&f.localBaseCommitId?fe(f.localBaseCommitId):fe(u.headCommitId??null))}),()=>{o=!0}},[u==null?void 0:u.documentId,u==null?void 0:u.headCommitId,D]);const[Ne,U]=a.useState(null),[xt,K]=a.useState(null),[q,Oe]=a.useState(null),[Pe,It]=a.useState(null),[Dt,X]=a.useState(""),[gn,Le]=a.useState("docs"),[Qe,be]=a.useState(!1),[Ct,yn]=pi(),[vn,Fe]=a.useState(!1),[_e,Be]=a.useState(null),Q=a.useRef(void 0),$e=a.useRef(void 0);Ti(localStorage.getItem("mdocs.autoPublish")==="true",Mt);async function Z(o){var f;await((f=Q.current)==null?void 0:f.call(Q)),o()}function bn(o){const c=(o.trim()||"untitled").replace(/[\\/:*?"<>|]/g,"-").slice(0,80);return c.endsWith(".md")?c:`${c}.md`}async function wn(){var f,c;if(!u||!M)return;await((f=Q.current)==null?void 0:f.call(Q));let o=((c=$e.current)==null?void 0:c.call($e))??"";if(!o.trim())try{o=(await rt({content:M.content,from:"lexical",to:"markdown"})).content}catch{o=""}Be({markdown:o,documentId:u.documentId,displayName:M.displayName||u.displayName||"未命名"}),Fe(!0),be(!1)}function xn(){Be({markdown:"",documentId:null,displayName:"未命名"}),Fe(!0),be(!1)}async function In(o){var j,L;const f=o.documentId.trim();if(!f)return;await((j=Q.current)==null?void 0:j.call(Q));let c="",w=o.displayName.trim()||"未命名";try{const ee=await Me(f);w=((L=ee.displayName)==null?void 0:L.trim())||w;try{c=(await rt({content:ee.content,from:"lexical",to:"markdown"})).content}catch{c=""}}catch{}Be({markdown:c,documentId:f,displayName:w}),Fe(!0),be(!1),Le("docs"),Z(()=>R(`/doc/${f}`))}async function Dn(o){(u==null?void 0:u.documentId)===o.documentId&&await jt()}async function Cn(o){if(o.documentId){if(!window.confirm("将把帮写结果写入当前文档的本地草稿(不会自动发布)。继续?")){const L=new Error("cancelled");throw L.silent=!0,L}const w=await rt({content:o.markdown,from:"markdown",to:"lexical"}),j=(u==null?void 0:u.documentId)===o.documentId?u:null;return await Di({documentId:o.documentId,content:w.content,displayName:o.displayName,localBaseCommitIdAtEditStart:(j==null?void 0:j.headCommitId)??null,snapshotMeta:j?{permission:j.permission,ownerVisitorId:j.ownerVisitorId,domainId:j.domainId}:void 0}),(u==null?void 0:u.documentId)===o.documentId?(O({documentId:o.documentId,content:w.content,displayName:o.displayName}),ie(L=>L+1),S(!0)):await Te(o.documentId),U("帮写已写入草稿,可在编辑器中继续修改后发布"),{documentId:o.documentId}}const f=await an({fileName:bn(o.displayName),displayName:o.displayName,content:o.markdown,contentFormat:"markdown",domainId:F||void 0,parentId:void 0});return await V(),await Te(f.documentId),U("已创建文档"),{documentId:f.documentId}}a.useEffect(()=>{Sn()},[]),a.useEffect(()=>{if(!Ne)return;const o=()=>{U(null)};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[Ne]),a.useEffect(()=>{const o=f=>{var j,L;const c=f;if(((j=c.detail)==null?void 0:j.status)===409)return;const w=(L=c.detail)==null?void 0:L.message;w&&K(w)};return window.addEventListener(ut,o),()=>window.removeEventListener(ut,o)},[]);async function Sn(){try{const o=await qt();E(o),qe(o.visitorId),await lt(o.visitorId,_,H,V),s("ready")}catch(o){if(o instanceof oe&&o.status===401){s("needsRegister");return}K(me(e,o)),s("needsRegister")}}async function kn(o,f){const c=await _o(o,f);E(c.visitor),y(c.visitor.visitorId),b(c.recoveryCode),qe(c.visitor.visitorId),await lt(c.visitor.visitorId,_,H,V),s("ready")}async function Nn(o){const f=await qt();E(f),await lt(f.visitorId,_,H,V),s("ready")}async function V(o){const c=await Uo(o??F);P(c)}function He(o){O({documentId:o.documentId,content:o.content,displayName:o.displayName}),ie(f=>f+1),S(!1)}function Pn(o,f){O({documentId:o,content:f.content,displayName:f.displayName}),ie(c=>c+1),S(!0)}async function St(o,f){await st(o);const c=await Me(o);if((u==null?void 0:u.documentId)===o&&v.current===o){N(je(c)),S(!1);const w=J.current,j=f!==void 0&&c.content===f,L=(w==null?void 0:w.documentId)===o&&w.content===c.content;j||L?(w==null?void 0:w.documentId)===o&&w.displayName!==c.displayName&&O({...w,displayName:c.displayName}):He(c)}return c}async function Te(o){v.current=o;try{const f=await G(o);if(v.current!==o)return;const c=await Me(o);if(v.current!==o||(c.domainId!==F&&(localStorage.setItem("mdocs.currentDomainId",c.domainId),H(c.domainId),V(c.domainId)),X(ze(c.relativePath)),c.headCommitId&&f&&!f.published&&(f.publishError===De.SYNC_HEAD_MISSING&&await dt(o),f.localBaseCommitId||await ye({...f,localBaseCommitId:c.headCommitId})),N(je(c)),v.current!==o))return;f&&!f.published?Pn(o,f):He(c)}catch(f){if(v.current!==o)return;K(me(e,f))}}a.useEffect(()=>{r==="ready"&&(Y?Te(Y):(N(null),O(null),fe(null)))},[r,Y]);const{createModal:we,setCreateModal:Ze,createModalError:kt,createModalBusy:xe,createModalInputRef:Tn,openNewDocumentModal:et,openNewFolderModal:tt,submitCreateModal:En}=vi({tree:A,currentDomainId:F,selectedCreateParentPath:Dt,t:e,onDocCreated:o=>{N(je(o)),He(o),X(ze(o.relativePath)),R(`/doc/${o.documentId}`)},refreshTree:V}),[An,Ue]=a.useState(!1),[jn,Ee]=a.useState(!1),[ge,Nt]=a.useState([]),[nt,Pt]=a.useState(""),[Ve,Tt]=a.useState(""),[Mn,Et]=a.useState(new Set);async function Rn(){try{const o=await Yo();Nt(o)}catch(o){K(me(e,o))}}const ot=a.useMemo(()=>{const o={};for(const f of T)o[f.domainId]=f.domainName;return o},[T]),At=a.useMemo(()=>{let o=ge;const f=nt.trim().toLowerCase();return f&&(o=o.filter(c=>{var w;return(w=c.displayName)==null?void 0:w.toLowerCase().includes(f)})),Ve&&(o=o.filter(c=>c.domainId===Ve)),o},[ge,nt,Ve]),On=a.useMemo(()=>{const o=new Set,f=[];for(const c of ge){const w=c.domainId;w&&!o.has(w)&&(o.add(w),f.push({id:w,name:ot[w]??w}))}return f},[ge,ot]);async function Ln(o,f,c,w,j){let L=await G(o);!L&&(u==null?void 0:u.documentId)===o&&(L={documentId:o,content:f,displayName:c,updatedAt:Date.now(),published:!1,localBaseCommitId:w,permission:u.permission,ownerVisitorId:u.ownerVisitorId,domainId:u.domainId},await ye(L)),L&&await Zt(o,{localBaseCommitId:w,conflictStatus:"publish_conflict",conflict:{localBaseCommitId:w,remoteCommitId:j.headCommitId,localSnapshotContent:f}}),re(!0)}async function Fn(o,f,c,w){return $t(c).execute(async()=>{const j=await G(c),L=(j==null?void 0:j.localBaseCommitId)??(u==null?void 0:u.headCommitId);if(!L)throw K(e("syncHeadMissing")),new Error("missing localBaseCommitId");try{await Gt(c,{content:o,displayName:f,permission:w,version:{localBaseCommitId:L}}),await ct(c),await St(c,o),await V(),re(!1),U(e("published")),window.setTimeout(()=>U(null),1200)}catch(ee){throw ee instanceof oe&&ee.status===409&&ee.code==="VERSION_CONFLICT"&&ee.details&&typeof ee.details=="object"&&await Ln(c,o,f,L,ee.details),ee}})}async function _n(){if(!u)return;const o=await Me(u.documentId);o.domainId!==F&&(localStorage.setItem("mdocs.currentDomainId",o.domainId),H(o.domainId),V(o.domainId)),X(ze(o.relativePath)),N(je(o)),He(o),U(e("syncPullDone")),window.setTimeout(()=>U(null),1200)}async function jt(){if(!u)return;const o=await G(u.documentId);if(o&&!o.published)return;if((o==null?void 0:o.conflictStatus)==="publish_conflict"||(o==null?void 0:o.conflictStatus)==="diverged"||!!(o!=null&&o.conflict)){pe(!0);return}await _n()}async function Bn(o){await ct(o.documentId),await st(o.documentId),S(!1),pe(!1),re(!1),await Te(o.documentId),V(o.domainId),U(e("published")),window.setTimeout(()=>U(null),1200)}async function $n(o,f,c){try{await Pi(o,f,c)}catch(w){if(!(w instanceof Re))throw w;const j=c??await G(o);throw U(Ni(e,j,w.code,w.cause??f)),window.setTimeout(()=>U(null),4e3),w}}async function Mt(o){let f;try{await $t(o).execute(async()=>{const c=await G(o);if(!c)return;f=c;let w=c.localBaseCommitId;if(w||(w=(await Me(o)).headCommitId??void 0,w&&(await ye({...c,localBaseCommitId:w}),c.publishError===De.SYNC_HEAD_MISSING&&await dt(o))),!w)throw new Re(De.SYNC_HEAD_MISSING);const j=await G(o);j&&(await Gt(o,{content:j.content,displayName:j.displayName,version:{localBaseCommitId:w}}),await ct(o),await dt(o),(u==null?void 0:u.documentId)===o?await St(o,j.content):await st(o),await V(),U(e("published")),window.setTimeout(()=>U(null),1200))})}catch(c){await $n(o,c,f)}}function Rt(o,f){Oe({type:"document",id:o,name:f})}function Ot(o,f){Oe({type:"folder",id:o,name:f})}async function Hn(o,f){try{const c=await zo(o,f);await V(c.domainId),(u==null?void 0:u.documentId)===o&&(N(je(c)),X(ze(c.relativePath)))}catch(c){c instanceof oe?c.status===409&&K(c.message):K(me(e,c))}}async function Un(){if(q)try{q.type==="document"?(await Wo(q.id),(u==null?void 0:u.documentId)===q.id&&(N(null),O(null),X(""),R("/"))):q.type==="folder"&&(await Go(q.id),u&&(N(null),O(null),X(""),R("/"))),await V(),U(q.type==="folder"?`已删除「${q.name}」及其下所有内容`:`已删除「${q.name}」`),window.setTimeout(()=>U(null),2e3)}catch(o){K(me(e,o))}finally{Oe(null)}}return r==="loading"?n.jsx("div",{className:"mdocs-loading muted",children:e("loading")}):r==="needsRegister"?n.jsx(ti,{onSubmit:kn,onRecover:Nn,error:Ne}):n.jsxs("div",{className:"mdocs-app-root",children:[rn(),n.jsxs("div",{className:"mdocs-shell",children:[$&&C&&n.jsx(ni,{visitorId:$,onDismiss:()=>y(null)}),I&&n.jsx("div",{className:"mdocs-dialog-backdrop",style:{position:"fixed",zIndex:9999},onClick:o=>{o.target===o.currentTarget&&b(null)},children:n.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:480,textAlign:"center"},children:[n.jsx("h1",{style:{fontSize:"1.25rem",marginBottom:8},children:"🔑 保存你的恢复码"}),n.jsxs("p",{className:"muted",style:{marginBottom:16,lineHeight:1.5},children:["恢复码是你的唯一凭证,当 Token 丢失时可用它找回身份。",n.jsx("br",{}),n.jsx("strong",{children:"请立即复制保存,此弹窗关闭后不可再查看。"})]}),n.jsx("div",{style:{background:"#f5f5f5",borderRadius:8,padding:"12px 16px",fontFamily:"monospace",fontSize:"1.25rem",letterSpacing:"0.1em",marginBottom:20,userSelect:"all"},children:I}),n.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"center"},children:[n.jsx("button",{type:"button",className:"primary",onClick:()=>{navigator.clipboard.writeText(I)},children:"复制恢复码"}),n.jsx("button",{type:"button",onClick:()=>b(null),children:"已保存,关闭"})]})]})}),n.jsxs(n.Fragment,{children:[n.jsx(fi,{open:Qe,onToggle:()=>be(o=>!o),position:Ct,onPositionChange:yn}),Qe?n.jsx(a.Suspense,{fallback:null,children:n.jsx(Oi,{open:Qe,onClose:()=>be(!1),visitorName:C==null?void 0:C.visitorName,anchorStyle:ui(Ct),onOpenDocument:o=>{Le("docs"),Z(()=>R(`/doc/${o}`)),be(!1)},onTreeChanged:()=>void V(),onDocumentOverwritten:o=>void Dn(o),onOpenCoding:o=>void In(o)})}):null]}),_e?n.jsx(a.Suspense,{fallback:null,children:n.jsx(Li,{open:vn,initialMarkdown:_e.markdown,documentId:_e.documentId,displayName:_e.displayName,onClose:()=>{Fe(!1),Be(null)},onComplete:Cn})}):null,gn==="settings"?n.jsx(a.Suspense,{fallback:n.jsx("div",{className:"mdocs-main muted",style:{padding:24},children:"加载设置…"}),children:n.jsx(Ri,{onBack:()=>Le("docs"),onPublishDraft:Mt,onOpenDocument:Te,onRecoverDraft:()=>void V()})}):n.jsxs("div",{className:"mdocs-layout",children:[n.jsxs("aside",{className:`mdocs-sidebar ${d?"mdocs-sidebar-collapsed":""}`,children:[n.jsxs("header",{className:"mdocs-sidebar-header",children:[n.jsxs("div",{className:"mdocs-brand",children:[n.jsx("img",{src:ji,alt:e("brand"),className:"mdocs-brand-logo"}),n.jsx("span",{children:e("brand")})]}),n.jsx("button",{type:"button",className:"mdocs-sidebar-toggle",onClick:p,"aria-label":e(d?"expandSidebar":"collapseSidebar"),style:{background:"none",border:"none",cursor:"pointer",padding:"6px",color:"var(--mdocs-text-muted, #999)",borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:o=>{o.currentTarget.style.background="var(--mdocs-hover-bg, #f0f0f0)"},onMouseLeave:o=>{o.currentTarget.style.background="none"},children:d?n.jsx(yo,{size:18}):n.jsx(ho,{size:18})})]}),n.jsxs("div",{className:"mdocs-sidebar-actions",children:[n.jsx("span",{className:"mdocs-sidebar-icon mdocs-tooltip","data-tooltip":e("newDocument"),onClick:()=>et(),style:{color:"var(--mdocs-accent)"},children:n.jsx(Ft,{size:20})}),n.jsx("span",{className:"mdocs-sidebar-icon mdocs-tooltip","data-tooltip":e("newFolder"),onClick:()=>tt(),children:n.jsx(_t,{size:20})})]}),n.jsx(oi,{nodes:A,activeDocumentId:Y??null,selectedParentPath:Dt,onOpen:o=>{Z(()=>R(`/doc/${o.documentId}`))},onOpenFolder:(o,f)=>{Z(()=>{X(o),f&&R(`/doc/${f}`)})},onContextMenu:It,onMoveDocument:Hn,onDeselect:()=>{Z(()=>{X(""),R("/")})}}),n.jsxs("footer",{className:"mdocs-sidebar-footer",children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1,cursor:"pointer"},onClick:()=>Z(()=>Le("settings")),children:[n.jsx("span",{className:"mdocs-visitor-avatar",children:C?C.visitorName.charAt(0).toUpperCase():"?"}),n.jsx("span",{className:"mdocs-visitor-footer-name",children:C?C.visitorName:""})]}),n.jsx("button",{type:"button",className:"mdocs-sidebar-bookmark mdocs-tooltip","data-tooltip":e("bookmark"),onClick:()=>{Ee(!0),Pt(""),Tt(""),Rn()},style:{background:"none",border:"none",cursor:"pointer",padding:"6px",color:"var(--mdocs-text-muted, #999)",fontSize:"1rem",lineHeight:1,borderRadius:4},children:n.jsx(bo,{size:16,strokeWidth:1.5})}),n.jsx("button",{type:"button",className:"mdocs-sidebar-logout mdocs-tooltip","data-tooltip":e("logout"),onClick:()=>Ue(!0),style:{background:"none",border:"none",cursor:"pointer",padding:"6px",color:"var(--mdocs-text-muted, #999)",lineHeight:1,borderRadius:4},children:n.jsx(mo,{size:16,strokeWidth:1.5})})]})]}),n.jsxs("main",{className:"mdocs-main",children:[u&&M&&M.documentId===u.documentId?n.jsxs("div",{className:"mdocs-editor-with-comments",children:[n.jsx("div",{className:"mdocs-editor-container",children:n.jsx(a.Suspense,{fallback:n.jsx("div",{className:"muted",style:{padding:24},children:"加载编辑器…"}),children:n.jsx(Mi,{meta:u,initialContent:M.content,initialDisplayName:M.displayName,contentRevision:Je,canEdit:!!(C&&(u.ownerVisitorId===C.visitorId||No(u.permission)||u.invitedEdit===!0)),domains:T,currentDomainId:F,onDomainChange:o=>{Z(()=>{localStorage.setItem("mdocs.currentDomainId",o),H(o),N(null),O(null),X(""),R("/"),V(o)})},onDomainsChange:_,onPublish:Fn,syncBehind:B,onSyncClick:()=>void jt(),onDraftExistsChange:S,onConflictModalRequest:()=>re(!0),onMergeRequest:()=>pe(!0),canManageInvites:!!(C&&C.visitorId===u.ownerVisitorId),onDelete:async()=>{if(u.relativePath.endsWith("/___desc___.md")){const o=u.relativePath.replace(/\/___desc___\.md$/,"");Ot(u.documentId,o)}else Rt(u.documentId,u.relativePath)},saveBeforeNavRef:Q,exportMarkdownRef:$e,onShowToast:U,onShowError:K,onToggleComments:()=>m(!h),commentPanelOpen:h,commentCount:g,onAiWrite:()=>void wn()},u.documentId)})}),h&&n.jsx(wi,{documentId:u.documentId,visitorId:C==null?void 0:C.visitorId,visitorName:C==null?void 0:C.visitorName,documentOwnerId:u.ownerVisitorId,onClose:()=>m(!1)})]}):n.jsxs("div",{className:"mdocs-welcome",children:[n.jsx("h1",{children:e("brand")}),n.jsx("p",{className:"muted mdocs-welcome-lead",children:A.length===0?e("noDocsInDomain"):e("createDocToStart")}),n.jsxs("div",{className:"mdocs-welcome-domain",children:[n.jsx("label",{className:"muted mdocs-welcome-domain-label",children:e("domainLabel")}),n.jsx(di,{domains:T.length?T:[{domainId:"default",domainName:e("defaultDomain"),permission:"",creatorVisitorId:"",docCount:0}],value:F,onChange:o=>{Z(()=>{localStorage.setItem("mdocs.currentDomainId",o),H(o),N(null),O(null),X(""),R("/"),V(o)})},onDomainsChange:_,ariaLabel:e("domainLabel"),localizeName:o=>gi(o,t,e)})]}),n.jsxs("div",{className:"mdocs-welcome-actions",children:[n.jsxs("button",{type:"button",className:"primary",onClick:()=>et(),style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx(Ft,{size:16,strokeWidth:1.5}),e("newDocument")]}),n.jsxs("button",{type:"button",className:"secondary",onClick:()=>tt(),style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx(_t,{size:16,strokeWidth:1.5}),e("newFolder")]}),n.jsxs("button",{type:"button",className:"secondary",onClick:()=>xn(),style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("img",{src:mn,alt:"",width:16,height:16,style:{display:"block"}}),"AI 帮写"]})]})]}),n.jsx(bi,{open:Ke,onClose:()=>re(!1),onResolve:()=>{re(!1),pe(!0)}}),ke&&u&&wt&&n.jsx(a.Suspense,{fallback:n.jsx("div",{className:"merge-view-loading",children:e("mergeLoadingRemote")}),children:n.jsx(Fi,{documentId:u.documentId,displayName:u.displayName,conflict:wt,onClose:()=>pe(!1),onSuccess:Bn,onError:o=>K(o)})}),Ne&&n.jsx("div",{className:"mdocs-toast",role:"status",children:Ne}),xt&&n.jsx(hi,{title:e("error"),message:xt,onClose:()=>K(null)})]}),An&&n.jsx("div",{className:"mdocs-dialog-backdrop",onClick:o=>{o.target===o.currentTarget&&Ue(!1)},children:n.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:440},children:[n.jsx("h1",{style:{fontSize:"1.125rem",marginBottom:8},children:"退出当前登录身份?"}),n.jsx("p",{style:{lineHeight:1.6,color:"var(--mdocs-text-secondary, #666)",marginBottom:20},children:"这将会导致您无法修改以前的文章。如果想找回账号,需要恢复码或联系管理员执行合并用户脚本。"}),n.jsxs("div",{className:"mdocs-dialog-actions",style:{justifyContent:"flex-end"},children:[n.jsx("button",{type:"button",onClick:()=>Ue(!1),children:"取消"}),n.jsx("button",{type:"button",className:"primary",style:{background:"#d32f2f"},onClick:()=>{Fo(),N(null),O(null),E(null),P([]),Ue(!1),s("needsRegister")},children:"确认退出"})]})]})}),jn&&n.jsx("div",{className:"mdocs-dialog-backdrop",onClick:o=>{o.target===o.currentTarget&&Ee(!1)},children:n.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:640,width:"min(640px, 100%)",maxHeight:"70vh",display:"flex",flexDirection:"column"},children:[n.jsxs("h1",{style:{fontSize:"1.125rem",marginBottom:16},children:[e("bookmarkTitle"),"(",ge.length,")"]}),ge.length>0&&n.jsxs("div",{className:"mdocs-bookmark-filterbar",children:[n.jsx("input",{type:"text",placeholder:e("bookmarkSearch"),value:nt,onChange:o=>Pt(o.target.value)}),n.jsxs("select",{value:Ve,onChange:o=>Tt(o.target.value),children:[n.jsx("option",{value:"",children:e("bookmarkFilterAll")}),On.map(o=>n.jsx("option",{value:o.id,children:o.name},o.id))]})]}),ge.length===0?n.jsx("p",{style:{color:"var(--mdocs-text-muted, #999)",textAlign:"center",padding:"2rem 0"},children:e("bookmarkEmpty")}):At.length===0?n.jsx("p",{style:{color:"var(--mdocs-text-muted, #999)",textAlign:"center",padding:"2rem 0"},children:e("bookmarkNoMatch")}):n.jsx("div",{style:{overflowY:"auto",flex:1,margin:"0 -1rem",padding:"0 1rem"},children:n.jsxs("table",{className:"mdocs-bookmark-table",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:e("bookmarkColTitle")}),n.jsx("th",{children:e("bookmarkColDomain")}),n.jsx("th",{children:e("bookmarkColAuthor")}),n.jsx("th",{children:e("bookmarkColTime")}),n.jsx("th",{className:"mdocs-bookmark-col-action"})]})}),n.jsx("tbody",{children:At.map(o=>{const f=Mn.has(o.documentId);return n.jsxs("tr",{className:`${f?"mdocs-bookmark-removing":""}`,style:{opacity:o.isDeleted?.6:1},children:[n.jsx("td",{className:"mdocs-bookmark-col-title",children:n.jsxs("div",{style:{cursor:o.isDeleted?"default":"pointer",display:"flex",alignItems:"center",gap:6,overflow:"hidden"},onClick:()=>{o.isDeleted||Z(()=>{Ee(!1),R(`/doc/${o.documentId}`)})},children:[n.jsx("span",{ref:c=>{if(c){const w=c.scrollWidth>c.clientWidth;c.title=w?o.displayName??"":""}},style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:o.displayName??"(无标题)"}),o.isDeleted&&n.jsx("span",{style:{fontSize:"0.7rem",color:"#d32f2f",background:"#ffebee",padding:"1px 6px",borderRadius:4,flexShrink:0},children:"已删除"})]})}),n.jsx("td",{children:o.isDeleted?"":ot[o.domainId??""]??o.domainId??""}),n.jsx("td",{children:o.isDeleted?"":o.ownerVisitorName??"-"}),n.jsx("td",{children:o.isDeleted?"":_i(o.bookmarkedAt,t)}),n.jsx("td",{className:"mdocs-bookmark-col-action",children:n.jsxs("div",{style:{display:"flex",gap:2,alignItems:"center",justifyContent:"flex-end"},children:[n.jsx("button",{type:"button",className:"mdocs-tooltip","data-tooltip":e("bookmarkOpen"),onClick:()=>{o.isDeleted||Z(()=>{Ee(!1),R(`/doc/${o.documentId}`)})},style:{background:"none",border:"none",cursor:o.isDeleted?"default":"pointer",padding:"4px",color:"var(--mdocs-text-muted, #999)",lineHeight:1,borderRadius:4,display:"inline-flex",alignItems:"center"},children:n.jsx(ao,{size:14,strokeWidth:1.5})}),n.jsx("button",{type:"button",className:"mdocs-tooltip","data-tooltip":e("bookmarkRemove"),onClick:async()=>{try{await Jo(o.documentId),Et(c=>new Set(c).add(o.documentId)),setTimeout(()=>{Nt(c=>c.filter(w=>w.documentId!==o.documentId)),Et(c=>{const w=new Set(c);return w.delete(o.documentId),w})},300)}catch(c){K(me(e,c))}},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"var(--mdocs-text-muted, #999)",fontSize:"1rem",lineHeight:1,borderRadius:4,display:"inline-flex",alignItems:"center"},onMouseEnter:c=>{c.currentTarget.style.color="#d32f2f"},onMouseLeave:c=>{c.currentTarget.style.color="var(--mdocs-text-muted, #999)"},children:"✕"})]})})]},o.documentId)})})]})}),n.jsx("div",{className:"mdocs-dialog-actions",style:{justifyContent:"flex-end",marginTop:16,paddingTop:16,borderTop:"1px solid var(--mdocs-border, #eee)"},children:n.jsx("button",{type:"button",onClick:()=>Ee(!1),children:e("close")})})]})}),Pe&&n.jsx(si,{x:Pe.x,y:Pe.y,node:Pe.node,parentPath:Pe.parentPath,onClose:()=>It(null),onCreateChild:o=>et(o),onCreateFolder:o=>tt(o),onDeleteDocument:o=>Rt(o.documentId,o.path),onDeleteFolder:o=>Ot(o.documentId,o.folderDisplayName||o.name)}),q&&n.jsx(un,{title:q.type==="folder"?"删除文件夹":"删除文档",message:q.type==="folder"?`确定要删除「${q.name}」及其下的所有文档和子文件夹吗?此操作不可撤销。`:`确定要删除「${q.name}」吗?`,confirmLabel:"删除",cancelLabel:"取消",onConfirm:Un,onCancel:()=>Oe(null),danger:!0}),we&&n.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:o=>{o.target===o.currentTarget&&!xe&&Ze(null)},children:n.jsxs("div",{className:"mdocs-dialog card",role:"dialog","aria-modal":"true",children:[n.jsx("h1",{children:we.kind==="document"?e("newDocumentTitle"):e("newFolderTitle")}),n.jsx("p",{className:"muted",children:we.kind==="document"?e("fileNameHint"):e("folderNameHint")}),n.jsxs("form",{onSubmit:En,className:"mdocs-dialog-form",children:[n.jsxs("label",{className:"mdocs-dialog-label",children:[we.kind==="document"?e("fileNameLabel"):e("folderNameLabel"),n.jsx("input",{ref:Tn,value:we.draft,onChange:o=>Ze(f=>f&&{...f,draft:o.target.value}),placeholder:we.kind==="document"?e("untitledPlaceholder"):e("folderExamplePlaceholder"),maxLength:200,disabled:xe})]}),kt&&n.jsx("div",{className:"mdocs-dialog-error",children:kt}),n.jsxs("div",{className:"mdocs-dialog-actions",children:[n.jsx("button",{type:"button",onClick:()=>!xe&&Ze(null),disabled:xe,children:e("cancel")}),n.jsx("button",{type:"submit",className:"primary",disabled:xe,children:e(xe?"creating":"create")})]})]})]})})]})]})]})}const Bi=a.lazy(()=>Ce(()=>import("./PlaygroundPage-BSGipUkC.js"),__vite__mapDeps([16,1,4,5,2,3,6,7,8,9])).then(e=>({default:e.PlaygroundPage})));function $i(){return n.jsxs(Gn,{children:[n.jsx(it,{path:"/",element:n.jsx(en,{})}),n.jsx(it,{path:"/doc/:documentId",element:n.jsx(en,{})}),n.jsx(it,{path:"/playground",element:n.jsx(a.Suspense,{fallback:n.jsx("div",{style:{padding:24},children:"Loading playground…"}),children:n.jsx(Bi,{})})})]})}const hn=document.getElementById("root");if(!hn)throw new Error("root element missing");Yn.createRoot(hn).render(n.jsx(Jn.StrictMode,{children:n.jsx(Xn,{motion:Zn,children:n.jsx(Qn,{children:n.jsx(So,{children:n.jsx(Kn,{children:n.jsx($i,{})})})})})}));export{Ir as $,Re as A,Ji as B,Ho as C,di as D,Or as E,Zo as F,ar as G,rr as H,ir as I,or as J,cr as K,Ki as L,fo as M,Qi as N,Xi as O,Zi as P,dr as Q,sr as R,bo as S,lr as T,mr as U,ur as V,qt as W,Dr as X,Cr as Y,br as Z,Yo as _,G as a,ji as a0,rn as a1,un as a2,tr as a3,er as a4,vr as a5,Sr as a6,Nr as a7,Ae as a8,kr as a9,Pr as aa,Tr as ab,Er as ac,Rr as ad,Mr as ae,jr as af,Ar as ag,Me as ah,fr as ai,rt as aj,Gt as ak,ho as al,de as b,se as c,st as d,wr as e,nr as f,$t as g,qi as h,mn as i,pr as j,xr as k,gi as l,te as m,gr as n,hr as o,yr as p,sn as q,Jo as r,Uo as s,oi as t,Di as u,an as v,me as w,Ci as x,Ni as y,dt as z};
|
|
184
|
+
`,Yi=[{documentId:"doc-welcome",relativePath:"README.md",displayName:"README",content:Vt,contentHash:ze(Vt),permission:1,ownerVisitorId:ne,domainId:"default",updatedBy:ne,updatedAt:new Date().toISOString(),createdAt:new Date().toISOString(),fileType:"md",parentId:null},{documentId:"doc-markdown-guide",relativePath:"指南/Markdown 语法.md",displayName:"Markdown 语法",content:Wt,contentHash:ze(Wt),permission:1,ownerVisitorId:ne,domainId:"default",updatedBy:ne,updatedAt:new Date().toISOString(),createdAt:new Date().toISOString(),fileType:"md",parentId:null},{documentId:"doc-diagram-guide",relativePath:"指南/图表支持.md",displayName:"图表支持",content:zt,contentHash:ze(zt),permission:1,ownerVisitorId:ne,domainId:"default",updatedBy:ne,updatedAt:new Date().toISOString(),createdAt:new Date().toISOString(),fileType:"md",parentId:null},{documentId:"doc-personal-note",relativePath:"个人笔记.md",displayName:"个人笔记",content:qt,contentHash:ze(qt),permission:0,ownerVisitorId:ne,domainId:ne,updatedBy:ne,updatedAt:new Date().toISOString(),createdAt:new Date().toISOString(),fileType:"md",parentId:null}];const ht="mdocs.visitorId",ut="mdocs-api-error";function Fo(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(ut,{detail:{status:e.status,code:e.code,message:e.message}}))}function an(){return!1}function Ki(){return window.localStorage.getItem(ht)}function Ge(e){window.localStorage.setItem(ht,e)}function _o(){window.localStorage.removeItem(ht)}async function b(e,t={}){try{an();const i=new Headers(t.headers);!i.has("Content-Type")&&t.body&&i.set("Content-Type","application/json");const r=await fetch(e,{...t,headers:i});if(r.status===204)return;const s=await r.text();let d;try{d=s?JSON.parse(s):null}catch{throw new oe(r.status,"BAD_RESPONSE","response is not valid JSON")}if(!r.ok){const l=d==null?void 0:d.error;throw new oe(r.status,(l==null?void 0:l.code)??"UNKNOWN",(l==null?void 0:l.message)??"request failed",l==null?void 0:l.details)}return d.data}catch(i){throw i instanceof oe&&Fo(i),i}}const Je="default",Xi=["public","restricted","private"];function Qi(e){return e===Je}function Zi(e,t){return t!==null&&e.creatorVisitorId===t}function er(e){return e.docCount>0}function Bo(e,t){return b("/api/visitors/register",{method:"POST",body:JSON.stringify({visitorName:e,password:t})})}function $o(e){return b("/api/visitors/recover",{method:"POST",body:JSON.stringify({recoveryCode:e})})}function Ho(e,t){return b("/api/visitors/login",{method:"POST",body:JSON.stringify({visitorName:e,password:t})})}function tr(e){return b("/api/visitors/set-password",{method:"POST",body:JSON.stringify({password:e})})}function nr(){return b("/api/visitors/recovery-code",{method:"POST"})}async function Gt(){return(await b("/api/visitors/me")).visitor}function or(){return b("/api/visitors").then(e=>e.visitors)}function Uo(){return b("/api/domains")}function ir(e){return b("/api/domains",{method:"POST",body:JSON.stringify(e)})}function rr(e,t){return b(`/api/domains/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({domainName:t})})}function ar(e,t){return b(`/api/domains/${encodeURIComponent(e)}/permission`,{method:"PUT",body:JSON.stringify({permission:t})})}function sr(e){return b(`/api/domains/${encodeURIComponent(e)}`,{method:"DELETE"})}function dr(e){return b(`/api/domains/${encodeURIComponent(e)}/members`).then(t=>t.members)}function cr(e,t){return b(`/api/domains/${encodeURIComponent(e)}/members`,{method:"PUT",body:JSON.stringify({visitorIds:t})})}function lr(){return b("/api/domain-member-templates")}function mr(e){return b("/api/domain-member-templates",{method:"POST",body:JSON.stringify(e)})}function ur(e,t){return b(`/api/domain-member-templates/${encodeURIComponent(String(e))}`,{method:"PUT",body:JSON.stringify(t)})}function fr(e){return b(`/api/domain-member-templates/${encodeURIComponent(String(e))}`,{method:"DELETE"})}function Vo(e){const t=e!=null&&e.trim()?`?domainId=${encodeURIComponent(e.trim())}`:"";return b(`/api/tree${t}`)}function Me(e){return b(`/api/documents/${encodeURIComponent(e)}`)}function sn(e){return b("/api/documents",{method:"POST",body:JSON.stringify(e)})}function Jt(e,t){return b(`/api/documents/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}function Wo(e,t){const i=t?`?localBaseCommitId=${encodeURIComponent(t)}`:"";return b(`/api/documents/${encodeURIComponent(e)}/sync-status${i}`)}function pr(e,t,i){const r=new URLSearchParams({localBaseCommitId:t,remoteCommitId:i});return b(`/api/documents/${encodeURIComponent(e)}/merge-context?${r}`)}function rt(e){return b("/api/documents/convert",{method:"POST",body:JSON.stringify(e)})}function zo(e){return b(`/api/documents/${encodeURIComponent(e)}`,{method:"DELETE"})}function qo(e,t){return b(`/api/documents/${encodeURIComponent(e)}/move`,{method:"POST",body:JSON.stringify({parentId:t})})}function hr(e){return b(`/api/documents/${encodeURIComponent(e)}/invites`)}function gr(e,t,i){return b(`/api/documents/${encodeURIComponent(e)}/invites`,{method:"POST",body:JSON.stringify({targetVisitorId:t,targetPermission:i})})}function yr(e,t){return b(`/api/documents/${encodeURIComponent(e)}/invites/${encodeURIComponent(t)}`,{method:"DELETE"})}async function vr(e,t){var m;const i=new FormData;i.append("file[]",e),i.append("documentId",t);const r=new Headers,s=await fetch("/api/assets/upload",{method:"POST",headers:r,body:i}),d=await s.json(),l=d;if(!s.ok||l.code===1){const g=d==null?void 0:d.error;throw new oe(s.status,(g==null?void 0:g.code)??"UPLOAD_FAILED",(g==null?void 0:g.message)??l.msg??"upload failed")}const f=((m=l.data)==null?void 0:m.succMap)??{},h=Object.values(f);if(h.length===0)throw new Error("upload succeeded but no URL returned");return h[0]}function Go(e){return b("/api/folders",{method:"POST",body:JSON.stringify(e)})}function Jo(e){return b(`/api/documents/folder/${encodeURIComponent(e)}`,{method:"DELETE"})}function br(e){return b("/api/cli/tokens",{method:"POST",body:JSON.stringify({})})}function wr(){return b("/api/cli/tokens")}function Yo(){return b("/api/bookmarks")}function xr(e){return b(`/api/bookmarks/${encodeURIComponent(e)}`)}function Ir(e){return b(`/api/bookmarks/${encodeURIComponent(e)}`,{method:"POST"})}function Ko(e){return b(`/api/bookmarks/${encodeURIComponent(e)}`,{method:"DELETE"})}function Dr(){return b("/api/visitors/me/documents")}function Xo(e){return b(`/api/documents/${encodeURIComponent(e)}/comments`)}function Qo(e,t){return b(`/api/documents/${encodeURIComponent(e)}/comments`,{method:"POST",body:JSON.stringify(t)})}function Zo(e,t){return b(`/api/documents/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`,{method:"DELETE"})}function Cr(){return b("/api/agent/config")}function kr(e){return b("/api/agent/config",{method:"PUT",body:JSON.stringify(e)})}function Sr(){return b("/api/agent/skills")}function Nr(e){return b("/api/agent/skills",{method:"POST",body:JSON.stringify(e)})}function Pr(e,t){return b(`/api/agent/skills/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function Tr(e){return b(`/api/agent/skills/${encodeURIComponent(e)}`,{method:"DELETE"})}function Ar(){return b("/api/agent/status")}function Er(){return b("/api/agent/context-usage")}function jr(e="normal",t){const i=new URLSearchParams;e==="coding"&&(i.set("mode","coding"),t&&i.set("documentId",t));const r=i.toString();return b(`/api/agent/session${r?`?${r}`:""}`)}function Mr(e="normal",t){const i=new URLSearchParams;e==="coding"&&(i.set("mode","coding"),t&&i.set("documentId",t));const r=i.toString();return b(`/api/agent/sessions${r?`?${r}`:""}`)}function Rr(e="normal",t){return b("/api/agent/sessions",{method:"POST",body:JSON.stringify({mode:e,...e==="coding"?{documentId:t??null}:{}})})}function Or(e,t="normal",i){return b("/api/agent/session/open",{method:"POST",body:JSON.stringify({sessionId:e,mode:t,...t==="coding"?{documentId:i??null}:{}})})}function Lr(e,t){return b("/api/agent/session/bind-document",{method:"POST",body:JSON.stringify({sessionId:e,documentId:t})})}function Fr(e,t){return b("/api/agent/choice",{method:"POST",body:JSON.stringify({requestId:e,choice:t})})}function _r(e){return b("/api/agent/choice",{method:"POST",body:JSON.stringify({requestId:e,expire:!0})})}function Br(e){return b("/api/agent/choice",{method:"POST",body:JSON.stringify({requestId:e,cancel:!0})})}function $r(e,t){return b("/api/agent/skill-form",{method:"POST",body:JSON.stringify({requestId:e,...t})})}function Hr(e){return b("/api/agent/skill-form",{method:"POST",body:JSON.stringify({requestId:e,expire:!0})})}function Ur(e){return b("/api/agent/skill-form",{method:"POST",body:JSON.stringify({requestId:e,cancel:!0})})}async function Vr(e,t){var m;const i={message:e,mode:t.mode==="coding"?"coding":"normal"},r=t.skillNames&&t.skillNames.length>0?t.skillNames:t.skillIds&&t.skillIds.length>0?t.skillIds:void 0;r&&(i.skillNames=r),t.mode==="coding"&&(t.documentId!==void 0&&(i.documentId=t.documentId),typeof t.workingMarkdown=="string"&&(i.workingMarkdown=t.workingMarkdown),typeof t.baseMarkdown=="string"&&(i.baseMarkdown=t.baseMarkdown));const s=await fetch("/api/agent/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),signal:t.signal});if(!s.ok){let g=`HTTP ${s.status}`;try{const k=await s.json();(m=k.error)!=null&&m.message&&(g=k.error.message)}catch{}throw new Error(g)}if(!s.body)throw new Error("empty response body");const d=s.body.getReader(),l=new TextDecoder;let f="";for(;;){const{done:g,value:k}=await d.read();if(g)break;f+=l.decode(k,{stream:!0});const v=f.split(`
|
|
185
|
+
`);f=v.pop()??"";for(const C of v){const A=C.trim();if(!A.startsWith("data:"))continue;const F=A.slice(5).trim();if(!(!F||F==="[DONE]"))try{t.onEvent(JSON.parse(F))}catch{}}}const h=f.trim();if(h.startsWith("data:")){const g=h.slice(5).trim();if(g&&g!=="[DONE]")try{t.onEvent(JSON.parse(g))}catch{}}}const ei={domainId:Je,domainName:"Default",permission:"public",creatorVisitorId:"",docCount:0};async function dn(){try{return await Uo()}catch{return[ei]}}function ti(e,t){var i,r,s;return((i=e.find(d=>d.domainId===t))==null?void 0:i.domainId)??((r=e.find(d=>d.domainId===Je))==null?void 0:r.domainId)??((s=e[0])==null?void 0:s.domainId)??Je}function ni(e){const{t}=de(),[i,r]=a.useState(!1),[s,d]=a.useState(null),[l,f]=a.useState("register"),[h,m]=a.useState(1),[g,k]=a.useState(""),[v,C]=a.useState(""),[A,F]=a.useState("password"),[y,I]=a.useState(""),[w,E]=a.useState(""),[P,T]=a.useState("");function B(N){if(N.preventDefault(),!g.trim()){d(t("nameRequired"));return}d(null),m(2)}async function _(N){N.preventDefault(),r(!0),d(null);try{const M=v.trim();await e.onSubmit(g.trim(),M||void 0)}catch(M){d(M instanceof Error?M.message:String(M)),m(1)}finally{r(!1)}}async function H(N){N.preventDefault();const M=y.trim(),O=w.trim();if(!M||!O){d("请输入用户名和密码");return}r(!0),d(null);try{const Y=await Ho(M,O);Ge(Y.visitor.visitorId),await e.onRecover(Y.visitor.visitorId)}catch(Y){d(Y instanceof Error?Y.message:String(Y))}finally{r(!1)}}async function J(N){N.preventDefault();const M=P.trim();if(!M){d("请输入恢复码");return}r(!0),d(null);try{const O=await $o(M);Ge(O.visitor.visitorId),await e.onRecover(O.visitor.visitorId)}catch(O){d(O instanceof Error?O.message:String(O))}finally{r(!1)}}const R=s??e.error;function u(N){d(null),f(N)}return n.jsx("div",{className:"mdocs-dialog-backdrop",children:n.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:420},children:[n.jsxs("div",{style:{display:"flex",borderBottom:"1px solid var(--mdocs-border)",marginBottom:16},children:[n.jsx("button",{type:"button",onClick:()=>u("register"),style:{flex:1,padding:"12px",border:"none",background:l==="register"?"var(--mdocs-bg)":"none",color:l==="register"?"var(--mdocs-text)":"var(--mdocs-text-secondary)",cursor:"pointer",fontWeight:l==="register"?600:400,borderBottom:l==="register"?"2px solid var(--mdocs-accent)":"none"},children:"注册"}),n.jsx("button",{type:"button",onClick:()=>u("login"),style:{flex:1,padding:"12px",border:"none",background:l==="login"?"var(--mdocs-bg)":"none",color:l==="login"?"var(--mdocs-text)":"var(--mdocs-text-secondary)",cursor:"pointer",fontWeight:l==="login"?600:400,borderBottom:l==="login"?"2px solid var(--mdocs-accent)":"none"},children:"登录"})]}),l==="register"&&n.jsx(n.Fragment,{children:h===1?n.jsxs(n.Fragment,{children:[n.jsx("h1",{children:t("welcomeTitle")}),n.jsx("p",{children:t("welcomeDesc")}),n.jsxs("form",{onSubmit:B,children:[n.jsx("input",{autoFocus:!0,placeholder:t("visitorNamePlaceholder"),value:g,onChange:N=>k(N.target.value),maxLength:60}),R&&n.jsx("div",{className:"mdocs-dialog-error",children:R}),n.jsx("button",{type:"submit",className:"primary",disabled:i,children:"下一步"})]}),n.jsx("p",{style:{marginTop:16,textAlign:"center"},children:n.jsx("button",{type:"button",style:{background:"none",border:"none",color:"var(--mdocs-accent)",cursor:"pointer",fontSize:"0.875rem",textDecoration:"underline",padding:0},onClick:()=>u("login"),children:"已有账号?点击登录"})})]}):n.jsxs(n.Fragment,{children:[n.jsx("h1",{children:"设置密码(可选)"}),n.jsx("p",{style:{marginBottom:8},children:"设置密码后,你可以在其他浏览器或设备上使用「用户名+密码」登录。"}),n.jsx("p",{style:{color:"var(--mdocs-text-secondary)",fontSize:"0.875rem",marginBottom:16},children:"留空不设置密码也能正常使用,但只能在当前浏览器操作。"}),n.jsxs("form",{onSubmit:_,children:[n.jsx("input",{autoFocus:!0,type:"password",placeholder:"设置密码(至少 4 位)",value:v,onChange:N=>C(N.target.value),minLength:4}),R&&n.jsx("div",{className:"mdocs-dialog-error",children:R}),n.jsx("button",{type:"submit",className:"primary",disabled:i,style:{marginTop:8},children:i?t("creating"):"完成注册"})]}),n.jsx("p",{style:{marginTop:16,textAlign:"center"},children:n.jsx("button",{type:"button",style:{background:"none",border:"none",color:"var(--mdocs-text-secondary)",cursor:"pointer",fontSize:"0.875rem",padding:0},onClick:()=>m(1),children:"← 返回上一步"})})]})}),l==="login"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16,marginBottom:16,fontSize:"0.875rem"},children:[n.jsx("button",{type:"button",onClick:()=>{d(null),F("password")},style:{background:"none",border:"none",color:A==="password"?"var(--mdocs-accent)":"var(--mdocs-text-secondary)",cursor:"pointer",padding:"4px 0",borderBottom:A==="password"?"2px solid var(--mdocs-accent)":"none",fontWeight:A==="password"?600:400},children:"用户名+密码"}),n.jsx("button",{type:"button",onClick:()=>{d(null),F("recovery")},style:{background:"none",border:"none",color:A==="recovery"?"var(--mdocs-accent)":"var(--mdocs-text-secondary)",cursor:"pointer",padding:"4px 0",borderBottom:A==="recovery"?"2px solid var(--mdocs-accent)":"none",fontWeight:A==="recovery"?600:400},children:"恢复码"})]}),A==="password"?n.jsxs(n.Fragment,{children:[n.jsx("h1",{children:"🔑 使用密码登录"}),n.jsx("p",{children:"输入用户名和密码,在其他设备上找回你的身份。"}),n.jsxs("form",{onSubmit:H,children:[n.jsx("input",{autoFocus:!0,placeholder:"用户名",value:y,onChange:N=>I(N.target.value),maxLength:60,style:{marginBottom:8}}),n.jsx("input",{type:"password",placeholder:"密码",value:w,onChange:N=>E(N.target.value)}),R&&n.jsx("div",{className:"mdocs-dialog-error",children:R}),n.jsx("button",{type:"submit",className:"primary",disabled:i,children:i?"验证中…":"登录"})]}),n.jsx("p",{style:{marginTop:16,textAlign:"center"},children:n.jsx("button",{type:"button",style:{background:"none",border:"none",color:"var(--mdocs-accent)",cursor:"pointer",fontSize:"0.875rem",textDecoration:"underline",padding:0},onClick:()=>u("register"),children:"没有账号?去注册"})})]}):n.jsxs(n.Fragment,{children:[n.jsx("h1",{children:"🔑 使用恢复码找回"}),n.jsx("p",{children:"输入注册时保存的恢复码,系统将为您生成新的身份令牌。"}),n.jsxs("form",{onSubmit:J,children:[n.jsx("input",{autoFocus:!0,placeholder:"ABCD-EFGH-IJKL-MNOP",value:P,onChange:N=>T(N.target.value),style:{fontFamily:"monospace",letterSpacing:"0.1em"},maxLength:30}),R&&n.jsx("div",{className:"mdocs-dialog-error",children:R}),n.jsx("button",{type:"submit",className:"primary",disabled:i,children:i?"验证中…":"找回身份"})]})]})]})]})})}function oi(e){const{t}=de();return n.jsxs("div",{className:"mdocs-notice card",children:[n.jsx("span",{children:t("visitorIdNotice",{id:e.visitorId})}),n.jsx("button",{type:"button",onClick:e.onDismiss,children:t("gotIt")})]})}const cn="application/x-mdocs-document-id",ft="mdocs-doc:";let ve=null;function ln(e,t,i=[]){for(const r of e){if(r.type==="document"){if(r.documentId===t)return{forceOpenFolderIds:i,scrollTreeId:r.documentId};continue}if(r.descDocumentId===t)return{forceOpenFolderIds:i,scrollTreeId:r.documentId};const s=ln(r.children,t,[...i,r.documentId]);if(s)return s}return null}function gt(e){if(ve)return ve;try{const t=e.getData(cn);if(t)return t;const i=e.getData("text/plain")||e.getData("Text");if(i.startsWith(ft))return i.slice(ft.length)}catch{}return""}function ue(e){return!!(e&&ve)}function ii(e){const{t}=de(),i=a.useRef(null),[r,s]=a.useState(null),[d,l]=a.useState(null),f=a.useMemo(()=>{var I;const y=(I=e.activeDocumentId)==null?void 0:I.trim();return y?ln(e.nodes,y):null},[e.nodes,e.activeDocumentId]),h=a.useMemo(()=>new Set((f==null?void 0:f.forceOpenFolderIds)??[]),[f]);a.useEffect(()=>{if(!(f!=null&&f.scrollTreeId))return;const y=f.scrollTreeId,I=()=>{var P;const E=(P=i.current)==null?void 0:P.querySelector(`[data-tree-id="${CSS.escape(y)}"]`);E==null||E.scrollIntoView({block:"nearest",behavior:"smooth"})},w=requestAnimationFrame(()=>{requestAnimationFrame(I)});return()=>cancelAnimationFrame(w)},[f==null?void 0:f.scrollTreeId,h,e.nodes]);function m(){s(null)}function g(){ve=null,l(null),m()}function k(y){ve=y,l(y),m()}function v(y){if(!ue(e.onMoveDocument))return;y.preventDefault(),y.dataTransfer.dropEffect="move",y.target.closest(".mdocs-tree-row")||s({kind:"root"})}function C(y){const I=y.relatedTarget;I&&y.currentTarget.contains(I)||s(w=>(w==null?void 0:w.kind)==="root"?null:w)}function A(y){if(!e.onMoveDocument||!ue(e.onMoveDocument))return;y.preventDefault(),y.stopPropagation();const w=y.target.closest(".mdocs-tree-row"),E=gt(y.dataTransfer);g(),!w&&E&&e.onMoveDocument(E,null)}const F="mdocs-sidebar-list"+((r==null?void 0:r.kind)==="root"?" mdocs-tree-drop-root":"");return e.nodes.length===0?n.jsx("div",{ref:i,className:F,onDragOver:v,onDragLeave:C,onDrop:A,children:n.jsx("div",{className:"muted",style:{padding:"8px 10px",fontSize:12},children:t("noDocumentsYet")})}):n.jsx("div",{ref:i,className:F,onClick:y=>{var w;y.target.closest(".mdocs-tree-row")||(w=e.onDeselect)==null||w.call(e)},onContextMenu:y=>{y.preventDefault(),e.onContextMenu({x:y.clientX,y:y.clientY,node:{type:"folder",name:"",path:"",documentId:"",children:e.nodes},parentPath:""})},onDragOver:v,onDragLeave:C,onDrop:A,children:e.nodes.map(y=>n.jsx(mn,{node:y,depth:0,parentPath:"",parentFolderId:null,activeDocumentId:e.activeDocumentId,selectedParentPath:e.selectedParentPath,forceOpenFolderIds:h,dropHighlight:r,setDropHighlight:s,clearDropHighlight:m,beginDragSession:k,endDragSession:g,draggingId:d,onOpen:e.onOpen,onOpenFolder:e.onOpenFolder,onContextMenu:e.onContextMenu,onMoveDocument:e.onMoveDocument},y.path))})}function mn(e){const t={paddingLeft:8+e.depth*16};return e.node.type==="folder"?n.jsx(si,{folder:e.node,depth:e.depth,indent:t,activeDocumentId:e.activeDocumentId,selectedParentPath:e.selectedParentPath,forceOpenFolderIds:e.forceOpenFolderIds,dropHighlight:e.dropHighlight,setDropHighlight:e.setDropHighlight,clearDropHighlight:e.clearDropHighlight,beginDragSession:e.beginDragSession,endDragSession:e.endDragSession,draggingId:e.draggingId,onOpen:e.onOpen,onOpenFolder:e.onOpenFolder,onContextMenu:e.onContextMenu,onMoveDocument:e.onMoveDocument}):n.jsx(ri,{doc:e.node,indent:t,parentPath:e.parentPath,parentFolderId:e.parentFolderId,activeDocumentId:e.activeDocumentId,dropHighlight:e.dropHighlight,setDropHighlight:e.setDropHighlight,clearDropHighlight:e.clearDropHighlight,beginDragSession:e.beginDragSession,endDragSession:e.endDragSession,draggingId:e.draggingId,onOpen:e.onOpen,onContextMenu:e.onContextMenu,onMoveDocument:e.onMoveDocument})}function ri(e){var h;const t=e.doc,i=t.documentId===e.activeDocumentId,r=!!e.onMoveDocument,s=e.draggingId===t.documentId,d=((h=e.dropHighlight)==null?void 0:h.kind)==="doc"&&e.dropHighlight.id===t.documentId,[l,f]=a.useState(!1);return n.jsxs("div",{role:"button",tabIndex:0,className:"mdocs-tree-row mdocs-tree-doc"+(i?" active":"")+(s?" mdocs-tree-dragging":"")+(d?" mdocs-tree-drop-target":""),"data-tree-id":t.documentId,style:{...e.indent,cursor:r?"grab":void 0},draggable:r,onDragStart:m=>{e.onMoveDocument&&(f(!0),e.beginDragSession(t.documentId),m.dataTransfer.setData(cn,t.documentId),m.dataTransfer.setData("text/plain",ft+t.documentId),m.dataTransfer.effectAllowed="move")},onDragEnd:()=>{e.endDragSession(),queueMicrotask(()=>f(!1))},onDragEnter:m=>{!ue(e.onMoveDocument)||ve===t.documentId||(m.preventDefault(),m.stopPropagation(),e.setDropHighlight({kind:"doc",id:t.documentId}))},onDragOver:m=>{!ue(e.onMoveDocument)||ve===t.documentId||(m.preventDefault(),m.stopPropagation(),m.dataTransfer.dropEffect="move",e.setDropHighlight({kind:"doc",id:t.documentId}))},onDrop:m=>{if(!e.onMoveDocument||!ue(e.onMoveDocument))return;m.preventDefault(),m.stopPropagation();const g=gt(m.dataTransfer),k=e.parentFolderId;e.endDragSession(),!(!g||g===t.documentId)&&e.onMoveDocument(g,k)},onClick:()=>{l||e.onOpen(t)},onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),e.onOpen(t))},onContextMenu:m=>{m.preventDefault(),m.stopPropagation(),e.onContextMenu({x:m.clientX,y:m.clientY,node:t,parentPath:e.parentPath})},children:[n.jsx("span",{className:"mdocs-tree-caret-spacer","aria-hidden":!0}),n.jsx("span",{className:"mdocs-tree-icon",children:"md"}),n.jsx("span",{className:"mdocs-tree-label",children:t.displayName||t.name})]})}function ai(){return n.jsx("span",{className:"mdocs-tree-icon mdocs-tree-icon-dir","aria-hidden":!0,children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M2 4.5h4.2L7.3 6H14v8.5H2V4.5z",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),n.jsx("path",{d:"M2 4.5V3h4l1.1 1.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]})})}function si(e){var g,k;const{t}=de(),i=e.forceOpenFolderIds.has(e.folder.documentId),[r,s]=a.useState(e.depth<1||i),d=r;a.useEffect(()=>{i&&s(!0)},[i,e.activeDocumentId]);const l=!!e.folder.descDocumentId&&e.folder.descDocumentId===e.activeDocumentId,f=e.selectedParentPath===e.folder.path,h=((g=e.dropHighlight)==null?void 0:g.kind)==="folder"&&e.dropHighlight.id===e.folder.documentId;function m(){e.onOpenFolder(e.folder.path,e.folder.descDocumentId)}return n.jsxs("div",{children:[n.jsxs("div",{className:"mdocs-tree-row mdocs-tree-folder mdocs-tree-folder-row"+(l?" active":f?" mdocs-tree-select-target":"")+(h?" mdocs-tree-drop-target":""),"data-tree-id":e.folder.documentId,style:e.indent,onClick:m,onContextMenu:v=>{v.preventDefault(),v.stopPropagation(),e.onContextMenu({x:v.clientX,y:v.clientY,node:e.folder,parentPath:e.folder.path})},onDragEnter:v=>{ue(e.onMoveDocument)&&(v.preventDefault(),v.stopPropagation(),e.setDropHighlight({kind:"folder",id:e.folder.documentId}),s(!0))},onDragOver:v=>{ue(e.onMoveDocument)&&(v.preventDefault(),v.stopPropagation(),v.dataTransfer.dropEffect="move",e.setDropHighlight({kind:"folder",id:e.folder.documentId}))},onDrop:v=>{if(!e.onMoveDocument||!ue(e.onMoveDocument))return;v.preventDefault(),v.stopPropagation();const C=gt(v.dataTransfer),A=e.folder.documentId;e.endDragSession(),C&&e.onMoveDocument(C,A)},children:[n.jsx("span",{className:"mdocs-tree-caret",role:"button",tabIndex:0,"aria-expanded":d,"aria-label":t(d?"collapseFolder":"expandFolder"),onClick:v=>{v.stopPropagation(),s(C=>!C),m()},onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),s(C=>!C),m())},children:d?"▾":"▸"}),n.jsx(ai,{}),n.jsx("span",{className:"mdocs-tree-folder-select",children:n.jsx("span",{className:"mdocs-tree-label",children:((k=e.folder.folderDisplayName)==null?void 0:k.trim())||e.folder.name})})]}),d&&e.folder.children.map(v=>n.jsx(mn,{node:v,depth:e.depth+1,parentPath:e.folder.path,parentFolderId:e.folder.documentId,activeDocumentId:e.activeDocumentId,selectedParentPath:e.selectedParentPath,forceOpenFolderIds:e.forceOpenFolderIds,dropHighlight:e.dropHighlight,setDropHighlight:e.setDropHighlight,clearDropHighlight:e.clearDropHighlight,beginDragSession:e.beginDragSession,endDragSession:e.endDragSession,draggingId:e.draggingId,onOpen:e.onOpen,onOpenFolder:e.onOpenFolder,onContextMenu:e.onContextMenu,onMoveDocument:e.onMoveDocument},v.path))]})}function di(e){var f;const{t}=de(),i=a.useRef(null);a.useEffect(()=>{function h(g){i.current&&!i.current.contains(g.target)&&e.onClose()}function m(g){g.key==="Escape"&&e.onClose()}return window.addEventListener("mousedown",h),window.addEventListener("keydown",m),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",m)}},[e.onClose]);const r=e.node.type==="folder";let s="";if(e.node.type==="folder"){const h=e.node;s=((f=h.folderDisplayName)==null?void 0:f.trim())||h.path||""}const d=r?s?t("newDocIn",{name:s}):t("newDocAtRoot"):t("newDocBeside"),l=r?s?t("newFolderIn",{name:s}):t("newFolderAtRoot"):t("newFolderBeside");return n.jsxs("div",{ref:i,className:"mdocs-context-menu card",style:{left:e.x,top:e.y},children:[n.jsx("button",{type:"button",className:"mdocs-context-item",onClick:()=>{const h=r?e.node.path:e.parentPath;e.onCreateChild(h),e.onClose()},children:d}),n.jsx("button",{type:"button",className:"mdocs-context-item",onClick:()=>{const h=r?e.node.path:e.parentPath;e.onCreateFolder(h),e.onClose()},children:l}),n.jsx("button",{type:"button",className:"mdocs-context-item danger",onClick:()=>{e.node.type==="document"?e.onDeleteDocument(e.node):e.onDeleteFolder(e.node),e.onClose()},children:e.node.type==="folder"?t("deleteFolder",{name:s||e.node.name}):t("deleteItem",{name:e.node.name})})]})}function ci({domains:e,value:t,onChange:i,ariaLabel:r,localizeName:s,onDomainsChange:d}){const[l,f]=a.useState(!1),[h,m]=a.useState(e),g=a.useRef(null),k=a.useRef(null);a.useEffect(()=>{m(e)},[e]);const v=h.find(y=>y.domainId===t),C=(v==null?void 0:v.permission)==="private";a.useEffect(()=>{if(!l)return;const y=I=>{var w,E;!((w=g.current)!=null&&w.contains(I.target))&&!((E=k.current)!=null&&E.contains(I.target))&&f(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[l]),a.useEffect(()=>{if(!l)return;const y=I=>{var w;I.key==="Escape"&&(f(!1),(w=g.current)==null||w.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[l]);function A(y){i(y),f(!1)}function F(){if(l){f(!1);return}f(!0),dn().then(y=>{m(y),d==null||d(y)})}return n.jsxs("div",{className:"mdocs-domain-select-wrapper",children:[n.jsxs("button",{ref:g,type:"button",className:"mdocs-domain-select-trigger","aria-label":r,"aria-expanded":l,"aria-haspopup":"listbox",onClick:F,children:[n.jsx("span",{className:"mdocs-domain-select-text",children:v?s(v.domainName):""}),C&&n.jsxs("svg",{className:"mdocs-domain-lock",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--mdocs-text-muted)",strokeWidth:"2",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),n.jsx("svg",{className:"mdocs-domain-select-chevron"+(l?" open":""),width:"10",height:"6",viewBox:"0 0 10 6",fill:"none",stroke:"var(--mdocs-text-muted)",strokeWidth:"1.5",children:n.jsx("path",{d:"M1 1l4 4 4-4"})})]}),l&&n.jsx("div",{ref:k,className:"mdocs-domain-select-menu card",role:"listbox","aria-label":r,children:h.map(y=>n.jsxs("button",{type:"button",className:"mdocs-domain-select-option"+(y.domainId===t?" active":""),role:"option","aria-selected":y.domainId===t,onClick:()=>A(y.domainId),children:[n.jsx("span",{children:s(y.domainName)}),y.permission==="private"&&n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--mdocs-text-muted)",strokeWidth:"2",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})]},y.domainId))})]})}const un="data:image/svg+xml,%3csvg%20fill='%234D6BFE'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDeepSeek%3c/title%3e%3cpath%20d='M23.748%204.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434%201.202-.422%201.84.027%201.436.633%202.58%201.838%203.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526%205.526%200%2001-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365%2011.365%200%2000-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055%203.055%200%2001-.465.137%209.597%209.597%200%2000-2.883-.102c-1.885.21-3.39%201.102-4.497%202.623C.082%208.606-.231%2010.684.152%2012.85c.403%202.284%201.569%204.175%203.36%205.653%201.858%201.533%203.997%202.284%206.438%202.14%201.482-.085%203.133-.284%204.994-1.86.47.234.962.327%201.78.397.63.059%201.236-.03%201.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926%201.096-1.296%202.746-2.642%203.392-7.003.05-.347.007-.565%200-.845-.004-.17.035-.237.23-.256a4.173%204.173%200%20001.545-.475c1.396-.763%201.96-2.015%202.093-3.517.02-.23-.004-.467-.247-.588zM11.581%2018c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696%204.696%200%20011.529-.039c2.132.312%203.946%201.265%205.468%202.774.868.86%201.525%201.887%202.202%202.891.72%201.066%201.494%202.082%202.48%202.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306%200%2001.415-.287.302.302%200%2001.2.288.306.306%200%2001-.31.307.303.303%200%2001-.304-.308zm3.11%201.596c-.2.081-.399.151-.59.16a1.245%201.245%200%2001-.798-.254c-.274-.23-.47-.358-.552-.758a1.73%201.73%200%2001.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559%200%2001-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136%201.146.016.352.144.618.408%201.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z'%3e%3c/path%3e%3c/svg%3e",ae={left:12,bottom:64},yt="mdocs.agentFabPosition",Ye=36,Yt=3;function vt(e){const i=Math.max(8,window.innerWidth-Ye-8),r=Math.max(8,window.innerHeight-Ye-8);return{left:Math.min(i,Math.max(8,e.left)),bottom:Math.min(r,Math.max(8,e.bottom))}}function li(e,t,i,r){const s=e-i,d=t-r,l=window.innerHeight-d-Ye;return vt({left:s,bottom:l})}function mi(){try{const e=localStorage.getItem(yt);if(!e)return ae;const t=JSON.parse(e);return typeof t.left!="number"||typeof t.bottom!="number"?ae:vt({left:t.left,bottom:t.bottom})}catch{return ae}}function Kt(e){localStorage.setItem(yt,JSON.stringify(e))}function ui(e){return e.left===ae.left&&e.bottom===ae.bottom}function fi(e){const i=Math.min(480,window.innerWidth-72);let r=e.left+Ye+8;r+i>window.innerWidth-8&&(r=e.left-8-i),r=Math.max(8,r);const s=Math.max(8,e.bottom-8);return{left:r,bottom:s}}function pi(e){const{t}=de(),[i,r]=a.useState(!1),[s,d]=a.useState(e.position),l=a.useRef(null),f=a.useRef(null),h=a.useRef(s),m=a.useRef(e.onPositionChange),g=a.useRef(e.onToggle);h.current=s,m.current=e.onPositionChange,g.current=e.onToggle;const k=a.useRef(null),v=a.useRef(0),C=a.useRef(null);a.useEffect(()=>{k.current||(d(e.position),h.current=e.position)},[e.position]),a.useEffect(()=>{function I(){const w=vt(h.current);w.left===h.current.left&&w.bottom===h.current.bottom||(h.current=w,d(w),m.current(w),Kt(w))}return window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[]),a.useEffect(()=>{function I(){v.current=0;const P=C.current;if(!P)return;C.current=null,h.current=P,d(P);const T=f.current;T&&(T.style.left=`${P.left}px`,T.style.bottom=`${P.bottom}px`),m.current(P)}function w(P){const T=k.current;if(!T||P.pointerId!==T.pointerId)return;P.preventDefault();const B=P.clientX-T.startX,_=P.clientY-T.startY;!T.didMove&&B*B+_*_>=Yt*Yt&&(T.didMove=!0,r(!0)),T.didMove&&(C.current=li(P.clientX,P.clientY,T.offsetX,T.offsetY),v.current||(v.current=requestAnimationFrame(I)))}function E(P){var B;const T=k.current;if(!(!T||P.pointerId!==T.pointerId)){k.current=null,r(!1),v.current&&(cancelAnimationFrame(v.current),v.current=0),C.current&&(h.current=C.current,d(C.current),C.current=null);try{(B=l.current)==null||B.releasePointerCapture(P.pointerId)}catch{}if(T.didMove){const _=h.current;m.current(_),Kt(_);return}g.current()}}return window.addEventListener("pointermove",w,{passive:!1}),window.addEventListener("pointerup",E),window.addEventListener("pointercancel",E),()=>{window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",E),window.removeEventListener("pointercancel",E),v.current&&cancelAnimationFrame(v.current)}},[]);function A(I){if(I.button!==0)return;I.preventDefault();const w=I.currentTarget.getBoundingClientRect();k.current={pointerId:I.pointerId,offsetX:I.clientX-w.left,offsetY:I.clientY-w.top,startX:I.clientX,startY:I.clientY,didMove:!1},I.currentTarget.setPointerCapture(I.pointerId)}function F(){h.current=ae,d(ae),e.onPositionChange(ae),localStorage.removeItem(yt)}const y=!ui(s);return n.jsxs("div",{ref:f,className:"mdocs-agent-fab-wrap"+(i?" dragging":""),style:{left:s.left,bottom:s.bottom},children:[n.jsx("button",{ref:l,type:"button",className:"mdocs-agent-fab"+(e.open?" open":"")+(i?" dragging":""),"aria-label":t("agentFabOpen"),"aria-expanded":e.open,onPointerDown:A,children:n.jsx("img",{src:un,alt:"",draggable:!1})}),y&&n.jsx("button",{type:"button",className:"mdocs-agent-fab-reset",onClick:F,"aria-label":t("agentFabReset"),children:t("agentFabReset")})]})}function hi(){const[e,t]=a.useState(()=>typeof window>"u"?ae:mi());return[e,t]}function gi({title:e,message:t,onClose:i}){const{t:r}=de();return n.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:s=>{s.target===s.currentTarget&&i()},children:n.jsxs("div",{className:"mdocs-dialog card mdocs-message-dialog",role:"alertdialog","aria-modal":"true",children:[e&&n.jsx("h2",{className:"mdocs-message-dialog-title",children:e}),n.jsx("p",{className:"mdocs-message-dialog-body",children:t}),n.jsx("div",{className:"mdocs-message-dialog-actions",children:n.jsx("button",{type:"button",className:"primary",onClick:i,children:r("gotIt")})})]})})}function fn({title:e,message:t,confirmLabel:i="确定",cancelLabel:r="取消",onConfirm:s,onCancel:d,busy:l=!1,danger:f=!1}){return n.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:h=>{h.target===h.currentTarget&&!l&&d()},children:n.jsxs("div",{className:"mdocs-dialog card mdocs-message-dialog",role:"alertdialog","aria-modal":"true",children:[e&&n.jsx("h2",{className:"mdocs-message-dialog-title",children:e}),n.jsx("p",{className:"mdocs-message-dialog-body",children:t}),n.jsxs("div",{className:"mdocs-message-dialog-actions",style:{gap:8},children:[n.jsx("button",{type:"button",onClick:d,disabled:l,children:r}),n.jsx("button",{type:"button",className:f?"danger":"primary",onClick:s,disabled:l,children:l?"…":i})]})]})})}const Xt={"relative path is required":"pathRequired","path must be relative":"pathMustBeRelative","use forward slashes":"useForwardSlashes","path must not contain ..":"pathNoDotDot","document path must end with .md":"pathMustEndWithMd","path contains unsupported characters":"pathUnsupportedChars","path escapes docs root":"pathEscapesRoot"},pn={"enter a folder name":"enterFolderName","use a single name, not a path":"singleNameNotPath","invalid folder name":"invalidFolderName","folder name is too long":"folderNameTooLong","enter a file name":"enterFileName","use a file name, not a path":"singleFileNameNotPath","invalid file name":"invalidFileName","file name is too long":"fileNameTooLong"};function me(e,t){if(t instanceof oe)return t.message;if(t instanceof le){const i=Xt[t.message];return i?e(i):t.message}if(t instanceof Error){const i=Xt[t.message]??pn[t.message];return i?e(i):t.message}return String(t)}function yi(e,t,i){if(e==="Default")return i("defaultDomain");const r="个人域";return e.endsWith(r)?e.slice(0,-r.length)+i("personalDomainSuffix"):e}function Wr(e,t){return e==="public"?t("domainPublic"):e==="restricted"?t("domainRestricted"):e==="private"?t("domainPrivate"):e}function qe(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function vi(e){return JSON.stringify({root:{children:[{children:[{detail:0,format:0,mode:"normal",text:e,type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"heading",tag:"h1",version:1}],direction:"ltr",type:"root",version:1}})}function Qt(e,t){const i=e.trim(),r=t.trim();return r?i?`${i}/${r}`:r:i}function hn(e,t=new Set){for(const i of e)i.type==="document"?t.add(i.path):(i.descDocumentId&&t.add(To(i.path)),hn(i.children,t));return t}function pt(e,t){for(const i of e){if(i.type==="folder"&&i.path===t)return i.documentId;if(i.type==="folder"){const r=pt(i.children,t);if(r)return r}}return null}function Zt(e,t){const i=pn[t];return i?e(i):t}function bi(e){const{tree:t,currentDomainId:i,selectedCreateParentPath:r,t:s,onDocCreated:d,refreshTree:l}=e,[f,h]=a.useState(null),[m,g]=a.useState(null),[k,v]=a.useState(!1),C=a.useRef(null);a.useEffect(()=>{if(!f)return;const I=window.setTimeout(()=>{var w;return(w=C.current)==null?void 0:w.focus()},0);return()=>window.clearTimeout(I)},[f]);function A(I){const w=I!==void 0;g(null),h({kind:"document",parentMode:w?"fixed":"selection",parentPath:w?I:"",draft:"untitled.md"})}function F(I){const w=I!==void 0;g(null),h({kind:"folder",parentMode:w?"fixed":"selection",parentPath:w?I:"",draft:""})}async function y(I){if(I.preventDefault(),!f)return;v(!0),g(null);const w=hn(t),E=f.parentMode==="selection"?r:f.parentPath;try{if(f.kind==="document"){const H=Mo(f.draft);if(!H.ok){g(Zt(s,H.message));return}const J=H.displayFile,R=J.replace(/\.md$/i,"");let u;try{u=Ro(Qt(E,J))}catch(O){g(me(s,O));return}if(w.has(u)){g(s("pathExists"));return}const N=E?pt(t,E)??void 0:void 0,M=await sn({fileName:J,displayName:R,content:vi(R),domainId:i,parentId:N});await l(),d(M),h(null);return}const P=jo(f.draft);if(!P.ok){g(Zt(s,P.message));return}const T=mt(P.display);if(!T){g(s("invalidFolderName"));return}const B=Qt(E,T);if(w.has(B)){g(s("folderExists"));return}const _=E?pt(t,E)??void 0:void 0;await Go({name:T,parentId:_,domainId:i}),await l(),h(null)}catch(P){g(me(s,P))}finally{v(!1)}}return{createModal:f,setCreateModal:h,createModalError:m,createModalBusy:k,createModalInputRef:C,openNewDocumentModal:A,openNewFolderModal:F,submitCreateModal:y}}function wi({open:e,onClose:t,onResolve:i}){const{t:r}=de();return e?n.jsx("div",{className:"mdocs-conflict-modal-root",role:"alertdialog","aria-modal":"true",children:n.jsxs("div",{className:"mdocs-conflict-modal-panel",children:[n.jsx("h2",{className:"mdocs-conflict-modal-title",children:r("conflictTitle")}),n.jsx("p",{className:"mdocs-conflict-modal-body",children:r("conflictBody")}),n.jsxs("div",{className:"mdocs-conflict-modal-actions",children:[n.jsx("button",{type:"button",className:"primary",onClick:i,children:r("conflictResolve")}),n.jsx("button",{type:"button",className:"secondary",onClick:t,children:r("conflictClose")})]})]})}):null}function xi({documentId:e,visitorId:t,visitorName:i,documentOwnerId:r,onClose:s}){const[d,l]=a.useState([]),[f,h]=a.useState(""),[m,g]=a.useState(null),[k,v]=a.useState(!0),[C,A]=a.useState(!1),[F,y]=a.useState(null),[I,w]=a.useState(null),[E,P]=a.useState(360),[T,B]=a.useState(80),_=a.useRef(!1),H=a.useRef(!1),J=300,R=80,u=a.useRef(null);function N(){const D=u.current;if(!D)return;D.style.height="auto";const S=D.scrollHeight,z=Math.min(Math.max(S,R),J);D.style.height=`${z}px`,B(z)}a.useEffect(()=>{setTimeout(()=>N(),0)},[m]);function M(D){return t?D.visitorId===t||r===t:!1}const{rootComments:O,repliesByParentId:Y,totalCount:Ke}=a.useMemo(()=>{const D=[],S=new Map;let z=0;for(const $ of d)$.isDeleted||(z++,$.parentId?(S.has($.parentId)||S.set($.parentId,[]),S.get($.parentId).push($)):D.push($));return{rootComments:D,repliesByParentId:S,totalCount:z}},[d]),ie=a.useRef(e);a.useEffect(()=>{ie.current=e,h(""),g(null),w(null),ce()},[e]);async function ce(){const D=ie.current;v(!0);try{const S=await Xo(e);if(ie.current!==D)return;l(S.comments)}catch(S){if(ie.current!==D)return;w("加载评论失败"),console.error("Failed to load comments:",S)}finally{ie.current===D&&v(!1)}}async function fe(){var D;if(!(!f.trim()||!t)){A(!0),w(null);try{await Qo(e,{content:f,parentId:(m==null?void 0:m.commentId)||null,replyToVisitorId:m?((D=d.find(S=>S.commentId===m.commentId))==null?void 0:D.visitorId)??null:null,replyToVisitorName:(m==null?void 0:m.visitorName)||null}),h(""),g(null),setTimeout(()=>N(),0),await ce()}catch(S){w(S.message||"发表失败,请重试")}finally{A(!1)}}}async function Xe(D){w(null);try{await Zo(e,D),await ce()}catch(S){w(S.message||"删除失败,请重试")}finally{y(null)}}function re(D){const S=Date.now()-new Date(D).getTime(),z=Math.floor(S/6e4),$=Math.floor(S/36e5),he=Math.floor(S/864e5);return z<1?"刚刚":z<60?`${z}分钟前`:$<24?`${$}小时前`:`${he}天前`}function Se(D){_.current=!0,D.preventDefault()}function pe(D){H.current=!0,D.preventDefault(),document.body.style.userSelect="none",document.body.style.cursor="row-resize"}return a.useEffect(()=>{function D(z){if(_.current){const $=Math.max(280,Math.min(600,window.innerWidth-z.clientX));P($)}if(H.current){const $=-z.movementY;B(he=>Math.max(60,Math.min(600,he+$)))}}function S(){_.current=!1,H.current=!1,document.body.style.userSelect="",document.body.style.cursor=""}return window.addEventListener("mousemove",D),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",D),window.removeEventListener("mouseup",S)}},[]),n.jsxs("div",{className:"mdocs-comments-panel",style:{width:E},children:[n.jsx("div",{className:"mdocs-comments-resize-handle",onMouseDown:Se}),n.jsxs("div",{className:"mdocs-comments-header",children:[n.jsxs("h3",{style:{margin:0,fontSize:"1rem",display:"flex",alignItems:"center",gap:6},children:[n.jsx(po,{size:18}),"评论 (",Ke,")"]}),n.jsx("button",{type:"button",onClick:s,className:"mdocs-comments-close-btn",children:n.jsx(Ee,{size:18})})]}),I&&n.jsxs("div",{className:"mdocs-comments-error",children:[I,n.jsx("button",{type:"button",onClick:()=>w(null),children:n.jsx(Ee,{size:14})})]}),n.jsx("div",{className:"mdocs-comments-list",children:k?n.jsx("div",{className:"mdocs-comments-empty",children:"加载中..."}):O.length===0?n.jsx("div",{className:"mdocs-comments-empty",children:"暂无评论,来发表第一条吧~"}):O.map(D=>n.jsxs("div",{className:"mdocs-comment-root",children:[n.jsxs("div",{className:"mdocs-comment-header",children:[n.jsx("span",{className:"mdocs-comment-avatar",children:D.visitorName.charAt(0).toUpperCase()}),n.jsx("span",{className:"mdocs-comment-author",children:D.visitorName}),n.jsx("span",{className:"mdocs-comment-time",children:re(D.createdAt)}),M(D)&&n.jsx("button",{type:"button",className:"mdocs-comment-delete",onClick:()=>y(D.commentId),title:"删除",children:n.jsx(Ee,{size:14})})]}),n.jsx("div",{className:"mdocs-comment-content",children:D.content}),t&&n.jsx("button",{type:"button",className:"mdocs-comment-reply-btn",onClick:()=>g({commentId:D.commentId,visitorName:D.visitorName}),children:"回复"}),(Y.get(D.commentId)??[]).length>0&&n.jsx("div",{className:"mdocs-comment-replies",children:(Y.get(D.commentId)??[]).map(S=>n.jsxs("div",{className:"mdocs-comment-reply",children:[n.jsxs("div",{className:"mdocs-comment-header",children:[n.jsx("span",{className:"mdocs-comment-avatar mdocs-comment-avatar-small",children:S.visitorName.charAt(0).toUpperCase()}),n.jsx("span",{className:"mdocs-comment-author",children:S.visitorName}),S.replyToVisitorName&&n.jsxs("span",{className:"mdocs-comment-reply-to",children:["回复 ",S.replyToVisitorName]}),n.jsx("span",{className:"mdocs-comment-time",children:re(S.createdAt)}),M(S)&&n.jsx("button",{type:"button",className:"mdocs-comment-delete",onClick:()=>y(S.commentId),title:"删除",children:n.jsx(Ee,{size:12})})]}),n.jsx("div",{className:"mdocs-comment-content",children:S.content}),t&&n.jsx("button",{type:"button",className:"mdocs-comment-reply-btn",onClick:()=>g({commentId:D.commentId,visitorName:S.visitorName}),children:"回复"})]},S.commentId))})]},D.commentId))}),t?n.jsxs("div",{className:"mdocs-comments-input-wrapper",children:[n.jsx("div",{className:"mdocs-comments-input-drag-handle",onMouseDown:pe}),m&&n.jsxs("div",{className:"mdocs-comment-reply-notice",children:[n.jsxs("span",{children:["回复 ",n.jsx("span",{className:"mdocs-comment-reply-to-name",children:m.visitorName})]}),n.jsxs("button",{type:"button",onClick:()=>g(null),children:[n.jsx(Ee,{size:14})," 取消"]})]}),n.jsx("textarea",{ref:u,value:f,onChange:D=>{h(D.target.value.slice(0,512)),setTimeout(()=>N(),0)},placeholder:m?`回复 ${m.visitorName}...`:"发表评论...",className:"mdocs-comments-input",style:{height:T},maxLength:512,onKeyDown:D=>{D.key==="Enter"&&(D.metaKey||D.ctrlKey)&&fe()}}),n.jsxs("div",{className:`mdocs-comments-char-count${f.length>=460?" mdocs-char-count--warn":""}`,children:[f.length,"/512"]}),n.jsx("div",{className:"mdocs-comments-input-actions",children:n.jsx("button",{type:"button",className:"mdocs-btn-primary",onClick:fe,disabled:C||!f.trim(),children:C?"发表中...":"发表"})})]}):n.jsx("div",{className:"mdocs-comments-input-wrapper",style:{textAlign:"center"},children:n.jsx("div",{style:{color:"#666",fontSize:"0.9rem"},children:"请先创建访客身份以发表评论"})}),F&&n.jsx(fn,{title:"删除评论",message:"确定要删除这条评论吗?",confirmLabel:"删除",danger:!0,onConfirm:()=>Xe(F),onCancel:()=>y(null)})]})}const Ii="mdocs-drafts",Di=4,W="drafts",De={DOC_NOT_FOUND:"DOC_NOT_FOUND",SYNC_HEAD_MISSING:"SYNC_HEAD_MISSING"};let at=null;function ke(){return at||(at=new Promise((e,t)=>{const i=indexedDB.open(Ii,Di);i.onupgradeneeded=r=>{const s=i.result;s.objectStoreNames.contains(W)||s.createObjectStore(W,{keyPath:"documentId"});const d=r.oldVersion;if(d>0&&d<4){const h=i.transaction.objectStore(W).openCursor();h.onsuccess=()=>{const m=h.result;if(!m)return;const g=m.value;typeof g.baseCommitId=="string"&&!g.localBaseCommitId&&(g.localBaseCommitId=g.baseCommitId,delete g.baseCommitId);const k=g.conflict;k&&(typeof k.baseCommitId=="string"&&!k.localBaseCommitId&&(k.localBaseCommitId=k.baseCommitId,delete k.baseCommitId),typeof k.expectedHeadCommitId=="string"&&!k.remoteCommitId&&(k.remoteCommitId=k.expectedHeadCommitId,delete k.expectedHeadCommitId)),m.update(g),m.continue()}}},i.onsuccess=()=>e(i.result),i.onerror=()=>t(i.error)})),at}async function Ci(e){var r;const t=await G(e.documentId),i={documentId:e.documentId,content:e.content,displayName:e.displayName,updatedAt:Date.now(),published:!1};if(t!=null&&t.localBaseCommitId)i.localBaseCommitId=t.localBaseCommitId;else{const s=(r=e.localBaseCommitIdAtEditStart)==null?void 0:r.trim();s&&(i.localBaseCommitId=s)}(t==null?void 0:t.permission)!=null?i.permission=t.permission:e.snapshotMeta&&(i.permission=e.snapshotMeta.permission),t!=null&&t.ownerVisitorId?i.ownerVisitorId=t.ownerVisitorId:e.snapshotMeta&&(i.ownerVisitorId=e.snapshotMeta.ownerVisitorId),t!=null&&t.domainId?i.domainId=t.domainId:e.snapshotMeta&&(i.domainId=e.snapshotMeta.domainId),t!=null&&t.publishError&&(i.publishError=t.publishError,i.publishErrorAt=t.publishErrorAt),t!=null&&t.conflictStatus&&(i.conflictStatus=t.conflictStatus),t!=null&&t.conflict&&(i.conflict=t.conflict),await ye(i)}function bt(e){const t={documentId:e.documentId,content:e.content,displayName:e.displayName,updatedAt:e.updatedAt,published:e.published};return e.permission!=null&&(t.permission=e.permission),e.ownerVisitorId&&(t.ownerVisitorId=e.ownerVisitorId),e.domainId&&(t.domainId=e.domainId),e.publishError!=null&&(t.publishError=e.publishError),e.publishErrorAt!=null&&(t.publishErrorAt=e.publishErrorAt),e.localBaseCommitId&&(t.localBaseCommitId=e.localBaseCommitId),e.conflictStatus!=null&&(t.conflictStatus=e.conflictStatus),e.conflict!=null&&(t.conflict=e.conflict),t}async function ye(e){const t=await ke(),i=bt(e);return new Promise((r,s)=>{const d=t.transaction(W,"readwrite");d.objectStore(W).put(i),d.oncomplete=()=>r(),d.onerror=()=>s(d.error)})}async function G(e){const t=await ke();return new Promise((i,r)=>{const d=t.transaction(W,"readonly").objectStore(W).get(e);d.onsuccess=()=>i(d.result),d.onerror=()=>r(d.error)})}async function st(e){const t=await ke();return new Promise((i,r)=>{const s=t.transaction(W,"readwrite");s.objectStore(W).delete(e),s.oncomplete=()=>i(),s.onerror=()=>r(s.error)})}async function ki(e){const t=await ke();return new Promise((i,r)=>{const d=t.transaction(W,"readonly").objectStore(W).getAll();d.onsuccess=()=>{let l=d.result;e!=null&&e.skipFailed&&(l=l.filter(f=>!f.publishError)),i(l)},d.onerror=()=>r(d.error)})}async function Si(e,t){const i=await ke();return new Promise((r,s)=>{const l=i.transaction(W,"readwrite").objectStore(W),f=l.get(e);f.onsuccess=()=>{const h=f.result;h&&l.put(bt({...h,publishError:t,publishErrorAt:Date.now()})),r()},f.onerror=()=>s(f.error)})}async function dt(e){const t=await ke();return new Promise((i,r)=>{const d=t.transaction(W,"readwrite").objectStore(W),l=d.get(e);l.onsuccess=()=>{const f=l.result;f&&d.put(bt({...f,publishError:void 0,publishErrorAt:void 0})),i()},l.onerror=()=>r(l.error)})}async function en(e,t){const i=await G(e);i&&await ye({...i,localBaseCommitId:t.localBaseCommitId,conflictStatus:t.conflictStatus,conflict:t.conflict})}async function ct(e){const t=await G(e);t&&await ye({...t,conflict:void 0,conflictStatus:"none"})}class Re extends Error{constructor(i,r){super(i);Ie(this,"code");Ie(this,"cause");this.name="DraftPublishAborted",this.code=i,this.cause=r==null?void 0:r.cause}}function Ni(e){return e instanceof Re?e.code:e instanceof oe?e.status===404?De.DOC_NOT_FOUND:e.code||`HTTP_${e.status}`:e instanceof Error&&e.message.trim()?e.message.trim().slice(0,120):"UNKNOWN"}function Pi(e,t,i,r){const s=(t==null?void 0:t.displayName)||e("unknownTitle");if(i===De.SYNC_HEAD_MISSING)return e("draftPublishFailedSyncHead",{name:s});if(i===De.DOC_NOT_FOUND)return e("draftPublishFailedNotice",{name:s});const d=r instanceof oe||r instanceof Error&&r.message?r.message:i;return e("draftPublishFailedGeneric",{name:s,reason:d})}async function Ti(e,t,i){const r=Ni(t);throw await Si(e,r),t instanceof Re?t:new Re(r,{cause:t})}function Ai(e,t){const i=a.useRef(t);i.current=t,a.useEffect(()=>{if(!e)return;const r=3e4,s=1e4,d=async()=>{const f=await ki({skipFailed:!0}),h=Date.now();for(const m of f)if(!m.published&&!(h-m.updatedAt<r))try{await i.current(m.documentId)}catch(g){console.log("[autoPublish] scan publish failed:",g)}};d();const l=setInterval(d,s);return()=>clearInterval(l)},[e])}const Ei=1e4;function ji(e,t){const[i,r]=a.useState(null),[s,d]=a.useState("up_to_date");return a.useEffect(()=>{if(!e){r(null),d("up_to_date");return}let f=!1;const h=e;async function m(){try{const k=await Wo(h,t??void 0);if(f)return;r(k.headCommitId),d(k.status)}catch{}}m();const g=window.setInterval(()=>void m(),Ei);return()=>{f=!0,window.clearInterval(g)}},[e,t]),{remoteCommitId:i,syncStatus:s,syncBehind:!!(t&&i&&t!==i)||s==="behind"}}const Mi="/assets/mdocs-logo-Dsv_2t6v.svg",Ri=a.lazy(()=>Ce(()=>import("./DocumentEditor-DtSzkl6A.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(e=>({default:e.DocumentEditor}))),Oi=a.lazy(()=>Ce(()=>import("./SettingsPage-CkYpe5v7.js"),__vite__mapDeps([11,1,10,2,3])).then(e=>({default:e.SettingsPage}))),Li=a.lazy(()=>Ce(()=>import("./AgentChatPanel-D95hI02c.js"),__vite__mapDeps([12,1,13,7,2,3,8])).then(e=>({default:e.AgentChatPanel}))),Fi=a.lazy(()=>Ce(()=>import("./AiWriteWorkbench-Qam8cfY6.js"),__vite__mapDeps([14,1,13,7,2,3])).then(e=>({default:e.AiWriteWorkbench}))),_i=a.lazy(()=>Ce(()=>import("./MergeView-DgFQHD5_.js"),__vite__mapDeps([15,1,4,5,2,3,6,7,8])).then(e=>({default:e.MergeView})));function Bi(e,t){try{const i=new Intl.RelativeTimeFormat(t,{numeric:"auto"}),r=Date.now()-new Date(e).getTime(),s=Math.floor(r/6e4),d=Math.floor(s/60),l=Math.floor(d/24);return l>30?i.format(-Math.floor(l/30),"month"):l>0?i.format(-l,"day"):d>0?i.format(-d,"hour"):s>0?i.format(-s,"minute"):i.format(-Math.floor(r/1e3),"second")}catch{return e.slice(0,10)}}async function lt(e,t,i,r){const s=await dn();t(s);const d=localStorage.getItem("mdocs.currentDomainId"),f=d&&s.some(h=>h.domainId===d)?d:ti(s,e);i(f),await r(f)}function tn(){const{t:e,lang:t,setLang:i}=de(),[r,s]=a.useState("loading"),[d,l]=a.useState(()=>localStorage.getItem("mdocs.sidebarCollapsed")==="true"),f=()=>{const o=!d;l(o),localStorage.setItem("mdocs.sidebarCollapsed",String(o))},[h,m]=a.useState(!1),[g,k]=a.useState(0),v=a.useRef(null),[C,A]=a.useState(null),[F,y]=a.useState(null),[I,w]=a.useState(null),[E,P]=a.useState([]),[T,B]=a.useState([]),[_,H]=a.useState("default"),{documentId:J}=qn(),R=Gn(),[u,N]=a.useState(null),[M,O]=a.useState(null),Y=a.useRef(M);Y.current=M;const[Ke,ie]=a.useState(0),[ce,fe]=a.useState(null),[Xe,re]=a.useState(!1),[Se,pe]=a.useState(!1),[D,S]=a.useState(!1),z=(u==null?void 0:u.documentId)??null,{syncBehind:$,remoteCommitId:he}=ji(z,ce),[wt,Qe]=a.useState(null);a.useEffect(()=>{if(!Se||!u){Qe(null);return}(async()=>{const o=await G(u.documentId);if(o!=null&&o.conflict){Qe(o.conflict);return}if(o&&ce&&he){const p=o.localBaseCommitId??ce;if(!p)return;const c={localBaseCommitId:p,remoteCommitId:he,localSnapshotContent:o.content};await en(u.documentId,{localBaseCommitId:c.localBaseCommitId,conflictStatus:"diverged",conflict:c}),Qe(c)}})()},[Se,u,ce,he]),a.useEffect(()=>{!u||!$||!D||G(u.documentId).then(async o=>{!o||o.conflict||o.conflictStatus==="publish_conflict"||o.conflictStatus!=="diverged"&&await ye({...o,conflictStatus:"diverged"})})},[u==null?void 0:u.documentId,$,D]),a.useEffect(()=>{if(!u){fe(null);return}let o=!1;return G(u.documentId).then(p=>{o||(p&&!p.published&&p.localBaseCommitId?fe(p.localBaseCommitId):fe(u.headCommitId??null))}),()=>{o=!0}},[u==null?void 0:u.documentId,u==null?void 0:u.headCommitId,D]);const[Ne,U]=a.useState(null),[xt,K]=a.useState(null),[q,Oe]=a.useState(null),[Pe,It]=a.useState(null),[Dt,X]=a.useState(""),[yn,Le]=a.useState("docs"),[Fe,be]=a.useState(!1),[Ct,vn]=hi(),kt=a.useRef(null),[bn,_e]=a.useState(!1),[Be,$e]=a.useState(null),Q=a.useRef(void 0),He=a.useRef(void 0);Ai(localStorage.getItem("mdocs.autoPublish")==="true",Rt);async function Z(o){var p;await((p=Q.current)==null?void 0:p.call(Q)),o()}function wn(o){const c=(o.trim()||"untitled").replace(/[\\/:*?"<>|]/g,"-").slice(0,80);return c.endsWith(".md")?c:`${c}.md`}async function xn(){var p,c;if(!u||!M)return;await((p=Q.current)==null?void 0:p.call(Q));let o=((c=He.current)==null?void 0:c.call(He))??"";if(!o.trim())try{o=(await rt({content:M.content,from:"lexical",to:"markdown"})).content}catch{o=""}$e({markdown:o,documentId:u.documentId,displayName:M.displayName||u.displayName||"未命名"}),_e(!0),be(!1)}function In(){$e({markdown:"",documentId:null,displayName:"未命名"}),_e(!0),be(!1)}async function Dn(o){var j,L;const p=o.documentId.trim();if(!p)return;await((j=Q.current)==null?void 0:j.call(Q));let c="",x=o.displayName.trim()||"未命名";try{const ee=await Me(p);x=((L=ee.displayName)==null?void 0:L.trim())||x;try{c=(await rt({content:ee.content,from:"lexical",to:"markdown"})).content}catch{c=""}}catch{}$e({markdown:c,documentId:p,displayName:x}),_e(!0),be(!1),Le("docs"),Z(()=>R(`/doc/${p}`))}async function Cn(o){(u==null?void 0:u.documentId)===o.documentId&&await Mt()}async function kn(o){if(o.documentId){if(!window.confirm("将把帮写结果写入当前文档的本地草稿(不会自动发布)。继续?")){const L=new Error("cancelled");throw L.silent=!0,L}const x=await rt({content:o.markdown,from:"markdown",to:"lexical"}),j=(u==null?void 0:u.documentId)===o.documentId?u:null;return await Ci({documentId:o.documentId,content:x.content,displayName:o.displayName,localBaseCommitIdAtEditStart:(j==null?void 0:j.headCommitId)??null,snapshotMeta:j?{permission:j.permission,ownerVisitorId:j.ownerVisitorId,domainId:j.domainId}:void 0}),(u==null?void 0:u.documentId)===o.documentId?(O({documentId:o.documentId,content:x.content,displayName:o.displayName}),ie(L=>L+1),S(!0)):await Te(o.documentId),U("帮写已写入草稿,可在编辑器中继续修改后发布"),{documentId:o.documentId}}const p=await sn({fileName:wn(o.displayName),displayName:o.displayName,content:o.markdown,contentFormat:"markdown",domainId:_||void 0,parentId:void 0});return await V(),await Te(p.documentId),U("已创建文档"),{documentId:p.documentId}}a.useEffect(()=>{Sn()},[]),a.useEffect(()=>{if(!Ne)return;const o=()=>{U(null)};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[Ne]),a.useEffect(()=>{const o=p=>{var j,L;const c=p;if(((j=c.detail)==null?void 0:j.status)===409)return;const x=(L=c.detail)==null?void 0:L.message;x&&K(x)};return window.addEventListener(ut,o),()=>window.removeEventListener(ut,o)},[]);async function Sn(){try{const o=await Gt();A(o),Ge(o.visitorId),await lt(o.visitorId,B,H,V),s("ready")}catch(o){if(o instanceof oe&&o.status===401){s("needsRegister");return}K(me(e,o)),s("needsRegister")}}async function Nn(o,p){const c=await Bo(o,p);A(c.visitor),y(c.visitor.visitorId),w(c.recoveryCode),Ge(c.visitor.visitorId),await lt(c.visitor.visitorId,B,H,V),s("ready")}async function Pn(o){const p=await Gt();A(p),await lt(p.visitorId,B,H,V),s("ready")}async function V(o){const c=await Vo(o??_);P(c)}function Ue(o){O({documentId:o.documentId,content:o.content,displayName:o.displayName}),ie(p=>p+1),S(!1)}function Tn(o,p){O({documentId:o,content:p.content,displayName:p.displayName}),ie(c=>c+1),S(!0)}async function St(o,p){await st(o);const c=await Me(o);if((u==null?void 0:u.documentId)===o&&v.current===o){N(je(c)),S(!1);const x=Y.current,j=p!==void 0&&c.content===p,L=(x==null?void 0:x.documentId)===o&&x.content===c.content;j||L?(x==null?void 0:x.documentId)===o&&x.displayName!==c.displayName&&O({...x,displayName:c.displayName}):Ue(c)}return c}async function Te(o){v.current=o;try{const p=await G(o);if(v.current!==o)return;const c=await Me(o);if(v.current!==o||(c.domainId!==_&&(localStorage.setItem("mdocs.currentDomainId",c.domainId),H(c.domainId),V(c.domainId)),X(qe(c.relativePath)),c.headCommitId&&p&&!p.published&&(p.publishError===De.SYNC_HEAD_MISSING&&await dt(o),p.localBaseCommitId||await ye({...p,localBaseCommitId:c.headCommitId})),N(je(c)),v.current!==o))return;p&&!p.published?Tn(o,p):Ue(c)}catch(p){if(v.current!==o)return;K(me(e,p))}}a.useEffect(()=>{r==="ready"&&(J?Te(J):(N(null),O(null),fe(null)))},[r,J]);const{createModal:we,setCreateModal:Ze,createModalError:Nt,createModalBusy:xe,createModalInputRef:An,openNewDocumentModal:et,openNewFolderModal:tt,submitCreateModal:En}=bi({tree:E,currentDomainId:_,selectedCreateParentPath:Dt,t:e,onDocCreated:o=>{N(je(o)),Ue(o),X(qe(o.relativePath)),R(`/doc/${o.documentId}`)},refreshTree:V}),[jn,Ve]=a.useState(!1),[Mn,Ae]=a.useState(!1),[ge,Pt]=a.useState([]),[nt,Tt]=a.useState(""),[We,At]=a.useState(""),[Rn,Et]=a.useState(new Set);async function On(){try{const o=await Yo();Pt(o)}catch(o){K(me(e,o))}}const ot=a.useMemo(()=>{const o={};for(const p of T)o[p.domainId]=p.domainName;return o},[T]),jt=a.useMemo(()=>{let o=ge;const p=nt.trim().toLowerCase();return p&&(o=o.filter(c=>{var x;return(x=c.displayName)==null?void 0:x.toLowerCase().includes(p)})),We&&(o=o.filter(c=>c.domainId===We)),o},[ge,nt,We]),Ln=a.useMemo(()=>{const o=new Set,p=[];for(const c of ge){const x=c.domainId;x&&!o.has(x)&&(o.add(x),p.push({id:x,name:ot[x]??x}))}return p},[ge,ot]);async function Fn(o,p,c,x,j){let L=await G(o);!L&&(u==null?void 0:u.documentId)===o&&(L={documentId:o,content:p,displayName:c,updatedAt:Date.now(),published:!1,localBaseCommitId:x,permission:u.permission,ownerVisitorId:u.ownerVisitorId,domainId:u.domainId},await ye(L)),L&&await en(o,{localBaseCommitId:x,conflictStatus:"publish_conflict",conflict:{localBaseCommitId:x,remoteCommitId:j.headCommitId,localSnapshotContent:p}}),re(!0)}async function _n(o,p,c,x){return Ht(c).execute(async()=>{const j=await G(c),L=(j==null?void 0:j.localBaseCommitId)??(u==null?void 0:u.headCommitId);if(!L)throw K(e("syncHeadMissing")),new Error("missing localBaseCommitId");try{await Jt(c,{content:o,displayName:p,permission:x,version:{localBaseCommitId:L}}),await ct(c),await St(c,o),await V(),re(!1),U(e("published")),window.setTimeout(()=>U(null),1200)}catch(ee){throw ee instanceof oe&&ee.status===409&&ee.code==="VERSION_CONFLICT"&&ee.details&&typeof ee.details=="object"&&await Fn(c,o,p,L,ee.details),ee}})}async function Bn(){if(!u)return;const o=await Me(u.documentId);o.domainId!==_&&(localStorage.setItem("mdocs.currentDomainId",o.domainId),H(o.domainId),V(o.domainId)),X(qe(o.relativePath)),N(je(o)),Ue(o),U(e("syncPullDone")),window.setTimeout(()=>U(null),1200)}async function Mt(){if(!u)return;const o=await G(u.documentId);if(o&&!o.published)return;if((o==null?void 0:o.conflictStatus)==="publish_conflict"||(o==null?void 0:o.conflictStatus)==="diverged"||!!(o!=null&&o.conflict)){pe(!0);return}await Bn()}async function $n(o){await ct(o.documentId),await st(o.documentId),S(!1),pe(!1),re(!1),await Te(o.documentId),V(o.domainId),U(e("published")),window.setTimeout(()=>U(null),1200)}async function Hn(o,p,c){try{await Ti(o,p,c)}catch(x){if(!(x instanceof Re))throw x;const j=c??await G(o);throw U(Pi(e,j,x.code,x.cause??p)),window.setTimeout(()=>U(null),4e3),x}}async function Rt(o){let p;try{await Ht(o).execute(async()=>{const c=await G(o);if(!c)return;p=c;let x=c.localBaseCommitId;if(x||(x=(await Me(o)).headCommitId??void 0,x&&(await ye({...c,localBaseCommitId:x}),c.publishError===De.SYNC_HEAD_MISSING&&await dt(o))),!x)throw new Re(De.SYNC_HEAD_MISSING);const j=await G(o);j&&(await Jt(o,{content:j.content,displayName:j.displayName,version:{localBaseCommitId:x}}),await ct(o),await dt(o),(u==null?void 0:u.documentId)===o?await St(o,j.content):await st(o),await V(),U(e("published")),window.setTimeout(()=>U(null),1200))})}catch(c){await Hn(o,c,p)}}function Ot(o,p){Oe({type:"document",id:o,name:p})}function Lt(o,p){Oe({type:"folder",id:o,name:p})}async function Un(o,p){try{const c=await qo(o,p);await V(c.domainId),(u==null?void 0:u.documentId)===o&&(N(je(c)),X(qe(c.relativePath)))}catch(c){c instanceof oe?c.status===409&&K(c.message):K(me(e,c))}}async function Vn(){if(q)try{q.type==="document"?(await zo(q.id),(u==null?void 0:u.documentId)===q.id&&(N(null),O(null),X(""),R("/"))):q.type==="folder"&&(await Jo(q.id),u&&(N(null),O(null),X(""),R("/"))),await V(),U(q.type==="folder"?`已删除「${q.name}」及其下所有内容`:`已删除「${q.name}」`),window.setTimeout(()=>U(null),2e3)}catch(o){K(me(e,o))}finally{Oe(null)}}return r==="loading"?n.jsx("div",{className:"mdocs-loading muted",children:e("loading")}):r==="needsRegister"?n.jsx(ni,{onSubmit:Nn,onRecover:Pn,error:Ne}):n.jsxs("div",{className:"mdocs-app-root",children:[an(),n.jsxs("div",{className:"mdocs-shell",children:[F&&C&&n.jsx(oi,{visitorId:F,onDismiss:()=>y(null)}),I&&n.jsx("div",{className:"mdocs-dialog-backdrop",style:{position:"fixed",zIndex:9999},onClick:o=>{o.target===o.currentTarget&&w(null)},children:n.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:480,textAlign:"center"},children:[n.jsx("h1",{style:{fontSize:"1.25rem",marginBottom:8},children:"🔑 保存你的恢复码"}),n.jsxs("p",{className:"muted",style:{marginBottom:16,lineHeight:1.5},children:["恢复码是你的唯一凭证,当 Token 丢失时可用它找回身份。",n.jsx("br",{}),n.jsx("strong",{children:"请立即复制保存,此弹窗关闭后不可再查看。"})]}),n.jsx("div",{style:{background:"#f5f5f5",borderRadius:8,padding:"12px 16px",fontFamily:"monospace",fontSize:"1.25rem",letterSpacing:"0.1em",marginBottom:20,userSelect:"all"},children:I}),n.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"center"},children:[n.jsx("button",{type:"button",className:"primary",onClick:()=>{navigator.clipboard.writeText(I)},children:"复制恢复码"}),n.jsx("button",{type:"button",onClick:()=>w(null),children:"已保存,关闭"})]})]})}),n.jsxs(n.Fragment,{children:[n.jsx(pi,{open:Fe,onToggle:()=>{var o;Fe?(o=kt.current)==null||o.requestClose():be(!0)},position:Ct,onPositionChange:vn}),Fe?n.jsx(a.Suspense,{fallback:null,children:n.jsx(Li,{ref:kt,open:Fe,onClose:()=>be(!1),visitorName:C==null?void 0:C.visitorName,anchorStyle:fi(Ct),onOpenDocument:o=>{Le("docs"),Z(()=>R(`/doc/${o}`)),be(!1)},onTreeChanged:()=>void V(),onDocumentOverwritten:o=>void Cn(o),onOpenCoding:o=>void Dn(o)})}):null]}),Be?n.jsx(a.Suspense,{fallback:null,children:n.jsx(Fi,{open:bn,initialMarkdown:Be.markdown,documentId:Be.documentId,displayName:Be.displayName,onClose:()=>{_e(!1),$e(null)},onComplete:kn})}):null,yn==="settings"?n.jsx(a.Suspense,{fallback:n.jsx("div",{className:"mdocs-main muted",style:{padding:24},children:"加载设置…"}),children:n.jsx(Oi,{onBack:()=>Le("docs"),onPublishDraft:Rt,onOpenDocument:Te,onRecoverDraft:()=>void V()})}):n.jsxs("div",{className:"mdocs-layout",children:[n.jsxs("aside",{className:`mdocs-sidebar ${d?"mdocs-sidebar-collapsed":""}`,children:[n.jsxs("header",{className:"mdocs-sidebar-header",children:[n.jsxs("div",{className:"mdocs-brand",children:[n.jsx("img",{src:Mi,alt:e("brand"),className:"mdocs-brand-logo"}),n.jsx("span",{children:e("brand")})]}),n.jsx("button",{type:"button",className:"mdocs-sidebar-toggle",onClick:f,"aria-label":e(d?"expandSidebar":"collapseSidebar"),style:{background:"none",border:"none",cursor:"pointer",padding:"6px",color:"var(--mdocs-text-muted, #999)",borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:o=>{o.currentTarget.style.background="var(--mdocs-hover-bg, #f0f0f0)"},onMouseLeave:o=>{o.currentTarget.style.background="none"},children:d?n.jsx(vo,{size:18}):n.jsx(go,{size:18})})]}),n.jsxs("div",{className:"mdocs-sidebar-actions",children:[n.jsx("span",{className:"mdocs-sidebar-icon mdocs-tooltip","data-tooltip":e("newDocument"),onClick:()=>et(),style:{color:"var(--mdocs-accent)"},children:n.jsx(_t,{size:20})}),n.jsx("span",{className:"mdocs-sidebar-icon mdocs-tooltip","data-tooltip":e("newFolder"),onClick:()=>tt(),children:n.jsx(Bt,{size:20})})]}),n.jsx(ii,{nodes:E,activeDocumentId:J??null,selectedParentPath:Dt,onOpen:o=>{Z(()=>R(`/doc/${o.documentId}`))},onOpenFolder:(o,p)=>{Z(()=>{X(o),p&&R(`/doc/${p}`)})},onContextMenu:It,onMoveDocument:Un,onDeselect:()=>{Z(()=>{X(""),R("/")})}}),n.jsxs("footer",{className:"mdocs-sidebar-footer",children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1,cursor:"pointer"},onClick:()=>Z(()=>Le("settings")),children:[n.jsx("span",{className:"mdocs-visitor-avatar",children:C?C.visitorName.charAt(0).toUpperCase():"?"}),n.jsx("span",{className:"mdocs-visitor-footer-name",children:C?C.visitorName:""})]}),n.jsx("button",{type:"button",className:"mdocs-sidebar-bookmark mdocs-tooltip","data-tooltip":e("bookmark"),onClick:()=>{Ae(!0),Tt(""),At(""),On()},style:{background:"none",border:"none",cursor:"pointer",padding:"6px",color:"var(--mdocs-text-muted, #999)",fontSize:"1rem",lineHeight:1,borderRadius:4},children:n.jsx(wo,{size:16,strokeWidth:1.5})}),n.jsx("button",{type:"button",className:"mdocs-sidebar-logout mdocs-tooltip","data-tooltip":e("logout"),onClick:()=>Ve(!0),style:{background:"none",border:"none",cursor:"pointer",padding:"6px",color:"var(--mdocs-text-muted, #999)",lineHeight:1,borderRadius:4},children:n.jsx(uo,{size:16,strokeWidth:1.5})})]})]}),n.jsxs("main",{className:"mdocs-main",children:[u&&M&&M.documentId===u.documentId?n.jsxs("div",{className:"mdocs-editor-with-comments",children:[n.jsx("div",{className:"mdocs-editor-container",children:n.jsx(a.Suspense,{fallback:n.jsx("div",{className:"muted",style:{padding:24},children:"加载编辑器…"}),children:n.jsx(Ri,{meta:u,initialContent:M.content,initialDisplayName:M.displayName,contentRevision:Ke,canEdit:!!(C&&(u.ownerVisitorId===C.visitorId||Po(u.permission)||u.invitedEdit===!0)),domains:T,currentDomainId:_,onDomainChange:o=>{Z(()=>{localStorage.setItem("mdocs.currentDomainId",o),H(o),N(null),O(null),X(""),R("/"),V(o)})},onDomainsChange:B,onPublish:_n,syncBehind:$,onSyncClick:()=>void Mt(),onDraftExistsChange:S,onConflictModalRequest:()=>re(!0),onMergeRequest:()=>pe(!0),canManageInvites:!!(C&&C.visitorId===u.ownerVisitorId),onDelete:async()=>{if(u.relativePath.endsWith("/___desc___.md")){const o=u.relativePath.replace(/\/___desc___\.md$/,"");Lt(u.documentId,o)}else Ot(u.documentId,u.relativePath)},saveBeforeNavRef:Q,exportMarkdownRef:He,onShowToast:U,onShowError:K,onToggleComments:()=>m(!h),commentPanelOpen:h,commentCount:g,onAiWrite:()=>void xn()},u.documentId)})}),h&&n.jsx(xi,{documentId:u.documentId,visitorId:C==null?void 0:C.visitorId,visitorName:C==null?void 0:C.visitorName,documentOwnerId:u.ownerVisitorId,onClose:()=>m(!1)})]}):n.jsxs("div",{className:"mdocs-welcome",children:[n.jsx("h1",{children:e("brand")}),n.jsx("p",{className:"muted mdocs-welcome-lead",children:E.length===0?e("noDocsInDomain"):e("createDocToStart")}),n.jsxs("div",{className:"mdocs-welcome-domain",children:[n.jsx("label",{className:"muted mdocs-welcome-domain-label",children:e("domainLabel")}),n.jsx(ci,{domains:T.length?T:[{domainId:"default",domainName:e("defaultDomain"),permission:"",creatorVisitorId:"",docCount:0}],value:_,onChange:o=>{Z(()=>{localStorage.setItem("mdocs.currentDomainId",o),H(o),N(null),O(null),X(""),R("/"),V(o)})},onDomainsChange:B,ariaLabel:e("domainLabel"),localizeName:o=>yi(o,t,e)})]}),n.jsxs("div",{className:"mdocs-welcome-actions",children:[n.jsxs("button",{type:"button",className:"primary",onClick:()=>et(),style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx(_t,{size:16,strokeWidth:1.5}),e("newDocument")]}),n.jsxs("button",{type:"button",className:"secondary",onClick:()=>tt(),style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx(Bt,{size:16,strokeWidth:1.5}),e("newFolder")]}),n.jsxs("button",{type:"button",className:"secondary",onClick:()=>In(),style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("img",{src:un,alt:"",width:16,height:16,style:{display:"block"}}),"AI 帮写"]})]})]}),n.jsx(wi,{open:Xe,onClose:()=>re(!1),onResolve:()=>{re(!1),pe(!0)}}),Se&&u&&wt&&n.jsx(a.Suspense,{fallback:n.jsx("div",{className:"merge-view-loading",children:e("mergeLoadingRemote")}),children:n.jsx(_i,{documentId:u.documentId,displayName:u.displayName,conflict:wt,onClose:()=>pe(!1),onSuccess:$n,onError:o=>K(o)})}),Ne&&n.jsx("div",{className:"mdocs-toast",role:"status",children:Ne}),xt&&n.jsx(gi,{title:e("error"),message:xt,onClose:()=>K(null)})]}),jn&&n.jsx("div",{className:"mdocs-dialog-backdrop",onClick:o=>{o.target===o.currentTarget&&Ve(!1)},children:n.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:440},children:[n.jsx("h1",{style:{fontSize:"1.125rem",marginBottom:8},children:"退出当前登录身份?"}),n.jsx("p",{style:{lineHeight:1.6,color:"var(--mdocs-text-secondary, #666)",marginBottom:20},children:"这将会导致您无法修改以前的文章。如果想找回账号,需要恢复码或联系管理员执行合并用户脚本。"}),n.jsxs("div",{className:"mdocs-dialog-actions",style:{justifyContent:"flex-end"},children:[n.jsx("button",{type:"button",onClick:()=>Ve(!1),children:"取消"}),n.jsx("button",{type:"button",className:"primary",style:{background:"#d32f2f"},onClick:()=>{_o(),N(null),O(null),A(null),P([]),Ve(!1),s("needsRegister")},children:"确认退出"})]})]})}),Mn&&n.jsx("div",{className:"mdocs-dialog-backdrop",onClick:o=>{o.target===o.currentTarget&&Ae(!1)},children:n.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:640,width:"min(640px, 100%)",maxHeight:"70vh",display:"flex",flexDirection:"column"},children:[n.jsxs("h1",{style:{fontSize:"1.125rem",marginBottom:16},children:[e("bookmarkTitle"),"(",ge.length,")"]}),ge.length>0&&n.jsxs("div",{className:"mdocs-bookmark-filterbar",children:[n.jsx("input",{type:"text",placeholder:e("bookmarkSearch"),value:nt,onChange:o=>Tt(o.target.value)}),n.jsxs("select",{value:We,onChange:o=>At(o.target.value),children:[n.jsx("option",{value:"",children:e("bookmarkFilterAll")}),Ln.map(o=>n.jsx("option",{value:o.id,children:o.name},o.id))]})]}),ge.length===0?n.jsx("p",{style:{color:"var(--mdocs-text-muted, #999)",textAlign:"center",padding:"2rem 0"},children:e("bookmarkEmpty")}):jt.length===0?n.jsx("p",{style:{color:"var(--mdocs-text-muted, #999)",textAlign:"center",padding:"2rem 0"},children:e("bookmarkNoMatch")}):n.jsx("div",{style:{overflowY:"auto",flex:1,margin:"0 -1rem",padding:"0 1rem"},children:n.jsxs("table",{className:"mdocs-bookmark-table",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:e("bookmarkColTitle")}),n.jsx("th",{children:e("bookmarkColDomain")}),n.jsx("th",{children:e("bookmarkColAuthor")}),n.jsx("th",{children:e("bookmarkColTime")}),n.jsx("th",{className:"mdocs-bookmark-col-action"})]})}),n.jsx("tbody",{children:jt.map(o=>{const p=Rn.has(o.documentId);return n.jsxs("tr",{className:`${p?"mdocs-bookmark-removing":""}`,style:{opacity:o.isDeleted?.6:1},children:[n.jsx("td",{className:"mdocs-bookmark-col-title",children:n.jsxs("div",{style:{cursor:o.isDeleted?"default":"pointer",display:"flex",alignItems:"center",gap:6,overflow:"hidden"},onClick:()=>{o.isDeleted||Z(()=>{Ae(!1),R(`/doc/${o.documentId}`)})},children:[n.jsx("span",{ref:c=>{if(c){const x=c.scrollWidth>c.clientWidth;c.title=x?o.displayName??"":""}},style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:o.displayName??"(无标题)"}),o.isDeleted&&n.jsx("span",{style:{fontSize:"0.7rem",color:"#d32f2f",background:"#ffebee",padding:"1px 6px",borderRadius:4,flexShrink:0},children:"已删除"})]})}),n.jsx("td",{children:o.isDeleted?"":ot[o.domainId??""]??o.domainId??""}),n.jsx("td",{children:o.isDeleted?"":o.ownerVisitorName??"-"}),n.jsx("td",{children:o.isDeleted?"":Bi(o.bookmarkedAt,t)}),n.jsx("td",{className:"mdocs-bookmark-col-action",children:n.jsxs("div",{style:{display:"flex",gap:2,alignItems:"center",justifyContent:"flex-end"},children:[n.jsx("button",{type:"button",className:"mdocs-tooltip","data-tooltip":e("bookmarkOpen"),onClick:()=>{o.isDeleted||Z(()=>{Ae(!1),R(`/doc/${o.documentId}`)})},style:{background:"none",border:"none",cursor:o.isDeleted?"default":"pointer",padding:"4px",color:"var(--mdocs-text-muted, #999)",lineHeight:1,borderRadius:4,display:"inline-flex",alignItems:"center"},children:n.jsx(so,{size:14,strokeWidth:1.5})}),n.jsx("button",{type:"button",className:"mdocs-tooltip","data-tooltip":e("bookmarkRemove"),onClick:async()=>{try{await Ko(o.documentId),Et(c=>new Set(c).add(o.documentId)),setTimeout(()=>{Pt(c=>c.filter(x=>x.documentId!==o.documentId)),Et(c=>{const x=new Set(c);return x.delete(o.documentId),x})},300)}catch(c){K(me(e,c))}},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"var(--mdocs-text-muted, #999)",fontSize:"1rem",lineHeight:1,borderRadius:4,display:"inline-flex",alignItems:"center"},onMouseEnter:c=>{c.currentTarget.style.color="#d32f2f"},onMouseLeave:c=>{c.currentTarget.style.color="var(--mdocs-text-muted, #999)"},children:"✕"})]})})]},o.documentId)})})]})}),n.jsx("div",{className:"mdocs-dialog-actions",style:{justifyContent:"flex-end",marginTop:16,paddingTop:16,borderTop:"1px solid var(--mdocs-border, #eee)"},children:n.jsx("button",{type:"button",onClick:()=>Ae(!1),children:e("close")})})]})}),Pe&&n.jsx(di,{x:Pe.x,y:Pe.y,node:Pe.node,parentPath:Pe.parentPath,onClose:()=>It(null),onCreateChild:o=>et(o),onCreateFolder:o=>tt(o),onDeleteDocument:o=>Ot(o.documentId,o.path),onDeleteFolder:o=>Lt(o.documentId,o.folderDisplayName||o.name)}),q&&n.jsx(fn,{title:q.type==="folder"?"删除文件夹":"删除文档",message:q.type==="folder"?`确定要删除「${q.name}」及其下的所有文档和子文件夹吗?此操作不可撤销。`:`确定要删除「${q.name}」吗?`,confirmLabel:"删除",cancelLabel:"取消",onConfirm:Vn,onCancel:()=>Oe(null),danger:!0}),we&&n.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:o=>{o.target===o.currentTarget&&!xe&&Ze(null)},children:n.jsxs("div",{className:"mdocs-dialog card",role:"dialog","aria-modal":"true",children:[n.jsx("h1",{children:we.kind==="document"?e("newDocumentTitle"):e("newFolderTitle")}),n.jsx("p",{className:"muted",children:we.kind==="document"?e("fileNameHint"):e("folderNameHint")}),n.jsxs("form",{onSubmit:En,className:"mdocs-dialog-form",children:[n.jsxs("label",{className:"mdocs-dialog-label",children:[we.kind==="document"?e("fileNameLabel"):e("folderNameLabel"),n.jsx("input",{ref:An,value:we.draft,onChange:o=>Ze(p=>p&&{...p,draft:o.target.value}),placeholder:we.kind==="document"?e("untitledPlaceholder"):e("folderExamplePlaceholder"),maxLength:200,disabled:xe})]}),Nt&&n.jsx("div",{className:"mdocs-dialog-error",children:Nt}),n.jsxs("div",{className:"mdocs-dialog-actions",children:[n.jsx("button",{type:"button",onClick:()=>!xe&&Ze(null),disabled:xe,children:e("cancel")}),n.jsx("button",{type:"submit",className:"primary",disabled:xe,children:e(xe?"creating":"create")})]})]})]})})]})]})]})}const $i=a.lazy(()=>Ce(()=>import("./PlaygroundPage-Dg57Xxpl.js"),__vite__mapDeps([16,1,4,5,2,3,6,7,8,9])).then(e=>({default:e.PlaygroundPage})));function Hi(){return n.jsxs(Jn,{children:[n.jsx(it,{path:"/",element:n.jsx(tn,{})}),n.jsx(it,{path:"/doc/:documentId",element:n.jsx(tn,{})}),n.jsx(it,{path:"/playground",element:n.jsx(a.Suspense,{fallback:n.jsx("div",{style:{padding:24},children:"Loading playground…"}),children:n.jsx($i,{})})})]})}const gn=document.getElementById("root");if(!gn)throw new Error("root element missing");Yn.createRoot(gn).render(n.jsx(Kn.StrictMode,{children:n.jsx(Qn,{motion:eo,children:n.jsx(Zn,{children:n.jsx(So,{children:n.jsx(Xn,{children:n.jsx(Hi,{})})})})})}));export{Pr as $,Re as A,Ki as B,Uo as C,ci as D,Wr as E,ei as F,sr as G,ar as H,rr as I,ir as J,lr as K,Xi as L,po as M,Zi as N,Qi as O,er as P,cr as Q,dr as R,wo as S,mr as T,ur as U,fr as V,Gt as W,Cr as X,kr as Y,Sr as Z,Nr as _,G as a,Tr as a0,wr as a1,Yo as a2,Dr as a3,Mi as a4,an as a5,fn as a6,nr as a7,tr as a8,br as a9,Ar as aa,jr as ab,Ee as ac,Er as ad,Mr as ae,Rr as af,Or as ag,Vr as ah,Br as ai,Ur as aj,_r as ak,Fr as al,Lr as am,Hr as an,$r as ao,Me as ap,pr as aq,rt as ar,Jt as as,go as at,de as b,se as c,st as d,xr as e,or as f,Ht as g,Gi as h,un as i,hr as j,Ir as k,yi as l,te as m,yr as n,gr as o,vr as p,dn as q,Ko as r,Vo as s,ii as t,Ci as u,sn as v,me as w,ki as x,Pi as y,dt as z};
|