@kangyishuai/dsh-casefile 0.0.0-stage → 0.1.0

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/lib/client.js ADDED
@@ -0,0 +1,1275 @@
1
+ // @ts-check
2
+ // client 半:classic script,以 __ModuleLoader__.load 注册 factory,不能使用 import。
3
+ // 注册面(M1):主面板(main keyed)+ 侧栏入口(sidebar.panellist)+ 设置分节(settings.section)。
4
+ // 宿主调用走 ctx.connection.rpc.call("/api", "casefile/<method>", { args })——
5
+ // 无构建插件没有 typert 生成的客户端产物,不能用 ctx.reflect.get("remote.xxx")。
6
+ window.__ModuleLoader__.load({
7
+ id: "@kangyishuai/dsh-casefile",
8
+ factory(require) {
9
+ var module = { exports: /** @type {any} */ ({}) };
10
+ var exports = module.exports;
11
+
12
+ /** @type {any} */
13
+ var React = require("react");
14
+ var h = React.createElement;
15
+ var useEffect = React.useEffect;
16
+ var useState = React.useState;
17
+ var useCallback = React.useCallback;
18
+
19
+ var NS = "casefile";
20
+ var PANEL_ID = "casefile";
21
+
22
+ // 运行时字典:无构建插件没有 typert 产物,必须在代码里注册(locale/*.json 只供插件管理器显示)。
23
+ var ZH = {
24
+ "panel.title": "案卷",
25
+ "panel.subtitle": "证据 · 义务 · 运行",
26
+ "panel.empty": "还没有项目。建一个,把目标、证据和结论收进来。",
27
+ "panel.new": "新建项目",
28
+ "panel.createTitle": "项目标题",
29
+ "panel.createTarget": "目标(路径 / URL)",
30
+ "panel.createKind": "目标类型",
31
+ "panel.createAuth": "授权档",
32
+ "panel.create": "创建",
33
+ "panel.creating": "创建中…",
34
+ "panel.cancel": "取消",
35
+ "panel.refresh": "刷新",
36
+ "panel.loading": "加载中…",
37
+ "panel.error": "加载失败:{reason}",
38
+ "panel.projects": "{count} 个项目",
39
+ "panel.back": "返回列表",
40
+ "tab.evidence": "证据",
41
+ "tab.obligation": "义务",
42
+ "tab.run": "运行",
43
+ "tab.evidence.count": "证据 {evidence} · 结论 {claims} · 选中 {selected}",
44
+ "tab.obligation.count": "开 {open} · 已关 {passed} · 未知 {unknowns}",
45
+ "claims.title": "结论(每条带出处与局限)",
46
+ "claims.empty": "还没有结论。用 case_claim 记录一条。",
47
+ "claims.selected": "已选中",
48
+ "claims.evidence": "证据 {count}",
49
+ "claims.limits": "局限:{text}",
50
+ "evidence.title": "证据",
51
+ "evidence.empty": "还没有证据。用 case_evidence 记录一条。",
52
+ "evidence.confidence": "{confidence} / {authority}",
53
+ "obligation.title": "义务(关闭必须有新鲜 PASS 检查)",
54
+ "obligation.empty": "还没有义务。用 case_obligation 加一条可验收的断言。",
55
+ "obligation.open": "待关闭",
56
+ "obligation.pass": "已关闭",
57
+ "obligation.fail": "失败",
58
+ "obligation.blocked": "阻塞",
59
+ "obligation.unknown": "未知项",
60
+ "obligation.unknownEmpty": "没有未解决的未知项。",
61
+ "obligation.close": "关闭",
62
+ "obligation.closing": "关闭中…",
63
+ "obligation.blockedReason": "还不能关闭:缺新鲜 PASS 检查",
64
+ "run.title": "构建与验收",
65
+ "run.empty": "还没有构建记录。用 case_build 起一轮构建。",
66
+ "run.builds": "构建轮次",
67
+ "run.checks": "检查结论",
68
+ "run.round": "第 {round} 轮",
69
+ "run.digest": "实现",
70
+ "run.command": "命令",
71
+ "run.noChecks": "还没有检查记录。",
72
+ "blocker.noFreshCheck": "没有新鲜检查",
73
+ "blocker.staleCheck": "检查已过期",
74
+ "blocker.checkFail": "检查未通过",
75
+ "blocker.checkUnknown": "检查无法判定",
76
+ "blocker.implementationMismatch": "实现已变化",
77
+ "blocker.ownerDigestMismatch": "原件已变化",
78
+ "blocker.missingCheck": "缺少检查记录",
79
+ "blocker.noObligations": "还没有义务",
80
+ "blocker.noChecks": "还没有检查",
81
+ "blocker.openObligations": "还有未关闭义务",
82
+ "blocker.openUnknowns": "还有未解决未知项",
83
+ "blocker.failedObligations": "有失败的义务",
84
+ "blocker.blockedObligations": "有阻塞的义务",
85
+ "blocker.coverageBelow": "覆盖率不足",
86
+ "blocker.implementationChanged": "实现已变化",
87
+ "blocker.originalChanged": "原件已变化",
88
+ "blocker.checkStale": "检查已过期",
89
+ "settings.section": "案卷",
90
+ "settings.summary": "{count} 个项目",
91
+ "settings.dataRoot": "数据根目录",
92
+ "settings.rea": "REA 能力",
93
+ "settings.reaMissing": "未检测到 mcp__rea__*(先接好 REA)",
94
+ "settings.reaOk": "已连接({count} 个工具)",
95
+ "settings.hint": "项目数据只在本机;规格包默认脱敏,但分享前请自己过一遍。",
96
+ "nav.title": "案卷",
97
+ "auth.owned": "自有",
98
+ "auth.authorized": "已授权",
99
+ "auth.research": "研究",
100
+ "state.investigating": "调查中",
101
+ "state.closed": "已关闭",
102
+ "common.loading": "加载中…",
103
+ "common.none": "—",
104
+ "row.evidence": "证据 {count}",
105
+ "row.claims": "结论 {count}",
106
+ "row.obligations": "义务 {count}",
107
+ "claims.limitsInline": "局限:{text}",
108
+ "obligation.needsCheck": "需新鲜 PASS 检查",
109
+ "obligation.status.pass": "已关闭",
110
+ "obligation.status.open": "待关闭",
111
+ };
112
+ var EN = {
113
+ "panel.title": "Casefile",
114
+ "panel.subtitle": "Evidence · Obligations · Runs",
115
+ "panel.empty": "No projects yet. Create one and collect targets, evidence, and claims.",
116
+ "panel.new": "New project",
117
+ "panel.createTitle": "Project title",
118
+ "panel.createTarget": "Target (path / URL)",
119
+ "panel.createKind": "Target kind",
120
+ "panel.createAuth": "Authorization",
121
+ "panel.create": "Create",
122
+ "panel.creating": "Creating…",
123
+ "panel.cancel": "Cancel",
124
+ "panel.refresh": "Refresh",
125
+ "panel.loading": "Loading…",
126
+ "panel.error": "Failed to load: {reason}",
127
+ "panel.projects": "{count} projects",
128
+ "panel.back": "Back to list",
129
+ "tab.evidence": "Evidence",
130
+ "tab.obligation": "Obligations",
131
+ "tab.run": "Runs",
132
+ "tab.evidence.count": "{evidence} evidence · {claims} claims · {selected} selected",
133
+ "tab.obligation.count": "{open} open · {passed} closed · {unknowns} unknowns",
134
+ "claims.title": "Claims (each with provenance and limits)",
135
+ "claims.empty": "No claims yet. Record one with case_claim.",
136
+ "claims.selected": "selected",
137
+ "claims.evidence": "evidence {count}",
138
+ "claims.limits": "limits: {text}",
139
+ "evidence.title": "Evidence",
140
+ "evidence.empty": "No evidence yet. Record one with case_evidence.",
141
+ "evidence.confidence": "{confidence} / {authority}",
142
+ "obligation.title": "Obligations (closing needs a fresh PASS check)",
143
+ "obligation.empty": "No obligations yet. Add a verifiable statement with case_obligation.",
144
+ "obligation.open": "open",
145
+ "obligation.pass": "closed",
146
+ "obligation.fail": "failed",
147
+ "obligation.blocked": "blocked",
148
+ "obligation.unknown": "Unknowns",
149
+ "obligation.unknownEmpty": "No open unknowns.",
150
+ "obligation.close": "Close",
151
+ "obligation.closing": "Closing…",
152
+ "obligation.blockedReason": "Cannot close yet: needs a fresh PASS check",
153
+ "run.title": "Build & verification",
154
+ "run.empty": "No builds yet. Start one with case_build.",
155
+ "run.builds": "Build rounds",
156
+ "run.checks": "Check verdicts",
157
+ "run.round": "Round {round}",
158
+ "run.digest": "implementation",
159
+ "run.command": "command",
160
+ "run.noChecks": "No checks recorded yet.",
161
+ "blocker.noFreshCheck": "no fresh check",
162
+ "blocker.staleCheck": "check is stale",
163
+ "blocker.checkFail": "check failed",
164
+ "blocker.checkUnknown": "check cannot judge",
165
+ "blocker.implementationMismatch": "implementation changed",
166
+ "blocker.ownerDigestMismatch": "original changed",
167
+ "blocker.missingCheck": "no check recorded",
168
+ "blocker.noObligations": "no obligations yet",
169
+ "blocker.noChecks": "no checks yet",
170
+ "blocker.openObligations": "obligations still open",
171
+ "blocker.openUnknowns": "unresolved unknowns",
172
+ "blocker.failedObligations": "failed obligations",
173
+ "blocker.blockedObligations": "blocked obligations",
174
+ "blocker.coverageBelow": "coverage below target",
175
+ "blocker.implementationChanged": "implementation changed",
176
+ "blocker.originalChanged": "original changed",
177
+ "blocker.checkStale": "check is stale",
178
+ "settings.section": "Casefile",
179
+ "settings.summary": "{count} projects",
180
+ "settings.dataRoot": "Data root",
181
+ "settings.rea": "REA capability",
182
+ "settings.reaMissing": "No mcp__rea__* detected (connect REA first)",
183
+ "settings.reaOk": "Connected ({count} tools)",
184
+ "settings.hint":
185
+ "Project data stays local; spec packs are redacted by default but review them before sharing.",
186
+ "nav.title": "Casefile",
187
+ "auth.owned": "owned",
188
+ "auth.authorized": "authorized",
189
+ "auth.research": "research",
190
+ "state.investigating": "investigating",
191
+ "state.closed": "closed",
192
+ "common.loading": "Loading…",
193
+ "common.none": "—",
194
+ "row.evidence": "{count} evidence",
195
+ "row.claims": "{count} claims",
196
+ "row.obligations": "{count} obligations",
197
+ "claims.limitsInline": "limits: {text}",
198
+ "obligation.needsCheck": "needs a fresh PASS check",
199
+ "obligation.status.pass": "closed",
200
+ "obligation.status.open": "open",
201
+ };
202
+
203
+ /**
204
+ * 极简插值:{name} → vars[name]。
205
+ * @param {any} t
206
+ * @param {string} key
207
+ * @param {Record<string, any>} [vars]
208
+ * @returns {string}
209
+ */
210
+ function text(t, key, vars) {
211
+ var raw = typeof t === "function" ? t(key) : key;
212
+ if (!vars) return raw;
213
+ return String(raw).replace(/\{(\w+)\}/g, (_, name) =>
214
+ vars[name] === undefined || vars[name] === null ? "—" : String(vars[name]),
215
+ );
216
+ }
217
+
218
+ // 业务拒绝里的 blocker 令牌 → 文案 key(与 actions 产出的字符串一一对应)。
219
+ var BLOCKER_KEYS = {
220
+ "no-fresh-check": "blocker.noFreshCheck",
221
+ "stale-check": "blocker.staleCheck",
222
+ "check-fail": "blocker.checkFail",
223
+ "check-unknown": "blocker.checkUnknown",
224
+ "implementation-mismatch": "blocker.implementationMismatch",
225
+ "owner-digest-mismatch": "blocker.ownerDigestMismatch",
226
+ "missing-check": "blocker.missingCheck",
227
+ "no-obligations": "blocker.noObligations",
228
+ "no-checks": "blocker.noChecks",
229
+ "stale-checks": "blocker.staleCheck",
230
+ "open-obligations": "blocker.openObligations",
231
+ "open-unknowns": "blocker.openUnknowns",
232
+ "failed-obligations": "blocker.failedObligations",
233
+ "blocked-obligations": "blocker.blockedObligations",
234
+ "coverage-below": "blocker.coverageBelow",
235
+ "implementation-changed": "blocker.implementationChanged",
236
+ "original-changed": "blocker.originalChanged",
237
+ "check-stale": "blocker.checkStale",
238
+ };
239
+
240
+ /**
241
+ * 把宿主返回的错误变成人能读的一句话:去掉 `[code]` 前缀,
242
+ * 把 `:a、b:2` 里的 blocker 令牌翻成文案。
243
+ * @param {any} err
244
+ * @param {any} t
245
+ * @returns {string}
246
+ */
247
+ function humanizeError(err, t) {
248
+ var message = err?.message ? String(err.message) : String(err);
249
+ message = message.replace(/^\[[a-zA-Z]+\]\s*/, "");
250
+ var colon = message.lastIndexOf(":");
251
+ if (colon < 0) return message;
252
+ var head = message.slice(0, colon);
253
+ var parts = message
254
+ .slice(colon + 1)
255
+ .split("、")
256
+ .map((/** @type {string} */ token) => {
257
+ var bits = token.split(":");
258
+ var key = /** @type {Record<string, string>} */ (BLOCKER_KEYS)[bits[0]];
259
+ if (!key) return token;
260
+ return bits[1] ? `${text(t, key)}(${bits[1]})` : text(t, key);
261
+ });
262
+ return `${head}:${parts.join(";")}`;
263
+ }
264
+
265
+ /**
266
+ * 调 casefile 的 Remote 方法。args 用「命名位置参数」。
267
+ * @param {any} ctx
268
+ * @param {string} method
269
+ * @param {Record<string, any>} [args]
270
+ * @returns {Promise<any>}
271
+ */
272
+ function call(ctx, method, args) {
273
+ var rpc = ctx.connection?.rpc;
274
+ if (!rpc || typeof rpc.call !== "function") {
275
+ return Promise.reject(new Error("casefile: no connection to the host"));
276
+ }
277
+ return Promise.resolve(rpc.call("/api", `casefile/${method}`, { args: args || {} })).then(
278
+ (/** @type {any} */ result) => {
279
+ if (!result || typeof result !== "object") return result;
280
+ var error;
281
+ if (result.ok === false) {
282
+ error = /** @type {any} */ (
283
+ new Error(result.error?.message || "host rejected the call")
284
+ );
285
+ error.code = result.error?.code;
286
+ error.hint = result.error?.hint;
287
+ throw error;
288
+ }
289
+ return "value" in result ? result.value : result;
290
+ },
291
+ );
292
+ }
293
+
294
+ // ---------- 样式(只用宿主 token;明暗都跟随) ----------
295
+
296
+ var CSS = [
297
+ ".cf-root{display:flex;flex-direction:column;height:100%;min-height:0;color:var(--dsw-alias-label-primary);font-size:13px}",
298
+ ".cf-head{display:flex;align-items:center;gap:8px;padding:12px 16px;border-bottom:1px solid var(--dsw-alias-border-l1)}",
299
+ ".cf-head h2{font-size:15px;margin:0;font-weight:600}",
300
+ ".cf-sub{color:var(--dsw-alias-label-secondary);font-size:12px}",
301
+ ".cf-grow{flex:1 1 auto;min-width:0}",
302
+ ".cf-btn{appearance:none;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);border-radius:6px;padding:4px 10px;font-size:12px;cursor:pointer}",
303
+ ".cf-btn:hover{background:var(--dsw-alias-bg-layer-2)}",
304
+ ".cf-btn[disabled]{opacity:.5;cursor:not-allowed}",
305
+ ".cf-btn-primary{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}",
306
+ ".cf-body{display:flex;flex:1 1 auto;min-height:0}",
307
+ ".cf-list{width:260px;flex:none;border-right:1px solid var(--dsw-alias-border-l1);overflow:auto;padding:8px}",
308
+ ".cf-detail{flex:1 1 auto;min-width:0;overflow:auto;padding:12px 16px}",
309
+ ".cf-row{display:flex;gap:8px;align-items:flex-start;padding:8px;border-radius:6px;cursor:pointer;min-width:0}",
310
+ ".cf-row:hover{background:var(--dsw-alias-bg-layer-1)}",
311
+ ".cf-row[data-active=true]{background:var(--dsw-alias-bg-layer-2)}",
312
+ ".cf-row-text{min-width:0;flex:1 1 auto}",
313
+ ".cf-row-title{font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
314
+ ".cf-row-meta{color:var(--dsw-alias-label-secondary);font-size:11px;margin-top:2px}",
315
+ ".cf-tabs{display:flex;gap:4px;border-bottom:1px solid var(--dsw-alias-border-l1);margin-bottom:12px}",
316
+ ".cf-tab{appearance:none;border:0;background:transparent;color:var(--dsw-alias-label-secondary);padding:6px 10px;font-size:12px;cursor:pointer;border-bottom:2px solid transparent}",
317
+ ".cf-tab[data-active=true]{color:var(--dsw-alias-label-primary);border-bottom-color:var(--dsw-alias-brand-primary)}",
318
+ ".cf-card{border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:10px 12px;margin-bottom:8px;background:var(--dsw-alias-bg-layer-1)}",
319
+ ".cf-card-title{font-weight:500;margin-bottom:4px;word-break:break-word}",
320
+ ".cf-tags{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}",
321
+ ".cf-tag{font-size:11px;padding:1px 6px;border-radius:999px;border:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary)}",
322
+ ".cf-tag[data-tone=ok]{color:var(--dsw-alias-state-success-primary);border-color:var(--dsw-alias-state-success-primary)}",
323
+ ".cf-tag[data-tone=warn]{color:var(--dsw-alias-state-warn-primary);border-color:var(--dsw-alias-state-warn-primary)}",
324
+ ".cf-tag[data-tone=err]{color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary)}",
325
+ ".cf-muted{color:var(--dsw-alias-label-secondary)}",
326
+ ".cf-empty{padding:24px;text-align:center;color:var(--dsw-alias-label-secondary)}",
327
+ ".cf-error{color:var(--dsw-alias-state-error-primary);padding:8px 0;word-break:break-word}",
328
+ ".cf-form{display:flex;flex-wrap:wrap;gap:8px;padding:12px 16px;border-bottom:1px solid var(--dsw-alias-border-l1)}",
329
+ ".cf-input,.cf-select{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);border-radius:6px;padding:4px 8px;font-size:12px;min-width:0}",
330
+ ".cf-input{flex:1 1 180px}",
331
+ ".cf-settings{padding:4px 0}",
332
+ ".cf-kv{display:flex;gap:8px;padding:2px 0;font-size:12px}",
333
+ ".cf-kv b{font-weight:500;flex:none;min-width:92px;color:var(--dsw-alias-label-secondary)}",
334
+ ].join("\n");
335
+
336
+ /**
337
+ * 注入样式(随组件挂载/卸载)。
338
+ * @returns {any}
339
+ */
340
+ function StyleOnce() {
341
+ useEffect(() => {
342
+ var el = document.createElement("style");
343
+ el.setAttribute("data-casefile-style", "1");
344
+ el.textContent = CSS;
345
+ document.head.appendChild(el);
346
+ return () => {
347
+ if (el.parentNode) el.parentNode.removeChild(el);
348
+ };
349
+ }, []);
350
+ return null;
351
+ }
352
+
353
+ // ---------- 小组件 ----------
354
+
355
+ /** @param {{ t: any, children?: any, tone?: string }} props */
356
+ function Tag(props) {
357
+ return h(
358
+ "span",
359
+ { className: "cf-tag", "data-tone": props.tone || "neutral" },
360
+ props.children,
361
+ );
362
+ }
363
+
364
+ /** @param {{ t: any, project: any, active: boolean, onClick: () => void }} props */
365
+ function ProjectRow(props) {
366
+ var project = props.project;
367
+ return h(
368
+ "div",
369
+ {
370
+ className: "cf-row",
371
+ "data-casefile-project-row": project.id,
372
+ "data-active": props.active ? "true" : "false",
373
+ onClick: props.onClick,
374
+ role: "button",
375
+ tabIndex: 0,
376
+ },
377
+ h(
378
+ "div",
379
+ { className: "cf-row-text" },
380
+ h("div", { className: "cf-row-title" }, project.title),
381
+ h(
382
+ "div",
383
+ { className: "cf-row-meta" },
384
+ project.target ? `${project.target.kind} · ${project.target.ref}` : project.id,
385
+ ),
386
+ h(
387
+ "div",
388
+ { className: "cf-row-meta" },
389
+ text(props.t, "row.evidence", { count: project.evidence }) +
390
+ " · " +
391
+ text(props.t, "row.claims", { count: project.claims }) +
392
+ " · " +
393
+ text(props.t, "row.obligations", { count: project.obligations || 0 }),
394
+ ),
395
+ ),
396
+ );
397
+ }
398
+
399
+ /** @param {{ t: any, claim: any }} props */
400
+ function ClaimCard(props) {
401
+ var claim = props.claim;
402
+ return h(
403
+ "div",
404
+ { className: "cf-card", "data-casefile-claim": claim.id },
405
+ h("div", { className: "cf-card-title" }, claim.text),
406
+ h(
407
+ "div",
408
+ { className: "cf-tags" },
409
+ h(Tag, { t: props.t }, claim.kind),
410
+ h(
411
+ Tag,
412
+ {
413
+ t: props.t,
414
+ tone:
415
+ claim.status === "observed"
416
+ ? "ok"
417
+ : claim.status === "inferred"
418
+ ? "warn"
419
+ : "neutral",
420
+ },
421
+ claim.status,
422
+ ),
423
+ claim.selected
424
+ ? h(Tag, { t: props.t, tone: "ok" }, text(props.t, "claims.selected"))
425
+ : null,
426
+ h(
427
+ Tag,
428
+ { t: props.t },
429
+ text(props.t, "claims.evidence", { count: (claim.evidenceIds || []).length }),
430
+ ),
431
+ ),
432
+ (claim.limitations || []).length > 0
433
+ ? h(
434
+ "div",
435
+ { className: "cf-muted", style: { marginTop: 6 } },
436
+ text(props.t, "claims.limitsInline", { text: claim.limitations.join("; ") }),
437
+ )
438
+ : null,
439
+ );
440
+ }
441
+
442
+ /** @param {{ t: any, item: any }} props */
443
+ function EvidenceCard(props) {
444
+ var item = props.item;
445
+ return h(
446
+ "div",
447
+ { className: "cf-card", "data-casefile-evidence": item.id },
448
+ h("div", { className: "cf-card-title" }, item.summary || item.id),
449
+ h(
450
+ "div",
451
+ { className: "cf-tags" },
452
+ h(Tag, { t: props.t }, item.kind),
453
+ h(
454
+ Tag,
455
+ { t: props.t, tone: item.confidence === "observed" ? "ok" : "warn" },
456
+ `${item.confidence} / ${item.authority}`,
457
+ ),
458
+ ),
459
+ h(
460
+ "div",
461
+ { className: "cf-muted", style: { marginTop: 4, fontSize: 11 } },
462
+ item.sourceTool || "unknown",
463
+ ),
464
+ (item.limitations || []).length > 0
465
+ ? h(
466
+ "div",
467
+ { className: "cf-muted", style: { marginTop: 4 } },
468
+ text(props.t, "claims.limitsInline", { text: item.limitations.join("; ") }),
469
+ )
470
+ : null,
471
+ );
472
+ }
473
+
474
+ /** @param {{ t: any, obligation: any, onClose: (id: string) => Promise<any> }} props */
475
+ function ObligationCard(props) {
476
+ var obligation = props.obligation;
477
+ var closing = useState(false);
478
+ var isClosing = closing[0];
479
+ var setClosing = closing[1];
480
+ var canClose = obligation.status === "open";
481
+ return h(
482
+ "div",
483
+ {
484
+ className: "cf-card",
485
+ "data-casefile-obligation": obligation.id,
486
+ "data-status": obligation.status,
487
+ },
488
+ h("div", { className: "cf-card-title" }, obligation.statement),
489
+ h(
490
+ "div",
491
+ { className: "cf-tags" },
492
+ h(Tag, { t: props.t }, obligation.kind),
493
+ h(
494
+ Tag,
495
+ {
496
+ t: props.t,
497
+ tone:
498
+ obligation.status === "pass"
499
+ ? "ok"
500
+ : obligation.status === "fail"
501
+ ? "err"
502
+ : "neutral",
503
+ },
504
+ text(
505
+ props.t,
506
+ obligation.status === "pass" ? "obligation.status.pass" : "obligation.status.open",
507
+ ),
508
+ ),
509
+ h(Tag, { t: props.t }, obligation.authorityRequired),
510
+ ),
511
+ h(
512
+ "div",
513
+ { style: { marginTop: 8, display: "flex", gap: 8, alignItems: "center" } },
514
+ h(
515
+ "button",
516
+ {
517
+ className: "cf-btn cf-btn-primary",
518
+ "data-casefile-close": obligation.id,
519
+ disabled: !canClose || isClosing,
520
+ onClick: () => {
521
+ setClosing(true);
522
+ props.onClose(obligation.id).finally(() => {
523
+ setClosing(false);
524
+ });
525
+ },
526
+ },
527
+ isClosing ? text(props.t, "obligation.closing") : text(props.t, "obligation.close"),
528
+ ),
529
+ canClose
530
+ ? h(
531
+ "span",
532
+ { className: "cf-muted", style: { fontSize: 11 } },
533
+ text(props.t, "obligation.needsCheck"),
534
+ )
535
+ : null,
536
+ ),
537
+ );
538
+ }
539
+
540
+ /** @param {{ t: any, unknown: any }} props */
541
+ function UnknownRow(props) {
542
+ return h(
543
+ "div",
544
+ { className: "cf-kv", "data-casefile-unknown": props.unknown.id },
545
+ h(
546
+ Tag,
547
+ { t: props.t, tone: props.unknown.severity === "high" ? "err" : "neutral" },
548
+ props.unknown.severity,
549
+ ),
550
+ h("span", null, props.unknown.text),
551
+ );
552
+ }
553
+
554
+ // ---------- 主面板 ----------
555
+
556
+ /**
557
+ * @param {{ api: any, t: any }} props
558
+ */
559
+ function CasefilePanel(props) {
560
+ var ctx = props.api.ctx;
561
+ var t = props.t;
562
+ var projectsState = useState([]);
563
+ var projects = projectsState[0];
564
+ var setProjects = projectsState[1];
565
+ var overviewState = useState(null);
566
+ var overview = overviewState[0];
567
+ var setOverview = overviewState[1];
568
+ var detailState = useState(null);
569
+ var detail = detailState[0];
570
+ var setDetail = detailState[1];
571
+ var errorState = useState("");
572
+ var error = errorState[0];
573
+ var setError = errorState[1];
574
+ var loadingState = useState(false);
575
+ var loading = loadingState[0];
576
+ var setLoading = loadingState[1];
577
+ var tabState = useState("evidence");
578
+ var tab = tabState[0];
579
+ var setTab = tabState[1];
580
+ var formState = useState(false);
581
+ var showForm = formState[0];
582
+ var setShowForm = formState[1];
583
+ var titleState = useState("");
584
+ var title = titleState[0];
585
+ var setTitle = titleState[1];
586
+ var targetState = useState("");
587
+ var target = targetState[0];
588
+ var setTarget = targetState[1];
589
+ var kindState = useState("binary");
590
+ var kind = kindState[0];
591
+ var setKind = kindState[1];
592
+ var authState = useState("research");
593
+ var auth = authState[0];
594
+ var setAuth = authState[1];
595
+ var busyState = useState(false);
596
+ var busy = busyState[0];
597
+ var setBusy = busyState[1];
598
+
599
+ var loadList = useCallback(() => {
600
+ setLoading(true);
601
+ return Promise.all([call(ctx, "listProjects"), call(ctx, "overview").catch(() => null)])
602
+ .then((values) => {
603
+ setProjects(values[0] || []);
604
+ setOverview(values[1] || null);
605
+ setError("");
606
+ })
607
+ .catch((/** @type {any} */ err) => {
608
+ setError(err?.message ? err.message : String(err));
609
+ })
610
+ .finally(() => {
611
+ setLoading(false);
612
+ });
613
+ }, [ctx]);
614
+
615
+ var openProject = useCallback(
616
+ (/** @type {string} */ id) => {
617
+ setLoading(true);
618
+ return call(ctx, "projectDetail", { projectId: id })
619
+ .then((value) => {
620
+ setDetail(value);
621
+ setError("");
622
+ })
623
+ .catch((/** @type {any} */ err) => {
624
+ setError(err?.message ? err.message : String(err));
625
+ })
626
+ .finally(() => {
627
+ setLoading(false);
628
+ });
629
+ },
630
+ [ctx],
631
+ );
632
+
633
+ useEffect(() => {
634
+ loadList();
635
+ }, [loadList]);
636
+
637
+ var create = () => {
638
+ if (busy) return;
639
+ setBusy(true);
640
+ call(ctx, "createProject", {
641
+ input: {
642
+ title: title,
643
+ target: { kind: kind, ref: target || title },
644
+ authTier: auth,
645
+ },
646
+ })
647
+ .then((project) => {
648
+ setShowForm(false);
649
+ setTitle("");
650
+ setTarget("");
651
+ return loadList().then(() => openProject(project.id));
652
+ })
653
+ .catch((/** @type {any} */ err) => {
654
+ setError(err?.message ? err.message : String(err));
655
+ })
656
+ .finally(() => {
657
+ setBusy(false);
658
+ });
659
+ };
660
+
661
+ var closeObligation = useCallback(
662
+ (/** @type {string} */ id) => {
663
+ if (!detail) return Promise.resolve();
664
+ return call(ctx, "closeObligation", { projectId: detail.project.id, obligationId: id })
665
+ .then(() => openProject(detail.project.id))
666
+ .catch((/** @type {any} */ err) => {
667
+ setError(humanizeError(err, t));
668
+ });
669
+ },
670
+ [ctx, detail, openProject],
671
+ );
672
+
673
+ // 渲染期局部量统一声明在函数根(biome noInnerDeclarations)
674
+ var body;
675
+ var content;
676
+ var stats;
677
+ var claims;
678
+ var evidence;
679
+ var obligations;
680
+ var unknowns;
681
+ var openUnknowns;
682
+ var builds;
683
+ var checks;
684
+ var tabs;
685
+ if (detail) {
686
+ stats = detail.stats || {};
687
+ claims = detail.claims || [];
688
+ evidence = detail.evidence || [];
689
+ obligations = detail.obligations || [];
690
+ unknowns = detail.unknowns || [];
691
+ openUnknowns = unknowns.filter((/** @type {any} */ item) => item.status !== "resolved");
692
+ tabs = [
693
+ ["evidence", text(t, "tab.evidence")],
694
+ ["obligation", text(t, "tab.obligation")],
695
+ ["run", text(t, "tab.run")],
696
+ ];
697
+ if (tab === "evidence") {
698
+ content = h(
699
+ "div",
700
+ null,
701
+ h(
702
+ "div",
703
+ { className: "cf-muted", style: { marginBottom: 8 } },
704
+ text(t, "tab.evidence.count", {
705
+ evidence: evidence.length,
706
+ claims: claims.length,
707
+ selected: stats.selectedClaims || 0,
708
+ }),
709
+ ),
710
+ h("h3", { style: { fontSize: 13, margin: "12px 0 8px" } }, text(t, "claims.title")),
711
+ claims.length === 0
712
+ ? h(
713
+ "div",
714
+ { className: "cf-empty", "data-casefile-empty": "claims" },
715
+ text(t, "claims.empty"),
716
+ )
717
+ : claims.map((/** @type {any} */ claim) =>
718
+ h(ClaimCard, { key: claim.id, t: t, claim: claim }),
719
+ ),
720
+ h("h3", { style: { fontSize: 13, margin: "16px 0 8px" } }, text(t, "evidence.title")),
721
+ evidence.length === 0
722
+ ? h(
723
+ "div",
724
+ { className: "cf-empty", "data-casefile-empty": "evidence" },
725
+ text(t, "evidence.empty"),
726
+ )
727
+ : evidence.map((/** @type {any} */ item) =>
728
+ h(EvidenceCard, { key: item.id, t: t, item: item }),
729
+ ),
730
+ );
731
+ } else if (tab === "obligation") {
732
+ content = h(
733
+ "div",
734
+ null,
735
+ h(
736
+ "div",
737
+ { className: "cf-muted", style: { marginBottom: 8 } },
738
+ text(t, "tab.obligation.count", {
739
+ open: stats.openObligations || 0,
740
+ passed: stats.passedObligations || 0,
741
+ unknowns: openUnknowns.length,
742
+ }),
743
+ ),
744
+ h("h3", { style: { fontSize: 13, margin: "12px 0 8px" } }, text(t, "obligation.title")),
745
+ obligations.length === 0
746
+ ? h(
747
+ "div",
748
+ { className: "cf-empty", "data-casefile-empty": "obligations" },
749
+ text(t, "obligation.empty"),
750
+ )
751
+ : obligations.map((/** @type {any} */ item) =>
752
+ h(ObligationCard, {
753
+ key: item.id,
754
+ t: t,
755
+ obligation: item,
756
+ onClose: closeObligation,
757
+ }),
758
+ ),
759
+ h(
760
+ "h3",
761
+ { style: { fontSize: 13, margin: "16px 0 8px" } },
762
+ text(t, "obligation.unknown"),
763
+ ),
764
+ openUnknowns.length === 0
765
+ ? h(
766
+ "div",
767
+ { className: "cf-muted", "data-casefile-empty": "unknowns" },
768
+ text(t, "obligation.unknownEmpty"),
769
+ )
770
+ : openUnknowns.map((/** @type {any} */ item) =>
771
+ h(UnknownRow, { key: item.id, t: t, unknown: item }),
772
+ ),
773
+ );
774
+ } else {
775
+ builds = detail.builds || [];
776
+ checks = detail.checks || [];
777
+ content = h(
778
+ "div",
779
+ null,
780
+ h(
781
+ "div",
782
+ { className: "cf-muted", style: { marginBottom: 8 } },
783
+ builds.length === 0
784
+ ? text(t, "run.empty")
785
+ : `${text(t, "run.builds")} · ${builds.length}`,
786
+ ),
787
+ builds.length === 0
788
+ ? h(
789
+ "div",
790
+ { className: "cf-empty", "data-casefile-empty": "runs" },
791
+ text(t, "run.empty"),
792
+ )
793
+ : builds
794
+ .slice()
795
+ .sort(
796
+ (/** @type {any} */ a, /** @type {any} */ b) => (b.round || 0) - (a.round || 0),
797
+ )
798
+ .map((/** @type {any} */ build) =>
799
+ h(
800
+ "div",
801
+ { key: build.id, className: "cf-card", "data-casefile-build": build.id },
802
+ h(
803
+ "div",
804
+ {
805
+ style: {
806
+ display: "flex",
807
+ gap: 8,
808
+ alignItems: "baseline",
809
+ flexWrap: "wrap",
810
+ },
811
+ },
812
+ h(
813
+ Tag,
814
+ {
815
+ t: t,
816
+ tone:
817
+ build.status === "pass"
818
+ ? "ok"
819
+ : build.status === "fail"
820
+ ? "err"
821
+ : "warn",
822
+ },
823
+ build.status,
824
+ ),
825
+ h("span", null, text(t, "run.round", { round: build.round })),
826
+ build.implementationDigest
827
+ ? h(
828
+ "span",
829
+ { className: "cf-muted", style: { fontSize: 11 } },
830
+ text(t, "run.digest") +
831
+ " " +
832
+ String(build.implementationDigest).slice(0, 12),
833
+ )
834
+ : null,
835
+ ),
836
+ h(
837
+ "div",
838
+ {
839
+ className: "cf-muted",
840
+ style: { fontSize: 11, marginTop: 4, wordBreak: "break-all" },
841
+ },
842
+ String(build.command || "").slice(0, 160),
843
+ ),
844
+ ),
845
+ ),
846
+ h("h3", { style: { fontSize: 13, margin: "16px 0 8px" } }, text(t, "run.checks")),
847
+ checks.length === 0
848
+ ? h(
849
+ "div",
850
+ { className: "cf-muted", "data-casefile-empty": "checks" },
851
+ text(t, "run.noChecks"),
852
+ )
853
+ : checks
854
+ .slice()
855
+ .reverse()
856
+ .map((/** @type {any} */ check) =>
857
+ h(
858
+ "div",
859
+ { key: check.id, className: "cf-kv", "data-casefile-check": check.id },
860
+ h(
861
+ Tag,
862
+ {
863
+ t: t,
864
+ tone:
865
+ check.verdict === "pass"
866
+ ? "ok"
867
+ : check.verdict === "fail"
868
+ ? "err"
869
+ : "warn",
870
+ },
871
+ check.verdict,
872
+ ),
873
+ h(
874
+ "span",
875
+ null,
876
+ (check.checker || "?") +
877
+ " · " +
878
+ String(check.implementationDigest || "—").slice(0, 12),
879
+ ),
880
+ ),
881
+ ),
882
+ );
883
+ }
884
+ body = h(
885
+ "div",
886
+ { className: "cf-body" },
887
+ h(
888
+ "div",
889
+ { className: "cf-list" },
890
+ h(
891
+ "button",
892
+ {
893
+ className: "cf-btn",
894
+ style: { marginBottom: 8 },
895
+ "data-casefile-back": "1",
896
+ onClick: () => {
897
+ setDetail(null);
898
+ },
899
+ },
900
+ text(t, "panel.back"),
901
+ ),
902
+ projects.map((/** @type {any} */ project) =>
903
+ h(ProjectRow, {
904
+ key: project.id,
905
+ t: t,
906
+ project: project,
907
+ active: project.id === detail.project.id,
908
+ onClick: () => {
909
+ openProject(project.id);
910
+ },
911
+ }),
912
+ ),
913
+ ),
914
+ h(
915
+ "div",
916
+ { className: "cf-detail" },
917
+ h(
918
+ "div",
919
+ { style: { display: "flex", gap: 8, alignItems: "baseline", marginBottom: 4 } },
920
+ h("h3", { style: { fontSize: 14, margin: 0 } }, detail.project.title),
921
+ h(Tag, { t: t }, detail.project.target ? detail.project.target.kind : "other"),
922
+ h(Tag, { t: t, tone: "warn" }, text(t, `auth.${detail.project.authTier}`)),
923
+ h(Tag, { t: t }, detail.project.scope === "selected" ? "selected" : "all"),
924
+ ),
925
+ h(
926
+ "div",
927
+ {
928
+ className: "cf-muted",
929
+ style: { fontSize: 11, marginBottom: 10, wordBreak: "break-all" },
930
+ },
931
+ detail.project.target ? detail.project.target.ref : "",
932
+ ),
933
+ h(
934
+ "div",
935
+ { className: "cf-tabs" },
936
+ tabs.map((/** @type {any[]} */ pair) =>
937
+ h(
938
+ "button",
939
+ {
940
+ key: pair[0],
941
+ className: "cf-tab",
942
+ "data-casefile-tab": pair[0],
943
+ "data-active": tab === pair[0] ? "true" : "false",
944
+ onClick: () => {
945
+ setTab(pair[0]);
946
+ },
947
+ },
948
+ pair[1],
949
+ ),
950
+ ),
951
+ ),
952
+ content,
953
+ ),
954
+ );
955
+ } else {
956
+ body = h(
957
+ "div",
958
+ { className: "cf-body" },
959
+ h(
960
+ "div",
961
+ { className: "cf-detail" },
962
+ overview?.summary
963
+ ? h(
964
+ "div",
965
+ {
966
+ className: "cf-card",
967
+ "data-casefile-overview": "1",
968
+ style: { display: "flex", gap: 8, alignItems: "baseline", flexWrap: "wrap" },
969
+ },
970
+ h("span", null, overview.summary),
971
+ Object.entries(overview.byKind || {})
972
+ .sort((a, b) => b[1] - a[1])
973
+ .map((entry) =>
974
+ h(
975
+ "span",
976
+ { key: entry[0], className: "cf-tag" },
977
+ `${entry[0]} × ${entry[1]}`,
978
+ ),
979
+ ),
980
+ )
981
+ : null,
982
+ projects.length === 0
983
+ ? h(
984
+ "div",
985
+ { className: "cf-empty", "data-casefile-empty": "projects" },
986
+ text(t, "panel.empty"),
987
+ )
988
+ : h(
989
+ "div",
990
+ null,
991
+ projects.map((/** @type {any} */ project) =>
992
+ h(ProjectRow, {
993
+ key: project.id,
994
+ t: t,
995
+ project: project,
996
+ active: false,
997
+ onClick: () => {
998
+ openProject(project.id);
999
+ },
1000
+ }),
1001
+ ),
1002
+ ),
1003
+ ),
1004
+ );
1005
+ }
1006
+
1007
+ return h(
1008
+ "div",
1009
+ { className: "cf-root", "data-casefile-page": "1" },
1010
+ h(StyleOnce, null),
1011
+ h(
1012
+ "div",
1013
+ { className: "cf-head" },
1014
+ h("h2", null, text(t, "panel.title")),
1015
+ h("span", { className: "cf-sub" }, text(t, "panel.subtitle")),
1016
+ h("span", { className: "cf-grow" }),
1017
+ h(
1018
+ "button",
1019
+ {
1020
+ className: "cf-btn",
1021
+ "data-casefile-refresh": "1",
1022
+ onClick: loadList,
1023
+ disabled: loading,
1024
+ },
1025
+ text(t, "panel.refresh"),
1026
+ ),
1027
+ h(
1028
+ "button",
1029
+ {
1030
+ className: "cf-btn cf-btn-primary",
1031
+ "data-casefile-new": "1",
1032
+ onClick: () => {
1033
+ setShowForm(!showForm);
1034
+ },
1035
+ },
1036
+ text(t, "panel.new"),
1037
+ ),
1038
+ ),
1039
+ showForm
1040
+ ? h(
1041
+ "div",
1042
+ { className: "cf-form", "data-casefile-create": "1" },
1043
+ h("input", {
1044
+ className: "cf-input",
1045
+ placeholder: text(t, "panel.createTitle"),
1046
+ value: title,
1047
+ onInput: (/** @type {any} */ event) => {
1048
+ setTitle(event.target.value);
1049
+ },
1050
+ }),
1051
+ h("input", {
1052
+ className: "cf-input",
1053
+ placeholder: text(t, "panel.createTarget"),
1054
+ value: target,
1055
+ onInput: (/** @type {any} */ event) => {
1056
+ setTarget(event.target.value);
1057
+ },
1058
+ }),
1059
+ h(
1060
+ "select",
1061
+ {
1062
+ className: "cf-select",
1063
+ value: kind,
1064
+ onChange: (/** @type {any} */ event) => {
1065
+ setKind(event.target.value);
1066
+ },
1067
+ },
1068
+ ["binary", "web", "app", "game", "artifact", "other"].map((item) =>
1069
+ h("option", { key: item, value: item }, item),
1070
+ ),
1071
+ ),
1072
+ h(
1073
+ "select",
1074
+ {
1075
+ className: "cf-select",
1076
+ value: auth,
1077
+ onChange: (/** @type {any} */ event) => {
1078
+ setAuth(event.target.value);
1079
+ },
1080
+ },
1081
+ ["owned", "authorized", "research"].map((item) =>
1082
+ h("option", { key: item, value: item }, text(t, `auth.${item}`)),
1083
+ ),
1084
+ ),
1085
+ h(
1086
+ "button",
1087
+ {
1088
+ className: "cf-btn cf-btn-primary",
1089
+ "data-casefile-submit": "1",
1090
+ disabled: busy || title.trim() === "",
1091
+ onClick: create,
1092
+ },
1093
+ busy ? text(t, "panel.creating") : text(t, "panel.create"),
1094
+ ),
1095
+ h(
1096
+ "button",
1097
+ {
1098
+ className: "cf-btn",
1099
+ onClick: () => {
1100
+ setShowForm(false);
1101
+ },
1102
+ },
1103
+ text(t, "panel.cancel"),
1104
+ ),
1105
+ )
1106
+ : null,
1107
+ error !== ""
1108
+ ? h("div", { className: "cf-error", "data-casefile-error": "1" }, error)
1109
+ : null,
1110
+ body,
1111
+ );
1112
+ }
1113
+
1114
+ // ---------- 侧栏入口 ----------
1115
+
1116
+ function CasefileIcon() {
1117
+ return h(
1118
+ "svg",
1119
+ { width: 16, height: 16, viewBox: "0 0 16 16", "aria-hidden": "true", role: "img" },
1120
+ h("path", {
1121
+ d: "M3 2.5h7l3 3v8H3z",
1122
+ fill: "none",
1123
+ stroke: "currentColor",
1124
+ strokeWidth: 1.2,
1125
+ strokeLinejoin: "round",
1126
+ }),
1127
+ h("path", { d: "M10 2.5v3h3", fill: "none", stroke: "currentColor", strokeWidth: 1.2 }),
1128
+ h("path", {
1129
+ d: "M5 9h6M5 11h4",
1130
+ stroke: "currentColor",
1131
+ strokeWidth: 1.2,
1132
+ strokeLinecap: "round",
1133
+ }),
1134
+ );
1135
+ }
1136
+
1137
+ // ---------- 设置分节 ----------
1138
+
1139
+ /**
1140
+ * @param {{ api: any, t: any }} props
1141
+ */
1142
+ function CasefileSettings(props) {
1143
+ var ctx = props.api.ctx;
1144
+ var t = props.t;
1145
+ var state = useState(null);
1146
+ var info = state[0];
1147
+ var setInfo = state[1];
1148
+ var errorState = useState("");
1149
+ var error = errorState[0];
1150
+ var setError = errorState[1];
1151
+
1152
+ useEffect(() => {
1153
+ Promise.all([call(ctx, "listProjects"), call(ctx, "diagnose")])
1154
+ .then((values) => {
1155
+ setInfo({ projects: values[0] || [], diagnose: values[1] || {} });
1156
+ setError("");
1157
+ })
1158
+ .catch((/** @type {any} */ err) => {
1159
+ setError(err?.message ? err.message : String(err));
1160
+ });
1161
+ }, [ctx]);
1162
+
1163
+ if (error !== "") {
1164
+ return h(
1165
+ "div",
1166
+ { className: "cf-settings", "data-casefile-settings": "1" },
1167
+ h("div", { className: "cf-error" }, error),
1168
+ );
1169
+ }
1170
+ if (!info) {
1171
+ return h(
1172
+ "div",
1173
+ { className: "cf-settings", "data-casefile-settings": "1" },
1174
+ h("div", { className: "cf-muted" }, text(t, "settings.summary", { count: "—" })),
1175
+ );
1176
+ }
1177
+ var diagnose = info.diagnose || {};
1178
+ var grade = diagnose.grade || {};
1179
+ var rea = diagnose.rea || {};
1180
+ return h(
1181
+ "div",
1182
+ { className: "cf-settings", "data-casefile-settings": "1" },
1183
+ h(
1184
+ "div",
1185
+ { className: "cf-kv" },
1186
+ h("b", null, text(t, "settings.summary", { count: info.projects.length })),
1187
+ ),
1188
+ h(
1189
+ "div",
1190
+ { className: "cf-kv" },
1191
+ h("b", null, text(t, "settings.dataRoot")),
1192
+ h(
1193
+ "span",
1194
+ { style: { minWidth: 0, overflowWrap: "anywhere", wordBreak: "break-word" } },
1195
+ diagnose.dataRoot || "—",
1196
+ ),
1197
+ ),
1198
+ h(
1199
+ "div",
1200
+ { className: "cf-kv" },
1201
+ h("b", null, text(t, "settings.rea")),
1202
+ h(
1203
+ "span",
1204
+ { "data-casefile-rea": grade.level || "unknown" },
1205
+ grade.ok
1206
+ ? text(t, "settings.reaOk", { count: rea.availableTools || 0 })
1207
+ : text(t, "settings.reaMissing"),
1208
+ ),
1209
+ ),
1210
+ h(
1211
+ "div",
1212
+ { className: "cf-muted", style: { marginTop: 6, fontSize: 11 } },
1213
+ text(t, "settings.hint"),
1214
+ ),
1215
+ );
1216
+ }
1217
+
1218
+ exports.inject = ["slots", "locale", "connection"];
1219
+ /** @param {any} ctx */
1220
+ exports.apply = function apply(ctx) {
1221
+ var c = /** @type {any} */ (ctx);
1222
+ c.effect(() => c.locale.register(NS, { zh: ZH, en: EN }), "casefile: dictionaries");
1223
+ var t = c.locale.bind(NS);
1224
+ var api = { ctx: c, t: t };
1225
+
1226
+ c.effect(
1227
+ () =>
1228
+ c.slots.inject("main", () =>
1229
+ c.slots.register(
1230
+ { name: "main", key: PANEL_ID, locale: NS, inject: () => ({ api: api, t: t }) },
1231
+ CasefilePanel,
1232
+ ),
1233
+ ),
1234
+ "casefile: main panel",
1235
+ );
1236
+
1237
+ c.effect(
1238
+ () =>
1239
+ c.slots.inject("sidebar.panellist", () =>
1240
+ c.slots.register(
1241
+ {
1242
+ name: "sidebar.panellist",
1243
+ id: PANEL_ID,
1244
+ order: 12,
1245
+ label: () => text(t, "nav.title"),
1246
+ locale: NS,
1247
+ },
1248
+ CasefileIcon,
1249
+ ),
1250
+ ),
1251
+ "casefile: nav entry",
1252
+ );
1253
+
1254
+ c.effect(
1255
+ () =>
1256
+ c.slots.inject("settings.section", () =>
1257
+ c.slots.register(
1258
+ {
1259
+ name: "settings.section",
1260
+ id: PANEL_ID,
1261
+ order: 94,
1262
+ label: () => text(t, "settings.section"),
1263
+ locale: NS,
1264
+ inject: () => ({ api: api, t: t }),
1265
+ },
1266
+ CasefileSettings,
1267
+ ),
1268
+ ),
1269
+ "casefile: settings section",
1270
+ );
1271
+ };
1272
+
1273
+ return module.exports;
1274
+ },
1275
+ });