@fgbg/mdocs 1.3.18 → 1.3.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +1 -1
  2. package/agent-skills/changelog/SKILL.md +17 -0
  3. package/agent-skills/index.json +1 -1
  4. package/agent-skills/usage-my-documents/SKILL.md +2 -5
  5. package/agent-skills/usage-search/SKILL.md +34 -12
  6. package/agent-skills/usage-settings/SKILL.md +2 -1
  7. package/dist/server/agent/Agent/tools-documents.js +57 -5
  8. package/dist/server/agent/Agent/tools-documents.js.map +1 -1
  9. package/dist/server/agent/Agent/tools-registry.test.js +2 -0
  10. package/dist/server/agent/Agent/tools-registry.test.js.map +1 -1
  11. package/dist/server/agent/Agent/tools-template.js +3 -1
  12. package/dist/server/agent/Agent/tools-template.js.map +1 -1
  13. package/dist/server/app.js +3 -0
  14. package/dist/server/app.js.map +1 -1
  15. package/dist/server/db/schema.js +11 -0
  16. package/dist/server/db/schema.js.map +1 -1
  17. package/dist/server/documents/document.service.js +9 -1
  18. package/dist/server/documents/document.service.js.map +1 -1
  19. package/dist/server/routes/documents.routes.js +43 -5
  20. package/dist/server/routes/documents.routes.js.map +1 -1
  21. package/dist/server/search/document-index-manager.js +66 -22
  22. package/dist/server/search/document-index-manager.js.map +1 -1
  23. package/dist/server/search/document-index-manager.test.js +24 -17
  24. package/dist/server/search/document-index-manager.test.js.map +1 -1
  25. package/dist/server/search/embedding-admin.js +158 -0
  26. package/dist/server/search/embedding-admin.js.map +1 -0
  27. package/dist/server/search/embedding-model.js +209 -0
  28. package/dist/server/search/embedding-model.js.map +1 -0
  29. package/dist/server/search/embedding-store.js +146 -0
  30. package/dist/server/search/embedding-store.js.map +1 -0
  31. package/dist/server/search/embedding-store.test.js +293 -0
  32. package/dist/server/search/embedding-store.test.js.map +1 -0
  33. package/dist/server/search/search.service.js +126 -48
  34. package/dist/server/search/search.service.js.map +1 -1
  35. package/dist/web/assets/{AgentChatPanel-DTj8Nz0Z.js → AgentChatPanel-BZlAgyrV.js} +3 -3
  36. package/dist/web/assets/{AgentSkillFormCard-DTgxybJh.js → AgentSkillFormCard-CzJG8FK4.js} +3 -3
  37. package/dist/web/assets/AiWriteWorkbench-DiSDDAee.js +7 -0
  38. package/dist/web/assets/{DiagramEditor-NtNY3sZL-B2Aeu79R.js → DiagramEditor-NtNY3sZL-DfkpQX3P.js} +1 -1
  39. package/dist/web/assets/{DocChrome-4qmjr6wa.js → DocChrome-QTGER_Af.js} +1 -1
  40. package/dist/web/assets/{DocumentEditor-KEURMFDp.js → DocumentEditor-DYSRZnJa.js} +1 -1
  41. package/dist/web/assets/{HtmlEditor-jCKtKOCT.js → HtmlEditor-oDPrhq3o.js} +1 -1
  42. package/dist/web/assets/{MergeView-eRcs-x1s.js → MergeView-CbFSN3Bi.js} +4 -4
  43. package/dist/web/assets/{PlaygroundPage-M7fqYn4Z.js → PlaygroundPage-DuMH_V-7.js} +1 -1
  44. package/dist/web/assets/SettingsPage-C_RMO-5M.js +1 -0
  45. package/dist/web/assets/{Toolbar-F3tR5o7R.js → Toolbar-D9FcRwg3.js} +1 -1
  46. package/dist/web/assets/{VisitorPickerModal-CPjKg8ox.js → VisitorPickerModal-CM13Y6jQ.js} +1 -1
  47. package/dist/web/assets/{check-CQSGOkW1.js → check-Bf8YbzH7.js} +1 -1
  48. package/dist/web/assets/{copy-BMAJ--_Y.js → copy-SBghRY2T.js} +1 -1
  49. package/dist/web/assets/{diagram-Bk84WZto.js → diagram-CgEd0hrk.js} +3 -3
  50. package/dist/web/assets/index-CIgmAX2Q.css +1 -0
  51. package/dist/web/assets/index-Cwy87sZC.js +293 -0
  52. package/dist/web/assets/{meta2dEngine-BD2XbzaV-BAZUiXoN.js → meta2dEngine-BD2XbzaV-ulfRZEvk.js} +1 -1
  53. package/dist/web/assets/{motion-DFABYlwt.js → motion-Dyy8pB0Q.js} +1 -1
  54. package/dist/web/assets/{plus-C3uXIATM.js → plus-CEapsZwl.js} +1 -1
  55. package/dist/web/assets/{react-BXGUMaBS.js → react-BkX5Koku.js} +3 -3
  56. package/dist/web/assets/ui-ZPt_BNBg.js +3165 -0
  57. package/dist/web/index.html +5 -5
  58. package/package.json +4 -2
  59. package/dist/web/assets/AiWriteWorkbench-D2RzXzty.js +0 -7
  60. package/dist/web/assets/SettingsPage-mS3g_vBq.js +0 -1
  61. package/dist/web/assets/index-C8iEyMxp.css +0 -1
  62. package/dist/web/assets/index-DUu4Is5p.js +0 -293
  63. package/dist/web/assets/ui-CvA4pq3d.js +0 -3116
@@ -0,0 +1,293 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DocumentEditor-DYSRZnJa.js","assets/react-vendor-BuABiQkA.js","assets/ui-ZPt_BNBg.js","assets/motion-Dyy8pB0Q.js","assets/react-BkX5Koku.js","assets/editor-CL03se2B.js","assets/diagram-CgEd0hrk.js","assets/plus-CEapsZwl.js","assets/check-Bf8YbzH7.js","assets/copy-SBghRY2T.js","assets/Toolbar-D9FcRwg3.js","assets/DocChrome-QTGER_Af.js","assets/file-type-policy-GUk904tm.js","assets/VisitorPickerModal-CM13Y6jQ.js","assets/HtmlEditor-oDPrhq3o.js","assets/HtmlEditor-iolk903a.css","assets/SettingsPage-C_RMO-5M.js","assets/AgentChatPanel-BZlAgyrV.js","assets/AgentSkillFormCard-CzJG8FK4.js","assets/AiWriteWorkbench-DiSDDAee.js","assets/MergeView-CbFSN3Bi.js","assets/PlaygroundPage-DuMH_V-7.js"])))=>i.map(i=>d[i]);
2
+ var $a=Object.defineProperty;var Ua=(e,n,r)=>n in e?$a(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var qt=(e,n,r)=>Ua(e,typeof n!="symbol"?n+"":n,r);import{r as x,j as c,R as Ni,B as Ba,_ as zt,a8 as Ha,a9 as Va,aa as Ga,ab as rr,c as Wa,ac as qa}from"./react-vendor-BuABiQkA.js";import{a5 as Ka,a6 as Ya}from"./ui-ZPt_BNBg.js";import{d as Ja,s as Sr,p as Xa,t as Za,a as Qa,q as es,o as ts,b as ns,c as rs,e as ft,f as os,g as is,y as as,m as wo,h as _o}from"./diagram-CgEd0hrk.js";import{f as ss}from"./motion-Dyy8pB0Q.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))o(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&o(s)}).observe(document,{childList:!0,subtree:!0});function r(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(a){if(a.ep)return;a.ep=!0;const i=r(a);fetch(a.href,i)}})();/**
3
+ * @license lucide-react v0.562.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */const ls=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),cs=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(n,r,o)=>o?o.toUpperCase():r.toLowerCase()),ko=e=>{const n=cs(e);return n.charAt(0).toUpperCase()+n.slice(1)},Pi=(...e)=>e.filter((n,r,o)=>!!n&&n.trim()!==""&&o.indexOf(n)===r).join(" ").trim(),ds=e=>{for(const n in e)if(n.startsWith("aria-")||n==="role"||n==="title")return!0};/**
8
+ * @license lucide-react v0.562.0 - ISC
9
+ *
10
+ * This source code is licensed under the ISC license.
11
+ * See the LICENSE file in the root directory of this source tree.
12
+ */var us={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
+ * @license lucide-react v0.562.0 - ISC
14
+ *
15
+ * This source code is licensed under the ISC license.
16
+ * See the LICENSE file in the root directory of this source tree.
17
+ */const fs=x.forwardRef(({color:e="currentColor",size:n=24,strokeWidth:r=2,absoluteStrokeWidth:o,className:a="",children:i,iconNode:s,...l},u)=>x.createElement("svg",{ref:u,...us,width:n,height:n,stroke:e,strokeWidth:o?Number(r)*24/Number(n):r,className:Pi("lucide",a),...!i&&!ds(l)&&{"aria-hidden":"true"},...l},[...s.map(([d,h])=>x.createElement(d,h)),...Array.isArray(i)?i:[i]]));/**
18
+ * @license lucide-react v0.562.0 - ISC
19
+ *
20
+ * This source code is licensed under the ISC license.
21
+ * See the LICENSE file in the root directory of this source tree.
22
+ */const ve=(e,n)=>{const r=x.forwardRef(({className:o,...a},i)=>x.createElement(fs,{ref:i,iconNode:n,className:Pi(`lucide-${ls(ko(e))}`,`lucide-${e}`,o),...a}));return r.displayName=ko(e),r};/**
23
+ * @license lucide-react v0.562.0 - ISC
24
+ *
25
+ * This source code is licensed under the ISC license.
26
+ * See the LICENSE file in the root directory of this source tree.
27
+ */const ms=[["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"}]],hs=ve("book-open",ms);/**
28
+ * @license lucide-react v0.562.0 - ISC
29
+ *
30
+ * This source code is licensed under the ISC license.
31
+ * See the LICENSE file in the root directory of this source tree.
32
+ */const ps=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Cr=ve("chevron-down",ps);/**
33
+ * @license lucide-react v0.562.0 - ISC
34
+ *
35
+ * This source code is licensed under the ISC license.
36
+ * See the LICENSE file in the root directory of this source tree.
37
+ */const gs=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],ys=ve("code-xml",gs);/**
38
+ * @license lucide-react v0.562.0 - ISC
39
+ *
40
+ * This source code is licensed under the ISC license.
41
+ * See the LICENSE file in the root directory of this source tree.
42
+ */const vs=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],bs=ve("code",vs);/**
43
+ * @license lucide-react v0.562.0 - ISC
44
+ *
45
+ * This source code is licensed under the ISC license.
46
+ * See the LICENSE file in the root directory of this source tree.
47
+ */const xs=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],ws=ve("ellipsis-vertical",xs);/**
48
+ * @license lucide-react v0.562.0 - ISC
49
+ *
50
+ * This source code is licensed under the ISC license.
51
+ * See the LICENSE file in the root directory of this source tree.
52
+ */const _s=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],ks=ve("eye",_s);/**
53
+ * @license lucide-react v0.562.0 - ISC
54
+ *
55
+ * This source code is licensed under the ISC license.
56
+ * See the LICENSE file in the root directory of this source tree.
57
+ */const Is=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Io=ve("file-text",Is);/**
58
+ * @license lucide-react v0.562.0 - ISC
59
+ *
60
+ * This source code is licensed under the ISC license.
61
+ * See the LICENSE file in the root directory of this source tree.
62
+ */const Ss=[["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"}]],Cs=ve("file",Ss);/**
63
+ * @license lucide-react v0.562.0 - ISC
64
+ *
65
+ * This source code is licensed under the ISC license.
66
+ * See the LICENSE file in the root directory of this source tree.
67
+ */const Ds=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["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"}]],Ns=ve("folder-plus",Ds);/**
68
+ * @license lucide-react v0.562.0 - ISC
69
+ *
70
+ * This source code is licensed under the ISC license.
71
+ * See the LICENSE file in the root directory of this source tree.
72
+ */const Ps=[["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"}]],Ts=ve("folder",Ps);/**
73
+ * @license lucide-react v0.562.0 - ISC
74
+ *
75
+ * This source code is licensed under the ISC license.
76
+ * See the LICENSE file in the root directory of this source tree.
77
+ */const As=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Nn=ve("loader-circle",As);/**
78
+ * @license lucide-react v0.562.0 - ISC
79
+ *
80
+ * This source code is licensed under the ISC license.
81
+ * See the LICENSE file in the root directory of this source tree.
82
+ */const js=[["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"}]],Ms=ve("log-out",js);/**
83
+ * @license lucide-react v0.562.0 - ISC
84
+ *
85
+ * This source code is licensed under the ISC license.
86
+ * See the LICENSE file in the root directory of this source tree.
87
+ */const Es=[["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"}]],Os=ve("message-square",Es);/**
88
+ * @license lucide-react v0.562.0 - ISC
89
+ *
90
+ * This source code is licensed under the ISC license.
91
+ * See the LICENSE file in the root directory of this source tree.
92
+ */const Rs=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],Hr=ve("network",Rs);/**
93
+ * @license lucide-react v0.562.0 - ISC
94
+ *
95
+ * This source code is licensed under the ISC license.
96
+ * See the LICENSE file in the root directory of this source tree.
97
+ */const Fs=[["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"}]],So=ve("panel-left-close",Fs);/**
98
+ * @license lucide-react v0.562.0 - ISC
99
+ *
100
+ * This source code is licensed under the ISC license.
101
+ * See the LICENSE file in the root directory of this source tree.
102
+ */const Ls=[["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"}]],Co=ve("panel-left-open",Ls);/**
103
+ * @license lucide-react v0.562.0 - ISC
104
+ *
105
+ * This source code is licensed under the ISC license.
106
+ * See the LICENSE file in the root directory of this source tree.
107
+ */const zs=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Do=ve("refresh-cw",zs);/**
108
+ * @license lucide-react v0.562.0 - ISC
109
+ *
110
+ * This source code is licensed under the ISC license.
111
+ * See the LICENSE file in the root directory of this source tree.
112
+ */const $s=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ti=ve("search",$s);/**
113
+ * @license lucide-react v0.562.0 - ISC
114
+ *
115
+ * This source code is licensed under the ISC license.
116
+ * See the LICENSE file in the root directory of this source tree.
117
+ */const Us=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],or=ve("settings-2",Us);/**
118
+ * @license lucide-react v0.562.0 - ISC
119
+ *
120
+ * This source code is licensed under the ISC license.
121
+ * See the LICENSE file in the root directory of this source tree.
122
+ */const Bs=[["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"}]],Hs=ve("star",Bs);/**
123
+ * @license lucide-react v0.562.0 - ISC
124
+ *
125
+ * This source code is licensed under the ISC license.
126
+ * See the LICENSE file in the root directory of this source tree.
127
+ */const Vs=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Et=ve("x",Vs);/**
128
+ * @license lucide-react v0.562.0 - ISC
129
+ *
130
+ * This source code is licensed under the ISC license.
131
+ * See the LICENSE file in the root directory of this source tree.
132
+ */const Gs=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Ai=ve("zap",Gs),Ws={loading:"loading...",saved:"Saved",saving:"Saving...",unsaved:"Editing...",publish:"Publish",publishing:"Publishing...",published:"Published",preview:"Preview",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:"Start writing",startWriting:"Start writing",newArticle:"New article",newDirectory:"New folder",newFolder:"New folder",noDocumentsYet:"no documents yet",collapseFolder:"Collapse folder",expandFolder:"Expand folder",noDocsInDomain:"No documents in this workspace yet. Switch workspace below or create a document.",createDocToStart:"Click Start writing, or open a document from the sidebar.",domainLabel:"Workspace",defaultDomain:"Default",displayNamePlaceholder:"Display name",currentDomainAria:"Current workspace",insertDiagram:"Insert diagram",outlineHide:"Hide outline",outlineShow:"Show outline",readOnlyNotice:`> You don't have permission to edit
133
+
134
+ `,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}}",copyDocumentId:"Copy document ID",copyDocumentUrl:"Copy URL",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 workspaces.",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:"Editable in workspace",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:"Workspaces",createDomain:"New workspace",domainName:"Name",domainPermission:"Permission",domainPublic:"Public",domainRestricted:"Restricted",domainPrivate:"Private",docCount:"{{count}} documents",rename:"Rename",deleteDomain:"Delete workspace",deleteDomainConfirm:"Delete workspace {{name}}?",domainLocked:"Has documents, locked",noDomains:"No workspaces",domainNameRequired:"Enter a name",domainBuiltIn:"Built-in",domainNotCreator:"Only the creator can modify this workspace",domainSearchPlaceholder:"Search name…",domainFilterAll:"All",domainColName:"Name",domainColType:"Type",domainColDocCount:"Documents",domainColActions:"Actions",domainTypeBuiltinSuffix:"(built-in)",domainChangeType:"Change type",domainPermissionNoDowngrade:"Permission cannot be made more private.",domainPermissionAlreadyTop:"Already the most open permission.",domainNotModifiable:"System preset, cannot be changed",domainTooltipTypeLocked:"With documents, permission can only become more open.",deleteDomainConfirmDetail:"Delete workspace «{{name}}»? All {{count}} document(s) in it will be permanently removed.",domainNoMatch:"No matching workspaces.",memberTemplates:"Member templates",memberTemplateFormNew:"New template",memberTemplateSavedList:"Saved templates",memberTemplateIntro:"Save reusable member lists for restricted workspaces. 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 workspace in Workspaces.",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 workspace 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 (workspace 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 workspaces you own: click Members… in the Actions column, then pick people in the dialog (or apply a saved template). The workspace 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",conflictForce:"Force overwrite",conflictForceHint:"Document owner only. Cloud content will be replaced with your local draft; others' published edits will not appear in the body (still in commit history).",conflictForceConfirm:"Overwrite the cloud copy with your local draft and discard others' published body changes. This cannot be undone automatically. Continue?",conflictForceBusy:"Overwriting…",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",mergeReceive:"Accept",mergeReject:"Reject",mergeUseAllMine:"Use all mine",mergeUseAllTheirs:"Use all theirs",mergeReviewHint:"Red = mine · Green = theirs; Accept takes theirs, Reject keeps mine",mergeEditAfterResolve:"All conflicts resolved — you can edit the document",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.",pullBlockedDraft:"Local draft exists — cannot overwrite with pull. Publish, or use Pull when behind to open merge.",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:"Workspace",bookmarkColAuthor:"Author",bookmarkColTime:"Bookmarked",bookmarkSearch:"Search bookmarks",bookmarkFilterAll:"All workspaces",bookmarkNoMatch:"No matching bookmarks",myDocuments:"My Documents",myDocumentsEmpty:"No documents yet",myDocumentsColTitle:"Title",myDocumentsColDomain:"Workspace",myDocumentsColCreator:"Creator",myDocumentsColUpdated:"Updated",myDocumentsColCreated:"Created",myDocumentsFilterDomain:"Filter by workspace",myDocumentsFilterAllDomains:"All workspaces",myDocumentsFilterCreator:"Filter by creator",myDocumentsFilterAllCreators:"All creators",myDocumentsGroupBy:"Group",myDocumentsGroupNone:"No grouping",myDocumentsGroupDomain:"Group by workspace",myDocumentsGroupCreator:"Group by creator",myDocumentsNoMatch:"No matching documents",myDocumentsPrev:"Previous",myDocumentsNext:"Next",myDocumentsJumpTo:"Go to",myDocumentsJump:"Go",myDocumentsPageInfo:"Page {{current}}/{{total}}, {{count}} total",myDocumentsSearchMode:"Search mode",myDocumentsModeAuto:"Default (hybrid)",myDocumentsModeKeyword:"Keyword",myDocumentsModeSemantic:"Semantic",myDocumentsSemanticNotReady:"Embedding model not ready; semantic search unavailable",myDocumentsSemanticNotReadyShort:"Model not ready; results may be incomplete",myDocumentsResultCount:"{{count}} results",embeddingIndex:"Semantic index",embeddingIndexDesc:"Select readable docs and rebuild local embedding vectors. Last build time comes from chunk rows.",embeddingIndexModel:"Model",embeddingIndexModelReady:"Ready",embeddingIndexModelPending:"Not ready (downloads/loads in background after start)",embeddingIndexOnlyMissing:"Missing only",embeddingIndexFilterBuilt:"Built",embeddingIndexFilterMissing:"Not built",embeddingIndexFilterReset:"Reset",embeddingIndexFilterOk:"OK",embeddingIndexPageTotal:"{{from}}–{{to}} of {{total}}",embeddingIndexPageSize:"Per page",embeddingIndexGoPage:"Page",embeddingIndexRefresh:"Refresh",embeddingIndexSearchPlaceholder:"Search title / path / ID…",embeddingIndexSearchSemanticPlaceholder:"Semantic search: describe what you're looking for…",embeddingIndexRebuildSelected:"Rebuild selected ({{count}})",embeddingIndexRebuilding:"Rebuilding…",embeddingIndexRebuildResult:"Done: ok {{ok}}, skipped {{skipped}}, failed {{failed}}",embeddingIndexRebuildFailed:"Rebuild failed",embeddingIndexLoadFailed:"Failed to load embedding index list",embeddingIndexEmpty:"No documents to manage",embeddingIndexSelectAll:"Select all in view",embeddingIndexColStatus:"Semantic status",embeddingIndexColBuiltAt:"Last semantic build",embeddingIndexColDocUpdated:"Doc updated",embeddingIndexStatusReady:"Indexed ({{chunks}} chunks)",embeddingIndexStatusBuiltUnknown:"Indexed",embeddingIndexStatusMissing:"Not indexed",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",docSearch:"Search documents",docSearchTitle:"Search documents",docSearchPlaceholder:"Search titles or body…",docSearchEmptyHint:"Type to search; all workspaces by default",docSearchNoResults:"No matching documents",docSearchHitTitle:"Title",docSearchHitBody:"Body",docSearchHitSemantic:"Semantic",docSearchNoDomain:"Select a workspace first",docSearchFailed:"Search failed",docSearchAllDomains:"All workspaces",docSearchDomainAria:"Search scope",docSearchDomainFilter:"Filter workspaces…",docSearchDomainNoMatch:"No matching workspaces",logout:"Sign out"},qs={loading:"加载中...",saved:"已保存",saving:"保存中...",unsaved:"编辑中...",publish:"发布",publishing:"发布中...",published:"已发布",preview:"预览",cancel:"取消",create:"创建",creating:"创建中...",close:"关闭",delete:"删除",save:"保存",gotIt:"知道了",error:"错误",brand:"mdocs",welcomeTitle:"欢迎使用 mdocs",welcomeDesc:"输入一个显示名称以创建访客身份。一个安全令牌将存储在此浏览器中,以便在后续访问时识别您。",visitorNamePlaceholder:"您的名字",createVisitor:"创建访客",nameRequired:"请输入名称",visitorIdNotice:"您的访客 ID 是 {{id}},请保存以便恢复",newDocument:"开始写作",startWriting:"开始写作",newArticle:"新建文章",newDirectory:"新建目录",newFolder:"新建文件夹",noDocumentsYet:"暂无文档",collapseFolder:"收起文件夹",expandFolder:"展开文件夹",noDocsInDomain:"此工作空间尚无文档。请在下方切换工作空间或创建文档。",createDocToStart:"点「开始写作」,或从左侧打开一篇文档。",domainLabel:"工作空间",defaultDomain:"默认",displayNamePlaceholder:"显示名称",currentDomainAria:"当前工作空间",insertDiagram:"插入图表",outlineHide:"隐藏大纲",outlineShow:"显示大纲",readOnlyNotice:`> 您无权限编辑
135
+
136
+ `,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}}」",copyDocumentId:"复制 documentId",copyDocumentUrl:"复制 URL",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:"改类型",domainPermissionNoDowngrade:"不能把权限改得更封闭。",domainPermissionAlreadyTop:"已经是最开放的权限。",domainNotModifiable:"系统预设,不可修改",domainTooltipTypeLocked:"已有文档时只能把权限改得更开放,不能收回。",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:"解决冲突",conflictForce:"强制覆盖",conflictForceHint:"仅文档所有者可用。覆盖后云端以你的本地正文为准,他人已发布的改动不会进入正文(仍可在提交历史中查看)。",conflictForceConfirm:"将用本地正文覆盖云端,丢弃他人已发布的正文变更。此操作不可自动撤销。继续?",conflictForceBusy:"覆盖中…",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:"手动编辑",mergeReceive:"接收",mergeReject:"拒绝",mergeUseAllMine:"全部用我的",mergeUseAllTheirs:"全部用别人的",mergeReviewHint:"红=我的 · 绿=别人的;接收用别人的,拒绝留我的",mergeEditAfterResolve:"冲突已处理完,可继续修改正文",mergeNoConflicts:"本地与远端正文一致,可直接发布。",mergeResultHint:"由冲突决议自动拼接,也可直接修改",mergeResultInlineHint:"相对祖先有改动的行均需在正文中点选确认",mergeBase:"祖先",mergeBaseMissing:"无法加载公共祖先,已退化为两方比对",pullBlockedConflict:"存在未解决的冲突,请先合并。",pullBlockedDraft:"有未发布的本地草稿,无法覆盖拉取。可点「发布」或在落后时点「拉取更新」进入合并。",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:"工作空间",myDocumentsColCreator:"创建者",myDocumentsColUpdated:"更新时间",myDocumentsColCreated:"创建时间",myDocumentsFilterDomain:"按工作空间筛选",myDocumentsFilterAllDomains:"全部工作空间",myDocumentsFilterCreator:"按创建者筛选",myDocumentsFilterAllCreators:"全部创建者",myDocumentsGroupBy:"分组",myDocumentsGroupNone:"不分组",myDocumentsGroupDomain:"按工作空间分组",myDocumentsGroupCreator:"按创建者分组",myDocumentsNoMatch:"暂无匹配的文章",myDocumentsPrev:"上一页",myDocumentsNext:"下一页",myDocumentsJumpTo:"跳至",myDocumentsJump:"跳转",myDocumentsPageInfo:"第 {{current}}/{{total}} 页,共 {{count}} 篇",myDocumentsSearchMode:"检索模式",myDocumentsModeAuto:"默认(混合)",myDocumentsModeKeyword:"关键词",myDocumentsModeSemantic:"语义",myDocumentsSemanticNotReady:"语义模型未就绪,暂无法语义检索",myDocumentsSemanticNotReadyShort:"语义模型未就绪,结果可能不全",myDocumentsResultCount:"共 {{count}} 条结果",embeddingIndex:"语义索引",embeddingIndexDesc:"勾选可读文档,手动重建本地语义向量。上次构建时间取自向量块。",embeddingIndexModel:"模型状态",embeddingIndexModelReady:"已就绪",embeddingIndexModelPending:"未就绪(启动后异步下载/加载)",embeddingIndexOnlyMissing:"仅未建",embeddingIndexFilterBuilt:"已建",embeddingIndexFilterMissing:"未建",embeddingIndexFilterReset:"重置",embeddingIndexFilterOk:"确定",embeddingIndexPageTotal:"第 {{from}}–{{to}} 条,共 {{total}} 篇",embeddingIndexPageSize:"每页",embeddingIndexGoPage:"页码",embeddingIndexRefresh:"刷新",embeddingIndexSearchPlaceholder:"搜索文章标题 / 路径 / ID…",embeddingIndexSearchSemanticPlaceholder:"语义搜索:用一句话描述要找的内容…",embeddingIndexRebuildSelected:"重建所选 ({{count}})",embeddingIndexRebuilding:"重建中…",embeddingIndexRebuildResult:"完成:成功 {{ok}},跳过 {{skipped}},失败 {{failed}}",embeddingIndexRebuildFailed:"重建失败",embeddingIndexLoadFailed:"加载语义索引列表失败",embeddingIndexEmpty:"没有可管理的文档",embeddingIndexSelectAll:"全选当前列表",embeddingIndexColStatus:"语义状态",embeddingIndexColBuiltAt:"上次语义构建",embeddingIndexColDocUpdated:"文章更新时间",embeddingIndexStatusReady:"已建 ({{chunks}} 块)",embeddingIndexStatusBuiltUnknown:"已建",embeddingIndexStatusMissing:"未建",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:"重置位置",docSearch:"搜索文档",docSearchTitle:"搜索文档",docSearchPlaceholder:"搜索标题或正文…",docSearchEmptyHint:"输入关键词搜索;默认全部工作空间",docSearchNoResults:"没有匹配的文档",docSearchHitTitle:"标题",docSearchHitBody:"正文",docSearchHitSemantic:"语义",docSearchNoDomain:"请先选择工作空间",docSearchFailed:"搜索失败",docSearchAllDomains:"全部工作空间",docSearchDomainAria:"选择搜索范围",docSearchDomainFilter:"筛选工作空间…",docSearchDomainNoMatch:"没有匹配的工作空间",logout:"退出登录"},ji="mdocs.lang",Ks={en:Ws,zh:qs};function Ys(){const e=window.localStorage.getItem(ji);return e==="zh"||e==="en"?e:navigator.language.toLowerCase().startsWith("zh")?"zh":"en"}const Mi=x.createContext(null);function Js({children:e}){const[n,r]=x.useState(Ys);x.useEffect(()=>{document.documentElement.lang=n==="zh"?"zh-CN":"en"},[n]);const o=x.useCallback(i=>{window.localStorage.setItem(ji,i),r(i)},[]),a=x.useCallback((i,s)=>{let l=Ks[n][i]??i;if(s)for(const[u,d]of Object.entries(s))l=l.replaceAll(`{{${u}}}`,d);return l},[n]);return c.jsx(Mi.Provider,{value:{lang:n,setLang:o,t:a},children:e})}function Je(){const e=x.useContext(Mi);if(!e)throw new Error("useI18n must be used within I18nProvider");return e}function an(e){const{content:n,contentHash:r,...o}=e;return o}function Xs(){let e=Promise.resolve();return{execute:r=>{const o=e.then(r);return e=o.then(()=>{},()=>{}),o}}}const No=new Map;function ir(e){let n=No.get(e);return n||(n=Xs(),No.set(e,n)),n}const nt={PRIVATE:0,DOMAIN_READ:1,DOMAIN_WRITE:2,PUBLIC_READ:3,PUBLIC_WRITE:4};function Po(e){return e===nt.PUBLIC_WRITE}function Yf(e){return e==="public"?[nt.PUBLIC_READ,nt.PUBLIC_WRITE]:e==="restricted"?[nt.DOMAIN_READ,nt.DOMAIN_WRITE]:[nt.PRIVATE,nt.DOMAIN_READ,nt.DOMAIN_WRITE,nt.PUBLIC_READ,nt.PUBLIC_WRITE]}const To="___desc___.md";function Zs(e){const n=e.trim();return n?`${n}/${To}`:To}class kt extends Error{constructor(n){super(n),this.name="DocPathError"}}const Qs=120,el=200;function Dr(e){let n=e.trim().replace(/\s+/g,"_");for(n=n.replace(/[^A-Za-z0-9_\-\.\u4e00-\u9fa5]/g,"_"),n=n.replace(/_+/g,"_"),n=n.replace(/^[._]+|[._]+$/g,"");n.includes("..");)n=n.replace(/\.\./g,"_");return n==="."||n===".."||!n?"":n}function tl(e){const n=e.trim();return n?n.includes("/")||n.includes("\\")?{ok:!1,message:"use a single name, not a path"}:n==="."||n===".."?{ok:!1,message:"invalid folder name"}:n.length>Qs?{ok:!1,message:"folder name is too long"}:{ok:!0,display:n}:{ok:!1,message:"enter a folder name"}}function Ao(e){let n=e.trim();if(!n)return{ok:!1,message:"enter a file name"};if(n.includes("/")||n.includes("\\"))return{ok:!1,message:"use a file name, not a path"};if(n==="."||n==="..")return{ok:!1,message:"invalid file name"};const r=n.toLowerCase();return!r.endsWith(".md")&&!r.endsWith(".html")&&(n+=".md"),n.length>el?{ok:!1,message:"file name is too long"}:{ok:!0,displayFile:n}}function jo(e){const n=e.trim().replace(/\\/g,"/");if(!n)throw new kt("relative path is required");if(n.startsWith("/"))throw new kt("path must be relative");if(n.includes(".."))throw new kt("path must not contain ..");const r=n.split("/").filter(h=>h.length>0);if(r.length===0)throw new kt("relative path is required");const o=[];for(let h=0;h<r.length-1;h+=1){const m=Dr(r[h]);if(!m)throw new kt("invalid path segment");o.push(m)}const a=r[r.length-1],i=a.toLowerCase(),s=i.endsWith(".html")?".html":i.endsWith(".md")?".md":null;if(!s)throw new kt("document path must end with .md or .html");const l=a.slice(0,-s.length),u=a.slice(-s.length),d=Dr(l);if(!d)throw new kt("invalid file name");return o.push(d+u),o.join("/")}class Ye extends Error{constructor(r,o,a,i){super(a);qt(this,"code");qt(this,"status");qt(this,"details");this.status=r,this.code=o,this.details=i}}const nl={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:`// 伪代码:表达「内容即文档」
137
+ 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
138
+ A[写 Markdown] --> B[整理知识库]
139
+ 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="&quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, 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="&quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, 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"},rl={root:nl},Mo=JSON.stringify(rl),rt="demo-visitor-001",Jf={visitorId:rt,visitorName:"Demo User",createdAt:new Date().toISOString(),lastSeenAt:new Date().toISOString(),disabledAt:null,mergedIntoVisitorId:null};function Pn(e){let n=0;for(let r=0;r<e.length;r++){const o=e.charCodeAt(r);n=(n<<5)-n+o,n=n&n}return Math.abs(n).toString(16).padStart(64,"0")}const Eo=`# Markdown 语法指南
140
+
141
+ ## 基础格式
142
+
143
+ **粗体文本**、*斜体文本*、~~删除线~~
144
+
145
+ ## 列表
146
+
147
+ ### 无序列表
148
+ - 项目一
149
+ - 项目二
150
+ - 嵌套项目
151
+
152
+ ### 有序列表
153
+ 1. 第一项
154
+ 2. 第二项
155
+ 3. 第三项
156
+
157
+ ## 代码
158
+
159
+ \`\`\`typescript
160
+ function hello(name: string): string {
161
+ return \`Hello, \${name}!\`;
162
+ }
163
+ \`\`\`
164
+
165
+ ## 表格
166
+
167
+ | 功能 | 支持 |
168
+ |------|------|
169
+ | Markdown | ✅ |
170
+ | 图表 | ✅ |
171
+ | 公式 | ✅ |
172
+
173
+ ## 引用
174
+
175
+ > 这是一段引用文本
176
+ > 可以有多行
177
+
178
+ ## 链接和图片
179
+
180
+ [访问 GitHub](https://github.com)
181
+
182
+ ## 数学公式(KaTeX)
183
+
184
+ 行内公式:$E = mc^2$
185
+
186
+ 块级公式:
187
+
188
+ $$
189
+ \\int_{-\\infty}^{\\infty} e^{-x^2} dx = \\sqrt{\\pi}
190
+ $$
191
+ `,Oo=`# 图表支持示例
192
+
193
+ mdocs 集成了多种图表类型。
194
+
195
+ ## Mermaid 流程图
196
+
197
+ \`\`\`mermaid
198
+ flowchart LR
199
+ A[开始] --> B{判断}
200
+ B -->|是| C[处理]
201
+ B -->|否| D[结束]
202
+ C --> D
203
+ \`\`\`
204
+
205
+ ## Mermaid 序列图
206
+
207
+ \`\`\`mermaid
208
+ sequenceDiagram
209
+ participant 用户
210
+ participant 前端
211
+ participant 后端
212
+
213
+ 用户->>前端: 输入内容
214
+ 前端->>后端: 提交数据
215
+ 后端-->>前端: 返回结果
216
+ 前端-->>用户: 显示成功
217
+ \`\`\`
218
+
219
+ ## Mermaid 甘特图
220
+
221
+ \`\`\`mermaid
222
+ gantt
223
+ title 项目进度
224
+ dateFormat YYYY-MM-DD
225
+ section 设计
226
+ 需求分析 :done, des1, 2024-01-01, 5d
227
+ 技术选型 :done, des2, after des1, 3d
228
+ section 开发
229
+ 前端开发 :active, dev1, 2024-01-09, 10d
230
+ 后端开发 : dev2, 2024-01-09, 10d
231
+ \`\`\`
232
+ `,Ro=`# 个人笔记
233
+
234
+ 这是我的私人域中的笔记,只有我能看到。
235
+
236
+ ## 今日待办
237
+
238
+ - [x] 完成 mdocs demo 模式
239
+ - [ ] 测试所有功能
240
+ - [ ] 部署到 GitHub Pages
241
+
242
+ ## 想法
243
+
244
+ Demo 模式的核心设计:
245
+ 1. API 层透明切换
246
+ 2. 数据存储在 IndexedDB
247
+ 3. 用户无感知切换
248
+
249
+ `,Xf=[{documentId:"doc-welcome",relativePath:"README.md",displayName:"README",content:Mo,contentHash:Pn(Mo),permission:1,ownerVisitorId:rt,domainId:"default",updatedBy:rt,updatedAt:new Date().toISOString(),createdAt:new Date().toISOString(),fileType:"md",parentId:null},{documentId:"doc-markdown-guide",relativePath:"指南/Markdown 语法.md",displayName:"Markdown 语法",content:Eo,contentHash:Pn(Eo),permission:1,ownerVisitorId:rt,domainId:"default",updatedBy:rt,updatedAt:new Date().toISOString(),createdAt:new Date().toISOString(),fileType:"md",parentId:null},{documentId:"doc-diagram-guide",relativePath:"指南/图表支持.md",displayName:"图表支持",content:Oo,contentHash:Pn(Oo),permission:1,ownerVisitorId:rt,domainId:"default",updatedBy:rt,updatedAt:new Date().toISOString(),createdAt:new Date().toISOString(),fileType:"md",parentId:null},{documentId:"doc-personal-note",relativePath:"个人笔记.md",displayName:"个人笔记",content:Ro,contentHash:Pn(Ro),permission:0,ownerVisitorId:rt,domainId:rt,updatedBy:rt,updatedAt:new Date().toISOString(),createdAt:new Date().toISOString(),fileType:"md",parentId:null}];const Vr="mdocs.visitorId",Nr="mdocs-api-error";function ol(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(Nr,{detail:{status:e.status,code:e.code,message:e.message}}))}function Ei(){return!1}function Zf(){return window.localStorage.getItem(Vr)}function Fn(e){window.localStorage.setItem(Vr,e)}function il(){window.localStorage.removeItem(Vr)}async function V(e,n={}){try{Ei();const r=new Headers(n.headers);!r.has("Content-Type")&&n.body&&r.set("Content-Type","application/json");const o=await fetch(e,{...n,headers:r});if(o.status===204)return;const a=await o.text();let i;try{i=a?JSON.parse(a):null}catch{throw new Ye(o.status,"BAD_RESPONSE","response is not valid JSON")}if(!o.ok){const s=i==null?void 0:i.error;throw new Ye(o.status,(s==null?void 0:s.code)??"UNKNOWN",(s==null?void 0:s.message)??"request failed",s==null?void 0:s.details)}return i.data}catch(r){throw r instanceof Ye&&!n.silent&&ol(r),r}}const Ln="default",Qf=["public","restricted","private"];function em(e){return e===Ln}function tm(e,n){return n!==null&&e.creatorVisitorId===n}function nm(e){return e.docCount>0}function al(e,n){return V("/api/visitors/register",{method:"POST",body:JSON.stringify({visitorName:e,password:n})})}function sl(e){return V("/api/visitors/recover",{method:"POST",body:JSON.stringify({recoveryCode:e})})}function ll(e,n){return V("/api/visitors/login",{method:"POST",body:JSON.stringify({visitorName:e,password:n})})}function rm(e){return V("/api/visitors/set-password",{method:"POST",body:JSON.stringify({password:e})})}function om(){return V("/api/visitors/recovery-code",{method:"POST"})}async function Fo(){return(await V("/api/visitors/me")).visitor}function im(){return V("/api/visitors").then(e=>e.visitors)}function cl(){return V("/api/domains")}function am(e){return V("/api/domains",{method:"POST",body:JSON.stringify(e)})}function sm(e,n){return V(`/api/domains/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({domainName:n})})}function lm(e,n){return V(`/api/domains/${encodeURIComponent(e)}/permission`,{method:"PUT",body:JSON.stringify({permission:n})})}function cm(e){return V(`/api/domains/${encodeURIComponent(e)}`,{method:"DELETE"})}function dm(e){return V(`/api/domains/${encodeURIComponent(e)}/members`).then(n=>n.members)}function um(e,n){return V(`/api/domains/${encodeURIComponent(e)}/members`,{method:"PUT",body:JSON.stringify({visitorIds:n})})}function fm(){return V("/api/domain-member-templates")}function mm(e){return V("/api/domain-member-templates",{method:"POST",body:JSON.stringify(e)})}function hm(e,n){return V(`/api/domain-member-templates/${encodeURIComponent(String(e))}`,{method:"PUT",body:JSON.stringify(n)})}function pm(e){return V(`/api/domain-member-templates/${encodeURIComponent(String(e))}`,{method:"DELETE"})}function dl(e){const n=e!=null&&e.trim()?`?domainId=${encodeURIComponent(e.trim())}`:"";return V(`/api/tree${n}`)}function Kt(e){return V(`/api/documents/${encodeURIComponent(e)}`)}function Pr(e){return V("/api/documents",{method:"POST",body:JSON.stringify(e)})}function ar(e,n){return V(`/api/documents/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(n)})}function ul(e,n){const r=n?`?localBaseCommitId=${encodeURIComponent(n)}`:"";return V(`/api/documents/${encodeURIComponent(e)}/sync-status${r}`,{silent:!0})}function gm(e,n,r){const o=new URLSearchParams({localBaseCommitId:n,remoteCommitId:r});return V(`/api/documents/${encodeURIComponent(e)}/merge-context?${o}`)}function sr(e){return V("/api/documents/convert",{method:"POST",body:JSON.stringify(e)})}function fl(e){return V(`/api/documents/${encodeURIComponent(e)}`,{method:"DELETE"})}function ml(e,n){return V(`/api/documents/${encodeURIComponent(e)}/move`,{method:"POST",body:JSON.stringify({parentId:n})})}function ym(e){return V(`/api/documents/${encodeURIComponent(e)}/invites`)}function vm(e,n,r){return V(`/api/documents/${encodeURIComponent(e)}/invites`,{method:"POST",body:JSON.stringify({targetVisitorId:n,targetPermission:r})})}function bm(e,n){return V(`/api/documents/${encodeURIComponent(e)}/invites/${encodeURIComponent(n)}`,{method:"DELETE"})}async function xm(e,n){var d;const r=new FormData;r.append("file[]",e),r.append("documentId",n);const o=new Headers,a=await fetch("/api/assets/upload",{method:"POST",headers:o,body:r}),i=await a.json(),s=i;if(!a.ok||s.code===1){const h=i==null?void 0:i.error;throw new Ye(a.status,(h==null?void 0:h.code)??"UPLOAD_FAILED",(h==null?void 0:h.message)??s.msg??"upload failed")}const l=((d=s.data)==null?void 0:d.succMap)??{},u=Object.values(l);if(u.length===0)throw new Error("upload succeeded but no URL returned");return u[0]}function hl(e){return V("/api/folders",{method:"POST",body:JSON.stringify(e)})}function pl(e){return V(`/api/documents/folder/${encodeURIComponent(e)}`,{method:"DELETE"})}function wm(e){return V("/api/cli/tokens",{method:"POST",body:JSON.stringify({})})}function _m(){return V("/api/cli/tokens")}function gl(e){return V("/api/documents/search",{method:"POST",body:JSON.stringify(e)})}function km(e){return V("/api/documents/embedding-index")}function Im(e){return V("/api/documents/embedding-rebuild",{method:"POST",body:JSON.stringify({documentIds:e})})}function yl(){return V("/api/bookmarks")}function Sm(e){return V(`/api/bookmarks/${encodeURIComponent(e)}`)}function Cm(e){return V(`/api/bookmarks/${encodeURIComponent(e)}`,{method:"POST"})}function vl(e){return V(`/api/bookmarks/${encodeURIComponent(e)}`,{method:"DELETE"})}function Dm(e={}){const n=new URLSearchParams({offset:String(e.offset??0),limit:String(e.limit??20)});return e.domainId&&n.set("domainId",e.domainId),e.creatorVisitorId&&n.set("creatorVisitorId",e.creatorVisitorId),e.groupBy&&n.set("groupBy",e.groupBy),V(`/api/visitors/me/documents?${n}`)}function bl(e){return V(`/api/documents/${encodeURIComponent(e)}/comments`)}function xl(e,n){return V(`/api/documents/${encodeURIComponent(e)}/comments`,{method:"POST",body:JSON.stringify(n)})}function wl(e,n){return V(`/api/documents/${encodeURIComponent(e)}/comments/${encodeURIComponent(n)}`,{method:"DELETE"})}function Nm(){return V("/api/agent/configs")}function Lo(e){return V("/api/agent/config",{method:"PUT",body:JSON.stringify(e)})}function Pm(e){return V(`/api/agent/config/${encodeURIComponent(e)}/default`,{method:"POST"})}function Tm(e){return V(`/api/agent/config/${encodeURIComponent(e)}`,{method:"DELETE"})}function Am(){return V("/api/agent/skills")}function jm(e){return V("/api/agent/skills",{method:"POST",body:JSON.stringify(e)})}function Mm(e,n){return V(`/api/agent/skills/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(n)})}function Em(e){return V(`/api/agent/skills/${encodeURIComponent(e)}`,{method:"DELETE"})}function Om(){return V("/api/agent/status")}function Rm(){return V("/api/agent/context-usage")}function Fm(e="normal",n){const r=new URLSearchParams;e==="coding"&&(r.set("mode","coding"),n&&r.set("documentId",n));const o=r.toString();return V(`/api/agent/session${o?`?${o}`:""}`)}function Lm(e="normal",n){const r=new URLSearchParams;e==="coding"&&(r.set("mode","coding"),n&&r.set("documentId",n));const o=r.toString();return V(`/api/agent/sessions${o?`?${o}`:""}`)}function zm(e="normal",n){return V("/api/agent/sessions",{method:"POST",body:JSON.stringify({mode:e,...e==="coding"?{documentId:n??null}:{}})})}function $m(e,n="normal",r){return V("/api/agent/session/open",{method:"POST",body:JSON.stringify({sessionId:e,mode:n,...n==="coding"?{documentId:r??null}:{}})})}function Um(e,n){return V("/api/agent/session/bind-document",{method:"POST",body:JSON.stringify({sessionId:e,documentId:n})})}function Bm(e,n){return V("/api/agent/choice",{method:"POST",body:JSON.stringify({requestId:e,choice:n})})}function Hm(e){return V("/api/agent/choice",{method:"POST",body:JSON.stringify({requestId:e,expire:!0})})}function Vm(e){return V("/api/agent/choice",{method:"POST",body:JSON.stringify({requestId:e,cancel:!0})})}function Gm(e,n){return V("/api/agent/skill-form",{method:"POST",body:JSON.stringify({requestId:e,...n})})}function Wm(e){return V("/api/agent/skill-form",{method:"POST",body:JSON.stringify({requestId:e,expire:!0})})}function qm(e){return V("/api/agent/skill-form",{method:"POST",body:JSON.stringify({requestId:e,cancel:!0})})}async function Km(e,n){var d;const r={message:e,mode:n.mode==="coding"?"coding":"normal"},o=n.skillNames&&n.skillNames.length>0?n.skillNames:n.skillIds&&n.skillIds.length>0?n.skillIds:void 0;o&&(r.skillNames=o),n.mode==="coding"?(n.documentId!==void 0&&(r.documentId=n.documentId),typeof n.workingMarkdown=="string"&&(r.workingMarkdown=n.workingMarkdown),typeof n.baseMarkdown=="string"&&(r.baseMarkdown=n.baseMarkdown)):n.references&&(r.references=n.references);const a=await fetch("/api/agent/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:n.signal});if(!a.ok){let h=`HTTP ${a.status}`;try{const m=await a.json();(d=m.error)!=null&&d.message&&(h=m.error.message)}catch{}throw new Error(h)}if(!a.body)throw new Error("empty response body");const i=a.body.getReader(),s=new TextDecoder;let l="";for(;;){const{done:h,value:m}=await i.read();if(h)break;l+=s.decode(m,{stream:!0});const f=l.split(`
250
+ `);l=f.pop()??"";for(const p of f){const g=p.trim();if(!g.startsWith("data:"))continue;const w=g.slice(5).trim();if(!(!w||w==="[DONE]"))try{n.onEvent(JSON.parse(w))}catch{}}}const u=l.trim();if(u.startsWith("data:")){const h=u.slice(5).trim();if(h&&h!=="[DONE]")try{n.onEvent(JSON.parse(h))}catch{}}}function zo(e){return V(`/api/graph/${e}`,{method:"GET"})}function _l(e){return V(`/api/graph/${e}/analyze`,{method:"POST"})}function $o(e){return V(`/api/graph/domain/${e}`,{method:"GET"})}function kl(e){return V(`/api/graph/domain/${e}/analyze`,{method:"POST"})}function Il(e){return V(`/api/graph/tasks/${encodeURIComponent(e)}`,{method:"GET"})}const Sl={domainId:Ln,domainName:"Default",permission:"public",creatorVisitorId:"",docCount:0};async function Gr(){try{return await cl()}catch{return[Sl]}}function Cl(e,n){var r,o,a;return((r=e.find(i=>i.domainId===n))==null?void 0:r.domainId)??((o=e.find(i=>i.domainId===Ln))==null?void 0:o.domainId)??((a=e[0])==null?void 0:a.domainId)??Ln}function Dl(e){const{t:n}=Je(),[r,o]=x.useState(!1),[a,i]=x.useState(null),[s,l]=x.useState("login"),[u,d]=x.useState(""),[h,m]=x.useState(""),[f,p]=x.useState("password"),[g,w]=x.useState(""),[b,v]=x.useState(""),[I,D]=x.useState("");function N(R){if(R.preventDefault(),!u.trim()){i(n("nameRequired"));return}i(null),l("register-password")}async function _(R){R.preventDefault(),o(!0),i(null);try{const $=h.trim();await e.onSubmit(u.trim(),$||void 0),d(""),m(""),l("login"),p("password"),w(u.trim()),v($||"")}catch($){i($ instanceof Error?$.message:String($)),l("register")}finally{o(!1)}}async function T(R){R.preventDefault();const $=g.trim(),H=b.trim();if(!$||!H){i("请输入用户名和密码");return}o(!0),i(null);try{const J=await ll($,H);Fn(J.visitor.visitorId),await e.onRecover(J.visitor.visitorId)}catch(J){i(J instanceof Error?J.message:String(J))}finally{o(!1)}}async function C(R){R.preventDefault();const $=I.trim();if(!$){i("请输入恢复码");return}o(!0),i(null);try{const H=await sl($);Fn(H.visitor.visitorId),await e.onRecover(H.visitor.visitorId)}catch(H){i(H instanceof Error?H.message:String(H))}finally{o(!1)}}const P=a??e.error;function z(){i(null),d(""),m(""),l("register")}function E(){i(null),l("login")}return c.jsx("div",{className:"mdocs-dialog-backdrop",children:c.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:420},children:[s==="login"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{style:{display:"flex",gap:16,marginBottom:16,fontSize:"0.875rem"},children:[c.jsx("button",{type:"button",onClick:()=>{i(null),p("password")},style:{background:"none",border:"none",color:f==="password"?"var(--mdocs-accent)":"var(--mdocs-text-secondary)",cursor:"pointer",padding:"4px 0",borderBottom:f==="password"?"2px solid var(--mdocs-accent)":"none",fontWeight:f==="password"?600:400},children:"用户名+密码"}),c.jsx("button",{type:"button",onClick:()=>{i(null),p("recovery")},style:{background:"none",border:"none",color:f==="recovery"?"var(--mdocs-accent)":"var(--mdocs-text-secondary)",cursor:"pointer",padding:"4px 0",borderBottom:f==="recovery"?"2px solid var(--mdocs-accent)":"none",fontWeight:f==="recovery"?600:400},children:"恢复码"})]}),f==="password"?c.jsxs(c.Fragment,{children:[c.jsx("h1",{children:"🔑 使用密码登录"}),c.jsx("p",{children:"输入用户名和密码,在其他设备上找回你的身份。"}),c.jsxs("form",{onSubmit:T,children:[c.jsx("input",{autoFocus:!0,placeholder:"用户名",value:g,onChange:R=>w(R.target.value),maxLength:60,style:{marginBottom:8}}),c.jsx("input",{type:"password",placeholder:"密码",value:b,onChange:R=>v(R.target.value)}),P&&c.jsx("div",{className:"mdocs-dialog-error",children:P}),c.jsx("button",{type:"submit",className:"primary",disabled:r,children:r?"验证中…":"登录"})]})]}):c.jsxs(c.Fragment,{children:[c.jsx("h1",{children:"🔑 使用恢复码找回"}),c.jsx("p",{children:"输入注册时保存的恢复码,系统将为您生成新的身份令牌。"}),c.jsxs("form",{onSubmit:C,children:[c.jsx("input",{autoFocus:!0,placeholder:"ABCD-EFGH-IJKL-MNOP",value:I,onChange:R=>D(R.target.value),style:{fontFamily:"monospace",letterSpacing:"0.1em"},maxLength:30}),P&&c.jsx("div",{className:"mdocs-dialog-error",children:P}),c.jsx("button",{type:"submit",className:"primary",disabled:r,children:r?"验证中…":"找回身份"})]})]}),c.jsx("p",{style:{marginTop:16,textAlign:"center"},children:c.jsx("button",{type:"button",style:{background:"none",border:"none",color:"var(--mdocs-accent)",cursor:"pointer",fontSize:"0.875rem",textDecoration:"underline",padding:0},onClick:z,children:"没有账号?点击注册"})})]}),s==="register"&&c.jsxs(c.Fragment,{children:[c.jsx("h1",{children:n("welcomeTitle")}),c.jsx("p",{children:n("welcomeDesc")}),c.jsxs("form",{onSubmit:N,children:[c.jsx("input",{autoFocus:!0,placeholder:n("visitorNamePlaceholder"),value:u,onChange:R=>d(R.target.value),maxLength:60}),P&&c.jsx("div",{className:"mdocs-dialog-error",children:P}),c.jsx("button",{type:"submit",className:"primary",disabled:r,children:"下一步"})]}),c.jsx("p",{style:{marginTop:16,textAlign:"center"},children:c.jsx("button",{type:"button",style:{background:"none",border:"none",color:"var(--mdocs-accent)",cursor:"pointer",fontSize:"0.875rem",textDecoration:"underline",padding:0},onClick:E,children:"已有账号?点击登录"})})]}),s==="register-password"&&c.jsxs(c.Fragment,{children:[c.jsx("h1",{children:"设置密码(可选)"}),c.jsx("p",{style:{marginBottom:8},children:"设置密码后,你可以在其他浏览器或设备上使用「用户名+密码」登录。"}),c.jsx("p",{style:{color:"var(--mdocs-text-secondary)",fontSize:"0.875rem",marginBottom:16},children:"留空不设置密码也能正常使用,但只能在当前浏览器操作。"}),c.jsxs("form",{onSubmit:_,children:[c.jsx("input",{autoFocus:!0,type:"password",placeholder:"设置密码(至少 4 位)",value:h,onChange:R=>m(R.target.value),minLength:4}),P&&c.jsx("div",{className:"mdocs-dialog-error",children:P}),c.jsx("button",{type:"submit",className:"primary",disabled:r,style:{marginTop:8},children:r?n("creating"):"完成注册"})]}),c.jsx("p",{style:{marginTop:16,textAlign:"center"},children:c.jsx("button",{type:"button",style:{background:"none",border:"none",color:"var(--mdocs-text-secondary)",cursor:"pointer",fontSize:"0.875rem",padding:0},onClick:()=>l("register"),children:"← 返回上一步"})})]})]})})}function Nl(e){const{t:n}=Je();return c.jsxs("div",{className:"mdocs-notice card",children:[c.jsx("span",{children:n("visitorIdNotice",{id:e.visitorId})}),c.jsx("button",{type:"button",onClick:e.onDismiss,children:n("gotIt")})]})}const Oi="application/x-mdocs-document-id",Tr="mdocs-doc:";let Ft=null;function Ri(e,n,r=[]){for(const o of e){if(o.type==="document"){if(o.documentId===n)return{forceOpenFolderIds:r,scrollTreeId:o.documentId};continue}if(o.descDocumentId===n)return{forceOpenFolderIds:r,scrollTreeId:o.documentId};const a=Ri(o.children,n,[...r,o.documentId]);if(a)return a}return null}function Wr(e){if(Ft)return Ft;try{const n=e.getData(Oi);if(n)return n;const r=e.getData("text/plain")||e.getData("Text");if(r.startsWith(Tr))return r.slice(Tr.length)}catch{}return""}function St(e){return!!(e&&Ft)}function Pl(e){const{t:n}=Je(),r=x.useRef(null),[o,a]=x.useState(null),[i,s]=x.useState(null),l=x.useMemo(()=>{var v,I;const b=((v=e.graphFocusAnchorId)==null?void 0:v.trim())||((I=e.activeDocumentId)==null?void 0:I.trim());return b?Ri(e.nodes,b):null},[e.nodes,e.activeDocumentId,e.graphFocusAnchorId]),u=x.useMemo(()=>new Set((l==null?void 0:l.forceOpenFolderIds)??[]),[l]);x.useEffect(()=>{if(!(l!=null&&l.scrollTreeId))return;const b=l.scrollTreeId,v=()=>{var N;const D=(N=r.current)==null?void 0:N.querySelector(`[data-tree-id="${CSS.escape(b)}"]`);D==null||D.scrollIntoView({block:"nearest",behavior:"smooth"})},I=requestAnimationFrame(()=>{requestAnimationFrame(v)});return()=>cancelAnimationFrame(I)},[l==null?void 0:l.scrollTreeId,u,e.nodes]);function d(){a(null)}function h(){Ft=null,s(null),d()}function m(b){Ft=b,s(b),d()}function f(b){if(!St(e.onMoveDocument))return;b.preventDefault(),b.dataTransfer.dropEffect="move",b.target.closest(".mdocs-tree-row")||a({kind:"root"})}function p(b){const v=b.relatedTarget;v&&b.currentTarget.contains(v)||a(I=>(I==null?void 0:I.kind)==="root"?null:I)}function g(b){if(!e.onMoveDocument||!St(e.onMoveDocument))return;b.preventDefault(),b.stopPropagation();const I=b.target.closest(".mdocs-tree-row"),D=Wr(b.dataTransfer);h(),!I&&D&&e.onMoveDocument(D,null)}const w="mdocs-sidebar-list"+((o==null?void 0:o.kind)==="root"?" mdocs-tree-drop-root":"");return e.nodes.length===0?c.jsx("div",{ref:r,className:w,onDragOver:f,onDragLeave:p,onDrop:g,children:c.jsx("div",{className:"muted",style:{padding:"8px 10px",fontSize:12},children:n("noDocumentsYet")})}):c.jsx("div",{ref:r,className:w,onClick:b=>{var I;b.target.closest(".mdocs-tree-row")||(I=e.onDeselect)==null||I.call(e)},onContextMenu:b=>{b.preventDefault(),e.onContextMenu({x:b.clientX,y:b.clientY,node:{type:"folder",name:"",path:"",documentId:"",children:e.nodes},parentPath:""})},onDragOver:f,onDragLeave:p,onDrop:g,children:e.nodes.map(b=>c.jsx(Fi,{node:b,depth:0,parentPath:"",parentFolderId:null,activeDocumentId:e.activeDocumentId,graphFocusAnchorId:e.graphFocusAnchorId??null,selectedParentPath:e.selectedParentPath,forceOpenFolderIds:u,dropHighlight:o,setDropHighlight:a,clearDropHighlight:d,beginDragSession:m,endDragSession:h,draggingId:i,onOpen:e.onOpen,onOpenFolder:e.onOpenFolder,onContextMenu:e.onContextMenu,onMoveDocument:e.onMoveDocument,onOpenGraph:e.onOpenGraph,onGenerateGraph:e.onGenerateGraph},b.path))})}function Fi(e){const n={paddingLeft:8+e.depth*16};return e.node.type==="folder"?c.jsx(jl,{folder:e.node,depth:e.depth,indent:n,activeDocumentId:e.activeDocumentId,graphFocusAnchorId:e.graphFocusAnchorId,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,onOpenGraph:e.onOpenGraph,onGenerateGraph:e.onGenerateGraph}):c.jsx(Tl,{doc:e.node,indent:n,parentPath:e.parentPath,parentFolderId:e.parentFolderId,activeDocumentId:e.activeDocumentId,graphFocusAnchorId:e.graphFocusAnchorId,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,onOpenGraph:e.onOpenGraph,onGenerateGraph:e.onGenerateGraph})}function Tl(e){var m;const n=e.doc,r=n.documentId===e.activeDocumentId,o=n.documentId===e.graphFocusAnchorId,a=!!e.onMoveDocument,i=e.draggingId===n.documentId,[s,l]=x.useState(!1),u=((m=e.dropHighlight)==null?void 0:m.kind)==="doc"&&e.dropHighlight.id===n.documentId,[d,h]=x.useState(!1);return c.jsxs("div",{role:"button",tabIndex:0,className:"mdocs-tree-row mdocs-tree-doc"+(r?" active":"")+(o?" mdocs-tree-row--graph-focus":"")+(i?" mdocs-tree-dragging":"")+(u?" mdocs-tree-drop-target":""),"data-tree-id":n.documentId,style:{...e.indent,cursor:a?"grab":void 0},draggable:a,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onDragStart:f=>{e.onMoveDocument&&(h(!0),e.beginDragSession(n.documentId),f.dataTransfer.setData(Oi,n.documentId),f.dataTransfer.setData("text/plain",Tr+n.documentId),f.dataTransfer.effectAllowed="move")},onDragEnd:()=>{e.endDragSession(),queueMicrotask(()=>h(!1))},onDragEnter:f=>{!St(e.onMoveDocument)||Ft===n.documentId||(f.preventDefault(),f.stopPropagation(),e.setDropHighlight({kind:"doc",id:n.documentId}))},onDragOver:f=>{!St(e.onMoveDocument)||Ft===n.documentId||(f.preventDefault(),f.stopPropagation(),f.dataTransfer.dropEffect="move",e.setDropHighlight({kind:"doc",id:n.documentId}))},onDrop:f=>{if(!e.onMoveDocument||!St(e.onMoveDocument))return;f.preventDefault(),f.stopPropagation();const p=Wr(f.dataTransfer),g=e.parentFolderId;e.endDragSession(),!(!p||p===n.documentId)&&e.onMoveDocument(p,g)},onClick:()=>{d||e.onOpen(n)},onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),e.onOpen(n))},onContextMenu:f=>{f.preventDefault(),f.stopPropagation(),e.onContextMenu({x:f.clientX,y:f.clientY,node:n,parentPath:e.parentPath})},children:[c.jsx("span",{className:"mdocs-tree-caret-spacer","aria-hidden":!0}),c.jsx("span",{className:`mdocs-tree-icon${n.fileType==="html"?" mdocs-tree-icon-html":""}`,children:n.fileType==="html"?c.jsx("span",{className:"mdocs-tree-html-bracket",children:"</>"}):"md"}),c.jsx("span",{className:"mdocs-tree-label",title:n.displayName||n.name,children:n.displayName||n.name}),(e.onOpenGraph||e.onGenerateGraph)&&c.jsxs("span",{className:"mdocs-tree-hover-actions",onClick:f=>f.stopPropagation(),children:[e.onOpenGraph&&c.jsx("button",{type:"button",className:"mdocs-tree-icon-btn",title:"查看图谱",onClick:f=>{var p;f.stopPropagation(),(p=e.onOpenGraph)==null||p.call(e,e.doc,e.parentFolderId??void 0)},children:c.jsx(Hr,{size:14,strokeWidth:1.75})}),e.onGenerateGraph&&c.jsx("button",{type:"button",className:"mdocs-tree-icon-btn",title:"生成图谱",onClick:f=>{var p;f.stopPropagation(),(p=e.onGenerateGraph)==null||p.call(e,e.doc,e.parentFolderId??void 0)},children:c.jsx(Ai,{size:14,strokeWidth:1.75})})]})]})}function Al(){return c.jsx("span",{className:"mdocs-tree-icon mdocs-tree-icon-dir","aria-hidden":!0,children:c.jsx(Ts,{size:16})})}function jl(e){var m,f,p;const{t:n}=Je(),r=e.forceOpenFolderIds.has(e.folder.documentId),[o,a]=x.useState(e.depth<1||r),i=o;x.useEffect(()=>{r&&a(!0)},[r,e.activeDocumentId]);const s=!!e.folder.descDocumentId&&e.folder.descDocumentId===e.activeDocumentId,l=e.folder.documentId===e.graphFocusAnchorId,u=e.selectedParentPath===e.folder.path,d=((m=e.dropHighlight)==null?void 0:m.kind)==="folder"&&e.dropHighlight.id===e.folder.documentId;function h(){e.onOpenFolder(e.folder.path,e.folder.descDocumentId)}return c.jsxs("div",{children:[c.jsxs("div",{className:"mdocs-tree-row mdocs-tree-folder mdocs-tree-folder-row"+(s?" active":u?" mdocs-tree-select-target":"")+(l?" mdocs-tree-row--graph-focus":"")+(d?" mdocs-tree-drop-target":""),"data-tree-id":e.folder.documentId,style:e.indent,onClick:h,onContextMenu:g=>{g.preventDefault(),g.stopPropagation(),e.onContextMenu({x:g.clientX,y:g.clientY,node:e.folder,parentPath:e.folder.path})},onDragEnter:g=>{St(e.onMoveDocument)&&(g.preventDefault(),g.stopPropagation(),e.setDropHighlight({kind:"folder",id:e.folder.documentId}),a(!0))},onDragOver:g=>{St(e.onMoveDocument)&&(g.preventDefault(),g.stopPropagation(),g.dataTransfer.dropEffect="move",e.setDropHighlight({kind:"folder",id:e.folder.documentId}))},onDrop:g=>{if(!e.onMoveDocument||!St(e.onMoveDocument))return;g.preventDefault(),g.stopPropagation();const w=Wr(g.dataTransfer),b=e.folder.documentId;e.endDragSession(),w&&e.onMoveDocument(w,b)},children:[c.jsx("span",{className:"mdocs-tree-caret",role:"button",tabIndex:0,"aria-expanded":i,"aria-label":n(i?"collapseFolder":"expandFolder"),onClick:g=>{g.stopPropagation(),a(w=>!w)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),a(w=>!w))},children:i?"▾":"▸"}),c.jsx(Al,{}),c.jsx("span",{className:"mdocs-tree-folder-select",children:c.jsx("span",{className:"mdocs-tree-label",title:((f=e.folder.folderDisplayName)==null?void 0:f.trim())||e.folder.name,children:((p=e.folder.folderDisplayName)==null?void 0:p.trim())||e.folder.name})}),(e.onOpenGraph||e.onGenerateGraph)&&c.jsxs("span",{className:"mdocs-tree-hover-actions",onClick:g=>g.stopPropagation(),children:[e.onOpenGraph&&c.jsx("button",{type:"button",className:"mdocs-tree-icon-btn",title:"查看图谱",onClick:g=>{var w;g.stopPropagation(),(w=e.onOpenGraph)==null||w.call(e,e.folder)},children:c.jsx(Hr,{size:14,strokeWidth:1.75})}),e.onGenerateGraph&&c.jsx("button",{type:"button",className:"mdocs-tree-icon-btn",title:"生成图谱",onClick:g=>{var w;g.stopPropagation(),(w=e.onGenerateGraph)==null||w.call(e,e.folder)},children:c.jsx(Ai,{size:14,strokeWidth:1.75})})]})]}),i&&e.folder.children.map(g=>c.jsx(Fi,{node:g,depth:e.depth+1,parentPath:e.folder.path,parentFolderId:e.folder.documentId,activeDocumentId:e.activeDocumentId,graphFocusAnchorId:e.graphFocusAnchorId,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,onOpenGraph:e.onOpenGraph,onGenerateGraph:e.onGenerateGraph},g.path))]})}function Ml(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,a,i,s,l=[],u=!0,d=!1;try{if(i=(r=r.call(e)).next,n===0){if(Object(r)!==r)return;u=!1}else for(;!(u=(o=i.call(r)).done)&&(l.push(o.value),l.length!==n);u=!0);}catch(h){d=!0,a=h}finally{try{if(!u&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(d)throw a}}return l}}function El(e,n,r){return n=Bl(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function Uo(e,n){return Fl(e)||Ml(e,n)||Li(e,n)||$l()}function Ol(e){return Rl(e)||Ll(e)||Li(e)||zl()}function Rl(e){if(Array.isArray(e))return Ar(e)}function Fl(e){if(Array.isArray(e))return e}function Ll(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Li(e,n){if(e){if(typeof e=="string")return Ar(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ar(e,n)}}function Ar(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,o=new Array(n);r<n;r++)o[r]=e[r];return o}function zl(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
251
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $l(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
252
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ul(e,n){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,n);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function Bl(e){var n=Ul(e,"string");return typeof n=="symbol"?n:String(n)}var Hl=function(n,r){var o=new Set(r);return Object.assign.apply(Object,[{}].concat(Ol(Object.entries(n).filter(function(a){var i=Uo(a,1),s=i[0];return!o.has(s)}).map(function(a){var i=Uo(a,2),s=i[0],l=i[1];return El({},s,l)}))))};function Vl(e,{wrapperElementType:n="div",nodeMapper:r=i=>i,methodNames:o=[],initPropNames:a=[]}={}){return x.forwardRef((i,s)=>{const l=x.useRef(),u=x.useMemo(()=>{const m=Object.fromEntries(a.filter(f=>i.hasOwnProperty(f)).map(f=>[f,i[f]]));return e(m)},[]);Bo(()=>{u(r(l.current))},x.useLayoutEffect),Bo(()=>u._destructor instanceof Function?u._destructor:void 0);const d=x.useCallback((m,...f)=>u[m]instanceof Function?u[m](...f):void 0,[u]),h=x.useRef({});return Object.keys(Hl(i,[...o,...a])).filter(m=>h.current[m]!==i[m]).forEach(m=>d(m,i[m])),h.current=i,x.useImperativeHandle(s,()=>Object.fromEntries(o.map(m=>[m,(...f)=>d(m,...f)])),[d]),Ni.createElement(n,{ref:l})})}function Bo(e,n=x.useEffect){const r=x.useRef(),o=x.useRef(!1),a=x.useRef(!1),[i,s]=x.useState(0);o.current&&(a.current=!0),n(()=>(o.current||(r.current=e(),o.current=!0),s(l=>l+1),()=>{a.current&&(r.current&&r.current(),r.current=void 0,o.current=!1,a.current=!1)}),[])}var Rt=Object.freeze({Linear:Object.freeze({None:function(e){return e},In:function(e){return e},Out:function(e){return e},InOut:function(e){return e}}),Quadratic:Object.freeze({In:function(e){return e*e},Out:function(e){return e*(2-e)},InOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)}}),Cubic:Object.freeze({In:function(e){return e*e*e},Out:function(e){return--e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}}),Quartic:Object.freeze({In:function(e){return e*e*e*e},Out:function(e){return 1- --e*e*e*e},InOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)}}),Quintic:Object.freeze({In:function(e){return e*e*e*e*e},Out:function(e){return--e*e*e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)}}),Sinusoidal:Object.freeze({In:function(e){return 1-Math.sin((1-e)*Math.PI/2)},Out:function(e){return Math.sin(e*Math.PI/2)},InOut:function(e){return .5*(1-Math.sin(Math.PI*(.5-e)))}}),Exponential:Object.freeze({In:function(e){return e===0?0:Math.pow(1024,e-1)},Out:function(e){return e===1?1:1-Math.pow(2,-10*e)},InOut:function(e){return e===0?0:e===1?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(-Math.pow(2,-10*(e-1))+2)}}),Circular:Object.freeze({In:function(e){return 1-Math.sqrt(1-e*e)},Out:function(e){return Math.sqrt(1- --e*e)},InOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)}}),Elastic:Object.freeze({In:function(e){return e===0?0:e===1?1:-Math.pow(2,10*(e-1))*Math.sin((e-1.1)*5*Math.PI)},Out:function(e){return e===0?0:e===1?1:Math.pow(2,-10*e)*Math.sin((e-.1)*5*Math.PI)+1},InOut:function(e){return e===0?0:e===1?1:(e*=2,e<1?-.5*Math.pow(2,10*(e-1))*Math.sin((e-1.1)*5*Math.PI):.5*Math.pow(2,-10*(e-1))*Math.sin((e-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(e){var n=1.70158;return e===1?1:e*e*((n+1)*e-n)},Out:function(e){var n=1.70158;return e===0?0:--e*e*((n+1)*e+n)+1},InOut:function(e){var n=2.5949095;return(e*=2)<1?.5*(e*e*((n+1)*e-n)):.5*((e-=2)*e*((n+1)*e+n)+2)}}),Bounce:Object.freeze({In:function(e){return 1-Rt.Bounce.Out(1-e)},Out:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},InOut:function(e){return e<.5?Rt.Bounce.In(e*2)*.5:Rt.Bounce.Out(e*2-1)*.5+.5}}),generatePow:function(e){return e===void 0&&(e=4),e=e<Number.EPSILON?Number.EPSILON:e,e=e>1e4?1e4:e,{In:function(n){return Math.pow(n,e)},Out:function(n){return 1-Math.pow(1-n,e)},InOut:function(n){return n<.5?Math.pow(n*2,e)/2:(1-Math.pow(2-n*2,e))/2+.5}}}}),fn=function(){return performance.now()},zi=function(){function e(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];this._tweens={},this._tweensAddedDuringUpdate={},this.add.apply(this,n)}return e.prototype.getAll=function(){var n=this;return Object.keys(this._tweens).map(function(r){return n._tweens[r]})},e.prototype.removeAll=function(){this._tweens={}},e.prototype.add=function(){for(var n,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];for(var a=0,i=r;a<i.length;a++){var s=i[a];(n=s._group)===null||n===void 0||n.remove(s),s._group=this,this._tweens[s.getId()]=s,this._tweensAddedDuringUpdate[s.getId()]=s}},e.prototype.remove=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];for(var o=0,a=n;o<a.length;o++){var i=a[o];i._group=void 0,delete this._tweens[i.getId()],delete this._tweensAddedDuringUpdate[i.getId()]}},e.prototype.allStopped=function(){return this.getAll().every(function(n){return!n.isPlaying()})},e.prototype.update=function(n,r){n===void 0&&(n=fn()),r===void 0&&(r=!0);var o=Object.keys(this._tweens);if(o.length!==0)for(;o.length>0;){this._tweensAddedDuringUpdate={};for(var a=0;a<o.length;a++){var i=this._tweens[o[a]],s=!r;i&&i.update(n,s)===!1&&!r&&this.remove(i)}o=Object.keys(this._tweensAddedDuringUpdate)}},e}(),jr={Linear:function(e,n){var r=e.length-1,o=r*n,a=Math.floor(o),i=jr.Utils.Linear;return n<0?i(e[0],e[1],o):n>1?i(e[r],e[r-1],r-o):i(e[a],e[a+1>r?r:a+1],o-a)},Utils:{Linear:function(e,n,r){return(n-e)*r+e}}},$i=function(){function e(){}return e.nextId=function(){return e._nextId++},e._nextId=0,e}(),Mr=new zi,Ho=function(){function e(n,r){this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Rt.Linear.None,this._interpolationFunction=jr.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=$i.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=n,typeof r=="object"?(this._group=r,r.add(this)):r===!0&&(this._group=Mr,Mr.add(this))}return e.prototype.getId=function(){return this._id},e.prototype.isPlaying=function(){return this._isPlaying},e.prototype.isPaused=function(){return this._isPaused},e.prototype.getDuration=function(){return this._duration},e.prototype.to=function(n,r){if(r===void 0&&(r=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=n,this._propertiesAreSetUp=!1,this._duration=r<0?0:r,this},e.prototype.duration=function(n){return n===void 0&&(n=1e3),this._duration=n<0?0:n,this},e.prototype.dynamic=function(n){return n===void 0&&(n=!1),this._isDynamic=n,this},e.prototype.start=function(n,r){if(n===void 0&&(n=fn()),r===void 0&&(r=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var o in this._valuesStartRepeat)this._swapEndStartRepeatValues(o),this._valuesStart[o]=this._valuesStartRepeat[o]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=n,this._startTime+=this._delayTime,!this._propertiesAreSetUp||r){if(this._propertiesAreSetUp=!0,!this._isDynamic){var a={};for(var i in this._valuesEnd)a[i]=this._valuesEnd[i];this._valuesEnd=a}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,r)}return this},e.prototype.startFromCurrentValues=function(n){return this.start(n,!0)},e.prototype._setupProperties=function(n,r,o,a,i){for(var s in o){var l=n[s],u=Array.isArray(l),d=u?"array":typeof l,h=!u&&Array.isArray(o[s]);if(!(d==="undefined"||d==="function")){if(h){var m=o[s];if(m.length===0)continue;for(var f=[l],p=0,g=m.length;p<g;p+=1){var w=this._handleRelativeValue(l,m[p]);if(isNaN(w)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}f.push(w)}h&&(o[s]=f)}if((d==="object"||u)&&l&&!h){r[s]=u?[]:{};var b=l;for(var v in b)r[s][v]=b[v];a[s]=u?[]:{};var m=o[s];if(!this._isDynamic){var I={};for(var v in m)I[v]=m[v];o[s]=m=I}this._setupProperties(b,r[s],m,a[s],i)}else(typeof r[s]>"u"||i)&&(r[s]=l),u||(r[s]*=1),h?a[s]=o[s].slice().reverse():a[s]=r[s]||0}}},e.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},e.prototype.end=function(){return this._goToEnd=!0,this.update(this._startTime+this._duration),this},e.prototype.pause=function(n){return n===void 0&&(n=fn()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=n,this)},e.prototype.resume=function(n){return n===void 0&&(n=fn()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=n-this._pauseStart,this._pauseStart=0,this)},e.prototype.stopChainedTweens=function(){for(var n=0,r=this._chainedTweens.length;n<r;n++)this._chainedTweens[n].stop();return this},e.prototype.group=function(n){return n?(n.add(this),this):(console.warn("tween.group() without args has been removed, use group.add(tween) instead."),this)},e.prototype.remove=function(){var n;return(n=this._group)===null||n===void 0||n.remove(this),this},e.prototype.delay=function(n){return n===void 0&&(n=0),this._delayTime=n,this},e.prototype.repeat=function(n){return n===void 0&&(n=0),this._initialRepeat=n,this._repeat=n,this},e.prototype.repeatDelay=function(n){return this._repeatDelayTime=n,this},e.prototype.yoyo=function(n){return n===void 0&&(n=!1),this._yoyo=n,this},e.prototype.easing=function(n){return n===void 0&&(n=Rt.Linear.None),this._easingFunction=n,this},e.prototype.interpolation=function(n){return n===void 0&&(n=jr.Linear),this._interpolationFunction=n,this},e.prototype.chain=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return this._chainedTweens=n,this},e.prototype.onStart=function(n){return this._onStartCallback=n,this},e.prototype.onEveryStart=function(n){return this._onEveryStartCallback=n,this},e.prototype.onUpdate=function(n){return this._onUpdateCallback=n,this},e.prototype.onRepeat=function(n){return this._onRepeatCallback=n,this},e.prototype.onComplete=function(n){return this._onCompleteCallback=n,this},e.prototype.onStop=function(n){return this._onStopCallback=n,this},e.prototype.update=function(n,r){var o=this,a;if(n===void 0&&(n=fn()),r===void 0&&(r=e.autoStartOnUpdate),this._isPaused)return!0;var i;if(!this._goToEnd&&!this._isPlaying)if(r)this.start(n,!0);else return!1;if(this._goToEnd=!1,n<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var s=n-this._startTime,l=this._duration+((a=this._repeatDelayTime)!==null&&a!==void 0?a:this._delayTime),u=this._duration+this._repeat*l,d=function(){if(o._duration===0||s>u)return 1;var w=Math.trunc(s/l),b=s-w*l,v=Math.min(b/o._duration,1);return v===0&&s===o._duration?1:v},h=d(),m=this._easingFunction(h);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,m),this._onUpdateCallback&&this._onUpdateCallback(this._object,h),this._duration===0||s>=this._duration)if(this._repeat>0){var f=Math.min(Math.trunc((s-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=f);for(i in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[i]=="string"&&(this._valuesStartRepeat[i]=this._valuesStartRepeat[i]+parseFloat(this._valuesEnd[i])),this._yoyo&&this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*f,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var p=0,g=this._chainedTweens.length;p<g;p++)this._chainedTweens[p].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},e.prototype._updateProperties=function(n,r,o,a){for(var i in o)if(r[i]!==void 0){var s=r[i]||0,l=o[i],u=Array.isArray(n[i]),d=Array.isArray(l),h=!u&&d;h?n[i]=this._interpolationFunction(l,a):typeof l=="object"&&l?this._updateProperties(n[i],s,l,a):(l=this._handleRelativeValue(s,l),typeof l=="number"&&(n[i]=s+(l-s)*a))}},e.prototype._handleRelativeValue=function(n,r){return typeof r!="string"?r:r.charAt(0)==="+"||r.charAt(0)==="-"?n+parseFloat(r):parseFloat(r)},e.prototype._swapEndStartRepeatValues=function(n){var r=this._valuesStartRepeat[n],o=this._valuesEnd[n];typeof o=="string"?this._valuesStartRepeat[n]=this._valuesStartRepeat[n]+parseFloat(o):this._valuesStartRepeat[n]=this._valuesEnd[n],this._valuesEnd[n]=r},e.autoStartOnUpdate=!1,e}();$i.nextId;var at=Mr;at.getAll.bind(at);at.removeAll.bind(at);at.add.bind(at);at.remove.bind(at);at.update.bind(at);function Vo(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,o=Array(n);r<n;r++)o[r]=e[r];return o}function Gl(e){if(Array.isArray(e))return e}function Wl(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function ql(e,n,r){return Object.defineProperty(e,"prototype",{writable:!1}),e}function Kl(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,a,i,s,l=[],u=!0,d=!1;try{if(i=(r=r.call(e)).next,n!==0)for(;!(u=(o=i.call(r)).done)&&(l.push(o.value),l.length!==n);u=!0);}catch(h){d=!0,a=h}finally{try{if(!u&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(d)throw a}}return l}}function Yl(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
253
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Jl(e,n){return Gl(e)||Kl(e,n)||Xl(e,n)||Yl()}function Xl(e,n){if(e){if(typeof e=="string")return Vo(e,n);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Vo(e,n):void 0}}var Zl=ql(function e(n,r){var o=r.default,a=o===void 0?null:o,i=r.triggerUpdate,s=i===void 0?!0:i,l=r.onChange,u=l===void 0?function(d,h){}:l;Wl(this,e),this.name=n,this.defaultVal=a,this.triggerUpdate=s,this.onChange=u});function qr(e){var n=e.stateInit,r=n===void 0?function(){return{}}:n,o=e.props,a=o===void 0?{}:o,i=e.methods,s=i===void 0?{}:i,l=e.aliases,u=l===void 0?{}:l,d=e.init,h=d===void 0?function(){}:d,m=e.update,f=m===void 0?function(){}:m,p=Object.keys(a).map(function(g){return new Zl(g,a[g])});return function g(){for(var w=arguments.length,b=new Array(w),v=0;v<w;v++)b[v]=arguments[v];var I=!!(this instanceof g&&this.constructor),D=I?b.shift():void 0,N=b[0],_=N===void 0?{}:N,T=Object.assign({},r instanceof Function?r(_):r,{initialised:!1}),C={};function P(R){return z(R,_),E(),P}var z=function($,H){h.call(P,$,T,H),T.initialised=!0},E=Ja(function(){T.initialised&&(f.call(P,T,C),C={})},1);return p.forEach(function(R){P[R.name]=$(R);function $(H){var J=H.name,ne=H.triggerUpdate,B=ne===void 0?!1:ne,G=H.onChange,se=G===void 0?function(re,oe){}:G,ue=H.defaultVal,j=ue===void 0?null:ue;return function(re){var oe=T[J];if(!arguments.length)return oe;var ie=re===void 0?j:re;return T[J]=ie,se.call(P,ie,T,oe),!C.hasOwnProperty(J)&&(C[J]=oe),B&&E(),P}}}),Object.keys(s).forEach(function(R){P[R]=function(){for(var $,H=arguments.length,J=new Array(H),ne=0;ne<H;ne++)J[ne]=arguments[ne];return($=s[R]).call.apply($,[P,T].concat(J))}}),Object.entries(u).forEach(function(R){var $=Jl(R,2),H=$[0],J=$[1];return P[H]=P[J]}),P.resetProps=function(){return p.forEach(function(R){P[R.name](R.defaultVal)}),P},P.resetProps(),T._rerender=E,I&&D&&P(D),P}}var ae=function(e){return typeof e=="function"?e:typeof e=="string"?function(n){return n[e]}:function(n){return e}};function zn(e){"@babel/helpers - typeof";return zn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},zn(e)}var Ql=/^\s+/,ec=/\s+$/;function Y(e,n){if(e=e||"",n=n||{},e instanceof Y)return e;if(!(this instanceof Y))return new Y(e,n);var r=tc(e);this._originalInput=e,this._r=r.r,this._g=r.g,this._b=r.b,this._a=r.a,this._roundA=Math.round(100*this._a)/100,this._format=n.format||r.format,this._gradientType=n.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=r.ok}Y.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var n=this.toRgb();return(n.r*299+n.g*587+n.b*114)/1e3},getLuminance:function(){var n=this.toRgb(),r,o,a,i,s,l;return r=n.r/255,o=n.g/255,a=n.b/255,r<=.03928?i=r/12.92:i=Math.pow((r+.055)/1.055,2.4),o<=.03928?s=o/12.92:s=Math.pow((o+.055)/1.055,2.4),a<=.03928?l=a/12.92:l=Math.pow((a+.055)/1.055,2.4),.2126*i+.7152*s+.0722*l},setAlpha:function(n){return this._a=Ui(n),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var n=Wo(this._r,this._g,this._b);return{h:n.h*360,s:n.s,v:n.v,a:this._a}},toHsvString:function(){var n=Wo(this._r,this._g,this._b),r=Math.round(n.h*360),o=Math.round(n.s*100),a=Math.round(n.v*100);return this._a==1?"hsv("+r+", "+o+"%, "+a+"%)":"hsva("+r+", "+o+"%, "+a+"%, "+this._roundA+")"},toHsl:function(){var n=Go(this._r,this._g,this._b);return{h:n.h*360,s:n.s,l:n.l,a:this._a}},toHslString:function(){var n=Go(this._r,this._g,this._b),r=Math.round(n.h*360),o=Math.round(n.s*100),a=Math.round(n.l*100);return this._a==1?"hsl("+r+", "+o+"%, "+a+"%)":"hsla("+r+", "+o+"%, "+a+"%, "+this._roundA+")"},toHex:function(n){return qo(this._r,this._g,this._b,n)},toHexString:function(n){return"#"+this.toHex(n)},toHex8:function(n){return ic(this._r,this._g,this._b,this._a,n)},toHex8String:function(n){return"#"+this.toHex8(n)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(pe(this._r,255)*100)+"%",g:Math.round(pe(this._g,255)*100)+"%",b:Math.round(pe(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(pe(this._r,255)*100)+"%, "+Math.round(pe(this._g,255)*100)+"%, "+Math.round(pe(this._b,255)*100)+"%)":"rgba("+Math.round(pe(this._r,255)*100)+"%, "+Math.round(pe(this._g,255)*100)+"%, "+Math.round(pe(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:yc[qo(this._r,this._g,this._b,!0)]||!1},toFilter:function(n){var r="#"+Ko(this._r,this._g,this._b,this._a),o=r,a=this._gradientType?"GradientType = 1, ":"";if(n){var i=Y(n);o="#"+Ko(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+a+"startColorstr="+r+",endColorstr="+o+")"},toString:function(n){var r=!!n;n=n||this._format;var o=!1,a=this._a<1&&this._a>=0,i=!r&&a&&(n==="hex"||n==="hex6"||n==="hex3"||n==="hex4"||n==="hex8"||n==="name");return i?n==="name"&&this._a===0?this.toName():this.toRgbString():(n==="rgb"&&(o=this.toRgbString()),n==="prgb"&&(o=this.toPercentageRgbString()),(n==="hex"||n==="hex6")&&(o=this.toHexString()),n==="hex3"&&(o=this.toHexString(!0)),n==="hex4"&&(o=this.toHex8String(!0)),n==="hex8"&&(o=this.toHex8String()),n==="name"&&(o=this.toName()),n==="hsl"&&(o=this.toHslString()),n==="hsv"&&(o=this.toHsvString()),o||this.toHexString())},clone:function(){return Y(this.toString())},_applyModification:function(n,r){var o=n.apply(null,[this].concat([].slice.call(r)));return this._r=o._r,this._g=o._g,this._b=o._b,this.setAlpha(o._a),this},lighten:function(){return this._applyModification(cc,arguments)},brighten:function(){return this._applyModification(dc,arguments)},darken:function(){return this._applyModification(uc,arguments)},desaturate:function(){return this._applyModification(ac,arguments)},saturate:function(){return this._applyModification(sc,arguments)},greyscale:function(){return this._applyModification(lc,arguments)},spin:function(){return this._applyModification(fc,arguments)},_applyCombination:function(n,r){return n.apply(null,[this].concat([].slice.call(r)))},analogous:function(){return this._applyCombination(pc,arguments)},complement:function(){return this._applyCombination(mc,arguments)},monochromatic:function(){return this._applyCombination(gc,arguments)},splitcomplement:function(){return this._applyCombination(hc,arguments)},triad:function(){return this._applyCombination(Yo,[3])},tetrad:function(){return this._applyCombination(Yo,[4])}};Y.fromRatio=function(e,n){if(zn(e)=="object"){var r={};for(var o in e)e.hasOwnProperty(o)&&(o==="a"?r[o]=e[o]:r[o]=mn(e[o]));e=r}return Y(e,n)};function tc(e){var n={r:0,g:0,b:0},r=1,o=null,a=null,i=null,s=!1,l=!1;return typeof e=="string"&&(e=wc(e)),zn(e)=="object"&&(ct(e.r)&&ct(e.g)&&ct(e.b)?(n=nc(e.r,e.g,e.b),s=!0,l=String(e.r).substr(-1)==="%"?"prgb":"rgb"):ct(e.h)&&ct(e.s)&&ct(e.v)?(o=mn(e.s),a=mn(e.v),n=oc(e.h,o,a),s=!0,l="hsv"):ct(e.h)&&ct(e.s)&&ct(e.l)&&(o=mn(e.s),i=mn(e.l),n=rc(e.h,o,i),s=!0,l="hsl"),e.hasOwnProperty("a")&&(r=e.a)),r=Ui(r),{ok:s,format:e.format||l,r:Math.min(255,Math.max(n.r,0)),g:Math.min(255,Math.max(n.g,0)),b:Math.min(255,Math.max(n.b,0)),a:r}}function nc(e,n,r){return{r:pe(e,255)*255,g:pe(n,255)*255,b:pe(r,255)*255}}function Go(e,n,r){e=pe(e,255),n=pe(n,255),r=pe(r,255);var o=Math.max(e,n,r),a=Math.min(e,n,r),i,s,l=(o+a)/2;if(o==a)i=s=0;else{var u=o-a;switch(s=l>.5?u/(2-o-a):u/(o+a),o){case e:i=(n-r)/u+(n<r?6:0);break;case n:i=(r-e)/u+2;break;case r:i=(e-n)/u+4;break}i/=6}return{h:i,s,l}}function rc(e,n,r){var o,a,i;e=pe(e,360),n=pe(n,100),r=pe(r,100);function s(d,h,m){return m<0&&(m+=1),m>1&&(m-=1),m<1/6?d+(h-d)*6*m:m<1/2?h:m<2/3?d+(h-d)*(2/3-m)*6:d}if(n===0)o=a=i=r;else{var l=r<.5?r*(1+n):r+n-r*n,u=2*r-l;o=s(u,l,e+1/3),a=s(u,l,e),i=s(u,l,e-1/3)}return{r:o*255,g:a*255,b:i*255}}function Wo(e,n,r){e=pe(e,255),n=pe(n,255),r=pe(r,255);var o=Math.max(e,n,r),a=Math.min(e,n,r),i,s,l=o,u=o-a;if(s=o===0?0:u/o,o==a)i=0;else{switch(o){case e:i=(n-r)/u+(n<r?6:0);break;case n:i=(r-e)/u+2;break;case r:i=(e-n)/u+4;break}i/=6}return{h:i,s,v:l}}function oc(e,n,r){e=pe(e,360)*6,n=pe(n,100),r=pe(r,100);var o=Math.floor(e),a=e-o,i=r*(1-n),s=r*(1-a*n),l=r*(1-(1-a)*n),u=o%6,d=[r,s,i,i,l,r][u],h=[l,r,r,s,i,i][u],m=[i,i,l,r,r,s][u];return{r:d*255,g:h*255,b:m*255}}function qo(e,n,r,o){var a=[Ke(Math.round(e).toString(16)),Ke(Math.round(n).toString(16)),Ke(Math.round(r).toString(16))];return o&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0):a.join("")}function ic(e,n,r,o,a){var i=[Ke(Math.round(e).toString(16)),Ke(Math.round(n).toString(16)),Ke(Math.round(r).toString(16)),Ke(Bi(o))];return a&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)&&i[3].charAt(0)==i[3].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0)+i[3].charAt(0):i.join("")}function Ko(e,n,r,o){var a=[Ke(Bi(o)),Ke(Math.round(e).toString(16)),Ke(Math.round(n).toString(16)),Ke(Math.round(r).toString(16))];return a.join("")}Y.equals=function(e,n){return!e||!n?!1:Y(e).toRgbString()==Y(n).toRgbString()};Y.random=function(){return Y.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function ac(e,n){n=n===0?0:n||10;var r=Y(e).toHsl();return r.s-=n/100,r.s=Wn(r.s),Y(r)}function sc(e,n){n=n===0?0:n||10;var r=Y(e).toHsl();return r.s+=n/100,r.s=Wn(r.s),Y(r)}function lc(e){return Y(e).desaturate(100)}function cc(e,n){n=n===0?0:n||10;var r=Y(e).toHsl();return r.l+=n/100,r.l=Wn(r.l),Y(r)}function dc(e,n){n=n===0?0:n||10;var r=Y(e).toRgb();return r.r=Math.max(0,Math.min(255,r.r-Math.round(255*-(n/100)))),r.g=Math.max(0,Math.min(255,r.g-Math.round(255*-(n/100)))),r.b=Math.max(0,Math.min(255,r.b-Math.round(255*-(n/100)))),Y(r)}function uc(e,n){n=n===0?0:n||10;var r=Y(e).toHsl();return r.l-=n/100,r.l=Wn(r.l),Y(r)}function fc(e,n){var r=Y(e).toHsl(),o=(r.h+n)%360;return r.h=o<0?360+o:o,Y(r)}function mc(e){var n=Y(e).toHsl();return n.h=(n.h+180)%360,Y(n)}function Yo(e,n){if(isNaN(n)||n<=0)throw new Error("Argument to polyad must be a positive number");for(var r=Y(e).toHsl(),o=[Y(e)],a=360/n,i=1;i<n;i++)o.push(Y({h:(r.h+i*a)%360,s:r.s,l:r.l}));return o}function hc(e){var n=Y(e).toHsl(),r=n.h;return[Y(e),Y({h:(r+72)%360,s:n.s,l:n.l}),Y({h:(r+216)%360,s:n.s,l:n.l})]}function pc(e,n,r){n=n||6,r=r||30;var o=Y(e).toHsl(),a=360/r,i=[Y(e)];for(o.h=(o.h-(a*n>>1)+720)%360;--n;)o.h=(o.h+a)%360,i.push(Y(o));return i}function gc(e,n){n=n||6;for(var r=Y(e).toHsv(),o=r.h,a=r.s,i=r.v,s=[],l=1/n;n--;)s.push(Y({h:o,s:a,v:i})),i=(i+l)%1;return s}Y.mix=function(e,n,r){r=r===0?0:r||50;var o=Y(e).toRgb(),a=Y(n).toRgb(),i=r/100,s={r:(a.r-o.r)*i+o.r,g:(a.g-o.g)*i+o.g,b:(a.b-o.b)*i+o.b,a:(a.a-o.a)*i+o.a};return Y(s)};Y.readability=function(e,n){var r=Y(e),o=Y(n);return(Math.max(r.getLuminance(),o.getLuminance())+.05)/(Math.min(r.getLuminance(),o.getLuminance())+.05)};Y.isReadable=function(e,n,r){var o=Y.readability(e,n),a,i;switch(i=!1,a=_c(r),a.level+a.size){case"AAsmall":case"AAAlarge":i=o>=4.5;break;case"AAlarge":i=o>=3;break;case"AAAsmall":i=o>=7;break}return i};Y.mostReadable=function(e,n,r){var o=null,a=0,i,s,l,u;r=r||{},s=r.includeFallbackColors,l=r.level,u=r.size;for(var d=0;d<n.length;d++)i=Y.readability(e,n[d]),i>a&&(a=i,o=Y(n[d]));return Y.isReadable(e,o,{level:l,size:u})||!s?o:(r.includeFallbackColors=!1,Y.mostReadable(e,["#fff","#000"],r))};var Er=Y.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},yc=Y.hexNames=vc(Er);function vc(e){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[e[r]]=r);return n}function Ui(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function pe(e,n){bc(e)&&(e="100%");var r=xc(e);return e=Math.min(n,Math.max(0,parseFloat(e))),r&&(e=parseInt(e*n,10)/100),Math.abs(e-n)<1e-6?1:e%n/parseFloat(n)}function Wn(e){return Math.min(1,Math.max(0,e))}function Le(e){return parseInt(e,16)}function bc(e){return typeof e=="string"&&e.indexOf(".")!=-1&&parseFloat(e)===1}function xc(e){return typeof e=="string"&&e.indexOf("%")!=-1}function Ke(e){return e.length==1?"0"+e:""+e}function mn(e){return e<=1&&(e=e*100+"%"),e}function Bi(e){return Math.round(parseFloat(e)*255).toString(16)}function Jo(e){return Le(e)/255}var We=function(){var e="[-\\+]?\\d+%?",n="[-\\+]?\\d*\\.\\d+%?",r="(?:"+n+")|(?:"+e+")",o="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?",a="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?";return{CSS_UNIT:new RegExp(r),rgb:new RegExp("rgb"+o),rgba:new RegExp("rgba"+a),hsl:new RegExp("hsl"+o),hsla:new RegExp("hsla"+a),hsv:new RegExp("hsv"+o),hsva:new RegExp("hsva"+a),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function ct(e){return!!We.CSS_UNIT.exec(e)}function wc(e){e=e.replace(Ql,"").replace(ec,"").toLowerCase();var n=!1;if(Er[e])e=Er[e],n=!0;else if(e=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=We.rgb.exec(e))?{r:r[1],g:r[2],b:r[3]}:(r=We.rgba.exec(e))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=We.hsl.exec(e))?{h:r[1],s:r[2],l:r[3]}:(r=We.hsla.exec(e))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=We.hsv.exec(e))?{h:r[1],s:r[2],v:r[3]}:(r=We.hsva.exec(e))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=We.hex8.exec(e))?{r:Le(r[1]),g:Le(r[2]),b:Le(r[3]),a:Jo(r[4]),format:n?"name":"hex8"}:(r=We.hex6.exec(e))?{r:Le(r[1]),g:Le(r[2]),b:Le(r[3]),format:n?"name":"hex"}:(r=We.hex4.exec(e))?{r:Le(r[1]+""+r[1]),g:Le(r[2]+""+r[2]),b:Le(r[3]+""+r[3]),a:Jo(r[4]+""+r[4]),format:n?"name":"hex8"}:(r=We.hex3.exec(e))?{r:Le(r[1]+""+r[1]),g:Le(r[2]+""+r[2]),b:Le(r[3]+""+r[3]),format:n?"name":"hex"}:!1}function _c(e){var n,r;return e=e||{level:"AA",size:"small"},n=(e.level||"AA").toUpperCase(),r=(e.size||"small").toLowerCase(),n!=="AA"&&n!=="AAA"&&(n="AA"),r!=="small"&&r!=="large"&&(r="small"),{level:n,size:r}}function Or(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,o=Array(n);r<n;r++)o[r]=e[r];return o}function kc(e){if(Array.isArray(e))return Or(e)}function Hi(e,n,r){if(typeof e=="function"?e===n:e.has(n))return arguments.length<3?n:r;throw new TypeError("Private element is not present on this object")}function Ic(e,n){if(n.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Sc(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function $e(e,n){return e.get(Hi(e,n))}function Xo(e,n,r){Ic(e,n),n.set(e,r)}function Zo(e,n,r){return e.set(Hi(e,n),r),r}function Cc(e,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,jc(o.key),o)}}function Dc(e,n,r){return n&&Cc(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Nc(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Pc(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
254
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Tc(e){return kc(e)||Nc(e)||Mc(e)||Pc()}function Ac(e,n){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,n);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function jc(e){var n=Ac(e,"string");return typeof n=="symbol"?n:n+""}function Mc(e,n){if(e){if(typeof e=="string")return Or(e,n);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Or(e,n):void 0}}var Ec=123,Oc=function(n){return"#".concat(Math.min(n,Math.pow(2,24)).toString(16).padStart(6,"0"))},Vi=function(n,r,o){return(n<<16)+(r<<8)+o},Rc=function(n){var r=Y(n).toRgb(),o=r.r,a=r.g,i=r.b;return Vi(o,a,i)},Qo=function(n,r){return n*Ec%Math.pow(2,r)},Mt=new WeakMap,dt=new WeakMap,Fc=function(){function e(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:6;Sc(this,e),Xo(this,Mt,void 0),Xo(this,dt,void 0),Zo(dt,this,n),this.reset()}return Dc(e,[{key:"reset",value:function(){Zo(Mt,this,["__reserved for background__"])}},{key:"register",value:function(r){if($e(Mt,this).length>=Math.pow(2,24-$e(dt,this)))return null;var o=$e(Mt,this).length,a=Qo(o,$e(dt,this)),i=Oc(o+(a<<24-$e(dt,this)));return $e(Mt,this).push(r),i}},{key:"lookup",value:function(r){if(!r)return null;var o=typeof r=="string"?Rc(r):Vi.apply(void 0,Tc(r));if(!o)return null;var a=o&Math.pow(2,24-$e(dt,this))-1,i=o>>24-$e(dt,this)&Math.pow(2,$e(dt,this))-1;return Qo(a,$e(dt,this))!==i||a>=$e(Mt,this).length?null:$e(Mt,this)[a]}}])}(),xn,ge,Gi,Wi,It,ei,qi,Ki,lr,Mn,hn,Yi,Kr,Rr,Fr,$n={},Un=[],Lc=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,qn=Array.isArray;function ot(e,n){for(var r in n)e[r]=n[r];return e}function Yr(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function zc(e,n,r){var o,a,i,s={};for(i in n)i=="key"?o=n[i]:i=="ref"?a=n[i]:s[i]=n[i];if(arguments.length>2&&(s.children=arguments.length>3?xn.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(i in e.defaultProps)s[i]===void 0&&(s[i]=e.defaultProps[i]);return pn(e,s,o,a,null)}function pn(e,n,r,o,a){var i={type:e,props:n,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:a??++Gi,__i:-1,__u:0};return a==null&&ge.vnode!=null&&ge.vnode(i),i}function Kn(e){return e.children}function En(e,n){this.props=e,this.context=n}function Lt(e,n){if(n==null)return e.__?Lt(e.__,e.__i+1):null;for(var r;n<e.__k.length;n++)if((r=e.__k[n])!=null&&r.__e!=null)return r.__e;return typeof e.type=="function"?Lt(e):null}function $c(e){if(e.__P&&e.__d){var n=e.__v,r=n.__e,o=[],a=[],i=ot({},n);i.__v=n.__v+1,ge.vnode&&ge.vnode(i),Jr(e.__P,i,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,o,r??Lt(n),!!(32&n.__u),a),i.__v=n.__v,i.__.__k[i.__i]=i,ea(o,i,a),n.__e=n.__=null,i.__e!=r&&Ji(i)}}function Ji(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(n){if(n!=null&&n.__e!=null)return e.__e=e.__c.base=n.__e}),Ji(e)}function ti(e){(!e.__d&&(e.__d=!0)&&It.push(e)&&!Bn.__r++||ei!=ge.debounceRendering)&&((ei=ge.debounceRendering)||qi)(Bn)}function Bn(){try{for(var e,n=1;It.length;)It.length>n&&It.sort(Ki),e=It.shift(),n=It.length,$c(e)}finally{It.length=Bn.__r=0}}function Xi(e,n,r,o,a,i,s,l,u,d,h){var m,f,p,g,w,b,v=o&&o.__k||Un,I=n.length;for(u=Uc(r,n,v,u,I),m=0;m<I;m++)(p=r.__k[m])!=null&&(f=p.__i!=-1&&v[p.__i]||$n,p.__i=m,b=Jr(e,p,f,a,i,s,l,u,d,h),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&Xr(f.ref,null,p),h.push(p.ref,p.__c||g,p)),w==null&&g!=null&&(w=g),4&p.__u?(u=Zi(p,u,e),f.__e&&(f.__e=null)):typeof p.type=="function"&&b!==void 0?u=b:g&&(u=g.nextSibling),p.__u&=-7);return r.__e=w,u}function Uc(e,n,r,o,a){var i,s,l,u,d,h=r.length,m=h,f=0;for(e.__k=new Array(a),i=0;i<a;i++)(s=n[i])!=null&&typeof s!="boolean"&&typeof s!="function"?(typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?s=e.__k[i]=pn(null,s,null,null,null):qn(s)?s=e.__k[i]=pn(Kn,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=e.__k[i]=pn(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):e.__k[i]=s,u=i+f,s.__=e,s.__b=e.__b+1,l=null,(d=s.__i=Bc(s,r,u,m))!=-1&&(m--,(l=r[d])&&(l.__u|=2)),l==null||l.__v==null?(d==-1&&(a>h?f--:a<h&&f++),typeof s.type!="function"&&(s.__u|=4)):d!=u&&(d==u-1?f--:d==u+1?f++:(d>u?f--:f++,s.__u|=4))):e.__k[i]=null;if(m)for(i=0;i<h;i++)(l=r[i])!=null&&!(2&l.__u)&&(l.__e==o&&(o=Lt(l)),na(l,l));return o}function Zi(e,n,r){var o,a;if(typeof e.type=="function"){for(o=e.__k,a=0;o&&a<o.length;a++)o[a]&&(o[a].__=e,n=Zi(o[a],n,r));return n}e.__e!=n&&(n&&e.type&&!n.parentNode&&(n=Lt(e)),n=r.insertBefore(e.__e,n||null));do n=n&&n.nextSibling;while(n!=null&&n.nodeType==8);return n}function Bc(e,n,r,o){var a,i,s,l=e.key,u=e.type,d=n[r],h=d!=null&&(2&d.__u)==0;if(d===null&&l==null||h&&l==d.key&&u==d.type)return r;if(o>(h?1:0)){for(a=r-1,i=r+1;a>=0||i<n.length;)if((d=n[s=a>=0?a--:i++])!=null&&!(2&d.__u)&&l==d.key&&u==d.type)return s}return-1}function ni(e,n,r){n[0]=="-"?e.setProperty(n,r??""):e[n]=r==null?"":typeof r!="number"||Lc.test(n)?r:r+"px"}function Tn(e,n,r,o,a){var i,s;e:if(n=="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof o=="string"&&(e.style.cssText=o=""),o)for(n in o)r&&n in r||ni(e.style,n,"");if(r)for(n in r)o&&r[n]==o[n]||ni(e.style,n,r[n])}else if(n[0]=="o"&&n[1]=="n")i=n!=(n=n.replace(Yi,"$1")),s=n.toLowerCase(),n=s in e||n=="onFocusOut"||n=="onFocusIn"?s.slice(2):n.slice(2),e.l||(e.l={}),e.l[n+i]=r,r?o?r[hn]=o[hn]:(r[hn]=Kr,e.addEventListener(n,i?Fr:Rr,i)):e.removeEventListener(n,i?Fr:Rr,i);else{if(a=="http://www.w3.org/2000/svg")n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(n!="width"&&n!="height"&&n!="href"&&n!="list"&&n!="form"&&n!="tabIndex"&&n!="download"&&n!="rowSpan"&&n!="colSpan"&&n!="role"&&n!="popover"&&n in e)try{e[n]=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&n[4]!="-"?e.removeAttribute(n):e.setAttribute(n,n=="popover"&&r==1?"":r))}}function ri(e){return function(n){if(this.l){var r=this.l[n.type+e];if(n[Mn]==null)n[Mn]=Kr++;else if(n[Mn]<r[hn])return;return r(ge.event?ge.event(n):n)}}}function Jr(e,n,r,o,a,i,s,l,u,d){var h,m,f,p,g,w,b,v,I,D,N,_,T,C,P,z,E=n.type;if(n.constructor!==void 0)return null;128&r.__u&&(u=!!(32&r.__u),i=[l=n.__e=r.__e]),(h=ge.__b)&&h(n);e:if(typeof E=="function"){m=s.length;try{if(I=n.props,D=E.prototype&&E.prototype.render,N=(h=E.contextType)&&o[h.__c],_=h?N?N.props.value:h.__:o,r.__c?v=(f=n.__c=r.__c).__=f.__E:(D?n.__c=f=new E(I,_):(n.__c=f=new En(I,_),f.constructor=E,f.render=Vc),N&&N.sub(f),f.state||(f.state={}),f.__n=o,p=f.__d=!0,f.__h=[],f._sb=[]),D&&f.__s==null&&(f.__s=f.state),D&&E.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=ot({},f.__s)),ot(f.__s,E.getDerivedStateFromProps(I,f.__s))),g=f.props,w=f.state,f.__v=n,p)D&&E.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),D&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(D&&E.getDerivedStateFromProps==null&&I!==g&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(I,_),n.__v==r.__v||!f.__e&&f.shouldComponentUpdate!=null&&f.shouldComponentUpdate(I,f.__s,_)===!1){n.__v!=r.__v&&(f.props=I,f.state=f.__s,f.__d=!1),n.__e=r.__e,n.__k=r.__k,n.__k.some(function(R){R&&(R.__=n)}),Un.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&s.push(f),l=Lt(r);break e}f.componentWillUpdate!=null&&f.componentWillUpdate(I,f.__s,_),D&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(g,w,b)})}if(f.context=_,f.props=I,f.__P=e,f.__e=!1,T=ge.__r,C=0,D)f.state=f.__s,f.__d=!1,T&&T(n),h=f.render(f.props,f.state,f.context),Un.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,T&&T(n),h=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++C<25);f.state=f.__s,f.getChildContext!=null&&(o=ot(ot({},o),f.getChildContext())),D&&!p&&f.getSnapshotBeforeUpdate!=null&&(b=f.getSnapshotBeforeUpdate(g,w)),P=h!=null&&h.type===Kn&&h.key==null?ta(h.props.children):h,l=Xi(e,qn(P)?P:[P],n,r,o,a,i,s,l,u,d),f.base=n.__e,n.__u&=-161,f.__h.length&&s.push(f),v&&(f.__E=f.__=null)}catch(R){if(s.length=m,n.__v=null,u||i!=null){if(R.then){for(n.__u|=u?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;i!=null&&(i[i.indexOf(l)]=null),n.__e=l}else if(i!=null)for(z=i.length;z--;)Yr(i[z])}else n.__e=r.__e;n.__k==null&&(n.__k=r.__k||[]),R.then||Qi(n),ge.__e(R,n,r)}}else i==null&&n.__v==r.__v?(n.__k=r.__k,n.__e=r.__e):l=n.__e=Hc(r.__e,n,r,o,a,i,s,u,d);return(h=ge.diffed)&&h(n),128&n.__u?void 0:l}function Qi(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Qi))}function ea(e,n,r){for(var o=0;o<r.length;o++)Xr(r[o],r[++o],r[++o]);ge.__c&&ge.__c(n,e),e.some(function(a){try{e=a.__h,a.__h=[],e.some(function(i){i.call(a)})}catch(i){ge.__e(i,a.__v)}})}function ta(e){return typeof e!="object"||e==null||e.__b>0?e:qn(e)?e.map(ta):e.constructor!==void 0?null:ot({},e)}function Hc(e,n,r,o,a,i,s,l,u){var d,h,m,f,p,g,w,b=r.props||$n,v=n.props,I=n.type;if(I=="svg"?a="http://www.w3.org/2000/svg":I=="math"?a="http://www.w3.org/1998/Math/MathML":a||(a="http://www.w3.org/1999/xhtml"),i!=null){for(d=0;d<i.length;d++)if((p=i[d])&&"setAttribute"in p==!!I&&(I?p.localName==I:p.nodeType==3)){e=p,i[d]=null;break}}if(e==null){if(I==null)return document.createTextNode(v);e=document.createElementNS(a,I,v.is&&v),l&&(ge.__m&&ge.__m(n,i),l=!1),i=null}if(I==null)b===v||l&&e.data==v||(e.data=v);else{if(i=I=="textarea"&&v.defaultValue!=null?null:i&&xn.call(e.childNodes),!l&&i!=null)for(b={},d=0;d<e.attributes.length;d++)b[(p=e.attributes[d]).name]=p.value;for(d in b)p=b[d],d=="dangerouslySetInnerHTML"?m=p:d=="children"||d in v||d=="value"&&"defaultValue"in v||d=="checked"&&"defaultChecked"in v||Tn(e,d,null,p,a);for(d in v)p=v[d],d=="children"?f=p:d=="dangerouslySetInnerHTML"?h=p:d=="value"?g=p:d=="checked"?w=p:l&&typeof p!="function"||b[d]===p||Tn(e,d,p,b[d],a);if(h)l||m&&(h.__html==m.__html||h.__html==e.innerHTML)||(e.innerHTML=h.__html),n.__k=[];else if(m&&(e.innerHTML=""),Xi(n.type=="template"?e.content:e,qn(f)?f:[f],n,r,o,I=="foreignObject"?"http://www.w3.org/1999/xhtml":a,i,s,i?i[0]:r.__k&&Lt(r,0),l,u),i!=null)for(d=i.length;d--;)Yr(i[d]);l&&I!="textarea"||(d="value",I=="progress"&&g==null?e.removeAttribute("value"):g!=null&&(g!==e[d]||I=="progress"&&!g||I=="option"&&g!=b[d])&&Tn(e,d,g,b[d],a),d="checked",w!=null&&w!=e[d]&&Tn(e,d,w,b[d],a))}return e}function Xr(e,n,r){try{if(typeof e=="function"){var o=typeof e.__u=="function";o&&e.__u(),o&&n==null||(e.__u=e(n))}else e.current=n}catch(a){ge.__e(a,r)}}function na(e,n,r){var o,a;if(ge.unmount&&ge.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||Xr(o,null,n)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(i){ge.__e(i,n)}o.base=o.__P=o.__n=null}if(o=e.__k)for(a=0;a<o.length;a++)o[a]&&na(o[a],n,r||typeof e.type!="function");r||Yr(e.__e),e.__c=e.__=e.__e=void 0}function Vc(e,n,r){return this.constructor(e,r)}function Gc(e,n,r){var o,a,i,s;n==document&&(n=document.documentElement),ge.__&&ge.__(e,n),a=(o=!1)?null:n.__k,i=[],s=[],Jr(n,e=n.__k=zc(Kn,null,[e]),a||$n,$n,n.namespaceURI,a?null:n.firstChild?xn.call(n.childNodes):null,i,a?a.__e:n.firstChild,o,s),ea(i,e,s),e.props.children=null}function ra(e,n,r){var o,a,i,s,l=ot({},e.props);for(i in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),n)i=="key"?o=n[i]:i=="ref"?a=n[i]:l[i]=n[i]===void 0&&s!=null?s[i]:n[i];return arguments.length>2&&(l.children=arguments.length>3?xn.call(arguments,2):r),pn(e.type,l,o||e.key,a||e.ref,null)}xn=Un.slice,ge={__e:function(e,n,r,o){for(var a,i,s;n=n.__;)if((a=n.__c)&&!a.__)try{if((i=a.constructor)&&i.getDerivedStateFromError!=null&&(a.setState(i.getDerivedStateFromError(e)),s=a.__d),a.componentDidCatch!=null&&(a.componentDidCatch(e,o||{}),s=a.__d),s)return a.__E=a}catch(l){e=l}throw e}},Gi=0,Wi=function(e){return e!=null&&e.constructor===void 0},En.prototype.setState=function(e,n){var r;r=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ot({},this.state),typeof e=="function"&&(e=e(ot({},r),this.props)),e&&ot(r,e),e!=null&&this.__v&&(n&&this._sb.push(n),ti(this))},En.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),ti(this))},En.prototype.render=Kn,It=[],qi=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ki=function(e,n){return e.__v.__b-n.__v.__b},Bn.__r=0,lr=Math.random().toString(8),Mn="__d"+lr,hn="__a"+lr,Yi=/(PointerCapture)$|Capture$/i,Kr=0,Rr=ri(!1),Fr=ri(!0);function oi(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,o=Array(n);r<n;r++)o[r]=e[r];return o}function Wc(e){if(Array.isArray(e))return e}function qc(e,n,r){return(n=Qc(n))in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function Kc(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,a,i,s,l=[],u=!0,d=!1;try{if(i=(r=r.call(e)).next,n!==0)for(;!(u=(o=i.call(r)).done)&&(l.push(o.value),l.length!==n);u=!0);}catch(h){d=!0,a=h}finally{try{if(!u&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(d)throw a}}return l}}function Yc(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
255
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ii(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,o)}return r}function Jc(e){for(var n=1;n<arguments.length;n++){var r=arguments[n]!=null?arguments[n]:{};n%2?ii(Object(r),!0).forEach(function(o){qc(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ii(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Xc(e,n){return Wc(e)||Kc(e,n)||ed(e,n)||Yc()}function Zc(e,n){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,n);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function Qc(e){var n=Zc(e,"string");return typeof n=="symbol"?n:n+""}function Hn(e){"@babel/helpers - typeof";return Hn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Hn(e)}function ed(e,n){if(e){if(typeof e=="string")return oi(e,n);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?oi(e,n):void 0}}var Lr=function(n){if(Hn(n)!=="object")return n;var r=ra(n);if(r.props){var o;r.props=Jc({},r.props),r!=null&&(o=r.props)!==null&&o!==void 0&&o.children&&(r.props.children=Array.isArray(r.props.children)?r.props.children.map(Lr):Lr(r.props.children))}return r},td=function(n){return Wi(ra(n))},nd=function(n,r){delete r.__k,Gc(Lr(n),r)};function rd(e,n){n===void 0&&(n={});var r=n.insertAt;if(!(typeof document>"u")){var o=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",r==="top"&&o.firstChild?o.insertBefore(a,o.firstChild):o.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}var od=`.float-tooltip-kap {
256
+ position: absolute;
257
+ width: max-content; /* prevent shrinking near right edge */
258
+ max-width: max(50%, 150px);
259
+ padding: 3px 5px;
260
+ border-radius: 3px;
261
+ font: 12px sans-serif;
262
+ color: #eee;
263
+ background: rgba(0,0,0,0.6);
264
+ pointer-events: none;
265
+ }
266
+ `;rd(od);var id=qr({props:{content:{default:!1},offsetX:{triggerUpdate:!1},offsetY:{triggerUpdate:!1}},init:function(n,r){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=o.style,i=a===void 0?{}:a,s=!!n&&Hn(n)==="object"&&!!n.node&&typeof n.node=="function",l=Sr(s?n.node():n);l.style("position")==="static"&&l.style("position","relative"),r.tooltipEl=l.append("div").attr("class","float-tooltip-kap"),Object.entries(i).forEach(function(d){var h=Xc(d,2),m=h[0],f=h[1];return r.tooltipEl.style(m,f)}),r.tooltipEl.style("left","-10000px").style("display","none");var u="tooltip-".concat(Math.round(Math.random()*1e12));r.mouseInside=!1,l.on("mousemove.".concat(u),function(d){r.mouseInside=!0;var h=Xa(d),m=l.node(),f=m.offsetWidth,p=m.offsetHeight,g=[r.offsetX===null||r.offsetX===void 0?"-".concat(h[0]/f*100,"%"):typeof r.offsetX=="number"?"calc(-50% + ".concat(r.offsetX,"px)"):r.offsetX,r.offsetY===null||r.offsetY===void 0?p>130&&p-h[1]<100?"calc(-100% - 6px)":"21px":typeof r.offsetY=="number"?r.offsetY<0?"calc(-100% - ".concat(Math.abs(r.offsetY),"px)"):"".concat(r.offsetY,"px"):r.offsetY];r.tooltipEl.style("left",h[0]+"px").style("top",h[1]+"px").style("transform","translate(".concat(g.join(","),")")),r.content&&r.tooltipEl.style("display","inline")}),l.on("mouseover.".concat(u),function(){r.mouseInside=!0,r.content&&r.tooltipEl.style("display","inline")}),l.on("mouseout.".concat(u),function(){r.mouseInside=!1,r.tooltipEl.style("display","none")})},update:function(n){n.tooltipEl.style("display",n.content&&n.mouseInside?"inline":"none"),n.content?n.content instanceof HTMLElement?(n.tooltipEl.text(""),n.tooltipEl.append(function(){return n.content})):typeof n.content=="string"?n.tooltipEl.html(n.content):td(n.content)?(n.tooltipEl.text(""),nd(n.content,n.tooltipEl.node())):(n.tooltipEl.style("display","none"),console.warn("Tooltip content is invalid, skipping.",n.content,n.content.toString())):n.tooltipEl.text("")}});function ad(e,n,r){var o,a=1;e==null&&(e=0),n==null&&(n=0),r==null&&(r=0);function i(){var s,l=o.length,u,d=0,h=0,m=0;for(s=0;s<l;++s)u=o[s],d+=u.x||0,h+=u.y||0,m+=u.z||0;for(d=(d/l-e)*a,h=(h/l-n)*a,m=(m/l-r)*a,s=0;s<l;++s)u=o[s],d&&(u.x-=d),h&&(u.y-=h),m&&(u.z-=m)}return i.initialize=function(s){o=s},i.x=function(s){return arguments.length?(e=+s,i):e},i.y=function(s){return arguments.length?(n=+s,i):n},i.z=function(s){return arguments.length?(r=+s,i):r},i.strength=function(s){return arguments.length?(a=+s,i):a},i}function sd(e){const n=+this._x.call(null,e);return oa(this.cover(n),n,e)}function oa(e,n,r){if(isNaN(n))return e;var o,a=e._root,i={data:r},s=e._x0,l=e._x1,u,d,h,m,f;if(!a)return e._root=i,e;for(;a.length;)if((h=n>=(u=(s+l)/2))?s=u:l=u,o=a,!(a=a[m=+h]))return o[m]=i,e;if(d=+e._x.call(null,a.data),n===d)return i.next=a,o?o[m]=i:e._root=i,e;do o=o?o[m]=new Array(2):e._root=new Array(2),(h=n>=(u=(s+l)/2))?s=u:l=u;while((m=+h)==(f=+(d>=u)));return o[f]=a,o[m]=i,e}function ld(e){Array.isArray(e)||(e=Array.from(e));const n=e.length,r=new Float64Array(n);let o=1/0,a=-1/0;for(let i=0,s;i<n;++i)isNaN(s=+this._x.call(null,e[i]))||(r[i]=s,s<o&&(o=s),s>a&&(a=s));if(o>a)return this;this.cover(o).cover(a);for(let i=0;i<n;++i)oa(this,r[i],e[i]);return this}function cd(e){if(isNaN(e=+e))return this;var n=this._x0,r=this._x1;if(isNaN(n))r=(n=Math.floor(e))+1;else{for(var o=r-n||1,a=this._root,i,s;n>e||e>=r;)switch(s=+(e<n),i=new Array(2),i[s]=a,a=i,o*=2,s){case 0:r=n+o;break;case 1:n=r-o;break}this._root&&this._root.length&&(this._root=a)}return this._x0=n,this._x1=r,this}function dd(){var e=[];return this.visit(function(n){if(!n.length)do e.push(n.data);while(n=n.next)}),e}function ud(e){return arguments.length?this.cover(+e[0][0]).cover(+e[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function pt(e,n,r){this.node=e,this.x0=n,this.x1=r}function fd(e,n){var r,o=this._x0,a,i,s=this._x1,l=[],u=this._root,d,h;for(u&&l.push(new pt(u,o,s)),n==null?n=1/0:(o=e-n,s=e+n);d=l.pop();)if(!(!(u=d.node)||(a=d.x0)>s||(i=d.x1)<o))if(u.length){var m=(a+i)/2;l.push(new pt(u[1],m,i),new pt(u[0],a,m)),(h=+(e>=m))&&(d=l[l.length-1],l[l.length-1]=l[l.length-1-h],l[l.length-1-h]=d)}else{var f=Math.abs(e-+this._x.call(null,u.data));f<n&&(n=f,o=e-f,s=e+f,r=u.data)}return r}function md(e){if(isNaN(u=+this._x.call(null,e)))return this;var n,r=this._root,o,a,i,s=this._x0,l=this._x1,u,d,h,m,f;if(!r)return this;if(r.length)for(;;){if((h=u>=(d=(s+l)/2))?s=d:l=d,n=r,!(r=r[m=+h]))return this;if(!r.length)break;n[m+1&1]&&(o=n,f=m)}for(;r.data!==e;)if(a=r,!(r=r.next))return this;return(i=r.next)&&delete r.next,a?(i?a.next=i:delete a.next,this):n?(i?n[m]=i:delete n[m],(r=n[0]||n[1])&&r===(n[1]||n[0])&&!r.length&&(o?o[f]=r:this._root=r),this):(this._root=i,this)}function hd(e){for(var n=0,r=e.length;n<r;++n)this.remove(e[n]);return this}function pd(){return this._root}function gd(){var e=0;return this.visit(function(n){if(!n.length)do++e;while(n=n.next)}),e}function yd(e){var n=[],r,o=this._root,a,i,s;for(o&&n.push(new pt(o,this._x0,this._x1));r=n.pop();)if(!e(o=r.node,i=r.x0,s=r.x1)&&o.length){var l=(i+s)/2;(a=o[1])&&n.push(new pt(a,l,s)),(a=o[0])&&n.push(new pt(a,i,l))}return this}function vd(e){var n=[],r=[],o;for(this._root&&n.push(new pt(this._root,this._x0,this._x1));o=n.pop();){var a=o.node;if(a.length){var i,s=o.x0,l=o.x1,u=(s+l)/2;(i=a[0])&&n.push(new pt(i,s,u)),(i=a[1])&&n.push(new pt(i,u,l))}r.push(o)}for(;o=r.pop();)e(o.node,o.x0,o.x1);return this}function bd(e){return e[0]}function xd(e){return arguments.length?(this._x=e,this):this._x}function ia(e,n){var r=new Zr(n??bd,NaN,NaN);return e==null?r:r.addAll(e)}function Zr(e,n,r){this._x=e,this._x0=n,this._x1=r,this._root=void 0}function ai(e){for(var n={data:e.data},r=n;e=e.next;)r=r.next={data:e.data};return n}var Re=ia.prototype=Zr.prototype;Re.copy=function(){var e=new Zr(this._x,this._x0,this._x1),n=this._root,r,o;if(!n)return e;if(!n.length)return e._root=ai(n),e;for(r=[{source:n,target:e._root=new Array(2)}];n=r.pop();)for(var a=0;a<2;++a)(o=n.source[a])&&(o.length?r.push({source:o,target:n.target[a]=new Array(2)}):n.target[a]=ai(o));return e};Re.add=sd;Re.addAll=ld;Re.cover=cd;Re.data=dd;Re.extent=ud;Re.find=fd;Re.remove=md;Re.removeAll=hd;Re.root=pd;Re.size=gd;Re.visit=yd;Re.visitAfter=vd;Re.x=xd;function wd(e){const n=+this._x.call(null,e),r=+this._y.call(null,e),o=+this._z.call(null,e);return aa(this.cover(n,r,o),n,r,o,e)}function aa(e,n,r,o,a){if(isNaN(n)||isNaN(r)||isNaN(o))return e;var i,s=e._root,l={data:a},u=e._x0,d=e._y0,h=e._z0,m=e._x1,f=e._y1,p=e._z1,g,w,b,v,I,D,N,_,T,C,P;if(!s)return e._root=l,e;for(;s.length;)if((N=n>=(g=(u+m)/2))?u=g:m=g,(_=r>=(w=(d+f)/2))?d=w:f=w,(T=o>=(b=(h+p)/2))?h=b:p=b,i=s,!(s=s[C=T<<2|_<<1|N]))return i[C]=l,e;if(v=+e._x.call(null,s.data),I=+e._y.call(null,s.data),D=+e._z.call(null,s.data),n===v&&r===I&&o===D)return l.next=s,i?i[C]=l:e._root=l,e;do i=i?i[C]=new Array(8):e._root=new Array(8),(N=n>=(g=(u+m)/2))?u=g:m=g,(_=r>=(w=(d+f)/2))?d=w:f=w,(T=o>=(b=(h+p)/2))?h=b:p=b;while((C=T<<2|_<<1|N)===(P=(D>=b)<<2|(I>=w)<<1|v>=g));return i[P]=s,i[C]=l,e}function _d(e){Array.isArray(e)||(e=Array.from(e));const n=e.length,r=new Float64Array(n),o=new Float64Array(n),a=new Float64Array(n);let i=1/0,s=1/0,l=1/0,u=-1/0,d=-1/0,h=-1/0;for(let m=0,f,p,g,w;m<n;++m)isNaN(p=+this._x.call(null,f=e[m]))||isNaN(g=+this._y.call(null,f))||isNaN(w=+this._z.call(null,f))||(r[m]=p,o[m]=g,a[m]=w,p<i&&(i=p),p>u&&(u=p),g<s&&(s=g),g>d&&(d=g),w<l&&(l=w),w>h&&(h=w));if(i>u||s>d||l>h)return this;this.cover(i,s,l).cover(u,d,h);for(let m=0;m<n;++m)aa(this,r[m],o[m],a[m],e[m]);return this}function kd(e,n,r){if(isNaN(e=+e)||isNaN(n=+n)||isNaN(r=+r))return this;var o=this._x0,a=this._y0,i=this._z0,s=this._x1,l=this._y1,u=this._z1;if(isNaN(o))s=(o=Math.floor(e))+1,l=(a=Math.floor(n))+1,u=(i=Math.floor(r))+1;else{for(var d=s-o||1,h=this._root,m,f;o>e||e>=s||a>n||n>=l||i>r||r>=u;)switch(f=(r<i)<<2|(n<a)<<1|e<o,m=new Array(8),m[f]=h,h=m,d*=2,f){case 0:s=o+d,l=a+d,u=i+d;break;case 1:o=s-d,l=a+d,u=i+d;break;case 2:s=o+d,a=l-d,u=i+d;break;case 3:o=s-d,a=l-d,u=i+d;break;case 4:s=o+d,l=a+d,i=u-d;break;case 5:o=s-d,l=a+d,i=u-d;break;case 6:s=o+d,a=l-d,i=u-d;break;case 7:o=s-d,a=l-d,i=u-d;break}this._root&&this._root.length&&(this._root=h)}return this._x0=o,this._y0=a,this._z0=i,this._x1=s,this._y1=l,this._z1=u,this}function Id(){var e=[];return this.visit(function(n){if(!n.length)do e.push(n.data);while(n=n.next)}),e}function Sd(e){return arguments.length?this.cover(+e[0][0],+e[0][1],+e[0][2]).cover(+e[1][0],+e[1][1],+e[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function de(e,n,r,o,a,i,s){this.node=e,this.x0=n,this.y0=r,this.z0=o,this.x1=a,this.y1=i,this.z1=s}function Cd(e,n,r,o){var a,i=this._x0,s=this._y0,l=this._z0,u,d,h,m,f,p,g=this._x1,w=this._y1,b=this._z1,v=[],I=this._root,D,N;for(I&&v.push(new de(I,i,s,l,g,w,b)),o==null?o=1/0:(i=e-o,s=n-o,l=r-o,g=e+o,w=n+o,b=r+o,o*=o);D=v.pop();)if(!(!(I=D.node)||(u=D.x0)>g||(d=D.y0)>w||(h=D.z0)>b||(m=D.x1)<i||(f=D.y1)<s||(p=D.z1)<l))if(I.length){var _=(u+m)/2,T=(d+f)/2,C=(h+p)/2;v.push(new de(I[7],_,T,C,m,f,p),new de(I[6],u,T,C,_,f,p),new de(I[5],_,d,C,m,T,p),new de(I[4],u,d,C,_,T,p),new de(I[3],_,T,h,m,f,C),new de(I[2],u,T,h,_,f,C),new de(I[1],_,d,h,m,T,C),new de(I[0],u,d,h,_,T,C)),(N=(r>=C)<<2|(n>=T)<<1|e>=_)&&(D=v[v.length-1],v[v.length-1]=v[v.length-1-N],v[v.length-1-N]=D)}else{var P=e-+this._x.call(null,I.data),z=n-+this._y.call(null,I.data),E=r-+this._z.call(null,I.data),R=P*P+z*z+E*E;if(R<o){var $=Math.sqrt(o=R);i=e-$,s=n-$,l=r-$,g=e+$,w=n+$,b=r+$,a=I.data}}return a}const Dd=(e,n,r,o,a,i)=>Math.sqrt((e-o)**2+(n-a)**2+(r-i)**2);function Nd(e,n,r,o){const a=[],i=e-o,s=n-o,l=r-o,u=e+o,d=n+o,h=r+o;return this.visit((m,f,p,g,w,b,v)=>{if(!m.length)do{const I=m.data;Dd(e,n,r,this._x(I),this._y(I),this._z(I))<=o&&a.push(I)}while(m=m.next);return f>u||p>d||g>h||w<i||b<s||v<l}),a}function Pd(e){if(isNaN(f=+this._x.call(null,e))||isNaN(p=+this._y.call(null,e))||isNaN(g=+this._z.call(null,e)))return this;var n,r=this._root,o,a,i,s=this._x0,l=this._y0,u=this._z0,d=this._x1,h=this._y1,m=this._z1,f,p,g,w,b,v,I,D,N,_,T;if(!r)return this;if(r.length)for(;;){if((I=f>=(w=(s+d)/2))?s=w:d=w,(D=p>=(b=(l+h)/2))?l=b:h=b,(N=g>=(v=(u+m)/2))?u=v:m=v,n=r,!(r=r[_=N<<2|D<<1|I]))return this;if(!r.length)break;(n[_+1&7]||n[_+2&7]||n[_+3&7]||n[_+4&7]||n[_+5&7]||n[_+6&7]||n[_+7&7])&&(o=n,T=_)}for(;r.data!==e;)if(a=r,!(r=r.next))return this;return(i=r.next)&&delete r.next,a?(i?a.next=i:delete a.next,this):n?(i?n[_]=i:delete n[_],(r=n[0]||n[1]||n[2]||n[3]||n[4]||n[5]||n[6]||n[7])&&r===(n[7]||n[6]||n[5]||n[4]||n[3]||n[2]||n[1]||n[0])&&!r.length&&(o?o[T]=r:this._root=r),this):(this._root=i,this)}function Td(e){for(var n=0,r=e.length;n<r;++n)this.remove(e[n]);return this}function Ad(){return this._root}function jd(){var e=0;return this.visit(function(n){if(!n.length)do++e;while(n=n.next)}),e}function Md(e){var n=[],r,o=this._root,a,i,s,l,u,d,h;for(o&&n.push(new de(o,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));r=n.pop();)if(!e(o=r.node,i=r.x0,s=r.y0,l=r.z0,u=r.x1,d=r.y1,h=r.z1)&&o.length){var m=(i+u)/2,f=(s+d)/2,p=(l+h)/2;(a=o[7])&&n.push(new de(a,m,f,p,u,d,h)),(a=o[6])&&n.push(new de(a,i,f,p,m,d,h)),(a=o[5])&&n.push(new de(a,m,s,p,u,f,h)),(a=o[4])&&n.push(new de(a,i,s,p,m,f,h)),(a=o[3])&&n.push(new de(a,m,f,l,u,d,p)),(a=o[2])&&n.push(new de(a,i,f,l,m,d,p)),(a=o[1])&&n.push(new de(a,m,s,l,u,f,p)),(a=o[0])&&n.push(new de(a,i,s,l,m,f,p))}return this}function Ed(e){var n=[],r=[],o;for(this._root&&n.push(new de(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));o=n.pop();){var a=o.node;if(a.length){var i,s=o.x0,l=o.y0,u=o.z0,d=o.x1,h=o.y1,m=o.z1,f=(s+d)/2,p=(l+h)/2,g=(u+m)/2;(i=a[0])&&n.push(new de(i,s,l,u,f,p,g)),(i=a[1])&&n.push(new de(i,f,l,u,d,p,g)),(i=a[2])&&n.push(new de(i,s,p,u,f,h,g)),(i=a[3])&&n.push(new de(i,f,p,u,d,h,g)),(i=a[4])&&n.push(new de(i,s,l,g,f,p,m)),(i=a[5])&&n.push(new de(i,f,l,g,d,p,m)),(i=a[6])&&n.push(new de(i,s,p,g,f,h,m)),(i=a[7])&&n.push(new de(i,f,p,g,d,h,m))}r.push(o)}for(;o=r.pop();)e(o.node,o.x0,o.y0,o.z0,o.x1,o.y1,o.z1);return this}function Od(e){return e[0]}function Rd(e){return arguments.length?(this._x=e,this):this._x}function Fd(e){return e[1]}function Ld(e){return arguments.length?(this._y=e,this):this._y}function zd(e){return e[2]}function $d(e){return arguments.length?(this._z=e,this):this._z}function sa(e,n,r,o){var a=new Qr(n??Od,r??Fd,o??zd,NaN,NaN,NaN,NaN,NaN,NaN);return e==null?a:a.addAll(e)}function Qr(e,n,r,o,a,i,s,l,u){this._x=e,this._y=n,this._z=r,this._x0=o,this._y0=a,this._z0=i,this._x1=s,this._y1=l,this._z1=u,this._root=void 0}function si(e){for(var n={data:e.data},r=n;e=e.next;)r=r.next={data:e.data};return n}var Se=sa.prototype=Qr.prototype;Se.copy=function(){var e=new Qr(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),n=this._root,r,o;if(!n)return e;if(!n.length)return e._root=si(n),e;for(r=[{source:n,target:e._root=new Array(8)}];n=r.pop();)for(var a=0;a<8;++a)(o=n.source[a])&&(o.length?r.push({source:o,target:n.target[a]=new Array(8)}):n.target[a]=si(o));return e};Se.add=wd;Se.addAll=_d;Se.cover=kd;Se.data=Id;Se.extent=Sd;Se.find=Cd;Se.findAllWithinRadius=Nd;Se.remove=Pd;Se.removeAll=Td;Se.root=Ad;Se.size=jd;Se.visit=Md;Se.visitAfter=Ed;Se.x=Rd;Se.y=Ld;Se.z=$d;function ht(e){return function(){return e}}function mt(e){return(e()-.5)*1e-6}function Ud(e){return e.index}function li(e,n){var r=e.get(n);if(!r)throw new Error("node not found: "+n);return r}function Bd(e){var n=Ud,r=f,o,a=ht(30),i,s,l,u,d,h,m=1;e==null&&(e=[]);function f(v){return 1/Math.min(u[v.source.index],u[v.target.index])}function p(v){for(var I=0,D=e.length;I<m;++I)for(var N=0,_,T,C,P=0,z=0,E=0,R,$;N<D;++N)_=e[N],T=_.source,C=_.target,P=C.x+C.vx-T.x-T.vx||mt(h),l>1&&(z=C.y+C.vy-T.y-T.vy||mt(h)),l>2&&(E=C.z+C.vz-T.z-T.vz||mt(h)),R=Math.sqrt(P*P+z*z+E*E),R=(R-i[N])/R*v*o[N],P*=R,z*=R,E*=R,C.vx-=P*($=d[N]),l>1&&(C.vy-=z*$),l>2&&(C.vz-=E*$),T.vx+=P*($=1-$),l>1&&(T.vy+=z*$),l>2&&(T.vz+=E*$)}function g(){if(s){var v,I=s.length,D=e.length,N=new Map(s.map((T,C)=>[n(T,C,s),T])),_;for(v=0,u=new Array(I);v<D;++v)_=e[v],_.index=v,typeof _.source!="object"&&(_.source=li(N,_.source)),typeof _.target!="object"&&(_.target=li(N,_.target)),u[_.source.index]=(u[_.source.index]||0)+1,u[_.target.index]=(u[_.target.index]||0)+1;for(v=0,d=new Array(D);v<D;++v)_=e[v],d[v]=u[_.source.index]/(u[_.source.index]+u[_.target.index]);o=new Array(D),w(),i=new Array(D),b()}}function w(){if(s)for(var v=0,I=e.length;v<I;++v)o[v]=+r(e[v],v,e)}function b(){if(s)for(var v=0,I=e.length;v<I;++v)i[v]=+a(e[v],v,e)}return p.initialize=function(v,...I){s=v,h=I.find(D=>typeof D=="function")||Math.random,l=I.find(D=>[1,2,3].includes(D))||2,g()},p.links=function(v){return arguments.length?(e=v,g(),p):e},p.id=function(v){return arguments.length?(n=v,p):n},p.iterations=function(v){return arguments.length?(m=+v,p):m},p.strength=function(v){return arguments.length?(r=typeof v=="function"?v:ht(+v),w(),p):r},p.distance=function(v){return arguments.length?(a=typeof v=="function"?v:ht(+v),b(),p):a},p}const Hd=1664525,Vd=1013904223,ci=4294967296;function Gd(){let e=1;return()=>(e=(Hd*e+Vd)%ci)/ci}var di=3;function cr(e){return e.x}function ui(e){return e.y}function Wd(e){return e.z}var qd=10,Kd=Math.PI*(3-Math.sqrt(5)),Yd=Math.PI*20/(9+Math.sqrt(221));function Jd(e,n){n=n||2;var r=Math.min(di,Math.max(1,Math.round(n))),o,a=1,i=.001,s=1-Math.pow(i,1/300),l=0,u=.6,d=new Map,h=Za(p),m=Qa("tick","end"),f=Gd();e==null&&(e=[]);function p(){g(),m.call("tick",o),a<i&&(h.stop(),m.call("end",o))}function g(v){var I,D=e.length,N;v===void 0&&(v=1);for(var _=0;_<v;++_)for(a+=(l-a)*s,d.forEach(function(T){T(a)}),I=0;I<D;++I)N=e[I],N.fx==null?N.x+=N.vx*=u:(N.x=N.fx,N.vx=0),r>1&&(N.fy==null?N.y+=N.vy*=u:(N.y=N.fy,N.vy=0)),r>2&&(N.fz==null?N.z+=N.vz*=u:(N.z=N.fz,N.vz=0));return o}function w(){for(var v=0,I=e.length,D;v<I;++v){if(D=e[v],D.index=v,D.fx!=null&&(D.x=D.fx),D.fy!=null&&(D.y=D.fy),D.fz!=null&&(D.z=D.fz),isNaN(D.x)||r>1&&isNaN(D.y)||r>2&&isNaN(D.z)){var N=qd*(r>2?Math.cbrt(.5+v):r>1?Math.sqrt(.5+v):v),_=v*Kd,T=v*Yd;r===1?D.x=N:r===2?(D.x=N*Math.cos(_),D.y=N*Math.sin(_)):(D.x=N*Math.sin(_)*Math.cos(T),D.y=N*Math.cos(_),D.z=N*Math.sin(_)*Math.sin(T))}(isNaN(D.vx)||r>1&&isNaN(D.vy)||r>2&&isNaN(D.vz))&&(D.vx=0,r>1&&(D.vy=0),r>2&&(D.vz=0))}}function b(v){return v.initialize&&v.initialize(e,f,r),v}return w(),o={tick:g,restart:function(){return h.restart(p),o},stop:function(){return h.stop(),o},numDimensions:function(v){return arguments.length?(r=Math.min(di,Math.max(1,Math.round(v))),d.forEach(b),o):r},nodes:function(v){return arguments.length?(e=v,w(),d.forEach(b),o):e},alpha:function(v){return arguments.length?(a=+v,o):a},alphaMin:function(v){return arguments.length?(i=+v,o):i},alphaDecay:function(v){return arguments.length?(s=+v,o):+s},alphaTarget:function(v){return arguments.length?(l=+v,o):l},velocityDecay:function(v){return arguments.length?(u=1-v,o):1-u},randomSource:function(v){return arguments.length?(f=v,d.forEach(b),o):f},force:function(v,I){return arguments.length>1?(I==null?d.delete(v):d.set(v,b(I)),o):d.get(v)},find:function(){var v=Array.prototype.slice.call(arguments),I=v.shift()||0,D=(r>1?v.shift():null)||0,N=(r>2?v.shift():null)||0,_=v.shift()||1/0,T=0,C=e.length,P,z,E,R,$,H;for(_*=_,T=0;T<C;++T)$=e[T],P=I-$.x,z=D-($.y||0),E=N-($.z||0),R=P*P+z*z+E*E,R<_&&(H=$,_=R);return H},on:function(v,I){return arguments.length>1?(m.on(v,I),o):m.on(v)}}}function Xd(){var e,n,r,o,a,i=ht(-30),s,l=1,u=1/0,d=.81;function h(g){var w,b=e.length,v=(n===1?ia(e,cr):n===2?es(e,cr,ui):n===3?sa(e,cr,ui,Wd):null).visitAfter(f);for(a=g,w=0;w<b;++w)r=e[w],v.visit(p)}function m(){if(e){var g,w=e.length,b;for(s=new Array(w),g=0;g<w;++g)b=e[g],s[b.index]=+i(b,g,e)}}function f(g){var w=0,b,v,I=0,D,N,_,T,C=g.length;if(C){for(D=N=_=T=0;T<C;++T)(b=g[T])&&(v=Math.abs(b.value))&&(w+=b.value,I+=v,D+=v*(b.x||0),N+=v*(b.y||0),_+=v*(b.z||0));w*=Math.sqrt(4/C),g.x=D/I,n>1&&(g.y=N/I),n>2&&(g.z=_/I)}else{b=g,b.x=b.data.x,n>1&&(b.y=b.data.y),n>2&&(b.z=b.data.z);do w+=s[b.data.index];while(b=b.next)}g.value=w}function p(g,w,b,v,I){if(!g.value)return!0;var D=[b,v,I][n-1],N=g.x-r.x,_=n>1?g.y-r.y:0,T=n>2?g.z-r.z:0,C=D-w,P=N*N+_*_+T*T;if(C*C/d<P)return P<u&&(N===0&&(N=mt(o),P+=N*N),n>1&&_===0&&(_=mt(o),P+=_*_),n>2&&T===0&&(T=mt(o),P+=T*T),P<l&&(P=Math.sqrt(l*P)),r.vx+=N*g.value*a/P,n>1&&(r.vy+=_*g.value*a/P),n>2&&(r.vz+=T*g.value*a/P)),!0;if(g.length||P>=u)return;(g.data!==r||g.next)&&(N===0&&(N=mt(o),P+=N*N),n>1&&_===0&&(_=mt(o),P+=_*_),n>2&&T===0&&(T=mt(o),P+=T*T),P<l&&(P=Math.sqrt(l*P)));do g.data!==r&&(C=s[g.data.index]*a/P,r.vx+=N*C,n>1&&(r.vy+=_*C),n>2&&(r.vz+=T*C));while(g=g.next)}return h.initialize=function(g,...w){e=g,o=w.find(b=>typeof b=="function")||Math.random,n=w.find(b=>[1,2,3].includes(b))||2,m()},h.strength=function(g){return arguments.length?(i=typeof g=="function"?g:ht(+g),m(),h):i},h.distanceMin=function(g){return arguments.length?(l=g*g,h):Math.sqrt(l)},h.distanceMax=function(g){return arguments.length?(u=g*g,h):Math.sqrt(u)},h.theta=function(g){return arguments.length?(d=g*g,h):Math.sqrt(d)},h}function Zd(e,n,r,o){var a,i,s=ht(.1),l,u;typeof e!="function"&&(e=ht(+e)),n==null&&(n=0),r==null&&(r=0),o==null&&(o=0);function d(m){for(var f=0,p=a.length;f<p;++f){var g=a[f],w=g.x-n||1e-6,b=(g.y||0)-r||1e-6,v=(g.z||0)-o||1e-6,I=Math.sqrt(w*w+b*b+v*v),D=(u[f]-I)*l[f]*m/I;g.vx+=w*D,i>1&&(g.vy+=b*D),i>2&&(g.vz+=v*D)}}function h(){if(a){var m,f=a.length;for(l=new Array(f),u=new Array(f),m=0;m<f;++m)u[m]=+e(a[m],m,a),l[m]=isNaN(u[m])?0:+s(a[m],m,a)}}return d.initialize=function(m,...f){a=m,i=f.find(p=>[1,2,3].includes(p))||2,h()},d.strength=function(m){return arguments.length?(s=typeof m=="function"?m:ht(+m),h(),d):s},d.radius=function(m){return arguments.length?(e=typeof m=="function"?m:ht(+m),h(),d):e},d.x=function(m){return arguments.length?(n=+m,d):n},d.y=function(m){return arguments.length?(r=+m,d):r},d.z=function(m){return arguments.length?(o=+m,d):o},d}const{abs:sn,cos:ut,sin:Yt,acos:Qd,atan2:ln,sqrt:wt,pow:Ue}=Math;function cn(e){return e<0?-Ue(-e,1/3):Ue(e,1/3)}const la=Math.PI,An=2*la,_t=la/2,eu=1e-6,dr=Number.MAX_SAFE_INTEGER||9007199254740991,ur=Number.MIN_SAFE_INTEGER||-9007199254740991,tu={x:0,y:0,z:0},U={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(e,n){const r=n(e);let o=r.x*r.x+r.y*r.y;return typeof r.z<"u"&&(o+=r.z*r.z),wt(o)},compute:function(e,n,r){if(e===0)return n[0].t=0,n[0];const o=n.length-1;if(e===1)return n[o].t=1,n[o];const a=1-e;let i=n;if(o===0)return n[0].t=e,n[0];if(o===1){const l={x:a*i[0].x+e*i[1].x,y:a*i[0].y+e*i[1].y,t:e};return r&&(l.z=a*i[0].z+e*i[1].z),l}if(o<4){let l=a*a,u=e*e,d,h,m,f=0;o===2?(i=[i[0],i[1],i[2],tu],d=l,h=a*e*2,m=u):o===3&&(d=l*a,h=l*e*3,m=a*u*3,f=e*u);const p={x:d*i[0].x+h*i[1].x+m*i[2].x+f*i[3].x,y:d*i[0].y+h*i[1].y+m*i[2].y+f*i[3].y,t:e};return r&&(p.z=d*i[0].z+h*i[1].z+m*i[2].z+f*i[3].z),p}const s=JSON.parse(JSON.stringify(n));for(;s.length>1;){for(let l=0;l<s.length-1;l++)s[l]={x:s[l].x+(s[l+1].x-s[l].x)*e,y:s[l].y+(s[l+1].y-s[l].y)*e},typeof s[l].z<"u"&&(s[l].z=s[l].z+(s[l+1].z-s[l].z)*e);s.splice(s.length-1,1)}return s[0].t=e,s[0]},computeWithRatios:function(e,n,r,o){const a=1-e,i=r,s=n;let l=i[0],u=i[1],d=i[2],h=i[3],m;if(l*=a,u*=e,s.length===2)return m=l+u,{x:(l*s[0].x+u*s[1].x)/m,y:(l*s[0].y+u*s[1].y)/m,z:o?(l*s[0].z+u*s[1].z)/m:!1,t:e};if(l*=a,u*=2*a,d*=e*e,s.length===3)return m=l+u+d,{x:(l*s[0].x+u*s[1].x+d*s[2].x)/m,y:(l*s[0].y+u*s[1].y+d*s[2].y)/m,z:o?(l*s[0].z+u*s[1].z+d*s[2].z)/m:!1,t:e};if(l*=a,u*=1.5*a,d*=3*a,h*=e*e*e,s.length===4)return m=l+u+d+h,{x:(l*s[0].x+u*s[1].x+d*s[2].x+h*s[3].x)/m,y:(l*s[0].y+u*s[1].y+d*s[2].y+h*s[3].y)/m,z:o?(l*s[0].z+u*s[1].z+d*s[2].z+h*s[3].z)/m:!1,t:e}},derive:function(e,n){const r=[];for(let o=e,a=o.length,i=a-1;a>1;a--,i--){const s=[];for(let l=0,u;l<i;l++)u={x:i*(o[l+1].x-o[l].x),y:i*(o[l+1].y-o[l].y)},n&&(u.z=i*(o[l+1].z-o[l].z)),s.push(u);r.push(s),o=s}return r},between:function(e,n,r){return n<=e&&e<=r||U.approximately(e,n)||U.approximately(e,r)},approximately:function(e,n,r){return sn(e-n)<=(r||eu)},length:function(e){const r=U.Tvalues.length;let o=0;for(let a=0,i;a<r;a++)i=.5*U.Tvalues[a]+.5,o+=U.Cvalues[a]*U.arcfn(i,e);return .5*o},map:function(e,n,r,o,a){const i=r-n,s=a-o,l=e-n,u=l/i;return o+s*u},lerp:function(e,n,r){const o={x:n.x+e*(r.x-n.x),y:n.y+e*(r.y-n.y)};return n.z!==void 0&&r.z!==void 0&&(o.z=n.z+e*(r.z-n.z)),o},pointToString:function(e){let n=e.x+"/"+e.y;return typeof e.z<"u"&&(n+="/"+e.z),n},pointsToString:function(e){return"["+e.map(U.pointToString).join(", ")+"]"},copy:function(e){return JSON.parse(JSON.stringify(e))},angle:function(e,n,r){const o=n.x-e.x,a=n.y-e.y,i=r.x-e.x,s=r.y-e.y,l=o*s-a*i,u=o*i+a*s;return ln(l,u)},round:function(e,n){const r=""+e,o=r.indexOf(".");return parseFloat(r.substring(0,o+1+n))},dist:function(e,n){const r=e.x-n.x,o=e.y-n.y;return wt(r*r+o*o)},closest:function(e,n){let r=Ue(2,63),o,a;return e.forEach(function(i,s){a=U.dist(n,i),a<r&&(r=a,o=s)}),{mdist:r,mpos:o}},abcratio:function(e,n){if(n!==2&&n!==3)return!1;if(typeof e>"u")e=.5;else if(e===0||e===1)return e;const r=Ue(e,n)+Ue(1-e,n),o=r-1;return sn(o/r)},projectionratio:function(e,n){if(n!==2&&n!==3)return!1;if(typeof e>"u")e=.5;else if(e===0||e===1)return e;const r=Ue(1-e,n),o=Ue(e,n)+r;return r/o},lli8:function(e,n,r,o,a,i,s,l){const u=(e*o-n*r)*(a-s)-(e-r)*(a*l-i*s),d=(e*o-n*r)*(i-l)-(n-o)*(a*l-i*s),h=(e-r)*(i-l)-(n-o)*(a-s);return h==0?!1:{x:u/h,y:d/h}},lli4:function(e,n,r,o){const a=e.x,i=e.y,s=n.x,l=n.y,u=r.x,d=r.y,h=o.x,m=o.y;return U.lli8(a,i,s,l,u,d,h,m)},lli:function(e,n){return U.lli4(e,e.c,n,n.c)},makeline:function(e,n){return new me(e.x,e.y,(e.x+n.x)/2,(e.y+n.y)/2,n.x,n.y)},findbbox:function(e){let n=dr,r=dr,o=ur,a=ur;return e.forEach(function(i){const s=i.bbox();n>s.x.min&&(n=s.x.min),r>s.y.min&&(r=s.y.min),o<s.x.max&&(o=s.x.max),a<s.y.max&&(a=s.y.max)}),{x:{min:n,mid:(n+o)/2,max:o,size:o-n},y:{min:r,mid:(r+a)/2,max:a,size:a-r}}},shapeintersections:function(e,n,r,o,a){if(!U.bboxoverlap(n,o))return[];const i=[],s=[e.startcap,e.forward,e.back,e.endcap],l=[r.startcap,r.forward,r.back,r.endcap];return s.forEach(function(u){u.virtual||l.forEach(function(d){if(d.virtual)return;const h=u.intersects(d,a);h.length>0&&(h.c1=u,h.c2=d,h.s1=e,h.s2=r,i.push(h))})}),i},makeshape:function(e,n,r){const o=n.points.length,a=e.points.length,i=U.makeline(n.points[o-1],e.points[0]),s=U.makeline(e.points[a-1],n.points[0]),l={startcap:i,forward:e,back:n,endcap:s,bbox:U.findbbox([i,e,n,s])};return l.intersections=function(u){return U.shapeintersections(l,l.bbox,u,u.bbox,r)},l},getminmax:function(e,n,r){if(!r)return{min:0,max:0};let o=dr,a=ur,i,s;r.indexOf(0)===-1&&(r=[0].concat(r)),r.indexOf(1)===-1&&r.push(1);for(let l=0,u=r.length;l<u;l++)i=r[l],s=e.get(i),s[n]<o&&(o=s[n]),s[n]>a&&(a=s[n]);return{min:o,mid:(o+a)/2,max:a,size:a-o}},align:function(e,n){const r=n.p1.x,o=n.p1.y,a=-ln(n.p2.y-o,n.p2.x-r),i=function(s){return{x:(s.x-r)*ut(a)-(s.y-o)*Yt(a),y:(s.x-r)*Yt(a)+(s.y-o)*ut(a)}};return e.map(i)},roots:function(e,n){n=n||{p1:{x:0,y:0},p2:{x:1,y:0}};const r=e.length-1,o=U.align(e,n),a=function(C){return 0<=C&&C<=1};if(r===2){const C=o[0].y,P=o[1].y,z=o[2].y,E=C-2*P+z;if(E!==0){const R=-wt(P*P-C*z),$=-C+P,H=-(R+$)/E,J=-(-R+$)/E;return[H,J].filter(a)}else if(P!==z&&E===0)return[(2*P-z)/(2*P-2*z)].filter(a);return[]}const i=o[0].y,s=o[1].y,l=o[2].y,u=o[3].y;let d=-i+3*s-3*l+u,h=3*i-6*s+3*l,m=-3*i+3*s,f=i;if(U.approximately(d,0)){if(U.approximately(h,0))return U.approximately(m,0)?[]:[-f/m].filter(a);const C=wt(m*m-4*h*f),P=2*h;return[(C-m)/P,(-m-C)/P].filter(a)}h/=d,m/=d,f/=d;const p=(3*m-h*h)/3,g=p/3,w=(2*h*h*h-9*h*m+27*f)/27,b=w/2,v=b*b+g*g*g;let I,D,N,_,T;if(v<0){const C=-p/3,P=C*C*C,z=wt(P),E=-w/(2*z),R=E<-1?-1:E>1?1:E,$=Qd(R),H=cn(z),J=2*H;return N=J*ut($/3)-h/3,_=J*ut(($+An)/3)-h/3,T=J*ut(($+2*An)/3)-h/3,[N,_,T].filter(a)}else{if(v===0)return I=b<0?cn(-b):-cn(b),N=2*I-h/3,_=-I-h/3,[N,_].filter(a);{const C=wt(v);return I=cn(-b+C),D=cn(b+C),[I-D-h/3].filter(a)}}},droots:function(e){if(e.length===3){const n=e[0],r=e[1],o=e[2],a=n-2*r+o;if(a!==0){const i=-wt(r*r-n*o),s=-n+r,l=-(i+s)/a,u=-(-i+s)/a;return[l,u]}else if(r!==o&&a===0)return[(2*r-o)/(2*(r-o))];return[]}if(e.length===2){const n=e[0],r=e[1];return n!==r?[n/(n-r)]:[]}return[]},curvature:function(e,n,r,o,a){let i,s,l,u,d=0,h=0;const m=U.compute(e,n),f=U.compute(e,r),p=m.x*m.x+m.y*m.y;if(o?(i=wt(Ue(m.y*f.z-f.y*m.z,2)+Ue(m.z*f.x-f.z*m.x,2)+Ue(m.x*f.y-f.x*m.y,2)),s=Ue(p+m.z*m.z,3/2)):(i=m.x*f.y-m.y*f.x,s=Ue(p,3/2)),i===0||s===0)return{k:0,r:0};if(d=i/s,h=s/i,!a){const g=U.curvature(e-.001,n,r,o,!0).k,w=U.curvature(e+.001,n,r,o,!0).k;u=(w-d+(d-g))/2,l=(sn(w-d)+sn(d-g))/2}return{k:d,r:h,dk:u,adk:l}},inflections:function(e){if(e.length<4)return[];const n=U.align(e,{p1:e[0],p2:e.slice(-1)[0]}),r=n[2].x*n[1].y,o=n[3].x*n[1].y,a=n[1].x*n[2].y,i=n[3].x*n[2].y,s=18*(-3*r+2*o+3*a-i),l=18*(3*r-o-3*a),u=18*(a-r);if(U.approximately(s,0)){if(!U.approximately(l,0)){let f=-u/l;if(0<=f&&f<=1)return[f]}return[]}const d=2*s;if(U.approximately(d,0))return[];const h=l*l-4*s*u;if(h<0)return[];const m=Math.sqrt(h);return[(m-l)/d,-(l+m)/d].filter(function(f){return 0<=f&&f<=1})},bboxoverlap:function(e,n){const r=["x","y"],o=r.length;for(let a=0,i,s,l,u;a<o;a++)if(i=r[a],s=e[i].mid,l=n[i].mid,u=(e[i].size+n[i].size)/2,sn(s-l)>=u)return!1;return!0},expandbox:function(e,n){n.x.min<e.x.min&&(e.x.min=n.x.min),n.y.min<e.y.min&&(e.y.min=n.y.min),n.z&&n.z.min<e.z.min&&(e.z.min=n.z.min),n.x.max>e.x.max&&(e.x.max=n.x.max),n.y.max>e.y.max&&(e.y.max=n.y.max),n.z&&n.z.max>e.z.max&&(e.z.max=n.z.max),e.x.mid=(e.x.min+e.x.max)/2,e.y.mid=(e.y.min+e.y.max)/2,e.z&&(e.z.mid=(e.z.min+e.z.max)/2),e.x.size=e.x.max-e.x.min,e.y.size=e.y.max-e.y.min,e.z&&(e.z.size=e.z.max-e.z.min)},pairiteration:function(e,n,r){const o=e.bbox(),a=n.bbox(),i=1e5,s=r||.5;if(o.x.size+o.y.size<s&&a.x.size+a.y.size<s)return[(i*(e._t1+e._t2)/2|0)/i+"/"+(i*(n._t1+n._t2)/2|0)/i];let l=e.split(.5),u=n.split(.5),d=[{left:l.left,right:u.left},{left:l.left,right:u.right},{left:l.right,right:u.right},{left:l.right,right:u.left}];d=d.filter(function(m){return U.bboxoverlap(m.left.bbox(),m.right.bbox())});let h=[];return d.length===0||(d.forEach(function(m){h=h.concat(U.pairiteration(m.left,m.right,s))}),h=h.filter(function(m,f){return h.indexOf(m)===f})),h},getccenter:function(e,n,r){const o=n.x-e.x,a=n.y-e.y,i=r.x-n.x,s=r.y-n.y,l=o*ut(_t)-a*Yt(_t),u=o*Yt(_t)+a*ut(_t),d=i*ut(_t)-s*Yt(_t),h=i*Yt(_t)+s*ut(_t),m=(e.x+n.x)/2,f=(e.y+n.y)/2,p=(n.x+r.x)/2,g=(n.y+r.y)/2,w=m+l,b=f+u,v=p+d,I=g+h,D=U.lli8(m,f,w,b,p,g,v,I),N=U.dist(D,e);let _=ln(e.y-D.y,e.x-D.x),T=ln(n.y-D.y,n.x-D.x),C=ln(r.y-D.y,r.x-D.x),P;return _<C?((_>T||T>C)&&(_+=An),_>C&&(P=C,C=_,_=P)):C<T&&T<_?(P=C,C=_,_=P):C+=An,D.s=_,D.e=C,D.r=N,D},numberSort:function(e,n){return e-n}};class gn{constructor(n){this.curves=[],this._3d=!1,n&&(this.curves=n,this._3d=this.curves[0]._3d)}valueOf(){return this.toString()}toString(){return"["+this.curves.map(function(n){return U.pointsToString(n.points)}).join(", ")+"]"}addCurve(n){this.curves.push(n),this._3d=this._3d||n._3d}length(){return this.curves.map(function(n){return n.length()}).reduce(function(n,r){return n+r})}curve(n){return this.curves[n]}bbox(){const n=this.curves;for(var r=n[0].bbox(),o=1;o<n.length;o++)U.expandbox(r,n[o].bbox());return r}offset(n){const r=[];return this.curves.forEach(function(o){r.push(...o.offset(n))}),new gn(r)}}const{abs:dn,min:fi,max:mi,cos:nu,sin:ru,acos:ou,sqrt:un}=Math,iu=Math.PI;class me{constructor(n){let r=n&&n.forEach?n:Array.from(arguments).slice(),o=!1;if(typeof r[0]=="object"){o=r.length;const p=[];r.forEach(function(g){["x","y","z"].forEach(function(w){typeof g[w]<"u"&&p.push(g[w])})}),r=p}let a=!1;const i=r.length;if(o){if(o>4){if(arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");a=!0}}else if(i!==6&&i!==8&&i!==9&&i!==12&&arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const s=this._3d=!a&&(i===9||i===12)||n&&n[0]&&typeof n[0].z<"u",l=this.points=[];for(let p=0,g=s?3:2;p<i;p+=g){var u={x:r[p],y:r[p+1]};s&&(u.z=r[p+2]),l.push(u)}const d=this.order=l.length-1,h=this.dims=["x","y"];s&&h.push("z"),this.dimlen=h.length;const m=U.align(l,{p1:l[0],p2:l[d]}),f=U.dist(l[0],l[d]);this._linear=m.reduce((p,g)=>p+dn(g.y),0)<f/50,this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(n,r,o,a){if(typeof a>"u"&&(a=.5),a===0)return new me(r,r,o);if(a===1)return new me(n,r,r);const i=me.getABC(2,n,r,o,a);return new me(n,i.A,o)}static cubicFromPoints(n,r,o,a,i){typeof a>"u"&&(a=.5);const s=me.getABC(3,n,r,o,a);typeof i>"u"&&(i=U.dist(r,s.C));const l=i*(1-a)/a,u=U.dist(n,o),d=(o.x-n.x)/u,h=(o.y-n.y)/u,m=i*d,f=i*h,p=l*d,g=l*h,w={x:r.x-m,y:r.y-f},b={x:r.x+p,y:r.y+g},v=s.A,I={x:v.x+(w.x-v.x)/(1-a),y:v.y+(w.y-v.y)/(1-a)},D={x:v.x+(b.x-v.x)/a,y:v.y+(b.y-v.y)/a},N={x:n.x+(I.x-n.x)/a,y:n.y+(I.y-n.y)/a},_={x:o.x+(D.x-o.x)/(1-a),y:o.y+(D.y-o.y)/(1-a)};return new me(n,N,_,o)}static getUtils(){return U}getUtils(){return me.getUtils()}static get PolyBezier(){return gn}valueOf(){return this.toString()}toString(){return U.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const n=this.points,r=n[0].x,o=n[0].y,a=["M",r,o,this.order===2?"Q":"C"];for(let i=1,s=n.length;i<s;i++)a.push(n[i].x),a.push(n[i].y);return a.join(" ")}setRatios(n){if(n.length!==this.points.length)throw new Error("incorrect number of ratio values");this.ratios=n,this._lut=[]}verify(){const n=this.coordDigest();n!==this._print&&(this._print=n,this.update())}coordDigest(){return this.points.map(function(n,r){return""+r+n.x+n.y+(n.z?n.z:0)}).join("")}update(){this._lut=[],this.dpoints=U.derive(this.points,this._3d),this.computedirection()}computedirection(){const n=this.points,r=U.angle(n[0],n[this.order],n[1]);this.clockwise=r>0}length(){return U.length(this.derivative.bind(this))}static getABC(n=2,r,o,a,i=.5){const s=U.projectionratio(i,n),l=1-s,u={x:s*r.x+l*a.x,y:s*r.y+l*a.y},d=U.abcratio(i,n);return{A:{x:o.x+(o.x-u.x)/d,y:o.y+(o.y-u.y)/d},B:o,C:u,S:r,E:a}}getABC(n,r){r=r||this.get(n);let o=this.points[0],a=this.points[this.order];return me.getABC(this.order,o,r,a,n)}getLUT(n){if(this.verify(),n=n||100,this._lut.length===n+1)return this._lut;this._lut=[],n++,this._lut=[];for(let r=0,o,a;r<n;r++)a=r/(n-1),o=this.compute(a),o.t=a,this._lut.push(o);return this._lut}on(n,r){r=r||5;const o=this.getLUT(),a=[];for(let i=0,s,l=0;i<o.length;i++)s=o[i],U.dist(s,n)<r&&(a.push(s),l+=i/o.length);return a.length?t/=a.length:!1}project(n){const r=this.getLUT(),o=r.length-1,a=U.closest(r,n),i=a.mpos,s=(i-1)/o,l=(i+1)/o,u=.1/o;let d=a.mdist,h=s,m=h,f;d+=1;for(let p;h<l+u;h+=u)f=this.compute(h),p=U.dist(n,f),p<d&&(d=p,m=h);return m=m<0?0:m>1?1:m,f=this.compute(m),f.t=m,f.d=d,f}get(n){return this.compute(n)}point(n){return this.points[n]}compute(n){return this.ratios?U.computeWithRatios(n,this.points,this.ratios,this._3d):U.compute(n,this.points,this._3d,this.ratios)}raise(){const n=this.points,r=[n[0]],o=n.length;for(let a=1,i,s;a<o;a++)i=n[a],s=n[a-1],r[a]={x:(o-a)/o*i.x+a/o*s.x,y:(o-a)/o*i.y+a/o*s.y};return r[o]=n[o-1],new me(r)}derivative(n){return U.compute(n,this.dpoints[0],this._3d)}dderivative(n){return U.compute(n,this.dpoints[1],this._3d)}align(){let n=this.points;return new me(U.align(n,{p1:n[0],p2:n[n.length-1]}))}curvature(n){return U.curvature(n,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return U.inflections(this.points)}normal(n){return this._3d?this.__normal3(n):this.__normal2(n)}__normal2(n){const r=this.derivative(n),o=un(r.x*r.x+r.y*r.y);return{t:n,x:-r.y/o,y:r.x/o}}__normal3(n){const r=this.derivative(n),o=this.derivative(n+.01),a=un(r.x*r.x+r.y*r.y+r.z*r.z),i=un(o.x*o.x+o.y*o.y+o.z*o.z);r.x/=a,r.y/=a,r.z/=a,o.x/=i,o.y/=i,o.z/=i;const s={x:o.y*r.z-o.z*r.y,y:o.z*r.x-o.x*r.z,z:o.x*r.y-o.y*r.x},l=un(s.x*s.x+s.y*s.y+s.z*s.z);s.x/=l,s.y/=l,s.z/=l;const u=[s.x*s.x,s.x*s.y-s.z,s.x*s.z+s.y,s.x*s.y+s.z,s.y*s.y,s.y*s.z-s.x,s.x*s.z-s.y,s.y*s.z+s.x,s.z*s.z];return{t:n,x:u[0]*r.x+u[1]*r.y+u[2]*r.z,y:u[3]*r.x+u[4]*r.y+u[5]*r.z,z:u[6]*r.x+u[7]*r.y+u[8]*r.z}}hull(n){let r=this.points,o=[],a=[],i=0;for(a[i++]=r[0],a[i++]=r[1],a[i++]=r[2],this.order===3&&(a[i++]=r[3]);r.length>1;){o=[];for(let s=0,l,u=r.length-1;s<u;s++)l=U.lerp(n,r[s],r[s+1]),a[i++]=l,o.push(l);r=o}return a}split(n,r){if(n===0&&r)return this.split(r).left;if(r===1)return this.split(n).right;const o=this.hull(n),a={left:this.order===2?new me([o[0],o[3],o[5]]):new me([o[0],o[4],o[7],o[9]]),right:this.order===2?new me([o[5],o[4],o[2]]):new me([o[9],o[8],o[6],o[3]]),span:o};return a.left._t1=U.map(0,0,1,this._t1,this._t2),a.left._t2=U.map(n,0,1,this._t1,this._t2),a.right._t1=U.map(n,0,1,this._t1,this._t2),a.right._t2=U.map(1,0,1,this._t1,this._t2),r?(r=U.map(r,n,1,0,1),a.right.split(r).left):a}extrema(){const n={};let r=[];return this.dims.forEach((function(o){let a=function(s){return s[o]},i=this.dpoints[0].map(a);n[o]=U.droots(i),this.order===3&&(i=this.dpoints[1].map(a),n[o]=n[o].concat(U.droots(i))),n[o]=n[o].filter(function(s){return s>=0&&s<=1}),r=r.concat(n[o].sort(U.numberSort))}).bind(this)),n.values=r.sort(U.numberSort).filter(function(o,a){return r.indexOf(o)===a}),n}bbox(){const n=this.extrema(),r={};return this.dims.forEach((function(o){r[o]=U.getminmax(this,o,n[o])}).bind(this)),r}overlaps(n){const r=this.bbox(),o=n.bbox();return U.bboxoverlap(r,o)}offset(n,r){if(typeof r<"u"){const o=this.get(n),a=this.normal(n),i={c:o,n:a,x:o.x+a.x*r,y:o.y+a.y*r};return this._3d&&(i.z=o.z+a.z*r),i}if(this._linear){const o=this.normal(0),a=this.points.map(function(i){const s={x:i.x+n*o.x,y:i.y+n*o.y};return i.z&&o.z&&(s.z=i.z+n*o.z),s});return[new me(a)]}return this.reduce().map(function(o){return o._linear?o.offset(n)[0]:o.scale(n)})}simple(){if(this.order===3){const a=U.angle(this.points[0],this.points[3],this.points[1]),i=U.angle(this.points[0],this.points[3],this.points[2]);if(a>0&&i<0||a<0&&i>0)return!1}const n=this.normal(0),r=this.normal(1);let o=n.x*r.x+n.y*r.y;return this._3d&&(o+=n.z*r.z),dn(ou(o))<iu/3}reduce(){let n,r=0,o=0,a=.01,i,s=[],l=[],u=this.extrema().values;for(u.indexOf(0)===-1&&(u=[0].concat(u)),u.indexOf(1)===-1&&u.push(1),r=u[0],n=1;n<u.length;n++)o=u[n],i=this.split(r,o),i._t1=r,i._t2=o,s.push(i),r=o;return s.forEach(function(d){for(r=0,o=0;o<=1;)for(o=r+a;o<=1+a;o+=a)if(i=d.split(r,o),!i.simple()){if(o-=a,dn(r-o)<a)return[];i=d.split(r,o),i._t1=U.map(r,0,1,d._t1,d._t2),i._t2=U.map(o,0,1,d._t1,d._t2),l.push(i),r=o;break}r<1&&(i=d.split(r,1),i._t1=U.map(r,0,1,d._t1,d._t2),i._t2=d._t2,l.push(i))}),l}translate(n,r,o){o=typeof o=="number"?o:r;const a=this.order;let i=this.points.map((s,l)=>(1-l/a)*r+l/a*o);return new me(this.points.map((s,l)=>({x:s.x+n.x*i[l],y:s.y+n.y*i[l]})))}scale(n){const r=this.order;let o=!1;if(typeof n=="function"&&(o=n),o&&r===2)return this.raise().scale(o);const a=this.clockwise,i=this.points;if(this._linear)return this.translate(this.normal(0),o?o(0):n,o?o(1):n);const s=o?o(0):n,l=o?o(1):n,u=[this.offset(0,10),this.offset(1,10)],d=[],h=U.lli4(u[0],u[0].c,u[1],u[1].c);if(!h)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(m){const f=d[m*r]=U.copy(i[m*r]);f.x+=(m?l:s)*u[m].n.x,f.y+=(m?l:s)*u[m].n.y}),o?([0,1].forEach(function(m){if(!(r===2&&m)){var f=i[m+1],p={x:f.x-h.x,y:f.y-h.y},g=o?o((m+1)/r):n;o&&!a&&(g=-g);var w=un(p.x*p.x+p.y*p.y);p.x/=w,p.y/=w,d[m+1]={x:f.x+g*p.x,y:f.y+g*p.y}}}),new me(d)):([0,1].forEach(m=>{if(r===2&&m)return;const f=d[m*r],p=this.derivative(m),g={x:f.x+p.x,y:f.y+p.y};d[m+1]=U.lli4(f,g,h,i[m+1])}),new me(d))}outline(n,r,o,a){if(r=r===void 0?n:r,this._linear){const _=this.normal(0),T=this.points[0],C=this.points[this.points.length-1];let P,z,E;o===void 0&&(o=n,a=r),P={x:T.x+_.x*n,y:T.y+_.y*n},E={x:C.x+_.x*o,y:C.y+_.y*o},z={x:(P.x+E.x)/2,y:(P.y+E.y)/2};const R=[P,z,E];P={x:T.x-_.x*r,y:T.y-_.y*r},E={x:C.x-_.x*a,y:C.y-_.y*a},z={x:(P.x+E.x)/2,y:(P.y+E.y)/2};const $=[E,z,P],H=U.makeline($[2],R[0]),J=U.makeline(R[2],$[0]),ne=[H,new me(R),J,new me($)];return new gn(ne)}const i=this.reduce(),s=i.length,l=[];let u=[],d,h=0,m=this.length();const f=typeof o<"u"&&typeof a<"u";function p(_,T,C,P,z){return function(E){const R=P/C,$=(P+z)/C,H=T-_;return U.map(E,0,1,_+R*H,_+$*H)}}i.forEach(function(_){const T=_.length();f?(l.push(_.scale(p(n,o,m,h,T))),u.push(_.scale(p(-r,-a,m,h,T)))):(l.push(_.scale(n)),u.push(_.scale(-r))),h+=T}),u=u.map(function(_){return d=_.points,d[3]?_.points=[d[3],d[2],d[1],d[0]]:_.points=[d[2],d[1],d[0]],_}).reverse();const g=l[0].points[0],w=l[s-1].points[l[s-1].points.length-1],b=u[s-1].points[u[s-1].points.length-1],v=u[0].points[0],I=U.makeline(b,g),D=U.makeline(w,v),N=[I].concat(l).concat([D]).concat(u);return new gn(N)}outlineshapes(n,r,o){r=r||n;const a=this.outline(n,r).curves,i=[];for(let s=1,l=a.length;s<l/2;s++){const u=U.makeshape(a[s],a[l-s],o);u.startcap.virtual=s>1,u.endcap.virtual=s<l/2-1,i.push(u)}return i}intersects(n,r){return n?n.p1&&n.p2?this.lineIntersects(n):(n instanceof me&&(n=n.reduce()),this.curveintersects(this.reduce(),n,r)):this.selfintersects(r)}lineIntersects(n){const r=fi(n.p1.x,n.p2.x),o=fi(n.p1.y,n.p2.y),a=mi(n.p1.x,n.p2.x),i=mi(n.p1.y,n.p2.y);return U.roots(this.points,n).filter(s=>{var l=this.get(s);return U.between(l.x,r,a)&&U.between(l.y,o,i)})}selfintersects(n){const r=this.reduce(),o=r.length-2,a=[];for(let i=0,s,l,u;i<o;i++)l=r.slice(i,i+1),u=r.slice(i+2),s=this.curveintersects(l,u,n),a.push(...s);return a}curveintersects(n,r,o){const a=[];n.forEach(function(s){r.forEach(function(l){s.overlaps(l)&&a.push({left:s,right:l})})});let i=[];return a.forEach(function(s){const l=U.pairiteration(s.left,s.right,o);l.length>0&&(i=i.concat(l))}),i}arcs(n){return n=n||.5,this._iterate(n,[])}_error(n,r,o,a){const i=(a-o)/4,s=this.get(o+i),l=this.get(a-i),u=U.dist(n,r),d=U.dist(n,s),h=U.dist(n,l);return dn(d-u)+dn(h-u)}_iterate(n,r){let o=0,a=1,i;do{i=0,a=1;let s=this.get(o),l,u,d,h,m=!1,f=!1,p,g=a,w=1;do if(f=m,h=d,g=(o+a)/2,l=this.get(g),u=this.get(a),d=U.getccenter(s,l,u),d.interval={start:o,end:a},m=this._error(d,s,o,a)<=n,p=f&&!m,p||(w=a),m){if(a>=1){if(d.interval.end=w=1,h=d,a>1){let v={x:d.x+d.r*nu(d.e),y:d.y+d.r*ru(d.e)};d.e+=U.angle({x:d.x,y:d.y},v,this.get(1))}break}a=a+(a-o)/2}else a=g;while(!p&&i++<100);if(i>=100)break;h=h||d,r.push(h),o=w}while(a<1);return r}}function zr(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,o=Array(n);r<n;r++)o[r]=e[r];return o}function au(e){if(Array.isArray(e))return e}function su(e){if(Array.isArray(e))return zr(e)}function lu(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function cu(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,a,i,s,l=[],u=!0,d=!1;try{if(i=(r=r.call(e)).next,n!==0)for(;!(u=(o=i.call(r)).done)&&(l.push(o.value),l.length!==n);u=!0);}catch(h){d=!0,a=h}finally{try{if(!u&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(d)throw a}}return l}}function du(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
267
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function uu(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
268
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fu(e,n){if(e==null)return{};var r,o,a=mu(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)r=i[o],n.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function mu(e,n){if(e==null)return{};var r={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(n.includes(o))continue;r[o]=e[o]}return r}function hu(e,n){return au(e)||cu(e,n)||ca(e,n)||du()}function pu(e){return su(e)||lu(e)||ca(e)||uu()}function gu(e,n){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,n);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function yu(e){var n=gu(e,"string");return typeof n=="symbol"?n:n+""}function ca(e,n){if(e){if(typeof e=="string")return zr(e,n);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?zr(e,n):void 0}}var vu=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,a=(n instanceof Array?n.length?n:[void 0]:[n]).map(function(l){return{keyAccessor:l,isProp:!(l instanceof Function)}}),i=e.reduce(function(l,u){var d=l,h=u;return a.forEach(function(m,f){var p=m.keyAccessor,g=m.isProp,w;if(g){var b=h,v=b[p],I=fu(b,[p].map(yu));w=v,h=I}else w=p(h,f);f+1<a.length?(d.hasOwnProperty(w)||(d[w]={}),d=d[w]):r?(d.hasOwnProperty(w)||(d[w]=[]),d[w].push(h)):d[w]=h}),l},{});r instanceof Function&&function l(u){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;d===a.length?Object.keys(u).forEach(function(h){return u[h]=r(u[h])}):Object.values(u).forEach(function(h){return l(h,d+1)})}(i);var s=i;return o&&(s=[],function l(u){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];d.length===a.length?s.push({keys:d,vals:u}):Object.entries(u).forEach(function(h){var m=hu(h,2),f=m[0],p=m[1];return l(p,[].concat(pu(d),[f]))})}(i),n instanceof Array&&n.length===0&&s.length===1&&(s[0].keys=[])),s};function bu(e,n){n===void 0&&(n={});var r=n.insertAt;if(!(typeof document>"u")){var o=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",r==="top"&&o.firstChild?o.insertBefore(a,o.firstChild):o.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}var xu=`.force-graph-container canvas {
269
+ display: block;
270
+ user-select: none;
271
+ outline: none;
272
+ -webkit-tap-highlight-color: transparent;
273
+ }
274
+
275
+ .force-graph-container .clickable {
276
+ cursor: pointer;
277
+ }
278
+
279
+ .force-graph-container .grabbable {
280
+ cursor: move;
281
+ cursor: grab;
282
+ cursor: -moz-grab;
283
+ cursor: -webkit-grab;
284
+ }
285
+
286
+ .force-graph-container .grabbable:active {
287
+ cursor: grabbing;
288
+ cursor: -moz-grabbing;
289
+ cursor: -webkit-grabbing;
290
+ }
291
+ `;bu(xu);function $r(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,o=Array(n);r<n;r++)o[r]=e[r];return o}function wu(e){if(Array.isArray(e))return e}function _u(e){if(Array.isArray(e))return $r(e)}function hi(e,n,r){if(da())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,n);var a=new(e.bind.apply(e,o));return a}function vn(e,n,r){return(n=Nu(n))in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function da(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(da=function(){return!!e})()}function ku(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Iu(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,a,i,s,l=[],u=!0,d=!1;try{if(i=(r=r.call(e)).next,n!==0)for(;!(u=(o=i.call(r)).done)&&(l.push(o.value),l.length!==n);u=!0);}catch(h){d=!0,a=h}finally{try{if(!u&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(d)throw a}}return l}}function Su(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
292
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Cu(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
293
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pi(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,o)}return r}function Jt(e){for(var n=1;n<arguments.length;n++){var r=arguments[n]!=null?arguments[n]:{};n%2?pi(Object(r),!0).forEach(function(o){vn(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pi(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function yn(e,n){return wu(e)||Iu(e,n)||ua(e,n)||Su()}function Be(e){return _u(e)||ku(e)||ua(e)||Cu()}function Du(e,n){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,n);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function Nu(e){var n=Du(e,"string");return typeof n=="symbol"?n:n+""}function Ur(e){"@babel/helpers - typeof";return Ur=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Ur(e)}function ua(e,n){if(e){if(typeof e=="string")return $r(e,n);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?$r(e,n):void 0}}var Pu=ts(ns);function gi(e,n,r){!n||typeof r!="string"||e.filter(function(o){return!o[r]}).forEach(function(o){o[r]=Pu(n(o))})}function Tu(e,n){var r=e.nodes,o=e.links,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=a.nodeFilter,s=i===void 0?function(){return!0}:i,l=a.onLoopError,u=l===void 0?function(p){throw"Invalid DAG structure! Found cycle in node path: ".concat(p.join(" -> "),".")}:l,d={};r.forEach(function(p){return d[n(p)]={data:p,out:[],depth:-1,skip:!s(p)}}),o.forEach(function(p){var g=p.source,w=p.target,b=N(g),v=N(w);if(!d.hasOwnProperty(b))throw"Missing source node with id: ".concat(b);if(!d.hasOwnProperty(v))throw"Missing target node with id: ".concat(v);var I=d[b],D=d[v];I.out.push(D);function N(_){return Ur(_)==="object"?n(_):_}});var h=[];f(Object.values(d));var m=Object.assign.apply(Object,[{}].concat(Be(Object.entries(d).filter(function(p){var g=yn(p,2),w=g[1];return!w.skip}).map(function(p){var g=yn(p,2),w=g[0],b=g[1];return vn({},w,b.depth)}))));return m;function f(p){for(var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,b=function(){var N=p[v];if(g.indexOf(N)!==-1){var _=[].concat(Be(g.slice(g.indexOf(N))),[N]).map(function(T){return n(T.data)});return h.some(function(T){return T.length===_.length&&T.every(function(C,P){return C===_[P]})})||(h.push(_),u(_)),1}w>N.depth&&(N.depth=w,f(N.out,[].concat(Be(g),[N]),w+(N.skip?0:1)))},v=0,I=p.length;v<I;v++)b()}}var Au=2,Te=function(n,r){return r.onNeedsRedraw&&r.onNeedsRedraw()},yi=function(n,r){if(!r.isShadow){var o=ae(r.linkDirectionalParticles);r.graphData.links.forEach(function(a){var i=Math.round(Math.abs(o(a)));i?a.__photons=Be(Array(i)).map(function(){return{}}):delete a.__photons})}},Vn=qr({props:{graphData:{default:{nodes:[],links:[]},onChange:function(n,r){r.engineRunning=!1,yi(n,r)}},dagMode:{onChange:function(n,r){!n&&(r.graphData.nodes||[]).forEach(function(o){return o.fx=o.fy=void 0})}},dagLevelDistance:{},dagNodeFilter:{default:function(n){return!0}},onDagError:{triggerUpdate:!1},nodeRelSize:{default:4,triggerUpdate:!1,onChange:Te},nodeId:{default:"id"},nodeVal:{default:"val",triggerUpdate:!1,onChange:Te},nodeColor:{default:"color",triggerUpdate:!1,onChange:Te},nodeAutoColorBy:{},nodeCanvasObject:{triggerUpdate:!1,onChange:Te},nodeCanvasObjectMode:{default:function(){return"replace"},triggerUpdate:!1,onChange:Te},nodeVisibility:{default:!0,triggerUpdate:!1,onChange:Te},linkSource:{default:"source"},linkTarget:{default:"target"},linkVisibility:{default:!0,triggerUpdate:!1,onChange:Te},linkColor:{default:"color",triggerUpdate:!1,onChange:Te},linkAutoColorBy:{},linkLineDash:{triggerUpdate:!1,onChange:Te},linkWidth:{default:1,triggerUpdate:!1,onChange:Te},linkCurvature:{default:0,triggerUpdate:!1,onChange:Te},linkCanvasObject:{triggerUpdate:!1,onChange:Te},linkCanvasObjectMode:{default:function(){return"replace"},triggerUpdate:!1,onChange:Te},linkDirectionalArrowLength:{default:0,triggerUpdate:!1,onChange:Te},linkDirectionalArrowColor:{triggerUpdate:!1,onChange:Te},linkDirectionalArrowRelPos:{default:.5,triggerUpdate:!1,onChange:Te},linkDirectionalParticles:{default:0,triggerUpdate:!1,onChange:yi},linkDirectionalParticleSpeed:{default:.01,triggerUpdate:!1},linkDirectionalParticleOffset:{default:0,triggerUpdate:!1},linkDirectionalParticleWidth:{default:4,triggerUpdate:!1},linkDirectionalParticleColor:{triggerUpdate:!1},linkDirectionalParticleCanvasObject:{triggerUpdate:!1},globalScale:{default:1,triggerUpdate:!1},d3AlphaMin:{default:0,triggerUpdate:!1},d3AlphaDecay:{default:.0228,triggerUpdate:!1,onChange:function(n,r){r.forceLayout.alphaDecay(n)}},d3AlphaTarget:{default:0,triggerUpdate:!1,onChange:function(n,r){r.forceLayout.alphaTarget(n)}},d3VelocityDecay:{default:.4,triggerUpdate:!1,onChange:function(n,r){r.forceLayout.velocityDecay(n)}},warmupTicks:{default:0,triggerUpdate:!1},cooldownTicks:{default:1/0,triggerUpdate:!1},cooldownTime:{default:15e3,triggerUpdate:!1},onUpdate:{default:function(){},triggerUpdate:!1},onFinishUpdate:{default:function(){},triggerUpdate:!1},onEngineTick:{default:function(){},triggerUpdate:!1},onEngineStop:{default:function(){},triggerUpdate:!1},onNeedsRedraw:{triggerUpdate:!1},isShadow:{default:!1,triggerUpdate:!1}},methods:{d3Force:function(n,r,o){return o===void 0?n.forceLayout.force(r):(n.forceLayout.force(r,o),this)},d3ReheatSimulation:function(n){return n.forceLayout.alpha(1),this.resetCountdown(),this},resetCountdown:function(n){return n.cntTicks=0,n.startTickTime=new Date,n.engineRunning=!0,this},isEngineRunning:function(n){return!!n.engineRunning},tickFrame:function(n){return!n.isShadow&&r(),a(),!n.isShadow&&i(),!n.isShadow&&s(),o(),this;function r(){n.engineRunning&&(++n.cntTicks>n.cooldownTicks||new Date-n.startTickTime>n.cooldownTime||n.d3AlphaMin>0&&n.forceLayout.alpha()<n.d3AlphaMin?(n.engineRunning=!1,n.onEngineStop()):(n.forceLayout.tick(),n.onEngineTick()))}function o(){var l=ae(n.nodeVisibility),u=ae(n.nodeVal),d=ae(n.nodeColor),h=ae(n.nodeCanvasObjectMode),m=n.ctx,f=n.isShadow/n.globalScale,p=n.graphData.nodes.filter(l);m.save(),p.forEach(function(g){var w=h(g);if(n.nodeCanvasObject&&(w==="before"||w==="replace")&&(n.nodeCanvasObject(g,m,n.globalScale),w==="replace")){m.restore();return}var b=Math.sqrt(Math.max(0,u(g)||1))*n.nodeRelSize+f;m.beginPath(),m.arc(g.x,g.y,b,0,2*Math.PI,!1),m.fillStyle=d(g)||"rgba(31, 120, 180, 0.92)",m.fill(),n.nodeCanvasObject&&w==="after"&&n.nodeCanvasObject(g,n.ctx,n.globalScale)}),m.restore()}function a(){var l=ae(n.linkVisibility),u=ae(n.linkColor),d=ae(n.linkWidth),h=ae(n.linkLineDash),m=ae(n.linkCurvature),f=ae(n.linkCanvasObjectMode),p=n.ctx,g=n.isShadow*2,w=n.graphData.links.filter(l);w.forEach(T);var b=[],v=[],I=w;if(n.linkCanvasObject){var D=[],N=[];w.forEach(function(C){return({before:b,after:v,replace:D}[f(C)]||N).push(C)}),I=[].concat(Be(b),v,N),b=b.concat(D)}p.save(),b.forEach(function(C){return n.linkCanvasObject(C,p,n.globalScale)}),p.restore();var _=vu(I,[u,d,h]);p.save(),Object.entries(_).forEach(function(C){var P=yn(C,2),z=P[0],E=P[1],R=!z||z==="undefined"?"rgba(0,0,0,0.15)":z;Object.entries(E).forEach(function($){var H=yn($,2),J=H[0],ne=H[1],B=(J||1)/n.globalScale+g;Object.entries(ne).forEach(function(G){var se=yn(G,2);se[0];var ue=se[1],j=h(ue[0]);p.beginPath(),ue.forEach(function(re){var oe=re.source,ie=re.target;if(!(!oe||!ie||!oe.hasOwnProperty("x")||!ie.hasOwnProperty("x"))){p.moveTo(oe.x,oe.y);var K=re.__controlPoints;K?p[K.length===2?"quadraticCurveTo":"bezierCurveTo"].apply(p,Be(K).concat([ie.x,ie.y])):p.lineTo(ie.x,ie.y)}}),p.strokeStyle=R,p.lineWidth=B,p.setLineDash(j||[]),p.stroke()})})}),p.restore(),p.save(),v.forEach(function(C){return n.linkCanvasObject(C,p,n.globalScale)}),p.restore();function T(C){var P=m(C);if(!P){C.__controlPoints=null;return}var z=C.source,E=C.target;if(!(!z||!E||!z.hasOwnProperty("x")||!E.hasOwnProperty("x"))){var R=Math.sqrt(Math.pow(E.x-z.x,2)+Math.pow(E.y-z.y,2));if(R>0){var $=Math.atan2(E.y-z.y,E.x-z.x),H=R*P,J={x:(z.x+E.x)/2+H*Math.cos($-Math.PI/2),y:(z.y+E.y)/2+H*Math.sin($-Math.PI/2)};C.__controlPoints=[J.x,J.y]}else{var ne=P*70;C.__controlPoints=[E.x,E.y-ne,E.x+ne,E.y]}}}}function i(){var l=1.6,u=.2,d=ae(n.linkDirectionalArrowLength),h=ae(n.linkDirectionalArrowRelPos),m=ae(n.linkVisibility),f=ae(n.linkDirectionalArrowColor||n.linkColor),p=ae(n.nodeVal),g=n.ctx;g.save(),n.graphData.links.filter(m).forEach(function(w){var b=d(w);if(!(!b||b<0)){var v=w.source,I=w.target;if(!(!v||!I||!v.hasOwnProperty("x")||!I.hasOwnProperty("x"))){var D=Math.sqrt(Math.max(0,p(v)||1))*n.nodeRelSize,N=Math.sqrt(Math.max(0,p(I)||1))*n.nodeRelSize,_=Math.min(1,Math.max(0,h(w))),T=f(w)||"rgba(0,0,0,0.28)",C=b/l/2,P=w.__controlPoints&&hi(me,[v.x,v.y].concat(Be(w.__controlPoints),[I.x,I.y])),z=P?function(B){return P.get(B)}:function(B){return{x:v.x+(I.x-v.x)*B||0,y:v.y+(I.y-v.y)*B||0}},E=P?P.length():Math.sqrt(Math.pow(I.x-v.x,2)+Math.pow(I.y-v.y,2)),R=D+b+(E-D-N-b)*_,$=z(R/E),H=z((R-b)/E),J=z((R-b*(1-u))/E),ne=Math.atan2($.y-H.y,$.x-H.x)-Math.PI/2;g.beginPath(),g.moveTo($.x,$.y),g.lineTo(H.x+C*Math.cos(ne),H.y+C*Math.sin(ne)),g.lineTo(J.x,J.y),g.lineTo(H.x-C*Math.cos(ne),H.y-C*Math.sin(ne)),g.fillStyle=T,g.fill()}}}),g.restore()}function s(){var l=ae(n.linkDirectionalParticles),u=ae(n.linkDirectionalParticleSpeed),d=ae(n.linkDirectionalParticleOffset),h=ae(n.linkDirectionalParticleWidth),m=ae(n.linkVisibility),f=ae(n.linkDirectionalParticleColor||n.linkColor),p=n.ctx;p.save(),n.graphData.links.filter(m).forEach(function(g){var w=l(g);if(!(!g.hasOwnProperty("__photons")||!g.__photons.length)){var b=g.source,v=g.target;if(!(!b||!v||!b.hasOwnProperty("x")||!v.hasOwnProperty("x"))){var I=u(g),D=Math.abs(d(g)),N=g.__photons||[],_=Math.max(0,h(g)/2)/Math.sqrt(n.globalScale),T=f(g)||"rgba(0,0,0,0.28)";p.fillStyle=T;var C=g.__controlPoints?hi(me,[b.x,b.y].concat(Be(g.__controlPoints),[v.x,v.y])):null,P=0,z=!1;N.forEach(function(E){var R=!!E.__singleHop;if(E.hasOwnProperty("__progressRatio")||(E.__progressRatio=R?I<0?1:0:(P+D)/w),!R&&P++,E.__progressRatio+=I,E.__progressRatio>=1||E.__progressRatio<0)if(!R)E.__progressRatio=E.__progressRatio%1,E.__progressRatio<0&&E.__progressRatio++;else{z=!0;return}var $=E.__progressRatio,H=C?C.get($):{x:b.x+(v.x-b.x)*$||0,y:b.y+(v.y-b.y)*$||0};n.linkDirectionalParticleCanvasObject?n.linkDirectionalParticleCanvasObject(H.x,H.y,g,p,n.globalScale):(p.beginPath(),p.arc(H.x,H.y,_,0,2*Math.PI,!1),p.fill())}),z&&(g.__photons=g.__photons.filter(function(E){return!E.__singleHop||E.__progressRatio<=1&&E.__progressRatio>=0}))}}}),p.restore()}},emitParticle:function(n,r){return r&&(!r.__photons&&(r.__photons=[]),r.__photons.push({__singleHop:!0})),this}},stateInit:function(){return{forceLayout:Jd().force("link",Bd()).force("charge",Xd()).force("center",ad()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(n,r){r.ctx=n},update:function(n,r){n.engineRunning=!1,n.onUpdate(),n.nodeAutoColorBy!==null&&gi(n.graphData.nodes,ae(n.nodeAutoColorBy),n.nodeColor),n.linkAutoColorBy!==null&&gi(n.graphData.links,ae(n.linkAutoColorBy),n.linkColor),n.graphData.links.forEach(function(f){f.source=f[n.linkSource],f.target=f[n.linkTarget]}),n.forceLayout.stop().alpha(1).nodes(n.graphData.nodes);var o=n.forceLayout.force("link");o&&o.id(function(f){return f[n.nodeId]}).links(n.graphData.links);var a=n.dagMode&&Tu(n.graphData,function(f){return f[n.nodeId]},{nodeFilter:n.dagNodeFilter,onLoopError:n.onDagError||void 0}),i=Math.max.apply(Math,Be(Object.values(a||[]))),s=n.dagLevelDistance||n.graphData.nodes.length/(i||1)*Au*(["radialin","radialout"].indexOf(n.dagMode)!==-1?.7:1);if(["lr","rl","td","bu"].includes(r.dagMode)){var l=["lr","rl"].includes(r.dagMode)?"fx":"fy";n.graphData.nodes.filter(n.dagNodeFilter).forEach(function(f){return delete f[l]})}if(["lr","rl","td","bu"].includes(n.dagMode)){var u=["rl","bu"].includes(n.dagMode),d=function(p){return(a[p[n.nodeId]]-i/2)*s*(u?-1:1)},h=["lr","rl"].includes(n.dagMode)?"fx":"fy";n.graphData.nodes.filter(n.dagNodeFilter).forEach(function(f){return f[h]=d(f)})}n.forceLayout.force("dagRadial",["radialin","radialout"].indexOf(n.dagMode)!==-1?Zd(function(f){var p=a[f[n.nodeId]]||-1;return(n.dagMode==="radialin"?i-p:p)*s}).strength(function(f){return n.dagNodeFilter(f)?1:0}):null);for(var m=0;m<n.warmupTicks&&!(n.d3AlphaMin>0&&n.forceLayout.alpha()<n.d3AlphaMin);m++)n.forceLayout.tick();this.resetCountdown(),n.onFinishUpdate()}});function fa(e,n){var r=e instanceof Array?e:[e],o=new n;return o._destructor&&o._destructor(),{linkProp:function(i){return{default:o[i](),onChange:function(l,u){r.forEach(function(d){return u[d][i](l)})},triggerUpdate:!1}},linkMethod:function(i){return function(s){for(var l=arguments.length,u=new Array(l>1?l-1:0),d=1;d<l;d++)u[d-1]=arguments[d];var h=[];return r.forEach(function(m){var f=s[m],p=f[i].apply(f,u);p!==f&&h.push(p)}),h.length?h[0]:this}}}}var ju=800,Mu=4,Eu=5,ma=fa("forceGraph",Vn),Ou=fa(["forceGraph","shadowGraph"],Vn),Ru=Object.assign.apply(Object,Be(["nodeColor","nodeAutoColorBy","nodeCanvasObject","nodeCanvasObjectMode","linkColor","linkAutoColorBy","linkLineDash","linkWidth","linkCanvasObject","linkCanvasObjectMode","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowRelPos","linkDirectionalParticles","linkDirectionalParticleSpeed","linkDirectionalParticleOffset","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleCanvasObject","dagMode","dagLevelDistance","dagNodeFilter","onDagError","d3AlphaMin","d3AlphaDecay","d3VelocityDecay","warmupTicks","cooldownTicks","cooldownTime","onEngineTick","onEngineStop"].map(function(e){return vn({},e,ma.linkProp(e))})).concat(Be(["nodeRelSize","nodeId","nodeVal","nodeVisibility","linkSource","linkTarget","linkVisibility","linkCurvature"].map(function(e){return vn({},e,Ou.linkProp(e))})))),Fu=Object.assign.apply(Object,Be(["d3Force","d3ReheatSimulation","emitParticle"].map(function(e){return vn({},e,ma.linkMethod(e))})));function fr(e){if(e.canvas){var n=e.canvas.width,r=e.canvas.height;n===300&&r===150&&(n=r=0);var o=window.devicePixelRatio;n/=o,r/=o,[e.canvas,e.shadowCanvas].forEach(function(i){i.style.width="".concat(e.width,"px"),i.style.height="".concat(e.height,"px"),i.width=e.width*o,i.height=e.height*o,!n&&!r&&i.getContext("2d").scale(o,o)});var a=ft(e.canvas).k;e.zoom.translateBy(e.zoom.__baseElem,(e.width-n)/2/a,(e.height-r)/2/a),e.needsRedraw=!0}}function ha(e){var n=window.devicePixelRatio;e.setTransform(n,0,0,n,0,0)}function vi(e,n,r){e.save(),ha(e),e.clearRect(0,0,n,r),e.restore()}var Lu=qr({props:Jt({width:{default:window.innerWidth,onChange:function(n,r){return fr(r)},triggerUpdate:!1},height:{default:window.innerHeight,onChange:function(n,r){return fr(r)},triggerUpdate:!1},graphData:{default:{nodes:[],links:[]},onChange:function(n,r){[n.nodes,n.links].every(function(a){return(a||[]).every(function(i){return!i.hasOwnProperty("__indexColor")})})&&r.colorTracker.reset(),[{type:"Node",objs:n.nodes},{type:"Link",objs:n.links}].forEach(o),r.forceGraph.graphData(n),r.shadowGraph.graphData(n);function o(a){var i=a.type,s=a.objs;s.filter(function(l){if(!l.hasOwnProperty("__indexColor"))return!0;var u=r.colorTracker.lookup(l.__indexColor);return!u||!u.hasOwnProperty("d")||u.d!==l}).forEach(function(l){l.__indexColor=r.colorTracker.register({type:i,d:l})})}},triggerUpdate:!1},backgroundColor:{onChange:function(n,r){r.canvas&&n&&(r.canvas.style.background=n)},triggerUpdate:!1},nodeLabel:{default:"name",triggerUpdate:!1},nodePointerAreaPaint:{onChange:function(n,r){r.shadowGraph.nodeCanvasObject(n?function(o,a,i){return n(o,o.__indexColor,a,i)}:null),r.flushShadowCanvas&&r.flushShadowCanvas()},triggerUpdate:!1},linkPointerAreaPaint:{onChange:function(n,r){r.shadowGraph.linkCanvasObject(n?function(o,a,i){return n(o,o.__indexColor,a,i)}:null),r.flushShadowCanvas&&r.flushShadowCanvas()},triggerUpdate:!1},linkLabel:{default:"name",triggerUpdate:!1},linkHoverPrecision:{default:4,triggerUpdate:!1},minZoom:{default:.01,onChange:function(n,r){r.zoom.scaleExtent([n,r.zoom.scaleExtent()[1]])},triggerUpdate:!1},maxZoom:{default:1e3,onChange:function(n,r){r.zoom.scaleExtent([r.zoom.scaleExtent()[0],n])},triggerUpdate:!1},enableNodeDrag:{default:!0,triggerUpdate:!1},enableZoomInteraction:{default:!0,triggerUpdate:!1},enablePanInteraction:{default:!0,triggerUpdate:!1},enableZoomPanInteraction:{default:!0,triggerUpdate:!1},enablePointerInteraction:{default:!0,onChange:function(n,r){r.hoverObj=null},triggerUpdate:!1},autoPauseRedraw:{default:!0,triggerUpdate:!1},onNodeDrag:{default:function(){},triggerUpdate:!1},onNodeDragEnd:{default:function(){},triggerUpdate:!1},onNodeClick:{triggerUpdate:!1},onNodeRightClick:{triggerUpdate:!1},onNodeHover:{triggerUpdate:!1},onLinkClick:{triggerUpdate:!1},onLinkRightClick:{triggerUpdate:!1},onLinkHover:{triggerUpdate:!1},onBackgroundClick:{triggerUpdate:!1},onBackgroundRightClick:{triggerUpdate:!1},showPointerCursor:{default:!0,triggerUpdate:!1},onZoom:{triggerUpdate:!1},onZoomEnd:{triggerUpdate:!1},onRenderFramePre:{triggerUpdate:!1},onRenderFramePost:{triggerUpdate:!1}},Ru),aliases:{stopAnimation:"pauseAnimation"},methods:Jt({graph2ScreenCoords:function(n,r,o){var a=ft(n.canvas);return{x:r*a.k+a.x,y:o*a.k+a.y}},screen2GraphCoords:function(n,r,o){var a=ft(n.canvas);return{x:(r-a.x)/a.k,y:(o-a.y)/a.k}},centerAt:function(n,r,o,a){if(!n.canvas)return null;if(r!==void 0||o!==void 0){var i=Object.assign({},r!==void 0?{x:r}:{},o!==void 0?{y:o}:{});return a?n.tweenGroup.add(new Ho(s()).to(i,a).easing(Rt.Quadratic.Out).onUpdate(l).onComplete(function(){n.tweenGroup.remove(this)}).start()):l(i),this}return s();function s(){var u=ft(n.canvas);return{x:(n.width/2-u.x)/u.k,y:(n.height/2-u.y)/u.k}}function l(u){var d=u.x,h=u.y;n.zoom.translateTo(n.zoom.__baseElem,d===void 0?s().x:d,h===void 0?s().y:h),n.needsRedraw=!0}},zoom:function(n,r,o){if(!n.canvas)return null;if(r!==void 0)return o?n.tweenGroup.add(new Ho({k:a()}).to({k:r},o).easing(Rt.Quadratic.Out).onUpdate(function(s){var l=s.k;return i(l)}).onComplete(function(){n.tweenGroup.remove(this)}).start()):i(r),this;return a();function a(){return ft(n.canvas).k}function i(s){n.zoom.scaleTo(n.zoom.__baseElem,s),n.needsRedraw=!0}},zoomToFit:function(n){for(var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,a=arguments.length,i=new Array(a>3?a-3:0),s=3;s<a;s++)i[s-3]=arguments[s];var l=this.getGraphBbox.apply(this,i);if(l){var u={x:(l.x[0]+l.x[1])/2,y:(l.y[0]+l.y[1])/2},d=Math.max(1e-12,Math.min(1e12,(n.width-o*2)/(l.x[1]-l.x[0]),(n.height-o*2)/(l.y[1]-l.y[0])));this.centerAt(u.x,u.y,r),this.zoom(d,r)}return this},getGraphBbox:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},o=ae(n.nodeVal),a=function(l){return Math.sqrt(Math.max(0,o(l)||1))*n.nodeRelSize},i=n.graphData.nodes.filter(r).map(function(s){return{x:s.x,y:s.y,r:a(s)}});return i.length?{x:[wo(i,function(s){return s.x-s.r}),_o(i,function(s){return s.x+s.r})],y:[wo(i,function(s){return s.y-s.r}),_o(i,function(s){return s.y+s.r})]}:null},pauseAnimation:function(n){return n.animationFrameRequestId&&(cancelAnimationFrame(n.animationFrameRequestId),n.animationFrameRequestId=null),this},resumeAnimation:function(n){return n.animationFrameRequestId||this._animationCycle(),this},_destructor:function(){this.pauseAnimation(),this.graphData({nodes:[],links:[]})}},Fu),stateInit:function(){return{lastSetZoom:1,zoom:as(),forceGraph:new Vn,shadowGraph:new Vn().cooldownTicks(0).nodeColor("__indexColor").linkColor("__indexColor").isShadow(!0),colorTracker:new Fc,tweenGroup:new zi}},init:function(n,r){var o=this;n.innerHTML="";var a=document.createElement("div");a.classList.add("force-graph-container"),a.style.position="relative",n.appendChild(a),r.canvas=document.createElement("canvas"),r.backgroundColor&&(r.canvas.style.background=r.backgroundColor),a.appendChild(r.canvas),r.shadowCanvas=document.createElement("canvas");var i=r.canvas.getContext("2d"),s=r.shadowCanvas.getContext("2d",{willReadFrequently:!0}),l={x:-1e12,y:-1e12},u=function(){var m=null,f=window.devicePixelRatio,p=l.x>0&&l.y>0?s.getImageData(l.x*f,l.y*f,1,1):null;return p&&(m=r.colorTracker.lookup(p.data)),m};Sr(r.canvas).call(rs().subject(function(){if(!r.enableNodeDrag)return null;var h=u();return h&&h.type==="Node"?h.d:null}).on("start",function(h){var m=h.subject;m.__initialDragPos={x:m.x,y:m.y,fx:m.fx,fy:m.fy},h.active||(m.fx=m.x,m.fy=m.y),r.canvas.classList.add("grabbable")}).on("drag",function(h){var m=h.subject,f=m.__initialDragPos,p=h,g=ft(r.canvas).k,w={x:f.x+(p.x-f.x)/g-m.x,y:f.y+(p.y-f.y)/g-m.y};["x","y"].forEach(function(b){return m["f".concat(b)]=m[b]=f[b]+(p[b]-f[b])/g}),!(!m.__dragged&&Eu>=Math.sqrt(os(["x","y"].map(function(b){return Math.pow(h[b]-f[b],2)}))))&&(r.forceGraph.d3AlphaTarget(.3).resetCountdown(),r.isPointerDragging=!0,m.__dragged=!0,r.onNodeDrag(m,w))}).on("end",function(h){var m=h.subject,f=m.__initialDragPos,p={x:m.x-f.x,y:m.y-f.y};f.fx===void 0&&(m.fx=void 0),f.fy===void 0&&(m.fy=void 0),delete m.__initialDragPos,r.forceGraph.d3AlphaTarget()&&r.forceGraph.d3AlphaTarget(0).resetCountdown(),r.canvas.classList.remove("grabbable"),r.isPointerDragging=!1,m.__dragged&&(delete m.__dragged,r.onNodeDragEnd(m,p))})),r.zoom(r.zoom.__baseElem=Sr(r.canvas)),r.zoom.__baseElem.on("dblclick.zoom",null),r.zoom.filter(function(h){return!h.button&&r.enableZoomPanInteraction&&(h.type!=="wheel"||ae(r.enableZoomInteraction)(h))&&(h.type==="wheel"||ae(r.enablePanInteraction)(h))}).on("zoom",function(h){var m=h.transform;[i,s].forEach(function(f){ha(f),f.translate(m.x,m.y),f.scale(m.k,m.k)}),r.isPointerDragging=!0,r.onZoom&&r.onZoom(Jt(Jt({},m),o.centerAt())),r.needsRedraw=!0}).on("end",function(h){r.isPointerDragging=!1,r.onZoomEnd&&r.onZoomEnd(Jt(Jt({},h.transform),o.centerAt()))}),fr(r),r.forceGraph.onNeedsRedraw(function(){return r.needsRedraw=!0}).onFinishUpdate(function(){ft(r.canvas).k===r.lastSetZoom&&r.graphData.nodes.length&&(r.zoom.scaleTo(r.zoom.__baseElem,r.lastSetZoom=Mu/Math.cbrt(r.graphData.nodes.length)),r.needsRedraw=!0)}),r.tooltip=new id(a),["pointermove","pointerdown"].forEach(function(h){return a.addEventListener(h,function(m){h==="pointerdown"&&(r.isPointerPressed=!0,r.pointerDownEvent=m),!r.isPointerDragging&&m.type==="pointermove"&&r.onBackgroundClick&&(m.pressure>0||r.isPointerPressed)&&(m.pointerType==="mouse"||m.movementX===void 0||[m.movementX,m.movementY].some(function(g){return Math.abs(g)>1}))&&(r.isPointerDragging=!0);var f=p(a);l.x=m.pageX-f.left,l.y=m.pageY-f.top;function p(g){var w=g.getBoundingClientRect(),b=window.pageXOffset||document.documentElement.scrollLeft,v=window.pageYOffset||document.documentElement.scrollTop;return{top:w.top+v,left:w.left+b}}},{passive:!0})}),a.addEventListener("pointerup",function(h){if(r.isPointerPressed){if(r.isPointerPressed=!1,r.isPointerDragging){r.isPointerDragging=!1;return}var m=[h,r.pointerDownEvent];requestAnimationFrame(function(){if(h.button===0)if(r.hoverObj){var f=r["on".concat(r.hoverObj.type,"Click")];f&&f.apply(void 0,[r.hoverObj.d].concat(m))}else r.onBackgroundClick&&r.onBackgroundClick.apply(r,m);if(h.button===2)if(r.hoverObj){var p=r["on".concat(r.hoverObj.type,"RightClick")];p&&p.apply(void 0,[r.hoverObj.d].concat(m))}else r.onBackgroundRightClick&&r.onBackgroundRightClick.apply(r,m)})}},{passive:!0}),a.addEventListener("contextmenu",function(h){return!r.onBackgroundRightClick&&!r.onNodeRightClick&&!r.onLinkRightClick?!0:(h.preventDefault(),!1)}),r.forceGraph(i),r.shadowGraph(s);var d=is(function(){vi(s,r.width,r.height),r.shadowGraph.linkWidth(function(m){return ae(r.linkWidth)(m)+r.linkHoverPrecision});var h=ft(r.canvas);r.shadowGraph.globalScale(h.k).tickFrame()},ju);r.flushShadowCanvas=d.flush,(this._animationCycle=function h(){var m=!r.autoPauseRedraw||!!r.needsRedraw||r.forceGraph.isEngineRunning()||r.graphData.links.some(function(D){return D.__photons&&D.__photons.length});if(r.needsRedraw=!1,r.enablePointerInteraction){var f=r.isPointerDragging?null:u();if(f!==r.hoverObj){var p=r.hoverObj,g=p?p.type:null,w=f?f.type:null;if(g&&g!==w){var b=r["on".concat(g,"Hover")];b&&b(null,p.d)}if(w){var v=r["on".concat(w,"Hover")];v&&v(f.d,g===w?p.d:null)}r.tooltip.content(f&&ae(r["".concat(f.type.toLowerCase(),"Label")])(f.d)||null),r.canvas.classList[(f&&r["on".concat(w,"Click")]||!f&&r.onBackgroundClick)&&ae(r.showPointerCursor)(f==null?void 0:f.d)?"add":"remove"]("clickable"),r.hoverObj=f}m&&d()}if(m){vi(i,r.width,r.height);var I=ft(r.canvas).k;r.onRenderFramePre&&r.onRenderFramePre(i,I),r.forceGraph.globalScale(I).tickFrame(),r.onRenderFramePost&&r.onRenderFramePost(i,I)}r.tweenGroup.update(),r.animationFrameRequestId=requestAnimationFrame(h)})()},update:function(n){}}),pa={exports:{}},zu="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",$u=zu,Uu=$u;function ga(){}function ya(){}ya.resetWarningCache=ga;var Bu=function(){function e(o,a,i,s,l,u){if(u!==Uu){var d=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw d.name="Invariant Violation",d}}e.isRequired=e;function n(){return e}var r={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:n,element:e,elementType:e,instanceOf:n,node:e,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:ya,resetWarningCache:ga};return r.PropTypes=r,r};pa.exports=Bu();var Hu=pa.exports;const S=Ba(Hu),Yn={width:S.number,height:S.number,graphData:S.shape({nodes:S.arrayOf(S.object).isRequired,links:S.arrayOf(S.object).isRequired}),backgroundColor:S.string,nodeRelSize:S.number,nodeId:S.string,nodeLabel:S.oneOfType([S.string,S.func]),nodeVal:S.oneOfType([S.number,S.string,S.func]),nodeVisibility:S.oneOfType([S.bool,S.string,S.func]),nodeColor:S.oneOfType([S.string,S.func]),nodeAutoColorBy:S.oneOfType([S.string,S.func]),onNodeHover:S.func,onNodeClick:S.func,linkSource:S.string,linkTarget:S.string,linkLabel:S.oneOfType([S.string,S.func]),linkVisibility:S.oneOfType([S.bool,S.string,S.func]),linkColor:S.oneOfType([S.string,S.func]),linkAutoColorBy:S.oneOfType([S.string,S.func]),linkWidth:S.oneOfType([S.number,S.string,S.func]),linkCurvature:S.oneOfType([S.number,S.string,S.func]),linkDirectionalArrowLength:S.oneOfType([S.number,S.string,S.func]),linkDirectionalArrowColor:S.oneOfType([S.string,S.func]),linkDirectionalArrowRelPos:S.oneOfType([S.number,S.string,S.func]),linkDirectionalParticles:S.oneOfType([S.number,S.string,S.func]),linkDirectionalParticleSpeed:S.oneOfType([S.number,S.string,S.func]),linkDirectionalParticleOffset:S.oneOfType([S.number,S.string,S.func]),linkDirectionalParticleWidth:S.oneOfType([S.number,S.string,S.func]),linkDirectionalParticleColor:S.oneOfType([S.string,S.func]),onLinkHover:S.func,onLinkClick:S.func,dagMode:S.oneOf(["td","bu","lr","rl","zin","zout","radialin","radialout"]),dagLevelDistance:S.number,dagNodeFilter:S.func,onDagError:S.func,d3AlphaMin:S.number,d3AlphaDecay:S.number,d3VelocityDecay:S.number,warmupTicks:S.number,cooldownTicks:S.number,cooldownTime:S.number,onEngineTick:S.func,onEngineStop:S.func,getGraphBbox:S.func},va={zoomToFit:S.func,onNodeRightClick:S.func,onNodeDrag:S.func,onNodeDragEnd:S.func,onLinkRightClick:S.func,linkHoverPrecision:S.number,onBackgroundClick:S.func,onBackgroundRightClick:S.func,showPointerCursor:S.oneOfType([S.bool,S.func]),enablePointerInteraction:S.bool,enableNodeDrag:S.bool},eo={showNavInfo:S.bool,nodeOpacity:S.number,nodeResolution:S.number,nodeThreeObject:S.oneOfType([S.object,S.string,S.func]),nodeThreeObjectExtend:S.oneOfType([S.bool,S.string,S.func]),nodePositionUpdate:S.func,linkOpacity:S.number,linkResolution:S.number,linkCurveRotation:S.oneOfType([S.number,S.string,S.func]),linkMaterial:S.oneOfType([S.object,S.string,S.func]),linkThreeObject:S.oneOfType([S.object,S.string,S.func]),linkThreeObjectExtend:S.oneOfType([S.bool,S.string,S.func]),linkPositionUpdate:S.func,linkDirectionalArrowResolution:S.number,linkDirectionalParticleResolution:S.number,linkDirectionalParticleThreeObject:S.oneOfType([S.object,S.string,S.func]),forceEngine:S.oneOf(["d3","ngraph"]),ngraphPhysics:S.object,numDimensions:S.oneOf([1,2,3])},Vu=Object.assign({},Yn,va,{linkLineDash:S.oneOfType([S.arrayOf(S.number),S.string,S.func]),nodeCanvasObjectMode:S.oneOfType([S.string,S.func]),nodeCanvasObject:S.func,nodePointerAreaPaint:S.func,linkCanvasObjectMode:S.oneOfType([S.string,S.func]),linkCanvasObject:S.func,linkPointerAreaPaint:S.func,linkDirectionalParticleCanvasObject:S.func,autoPauseRedraw:S.bool,minZoom:S.number,maxZoom:S.number,enableZoomInteraction:S.oneOfType([S.bool,S.func]),enablePanInteraction:S.oneOfType([S.bool,S.func]),onZoom:S.func,onZoomEnd:S.func,onRenderFramePre:S.func,onRenderFramePost:S.func});Object.assign({},Yn,va,eo,{enableNavigationControls:S.bool,controlType:S.oneOf(["trackball","orbit","fly"]),rendererConfig:S.object,extraRenderers:S.arrayOf(S.shape({render:S.func.isRequired}))});Object.assign({},Yn,eo,{nodeDesc:S.oneOfType([S.string,S.func]),linkDesc:S.oneOfType([S.string,S.func])});Object.assign({},Yn,eo,{markerAttrs:S.object,yOffset:S.number,glScale:S.number});const to=Vl(Lu,{methodNames:["emitParticle","d3Force","d3ReheatSimulation","stopAnimation","pauseAnimation","resumeAnimation","centerAt","zoom","zoomToFit","getGraphBbox","screen2GraphCoords","graph2ScreenCoords"]});to.displayName="ForceGraph2D";to.propTypes=Vu;const Gu=[{value:"openai-completions",label:"OpenAI 兼容"},{value:"anthropic-messages",label:"Anthropic 兼容"}];function Wu(e){const{t:n}=Je(),[r,o]=x.useState("deepseek"),[a,i]=x.useState(""),[s,l]=x.useState(""),[u,d]=x.useState("openai-completions"),[h,m]=x.useState(""),[f,p]=x.useState(!1),[g,w]=x.useState(!1),[b,v]=x.useState(null),I=x.useRef(!1);function D(C){if(i(C),I.current)return;C.toLowerCase().includes("anthropic")?d("anthropic-messages"):d("openai-completions")}function N(C){I.current=!0,d(C)}async function _(){var P;const C=h.trim();if(!C){v("请输入 API Key");return}w(!0),v(null);try{if(r==="deepseek")await Lo({kind:"deepseek",modelId:"deepseek-flash",apiKey:C});else{const z=a.trim();if(!z){v("请输入 API 地址");return}const E=s.trim();if(!E){v("请输入 Model ID");return}await Lo({kind:"custom",baseUrl:z,modelId:E,apiType:u,apiKey:C})}m(""),i(""),l(""),await((P=e.onConfigured)==null?void 0:P.call(e))}catch(z){v(z instanceof Error?z.message:String(z))}finally{w(!1)}}const T=h.trim()&&(r==="deepseek"||a.trim()&&s.trim());return c.jsxs("div",{className:"mdocs-agent-apikey-inline",children:[c.jsx("p",{className:"mdocs-agent-apikey-inline-lead",children:"配置 AI 供应商后即可使用(仅本人可见,不会分享给其他访客)"}),c.jsxs("div",{className:"mdocs-agent-kind-tabs mdocs-agent-apikey-inline-tabs",role:"tablist","aria-label":"配置方式",children:[c.jsx("button",{type:"button",role:"tab","aria-selected":r==="deepseek",className:r==="deepseek"?"active":"",onClick:()=>o("deepseek"),disabled:g,children:"Deepseek"}),c.jsx("button",{type:"button",role:"tab","aria-selected":r==="custom",className:r==="custom"?"active":"",onClick:()=>o("custom"),disabled:g,children:"自定义"})]}),r==="custom"?c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"mdocs-agent-field mdocs-agent-apikey-inline-field",children:[c.jsx("span",{children:"API 地址"}),c.jsx("input",{type:"url",value:a,onChange:C=>D(C.target.value),placeholder:"https://api.example.com/v1",className:"mdocs-agent-mono",disabled:g,onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),_())}})]}),c.jsxs("label",{className:"mdocs-agent-field mdocs-agent-apikey-inline-field",children:[c.jsx("span",{children:"API 协议"}),c.jsx("div",{className:"mdocs-agent-apikey-inline-protocol",children:Gu.map(C=>c.jsx("button",{type:"button",className:u===C.value?"active":"",onClick:()=>N(C.value),disabled:g,children:C.label},C.value))})]}),c.jsxs("label",{className:"mdocs-agent-field mdocs-agent-apikey-inline-field",children:[c.jsx("span",{children:"Model ID"}),c.jsx("input",{type:"text",value:s,onChange:C=>l(C.target.value),placeholder:"模型名称,如 gpt-4o / claude-3-5-sonnet",className:"mdocs-agent-mono",disabled:g,onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),_())}})]})]}):null,c.jsxs("div",{className:"mdocs-agent-config-apikey mdocs-agent-apikey-inline-field",children:[c.jsx("input",{type:f?"text":"password",value:h,onChange:C=>m(C.target.value),placeholder:n("agentConfigApiKeyPlaceholder"),autoComplete:"off",disabled:g,onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),_())}}),c.jsx("button",{type:"button",className:"mdocs-agent-config-eye","aria-label":n(f?"agentConfigHideKey":"agentConfigShowKey"),onClick:()=>p(C=>!C),disabled:g,children:f?c.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":!0,children:[c.jsx("path",{d:"M3 3l18 18"}),c.jsx("path",{d:"M10.6 10.6a2 2 0 002.8 2.8"}),c.jsx("path",{d:"M9.9 5.1A10.5 0 0121 12c-.6 1.1-1.4 2.1-2.4 2.9"}),c.jsx("path",{d:"M6.1 6.1C4.5 7.4 3.2 9.1 2.5 12c1.5 3.5 5 7 9.5 7 1.4 0 2.7-.3 3.9-.8"})]}):c.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":!0,children:[c.jsx("path",{d:"M2.5 12C4 8.5 7.5 5 12 5s8 3.5 9.5 7c-1.5 3.5-5 7-9.5 7s-8-3.5-9.5-7z"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"})]})})]}),b?c.jsx("p",{className:"mdocs-agent-apikey-inline-error",children:b}):null,c.jsx("button",{type:"button",className:"mdocs-agent-apikey-inline-save",onClick:()=>void _(),disabled:g||!T,children:g?n("saving"):"保存并启用"})]})}function bi(e){return e==="contains"}function qu(e){return e==="related_to"||e==="part_of"||e==="depends_on"}function Ku(e,n){var h,m;const r=new Set(e),o=new Map,a=new Map,i=new Map;for(const f of e)o.set(f,[]),a.set(f,[]),i.set(f,0);for(const f of n)!r.has(f.from)||!r.has(f.to)||f.from===f.to||(o.get(f.from).push(f.to),a.get(f.to).push(f.from),i.set(f.to,(i.get(f.to)??0)+1));let s=e.filter(f=>(i.get(f)??0)===0);if(s.length===0&&e.length>0){const f=new Map;for(const w of e)f.set(w,(((h=o.get(w))==null?void 0:h.length)??0)+(((m=a.get(w))==null?void 0:m.length)??0));const p=[...e].sort((w,b)=>(f.get(b)??0)-(f.get(w)??0)),g=f.get(p[0])??0;s=p.filter(w=>(f.get(w)??0)===g).slice(0,12)}const l=new Map,u=[];for(const f of s)l.set(f,0),u.push(f);let d=0;for(;d<u.length;){const f=u[d++],p=l.get(f)??0;for(const g of o.get(f)??[]){const w=p+1;(!l.has(g)||w<(l.get(g)??1/0))&&(l.set(g,w),u.push(g))}}for(const f of e)l.has(f)||l.set(f,0);return{childrenOf:o,parentsOf:a,roots:s,depthMap:l}}function mr(e,n,r,o,a){return a.has(e)?!1:(r.get(e)??0)<n?!0:o.has(e)}function Yu(e,n,r){const o=new Set(e),a=[...e];let i=0;for(;i<a.length;){const s=a[i++];if(r(s))for(const l of n.get(s)??[])o.has(l)||(o.add(l),a.push(l))}return o}function Ju(e,n){const r=[],o=new Set,a=[...n.get(e)??[]];for(;a.length>0;){const i=a.pop();if(!o.has(i)){o.add(i),r.push(i);for(const s of n.get(i)??[])a.push(s)}}return r}function Xu(e){const{event:n,data:r}=e;switch(n){case"task.started":return`🚀 开始生成,共 ${(r==null?void 0:r.totalDocs)??0} 篇文档`;case"doc.started":return`📄 处理中:${(r==null?void 0:r.docPath)??""}(${(r==null?void 0:r.index)??0}/${(r==null?void 0:r.total)??0})`;case"doc.completed":return`✅ ${(r==null?void 0:r.docPath)??""}(提取 ${(r==null?void 0:r.conceptsExtracted)??0} 个知识块)`;case"doc.failed":return`⚠️ ${(r==null?void 0:r.docPath)??""} 失败:${(r==null?void 0:r.error)??""}`;case"folder.started":return`📁 归纳目录:${(r==null?void 0:r.folderPath)??""}`;case"folder.completed":return`✅ 目录归纳完成:${(r==null?void 0:r.folderPath)??""}`;case"domain.started":return"🌐 开始 domain 级合成";case"domain.completed":return`✅ domain 合成完成(${(r==null?void 0:r.totalNodes)??0} 节点,${(r==null?void 0:r.totalEdges)??0} 边)`;case"task.yielded":return"⏸️ 让出资源,排队等待中...";case"task.progress":return`⏳ ${(r==null?void 0:r.phase)??"progress"} ${(r==null?void 0:r.current)??0}/${(r==null?void 0:r.total)??0}`;case"task.completed":return`🎉 生成完成!${(r==null?void 0:r.nodes)??0} 个节点,${(r==null?void 0:r.edges)??0} 条边`;case"task.failed":return`❌ 生成失败:${(r==null?void 0:r.error)??""}`;default:return`${n}${r?`: ${JSON.stringify(r)}`:""}`}}function hr(e){return e<=1?"排队中,即将开始…":`排队中,前面还有 ${e-1} 个任务`}function pr(e,n,r){const o=Math.max(e,.2);return Math.max(r??n*.75,n)/o}function Zu({scope:e,resourceId:n,name:r,onOpenDocument:o,onClose:a}){const[i,s]=x.useState(null),[l,u]=x.useState(!0),[d,h]=x.useState(null),[m,f]=x.useState(!1),[p,g]=x.useState(!1),[w,b]=x.useState(0),[v,I]=x.useState(()=>new Set),[D,N]=x.useState(()=>new Set),[_,T]=x.useState(null),[C,P]=x.useState(null),[z,E]=x.useState(null),R=x.useRef(null),$=x.useRef(new Map),[H,J]=x.useState("not_found"),[ne,B]=x.useState([]),[G,se]=x.useState(null),[ue,j]=x.useState(0),re=`graph:${e==="domain"?"domain":"dir"}:${n}`,oe=x.useRef(re),ie=x.useRef(null),[K,Z]=x.useState(!1),[we,le]=x.useState(!1),[Xe,Ct]=x.useState(!1),[gt,en]=x.useState(!1),[$t,Dt]=x.useState(!1),Ze=x.useRef(null),ke=H==="running"||H==="pending";x.useEffect(()=>{let k=!1;return u(!0),h(null),T(null),b(0),I(new Set),N(new Set),g(!1),E(null),$.current=new Map,(e==="domain"?$o:zo)(n).then(L=>{k||(s(L),u(!1))}).catch(L=>{k||(h(L.message||"加载失败"),u(!1))}),()=>{k=!0}},[n,e]),x.useEffect(()=>(oe.current=re,et(),Qe(),()=>et()),[re]);async function Qe(){try{const k=await Il(oe.current);J(k.status),B(k.logs),se(k.progress??null),j(k.position),k.status==="completed"?(et(),Nt()):k.status==="failed"||k.status==="stale"?(et(),k.error&&h(k.error)):(k.status==="running"||k.status==="pending")&&wn()}catch{}}function wn(){ie.current||(ie.current=window.setInterval(()=>{Qe()},2e3))}function et(){ie.current&&(clearInterval(ie.current),ie.current=null)}async function Nt(){try{const M=await(e==="domain"?$o:zo)(n);s(M)}catch(k){h(k.message||"加载失败")}}const ze=async()=>{if(!ke){h(null),Z(!1);try{const M=await(e==="domain"?kl:_l)(n);oe.current=M.taskId,J(M.status),j(M.position),B([]),se(null),wn()}catch(k){if(k instanceof Ye&&k.code==="AI_NOT_CONFIGURED"){Z(!0),h(k.message);return}h((k==null?void 0:k.message)||"生成失败")}}},Ut=async()=>{le(!1),Z(!1),h(null),await ze()},Me=x.useMemo(()=>i?m?i.nodes:i.nodes.filter(k=>k.type==="concept"):[],[i,m]),he=x.useMemo(()=>{if(!i)return[];const k=new Set(Me.map(M=>M.id));return i.edges.filter(M=>k.has(M.from)&&k.has(M.to))},[i,Me]),Ce=x.useMemo(()=>{const k=he.filter(M=>bi(String(M.type))).map(M=>({from:M.from,to:M.to}));return Ku(Me.map(M=>M.id),k)},[Me,he]),be=x.useMemo(()=>Yu(Ce.roots,Ce.childrenOf,k=>mr(k,w,Ce.depthMap,v,D)),[Ce,w,v,D]),{displayNodes:xe,displayEdges:Pt}=x.useMemo(()=>{const k=Me.filter(L=>be.has(L.id)),M=he.filter(L=>{if(!be.has(L.from)||!be.has(L.to))return!1;const F=String(L.type);return!!(bi(F)||p&&qu(F))});return{displayNodes:k,displayEdges:M}},[Me,he,be,p]),yt=x.useMemo(()=>{const k=new Map;for(const M of Me)k.set(M.id,M);return k},[Me]);function st(k){b(k),I(new Set),N(new Set)}function tn(k){if((Ce.childrenOf.get(k)??[]).length===0)return;mr(k,w,Ce.depthMap,v,D)?(N(F=>new Set(F).add(k)),I(F=>{const q=new Set(F);return q.delete(k),q})):(N(F=>{const q=new Set(F);return q.delete(k),q}),I(F=>new Set(F).add(k)))}function Ee(k){const M=Ju(k.id,Ce.parentsOf);N(L=>{const F=new Set(L);for(const q of M)F.delete(q);return F}),I(L=>{const F=new Set(L);for(const q of M)F.add(q);return F}),T(k)}const _n=x.useMemo(()=>{const k=xe.map(F=>{var De;const q=((De=Ce.childrenOf.get(F.id))==null?void 0:De.length)??0,X=mr(F.id,w,Ce.depthMap,v,D),te=$.current.get(F.id);let Q=te==null?void 0:te.x,ye=te==null?void 0:te.y;if(Q==null||ye==null){const je=(Ce.parentsOf.get(F.id)??[]).map(Ne=>$.current.get(Ne)).find(Ne=>Ne!=null);je?(Q=je.x+(Math.random()-.5)*60,ye=je.y+50+Math.random()*40):(Q=(Math.random()-.5)*240,ye=(Math.random()-.5)*180),$.current.set(F.id,{x:Q,y:ye})}return{id:F.id,name:F.label,type:F.type,val:F.type==="concept"?4:2,x:Q,y:ye,__raw:F,__childCount:q,__expanded:X}}),M=new Map,L=Pt.map(F=>{const q=`${F.from}->${F.to}`,X=M.get(q)??0;M.set(q,X+1);const te=X===0?.08:.08+X*.14;return{source:F.from,target:F.to,type:F.type,curvature:te,__raw:F}});return{nodes:k,links:L}},[xe,Pt,Ce,w,v,D]),tt=x.useMemo(()=>{const k=Math.max(1,xe.length);return{linkDistance:Math.min(140,70+Math.sqrt(k)*8),chargeStrength:Math.max(-420,-120-k*6)}},[xe.length]),Fe=x.useRef(null),[He,kn]=x.useState({width:800,height:600});x.useEffect(()=>{if(!Fe.current)return;const k=()=>{Fe.current&&kn({width:Fe.current.clientWidth,height:Fe.current.clientHeight})};k();const M=new ResizeObserver(k);return M.observe(Fe.current),()=>M.disconnect()},[]),x.useEffect(()=>{if(!i||l)return;const k=window.setTimeout(()=>{var M,L;(L=(M=R.current)==null?void 0:M.zoomToFit)==null||L.call(M,400,80)},450);return()=>window.clearTimeout(k)},[i,m,p,l,He.width,He.height,w,be]),x.useEffect(()=>{var F,q,X,te;if(!i||l)return;const k=R.current;if(!k)return;const M=k.d3Force("charge");(F=M==null?void 0:M.strength)==null||F.call(M,tt.chargeStrength);const L=k.d3Force("link");(q=L==null?void 0:L.distance)==null||q.call(L,tt.linkDistance),(X=L==null?void 0:L.strength)==null||X.call(L,.35),(te=k.d3ReheatSimulation)==null||te.call(k)},[tt,i,l,m,_n]);const vt=k=>(Ce.childrenOf.get(k)??[]).map(L=>yt.get(L)??(i==null?void 0:i.nodes.find(F=>F.id===L))).filter(L=>!!L),Bt=k=>(Ce.parentsOf.get(k)??[]).map(L=>yt.get(L)??(i==null?void 0:i.nodes.find(F=>F.id===L))).filter(L=>!!L),In=k=>{if(!i)return[];const M=new Set,L=[],F=[k];for(;F.length>0;){const q=F.shift();if(M.has(q))continue;M.add(q);const X=i.nodes.find(Q=>Q.id===q);(X==null?void 0:X.type)==="doc"&&L.push(X);const te=i.edges.filter(Q=>Q.from===q).map(Q=>Q.to);F.push(...te)}return L};return x.useEffect(()=>{if(!$t)return;const k=M=>{Ze.current&&!Ze.current.contains(M.target)&&Dt(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[$t]),c.jsxs("div",{className:"graph-page",children:[c.jsxs("div",{className:"graph-toolbar",children:[c.jsxs("div",{className:"graph-toolbar-left",children:[c.jsx("span",{className:"graph-icon",children:"🕸️"}),c.jsxs("span",{className:"graph-title-text",title:`知识图谱 — ${r}`,children:["知识图谱 — ",r]}),a&&c.jsx("button",{className:"graph-btn graph-btn-danger",onClick:a,children:"退出图谱"})]}),c.jsxs("div",{className:"graph-toolbar-right",children:[c.jsxs("div",{className:"graph-mobile-toggle-wrap",ref:Ze,children:[c.jsx("button",{type:"button",className:"graph-mobile-toggle-btn",onClick:()=>Dt(k=>!k),"aria-label":"更多操作",children:c.jsx(ws,{size:18,strokeWidth:1.75})}),$t&&c.jsxs("div",{className:"graph-mobile-actions card",onClick:()=>Dt(!1),children:[c.jsxs("div",{className:"graph-mobile-action-group",children:[c.jsx("div",{className:"graph-mobile-action-label",children:"层级控制"}),c.jsx("button",{type:"button",className:`graph-mobile-action-item ${w===1?"active":""}`,onMouseDown:()=>st(1),children:"展开一级"}),c.jsx("button",{type:"button",className:`graph-mobile-action-item ${w===2?"active":""}`,onMouseDown:()=>st(2),children:"展开到二级"}),c.jsx("button",{type:"button",className:`graph-mobile-action-item ${w===0&&v.size===0?"active":""}`,onMouseDown:()=>st(0),children:"全部收起"})]}),c.jsxs("div",{className:"graph-mobile-action-group",children:[c.jsx("div",{className:"graph-mobile-action-label",children:"视图"}),c.jsxs("label",{className:"graph-mobile-action-switch",children:[c.jsx("input",{type:"checkbox",checked:p,onChange:k=>g(k.target.checked)}),c.jsx("span",{children:"显示其它关系"})]}),c.jsxs("label",{className:"graph-mobile-action-switch",children:[c.jsx("input",{type:"checkbox",checked:m,onChange:k=>f(k.target.checked)}),c.jsx("span",{children:"显示 doc 节点"})]})]}),c.jsxs("button",{className:"graph-mobile-action-item",onMouseDown:()=>le(!0),children:[c.jsx(or,{size:14}),"配置 AI"]}),c.jsx("button",{className:"graph-mobile-action-item graph-mobile-action-primary",onMouseDown:ze,disabled:ke,children:ke?c.jsxs(c.Fragment,{children:[c.jsx(Nn,{size:14,className:"spin"}),H==="pending"?hr(ue):"生成中..."]}):c.jsxs(c.Fragment,{children:[c.jsx(Do,{size:14}),i?"重新生成":"生成图谱"]})})]})]}),c.jsxs("div",{className:"graph-desktop-actions",children:[c.jsxs("div",{className:"graph-dropdown",children:[c.jsxs("button",{type:"button",className:"graph-btn",onClick:()=>Ct(k=>!k),onBlur:()=>setTimeout(()=>Ct(!1),150),children:["层级控制 ",c.jsx(Cr,{size:12})]}),Xe&&c.jsxs("div",{className:"graph-dropdown-menu graph-dropdown-menu--right",children:[c.jsx("button",{type:"button",className:`graph-dropdown-item ${w===1?"active":""}`,onMouseDown:()=>{st(1),Ct(!1)},children:"展开一级"}),c.jsx("button",{type:"button",className:`graph-dropdown-item ${w===2?"active":""}`,onMouseDown:()=>{st(2),Ct(!1)},children:"展开到二级"}),c.jsx("button",{type:"button",className:`graph-dropdown-item ${w===0&&v.size===0?"active":""}`,onMouseDown:()=>{st(0),Ct(!1)},children:"全部收起"})]})]}),c.jsxs("div",{className:"graph-dropdown",children:[c.jsxs("button",{type:"button",className:"graph-btn",onClick:()=>en(k=>!k),onBlur:()=>setTimeout(()=>en(!1),150),children:[c.jsx(ks,{size:14})," 视图 ",c.jsx(Cr,{size:12})]}),gt&&c.jsxs("div",{className:"graph-dropdown-menu graph-dropdown-menu--right",children:[c.jsxs("label",{className:"graph-dropdown-switch",children:[c.jsx("input",{type:"checkbox",checked:p,onChange:k=>g(k.target.checked)}),c.jsx("span",{children:"显示其它关系"})]}),c.jsxs("label",{className:"graph-dropdown-switch",children:[c.jsx("input",{type:"checkbox",checked:m,onChange:k=>f(k.target.checked)}),c.jsx("span",{children:"显示 doc 节点"})]})]})]}),c.jsxs("button",{className:"graph-btn graph-btn-ghost",onClick:()=>le(!0),title:"配置用于图谱分析的 AI 模型",children:[c.jsx(or,{size:14}),"配置 AI"]}),c.jsx("button",{className:"graph-btn graph-btn-primary",onClick:ze,disabled:ke,children:ke?c.jsxs(c.Fragment,{children:[c.jsx(Nn,{size:14,className:"spin"}),H==="pending"?hr(ue):"生成中..."]}):c.jsxs(c.Fragment,{children:[c.jsx(Do,{size:14}),i?"重新生成":"生成图谱"]})})]})]})]}),c.jsxs("div",{className:"graph-canvas-container",ref:Fe,children:[l&&c.jsxs("div",{className:"graph-loading",children:[c.jsx(Nn,{size:32,className:"spin"}),c.jsx("p",{children:"加载图谱中..."})]}),d&&!l&&c.jsx("div",{className:"graph-error",children:K?c.jsxs(c.Fragment,{children:[c.jsx("p",{style:{fontSize:40,margin:0},children:"🔑"}),c.jsx("h3",{children:"还没有配置 AI 模型"}),c.jsx("p",{className:"muted",children:"图谱由 AI 分析生成,需要先配置一个可用的模型"}),c.jsxs("button",{className:"graph-btn graph-btn-primary",onClick:()=>le(!0),style:{marginTop:12},children:[c.jsx(or,{size:14}),"配置 AI"]})]}):c.jsxs(c.Fragment,{children:[c.jsxs("p",{children:["❌ ",d]}),c.jsx("button",{className:"graph-btn",onClick:ze,children:"重试生成"})]})}),!l&&!d&&!i&&!ke&&c.jsxs("div",{className:"graph-empty",children:[c.jsx("p",{style:{fontSize:48,margin:0},children:"🕸️"}),c.jsx("h3",{children:"还没有知识图谱"}),c.jsx("p",{className:"muted",children:"点击右上角「生成图谱」开始构建"}),c.jsx("button",{className:"graph-btn graph-btn-primary",onClick:ze,disabled:ke,children:ke?"生成中...":"生成图谱"})]}),ke&&c.jsxs("div",{className:"graph-progress-panel",children:[c.jsxs("div",{className:"graph-progress-header",children:[c.jsx(Nn,{size:16,className:"spin"}),c.jsx("span",{children:H==="pending"?hr(ue):G?`正在生成(${G.current}/${G.total})`:"正在生成..."})]}),G&&G.total>0&&c.jsx("div",{className:"graph-progress-bar",children:c.jsx("div",{className:"graph-progress-bar-fill",style:{width:`${G.current/G.total*100}%`}})}),c.jsx("div",{className:"graph-progress-logs",children:ne.slice(-10).map((k,M)=>c.jsx("div",{className:`graph-log-item graph-log-${k.level}`,children:c.jsx("span",{className:"graph-log-event",children:Xu(k)})},M))})]}),!l&&!d&&i&&i.nodes.length===0&&!ke&&c.jsxs("div",{className:"graph-empty",children:[c.jsx("p",{style:{fontSize:48,margin:0},children:"📄"}),c.jsx("h3",{children:"图谱已生成"}),c.jsx("p",{className:"muted",children:"当前内容暂未提取到可关联的知识概念"}),c.jsx("p",{className:"muted",style:{fontSize:13,marginTop:4},children:"内容较少或结构较简单时可能出现这种情况,补充更多内容后可以重新生成"}),c.jsx("button",{className:"graph-btn graph-btn-primary",onClick:ze,disabled:ke,style:{marginTop:12},children:"重新生成"})]}),!l&&!d&&i&&i.nodes.length>0&&c.jsx(to,{ref:R,width:He.width,height:He.height,graphData:_n,nodeId:"id",nodeVal:k=>k.type==="concept"?6:3,nodeColor:k=>k.type==="concept"?"#8b5cf6":"#06b6d4",nodeCanvasObjectMode:()=>"replace",nodeCanvasObject:(k,M,L)=>{const F=String(k.name??""),q=k.type==="concept",X=k.id===(_==null?void 0:_.id)||k.id===C,te=(q?9:5)/Math.max(L,.35);if(M.beginPath(),M.arc(k.x,k.y,te,0,2*Math.PI),M.fillStyle=q?"#8b5cf6":"#06b6d4",M.globalAlpha=X||!_?1:.35,M.fill(),M.strokeStyle="#ffffff",M.lineWidth=1.5/Math.max(L,.35),M.stroke(),M.globalAlpha=1,k.__childCount>0){const xt=7/Math.max(L,.4),lt=k.x+te+xt*.9,fe=k.y-te*.2;M.beginPath(),M.arc(lt,fe,xt,0,2*Math.PI),M.fillStyle=k.__expanded?"#475569":"#6366f1",M.fill(),M.fillStyle="#ffffff";const Ve=k.__expanded?"−":"+",Tt=Math.max(10/L,9/L);M.font=`700 ${Tt}px -apple-system, BlinkMacSystemFont, sans-serif`,M.textAlign="center",M.textBaseline="middle",M.fillText(Ve,lt,fe+.5/L)}if(!(X||q&&L>=.55||!q&&L>=1.4))return;const ye=Math.max(10/L,q?11/L:9/L),De=q?L<.9?8:16:10,je=F.length>De?F.slice(0,De)+"…":F;M.font=`${q?"600":"400"} ${ye}px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,M.textAlign="center",M.textBaseline="top";const Ne=k.y+te+3/L,Ie=M.measureText(je).width,Pe=4/L,bt=2/L;M.fillStyle="rgba(255,255,255,0.88)",M.fillRect(k.x-Ie/2-Pe,Ne-bt,Ie+Pe*2,ye+bt*2),M.fillStyle=q?"#1e1b4b":"#0c4a6e",M.fillText(je,k.x,Ne)},linkDirectionalArrowLength:k=>{var F,q,X,te,Q,ye;const M=((q=(F=R.current)==null?void 0:F.zoom)==null?void 0:q.call(F))??1,L=((X=k.source)==null?void 0:X.id)===C||((te=k.target)==null?void 0:te.id)===C||((Q=k.source)==null?void 0:Q.id)===(_==null?void 0:_.id)||((ye=k.target)==null?void 0:ye.id)===(_==null?void 0:_.id);return pr(M,L?13:11,9)},linkDirectionalArrowRelPos:.86,linkDirectionalArrowColor:()=>"#475569",linkWidth:k=>{var F,q,X,te,Q,ye;const M=((q=(F=R.current)==null?void 0:F.zoom)==null?void 0:q.call(F))??1,L=((X=k.source)==null?void 0:X.id)===C||((te=k.target)==null?void 0:te.id)===C||((Q=k.source)==null?void 0:Q.id)===(_==null?void 0:_.id)||((ye=k.target)==null?void 0:ye.id)===(_==null?void 0:_.id);return pr(M,L?3.5:3,2.25)},linkColor:k=>{var L,F,q,X;return((L=k.source)==null?void 0:L.id)===C||((F=k.target)==null?void 0:F.id)===C||((q=k.source)==null?void 0:q.id)===(_==null?void 0:_.id)||((X=k.target)==null?void 0:X.id)===(_==null?void 0:_.id)?"#334155":"#64748b"},linkCurvature:k=>k.curvature??.12,linkCanvasObjectMode:()=>"after",linkCanvasObject:(k,M,L)=>{if(L<.45)return;const F=k.source,q=k.target;if(F.x==null||F.y==null||q.x==null||q.y==null)return;const te={contains:"包含",related_to:"相关",part_of:"属于",depends_on:"依赖"}[k.type]||String(k.type??""),Q=typeof k.curvature=="number"?k.curvature:.12,ye=(F.x+q.x)/2,De=(F.y+q.y)/2,je=ye-(q.y-F.y)*Q,Ne=De+(q.x-F.x)*Q,Ie=.5,Pe=1-Ie,bt=Pe*Pe*F.x+2*Pe*Ie*je+Ie*Ie*q.x,xt=Pe*Pe*F.y+2*Pe*Ie*Ne+Ie*Ie*q.y,lt=2*Pe*(je-F.x)+2*Ie*(q.x-je),fe=2*Pe*(Ne-F.y)+2*Ie*(q.y-Ne);let Ve=Math.atan2(fe,lt);(Ve>Math.PI/2||Ve<-Math.PI/2)&&(Ve+=Math.PI);const Tt=pr(L,11,9);M.save(),M.translate(bt,xt),M.rotate(Ve),M.font=`500 ${Tt}px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,M.textAlign="center",M.textBaseline="middle";const nn=M.measureText(te).width,At=3/L,Ht=1.5/L;M.fillStyle="rgba(255,255,255,0.92)",M.fillRect(-nn/2-At,-Tt/2-Ht,nn+At*2,Tt+Ht*2),M.fillStyle="#475569",M.fillText(te,0,0),M.restore()},onZoom:()=>{var k,M;(M=(k=R.current)==null?void 0:k.refresh)==null||M.call(k)},cooldownTicks:120,cooldownTime:4e3,d3AlphaDecay:.022,d3VelocityDecay:.3,onNodeClick:(k,M)=>{var q,X,te,Q,ye;const L=k.__childCount??0;if(L>0&&R.current&&Fe.current){const De=Fe.current.getBoundingClientRect(),je=R.current.screen2GraphCoords(M.clientX-De.left,M.clientY-De.top),Ne=((X=(q=R.current).zoom)==null?void 0:X.call(q))??1,Ie=(k.type==="concept"?9:5)/Math.max(Ne,.35),Pe=7/Math.max(Ne,.4),bt=k.x+Ie+Pe*.9,xt=k.y-Ie*.2,lt=je.x-bt,fe=je.y-xt;if(lt*lt+fe*fe<=(Pe+4/Ne)**2){tn(String(k.id)),T(k.__raw);return}}const F=k.__raw;if(T(F),L>0&&!k.__expanded&&tn(String(k.id)),(F==null?void 0:F.type)==="doc"){const De=(ye=(Q=(te=F.sources)==null?void 0:te[0])==null?void 0:Q.documentId)==null?void 0:ye.trim();De&&o(De)}},onNodeHover:k=>{var L;if(!k){P(null),E(null);return}P(String(k.id));const M=String(k.name??((L=k.__raw)==null?void 0:L.label)??"");if(R.current&&M){const F=R.current.graph2ScreenCoords(k.x,k.y);E({text:M,x:F.x,y:F.y})}else E({text:M,x:0,y:0})},onBackgroundClick:()=>{T(null),P(null),E(null)},onEngineTick:()=>{var M,L;const k=(L=(M=R.current)==null?void 0:M.graphData)==null?void 0:L.call(M);if(k!=null&&k.nodes)for(const F of k.nodes)F.id!=null&&F.x!=null&&F.y!=null&&$.current.set(String(F.id),{x:F.x,y:F.y})},onEngineStop:()=>{var k,M;(M=(k=R.current)==null?void 0:k.zoomToFit)==null||M.call(k,300,72)},linkHoverPrecision:8,enableNodeDrag:!0,enableZoomInteraction:!0,enablePanInteraction:!0,nodePointerAreaPaint:(k,M,L,F)=>{const q=(k.type==="concept"?14:9)/Math.max(F,.35);if(L.fillStyle=M,L.beginPath(),L.arc(k.x,k.y,q,0,2*Math.PI),L.fill(),k.__childCount>0){const X=10/Math.max(F,.4),te=(k.type==="concept"?9:5)/Math.max(F,.35),Q=k.x+te+X*.7,ye=k.y-te*.2;L.beginPath(),L.arc(Q,ye,X,0,2*Math.PI),L.fill()}}}),z&&c.jsx("div",{className:"graph-node-tooltip",style:{left:z.x,top:z.y},children:z.text})]}),_&&c.jsxs("div",{className:"graph-detail-panel",children:[c.jsxs("div",{className:"graph-detail-header",children:[c.jsx("span",{className:`graph-node-type-badge ${_.type}`,children:_.type==="concept"?"概念":"知识要点"}),c.jsx("button",{type:"button",className:"graph-close-btn","aria-label":"关闭",onClick:()=>T(null),children:c.jsx(Et,{size:18,strokeWidth:2.25})})]}),c.jsx("h3",{className:"graph-detail-title",children:_.label}),_.definition&&c.jsxs("div",{className:"graph-detail-section",children:[c.jsx("h4",{children:"定义"}),c.jsx("p",{children:_.definition})]}),c.jsxs("div",{className:"graph-detail-section",children:[c.jsx("h4",{children:"描述"}),c.jsx("p",{children:_.description})]}),c.jsx("div",{className:"graph-detail-meta",children:c.jsxs("span",{children:["置信度: ",(_.confidence*100).toFixed(0),"%"]})}),_.type==="concept"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"graph-detail-section",children:[c.jsxs("h4",{children:["包含的子节点 (",vt(_.id).length,")"]}),c.jsxs("ul",{className:"graph-node-list",children:[vt(_.id).slice(0,20).map(k=>c.jsxs("li",{className:`graph-node-item ${k.type}`,onClick:()=>Ee(k),children:[c.jsx("span",{className:"dot"}),k.label]},k.id)),vt(_.id).length>20&&c.jsxs("li",{className:"muted",children:["还有 ",vt(_.id).length-20," 个..."]})]})]}),c.jsxs("div",{className:"graph-detail-section",children:[c.jsxs("h4",{children:["相关文章 (",In(_.id).length,")"]}),c.jsx("ul",{className:"graph-doc-list",children:Array.from(new Set(In(_.id).flatMap(k=>{var M;return((M=k.sources)==null?void 0:M.map(L=>({documentId:L.documentId,title:L.title||L.documentId,heading:L.heading})))||[]}))).slice(0,10).map((k,M)=>c.jsx("li",{className:"graph-doc-item",children:c.jsxs("button",{onClick:()=>o(k.documentId),children:["📄 ",k.title,k.heading&&c.jsxs("span",{className:"muted",children:[" · ",k.heading]})]})},M))})]})]}),_.type==="doc"&&_.sources&&c.jsxs("div",{className:"graph-detail-section",children:[c.jsx("h4",{children:"来源"}),c.jsx("ul",{className:"graph-doc-list",children:_.sources.map((k,M)=>c.jsx("li",{className:"graph-doc-item",children:c.jsxs("button",{onClick:()=>o(k.documentId),children:["📄 ",k.title||k.documentId,k.heading&&c.jsxs("span",{className:"muted",children:[" · ",k.heading]})]})},M))})]}),Bt(_.id).length>0&&c.jsxs("div",{className:"graph-detail-section",children:[c.jsxs("h4",{children:["所属概念 (",Bt(_.id).length,")"]}),c.jsx("ul",{className:"graph-node-list",children:Bt(_.id).map(k=>c.jsxs("li",{className:`graph-node-item ${k.type}`,onClick:()=>Ee(k),children:[c.jsx("span",{className:"dot"}),k.label]},k.id))})]})]}),we&&c.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:k=>{k.target===k.currentTarget&&le(!1)},children:c.jsxs("div",{className:"mdocs-dialog card",role:"dialog","aria-modal":"true","aria-label":"配置 AI 模型",children:[c.jsx("h2",{children:"配置 AI 模型"}),c.jsx(Wu,{onConfigured:Ut}),c.jsx("div",{className:"mdocs-dialog-actions",children:c.jsx("button",{type:"button",onClick:()=>le(!1),children:"取消"})})]})})]})}async function xi(e){var r;const n=e.replace(/\u00a0/g," ");if(!n)return!1;try{if(typeof navigator<"u"&&((r=navigator.clipboard)!=null&&r.writeText))return await navigator.clipboard.writeText(n),!0}catch{}try{const o=document.createElement("textarea");o.value=n,o.setAttribute("readonly",""),o.style.position="fixed",o.style.top="0",o.style.left="0",o.style.width="1px",o.style.height="1px",o.style.padding="0",o.style.border="none",o.style.outline="none",o.style.boxShadow="none",o.style.background="transparent",o.style.opacity="0",document.body.appendChild(o),o.focus(),o.select(),o.setSelectionRange(0,n.length);const a=document.execCommand("copy");return document.body.removeChild(o),a}catch{return!1}}function Qu(e){var d;const{t:n}=Je(),r=x.useRef(null);x.useEffect(()=>{function h(f){r.current&&!r.current.contains(f.target)&&e.onClose()}function m(f){f.key==="Escape"&&e.onClose()}return window.addEventListener("mousedown",h),window.addEventListener("keydown",m),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",m)}},[e.onClose]);const o=e.node.type==="folder";let a="";if(e.node.type==="folder"){const h=e.node;a=((d=h.folderDisplayName)==null?void 0:d.trim())||h.path||""}const i=o?a?n("newDocIn",{name:a}):n("newDocAtRoot"):n("newDocBeside"),s=o?a?n("newFolderIn",{name:a}):n("newFolderAtRoot"):n("newFolderBeside"),l=e.node.documentId,u=e.node.type==="folder"&&e.node.descDocumentId||e.node.documentId;return c.jsxs("div",{ref:r,className:"mdocs-context-menu card",style:{left:e.x,top:e.y},children:[c.jsx("button",{type:"button",className:"mdocs-context-item",onClick:()=>{const h=o?e.node.path:e.parentPath;e.onCreateChild(h),e.onClose()},children:i}),c.jsx("button",{type:"button",className:"mdocs-context-item",onClick:()=>{const h=o?e.node.path:e.parentPath;e.onCreateFolder(h),e.onClose()},children:s}),c.jsx("div",{className:"mdocs-context-divider"}),c.jsx("button",{type:"button",className:"mdocs-context-item",onClick:()=>{xi(l).finally(e.onClose)},children:n("copyDocumentId")}),c.jsx("button",{type:"button",className:"mdocs-context-item",onClick:()=>{const h="/",m=h.endsWith("/")?h:`${h}/`;xi(`${window.location.origin}${m}#/doc/${u}`).finally(e.onClose)},children:n("copyDocumentUrl")}),c.jsx("div",{className:"mdocs-context-divider"}),c.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"?n("deleteFolder",{name:a||e.node.name}):n("deleteItem",{name:e.node.name})})]})}function ef({domains:e,value:n,onChange:r,ariaLabel:o,localizeName:a,onDomainsChange:i}){const[s,l]=x.useState(!1),[u,d]=x.useState(e),h=x.useRef(null),m=x.useRef(null);x.useEffect(()=>{d(e)},[e]);const f=u.find(b=>b.domainId===n),p=(f==null?void 0:f.permission)==="private";x.useEffect(()=>{if(!s)return;const b=v=>{var I,D;!((I=h.current)!=null&&I.contains(v.target))&&!((D=m.current)!=null&&D.contains(v.target))&&l(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[s]),x.useEffect(()=>{if(!s)return;const b=v=>{var I;v.key==="Escape"&&(l(!1),(I=h.current)==null||I.focus())};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[s]);function g(b){r(b),l(!1)}function w(){if(s){l(!1);return}l(!0),Gr().then(b=>{d(b),i==null||i(b)})}return c.jsxs("div",{className:"mdocs-domain-select-wrapper",children:[c.jsxs("button",{ref:h,type:"button",className:"mdocs-domain-select-trigger","aria-label":o,"aria-expanded":s,"aria-haspopup":"listbox",onClick:w,children:[c.jsx("span",{className:"mdocs-domain-select-text",children:f?a(f.domainName):""}),p&&c.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:[c.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),c.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),c.jsx("svg",{className:"mdocs-domain-select-chevron"+(s?" open":""),width:"10",height:"6",viewBox:"0 0 10 6",fill:"none",stroke:"var(--mdocs-text-muted)",strokeWidth:"1.5",children:c.jsx("path",{d:"M1 1l4 4 4-4"})})]}),s&&c.jsx("div",{ref:m,className:"mdocs-domain-select-menu card",role:"listbox","aria-label":o,children:u.map(b=>c.jsxs("button",{type:"button",className:"mdocs-domain-select-option"+(b.domainId===n?" active":""),role:"option","aria-selected":b.domainId===n,onClick:()=>g(b.domainId),children:[c.jsx("span",{children:a(b.domainName)}),b.permission==="private"&&c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--mdocs-text-muted)",strokeWidth:"2",children:[c.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),c.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})]},b.domainId))})]})}const ba="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",it={left:12,bottom:64},no="mdocs.agentFabPosition",Gn=36,wi=3;function ro(e){const r=Math.max(8,window.innerWidth-Gn-8),o=Math.max(8,window.innerHeight-Gn-8);return{left:Math.min(r,Math.max(8,e.left)),bottom:Math.min(o,Math.max(8,e.bottom))}}function tf(e,n,r,o){const a=e-r,i=n-o,s=window.innerHeight-i-Gn;return ro({left:a,bottom:s})}function nf(){try{const e=localStorage.getItem(no);if(!e)return it;const n=JSON.parse(e);return typeof n.left!="number"||typeof n.bottom!="number"?it:ro({left:n.left,bottom:n.bottom})}catch{return it}}function _i(e){localStorage.setItem(no,JSON.stringify(e))}function rf(e){return e.left===it.left&&e.bottom===it.bottom}function of(e){const r=Math.min(480,window.innerWidth-72);let o=e.left+Gn+8;o+r>window.innerWidth-8&&(o=e.left-8-r),o=Math.max(8,o);const a=Math.max(8,e.bottom-8);return{left:o,bottom:a}}function af(e){const{t:n}=Je(),r=!!e.disableDrag,[o,a]=x.useState(!1),[i,s]=x.useState(e.position),l=x.useRef(null),u=x.useRef(null),d=x.useRef(i),h=x.useRef(e.onPositionChange),m=x.useRef(e.onToggle);d.current=i,h.current=e.onPositionChange,m.current=e.onToggle;const f=x.useRef(null),p=x.useRef(0),g=x.useRef(null);x.useEffect(()=>{f.current||(s(e.position),d.current=e.position)},[e.position]),x.useEffect(()=>{function D(){const N=ro(d.current);N.left===d.current.left&&N.bottom===d.current.bottom||(d.current=N,s(N),h.current(N),_i(N))}return window.addEventListener("resize",D),()=>window.removeEventListener("resize",D)},[]),x.useEffect(()=>{function D(){p.current=0;const T=g.current;if(!T)return;g.current=null,d.current=T,s(T);const C=u.current;C&&(C.style.left=`${T.left}px`,C.style.bottom=`${T.bottom}px`),h.current(T)}function N(T){const C=f.current;if(!C||T.pointerId!==C.pointerId)return;T.preventDefault();const P=T.clientX-C.startX,z=T.clientY-C.startY;!C.didMove&&P*P+z*z>=wi*wi&&(C.didMove=!0,a(!0)),C.didMove&&(g.current=tf(T.clientX,T.clientY,C.offsetX,C.offsetY),p.current||(p.current=requestAnimationFrame(D)))}function _(T){var P;const C=f.current;if(!(!C||T.pointerId!==C.pointerId)){f.current=null,a(!1),p.current&&(cancelAnimationFrame(p.current),p.current=0),g.current&&(d.current=g.current,s(g.current),g.current=null);try{(P=l.current)==null||P.releasePointerCapture(T.pointerId)}catch{}if(C.didMove){const z=d.current;h.current(z),_i(z);return}m.current()}}return window.addEventListener("pointermove",N,{passive:!1}),window.addEventListener("pointerup",_),window.addEventListener("pointercancel",_),()=>{window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",_),window.removeEventListener("pointercancel",_),p.current&&cancelAnimationFrame(p.current)}},[]);function w(D){if(D.button!==0)return;if(r){D.preventDefault(),e.onToggle();return}D.preventDefault();const N=D.currentTarget.getBoundingClientRect();f.current={pointerId:D.pointerId,offsetX:D.clientX-N.left,offsetY:D.clientY-N.top,startX:D.clientX,startY:D.clientY,didMove:!1},D.currentTarget.setPointerCapture(D.pointerId)}function b(){d.current=it,s(it),e.onPositionChange(it),localStorage.removeItem(no)}const v=r?it:i,I=!r&&!rf(i);return c.jsxs("div",{ref:u,className:"mdocs-agent-fab-wrap"+(o?" dragging":""),style:{left:v.left,bottom:v.bottom},children:[c.jsx("button",{ref:l,type:"button",className:"mdocs-agent-fab"+(e.open?" open":"")+(o?" dragging":"")+(r?" mdocs-agent-fab--nodrag":""),"aria-label":n("agentFabOpen"),"aria-expanded":e.open,onPointerDown:w,children:c.jsx("img",{src:ba,alt:"",draggable:!1})}),I&&c.jsx("button",{type:"button",className:"mdocs-agent-fab-reset",onClick:b,"aria-label":n("agentFabReset"),children:n("agentFabReset")})]})}function sf(){const[e,n]=x.useState(()=>typeof window>"u"?it:nf());return[e,n]}function lf({title:e,message:n,onClose:r}){const{t:o}=Je();return c.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:a=>{a.target===a.currentTarget&&r()},children:c.jsxs("div",{className:"mdocs-dialog card mdocs-message-dialog",role:"alertdialog","aria-modal":"true",children:[e&&c.jsx("h2",{className:"mdocs-message-dialog-title",children:e}),c.jsx("p",{className:"mdocs-message-dialog-body",children:n}),c.jsx("div",{className:"mdocs-message-dialog-actions",children:c.jsx("button",{type:"button",className:"primary",onClick:r,children:o("gotIt")})})]})})}function xa({title:e,message:n,confirmLabel:r="确定",cancelLabel:o="取消",onConfirm:a,onCancel:i,busy:s=!1,danger:l=!1}){return c.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:u=>{u.target===u.currentTarget&&!s&&i()},children:c.jsxs("div",{className:"mdocs-dialog card mdocs-message-dialog",role:"alertdialog","aria-modal":"true",children:[e&&c.jsx("h2",{className:"mdocs-message-dialog-title",children:e}),c.jsx("p",{className:"mdocs-message-dialog-body",children:n}),c.jsxs("div",{className:"mdocs-message-dialog-actions",style:{gap:8},children:[c.jsx("button",{type:"button",onClick:i,disabled:s,children:o}),c.jsx("button",{type:"button",className:l?"danger":"primary",onClick:a,disabled:s,children:s?"…":r})]})]})})}const ki={"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"},wa={"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 qe(e,n){if(n instanceof Ye)return n.message;if(n instanceof kt){const r=ki[n.message];return r?e(r):n.message}if(n instanceof Error){const r=ki[n.message]??wa[n.message];return r?e(r):n.message}return String(n)}function On(e,n,r){if(e==="Default")return r("defaultDomain");const o="个人域";return e.endsWith(o)?e.slice(0,-o.length)+r("personalDomainSuffix"):e}function Ym(e,n){return e==="public"?n("domainPublic"):e==="restricted"?n("domainRestricted"):e==="private"?n("domainPrivate"):e}function jn(e){const n=e.lastIndexOf("/");return n===-1?"":e.slice(0,n)}const cf=280,Xt="";function df(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function gr(e,n){const r=Array.from(new Set(n.filter(u=>u.length>0))).sort((u,d)=>d.length-u.length);if(r.length===0)return e;const o=new RegExp(r.map(df).join("|"),"gi"),a=[];let i=0,s,l=0;for(;(s=o.exec(e))!==null;)s.index>i&&a.push(e.slice(i,s.index)),a.push(c.jsx("mark",{children:s[0]},l++)),i=s.index+s[0].length,s[0].length===0&&o.lastIndex++;return i<e.length&&a.push(e.slice(i)),a}function uf(e,n){const r=new Date(e);return Number.isNaN(r.getTime())?"":r.toLocaleString(n==="zh"?"zh-CN":"en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function ff(e){const{t:n,lang:r}=Je(),o=x.useRef(null),a=x.useRef(null),[i,s]=x.useState(""),[l,u]=x.useState(Xt),[d,h]=x.useState("auto"),[m,f]=x.useState(!0),[p,g]=x.useState(!1),[w,b]=x.useState(""),[v,I]=x.useState(e.domains),[D,N]=x.useState([]),[_,T]=x.useState([]),[C,P]=x.useState(!1),[z,E]=x.useState(null),R=x.useRef(0);x.useEffect(()=>{I(e.domains)},[e.domains]);const $=x.useMemo(()=>{const B=new Map;for(const G of v)B.set(G.domainId,On(G.domainName,r,n));return B},[v,r,n]),H=x.useMemo(()=>{const B=w.trim().toLowerCase();return B?v.filter(G=>On(G.domainName,r,n).toLowerCase().includes(B)||G.domainName.toLowerCase().includes(B)||G.domainId.toLowerCase().includes(B)):v},[v,w,r,n]),J=l===Xt?n("docSearchAllDomains"):$.get(l)??n("docSearchAllDomains");function ne(){Gr().then(B=>{var G;I(B),(G=e.onDomainsChange)==null||G.call(e,B)})}return x.useEffect(()=>{if(!e.open)return;s(""),u(Xt),g(!1),b(""),N([]),E(null),P(!1),ne();const B=window.setTimeout(()=>{var G;return(G=o.current)==null?void 0:G.focus()},0);return()=>window.clearTimeout(B)},[e.open]),x.useEffect(()=>{if(!e.open)return;const B=G=>{if(G.key==="Escape"){if(G.preventDefault(),p){g(!1);return}e.onClose()}};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[e.open,e.onClose,p]),x.useEffect(()=>{if(!p)return;const B=G=>{var se;(se=a.current)!=null&&se.contains(G.target)||g(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[p]),x.useEffect(()=>{if(!e.open)return;const B=i.trim();if(!B){N([]),P(!1),E(null);return}P(!0),E(null);const G=++R.current,se=window.setTimeout(()=>{gl({query:B,mode:d,domainId:l||void 0,topN:20}).then(ue=>{G===R.current&&(N(ue.results),f(ue.modelReady),T(ue.tokens??[]),P(!1))}).catch(ue=>{G===R.current&&(N([]),f(!0),T([]),P(!1),E(qe(n,ue)||n("docSearchFailed")))})},cf);return()=>window.clearTimeout(se)},[i,e.open,l,d,n]),e.open?c.jsx("div",{className:"mdocs-doc-search-backdrop",role:"presentation",onMouseDown:B=>{B.target===B.currentTarget&&e.onClose()},children:c.jsxs("div",{className:"mdocs-doc-search-panel",role:"dialog","aria-modal":"true","aria-label":n("docSearchTitle"),children:[c.jsxs("div",{className:"mdocs-doc-search-bar",children:[c.jsx(Ti,{size:18,strokeWidth:1.75,"aria-hidden":!0}),c.jsx("input",{ref:o,className:"mdocs-doc-search-input",type:"search",value:i,placeholder:n("docSearchPlaceholder"),"aria-label":n("docSearchPlaceholder"),onChange:B=>s(B.target.value)}),c.jsxs("select",{className:"mdocs-doc-search-mode",value:d,"aria-label":n("myDocumentsSearchMode"),onChange:B=>h(B.target.value),children:[c.jsx("option",{value:"auto",children:n("myDocumentsModeAuto")}),c.jsx("option",{value:"keyword",children:n("myDocumentsModeKeyword")}),c.jsx("option",{value:"semantic",children:n("myDocumentsModeSemantic")})]}),c.jsxs("div",{className:"mdocs-doc-search-domain",ref:a,children:[c.jsxs("button",{type:"button",className:"mdocs-doc-search-domain-trigger","aria-label":n("docSearchDomainAria"),"aria-expanded":p,"aria-haspopup":"listbox",onClick:()=>{if(p){g(!1);return}g(!0),b(""),ne()},children:[c.jsx("span",{className:"mdocs-doc-search-domain-label",children:J}),c.jsx(Cr,{size:14,strokeWidth:1.75})]}),p&&c.jsxs("div",{className:"mdocs-doc-search-domain-menu",role:"listbox","aria-label":n("docSearchDomainAria"),children:[c.jsx("input",{className:"mdocs-doc-search-domain-filter",type:"search",value:w,placeholder:n("docSearchDomainFilter"),"aria-label":n("docSearchDomainFilter"),autoFocus:!0,onChange:B=>b(B.target.value),onClick:B=>B.stopPropagation()}),c.jsx("button",{type:"button",className:"mdocs-doc-search-domain-option"+(l===Xt?" active":""),role:"option","aria-selected":l===Xt,onClick:()=>{u(Xt),g(!1)},children:c.jsx("span",{className:"mdocs-doc-search-domain-option-name",children:n("docSearchAllDomains")})}),H.map(B=>{const G=On(B.domainName,r,n),se=B.permission==="private";return c.jsxs("button",{type:"button",className:"mdocs-doc-search-domain-option"+(B.domainId===l?" active":""),role:"option","aria-selected":B.domainId===l,onClick:()=>{u(B.domainId),g(!1)},children:[c.jsx("span",{className:"mdocs-doc-search-domain-option-name",children:G}),se?c.jsx("span",{className:"mdocs-doc-search-domain-option-tag","aria-hidden":!0,children:c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[c.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),c.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}):null]},B.domainId)}),H.length===0&&c.jsx("p",{className:"mdocs-doc-search-domain-empty",children:n("docSearchDomainNoMatch")})]})]}),c.jsx("button",{type:"button",className:"mdocs-doc-search-close","aria-label":n("close"),onClick:e.onClose,children:c.jsx(Et,{size:16,strokeWidth:1.75})})]}),c.jsxs("div",{className:"mdocs-doc-search-results",children:[!i.trim()&&c.jsx("p",{className:"mdocs-doc-search-hint",children:n("docSearchEmptyHint")}),C&&c.jsx("p",{className:"mdocs-doc-search-hint",children:n("loading")}),z&&c.jsx("p",{className:"mdocs-doc-search-error",children:z}),!C&&!z&&i.trim()&&D.length===0&&c.jsx("p",{className:"mdocs-doc-search-hint",children:n(d==="semantic"&&!m?"myDocumentsSemanticNotReady":"docSearchNoResults")}),D.map(B=>{var re;const G=uf(B.updatedAt,r),ue=[$.get(B.domainId),(re=B.ownerVisitorName)==null?void 0:re.trim(),G].filter(Boolean),j=[];return B.titleHit&&j.push(n("docSearchHitTitle")),B.bodyHit&&j.push(n("docSearchHitBody")),B.semanticHit&&j.push(n("docSearchHitSemantic")),c.jsxs("button",{type:"button",className:"mdocs-doc-search-row",onClick:()=>{e.onOpenDocument(B.documentId),e.onClose()},children:[c.jsxs("span",{className:"mdocs-doc-search-row-head",children:[c.jsx("span",{className:"mdocs-doc-search-row-title",children:gr(B.displayName,_)}),j.length>0&&c.jsx("span",{className:"mdocs-doc-search-row-sources",children:j.map(oe=>c.jsx("span",{className:"mdocs-doc-search-row-source",children:oe},oe))})]}),ue.length>0&&c.jsx("span",{className:"mdocs-doc-search-row-meta",children:ue.join(" · ")}),B.relativePath&&c.jsx("span",{className:"mdocs-doc-search-row-path",children:gr(B.relativePath,_)}),B.snippet&&c.jsx("span",{className:"mdocs-doc-search-row-snippet",children:gr(B.snippet,_)})]},B.documentId)})]})]})}):null}function mf(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 yr(e,n){const r=e.trim(),o=n.trim();return o?r?`${r}/${o}`:o:r}function _a(e,n=new Set){for(const r of e)r.type==="document"?n.add(r.path):(r.descDocumentId&&n.add(Zs(r.path)),_a(r.children,n));return n}function Rn(e,n){for(const r of e){if(r.type==="folder"&&r.path===n)return r.documentId;if(r.type==="folder"){const o=Rn(r.children,n);if(o)return o}}return null}function vr(e,n){const r=wa[n];return r?e(r):n}function hf(e){const{tree:n,currentDomainId:r,selectedCreateParentPath:o,t:a,onDocCreated:i,refreshTree:s}=e,[l,u]=x.useState(null),[d,h]=x.useState(null),[m,f]=x.useState(!1),p=x.useRef(null);x.useEffect(()=>{if(!l)return;const v=window.setTimeout(()=>{var I;return(I=p.current)==null?void 0:I.focus()},0);return()=>window.clearTimeout(v)},[l]);function g(v,I="md"){const D=v!==void 0;h(null),u({kind:"document",parentMode:D?"fixed":"selection",parentPath:D?v:"",draft:I==="html"?"untitled.html":"untitled.md",fileType:I})}function w(v){const I=v!==void 0;h(null),u({kind:"folder",parentMode:I?"fixed":"selection",parentPath:I?v:"",draft:""})}async function b(v){if(v.preventDefault(),!l)return;f(!0),h(null);const I=_a(n),D=l.parentMode==="selection"?o:l.parentPath;try{if(l.kind==="document"){if(l.fileType==="html"){const ne=Ao(l.draft);if(!ne.ok){h(vr(a,ne.message));return}const B=ne.displayFile,G=B.replace(/\.html$/i,"").replace(/\.md$/i,"");let se;try{se=jo(yr(D,B))}catch(re){h(qe(a,re));return}if(I.has(se)){h(a("pathExists"));return}const ue=D?Rn(n,D)??void 0:void 0,j=await Pr({fileName:B,displayName:G,content:"",domainId:r,parentId:ue,fileType:"html"});await s(),i(j),u(null);return}const z=Ao(l.draft);if(!z.ok){h(vr(a,z.message));return}const E=z.displayFile,R=E.replace(/\.md$/i,"");let $;try{$=jo(yr(D,E))}catch(ne){h(qe(a,ne));return}if(I.has($)){h(a("pathExists"));return}const H=D?Rn(n,D)??void 0:void 0,J=await Pr({fileName:E,displayName:R,content:mf(R),domainId:r,parentId:H});await s(),i(J),u(null);return}const N=tl(l.draft);if(!N.ok){h(vr(a,N.message));return}const _=Dr(N.display);if(!_){h(a("invalidFolderName"));return}const T=yr(D,_);if(I.has(T)){h(a("folderExists"));return}const C=D?Rn(n,D)??void 0:void 0;await hl({name:_,parentId:C,domainId:r}),await s(),u(null)}catch(N){h(qe(a,N))}finally{f(!1)}}return{createModal:l,setCreateModal:u,createModalError:d,createModalBusy:m,createModalInputRef:p,openNewDocumentModal:g,openNewFolderModal:w,submitCreateModal:b}}const Ii="(max-width: 768px)";function pf(){const[e,n]=x.useState(()=>typeof window<"u"?window.matchMedia(Ii).matches:!1);return x.useEffect(()=>{const r=window.matchMedia(Ii),o=()=>n(r.matches);return o(),r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[]),e}function gf({open:e,onClose:n,onResolve:r,onForceOverwrite:o,forceBusy:a}){const{t:i}=Je();return e?c.jsx("div",{className:"mdocs-conflict-modal-root",role:"alertdialog","aria-modal":"true",children:c.jsxs("div",{className:"mdocs-conflict-modal-panel",children:[c.jsx("h2",{className:"mdocs-conflict-modal-title",children:i("conflictTitle")}),c.jsx("p",{className:"mdocs-conflict-modal-body",children:i("conflictBody")}),o?c.jsx("p",{className:"mdocs-conflict-modal-force-hint",children:i("conflictForceHint")}):null,c.jsxs("div",{className:"mdocs-conflict-modal-actions",children:[c.jsx("button",{type:"button",className:"primary",onClick:r,disabled:a,children:i("conflictResolve")}),o?c.jsx("button",{type:"button",className:"mdocs-conflict-force-btn",disabled:a,onClick:o,children:i(a?"conflictForceBusy":"conflictForce")}):null,c.jsx("button",{type:"button",className:"secondary",onClick:n,disabled:a,children:i("conflictClose")})]})]})}):null}function Si({documentId:e,visitorId:n,visitorName:r,documentOwnerId:o,onClose:a}){const[i,s]=x.useState([]),[l,u]=x.useState(""),[d,h]=x.useState(null),[m,f]=x.useState(!0),[p,g]=x.useState(!1),[w,b]=x.useState(null),[v,I]=x.useState(null),[D,N]=x.useState(360),[_,T]=x.useState(80),C=x.useRef(!1),P=x.useRef(!1),z=300,E=80,R=x.useRef(null);function $(){const K=R.current;if(!K)return;K.style.height="auto";const Z=K.scrollHeight,we=Math.min(Math.max(Z,E),z);K.style.height=`${we}px`,T(we)}x.useEffect(()=>{setTimeout(()=>$(),0)},[d]);function H(K){return n?K.visitorId===n||o===n:!1}const{rootComments:J,repliesByParentId:ne,totalCount:B}=x.useMemo(()=>{const K=[],Z=new Map;let we=0;for(const le of i)le.isDeleted||(we++,le.parentId?(Z.has(le.parentId)||Z.set(le.parentId,[]),Z.get(le.parentId).push(le)):K.push(le));return{rootComments:K,repliesByParentId:Z,totalCount:we}},[i]),G=x.useRef(e);x.useEffect(()=>{G.current=e,u(""),h(null),I(null),se()},[e]);async function se(){const K=G.current;f(!0);try{const Z=await bl(e);if(G.current!==K)return;s(Z.comments)}catch(Z){if(G.current!==K)return;I("加载评论失败"),console.error("Failed to load comments:",Z)}finally{G.current===K&&f(!1)}}async function ue(){var K;if(!(!l.trim()||!n)){g(!0),I(null);try{await xl(e,{content:l,parentId:(d==null?void 0:d.commentId)||null,replyToVisitorId:d?((K=i.find(Z=>Z.commentId===d.commentId))==null?void 0:K.visitorId)??null:null,replyToVisitorName:(d==null?void 0:d.visitorName)||null}),u(""),h(null),setTimeout(()=>$(),0),await se()}catch(Z){I(Z.message||"发表失败,请重试")}finally{g(!1)}}}async function j(K){I(null);try{await wl(e,K),await se()}catch(Z){I(Z.message||"删除失败,请重试")}finally{b(null)}}function re(K){const Z=Date.now()-new Date(K).getTime(),we=Math.floor(Z/6e4),le=Math.floor(Z/36e5),Xe=Math.floor(Z/864e5);return we<1?"刚刚":we<60?`${we}分钟前`:le<24?`${le}小时前`:`${Xe}天前`}function oe(K){C.current=!0,K.preventDefault()}function ie(K){P.current=!0,K.preventDefault(),document.body.style.userSelect="none",document.body.style.cursor="row-resize"}return x.useEffect(()=>{function K(we){if(C.current){const le=Math.max(280,Math.min(600,window.innerWidth-we.clientX));N(le)}if(P.current){const le=-we.movementY;T(Xe=>Math.max(60,Math.min(600,Xe+le)))}}function Z(){C.current=!1,P.current=!1,document.body.style.userSelect="",document.body.style.cursor=""}return window.addEventListener("mousemove",K),window.addEventListener("mouseup",Z),()=>{window.removeEventListener("mousemove",K),window.removeEventListener("mouseup",Z)}},[]),c.jsxs("div",{className:"mdocs-comments-panel",style:{width:D},children:[c.jsx("div",{className:"mdocs-comments-resize-handle",onMouseDown:oe}),c.jsxs("div",{className:"mdocs-comments-header",children:[c.jsxs("h3",{style:{margin:0,fontSize:"1rem",display:"flex",alignItems:"center",gap:6},children:[c.jsx(Os,{size:18}),"评论 (",B,")"]}),c.jsx("button",{type:"button",onClick:a,className:"mdocs-comments-close-btn",children:c.jsx(Et,{size:18})})]}),v&&c.jsxs("div",{className:"mdocs-comments-error",children:[v,c.jsx("button",{type:"button",onClick:()=>I(null),children:c.jsx(Et,{size:14})})]}),c.jsx("div",{className:"mdocs-comments-list",children:m?c.jsx("div",{className:"mdocs-comments-empty",children:"加载中..."}):J.length===0?c.jsx("div",{className:"mdocs-comments-empty",children:"暂无评论,来发表第一条吧~"}):J.map(K=>c.jsxs("div",{className:"mdocs-comment-root",children:[c.jsxs("div",{className:"mdocs-comment-header",children:[c.jsx("span",{className:"mdocs-comment-avatar",children:K.visitorName.charAt(0).toUpperCase()}),c.jsx("span",{className:"mdocs-comment-author",children:K.visitorName}),c.jsx("span",{className:"mdocs-comment-time",children:re(K.createdAt)}),H(K)&&c.jsx("button",{type:"button",className:"mdocs-comment-delete",onClick:()=>b(K.commentId),title:"删除",children:c.jsx(Et,{size:14})})]}),c.jsx("div",{className:"mdocs-comment-content",children:K.content}),n&&c.jsx("button",{type:"button",className:"mdocs-comment-reply-btn",onClick:()=>h({commentId:K.commentId,visitorName:K.visitorName}),children:"回复"}),(ne.get(K.commentId)??[]).length>0&&c.jsx("div",{className:"mdocs-comment-replies",children:(ne.get(K.commentId)??[]).map(Z=>c.jsxs("div",{className:"mdocs-comment-reply",children:[c.jsxs("div",{className:"mdocs-comment-header",children:[c.jsx("span",{className:"mdocs-comment-avatar mdocs-comment-avatar-small",children:Z.visitorName.charAt(0).toUpperCase()}),c.jsx("span",{className:"mdocs-comment-author",children:Z.visitorName}),Z.replyToVisitorName&&c.jsxs("span",{className:"mdocs-comment-reply-to",children:["回复 ",Z.replyToVisitorName]}),c.jsx("span",{className:"mdocs-comment-time",children:re(Z.createdAt)}),H(Z)&&c.jsx("button",{type:"button",className:"mdocs-comment-delete",onClick:()=>b(Z.commentId),title:"删除",children:c.jsx(Et,{size:12})})]}),c.jsx("div",{className:"mdocs-comment-content",children:Z.content}),n&&c.jsx("button",{type:"button",className:"mdocs-comment-reply-btn",onClick:()=>h({commentId:K.commentId,visitorName:Z.visitorName}),children:"回复"})]},Z.commentId))})]},K.commentId))}),n?c.jsxs("div",{className:"mdocs-comments-input-wrapper",children:[c.jsx("div",{className:"mdocs-comments-input-drag-handle",onMouseDown:ie}),d&&c.jsxs("div",{className:"mdocs-comment-reply-notice",children:[c.jsxs("span",{children:["回复 ",c.jsx("span",{className:"mdocs-comment-reply-to-name",children:d.visitorName})]}),c.jsxs("button",{type:"button",onClick:()=>h(null),children:[c.jsx(Et,{size:14})," 取消"]})]}),c.jsx("textarea",{ref:R,value:l,onChange:K=>{u(K.target.value.slice(0,512)),setTimeout(()=>$(),0)},placeholder:d?`回复 ${d.visitorName}...`:"发表评论...",className:"mdocs-comments-input",style:{height:_},maxLength:512,onKeyDown:K=>{K.key==="Enter"&&(K.metaKey||K.ctrlKey)&&ue()}}),c.jsxs("div",{className:`mdocs-comments-char-count${l.length>=460?" mdocs-char-count--warn":""}`,children:[l.length,"/512"]}),c.jsx("div",{className:"mdocs-comments-input-actions",children:c.jsx("button",{type:"button",className:"mdocs-btn-primary",onClick:ue,disabled:p||!l.trim(),children:p?"发表中...":"发表"})})]}):c.jsx("div",{className:"mdocs-comments-input-wrapper",style:{textAlign:"center"},children:c.jsx("div",{style:{color:"#666",fontSize:"0.9rem"},children:"请先创建访客身份以发表评论"})}),w&&c.jsx(xa,{title:"删除评论",message:"确定要删除这条评论吗?",confirmLabel:"删除",danger:!0,onConfirm:()=>j(w),onCancel:()=>b(null)})]})}const yf="mdocs-drafts",vf=5,Ae="drafts";let ka=0;const Br=new Set;function Jm(e){return Br.add(e),()=>{Br.delete(e)}}function Xm(){return ka}function Ia(e,n){ka+=1;for(const r of Br)r(e,n)}const Zt={DOC_NOT_FOUND:"DOC_NOT_FOUND",SYNC_HEAD_MISSING:"SYNC_HEAD_MISSING"};let br=null;function Qt(){return br||(br=new Promise((e,n)=>{const r=indexedDB.open(yf,vf);r.onupgradeneeded=o=>{const a=r.result;a.objectStoreNames.contains(Ae)||a.createObjectStore(Ae,{keyPath:"documentId"});const i=o.oldVersion;if(i>0&&i<4){const u=r.transaction.objectStore(Ae).openCursor();u.onsuccess=()=>{const d=u.result;if(!d)return;const h=d.value;typeof h.baseCommitId=="string"&&!h.localBaseCommitId&&(h.localBaseCommitId=h.baseCommitId,delete h.baseCommitId);const m=h.conflict;m&&(typeof m.baseCommitId=="string"&&!m.localBaseCommitId&&(m.localBaseCommitId=m.baseCommitId,delete m.baseCommitId),typeof m.expectedHeadCommitId=="string"&&!m.remoteCommitId&&(m.remoteCommitId=m.expectedHeadCommitId,delete m.expectedHeadCommitId)),d.update(h),d.continue()}}if(i>0&&i<5){const u=r.transaction.objectStore(Ae).openCursor();u.onsuccess=()=>{const d=u.result;if(!d)return;const h=d.value;h.contentKind==null&&(h.contentKind="lexical",d.update(h)),d.continue()}}},r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)})),br}async function bf(e){var o;const n=await Oe(e.documentId),r={documentId:e.documentId,content:e.content,contentKind:e.contentKind??(n==null?void 0:n.contentKind)??"lexical",displayName:e.displayName,updatedAt:Date.now(),published:!1};if(n!=null&&n.localBaseCommitId)r.localBaseCommitId=n.localBaseCommitId;else{const a=(o=e.localBaseCommitIdAtEditStart)==null?void 0:o.trim();a&&(r.localBaseCommitId=a)}(n==null?void 0:n.permission)!=null?r.permission=n.permission:e.snapshotMeta&&(r.permission=e.snapshotMeta.permission),n!=null&&n.ownerVisitorId?r.ownerVisitorId=n.ownerVisitorId:e.snapshotMeta&&(r.ownerVisitorId=e.snapshotMeta.ownerVisitorId),n!=null&&n.domainId?r.domainId=n.domainId:e.snapshotMeta&&(r.domainId=e.snapshotMeta.domainId),n!=null&&n.publishError&&(r.publishError=n.publishError,r.publishErrorAt=n.publishErrorAt),n!=null&&n.conflictStatus&&(r.conflictStatus=n.conflictStatus),n!=null&&n.conflict&&(r.conflict=n.conflict),await Ot(r)}function oo(e){const n={documentId:e.documentId,content:e.content,displayName:e.displayName,updatedAt:e.updatedAt,published:e.published};return e.permission!=null&&(n.permission=e.permission),e.ownerVisitorId&&(n.ownerVisitorId=e.ownerVisitorId),e.domainId&&(n.domainId=e.domainId),e.publishError!=null&&(n.publishError=e.publishError),e.publishErrorAt!=null&&(n.publishErrorAt=e.publishErrorAt),e.localBaseCommitId&&(n.localBaseCommitId=e.localBaseCommitId),e.conflictStatus!=null&&(n.conflictStatus=e.conflictStatus),e.conflict!=null&&(n.conflict=e.conflict),n}async function Ot(e){const n=await Qt(),r=oo(e);return new Promise((o,a)=>{const i=n.transaction(Ae,"readwrite");i.objectStore(Ae).put(r),i.oncomplete=()=>{Ia(r.documentId,!r.published),o()},i.onerror=()=>a(i.error)})}async function Oe(e){const n=await Qt();return new Promise((r,o)=>{const i=n.transaction(Ae,"readonly").objectStore(Ae).get(e);i.onsuccess=()=>r(i.result),i.onerror=()=>o(i.error)})}async function xr(e){const n=await Qt();return new Promise((r,o)=>{const a=n.transaction(Ae,"readwrite");a.objectStore(Ae).delete(e),a.oncomplete=()=>{Ia(e,!1),r()},a.onerror=()=>o(a.error)})}async function xf(e){const n=await Qt();return new Promise((r,o)=>{const i=n.transaction(Ae,"readonly").objectStore(Ae).getAll();i.onsuccess=()=>{let s=i.result;e!=null&&e.skipFailed&&(s=s.filter(l=>!l.publishError)),r(s)},i.onerror=()=>o(i.error)})}async function wf(e,n){const r=await Qt();return new Promise((o,a)=>{const s=r.transaction(Ae,"readwrite").objectStore(Ae),l=s.get(e);l.onsuccess=()=>{const u=l.result;u&&s.put(oo({...u,publishError:n,publishErrorAt:Date.now()})),o()},l.onerror=()=>a(l.error)})}async function wr(e){const n=await Qt();return new Promise((r,o)=>{const i=n.transaction(Ae,"readwrite").objectStore(Ae),s=i.get(e);s.onsuccess=()=>{const l=s.result;l&&i.put(oo({...l,publishError:void 0,publishErrorAt:void 0})),r()},s.onerror=()=>o(s.error)})}async function _r(e,n){const r=await Oe(e);r&&await Ot({...r,localBaseCommitId:n.localBaseCommitId,conflictStatus:n.conflictStatus,conflict:n.conflict})}async function kr(e){const n=await Oe(e);n&&await Ot({...n,conflict:void 0,conflictStatus:"none"})}class bn extends Error{constructor(r,o){super(r);qt(this,"code");qt(this,"cause");this.name="DraftPublishAborted",this.code=r,this.cause=o==null?void 0:o.cause}}function _f(e){return e instanceof bn?e.code:e instanceof Ye?e.status===404?Zt.DOC_NOT_FOUND:e.code||`HTTP_${e.status}`:e instanceof Error&&e.message.trim()?e.message.trim().slice(0,120):"UNKNOWN"}function kf(e,n,r,o){const a=(n==null?void 0:n.displayName)||e("unknownTitle");if(r===Zt.SYNC_HEAD_MISSING)return e("draftPublishFailedSyncHead",{name:a});if(r===Zt.DOC_NOT_FOUND)return e("draftPublishFailedNotice",{name:a});const i=o instanceof Ye||o instanceof Error&&o.message?o.message:r;return e("draftPublishFailedGeneric",{name:a,reason:i})}async function If(e,n,r){const o=_f(n);throw await wf(e,o),n instanceof bn?n:new bn(o,{cause:n})}function Sf(e,n){const r=x.useRef(n);r.current=n,x.useEffect(()=>{if(!e)return;const o=3e4,a=1e4,i=async()=>{const l=await xf({skipFailed:!0}),u=Date.now();for(const d of l)if(!d.published&&!(u-d.updatedAt<o))try{await r.current(d.documentId)}catch(h){console.log("[autoPublish] scan publish failed:",h)}};i();const s=setInterval(i,a);return()=>clearInterval(s)},[e])}const Cf=1e4;function Df(e,n){const[r,o]=x.useState(null),[a,i]=x.useState("up_to_date");return x.useEffect(()=>{if(!e){o(null),i("up_to_date");return}let l=!1;const u=e;async function d(){try{const m=await ul(u,n??void 0);if(l)return;o(m.headCommitId),i(m.status)}catch{}}d();const h=window.setInterval(()=>void d(),Cf);return()=>{l=!0,window.clearInterval(h)}},[e,n]),{remoteCommitId:r,syncStatus:a,syncBehind:!!(n&&r&&n!==r)||a==="behind"}}function Ci(e){return e.trim()}function Nf(e){return e.trim()}const Pf=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".ico",".bmp",".jfif",".pjpeg"]);function Tf(e){const n=e.split("/").pop()??"",r=n.lastIndexOf(".");return r<=0?"":n.slice(r).toLowerCase()}function Af(e,n,r){let o,a;try{o=new URL(r),a=new URL(e,r)}catch{return null}if(a.origin!==o.origin||!a.pathname.startsWith("/api/assets/")||Pf.has(Tf(a.pathname)))return null;const i=n==null?void 0:n.trim();return i&&!a.searchParams.has("name")&&a.searchParams.set("name",i),a.toString()}function jf(){const e=n=>{if(n.button!==0)return;const o=n.composedPath().find(i=>i instanceof HTMLAnchorElement);if(!o)return;const a=Af(o.href,o.getAttribute("download"),window.location.href);a&&(n.preventDefault(),n.stopPropagation(),window.location.assign(a))};return document.addEventListener("click",e,!0),()=>document.removeEventListener("click",e,!0)}const Ge={DOCUMENT:"md",HTML:"html",FOLDER:"dir",FOLDER_DESC:"folder_desc",GRAPH_FILE:"graph_file",GRAPH_DIR:"graph_dir"},Mf="/assets/mdocs-logo-Dsv_2t6v.svg",Ef=x.lazy(()=>zt(()=>import("./DocumentEditor-DYSRZnJa.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(e=>({default:e.DocumentEditor}))),Of=x.lazy(()=>zt(()=>import("./HtmlEditor-oDPrhq3o.js"),__vite__mapDeps([14,1,11,12,13,2,3,6,15])).then(e=>({default:e.HtmlEditor}))),Rf=x.lazy(()=>zt(()=>import("./SettingsPage-C_RMO-5M.js"),__vite__mapDeps([16,1,13,8,2,3,6])).then(e=>({default:e.SettingsPage}))),Ff=x.lazy(()=>zt(()=>import("./AgentChatPanel-BZlAgyrV.js"),__vite__mapDeps([17,1,18,8,9,7,2,3,6])).then(e=>({default:e.AgentChatPanel}))),Lf=x.lazy(()=>zt(()=>import("./AiWriteWorkbench-DiSDDAee.js"),__vite__mapDeps([19,1,18,7,2,3,6])).then(e=>({default:e.AiWriteWorkbench}))),zf=x.lazy(()=>zt(()=>import("./MergeView-CbFSN3Bi.js"),__vite__mapDeps([20,1,4,5,2,3,6,7,8,9,12])).then(e=>({default:e.MergeView})));function $f(e,n){try{const r=new Intl.RelativeTimeFormat(n,{numeric:"auto"}),o=Date.now()-new Date(e).getTime(),a=Math.floor(o/6e4),i=Math.floor(a/60),s=Math.floor(i/24);return s>30?r.format(-Math.floor(s/30),"month"):s>0?r.format(-s,"day"):i>0?r.format(-i,"hour"):a>0?r.format(-a,"minute"):r.format(-Math.floor(o/1e3),"second")}catch{return e.slice(0,10)}}async function Ir(e,n,r,o){const a=await Gr();n(a);const i=localStorage.getItem("mdocs.currentDomainId"),l=i&&a.some(u=>u.domainId===i)?i:Cl(a,e);r(l),await o(l)}function Di(){const{t:e,lang:n,setLang:r}=Je(),[o,a]=x.useState("loading"),[i,s]=x.useState(()=>localStorage.getItem("mdocs.sidebarCollapsed")==="true"),l=pf(),[u,d]=x.useState(!1),h=()=>{if(l){d(O=>!O);return}const y=!i;s(y),localStorage.setItem("mdocs.sidebarCollapsed",String(y))};x.useEffect(()=>{l||d(!1)},[l]),x.useEffect(()=>jf(),[]);const[m,f]=x.useState(!1),[p,g]=x.useState(0),w=x.useRef(null),[b,v]=x.useState(null),[I,D]=x.useState(null),[N,_]=x.useState(null),[T,C]=x.useState([]),[P,z]=x.useState([]),[E,R]=x.useState("default"),[$,H]=x.useState(!1),J=x.useRef(null),{documentId:ne}=Ha(),B=Va(),[G,se]=x.useState(null),ue=(G==null?void 0:G.kind)==="document"?G.documentId:null,[j,re]=x.useState(null),[oe,ie]=x.useState(null),K=x.useRef(oe);K.current=oe;const[Z,we]=x.useState(0),[le,Xe]=x.useState(null),[Ct,gt]=x.useState(!1),[en,$t]=x.useState(!1),[Dt,Ze]=x.useState(!1),[ke,Qe]=x.useState(!1),wn=(j==null?void 0:j.documentId)??null,{syncBehind:et,remoteCommitId:Nt}=Df(wn,le),[ze,Ut]=x.useState(null);x.useEffect(()=>{if(!Dt||!j){Ut(null);return}(async()=>{const y=await Oe(j.documentId);if(y!=null&&y.conflict){Ut(y.conflict);return}if(y&&le&&Nt){const O=y.localBaseCommitId??le;if(!O)return;const A={localBaseCommitId:O,remoteCommitId:Nt,localSnapshotContent:y.content};await _r(j.documentId,{localBaseCommitId:A.localBaseCommitId,conflictStatus:"diverged",conflict:A}),Ut(A)}})()},[Dt,j,le,Nt]),x.useEffect(()=>{!j||!et||!ke||Oe(j.documentId).then(async y=>{!y||y.conflict||y.conflictStatus==="publish_conflict"||y.conflictStatus!=="diverged"&&await Ot({...y,conflictStatus:"diverged"})})},[j==null?void 0:j.documentId,et,ke]),x.useEffect(()=>{if(!j){Xe(null);return}let y=!1;return Oe(j.documentId).then(O=>{y||(O&&!O.published&&O.localBaseCommitId?Xe(O.localBaseCommitId):Xe(j.headCommitId??null))}),()=>{y=!0}},[j==null?void 0:j.documentId,j==null?void 0:j.headCommitId,ke]);const[Me,he]=x.useState(null),[Ce,be]=x.useState(null),[xe,Pt]=x.useState(null),[yt,st]=x.useState(null),[tn,Ee]=x.useState(""),[_n,tt]=x.useState("docs"),[Fe,He]=x.useState(!1),[kn,vt]=x.useState(!1),[Bt,In]=sf(),k=x.useRef(null),[M,L]=x.useState(!1),[F,q]=x.useState(null),X=x.useRef(void 0),te=x.useRef(void 0);Sf(localStorage.getItem("mdocs.autoPublish")==="true",po);async function Q(y){var O;await((O=X.current)==null?void 0:O.call(X)),y()}function ye(y){const A=(y.trim()||"untitled").replace(/[\\/:*?"<>|]/g,"-").slice(0,80);return A.endsWith(".md")?A:`${A}.md`}async function De(){var A,W;if(!j||!oe)return;await((A=X.current)==null?void 0:A.call(X));const y=j.fileType===Ge.HTML;let O="";if(y)O=Ci(oe.content);else if(O=((W=te.current)==null?void 0:W.call(te))??"",!O.trim())try{O=(await sr({content:oe.content,from:"lexical",to:"markdown"})).content}catch{O=""}q({markdown:O,documentId:j.documentId,displayName:oe.displayName||j.displayName||"未命名",fileType:y?Ge.HTML:Ge.DOCUMENT}),L(!0),He(!1)}function je(){q({markdown:"",documentId:null,displayName:"未命名",fileType:Ge.DOCUMENT}),L(!0),He(!1)}async function Ne(y){var ce,_e;const O=y.documentId.trim();if(!O)return;await((ce=X.current)==null?void 0:ce.call(X));let A="",W=y.displayName.trim()||"未命名",ee=Ge.DOCUMENT;try{const Wt=await Kt(O);if(W=((_e=Wt.displayName)==null?void 0:_e.trim())||W,ee=Wt.fileType===Ge.HTML?Ge.HTML:Ge.DOCUMENT,ee===Ge.HTML)A=Ci(Wt.content);else try{A=(await sr({content:Wt.content,from:"lexical",to:"markdown"})).content}catch{A=""}}catch{}q({markdown:A,documentId:O,displayName:W,fileType:ee}),L(!0),He(!1),tt("docs"),Q(()=>B(`/doc/${O}`))}async function Ie(y){(j==null?void 0:j.documentId)===y.documentId&&await er()}async function Pe(y){const A=(y.documentId&&(F==null?void 0:F.documentId)===y.documentId?F.fileType:(j==null?void 0:j.documentId)===y.documentId?j.fileType:Ge.DOCUMENT)===Ge.HTML;if(y.documentId){const ee=(j==null?void 0:j.documentId)===y.documentId?j:null;let ce;return A?ce=Nf(y.markdown):ce=(await sr({content:y.markdown,from:"markdown",to:"lexical"})).content,await bf({documentId:y.documentId,content:ce,displayName:y.displayName,localBaseCommitIdAtEditStart:(ee==null?void 0:ee.headCommitId)??null,contentKind:A?"html":"lexical",snapshotMeta:ee?{permission:ee.permission,ownerVisitorId:ee.ownerVisitorId,domainId:ee.domainId}:void 0}),(j==null?void 0:j.documentId)===y.documentId?(ie({documentId:y.documentId,content:ce,displayName:y.displayName}),we(_e=>_e+1),Qe(!0)):await rn(y.documentId),he("帮写已写入草稿,可在编辑器中继续修改后发布"),{documentId:y.documentId}}const W=await Pr({fileName:ye(y.displayName),displayName:y.displayName,content:y.markdown,contentFormat:"markdown",domainId:E||void 0,parentId:void 0});return await fe(),await rn(W.documentId),he("已创建文档"),{documentId:W.documentId}}x.useEffect(()=>{bt()},[]),x.useEffect(()=>{if(!Me)return;const y=()=>{he(null)};return window.addEventListener("pointerdown",y,!0),()=>window.removeEventListener("pointerdown",y,!0)},[Me]),x.useEffect(()=>{const y=O=>{var ee,ce,_e;const A=O;if(((ee=A.detail)==null?void 0:ee.status)===409||((ce=A.detail)==null?void 0:ce.code)==="AI_NOT_CONFIGURED")return;const W=(_e=A.detail)==null?void 0:_e.message;W&&be(W)};return window.addEventListener(Nr,y),()=>window.removeEventListener(Nr,y)},[]);async function bt(){try{const y=await Fo();v(y),Fn(y.visitorId),await Ir(y.visitorId,z,R,fe),a("ready")}catch(y){if(y instanceof Ye&&y.status===401){a("needsRegister");return}be(qe(e,y)),a("needsRegister")}}async function xt(y,O){const A=await al(y,O);v(A.visitor),D(A.visitor.visitorId),_(A.recoveryCode),Fn(A.visitor.visitorId),await Ir(A.visitor.visitorId,z,R,fe),a("ready")}async function lt(y){const O=await Fo();v(O),await Ir(O.visitorId,z,R,fe),a("ready")}async function fe(y){const A=await dl(y??E);C(A)}function Ve(y){ie({documentId:y.documentId,content:y.content,displayName:y.displayName}),we(O=>O+1),Qe(!1)}function Tt(y,O){ie({documentId:y,content:O.content,displayName:O.displayName}),we(A=>A+1),Qe(!0)}async function nn(y,O){await xr(y);const A=await Kt(y);if((j==null?void 0:j.documentId)===y&&w.current===y){re(an(A)),Qe(!1);const W=K.current,ee=O!==void 0&&A.content===O,ce=(W==null?void 0:W.documentId)===y&&W.content===A.content;ee||ce?(W==null?void 0:W.documentId)===y&&W.displayName!==A.displayName&&ie({...W,displayName:A.displayName}):Ve(A)}return A}function At(y,O,A="folder"){console.log("[openGraph]",A,y,O),re(null),ie(null),se({kind:"graph",scope:A,resourceId:y,name:O})}function Ht(){se(null)}x.useEffect(()=>{function y(O){J.current&&!J.current.contains(O.target)&&H(!1)}if($)return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[$]);async function rn(y){w.current=y,tt("docs"),se({kind:"document",documentId:y});try{const O=await Oe(y);if(w.current!==y)return;const A=await Kt(y);if(w.current!==y||(A.domainId!==E&&(localStorage.setItem("mdocs.currentDomainId",A.domainId),R(A.domainId),fe(A.domainId)),Ee(jn(A.relativePath)),A.headCommitId&&O&&!O.published&&(O.publishError===Zt.SYNC_HEAD_MISSING&&await wr(y),O.localBaseCommitId||await Ot({...O,localBaseCommitId:A.headCommitId})),re(an(A)),w.current!==y))return;O&&!O.published?Tt(y,O):Ve(A)}catch(O){if(w.current!==y)return;be(qe(e,O))}}x.useEffect(()=>{o==="ready"&&(ne?rn(ne):(se(null),re(null),ie(null),Xe(null)))},[o,ne]);const{createModal:Vt,setCreateModal:Jn,createModalError:io,createModalBusy:Gt,createModalInputRef:Ca,openNewDocumentModal:Sn,openNewFolderModal:ao,submitCreateModal:Da}=hf({tree:T,currentDomainId:E,selectedCreateParentPath:tn,t:e,onDocCreated:y=>{re(an(y)),Ve(y),Ee(jn(y.relativePath)),B(`/doc/${y.documentId}`)},refreshTree:fe}),[Na,Cn]=x.useState(!1),[Pa,Xn]=x.useState(!1);x.useEffect(()=>{const y=O=>{!(O.metaKey||O.ctrlKey)||O.key.toLowerCase()!=="k"||(O.preventDefault(),Xn(!0))};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[]);const[Ta,on]=x.useState(!1),[jt,so]=x.useState([]),[Zn,lo]=x.useState(""),[Dn,co]=x.useState(""),[Aa,uo]=x.useState(new Set);async function ja(){try{const y=await yl();so(y)}catch(y){be(qe(e,y))}}const Qn=x.useMemo(()=>{const y={};for(const O of P)y[O.domainId]=O.domainName;return y},[P]),fo=x.useMemo(()=>{let y=jt;const O=Zn.trim().toLowerCase();return O&&(y=y.filter(A=>{var W;return(W=A.displayName)==null?void 0:W.toLowerCase().includes(O)})),Dn&&(y=y.filter(A=>A.domainId===Dn)),y},[jt,Zn,Dn]),Ma=x.useMemo(()=>{const y=new Set,O=[];for(const A of jt){const W=A.domainId;W&&!y.has(W)&&(y.add(W),O.push({id:W,name:Qn[W]??W}))}return O},[jt,Qn]);async function Ea(y,O,A,W,ee){let ce=await Oe(y);!ce&&(j==null?void 0:j.documentId)===y&&(ce={documentId:y,content:O,displayName:A,updatedAt:Date.now(),published:!1,localBaseCommitId:W,permission:j.permission,ownerVisitorId:j.ownerVisitorId,domainId:j.domainId},await Ot(ce)),ce&&await _r(y,{localBaseCommitId:W,conflictStatus:"publish_conflict",conflict:{localBaseCommitId:W,remoteCommitId:ee.headCommitId,localSnapshotContent:O}}),gt(!0)}async function Oa(){if(!j||en||(b==null?void 0:b.visitorId)!==j.ownerVisitorId||!window.confirm(e("conflictForceConfirm")))return;const O=j.documentId;$t(!0);try{await ir(O).execute(async()=>{var nr,yo,vo,bo,xo;const A=await Oe(O),W=((nr=A==null?void 0:A.conflict)==null?void 0:nr.localBaseCommitId)??(A==null?void 0:A.localBaseCommitId)??le??j.headCommitId,ee=((yo=A==null?void 0:A.conflict)==null?void 0:yo.remoteCommitId)??(ze==null?void 0:ze.remoteCommitId),ce=((vo=A==null?void 0:A.conflict)==null?void 0:vo.localSnapshotContent)??(A==null?void 0:A.content)??((bo=K.current)==null?void 0:bo.content),_e=(A==null?void 0:A.displayName)??((xo=K.current)==null?void 0:xo.displayName)??j.displayName;if(!W||!ee||ce==null)throw be(e("syncHeadMissing")),new Error("missing force overwrite payload");await ar(O,{content:ce,displayName:_e,version:{localBaseCommitId:W,merge:{remoteCommitId:ee,localSnapshotContent:ce,forceLocal:!0}}});const Wt=await Kt(O);await ho(Wt)})}catch(A){A instanceof Error&&A.message==="missing force overwrite payload"||be(qe(e,A))}finally{$t(!1)}}async function mo(y,O,A,W){return ir(A).execute(async()=>{const ee=await Oe(A),ce=(ee==null?void 0:ee.localBaseCommitId)??(j==null?void 0:j.headCommitId);if(!ce)throw be(e("syncHeadMissing")),new Error("missing localBaseCommitId");try{await ar(A,{content:y,displayName:O,permission:W,version:{localBaseCommitId:ce}}),await kr(A),await nn(A,y),await fe(),gt(!1),he(e("published")),window.setTimeout(()=>he(null),1200)}catch(_e){throw _e instanceof Ye&&_e.status===409&&_e.code==="VERSION_CONFLICT"&&_e.details&&typeof _e.details=="object"&&await Ea(A,y,O,ce,_e.details),_e}})}async function Ra(){if(!j)return;const y=await Kt(j.documentId);y.domainId!==E&&(localStorage.setItem("mdocs.currentDomainId",y.domainId),R(y.domainId),fe(y.domainId)),Ee(jn(y.relativePath)),re(an(y)),Ve(y),he(e("syncPullDone")),window.setTimeout(()=>he(null),1200)}async function er(){if(!j)return;const y=await Oe(j.documentId),O=!!(y&&!y.published);if((y==null?void 0:y.conflictStatus)==="publish_conflict"||(y==null?void 0:y.conflictStatus)==="diverged"||!!(y!=null&&y.conflict)){Ze(!0);return}if(O&&y){if(et&&Nt){const W=y.localBaseCommitId??le;if(W){const ee={localBaseCommitId:W,remoteCommitId:Nt,localSnapshotContent:y.content};await _r(j.documentId,{localBaseCommitId:W,conflictStatus:"diverged",conflict:ee}),Ut(ee)}Ze(!0);return}he(e("pullBlockedDraft")),window.setTimeout(()=>he(null),3e3);return}await Ra()}async function ho(y){await kr(y.documentId),await xr(y.documentId),Qe(!1),Ze(!1),gt(!1),await rn(y.documentId),fe(y.domainId),he(e("published")),window.setTimeout(()=>he(null),1200)}async function Fa(y,O,A){try{await If(y,O,A)}catch(W){if(!(W instanceof bn))throw W;const ee=A??await Oe(y);throw he(kf(e,ee,W.code,W.cause??O)),window.setTimeout(()=>he(null),4e3),W}}async function po(y){let O;try{await ir(y).execute(async()=>{const A=await Oe(y);if(!A)return;O=A;let W=A.localBaseCommitId;if(W||(W=(await Kt(y)).headCommitId??void 0,W&&(await Ot({...A,localBaseCommitId:W}),A.publishError===Zt.SYNC_HEAD_MISSING&&await wr(y))),!W)throw new bn(Zt.SYNC_HEAD_MISSING);const ee=await Oe(y);ee&&(await ar(y,{content:ee.content,displayName:ee.displayName,version:{localBaseCommitId:W}}),await kr(y),await wr(y),(j==null?void 0:j.documentId)===y?await nn(y,ee.content):await xr(y),await fe(),he(e("published")),window.setTimeout(()=>he(null),1200))})}catch(A){await Fa(y,A,O)}}function tr(y,O){Pt({type:"document",id:y,name:O})}function go(y,O){Pt({type:"folder",id:y,name:O})}async function La(y,O){try{const A=await ml(y,O);await fe(A.domainId),(j==null?void 0:j.documentId)===y&&(re(an(A)),Ee(jn(A.relativePath)))}catch(A){A instanceof Ye?A.status===409&&be(A.message):be(qe(e,A))}}async function za(){if(xe)try{xe.type==="document"?(await fl(xe.id),(j==null?void 0:j.documentId)===xe.id&&(re(null),ie(null),Ee(""),B("/"))):xe.type==="folder"&&(await pl(xe.id),j&&(re(null),ie(null),Ee(""),B("/"))),await fe(),he(xe.type==="folder"?`已删除「${xe.name}」及其下所有内容`:`已删除「${xe.name}」`),window.setTimeout(()=>he(null),2e3)}catch(y){be(qe(e,y))}finally{Pt(null)}}return o==="loading"?c.jsx("div",{className:"mdocs-loading muted",children:e("loading")}):o==="needsRegister"?c.jsx(Dl,{onSubmit:xt,onRecover:lt,error:Me}):c.jsxs("div",{className:"mdocs-app-root",children:[Ei(),c.jsx("div",{className:"mdocs-shell",children:_n==="settings"?c.jsx(x.Suspense,{fallback:c.jsx("div",{className:"mdocs-main muted",style:{padding:24},children:"加载设置…"}),children:c.jsx(Rf,{onBack:()=>tt("docs"),onPublishDraft:po,onOpenDocument:rn,onRecoverDraft:()=>void fe()})}):c.jsxs("div",{className:"mdocs-layout"+(l?" mdocs-layout--reader":""),children:[l&&u?c.jsx("button",{type:"button",className:"mdocs-mobile-nav-scrim","aria-label":e("collapseSidebar"),onClick:()=>d(!1)}):null,c.jsxs("aside",{className:"mdocs-sidebar"+(l?u?" mdocs-sidebar--drawer-open":" mdocs-sidebar--drawer":i?" mdocs-sidebar-collapsed":""),children:[c.jsxs("header",{className:"mdocs-sidebar-header",children:[c.jsxs("div",{className:"mdocs-brand",children:[c.jsx("img",{src:Mf,alt:e("brand"),className:"mdocs-brand-logo"}),c.jsx("span",{children:e("brand")})]}),c.jsx("button",{type:"button",className:"mdocs-sidebar-toggle",onClick:h,"aria-label":e(l?u?"collapseSidebar":"expandSidebar":i?"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:y=>{y.currentTarget.style.background="var(--mdocs-hover-bg, #f0f0f0)"},onMouseLeave:y=>{y.currentTarget.style.background="none"},children:l?c.jsx(So,{size:18}):i?c.jsx(Co,{size:18}):c.jsx(So,{size:18})})]}),c.jsxs("div",{className:"mdocs-sidebar-actions",ref:J,children:[c.jsxs("button",{type:"button",className:"mdocs-sidebar-create-btn",onClick:()=>H(y=>!y),children:[c.jsx(Io,{size:15,strokeWidth:1.75}),e("newArticle")]}),$&&c.jsxs("div",{className:"mdocs-create-dropdown",children:[c.jsxs("button",{type:"button",className:"mdocs-create-dropdown-item",onClick:()=>{H(!1),Sn()},children:[c.jsx(Io,{size:14,strokeWidth:1.5}),"Markdown"]}),c.jsxs("button",{type:"button",className:"mdocs-create-dropdown-item",onClick:()=>{H(!1),Sn(void 0,"html")},children:[c.jsx(bs,{size:14,strokeWidth:1.5}),"HTML"]})]}),c.jsxs("button",{type:"button",className:"mdocs-sidebar-create-btn",onClick:()=>{H(!1),ao()},children:[c.jsx(Ns,{size:15,strokeWidth:1.75}),e("newDirectory")]}),c.jsx("span",{className:"mdocs-sidebar-icon mdocs-tooltip","data-tooltip":e("docSearch"),onClick:()=>Xn(!0),children:c.jsx(Ti,{size:18,strokeWidth:1.75})}),c.jsx("span",{className:"mdocs-sidebar-icon mdocs-tooltip","data-tooltip":"知识图谱",onClick:()=>At(E,"知识图谱","domain"),children:c.jsx(Hr,{size:18,strokeWidth:1.75})})]}),c.jsx(Pl,{nodes:T,activeDocumentId:ue,graphFocusAnchorId:(G==null?void 0:G.kind)==="graph"?G.resourceId:null,selectedParentPath:tn,onOpen:y=>{l&&d(!1),Q(()=>B(`/doc/${y.documentId}`))},onOpenFolder:(y,O)=>{Q(()=>{Ee(y),O&&(Ht(),l&&d(!1),B(`/doc/${O}`))})},onContextMenu:st,onMoveDocument:La,onDeselect:()=>{Ht(),Q(()=>{Ee(""),B("/")})},onOpenGraph:(y,O)=>{if(y.type==="folder")At(y.documentId,y.name);else if(O){const A=T.find(W=>W.documentId===O);At(O,(A==null?void 0:A.name)??"图谱")}},onGenerateGraph:async(y,O)=>{var ee;const A=y.type==="folder"?y.documentId:O;if(!A)return;const W=y.type==="folder"?y.name:((ee=T.find(ce=>ce.documentId===O))==null?void 0:ee.name)??"图谱";At(A,W)}}),c.jsxs("footer",{className:"mdocs-sidebar-footer",children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1,cursor:"pointer"},onClick:()=>Q(()=>tt("settings")),children:[c.jsx("span",{className:"mdocs-visitor-avatar",children:b?b.visitorName.charAt(0).toUpperCase():"?"}),c.jsx("span",{className:"mdocs-visitor-footer-name",children:b?b.visitorName:""})]}),c.jsx("button",{type:"button",className:"mdocs-sidebar-bookmark mdocs-tooltip","data-tooltip":e("bookmark"),onClick:()=>{on(!0),lo(""),co(""),ja()},style:{background:"none",border:"none",cursor:"pointer",padding:"6px",color:"var(--mdocs-text-muted, #999)",fontSize:"1rem",lineHeight:1,borderRadius:4},children:c.jsx(Hs,{size:16,strokeWidth:1.5})}),c.jsx("button",{type:"button",className:"mdocs-sidebar-logout mdocs-tooltip","data-tooltip":e("logout"),onClick:()=>Cn(!0),style:{background:"none",border:"none",cursor:"pointer",padding:"6px",color:"var(--mdocs-text-muted, #999)",lineHeight:1,borderRadius:4},children:c.jsx(Ms,{size:16,strokeWidth:1.5})})]})]}),c.jsxs("main",{className:"mdocs-main",children:[(G==null?void 0:G.kind)==="graph"?c.jsx(Zu,{scope:G.scope,resourceId:G.resourceId,name:G.name,onClose:Ht,onOpenDocument:y=>{Q(()=>B(`/doc/${y}`))}},`${G.scope}-${G.resourceId}`):j&&oe&&oe.documentId===j.documentId?j.fileType==="html"?c.jsxs("div",{className:"mdocs-editor-with-comments",children:[c.jsx("div",{className:"mdocs-editor-container",children:c.jsx(x.Suspense,{fallback:c.jsx("div",{className:"muted",style:{padding:24},children:"加载编辑器…"}),children:c.jsx(Of,{meta:j,initialContent:oe.content,initialDisplayName:oe.displayName,contentRevision:Z,canEdit:!!(b&&(j.ownerVisitorId===b.visitorId||Po(j.permission)||j.invitedEdit===!0)),domains:P,currentDomainId:E,onDomainChange:y=>{Q(()=>{localStorage.setItem("mdocs.currentDomainId",y),R(y),re(null),ie(null),Ee(""),B("/"),fe(y)})},onDomainsChange:z,onContentChange:y=>{ie(O=>O&&{...O,content:y})},onDraftExistsChange:Qe,hasLocalDraft:ke,onPublish:mo,syncBehind:et,onSyncClick:()=>void er(),canManageInvites:!!(b&&b.visitorId===j.ownerVisitorId),onDelete:async()=>{tr(j.documentId,j.relativePath)},onToggleComments:()=>f(!m),commentPanelOpen:m,commentCount:p,onAiWrite:l?void 0:()=>void De(),onShowToast:he,readerChrome:l,onOpenMobileNav:()=>d(!0)},j.documentId)})}),m&&c.jsx(Si,{documentId:j.documentId,visitorId:b==null?void 0:b.visitorId,visitorName:b==null?void 0:b.visitorName,documentOwnerId:j.ownerVisitorId,onClose:()=>f(!1)})]}):c.jsxs("div",{className:"mdocs-editor-with-comments",children:[c.jsx("div",{className:"mdocs-editor-container",children:c.jsx(x.Suspense,{fallback:c.jsx("div",{className:"muted",style:{padding:24},children:"加载编辑器…"}),children:c.jsx(Ef,{meta:j,initialContent:oe.content,initialDisplayName:oe.displayName,contentRevision:Z,canEdit:!!(b&&(j.ownerVisitorId===b.visitorId||Po(j.permission)||j.invitedEdit===!0)),domains:P,currentDomainId:E,onDomainChange:y=>{Q(()=>{localStorage.setItem("mdocs.currentDomainId",y),R(y),re(null),ie(null),Ee(""),B("/"),fe(y)})},onDomainsChange:z,onPublish:mo,syncBehind:et,onSyncClick:()=>void er(),onDraftExistsChange:Qe,hasLocalDraft:ke,onConflictModalRequest:()=>gt(!0),onMergeRequest:()=>Ze(!0),canManageInvites:!!(b&&b.visitorId===j.ownerVisitorId),onDelete:async()=>{if(j.relativePath.endsWith("/___desc___.md")){const y=j.relativePath.replace(/\/___desc___\.md$/,"");go(j.documentId,y)}else tr(j.documentId,j.relativePath)},saveBeforeNavRef:X,exportMarkdownRef:te,onShowToast:he,onShowError:be,onToggleComments:()=>f(!m),commentPanelOpen:m,commentCount:p,onAiWrite:l?void 0:()=>void De(),readerChrome:l,onOpenMobileNav:()=>d(!0)},j.documentId)})}),m&&c.jsx(Si,{documentId:j.documentId,visitorId:b==null?void 0:b.visitorId,visitorName:b==null?void 0:b.visitorName,documentOwnerId:j.ownerVisitorId,onClose:()=>f(!1)})]}):c.jsxs("div",{className:"mdocs-welcome",children:[l?c.jsxs("button",{type:"button",className:"mdocs-reader-float-pill",onClick:()=>d(!0),"aria-label":e("expandSidebar"),children:[c.jsx(Co,{size:18,strokeWidth:1.75}),c.jsx("span",{children:e("brand")})]}):null,c.jsx("div",{className:"mdocs-welcome-icon",children:c.jsx(ys,{size:64,strokeWidth:1,opacity:.15})}),c.jsx("h1",{children:e("brand")}),c.jsx("p",{className:"mdocs-welcome-lead",children:e("createDocToStart")}),c.jsxs("div",{className:"mdocs-welcome-actions",children:[c.jsxs("button",{type:"button",className:"primary",onClick:()=>Sn(),style:{display:"flex",alignItems:"center",gap:6},children:[c.jsx(Cs,{size:16,strokeWidth:1.5}),e("startWriting")]}),l?null:c.jsxs("button",{type:"button",className:"secondary",onClick:()=>je(),style:{display:"flex",alignItems:"center",gap:6},children:[c.jsx("img",{src:ba,alt:"",width:16,height:16,style:{display:"block"}}),"AI 帮写"]})]}),c.jsxs("div",{className:"mdocs-welcome-domain",children:[c.jsx("label",{className:"muted mdocs-welcome-domain-label",children:e("domainLabel")}),c.jsx(ef,{domains:P.length?P:[{domainId:"default",domainName:e("defaultDomain"),permission:"",creatorVisitorId:"",docCount:0}],value:E,onChange:y=>{Q(()=>{localStorage.setItem("mdocs.currentDomainId",y),R(y),re(null),ie(null),Ee(""),B("/"),fe(y)})},onDomainsChange:z,ariaLabel:e("domainLabel"),localizeName:y=>On(y,n,e)})]})]}),c.jsx(gf,{open:Ct,onClose:()=>gt(!1),onResolve:()=>{gt(!1),Ze(!0)},onForceOverwrite:b&&j&&b.visitorId===j.ownerVisitorId?()=>void Oa():void 0,forceBusy:en}),Dt&&j&&ze&&c.jsx(x.Suspense,{fallback:c.jsx("div",{className:"merge-view-loading",children:e("mergeLoadingRemote")}),children:c.jsx(zf,{documentId:j.documentId,displayName:j.displayName,conflict:ze,fileType:j.fileType,onClose:()=>Ze(!1),onSuccess:ho,onError:y=>be(y)})}),Me&&c.jsx("div",{className:"mdocs-toast",role:"status",children:Me}),Ce&&c.jsx(lf,{title:e("error"),message:Ce,onClose:()=>be(null)})]}),Na&&c.jsx("div",{className:"mdocs-dialog-backdrop",onClick:y=>{y.target===y.currentTarget&&Cn(!1)},children:c.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:440},children:[c.jsx("h1",{style:{fontSize:"1.125rem",marginBottom:8},children:"退出当前登录身份?"}),c.jsx("p",{style:{lineHeight:1.6,color:"var(--mdocs-text-secondary, #666)",marginBottom:20},children:"这将会导致您无法修改以前的文章。如果想找回账号,需要恢复码或联系管理员执行合并用户脚本。"}),c.jsxs("div",{className:"mdocs-dialog-actions",style:{justifyContent:"flex-end"},children:[c.jsx("button",{type:"button",onClick:()=>Cn(!1),children:"取消"}),c.jsx("button",{type:"button",className:"primary",style:{background:"#d32f2f"},onClick:()=>{il(),re(null),ie(null),v(null),C([]),Cn(!1),a("needsRegister")},children:"确认退出"})]})]})}),Ta&&c.jsx("div",{className:"mdocs-dialog-backdrop",onClick:y=>{y.target===y.currentTarget&&on(!1)},children:c.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:640,width:"min(640px, 100%)",maxHeight:"70vh",display:"flex",flexDirection:"column"},children:[c.jsxs("h1",{style:{fontSize:"1.125rem",marginBottom:16},children:[e("bookmarkTitle"),"(",jt.length,")"]}),jt.length>0&&c.jsxs("div",{className:"mdocs-bookmark-filterbar",children:[c.jsx("input",{type:"text",placeholder:e("bookmarkSearch"),value:Zn,onChange:y=>lo(y.target.value)}),c.jsxs("select",{value:Dn,onChange:y=>co(y.target.value),children:[c.jsx("option",{value:"",children:e("bookmarkFilterAll")}),Ma.map(y=>c.jsx("option",{value:y.id,children:y.name},y.id))]})]}),jt.length===0?c.jsx("p",{style:{color:"var(--mdocs-text-muted, #999)",textAlign:"center",padding:"2rem 0"},children:e("bookmarkEmpty")}):fo.length===0?c.jsx("p",{style:{color:"var(--mdocs-text-muted, #999)",textAlign:"center",padding:"2rem 0"},children:e("bookmarkNoMatch")}):c.jsx("div",{style:{overflowY:"auto",flex:1,margin:"0 -1rem",padding:"0 1rem"},children:c.jsxs("table",{className:"mdocs-bookmark-table",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{children:e("bookmarkColTitle")}),c.jsx("th",{children:e("bookmarkColDomain")}),c.jsx("th",{children:e("bookmarkColAuthor")}),c.jsx("th",{children:e("bookmarkColTime")}),c.jsx("th",{className:"mdocs-bookmark-col-action"})]})}),c.jsx("tbody",{children:fo.map(y=>{const O=Aa.has(y.documentId);return c.jsxs("tr",{className:`${O?"mdocs-bookmark-removing":""}`,style:{opacity:y.isDeleted?.6:1},children:[c.jsx("td",{className:"mdocs-bookmark-col-title",children:c.jsxs("div",{style:{cursor:y.isDeleted?"default":"pointer",display:"flex",alignItems:"center",gap:6,overflow:"hidden"},onClick:()=>{y.isDeleted||Q(()=>{on(!1),B(`/doc/${y.documentId}`)})},children:[c.jsx("span",{ref:A=>{if(A){const W=A.scrollWidth>A.clientWidth;A.title=W?y.displayName??"":""}},style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:y.displayName??"(无标题)"}),y.isDeleted&&c.jsx("span",{style:{fontSize:"0.7rem",color:"#d32f2f",background:"#ffebee",padding:"1px 6px",borderRadius:4,flexShrink:0},children:"已删除"})]})}),c.jsx("td",{children:y.isDeleted?"":Qn[y.domainId??""]??y.domainId??""}),c.jsx("td",{children:y.isDeleted?"":y.ownerVisitorName??"-"}),c.jsx("td",{children:y.isDeleted?"":$f(y.bookmarkedAt,n)}),c.jsx("td",{className:"mdocs-bookmark-col-action",children:c.jsxs("div",{style:{display:"flex",gap:2,alignItems:"center",justifyContent:"flex-end"},children:[c.jsx("button",{type:"button",className:"mdocs-tooltip","data-tooltip":e("bookmarkOpen"),onClick:()=>{y.isDeleted||Q(()=>{on(!1),B(`/doc/${y.documentId}`)})},style:{background:"none",border:"none",cursor:y.isDeleted?"default":"pointer",padding:"4px",color:"var(--mdocs-text-muted, #999)",lineHeight:1,borderRadius:4,display:"inline-flex",alignItems:"center"},children:c.jsx(hs,{size:14,strokeWidth:1.5})}),c.jsx("button",{type:"button",className:"mdocs-tooltip","data-tooltip":e("bookmarkRemove"),onClick:async()=>{try{await vl(y.documentId),uo(A=>new Set(A).add(y.documentId)),setTimeout(()=>{so(A=>A.filter(W=>W.documentId!==y.documentId)),uo(A=>{const W=new Set(A);return W.delete(y.documentId),W})},300)}catch(A){be(qe(e,A))}},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:A=>{A.currentTarget.style.color="#d32f2f"},onMouseLeave:A=>{A.currentTarget.style.color="var(--mdocs-text-muted, #999)"},children:"✕"})]})})]},y.documentId)})})]})}),c.jsx("div",{className:"mdocs-dialog-actions",style:{justifyContent:"flex-end",marginTop:16,paddingTop:16,borderTop:"1px solid var(--mdocs-border, #eee)"},children:c.jsx("button",{type:"button",onClick:()=>on(!1),children:e("close")})})]})}),yt&&c.jsx(Qu,{x:yt.x,y:yt.y,node:yt.node,parentPath:yt.parentPath,onClose:()=>st(null),onCreateChild:y=>Sn(y),onCreateFolder:y=>ao(y),onDeleteDocument:y=>tr(y.documentId,y.path),onDeleteFolder:y=>go(y.documentId,y.folderDisplayName||y.name)}),xe&&c.jsx(xa,{title:xe.type==="folder"?"删除文件夹":"删除文档",message:xe.type==="folder"?`确定要删除「${xe.name}」及其下的所有文档和子文件夹吗?此操作不可撤销。`:`确定要删除「${xe.name}」吗?`,confirmLabel:"删除",cancelLabel:"取消",onConfirm:za,onCancel:()=>Pt(null),danger:!0}),Vt&&c.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&!Gt&&Jn(null)},children:c.jsxs("div",{className:"mdocs-dialog card",role:"dialog","aria-modal":"true",children:[c.jsx("h1",{children:Vt.kind==="document"?e("newDocumentTitle"):e("newFolderTitle")}),c.jsx("p",{className:"muted",children:Vt.kind==="document"?e("fileNameHint"):e("folderNameHint")}),c.jsxs("form",{onSubmit:Da,className:"mdocs-dialog-form",children:[c.jsxs("label",{className:"mdocs-dialog-label",children:[Vt.kind==="document"?e("fileNameLabel"):e("folderNameLabel"),c.jsx("input",{ref:Ca,value:Vt.draft,onChange:y=>Jn(O=>O&&{...O,draft:y.target.value}),placeholder:Vt.kind==="document"?e("untitledPlaceholder"):e("folderExamplePlaceholder"),maxLength:200,disabled:Gt})]}),io&&c.jsx("div",{className:"mdocs-dialog-error",children:io}),c.jsxs("div",{className:"mdocs-dialog-actions",children:[c.jsx("button",{type:"button",onClick:()=>!Gt&&Jn(null),disabled:Gt,children:e("cancel")}),c.jsx("button",{type:"submit",className:"primary",disabled:Gt,children:e(Gt?"creating":"create")})]})]})]})})]})}),I&&b&&c.jsx(Nl,{visitorId:I,onDismiss:()=>D(null)}),N&&c.jsx("div",{className:"mdocs-dialog-backdrop",style:{position:"fixed",zIndex:9999},onClick:y=>{y.target===y.currentTarget&&_(null)},children:c.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:480,textAlign:"center"},children:[c.jsx("h1",{style:{fontSize:"1.25rem",marginBottom:8},children:"🔑 保存你的恢复码"}),c.jsxs("p",{className:"muted",style:{marginBottom:16,lineHeight:1.5},children:["恢复码是你的唯一凭证,当 Token 丢失时可用它找回身份。",c.jsx("br",{}),c.jsx("strong",{children:"请立即复制保存,此弹窗关闭后不可再查看。"})]}),c.jsx("div",{style:{background:"#f5f5f5",borderRadius:8,padding:"12px 16px",fontFamily:"monospace",fontSize:"1.25rem",letterSpacing:"0.1em",marginBottom:20,userSelect:"all"},children:N}),c.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"center"},children:[c.jsx("button",{type:"button",className:"primary",onClick:()=>{navigator.clipboard.writeText(N)},children:"复制恢复码"}),c.jsx("button",{type:"button",onClick:()=>_(null),children:"已保存,关闭"})]})]})}),c.jsxs(c.Fragment,{children:[c.jsx(af,{open:Fe,onToggle:()=>{var y;Fe?(y=k.current)==null||y.requestClose():He(!0)},position:Bt,onPositionChange:In,disableDrag:l}),Fe?c.jsx(x.Suspense,{fallback:null,children:c.jsx(Ff,{ref:k,open:Fe,onClose:()=>{He(!1),vt(!1)},visitorName:b==null?void 0:b.visitorName,fullscreen:l||kn,onToggleFullscreen:l?void 0:()=>vt(y=>!y),domainId:E||null,documentId:(j==null?void 0:j.documentId)??null,documentTitle:(j==null?void 0:j.displayName)??null,documentPath:(j==null?void 0:j.relativePath)??null,graphFileId:(G==null?void 0:G.kind)==="graph"?`${G.resourceId}.graph-file`:null,graphLabel:(G==null?void 0:G.kind)==="graph"?G.name:null,anchorStyle:l||kn?void 0:of(Bt),onOpenDocument:y=>{tt("docs"),Q(()=>B(`/doc/${y}`)),He(!1),vt(!1)},onTreeChanged:()=>void fe(),onDocumentOverwritten:y=>void Ie(y),onOpenCoding:l?void 0:y=>void Ne(y)})}):null]}),F?c.jsx(x.Suspense,{fallback:null,children:c.jsx(Lf,{open:M,initialMarkdown:F.markdown,documentId:F.documentId,displayName:F.displayName,onClose:()=>{L(!1),q(null)},onComplete:Pe})}):null,c.jsx(ff,{open:Pa,domains:P,onDomainsChange:z,onClose:()=>Xn(!1),onOpenDocument:y=>{l&&d(!1),tt("docs"),Q(()=>B(`/doc/${y}`))}})]})}const Uf=x.lazy(()=>zt(()=>import("./PlaygroundPage-DuMH_V-7.js"),__vite__mapDeps([21,1,4,5,2,3,6,7,8,9,10])).then(e=>({default:e.PlaygroundPage})));function Bf(){return c.jsxs(Ga,{children:[c.jsx(rr,{path:"/",element:c.jsx(Di,{})}),c.jsx(rr,{path:"/doc/:documentId",element:c.jsx(Di,{})}),c.jsx(rr,{path:"/playground",element:c.jsx(x.Suspense,{fallback:c.jsx("div",{style:{padding:24},children:"Loading playground…"}),children:c.jsx(Uf,{})})})]})}function Hf(){const{pathname:e,hash:n,search:r,origin:o}=window.location,a="/",i=a.endsWith("/")?a.slice(0,-1):a;let s=e;i&&s.startsWith(i)&&(s=s.slice(i.length)||"/");const l=s.match(/^\/doc\/([^/]+)\/?$/);if(!l)return;const u=n.match(/^#\/doc\/([^/?#]+)/),d=(u==null?void 0:u[1])??l[1];if(!d)return;const h=a.endsWith("/")?a:`${a}/`;window.location.replace(`${o}${h}${r}#/doc/${d}`)}Hf();const Sa=document.getElementById("root");if(!Sa)throw new Error("root element missing");Wa.createRoot(Sa).render(c.jsx(Ni.StrictMode,{children:c.jsx(Ka,{motion:ss,children:c.jsx(Ya,{children:c.jsx(Js,{children:c.jsx(qa,{children:c.jsx(Bf,{})})})})})}));export{mm as $,kf as A,wr as B,ys as C,nt as D,ws as E,Sl as F,bn as G,Zf as H,cl as I,Ym as J,cm as K,lm as L,Os as M,Hr as N,sm as O,Co as P,am as Q,Do as R,Hs as S,fm as T,Qf as U,tm as V,em as W,nm as X,Et as Y,um as Z,dm as _,Oe as a,hm as a0,pm as a1,Nm as a2,Fo as a3,xa as a4,Pm as a5,Lo as a6,Tm as a7,Am as a8,jm as a9,Vm as aA,qm as aB,Hm as aC,Bm as aD,Um as aE,Wm as aF,Gm as aG,Kt as aH,gm as aI,sr as aJ,ar as aK,Nn as aL,Cr as aM,Mm as aa,Em as ab,gl as ac,km as ad,Im as ae,pf as af,_m as ag,yl as ah,Dm as ai,Mf as aj,So as ak,Ei as al,Ti as am,om as an,rm as ao,wm as ap,xi as aq,Om as ar,Fm as as,Wu as at,Io as au,Rm as av,Lm as aw,zm as ax,$m as ay,Km as az,Xm as b,Je as c,xr as d,Sm as e,im as f,ir as g,Yf as h,Cm as i,ym as j,bm as k,On as l,vm as m,xm as n,ve as o,ef as p,ba as q,vl as r,Jm as s,Gr as t,bf as u,dl as v,Pl as w,Pr as x,qe as y,xf as z};