dsh-memu-memory 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +6 -3
- package/CHANGELOG.md +57 -0
- package/README.md +8 -7
- package/README.zh.md +8 -5
- package/assets/screenshots/drawer.jpg +0 -0
- package/assets/screenshots/mobile.jpg +0 -0
- package/assets/screenshots/relations.jpg +0 -0
- package/assets/screenshots/settings.jpg +0 -0
- package/assets/screenshots/stats.jpg +0 -0
- package/assets/screenshots/webui-dark.jpg +0 -0
- package/assets/screenshots/webui-memory.jpg +0 -0
- package/docs/client-conventions.md +11 -0
- package/docs/contributing.md +6 -4
- package/docs/env-and-commands.md +12 -1
- package/docs/memory-semantics.md +8 -2
- package/docs/troubleshooting.md +24 -6
- package/lib/auto-link/apply.js +249 -0
- package/lib/auto-link/candidates.js +155 -0
- package/lib/auto-link/decide.js +304 -0
- package/lib/auto-link/normalize.js +99 -0
- package/lib/auto-link/policy.js +42 -0
- package/lib/auto-link/suppression.js +101 -0
- package/lib/auto-link/terminology.js +265 -0
- package/lib/binding-diagnostics.js +2 -2
- package/lib/client.js +1509 -72
- package/lib/graph.js +269 -18
- package/lib/memory.js +11 -0
- package/lib/memu.js +7 -6
- package/lib/private-links.js +105 -137
- package/lib/private.js +138 -38
- package/lib/rpc.js +73 -8
- package/lib/state.js +7 -2
- package/lib/tools.js +4 -2
- package/lib/webui/graph-LICENSE.txt +1 -62
- package/lib/webui/graph-view.bundle.js +1 -1
- package/lib/webui/graph-view.js +921 -126
- package/lib/webui/standalone.js +3 -3
- package/package.json +1 -2
- package/scripts/build-graph.mjs +35 -7
- package/scripts/check-all.mjs +2 -0
- package/scripts/check-graph-browser.mjs +106 -23
- package/scripts/make-readme-shots.mjs +59 -0
- package/scripts/rebuild-auto-links.mjs +252 -0
- package/tests/audit-regression.test.mjs +11 -8
- package/tests/auto-link-candidates.test.mjs +161 -0
- package/tests/auto-link-decide.test.mjs +512 -0
- package/tests/auto-link-migration.test.mjs +133 -0
- package/tests/browser.test.mjs +27 -0
- package/tests/client-render.test.mjs +178 -6
- package/tests/consolidation-fork.test.mjs +148 -0
- package/tests/cycle.test.mjs +1 -1
- package/tests/graph-view.test.mjs +221 -22
- package/tests/graph.test.mjs +5 -0
- package/tests/help-page.test.mjs +3 -3
- package/tests/memu-resident-route.test.mjs +130 -0
- package/tests/private-links.test.mjs +81 -45
- package/tests/stubs/child-process-spy.mjs +14 -0
- package/tests/tools.test.mjs +24 -18
package/lib/rpc.js
CHANGED
|
@@ -20,7 +20,11 @@ import { recallCacheStats } from './recall-cache.js'
|
|
|
20
20
|
import { getMemuConfig, saveMemuConfig, setEmbeddingSource, testMemuConfig, getSummaryConfig, getVisionConfig } from './memu-config.js'
|
|
21
21
|
import { getLocalVectorState, downloadLocalVectorModel, installLocalVectorRuntime, selectLocalVectorModel, switchLocalVectorProfile, rollbackLocalVectorProfile, abortLocalVectorMigration, testLocalVector } from './local-vector-service.js'
|
|
22
22
|
import { webUiHtml, WEBUI_PATH, standaloneHtml, standaloneAsset, SETTINGS_PATH } from './webui.js'
|
|
23
|
-
import { getGraph, listEntities, createEntity, renameEntity, deleteEntity, mergeEntities, suggestEntityMerges, linkEntries, unlinkEntry, getRelationship, updateRelationship, graphExport, restoreGraphData } from './graph.js'
|
|
23
|
+
import { getGraph, listEntities, createEntity, confirmEntities, renameEntity, deleteEntity, mergeEntities, suggestEntityMerges, linkEntries, unlinkEntry, purgeAutoLinks, getRelationship, updateRelationship, graphExport, restoreGraphData } from './graph.js'
|
|
24
|
+
import { generateAnchorCandidates, resetAnchorCandidatesCache } from './auto-link/candidates.js'
|
|
25
|
+
import { refreshPrivateAutoLinks } from './private-links.js'
|
|
26
|
+
import { refreshEntityMentions } from './auto-link/apply.js'
|
|
27
|
+
import { clearSuppression, suppressionSet } from './auto-link/suppression.js'
|
|
24
28
|
import { getAttachment, attachmentThumbnail, attachmentPreview, exportMediaBundle, importMediaBundle, streamMediaExport, importMediaStream } from './media.js'
|
|
25
29
|
import { listEvents, logStats, clearEvents } from './activity-log.js'
|
|
26
30
|
import { redactSecrets, warn } from './paths.js'
|
|
@@ -80,6 +84,8 @@ const LIBRARY_ROUTE_OPERATIONS = new Map([
|
|
|
80
84
|
['importMemories', 'import'], ['exportLibrary', 'export'], ['getAttachment', 'attachment.read'],
|
|
81
85
|
['browseWall', 'read'], ['getGraph', 'read'], ['listEntities', 'read'], ['createEntity', 'write'], ['renameEntity', 'write'],
|
|
82
86
|
['deleteEntity', 'write'], ['mergeEntities', 'write'], ['suggestEntityMerges', 'read'],
|
|
87
|
+
// 自动关联的候选队列与实体确认同样按库鉴权:未登记的端点会被直接放行。
|
|
88
|
+
['getAnchorCandidates', 'read'], ['confirmEntities', 'write'], ['purgeAutoLinks', 'write'], ['clearLinkSuppression', 'write'],
|
|
83
89
|
['linkEntries', 'write'], ['unlinkEntry', 'write'], ['getRelationship', 'read'], ['updateRelationship', 'write'],
|
|
84
90
|
['listReviews', 'read'], ['resolveReview', 'write'], ['lexiconList', 'read'], ['lexiconSearch', 'read'], ['lexiconAdd', 'write'],
|
|
85
91
|
['lexiconUpdate', 'write'], ['lexiconDelete', 'write'], ['lexiconArchive', 'write'], ['lexiconRestore', 'write'],
|
|
@@ -1032,6 +1038,8 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1032
1038
|
// 整理 fork 的模型选择(三模式):恢复默认 = 回到 inherit,不留 host/custom 残配置。
|
|
1033
1039
|
'consolidationModelMode', 'consolidationModel', 'consolidationReasoningEffort',
|
|
1034
1040
|
'consolidationCustomBaseURL', 'consolidationCustomApiKey', 'consolidationCustomModel', 'consolidationCustomApi',
|
|
1041
|
+
// 自动关联:恢复默认 = 回到 suggest(只出候选、不写边)。
|
|
1042
|
+
'autoLinkMode', 'allowWorkerAssertion',
|
|
1035
1043
|
]) patch[key] = DEFAULT_SETTINGS[key]
|
|
1036
1044
|
return redactConsolidationSettings(updateSettings(patch))
|
|
1037
1045
|
}
|
|
@@ -1058,10 +1066,25 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1058
1066
|
// 写入;回包经 redactConsolidationSettings 打码,明文只落 state.json)。
|
|
1059
1067
|
'consolidationModelMode', 'consolidationModel', 'consolidationReasoningEffort',
|
|
1060
1068
|
'consolidationCustomBaseURL', 'consolidationCustomApiKey', 'consolidationCustomModel', 'consolidationCustomApi',
|
|
1069
|
+
// 自动关联的写入门控(DESIGN §6.4):suggest / deterministic / off。
|
|
1070
|
+
'autoLinkMode', 'allowWorkerAssertion',
|
|
1061
1071
|
])
|
|
1062
1072
|
const clean = {}
|
|
1063
1073
|
for (const [k, v] of Object.entries(patch)) if (allowed.has(k)) clean[k] = v
|
|
1064
|
-
|
|
1074
|
+
const beforeMode = getSettings().autoLinkMode
|
|
1075
|
+
const saved = redactConsolidationSettings(updateSettings(clean))
|
|
1076
|
+
// 切换到确定性写边时补一次全量重算:off/suggest 期间确认过的实体状态已是
|
|
1077
|
+
// confirmed,日常按 ids 的增量不会碰它们,否则提及边会永久缺失。
|
|
1078
|
+
if (clean.autoLinkMode === 'deterministic' && beforeMode !== 'deterministic') {
|
|
1079
|
+
try {
|
|
1080
|
+
for (const lib of listLibraries()) {
|
|
1081
|
+
await refreshPrivateAutoLinks({ libraryId: lib.id, full: true })
|
|
1082
|
+
}
|
|
1083
|
+
} catch (error) {
|
|
1084
|
+
try { warn('auto-link rebuild after mode switch skipped: ' + (error?.message || error)) } catch {}
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
return saved
|
|
1065
1088
|
}
|
|
1066
1089
|
case 'listForkModelOptions': {
|
|
1067
1090
|
// 整理 fork 模型选择器的数据源:宿主已激活 route 的 provider/model 目录 +
|
|
@@ -1198,7 +1221,12 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1198
1221
|
return { ok: true, scopeMissing: libraryScopeMissing(result.library), archived: archivedLibraryView() }
|
|
1199
1222
|
}
|
|
1200
1223
|
case 'listSessions': {
|
|
1201
|
-
|
|
1224
|
+
const sessions = await recentSessions(ctx, payload?.limit)
|
|
1225
|
+
// 手动整理按钮需要「这个库绑了哪些对话」。绑定表里本来就有 libraryId
|
|
1226
|
+
// (boundSessions 计数用的就是它),这里只补一个只读字段:不新增端点、
|
|
1227
|
+
// 不动鉴权,整理仍然走会话维度的 generatePrivate(与侧边栏同一通道)。
|
|
1228
|
+
const bindings = loadState().sessions || {}
|
|
1229
|
+
return { sessions: sessions.map(row => ({ ...row, libraryId: bindings[row.id]?.libraryId || null })) }
|
|
1202
1230
|
}
|
|
1203
1231
|
case 'listPrivate': {
|
|
1204
1232
|
const sessionId = requireSessionId(payload)
|
|
@@ -1456,8 +1484,19 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1456
1484
|
return getGraph(payload || {})
|
|
1457
1485
|
case 'listEntities':
|
|
1458
1486
|
return listEntities(payload || {})
|
|
1459
|
-
case 'createEntity':
|
|
1460
|
-
|
|
1487
|
+
case 'createEntity': {
|
|
1488
|
+
// 手工创建就是一次用户断言:直接 confirmed,并立刻挂上提及边。
|
|
1489
|
+
const entity = createEntity({ ...(payload || {}), status: 'confirmed', confirmedBy: 'user', origin: 'user' })
|
|
1490
|
+
if (entity?.status === 'confirmed') {
|
|
1491
|
+
let suppression = null
|
|
1492
|
+
try { suppression = suppressionSet(payload?.libraryId) } catch {}
|
|
1493
|
+
try {
|
|
1494
|
+
refreshEntityMentions({ libraryId: payload?.libraryId, entity, suppression, operation: 'auto-link-create' })
|
|
1495
|
+
} catch {}
|
|
1496
|
+
resetAnchorCandidatesCache()
|
|
1497
|
+
}
|
|
1498
|
+
return entity
|
|
1499
|
+
}
|
|
1461
1500
|
case 'renameEntity':
|
|
1462
1501
|
return renameEntity(payload || {})
|
|
1463
1502
|
case 'deleteEntity':
|
|
@@ -1466,6 +1505,33 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1466
1505
|
return mergeEntities(payload || {})
|
|
1467
1506
|
case 'suggestEntityMerges':
|
|
1468
1507
|
return suggestEntityMerges(payload || {})
|
|
1508
|
+
case 'getAnchorCandidates':
|
|
1509
|
+
// 派生数据:只读记忆/实体/词典,生成本库的待确认队列快照。
|
|
1510
|
+
return generateAnchorCandidates({ libraryId: payload?.libraryId, force: payload?.force === true })
|
|
1511
|
+
case 'confirmEntities': {
|
|
1512
|
+
// 人工确认是唯一入口:确认后同步补挂提及边(增量 R1),不等下次整理。
|
|
1513
|
+
const result = confirmEntities({ libraryId: payload?.libraryId, entityIds: payload?.entityIds, by: 'user' })
|
|
1514
|
+
resetAnchorCandidatesCache()
|
|
1515
|
+
return result
|
|
1516
|
+
}
|
|
1517
|
+
case 'purgeAutoLinks': {
|
|
1518
|
+
// 关系图的“删除全部自动边”:只删 source:'auto',并写抑制键防复活。
|
|
1519
|
+
const result = purgeAutoLinks({ libraryId: payload?.libraryId })
|
|
1520
|
+
resetAnchorCandidatesCache()
|
|
1521
|
+
return result
|
|
1522
|
+
}
|
|
1523
|
+
case 'clearLinkSuppression': {
|
|
1524
|
+
// 反向操作:清除本库的删除标记;deterministic 模式下顺带全量重算一次。
|
|
1525
|
+
const result = clearSuppression(payload?.libraryId)
|
|
1526
|
+
let rebuilt = null
|
|
1527
|
+
try {
|
|
1528
|
+
rebuilt = await refreshPrivateAutoLinks({ libraryId: payload?.libraryId, full: true })
|
|
1529
|
+
} catch (error) {
|
|
1530
|
+
try { warn('auto-link rebuild after suppression clear skipped: ' + (error?.message || error)) } catch {}
|
|
1531
|
+
}
|
|
1532
|
+
resetAnchorCandidatesCache()
|
|
1533
|
+
return { ...result, rebuilt: rebuilt?.applied ? (rebuilt.applied.added + rebuilt.applied.updated) : 0, skipped: rebuilt?.skipped || null }
|
|
1534
|
+
}
|
|
1469
1535
|
case 'linkEntries':
|
|
1470
1536
|
return linkEntries(payload || {})
|
|
1471
1537
|
case 'unlinkEntry':
|
|
@@ -1915,10 +1981,9 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1915
1981
|
return getMemuConfig()
|
|
1916
1982
|
case 'setEmbeddingSource': {
|
|
1917
1983
|
const config = setEmbeddingSource(String(payload?.source || ''))
|
|
1918
|
-
//
|
|
1919
|
-
//
|
|
1984
|
+
// 两条向量路线现在共用同一个常驻解释器:切回远程 API 不应释放它,
|
|
1985
|
+
// 否则下一次召回又会重新付一遍 Python 导入链的冷启动。
|
|
1920
1986
|
if (config?.source === 'local') void prewarmMemuResident()
|
|
1921
|
-
else closeMemuResident()
|
|
1922
1987
|
return config
|
|
1923
1988
|
}
|
|
1924
1989
|
case 'saveMemuConfig':
|
package/lib/state.js
CHANGED
|
@@ -27,6 +27,11 @@ export const DEFAULT_SETTINGS = {
|
|
|
27
27
|
// Producer-owned tool meta is the preferred integration and needs no allowlist.
|
|
28
28
|
inboundToolNames: [],
|
|
29
29
|
autoInject: 'smart',
|
|
30
|
+
// 自动关联(DESIGN §6.4):'suggest' 只出候选、不写任何边(迁移期默认),
|
|
31
|
+
// 'deterministic' 只写由已确认实体或字段证据推出的确定性边,'off' 完全关闭。
|
|
32
|
+
// allowWorkerAssertion 是 v3 的预留开关(worker 确认实体),本版不读取。
|
|
33
|
+
autoLinkMode: 'suggest',
|
|
34
|
+
allowWorkerAssertion: false,
|
|
30
35
|
// These defaults are tuned for high-density chat — a QQ-style group where many
|
|
31
36
|
// short messages arrive per minute, in fragments rather than sentences, and the
|
|
32
37
|
// topic drifts every few of them. Under that cadence the failure mode is not
|
|
@@ -407,7 +412,7 @@ export function updateSettings(patch) {
|
|
|
407
412
|
activeMemoryMinScore: [0, 10], activeMemoryStarvationMinutes: [1, 1440],
|
|
408
413
|
activeMemoryCooldownMinutes: [0, 10080], activeMemoryRecallCooldownMinutes: [0, 10080],
|
|
409
414
|
}
|
|
410
|
-
const enums = { autoInject: ['smart', 'anchor-only', 'per-turn', 'off'], memoryMode: ['local', 'cloud'], memoryBackend: ['agent', 'api'], vectorSource: ['local', 'api'], newSessionDefault: ['off', 'auto', 'global', 'both'], curatorReviewMode: ['auto', 'review-all'], salientWake: ['off', 'schedule'], consolidationModelMode: ['inherit', 'host', 'custom'], consolidationReasoningEffort: ['inherit', 'off', 'low', 'medium', 'high'], consolidationCustomApi: ['openai-completions', 'openai-responses', 'anthropic-messages'] }
|
|
415
|
+
const enums = { autoInject: ['smart', 'anchor-only', 'per-turn', 'off'], autoLinkMode: ['suggest', 'deterministic', 'off'], memoryMode: ['local', 'cloud'], memoryBackend: ['agent', 'api'], vectorSource: ['local', 'api'], newSessionDefault: ['off', 'auto', 'global', 'both'], curatorReviewMode: ['auto', 'review-all'], salientWake: ['off', 'schedule'], consolidationModelMode: ['inherit', 'host', 'custom'], consolidationReasoningEffort: ['inherit', 'off', 'low', 'medium', 'high'], consolidationCustomApi: ['openai-completions', 'openai-responses', 'anthropic-messages'] }
|
|
411
416
|
for (const [key, value] of Object.entries(patch || {})) {
|
|
412
417
|
if (!Object.hasOwn(DEFAULT_SETTINGS, key)) continue
|
|
413
418
|
if (enums[key]) {
|
|
@@ -663,7 +668,7 @@ export function deleteLibrary(id) {
|
|
|
663
668
|
const vectorGenerationFiles = fs.existsSync(librariesDir())
|
|
664
669
|
? fs.readdirSync(librariesDir()).filter(name => name.startsWith(vectorPrefix) && name.endsWith('.sqlite3')).map(name => path.join(librariesDir(), name))
|
|
665
670
|
: []
|
|
666
|
-
for (const file of [activeVectorDb, legacyVectorDb, ...vectorGenerationFiles, ...['json', 'entities.json', 'media.json', 'stats.json'].map(suffix => path.join(indexDir(), `${id}.${suffix}`))]) {
|
|
671
|
+
for (const file of [activeVectorDb, legacyVectorDb, ...vectorGenerationFiles, ...['json', 'entities.json', 'media.json', 'stats.json', 'link-suppression.json', 'anchor-candidates.json'].map(suffix => path.join(indexDir(), `${id}.${suffix}`))]) {
|
|
667
672
|
if (!file) continue
|
|
668
673
|
try {
|
|
669
674
|
if (fs.existsSync(file)) { fs.rmSync(file, { force: true }); removed.push(file) }
|
package/lib/tools.js
CHANGED
|
@@ -310,7 +310,9 @@ export function registerTools(ctx, { only = null } = {}) {
|
|
|
310
310
|
if (existing.kind !== kind) throw new Error(`entity "${name}" already exists as ${existing.kind}; use that kind instead of ${kind}`)
|
|
311
311
|
toId = existing.id
|
|
312
312
|
} else {
|
|
313
|
-
|
|
313
|
+
// worker 显式点名只创建实体与一条非 auto 边,不等于确认:
|
|
314
|
+
// allowWorkerAssertion 在 v3 是预留开关,确认仍由用户完成。
|
|
315
|
+
toId = createEntity({ exec, name, kind, status: 'provisional', origin: 'worker' }).id
|
|
314
316
|
}
|
|
315
317
|
}
|
|
316
318
|
return JSON.stringify(linkEntries({ exec, fromId: args.from, toId, kind: args.kind, note: args.note, confidence: args.confidence }))
|
|
@@ -319,7 +321,7 @@ export function registerTools(ctx, { only = null } = {}) {
|
|
|
319
321
|
|
|
320
322
|
tools.push(toolBase(
|
|
321
323
|
'memu_private_link_suggest',
|
|
322
|
-
'Local algorithm pass over the memories this consolidation just wrote. It
|
|
324
|
+
'Local algorithm pass over the memories this consolidation just wrote. It refreshes only deterministic evidence edges (mentions of confirmed entities, conflicts_with / supersedes / same fact_key) and returns uncertain statistical pairs for you to adjudicate with memu_private_link. Similarity and shared tokens never create an edge. Call it once after writing, with the ids you created or updated; it needs no extra transcript read and never returns full memory bodies.',
|
|
323
325
|
{
|
|
324
326
|
ids: {
|
|
325
327
|
type: 'array',
|
|
@@ -1,62 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright 2010-2021 Mike Bostock
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
5
|
-
with or without fee is hereby granted, provided that the above copyright notice
|
|
6
|
-
and this permission notice appear in all copies.
|
|
7
|
-
|
|
8
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
10
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
12
|
-
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
13
|
-
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
14
|
-
THIS SOFTWARE.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
d3-dispatch
|
|
18
|
-
Copyright 2010-2021 Mike Bostock
|
|
19
|
-
|
|
20
|
-
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
21
|
-
with or without fee is hereby granted, provided that the above copyright notice
|
|
22
|
-
and this permission notice appear in all copies.
|
|
23
|
-
|
|
24
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
25
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
26
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
27
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
28
|
-
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
29
|
-
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
30
|
-
THIS SOFTWARE.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
d3-quadtree
|
|
34
|
-
Copyright 2010-2021 Mike Bostock
|
|
35
|
-
|
|
36
|
-
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
37
|
-
with or without fee is hereby granted, provided that the above copyright notice
|
|
38
|
-
and this permission notice appear in all copies.
|
|
39
|
-
|
|
40
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
41
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
42
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
43
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
44
|
-
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
45
|
-
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
46
|
-
THIS SOFTWARE.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
d3-timer
|
|
50
|
-
Copyright 2010-2021 Mike Bostock
|
|
51
|
-
|
|
52
|
-
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
53
|
-
with or without fee is hereby granted, provided that the above copyright notice
|
|
54
|
-
and this permission notice appear in all copies.
|
|
55
|
-
|
|
56
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
57
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
58
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
59
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
60
|
-
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
61
|
-
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
62
|
-
THIS SOFTWARE.
|
|
1
|
+
graph-view.bundle.js: 本 bundle 无第三方运行时依赖(自研力导向引擎)。
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* Generated by scripts/build-graph.mjs. Licenses: graph-LICENSE.txt */
|
|
2
|
-
var DshMemuGraph=(()=>{var ht=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var xe=Object.prototype.hasOwnProperty;var pe=(t,e)=>{for(var n in e)ht(t,n,{get:e[n],enumerable:!0})},de=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of he(e))!xe.call(t,a)&&a!==n&&ht(t,a,{get:()=>e[a],enumerable:!(i=ce(e,a))||i.enumerable});return t};var ye=t=>de(ht({},"__esModule",{value:!0}),t);var De={};pe(De,{DEFAULT_OPTIONS:()=>Nt,createGraphView:()=>Te,createLayout:()=>ee,fitCamera:()=>ne,placeLabels:()=>re,zoomCamera:()=>At});function zt(t){let e=+this._x.call(null,t),n=+this._y.call(null,t);return It(this.cover(e,n),e,n,t)}function It(t,e,n,i){if(isNaN(e)||isNaN(n))return t;var a,f=t._root,s={data:i},o=t._x0,u=t._y0,l=t._x1,d=t._y1,y,m,h,v,r,c,p,g;if(!f)return t._root=s,t;for(;f.length;)if((r=e>=(y=(o+l)/2))?o=y:l=y,(c=n>=(m=(u+d)/2))?u=m:d=m,a=f,!(f=f[p=c<<1|r]))return a[p]=s,t;if(h=+t._x.call(null,f.data),v=+t._y.call(null,f.data),e===h&&n===v)return s.next=f,a?a[p]=s:t._root=s,t;do a=a?a[p]=new Array(4):t._root=new Array(4),(r=e>=(y=(o+l)/2))?o=y:l=y,(c=n>=(m=(u+d)/2))?u=m:d=m;while((p=c<<1|r)===(g=(v>=m)<<1|h>=y));return a[g]=f,a[p]=s,t}function St(t){var e,n,i=t.length,a,f,s=new Array(i),o=new Array(i),u=1/0,l=1/0,d=-1/0,y=-1/0;for(n=0;n<i;++n)isNaN(a=+this._x.call(null,e=t[n]))||isNaN(f=+this._y.call(null,e))||(s[n]=a,o[n]=f,a<u&&(u=a),a>d&&(d=a),f<l&&(l=f),f>y&&(y=f));if(u>d||l>y)return this;for(this.cover(u,l).cover(d,y),n=0;n<i;++n)It(this,s[n],o[n],t[n]);return this}function Tt(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,i=this._y0,a=this._x1,f=this._y1;if(isNaN(n))a=(n=Math.floor(t))+1,f=(i=Math.floor(e))+1;else{for(var s=a-n||1,o=this._root,u,l;n>t||t>=a||i>e||e>=f;)switch(l=(e<i)<<1|t<n,u=new Array(4),u[l]=o,o=u,s*=2,l){case 0:a=n+s,f=i+s;break;case 1:n=a-s,f=i+s;break;case 2:a=n+s,i=f-s;break;case 3:n=a-s,i=f-s;break}this._root&&this._root.length&&(this._root=o)}return this._x0=n,this._y0=i,this._x1=a,this._y1=f,this}function Dt(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function Ct(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function E(t,e,n,i,a){this.node=t,this.x0=e,this.y0=n,this.x1=i,this.y1=a}function Pt(t,e,n){var i,a=this._x0,f=this._y0,s,o,u,l,d=this._x1,y=this._y1,m=[],h=this._root,v,r;for(h&&m.push(new E(h,a,f,d,y)),n==null?n=1/0:(a=t-n,f=e-n,d=t+n,y=e+n,n*=n);v=m.pop();)if(!(!(h=v.node)||(s=v.x0)>d||(o=v.y0)>y||(u=v.x1)<a||(l=v.y1)<f))if(h.length){var c=(s+u)/2,p=(o+l)/2;m.push(new E(h[3],c,p,u,l),new E(h[2],s,p,c,l),new E(h[1],c,o,u,p),new E(h[0],s,o,c,p)),(r=(e>=p)<<1|t>=c)&&(v=m[m.length-1],m[m.length-1]=m[m.length-1-r],m[m.length-1-r]=v)}else{var g=t-+this._x.call(null,h.data),b=e-+this._y.call(null,h.data),w=g*g+b*b;if(w<n){var N=Math.sqrt(n=w);a=t-N,f=e-N,d=t+N,y=e+N,i=h.data}}return i}function Et(t){if(isNaN(d=+this._x.call(null,t))||isNaN(y=+this._y.call(null,t)))return this;var e,n=this._root,i,a,f,s=this._x0,o=this._y0,u=this._x1,l=this._y1,d,y,m,h,v,r,c,p;if(!n)return this;if(n.length)for(;;){if((v=d>=(m=(s+u)/2))?s=m:u=m,(r=y>=(h=(o+l)/2))?o=h:l=h,e=n,!(n=n[c=r<<1|v]))return this;if(!n.length)break;(e[c+1&3]||e[c+2&3]||e[c+3&3])&&(i=e,p=c)}for(;n.data!==t;)if(a=n,!(n=n.next))return this;return(f=n.next)&&delete n.next,a?(f?a.next=f:delete a.next,this):e?(f?e[c]=f:delete e[c],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(i?i[p]=n:this._root=n),this):(this._root=f,this)}function Ot(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function jt(){return this._root}function Rt(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function Ft(t){var e=[],n,i=this._root,a,f,s,o,u;for(i&&e.push(new E(i,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(i=n.node,f=n.x0,s=n.y0,o=n.x1,u=n.y1)&&i.length){var l=(f+o)/2,d=(s+u)/2;(a=i[3])&&e.push(new E(a,l,d,o,u)),(a=i[2])&&e.push(new E(a,f,d,l,u)),(a=i[1])&&e.push(new E(a,l,s,o,d)),(a=i[0])&&e.push(new E(a,f,s,l,d))}return this}function Lt(t){var e=[],n=[],i;for(this._root&&e.push(new E(this._root,this._x0,this._y0,this._x1,this._y1));i=e.pop();){var a=i.node;if(a.length){var f,s=i.x0,o=i.y0,u=i.x1,l=i.y1,d=(s+u)/2,y=(o+l)/2;(f=a[0])&&e.push(new E(f,s,o,d,y)),(f=a[1])&&e.push(new E(f,d,o,u,y)),(f=a[2])&&e.push(new E(f,s,y,d,l)),(f=a[3])&&e.push(new E(f,d,y,u,l))}n.push(i)}for(;i=n.pop();)t(i.node,i.x0,i.y0,i.x1,i.y1);return this}function Bt(t){return t[0]}function Wt(t){return arguments.length?(this._x=t,this):this._x}function Yt(t){return t[1]}function Xt(t){return arguments.length?(this._y=t,this):this._y}function q(t,e,n){var i=new xt(e??Bt,n??Yt,NaN,NaN,NaN,NaN);return t==null?i:i.addAll(t)}function xt(t,e,n,i,a,f){this._x=t,this._y=e,this._x0=n,this._y0=i,this._x1=a,this._y1=f,this._root=void 0}function Ht(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var j=q.prototype=xt.prototype;j.copy=function(){var t=new xt(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,i;if(!e)return t;if(!e.length)return t._root=Ht(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var a=0;a<4;++a)(i=e.source[a])&&(i.length?n.push({source:i,target:e.target[a]=new Array(4)}):e.target[a]=Ht(i));return t};j.add=zt;j.addAll=St;j.cover=Tt;j.data=Dt;j.extent=Ct;j.find=Pt;j.remove=Et;j.removeAll=Ot;j.root=jt;j.size=Rt;j.visit=Ft;j.visitAfter=Lt;j.x=Wt;j.y=Xt;function P(t){return function(){return t}}function X(t){return(t()-.5)*1e-6}function me(t){return t.x+t.vx}function ge(t){return t.y+t.vy}function pt(t){var e,n,i,a=1,f=1;typeof t!="function"&&(t=P(t==null?1:+t));function s(){for(var l,d=e.length,y,m,h,v,r,c,p=0;p<f;++p)for(y=q(e,me,ge).visitAfter(o),l=0;l<d;++l)m=e[l],r=n[m.index],c=r*r,h=m.x+m.vx,v=m.y+m.vy,y.visit(g);function g(b,w,N,z,I){var T=b.data,O=b.r,D=r+O;if(T){if(T.index>m.index){var L=h-T.x-T.vx,B=v-T.y-T.vy,C=L*L+B*B;C<D*D&&(L===0&&(L=X(i),C+=L*L),B===0&&(B=X(i),C+=B*B),C=(D-(C=Math.sqrt(C)))/C*a,m.vx+=(L*=C)*(D=(O*=O)/(c+O)),m.vy+=(B*=C)*D,T.vx-=L*(D=1-D),T.vy-=B*D)}return}return w>h+D||z<h-D||N>v+D||I<v-D}}function o(l){if(l.data)return l.r=n[l.data.index];for(var d=l.r=0;d<4;++d)l[d]&&l[d].r>l.r&&(l.r=l[d].r)}function u(){if(e){var l,d=e.length,y;for(n=new Array(d),l=0;l<d;++l)y=e[l],n[y.index]=+t(y,l,e)}}return s.initialize=function(l,d){e=l,i=d,u()},s.iterations=function(l){return arguments.length?(f=+l,s):f},s.strength=function(l){return arguments.length?(a=+l,s):a},s.radius=function(l){return arguments.length?(t=typeof l=="function"?l:P(+l),u(),s):t},s}function we(t){return t.index}function Qt(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function dt(t){var e=we,n=y,i,a=P(30),f,s,o,u,l,d=1;t==null&&(t=[]);function y(c){return 1/Math.min(o[c.source.index],o[c.target.index])}function m(c){for(var p=0,g=t.length;p<d;++p)for(var b=0,w,N,z,I,T,O,D;b<g;++b)w=t[b],N=w.source,z=w.target,I=z.x+z.vx-N.x-N.vx||X(l),T=z.y+z.vy-N.y-N.vy||X(l),O=Math.sqrt(I*I+T*T),O=(O-f[b])/O*c*i[b],I*=O,T*=O,z.vx-=I*(D=u[b]),z.vy-=T*D,N.vx+=I*(D=1-D),N.vy+=T*D}function h(){if(s){var c,p=s.length,g=t.length,b=new Map(s.map((N,z)=>[e(N,z,s),N])),w;for(c=0,o=new Array(p);c<g;++c)w=t[c],w.index=c,typeof w.source!="object"&&(w.source=Qt(b,w.source)),typeof w.target!="object"&&(w.target=Qt(b,w.target)),o[w.source.index]=(o[w.source.index]||0)+1,o[w.target.index]=(o[w.target.index]||0)+1;for(c=0,u=new Array(g);c<g;++c)w=t[c],u[c]=o[w.source.index]/(o[w.source.index]+o[w.target.index]);i=new Array(g),v(),f=new Array(g),r()}}function v(){if(s)for(var c=0,p=t.length;c<p;++c)i[c]=+n(t[c],c,t)}function r(){if(s)for(var c=0,p=t.length;c<p;++c)f[c]=+a(t[c],c,t)}return m.initialize=function(c,p){s=c,l=p,h()},m.links=function(c){return arguments.length?(t=c,h(),m):t},m.id=function(c){return arguments.length?(e=c,m):e},m.iterations=function(c){return arguments.length?(d=+c,m):d},m.strength=function(c){return arguments.length?(n=typeof c=="function"?c:P(+c),v(),m):n},m.distance=function(c){return arguments.length?(a=typeof c=="function"?c:P(+c),r(),m):a},m}var ve={value:()=>{}};function Vt(){for(var t=0,e=arguments.length,n={},i;t<e;++t){if(!(i=arguments[t]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new rt(n)}function rt(t){this._=t}function _e(t,e){return t.trim().split(/^|\s+/).map(function(n){var i="",a=n.indexOf(".");if(a>=0&&(i=n.slice(a+1),n=n.slice(0,a)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}rt.prototype=Vt.prototype={constructor:rt,on:function(t,e){var n=this._,i=_e(t+"",n),a,f=-1,s=i.length;if(arguments.length<2){for(;++f<s;)if((a=(t=i[f]).type)&&(a=Me(n[a],t.name)))return a;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++f<s;)if(a=(t=i[f]).type)n[a]=Ut(n[a],t.name,e);else if(e==null)for(a in n)n[a]=Ut(n[a],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new rt(t)},call:function(t,e){if((a=arguments.length-2)>0)for(var n=new Array(a),i=0,a,f;i<a;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(f=this._[t],i=0,a=f.length;i<a;++i)f[i].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var i=this._[t],a=0,f=i.length;a<f;++a)i[a].value.apply(e,n)}};function Me(t,e){for(var n=0,i=t.length,a;n<i;++n)if((a=t[n]).name===e)return a.value}function Ut(t,e,n){for(var i=0,a=t.length;i<a;++i)if(t[i].name===e){t[i]=ve,t=t.slice(0,i).concat(t.slice(i+1));break}return n!=null&&t.push({name:e,value:n}),t}var yt=Vt;var J=0,Z=0,K=0,$t=1e3,it,tt,ot=0,$=0,at=0,et=typeof performance=="object"&&performance.now?performance:Date,Gt=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function wt(){return $||(Gt(be),$=et.now()+at)}function be(){$=0}function mt(){this._call=this._time=this._next=null}mt.prototype=st.prototype={constructor:mt,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?wt():+n)+(e==null?0:+e),!this._next&&tt!==this&&(tt?tt._next=this:it=this,tt=this),this._call=t,this._time=n,gt()},stop:function(){this._call&&(this._call=null,this._time=1/0,gt())}};function st(t,e,n){var i=new mt;return i.restart(t,e,n),i}function Jt(){wt(),++J;for(var t=it,e;t;)(e=$-t._time)>=0&&t._call.call(void 0,e),t=t._next;--J}function qt(){$=(ot=et.now())+at,J=Z=0;try{Jt()}finally{J=0,Ne(),$=0}}function Ae(){var t=et.now(),e=t-ot;e>$t&&(at-=e,ot=t)}function Ne(){for(var t,e=it,n,i=1/0;e;)e._call?(i>e._time&&(i=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:it=n);tt=t,gt(i)}function gt(t){if(!J){Z&&(Z=clearTimeout(Z));var e=t-$;e>24?(t<1/0&&(Z=setTimeout(qt,t-et.now()-at)),K&&(K=clearInterval(K))):(K||(ot=et.now(),K=setInterval(Ae,$t)),J=1,Gt(qt))}}function Kt(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function Zt(t){return t.x}function te(t){return t.y}var ke=10,ze=Math.PI*(3-Math.sqrt(5));function vt(t){var e,n=1,i=.001,a=1-Math.pow(i,1/300),f=0,s=.6,o=new Map,u=st(y),l=yt("tick","end"),d=Kt();t==null&&(t=[]);function y(){m(),l.call("tick",e),n<i&&(u.stop(),l.call("end",e))}function m(r){var c,p=t.length,g;r===void 0&&(r=1);for(var b=0;b<r;++b)for(n+=(f-n)*a,o.forEach(function(w){w(n)}),c=0;c<p;++c)g=t[c],g.fx==null?g.x+=g.vx*=s:(g.x=g.fx,g.vx=0),g.fy==null?g.y+=g.vy*=s:(g.y=g.fy,g.vy=0);return e}function h(){for(var r=0,c=t.length,p;r<c;++r){if(p=t[r],p.index=r,p.fx!=null&&(p.x=p.fx),p.fy!=null&&(p.y=p.fy),isNaN(p.x)||isNaN(p.y)){var g=ke*Math.sqrt(.5+r),b=r*ze;p.x=g*Math.cos(b),p.y=g*Math.sin(b)}(isNaN(p.vx)||isNaN(p.vy))&&(p.vx=p.vy=0)}}function v(r){return r.initialize&&r.initialize(t,d),r}return h(),e={tick:m,restart:function(){return u.restart(y),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,h(),o.forEach(v),e):t},alpha:function(r){return arguments.length?(n=+r,e):n},alphaMin:function(r){return arguments.length?(i=+r,e):i},alphaDecay:function(r){return arguments.length?(a=+r,e):+a},alphaTarget:function(r){return arguments.length?(f=+r,e):f},velocityDecay:function(r){return arguments.length?(s=1-r,e):1-s},randomSource:function(r){return arguments.length?(d=r,o.forEach(v),e):d},force:function(r,c){return arguments.length>1?(c==null?o.delete(r):o.set(r,v(c)),e):o.get(r)},find:function(r,c,p){var g=0,b=t.length,w,N,z,I,T;for(p==null?p=1/0:p*=p,g=0;g<b;++g)I=t[g],w=r-I.x,N=c-I.y,z=w*w+N*N,z<p&&(T=I,p=z);return T},on:function(r,c){return arguments.length>1?(l.on(r,c),e):l.on(r)}}}function _t(){var t,e,n,i,a=P(-30),f,s=1,o=1/0,u=.81;function l(h){var v,r=t.length,c=q(t,Zt,te).visitAfter(y);for(i=h,v=0;v<r;++v)e=t[v],c.visit(m)}function d(){if(t){var h,v=t.length,r;for(f=new Array(v),h=0;h<v;++h)r=t[h],f[r.index]=+a(r,h,t)}}function y(h){var v=0,r,c,p=0,g,b,w;if(h.length){for(g=b=w=0;w<4;++w)(r=h[w])&&(c=Math.abs(r.value))&&(v+=r.value,p+=c,g+=c*r.x,b+=c*r.y);h.x=g/p,h.y=b/p}else{r=h,r.x=r.data.x,r.y=r.data.y;do v+=f[r.data.index];while(r=r.next)}h.value=v}function m(h,v,r,c){if(!h.value)return!0;var p=h.x-e.x,g=h.y-e.y,b=c-v,w=p*p+g*g;if(b*b/u<w)return w<o&&(p===0&&(p=X(n),w+=p*p),g===0&&(g=X(n),w+=g*g),w<s&&(w=Math.sqrt(s*w)),e.vx+=p*h.value*i/w,e.vy+=g*h.value*i/w),!0;if(h.length||w>=o)return;(h.data!==e||h.next)&&(p===0&&(p=X(n),w+=p*p),g===0&&(g=X(n),w+=g*g),w<s&&(w=Math.sqrt(s*w)));do h.data!==e&&(b=f[h.data.index]*i/w,e.vx+=p*b,e.vy+=g*b);while(h=h.next)}return l.initialize=function(h,v){t=h,n=v,d()},l.strength=function(h){return arguments.length?(a=typeof h=="function"?h:P(+h),d(),l):a},l.distanceMin=function(h){return arguments.length?(s=h*h,l):Math.sqrt(s)},l.distanceMax=function(h){return arguments.length?(o=h*h,l):Math.sqrt(o)},l.theta=function(h){return arguments.length?(u=h*h,l):Math.sqrt(u)},l}function Mt(t){var e=P(.1),n,i,a;typeof t!="function"&&(t=P(t==null?0:+t));function f(o){for(var u=0,l=n.length,d;u<l;++u)d=n[u],d.vx+=(a[u]-d.x)*i[u]*o}function s(){if(n){var o,u=n.length;for(i=new Array(u),a=new Array(u),o=0;o<u;++o)i[o]=isNaN(a[o]=+t(n[o],o,n))?0:+e(n[o],o,n)}}return f.initialize=function(o){n=o,s()},f.strength=function(o){return arguments.length?(e=typeof o=="function"?o:P(+o),s(),f):e},f.x=function(o){return arguments.length?(t=typeof o=="function"?o:P(+o),s(),f):t},f}function bt(t){var e=P(.1),n,i,a;typeof t!="function"&&(t=P(t==null?0:+t));function f(o){for(var u=0,l=n.length,d;u<l;++u)d=n[u],d.vy+=(a[u]-d.y)*i[u]*o}function s(){if(n){var o,u=n.length;for(i=new Array(u),a=new Array(u),o=0;o<u;++o)i[o]=isNaN(a[o]=+t(n[o],o,n))?0:+e(n[o],o,n)}}return f.initialize=function(o){n=o,s()},f.strength=function(o){return arguments.length?(e=typeof o=="function"?o:P(+o),s(),f):e},f.y=function(o){return arguments.length?(t=typeof o=="function"?o:P(+o),s(),f):t},f}var Ie=200,Q=(t,e,n)=>Math.max(e,Math.min(n,t)),Nt=Object.freeze({repulsion:120,distance:100,labels:!0,motion:!0});function ee(){let t=new Map,e=[],n=[],i="",a={...Nt},f=vt().stop().alphaDecay(.035).velocityDecay(.48).force("charge",_t().strength(-a.repulsion).distanceMax(1400)).force("collision",pt(o=>o.radius+12).iterations(2)).force("x",Mt(0).strength(.025)).force("y",bt(0).strength(.025));return{simulation:f,update:o=>{let u=[...new Map((o.nodes||[]).slice(0,Ie).map(r=>[r.id,r])).values()].sort((r,c)=>String(r.id).localeCompare(String(c.id))),l=new Set(u.map(r=>r.id)),d=(o.edges||[]).filter(r=>l.has(r.from)&&l.has(r.to)&&r.from!==r.to),y=JSON.stringify([u.map(r=>r.id),d.map(r=>[r.from,r.to]).sort()]),m=i!==y,h=new Map;for(let r of d)h.set(r.from,(h.get(r.from)||0)+1),h.set(r.to,(h.get(r.to)||0)+1);let v=u.filter(r=>!t.has(r.id));for(let r=0;r<v.length;r++){let c=v[r],p=d.filter(z=>z.from===c.id||z.to===c.id).map(z=>t.get(z.from===c.id?z.to:z.from)).filter(Boolean),g=r*2.399963229728653,b=p.length?32:24*Math.sqrt(r+.5),w=p.length?p.reduce((z,I)=>z+I.x,0)/p.length:0,N=p.length?p.reduce((z,I)=>z+I.y,0)/p.length:0;t.set(c.id,{id:c.id,x:w+Math.cos(g)*b,y:N+Math.sin(g)*b,vx:0,vy:0})}e=u.map(r=>Object.assign(t.get(r.id),r,{degree:h.get(r.id)||0,radius:4+Math.min(3,Math.log2(1+(h.get(r.id)||0)))+Q(Number(r.strength)||0,0,1)*2})),n=d.map(r=>({...r,source:t.get(r.from),target:t.get(r.to)})),m&&(f.nodes(e).force("link",dt(n).id(r=>r.id).distance(a.distance).strength(.18)),f.alpha(i?.25:1)),i=y;for(let r of t.keys())t.size>800&&!l.has(r)&&t.delete(r);return m},get nodes(){return e},get edges(){return n},configure(o){a={...a,...o},f.force("charge").strength(-a.repulsion),f.force("link")?.distance(a.distance),f.alpha(Math.max(.25,f.alpha()))},settle(o=200){f.tick(o)},dispose(){f.stop(),t.clear()}}}function ne(t,e,n){if(!t.length)return{x:e/2,y:n/2,k:1};let i=Math.min(...t.map(u=>u.x-u.radius)),a=Math.max(...t.map(u=>u.x+u.radius)),f=Math.min(...t.map(u=>u.y-u.radius)),s=Math.max(...t.map(u=>u.y+u.radius)),o=Q(Math.min(Math.max(32,e-100)/Math.max(120,a-i),Math.max(32,n-96)/Math.max(120,s-f)),.06,1.6);return{x:e/2-(i+a)*o/2,y:n/2-(f+s)*o/2,k:o}}function At(t,e,n){let i=Q(t.k*e,.06,5);return{k:i,x:n.x-(n.x-t.x)*i/t.k,y:n.y-(n.y-t.y)*i/t.k}}var Se=(t,e)=>t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y;function re(t,e,n,i){let a=[...e],f=[];for(let s of t){let{x:o,y:u,radius:l,textWidth:d}=s,y=[{x:o-d/2,y:u+l+5},{x:o-d/2,y:u-l-21},{x:o+l+6,y:u-8},{x:o-l-d-6,y:u-8}];if(s.priority)for(let h of[28,48,72])y.push({x:o-d/2,y:u+l+h},{x:o-d/2,y:u-l-16-h},{x:o+l+h,y:u-8},{x:o-l-d-h,y:u-8});let m=y.map(h=>({...h,width:d,height:16})).find(h=>h.x>=5&&h.y>=5&&h.x+h.width<=n-5&&h.y+h.height<=i-5&&!a.some(v=>Se(h,v)));m&&(a.push({x:m.x-3,y:m.y-2,width:m.width+6,height:m.height+4}),f.push({...s,box:m}))}return f}function Te(t,{onFocus:e=()=>{},onZoom:n=()=>{},tooltip:i,reducedMotion:a=!1,emptyLabel:f=""}={}){let s=t.getContext("2d");if(!s)throw new Error("Canvas 2D is unavailable");let o=ee(),u=1,l=1,d=1,y={x:0,y:0,k:1},m={...Nt},h="",v=null,r=null,c=!1,p=!1,g=null,b=0,w=0,N=new Map,z=[],I=t.ownerDocument.defaultView,T=x=>({x:(x.x-y.x)/y.k,y:(x.y-y.y)/y.k}),O=x=>({x:x.x*y.k+y.x,y:x.y*y.k+y.y}),D=x=>Q(x.radius*Math.sqrt(y.k),2.5,22),L=x=>{let _=t.getBoundingClientRect();return{x:(x.clientX-_.left)*u/_.width,y:(x.clientY-_.top)*l/_.height}},B=x=>{let _=null,k=1/0;for(let A of o.nodes){let W=O(A),V=Math.hypot(W.x-x.x,W.y-x.y);V<=Math.max(10,D(A)+4)&&V<k&&(_=A,k=V)}return _},C=()=>{i&&(i.hidden=!0)},ie=(x,_)=>{v!==x&&(v=x,F()),t.style.cursor=r?"grabbing":x?"pointer":"grab",i&&(i.hidden=!x||!!r,!(!x||r)&&(i.textContent=String(x.title||x.id),i.style.left=`${Q(_.x+14,6,Math.max(6,u-Math.min(260,u-12)))}px`,i.style.top=`${(t.offsetTop||0)+Q(_.y+16,6,l-60)}px`))},oe=()=>{s.setTransform(d,0,0,d,0,0),s.clearRect(0,0,u,l);let x=I.getComputedStyle(t),_=x.color,k=x.getPropertyValue("--dsw-alias-bg-layer-1").trim()||"#ffffff",A=v?.id||h,W=new Set(A?[A]:[]);for(let S of o.edges)S.from===A&&W.add(S.to),S.to===A&&W.add(S.from);s.strokeStyle=_;for(let S of o.edges){let Y=O(S.source),M=O(S.target),R=A&&(S.from===A||S.to===A);s.globalAlpha=R?.6:A?.055:.16,s.lineWidth=R?1.5:.8,s.beginPath(),s.moveTo(Y.x,Y.y),s.lineTo(M.x,M.y),s.stroke()}let V=o.nodes.map(S=>({node:S,...O(S),radius:D(S)})).filter(S=>S.x>=-30&&S.x<=u+30&&S.y>=-30&&S.y<=l+30);for(let S of V){let Y=S.node,M=Y.missing?"#92959c":Y.kind==="global"?"#8b7bd8":Y.kind!=="memory"?"#36a582":Y.layer==="must_remember"?"#d97768":"#618fcd";s.globalAlpha=A&&!W.has(Y.id)?.22:1,s.fillStyle=M,s.beginPath(),s.arc(S.x,S.y,S.radius,0,Math.PI*2),s.fill(),Y.id===A&&(s.strokeStyle=M,s.lineWidth=1.5,s.beginPath(),s.arc(S.x,S.y,S.radius+4,0,Math.PI*2),s.stroke())}if(s.globalAlpha=1,m.labels){s.font="12px system-ui, sans-serif";let S=V.filter(M=>!A||W.has(M.node.id)).filter(M=>y.k>=.45||M.node.id===A||M.node.degree>=3||o.nodes.length<30).sort((M,R)=>+(R.node.id===A)-+(M.node.id===A)||R.node.degree-M.node.degree||String(M.node.id).localeCompare(String(R.node.id))).map(M=>{let R=String(M.node.title||M.node.id),H=R;for(;H.length>1&&s.measureText(H).width>Math.min(136,u-24);)H=H.slice(0,-1);return H!==R&&(H=H.slice(0,-2)+"..."),{...M,text:H,textWidth:s.measureText(H).width+4,priority:M.node.degree>=3||M.node.id===A}}),Y=re(S,V.map(M=>({x:M.x-M.radius-2,y:M.y-M.radius-2,width:M.radius*2+4,height:M.radius*2+4})),u,l);s.textAlign="left",s.textBaseline="top";for(let M of Y){let R={x:Q(M.x,M.box.x,M.box.x+M.box.width),y:Q(M.y,M.box.y,M.box.y+M.box.height)};Math.hypot(R.x-M.x,R.y-M.y)>M.radius+18&&(s.globalAlpha=.25,s.strokeStyle=_,s.lineWidth=.7,s.beginPath(),s.moveTo(M.x,M.y),s.lineTo(R.x,R.y),s.stroke()),s.fillStyle=k,s.globalAlpha=.88,s.fillRect(M.box.x-1,M.box.y,M.box.width+2,M.box.height),s.globalAlpha=M.node.id===A?1:.78,s.fillStyle=_,s.fillText(M.text,M.box.x+2,M.box.y+1)}s.globalAlpha=1}!o.nodes.length&&f&&(s.font="13px system-ui, sans-serif",s.textAlign="center",s.textBaseline="middle",s.fillStyle=_,s.globalAlpha=.55,s.fillText(f,u/2,l/2),s.globalAlpha=1)},ae=x=>{if(g=null,!p){if(m.motion&&!a&&o.simulation.alpha()>o.simulation.alphaMin()){for(w+=b?Math.min(64,x-b):17;w>=1e3/60;w-=1e3/60)o.simulation.tick();b=x,F()}else b=0,w=0;oe()}};function F(){!p&&g===null&&(g=I.requestAnimationFrame(ae))}let ft=()=>{n(y.k),F()},lt=()=>{y=ne(o.nodes,u,l),C(),ft()},nt=(x,_={x:u/2,y:l/2})=>{y=At(y,x,_),C(),ft()},ut=()=>{let x=t.getBoundingClientRect();if(!x.width||!x.height)return;let _=x.width,k=x.height;y.x+=(_-u)/2,y.y+=(k-l)/2,u=_,l=k,d=Math.min(2,I.devicePixelRatio||1),t.width=Math.round(u*d),t.height=Math.round(l*d),F()},G=()=>{r?.node&&(r.node.fx=null,r.node.fy=null,r.node.vx=0,r.node.vy=0)},se=()=>{G();let[x,_]=[...N.values()];r={type:"pinch",distance:Math.max(1,Math.hypot(_.x-x.x,_.y-x.y)),camera:{...y},center:{x:(x.x+_.x)/2,y:(x.y+_.y)/2},moved:!0}},fe=x=>{if(x.button!==0&&x.pointerType!=="touch")return;x.preventDefault(),t.focus({preventScroll:!0});let _=L(x);if(N.set(x.pointerId,_),t.setPointerCapture?.(x.pointerId),N.size>=2){se(),C();return}let k=B(_);r={type:k?"node":"pan",node:k,start:_,camera:{...y},moved:!1,offset:k?{x:k.x-T(_).x,y:k.y-T(_).y}:null},k&&(k.fx=k.x,k.fy=k.y,k.vx=0,k.vy=0),C(),t.style.cursor="grabbing"},le=x=>{let _=L(x);if(!N.has(x.pointerId)||!r){ie(B(_),_);return}if(N.set(x.pointerId,_),r.type==="pinch"){if(N.size<2)return;let[k,A]=[...N.values()],W={x:(k.x+A.x)/2,y:(k.y+A.y)/2};y=At(r.camera,Math.hypot(A.x-k.x,A.y-k.y)/r.distance,r.center),y.x+=W.x-r.center.x,y.y+=W.y-r.center.y,ft()}else{if(r.moved||(r.moved=Math.hypot(_.x-r.start.x,_.y-r.start.y)>5),!r.moved)return;if(r.node){let k=T(_),A=r.node;A.x=A.fx=k.x+r.offset.x,A.y=A.fy=k.y+r.offset.y,A.vx=0,A.vy=0,o.simulation.alpha(Math.max(.08,o.simulation.alpha()))}else y.x=r.camera.x+_.x-r.start.x,y.y=r.camera.y+_.y-r.start.y;F()}},ue=x=>{if(!N.has(x.pointerId))return;let _=x.type!=="pointerup",k=r?.node,A=!_&&!r?.moved&&r?.type!=="pinch";G(),N.delete(x.pointerId),r=null,N.size&&(r={type:"pan",start:[...N.values()][0],camera:{...y},moved:!0}),t.hasPointerCapture?.(x.pointerId)&&t.releasePointerCapture(x.pointerId),A&&e(k?.id||""),v=null,t.style.cursor="grab",C(),F()},U=(x,_,k,A)=>{x.addEventListener(_,k,A),z.push(()=>x.removeEventListener(_,k,A))};U(t,"pointerdown",fe),U(t,"pointermove",le);for(let x of["pointerup","pointercancel","lostpointercapture"])U(t,x,ue);U(t,"pointerleave",()=>{r||(v=null,C(),F())}),U(t,"wheel",x=>{x.preventDefault(),nt(Math.exp(-Q(x.deltaY,-160,160)*.0025),L(x))},{passive:!1}),U(t,"keydown",x=>{if(x.key==="+"||x.key==="=")nt(1.25);else if(x.key==="-")nt(.8);else if(x.key==="0"||x.key==="Home")lt();else if(x.key==="Escape")G(),r=null,N.clear(),e(""),C(),F();else if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(x.key)){let _=x.shiftKey?90:30;y.x+=x.key==="ArrowLeft"?_:x.key==="ArrowRight"?-_:0,y.y+=x.key==="ArrowUp"?_:x.key==="ArrowDown"?-_:0,F()}else return;x.preventDefault()}),U(I,"blur",()=>{G(),r=null,N.clear(),v=null,C(),F()});let kt=I.ResizeObserver?new I.ResizeObserver(ut):null;kt?.observe(t),U(I,"resize",ut);let ct=I.MutationObserver?new I.MutationObserver(F):null;return ct?.observe(t.ownerDocument.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}),t.ownerDocument.body&&ct?.observe(t.ownerDocument.body,{attributes:!0,attributeFilter:["class","data-theme","style"]}),ut(),{update(x,_=""){r?.node&&!x.nodes.some(A=>A.id===r.node.id)&&(G(),r=null,N.clear());let k=o.update(x);h=_,v&&!o.nodes.includes(v)&&(v=null,C()),!c&&o.nodes.length?(o.settle(220),c=!0,lt()):k&&a&&o.settle(180),F()},configure(x){let _=x.repulsion!==void 0&&x.repulsion!==m.repulsion||x.distance!==void 0&&x.distance!==m.distance;m={...m,...x},_&&(o.configure(m),a&&o.settle(180)),F()},fit:lt,zoom:nt,dispose(){p=!0,G(),g!==null&&I.cancelAnimationFrame(g);for(let x of z)x();kt?.disconnect(),ct?.disconnect(),o.dispose(),C()}}}return ye(De);})();
|
|
2
|
+
var DshMemuGraph=(()=>{var Tt=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var qt=Object.prototype.hasOwnProperty;var _t=(d,y)=>{for(var N in y)Tt(d,N,{get:y[N],enumerable:!0})},Gt=(d,y,N,L)=>{if(y&&typeof y=="object"||typeof y=="function")for(let R of jt(y))!qt.call(d,R)&&R!==N&&Tt(d,R,{get:()=>y[R],enumerable:!(L=$t(y,R))||L.enumerable});return d};var Wt=d=>Gt(Tt({},"__esModule",{value:!0}),d);var Zt={};_t(Zt,{DEFAULT_OPTIONS:()=>Ct,createForceLayout:()=>Rt,createGraphView:()=>Qt,fitCamera:()=>Et,placeLabels:()=>Xt,zoomCamera:()=>Nt});var Pt=Math.PI*2,Ht=2.399963229728653,Jt=200,Ut=800,Vt=new Set(["x","y","vx","vy","fx","fy"]),Y=(d,y,N)=>Math.max(y,Math.min(N,d)),Ct=Object.freeze({repulsion:120,distance:100,center:0,labels:!0,motion:!0,grid:!0,clusterScope:!0}),W=Object.freeze({cell:120,range:150,repel:900,link:.9,centerForce:.012,vDecay:.6,alphaDecay:.025,alphaTarget:.02}),dt=Object.freeze({memory:"#618fcd",must:"#d97768",short:"#8a93a6",entity:"#36a582",provisional:"#b9963f",global:"#8b7bd8",missing:"#92959c"}),zt=Object.freeze({"entity-mention":"#4f6bdb",conflict:"#d9705f",supersede:"#c08a49","fact-key":"#7a8fbc","worker-quote":"#8a7cc0"}),Yt=(d,y,N)=>d.rule&&zt[d.rule]?zt[d.rule]:d.manual?N:y,wt=d=>d.missing?dt.missing:d.kind==="global"?dt.global:d.kind!=="memory"?d.status==="provisional"?dt.provisional:dt.entity:d.layer==="must_remember"?dt.must:d.layer==="short_term"?dt.short:dt.memory,Dt=d=>{let y=2166136261,N=String(d);for(let L=0;L<N.length;L++)y^=N.charCodeAt(L),y=Math.imul(y,16777619);return y>>>0},Ft=(d,y)=>`${Math.floor(d/W.cell)},${Math.floor(y/W.cell)}`;function Rt(d={}){let y=new Map,N=new Map,L=[],R=[],H=new Map,U=null,e="",f=1,T={...Ct,...d},O=null,V=!1,v=!1,z=!1,ht=()=>({repel:Y(T.repulsion,1,1e3)/120,linkDist:Y(T.distance,1,1e3)/100,center:Y(T.center,0,20)}),K=(r,l)=>Y(Math.hypot(r.x-l.x,r.y-l.y)||56,48,160),b=()=>{let r=new Map;for(let l of R)r.has(l.from)||r.set(l.from,new Set),r.has(l.to)||r.set(l.to,new Set),r.get(l.from).add(l.to),r.get(l.to).add(l.from);return r},St=()=>{let r=new Map;for(let l of L){if(r.has(l.id))continue;let x=new Set([l.id]),k=[l.id],F=[];for(let w=0;w<k.length;w++){let o=k[w],I=y.get(o);I&&F.push(I);for(let m of H.get(o)||[])x.has(m)||(x.add(m),k.push(m))}let s={ids:x,members:F};for(let w of x)r.set(w,s)}return r},Q=r=>{f=Math.max(f,r)},rt=r=>T.clusterScope&&U?U.get(r):null,it=18,yt=r=>Y(Math.sqrt(900/Math.max(900,r)),.56,1),J=()=>{let r=[],l=new Set;for(let x of L){if(l.has(x.id))continue;let k=U?.get(x.id),F=k?[...k.ids]:[x.id];for(let a of F)l.add(a);let s=new Map(F.map(a=>[a,[]]));for(let a of R)!s.has(a.from)||!s.has(a.to)||(s.get(a.from).push(a.to),s.get(a.to).push(a.from));let w=F[0],o=-1;for(let a of F){let c=y.get(a),P=(s.get(a)?.length||0)*10+(c?.kind==="memory"?0:3);(P>o||P===o&&a<w)&&(w=a,o=P)}let I=new Map([[w,null]]),m=new Map([[w,[]]]),i=new Map([[w,0]]),p=[w];for(let a=0;a<p.length;a++){let c=p[a];for(let P of s.get(c)||[])I.has(P)||(I.set(P,c),m.set(P,[]),i.set(P,i.get(c)+1),m.get(c).push(P),p.push(P))}let u=new Map;for(let a=p.length-1;a>=0;a--){let c=p[a],P=0;for(let j of m.get(c)||[])P+=u.get(j);u.set(c,P||1)}r.push({ids:F,root:w,kids:m,weight:u})}return r.sort((x,k)=>k.ids.length-x.ids.length),r},It=(r,l,x,k)=>{let F=y.get(r.root);if(!F)return;F.x=0,F.y=0;let s=[{id:r.root,x:0,y:0,dir:-Math.PI/2,span:Math.PI*2}];for(;s.length;){let w=s.pop(),o=r.kids.get(w.id);if(!o||!o.length)continue;let I=o.length>1?o.slice().sort((c,P)=>r.weight.get(P)-r.weight.get(c)):o,m=0;for(let c of I)m+=r.weight.get(c);let i=1/0;for(let c of I)i=Math.min(i,w.span*r.weight.get(c)/m);let p=l;I.length>1&&i>1e-6&&(p=Math.max(l,x/(2*Math.sin(Math.min(Math.PI,i)/2)))),p>k&&(p=k);let u=I.length===1?.62:0,a=w.dir-w.span/2;for(let c of I){let P=w.span*r.weight.get(c)/m,j=a+P/2+u,t=y.get(c);t&&(t.x=w.x+Math.cos(j)*p,t.y=w.y+Math.sin(j)*p),s.push({id:c,x:t?t.x:w.x,y:t?t.y:w.y,dir:j,span:P}),a+=P}}},et=r=>{let x=new Float64Array(36),k=r[0],F=m=>Math.min(35,Math.floor((m+Math.PI)/(Math.PI*2)*36));for(let m of k.ids){let i=y.get(m);if(!i)continue;let p=Math.hypot(i.x-(k.cx||0),i.y-(k.cy||0)),u=F(Math.atan2(i.y-(k.cy||0),i.x-(k.cx||0)));p>x[u]&&(x[u]=p)}let s=0,w=1/0;for(let m=0;m<36;m++){let i=m/36*Math.PI*2,p=Float64Array.from(x);for(let c=1;c<r.length;c++){let P=r[c],j=Math.hypot(P.ax,P.ay),t=Math.atan2(P.ay,P.ax)+i,n=P.radius;for(let h=0;h<36;h++){let S=-Math.PI+(h+.5)/36*Math.PI*2-t;for(;S>Math.PI;)S-=Math.PI*2;for(;S<-Math.PI;)S+=Math.PI*2;let E=j*Math.sin(S);if(Math.abs(E)>=n||Math.abs(S)>=Math.PI/2)continue;let ot=j*Math.cos(S)+Math.sqrt(n*n-E*E);ot>p[h]&&(p[h]=ot)}}let u=0;for(let c=0;c<36;c++)u+=p[c];u/=36;let a=0;for(let c=0;c<36;c++)a+=(p[c]-u)*(p[c]-u);a<w&&(w=a,s=i)}if(!s)return;let o=Math.cos(s),I=Math.sin(s);for(let m=1;m<r.length;m++){let i=r[m],p=i.ax,u=i.ay;i.ax=p*o-u*I,i.ay=p*I+u*o}},Mt=r=>{let l=r.slice().sort((s,w)=>w.radius-s.radius);if(!l.length)return;l[0].ax=0,l[0].ay=0;let x=l[0].radius+it,k=1,F=1;for(;k<l.length;){let s=[],w=0,o=k;for(;o<l.length;){let u=l[o],a=x+u.radius,c=(2*u.radius+it)/Math.max(1,a);if(s.length&&w+c>Math.PI*2)break;s.push({c:u,d:a,need:c}),w+=c,o++}let I=0,m=x;for(let u of s)I+=u.need,m=Math.max(m,u.d+u.c.radius);let i=-Math.PI/2+F*.9,p=0;for(let u of s){let a=(2*u.c.radius+it)/Math.max(1,u.d),c=i+(p+a/2)/Math.max(1e-6,I)*Math.PI*2;u.c.ax=Math.cos(c)*u.d,u.c.ay=Math.sin(c)*u.d,p+=a}x=m+it,k=o,F++}l.length<=12&&et(l)},ut=(r,l)=>{let x=r.filter(s=>Math.hypot(s.ax,s.ay)>1);if(!x.length)return;let k=0;for(let s of x)k=Math.max(k,Math.hypot(s.ax,s.ay)+s.radius*.5);let F=Math.PI*2/x.length;x.sort((s,w)=>Math.atan2(s.ay,s.ax)-Math.atan2(w.ay,w.ax));for(let s=0;s<x.length;s++){let w=x[s],o=w.ids.map(a=>y.get(a)).filter(Boolean);if(!o.length)continue;let I=1/0,m=-1/0;for(let a of o){let c=a.x-w.ax;c<I&&(I=c),c>m&&(m=c)}let i=Math.max(1,m-I),p=-Math.PI/2+(s+.5)*F,u=Math.min(F*.94,Math.max(1,o.length)*(l/Math.max(k,l)));for(let a of o){let c=a.x-w.ax,P=a.y-w.ay,j=(c-I)/i-.5,t=p+j*u,n=k+Y(P,-l,l)*.28;a.x=Math.cos(t)*n,a.y=Math.sin(t)*n}}},lt=()=>{if(!L.length)return;let r=yt(L.length),l=56*r,x=Math.max(22,44*r),k=l*2.8,F=J();for(let s of F){It(s,l,x,k);let w=1/0,o=-1/0,I=1/0,m=-1/0;for(let u of s.ids){let a=y.get(u);a&&(a.x<w&&(w=a.x),a.x>o&&(o=a.x),a.y<I&&(I=a.y),a.y>m&&(m=a.y))}s.cx=(w+o)/2,s.cy=(I+m)/2;let i=[];for(let u of s.ids){let a=y.get(u);a&&i.push(Math.hypot(a.x-s.cx,a.y-s.cy))}i.sort((u,a)=>u-a);let p=i.length?i[Math.min(i.length-1,Math.floor(i.length*.88))]:0;if(s.radius=p+26,s.cx||s.cy){for(let u of s.ids){let a=y.get(u);a&&(a.x-=s.cx,a.y-=s.cy)}s.cx=0,s.cy=0}}Mt(F);for(let s of F)for(let w of s.ids){let o=y.get(w);o&&(o.x+=s.ax,o.y+=s.ay)}F.length<=12&&ut(F,l);for(let s of y.values())s.vx=0,s.vy=0,s.fx=null,s.fy=null,s.locked=!1;for(let s of R){let w=s.source,o=s.target;s.baseLen=w&&o?Math.max(1,Math.hypot(w.x-o.x,w.y-o.y)):56,N.set(JSON.stringify([s.from,s.to,s.kind||""]),s.baseLen)}},xt=r=>{let l=[...new Map((r?.nodes||[]).slice(0,Jt).map(i=>[i.id,i])).values()].sort((i,p)=>String(i.id).localeCompare(String(p.id))),x=new Set(l.map(i=>i.id)),k=(r?.edges||[]).filter(i=>x.has(i.from)&&x.has(i.to)&&i.from!==i.to),F=JSON.stringify([l.map(i=>i.id),k.map(i=>[i.from,i.to]).sort()]),s=e!==F,w=L.length,o=new Map;for(let i of k)o.set(i.from,(o.get(i.from)||0)+1),o.set(i.to,(o.get(i.to)||0)+1);let I=l.filter(i=>!y.has(i.id));for(let i=0;i<I.length;i++){let p=I[i],u=k.filter(t=>t.from===p.id||t.to===p.id).map(t=>y.get(t.from===p.id?t.to:t.from)).filter(Boolean),a=i*Ht,c=u.length?32:24*Math.sqrt(i+.5),P=u.length?u.reduce((t,n)=>t+n.x,0)/u.length:0,j=u.length?u.reduce((t,n)=>t+n.y,0)/u.length:0;y.set(p.id,{id:p.id,x:P+Math.cos(a)*c,y:j+Math.sin(a)*c,vx:0,vy:0,fx:null,fy:null,locked:!1})}L=l.map(i=>{let p=y.get(i.id);for(let[u,a]of Object.entries(i))Vt.has(u)||(p[u]=a);return p.degree=o.get(i.id)||0,p.radius=4+Math.min(3,Math.log2(1+p.degree))+Y(Number(i.strength)||0,0,1)*2,p}),R=k.map(i=>{let p=y.get(i.from),u=y.get(i.to),a=JSON.stringify([i.from,i.to,i.kind||""]),c=N.get(a);return c===void 0&&(c=K(p,u),N.set(a,c)),{...i,source:p,target:u,manual:i.source!=="auto",baseLen:c}}),H=b(),s&&(U=St());let m=L.length>0&&I.length>=Math.ceil(L.length*.6)&&w<=Math.max(8,L.length*.2);s&&L.length&&(!z||m)&&(lt(),z=!0),s&&Q(e?.25:1),e=F;for(let i of y.keys())y.size>Ut&&!x.has(i)&&y.delete(i);return N.size>4e3&&N.clear(),s},Z=()=>{if(!L.length)return;f+=(W.alphaTarget-f)*W.alphaDecay,f<W.alphaTarget&&(f=W.alphaTarget);let r=ht();O&&!V&&!v&&f<.05&&(O=null);let l=O?O.members:L,x=O?O.ids:null,k=new Map;for(let o of L){let I=Ft(o.x,o.y),m=k.get(I);m||k.set(I,m=[]),m.push(o)}let F=W.range*W.range,s=W.repel*r.repel*f;for(let o of l){let I=Math.floor(o.x/W.cell),m=Math.floor(o.y/W.cell);for(let i=-1;i<=1;i++)for(let p=-1;p<=1;p++){let u=k.get(`${I+i},${m+p}`);if(u)for(let a of u){if(a===o)continue;let c=o.x-a.x,P=o.y-a.y,j=c*c+P*P;if(j>F)continue;if(j<1){let h=Dt(o.id)^Dt(a.id);c=(h&1023)/1023-.5||.25,P=(h>>>10&1023)/1023-.5||.25,j=c*c+P*P+1}let t=Math.sqrt(j),n=s/(j+60);o.vx+=c/t*n,o.vy+=P/t*n}}}let w=W.link*f;for(let o of R){if(x&&(!x.has(o.from)||!x.has(o.to)))continue;let I=o.source,m=o.target;if(!I||!m)continue;let i=m.x-I.x,p=m.y-I.y,u=Math.hypot(i,p)||.01,a=(u-o.baseLen*r.linkDist)/u*w,c=i*a,P=p*a;I.vx+=c,I.vy+=P,m.vx-=c,m.vy-=P}if(r.center>0&&l.length){let o=0,I=0;for(let i of l)o+=i.x,I+=i.y;o/=l.length,I/=l.length;let m=W.centerForce*r.center*f;for(let i of l)i.vx+=(o-i.x)*m,i.vy+=(I-i.y)*m}for(let o of l)if(o.vx=Y(o.vx,-24,24),o.vy=Y(o.vy,-24,24),o.fx!=null?(o.x=o.fx,o.vx=0):(o.vx*=W.vDecay,o.x+=o.vx),o.fy!=null?(o.y=o.fy,o.vy=0):(o.vy*=W.vDecay,o.y+=o.vy),(!Number.isFinite(o.x)||!Number.isFinite(o.y))&&(o.x=0,o.y=0,o.vx=0,o.vy=0),o.fx==null||!V&&!o.locked){let I=(Number(o.radius)||4)+(V?2:8),m=Math.floor(o.x/W.cell),i=Math.floor(o.y/W.cell);for(let p=-1;p<=1;p++)for(let u=-1;u<=1;u++){let a=k.get(`${m+p},${i+u}`);if(a)for(let c of a){if(c===o)continue;let P=o.x-c.x,j=o.y-c.y,t=P*P+j*j,n=I+(Number(c.radius)||4),h=n*n;if(t>=h)continue;let C=Math.sqrt(t);if(C<.01){let E=Dt(o.id)^Dt(c.id);P=(E&1023)/1023-.5||.25,j=(E>>>10&1023)/1023-.5||.25,C=Math.hypot(P,j)||1}let S=n-C;o.x+=P/C*S,o.y+=j/C*S}}o.vx*=.3,o.vy*=.3,o.fx!=null&&(o.fx=o.x,o.fy=o.y)}};return{get nodes(){return L},get edges(){return R},get alpha(){return f},get active(){return f>W.alphaTarget+1e-4||V},update:xt,tick:Z,settle(r=200){v=!0;try{for(let l=0;l<r;l++)Z()}finally{v=!1}f=W.alphaTarget},configure(r){let l=r?.distance!==void 0&&r.distance!==T.distance;if(T={...T,...r},l){N.clear();for(let x of R)x.baseLen=K(x.source,x.target),N.set(JSON.stringify([x.from,x.to,x.kind||""]),x.baseLen)}Q(.25)},reheat:Q,pin(r,l,x){let k=y.get(r);k&&(k.fx=l,k.fy=x,k.x=l,k.y=x,k.vx=0,k.vy=0,k.locked=!0,Q(.3))},hold(r,l,x){let k=y.get(r);k&&(k.fx=l,k.fy=x,k.x=l,k.y=x,k.vx=0,k.vy=0,Q(.55))},release(r){let l=y.get(r);if(l){l.fx=null,l.fy=null,l.vx=0,l.vy=0;for(let x of R)x.from!==r&&x.to!==r||(x.baseLen=Math.max(24,Math.hypot(x.source.x-x.target.x,x.source.y-x.target.y)),N.set(JSON.stringify([x.from,x.to,x.kind||""]),x.baseLen));Q(.2)}},unpin(r){let l=y.get(r);l&&(l.fx=null,l.fy=null,l.vx=0,l.vy=0,l.locked=!1,Q(.3))},unpinAll(){for(let r of y.values())r.fx=null,r.fy=null,r.vx=0,r.vy=0,r.locked=!1;Q(.35)},relayout(){lt(),N.clear();for(let r of R)r.baseLen=K(r.source,r.target),N.set(JSON.stringify([r.from,r.to,r.kind||""]),r.baseLen);O=null,V=!1,f=1},componentOf:rt,startDragScope(r){V=!0;let l=rt(r);return O=l?{ids:l.ids,members:l.members}:null,Q(.35),O},setDragging(r){V=r},clearDragScope(){O=null,V=!1},nodeById:r=>y.get(r),dispose(){y.clear(),N.clear(),L=[],R=[],U=null,H=new Map}}}function Et(d,y,N){if(!d.length)return{x:y/2,y:N/2,k:1};let L=1/0,R=-1/0,H=1/0,U=-1/0;for(let f of d){let T=Number(f.radius)||4;L=Math.min(L,f.x-T),R=Math.max(R,f.x+T),H=Math.min(H,f.y-T),U=Math.max(U,f.y+T)}let e=Y(Math.min(Math.max(32,y-100)/Math.max(120,R-L),Math.max(32,N-96)/Math.max(120,U-H)),.06,1.6);return{x:y/2-(L+R)*e/2,y:N/2-(H+U)*e/2,k:e}}function Nt(d,y,N){let L=Y(d.k*y,.06,5);return{k:L,x:N.x-(N.x-d.x)*L/d.k,y:N.y-(N.y-d.y)*L/d.k}}var Kt=(d,y)=>d.x<y.x+y.width&&d.x+d.width>y.x&&d.y<y.y+y.height&&d.y+d.height>y.y;function Xt(d,y,N,L){let R=[...y],H=[];for(let U of d){let{x:e,y:f,radius:T,textWidth:O}=U,V=[{x:e-O/2,y:f+T+5},{x:e-O/2,y:f-T-21},{x:e+T+6,y:f-8},{x:e-T-O-6,y:f-8}];if(U.priority)for(let z of[28,48,72])V.push({x:e-O/2,y:f+T+z},{x:e-O/2,y:f-T-16-z},{x:e+T+z,y:f-8},{x:e-T-O-z,y:f-8});let v=V.map(z=>({...z,width:O,height:16})).find(z=>z.x>=5&&z.y>=5&&z.x+z.width<=N-5&&z.y+z.height<=L-5&&!R.some(ht=>Kt(z,ht)));v&&(R.push({x:v.x-3,y:v.y-2,width:v.width+6,height:v.height+4}),H.push({...U,box:v}))}return H}function Qt(d,{onFocus:y=()=>{},onZoom:N=()=>{},onPaint:L=()=>{},tooltip:R,reducedMotion:H=!1,emptyLabel:U=""}={}){let e=d.getContext("2d");if(!e)throw new Error("Canvas 2D is unavailable");let f=Rt(),T=1,O=1,V=1,v={x:0,y:0,k:1},z={...Ct},ht="",K=null,b=null,St=!1,Q=!1,rt=null,it=0,yt=0,J=new Map,It=[],et=d.ownerDocument.defaultView,Mt=t=>({x:(t.x-v.x)/v.k,y:(t.y-v.y)/v.k}),ut=t=>Y((Number(t.radius)||4)*Math.sqrt(v.k),2.5,22),lt=t=>{let n=d.getBoundingClientRect();return{x:(t.clientX-n.left)*T/n.width,y:(t.clientY-n.top)*O/n.height}},xt=(t,n)=>{let h=f.nodes;if(!h.length)return null;let C=Mt(t),S=Y(Math.ceil(40/Math.max(v.k,.06)/W.cell),1,8),E=Math.floor(C.x/W.cell),ot=Math.floor(C.y/W.cell),$=new Map;for(let tt of h){let g=Ft(tt.x,tt.y),D=$.get(g);D||$.set(g,D=[]),D.push(tt)}let X=tt=>Math.max(6,ut(tt)+4),nt=null,at=1/0,st=1/0;for(let tt=-S;tt<=S;tt++)for(let g=-S;g<=S;g++){let D=$.get(`${E+tt},${ot+g}`);if(D)for(let M of D){let A=M.x*v.k+v.x,_=M.y*v.k+v.y,B=Math.hypot(A-t.x,_-t.y);M===n&&(st=B),B<=X(M)&&B<at&&(nt=M,at=B)}}return n&&st<=X(n)&&(!nt||at>st-2)?n:nt},Z=()=>{R&&(R.hidden=!0)},r=(t,n)=>{K!==t&&(K=t,s()),d.style.cursor=b?"grabbing":t?"pointer":"grab",R&&(R.hidden=!t||!!b,!(!t||b)&&(R.textContent=String(t.title||t.id),R.style.left=`${Y(n.x+14,6,Math.max(6,T-Math.min(260,T-12)))}px`,R.style.top=`${(d.offsetTop||0)+Y(n.y+16,6,O-60)}px`))},l=t=>{if(t?.snapshot){for(let n of t.snapshot){let h=f.nodeById(n.id);h&&(h.fx=n.fx,h.fy=n.fy,h.locked=n.locked===!0,h.x=n.x,h.y=n.y,h.vx=0,h.vy=0)}f.clearDragScope()}},x=t=>{let n=34*v.k;if(n<12)return;let h=(v.x%n+n)%n,C=(v.y%n+n)%n;e.fillStyle=e.strokeStyle,e.globalAlpha=t,e.beginPath();for(let S=h;S<T;S+=n)for(let E=C;E<O;E+=n)e.rect(S,E,1.2,1.2);e.fill()},k=()=>{e.setTransform(V,0,0,V,0,0),e.clearRect(0,0,T,O);let t=et.getComputedStyle(d),n=t.color||"#202020",h=t.getPropertyValue("--dsw-alias-bg-layer-1").trim()||"#ffffff",C=t.getPropertyValue("--dsw-alias-brand-primary").trim()||"#3b5bdb",S=K?.id||ht,E=new Set(S?[S]:[]);for(let g of f.edges)g.from===S&&E.add(g.to),g.to===S&&E.add(g.from);e.strokeStyle=n;let ot=z.motion&&!H&&f.active?.06+.025*Math.sin(Date.now()/900):.07;z.grid!==!1&&x(ot);let $=v.k,X=v.x,nt=v.y,at=new Map;for(let g of f.edges){let D={x:g.source.x*$+X,y:g.source.y*$+nt},M={x:g.target.x*$+X,y:g.target.y*$+nt};if(D.x<-40&&M.x<-40||D.x>T+40&&M.x>T+40||D.y<-40&&M.y<-40||D.y>O+40&&M.y>O+40)continue;let A=Yt(g,n,C),_=g.source.kind!=="memory"&&g.target.kind!=="memory",B=`${A}|${g.manual?"d":"s"}|${_?"k":"n"}`,q=at.get(B);q||at.set(B,q={color:A,manual:g.manual,skeleton:_,list:[]}),q.list.push({edge:g,a:D,b:M})}e.lineWidth=.8;for(let g of at.values()){e.strokeStyle=g.color,e.globalAlpha=S?.055:g.skeleton?.1:g.manual?.24:.16,e.setLineDash(g.manual?[5,4]:[]),e.beginPath();for(let D of g.list)e.moveTo(D.a.x,D.a.y),e.lineTo(D.b.x,D.b.y);if(e.stroke(),e.setLineDash([]),g.manual&&v.k>=.3){e.fillStyle=g.color,e.globalAlpha=S?.22:.4;for(let D of g.list){if(D.edge.rule==="entity-mention"||D.edge.rule==="conflict")continue;let M=D.b.x-D.a.x,A=D.b.y-D.a.y,_=Math.hypot(M,A);if(_<=22)continue;let B=M/_,q=A/_,gt=ut(D.edge.target)+3,pt=D.b.x-B*gt,mt=D.b.y-q*gt;e.beginPath(),e.moveTo(pt,mt),e.lineTo(pt-B*7-q*3.4,mt-q*7+B*3.4),e.lineTo(pt-B*7+q*3.4,mt-q*7-B*3.4),e.closePath(),e.fill()}}}if(S){e.globalAlpha=.6,e.lineWidth=1.5,e.strokeStyle=C,e.beginPath();for(let g of f.edges)g.from!==S&&g.to!==S||(e.moveTo(g.source.x*$+X,g.source.y*$+nt),e.lineTo(g.target.x*$+X,g.target.y*$+nt));e.stroke()}e.globalAlpha=1,e.strokeStyle=n;let st=[];for(let g of f.nodes){let D=g.x*$+X,M=g.y*$+nt;D>=-120&&D<=T+120&&M>=-120&&M<=O+120&&st.push({node:g,x:D,y:M,r:ut(g)})}let tt=f.nodes.length>2400&&v.k<.3;if(tt){let g=new Map;for(let D of f.nodes){let M=D.x*$+X,A=D.y*$+nt;if(M<0||M>T||A<0||A>O)continue;let _=wt(D),B=g.get(_);B||g.set(_,B=[]),B.push(M,A)}e.globalAlpha=1;for(let[D,M]of g){e.fillStyle=D,e.beginPath();for(let A=0;A<M.length;A+=2)e.rect(M[A]-1,M[A+1]-1,2,2);e.fill()}}else{let g=new Map;for(let M of st){let A=!!S&&!E.has(M.node.id),_=wt(M.node)+(A?"|d":"|n"),B=g.get(_);B||g.set(_,B=[]),B.push(M)}for(let[M,A]of g){let[_,B]=M.split("|");e.globalAlpha=B==="d"?.22:1,e.fillStyle=_,e.beginPath();for(let q of A)e.moveTo(q.x+q.r,q.y),e.arc(q.x,q.y,q.r,0,Pt);e.fill()}e.globalAlpha=1;let D=String(z.query||"").trim().toLowerCase();for(let M of st){if(M.node.kind==="memory"||M.node.missing)continue;let A=M.r*1.75,_=Math.min(5,A/3),B=M.x-A/2,q=M.y-A/2;e.fillStyle=wt(M.node),e.beginPath(),e.moveTo(B+_,q),e.arcTo(B+A,q,B+A,q+A,_),e.arcTo(B+A,q+A,B,q+A,_),e.arcTo(B,q+A,B,q,_),e.arcTo(B,q,B+A,q,_),e.closePath(),e.fill()}for(let M of st){let A=M.node;A.status==="provisional"&&(e.strokeStyle=wt(A),e.lineWidth=1.2,e.setLineDash([3,3]),e.beginPath(),e.ellipse(M.x,M.y,M.r+5,M.r+5,0,0,Pt),e.stroke(),e.setLineDash([])),A.locked&&(e.fillStyle=h,e.globalAlpha=.95,e.fillRect(M.x-1.5,M.y-1.5,3,3),e.globalAlpha=1),(A.id===S||A.id===K?.id)&&(e.strokeStyle=A.id===S?C:wt(A),e.lineWidth=1.5,e.beginPath(),e.ellipse(M.x,M.y,M.r+4,M.r+4,0,0,Pt),e.stroke()),D&&String(A.title||A.id).toLowerCase().includes(D)&&(e.strokeStyle=C,e.lineWidth=2,e.beginPath(),e.ellipse(M.x,M.y,M.r+4,M.r+4,0,0,Pt),e.stroke())}}if(e.globalAlpha=1,e.strokeStyle=n,z.labels&&!tt){e.font='11.5px -apple-system,"PingFang SC","Microsoft YaHei",sans-serif';let g=st.filter(G=>G.x>-60&&G.x<T+60&&G.y>-60&&G.y<O+60),D=(v.k>=.55||st.length<34)&&g.length<=260,M=g.length>260?9999:3,A=Y((v.k-.3)/.35,0,1),_=b?.type==="pan"&&b.moved,gt=(b?.type==="node"&&b.moved||_)&&f.nodes.length>400?g.filter(G=>G.node.id===S):D?g:g.filter(G=>G.node.id===S||G.node.degree>=M),pt=gt.length>260?gt.slice(0,260):gt;pt.sort((G,bt)=>+(bt.node.id===S)-+(G.node.id===S)||bt.node.degree-G.node.degree);let mt=[];e.textAlign="center",e.textBaseline="top";for(let G of pt){if(S&&!E.has(G.node.id))continue;let bt=G.node.id===S;if(!bt&&(!D&&G.node.degree<M||A<.02))continue;let At=String(G.node.title||G.node.id),Lt=e.measureText(At).width,Ot=ft=>({l:G.x-Lt/2-3,t:ft-1,r:G.x+Lt/2+3,b:ft+14}),Bt=ft=>mt.some(vt=>ft.l<vt.r&&ft.r>vt.l&&ft.t<vt.b&&ft.b>vt.t),kt=G.y+G.r+4,ct=Ot(kt);Bt(ct)&&(kt+=16,ct=Ot(kt),Bt(ct))||ct.l<2||ct.r>T-2||ct.b>O-2||(mt.push(ct),e.globalAlpha=bt?1:.78*Math.max(.35,A),e.lineWidth=3.5,e.strokeStyle=h,e.lineJoin="round",e.strokeText(At,G.x,kt),e.fillStyle=n,e.fillText(At,G.x,kt))}e.globalAlpha=1}else if(z.labels&&tt&&S){let g=f.nodes.find(D=>D.id===S);g&&(e.font="12px system-ui, sans-serif",e.textAlign="center",e.textBaseline="top",e.fillStyle=n,e.fillText(String(g.title||g.id),g.x*$+X,g.y*$+nt+10))}!f.nodes.length&&U&&(e.font="13px system-ui, sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillStyle=n,e.globalAlpha=.55,e.fillText(U,T/2,O/2),e.globalAlpha=1),L()},F=t=>{if(rt=null,Q)return;let n=z.motion&&!H&&f.active;if(n){yt+=it?Math.min(64,t-it):17;let h=0;for(;yt>=1e3/60&&h<4;yt-=1e3/60,h++)f.tick();it=t}else it=0,yt=0;k(),n&&s()};function s(){!Q&&rt===null&&(rt=et.requestAnimationFrame(F))}let w=()=>{N(v.k),s()},o=()=>{v=Et(f.nodes,T,O),Z(),w()},I=(t,n={x:T/2,y:O/2})=>{v=Nt(v,t,n),Z(),w()},m=()=>{let t=d.getBoundingClientRect();if(!t.width||!t.height)return;let n=t.width,h=t.height;v.x+=(n-T)/2,v.y+=(h-O)/2,T=n,O=h,V=Math.min(2,et.devicePixelRatio||1),d.width=Math.round(T*V),d.height=Math.round(O*V),s()},i=()=>{l(b);let[t,n]=[...J.values()];b={type:"pinch",distance:Math.max(1,Math.hypot(n.x-t.x,n.y-t.y)),camera:{...v},center:{x:(t.x+n.x)/2,y:(t.y+n.y)/2},moved:!0}},p=t=>{if(t.button!==0&&t.pointerType!=="touch")return;t.preventDefault(),d.focus({preventScroll:!0});let n=lt(t);if(J.set(t.pointerId,n),d.setPointerCapture?.(t.pointerId),J.size>=2){i(),Z();return}let h=xt(n),C=Mt(n),S=h?f.componentOf(h.id):null,E=h&&t.shiftKey&&S?"rigid":"node",ot=E==="rigid"?S.members:h?[h]:[];if(b={type:h?"node":"pan",node:h,mode:E,members:ot,start:n,camera:{...v},moved:!1,offset:h?{x:h.x-C.x,y:h.y-C.y}:null,snapshot:ot.map($=>({id:$.id,x:$.x,y:$.y,fx:$.fx,fy:$.fy,locked:$.locked}))},h){for(let $ of ot)f.hold($.id,$.x,$.y);f.startDragScope(h.id),f.setDragging(!0)}Z(),d.style.cursor="grabbing"},u=t=>{let n=lt(t);if(!J.has(t.pointerId)||!b){r(xt(n,K),n);return}if(J.set(t.pointerId,n),b.type==="pinch"){if(J.size<2)return;let[h,C]=[...J.values()],S={x:(h.x+C.x)/2,y:(h.y+C.y)/2};v=Nt(b.camera,Math.hypot(C.x-h.x,C.y-h.y)/b.distance,b.center),v.x+=S.x-b.center.x,v.y+=S.y-b.center.y,w()}else{if(b.moved||(b.moved=Math.hypot(n.x-b.start.x,n.y-b.start.y)>5),!b.moved)return;if(b.node){let h=Mt(n),C=b.node;if(b.mode==="rigid"){let S=h.x+b.offset.x,E=h.y+b.offset.y,ot=S-C.fx,$=E-C.fy;for(let X of b.members)f.hold(X.id,X.fx+ot,X.fy+$)}else f.hold(C.id,h.x+b.offset.x,h.y+b.offset.y);f.settle(2)}else v.x=b.camera.x+n.x-b.start.x,v.y=b.camera.y+n.y-b.start.y;s()}},a=t=>{if(!J.has(t.pointerId))return;let n=t.type!=="pointerup",h=b?.node,C=!n&&!b?.moved&&b?.type!=="pinch"&&(t.detail??1)<2;if(C||n)l(b);else if(h){for(let S of b.snapshot){let E=f.nodeById(S.id);E&&(S.locked||S.fx!=null?(E.fx=E.x,E.fy=E.y,E.locked=!0,E.vx=0,E.vy=0):f.release(S.id))}f.setDragging(!1),H||!z.motion?(f.settle(120),f.clearDragScope()):f.reheat(.3)}J.delete(t.pointerId),b=null,J.size&&(b={type:"pan",start:[...J.values()][0],camera:{...v},moved:!0}),d.hasPointerCapture?.(t.pointerId)&&d.releasePointerCapture(t.pointerId),C&&y(h?.id||""),K=null,d.style.cursor="grab",Z(),s()},c=(t,n,h,C)=>{t.addEventListener(n,h,C),It.push(()=>t.removeEventListener(n,h,C))};c(d,"pointerdown",p),c(d,"pointermove",u);for(let t of["pointerup","pointercancel","lostpointercapture"])c(d,t,a);c(d,"pointerleave",()=>{b||(K=null,Z(),s())}),c(d,"contextmenu",t=>{t.preventDefault();let n=xt(lt(t));if(!n)return;let h=f.nodeById(n.id);h&&(h.fx!=null?f.unpin(n.id):f.pin(n.id,h.x,h.y),f.setDragging(!1),(H||!z.motion)&&f.settle(20),s())}),c(d,"dblclick",t=>{y(xt(lt(t))?.id||"")}),c(d,"wheel",t=>{t.preventDefault(),I(Math.exp(-Y(t.deltaY,-160,160)*.0025),lt(t))},{passive:!1}),c(d,"keydown",t=>{if(t.key==="+"||t.key==="=")I(1.25);else if(t.key==="-")I(.8);else if(t.key==="0"||t.key==="Home")o();else if(t.key==="Escape")l(b),b=null,J.clear(),y(""),Z(),s();else if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key)){let n=t.shiftKey?90:30;v.x+=t.key==="ArrowLeft"?n:t.key==="ArrowRight"?-n:0,v.y+=t.key==="ArrowUp"?n:t.key==="ArrowDown"?-n:0,s()}else return;t.preventDefault()}),c(et,"blur",()=>{l(b),b=null,J.clear(),K=null,Z(),s()});let P=et.ResizeObserver?new et.ResizeObserver(m):null;P?.observe(d),c(et,"resize",m);let j=et.MutationObserver?new et.MutationObserver(s):null;return j?.observe(d.ownerDocument.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}),d.ownerDocument.body&&j?.observe(d.ownerDocument.body,{attributes:!0,attributeFilter:["class","data-theme","style"]}),m(),{update(t,n=""){b?.node&&!t.nodes.some(C=>C.id===b.node.id)&&(l(b),b=null,J.clear());let h=f.update(t);ht=n,K&&!f.nodes.includes(K)&&(K=null,Z()),!St&&f.nodes.length?(f.settle(220),St=!0,o()):h&&(H||!z.motion)&&f.settle(180),s()},configure(t){let n=["repulsion","distance","center"].some(h=>t[h]!==void 0&&t[h]!==z[h]);z={...z,...t},n&&(f.configure(t),(H||!z.motion)&&f.settle(160)),s()},fit:o,zoom:I,isPinned(t){return f.nodeById(t)?.locked===!0},pinnedCount(){return f.nodes.reduce((t,n)=>t+(n.locked?1:0),0)},snapshot(){return f.nodes.map(t=>({id:t.id,x:t.x*v.k+v.x,y:t.y*v.k+v.y,r:ut(t),pinned:t.locked===!0,degree:t.degree||0}))},unpinAll(){f.unpinAll(),f.clearDragScope(),(H||!z.motion)&&f.settle(120),s()},relayout(){l(b),b=null,J.clear(),f.relayout(),(H||!z.motion)&&f.settle(220),s()},dispose(){Q=!0,l(b),b=null,J.clear(),rt!==null&&et.cancelAnimationFrame(rt);for(let t of It)t();P?.disconnect(),j?.disconnect(),f.dispose(),Z()}}}return Wt(Zt);})();
|