hanoman 0.9.33 → 0.9.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/dist/build-info.json +3 -3
  2. package/dist/cli.js +26 -3
  3. package/dist/server.js +52 -10
  4. package/package.json +1 -1
  5. package/web/assets/{DalangHanomanScreen-DAXIQxrw.js → DalangHanomanScreen-BVu8tGjd.js} +1 -1
  6. package/web/assets/{DocPreviewModal-Cu0UFzPH.js → DocPreviewModal-DwhXR__7.js} +1 -1
  7. package/web/assets/{DocsWorkspace-DElNcoar.js → DocsWorkspace-poV6NPLq.js} +1 -1
  8. package/web/assets/{IdeScreen-BBr567gf.js → IdeScreen-BpGoKqok.js} +1 -1
  9. package/web/assets/{LeadScreen-CYn8RS3H.js → LeadScreen-Bqj27JHC.js} +1 -1
  10. package/web/assets/{ReviewScreen-zAvwSL50.js → ReviewScreen-ykVVM8ir.js} +1 -1
  11. package/web/assets/{SchedulerScreen-BptlSAOx.js → SchedulerScreen-26uRd--J.js} +1 -1
  12. package/web/assets/{SettingsScreen-a0Cx4M4j.js → SettingsScreen-D7qZqj-w.js} +3 -3
  13. package/web/assets/{TeamScreen-Cm_phItS.js → TeamScreen-NC9C8iL8.js} +1 -1
  14. package/web/assets/{TerminalScreen-CFuNRq6d.js → TerminalScreen-Do49p9t6.js} +1 -1
  15. package/web/assets/{TriageScreen-ChTidhCT.js → TriageScreen-DzKT-O0A.js} +1 -1
  16. package/web/assets/{VpsScreen-8vz0QHO-.js → VpsScreen-bVd5YC2y.js} +1 -1
  17. package/web/assets/{fields-Bhl01LnE.js → fields-Cqp-sr6L.js} +1 -1
  18. package/web/assets/{index-R2HBkTbR.js → index-BjNlrKWq.js} +25 -25
  19. package/web/assets/{live-V9nWiHoE.js → live-COTGt6Jw.js} +1 -1
  20. package/web/assets/{sched-lead-shared-Dr48bY7n.js → sched-lead-shared-Xe8lxNc_.js} +1 -1
  21. package/web/assets/{settings-rebase-DOqNAynI.js → settings-rebase-Cp2i2t6-.js} +1 -1
  22. package/web/index.html +1 -1
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.9.33",
3
- "sha": "bc8cdfb7",
4
- "builtAt": "2026-10-20T11:34:16.388Z"
2
+ "version": "0.9.35",
3
+ "sha": "30c1066b",
4
+ "builtAt": "2026-10-25T01:25:29.794Z"
5
5
  }
package/dist/cli.js CHANGED
@@ -4137,7 +4137,7 @@ var init_enums = __esm({
4137
4137
  zSeverity = external_exports.enum(["critical", "major", "minor"]);
4138
4138
  zTicketCategory = external_exports.enum(["bug", "fitur", "pertanyaan", "lainnya"]);
4139
4139
  zTicketStatus = external_exports.enum(["new", "accepted", "rejected"]);
4140
- VERIFY_SCOPES = ["changed", "full"];
4140
+ VERIFY_SCOPES = ["changed", "full", "none"];
4141
4141
  zVerifyScope = external_exports.enum(VERIFY_SCOPES);
4142
4142
  }
4143
4143
  });
@@ -6908,6 +6908,8 @@ var init_dto = __esm({
6908
6908
  priority: zPriority.optional(),
6909
6909
  payload: external_exports.union([zBriefPayload, zQaPayload, zGoalPayload]).optional(),
6910
6910
  // SPEC-407 · +goal
6911
+ // Pindah project: konten-sejenis, jadi ikut gerbang `editingContent` (hanya selagi belum dimulai).
6912
+ projectId: external_exports.string().min(1).optional(),
6911
6913
  // SPEC-447 · ADR-0093 · SENGAJA di luar gerbang `editingContent` (SPEC-186): gerbang itu
6912
6914
  // melindungi konten yang sudah jadi dasar kerja sesi berjalan, sedangkan dependsOn hanya
6913
6915
  // menggerbangi peluncuran BERIKUTNYA. `[]` = kosongkan.
@@ -9472,6 +9474,7 @@ var init_backlog = __esm({
9472
9474
  title: str("Judul baru."),
9473
9475
  priority: PRIORITY,
9474
9476
  payload: SPEC_PAYLOAD_ONEOF,
9477
+ projectId: str("Pindahkan backlog ke project lain (id project). Hanya selagi belum dimulai; branch asal & dependency dikosongkan, dan ditolak 409 bila item lain bergantung padanya."),
9475
9478
  dependsOn: strArray("Ganti seluruh daftar dependency. `[]` mengosongkan. Ini SATU-SATUNYA field di sini yang masih boleh diubah setelah item dimulai.")
9476
9479
  },
9477
9480
  required: ["spec"]
@@ -9487,6 +9490,7 @@ var init_backlog = __esm({
9487
9490
  ...s(a.title) ? { title: a.title } : {},
9488
9491
  ...s(a.priority) ? { priority: a.priority } : {},
9489
9492
  ...a.payload !== void 0 ? { payload: a.payload } : {},
9493
+ ...s(a.projectId) ? { projectId: a.projectId } : {},
9490
9494
  ...Array.isArray(a.dependsOn) ? { dependsOn: a.dependsOn } : {}
9491
9495
  }
9492
9496
  }),
@@ -11624,7 +11628,7 @@ var init_sessions = __esm({
11624
11628
  effort: str("Effort. Kosong = default global."),
11625
11629
  goal: bool("Mode goal per-sesi. Kosong = ikut setelan global."),
11626
11630
  goalCondition: str("Kondisi selesai mode goal (maks 4000 karakter)."),
11627
- verifyScope: enumStr(["changed", "full"], "Scope verifikasi. Kosong = ikut setelan global."),
11631
+ verifyScope: enumStr(["changed", "full", "none"], "Scope verifikasi: changed = hanya yang berubah, full = seluruh project, none = jangan jalankan test. Kosong = ikut setelan global."),
11628
11632
  method: str("Metode workflow. Id tak dikenal jatuh ke default, bukan ditolak."),
11629
11633
  phaseOverrides: {
11630
11634
  type: "object",
@@ -15310,7 +15314,7 @@ var init_reverse_standard = __esm({
15310
15314
  });
15311
15315
 
15312
15316
  // ../runner/src/verify-scope.ts
15313
- var CHANGED;
15317
+ var CHANGED, NONE;
15314
15318
  var init_verify_scope = __esm({
15315
15319
  "../runner/src/verify-scope.ts"() {
15316
15320
  "use strict";
@@ -15351,6 +15355,25 @@ var init_verify_scope = __esm({
15351
15355
  "tipe/kontrak bersama, skema, atau berkas yang diimpor banyak modul), perluas scope seperlunya",
15352
15356
  "dan katakan alasannya. Ini panduan biaya, bukan larangan."
15353
15357
  ].join("\n");
15358
+ NONE = [
15359
+ "Scope verifikasi: TANPA menjalankan test. Operator memilih mode ini karena perangkatnya tak",
15360
+ "kuat menjalankan test \u2014 run sebelumnya membuat mesin tersendat.",
15361
+ "",
15362
+ "- JANGAN menjalankan test apa pun: `pnpm test`, `vitest` (termasuk `--changed`/`related`),",
15363
+ " `jest`, `pytest`, `go test`, Playwright/e2e, maupun skrip yang memanggilnya. Aturan ini",
15364
+ ' MENIMPA instruksi skill/metode (mis. TDD "jalankan test, lihat merah lalu hijau"), instruksi',
15365
+ " fase Verifikasi/review, dan Definition of Done repo target.",
15366
+ "- Menulis atau memperbarui berkas test tetap boleh \u2014 hanya jangan menjalankannya.",
15367
+ "- JANGAN build, lint seluruh repo, boot server + curl, atau smoke end-to-end.",
15368
+ "- Typecheck: paling banyak SEKALI di akhir, hanya untuk paket yang tersentuh",
15369
+ " (mis. `pnpm --filter ./server typecheck`). JANGAN `pnpm -r typecheck`.",
15370
+ '- Verifikasi dengan MEMBACA: telusuri diff-mu (`git diff "$HANOMAN_BASE_SHA"...HEAD`,',
15371
+ " `git status --porcelain`), periksa pemanggil, tipe, dan cabang error dengan grep/baca berkas.",
15372
+ "- Laporan: nyatakan terang bahwa test TIDAK dijalankan (scope verifikasi `none`) dan sebut berkas",
15373
+ " test yang perlu dijalankan manusia. Jangan pernah mengklaim test hijau.",
15374
+ "",
15375
+ "Menjalankan test adalah tugas MANUSIA sebelum merge, bukan tugas sesi."
15376
+ ].join("\n");
15354
15377
  }
15355
15378
  });
15356
15379
 
package/dist/server.js CHANGED
@@ -4159,7 +4159,7 @@ var init_enums = __esm({
4159
4159
  zSeverity = external_exports.enum(["critical", "major", "minor"]);
4160
4160
  zTicketCategory = external_exports.enum(["bug", "fitur", "pertanyaan", "lainnya"]);
4161
4161
  zTicketStatus = external_exports.enum(["new", "accepted", "rejected"]);
4162
- VERIFY_SCOPES = ["changed", "full"];
4162
+ VERIFY_SCOPES = ["changed", "full", "none"];
4163
4163
  zVerifyScope = external_exports.enum(VERIFY_SCOPES);
4164
4164
  }
4165
4165
  });
@@ -7792,6 +7792,8 @@ var init_dto = __esm({
7792
7792
  priority: zPriority.optional(),
7793
7793
  payload: external_exports.union([zBriefPayload, zQaPayload, zGoalPayload]).optional(),
7794
7794
  // SPEC-407 · +goal
7795
+ // Pindah project: konten-sejenis, jadi ikut gerbang `editingContent` (hanya selagi belum dimulai).
7796
+ projectId: external_exports.string().min(1).optional(),
7795
7797
  // SPEC-447 · ADR-0093 · SENGAJA di luar gerbang `editingContent` (SPEC-186): gerbang itu
7796
7798
  // melindungi konten yang sudah jadi dasar kerja sesi berjalan, sedangkan dependsOn hanya
7797
7799
  // menggerbangi peluncuran BERIKUTNYA. `[]` = kosongkan.
@@ -11059,6 +11061,7 @@ var init_backlog = __esm({
11059
11061
  title: str("Judul baru."),
11060
11062
  priority: PRIORITY,
11061
11063
  payload: SPEC_PAYLOAD_ONEOF,
11064
+ projectId: str("Pindahkan backlog ke project lain (id project). Hanya selagi belum dimulai; branch asal & dependency dikosongkan, dan ditolak 409 bila item lain bergantung padanya."),
11062
11065
  dependsOn: strArray("Ganti seluruh daftar dependency. `[]` mengosongkan. Ini SATU-SATUNYA field di sini yang masih boleh diubah setelah item dimulai.")
11063
11066
  },
11064
11067
  required: ["spec"]
@@ -11074,6 +11077,7 @@ var init_backlog = __esm({
11074
11077
  ...s(a.title) ? { title: a.title } : {},
11075
11078
  ...s(a.priority) ? { priority: a.priority } : {},
11076
11079
  ...a.payload !== void 0 ? { payload: a.payload } : {},
11080
+ ...s(a.projectId) ? { projectId: a.projectId } : {},
11077
11081
  ...Array.isArray(a.dependsOn) ? { dependsOn: a.dependsOn } : {}
11078
11082
  }
11079
11083
  }),
@@ -13211,7 +13215,7 @@ var init_sessions = __esm({
13211
13215
  effort: str("Effort. Kosong = default global."),
13212
13216
  goal: bool("Mode goal per-sesi. Kosong = ikut setelan global."),
13213
13217
  goalCondition: str("Kondisi selesai mode goal (maks 4000 karakter)."),
13214
- verifyScope: enumStr(["changed", "full"], "Scope verifikasi. Kosong = ikut setelan global."),
13218
+ verifyScope: enumStr(["changed", "full", "none"], "Scope verifikasi: changed = hanya yang berubah, full = seluruh project, none = jangan jalankan test. Kosong = ikut setelan global."),
13215
13219
  method: str("Metode workflow. Id tak dikenal jatuh ke default, bukan ditolak."),
13216
13220
  phaseOverrides: {
13217
13221
  type: "object",
@@ -17239,7 +17243,7 @@ dengan folder implementasi nyata repo ini (hasil fase Scan):
17239
17243
  });
17240
17244
 
17241
17245
  // ../runner/src/verify-scope.ts
17242
- var CHANGED, verifyScopeClause;
17246
+ var CHANGED, NONE, verifyScopeClause;
17243
17247
  var init_verify_scope = __esm({
17244
17248
  "../runner/src/verify-scope.ts"() {
17245
17249
  "use strict";
@@ -17280,7 +17284,26 @@ var init_verify_scope = __esm({
17280
17284
  "tipe/kontrak bersama, skema, atau berkas yang diimpor banyak modul), perluas scope seperlunya",
17281
17285
  "dan katakan alasannya. Ini panduan biaya, bukan larangan."
17282
17286
  ].join("\n");
17283
- verifyScopeClause = (scope) => scope === "changed" ? CHANGED : "";
17287
+ NONE = [
17288
+ "Scope verifikasi: TANPA menjalankan test. Operator memilih mode ini karena perangkatnya tak",
17289
+ "kuat menjalankan test \u2014 run sebelumnya membuat mesin tersendat.",
17290
+ "",
17291
+ "- JANGAN menjalankan test apa pun: `pnpm test`, `vitest` (termasuk `--changed`/`related`),",
17292
+ " `jest`, `pytest`, `go test`, Playwright/e2e, maupun skrip yang memanggilnya. Aturan ini",
17293
+ ' MENIMPA instruksi skill/metode (mis. TDD "jalankan test, lihat merah lalu hijau"), instruksi',
17294
+ " fase Verifikasi/review, dan Definition of Done repo target.",
17295
+ "- Menulis atau memperbarui berkas test tetap boleh \u2014 hanya jangan menjalankannya.",
17296
+ "- JANGAN build, lint seluruh repo, boot server + curl, atau smoke end-to-end.",
17297
+ "- Typecheck: paling banyak SEKALI di akhir, hanya untuk paket yang tersentuh",
17298
+ " (mis. `pnpm --filter ./server typecheck`). JANGAN `pnpm -r typecheck`.",
17299
+ '- Verifikasi dengan MEMBACA: telusuri diff-mu (`git diff "$HANOMAN_BASE_SHA"...HEAD`,',
17300
+ " `git status --porcelain`), periksa pemanggil, tipe, dan cabang error dengan grep/baca berkas.",
17301
+ "- Laporan: nyatakan terang bahwa test TIDAK dijalankan (scope verifikasi `none`) dan sebut berkas",
17302
+ " test yang perlu dijalankan manusia. Jangan pernah mengklaim test hijau.",
17303
+ "",
17304
+ "Menjalankan test adalah tugas MANUSIA sebelum merge, bukan tugas sesi."
17305
+ ].join("\n");
17306
+ verifyScopeClause = (scope) => scope === "changed" ? CHANGED : scope === "none" ? NONE : "";
17284
17307
  }
17285
17308
  });
17286
17309
 
@@ -76929,22 +76952,33 @@ ${item.context}` : item.context;
76929
76952
  return reply.code(403).send({ error: "capability required", need: "backlog:lifecycle" });
76930
76953
  const spec = await prisma.spec.findUnique({ where: { id: id2 } });
76931
76954
  if (!spec) return reply.code(404).send({ error: "not found" });
76932
- const { branchFrom, stage, confirmDelete, title, priority: newPriority, payload, dependsOn, autoMerge } = parsed.data;
76933
- const editingContent = title !== void 0 || newPriority !== void 0 || payload !== void 0;
76955
+ const { branchFrom, stage, confirmDelete, title, priority: newPriority, payload, dependsOn, autoMerge, projectId: newProjectId } = parsed.data;
76956
+ const moving = newProjectId !== void 0 && newProjectId !== spec.projectId;
76957
+ const editingContent = title !== void 0 || newPriority !== void 0 || payload !== void 0 || moving;
76934
76958
  if (editingContent && (spec.stage !== "brainstorming" || spec.baseSha !== null))
76935
76959
  return reply.code(409).send({ error: "backlog item sudah dimulai \u2014 tak bisa diedit" });
76960
+ if (moving) {
76961
+ if (!await prisma.project.findUnique({ where: { id: newProjectId }, select: { id: true } }))
76962
+ return reply.code(400).send({ error: "project tujuan tidak ditemukan" });
76963
+ if (dependsOn?.length) return reply.code(400).send({ error: "dependency harus di project yang sama" });
76964
+ const siblings = await prisma.spec.findMany({ where: { projectId: spec.projectId }, select: { id: true, dependsOn: true } });
76965
+ const dependents = siblings.filter((r) => dependsOnOf(r).includes(id2)).map((r) => r.id);
76966
+ if (dependents.length)
76967
+ return reply.code(409).send({ error: `masih dipakai sebagai dependency oleh ${dependents.join(", ")}` });
76968
+ }
76969
+ const effProjectId = moving ? newProjectId : spec.projectId;
76936
76970
  if (branchFrom) {
76937
- if (await branchUnknown(await resolveRepoDir(spec.projectId), branchFrom))
76971
+ if (await branchUnknown(await resolveRepoDir(effProjectId), branchFrom))
76938
76972
  return reply.code(400).send({ error: `branch "${branchFrom}" tidak ada di repo project` });
76939
76973
  }
76940
76974
  let depIds;
76941
76975
  if (dependsOn !== void 0) {
76942
- const d = await validateDependsOn(spec.id, spec.projectId, dependsOn);
76976
+ const d = await validateDependsOn(spec.id, effProjectId, dependsOn);
76943
76977
  if (!d.ok) return reply.code(400).send({ error: d.error });
76944
76978
  depIds = d.ids;
76945
76979
  }
76946
76980
  if ("autoMerge" in parsed.data) {
76947
- const gate2 = await checkAutoMerge(await resolveRepoDir(spec.projectId), autoMerge);
76981
+ const gate2 = await checkAutoMerge(await resolveRepoDir(effProjectId), autoMerge);
76948
76982
  if (!gate2.ok) return reply.code(gate2.code).send({ error: gate2.error });
76949
76983
  }
76950
76984
  if (stage !== void 0) {
@@ -76964,6 +76998,11 @@ ${item.context}` : item.context;
76964
76998
  data.stage = stage;
76965
76999
  data.reviewedAt = null;
76966
77000
  }
77001
+ if (moving) {
77002
+ data.projectId = newProjectId;
77003
+ if (branchFrom === void 0) data.branchFrom = null;
77004
+ if (depIds === void 0) data.dependsOn = [];
77005
+ }
76967
77006
  if (editingContent) {
76968
77007
  const effPayload = payload ?? spec.payload;
76969
77008
  const { priority, objective } = deriveSpecFields(spec.source, effPayload, newPriority ?? spec.priority);
@@ -76972,7 +77011,10 @@ ${item.context}` : item.context;
76972
77011
  data.priority = priority;
76973
77012
  data.objective = objective;
76974
77013
  }
76975
- const updated = await prisma.spec.update({ where: { id: id2 }, data });
77014
+ const [updated] = await prisma.$transaction([
77015
+ prisma.spec.update({ where: { id: id2 }, data }),
77016
+ ...moving ? [prisma.specAttachment.updateMany({ where: { specId: id2 }, data: { projectId: newProjectId } })] : []
77017
+ ]);
76976
77018
  await notifySynced("spec", id2);
76977
77019
  return updated;
76978
77020
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hanoman",
3
- "version": "0.9.33",
3
+ "version": "0.9.35",
4
4
  "description": "Orchestrator + dashboard workflow docs-driven untuk sesi Claude Code / Codex",
5
5
  "type": "module",
6
6
  "repository": {
@@ -1,4 +1,4 @@
1
- import{j as e,u as be,I as C,l as I,S as se,F as te}from"./index-R2HBkTbR.js";import{R as d}from"./react-DfGhg7ZW.js";import"./markdown-CWEY34jk.js";import"./xterm-3VOAfa_q.js";function ye({height:s,color:a,rod:l}){return e.jsxs("svg",{viewBox:"0 0 64 128",width:s*64/128,height:s,"aria-hidden":"true",focusable:"false",children:[e.jsx("path",{d:"M31.2 74 L30.2 127 L33.8 127 L32.8 74 Z",fill:l}),e.jsx("path",{d:"M51 79 L50.2 122 L53 122 L52.4 79 Z",fill:l}),e.jsx("path",{d:`M32 73
1
+ import{j as e,u as be,I as C,l as I,S as se,F as te}from"./index-BjNlrKWq.js";import{R as d}from"./react-DfGhg7ZW.js";import"./markdown-CWEY34jk.js";import"./xterm-3VOAfa_q.js";function ye({height:s,color:a,rod:l}){return e.jsxs("svg",{viewBox:"0 0 64 128",width:s*64/128,height:s,"aria-hidden":"true",focusable:"false",children:[e.jsx("path",{d:"M31.2 74 L30.2 127 L33.8 127 L32.8 74 Z",fill:l}),e.jsx("path",{d:"M51 79 L50.2 122 L53 122 L52.4 79 Z",fill:l}),e.jsx("path",{d:`M32 73
2
2
  C 24 76, 19 88, 17.5 103 C 17 106, 20 107, 24 106.4
3
3
  C 28 106, 30 104, 32 104 C 34 104, 36 106, 40 106.4 C 44 107, 47 106, 46.5 103
4
4
  C 45 88, 40 76, 32 73 Z`,fill:a}),e.jsx("path",{d:"M32 74 C 29.5 66, 29.5 60, 31 53 L 37 53 C 38.5 60, 37.5 67, 34.5 74 Z",fill:a}),e.jsx("path",{d:`M31 53
@@ -1 +1 @@
1
- import{j as e,M as r,aP as d,aR as a,m as x}from"./index-R2HBkTbR.js";import"./react-DfGhg7ZW.js";function f({path:i,text:o,eyebrow:n,download:t,onClose:s}){const l=i.slice(i.lastIndexOf("/")+1)||i;return e.jsx(r,{open:!0,title:l,eyebrow:n??i,icon:"book-open",onClose:s,width:980,fillHeight:!0,children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[t&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",paddingBottom:6,borderBottom:"1px solid var(--border-hair)",marginBottom:8},children:e.jsx(d,{href:t})}),e.jsx("div",{"data-testid":"doc-preview-scroll",style:{flex:"1 1 0",minHeight:0,overflow:"auto",padding:"0 4px 8px"},children:o?e.jsx(a,{text:o,name:i}):e.jsx(x,{kind:"empty",icon:"file-text",title:"Berkas kosong",hint:i})})]})})}export{f as D};
1
+ import{j as e,M as r,aP as d,aR as a,m as x}from"./index-BjNlrKWq.js";import"./react-DfGhg7ZW.js";function f({path:i,text:o,eyebrow:n,download:t,onClose:s}){const l=i.slice(i.lastIndexOf("/")+1)||i;return e.jsx(r,{open:!0,title:l,eyebrow:n??i,icon:"book-open",onClose:s,width:980,fillHeight:!0,children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[t&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",paddingBottom:6,borderBottom:"1px solid var(--border-hair)",marginBottom:8},children:e.jsx(d,{href:t})}),e.jsx("div",{"data-testid":"doc-preview-scroll",style:{flex:"1 1 0",minHeight:0,overflow:"auto",padding:"0 4px 8px"},children:o?e.jsx(a,{text:o,name:i}):e.jsx(x,{kind:"empty",icon:"file-text",title:"Berkas kosong",hint:i})})]})})}export{f as D};
@@ -1,3 +1,3 @@
1
- import{q as Ne,d as De,h as S,j as e,m as w,I as N,U as Se,Y as Ce,B as O,f as Ke,n as U,O as Le,aP as Me,aR as te,D as Pe,aU as $e,i as ie}from"./index-R2HBkTbR.js";import{R as o}from"./react-DfGhg7ZW.js";import"./markdown-CWEY34jk.js";import"./xterm-3VOAfa_q.js";function de(n){let t={...n,kids:n.kids.map(de)};for(;!t.cat&&t.kids.length===1;){const i=t.kids[0];t={...i,label:t.label+"/"+i.label}}return t}function re(n){const t={path:"",kids:[]};for(const i of n){if(i.cat==="."){t.kids.push({path:".",label:".",cat:i,kids:[]});continue}let l=t;for(const u of i.cat.split("/")){const k=l.path?l.path+"/"+u:u;let m=l.kids.find(s=>s.path===k);m||(m={path:k,label:u,kids:[]},l.kids.push(m)),l=m}l.cat=i}return t.kids.map(de)}function le(n){const t=n.find(i=>i.scored&&i.linked)??n.find(i=>i.scored)??n[0];return t&&t.files[0]?`${t.cat}/${t.files[0]}`:""}function oe(n){return/(^|\/)adr(s)?(\/|$)/i.test(n)?"ADR":/(^|\/)prd(s)?(\/|$)/i.test(n)?"PRD":/(^|\/)spec(s|ification)?(\/|$)/i.test(n)?"Spec":"Lainnya"}const ze=["PRD","Spec","ADR","Lainnya"],ue=n=>`dir:${n}`,Fe=(n,t)=>!!t&&t.startsWith(n.path+"/");function he({node:n,depth:t,ctx:i}){var h,p,y;const l=Fe(n,i.selected),[u,k]=o.useState(l);o.useEffect(()=>{l&&k(!0)},[l]);const m=((h=n.cat)==null?void 0:h.scored)??!0,s=((p=n.cat)==null?void 0:p.linked)??!0,v=ue(n.path),b=()=>k(d=>!d),c=d=>{d.key==="Enter"||d.key===" "?(d.preventDefault(),b()):d.key==="ArrowRight"&&!u?(d.preventDefault(),k(!0)):d.key==="ArrowLeft"&&u&&(d.preventDefault(),k(!1))};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{role:"treeitem","aria-level":t+1,"aria-expanded":u,tabIndex:i.tabbable===v?0:-1,className:"hn-docs-node hn-docs-node-dir",style:{paddingLeft:6+t*12},onClick:b,onKeyDown:c,onFocus:()=>i.setFocusKey(v),children:[e.jsx(N,{name:u?"chevron-down":"chevron-right",size:14,color:"var(--text-subtle)"}),e.jsx(N,{name:"folder",size:15,color:m?s?"var(--brass-500)":"var(--clay-500)":"var(--text-subtle)"}),e.jsxs("span",{className:"hn-docs-dir-label",children:[n.label,"/"]}),n.cat&&m&&(n.cat.linked?e.jsx(N,{name:"link",size:13,color:"var(--leaf-600)"}):e.jsx(N,{name:"unlink",size:13,color:"var(--clay-500)"}))]}),u&&e.jsxs("div",{role:"group",className:"hn-docs-group",children:[n.kids.map(d=>e.jsx(he,{node:d,depth:t+1,ctx:i},d.path)),(y=n.cat)==null?void 0:y.files.map(d=>{const f=n.path+"/"+d,j=f===i.selected;return e.jsxs("div",{role:"treeitem","aria-level":t+2,"aria-selected":j,"aria-current":j?"true":void 0,tabIndex:i.tabbable===f?0:-1,className:`hn-docs-node hn-docs-node-file${j?" is-selected":""}`,style:{paddingLeft:18+t*12},onClick:()=>i.onSelect(f),onFocus:()=>i.setFocusKey(f),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),i.onSelect(f))},children:[e.jsx(N,{name:"file-text",size:13,color:j?"var(--brass-700)":"var(--text-subtle)"}),e.jsx("span",{className:`hn-docs-file-label${!m||s?"":" is-unlinked"}`,children:d})]},d)})]})]})}function ce({label:n,nodes:t,selected:i,onSelect:l}){const[u,k]=o.useState(null),m=t[0]?ue(t[0].path):"",v={selected:i,onSelect:l,tabbable:u??(i||m),setFocusKey:c=>k(c)},b=c=>{if(c.key!=="ArrowDown"&&c.key!=="ArrowUp")return;const h=Array.from(c.currentTarget.querySelectorAll('[role="treeitem"]')),p=h.indexOf(document.activeElement);if(p<0)return;c.preventDefault();const y=h[Math.min(h.length-1,Math.max(0,p+(c.key==="ArrowDown"?1:-1)))];y==null||y.focus()};return e.jsx("div",{role:"tree","aria-label":n,className:"hn-docs-tree",onKeyDown:b,children:t.map(c=>e.jsx(he,{node:c,depth:0,ctx:v},c.path))})}function Ie({projectId:n,projectName:t,docStatus:i}){const[l,u]=o.useState([]),[k,m]=o.useState(0),[s,v]=Ne($e("docs",n),"selected","",Pe),[b,c]=o.useState({}),[h,p]=o.useState("preview"),[y,d]=o.useState("tree"),[f,j]=o.useState(""),[g,q]=o.useState(!1),[L,W]=o.useState(!1),[G,C]=o.useState(""),[P,J]=o.useState(""),[D,$]=o.useState("all"),{confirm:Q,dialog:me}=De(),[z,K]=o.useState("loading"),[pe,ke]=o.useState(0);o.useEffect(()=>{let a=!0;return K("loading"),S.getDocs(n).then(r=>{if(!a)return;const x=r.tree;u(x),m(r.coverage),c({}),p("preview"),K("ready"),C(""),J(""),$("all"),v(le(x))}).catch(()=>{a&&(u([]),v(""),K("error"))}),()=>{a=!1}},[n,pe]),o.useEffect(()=>{if(!s||s in b)return;let a=!0;return S.getDoc(n,s).then(r=>{a&&c(x=>({...x,[s]:r.content}))}).catch(()=>{a&&c(r=>({...r,[s]:null}))}),()=>{a=!1}},[s,n,b]);const F=!!s&&!(s in b),A=s?b[s]===null:!1,fe=()=>c(a=>{const r={...a};return delete r[s],r}),V=a=>D==="all"||oe(a.cat)===D,xe=re(l.filter(a=>a.scored&&V(a))),Y=re(l.filter(a=>!a.scored&&V(a))),B=b[s]??"",be=s.includes("/")?s.slice(0,s.lastIndexOf("/")):".",T=l.find(a=>a.cat===be),_=s,E=h==="edit"&&f!==B,I=o.useMemo(()=>l.flatMap(a=>a.files.map(r=>({key:`${a.cat}/${r}`,scored:a.scored,linked:a.linked,kind:oe(a.cat)}))),[l]),R=P.trim().toLowerCase(),X=R?I.filter(a=>(D==="all"||a.kind===D)&&a.key.toLowerCase().includes(R)):[],ve=o.useMemo(()=>{const a={PRD:0,Spec:0,ADR:0,Lainnya:0};for(const r of I)a[r.kind]+=1;return a},[I]),ye=i==="broken"?"broken":i==="drift"?"drift":"ok";function Z(a){if(!E){p("preview"),a();return}Q({title:"Buang perubahan?",eyebrow:s,message:"Isi dokumen yang kamu ubah belum disimpan.",impact:["Perubahan di editor hilang dan tak bisa dikembalikan dari dashboard."],confirmLabel:"Buang perubahan",cancelLabel:"Lanjut mengedit",tone:"danger",icon:"trash-2"}).then(r=>{r&&(p("preview"),a())})}function ge(){C(""),j(B),p("edit")}const ee=()=>Z(()=>{});async function ae(){if(!(L||!s)){W(!0),C("");try{await S.putDoc(n,s,f),c(a=>({...a,[s]:f})),p("preview")}catch(a){C(ie("menyimpan dokumen",a))}finally{W(!1)}}}function H(a){Z(()=>{v(a),p("preview"),d("viewer")})}async function se(){const a=await S.getDocs(n),r=a.tree;u(r),m(a.coverage),r.some(x=>x.files.some(M=>`${x.cat}/${M}`===s))||v(le(r))}async function ne(){if(!g){q(!0);try{await se()}catch{K("error")}finally{q(!1)}}}async function je(){if(!s)return;const a=s;let r=!1;try{r=await Q({title:`Hapus ${a}?`,eyebrow:"Source of Truth",message:"Dokumen ini adalah Source of Truth project. Berkas aslinya di disk ikut dihapus.",impact:["Berkas di disk dihapus dan tak bisa dikembalikan dari dashboard.","Kategori indeks dihitung ulang setelah penghapusan."],confirmLabel:"Hapus dokumen",tone:"danger",icon:"trash-2",run:()=>S.deleteDoc(n,a)})}catch(x){C(ie("menghapus dokumen",x));return}if(r){c(x=>{const M={...x};return delete M[a],M});try{await se()}catch{K("error")}}}const we=z==="loading"?e.jsx(w,{kind:"loading",compact:!0,title:"Memuat indeks…"}):z==="error"?e.jsx(w,{kind:"error",compact:!0,title:"Gagal memuat indeks dokumen",hint:t,action:()=>ke(a=>a+1)}):l.length===0?e.jsx(w,{kind:"empty",compact:!0,icon:"folder-open",title:"Belum ada dokumen",hint:"Belum ada Markdown di repo ini.",action:ne,actionLabel:"Muat ulang",actionIcon:"radar"}):R?X.length===0?e.jsx(w,{kind:"empty",compact:!0,icon:"search",title:"Tak ada berkas cocok",hint:`Tak ada yang cocok dengan “${P.trim()}”.`}):e.jsx("div",{role:"list","aria-label":"Hasil pencarian berkas",className:"hn-docs-results",children:X.map(a=>e.jsxs("button",{type:"button","aria-current":a.key===s?"true":void 0,onClick:()=>H(a.key),className:`hn-docs-result${a.key===s?" is-selected":""}`,children:[e.jsx(N,{name:"file-text",size:13,color:"var(--text-subtle)"}),e.jsx("span",{className:"hn-prj-mono",children:a.key}),e.jsx("span",{className:"hn-docs-result-kind",children:a.kind})]},a.key))}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{label:"Berkas dokumen",nodes:xe,selected:s,onSelect:H}),Y.length>0&&e.jsxs("div",{className:"hn-docs-unscored",children:[e.jsx("div",{className:"hn-eyebrow hn-docs-unscored-label",children:"Lainnya (tidak dinilai)"}),e.jsx(ce,{label:"Dokumen tidak dinilai",nodes:Y,selected:s,onSelect:H})]})]});return e.jsxs(e.Fragment,{children:[e.jsx(Se,{ariaLabel:"Panel Dokumen",active:y,onActiveChange:a=>d(a),masterWidth:288,className:"hn-workspace-panels",panels:[{id:"tree",label:"Indeks",className:"hn-panel-flex",content:e.jsxs("aside",{"aria-label":"Indeks dokumen",className:"hn-docs-index",children:[e.jsxs("div",{className:"hn-docs-index-head",children:[e.jsxs("span",{className:"hn-eyebrow",children:["dokumen · ",t]}),e.jsxs("div",{className:"hn-docs-index-actions",children:[e.jsx(Ce,{status:ye,size:"sm"}),e.jsx(O,{size:"sm",variant:"ghost",leftIcon:g?"loader":"radar",onClick:ne,disabled:g,children:g?"Memuat…":"Muat ulang"})]})]}),z==="ready"&&l.length>0&&e.jsxs("div",{className:"hn-docs-index-tools",children:[e.jsx(Ke,{size:"sm","aria-label":"Cari berkas dokumen",leftIcon:"search",value:P,placeholder:"mis. product/prd",onChange:a=>J(a.target.value),className:"hn-prj-full"}),e.jsxs("div",{role:"group","aria-label":"Kategori dokumen",className:"hn-prj-chips",children:[e.jsx("button",{type:"button",className:"hn-prj-chip hn-touch-target","aria-pressed":D==="all",onClick:()=>$("all"),children:"Semua"}),ze.map(a=>e.jsxs("button",{type:"button",className:"hn-prj-chip hn-touch-target","aria-pressed":D===a,onClick:()=>$(a),children:[a,e.jsx("span",{className:"hn-prj-chip-count",children:ve[a]})]},a))]}),e.jsxs("span",{className:"hn-docs-cov",title:"Persentase kategori yang terindeks",children:["Cakupan ",Math.round(k),"%"]})]}),e.jsx("div",{className:"hn-docs-tree-scroll",children:we})]})},{id:"viewer",label:"Dokumen",className:"hn-panel-flex",content:e.jsxs("section",{"aria-label":"Isi dokumen",className:"hn-docs-viewer",style:{display:"flex",flexDirection:"column",minHeight:0},children:[e.jsxs("div",{className:"hn-docs-viewer-head",children:[e.jsx(N,{name:"file-text",size:15,color:"var(--text-muted)"}),e.jsx("span",{className:"hn-prj-mono hn-docs-path",children:_}),T&&T.scored&&(T.linked?e.jsx(U,{tone:"ok",size:"sm",icon:"link",children:"terindeks"}):e.jsx(U,{tone:"err",size:"sm",icon:"unlink",children:"tak tertaut"})),e.jsx("span",{className:"hn-grow"}),e.jsxs("div",{role:"group","aria-label":"Mode dokumen",className:"hn-prj-seg",children:[e.jsx("button",{type:"button","aria-pressed":h==="preview",className:"hn-touch-target",onClick:()=>{h==="edit"&&ee()},children:"Baca"}),e.jsx("button",{type:"button","aria-pressed":h==="edit",className:"hn-touch-target",onClick:()=>{h!=="edit"&&ge()},disabled:!s||F||A,children:"Edit"})]}),h==="preview"&&e.jsx(Le,{label:"Aksi untuk dokumen",icon:"ellipsis",items:[{key:"delete",label:"Hapus dokumen…",icon:"trash-2",tone:"danger",disabled:!s,onSelect:()=>{je()}}],children:e.jsx(Me,{href:a=>S.docDownloadUrl(n,s,a),disabled:!s||F||A})})]}),h==="edit"&&e.jsxs("div",{role:"region","aria-label":"Simpan perubahan",className:"hn-docs-savebar",children:[E?e.jsx(U,{tone:"warn",size:"sm",children:"belum disimpan"}):e.jsx("span",{className:"hn-prj-hint",children:"Tak ada perubahan"}),e.jsx("span",{className:"hn-grow"}),e.jsx(O,{size:"sm",variant:"ghost",onClick:ee,disabled:L,children:"Batal"}),e.jsx(O,{size:"sm",leftIcon:"check",onClick:()=>void ae(),loading:L,disabled:L||!E,children:"Simpan"})]}),G&&e.jsx("div",{role:"alert",className:"hn-docs-error",children:G}),h==="preview"?e.jsx("div",{"data-testid":"doc-preview-scroll",className:"hn-docs-body",style:{flex:"1 1 auto",minHeight:0,overflow:"auto"},children:s?F?e.jsx(w,{kind:"loading",title:"Memuat dokumen…",hint:s}):A?e.jsx(w,{kind:"error",title:"Gagal memuat dokumen",hint:s,action:fe}):e.jsx("div",{className:"hn-docs-read",children:e.jsx(te,{text:B,name:s})}):e.jsx(w,{kind:"empty",icon:"file-text",title:"Tidak ada dokumen dipilih",hint:"Pilih file dari indeks di kiri."})}):e.jsxs("div",{className:"hn-docs-edit",children:[e.jsxs("div",{className:"hn-docs-edit-pane",children:[e.jsx("div",{className:"hn-docs-edit-label",children:e.jsx("span",{className:"hn-eyebrow",children:"Markdown"})}),e.jsx("textarea",{"aria-label":`Isi ${_}`,value:f,spellCheck:!1,onChange:a=>j(a.target.value),onKeyDown:a=>{(a.metaKey||a.ctrlKey)&&a.key.toLowerCase()==="s"&&(a.preventDefault(),ae())},placeholder:`# Judul dokumen
1
+ import{q as Ne,d as De,h as S,j as e,m as w,I as N,U as Se,Y as Ce,B as O,f as Ke,n as U,O as Le,aP as Me,aR as te,D as Pe,aU as $e,i as ie}from"./index-BjNlrKWq.js";import{R as o}from"./react-DfGhg7ZW.js";import"./markdown-CWEY34jk.js";import"./xterm-3VOAfa_q.js";function de(n){let t={...n,kids:n.kids.map(de)};for(;!t.cat&&t.kids.length===1;){const i=t.kids[0];t={...i,label:t.label+"/"+i.label}}return t}function re(n){const t={path:"",kids:[]};for(const i of n){if(i.cat==="."){t.kids.push({path:".",label:".",cat:i,kids:[]});continue}let l=t;for(const u of i.cat.split("/")){const k=l.path?l.path+"/"+u:u;let m=l.kids.find(s=>s.path===k);m||(m={path:k,label:u,kids:[]},l.kids.push(m)),l=m}l.cat=i}return t.kids.map(de)}function le(n){const t=n.find(i=>i.scored&&i.linked)??n.find(i=>i.scored)??n[0];return t&&t.files[0]?`${t.cat}/${t.files[0]}`:""}function oe(n){return/(^|\/)adr(s)?(\/|$)/i.test(n)?"ADR":/(^|\/)prd(s)?(\/|$)/i.test(n)?"PRD":/(^|\/)spec(s|ification)?(\/|$)/i.test(n)?"Spec":"Lainnya"}const ze=["PRD","Spec","ADR","Lainnya"],ue=n=>`dir:${n}`,Fe=(n,t)=>!!t&&t.startsWith(n.path+"/");function he({node:n,depth:t,ctx:i}){var h,p,y;const l=Fe(n,i.selected),[u,k]=o.useState(l);o.useEffect(()=>{l&&k(!0)},[l]);const m=((h=n.cat)==null?void 0:h.scored)??!0,s=((p=n.cat)==null?void 0:p.linked)??!0,v=ue(n.path),b=()=>k(d=>!d),c=d=>{d.key==="Enter"||d.key===" "?(d.preventDefault(),b()):d.key==="ArrowRight"&&!u?(d.preventDefault(),k(!0)):d.key==="ArrowLeft"&&u&&(d.preventDefault(),k(!1))};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{role:"treeitem","aria-level":t+1,"aria-expanded":u,tabIndex:i.tabbable===v?0:-1,className:"hn-docs-node hn-docs-node-dir",style:{paddingLeft:6+t*12},onClick:b,onKeyDown:c,onFocus:()=>i.setFocusKey(v),children:[e.jsx(N,{name:u?"chevron-down":"chevron-right",size:14,color:"var(--text-subtle)"}),e.jsx(N,{name:"folder",size:15,color:m?s?"var(--brass-500)":"var(--clay-500)":"var(--text-subtle)"}),e.jsxs("span",{className:"hn-docs-dir-label",children:[n.label,"/"]}),n.cat&&m&&(n.cat.linked?e.jsx(N,{name:"link",size:13,color:"var(--leaf-600)"}):e.jsx(N,{name:"unlink",size:13,color:"var(--clay-500)"}))]}),u&&e.jsxs("div",{role:"group",className:"hn-docs-group",children:[n.kids.map(d=>e.jsx(he,{node:d,depth:t+1,ctx:i},d.path)),(y=n.cat)==null?void 0:y.files.map(d=>{const f=n.path+"/"+d,j=f===i.selected;return e.jsxs("div",{role:"treeitem","aria-level":t+2,"aria-selected":j,"aria-current":j?"true":void 0,tabIndex:i.tabbable===f?0:-1,className:`hn-docs-node hn-docs-node-file${j?" is-selected":""}`,style:{paddingLeft:18+t*12},onClick:()=>i.onSelect(f),onFocus:()=>i.setFocusKey(f),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),i.onSelect(f))},children:[e.jsx(N,{name:"file-text",size:13,color:j?"var(--brass-700)":"var(--text-subtle)"}),e.jsx("span",{className:`hn-docs-file-label${!m||s?"":" is-unlinked"}`,children:d})]},d)})]})]})}function ce({label:n,nodes:t,selected:i,onSelect:l}){const[u,k]=o.useState(null),m=t[0]?ue(t[0].path):"",v={selected:i,onSelect:l,tabbable:u??(i||m),setFocusKey:c=>k(c)},b=c=>{if(c.key!=="ArrowDown"&&c.key!=="ArrowUp")return;const h=Array.from(c.currentTarget.querySelectorAll('[role="treeitem"]')),p=h.indexOf(document.activeElement);if(p<0)return;c.preventDefault();const y=h[Math.min(h.length-1,Math.max(0,p+(c.key==="ArrowDown"?1:-1)))];y==null||y.focus()};return e.jsx("div",{role:"tree","aria-label":n,className:"hn-docs-tree",onKeyDown:b,children:t.map(c=>e.jsx(he,{node:c,depth:0,ctx:v},c.path))})}function Ie({projectId:n,projectName:t,docStatus:i}){const[l,u]=o.useState([]),[k,m]=o.useState(0),[s,v]=Ne($e("docs",n),"selected","",Pe),[b,c]=o.useState({}),[h,p]=o.useState("preview"),[y,d]=o.useState("tree"),[f,j]=o.useState(""),[g,q]=o.useState(!1),[L,W]=o.useState(!1),[G,C]=o.useState(""),[P,J]=o.useState(""),[D,$]=o.useState("all"),{confirm:Q,dialog:me}=De(),[z,K]=o.useState("loading"),[pe,ke]=o.useState(0);o.useEffect(()=>{let a=!0;return K("loading"),S.getDocs(n).then(r=>{if(!a)return;const x=r.tree;u(x),m(r.coverage),c({}),p("preview"),K("ready"),C(""),J(""),$("all"),v(le(x))}).catch(()=>{a&&(u([]),v(""),K("error"))}),()=>{a=!1}},[n,pe]),o.useEffect(()=>{if(!s||s in b)return;let a=!0;return S.getDoc(n,s).then(r=>{a&&c(x=>({...x,[s]:r.content}))}).catch(()=>{a&&c(r=>({...r,[s]:null}))}),()=>{a=!1}},[s,n,b]);const F=!!s&&!(s in b),A=s?b[s]===null:!1,fe=()=>c(a=>{const r={...a};return delete r[s],r}),V=a=>D==="all"||oe(a.cat)===D,xe=re(l.filter(a=>a.scored&&V(a))),Y=re(l.filter(a=>!a.scored&&V(a))),B=b[s]??"",be=s.includes("/")?s.slice(0,s.lastIndexOf("/")):".",T=l.find(a=>a.cat===be),_=s,E=h==="edit"&&f!==B,I=o.useMemo(()=>l.flatMap(a=>a.files.map(r=>({key:`${a.cat}/${r}`,scored:a.scored,linked:a.linked,kind:oe(a.cat)}))),[l]),R=P.trim().toLowerCase(),X=R?I.filter(a=>(D==="all"||a.kind===D)&&a.key.toLowerCase().includes(R)):[],ve=o.useMemo(()=>{const a={PRD:0,Spec:0,ADR:0,Lainnya:0};for(const r of I)a[r.kind]+=1;return a},[I]),ye=i==="broken"?"broken":i==="drift"?"drift":"ok";function Z(a){if(!E){p("preview"),a();return}Q({title:"Buang perubahan?",eyebrow:s,message:"Isi dokumen yang kamu ubah belum disimpan.",impact:["Perubahan di editor hilang dan tak bisa dikembalikan dari dashboard."],confirmLabel:"Buang perubahan",cancelLabel:"Lanjut mengedit",tone:"danger",icon:"trash-2"}).then(r=>{r&&(p("preview"),a())})}function ge(){C(""),j(B),p("edit")}const ee=()=>Z(()=>{});async function ae(){if(!(L||!s)){W(!0),C("");try{await S.putDoc(n,s,f),c(a=>({...a,[s]:f})),p("preview")}catch(a){C(ie("menyimpan dokumen",a))}finally{W(!1)}}}function H(a){Z(()=>{v(a),p("preview"),d("viewer")})}async function se(){const a=await S.getDocs(n),r=a.tree;u(r),m(a.coverage),r.some(x=>x.files.some(M=>`${x.cat}/${M}`===s))||v(le(r))}async function ne(){if(!g){q(!0);try{await se()}catch{K("error")}finally{q(!1)}}}async function je(){if(!s)return;const a=s;let r=!1;try{r=await Q({title:`Hapus ${a}?`,eyebrow:"Source of Truth",message:"Dokumen ini adalah Source of Truth project. Berkas aslinya di disk ikut dihapus.",impact:["Berkas di disk dihapus dan tak bisa dikembalikan dari dashboard.","Kategori indeks dihitung ulang setelah penghapusan."],confirmLabel:"Hapus dokumen",tone:"danger",icon:"trash-2",run:()=>S.deleteDoc(n,a)})}catch(x){C(ie("menghapus dokumen",x));return}if(r){c(x=>{const M={...x};return delete M[a],M});try{await se()}catch{K("error")}}}const we=z==="loading"?e.jsx(w,{kind:"loading",compact:!0,title:"Memuat indeks…"}):z==="error"?e.jsx(w,{kind:"error",compact:!0,title:"Gagal memuat indeks dokumen",hint:t,action:()=>ke(a=>a+1)}):l.length===0?e.jsx(w,{kind:"empty",compact:!0,icon:"folder-open",title:"Belum ada dokumen",hint:"Belum ada Markdown di repo ini.",action:ne,actionLabel:"Muat ulang",actionIcon:"radar"}):R?X.length===0?e.jsx(w,{kind:"empty",compact:!0,icon:"search",title:"Tak ada berkas cocok",hint:`Tak ada yang cocok dengan “${P.trim()}”.`}):e.jsx("div",{role:"list","aria-label":"Hasil pencarian berkas",className:"hn-docs-results",children:X.map(a=>e.jsxs("button",{type:"button","aria-current":a.key===s?"true":void 0,onClick:()=>H(a.key),className:`hn-docs-result${a.key===s?" is-selected":""}`,children:[e.jsx(N,{name:"file-text",size:13,color:"var(--text-subtle)"}),e.jsx("span",{className:"hn-prj-mono",children:a.key}),e.jsx("span",{className:"hn-docs-result-kind",children:a.kind})]},a.key))}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{label:"Berkas dokumen",nodes:xe,selected:s,onSelect:H}),Y.length>0&&e.jsxs("div",{className:"hn-docs-unscored",children:[e.jsx("div",{className:"hn-eyebrow hn-docs-unscored-label",children:"Lainnya (tidak dinilai)"}),e.jsx(ce,{label:"Dokumen tidak dinilai",nodes:Y,selected:s,onSelect:H})]})]});return e.jsxs(e.Fragment,{children:[e.jsx(Se,{ariaLabel:"Panel Dokumen",active:y,onActiveChange:a=>d(a),masterWidth:288,className:"hn-workspace-panels",panels:[{id:"tree",label:"Indeks",className:"hn-panel-flex",content:e.jsxs("aside",{"aria-label":"Indeks dokumen",className:"hn-docs-index",children:[e.jsxs("div",{className:"hn-docs-index-head",children:[e.jsxs("span",{className:"hn-eyebrow",children:["dokumen · ",t]}),e.jsxs("div",{className:"hn-docs-index-actions",children:[e.jsx(Ce,{status:ye,size:"sm"}),e.jsx(O,{size:"sm",variant:"ghost",leftIcon:g?"loader":"radar",onClick:ne,disabled:g,children:g?"Memuat…":"Muat ulang"})]})]}),z==="ready"&&l.length>0&&e.jsxs("div",{className:"hn-docs-index-tools",children:[e.jsx(Ke,{size:"sm","aria-label":"Cari berkas dokumen",leftIcon:"search",value:P,placeholder:"mis. product/prd",onChange:a=>J(a.target.value),className:"hn-prj-full"}),e.jsxs("div",{role:"group","aria-label":"Kategori dokumen",className:"hn-prj-chips",children:[e.jsx("button",{type:"button",className:"hn-prj-chip hn-touch-target","aria-pressed":D==="all",onClick:()=>$("all"),children:"Semua"}),ze.map(a=>e.jsxs("button",{type:"button",className:"hn-prj-chip hn-touch-target","aria-pressed":D===a,onClick:()=>$(a),children:[a,e.jsx("span",{className:"hn-prj-chip-count",children:ve[a]})]},a))]}),e.jsxs("span",{className:"hn-docs-cov",title:"Persentase kategori yang terindeks",children:["Cakupan ",Math.round(k),"%"]})]}),e.jsx("div",{className:"hn-docs-tree-scroll",children:we})]})},{id:"viewer",label:"Dokumen",className:"hn-panel-flex",content:e.jsxs("section",{"aria-label":"Isi dokumen",className:"hn-docs-viewer",style:{display:"flex",flexDirection:"column",minHeight:0},children:[e.jsxs("div",{className:"hn-docs-viewer-head",children:[e.jsx(N,{name:"file-text",size:15,color:"var(--text-muted)"}),e.jsx("span",{className:"hn-prj-mono hn-docs-path",children:_}),T&&T.scored&&(T.linked?e.jsx(U,{tone:"ok",size:"sm",icon:"link",children:"terindeks"}):e.jsx(U,{tone:"err",size:"sm",icon:"unlink",children:"tak tertaut"})),e.jsx("span",{className:"hn-grow"}),e.jsxs("div",{role:"group","aria-label":"Mode dokumen",className:"hn-prj-seg",children:[e.jsx("button",{type:"button","aria-pressed":h==="preview",className:"hn-touch-target",onClick:()=>{h==="edit"&&ee()},children:"Baca"}),e.jsx("button",{type:"button","aria-pressed":h==="edit",className:"hn-touch-target",onClick:()=>{h!=="edit"&&ge()},disabled:!s||F||A,children:"Edit"})]}),h==="preview"&&e.jsx(Le,{label:"Aksi untuk dokumen",icon:"ellipsis",items:[{key:"delete",label:"Hapus dokumen…",icon:"trash-2",tone:"danger",disabled:!s,onSelect:()=>{je()}}],children:e.jsx(Me,{href:a=>S.docDownloadUrl(n,s,a),disabled:!s||F||A})})]}),h==="edit"&&e.jsxs("div",{role:"region","aria-label":"Simpan perubahan",className:"hn-docs-savebar",children:[E?e.jsx(U,{tone:"warn",size:"sm",children:"belum disimpan"}):e.jsx("span",{className:"hn-prj-hint",children:"Tak ada perubahan"}),e.jsx("span",{className:"hn-grow"}),e.jsx(O,{size:"sm",variant:"ghost",onClick:ee,disabled:L,children:"Batal"}),e.jsx(O,{size:"sm",leftIcon:"check",onClick:()=>void ae(),loading:L,disabled:L||!E,children:"Simpan"})]}),G&&e.jsx("div",{role:"alert",className:"hn-docs-error",children:G}),h==="preview"?e.jsx("div",{"data-testid":"doc-preview-scroll",className:"hn-docs-body",style:{flex:"1 1 auto",minHeight:0,overflow:"auto"},children:s?F?e.jsx(w,{kind:"loading",title:"Memuat dokumen…",hint:s}):A?e.jsx(w,{kind:"error",title:"Gagal memuat dokumen",hint:s,action:fe}):e.jsx("div",{className:"hn-docs-read",children:e.jsx(te,{text:B,name:s})}):e.jsx(w,{kind:"empty",icon:"file-text",title:"Tidak ada dokumen dipilih",hint:"Pilih file dari indeks di kiri."})}):e.jsxs("div",{className:"hn-docs-edit",children:[e.jsxs("div",{className:"hn-docs-edit-pane",children:[e.jsx("div",{className:"hn-docs-edit-label",children:e.jsx("span",{className:"hn-eyebrow",children:"Markdown"})}),e.jsx("textarea",{"aria-label":`Isi ${_}`,value:f,spellCheck:!1,onChange:a=>j(a.target.value),onKeyDown:a=>{(a.metaKey||a.ctrlKey)&&a.key.toLowerCase()==="s"&&(a.preventDefault(),ae())},placeholder:`# Judul dokumen
2
2
 
3
3
  Paragraf pembuka…`,className:"hn-docs-textarea"})]}),e.jsxs("div",{className:"hn-docs-edit-pane",children:[e.jsx("div",{className:"hn-docs-edit-label",children:e.jsx("span",{className:"hn-eyebrow",children:"Pratinjau langsung"})}),e.jsx("div",{className:"hn-docs-preview",children:e.jsx(te,{text:f,name:s})})]})]})]})}]}),me]})}export{Ie as DocsWorkspace,re as buildTree,oe as docKind,le as firstDoc};