@popcorn245/cornfield-components 0.50.1 → 0.51.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.
@@ -0,0 +1,4417 @@
1
+ import { n as e, r as t, t as n } from "./runtime-DFu6W5g-.js";
2
+ import { $ as r, $t as i, A as a, B as o, C as s, D as c, E as l, Gt as u, Ht as d, It as f, Jt as p, Kt as m, Mt as h, Nt as g, O as _, S as v, T as y, Ut as b, Vt as x, Wt as S, Xt as C, Yt as w, Zt as T, _ as E, c as D, cn as O, ct as k, d as A, dt as j, en as M, f as N, ft as P, in as F, it as I, jt as L, k as R, l as z, ln as B, m as ee, nn as V, ot as te, p as H, pt as ne, qt as U, rn as W, st as re, t as ie, tn as ae, u as oe, ut as se, v as ce, w as G, x as le, y as ue, z as de } from "./engine-ClfnAsgM.js";
3
+ import { i as fe, n as pe, r as me, t as he } from "./map-B6AeKeiu.js";
4
+ import { _ as ge, a as _e, c as ve, f as ye, g as be, h as xe, i as Se, l as Ce, m as we, n as Te, p as Ee, r as De, s as Oe, u as ke } from "./source-address-B7hYRgt8.js";
5
+ // ../explorer/review-model.js
6
+ var Ae = 6e4, je = 60 * Ae, Me = 24 * je, Ne = (e, t) => `${e} ${t}${e === 1 ? "" : "s"}`;
7
+ function Pe(e, t) {
8
+ let n = typeof e == "string" ? Date.parse(e) : NaN;
9
+ if (!Number.isFinite(n) || !Number.isFinite(t)) return "";
10
+ let r = t - n;
11
+ return r < Ae ? "just now" : r < je ? `${Ne(Math.floor(r / Ae), "minute")} ago` : r < Me ? `${Ne(Math.floor(r / je), "hour")} ago` : `${Ne(Math.floor(r / Me), "day")} ago`;
12
+ }
13
+ var Fe = {
14
+ approved: "Approved",
15
+ notes: "Sent back"
16
+ };
17
+ function Ie(e, t) {
18
+ let { verdict: n, when: r } = Le(e, t);
19
+ return r ? `${n} ${r}` : n;
20
+ }
21
+ function Le(e, t) {
22
+ return !e || !Fe[e.verdict] ? {
23
+ verdict: "",
24
+ when: ""
25
+ } : {
26
+ verdict: Fe[e.verdict],
27
+ when: Pe(e.at, t) || ""
28
+ };
29
+ }
30
+ function Re(e) {
31
+ return typeof e == "string" && e.trim() ? null : "Say what should change before you send it back.";
32
+ }
33
+ function ze(e, t, n) {
34
+ return {
35
+ verdict: e,
36
+ note: typeof t == "string" ? t.trim() : "",
37
+ edits: structuredClone(Array.isArray(n) ? n : [])
38
+ };
39
+ }
40
+ var Be = (e) => typeof e == "string" && /^pull\/[1-9]\d{0,8}$/.test(e);
41
+ function Ve(e, t) {
42
+ if (!t) return "";
43
+ let n = Ne(t, "edit");
44
+ return e === "approved" ? `Your ${n} ${t === 1 ? "is" : "are"} in the review comment on the PR. The drafting agent will fold ${t === 1 ? "it" : "them"} into the proposal.` : `Sent with your ${n}. The drafting agent will fold ${t === 1 ? "it" : "them"} into the next draft.`;
45
+ }
46
+ var He = 0;
47
+ function Ue(e, t = 5) {
48
+ if (e.length <= t + 1) return e.join("");
49
+ let n = `hx-more-${++He}`, r = e.length - t;
50
+ return `${e.slice(0, t).join("")}<div class="hx-more" id="${n}" hidden>${e.slice(t).join("")}</div><button data-corn="more" data-corn-kind="quiet" type="button" class="hx-btn hx-btn--quiet hx-textact hx-more-btn" data-more="${n}" data-rest="${r}" aria-expanded="false" aria-controls="${n}">and ${r} more</button>`;
51
+ }
52
+ function We(e) {
53
+ let t = e.closest && e.closest("[data-more]");
54
+ if (!t) return !1;
55
+ let n = t.previousElementSibling, r = n && n.id === t.dataset.more ? n : null, i = t.getAttribute("aria-expanded") !== "true";
56
+ return r && (r.hidden = !i), t.setAttribute("aria-expanded", String(i)), t.textContent = i ? "Show fewer" : `and ${t.dataset.rest} more`, !0;
57
+ }
58
+ // ../explorer/engine/flow-ui.js
59
+ function Ge(e, t) {
60
+ let { state: n } = e, r = (e) => (n.nodes.find((t) => t.id === e) || { label: e }).label, i = n.edges.filter((e) => e.kind === "flow" && (e.from === t.id || e.to === t.id)), a = (e, t, n) => t.length ? `<div class="hx-fact" data-corn="section"><div class="hx-fact-k">${e}</div><div class="hx-fact-v">${Ue(t.map((e) => `<div class="hx-line"><span><span class="hx-name">${D(r(n ? e.to : e.from))}</span> · ${D(e.label)}${e.status === "live" ? "" : " <span class=\"hx-warn\">(proposed)</span>"}</span></div>`))}</div></div>` : "";
61
+ return a("Sends to", i.filter((e) => e.from === t.id), !0) + a("Gets from", i.filter((e) => e.to === t.id && e.from !== t.id), !1);
62
+ }
63
+ // ../explorer/corn-state.js
64
+ var Ke = Object.freeze([
65
+ "open",
66
+ "merged",
67
+ "closed",
68
+ "draft",
69
+ "queued",
70
+ "running",
71
+ "requested",
72
+ "claimed",
73
+ "working",
74
+ "waiting",
75
+ "done",
76
+ "failed",
77
+ "stopped",
78
+ "success",
79
+ "failure",
80
+ "added",
81
+ "changed",
82
+ "removed",
83
+ "edit",
84
+ "sent-back"
85
+ ]), qe = Object.freeze([
86
+ "added",
87
+ "changed",
88
+ "removed",
89
+ "edit"
90
+ ]);
91
+ Object.freeze([
92
+ "requested",
93
+ "claimed",
94
+ "working",
95
+ "waiting",
96
+ "done",
97
+ "failed",
98
+ "stopped"
99
+ ]);
100
+ var Je = Object.freeze({
101
+ quiet: "waiting",
102
+ "stop-requested": "stopped",
103
+ neutral: "done",
104
+ skipped: "done",
105
+ cancelled: "stopped",
106
+ approved: "success",
107
+ unreviewed: "waiting",
108
+ changed: "waiting",
109
+ missing: "failure",
110
+ allowed: "success",
111
+ refused: "failure",
112
+ mismatch: "failure",
113
+ pending: "running",
114
+ ok: "success",
115
+ bad: "failure",
116
+ stale: "waiting",
117
+ off: "stopped",
118
+ error: "failure",
119
+ idle: "running"
120
+ });
121
+ function Ye(e) {
122
+ let t = String(e || "");
123
+ return Je[t] || (Ke.includes(t) && !qe.includes(t) ? t : "");
124
+ }
125
+ function Xe(e) {
126
+ let t = String(e || "");
127
+ return qe.includes(t) ? t : "";
128
+ }
129
+ function Ze(e) {
130
+ let t = Xe(e);
131
+ return t ? ` data-corn-state="${t}"` : "";
132
+ }
133
+ function Qe(e) {
134
+ let t = Ye(e);
135
+ return t ? ` data-corn-state="${t}"` : "";
136
+ }
137
+ Object.freeze({
138
+ requested: "<circle cx=\"6\" cy=\"6\" r=\"4.2\" stroke-dasharray=\"2 1.8\"/>",
139
+ queued: "<circle cx=\"6\" cy=\"6\" r=\"4.2\" stroke-dasharray=\"2 1.8\"/>",
140
+ claimed: "<circle cx=\"6\" cy=\"6\" r=\"4.2\"/><circle cx=\"6\" cy=\"6\" r=\"1.4\" fill=\"currentColor\" stroke=\"none\"/>",
141
+ working: "<path class=\"hx-state-spin\" d=\"M6 1.8a4.2 4.2 0 1 1-4.2 4.2\"/>",
142
+ running: "<path class=\"hx-state-spin\" d=\"M6 1.8a4.2 4.2 0 1 1-4.2 4.2\"/>",
143
+ waiting: "<path d=\"M6 1.2L11 10.4H1Z\" stroke-linejoin=\"round\"/><path d=\"M6 4.6v2.7M6 8.6v.1\"/>",
144
+ done: "<path d=\"M2 6.4l2.6 2.6L10 3.4\"/>",
145
+ success: "<path d=\"M2 6.4l2.6 2.6L10 3.4\"/>",
146
+ failed: "<path d=\"M2.6 2.6l6.8 6.8M9.4 2.6L2.6 9.4\"/>",
147
+ failure: "<path d=\"M2.6 2.6l6.8 6.8M9.4 2.6L2.6 9.4\"/>",
148
+ stopped: "<rect x=\"2.4\" y=\"2.4\" width=\"7.2\" height=\"7.2\" rx=\"1\" fill=\"currentColor\"/>",
149
+ neutral: "<path d=\"M2.4 6h7.2\"/>",
150
+ skipped: "<path d=\"M2.4 6h7.2\"/>",
151
+ cancelled: "<circle cx=\"6\" cy=\"6\" r=\"4.2\"/><path d=\"M3 9L9 3\"/>",
152
+ "sent-back": "<path d=\"M4.6 2.2L2 4.8l2.6 2.6\"/><path d=\"M2.2 4.8H7a2.8 2.8 0 0 1 0 5.6H4.6\"/>"
153
+ }), Object.freeze([
154
+ ["code", "Code: a branch and a pull request"],
155
+ ["summary", "Summary of the conversation"],
156
+ ["brief", "A brief for another run"],
157
+ ["proposal", "A proposal drafted from the thread"]
158
+ ]), Object.freeze({
159
+ merged: "done",
160
+ closed: "stopped",
161
+ quiet: "waiting",
162
+ "stop-requested": "stopped"
163
+ });
164
+ function $e(e) {
165
+ let t = Math.max(0, Math.round(e / 1e3));
166
+ return t < 60 ? `${t} s` : t < 3600 ? `${Math.floor(t / 60)} min` : `${Math.floor(t / 3600)} h`;
167
+ }
168
+ Object.freeze([
169
+ "minutes",
170
+ "turns",
171
+ "cost",
172
+ "tokens"
173
+ ]), Object.freeze([
174
+ {
175
+ key: "decide",
176
+ title: "toDecide"
177
+ },
178
+ {
179
+ key: "agent",
180
+ title: "withAgent"
181
+ },
182
+ {
183
+ key: "approved",
184
+ title: "approvedGroup"
185
+ },
186
+ {
187
+ key: "drafts",
188
+ title: "drafts"
189
+ }
190
+ ]), Object.freeze([
191
+ {
192
+ key: "needs",
193
+ title: "needsYou"
194
+ },
195
+ {
196
+ key: "motion",
197
+ title: "inMotion"
198
+ },
199
+ {
200
+ key: "finished",
201
+ title: "finished"
202
+ }
203
+ ]), Object.freeze([
204
+ "to-decide",
205
+ "changed",
206
+ "sent-back",
207
+ "approved",
208
+ "draft-pr",
209
+ "local",
210
+ "unknown"
211
+ ]), Object.freeze({
212
+ "to-decide": "To decide",
213
+ changed: "Changed since approved",
214
+ "sent-back": "Sent back",
215
+ approved: "Approved",
216
+ "draft-pr": "Draft PR",
217
+ local: "Local",
218
+ unknown: "Review state unknown"
219
+ }), Object.freeze({
220
+ "to-decide": "waiting",
221
+ changed: "waiting",
222
+ "sent-back": "sent-back",
223
+ approved: "success",
224
+ "draft-pr": "draft",
225
+ local: "draft",
226
+ unknown: "failure"
227
+ });
228
+ function et(e) {
229
+ let t = e && e.report && typeof e.report.note == "string" ? e.report.note.replace(/\s+/g, " ").trim() : "", n = t.length > 90 ? `${t.slice(0, 89).trimEnd()}\u2026` : t;
230
+ return `A run is waiting on you${n ? `: ${n}` : ""}`;
231
+ }
232
+ // ../explorer/proposal-model.js
233
+ var tt = [
234
+ "before",
235
+ "diff",
236
+ "after"
237
+ ], nt = [
238
+ "added",
239
+ "changed",
240
+ "removed"
241
+ ];
242
+ function rt(e) {
243
+ let t = it({
244
+ ...e,
245
+ scenarios: 0
246
+ }).filter((e) => e.mark).map((e) => e.text.replace(/^\+/, ""));
247
+ return t.length ? t.join(" · ") : "No changes";
248
+ }
249
+ function it(e) {
250
+ let t = (t) => e?.[t] || 0, n = (e, t) => `${e} ${t}${e === 1 ? "" : "s"}`, r = (r) => {
251
+ let i = e?.nodes?.[r] || 0, a = e?.edges?.[r] || 0;
252
+ return !e?.nodes || i + a !== t(r) ? `${r === "added" ? "+" : ""}${t(r)} ${r}` : `${[i && n(i, "node"), a && n(a, "edge")].filter(Boolean).join(", ")} ${r}`;
253
+ }, i = nt.filter((e) => t(e) > 0).map((e) => ({
254
+ mark: e,
255
+ text: r(e)
256
+ }));
257
+ return t("scenarios") > 0 && i.push({
258
+ mark: null,
259
+ text: `${t("scenarios")} ${t("scenarios") === 1 ? "scenario" : "scenarios"}`
260
+ }), i.length ? i : [{
261
+ mark: null,
262
+ text: "No changes"
263
+ }];
264
+ }
265
+ var at = (e) => `${e === "before" ? "Before" : e === "after" ? "After" : "Diff"} view`, ot = (e, t) => `${t}, ${String(e).toLowerCase()}. The map is on it.`, st = /^[A-Za-z0-9][A-Za-z0-9._-]*$/, ct = 200, lt = (e) => typeof e == "string" && e.length <= ct && st.test(e);
266
+ function ut(e) {
267
+ let t = String(e ?? ""), n = t.length > 60 ? `${t.slice(0, 59)}\u2026` : t;
268
+ return n.trim() ? `\u201c${n}\u201d is not a proposal's name.` : "That is not a proposal's name.";
269
+ }
270
+ function dt(e) {
271
+ return e == null ? "" : typeof e == "string" ? e : JSON.stringify(e);
272
+ }
273
+ var ft = [
274
+ "mark",
275
+ "editOp",
276
+ "before",
277
+ "why",
278
+ "x",
279
+ "y",
280
+ "r",
281
+ "baseR",
282
+ "degree",
283
+ "scaleDelta",
284
+ "color",
285
+ "from",
286
+ "to"
287
+ ];
288
+ function pt(e) {
289
+ return F(e) === "added" ? Object.keys(e).filter((t) => !ft.includes(t) && e[t] !== void 0).map((t) => ({
290
+ field: t,
291
+ before: "",
292
+ after: dt(e[t])
293
+ })) : e.mark === "changed" && e.before ? Object.keys(e.before).map((t) => ({
294
+ field: t,
295
+ before: dt(e.before[t]),
296
+ after: dt(e[t])
297
+ })) : [];
298
+ }
299
+ var mt = {
300
+ added: "Added",
301
+ changed: "Changed",
302
+ removed: "Removed",
303
+ edit: "Your edit"
304
+ };
305
+ function ht(e) {
306
+ if (!W(e)) return "";
307
+ let t = pt(e).map((t) => e.mark === "changed" ? `<div class="hx-change" data-corn="field-change"><span class="hx-change-field">${D(t.field)}</span><span class="hx-change-before">${D(t.before) || "<em>nothing</em>"}</span><span class="hx-change-arrow" aria-hidden="true">→</span><span class="hx-change-after">${D(t.after) || "<em>nothing</em>"}</span></div>` : `<div class="hx-change" data-corn="field-change"><span class="hx-change-field">${D(t.field)}</span><span class="hx-change-after">${D(t.after)}</span></div>`).join("");
308
+ return `<div class="hx-sec hx-proposal-sec hx-proposal-sec--${D(e.mark)}" data-proposal-mark="${D(e.mark)}" data-corn="section">
309
+ <strong class="hx-strong"><span class="hx-mark-dot hx-mark-dot--${D(e.mark)}" data-corn="mark-dot"${Ze(e.mark)}></span>${D(e.mark === "edit" ? `${e.editOp === "removed" ? "Removed" : "Added"} by your edit` : `${mt[e.mark] || e.mark} by this proposal`)}</strong>
310
+ ${e.why ? `<div class="hx-why">${D(e.why)}</div>` : ""}
311
+ ${t}
312
+ </div>`;
313
+ }
314
+ var gt = (e, t) => `${e} ${t}${e === 1 ? "" : "s"}`;
315
+ function _t(e) {
316
+ if (!Array.isArray(e) || e.length === 0) return "no checks";
317
+ let t = (t) => e.filter((e) => t.includes(e.state)).length, n = t(["failure"]), r = t(["cancelled"]), i = t(["running", "queued"]), a = [];
318
+ return n && a.push(`${gt(n, "check")} failed`), r && a.push(`${gt(r, "check")} cancelled`), i && a.push(`${gt(i, "check")} running`), a.length ? a.join(", ") : e.length === 1 ? "1 check passed" : `all ${e.length} checks passed`;
319
+ }
320
+ function K(e) {
321
+ let t = typeof e == "string" ? /^pull\/([1-9]\d{0,8})$/.exec(e) : null;
322
+ return t ? Number(t[1]) : null;
323
+ }
324
+ function vt(e) {
325
+ let t = K(e);
326
+ return t ? `PR #${t}` : !e || e === "checkout" ? "the checkout" : `worktree ${e}`;
327
+ }
328
+ function yt(e, t = null, n = null) {
329
+ let r = K(e);
330
+ if (!r) {
331
+ let t = !e || e === "checkout" ? "in the checkout" : `in worktree ${e}`;
332
+ return {
333
+ text: `Local draft \u00b7 ${t}`,
334
+ href: null,
335
+ state: "draft",
336
+ label: `This is a local draft, ${t}, not a pull request`
337
+ };
338
+ }
339
+ let i = [`PR #${r}`], a = t ? t.state === "merged" || t.state === "closed" ? t.state : typeof t.draft == "boolean" ? t.draft ? "draft" : "open" : "" : "";
340
+ return a && i.push(a), Array.isArray(n) && i.push(_t(n)), {
341
+ text: i.join(" · "),
342
+ href: t && typeof t.url == "string" ? t.url : null,
343
+ state: a,
344
+ label: `Reviewing spec pull request: ${i.join(", ")}`
345
+ };
346
+ }
347
+ function bt(e, t, n = null) {
348
+ return t ? K(t) || t === "checkout" || n && n.has(t) && st.test(t) ? `There is no proposal called ${e} in ${vt(t)}.` : `There is no proposal called ${e}. This link's source is not a PR, the checkout or a worktree.` : `There is no proposal called ${e}.`;
349
+ }
350
+ function xt(e) {
351
+ let t = new URLSearchParams(e || "");
352
+ if (!t.has("proposal")) return null;
353
+ let n = t.get("proposal") || "";
354
+ return st.test(n) ? null : n.trim() ? `This link does not name a proposal: ${ut(n)}` : "This link does not name a proposal.";
355
+ }
356
+ function St(e, t, n) {
357
+ return Array.isArray(e) ? e.filter((e) => e && e.slug === t && e.source !== n && !e.error).sort((e, t) => +!!K(t.source) - !!K(e.source)).map((e) => ({
358
+ slug: e.slug,
359
+ source: e.source,
360
+ label: K(e.source) ? `Open the copy in PR #${K(e.source)}${e.pull && e.pull.draft ? " (draft)" : ""}` : `Open the copy ${e.source === "checkout" ? "in the checkout" : `in worktree ${e.source}`}`
361
+ })) : [];
362
+ }
363
+ function Ct(e, t = !1) {
364
+ let n = Array.isArray(e) ? e : [];
365
+ if (!n.length) return "";
366
+ let r = (e) => n.filter((t) => t && e.includes(t.op)).length, i = (e, t) => `${e} ${t}${e === 1 ? "" : "s"}`, a = [];
367
+ r(["add-node"]) && a.push(`+${i(r(["add-node"]), "node")}`), r(["add-edge"]) && a.push(`+${i(r(["add-edge"]), "edge")}`), r(["remove-node"]) && a.push(`\u2212${i(r(["remove-node"]), "node")}`), r(["remove-edge"]) && a.push(`\u2212${i(r(["remove-edge"]), "edge")}`);
368
+ let o = r([
369
+ "add-step",
370
+ "reword-step",
371
+ "delete-step",
372
+ "move-step"
373
+ ]);
374
+ o && a.push(`${i(o, "step")} changed`);
375
+ let s = n.length - r([
376
+ "add-node",
377
+ "add-edge",
378
+ "remove-node",
379
+ "remove-edge",
380
+ "add-step",
381
+ "reword-step",
382
+ "delete-step",
383
+ "move-step"
384
+ ]);
385
+ return s > 0 && a.push(i(s, "other edit")), `yours: ${a.join(", ")}${t ? " (hidden)" : ""}`;
386
+ }
387
+ // ../core/proposal.js
388
+ var wt = [
389
+ "version",
390
+ "spec",
391
+ "title",
392
+ "summary",
393
+ "nodes",
394
+ "edges",
395
+ "mockups",
396
+ "scenarios"
397
+ ], Tt = [
398
+ "node",
399
+ "path",
400
+ "title"
401
+ ], Et = [
402
+ "png",
403
+ "jpg",
404
+ "jpeg",
405
+ "webp",
406
+ "svg",
407
+ "html"
408
+ ], Dt = [
409
+ "id",
410
+ "title",
411
+ "steps",
412
+ "stepMs",
413
+ "linkNodes",
414
+ "actor",
415
+ "down"
416
+ ], Ot = [
417
+ "node",
418
+ "edge",
419
+ "text",
420
+ "ms",
421
+ "actor",
422
+ "at",
423
+ "check",
424
+ "expect"
425
+ ], kt = [
426
+ "GET",
427
+ "POST",
428
+ "PUT",
429
+ "PATCH",
430
+ "DELETE"
431
+ ], At = [
432
+ "read",
433
+ "write",
434
+ "delete"
435
+ ], jt = [
436
+ "own",
437
+ "household",
438
+ "others",
439
+ "shared-read",
440
+ "shared-write"
441
+ ], Mt = ["allowed", "refused"], Nt = /^[a-z0-9]+(?:-[a-z0-9]+)*$/, Pt = `live-room-<id>, live-floor-<id> or live-device-<kind>-<id> (kind one of ${m.join(", ")})`, Ft = [
442
+ "add",
443
+ "change",
444
+ "remove"
445
+ ], It = ["mark", "before"], Lt = [
446
+ "mark",
447
+ "before",
448
+ "why"
449
+ ], Rt = [
450
+ "from",
451
+ "to",
452
+ "kind",
453
+ "flow"
454
+ ], q = (e) => typeof e == "object" && !!e && !Array.isArray(e), J = (e) => typeof e == "string" && e.trim() !== "", zt = (e) => e === void 0 ? e : JSON.parse(JSON.stringify(e)), Y = (e) => Array.isArray(e) ? e : [], Bt = (e) => typeof e == "number" && Number.isFinite(e) && e > 0;
455
+ function Vt(e, t) {
456
+ if (e === t) return !0;
457
+ if (!e || !t || typeof e != "object" || typeof t != "object" || Array.isArray(e) !== Array.isArray(t)) return !1;
458
+ let n = Object.keys(e);
459
+ return n.length === Object.keys(t).length && n.every((n) => Vt(e[n], t[n]));
460
+ }
461
+ function Ht(e) {
462
+ if (typeof e != "string" || e.trim() === "") return "\"path\" must be the file's path, relative to the proposals folder.";
463
+ if (e.length > 200) return "\"path\" is at most 200 characters.";
464
+ if (/[\\\u0000-\u001f:%?#]/.test(e)) return "\"path\" has a character a plain relative path does not (a backslash, a colon, a control character, %, ? or #).";
465
+ if (e.startsWith("/")) return "\"path\" is relative to the proposals folder; it does not start with a slash.";
466
+ let t = e.split("/");
467
+ if (t.some((e) => e === "" || e === "." || e === "..")) return "\"path\" stays inside the proposals folder: no \"..\", no \".\" and no empty parts.";
468
+ if (t.some((e) => e.startsWith("."))) return "\"path\" has a hidden part (one that starts with a dot).";
469
+ let n = t[t.length - 1].split(".").length > 1 ? t[t.length - 1].split(".").pop().toLowerCase() : "";
470
+ return Et.includes(n) ? null : `A mockup is one of: ${Et.join(", ")}.`;
471
+ }
472
+ function Ut(e) {
473
+ if (!q(e) || !Array.isArray(e.mockups)) return [];
474
+ let t = [];
475
+ return e.mockups.slice(0, 40).forEach((e, n) => {
476
+ q(e) && J(e.node) && J(e.title) && Ht(e.path) === null && t.push({
477
+ index: n,
478
+ node: e.node,
479
+ path: e.path,
480
+ title: e.title.trim()
481
+ });
482
+ }), t;
483
+ }
484
+ function X(e) {
485
+ return `${e.from}|${e.to}|${e.kind === "flow" ? `flow:${e.flow}` : e.kind || "own"}`;
486
+ }
487
+ var Wt = (e) => ({
488
+ from: e.parent,
489
+ to: e.id
490
+ });
491
+ function Gt(e, t) {
492
+ let n = [], r = (e, t, r) => n.push(r ? {
493
+ path: e,
494
+ message: t,
495
+ state: r
496
+ } : {
497
+ path: e,
498
+ message: t
499
+ });
500
+ if (!q(t)) return r("", "A proposal is a JSON object."), n;
501
+ for (let e of Object.keys(t)) wt.includes(e) || r(e, `Unknown key "${e}". A proposal has: ${wt.join(", ")}.`);
502
+ t.version !== 1 && r("version", `"version" must be the number 1 (got ${JSON.stringify(t.version)}).`), J(t.title) || r("title", "\"title\" must be a non-empty string."), J(t.summary) || r("summary", "\"summary\" must be a non-empty string: the one sentence the maintainer reads first."), t.spec !== void 0 && !J(t.spec) && r("spec", "\"spec\" must be the spec number as a string, like \"0013\".");
503
+ let a = (e) => {
504
+ let n = t[e];
505
+ if (n === void 0) return {
506
+ add: [],
507
+ change: [],
508
+ remove: []
509
+ };
510
+ if (!q(n)) return r(e, `"${e}" must be an object with add, change and remove lists.`), {
511
+ add: [],
512
+ change: [],
513
+ remove: []
514
+ };
515
+ let i = {};
516
+ for (let t of Object.keys(n)) Ft.includes(t) || r(`${e}.${t}`, `Unknown key "${t}" in "${e}". Use add, change or remove.`);
517
+ for (let t of Ft) n[t] === void 0 ? i[t] = [] : Array.isArray(n[t]) ? i[t] = n[t] : (r(`${e}.${t}`, `"${e}.${t}" must be a list.`), i[t] = []);
518
+ return i;
519
+ }, o = a("nodes"), s = a("edges"), c = new Map(Y(e?.nodes).map((e) => [e.id, e])), l = new Set(Y(e?.edges).map(X)), u = /* @__PURE__ */ new Map();
520
+ o.add.forEach((e, t) => {
521
+ q(e) && J(e.id) && !u.has(e.id) && u.set(e.id, t);
522
+ });
523
+ let d = new Set(o.remove.filter((e) => q(e) && J(e.id)).map((e) => e.id)), f = (e) => c.has(e) || u.has(e), h = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map();
524
+ o.add.forEach((e, t) => {
525
+ let n = `nodes.add[${t}]`;
526
+ if (!q(e)) return r(n, "An added node is an object with an id, a label and a type.");
527
+ J(e.id) ? c.has(e.id) ? r(`${n}.id`, `Node "${e.id}" already exists in the map. Use nodes.change to change it.`, "exists") : h.has(e.id) && r(`${n}.id`, `Node "${e.id}" is added twice.`) : r(`${n}.id`, "An added node needs an \"id\"."), J(e.id) && h.add(e.id), J(e.label) || r(`${n}.label`, "An added node needs a \"label\"."), J(e.type) ? T[e.type] ? e.type === "page" && J(e.label) && (e.label.startsWith("/") || r(`${n}.label`, `A page label "${e.label}" must start with a slash route (like "/meals"), as topology validate demands.`), e.label.includes(".html") && r(`${n}.label`, `A page label "${e.label}" must not contain ".html".`)) : r(`${n}.type`, `Unknown node type "${e.type}". Valid types: ${Object.keys(T).join(", ")}.`) : r(`${n}.type`, "An added node needs a \"type\".");
528
+ for (let t of It) t in e && r(`${n}.${t}`, `"${t}" is set when the proposal is applied; leave it out.`);
529
+ if (e.type === "device" && !m.includes(e.kind) && r(`${n}.kind`, `A device needs "kind", one of: ${m.join(", ")}.`), e.type === "external" && e.kind !== void 0 && !p.includes(e.kind) && r(`${n}.kind`, `An external's "kind" is one of: ${p.join(", ")} (or none, until the registry draws it).`), J(e.id) && T[e.type] && M(e)) {
530
+ let t = ae(e.id), i = e.type === "device" ? `live-device-${m.includes(e.kind) ? e.kind : "<kind>"}-<id>` : `live-${e.type}-<id>`;
531
+ !t || t.type !== e.type ? r(`${n}.id`, [
532
+ "floor",
533
+ "room",
534
+ "device"
535
+ ].includes(e.type) ? `"${e.id}" is a ${e.type} only the live layer draws${e.type === "device" ? " (no code file derives it)" : ""}: its id must be ${i}.` : `"${e.id}" starts with "${C}", which only the live layer's floors, rooms and devices use (${Pt}).`) : t.kind && m.includes(e.kind) && t.kind !== e.kind && r(`${n}.kind`, `"${e.id}" names the kind "${t.kind}" but the node says "${e.kind}".`);
536
+ }
537
+ e.parent !== void 0 && (J(e.parent) ? e.parent === e.id ? r(`${n}.parent`, "A node cannot be its own parent.") : f(e.parent) ? d.has(e.parent) ? r(`${n}.parent`, `Parent "${e.parent}" is a node this proposal removes.`) : J(e.id) && g.set(X(Wt(e)), `nodes.add[${t}].parent`) : r(`${n}.parent`, `Parent "${e.parent}" is in neither the map nor the added nodes.`, "dangling") : r(`${n}.parent`, "\"parent\" must be the id of a node."));
538
+ });
539
+ let _ = /* @__PURE__ */ new Set();
540
+ o.change.forEach((e, t) => {
541
+ let n = `nodes.change[${t}]`;
542
+ if (!q(e)) return r(n, "A changed node is an object with an id, a set and a why.");
543
+ if (J(e.id) ? u.has(e.id) ? r(`${n}.id`, `Node "${e.id}" is added by this proposal: change its entry in nodes.add instead.`) : c.has(e.id) ? _.has(e.id) && r(`${n}.id`, `Node "${e.id}" is changed twice: merge the two sets.`) : r(`${n}.id`, `Node "${e.id}" does not exist in the map, so it cannot be changed.`, "missing-target") : r(`${n}.id`, "A changed node needs an \"id\"."), J(e.id) && _.add(e.id), !q(e.set) || Object.keys(e.set).length === 0) r(`${n}.set`, "\"set\" must be an object of the fields to change.");
544
+ else {
545
+ "id" in e.set && r(`${n}.set.id`, "A change cannot set \"id\": it names the node."), "parent" in e.set && r(`${n}.set.parent`, "\"parent\" is not a node field: remove the ownership edge and add a new one.");
546
+ for (let t of Lt) t in e.set && r(`${n}.set.${t}`, `"${t}" is set when the proposal is applied; leave it out of "set".`);
547
+ "type" in e.set && !T[e.set.type] && r(`${n}.set.type`, `Unknown node type "${e.set.type}". Valid types: ${Object.keys(T).join(", ")}.`);
548
+ }
549
+ J(e.why) || r(`${n}.why`, "A change needs a \"why\": the reason the maintainer reads.");
550
+ });
551
+ let v = /* @__PURE__ */ new Set();
552
+ o.remove.forEach((e, t) => {
553
+ let n = `nodes.remove[${t}]`;
554
+ if (!q(e)) return r(n, "A removed node is an object with an id and a why.");
555
+ J(e.id) ? u.has(e.id) ? r(`${n}.id`, `Node "${e.id}" is added by this proposal: drop its entry from nodes.add instead of removing it.`) : c.has(e.id) ? v.has(e.id) ? r(`${n}.id`, `Node "${e.id}" is removed twice.`) : _.has(e.id) && r(`${n}.id`, `Node "${e.id}" is both changed and removed.`) : r(`${n}.id`, `Node "${e.id}" does not exist in the map, so it cannot be removed.`, "missing-target") : r(`${n}.id`, "A removed node needs an \"id\"."), J(e.id) && v.add(e.id), J(e.why) || r(`${n}.why`, "A removal needs a \"why\".");
556
+ });
557
+ let y = new Map(o.change.filter((e) => q(e) && J(e.id) && q(e.set)).map((e) => [e.id, e.set])), b = new Map(o.add.filter((e) => q(e) && J(e.id)).map((e) => [e.id, e])), x = (e) => b.get(e) || (c.has(e) ? {
558
+ ...c.get(e),
559
+ ...y.get(e) || {}
560
+ } : void 0), S = (e, t) => {
561
+ J(e.from) || r(`${t}.from`, "An edge needs a \"from\" node id."), J(e.to) || r(`${t}.to`, "An edge needs a \"to\" node id.");
562
+ let n = J(e.from) && J(e.to);
563
+ return e.kind !== void 0 && !U.includes(e.kind) && (r(`${t}.kind`, `Unknown edge kind "${e.kind}". Valid kinds: ${U.join(", ")} (or none, for ownership).`), n = !1), e.kind === "flow" ? w.includes(e.flow) || (r(`${t}.flow`, `A flow edge needs "flow", one of: ${w.join(", ")}.`), n = !1) : e.flow !== void 0 && r(`${t}.flow`, "\"flow\" only goes on an edge of kind \"flow\"."), n ? X(e) : null;
564
+ }, E = (e) => `${e.from} -> ${e.to}${e.kind ? ` (${e.kind === "flow" ? `flow ${e.flow}` : e.kind})` : " (ownership)"}`, D = new Map([...g]);
565
+ s.add.forEach((e, t) => {
566
+ let n = `edges.add[${t}]`;
567
+ if (!q(e)) return r(n, "An added edge is an object with from, to and optionally a kind.");
568
+ let a = S(e, n);
569
+ for (let t of It) t in e && r(`${n}.${t}`, `"${t}" is set when the proposal is applied; leave it out.`);
570
+ for (let t of ["from", "to"]) J(e[t]) && (f(e[t]) ? d.has(e[t]) && r(`${n}.${t}`, `Node "${e[t]}" is a node this proposal removes, so an edge cannot be added to it.`) : r(`${n}.${t}`, `Node "${e[t]}" is in neither the map nor the added nodes.`, "dangling"));
571
+ let o = x(e.from), s = x(e.to);
572
+ if (o && s) {
573
+ for (let t of ["when", "side"]) if (e[t] !== void 0) for (let a of i({
574
+ kind: e.kind,
575
+ [t]: e[t]
576
+ }, o, s)) r(`${n}.${t}`, `The edge ${a}`);
577
+ }
578
+ a && (l.has(a) ? r(n, `Edge ${E(e)} already exists in the map.`, "exists") : D.has(a) && r(n, `Edge ${E(e)} is already added by ${D.get(a)}.`), D.set(a, D.get(a) || n));
579
+ });
580
+ let O = /* @__PURE__ */ new Map(), k = (e, t, n) => {
581
+ let i = S(e, t);
582
+ return i ? (l.has(i) ? O.has(i) ? r(t, `Edge ${E(e)} is already ${O.get(i)} by this proposal.`) : O.set(i, n === "change" ? "changed" : "removed") : r(t, `Edge ${E(e)} does not exist in the map, so it cannot be ${n === "change" ? "changed" : "removed"}.`, "missing-target"), i) : null;
583
+ };
584
+ s.change.forEach((e, t) => {
585
+ let n = `edges.change[${t}]`;
586
+ if (!q(e)) return r(n, "A changed edge is an object with from, to, set and why.");
587
+ if (k(e, n, "change"), !q(e.set) || Object.keys(e.set).length === 0) r(`${n}.set`, "\"set\" must be an object of the fields to change.");
588
+ else {
589
+ for (let t of Rt) t in e.set && r(`${n}.set.${t}`, `A change cannot set "${t}": it names the edge. Remove the edge and add a new one.`);
590
+ for (let t of Lt) t in e.set && r(`${n}.set.${t}`, `"${t}" is set when the proposal is applied; leave it out of "set".`);
591
+ }
592
+ J(e.why) || r(`${n}.why`, "A change needs a \"why\".");
593
+ }), s.remove.forEach((e, t) => {
594
+ let n = `edges.remove[${t}]`;
595
+ if (!q(e)) return r(n, "A removed edge is an object with from, to and why.");
596
+ k(e, n, "remove"), J(e.why) || r(`${n}.why`, "A removal needs a \"why\".");
597
+ });
598
+ function A(e, t) {
599
+ if (!J(e) || !Nt.test(e)) return r(t, `"actor" must be a persona id: lower-case words joined by dashes, like "child" (got ${JSON.stringify(e)}).`);
600
+ let n = V(e);
601
+ f(n) || r(t, `Actor "${e}" is no persona: "${n}" is in neither the map nor the added nodes.`, "dangling");
602
+ }
603
+ function j(e, t) {
604
+ if (!J(e)) return r(t, `"at" must be a node id or a live id (${Pt}).`);
605
+ f(e) || ae(e) || (e.startsWith("live-") ? r(t, `"${e}" is not a live id: write ${Pt}.`) : r(t, `Step happens nowhere: "${e}" is in neither the map nor the added nodes, and is not a live id.`, "dangling"));
606
+ }
607
+ let N = "A check is { route, method } or { table, op, row? }";
608
+ function P(e, t) {
609
+ if (!q(e)) return r(t, `${N}.`);
610
+ let n = "route" in e || "method" in e, i = "table" in e || "op" in e || "row" in e;
611
+ if (n && i) return r(t, `${N}: either one, not both.`);
612
+ if (!n && !i) return r(t, `${N}.`);
613
+ let a = n ? ["route", "method"] : [
614
+ "table",
615
+ "op",
616
+ "row"
617
+ ];
618
+ for (let i of Object.keys(e)) a.includes(i) || r(`${t}.${i}`, `Unknown key "${i}" in a ${n ? "route" : "table"} check. It has: ${a.join(", ")}.`);
619
+ n ? (J(e.route) && e.route.startsWith("/") || r(`${t}.route`, "\"route\" must be a path starting with a slash, as the map labels it (\"/api/v1/rooms/[id]\") or a concrete one."), kt.includes(e.method) || r(`${t}.method`, `"method" must be one of: ${kt.join(", ")}.`)) : (J(e.table) || r(`${t}.table`, "\"table\" must be the SQL table name."), At.includes(e.op) || r(`${t}.op`, `"op" must be one of: ${At.join(", ")}.`), e.row !== void 0 && !jt.includes(e.row) && r(`${t}.row`, `"row" must be one of: ${jt.join(", ")}.`));
620
+ }
621
+ function F(e, t) {
622
+ Array.isArray(e) ? e.forEach((e, n) => P(e, `${t}[${n}]`)) : P(e, t);
623
+ }
624
+ function I(e, t) {
625
+ if (!Array.isArray(e)) return r(t, "\"down\" must be a list of the cloud node ids the scenario takes down.");
626
+ if (e.length === 0) return r(t, "\"down\" needs at least one cloud node id; leave it out for a scenario that is no outage.");
627
+ let n = /* @__PURE__ */ new Set();
628
+ e.forEach((e, i) => {
629
+ let a = `${t}[${i}]`;
630
+ if (!J(e)) return r(a, "\"down\" holds node ids: strings like \"ext-cloudflare\".");
631
+ if (n.has(e)) return r(a, `"${e}" is down twice.`);
632
+ n.add(e);
633
+ let o = x(e);
634
+ if (!o) return r(a, `Down node "${e}" is in neither the map nor the added nodes.`, d.has(e) ? "missing-target" : "dangling");
635
+ if (o.type !== "external" || o.kind !== "cloud") {
636
+ let t = o.type === "external" ? o.kind === void 0 ? "an external with no kind" : `an external of kind ${o.kind}` : `a ${o.type}`;
637
+ r(a, `"${e}" is ${t}: only an external of kind cloud can be down (a container, a stack or a machine is the House view's; the public web is never down as a whole).`);
638
+ }
639
+ });
640
+ }
641
+ let L = new Set(s.remove.filter((e) => q(e) && J(e.from) && J(e.to)).map(X)), R = (e, t) => L.has(e) || d.has(t.from) || d.has(t.to);
642
+ t.scenarios !== void 0 && !Array.isArray(t.scenarios) && r("scenarios", "\"scenarios\" must be a list.");
643
+ let z = /* @__PURE__ */ new Set();
644
+ if (Y(t.scenarios).forEach((e, t) => {
645
+ let n = `scenarios[${t}]`;
646
+ if (!q(e)) return r(n, "A scenario is an object with an id, a title and steps.");
647
+ J(e.id) ? z.has(e.id) && r(`${n}.id`, `Scenario id "${e.id}" is used twice.`) : r(`${n}.id`, "A scenario needs an \"id\"."), J(e.id) && z.add(e.id), J(e.title) || r(`${n}.title`, "A scenario needs a \"title\".");
648
+ for (let t of Object.keys(e)) Dt.includes(t) || r(`${n}.${t}`, `Unknown key "${t}" in a scenario. A scenario has: ${Dt.join(", ")}.`);
649
+ if (e.stepMs !== void 0 && !Bt(e.stepMs) && r(`${n}.stepMs`, "\"stepMs\" must be a positive number of milliseconds."), e.linkNodes !== void 0 && typeof e.linkNodes != "boolean" && r(`${n}.linkNodes`, "\"linkNodes\" must be true or false."), e.actor !== void 0 && A(e.actor, `${n}.actor`), e.down !== void 0 && I(e.down, `${n}.down`), !Array.isArray(e.steps)) return r(`${n}.steps`, "\"steps\" must be a list.");
650
+ if (e.steps.length === 0) return r(`${n}.steps`, "A scenario needs at least one step.");
651
+ e.steps.forEach((t, i) => {
652
+ let a = `${n}.steps[${i}]`;
653
+ if (!q(t)) return r(a, "A step is an object with a \"node\" or an \"edge\", and some \"text\".");
654
+ for (let e of Object.keys(t)) Ot.includes(e) || r(`${a}.${e}`, `Unknown key "${e}" in a step. A step has "node" or "edge", and "text"; optionally ${Ot.slice(3).join(", ")}.`);
655
+ if (J(t.text) || r(`${a}.text`, "A step needs \"text\": what happens at this point."), t.ms !== void 0 && !Bt(t.ms) && r(`${a}.ms`, "\"ms\" must be a positive number of milliseconds."), t.actor !== void 0 && A(t.actor, `${a}.actor`), t.at !== void 0 && j(t.at, `${a}.at`), t.check !== void 0 && F(t.check, `${a}.check`), t.expect !== void 0 && (Mt.includes(t.expect) ? t.actor === void 0 && e.actor === void 0 && r(`${a}.expect`, "\"expect\" needs an actor, on the step or its scenario: a step with no actor is never checked.") : r(`${a}.expect`, `"expect" must be one of: ${Mt.join(", ")}.`)), t.node === void 0 == (t.edge === void 0) && r(a, "A step points at exactly one of \"node\" or \"edge\"."), t.node !== void 0 && (J(t.node) ? f(t.node) || r(`${a}.node`, `Step points at nothing: node "${t.node}" is in neither the map nor the added nodes.`, d.has(t.node) ? "missing-target" : "dangling") : r(`${a}.node`, "\"node\" must be a node id.")), t.edge !== void 0) {
656
+ if (!q(t.edge)) return r(`${a}.edge`, "\"edge\" must be an object with from and to.");
657
+ let e = S(t.edge, `${a}.edge`);
658
+ e && !l.has(e) && !D.has(e) && r(`${a}.edge`, `Step points at nothing: edge ${E(t.edge)} is in neither the map nor the added edges.`, R(e, t.edge) ? "missing-target" : "dangling");
659
+ }
660
+ });
661
+ }), t.mockups !== void 0 && !Array.isArray(t.mockups)) r("mockups", "\"mockups\" must be a list.");
662
+ else if (Array.isArray(t.mockups)) {
663
+ t.mockups.length > 40 && r("mockups", "At most 40 mockups in one proposal.");
664
+ let e = /* @__PURE__ */ new Set([
665
+ ...u.keys(),
666
+ ...d,
667
+ ...o.change.filter((e) => q(e) && J(e.id)).map((e) => e.id)
668
+ ]), n = /* @__PURE__ */ new Set();
669
+ t.mockups.forEach((t, i) => {
670
+ let a = `mockups[${i}]`;
671
+ if (!q(t)) return r(a, "A mockup is an object with a node, a path and a title.");
672
+ for (let e of Object.keys(t)) Tt.includes(e) || r(`${a}.${e}`, `Unknown key "${e}" in a mockup. A mockup has: ${Tt.join(", ")}.`);
673
+ J(t.title) || r(`${a}.title`, "A mockup needs a \"title\": what the screen is. It is also its alt text.");
674
+ let o = Ht(t.path);
675
+ o ? r(`${a}.path`, o) : n.has(`${t.node}|${t.path}`) ? r(a, `Mockup "${t.path}" is listed twice for node "${t.node}".`) : n.add(`${t.node}|${t.path}`), J(t.node) ? e.has(t.node) || r(`${a}.node`, `Mockup is beside node "${t.node}", which this proposal does not add, change or remove. Name a node the proposal touches.`) : r(`${a}.node`, "A mockup needs the \"node\" it belongs to.");
676
+ });
677
+ }
678
+ return n;
679
+ }
680
+ var Kt = T.external;
681
+ function qt(e, t) {
682
+ let n = e.nodes.map((e) => ({
683
+ ...e,
684
+ mark: "none"
685
+ })), r = e.edges.map((e) => ({
686
+ ...e,
687
+ mark: "none"
688
+ })), i = new Map(n.map((e) => [e.id, e])), a = /* @__PURE__ */ new Map();
689
+ for (let e of r) {
690
+ let t = X(e);
691
+ a.has(t) || a.set(t, []), a.get(t).push(e);
692
+ }
693
+ let o = (e) => ({
694
+ add: Y(t[e]?.add),
695
+ change: Y(t[e]?.change),
696
+ remove: Y(t[e]?.remove)
697
+ }), s = o("nodes"), c = o("edges"), l = (e, t, n) => {
698
+ let r = {}, i = (t, n) => {
699
+ Vt(e[t], n) || (r[t] = e[t] === void 0 ? null : e[t], e[t] = zt(n));
700
+ };
701
+ for (let [e, n] of Object.entries(t || {})) i(e, n);
702
+ e.mark = "changed", e.before = r, e.why = n;
703
+ };
704
+ for (let e of s.change) {
705
+ let t = i.get(e.id);
706
+ if (!t) continue;
707
+ let n = { ...e.set }, r = T[n.type];
708
+ r && ("color" in n || (n.color = r.color), "r" in n || (n.r = r.r)), l(t, n, e.why);
709
+ }
710
+ for (let e of c.change) for (let t of a.get(X(e)) || []) l(t, e.set, e.why);
711
+ for (let e of c.remove) for (let t of a.get(X(e)) || []) delete t.before, t.mark = "removed", t.why = e.why;
712
+ for (let e of s.remove) {
713
+ let t = i.get(e.id);
714
+ if (t) {
715
+ t.mark = "removed", t.why = e.why;
716
+ for (let t of r) (t.from === e.id || t.to === e.id) && t.mark !== "removed" && (delete t.before, t.mark = "removed", t.why = e.why);
717
+ }
718
+ }
719
+ let u = [], d = (e) => {
720
+ let t = a.get(X(e));
721
+ t ? t.forEach((e) => {
722
+ e.mark === "none" && (e.mark = "added");
723
+ }) : r.push({
724
+ ...zt(e),
725
+ mark: "added"
726
+ });
727
+ };
728
+ for (let e of s.add) {
729
+ let { parent: t, ...r } = zt(e), a = T[e.type] || Kt, o = i.get(e.id);
730
+ o ? o.mark === "none" && (o.mark = "added") : n.push({
731
+ ...r,
732
+ color: a.color,
733
+ r: e.r ?? a.r,
734
+ mark: "added"
735
+ }), t && u.push({
736
+ from: t,
737
+ to: e.id
738
+ });
739
+ }
740
+ for (let e of u) d(e);
741
+ for (let e of c.add) d(e);
742
+ return {
743
+ nodes: n,
744
+ edges: r
745
+ };
746
+ }
747
+ function Jt(e, t) {
748
+ let n = new Map(e.nodes.map((e) => [e.id, e])), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
749
+ for (let t of e.edges) {
750
+ let e = X(t);
751
+ r.has(e) || r.set(e, t);
752
+ let n = `${t.from}|${t.to}`;
753
+ i.has(n) || i.set(n, /* @__PURE__ */ new Set()), i.get(n).add(e), !t.kind && !t.dashed && (a.has(t.to) || a.set(t.to, /* @__PURE__ */ new Set()), a.get(t.to).add(t.from));
754
+ }
755
+ let o = (e, t) => Object.entries(t || {}).every(([t, n]) => Vt(e[t], n)), s = (e, n) => Y(t?.[e]?.[n]), c = new Set(s("nodes", "add").filter((e) => q(e) && M(e)).map((e) => e.id)), l = (e) => c.has(e) || typeof e == "string" && e.startsWith("live-"), u = [], d = (e, t, n, r) => u.push({
756
+ kind: e,
757
+ op: t,
758
+ key: n,
759
+ status: r
760
+ });
761
+ for (let e of s("nodes", "add")) {
762
+ if (c.has(e.id)) {
763
+ d("node", "add", e.id, "live");
764
+ continue;
765
+ }
766
+ let t = n.get(e.id);
767
+ d("node", "add", e.id, t ? t.type !== e.type || e.parent && !a.get(e.id)?.has(e.parent) ? "diverged" : "landed" : "pending");
768
+ }
769
+ for (let e of s("nodes", "change")) {
770
+ let t = n.get(e.id);
771
+ d("node", "change", e.id, t ? o(t, e.set) ? "landed" : "pending" : "diverged");
772
+ }
773
+ for (let e of s("nodes", "remove")) d("node", "remove", e.id, n.has(e.id) ? "pending" : "landed");
774
+ for (let e of s("edges", "add")) {
775
+ let t = X(e);
776
+ if (l(e.from) || l(e.to)) {
777
+ d("edge", "add", t, "live");
778
+ continue;
779
+ }
780
+ let n = [...i.get(`${e.from}|${e.to}`) || []].some((e) => e !== t);
781
+ d("edge", "add", t, r.has(t) ? "landed" : n ? "diverged" : "pending");
782
+ }
783
+ for (let e of s("edges", "change")) {
784
+ let t = X(e), n = r.get(t);
785
+ d("edge", "change", t, n ? o(n, e.set) ? "landed" : "pending" : "diverged");
786
+ }
787
+ for (let e of s("edges", "remove")) {
788
+ let t = X(e);
789
+ d("edge", "remove", t, r.has(t) ? "pending" : "landed");
790
+ }
791
+ let f = {
792
+ total: u.length,
793
+ pending: 0,
794
+ landed: 0,
795
+ diverged: 0,
796
+ live: 0
797
+ };
798
+ for (let e of u) f[e.status]++;
799
+ return {
800
+ items: u,
801
+ summary: f
802
+ };
803
+ }
804
+ function Yt(e, t) {
805
+ let n = Gt(e, t), r = !1;
806
+ if (n.some((e) => e.state === "exists" || e.state === "missing-target")) try {
807
+ r = Jt(e, t).items.some((e) => e.op === "add" && e.status === "landed");
808
+ } catch {}
809
+ return {
810
+ errors: r ? n.filter((e) => e.state !== "exists" && e.state !== "missing-target") : n,
811
+ building: r
812
+ };
813
+ }
814
+ function Xt(e) {
815
+ let t = (e) => ({
816
+ added: Y(e?.add).length,
817
+ changed: Y(e?.change).length,
818
+ removed: Y(e?.remove).length
819
+ }), n = t(e?.nodes), r = t(e?.edges);
820
+ return {
821
+ added: n.added + r.added,
822
+ changed: n.changed + r.changed,
823
+ removed: n.removed + r.removed,
824
+ scenarios: Y(e?.scenarios).length,
825
+ nodes: n,
826
+ edges: r
827
+ };
828
+ }
829
+ // ../explorer/mockups-model.js
830
+ var Zt = {
831
+ approved: "Reviewed",
832
+ changed: "Changed since you approved",
833
+ unreviewed: "Not reviewed yet",
834
+ missing: "File not found"
835
+ }, Qt = (e) => Zt[e] || Zt.unreviewed, $t = (e) => /\.html$/i.test(String(e)) ? "page" : "image";
836
+ function en(e, t, n) {
837
+ return `/proposals/${encodeURIComponent(e)}/mockups/${n}${t ? `?source=${encodeURIComponent(t)}` : ""}`;
838
+ }
839
+ function tn(e, t, n, r, i = {}) {
840
+ return !e || !t ? [] : Ut(e).filter((e) => e.node === r).map((e) => ({
841
+ ...e,
842
+ type: $t(e.path),
843
+ url: en(t, n, e.index),
844
+ state: i[e.index] || "unreviewed"
845
+ }));
846
+ }
847
+ function nn(e) {
848
+ if (!e.length) return "";
849
+ let t = e.map((e) => `<li class="hx-mockup-item" data-corn="row">
850
+ <button data-corn-kind="secondary" type="button" class="hx-btn hx-mockup-open" data-mockup="${e.index}" aria-haspopup="dialog">${D(e.title)}<span class="hx-sr-only"> (${e.type === "page" ? "page" : "image"}, opens in a window)</span></button>
851
+ <span class="hx-mockup-state hx-mockup-state--${D(e.state)}" data-corn="state-pill"${Qe(e.state)}>${D(Qt(e.state))}</span>
852
+ </li>`).join("");
853
+ return `<div class="hx-sec hx-mockups" data-mockups data-corn="section">
854
+ <h3 class="hx-sec-title" id="hx-mockups-h">${e.length === 1 ? "Mockup" : "Mockups"}</h3>
855
+ <ul class="hx-mockup-list" aria-labelledby="hx-mockups-h">${t}</ul>
856
+ </div>`;
857
+ }
858
+ function rn(e, t) {
859
+ return nn(tn(e.proposal, e.proposalSlug, e.proposalSource, t, e.mockupStates || {}));
860
+ }
861
+ // ../explorer/engine/sheets.js
862
+ var an = 20;
863
+ function on(e, t) {
864
+ G(e).box = t || null;
865
+ }
866
+ function sn(e, t) {
867
+ let { box: n } = G(e), r = e.win && e.win.ResizeObserver;
868
+ if (n && typeof r == "function") {
869
+ let i = v(e), a = new r(() => {
870
+ let n = v(e);
871
+ n !== i && (i = n, t());
872
+ });
873
+ a.observe(n);
874
+ let o = () => {
875
+ a.disconnect(), e.release(o);
876
+ };
877
+ return e.own(o), o;
878
+ }
879
+ if (e.win && typeof e.win.matchMedia == "function") {
880
+ let n = e.win.matchMedia(le);
881
+ if (n && n.addEventListener) return e.listen(n, "change", () => t());
882
+ }
883
+ return () => {};
884
+ }
885
+ function cn(e, t) {
886
+ let n = G(e);
887
+ return n.listeners.add(t), () => n.listeners.delete(t);
888
+ }
889
+ function ln(e) {
890
+ let t = G(e), { model: n } = t;
891
+ dn(e);
892
+ for (let [r, i] of t.elements) {
893
+ let t = n.isExpanded(r), a = n.stateOf(r);
894
+ i.dataset.sheetState = a === "hidden" ? "peek" : a;
895
+ let o = [...i.children].find((e) => e.classList.contains("hx-sheet-handle"));
896
+ o && (o.setAttribute("aria-expanded", String(t)), o.setAttribute("aria-label", t ? "Collapse this panel" : "Expand this panel")), pn(e, r, i, a === "stub");
897
+ }
898
+ let r = y(e, t);
899
+ r && (r.dataset.sheetOpen = n.expanded() || ""), t.dock && v(e) && t.dock.style.setProperty("--hx-sheet-cap", `${c((t.box ? t.box.clientHeight : e.win.innerHeight) || 0, n.stubs())}px`), hn(e), s(e), t.listeners.forEach((e) => e());
900
+ }
901
+ function un(e, t) {
902
+ return e === "forge" ? t.classList.contains("forge-open") : e === "drawer" ? t.classList.contains("drawer-open") : !t.hidden && t.isConnected;
903
+ }
904
+ function dn(e) {
905
+ let t = G(e), { model: n } = t;
906
+ if (v(e)) {
907
+ for (let [r, i] of t.elements) {
908
+ let a = un(r, i) && !t.away.has(r);
909
+ if (!a && !un(r, i) && t.away.delete(r), a && !n.isShown(r)) for (let t of n.show(r)) fn(e, t);
910
+ else !a && n.isShown(r) && n.hide(r);
911
+ }
912
+ for (let [e, n] of t.elements) {
913
+ let r = t.away.has(e), i = n.hasAttribute("data-sheet-away");
914
+ n.toggleAttribute("data-sheet-away", r), r && !n.inert ? n.inert = !0 : !r && i && un(e, n) && (n.inert = !1);
915
+ }
916
+ } else {
917
+ t.away.clear();
918
+ for (let e of t.elements.values()) e.removeAttribute("data-sheet-away");
919
+ }
920
+ }
921
+ function fn(e, t) {
922
+ let n = G(e);
923
+ if (!n.elements.get(t)) return;
924
+ n.away.add(t);
925
+ let r = n.options.get(t);
926
+ r && r.away && r.away();
927
+ }
928
+ function pn(e, t, n, r) {
929
+ let i = G(e), a = [...n.children].find((e) => e.classList.contains("hx-sheet-stub"));
930
+ if (!a) {
931
+ if (!r) return;
932
+ a = e.doc.createElement("button"), a.type = "button", a.className = "hx-sheet-stub", a.dataset.corn = "sheet-stub", a.setAttribute("part", "sheet-stub"), a.addEventListener("click", (r) => {
933
+ r.stopPropagation(), r.preventDefault(), vn(e, t);
934
+ let i = [...n.children].find((e) => e.classList.contains("hx-sheet-handle"));
935
+ i && v(e) && i.focus();
936
+ }), n.append(a);
937
+ }
938
+ if (a.hidden = !r, !r) return;
939
+ let o = i.options.get(t), s = (o && o.stub ? o.stub() : null) || { title: n.getAttribute("aria-label") || t }, c = String(s.title || ""), l = s.badge ? String(s.badge) : "", u = `${c}\u0000${l}\u0000${s.label || ""}`;
940
+ if (a.dataset.key === u) return;
941
+ a.dataset.key = u, a.replaceChildren();
942
+ let d = e.doc.createElement("span");
943
+ if (d.className = "hx-sheet-stub-title", d.textContent = c, a.append(d), l) {
944
+ let t = e.doc.createElement("span");
945
+ t.className = "hx-waiting-badge", t.dataset.corn = "waiting-badge", t.setAttribute("part", "waiting-badge"), t.setAttribute("aria-hidden", "true"), t.textContent = l, a.append(t);
946
+ }
947
+ a.setAttribute("aria-label", s.label || (l ? `${c}, ${l}` : c));
948
+ }
949
+ function mn(e, t) {
950
+ let n = G(e);
951
+ n.elements.has(t) && (n.away.delete(t), ln(e));
952
+ }
953
+ function hn(e) {
954
+ let { dock: t } = G(e);
955
+ if (!t) return;
956
+ let n = null;
957
+ for (let e of t.children) {
958
+ e.removeAttribute("data-sheet-last");
959
+ let t = e.classList.contains("hx-drawer") && !e.classList.contains("drawer-open") || e.classList.contains("hx-forge") && !e.classList.contains("forge-open");
960
+ !e.hidden && !t && (n = e);
961
+ }
962
+ n && n.setAttribute("data-sheet-last", "");
963
+ }
964
+ function gn(e, t, n, r = {}) {
965
+ if (!n) return;
966
+ let i = G(e);
967
+ _n(e, t, !1), i.model.add(t), i.elements.set(t, n), i.options.set(t, r), n.classList.add("hx-sheet");
968
+ let a = [...n.children].find((e) => e.classList.contains("hx-sheet-handle"));
969
+ a || (a = e.doc.createElement("button"), a.type = "button", a.className = "hx-sheet-handle", a.dataset.corn = "sheet-handle", a.setAttribute("part", "sheet-handle"), a.innerHTML = "<span data-corn=\"sheet-grip\" part=\"sheet-grip\"></span>", n.prepend(a)), i.offs.set(t, [...Sn(e, t, a), e.listen(n, "click", (n) => Cn(e, t, n), !0)]), ln(e);
970
+ }
971
+ function _n(e, t, n = !0) {
972
+ let r = G(e);
973
+ r.model.has(t) && ((r.offs.get(t) || []).forEach((e) => e()), r.offs.delete(t), r.model.remove(t), r.elements.delete(t), r.options.delete(t), r.away.delete(t), n && ln(e));
974
+ }
975
+ function vn(e, t) {
976
+ dn(e), G(e).model.expand(t) && ln(e);
977
+ }
978
+ function yn(e, t) {
979
+ G(e).model.collapse(t) && ln(e);
980
+ }
981
+ function bn(e) {
982
+ G(e).model.collapseAll() && ln(e);
983
+ }
984
+ function xn(e, t) {
985
+ dn(e), G(e).model.toggle(t) && ln(e);
986
+ }
987
+ function Sn(e, t, n) {
988
+ let r = null, i = !1, a = [];
989
+ return a.push(e.listen(n, "pointerdown", (e) => {
990
+ if (r = e.clientY, i = !1, n.setPointerCapture && e.pointerId !== void 0) try {
991
+ n.setPointerCapture(e.pointerId);
992
+ } catch {}
993
+ })), a.push(e.listen(n, "pointerup", (n) => {
994
+ if (r === null) return;
995
+ let a = n.clientY - r;
996
+ r = null, Math.abs(a) < an || (i = !0, a < 0 ? vn(e, t) : yn(e, t));
997
+ })), a.push(e.listen(n, "pointercancel", () => {
998
+ r = null;
999
+ })), a.push(e.listen(n, "click", (n) => {
1000
+ n.stopPropagation(), i ? i = !1 : xn(e, t);
1001
+ })), a;
1002
+ }
1003
+ function Cn(e, t, n) {
1004
+ if (!v(e) || G(e).model.isExpanded(t)) return;
1005
+ let r = n.target;
1006
+ if (r.closest && r.closest(".hx-sheet-handle, .hx-sheet-stub") || r.closest && r.closest("select, input, textarea, [data-peek-ok]")) return;
1007
+ let i = r.closest && r.closest("[data-action]");
1008
+ i && /close/.test(i.dataset.action) || (n.preventDefault(), n.stopPropagation(), vn(e, t));
1009
+ }
1010
+ function wn(e, t) {
1011
+ t.target === e.state.canvas && v(e) && bn(e);
1012
+ }
1013
+ function Tn(e, t) {
1014
+ if (t.key !== "Escape" || t.defaultPrevented || !v(e)) return;
1015
+ let n = G(e), r = n.model.expanded(), i = r && n.elements.get(r);
1016
+ if (!i || !i.contains(t.target) || t.target.closest && t.target.closest("select, input, textarea")) return;
1017
+ t.preventDefault(), t.stopPropagation(), yn(e, r);
1018
+ let a = [...i.children].find((e) => e.classList.contains("hx-sheet-handle"));
1019
+ a && a.focus();
1020
+ }
1021
+ function En(e, t) {
1022
+ v(e) && (t.stopPropagation(), bn(e));
1023
+ }
1024
+ function Dn(e) {
1025
+ let t = G(e), n = e.el("sheet-dock");
1026
+ if (n) {
1027
+ if (n !== t.dock && (t.observers.forEach((e) => e.disconnect()), t.observers = [], t.model.ids().forEach((e) => t.model.remove(e)), t.elements.clear(), t.options.clear(), t.away.clear(), t.lastCovered = 0, t.dock = n), t.wiredDock !== t.dock) {
1028
+ t.wiredDock = t.dock;
1029
+ let n = e.win;
1030
+ if (n && typeof n.MutationObserver == "function") {
1031
+ let r = new n.MutationObserver(() => {
1032
+ hn(e), s(e);
1033
+ });
1034
+ r.observe(t.dock, {
1035
+ childList: !0,
1036
+ subtree: !0,
1037
+ attributes: !0,
1038
+ attributeFilter: ["hidden", "class"]
1039
+ }), t.observers.push(r), e.own(() => r.disconnect());
1040
+ }
1041
+ if (n && typeof n.ResizeObserver == "function") {
1042
+ let r = new n.ResizeObserver(() => s(e));
1043
+ r.observe(t.dock), t.observers.push(r), e.own(() => r.disconnect());
1044
+ }
1045
+ }
1046
+ if (!t.documentWired) {
1047
+ t.documentWired = !0;
1048
+ for (let t of [
1049
+ "pointerdown",
1050
+ "touchstart",
1051
+ "mousedown"
1052
+ ]) e.listen(e.root, t, (t) => wn(e, t), {
1053
+ passive: !0,
1054
+ capture: !0
1055
+ });
1056
+ e.listen(e.root, "keydown", (t) => Tn(e, t), !0), sn(e, () => {
1057
+ bn(e), s(e);
1058
+ });
1059
+ }
1060
+ ln(e);
1061
+ }
1062
+ }
1063
+ // ../explorer/camera-frame.js
1064
+ var On = .18;
1065
+ function kn(e, t, n, r = 0) {
1066
+ return e.every((e) => {
1067
+ let i = t.x + e.x * t.zoom, a = t.y + e.y * t.zoom;
1068
+ return i >= n.x + r && i <= n.x + n.width - r && a >= n.y + r && a <= n.y + n.height - r;
1069
+ });
1070
+ }
1071
+ function An(e, t, { padding: n = 40, minZoom: r = On } = {}) {
1072
+ if (e.length < 2) return e;
1073
+ let i = ne(n, t), a = (t.width - i * 2) / r, o = (t.height - i * 2) / r, s = e.map(j), c = (t, n) => e.filter((e, r) => s[r].left >= t && s[r].right <= t + a && s[r].top >= n && s[r].bottom <= n + o), l = s.map((e) => e.left), u = s.map((e) => e.top), d = [], f = e.length <= 120 ? l.flatMap((e) => u.map((t) => [e, t])) : s.map((e) => [e.left, e.top]);
1074
+ for (let [t, n] of f) {
1075
+ if (d.length === e.length) break;
1076
+ let r = c(t, n);
1077
+ r.length > d.length && (d = r);
1078
+ }
1079
+ return d.length ? d : [e[0]];
1080
+ }
1081
+ function jn(e, t, n, r = 0) {
1082
+ let i = e.x + t.x * e.zoom, a = e.y + t.y * e.zoom, o = Math.min(r, (n.right - n.left) / 2), s = Math.min(r, (n.bottom - n.top) / 2), c = i < n.left + o || i > n.right - o, l = a < n.top + s || a > n.bottom - s;
1083
+ return !c && !l ? null : {
1084
+ x: c ? (n.left + n.right) / 2 - t.x * e.zoom : e.x,
1085
+ y: l ? (n.top + n.bottom) / 2 - t.y * e.zoom : e.y,
1086
+ zoom: e.zoom
1087
+ };
1088
+ }
1089
+ // ../explorer/cloud-panel.js
1090
+ var Mn = {
1091
+ free: "Free",
1092
+ paid: "Paid",
1093
+ unknown: "Plan unknown",
1094
+ off: "Off"
1095
+ };
1096
+ function Nn(e) {
1097
+ return !e || !Mn[e.tier] ? "" : e.note ? `${Mn[e.tier]} · ${e.note}` : Mn[e.tier];
1098
+ }
1099
+ var Pn = {
1100
+ container: ["container", "containers"],
1101
+ machine: ["machine", "machines"],
1102
+ app: ["app", "apps"],
1103
+ service: ["service", "services"],
1104
+ page: ["endpoint", "endpoints"],
1105
+ external: ["cloud service", "cloud services"]
1106
+ }, Fn = (e, t) => {
1107
+ let n = Pn[e] || [e, `${e}s`];
1108
+ return t === 1 ? n[0] : n[1];
1109
+ };
1110
+ function In(e, t, n) {
1111
+ let r = new Map(t.map((e) => [e.id, e])), i = new Map(Object.keys(b).map((e) => [e, /* @__PURE__ */ new Map()]));
1112
+ for (let t of n) {
1113
+ if (t.kind !== "calls" || t.to !== e.id) continue;
1114
+ let n = i.get(u(t)), a = r.get(t.from) || {
1115
+ id: t.from,
1116
+ label: t.from,
1117
+ type: "node"
1118
+ }, o = n.get(t.from) || {
1119
+ id: t.from,
1120
+ label: String(a.label || t.from),
1121
+ type: a.type,
1122
+ vias: [],
1123
+ browser: !1
1124
+ };
1125
+ t.label && !o.vias.includes(t.label) && o.vias.push(t.label), t.side === "browser" && (o.browser = !0), n.set(t.from, o);
1126
+ }
1127
+ let a = [];
1128
+ for (let [e, t] of i) {
1129
+ if (t.size === 0) continue;
1130
+ let n = /* @__PURE__ */ new Map();
1131
+ for (let { vias: e, ...r } of t.values()) n.has(r.type) || n.set(r.type, []), n.get(r.type).push({
1132
+ ...r,
1133
+ via: e.join(", ")
1134
+ });
1135
+ let r = [...n].map(([e, t]) => ({
1136
+ type: e,
1137
+ noun: Fn(e, 1),
1138
+ items: t.sort((e, t) => e.label.localeCompare(t.label))
1139
+ })).sort((e, t) => t.items.length - e.items.length || e.type.localeCompare(t.type)), { title: i, color: o } = b[e];
1140
+ a.push({
1141
+ when: e,
1142
+ title: i,
1143
+ color: o,
1144
+ count: t.size,
1145
+ types: r
1146
+ });
1147
+ }
1148
+ return a;
1149
+ }
1150
+ var Ln = {
1151
+ run: "Breaks now",
1152
+ deploy: "Breaks on deploy",
1153
+ renew: "Breaks on renewal"
1154
+ }, Rn = (e, t) => t.length ? `<div class="hx-fact" data-corn="section"><div class="hx-fact-k">${D(e)}</div><div class="hx-fact-v">${Ue(t)}</div></div>` : "", zn = (e) => `<div class="hx-line">${e}</div>`, Bn = (e) => `<span class="hx-name">${D(e)}</span>`;
1155
+ function Vn(e, t) {
1156
+ let n = e.browser ? " <span class=\"hx-cloud-browser\">(browser)</span>" : "", r = [t ? Fn(e.type, 1) : "", e.via].filter(Boolean);
1157
+ return zn(`<span>${Bn(e.label)}${n}${r.length ? `<span class="hx-faint"> · ${D(r.join(" · "))}</span>` : ""}</span>`);
1158
+ }
1159
+ var Hn = (e) => `<button data-corn-kind="quiet" type="button" class="hx-btn hx-btn--quiet hx-cloud-play" data-action="play-outage" data-id="${D(e.id)}">Play: ${D(String(e.label || e.id))} is down</button>`;
1160
+ function Un(e, t, n) {
1161
+ let r = new Map(t.map((e) => [e.id, e])), i = (e) => String((r.get(e) || { label: e }).label || e), a = e.kind === "web", o = a ? [] : e.roles || [], s = In(e, t, n).map((e) => {
1162
+ let t = e.types.length > 1;
1163
+ return Rn(Ln[e.when], e.types.flatMap((e) => e.items.map((e) => Vn(e, t))));
1164
+ }).join("") || Rn("Used by", [zn("<span class=\"hx-faint\">Nothing on the map uses it.</span>")]), c = n.filter((t) => t.kind === "calls" && t.from === e.id && (r.get(t.to) || {}).type === "external").map((e) => zn(`<span>${Bn(i(e.to))}${e.label ? `<span class="hx-faint"> · ${D(e.label)}</span>` : ""}</span>`)), l = n.filter((t) => t.kind === "delivers" && t.from === e.id).map((e) => zn(Bn(i(e.to))));
1165
+ return (a ? "" : Rn("Plan", [zn(D(Nn(e.plan) || Mn.unknown))])) + Rn("Roles", o.length ? [zn(D(o.join(", ")))] : []) + Rn("If it's down", [zn(D(e.breaks || "Not described yet."))]) + s + Rn("Relies on", c) + Rn("Pushes to", l) + (a ? "" : Hn(e));
1166
+ }
1167
+ // ../explorer/file-url.js
1168
+ var Wn = {
1169
+ github: "blob",
1170
+ forgejo: "src/branch"
1171
+ };
1172
+ function Gn(e) {
1173
+ if (typeof e != "string" || !e || /[\\\u0000-\u001f\u007f]/.test(e) || e.startsWith("/") || /^[A-Za-z][A-Za-z0-9+.-]*:/.test(e)) return null;
1174
+ let t = e.split("/");
1175
+ return t.every((e) => e && e !== "." && e !== "..") ? t : null;
1176
+ }
1177
+ function Kn(e, t, n) {
1178
+ let r = e && Object.hasOwn(Wn, e.type) && Wn[e.type], i = Gn(t), a = Gn(n || "HEAD"), o = Gn(e && e.repo);
1179
+ if (!r || !i || !a || !o || o.length !== 2) return null;
1180
+ try {
1181
+ let t = new URL(e.url);
1182
+ if (t.protocol !== "https:" || t.username || t.password || String(e.url).includes("\\")) return null;
1183
+ let n = (e) => e.map(encodeURIComponent).join("/");
1184
+ return t.pathname = `${t.pathname.replace(/\/+$/, "")}/${n(o)}/${r}/${n(a)}/${n(i)}`, t.search = "", t.hash = "", t.href;
1185
+ } catch {
1186
+ return null;
1187
+ }
1188
+ }
1189
+ // ../explorer/engine/feedback.js
1190
+ var qn = 6e3, Jn = (e) => e.slot("feedback", () => /* @__PURE__ */ new Map());
1191
+ function Yn(e, t, n, r = !0) {
1192
+ Jn(e).set(t, {
1193
+ text: n,
1194
+ ok: r
1195
+ }), H(e, n);
1196
+ }
1197
+ function Xn(e, t) {
1198
+ Jn(e).delete(t);
1199
+ }
1200
+ function Zn(e, t, n) {
1201
+ if (!t) return;
1202
+ let r = Jn(e).get(n);
1203
+ t.hidden = !r, t.textContent = r ? r.text : "", r ? t.dataset.cornState = r.ok ? "success" : "failure" : delete t.dataset.cornState;
1204
+ }
1205
+ // ../explorer/selection-words.js
1206
+ var Qn = [
1207
+ "ownership",
1208
+ "usage",
1209
+ "flow",
1210
+ "reads",
1211
+ "writes",
1212
+ "calls",
1213
+ "triggers",
1214
+ "delivers",
1215
+ "runs-on",
1216
+ "uses",
1217
+ "extends"
1218
+ ], $n = (e) => Object.hasOwn(te, e) ? te[e].panel : String(e);
1219
+ function er(e) {
1220
+ let t = (e) => {
1221
+ let t = Qn.indexOf(e);
1222
+ return t < 0 ? Qn.length : t;
1223
+ };
1224
+ return [...e.kinds.entries()].sort((e, n) => t(e[0]) - t(n[0]) || (e[0] < n[0] ? -1 : +(e[0] > n[0]))).map(([e, t]) => ({
1225
+ kind: e,
1226
+ count: t,
1227
+ word: $n(e)
1228
+ }));
1229
+ }
1230
+ function tr(e, t) {
1231
+ let n = [], r = /* @__PURE__ */ new Set();
1232
+ for (let i of e.edges) {
1233
+ if (k(i) !== t) continue;
1234
+ let a = i.from === e.selectedId, o = a ? i.to : i.from;
1235
+ r.has(o) || (r.add(o), n.push({
1236
+ id: o,
1237
+ out: a
1238
+ }));
1239
+ }
1240
+ return n;
1241
+ }
1242
+ function nr(e, t) {
1243
+ return t > 0 ? `${e} connected · ${t} off screen` : `${e} connected · all on screen`;
1244
+ }
1245
+ // ../explorer/pieces/node-panel.js
1246
+ var Z = (e) => `<code class="hx-code">${D(e)}</code>`, Q = (e) => `<div class="hx-line">${e}</div>`, rr = {
1247
+ "Uses design tokens": "Tokens",
1248
+ "Loaded by the server per request": "Loaded by",
1249
+ "Domains served (Caddyfile → service)": "Domains",
1250
+ "Compose file": "File",
1251
+ "Baked pages": "Baked",
1252
+ "Reads tables": "Reads",
1253
+ "Writes tables": "Writes",
1254
+ "Self-hosted": "Role",
1255
+ "Pushes to (webhook)": "Pushes to",
1256
+ "Calls outside": "Calls",
1257
+ "Client modules": "Modules",
1258
+ "Data flows": "Flows"
1259
+ }, ir = /^(?:Defines )?\d+ (?:CSS )?(variable|service)\(s\)$/, ar = (e) => {
1260
+ let t = e.replace(/:$/, ""), n = ir.exec(t);
1261
+ return n ? n[1] === "service" ? "Services" : t.startsWith("Defines") ? "Defines" : "Variables" : rr[t] || t;
1262
+ }, $ = (e, t) => t.length ? `<div class="hx-fact" data-corn="section"><div class="hx-fact-k">${D(ar(e))}</div><div class="hx-fact-v">${Ue(t)}</div></div>` : "", or = (e) => `<div class="hx-chips">${Ue(e.map((e) => `<code class="hx-var">${D(e)}</code>`))}</div>`;
1263
+ function sr(e) {
1264
+ if (e.type === "external" && e.kind) return e.kind === "web" ? "Public web" : "Cloud";
1265
+ let t = e.type.charAt(0).toUpperCase() + e.type.slice(1);
1266
+ return typeof e.kind == "string" && e.kind ? `${t} · ${e.kind}` : t;
1267
+ }
1268
+ function cr(e) {
1269
+ if (e.url) try {
1270
+ return new URL(e.url).host;
1271
+ } catch {}
1272
+ return e.host || "";
1273
+ }
1274
+ function lr(e, t) {
1275
+ let n = e && e.mark;
1276
+ if (!n || n === "none") return "";
1277
+ if (n === "edit") return `${e.editOp === "removed" ? "Removed" : "Added"} by your edit`;
1278
+ let r = t && typeof t.title == "string" ? t.title : "";
1279
+ return r ? `${mt[n] || n} by ${r}` : `${mt[n] || n} by this proposal`;
1280
+ }
1281
+ var ur = () => ({
1282
+ drawer: "<aside id=\"spec-drawer\" class=\"hx-drawer glass\" aria-label=\"Node details\" inert data-corn=\"node-panel\"><div class=\"hx-drawer-body\"><div class=\"hx-drawer-head\"><div class=\"hx-drawer-id\"><p class=\"hx-kicker\"><span id=\"drawer-badge\" data-corn=\"badge\">Atom</span><span id=\"drawer-host\" data-corn=\"node-host\"></span><span id=\"drawer-diff\" class=\"hx-diffpill\" data-corn=\"diff-pill\" hidden></span></p><h2 id=\"drawer-title\" class=\"hx-drawer-title\" data-corn=\"node-title\">&lt;pop-button&gt;</h2></div><button type=\"button\" class=\"hx-close\" data-action=\"close-drawer\" aria-label=\"Close\" data-corn-kind=\"icon\">✕</button></div><p id=\"drawer-description\" class=\"hx-lead\" hidden></p><div class=\"hx-block\"><div id=\"drawer-meta-list\" class=\"hx-meta\"></div></div></div><div class=\"hx-drawer-foot\" data-corn=\"node-foot\"><a data-corn=\"open-link\" id=\"drawer-file-btn\" data-corn-kind=\"primary\" class=\"hx-open\" href=\"#\" target=\"_blank\" rel=\"noreferrer\" hidden>Open file ↗</a><a data-corn=\"open-link\" id=\"drawer-open-btn\" data-corn-kind=\"primary\" class=\"hx-open\" href=\"#\" target=\"_blank\" rel=\"noreferrer\" hidden>Open route ↗</a><button data-corn-kind=\"secondary\" type=\"button\" id=\"drawer-run-btn\" class=\"hx-btn hx-foot-btn\" data-action=\"start-run\" data-corn-string=\"startRun\" hidden>Start a run</button><button data-corn-kind=\"quiet\" type=\"button\" class=\"hx-btn hx-btn--quiet hx-foot-btn\" data-action=\"copy-spec\" data-corn-string=\"copySpec\">Copy Spec</button><p id=\"copy-spec-result\" class=\"hx-forge-result\" data-corn=\"result\" hidden></p></div></aside>",
1283
+ backdrop: "<div id=\"drawer-backdrop\" class=\"hx-backdrop\" data-action=\"close-drawer\" hidden data-corn=\"backdrop\"></div>"
1284
+ }), dr = (e) => e.slot("copy-spec", () => ({ timer: 0 }));
1285
+ async function fr(e, t) {
1286
+ let { state: n } = e;
1287
+ if (!n.selectedNode) return;
1288
+ let r = dr(e), i = JSON.stringify({ node: n.selectedNode }, null, 2);
1289
+ clearTimeout(r.timer), Xn(e, "copy-spec");
1290
+ try {
1291
+ await e.win.navigator.clipboard.writeText(i), Yn(e, "copy-spec", `Copied the spec of ${n.selectedNode.label || n.selectedNode.id} to the clipboard.`, !0);
1292
+ } catch {
1293
+ Yn(e, "copy-spec", "The browser did not allow copying, so nothing was copied. Allow clipboard access for this page, then press Copy Spec again.", !1);
1294
+ }
1295
+ Zn(e, t, "copy-spec"), r.timer = setTimeout(() => {
1296
+ Xn(e, "copy-spec"), Zn(e, t, "copy-spec");
1297
+ }, qn);
1298
+ }
1299
+ function pr(e) {
1300
+ let { state: t } = e, n = (e) => t.nodes.find((t) => t.id === e), r = (e) => (n(e) || { label: e }).label, i = (e) => `<span class="hx-name">${D(r(e))}</span>`, a = (e, n, r) => t.edges.filter((t) => t.kind === e && t[n] === r);
1301
+ function o(e) {
1302
+ let o = t.edges.filter((e) => e.kind === "reads"), s = t.edges.filter((e) => e.kind === "writes"), c = t.edges.filter((t) => t.kind === "uses" && t.from === e.id), l = $("Extends:", t.edges.filter((t) => t.kind === "extends" && t.from === e.id).map((e) => Q(i(e.to)))) + $("Uses design tokens:", c.map((e) => Q(`${i(e.to)} · ${e.vars.length}${or(e.vars)}`))) + (e.type !== "token" && e.vars ? $(`Defines ${e.vars.length} CSS variable(s):`, [or(e.vars)]) : "");
1303
+ if (e.type === "app") {
1304
+ let n = e.deployed ? Q(`${/^https?:\/\//.test(e.url) ? `<a data-corn="text-link" class="hx-link" href="${D(e.url)}" target="_blank" rel="noreferrer">${D(e.url)}</a>` : Z(e.url)} → ${(e.upstreams || []).map(Z).join(" ")}${e.stack ? ` <span class="hx-faint">[${D(e.stack)}]</span>` : ""}`) : Q("Not deployed by any stack in this repo"), r = t.edges.filter((t) => t.kind === "runs-on" && t.from === e.id).map((e) => Q(`${i(e.to)}${(e.mappings || []).map((e) => `<div class="hx-faint">${Z(e.host)} → ${Z(e.upstream)}${e.service ? ` = ${Z(e.service)}` : ""}</div>`).join("")}`));
1305
+ return $("Served:", [n]) + $("Runs on:", r) + $("Loaded by the server per request:", o.filter((t) => t.to === e.id).map((e) => Q(i(e.from)))) + l;
1306
+ }
1307
+ if (e.type === "token") {
1308
+ let n = t.edges.filter((t) => t.kind === "uses" && t.to === e.id);
1309
+ return $(`${e.vars.length} variable(s):`, [or(e.vars)]) + $("Used by:", n.map((e) => Q(`${i(e.from)} · ${D(e.vars.join(" "))}`)));
1310
+ }
1311
+ if ([
1312
+ "atom",
1313
+ "molecule",
1314
+ "core"
1315
+ ].includes(e.type)) {
1316
+ let n = t.edges.filter((t) => t.dashed && t.to === e.id).map((e) => Q(i(e.from)));
1317
+ return (e.table ? $("Record of:", [Q(`${D(e.model)} · table ${Z(e.table)}`)]) : "") + $("Rendered by:", n) + l;
1318
+ }
1319
+ if (e.type === "stack") return $("Domains served (Caddyfile → service):", t.edges.filter((t) => t.kind === "runs-on" && t.to === e.id).flatMap((e) => (e.mappings || []).map((e) => Q(`<span class="hx-name">${D(e.host)}</span> → ${Z(e.upstream)}${e.service ? ` = ${Z(e.service)}` : ""}`)))) + $(`${(e.services || []).length} service(s):`, (e.services || []).map((e) => Q(`<span class="hx-name">${D(e.name)}</span>${e.image ? ` <span class="hx-faint">${D(e.image)}</span>` : ""}${e.ports.length ? `<div>${e.ports.map(Z).join(" ")}</div>` : ""}${e.volumes.length ? `<div class="hx-faint">${e.volumes.map(D).join("<br>")}</div>` : ""}`))) + $("Compose file:", [Q(Z(e.file))]);
1320
+ if (e.type === "table") {
1321
+ let t = o.filter((t) => t.from === e.id), a = s.filter((t) => t.to === e.id), c = t.filter((e) => (n(e.to) || {}).render?.rom === "bake");
1322
+ return (e.model ? $("Model:", [Q(D(e.model))]) : "") + $("Read by:", t.map((e) => Q(`${i(e.to)} · ${e.keys.map(Z).join(" ")}`))) + $("Written by:", a.map((e) => Q(`${i(e.from)} · ${D(e.label)}`))) + (c.length ? $("Baked pages:", [Q(`a write here re-bakes <span class="hx-rom hx-bold">${c.length}</span> file(s): ${c.map((e) => D(r(e.to))).join(", ")}`)]) : "");
1323
+ }
1324
+ if (e.type === "service") {
1325
+ let t = (e, t) => `${i(e[t])}${e.label && e.label !== "imports" ? ` · ${D(e.label)}` : ""}`;
1326
+ return (e.summary && !String(e.desc || "").includes(e.summary) ? $("Summary:", [Q(`<span class="hx-faint">${D(e.summary)}</span>`)]) : "") + $("Started by:", [...(e.triggers || []).map((e) => Q(D(e))), ...a("triggers", "to", e.id).map((e) => Q(t(e, "from")))]) + $("Jobs:", (e.jobs || []).map((e) => Q(`${Z(e.name)} · cron ${Z(e.cron)}`))) + $("Runs:", a("triggers", "from", e.id).map((e) => Q(t(e, "to")))) + $("Calls:", a("calls", "from", e.id).map((e) => Q(t(e, "to")))) + $("Called by:", a("calls", "to", e.id).map((e) => Q(t(e, "from")))) + $("Reads tables:", o.filter((t) => t.to === e.id).map((e) => Q(i(e.from)))) + $("Writes tables:", s.filter((t) => t.from === e.id).map((e) => Q(i(e.to)))) + $("Mechanisms:", (e.mechanisms || []).map((e) => Q(D(e))));
1327
+ }
1328
+ if (e.type === "container" && e.selfHosted) {
1329
+ let a = (e, t) => `${i(e[t])}${e.label && e.label !== "calls" ? ` · ${D(e.label)}` : ""}`, o = t.edges.filter((t) => t.to === e.id && (t.kind === "calls" || t.kind === "flow" && t.flow === "api")), s = (e) => o.filter((t) => n(t.from)?.type === e).map((e) => Q(a(e, "from"))), c = new Set(t.nodes.filter((t) => t.type === "container" && t.stack === e.stack).map((e) => e.id));
1330
+ return $("Self-hosted:", [Q(D(e.summary || ""))]) + $("Called by services:", s("service")) + $("Called by endpoints:", s("page")) + $("Called by apps:", s("app")) + $("Pushes to (webhook):", t.edges.filter((e) => e.kind === "delivers" && c.has(e.from) && n(e.to)?.type === "page").map((t) => Q(`${i(t.to)}${t.from === e.id ? "" : ` <span class="hx-faint">from ${D(r(t.from))}</span>`}`)));
1331
+ }
1332
+ if (e.type === "external" && e.kind) return Un(e, t.nodes, t.edges);
1333
+ if (e.type === "external") {
1334
+ let t = (t) => a("calls", "to", e.id).filter((e) => n(e.from)?.type === t);
1335
+ return $("System:", [Q(`${D(e.summary || "")}${e.host ? `<div class="hx-faint">Runs here as ${Z(e.host)}</div>` : "<div class=\"hx-faint\">Not run by this stack</div>"}`)]) + $("Client modules:", (e.modules || []).map((e) => Q(Z(e)))) + $("Called by services:", t("service").map((e) => Q(i(e.from)))) + $("Called by endpoints:", t("page").map((e) => Q(i(e.from)))) + $("Pushes to (webhook):", a("delivers", "from", e.id).map((e) => Q(i(e.to))));
1336
+ }
1337
+ if (e.type === "page") {
1338
+ let n = e.render, r = t.edges.filter((t) => t.dashed && t.from === e.id).map((e) => Q(i(e.to)));
1339
+ return (e.methods ? $("Methods:", [Q(e.methods.map(Z).join(" "))]) : "") + (e.render_fn ? $("Rendered by:", [Q(`${Z(e.render_fn)} · ${D(e.file)}`)]) : "") + $("Calls outside:", a("calls", "from", e.id).map((e) => Q(i(e.to)))) + $("Pushed to by:", a("delivers", "to", e.id).map((e) => Q(`${i(e.from)} · ${D(e.label)}`))) + $("Starts:", a("triggers", "from", e.id).map((e) => Q(`${i(e.to)} · ${D(e.label)}`))) + $("Renders:", r) + $("Reads:", o.filter((t) => t.to === e.id).map((e) => Q(`${i(e.from)} · ${e.keys.map(Z).join(" ")}`))) + $("Writes:", s.filter((t) => t.from === e.id).map((e) => Q(`${i(e.to)} · ${D(e.label)}`))) + (n ? $("Render:", [Q(`today: ${Z(n.now)} · ROM: ${n.rom === "bake" ? "<span class=\"hx-rom hx-bold\">bake</span>" : "<span class=\"hx-faint\">skip (per request)</span>"}${n.note ? `<div class="hx-faint">${D(n.note)}</div>` : ""}`)]) : "");
1340
+ }
1341
+ return "";
1342
+ }
1343
+ function s(t) {
1344
+ let n = e.ask("threads:index", t.id);
1345
+ if (!n) return "";
1346
+ let r = n.threads, i = n.start ? `<button data-corn-kind="quiet" type="button" class="hx-btn hx-btn--quiet hx-textact" data-thread-start="${D(t.id)}" aria-label="Start a thread about this: opens the New idea form for ${D(n.forge)}, with this node mentioned">Start a thread about this</button>` : "";
1347
+ return !r || !r.length ? i : `<div class="hx-sec-block" data-corn="section"><h3 class="hx-sec-title">Threads</h3><ul class="hx-rows">${r.map((e) => {
1348
+ let t = Number(e.comments) || 0;
1349
+ return `<li><button type="button" class="hx-row hx-thread-open" data-thread-open="${D(e.number)}" data-corn="row" aria-label="Open thread #${D(e.number)}, ${D(e.title)}, ${t} ${t === 1 ? "comment" : "comments"}, in the issues and pull requests panel"><span class="hx-row-title">${D(e.title)}</span><span class="hx-row-meta">#${D(e.number)} · ${t}</span></button></li>`;
1350
+ }).join("")}</ul>${i}</div>`;
1351
+ }
1352
+ function c(e) {
1353
+ let n = F(e);
1354
+ if (!lr(e, t.proposal)) return "";
1355
+ let r = (e, t) => `<div class="hx-diff-k">${D(e)}</div><div class="hx-diff-v">${t}</div>`, i = [r("id", D(e.id))], a = t.edges.find((t) => !t.kind && !t.dashed && t.to === e.id);
1356
+ a && i.push(r("parent", D(a.from)));
1357
+ let o = t.edges.filter((t) => t.from === e.id || t.to === e.id), s = o.filter((e) => F(e) === "added").length, c = o.filter((e) => F(e) === "removed").length;
1358
+ if ((s || c) && i.push(r("edges", D([s ? `+${s}` : "", c ? `−${c}` : ""].filter(Boolean).join(" ")))), n === "changed") for (let t of pt(e)) i.push(r(t.field, `<span class="hx-change-before">${D(t.before) || "<em>nothing</em>"}</span> <span aria-hidden="true">→</span><span class="hx-sr-only"> became </span> <span class="hx-change-after">${D(t.after) || "<em>nothing</em>"}</span>`));
1359
+ return `<div class="hx-sec-block" data-proposal-mark="${D(e.mark)}" data-corn="section"><h3 class="hx-sec-title">In this proposal</h3>${e.why ? `<p class="hx-why">${D(e.why)}</p>` : ""}<div class="hx-diff hx-diff--${D(n)}" data-corn="diff-block"${Ze(e.mark)}>${i.join("")}</div></div>`;
1360
+ }
1361
+ return {
1362
+ dataSummary: o,
1363
+ threadsSection: s,
1364
+ diffSection: c,
1365
+ nameOf: r,
1366
+ nodeById: n
1367
+ };
1368
+ }
1369
+ function mr(e, t, n = {}) {
1370
+ let { state: r } = t, i = A(t), o = pr(t), c = [...oe(t, e, ur().drawer, n.slots, "drawer"), ...oe(t, e, ur().backdrop, n.slots, "backdrop")], l = (e) => {
1371
+ for (let t of c) {
1372
+ if (t.id === e) return t;
1373
+ let n = t.querySelector(`[id="${e}"]`);
1374
+ if (n) return n;
1375
+ }
1376
+ return null;
1377
+ };
1378
+ i.keepParts(...c);
1379
+ let u = l("spec-drawer"), d = l("drawer-backdrop"), f = !1, p = () => re(r.selectedNode, t.viewEdges(), {
1380
+ throughChildren: r.throughChildren,
1381
+ kind: r.selectedKind
1382
+ });
1383
+ function m(e) {
1384
+ let n = p();
1385
+ if (!n || !n.kinds.size) return "";
1386
+ let i = er(n).map(({ kind: e, count: t, word: r }) => `<button type="button" class="hx-lines-kind" data-corn="lines-kind" data-corn-kind="quiet" data-lines-kind="${D(e)}" data-focus-key="kind:${D(e)}" aria-pressed="${n.kind === e}">${D(r)} <span class="hx-lines-count" data-corn="count">${t}</span></button>`).join(""), s = n.kind ? tr(n, n.kind).map((e) => `<button type="button" class="hx-linkbtn" data-corn="node-link" data-action="select-node" data-id="${D(e.id)}"><span class="hx-sr-only">${e.out ? "to " : "from "}</span><span aria-hidden="true">${e.out ? "→" : "←"}</span> ${D(o.nameOf(e.id))}</button>`) : [], c = s.length ? `<div class="hx-lines-list">${Ue(s, 12)}</div>` : "", l = re(e, t.viewEdges(), { throughChildren: !1 }).childIds.size > 0 ? `<label class="hx-lines-switch"><input type="checkbox" data-corn="lines-switch" data-lines-switch data-focus-key="switch"${r.throughChildren ? " checked" : ""}> <span>${D(a(t, "throughChildren"))}</span></label>` : "", { connected: u, off: d } = ue(t);
1387
+ return `<div class="hx-sec-block hx-lines" id="drawer-lines" data-corn="lines-by-kind"><h3 class="hx-sec-title">Lines</h3><div class="hx-chips" role="group" aria-label="Lit lines by kind">${i}</div>${c}${l}<div class="hx-lines-reach"><span data-lines-reach>${D(nr(u, d))}</span> <button type="button" data-corn="frame-button" data-corn-kind="secondary" class="hx-btn hx-btn--secondary" data-action="frame-selection" data-focus-key="frame">${D(a(t, "frame"))}</button></div></div>`;
1388
+ }
1389
+ function h() {
1390
+ let e = l("drawer-lines");
1391
+ if (!e || !r.selectedNode) return;
1392
+ let n = t.active(), i = n && e.contains(n) ? n.dataset.focusKey : "", a = t.doc.createElement("div");
1393
+ a.innerHTML = m(r.selectedNode), z(a);
1394
+ let o = a.firstElementChild;
1395
+ if (o ? e.replaceWith(o) : e.remove(), i) {
1396
+ let e = l("drawer-lines"), t = e && [...e.querySelectorAll("[data-focus-key]")].find((e) => e.dataset.focusKey === i);
1397
+ t && t.focus();
1398
+ }
1399
+ }
1400
+ function g(e) {
1401
+ let n = e.target.closest && e.target.closest("[data-lines-kind]");
1402
+ if (!n || !r.selectedNode) return !1;
1403
+ let i = n.dataset.linesKind;
1404
+ r.selectedKind = r.selectedKind === i ? null : i, t.touchScene(), t.map.render(), h();
1405
+ let a = p();
1406
+ return H(t, a && a.kind ? `Showing ${$n(a.kind).toLowerCase()} only: ${a.edges.length} ${a.edges.length === 1 ? "line" : "lines"}` : "Showing every kind of line"), !0;
1407
+ }
1408
+ function _(e) {
1409
+ let n = e.target.closest && e.target.closest("[data-lines-switch]");
1410
+ if (!n || !r.selectedNode) return;
1411
+ r.throughChildren = !!n.checked, r.selectedKind = null, t.touchScene(), t.map.render(), h();
1412
+ let i = p();
1413
+ H(t, `${r.throughChildren ? "Including" : "Not including"} its children's lines: ${i ? i.connectedNodeIds.size - 1 : 0} connected`);
1414
+ }
1415
+ let y = l("drawer-meta-list");
1416
+ i.listen(y, "click", (e) => {
1417
+ g(e) || We(e.target);
1418
+ }), i.listen(y, "change", _), i.own(t.map.onPaint(() => {
1419
+ if (!r.selectedNode) return;
1420
+ let e = u.querySelector("[data-lines-reach]");
1421
+ if (!e) return;
1422
+ let { connected: n, off: i } = ue(t), a = nr(n, i);
1423
+ e.textContent !== a && (e.textContent = a);
1424
+ }));
1425
+ function b() {
1426
+ let e = l("drawer-threads");
1427
+ e && r.selectedNode && (e.innerHTML = o.threadsSection(r.selectedNode), z(e));
1428
+ }
1429
+ function x(e, { frame: n = !1 } = {}) {
1430
+ if (!e || f) return;
1431
+ let i = l("drawer-title");
1432
+ i.textContent = e.tag ? `<${e.tag}>` : e.label, i.classList.toggle("hx-mono", e.type === "page" || !!e.tag), l("drawer-badge").textContent = sr(e);
1433
+ let s = cr(e);
1434
+ l("drawer-host").textContent = s ? ` · ${s}` : "";
1435
+ let c = lr(e, r.proposal), p = l("drawer-diff");
1436
+ p.textContent = c, p.hidden = !c;
1437
+ let h = Xe(c ? e.mark : "");
1438
+ h ? p.dataset.cornState = h : delete p.dataset.cornState;
1439
+ let g = l("drawer-description");
1440
+ g.textContent = e.desc || "", g.hidden = !e.desc;
1441
+ let _ = `${e.file ? $("File", [Z(e.file)]) : ""}${Ge(t, e)}${o.dataSummary(e)}`, v = t.ask("live:section", e) || "";
1442
+ y.innerHTML = `${m(e)}${_ ? `<div class="hx-facts">${_}</div>` : ""}
1443
+ <div id="drawer-live">${v}</div>
1444
+ ${rn(r, e.id)}
1445
+ <div id="drawer-threads">${o.threadsSection(e)}</div>
1446
+ ${o.diffSection(e)}`, z(y), t.emit("threads:ensure"), t.emit("live:hydrate", l("drawer-live"));
1447
+ let b = l("drawer-file-btn"), x = l("drawer-open-btn"), S = e.file && r.forge ? Kn(r.forge, e.file, r.forge.baseBranch) : null;
1448
+ b.hidden = !S, S ? b.href = S : b.removeAttribute("href");
1449
+ let w = !!(e.url && /^https?:\/\//.test(e.url));
1450
+ w ? x.href = e.url : x.removeAttribute("href"), x.hidden = !w, x.className = S ? "hx-btn hx-btn--quiet hx-foot-btn" : "hx-open", S ? x.dataset.cornKind = "quiet" : x.dataset.cornKind = "primary", x.textContent = `${a(t, "openRoute")} ↗`, b.textContent = `${a(t, "openFile")} ↗`, l("drawer-run-btn").hidden = !(r.proposalSlug && t.ask("forge:can-start")), u.classList.add("drawer-open"), u.inert = !1, d.hidden = !1, mn(t, "drawer"), n || C(), t.emit("node:painted", { node: e });
1451
+ }
1452
+ function S(e) {
1453
+ if (!e || f) return;
1454
+ let t = (e, t) => t ? `<div class="hx-fact" data-corn="section"><div class="hx-fact-k">${D(e)}</div><div class="hx-fact-v">${D(t)}</div></div>` : "", n = t("Kind", e.kind || (e.dashed ? "usage" : "ownership")) + t("Flow", e.flow) + t("Label", e.label) + t("Reads", Array.isArray(e.keys) ? e.keys.join(", ") : ""), r = l("drawer-title");
1455
+ r.textContent = `${o.nameOf(e.from)} → ${o.nameOf(e.to)}`, r.classList.remove("hx-mono"), l("drawer-badge").textContent = "Edge", l("drawer-host").textContent = "", l("drawer-diff").hidden = !0;
1456
+ let i = l("drawer-description");
1457
+ i.textContent = "", i.hidden = !0, y.innerHTML = `${n ? `<div class="hx-facts">${n}</div>` : ""}
1458
+ <div class="hx-facts">
1459
+ <div class="hx-fact" data-corn="section"><div class="hx-fact-k">From</div><div class="hx-fact-v"><button data-corn="node-link" type="button" class="hx-linkbtn" data-action="select-node" data-id="${D(e.from)}">${D(o.nameOf(e.from))}</button></div></div>
1460
+ <div class="hx-fact" data-corn="section"><div class="hx-fact-k">To</div><div class="hx-fact-v"><button data-corn="node-link" type="button" class="hx-linkbtn" data-action="select-node" data-id="${D(e.to)}">${D(o.nameOf(e.to))}</button></div></div>
1461
+ </div>${ht(e)}`, z(y), l("drawer-open-btn").hidden = !0, l("drawer-file-btn").hidden = !0, l("drawer-run-btn").hidden = !0, u.classList.add("drawer-open"), u.inert = !1, d.hidden = !1;
1462
+ }
1463
+ function C() {
1464
+ let e = r.selectedNode;
1465
+ if (!e || !r.width || !v(t) || f) return;
1466
+ let n = s(t), i = jn(r.camera, e, {
1467
+ left: 0,
1468
+ top: 0,
1469
+ right: r.width,
1470
+ bottom: r.height - n
1471
+ }, e.r * r.camera.zoom + 16);
1472
+ i && (Object.assign(r.camera, i), t.map.render());
1473
+ }
1474
+ function w() {
1475
+ u.classList.remove("drawer-open"), u.inert = !0, d.hidden = !0, yn(t, "drawer");
1476
+ }
1477
+ function T() {
1478
+ r.proposalSlug && t.emit("forge:start", {
1479
+ slug: r.proposalSlug,
1480
+ returnTo: "#drawer-run-btn"
1481
+ });
1482
+ }
1483
+ i.own(() => clearTimeout(dr(t).timer));
1484
+ let O = {
1485
+ "close-drawer": () => E(t, { source: "tap" }),
1486
+ "copy-spec": () => fr(t, l("copy-spec-result")),
1487
+ "start-run": () => T(),
1488
+ "select-node": (e) => ce(t, o.nodeById(e.dataset.id), {
1489
+ frame: !0,
1490
+ source: "link"
1491
+ }),
1492
+ "frame-selection": () => ee(t)
1493
+ };
1494
+ return i.listen(u, "click", (e) => {
1495
+ let t = e.target.closest && e.target.closest("[data-action]");
1496
+ if (!t) return;
1497
+ let n = O[t.dataset.action];
1498
+ n && n(t), t.dataset.action === "close-drawer" && r.canvas && i.timeout(() => r.canvas.focus(), 0);
1499
+ }), i.listen(u, "click", (e) => {
1500
+ let n = e.target.closest && e.target.closest("[data-thread-open]");
1501
+ n ? t.emit("thread:open", { number: Number(n.dataset.threadOpen) }) : e.target.closest && e.target.closest("[data-thread-start]") && r.selectedNode && t.emit("thread:start", { node: r.selectedNode });
1502
+ }), i.on("threads:changed", () => b()), i.listen(d, "click", (e) => {
1503
+ v(t) ? En(t, e) : E(t, { source: "tap" });
1504
+ }, !0), i.listen(u, "keydown", (e) => {
1505
+ e.key !== "Escape" || e.defaultPrevented || e.target.closest && e.target.closest("select, input, textarea") || (e.preventDefault(), E(t, { source: "keyboard" }), r.canvas && r.canvas.focus(), H(t, "Panel closed"));
1506
+ }), i.on("node:show", ({ node: e, frame: t }) => x(e, { frame: t })), i.on("node:close", w), i.on("node:show-edge", ({ edge: e }) => S(e)), i.on("node:focus", () => {
1507
+ let e = l("drawer-title");
1508
+ e && (e.setAttribute("tabindex", "-1"), e.focus());
1509
+ }), i.own(cn(t, () => C())), Dn(t), gn(t, "drawer", u, { stub: () => ({ title: l("drawer-title") && l("drawer-title").textContent || "Node" }) }), i.own(() => _n(t, "drawer")), r.selectedNode && x(r.selectedNode, { frame: !1 }), i.own(() => {
1510
+ f = !0, c.forEach((e) => e.remove());
1511
+ }), {
1512
+ elements: c,
1513
+ show: x,
1514
+ close: w,
1515
+ repaintThreads: b,
1516
+ copySpec: () => fr(t, l("copy-spec-result")),
1517
+ startRun: T,
1518
+ keepSelectedInView: C,
1519
+ update(e) {
1520
+ e && "node" in e ? e.node ? ce(t, e.node, { source: "api" }) : E(t, { source: "api" }) : r.selectedNode && u.classList.contains("drawer-open") && x(r.selectedNode, { frame: !1 });
1521
+ },
1522
+ destroy: () => i.destroy()
1523
+ };
1524
+ }
1525
+ // ../explorer/engine/proposal.js
1526
+ var hr = (e) => e.slot("proposal", () => ({
1527
+ pinnedSource: !1,
1528
+ listing: null,
1529
+ listingProblem: null,
1530
+ forgeProblem: null,
1531
+ listingAt: 0,
1532
+ watchers: /* @__PURE__ */ new Set(),
1533
+ openToken: 0,
1534
+ message: null
1535
+ })), gr = (e) => e.proposal && typeof e.proposal.title == "string" && e.proposal.title || e.proposalSlug || "Proposal", _r = (e) => e.ask("proposal:specs-list") === !1 ? null : {
1536
+ label: a(e, "openSpecsList"),
1537
+ way: "specs"
1538
+ };
1539
+ function vr(e) {
1540
+ let t = hr(e);
1541
+ return {
1542
+ entries: t.listing,
1543
+ problem: t.listingProblem,
1544
+ forgeProblem: t.forgeProblem,
1545
+ at: t.listingAt
1546
+ };
1547
+ }
1548
+ async function yr(e) {
1549
+ let t = hr(e), n = Se(e);
1550
+ try {
1551
+ let r;
1552
+ try {
1553
+ r = await n("/proposals", { cache: "no-store" });
1554
+ } catch {
1555
+ throw Error(e.offline() ? "You are offline." : "cornfield could not be reached. Check that it is still running.");
1556
+ }
1557
+ if (!r.ok) throw Error(`The server could not list them (error ${r.status}).`);
1558
+ let i;
1559
+ try {
1560
+ i = await r.json();
1561
+ } catch {
1562
+ throw Error("cornfield sent a list this page could not read.");
1563
+ }
1564
+ if (!Array.isArray(i)) throw Error("cornfield sent something that is not a list of proposals.");
1565
+ t.listing = i, t.listingProblem = null;
1566
+ let a = r.headers.get("X-Proposals-Forge-Error");
1567
+ t.forgeProblem = a ? decodeURIComponent(a) : null;
1568
+ } catch (e) {
1569
+ t.listing = null, t.forgeProblem = null, t.listingProblem = e.message || "cornfield did not answer.";
1570
+ }
1571
+ t.listingAt = Date.now(), e.emit("proposal:listing");
1572
+ for (let e of [...t.watchers]) e();
1573
+ return t.listing;
1574
+ }
1575
+ function br(e, t, n = !1, r = []) {
1576
+ let i = hr(e);
1577
+ i.message = {
1578
+ text: t,
1579
+ isError: n,
1580
+ ways: r
1581
+ }, e.emit("proposal:message", i.message);
1582
+ }
1583
+ var xr = (e) => hr(e).message;
1584
+ async function Sr(e, t, n = null) {
1585
+ let r = hr(e), i = ++r.openToken;
1586
+ if (!lt(t)) {
1587
+ let r = ut(t);
1588
+ return br(e, r, !0, []), e.emit("proposal:failed", {
1589
+ slug: t,
1590
+ source: n,
1591
+ status: 0,
1592
+ notFound: !1,
1593
+ message: r
1594
+ }), !1;
1595
+ }
1596
+ br(e, `Opening ${t} …`);
1597
+ try {
1598
+ let r;
1599
+ try {
1600
+ r = await Se(e)(`/proposals/${encodeURIComponent(t)}.json${n ? `?source=${encodeURIComponent(n)}` : ""}`, { cache: "no-store" });
1601
+ } catch {
1602
+ throw Error(e.offline() ? `${t} could not be opened: you are offline.` : `${t} could not be opened: cornfield could not be reached.`);
1603
+ }
1604
+ if (!r.ok) {
1605
+ let i = "";
1606
+ try {
1607
+ i = (await r.json()).error || "";
1608
+ } catch {}
1609
+ let a = r.status === 401 || r.status === 403;
1610
+ a && e.emit("auth", {
1611
+ status: r.status,
1612
+ during: "proposal"
1613
+ });
1614
+ let o = a ? r.status === 403 ? "this is for the project's maintainers." : "you are not signed in." : `the server had a problem (error ${r.status}).`, s = Error(r.status === 404 ? bt(t, n) : `${t} could not be opened: ${typeof i == "string" && i ? i : o}`);
1615
+ throw s.notFound = r.status === 404, s.status = r.status, s;
1616
+ }
1617
+ let i = r.headers.get("X-Proposal-Source"), a;
1618
+ try {
1619
+ a = await r.json();
1620
+ } catch {
1621
+ throw Error(`${t} could not be opened: cornfield sent a file this page could not read.`);
1622
+ }
1623
+ let o = r.headers.get("X-Proposal-Sha256");
1624
+ return !e.ended && (Cr(e, a, {
1625
+ slug: t,
1626
+ source: n || (i ? decodeURIComponent(i) : null),
1627
+ pinSource: !!n,
1628
+ view: "diff",
1629
+ fit: !0,
1630
+ sha256: o
1631
+ }), H(e, [e.ask("changes:opened-line", gr(e.state)), we(e)].filter(Boolean).join(" ")), !0);
1632
+ } catch (a) {
1633
+ if (e.ended) return !1;
1634
+ console.error("Opening the proposal failed", a);
1635
+ let o = a.message || `${t} could not be opened.`;
1636
+ if (br(e, o, !0, a.notFound ? [_r(e)].filter(Boolean) : [{
1637
+ label: "Retry",
1638
+ way: "retry",
1639
+ slug: t,
1640
+ source: n
1641
+ }, {
1642
+ label: "Close",
1643
+ way: "close"
1644
+ }]), a.notFound && i === r.openToken) {
1645
+ await yr(e);
1646
+ let a = new Set((Array.isArray(r.listing) ? r.listing : []).map((e) => e && e.source));
1647
+ i === r.openToken && (o = bt(t, n, a), br(e, o, !0, [...St(r.listing, t, n).map((e) => ({
1648
+ label: e.label,
1649
+ way: "open",
1650
+ slug: e.slug,
1651
+ source: e.source
1652
+ })), _r(e)].filter(Boolean)));
1653
+ }
1654
+ return i === r.openToken && e.emit("proposal:failed", {
1655
+ slug: t,
1656
+ source: n,
1657
+ status: a.status || 0,
1658
+ notFound: !!a.notFound,
1659
+ message: o
1660
+ }), !1;
1661
+ }
1662
+ }
1663
+ function Cr(e, t, { slug: n = null, source: r = null, pinSource: i = !1, view: a, fit: o = !0, sha256: s = null } = {}) {
1664
+ let { state: c } = e;
1665
+ c.proposal = t, ve(e), c.proposalSlug = n, c.proposalSource = r, c.proposalSha256 = typeof s == "string" && /^[0-9a-f]{64}$/.test(s) ? s : null, hr(e).pinnedSource = i, a ? c.proposalView = a : tt.includes(c.proposalView) || (c.proposalView = "diff");
1666
+ let l = e.ask("proposal:effective", t);
1667
+ Er(e, l === void 0 ? t : l, { fit: o }), wr(e, "opened");
1668
+ }
1669
+ function wr(e, t) {
1670
+ let { state: n } = e;
1671
+ e.emit("proposal", {
1672
+ change: t,
1673
+ slug: n.proposalSlug || null,
1674
+ source: n.proposalSource || null,
1675
+ pinSource: hr(e).pinnedSource,
1676
+ view: n.proposalView,
1677
+ proposal: n.proposal || null
1678
+ });
1679
+ }
1680
+ function Tr(e) {
1681
+ let t = !!e.state.proposal;
1682
+ e.emit("proposal:draw", { open: t }), e.emit("proposal:bar", { open: t });
1683
+ }
1684
+ function Er(e, t, { fit: n = !1 } = {}) {
1685
+ let { state: r } = e;
1686
+ if (t === void 0) {
1687
+ let n = e.ask("proposal:effective", r.proposal);
1688
+ t = n === void 0 ? r.proposal : n;
1689
+ }
1690
+ let i = {
1691
+ nodes: r.baseNodes,
1692
+ edges: r.baseEdges
1693
+ }, a;
1694
+ r.effectiveProposal = t;
1695
+ try {
1696
+ r.proposalErrors = Yt(i, t).errors, a = qt(i, t), e.emit("proposal:mark", {
1697
+ applied: a,
1698
+ effective: t,
1699
+ proposal: r.proposal
1700
+ });
1701
+ } catch (e) {
1702
+ r.proposalErrors = [{
1703
+ path: "",
1704
+ message: `This proposal could not be read: ${e.message}`
1705
+ }], a = {
1706
+ nodes: r.baseNodes.map((e) => ({
1707
+ ...e,
1708
+ mark: "none"
1709
+ })),
1710
+ edges: r.baseEdges.map((e) => ({
1711
+ ...e,
1712
+ mark: "none"
1713
+ }))
1714
+ };
1715
+ }
1716
+ kr(e, a.nodes, a.edges), Tr(e), Ee(e), n && Ar(e), e.map.render(), e.map.ensureFlowLoop();
1717
+ }
1718
+ function Dr(e) {
1719
+ let { state: t } = e;
1720
+ return e.ask("proposal:before-close") !== !1 && (t.proposal = null, t.effectiveProposal = null, t.proposalSlug = null, t.proposalSource = null, t.proposalSha256 = null, t.proposalErrors = [], ke(e), kr(e, t.baseNodes.map((e) => ({ ...e })), t.baseEdges), e.map.fitGraphToViewport(e.map.fitPadding()), e.map.render(), e.map.ensureFlowLoop(), Tr(e), wr(e, "closed"), !0);
1721
+ }
1722
+ function Or(e, t, { quiet: n = !1 } = {}) {
1723
+ let { state: r } = e;
1724
+ r.proposal && tt.includes(t) && r.proposalView !== t && (r.proposalView = t, e.touchScene(), r.selectedNode && !e.map.isNodeVisible(r.selectedNode) && E(e, { source: "api" }), t === "diff" && Ar(e), e.map.render(), Tr(e), wr(e, "view"), n || H(e, at(t)));
1725
+ }
1726
+ function kr(e, t, n) {
1727
+ let { state: r } = e, i = r.selectedNode ? r.selectedNode.id : null;
1728
+ if (e.ask("map:set", {
1729
+ nodes: t,
1730
+ edges: n
1731
+ }) || (r.mapNodes = t, r.mapEdges = n, r.nodes = t, r.edges = n), r.selectedEdge = null, i) {
1732
+ let t = r.nodes.find((e) => e.id === i);
1733
+ t ? r.selectedNode = t : E(e, { source: "api" });
1734
+ }
1735
+ e.touchScene();
1736
+ }
1737
+ function Ar(e) {
1738
+ let { state: t, map: n } = e, { touched: r } = O(t.nodes, e.viewEdges()), i = t.nodes.filter((e) => r.has(e.id) && n.isNodeVisible(e)), a = l(e), o = {
1739
+ padding: n.fitPadding(),
1740
+ maxZoom: 1,
1741
+ minZoom: n.getMinZoom()
1742
+ }, s = An(i, a, {
1743
+ ...o,
1744
+ minZoom: Math.max(o.minZoom, On)
1745
+ }), c = i.length ? P(s, a, o) : null;
1746
+ c ? (Object.assign(t.camera, c), n.render()) : n.fitGraphToViewport(n.fitPadding());
1747
+ }
1748
+ var jr = (e, t) => (e.nodes.find((e) => e.id === t) || { label: t }).label, Mr = (e) => e.kind || (e.dashed ? "usage" : "ownership");
1749
+ function Nr(e, t, n, { select: r = !0 } = {}) {
1750
+ let { state: i, map: a } = e, o = t === "edge" ? i.edges.find((e) => X(e) === n) : i.nodes.find((e) => e.id === n);
1751
+ if (!o) return;
1752
+ let s = (t === "edge" ? [i.nodes.find((e) => e.id === o.from), i.nodes.find((e) => e.id === o.to)] : [o]).filter(Boolean);
1753
+ if (!s.length) return;
1754
+ i.proposalView !== "diff" && s.some((e) => !a.isNodeVisible(e)) && Or(e, "diff", { quiet: !0 }), r && (t === "edge" ? Fr(e, o) : ce(e, o));
1755
+ let c = P(s, l(e), {
1756
+ padding: a.fitPadding(),
1757
+ maxZoom: Math.max(1, i.camera.zoom),
1758
+ minZoom: a.getMinZoom()
1759
+ });
1760
+ c && Object.assign(i.camera, c), a.render(), H(e, ot(mt[o.mark] || o.mark, t === "edge" ? `${jr(i, o.from)} to ${jr(i, o.to)}` : o.label));
1761
+ }
1762
+ function Pr(e, t, n, i) {
1763
+ let a = null, o = i;
1764
+ for (let i of e.map.getScene().edges) if (i.mark !== "none") for (let e = 0; e <= 1; e += 1 / 20) {
1765
+ let s = r(i, e), c = Math.hypot(s.x - t, s.y - n);
1766
+ c <= o && (a = i, o = c);
1767
+ }
1768
+ return a && e.viewEdges().find((e) => e.from === a.from && e.to === a.to && Mr(e) === a.kind) || null;
1769
+ }
1770
+ function Fr(e, t) {
1771
+ E(e, { source: "api" }), e.state.selectedEdge = t, e.emit("node:show-edge", { edge: t }), e.touchScene(), e.map.render();
1772
+ }
1773
+ function Ir(e, t) {
1774
+ let n = e.state.canvas;
1775
+ if (!n) return () => {};
1776
+ let r = null, i = [t(n, "mousedown", (e) => {
1777
+ r = {
1778
+ x: e.clientX,
1779
+ y: e.clientY
1780
+ };
1781
+ }), t(n, "click", (t) => {
1782
+ let { state: i } = e;
1783
+ if (!i.proposal || i.proposalView === "before" || r && Math.hypot(t.clientX - r.x, t.clientY - r.y) > 5) return;
1784
+ let a = n.getBoundingClientRect(), o = e.map.screenToWorld(t.clientX - a.left, t.clientY - a.top), s = i.camera.zoom;
1785
+ if (i.nodes.some((t) => e.map.isNodeVisible(t) && Math.hypot(t.x - o.x, t.y - o.y) <= t.r + 6 / s)) return;
1786
+ let c = Pr(e, o.x, o.y, 8 / s);
1787
+ c && Fr(e, c);
1788
+ })];
1789
+ return () => i.forEach((e) => e());
1790
+ }
1791
+ var Lr = (e) => hr(e).pinnedSource, Rr = ({ edit: e = !0 } = {}) => ({
1792
+ bar: "<section id=\"proposal-bar\" class=\"hx-proposal-bar glass\" aria-label=\"Open proposal\" hidden data-corn=\"proposal-bar\"><p id=\"proposal-message\" class=\"hx-proposal-message\" data-corn=\"message\" role=\"status\" hidden></p><div id=\"proposal-ways\" class=\"hx-proposal-ways\" role=\"group\" aria-label=\"Ways on\" data-corn=\"proposal-ways\" hidden></div><div id=\"proposal-body\"><div class=\"hx-proposal-head\" data-corn=\"proposal-head\" role=\"group\" aria-label=\"Proposal actions\"><h2 id=\"proposal-title\" class=\"hx-proposal-name\" data-corn=\"proposal-title\"></h2><a id=\"proposal-source\" class=\"hx-proposal-source\" data-corn=\"proposal-source\" hidden></a><div class=\"hx-proposal-counts\"><div id=\"proposal-chip\" class=\"hx-proposal-chip\" data-corn=\"proposal-counts\"></div><p id=\"proposal-peek\" class=\"hx-proposal-peek\"></p><button type=\"button\" id=\"proposal-mode\" class=\"hx-proposal-mode\" data-corn=\"proposal-mode\" data-action=\"toggle-proposal-mode\" data-peek-ok aria-expanded=\"false\" aria-controls=\"proposal-seg\" title=\"Before, Diff or After\"></button></div><div id=\"proposal-seg\" class=\"hx-seg\" data-corn=\"compare\" role=\"group\" aria-label=\"Compare\"><button data-corn=\"compare-option\" type=\"button\" class=\"hx-seg-btn\" data-action=\"proposal-view\" data-view=\"before\" aria-pressed=\"false\" data-corn-string=\"before\">Before</button><button data-corn=\"compare-option\" type=\"button\" class=\"hx-seg-btn\" data-action=\"proposal-view\" data-view=\"diff\" aria-pressed=\"true\" data-corn-string=\"diff\">Diff</button><button data-corn=\"compare-option\" type=\"button\" class=\"hx-seg-btn\" data-action=\"proposal-view\" data-view=\"after\" aria-pressed=\"false\" data-corn-string=\"after\">After</button></div><div class=\"hx-proposal-tools\"><button data-corn=\"whole-map\" data-corn-kind=\"secondary\" type=\"button\" id=\"proposal-whole\" class=\"hx-btn\" data-action=\"proposal-whole\" aria-pressed=\"false\" aria-label=\"Show the whole map\" title=\"Show the whole map\" data-peek-ok data-corn-string=\"wholeMap\" data-corn-string-aria-label=\"showWholeMap\">Whole map</button>" + (e ? "<button data-corn-kind=\"secondary\" type=\"button\" id=\"proposal-myedits\" class=\"hx-btn\" aria-pressed=\"true\" data-peek-ok data-corn-string=\"myEdits\" hidden>My edits</button><button data-corn-kind=\"secondary\" type=\"button\" id=\"proposal-edit\" class=\"hx-btn\" aria-expanded=\"false\" aria-controls=\"whatif\" title=\"Try a change: add a node or an edge, reword a scenario\">Edit</button>" : "") + "</div><div class=\"hx-proposal-more\"><button type=\"button\" id=\"proposal-more\" class=\"hx-btn hx-btn--icon\" data-action=\"toggle-proposal-more\" aria-haspopup=\"menu\" aria-expanded=\"false\" aria-controls=\"proposal-more-menu\" aria-label=\"More\" data-corn-kind=\"icon\"><svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden=\"true\"><circle cx=\"3\" cy=\"8\" r=\"1.5\"/><circle cx=\"8\" cy=\"8\" r=\"1.5\"/><circle cx=\"13\" cy=\"8\" r=\"1.5\"/></svg></button><div id=\"proposal-more-menu\" class=\"hx-proposal-more-menu glass\" data-corn=\"proposal-menu\" role=\"menu\" aria-label=\"More\" hidden><button type=\"button\" role=\"menuitem\" class=\"hx-btn hx-btn--quiet\" data-action=\"close-proposal\" title=\"Close the proposal and go back to the map\" data-corn-kind=\"quiet\" data-corn-string=\"closeProposal\">Close</button></div></div></div><details id=\"proposal-errors\" class=\"hx-proposal-errors\" data-corn=\"proposal-errors\" hidden><summary data-corn=\"summary\" id=\"proposal-errors-count\"></summary><ul id=\"proposal-errors-list\"></ul><p class=\"hx-faint\">The map shows what it can.</p></details></div></section>",
1793
+ menu: "<div id=\"proposal-wrap\"><button type=\"button\" id=\"proposal-btn\" class=\"hx-account-item\" data-action=\"toggle-proposals-menu\" aria-haspopup=\"true\" aria-expanded=\"false\" title=\"Open a proposal: what a change would add, change and remove\" data-corn=\"proposals-button\"><span data-corn-string=\"proposals\">Proposals</span><span class=\"hx-faint\" aria-hidden=\"true\">▾</span></button><div id=\"proposal-menu\" class=\"hx-menu hx-menu--proposals\" hidden data-corn=\"proposals-menu\"></div></div>"
1794
+ });
1795
+ function zr(e, t = 8) {
1796
+ let n = e.slice(0, t).map((e) => `<li>${e.path ? `<code class="hx-code">${D(e.path)}</code> ` : ""}${D(e.message)}</li>`);
1797
+ return e.length > t && n.push(`<li class="hx-faint">and ${e.length - t} more</li>`), n.join("");
1798
+ }
1799
+ var Br = (e, t) => `${e} ${t}${e === 1 ? "" : "s"}`, Vr = (e) => typeof e == "string" && /^https?:\/\//i.test(e) ? e : null;
1800
+ function Hr(e) {
1801
+ return e.pull ? `Spec PR #${e.pull.number}${e.pull.draft ? " (draft)" : ""}${e.pull.author ? ` by ${e.pull.author}` : ""}` : e.source === "checkout" ? "In the checkout" : `In worktree ${e.source}`;
1802
+ }
1803
+ function Ur(e, t) {
1804
+ let n = t && t.slug === e.slug && t.source === e.source, r = `<span class="hx-proposal-title">${D(e.title || e.slug)}</span>`, i = [`<span class="hx-proposal-where">${D(Hr(e))}</span>`];
1805
+ if (e.spec && i.push(`<span>spec ${D(e.spec)}</span>`), e.error) return `<div class="hx-proposal-item is-broken" data-corn="row">${r}<span class="hx-proposal-sum hx-error-text">${D(e.error)}</span><span class="hx-proposal-meta">${i.join("")}</span></div>`;
1806
+ e.counts && i.push(`<span>${D(rt(e.counts))}</span>`);
1807
+ let a = Ie(e.review, Date.now());
1808
+ return a && i.push(`<span class="hx-proposal-reviewed">${D(a)}</span>`), e.errors && i.push(`<span class="hx-warn">${D(Br(e.errors, "problem"))}</span>`), `<button type="button" class="hx-proposal-item${n ? " is-current" : ""}" data-action="open-proposal" data-slug="${D(e.slug)}" data-source="${D(e.source)}" data-corn="row">${r}${e.summary ? `<span class="hx-proposal-sum">${D(e.summary)}</span>` : ""}<span class="hx-proposal-meta">${i.join("")}</span></button>`;
1809
+ }
1810
+ function Wr(e, t, n = {}) {
1811
+ let { state: r } = t, i = A(t), s = Rr({ edit: n.edit !== !1 }), c = [...oe(t, e, s.bar, n.slots, "bar"), ...oe(t, e, s.menu, n.slots, "menu")], l = (e) => {
1812
+ for (let t of c) {
1813
+ if (t.id === e) return t;
1814
+ let n = t.querySelector(`[id="${e}"]`);
1815
+ if (n) return n;
1816
+ }
1817
+ return null;
1818
+ };
1819
+ i.keepParts(...c);
1820
+ let u = l("proposal-bar"), d = null, f = null, p = !1;
1821
+ function m({ text: e, isError: t, ways: n }) {
1822
+ u.hidden = !1, u.classList.toggle("is-error", t), l("proposal-body").hidden = !0;
1823
+ let r = l("proposal-message");
1824
+ r.hidden = !1, r.textContent = e;
1825
+ let i = l("proposal-ways");
1826
+ i.hidden = n.length === 0, i.innerHTML = n.map((e) => `<button type="button" class="hx-btn" data-action="proposal-way" data-way="${D(e.way)}"${e.slug ? ` data-slug="${D(e.slug)}"` : ""}${e.source ? ` data-source="${D(e.source)}"` : ""} data-peek-ok data-corn-kind="quiet">${D(e.label)}</button>`).join(""), z(i);
1827
+ }
1828
+ let h = t.slot("proposal-pulls", () => /* @__PURE__ */ new Map()), g = null;
1829
+ function _() {
1830
+ let e = l("proposal-source"), n = r.proposal ? r.proposalSource : null;
1831
+ if (e.hidden = !n, !n) return;
1832
+ let i = K(n), a = i ? h.get(i) : null, o = vr(t).entries, s = i && Array.isArray(o) ? o.find((e) => e.slug === r.proposalSlug && e.source === n) : null, c = yt(n, a && a.pull || s && s.pull || null, a ? a.checks : null);
1833
+ e.textContent = c.text, c.state ? e.dataset.cornState = c.state : delete e.dataset.cornState;
1834
+ let u = Vr(c.href);
1835
+ u ? (e.setAttribute("href", u), e.setAttribute("target", "_blank"), e.setAttribute("rel", "noreferrer"), e.title = "Open this pull request") : (e.removeAttribute("href"), e.removeAttribute("target"), e.removeAttribute("rel"), e.title = c.label);
1836
+ let d = `${n}/${r.proposalSlug}`;
1837
+ i && g !== d && (g = d, v(i));
1838
+ }
1839
+ async function v(e) {
1840
+ try {
1841
+ let n = await Se(t)(`/api/forge/pulls/${e}`), i = n.ok ? await n.json() : null;
1842
+ if (p) return;
1843
+ i && i.ok !== !1 && i.pull && h.set(e, {
1844
+ pull: i.pull,
1845
+ checks: Array.isArray(i.checks) ? i.checks : null
1846
+ }), i && i.pull && K(r.proposalSource) === e && t.emit("proposal:pull-head", i.pull.head && typeof i.pull.head.sha == "string" ? i.pull.head.sha : "");
1847
+ } catch {}
1848
+ !p && r.proposal && K(r.proposalSource) === e && _();
1849
+ }
1850
+ function y({ open: e = !!r.proposal } = {}) {
1851
+ if (u.hidden = !e, !e) {
1852
+ w(), E(!1), yn(t, "proposal");
1853
+ return;
1854
+ }
1855
+ u.classList.remove("is-error"), l("proposal-message").hidden = !0, l("proposal-body").hidden = !1;
1856
+ let n = r.proposal, i = l("proposal-title");
1857
+ i.textContent = n && typeof n.title == "string" && n.title || r.proposalSlug || "Proposal", _(), i.title = n && typeof n.summary == "string" && n.summary || "";
1858
+ let o = l("proposal-chip");
1859
+ o.innerHTML = it(Xt(n)).map((e) => {
1860
+ let t = e.mark ? `<span class="hx-mark-dot hx-mark-dot--${e.mark}" data-corn="mark-dot"${Ze(e.mark)} aria-hidden="true"></span>` : "";
1861
+ return !e.mark && /scenarios?$/.test(e.text) ? `<button type="button" class="hx-proposal-count" data-action="review-show-scenarios" data-corn-kind="quiet" title="Show the personas and their scenarios">${D(e.text)}</button>` : `<button type="button" class="hx-proposal-count" data-action="review-show-changes" data-corn-kind="quiet" title="Show the list of changes">${t}${D(e.text)}</button>`;
1862
+ }).join("<span class=\"hx-proposal-sep\" aria-hidden=\"true\"> · </span>");
1863
+ let s = Ct(r.whatIf && r.whatIf.edits, !!r.whatIfOff);
1864
+ s && o.insertAdjacentHTML("beforeend", `<span class="hx-proposal-sep" aria-hidden="true"> · </span><span class="hx-proposal-count hx-proposal-yours"><span class="hx-mark-dot hx-mark-dot--edit" data-corn="mark-dot" data-corn-state="edit" aria-hidden="true"></span>${D(s)}</span>`), z(o), l("proposal-mode").textContent = a(t, r.proposalView);
1865
+ for (let e of u.querySelectorAll("[data-action=\"proposal-view\"]")) {
1866
+ let t = e.dataset.view === r.proposalView;
1867
+ e.setAttribute("aria-pressed", String(t)), e.classList.toggle("is-on", t);
1868
+ }
1869
+ let c = l("proposal-whole"), d = !!(r.review && r.review.whole);
1870
+ c.setAttribute("aria-pressed", String(d)), c.title = a(t, "showWholeMap"), c.classList.toggle("hx-btn--active", d);
1871
+ let f = r.proposalErrors || [], p = l("proposal-errors");
1872
+ p.hidden = f.length === 0, f.length && (l("proposal-errors-count").textContent = `${Br(f.length, "problem")} in this proposal`, l("proposal-errors-list").innerHTML = zr(f));
1873
+ }
1874
+ function b() {
1875
+ let e = l("proposal-body");
1876
+ if (d && d.isConnected) return d;
1877
+ d = t.doc.createElement("p"), d.className = "hx-waiting-line", d.dataset.corn = "waiting-line", d.setAttribute("part", "waiting-line"), d.dataset.cornState = "waiting", d.hidden = !0, d.innerHTML = "<span data-waiting-words></span> <button type=\"button\" class=\"hx-btn hx-forge-act\" data-waiting-answer data-peek-ok data-corn-kind=\"secondary\"></button>";
1878
+ let n = e.querySelector(".hx-proposal-head");
1879
+ return n ? n.after(d) : e.append(d), d;
1880
+ }
1881
+ function x(e, n) {
1882
+ let r = b();
1883
+ if (r.hidden = !e, !e) {
1884
+ f = null;
1885
+ return;
1886
+ }
1887
+ let i = et(e);
1888
+ r.querySelector("[data-waiting-words]").textContent = i;
1889
+ let o = r.querySelector("[data-waiting-answer]");
1890
+ o.textContent = a(t, "answer"), o.dataset.waitingAnswer = e.runId, o.setAttribute("aria-label", `${a(t, "answer")}: ${i}`);
1891
+ let s = `${n}|${e.runId}`;
1892
+ f !== s && (f = s, H(t, i));
1893
+ }
1894
+ let S = () => [...u.querySelectorAll("#proposal-more-menu [role=\"menuitem\"]")], C = () => {
1895
+ let e = l("proposal-more-menu");
1896
+ return !!e && !e.hidden;
1897
+ };
1898
+ function w(e = !1) {
1899
+ l("proposal-more-menu").hidden = !0;
1900
+ let t = l("proposal-more");
1901
+ t.setAttribute("aria-expanded", "false"), e && t.focus();
1902
+ }
1903
+ function T(e = "first") {
1904
+ l("proposal-more-menu").hidden = !1, l("proposal-more").setAttribute("aria-expanded", "true");
1905
+ let t = S();
1906
+ (e === "last" ? t[t.length - 1] : t[0])?.focus();
1907
+ }
1908
+ function E(e) {
1909
+ let t = typeof e == "boolean" ? e : u.dataset.modeOpen !== "true";
1910
+ u.dataset.modeOpen = String(t), l("proposal-mode").setAttribute("aria-expanded", String(t));
1911
+ }
1912
+ function O(e) {
1913
+ let n = l("proposal-more");
1914
+ if (e.target === n && (e.key === "ArrowDown" || e.key === "ArrowUp")) {
1915
+ e.preventDefault(), T(e.key === "ArrowUp" ? "last" : "first");
1916
+ return;
1917
+ }
1918
+ if (!C()) return;
1919
+ if (e.key === "Escape") {
1920
+ e.preventDefault(), w(!0);
1921
+ return;
1922
+ }
1923
+ if (e.key === "Tab") {
1924
+ w();
1925
+ return;
1926
+ }
1927
+ let r = S(), i = r.indexOf(t.active());
1928
+ if (i < 0) return;
1929
+ let a = {
1930
+ ArrowDown: (i + 1) % r.length,
1931
+ ArrowUp: (i - 1 + r.length) % r.length,
1932
+ Home: 0,
1933
+ End: r.length - 1
1934
+ }[e.key];
1935
+ a !== void 0 && (e.preventDefault(), r[a].focus());
1936
+ }
1937
+ let k = () => {
1938
+ let e = l("proposal-menu");
1939
+ return !!e && !e.hidden;
1940
+ };
1941
+ function j() {
1942
+ l("proposal-menu").hidden = !0, l("proposal-btn").setAttribute("aria-expanded", "false");
1943
+ }
1944
+ async function M() {
1945
+ let e = l("proposal-menu");
1946
+ if (k()) return j();
1947
+ e.hidden = !1, l("proposal-btn").setAttribute("aria-expanded", "true"), vr(t).entries || N(!0), await yr(t);
1948
+ }
1949
+ function N(e = !1) {
1950
+ let n = l("proposal-menu"), { entries: i, problem: o, forgeProblem: s } = vr(t), c = r.proposal ? {
1951
+ slug: r.proposalSlug,
1952
+ source: r.proposalSource
1953
+ } : null, u;
1954
+ u = e && !i ? "<p class=\"hx-faint hx-proposal-empty\">Looking for proposals …</p>" : o ? `<p class="hx-error-text hx-proposal-empty">The list could not be loaded: ${D(o)}</p>` : !i || i.length === 0 ? "<p class=\"hx-faint hx-proposal-empty\">No proposals</p>" : `<div class="hx-proposal-list" role="list">${i.map((e) => `<div role="listitem">${Ur(e, c)}</div>`).join("")}</div>`;
1955
+ let d = s && !o ? `<p class="hx-error-text hx-proposal-empty">The spec PRs could not be listed: ${D(s)}</p>` : "";
1956
+ n.innerHTML = `<div class="hx-menu-title hx-menu-head" data-corn="menu-title"><span>${D(a(t, "proposals"))}</span></div>${d}${u}`, z(n);
1957
+ }
1958
+ async function P(e, n) {
1959
+ let r = await Sr(t, e, n);
1960
+ if (p) return;
1961
+ let i = r ? l("proposal-title") : u.querySelector("#proposal-ways [data-way=\"retry\"]");
1962
+ i && (r && (i.tabIndex = -1), i.focus());
1963
+ }
1964
+ function F() {
1965
+ Dr(t), r.canvas && r.canvas.focus();
1966
+ }
1967
+ function L() {
1968
+ t.ask("work:open-specs") !== !0 && (k() || M());
1969
+ }
1970
+ let R = {
1971
+ "toggle-proposals-menu": () => M(),
1972
+ "open-proposal": (e) => Sr(t, e.dataset.slug, e.dataset.source || null),
1973
+ "close-proposal": () => Dr(t),
1974
+ "proposal-whole": () => {
1975
+ ge(t, !(r.review && r.review.whole)), Tr(t);
1976
+ },
1977
+ "proposal-view": (e) => {
1978
+ Or(t, e.dataset.view), E(!1);
1979
+ },
1980
+ "toggle-proposal-mode": () => E(),
1981
+ "toggle-proposal-more": () => C() ? w() : T(),
1982
+ "review-show-changes": () => t.emit("changes:show", "changes"),
1983
+ "review-show-scenarios": () => t.emit("changes:show", "scenarios"),
1984
+ "proposal-way": (e) => e.dataset.way === "open" ? Sr(t, e.dataset.slug, e.dataset.source || null) : e.dataset.way === "retry" ? P(e.dataset.slug, e.dataset.source || null) : e.dataset.way === "close" ? F() : L()
1985
+ };
1986
+ i.listen(t.root, "click", (e) => {
1987
+ let t = e.target.closest ? e.target.closest("[data-action]") : null, n = t && Object.hasOwn(R, t.dataset.action) && R[t.dataset.action];
1988
+ n && n(t), C() && !(t && t.dataset.action === "toggle-proposal-more") && w(!!(t && t.closest("#proposal-more-menu")));
1989
+ let r = l("proposal-wrap");
1990
+ k() && r && !r.contains(e.target) && !(t && t.dataset.action === "proposal-way") && j();
1991
+ }), i.listen(u, "click", (e) => {
1992
+ let n = e.target.closest && e.target.closest("[data-waiting-answer]");
1993
+ n && (e.preventDefault(), e.stopPropagation(), t.emit("work:answer", { run: n.dataset.waitingAnswer }));
1994
+ }, !0);
1995
+ let B = (e) => {
1996
+ let t = l("proposal-wrap");
1997
+ t && (t.hidden = !!e);
1998
+ };
1999
+ i.on("work:available", ({ on: e }) => B(e)), t.ask("work:on") && B(!0), i.listen(t.root, "keydown", (e) => {
2000
+ e.key === "Escape" && k() && j(), O(e);
2001
+ });
2002
+ function ee() {
2003
+ let e = t.tokenElement();
2004
+ if (!e || !e.style) return;
2005
+ let { mark: n } = de(I(r.theme), o(t).get());
2006
+ for (let t of Object.keys(n)) e.style.setProperty(`--hx-mark-${t}`, n[t].color);
2007
+ }
2008
+ ee(), i.on("theme", ee), i.own(o(t).onChange(() => ee())), i.on("proposal:draw", ({ open: e }) => y({ open: e })), i.on("changes:peek", (e) => {
2009
+ l("proposal-peek").textContent = e;
2010
+ }), i.on("proposal:focus-title", () => {
2011
+ let e = l("proposal-title");
2012
+ e.tabIndex = -1, e.focus();
2013
+ }), i.on("proposal:message", (e) => m(e)), i.on("proposal:listing", () => {
2014
+ N(), r.proposal && _();
2015
+ }), i.on("proposal:waiting", ({ run: e, key: t }) => x(e, t)), i.on("proposal:waiting-reset", () => {
2016
+ f = null, d = null;
2017
+ }), i.on("proposal", ({ change: e }) => {
2018
+ e === "opened" && j();
2019
+ }), i.own(Ir(t, (e, t, n) => i.listen(e, t, n))), Dn(t), gn(t, "proposal", u, { stub: () => ({ title: l("proposal-title") && l("proposal-title").textContent || "Proposal" }) }), i.own(() => _n(t, "proposal")), i.own(() => {
2020
+ p = !0, c.forEach((e) => e.remove());
2021
+ }), y();
2022
+ let V = xr(t);
2023
+ return V && !r.proposal && m(V), {
2024
+ elements: c,
2025
+ renderBar: () => Tr(t),
2026
+ paintWaitingLine: x,
2027
+ toggleMenu: M,
2028
+ closeMenu: j,
2029
+ setMessage: (e, n, r) => br(t, e, n, r),
2030
+ sayBadLink: (e) => {
2031
+ let n = xt(e);
2032
+ return n && br(t, n, !0, [{
2033
+ label: a(t, "openSpecsList"),
2034
+ way: "specs"
2035
+ }]), !!n;
2036
+ },
2037
+ update(e) {
2038
+ if (!e || !("proposal" in e || "view" in e)) {
2039
+ Tr(t);
2040
+ return;
2041
+ }
2042
+ let n;
2043
+ if ("proposal" in e) {
2044
+ let i = e.proposal;
2045
+ i === null ? Dr(t) : typeof i == "string" ? n = r.proposal && r.proposalSlug === i && (e.source || null) === (r.proposalSource || null) && r.proposal ? Promise.resolve(!0) : Sr(t, i, e.source || null) : i && typeof i == "object" && Cr(t, i, {
2046
+ slug: e.slug || null,
2047
+ source: e.source || null,
2048
+ pinSource: !!e.source,
2049
+ view: tt.includes(e.view) ? e.view : "diff",
2050
+ sha256: e.sha256 || null
2051
+ });
2052
+ }
2053
+ return "view" in e && tt.includes(e.view) && !(typeof e.proposal == "string" && n) ? Or(t, e.view, { quiet: !0 }) : "view" in e && n && (n = n.then((n) => (n && tt.includes(e.view) && Or(t, e.view, { quiet: !0 }), n))), n;
2054
+ },
2055
+ pinnedSource: () => Lr(t),
2056
+ destroy: () => i.destroy()
2057
+ };
2058
+ }
2059
+ var Gr = (e) => e === void 0 ? null : Array.isArray(e) ? e : [e], Kr = (e) => !e.kind && !e.dashed;
2060
+ function qr(e, t) {
2061
+ if (!t) return null;
2062
+ let n = V(t);
2063
+ return e.find((e) => e.type === "persona" && (e.id === n || e.id === t)) || null;
2064
+ }
2065
+ function Jr(e) {
2066
+ return e.account === !1 ? { account: !1 } : {
2067
+ role: e.role,
2068
+ groups: Array.isArray(e.groups) ? [...e.groups] : []
2069
+ };
2070
+ }
2071
+ var Yr = (e) => e ? e.codeLabel || e.label || e.id : "";
2072
+ function Xr(e, t) {
2073
+ let n = new Map(e.map((e) => [e.id, e])), r = /* @__PURE__ */ new Map();
2074
+ for (let e of t) Kr(e) && !r.has(e.to) && r.set(e.to, e.from);
2075
+ return {
2076
+ nodes: e,
2077
+ byId: n,
2078
+ owner: r
2079
+ };
2080
+ }
2081
+ function Zr(e, t) {
2082
+ let n = e.byId.get(t);
2083
+ return n ? n.type === "table" && (n.table || n.label) || null : typeof t == "string" && t.startsWith("table-") ? t.slice(6) : null;
2084
+ }
2085
+ function Qr(e, t, n) {
2086
+ return !t || t.type !== "page" || !Array.isArray(t.methods) || t.methods.length === 0 ? !1 : !n || !Array.isArray(n.apps) || n.apps.includes(e.owner.get(t.id));
2087
+ }
2088
+ function $r(e, t, n) {
2089
+ let r = Gr(e && e.check);
2090
+ if (r) return r.map((e) => ({ ...e }));
2091
+ if (!e) return [];
2092
+ if (e.node !== void 0) {
2093
+ let r = t.byId.get(e.node);
2094
+ if (!Qr(t, r, n)) return [];
2095
+ let i = r.methods.map((e) => String(e).toUpperCase());
2096
+ return [{
2097
+ route: r.label,
2098
+ method: i.includes("GET") ? "GET" : i[0]
2099
+ }];
2100
+ }
2101
+ if (e.edge && e.edge.kind === "writes") {
2102
+ let n = Zr(t, e.edge.to);
2103
+ return n ? [{
2104
+ table: n,
2105
+ op: "write"
2106
+ }] : [];
2107
+ }
2108
+ if (e.edge && e.edge.kind === "reads") {
2109
+ let n = Zr(t, e.edge.from);
2110
+ return n ? [{
2111
+ table: n,
2112
+ op: "read"
2113
+ }] : [];
2114
+ }
2115
+ return [];
2116
+ }
2117
+ function ei(e, t, n, { as: r = null } = {}) {
2118
+ let i = [], a = [];
2119
+ return (e && Array.isArray(e.steps) ? e.steps : []).forEach((o, s) => {
2120
+ let c = r || o.actor || e.actor || null, l = {
2121
+ index: s,
2122
+ actor: c,
2123
+ actorLabel: "",
2124
+ kind: "none",
2125
+ checks: [],
2126
+ expect: o.expect
2127
+ };
2128
+ if (i.push(l), !c) return;
2129
+ let u = qr(t.nodes, c);
2130
+ if (l.actorLabel = u ? Yr(u) : c, !u) {
2131
+ l.kind = "unchecked", l.why = `no persona "${c}" on the map`;
2132
+ return;
2133
+ }
2134
+ let d = $r(o, t, n);
2135
+ if (d.length === 0) {
2136
+ l.kind = "unchecked", l.why = Array.isArray(o.check) ? "this step is not a permission question" : "nothing in this step to ask";
2137
+ return;
2138
+ }
2139
+ l.kind = "ask";
2140
+ let f = Jr(u);
2141
+ l.checks = d.map((e, t) => ({
2142
+ id: `s${s + 1}-${t + 1}`,
2143
+ ...e
2144
+ })), l.checks.forEach((e) => a.push({
2145
+ ...e,
2146
+ actor: f
2147
+ }));
2148
+ }), {
2149
+ steps: i,
2150
+ items: a,
2151
+ key: JSON.stringify(a)
2152
+ };
2153
+ }
2154
+ function ti(e, t = {}) {
2155
+ let n = Error(t.message || e);
2156
+ return n.reason = e, Object.assign(n, t), n;
2157
+ }
2158
+ async function ni(e, t, { signal: n } = {}) {
2159
+ let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
2160
+ if (!e) throw ti("no-checker", { message: "no permission checker" });
2161
+ let a = e.max > 0 ? e.max : 100, o = t.slice();
2162
+ for (; o.length;) {
2163
+ let t = o.slice(0, a), s;
2164
+ try {
2165
+ s = await e.check(t, { signal: n });
2166
+ } catch (e) {
2167
+ let n = e && e.reason === "bad-check" ? e.checkId : null;
2168
+ if (n && t.some((e) => e.id === n)) {
2169
+ i.set(n, e.message || "the checker refused this check"), o = o.filter((e) => e.id !== n);
2170
+ continue;
2171
+ }
2172
+ throw e;
2173
+ }
2174
+ for (let e of s || []) e && typeof e.id == "string" && r.set(e.id, e);
2175
+ o = o.slice(t.length);
2176
+ }
2177
+ return {
2178
+ results: r,
2179
+ bad: i
2180
+ };
2181
+ }
2182
+ function ri(e, t) {
2183
+ let n = {
2184
+ mismatch: !1,
2185
+ actor: e ? e.actorLabel : "",
2186
+ checks: []
2187
+ };
2188
+ if (!e || e.kind === "none") return {
2189
+ ...n,
2190
+ state: "none"
2191
+ };
2192
+ if (e.expect && (n.expect = e.expect), e.kind === "unchecked") return {
2193
+ ...n,
2194
+ state: "unchecked",
2195
+ why: e.why
2196
+ };
2197
+ if (!t || t.status === "idle" || t.status === "pending") return {
2198
+ ...n,
2199
+ state: "pending",
2200
+ checks: e.checks
2201
+ };
2202
+ if (t.status === "failed") return {
2203
+ ...n,
2204
+ state: "unavailable",
2205
+ why: ii(t.error),
2206
+ checks: e.checks
2207
+ };
2208
+ let r = e.checks.map((e) => ({
2209
+ ...e,
2210
+ result: t.results.get(e.id) || null
2211
+ })), i = e.checks.find((e) => t.bad && t.bad.has(e.id));
2212
+ if (i) return {
2213
+ ...n,
2214
+ state: "unchecked",
2215
+ why: t.bad.get(i.id),
2216
+ checks: r
2217
+ };
2218
+ if (r.some((e) => !e.result)) return {
2219
+ ...n,
2220
+ state: "unavailable",
2221
+ why: "the checker gave no answer for this step",
2222
+ checks: r
2223
+ };
2224
+ let a = r.find((e) => e.result.allowed !== !0), o = a ? "refused" : "allowed", s = {
2225
+ ...n,
2226
+ state: o,
2227
+ checks: r
2228
+ };
2229
+ return a && (s.reason = a.result.reason || `refused (${a.result.status})`, a.result.rule && (s.rule = a.result.rule)), s.mismatch = !!e.expect && e.expect !== o, s;
2230
+ }
2231
+ function ii(e) {
2232
+ let t = e && e.reason;
2233
+ return t === "no-checker" ? "no permission checker" : t === "no-token" ? `no token${e.hint ? ` (${e.hint})` : ""}` : t === "forbidden" ? "the token is not an admin's" : "the checker is not answering";
2234
+ }
2235
+ function ai(e) {
2236
+ return e.route === void 0 ? [
2237
+ e.table,
2238
+ e.op,
2239
+ e.row
2240
+ ].filter(Boolean).join(" · ") : `${String(e.method || "").toUpperCase()} ${e.route}`;
2241
+ }
2242
+ function oi(e) {
2243
+ if (!e || e.state === "none") return null;
2244
+ let t = e.actor ? ` as ${e.actor}` : "", n = e.checks.map(ai).join(", "), r = n ? `${n}${t}` : e.actor ? `As ${e.actor}` : "", i = () => `${e.reason}${e.rule ? ` (${e.rule})` : ""}`;
2245
+ if (e.state === "pending") return {
2246
+ tone: "pending",
2247
+ pill: "Checking…",
2248
+ line: `Checking${t}…`,
2249
+ detail: r
2250
+ };
2251
+ if (e.state === "unchecked") return {
2252
+ tone: "unchecked",
2253
+ pill: "Not checked",
2254
+ line: `Not checked: ${e.why}`,
2255
+ detail: r
2256
+ };
2257
+ if (e.state === "unavailable") return {
2258
+ tone: "unavailable",
2259
+ pill: "Unavailable",
2260
+ line: `Not checked: live layer unavailable (${e.why})`,
2261
+ detail: r
2262
+ };
2263
+ if (e.mismatch) {
2264
+ let t = e.state === "refused" ? `Expected allowed, but refused: ${i()}` : "Expected refused, but allowed";
2265
+ return {
2266
+ tone: "mismatch",
2267
+ pill: `Expected ${e.expect}`,
2268
+ line: t,
2269
+ detail: r
2270
+ };
2271
+ }
2272
+ return e.state === "refused" ? {
2273
+ tone: "refused",
2274
+ pill: "✕ Refused",
2275
+ line: `Refused: ${i()}`,
2276
+ detail: r
2277
+ } : {
2278
+ tone: "allowed",
2279
+ pill: "✓ Allowed",
2280
+ line: "Allowed",
2281
+ detail: r
2282
+ };
2283
+ }
2284
+ // ../explorer/engine/checks.js
2285
+ var si = (e) => !!e && (!!e.actor || Array.isArray(e.steps) && e.steps.some((e) => e && e.actor));
2286
+ function ci(e, t = {}) {
2287
+ let { state: n } = e, r = t.checker || null, i = null, a = 0, o = /* @__PURE__ */ new WeakMap(), s = [];
2288
+ function c() {
2289
+ i && i.controller && i.controller.abort(), i = null, a++;
2290
+ }
2291
+ function l(e) {
2292
+ e ||= null, e !== r && c(), r = e;
2293
+ }
2294
+ function u() {
2295
+ let e = i;
2296
+ if (!e) return;
2297
+ e.controller && e.controller.abort();
2298
+ let t = e.plan.items;
2299
+ if (t.length === 0) {
2300
+ e.answer = {
2301
+ status: "ok",
2302
+ results: /* @__PURE__ */ new Map(),
2303
+ bad: /* @__PURE__ */ new Map()
2304
+ }, a++;
2305
+ return;
2306
+ }
2307
+ let n = new AbortController();
2308
+ e.controller = n, e.answer = { status: "pending" }, a++, ni(r, t, { signal: n.signal }).then(({ results: t, bad: r }) => d(e, n, {
2309
+ status: "ok",
2310
+ results: t,
2311
+ bad: r
2312
+ }), (t) => {
2313
+ n.signal.aborted || d(e, n, {
2314
+ status: "failed",
2315
+ error: t
2316
+ });
2317
+ });
2318
+ }
2319
+ function d(e, t, n) {
2320
+ i === e && e.controller === t && (e.controller = null, e.answer = n, a++, e.onChange());
2321
+ }
2322
+ function f(e, t = !1) {
2323
+ let o = i;
2324
+ if (!o || !t && o.scenario === e && o.nodes === n.nodes && o.plan) return;
2325
+ let s = o.plan ? o.plan.key : null;
2326
+ o.scenario = e, o.nodes = n.nodes, o.plan = ei(e, Xr(n.nodes, n.edges), r, { as: o.as }), a++, (t || o.plan.key !== s) && u();
2327
+ }
2328
+ function p(t, r = () => {}) {
2329
+ i && i.scenario && t && i.scenario.id === t.id ? (i.onChange = r, f(t)) : (c(), i = {
2330
+ scenario: null,
2331
+ as: null,
2332
+ nodes: null,
2333
+ plan: null,
2334
+ answer: { status: "idle" },
2335
+ controller: null,
2336
+ onChange: r
2337
+ }, si(t) && h(n).persona !== !0 && xe(e, "persona", !0, { scenario: !0 }), f(t));
2338
+ }
2339
+ function m(e, t) {
2340
+ if (!i) return e;
2341
+ f(t);
2342
+ let n = i.plan.steps[e.index];
2343
+ return e.verdict = ri(n, i.answer), i.as && n && n.actor && (e.current.actor = n.actor), e;
2344
+ }
2345
+ function g() {
2346
+ return !i || !i.plan ? [] : i.plan.steps.map((e) => ri(e, i.answer));
2347
+ }
2348
+ function _(e) {
2349
+ i && (i.as = e || null, f(i.scenario, !0), i.onChange());
2350
+ }
2351
+ function v() {
2352
+ i && (f(i.scenario, !0), i.onChange());
2353
+ }
2354
+ function y(t) {
2355
+ let n = e.doc, r = n.createElement("span");
2356
+ r.className = "hx-player-verdict", r.dataset.corn = "state-pill", r.hidden = !0;
2357
+ let i = t.querySelector(".hx-player-text");
2358
+ i ? i.append(" ", r) : t.prepend(r);
2359
+ let a = n.createElement("p");
2360
+ a.className = "hx-player-check", a.dataset.corn = "scenario-check", a.hidden = !0;
2361
+ let o = n.createElement("div");
2362
+ o.className = "hx-player-as", o.innerHTML = "\n <label class=\"hx-player-as-label\">As <select data-corn=\"control\" class=\"hx-player-speed hx-player-as-menu\" data-check=\"as\" aria-label=\"Act every step as\"></select></label>\n <button data-corn-kind=\"secondary\" type=\"button\" class=\"hx-btn\" data-check=\"recheck\">Check again</button>\n <span class=\"hx-player-as-sum hx-faint\"></span>";
2363
+ let c = t.querySelector(".hx-player-track");
2364
+ c ? (c.before(a), c.before(o)) : (t.appendChild(a), t.appendChild(o));
2365
+ for (let e of [
2366
+ r,
2367
+ a,
2368
+ o
2369
+ ]) e.hasAttribute("data-corn") && e.setAttribute("part", e.getAttribute("data-corn"));
2370
+ z(o);
2371
+ let l = o.querySelector("[data-check=as]"), u = o.querySelector("[data-check=recheck]"), d = (e) => _(e.target.value);
2372
+ l.addEventListener("change", d), u.addEventListener("click", v), s.push(() => {
2373
+ l.removeEventListener("change", d), u.removeEventListener("click", v);
2374
+ });
2375
+ }
2376
+ function b() {
2377
+ let e = s;
2378
+ s = [], e.forEach((e) => e());
2379
+ }
2380
+ function x(e) {
2381
+ let t = [{
2382
+ value: "",
2383
+ label: "As written"
2384
+ }, ...n.nodes.filter((e) => e.type === "persona").map((e) => ({
2385
+ value: e.id.replace(/^persona-/, ""),
2386
+ label: Yr(e)
2387
+ }))], r = t.map((e) => `${e.value}\u0000${e.label}`).join("");
2388
+ e.dataset.key !== r && (e.innerHTML = t.map((e) => `<option value="${D(e.value)}">${D(e.label)}</option>`).join(""), e.dataset.key = r), e.value = i && i.as ? i.as : "";
2389
+ }
2390
+ function S() {
2391
+ let e = g(), t = e.reduce((e, t) => e + t.checks.length, 0);
2392
+ if (!i || i.answer.status === "pending") return t ? `Checking ${t}…` : "";
2393
+ if (i.answer.status === "failed") return "";
2394
+ let n = e.filter((e) => e.state === "refused").length, r = e.filter((e) => e.mismatch).length, a = [`${t} ${t === 1 ? "check" : "checks"}`];
2395
+ return n && a.push(`${n} refused`), r && a.push(`${r} not as expected`), t ? a.join(" · ") : "No permission questions";
2396
+ }
2397
+ function C(e, t) {
2398
+ if (!e || !i) return;
2399
+ if (!e.querySelector(".hx-player-as")) {
2400
+ if (!si(i.scenario)) return;
2401
+ y(e);
2402
+ }
2403
+ let n = e.querySelector(".hx-player-verdict"), r = e.querySelector(".hx-player-check"), a = e.querySelector(".hx-player-as");
2404
+ if (!n || !r || !a) return;
2405
+ let s = t.done ? null : oi(t.verdict);
2406
+ if (n.hidden = !s, r.hidden = !s, s) {
2407
+ n.dataset.tone = s.tone, Ye(s.tone) ? n.dataset.cornState = Ye(s.tone) : delete n.dataset.cornState, n.textContent = s.pill, n.title = s.line, r.dataset.tone = s.tone;
2408
+ let e = `${D(s.line)}${s.detail ? ` <span class="hx-player-check-detail">${D(s.detail)}</span>` : ""}`;
2409
+ o.get(r) !== e && (o.set(r, e), r.innerHTML = e);
2410
+ }
2411
+ x(a.querySelector("[data-check=as]")), a.querySelector("[data-check=recheck]").disabled = i.answer.status === "pending", a.querySelector(".hx-player-as-sum").textContent = S();
2412
+ }
2413
+ return {
2414
+ setChecker: l,
2415
+ open: p,
2416
+ close: c,
2417
+ decorate: m,
2418
+ paint: C,
2419
+ unmount: b,
2420
+ verdicts: g,
2421
+ chooseActor: _,
2422
+ recheck: v,
2423
+ version: () => a,
2424
+ checkedScenarioId: () => i && i.scenario ? i.scenario.id : null
2425
+ };
2426
+ }
2427
+ // ../explorer/scenario.js
2428
+ var li = 5e3, ui = "topology.scenarioSpeed", di = [
2429
+ {
2430
+ value: "2000",
2431
+ label: "2 s"
2432
+ },
2433
+ {
2434
+ value: "5000",
2435
+ label: "5 s"
2436
+ },
2437
+ {
2438
+ value: "10000",
2439
+ label: "10 s"
2440
+ },
2441
+ {
2442
+ value: "manual",
2443
+ label: "Manual"
2444
+ }
2445
+ ];
2446
+ function fi(e) {
2447
+ let t = di.find((t) => t.value === e);
2448
+ return t ? t.value === "manual" ? "manual" : Number(t.value) : li;
2449
+ }
2450
+ function pi(e, t = li) {
2451
+ let n = e && e.ms;
2452
+ return typeof n == "number" && n > 0 && Number.isFinite(n) ? n : t;
2453
+ }
2454
+ var mi = (e) => e && Array.isArray(e.steps) ? e.steps : [];
2455
+ function hi(e) {
2456
+ let t = e && Array.isArray(e.down) ? e.down : [];
2457
+ return [...new Set(t.filter((e) => typeof e == "string" && e !== ""))];
2458
+ }
2459
+ function gi(e, t) {
2460
+ return t && t.actor || e && e.actor || null;
2461
+ }
2462
+ function _i(e, t = {}) {
2463
+ let n = e, r = t.stepMs, i = () => r === "manual", a = () => n.stepMs ?? (typeof r == "number" && r > 0 ? r : 5e3), o = t.maxFrameMs ?? Infinity, s = 0, c = !1, l = mi(e).length === 0, u = 0, d = null, f = null, p = () => mi(n), m = () => p().length - 1, h = (e) => pi(p()[e], a()), g = (e) => Math.max(0, Math.min(Math.max(0, m()), e)), _ = () => {
2464
+ s = 0, l = p().length === 0, u = 0, d = null, f = null;
2465
+ }, v = () => {
2466
+ c = !1, d = null, f = null;
2467
+ };
2468
+ return {
2469
+ play() {
2470
+ p().length === 0 || i() || (l && _(), c || (c = !0, d = null));
2471
+ },
2472
+ pause() {
2473
+ v();
2474
+ },
2475
+ isPlaying: () => c,
2476
+ next() {
2477
+ v(), s < m() ? (s++, u = 0) : p().length && (l = !0);
2478
+ },
2479
+ prev() {
2480
+ v(), l = !1, s > 0 && (s--, u = 0);
2481
+ },
2482
+ goTo(e) {
2483
+ if (v(), !Number.isFinite(e)) return;
2484
+ let t = g(Math.floor(e));
2485
+ t !== s && (s = t, u = 0), l = !1;
2486
+ },
2487
+ stop() {
2488
+ v(), _();
2489
+ },
2490
+ setSpeed(e) {
2491
+ r = e, i() && v();
2492
+ },
2493
+ scenario: () => n,
2494
+ setScenario(e) {
2495
+ n = e, s = g(s), p().length === 0 && (l = !0);
2496
+ },
2497
+ tick(e) {
2498
+ if (!c || i()) return;
2499
+ if (d === null) {
2500
+ d = e, f = e - u;
2501
+ return;
2502
+ }
2503
+ let t = Math.max(0, e - d);
2504
+ for (u += Math.min(t, o), t > o && (f = e - u), d = e; u >= h(s);) {
2505
+ if (s >= m()) {
2506
+ u = h(s), l = !0, v();
2507
+ return;
2508
+ }
2509
+ u -= h(s), f += h(s), s++;
2510
+ }
2511
+ },
2512
+ snapshot() {
2513
+ let e = p(), t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), a = [];
2514
+ for (let n = 0; n <= s && n < e.length; n++) {
2515
+ let i = e[n];
2516
+ if (i.node !== void 0 && t.add(i.node), i.at !== void 0 && t.add(i.at), i.edge) {
2517
+ t.add(i.edge.from), t.add(i.edge.to);
2518
+ let e = X(i.edge);
2519
+ r.has(e) || (r.add(e), a.push({ ...i.edge }));
2520
+ }
2521
+ }
2522
+ let o = e[s], d = { text: o ? String(o.text ?? "") : "" };
2523
+ o && o.node !== void 0 && (d.node = o.node), o && o.edge && (d.edge = { ...o.edge }, d.edgeKey = X(o.edge));
2524
+ let m = gi(n, o);
2525
+ m && (d.actor = m), o && o.at !== void 0 && (d.at = o.at), o && o.check !== void 0 && (d.check = JSON.parse(JSON.stringify(o.check))), o && o.expect !== void 0 && (d.expect = o.expect);
2526
+ let g = h(s);
2527
+ return {
2528
+ id: n.id,
2529
+ title: n.title,
2530
+ total: e.length,
2531
+ index: s,
2532
+ playing: c,
2533
+ done: l,
2534
+ visited: {
2535
+ nodes: t,
2536
+ edges: r,
2537
+ edgeList: a
2538
+ },
2539
+ current: d,
2540
+ progress: l ? 1 : i() ? 0 : Math.min(1, u / g),
2541
+ manual: i(),
2542
+ stepMs: g,
2543
+ stepStartMs: f,
2544
+ linkNodes: !!n.linkNodes,
2545
+ down: hi(n)
2546
+ };
2547
+ }
2548
+ };
2549
+ }
2550
+ function vi(e, t, n, r, i = 60, a = se) {
2551
+ if (!n.width || !n.height) return null;
2552
+ let o = e.node === void 0 ? e.edge ? [e.edge.from, e.edge.to] : [] : [e.node], s = o.map((e) => r.get(e));
2553
+ if (s.length === 0 || s.some((e) => !e)) return null;
2554
+ e.at !== void 0 && r.has(e.at) && !o.includes(e.at) && s.push(r.get(e.at));
2555
+ let c = {
2556
+ x: n.x || 0,
2557
+ y: n.y || 0,
2558
+ width: n.width,
2559
+ height: n.height
2560
+ }, l = P(s, c, {
2561
+ padding: i,
2562
+ maxZoom: Math.max(1, t.zoom),
2563
+ minZoom: a
2564
+ });
2565
+ return kn(s, t, c, Math.min(i, c.width / 4, c.height / 4)) && t.zoom >= l.zoom - .001 ? null : l;
2566
+ }
2567
+ // ../explorer/outage-scenario.js
2568
+ function yi(e, t) {
2569
+ if (!e) return [];
2570
+ let n = new Map(t.map((e) => [e.id, e])), r = /* @__PURE__ */ new Set();
2571
+ for (let t of [...e.down, ...e.hits.keys()]) {
2572
+ let e = n.get(t);
2573
+ e && r.add(e.type === "external" ? S(e) : e.type);
2574
+ }
2575
+ return [...r];
2576
+ }
2577
+ var bi = 3, xi = " (in the visitor's browser)";
2578
+ function Si(e) {
2579
+ if (e.length < 2) return e.join("");
2580
+ let t = e.some((e) => e.includes(" and ")) ? ", and " : " and ";
2581
+ return `${e.slice(0, -1).join(", ")}${t}${e[e.length - 1]}`;
2582
+ }
2583
+ function Ci(e) {
2584
+ let t = /* @__PURE__ */ new Map();
2585
+ for (let n of e) t.has(n.type) || t.set(n.type, []), t.get(n.type).push(n);
2586
+ return Si([...t].sort(([e, t], [n, r]) => r.length - t.length || d(e) - d(n) || e.localeCompare(n)).map(([e, t]) => {
2587
+ let n = Fn(e, t.length);
2588
+ if (t.length > bi) {
2589
+ let e = t.filter((e) => e.browser).length;
2590
+ return `${t.length} ${n}${e === t.length ? xi : e ? ` (${e} in the visitor's browser)` : ""}`;
2591
+ }
2592
+ return `the ${n} ${Si(t.map((e) => `${e.label}${e.browser ? xi : ""}`))}`;
2593
+ }));
2594
+ }
2595
+ function wi(e, t, n) {
2596
+ let r = new Map(t.map((e) => [e.id, e])), i = String(e.label || e.id), a = x([e.id], t, n), o = (e) => (t) => a.hits.has(t.id) && a.hits.get(t.id).when === e, s = new Map(In(e, t, n).map((e) => [e.when, e.types.flatMap((e) => e.items).filter(o(e.when)).map((e) => ({
2597
+ ...e,
2598
+ browser: a.hits.get(e.id).browser
2599
+ }))])), c = [
2600
+ `${i} is down.`,
2601
+ e.breaks ? String(e.breaks) : "",
2602
+ a.groups.length ? "" : "Nothing on the map uses it."
2603
+ ].filter(Boolean).join(" "), l = [{
2604
+ node: e.id,
2605
+ text: c
2606
+ }];
2607
+ for (let t of a.groups) {
2608
+ let n = s.get(t.when) || [], i = new Set(n.map((e) => e.id)), o = t.ids.filter((e) => !i.has(e)).map((e) => {
2609
+ let t = r.get(e);
2610
+ return {
2611
+ id: e,
2612
+ label: String(t.label || e),
2613
+ type: t.type,
2614
+ browser: a.hits.get(e).browser
2615
+ };
2616
+ }), c;
2617
+ c = n.length ? `${t.title}: ${Ci(n)}.${o.length ? ` Through ${n.length === 1 ? "it" : "them"}: ${Ci(o)}.` : ""}` : `${t.title}, through what uses it: ${Ci(o)}.`, l.push(n.length ? {
2618
+ edge: {
2619
+ from: n[0].id,
2620
+ to: e.id,
2621
+ kind: "calls"
2622
+ },
2623
+ text: c
2624
+ } : {
2625
+ node: t.ids[0],
2626
+ text: c
2627
+ });
2628
+ }
2629
+ return {
2630
+ id: `outage-${e.id}`,
2631
+ title: `${i} is down`,
2632
+ down: [e.id],
2633
+ steps: l
2634
+ };
2635
+ }
2636
+ // ../explorer/scenario-list-model.js
2637
+ var Ti = (e) => Array.isArray(e) ? e : [], Ei = (e, t) => `${e} ${t}${e === 1 ? "" : "s"}`, Di = (e) => String(e ?? "").replace(/[^A-Za-z0-9_-]+/g, "_") || "_", Oi = (e) => String(e.id).replace(/^persona-/, ""), ki = (e) => e.codeLabel || e.label || Oi(e);
2638
+ function Ai(e, t, n) {
2639
+ let r = new Set([
2640
+ "add",
2641
+ "change",
2642
+ "remove"
2643
+ ].flatMap((e) => Ti(n?.edges?.[e]).map(X))), i = (t) => (e.find((e) => e.id === t) || { label: t }).label || t, a = [];
2644
+ for (let n of [...nt, "edit"]) {
2645
+ for (let t of e.filter((e) => e.mark === n)) a.push({
2646
+ kind: "node",
2647
+ key: t.id,
2648
+ mark: n,
2649
+ word: mt[n],
2650
+ name: String(t.label ?? t.id),
2651
+ type: String(t.type ?? "")
2652
+ });
2653
+ for (let e of t.filter((e) => e.mark === n && r.has(X(e)))) a.push({
2654
+ kind: "edge",
2655
+ key: X(e),
2656
+ mark: n,
2657
+ word: mt[n],
2658
+ name: `${i(e.from)} → ${i(e.to)}`,
2659
+ type: String(e.kind || "ownership")
2660
+ });
2661
+ }
2662
+ return a;
2663
+ }
2664
+ function ji(e) {
2665
+ let t = [], n = (e) => {
2666
+ typeof e == "string" && e && !t.includes(e) && t.push(e);
2667
+ };
2668
+ n(e?.actor);
2669
+ for (let t of Ti(e?.steps)) n(t?.actor);
2670
+ return t;
2671
+ }
2672
+ function Mi(e, t = {}) {
2673
+ let n = t.notChecked || "Not checked";
2674
+ return !e || e.state === "none" ? null : e.state === "pending" ? {
2675
+ words: "Checking…",
2676
+ state: "",
2677
+ tone: "pending"
2678
+ } : e.state === "unchecked" ? {
2679
+ words: `${n}: ${e.why || "nothing to ask"}`,
2680
+ state: "",
2681
+ tone: "unchecked"
2682
+ } : e.state === "unavailable" ? {
2683
+ words: `${n}: the checker did not answer${e.why ? ` (${e.why})` : ""}`,
2684
+ state: "",
2685
+ tone: "unavailable"
2686
+ } : e.mismatch ? {
2687
+ words: e.state === "refused" ? `Expected allowed, was refused${e.reason ? `: ${e.reason}` : ""}` : "Expected refused, was allowed",
2688
+ state: "failure",
2689
+ tone: "mismatch"
2690
+ } : e.state === "refused" ? {
2691
+ words: `Refused: ${e.reason || "no reason given"}`,
2692
+ state: e.expect === "refused" ? "success" : "failure",
2693
+ tone: "refused"
2694
+ } : {
2695
+ words: "Allowed",
2696
+ state: "success",
2697
+ tone: "allowed"
2698
+ };
2699
+ }
2700
+ function Ni(e, t) {
2701
+ return Ti(e.steps).map((n, r) => {
2702
+ let i = n && n.actor || e.actor || null, a = "", o = "", s = [];
2703
+ if (n && n.edge) {
2704
+ a = `${t.label(n.edge.from)} → ${t.label(n.edge.to)}`, s = [
2705
+ `edge:${X(n.edge)}`,
2706
+ `node:${n.edge.from}`,
2707
+ `node:${n.edge.to}`
2708
+ ];
2709
+ let e = t.edges.find((e) => X(e) === X(n.edge));
2710
+ e && e.mark && e.mark !== "none" && t.changeKeys.has(`edge:${X(e)}`) && (o = e.mark);
2711
+ } else if (n && n.node !== void 0) {
2712
+ a = t.label(n.node), s = [`node:${n.node}`];
2713
+ let e = t.nodes.find((e) => e.id === n.node);
2714
+ e && e.mark && e.mark !== "none" && (o = e.mark);
2715
+ }
2716
+ let c = t.verdicts ? Mi(t.verdicts[r], t.words) : null, l = !!t.hidden && s.some((e) => e.startsWith("node:") && t.hidden(e.slice(5)));
2717
+ return {
2718
+ index: r,
2719
+ number: r + 1,
2720
+ actor: i,
2721
+ actorLabel: i ? t.personaLabel(i) : "",
2722
+ where: a,
2723
+ mark: o,
2724
+ markWord: o && mt[o] || "",
2725
+ text: String((n && n.text) ?? ""),
2726
+ verdict: i ? c : null,
2727
+ layerOff: l,
2728
+ touched: s
2729
+ };
2730
+ });
2731
+ }
2732
+ function Pi(e, t) {
2733
+ let n = [
2734
+ e.where,
2735
+ e.markWord,
2736
+ e.layerOff ? "on a layer that is off" : ""
2737
+ ].filter(Boolean).join(", ");
2738
+ return [
2739
+ `Step ${e.number} of ${t}${e.actorLabel ? `, as ${e.actorLabel}` : ""}${n ? `: ${n}` : ""}.`,
2740
+ e.text,
2741
+ e.verdict ? `${e.verdict.words}${/[.!?…]$/.test(e.verdict.words) ? "" : "."}` : ""
2742
+ ].filter(Boolean).join(" ");
2743
+ }
2744
+ function Fi({ snap: e, nodes: t, edges: n, words: r = {} }) {
2745
+ let i = e.current || {}, a = (e) => String((t.find((t) => t.id === e) || { label: e }).label ?? e), o = i.actor ? t.find((e) => e.type === "persona" && (e.id === `persona-${i.actor}` || e.id === i.actor)) : null, s = "", c = "";
2746
+ if (i.edge) {
2747
+ s = `${a(i.edge.from)} → ${a(i.edge.to)}`;
2748
+ let e = n.find((e) => X(e) === X(i.edge));
2749
+ e && e.mark && e.mark !== "none" && (c = e.mark);
2750
+ } else if (i.node !== void 0) {
2751
+ s = a(i.node);
2752
+ let e = t.find((e) => e.id === i.node);
2753
+ e && e.mark && e.mark !== "none" && (c = e.mark);
2754
+ }
2755
+ let l = i.actor ? Mi(e.verdict, r) : null;
2756
+ return Pi({
2757
+ number: e.index + 1,
2758
+ actorLabel: i.actor ? o ? ki(o) : String(i.actor) : "",
2759
+ where: s,
2760
+ markWord: c && mt[c] || "",
2761
+ text: String(i.text ?? ""),
2762
+ verdict: l
2763
+ }, e.total);
2764
+ }
2765
+ function Ii(e) {
2766
+ let t = (t) => e.filter((e) => e.verdict && e.verdict.tone === t).length;
2767
+ return [
2768
+ [t("allowed"), "allowed"],
2769
+ [t("refused"), "refused"],
2770
+ [t("mismatch"), "not as expected"]
2771
+ ].filter(([e]) => e > 0).map(([e, t]) => `${e} ${t}`).join(" · ");
2772
+ }
2773
+ function Li({ scenarios: e, nodes: t, edges: n, proposal: r = null, verdicts: i = null, seen: a = null, words: o = {}, hidden: s = null }) {
2774
+ let c = Ti(e), l = t.filter((e) => e.type === "persona"), u = new Map(l.map((e) => [Oi(e), e])), d = (e) => String((t.find((t) => t.id === e) || { label: e }).label ?? e), f = (e) => u.has(e) ? ki(u.get(e)) : String(e), p = Ai(t, n, r), m = new Set(p.map((e) => `${e.kind}:${e.key}`)), h = new Set(Ti(a?.played)), g = new Set(Ti(a?.read)), _ = c.map((e, r) => {
2775
+ let a = i && i.get(e.id), c = Ni(e, {
2776
+ nodes: t,
2777
+ edges: n,
2778
+ changeKeys: m,
2779
+ verdicts: a || null,
2780
+ words: o,
2781
+ label: d,
2782
+ personaLabel: f,
2783
+ hidden: s
2784
+ }), l = new Set(c.flatMap((e) => e.touched).filter((e) => m.has(e))), u = c.length, p = [Ei(u, "step")];
2785
+ m.size > 0 && p.push(`walks ${l.size} of ${Ei(m.size, "change")}`);
2786
+ let _ = Ii(c);
2787
+ return {
2788
+ index: r,
2789
+ id: String(e.id ?? ""),
2790
+ key: `${r}-${Di(e.id)}`,
2791
+ title: String(e.title ?? e.id ?? ""),
2792
+ actors: ji(e),
2793
+ steps: c,
2794
+ stepCount: u,
2795
+ summary: p.join(" · "),
2796
+ verdictSummary: _,
2797
+ seen: h.has(String(e.id)) ? "played" : g.has(String(e.id)) ? "read" : ""
2798
+ };
2799
+ }), v = [...u.keys()];
2800
+ for (let e of _) for (let t of e.actors) v.includes(t) || v.push(t);
2801
+ let y = [];
2802
+ for (let e of v) {
2803
+ let t = _.filter((t) => t.actors.includes(e));
2804
+ if (!t.length) continue;
2805
+ let n = f(e);
2806
+ y.push({
2807
+ key: Di(e),
2808
+ persona: e,
2809
+ label: n,
2810
+ anyone: !1,
2811
+ heading: `${n} · ${Ei(t.length, "scenario")}`,
2812
+ scenarios: t
2813
+ });
2814
+ }
2815
+ let b = _.filter((e) => e.actors.length === 0);
2816
+ b.length && y.push({
2817
+ key: "anyone",
2818
+ persona: null,
2819
+ label: "Anyone",
2820
+ anyone: !0,
2821
+ heading: `Anyone · ${Ei(b.length, "scenario")}`,
2822
+ scenarios: b
2823
+ });
2824
+ let x = new Set(_.flatMap((e) => e.actors)), S = _.length ? l.filter((e) => !x.has(Oi(e))).map(ki) : [], C = _.filter((e) => e.seen === "played").length;
2825
+ return {
2826
+ total: _.length,
2827
+ personaCount: y.filter((e) => !e.anyone).length,
2828
+ groups: y,
2829
+ notInAny: S,
2830
+ coverage: S.length ? `Not in any scenario: ${S.join(", ")}` : "",
2831
+ playedLine: _.length && C ? `${C} of ${_.length} ${_.length === 1 ? "scenario" : "scenarios"} played` : ""
2832
+ };
2833
+ }
2834
+ function Ri(e, t) {
2835
+ let n = [Ei(e, "change")];
2836
+ return t.total > 0 && n.push(`${Ei(t.total, "scenario")}${t.personaCount > 0 ? ` for ${Ei(t.personaCount, "persona")}` : ""}`), n.join(" · ");
2837
+ }
2838
+ function zi(e, t, n) {
2839
+ return `Opened ${e}: ${Ri(t, n).replace(" · ", ", ")}.`;
2840
+ }
2841
+ var Bi = (e, t, n = "") => `cornfield.seen.${e || "checkout"}/${t || ""}@${n || ""}`;
2842
+ function Vi(e, t) {
2843
+ let n = {
2844
+ played: [],
2845
+ read: []
2846
+ };
2847
+ try {
2848
+ let r = e && e.getItem(t);
2849
+ if (!r) return n;
2850
+ let i = JSON.parse(r), a = (e) => Array.isArray(e) ? e.filter((e) => typeof e == "string").slice(0, 200) : [];
2851
+ return {
2852
+ played: a(i && i.played),
2853
+ read: a(i && i.read)
2854
+ };
2855
+ } catch {
2856
+ return n;
2857
+ }
2858
+ }
2859
+ function Hi(e, t, n, r, i = null) {
2860
+ let a = i ? {
2861
+ played: [...Ti(i.played)],
2862
+ read: [...Ti(i.read)]
2863
+ } : Vi(e, t), o = String(n);
2864
+ r === "played" ? (a.played.includes(o) || a.played.push(o), a.read = a.read.filter((e) => e !== o)) : !a.read.includes(o) && !a.played.includes(o) && a.read.push(o);
2865
+ try {
2866
+ e && e.setItem(t, JSON.stringify(a));
2867
+ } catch {}
2868
+ return a;
2869
+ }
2870
+ // ../explorer/engine/player.js
2871
+ var Ui = 250, Wi = 140;
2872
+ function Gi(e, t) {
2873
+ let { state: n } = e;
2874
+ if (!t || n.view === "dataflow" || n.view === "house") return [];
2875
+ let r = h(n), i = (e) => r[e] !== !1, a = t.type;
2876
+ if (a === "root" || f(n, t)) return [];
2877
+ let o = g(n, t);
2878
+ if (o) return i(o) ? [] : [o];
2879
+ if (a === "core") return [...i("core") ? [] : ["core"], ...r.pkg || r.atom ? [] : ["pkg"]];
2880
+ if (a === "store") return ["flow", "store"].filter((e) => !i(e));
2881
+ if (a === "rom") return ["rom", "flow"].filter((e) => !i(e));
2882
+ if (a === "floor" || a === "room") return i("house") ? [] : ["house"];
2883
+ let s = a === "external" ? S(t) : a;
2884
+ return i(s) ? [] : [s];
2885
+ }
2886
+ var Ki = (e) => (Array.isArray(e?.steps) ? e.steps : []).flatMap((e) => e?.edge ? [e.edge.from, e.edge.to] : e && e.node !== void 0 ? [e.node] : []), qi = "input, textarea, select, [contenteditable=\"\"], [contenteditable=\"true\"]", Ji = (e) => !!(e && e.closest && e.closest(qi));
2887
+ function Yi(e, t) {
2888
+ let n = new Set(e.map((e) => e.id)), r = (t) => (e.find((e) => e.id === t) || { label: t }).label, i = t.filter((e) => (e.kind || e.dashed) && n.has(e.from) && n.has(e.to) && e.from !== e.to);
2889
+ if (!i.length) return null;
2890
+ let a = /* @__PURE__ */ new Map();
2891
+ for (let e of i) a.has(e.from) || a.set(e.from, []), a.get(e.from).push(e);
2892
+ let o = [...a.keys()].sort((e, t) => a.get(t).length - a.get(e).length || e.localeCompare(t))[0], s = [{
2893
+ node: o,
2894
+ text: `It starts at ${r(o)}.`
2895
+ }], c = /* @__PURE__ */ new Set([o]), l = o;
2896
+ for (let e = 0; e < 3; e++) {
2897
+ let e = (a.get(l) || []).find((e) => !c.has(e.to));
2898
+ if (!e) break;
2899
+ let t = {
2900
+ from: e.from,
2901
+ to: e.to,
2902
+ ...e.kind ? { kind: e.kind } : {},
2903
+ ...e.kind === "flow" ? { flow: e.flow } : {}
2904
+ };
2905
+ s.push({
2906
+ edge: t,
2907
+ text: `${r(e.from)} ${e.label || e.kind || "uses"} ${r(e.to)}.`
2908
+ }), s.push({
2909
+ node: e.to,
2910
+ text: `Now at ${r(e.to)}.`
2911
+ }), c.add(e.to), l = e.to;
2912
+ }
2913
+ return s.length < 2 ? null : {
2914
+ id: "demo",
2915
+ title: "A walk over the map",
2916
+ steps: s
2917
+ };
2918
+ }
2919
+ function Xi(e, t, n) {
2920
+ let { state: r } = e, i = null, o = null, s = "", c = null, u = !1, d = -1, f = null, p = -1, m = null, h = null, g = null, _ = null, v = /* @__PURE__ */ new Set(), y = [], b = (t) => {
2921
+ for (let e of [...v]) e(t);
2922
+ e.emit("scenario:player", t);
2923
+ }, S = () => r.canvas ? r.canvas.parentElement : null, C = () => e.map.render();
2924
+ function w() {
2925
+ let t = e.active();
2926
+ return t && t !== e.doc.body && !t.closest?.(".hx-player") && !t.closest?.("#review-column") && t !== r.canvas ? t : null;
2927
+ }
2928
+ function T() {
2929
+ let t = e.active();
2930
+ return !!t && t !== e.doc.body && !Ji(t);
2931
+ }
2932
+ function E() {
2933
+ let t = m;
2934
+ m = null;
2935
+ let n = (t) => !t || !t.isConnected || t.hidden || t.disabled || t.closest("[hidden]") ? !1 : (t.focus(), e.active() === t);
2936
+ n(h && h()) || n(t) || n(r.canvas);
2937
+ }
2938
+ function O(t) {
2939
+ t && Array.isArray(t.down) && t.down.length && yi(x(t.down, r.nodes, r.edges), r.nodes).forEach((t) => {
2940
+ L(r, t) || xe(e, t, !0, { scenario: !0 });
2941
+ });
2942
+ }
2943
+ function k(t) {
2944
+ let n = new Map(r.nodes.map((e) => [e.id, e])), i = [];
2945
+ for (let r of Ki(t)) for (let t of Gi(e, n.get(r))) i.includes(t) || i.push(t);
2946
+ if (!i.length) return;
2947
+ for (let t of i) xe(e, t, !0, { scenario: !0 });
2948
+ let a = i.map((e) => (Oe.find((t) => t.key === e) || (r.projectLayers || []).find((t) => t.key === e) || { label: e }).label);
2949
+ H(e, `Turned on ${a.length > 1 ? `${a.slice(0, -1).join(", ")} and ${a[a.length - 1]}` : a[0]} to show this scenario's steps.`);
2950
+ }
2951
+ function A(t, r = {}) {
2952
+ let a = w(), s = T() && r.focus !== !1;
2953
+ M({ keepChecks: !0 }), m = a;
2954
+ let c = r.stepMs ?? V();
2955
+ if (i = _i(t, {
2956
+ stepMs: c,
2957
+ maxFrameMs: Ui
2958
+ }), Number.isFinite(r.step) && r.step > 0 && i.goTo(r.step), ee(c), n.open(t, () => {
2959
+ P(), C();
2960
+ }), O(t), k(t), r.autoplay !== !1 && !(r.step > 0) && i.play(), P(!0), C(), e.map.ensureFlowLoop(), s && o) {
2961
+ let e = o.querySelector("[data-action=scenario-toggle]");
2962
+ e && !e.disabled ? e.focus() : o.querySelector("[data-action=scenario-next]")?.focus();
2963
+ }
2964
+ return i;
2965
+ }
2966
+ function j(e) {
2967
+ let t = r.nodes.find((t) => t.id === e);
2968
+ return !t || t.type !== "external" || t.kind !== "cloud" ? null : A(wi(t, r.nodes, r.edges));
2969
+ }
2970
+ function M({ keepChecks: t = !1, closing: a = !1 } = {}) {
2971
+ let l = !!i || !!r.scenario;
2972
+ l && Ce(e), i = null, c = null, s = "", r.scenario = null, t || n.close(), f &&= (f.disconnect(), null), o &&= (_n(e, "player"), y.forEach((e) => e()), y = [], n.unmount(), o.remove(), null), l && (!t || a) && b(null);
2973
+ }
2974
+ function N() {
2975
+ if (!i && !r.scenario) return;
2976
+ let t = e.active(), n = !!o && o.contains(t) || !!t?.closest?.("#review-column");
2977
+ M({
2978
+ keepChecks: !!i && !!g && g(i.scenario().id),
2979
+ closing: !0
2980
+ }), e.touchScene(), C();
2981
+ let a = e.active();
2982
+ n || !a || a === e.doc.body ? E() : m = null;
2983
+ }
2984
+ function P(t = !1) {
2985
+ if (!i) return !1;
2986
+ let a = n.decorate(i.snapshot(), i.scenario());
2987
+ r.scenario = a;
2988
+ let o = `${a.index}|${a.playing}|${a.done}|${a.stepStartMs}|${a.stepMs}|${a.manual}|${n.version()}`, c = t || o !== s;
2989
+ if (c) {
2990
+ let n = t || o.split("|")[0] !== s.split("|")[0];
2991
+ s = o, e.touchScene(), n && (u = !1, F(a));
2992
+ }
2993
+ return U(a), c && b({
2994
+ id: a.id,
2995
+ index: a.index,
2996
+ total: a.total,
2997
+ done: a.done,
2998
+ playing: a.playing,
2999
+ checks: n.version()
3000
+ }), c;
3001
+ }
3002
+ function F(t) {
3003
+ let n = /* @__PURE__ */ new Map();
3004
+ r.nodes.forEach((t) => {
3005
+ e.map.isNodeVisible(t) && n.set(t.id, t);
3006
+ });
3007
+ let i = l(e);
3008
+ d = o ? o.offsetHeight : 0;
3009
+ let a = vi({
3010
+ node: t.current.node,
3011
+ edge: t.current.edge,
3012
+ at: t.current.at,
3013
+ text: t.current.text
3014
+ }, r.camera, i, n, 60, e.map.getMinZoom());
3015
+ a && (e.reducedMotion ? (Object.assign(r.camera, a), c = null, C()) : (c = {
3016
+ to: a,
3017
+ last: null
3018
+ }, e.map.ensureFlowLoop()));
3019
+ }
3020
+ function I(e) {
3021
+ if (!c) return;
3022
+ let t = c.last === null ? 16 : Math.min(e - c.last, 100);
3023
+ c.last = e;
3024
+ let n = 1 - Math.exp(-t / Wi), i = r.camera;
3025
+ i.x += (c.to.x - i.x) * n, i.y += (c.to.y - i.y) * n, i.zoom += (c.to.zoom - i.zoom) * n, Math.abs(c.to.x - i.x) < .5 && Math.abs(c.to.y - i.y) < .5 && Math.abs(c.to.zoom - i.zoom) < .002 && (Object.assign(i, c.to), c = null);
3026
+ }
3027
+ let R = () => !!i && (i.isPlaying() || !!c);
3028
+ function B(e) {
3029
+ i && (i.tick(e), P(), I(e));
3030
+ }
3031
+ t.own(e.map.addFrameClient({
3032
+ wants: R,
3033
+ tick: B
3034
+ }));
3035
+ function ee(t) {
3036
+ let n = S();
3037
+ if (!n) return;
3038
+ o = e.doc.createElement("div"), o.className = "hx-player glass", o.dataset.corn = "scenario-player", o.setAttribute("part", "scenario-player"), o.setAttribute("role", "region"), o.setAttribute("aria-label", "Scenario player"), o.innerHTML = `
3039
+ <span class="hx-player-title hx-sr-only"></span>
3040
+ <div class="hx-player-controls" role="group">
3041
+ <button data-corn-kind="secondary" type="button" class="hx-btn hx-player-prev" data-action="scenario-prev" data-peek-ok><span class="hx-player-label"></span></button>
3042
+ <button type="button" class="hx-btn hx-btn--active hx-player-toggle" data-action="scenario-toggle" data-peek-ok data-corn-kind="primary"><span class="hx-player-label"></span></button>
3043
+ <button data-corn-kind="secondary" type="button" class="hx-btn hx-player-next" data-action="scenario-next" data-peek-ok><span class="hx-player-label"></span></button>
3044
+ <button data-corn-kind="secondary" type="button" class="hx-btn hx-player-next-scenario" data-action="scenario-next-scenario" data-peek-ok hidden></button>
3045
+ </div>
3046
+ <p class="hx-player-text"><span class="hx-player-count" data-corn="count"></span><span class="hx-player-sep" aria-hidden="true"> · </span><span class="hx-player-who"></span><span class="hx-player-step"></span></p>
3047
+ <span class="hx-player-says hx-sr-only" role="status" aria-live="polite"></span>
3048
+ <div class="hx-player-side">
3049
+ <select data-corn="control" class="hx-player-speed" data-action="scenario-speed" aria-label="Time for each step" title="Time for each step">${di.map((e) => `<option value="${D(String(e.value))}">${D(e.label)}</option>`).join("")}</select>
3050
+ <button type="button" class="hx-close" data-action="scenario-close" aria-label="Close the scenario" data-corn-kind="icon">✕</button>
3051
+ </div>
3052
+ <div class="hx-player-track" data-corn="scenario-track" aria-hidden="true"><span class="hx-player-fill" data-corn="scenario-fill"></span></div>`, z(o), o.querySelector(".hx-player-controls").setAttribute("aria-label", a(e, "steps")), o.querySelector(".hx-player-prev .hx-player-label").textContent = a(e, "previousStep"), o.querySelector(".hx-player-next .hx-player-label").textContent = a(e, "nextStep"), o.querySelector(".hx-player-next-scenario").textContent = a(e, "nextScenario");
3053
+ let s = (e) => {
3054
+ let t = e.target.closest("[data-action]");
3055
+ t && ne(t.dataset.action);
3056
+ }, c = o.querySelector(".hx-player-speed"), l = (e) => te(e.target.value), p = o;
3057
+ p.addEventListener("click", s), c.value = String(t), c.addEventListener("change", l), y.push(() => {
3058
+ p.removeEventListener("click", s), c.removeEventListener("change", l);
3059
+ });
3060
+ let m = e.el("sheet-dock"), h = e.el("spec-drawer");
3061
+ m && h && h.parentElement === m ? m.insertBefore(o, h) : (m || n).appendChild(o), gn(e, "player", o), bn(e);
3062
+ let g = e.win && e.win.ResizeObserver;
3063
+ typeof g == "function" && (f = new g(() => {
3064
+ o && i && r.scenario && !u && o.offsetHeight !== d && F(i.snapshot());
3065
+ }), f.observe(o));
3066
+ }
3067
+ let V = () => fi(e.store.get(ui));
3068
+ function te(t) {
3069
+ let n = fi(t);
3070
+ e.store.set(ui, String(n)), i && (i.setSpeed(n), P(), C(), e.map.ensureFlowLoop());
3071
+ }
3072
+ function ne(t) {
3073
+ if (i) {
3074
+ if (t === "scenario-close") return N();
3075
+ if (t === "scenario-next-scenario") {
3076
+ let e = _ ? _(i.scenario().id) : null;
3077
+ e && A(e);
3078
+ } else {
3079
+ if (t === "scenario-toggle") {
3080
+ let t = i.snapshot();
3081
+ t.playing ? i.pause() : i.play(), H(e, t.playing ? "Paused" : t.done ? "Playing again" : t.index > 0 || t.progress > 0 ? "Resumed" : "Playing");
3082
+ } else if (t === "scenario-prev") i.prev();
3083
+ else if (t === "scenario-next") i.next();
3084
+ else return;
3085
+ P(), C(), e.map.ensureFlowLoop();
3086
+ }
3087
+ }
3088
+ }
3089
+ function U(t) {
3090
+ if (!o) return;
3091
+ let i = (e) => o.querySelector(e), s = (e, t) => {
3092
+ let n = i(e);
3093
+ n.textContent !== t && (n.textContent = t);
3094
+ };
3095
+ s(".hx-player-title", t.title), o.setAttribute("aria-label", `Scenario player: ${t.title}`), s(".hx-player-count", `${Math.min(t.index + 1, Math.max(t.total, 1))} of ${t.total}`);
3096
+ let c = t.current.actor ? Yr(qr(r.nodes, t.current.actor)) || t.current.actor : "";
3097
+ s(".hx-player-who", c && !t.done ? `As ${c} · ` : ""), s(".hx-player-step", t.done ? "Played to the end" : t.current.text), o.dataset.done = String(!!t.done);
3098
+ let l = i("[data-action=scenario-toggle]");
3099
+ s("[data-action=scenario-toggle] .hx-player-label", t.playing ? a(e, "pause") : t.done ? a(e, "playAgain") : a(e, "play")), l.dataset.state = t.playing ? "playing" : t.done ? "done" : "paused", l.disabled = t.total === 0 || t.manual, l.title = t.manual ? "The time for each step is Manual: use Next" : "", i("[data-action=scenario-prev]").disabled = t.index === 0 && !t.done;
3100
+ let u = i("[data-action=scenario-next]");
3101
+ u.disabled = t.done || t.total === 0;
3102
+ let d = t.done && _ ? _(t.id) : null;
3103
+ i("[data-action=scenario-next-scenario]").hidden = !d, u.hidden = !!d, s(".hx-player-says", t.done ? `${t.title}: played to the end.` : Fi({
3104
+ snap: t,
3105
+ nodes: r.nodes,
3106
+ edges: r.edges,
3107
+ words: { notChecked: a(e, "notChecked") }
3108
+ }));
3109
+ let f = t.total ? Math.round((t.done ? t.total : t.index + t.progress) / t.total * 1e3) / 10 : 0;
3110
+ f !== p && (p = f, i(".hx-player-fill").style.width = `${f}%`), n.paint(o, t);
3111
+ }
3112
+ function W() {
3113
+ return !!e.root.querySelector("#legend-dropdown:not([hidden]), #proposal-more-menu:not([hidden]), [data-corn=\"dialog-scrim\"]:not([hidden]), .hx-mockup-dialog");
3114
+ }
3115
+ t.listen(e.root, "keydown", (e) => {
3116
+ if (e.key === "Escape" && !e.defaultPrevented && !e.ctrlKey && !e.metaKey && !e.altKey && i && !Ji(e.target) && !W()) {
3117
+ e.preventDefault(), N();
3118
+ return;
3119
+ }
3120
+ if (!i || e.defaultPrevented || e.ctrlKey || e.metaKey || e.altKey || Ji(e.target) || (e.key === " " || e.code === "Space") && e.target.closest?.("#review-column")) return;
3121
+ let t = e.key === " " || e.code === "Space" ? "scenario-toggle" : e.key === "ArrowLeft" ? "scenario-prev" : e.key === "ArrowRight" ? "scenario-next" : null;
3122
+ t && (e.preventDefault(), ne(t));
3123
+ }), t.listen(e.root, "keyup", (e) => {
3124
+ i && (e.key === " " || e.code === "Space") && !Ji(e.target) && e.preventDefault();
3125
+ }), t.own(cn(e, () => {
3126
+ i && r.scenario && F(i.snapshot());
3127
+ }));
3128
+ for (let n of [
3129
+ "pointerdown",
3130
+ "wheel",
3131
+ "touchstart",
3132
+ "mousedown"
3133
+ ]) t.listen(e.root, n, (e) => {
3134
+ e.target === r.canvas && (c = null, u = !0);
3135
+ }, {
3136
+ passive: !0,
3137
+ capture: !0
3138
+ });
3139
+ return t.on("scenario:clear", () => M()), t.own(() => {
3140
+ M({ keepChecks: !1 }), v.clear();
3141
+ }), {
3142
+ play: A,
3143
+ stop: N,
3144
+ clear: M,
3145
+ tick: B,
3146
+ playOutage: j,
3147
+ getPlayer: () => i,
3148
+ bar: () => o,
3149
+ wantsFrames: R,
3150
+ onChange(e) {
3151
+ return v.add(e), () => v.delete(e);
3152
+ },
3153
+ setCloseFocus(e) {
3154
+ h = typeof e == "function" ? e : null;
3155
+ },
3156
+ setNextScenario(e) {
3157
+ _ = typeof e == "function" ? e : null;
3158
+ },
3159
+ setKeepChecksOnClose(e) {
3160
+ g = typeof e == "function" ? e : null;
3161
+ },
3162
+ demo(e = !0) {
3163
+ if (!e) return !1;
3164
+ let t = Yi(r.nodes, r.edges);
3165
+ return t ? (A(t), !0) : (console.warn("scenario-demo: the map has none of the nodes the demo walks over"), !1);
3166
+ }
3167
+ };
3168
+ }
3169
+ // ../explorer/pieces/changes.js
3170
+ var Zi = "cornfield.reviewTab", Qi = 1360, $i = () => ({ column: "<aside id=\"review-column\" class=\"hx-review-column glass\" aria-label=\"Review\" data-corn=\"review-column\" hidden><div class=\"hx-rc-scroll\"><p id=\"proposal-summary\" class=\"hx-proposal-summary\" hidden></p><div id=\"review-lists\" class=\"hx-rc-lists\"></div></div><!--corn-piece:decision/foot--></aside>" }), ea = (e, t) => `${D(e)}<span aria-hidden="true"> · </span><span class="hx-sr-only">, </span><span data-corn="count">${t}</span>`;
3171
+ function ta(e) {
3172
+ let t = `${e.word} ${e.name}, ${e.type}`;
3173
+ return `<li><button type="button" class="hx-change-row" data-action="proposal-focus" data-kind="${e.kind}" data-key="${D(e.key)}" data-focus-key="ch:${D(e.kind)}:${D(e.key)}" data-corn="row" aria-label="${D(t)}"><span class="hx-mark-dot hx-mark-dot--${e.mark}" data-corn="mark-dot"${Ze(e.mark)} aria-hidden="true"></span><span class="hx-change-what">${D(e.word)}</span><span class="hx-name">${D(e.name)}</span><span class="hx-faint">${D(e.type)}</span></button></li>`;
3174
+ }
3175
+ function na(e, t, n = {}) {
3176
+ let { state: r } = t, i = A(t), o = oe(t, e, $i().column, n.slots, "column"), s = (e) => {
3177
+ for (let t of o) {
3178
+ if (t.id === e) return t;
3179
+ let n = t.querySelector(`[id="${e}"]`);
3180
+ if (n) return n;
3181
+ }
3182
+ return null;
3183
+ };
3184
+ i.keepParts(...o);
3185
+ let c = s("review-column"), l = !1, u = ci(t, { checker: n.checker }), d = Xi(t, i, u);
3186
+ i.own(() => u.close());
3187
+ let f = {
3188
+ checks: 0,
3189
+ open: null,
3190
+ tab: null,
3191
+ tabNow: null,
3192
+ tabFor: "",
3193
+ openFor: "",
3194
+ head: "",
3195
+ headFor: "",
3196
+ current: null,
3197
+ lastStep: null,
3198
+ seen: {
3199
+ played: [],
3200
+ read: []
3201
+ },
3202
+ seenFor: "",
3203
+ pending: []
3204
+ }, p = {
3205
+ getItem: (e) => t.store.get(e),
3206
+ setItem: (e, n) => t.store.set(e, n)
3207
+ }, m = t.store.get(Zi);
3208
+ (m === "changes" || m === "scenarios") && (f.tab = m);
3209
+ let h = () => {
3210
+ let e = r.effectiveProposal || r.proposal;
3211
+ return e && Array.isArray(e.scenarios) ? e.scenarios : [];
3212
+ }, g = () => `${r.proposalSource || ""}/${r.proposalSlug || ""}`;
3213
+ function _() {
3214
+ return K(r.proposalSource) ? f.headFor === g() && f.head ? Bi(r.proposalSource, r.proposalSlug, f.head) : null : Bi(r.proposalSource, r.proposalSlug, "");
3215
+ }
3216
+ function y() {
3217
+ let e = _(), t = e || `pending:${g()}`;
3218
+ if (f.seenFor === t) return;
3219
+ let n = f.seenFor;
3220
+ if (f.seenFor = t, !e) f.seen = {
3221
+ played: [],
3222
+ read: []
3223
+ }, f.pending = [];
3224
+ else {
3225
+ if (f.seen = Vi(p, e), n === `pending:${g()}`) for (let [t, n] of f.pending) f.seen = Hi(p, e, t, n);
3226
+ f.pending = [];
3227
+ }
3228
+ }
3229
+ function b(e, t) {
3230
+ y(), f.seenFor.startsWith("pending:") ? (f.pending.push([String(e), t]), f.seen = Hi(null, "", e, t, f.seen)) : f.seen = Hi(p, f.seenFor, e, t);
3231
+ }
3232
+ function x(e) {
3233
+ let t = typeof e == "string" ? e : "";
3234
+ (t !== f.head || f.headFor !== g()) && (f.head = t, f.headFor = g(), r.proposal && L());
3235
+ }
3236
+ function S() {
3237
+ y();
3238
+ let e = /* @__PURE__ */ new Map(), n = u.checkedScenarioId();
3239
+ n !== null && e.set(n, u.verdicts());
3240
+ let i = r.effectiveProposal || r.proposal, o = { notChecked: a(t, "notChecked") }, s = new Map(r.nodes.map((e) => [e.id, e]));
3241
+ return Li({
3242
+ scenarios: h(),
3243
+ nodes: r.nodes,
3244
+ edges: r.edges,
3245
+ proposal: i,
3246
+ verdicts: e,
3247
+ seen: f.seen,
3248
+ words: o,
3249
+ hidden: (e) => s.has(e) && Gi(t, s.get(e)).length > 0
3250
+ });
3251
+ }
3252
+ let C = (e) => Ai(r.nodes, r.edges, e).filter((e) => e.mark !== "edit");
3253
+ function w(e) {
3254
+ let t = r.effectiveProposal || r.proposal;
3255
+ return zi(e, C(t).length, S());
3256
+ }
3257
+ function T() {
3258
+ let e = r.effectiveProposal || r.proposal;
3259
+ return Ri(C(e).length, S());
3260
+ }
3261
+ function O(e, t, n, r) {
3262
+ let i = f.current && f.current.index === e.index && f.current.step === t.index && f.current.id === e.id, a = t.verdict ? `<span class="hx-step-verdict" data-corn="state-pill" data-tone="${D(t.verdict.tone)}"${t.verdict.state ? ` data-corn-state="${t.verdict.state}"` : ""}>${D(t.verdict.words)}</span>` : "", o = t.mark ? `<span class="hx-step-mark"><span class="hx-mark-dot hx-mark-dot--${t.mark}" data-corn="mark-dot"${Ze(t.mark)} aria-hidden="true"></span>${D(t.markWord)}</span>` : "", s = t.actorLabel ? `<span class="hx-step-who">As ${D(t.actorLabel)}</span>` : "";
3263
+ return `<li><button type="button" class="hx-step" data-corn="step" data-action="scenario-step" data-scenario-index="${e.index}" data-step-index="${t.index}" data-focus-key="st:${n.key}:${e.key}:${t.index}" aria-label="${D(Pi(t, r))}"${i ? " aria-current=\"step\"" : ""}><span class="hx-step-n" aria-hidden="true">${t.number}</span><span class="hx-step-body"><span class="hx-step-line">${s}<span class="hx-step-where">${D(t.where)}</span>${o}${t.layerOff ? "<span class=\"hx-step-off\">Layer off: shown when played</span>" : ""}</span><span class="hx-step-text">${D(t.text)}</span></span>${a}</button></li>`;
3264
+ }
3265
+ function k(e, n) {
3266
+ let r = f.open === e.id, i = `rc-steps-${n.key}-${e.key}`, o = e.seen ? `<span class="hx-sc-seen" data-seen="${e.seen}">${e.seen === "played" ? "✓ Played" : "✓ Read"}</span>` : "", s = e.verdictSummary ? ` · ${D(e.verdictSummary)}` : "", c = r && B(e.id) && e.steps.some((e) => e.actor) ? "<p class=\"hx-faint hx-rc-note hx-sc-waits\" data-corn=\"notice\">Not checked while another scenario plays. Close the player, or choose a step here to play this one.</p>" : "";
3267
+ return `<li class="hx-sc" data-open="${r}"><button type="button" class="hx-sc-row" data-corn="row" data-action="scenario-open" data-scenario-index="${e.index}" data-focus-key="sc:${n.key}:${e.key}" aria-expanded="${r}" aria-controls="${i}"><span class="hx-sc-caret" aria-hidden="true">${r ? "▾" : "▸"}</span><span class="hx-sc-main"><span class="hx-sc-title">${D(e.title)}</span><span class="hx-sc-meta">${D(e.summary)}${s}</span></span>${o}</button>${c}<ol class="hx-steps" id="${i}" data-corn="step-list" aria-label="${D(a(t, "steps"))}: ${D(e.title)}"${r ? "" : " hidden"}>${r ? e.steps.map((t) => O(e, t, n, e.steps.length)).join("") : ""}</ol></li>`;
3268
+ }
3269
+ function j(e) {
3270
+ let n = e.scenarios.length, r = e.anyone ? a(t, "anyone") : e.label, i = `${D(r)}<span aria-hidden="true"> · </span><span class="hx-sr-only">, </span>${n} ${n === 1 ? "scenario" : "scenarios"}`;
3271
+ return `<div class="hx-persona" data-corn="persona-group" data-persona="${D(e.key)}"><h4 class="hx-persona-name">${i}</h4><ul class="hx-sc-list">${e.scenarios.map((t) => k(t, e)).join("")}</ul></div>`;
3272
+ }
3273
+ function M() {
3274
+ let e = r.effectiveProposal || r.proposal, n = Ai(r.nodes, r.edges, e), i = n.filter((e) => e.mark !== "edit"), o = n.filter((e) => e.mark === "edit"), s = S(), c = v(t);
3275
+ f.tabFor !== g() && (f.tabFor = g(), f.tabNow = s.total ? f.tab || "scenarios" : "changes");
3276
+ let l = f.tabNow || "changes", u = r.nodes.some((e) => e.type === "persona"), d = `<div class="hx-rc-tabs" role="tablist" aria-label="Review" data-corn="tabs"${c ? "" : " hidden"}><button type="button" role="tab" id="rc-tab-changes" class="hx-rc-tab" data-corn="tab" data-action="review-tab" data-tab="changes" aria-selected="${l === "changes"}" aria-controls="rc-changes" tabindex="${l === "changes" ? 0 : -1}">${D(a(t, "changes"))} · ${i.length}</button><button type="button" role="tab" id="rc-tab-scenarios" class="hx-rc-tab" data-corn="tab" data-action="review-tab" data-tab="scenarios" aria-selected="${l === "scenarios"}" aria-controls="rc-scenarios" tabindex="${l === "scenarios" ? 0 : -1}">${D(a(t, "scenarios"))} · ${s.total}</button></div>`, p = `<section id="rc-changes" class="hx-rc-section" data-corn="proposal-changes"${c ? ` role="tabpanel" aria-labelledby="rc-tab-changes"${l === "changes" ? "" : " hidden"}` : " aria-labelledby=\"rc-changes-h\""}><h3 id="rc-changes-h" class="hx-rc-h" tabindex="-1">${ea(a(t, "changes"), i.length)}</h3>` + (o.length ? `<h4 class="hx-rc-sub">${ea(a(t, "yourEdits"), o.length)}</h4><ul class="hx-change-list">${o.map(ta).join("")}</ul>` : "") + (i.length ? `<ul class="hx-change-list">${i.map(ta).join("")}</ul>` : "<p class=\"hx-faint hx-rc-empty\">This proposal changes nothing on the map.</p>") + "</section>", m;
3277
+ return s.total ? (m = s.groups.map(j).join(""), u || (m += `<p class="hx-faint hx-rc-note">This map has no personas (topology.personas.json), so every scenario is listed under ${D(a(t, "anyone"))}.</p>`), s.coverage && (m += `<p class="hx-rc-coverage" data-corn="notice">${D(a(t, "notInAnyScenario"))}: ${s.notInAny.map(D).join(", ")}</p>`)) : m = "<p class=\"hx-faint hx-rc-empty\">This proposal has no scenarios: there is nothing to walk through, and its changes are all it shows.</p>", `${d}${p}${`<section id="rc-scenarios" class="hx-rc-section" data-corn="scenario-list"${c ? ` role="tabpanel" aria-labelledby="rc-tab-scenarios"${l === "scenarios" ? "" : " hidden"}` : " aria-labelledby=\"rc-scenarios-h\""}><h3 id="rc-scenarios-h" class="hx-rc-h" tabindex="-1">${ea(a(t, "personasAndScenarios"), s.total)}</h3><div class="hx-rc-sbody">${m}</div></section>`}`;
3278
+ }
3279
+ function N() {
3280
+ let e = t.el("sheet-dock"), n = t.el("proposal-body");
3281
+ if (v(t) && n) c.parentElement !== n && n.appendChild(c);
3282
+ else if (e) {
3283
+ let n = t.el("proposal-bar");
3284
+ n && c.parentElement !== e && n.after(c);
3285
+ }
3286
+ return c;
3287
+ }
3288
+ function P() {
3289
+ let e = t.el("proposal-bar");
3290
+ !e || v(t) || e.hidden || c.style.setProperty("--hx-column-top", `${Math.round(e.offsetTop + e.offsetHeight + 8)}px`);
3291
+ }
3292
+ function F() {
3293
+ if (l) return;
3294
+ N();
3295
+ let e = !!r.proposal;
3296
+ if (c.hidden = !e, !e) {
3297
+ f.open = null, f.current = null, f.lastStep = null, ee();
3298
+ let e = s("review-lists");
3299
+ e && (e.innerHTML = "");
3300
+ } else L(), P();
3301
+ }
3302
+ function I() {
3303
+ let e = s("review-lists"), n = s("rc-scenarios");
3304
+ if (!e || !n || c.hidden || v(t)) return;
3305
+ let r = e.clientHeight;
3306
+ if (!r) return;
3307
+ let i = parseFloat(t.win.getComputedStyle(e).rowGap) || 0, a = n.querySelector(".hx-rc-h"), o = n.querySelector(".hx-rc-sbody"), l = Math.ceil((a ? a.offsetHeight + (parseFloat(t.win.getComputedStyle(a).marginBottom) || 0) : 0) + (o ? o.scrollHeight : 0));
3308
+ c.style.setProperty("--hx-scenarios-need", `${l}px`), c.style.setProperty("--hx-changes-max", `${Math.floor(Math.max(.4 * r, r - l - i))}px`);
3309
+ }
3310
+ function L() {
3311
+ let e = s("review-lists");
3312
+ if (l || !e || !r.proposal) return;
3313
+ f.openFor !== g() && (f.openFor = g(), d.getPlayer() || (f.open = null, f.current = null, f.lastStep = null)), f.open !== null && !h().some((e) => e.id === f.open) && (f.open = null);
3314
+ let n = f.open !== null && !d.getPlayer() ? h().find((e) => e.id === f.open) : null;
3315
+ n && u.checkedScenarioId() === n.id && u.open(n, () => L());
3316
+ let i = t.active(), a = i && e.contains(i) && i.getAttribute ? i.getAttribute("data-focus-key") : null, o = e.scrollTop;
3317
+ e.innerHTML = M(), z(e);
3318
+ let c = r.proposal, p = s("proposal-summary");
3319
+ if (p.textContent = c && typeof c.summary == "string" && c.summary || "", p.hidden = !p.textContent, e.scrollTop = o, t.emit("changes:peek", T()), a) {
3320
+ let t = [...e.querySelectorAll("[data-focus-key]")].find((e) => e.getAttribute("data-focus-key") === a);
3321
+ t && t.focus();
3322
+ }
3323
+ I(), t.emit("changes:paint");
3324
+ }
3325
+ let R = (e) => h()[Number(e.dataset.scenarioIndex)] || null, B = (e) => {
3326
+ let t = d.getPlayer();
3327
+ return !!t && t.scenario().id !== e;
3328
+ };
3329
+ function ee() {
3330
+ d.getPlayer() || u.close();
3331
+ }
3332
+ function V(e) {
3333
+ f.open === e.id ? (f.open = null, d.getPlayer() || u.close()) : (f.open = e.id, b(e.id, "read"), B(e.id) || u.open(e, () => L())), L();
3334
+ }
3335
+ function te(e, n) {
3336
+ f.open = e.id;
3337
+ let i = t.el("spec-drawer"), a = r.canvas && r.canvas.parentElement;
3338
+ !v(t) && i && i.classList.contains("drawer-open") && a && a.clientWidth < Qi && E(t, { source: "api" }), d.play(e, {
3339
+ autoplay: !1,
3340
+ step: n,
3341
+ focus: v(t)
3342
+ }), L();
3343
+ }
3344
+ function H(e, { focus: n = !1 } = {}) {
3345
+ f.tab = e, f.tabNow = e, f.tabFor = g(), t.store.set(Zi, e), L(), n && s(`rc-tab-${e}`)?.focus();
3346
+ }
3347
+ function ne(e) {
3348
+ if (!r.proposal) return;
3349
+ v(t) && (H(e), vn(t, "proposal"));
3350
+ let n = s(e === "scenarios" ? "rc-scenarios" : "rc-changes"), i = s(e === "scenarios" ? "rc-scenarios-h" : "rc-changes-h");
3351
+ n && typeof n.scrollIntoView == "function" && n.scrollIntoView({ block: "start" }), i && i.focus();
3352
+ }
3353
+ i.listen(c, "click", (e) => {
3354
+ let n = e.target.closest ? e.target.closest("[data-action]") : null;
3355
+ if (!n) return;
3356
+ let r = n.dataset.action;
3357
+ if (r === "scenario-open") {
3358
+ let e = R(n);
3359
+ e && V(e);
3360
+ } else if (r === "scenario-step") {
3361
+ let e = R(n);
3362
+ e && te(e, Number(n.dataset.stepIndex));
3363
+ } else r === "review-tab" ? H(n.dataset.tab, { focus: !1 }) : r === "proposal-focus" && Nr(t, n.dataset.kind, n.dataset.key);
3364
+ }), i.listen(c, "keydown", (e) => {
3365
+ let t = e.target.closest ? e.target.closest("[role=\"tab\"]") : null;
3366
+ t && [
3367
+ "ArrowLeft",
3368
+ "ArrowRight",
3369
+ "Home",
3370
+ "End"
3371
+ ].includes(e.key) && (e.preventDefault(), H(t.dataset.tab === "changes" ? "scenarios" : "changes", { focus: !0 }));
3372
+ });
3373
+ function U(e) {
3374
+ if (!e) {
3375
+ let e = f.open !== null && r.proposal && f.openFor === g() ? h().find((e) => e.id === f.open) : null;
3376
+ e && u.open(e, () => L()), (f.current || e) && (f.current = null, L());
3377
+ return;
3378
+ }
3379
+ let t = h().findIndex((t) => t.id === e.id), n = {
3380
+ id: e.id,
3381
+ index: t,
3382
+ step: Math.min(e.index, Math.max(e.total - 1, 0))
3383
+ };
3384
+ f.lastStep = n, e.done && (y(), f.seen.played.includes(e.id) || b(e.id, "played"));
3385
+ let i = f.current && f.current.id === n.id && f.current.step === n.step;
3386
+ f.current = n, f.open !== e.id && (f.open = e.id), (!i || e.done || e.checks !== f.checks) && (f.checks = e.checks, L());
3387
+ }
3388
+ function W() {
3389
+ let e = f.lastStep;
3390
+ if (!e) return null;
3391
+ v(t) && vn(t, "proposal");
3392
+ let n = s("review-lists");
3393
+ return n ? n.querySelector(`[data-action="scenario-step"][data-scenario-index="${e.index}"][data-step-index="${e.step}"]`) : null;
3394
+ }
3395
+ function re(e) {
3396
+ let t = [];
3397
+ for (let e of S().groups) for (let n of e.scenarios) t.includes(n.id) || t.push(n.id);
3398
+ let n = t.indexOf(e), r = n >= 0 ? t[n + 1] : void 0;
3399
+ return r === void 0 ? null : h().find((e) => String(e.id) === r) || null;
3400
+ }
3401
+ i.own(d.onChange(U)), d.setCloseFocus(W), d.setNextScenario(re), d.setKeepChecksOnClose((e) => f.open === e && !!r.proposal), i.own(ye(t, () => {
3402
+ r.proposal && L();
3403
+ })), i.on("proposal:draw", () => F()), i.on("proposal:pull-head", (e) => x(e)), i.on("changes:show", (e) => ne(e));
3404
+ let ie = t.win && t.win.ResizeObserver, ae = (e, t) => {
3405
+ if (e && typeof ie == "function") {
3406
+ let n = new ie(t);
3407
+ n.observe(e), i.own(() => n.disconnect());
3408
+ }
3409
+ };
3410
+ return ae(t.el("proposal-bar"), () => P()), ae(c, () => I()), i.own(sn(t, () => {
3411
+ r.proposal && F();
3412
+ })), i.own(() => {
3413
+ l = !0, o.forEach((e) => e.remove());
3414
+ }), F(), i.on("changes:opened-line", (e) => r.proposal ? w(e) : void 0), i.on("changes:played-line", () => r.proposal ? S().playedLine : ""), {
3415
+ elements: o,
3416
+ playScenario: d.play,
3417
+ stopScenario: d.stop,
3418
+ clearScenario: d.clear,
3419
+ playOutage: d.playOutage,
3420
+ getPlayer: d.getPlayer,
3421
+ wantsFrames: d.wantsFrames,
3422
+ setCloseFocus: d.setCloseFocus,
3423
+ setNextScenario: d.setNextScenario,
3424
+ setKeepChecksOnClose: d.setKeepChecksOnClose,
3425
+ tickScenario: d.tick,
3426
+ demo: d.demo,
3427
+ layersHiding: (e) => Gi(t, e),
3428
+ checks: u,
3429
+ renderColumn: F,
3430
+ shareRoom: I,
3431
+ setPullHead: x,
3432
+ openedLine: w,
3433
+ peekLine: T,
3434
+ update(e) {
3435
+ e && "checker" in e && u.setChecker(e.checker), r.proposal && L();
3436
+ },
3437
+ destroy: () => i.destroy()
3438
+ };
3439
+ }
3440
+ // ../explorer/decision-model.js
3441
+ var ra = 5e3, ia = 3, aa = 40, oa = (e, t) => `${e} ${t}${e === 1 ? "" : "s"}`, sa = (e) => String(e).replace(/\s+/g, " ").trim(), ca = (e) => {
3442
+ let t = sa(e);
3443
+ return t.length > aa ? `${t.slice(0, 39)}…` : t;
3444
+ };
3445
+ function la(e) {
3446
+ let t = e.slice(0, ia).map(ca), n = e.length - t.length;
3447
+ return n > 0 ? `${t.join(", ")} and ${n} more` : t.length < 2 ? t.join("") : `${t.slice(0, -1).join(", ")} and ${t[t.length - 1]}`;
3448
+ }
3449
+ var ua = (e) => e && e.checks && Array.isArray(e.checks.failed) ? e.checks.failed : [], da = (e) => e && e.checks && e.checks.running || 0, fa = (e) => `${la(e)} failed`;
3450
+ function pa(e, t) {
3451
+ if (!e) return "";
3452
+ let n = [
3453
+ "code",
3454
+ "summary",
3455
+ "brief",
3456
+ "proposal"
3457
+ ].includes(e.kind) ? e.kind : "code", r = n === "code" ? "a code run" : `a ${n} run`;
3458
+ if (e.open) return `No new run is asked for: ${typeof e.open == "string" ? `run ${sa(e.open).slice(0, 40)} is` : "one is"} still open on it.`;
3459
+ if (e.fired) return `No new run is asked for: ${r} was asked for at this head already.`;
3460
+ let i = `Then ${r} is asked for.`;
3461
+ if (e.transport !== "pull") return `${i} The request is posted for your runner.`;
3462
+ if (e.runner === "online") return `${i} A runner is online.`;
3463
+ let a = typeof e.lastSeen == "string" ? Date.parse(e.lastSeen) : NaN;
3464
+ return e.runner === "quiet" && Number.isFinite(a) ? `${i} No runner has polled for ${$e(t - a)}: the run will wait.` : `${i} No runner has polled yet: the run will wait.`;
3465
+ }
3466
+ var ma = (e) => e > 0 ? `Your ${oa(e, "edit")} ${e === 1 ? "goes" : "go"} in the comment, for the agent to fold in.` : "";
3467
+ function ha(e) {
3468
+ let t = e.pull.number, n = !!e.lands;
3469
+ if (e.pull.draft) return n ? `PR #${t} is a draft. Approve posts an approval; it lands only if the PR is marked ready within 60 minutes.` : `PR #${t} is a draft. Approve posts an approval on it.`;
3470
+ let r = `Approve posts an approval on PR #${t}.`, i = e.checks, a = ua(e), o = da(e);
3471
+ return a.length ? n ? `${r} It will not land: ${fa(a)}.` : `${r} ${fa(a)}.` : i && i.total === 0 ? n ? `${r} It will not land: the PR has no checks.` : `${r} It does not land it.` : o ? n ? `${r} It lands once ${o === 1 ? "1 running check passes" : `${o} running checks pass`}.` : `${r} ${o === 1 ? "1 check is" : `${o} checks are`} still running.` : i && !i.passed ? n ? `${r} It will not land: no check has passed.` : `${r} It does not land it.` : n ? `Approve posts an approval on PR #${t} and lands it.` : `${r} It does not land it.`;
3472
+ }
3473
+ function ga(e, t) {
3474
+ return `An approval of this version of PR #${e} stands.${t && t.landing ? " Its landing waits for the checks." : ""} A push makes Approve live again.`;
3475
+ }
3476
+ function _a({ facts: e, edits: t = 0, form: n = null }) {
3477
+ let r = [];
3478
+ if (e && e.pull) {
3479
+ let t = ua(e);
3480
+ t.length && r.push({
3481
+ key: "failed",
3482
+ text: `${fa(t)} on PR #${e.pull.number}.`
3483
+ }), e.pull.draft && r.push({
3484
+ key: "draft",
3485
+ text: `PR #${e.pull.number} is a draft: its author has not marked it ready.`
3486
+ });
3487
+ }
3488
+ return n && r.push({
3489
+ key: "form",
3490
+ text: `Your ${sa(n.name)} form is not added.`
3491
+ }), e && e.pull && e.lands && t > 0 && r.push({
3492
+ key: "edits",
3493
+ text: `PR #${e.pull.number} lands as written; your ${oa(t, "edit")} only go${t === 1 ? "es" : ""} in the comment.`
3494
+ }), r;
3495
+ }
3496
+ function va(e, t = "Approve") {
3497
+ if (!e.length) return "";
3498
+ let n = e.length === 1 ? e[0] : null, r = n && n.key === "form" ? `${t} without it?` : `${t} anyway?`;
3499
+ return `${e.map((e) => e.text).join(" ")} ${r}`;
3500
+ }
3501
+ var ya = (e, t) => e.filter((e) => !t.includes(e.key)), ba = "Shown to read only: there is no cornfield server here to send an approval or a send back to.";
3502
+ function xa({ source: e, facts: t, factsState: n, review: r = null, edits: i = 0, form: a = null, played: o = "", now: s = Date.now() }) {
3503
+ let c = K(e), l = (...e) => e.filter(Boolean).join(" ");
3504
+ if (!c) return {
3505
+ line: `Draft in ${!e || e === "checkout" ? "the checkout" : `worktree ${sa(e)}`}: push it as a spec PR to review it here.`,
3506
+ approve: "refused",
3507
+ reasons: [],
3508
+ ask: ""
3509
+ };
3510
+ let u = !!r && r.verdict === "approved" && r.current === !0;
3511
+ if (n === "loading" || !t && n !== "unread") return {
3512
+ line: l(`Reading PR #${c} …`, o),
3513
+ approve: u ? "done" : "reading",
3514
+ reasons: [],
3515
+ ask: ""
3516
+ };
3517
+ if (!t || n === "unread") return {
3518
+ line: l(`Could not read PR #${c}'s checks. Approve posts an approval on it.`, ma(i), o),
3519
+ approve: u ? "done" : "allowed",
3520
+ reasons: _a({
3521
+ facts: null,
3522
+ edits: i,
3523
+ form: a
3524
+ }),
3525
+ ask: ""
3526
+ };
3527
+ let d = _a({
3528
+ facts: t,
3529
+ edits: i,
3530
+ form: a
3531
+ }), f = t.run ? pa(t.run, s) : "", p = l(ha(t), f, ma(i), o);
3532
+ return u ? {
3533
+ line: l(ga(c, t), o),
3534
+ approve: "done",
3535
+ reasons: d,
3536
+ ask: ""
3537
+ } : {
3538
+ line: p,
3539
+ approve: d.length ? "asks" : "allowed",
3540
+ reasons: d,
3541
+ ask: va(d)
3542
+ };
3543
+ }
3544
+ function Sa({ source: e, edits: t = 0 }) {
3545
+ let n = K(e);
3546
+ return n ? `Posts ${t > 0 ? `your note and ${oa(t, "edit")}` : "your note"} on PR #${n} for the drafting agent. No run is asked for.` : "";
3547
+ }
3548
+ function Ca({ form: e = null }) {
3549
+ let t = _a({
3550
+ facts: null,
3551
+ edits: 0,
3552
+ form: e
3553
+ });
3554
+ return {
3555
+ asks: t.length > 0,
3556
+ reasons: t,
3557
+ ask: va(t, "Send back")
3558
+ };
3559
+ }
3560
+ function wa(e, t = "") {
3561
+ if (e === 401) return "Your sign-in has ended. Sign in again: your edits are kept here.";
3562
+ let n = sa(t);
3563
+ return e === 403 || e === 409 ? n || "The review was not posted." : `The review was not posted. ${n || `The server answered ${e}.`}`;
3564
+ }
3565
+ var Ta = (e, t) => `${e === "approved" ? "Approving" : "Sending back"} in ${Math.max(0, Math.ceil(t))} s`, Ea = (e, t) => `${e === "approved" ? "Approving" : "Sending back"} in ${oa(Math.ceil(t), "second")}. Undo to stop it; nothing has been sent.`;
3566
+ function Da(e, t) {
3567
+ let n = e === "approved" ? "The approval" : "The send back";
3568
+ return `${{
3569
+ undo: `${n} was undone.`,
3570
+ escape: `${n} was undone.`,
3571
+ closed: `${n} was stopped: the proposal was closed.`,
3572
+ other: `${n} was stopped: another proposal was opened.`,
3573
+ hidden: `${n} was stopped: this tab was hidden.`,
3574
+ offline: `${n} was stopped: you are offline.`,
3575
+ edits: `${n} was stopped: your edits changed.`,
3576
+ pushed: `${n} was stopped: the PR was pushed to while it was held, so it is not what you looked at. Look again before you decide.`
3577
+ }[t] || `${n} was stopped.`} Nothing was sent.`;
3578
+ }
3579
+ var Oa = (e) => `Sent with ${oa(e, "edit")}`, ka = 3e4, Aa = 3e4, ja = "cornfield.reviewNote.", Ma = () => ({ foot: "<div id=\"review-decision\" class=\"hx-rc-foot\" data-corn=\"decision\" role=\"group\" aria-label=\"Decision\"><div id=\"review\" class=\"hx-review\" data-corn=\"review-bar\"><p class=\"hx-review-status\" data-review-status hidden><span data-review-verdict role=\"status\"></span><span data-review-when></span></p><div class=\"hx-review-form\" id=\"review-form\" data-review-form hidden><label class=\"hx-review-label\" for=\"review-note\" data-corn=\"review-label\"></label><textarea data-corn=\"review-note\" id=\"review-note\" class=\"hx-review-note\" rows=\"2\" maxlength=\"20000\"></textarea><p class=\"hx-review-line\" id=\"review-sendback-line\" data-review-sendback-line></p><div class=\"hx-review-row\"><button type=\"button\" class=\"hx-btn hx-btn--quiet\" data-review-cancel data-corn-kind=\"quiet\">Cancel</button></div></div><p class=\"hx-review-msg\" data-review-loadfail role=\"alert\" hidden data-corn=\"message\" data-corn-state=\"failure\"><span data-review-loadfail-text></span> <button type=\"button\" class=\"hx-btn hx-btn--quiet\" data-review-retry data-corn-kind=\"quiet\">Retry</button></p><p class=\"hx-review-msg\" data-review-msg role=\"alert\" hidden></p><p class=\"hx-review-line\" id=\"review-hint\" data-review-hint role=\"status\" hidden></p><details class=\"hx-sent-edits\" data-corn=\"sent-edits\" data-review-sent hidden><summary data-corn=\"summary\" data-review-sent-summary></summary><ul class=\"hx-whatif-list\" data-review-sent-list></ul></details><div class=\"hx-review-landing\" data-corn=\"notice\" data-corn-state=\"waiting\" data-review-landing hidden><p data-review-landing-text></p><button type=\"button\" class=\"hx-btn hx-btn--quiet\" data-review-cancel-landing data-corn-kind=\"quiet\"></button></div><p class=\"hx-review-ask\" id=\"review-ask\" data-corn=\"message\" data-corn-state=\"waiting\" data-review-ask role=\"alert\" hidden></p><p class=\"hx-decision-line\" id=\"review-line\" data-review-line></p><div class=\"hx-hold\" data-review-hold hidden aria-hidden=\"true\"><span class=\"hx-hold-fill\" data-review-hold-fill></span></div><p class=\"hx-sr-only\" data-review-hold-live role=\"status\"></p></div><div class=\"hx-proposal-actions\"><button data-corn-kind=\"secondary\" type=\"button\" class=\"hx-btn\" data-review=\"notes\" data-peek-ok title=\"Send it back to the drafting agent with a note and your edits\" data-corn-string=\"sendBack\">Send back</button><button type=\"button\" class=\"hx-btn hx-review-undo\" data-review-undo data-corn-kind=\"secondary\" hidden></button><button type=\"button\" class=\"hx-btn hx-btn--approve\" data-review=\"approved\" data-peek-ok title=\"Sign this proposal off\" data-corn-kind=\"approve\" data-corn-string=\"approve\">Approve</button></div></div>" });
3580
+ function Na(e, t, n = {}) {
3581
+ let { state: r } = t, i = A(t), o = typeof n.now == "function" ? n.now : () => Date.now(), s = typeof n.unnamed == "string" && n.unnamed ? n.unnamed : "", c = Se(t), l = oe(t, e, Ma().foot, n.slots, "foot");
3582
+ i.keepParts(...l);
3583
+ let u = l[0], d = u.querySelector("#review"), f = u.querySelector(".hx-proposal-actions"), p = !1, m = {
3584
+ key: null,
3585
+ reviewable: !1,
3586
+ review: null,
3587
+ loadFailed: !1,
3588
+ busy: !1,
3589
+ noting: !1,
3590
+ message: "",
3591
+ hint: "",
3592
+ facts: null,
3593
+ factsState: "loading",
3594
+ factsAt: 0,
3595
+ asking: null,
3596
+ hold: null,
3597
+ sent: null
3598
+ }, h = () => r.proposalSlug || null, g = () => r.proposal && h() ? `${r.proposalSource || ""}/${h()}` : null, _ = () => r.proposalSource ? `?source=${encodeURIComponent(r.proposalSource)}` : "", y = () => `/proposals/${encodeURIComponent(h())}/review${_()}`, b = (e) => `/proposals/${encodeURIComponent(h())}/decision${_()}${e ? "&fresh=1" : ""}`, x = (e) => d.querySelector(e), S = (e) => u.querySelector(`[data-review="${e}"]`), C = () => u.querySelector("[data-review-undo]"), w = () => {
3599
+ let e = t.ask("whatif:edits");
3600
+ return Array.isArray(e) ? e : [];
3601
+ }, T = () => {
3602
+ let e = t.ask("whatif:form");
3603
+ return e === void 0 ? null : e;
3604
+ }, E = () => {
3605
+ let e = t.ask("changes:played-line");
3606
+ return typeof e == "string" ? e : "";
3607
+ }, D = () => r.whatIf ? r.whatIf.edits.length : 0;
3608
+ function O() {
3609
+ return xa({
3610
+ source: r.proposalSource,
3611
+ facts: m.facts,
3612
+ factsState: m.factsState,
3613
+ review: m.review,
3614
+ edits: D(),
3615
+ form: T(),
3616
+ played: E(),
3617
+ now: o()
3618
+ });
3619
+ }
3620
+ function k() {
3621
+ if (p) return;
3622
+ let e = x("[data-review-status]"), { verdict: n, when: i } = Le(m.review, o()), c = x("[data-review-verdict]");
3623
+ c.textContent !== n && (c.textContent = n), x("[data-review-when]").textContent = i ? ` ${i}` : "", e.hidden = !n;
3624
+ let l = x("[data-review-loadfail]");
3625
+ l.hidden = !m.loadFailed, x("[data-review-loadfail-text]").textContent = m.loadFailed ? `Could not load this proposal's reviews.${t.offline() ? " You are offline." : ""} It may already be approved or sent back; try again before you decide.` : "";
3626
+ let d = O(), h = "";
3627
+ if (m.asking && !m.hold) {
3628
+ if (m.asking.verdict === "approved") h = d.reasons.length ? va(d.reasons) : "";
3629
+ else {
3630
+ let e = Ca({ form: T() });
3631
+ h = e.asks ? e.ask : "";
3632
+ }
3633
+ h || (m.asking = null);
3634
+ }
3635
+ let g = m.hold, _ = S("approved"), v = S("notes"), y = m.asking && m.asking.verdict === "approved" ? "anyway" : g && g.verdict === "approved" ? "hold" : d.approve === "done" ? "done" : "plain", b = m.asking && m.asking.verdict === "notes" ? "anyway" : g && g.verdict === "notes" ? "hold" : "plain", w = x("[data-review-line]"), E = !m.key && !!r.proposal && !!s;
3636
+ w.textContent = m.key ? d.line : E ? s : "", w.hidden = !m.key && !E || !!h, f.hidden = E;
3637
+ let k = x("[data-review-ask]");
3638
+ k.textContent !== h && (k.textContent = h), k.hidden = !h, x("[data-review-sendback-line]").textContent = Sa({
3639
+ source: r.proposalSource,
3640
+ edits: D()
3641
+ });
3642
+ let A = m.key && d.approve === "refused";
3643
+ for (let e of u.querySelectorAll("[data-review]")) !m.reviewable || m.busy || g || e === _ && (d.approve === "done" || d.approve === "reading") ? e.setAttribute("aria-disabled", "true") : e.removeAttribute("aria-disabled"), e.disabled = !1, m.key && e === _ ? e.setAttribute("aria-describedby", h ? "review-ask" : "review-line") : m.key && !m.noting && e === v && A ? e.setAttribute("aria-describedby", "review-line") : m.key && m.noting && e === v ? e.setAttribute("aria-describedby", "review-sendback-line") : e.removeAttribute("aria-describedby");
3644
+ _ && (_.textContent = y === "hold" ? Ta("approved", g.left) : y === "anyway" ? a(t, "approveAnyway") : y === "done" ? a(t, "approved") : a(t, "approve"), _.dataset.holding = y === "hold" ? "true" : "false"), v && (v.textContent = b === "hold" ? Ta("notes", g.left) : b === "anyway" ? a(t, "sendBackAnyway") : m.noting ? a(t, "sendBackWithNote") : a(t, "sendBack"), v.setAttribute("aria-expanded", String(m.noting)), v.setAttribute("aria-controls", "review-form"), v.dataset.holding = b === "hold" ? "true" : "false");
3645
+ let j = C();
3646
+ j && (j.hidden = !g, j.textContent = a(t, "undo"));
3647
+ let M = x("[data-review-hold]");
3648
+ M.hidden = !g, x("[data-review-form]").hidden = !m.noting, x("[data-review-cancel]").disabled = m.busy || !!g;
3649
+ let N = x("#review-note");
3650
+ N.disabled = !m.reviewable, N.readOnly = !!g;
3651
+ for (let [e, t] of [["[data-review-msg]", m.message], ["[data-review-hint]", m.reviewable ? m.hint : ""]]) {
3652
+ let n = x(e);
3653
+ n.hidden = !t, n.textContent = t;
3654
+ }
3655
+ let P = x("[data-review-sent]");
3656
+ if (P.hidden = !m.sent, m.sent) {
3657
+ x("[data-review-sent-summary]").textContent = Oa(m.sent.lines.length);
3658
+ let e = x("[data-review-sent-list]");
3659
+ e.dataset.for !== m.sent.key && (e.dataset.for = m.sent.key, e.replaceChildren(...m.sent.lines.map((e) => {
3660
+ let n = t.doc.createElement("li");
3661
+ return n.className = "hx-whatif-edit", n.textContent = e, n;
3662
+ })));
3663
+ }
3664
+ let F = x("[data-review-landing]"), I = m.reviewable && m.facts && m.facts.landing ? m.facts.landing : null;
3665
+ F.hidden = !I, I && (x("[data-review-landing-text]").textContent = `Landing on approval waits for PR #${m.facts.pull.number} to be ready and green.`);
3666
+ }
3667
+ x(".hx-review-label").textContent = a(t, "reviewNoteLabel"), x("#review-note").setAttribute("placeholder", a(t, "reviewNotePlaceholder")), x("[data-review-cancel-landing]").textContent = a(t, "cancelLanding"), C().textContent = a(t, "undo");
3668
+ function j() {
3669
+ m.noting = !0, m.message = "", k(), v(t) && vn(t, "proposal"), x("#review-note").focus();
3670
+ let e = S("notes");
3671
+ v(t) && e && typeof e.scrollIntoView == "function" && e.scrollIntoView({ block: "nearest" });
3672
+ }
3673
+ function M() {
3674
+ m.noting = !1, m.asking = null, m.message = "", x("#review-note").value = "", z(m.key), k();
3675
+ let e = S("notes");
3676
+ e && e.focus();
3677
+ }
3678
+ function N({ open: e }) {
3679
+ let t = e ? g() : null;
3680
+ if (d.hidden = !(t || e && s), t === m.key) {
3681
+ k();
3682
+ return;
3683
+ }
3684
+ m.hold && W(e ? "other" : "closed", { quiet: !1 }), m.key = t, m.reviewable = !!t && Be(r.proposalSource), m.review = null, m.loadFailed = !1, m.busy = !1, m.noting = !1, m.asking = null, m.sent = null, m.facts = null, m.factsState = m.reviewable ? "loading" : "ready", m.message = m.hint = "";
3685
+ let n = x("#review-note"), i = t && m.reviewable ? R(t) : "";
3686
+ n && (n.value = i), i && (m.noting = !0), k(), t && m.reviewable && (V(t), F());
3687
+ }
3688
+ let P = (e, n) => {
3689
+ (e === 401 || e === 403) && t.emit("auth", {
3690
+ status: e,
3691
+ during: n
3692
+ });
3693
+ };
3694
+ async function F({ fresh: e = !1 } = {}) {
3695
+ let t = m.key;
3696
+ if (!t || !m.reviewable || !K(r.proposalSource)) return;
3697
+ m.factsAt = o();
3698
+ let n = null;
3699
+ try {
3700
+ let t = await c(b(e), { cache: "no-store" });
3701
+ t.ok ? n = await t.json() : P(t.status, "facts");
3702
+ } catch {
3703
+ n = null;
3704
+ }
3705
+ if (p || t !== m.key) return;
3706
+ let i = n && n.pull ? n.pull.head : null, a = m.facts && m.facts.pull ? m.facts.pull.head : null;
3707
+ m.facts = n && n.pull ? n : null, m.factsState = m.facts ? "ready" : "unread", i && a && i !== a && V(t), k();
3708
+ }
3709
+ let I = () => {
3710
+ try {
3711
+ return t.win.sessionStorage;
3712
+ } catch {
3713
+ return null;
3714
+ }
3715
+ };
3716
+ function L(e, t) {
3717
+ if (e) try {
3718
+ t && t.trim() ? I().setItem(ja + e, t.slice(0, 2e4)) : I().removeItem(ja + e);
3719
+ } catch {}
3720
+ }
3721
+ function R(e) {
3722
+ try {
3723
+ return I().getItem(ja + e) || "";
3724
+ } catch {
3725
+ return "";
3726
+ }
3727
+ }
3728
+ function z(e) {
3729
+ if (e) try {
3730
+ I().removeItem(ja + e);
3731
+ } catch {}
3732
+ }
3733
+ function B(e = 0) {
3734
+ m.key && m.reviewable && !m.hold && !m.busy && (t.hidden() || o() - m.factsAt < e || F());
3735
+ }
3736
+ function ee() {
3737
+ let e = t.active(), n = !!e && d.contains(e) && e.matches("[data-review-retry]");
3738
+ m.loadFailed = !1, k(), n && t.emit("proposal:focus-title");
3739
+ }
3740
+ async function V(e) {
3741
+ try {
3742
+ let t = await c(y(), { cache: "no-store" });
3743
+ if (p || e !== m.key) return;
3744
+ if (t.status === 404) {
3745
+ m.review = null, ee();
3746
+ return;
3747
+ }
3748
+ if (!t.ok) throw P(t.status, "review"), Error(`The server answered ${t.status}.`);
3749
+ let n = await t.json();
3750
+ if (p || e !== m.key) return;
3751
+ n && typeof n.verdict == "string" && (m.review = {
3752
+ verdict: n.verdict,
3753
+ at: n.at,
3754
+ current: n.current === !0
3755
+ }), ee();
3756
+ } catch {
3757
+ !p && e === m.key && (m.loadFailed = !0, k());
3758
+ }
3759
+ }
3760
+ function te(e) {
3761
+ if (!e.target.closest || e.detail > 1 && e.target.closest("[data-review], [data-review-undo]")) return;
3762
+ if (e.target.closest("[data-review-undo]")) {
3763
+ m.hold && W("undo");
3764
+ return;
3765
+ }
3766
+ if (m.hold || m.busy) return;
3767
+ if (e.target.closest("[data-review-cancel-landing]")) {
3768
+ ie();
3769
+ return;
3770
+ }
3771
+ if (e.target.closest("[data-review-cancel]")) {
3772
+ M();
3773
+ return;
3774
+ }
3775
+ if (e.target.closest("[data-review-retry]")) {
3776
+ x("[data-review-loadfail-text]").textContent = "Reading the reviews again …", V(m.key);
3777
+ return;
3778
+ }
3779
+ let t = e.target.closest("[data-review]");
3780
+ if (!t) return;
3781
+ let n = t.dataset.review;
3782
+ m.asking && m.asking.verdict !== n && (m.asking = null, k()), t.getAttribute("aria-disabled") !== "true" && m.reviewable && (n === "notes" && !m.noting ? j() : ne(n));
3783
+ }
3784
+ function ne(e) {
3785
+ if (m.message = "", m.hint = "", m.sent = null, t.offline()) {
3786
+ m.asking = null, m.message = _e(t, e === "approved" ? "Your approval" : "Your send back"), k();
3787
+ return;
3788
+ }
3789
+ let n = [];
3790
+ if (e === "notes") {
3791
+ let e = Re(x("#review-note").value);
3792
+ if (e) {
3793
+ m.message = e, m.noting = !0, k(), v(t) && vn(t, "proposal"), x("#review-note").focus();
3794
+ return;
3795
+ }
3796
+ let r = Ca({ form: T() });
3797
+ if (r.asks && !(m.asking && m.asking.verdict === "notes")) {
3798
+ m.asking = {
3799
+ verdict: "notes",
3800
+ answered: []
3801
+ }, k(), H(t, r.ask);
3802
+ return;
3803
+ }
3804
+ n = r.reasons.map((e) => e.key);
3805
+ } else {
3806
+ let e = O();
3807
+ if (e.approve === "refused" || e.approve === "done" || e.approve === "reading") {
3808
+ k();
3809
+ return;
3810
+ }
3811
+ if (e.approve === "asks" && !(m.asking && m.asking.verdict === "approved")) {
3812
+ m.asking = {
3813
+ verdict: "approved",
3814
+ answered: []
3815
+ }, k();
3816
+ return;
3817
+ }
3818
+ n = e.reasons.map((e) => e.key);
3819
+ }
3820
+ U(e, n);
3821
+ }
3822
+ function U(e, t) {
3823
+ let n = {
3824
+ ...r.proposalSha256 ? { sha256: r.proposalSha256 } : {},
3825
+ ...m.facts && m.facts.pull && m.facts.pull.head ? { headSha: m.facts.pull.head } : {}
3826
+ }, i = {
3827
+ ...ze(e, e === "notes" ? x("#review-note").value : "", w()),
3828
+ ...n
3829
+ };
3830
+ m.asking = null;
3831
+ let a = {
3832
+ verdict: e,
3833
+ body: i,
3834
+ answered: t,
3835
+ left: ra / 1e3,
3836
+ tick: null,
3837
+ end: null
3838
+ };
3839
+ m.hold = a, a.tick = setInterval(() => {
3840
+ a.left = Math.max(0, a.left - 1), k();
3841
+ }, 1e3), a.end = setTimeout(() => {
3842
+ re(a);
3843
+ }, ra), x("[data-review-hold-fill]").style.animationDuration = `${ra}ms`, k(), x("[data-review-hold-live]").textContent = Ea(e, ra / 1e3);
3844
+ let o = C();
3845
+ o && o.focus();
3846
+ }
3847
+ function W(e, { quiet: n = !1 } = {}) {
3848
+ let r = m.hold;
3849
+ if (!r) return;
3850
+ clearInterval(r.tick), clearTimeout(r.end), m.hold = null;
3851
+ let i = Da(r.verdict, e);
3852
+ if (e === "closed" || e === "other" ? n || H(t, i) : m.message = i, p) return;
3853
+ k();
3854
+ let a = x("[data-review-hold-live]");
3855
+ a && (a.textContent = e === "closed" || e === "other" ? "" : i), e !== "closed" && e !== "other" && S(r.verdict)?.focus();
3856
+ }
3857
+ async function re(e) {
3858
+ if (m.hold !== e) return;
3859
+ if (clearInterval(e.tick), t.offline()) {
3860
+ W("offline");
3861
+ return;
3862
+ }
3863
+ if (t.hidden()) {
3864
+ W("hidden");
3865
+ return;
3866
+ }
3867
+ let n = m.key;
3868
+ if (e.verdict === "approved" && m.reviewable && await F({ fresh: !0 }), p || m.hold !== e || n !== m.key) return;
3869
+ let r = m.facts && m.facts.pull ? m.facts.pull.head : null;
3870
+ if (e.verdict === "approved" && e.body.headSha && r && r !== e.body.headSha) {
3871
+ W("pushed");
3872
+ return;
3873
+ }
3874
+ if (e.verdict === "approved" && ya(_a({
3875
+ facts: m.facts,
3876
+ edits: e.body.edits.length,
3877
+ form: T()
3878
+ }), e.answered).length) {
3879
+ m.hold = null, m.asking = {
3880
+ verdict: "approved",
3881
+ answered: e.answered
3882
+ }, k(), S("approved")?.focus();
3883
+ return;
3884
+ }
3885
+ m.hold = null;
3886
+ let i = x("[data-review-hold-live]");
3887
+ i && (i.textContent = ""), await ae(e.verdict, { body: e.body });
3888
+ }
3889
+ async function ie() {
3890
+ let e = K(r.proposalSource);
3891
+ if (!e) return;
3892
+ m.busy = !0, k();
3893
+ let n = "";
3894
+ try {
3895
+ let t = await c(`/api/forge/pulls/${e}/landing/cancel`, {
3896
+ method: "POST",
3897
+ headers: { "Content-Type": "application/json" },
3898
+ body: "{}"
3899
+ });
3900
+ if (!t.ok) {
3901
+ P(t.status, "landing");
3902
+ let e = "";
3903
+ try {
3904
+ e = (await t.json()).error || "";
3905
+ } catch {}
3906
+ n = wa(t.status, e);
3907
+ }
3908
+ } catch {
3909
+ n = _e(t, "Cancelling the landing");
3910
+ }
3911
+ p || (m.busy = !1, m.message = n, await F({ fresh: !0 }), p || (k(), n || H(t, "Landing cancelled. The approval stands and the PR stays open."), (S("approved") || S("notes"))?.focus()));
3912
+ }
3913
+ async function ae(e, n = {}) {
3914
+ if (p || !r.proposal || !h() || !m.reviewable) return !1;
3915
+ let i = x("#review-note"), a = e === "notes" ? i.value : "";
3916
+ if (m.hint = "", e === "notes" && !n.body) {
3917
+ let e = Re(a);
3918
+ if (e) return m.message = e, m.noting = !0, k(), v(t) && vn(t, "proposal"), i.focus(), !1;
3919
+ }
3920
+ m.message = "", m.busy = !0, k();
3921
+ let o = m.key, s = h(), l = r.proposalSource || null, u = n.body || ze(e, a, w()), d = t.ask("whatif:describe"), f = e === "notes" && Array.isArray(d) ? d : [], g, _ = e === "approved" ? "Your approval" : "Your send back", b;
3922
+ try {
3923
+ b = await c(y(), {
3924
+ method: "PUT",
3925
+ headers: { "Content-Type": "application/json" },
3926
+ body: JSON.stringify(u)
3927
+ });
3928
+ } catch {
3929
+ return p || (m.busy = !1, m.message = _e(t, _), k()), !1;
3930
+ }
3931
+ if (p) return !1;
3932
+ try {
3933
+ let e = null;
3934
+ try {
3935
+ e = await b.json();
3936
+ } catch {}
3937
+ if (b.status === 401 || b.redirected) throw Object.assign(/* @__PURE__ */ Error(""), { status: 401 });
3938
+ if (!b.ok) throw Object.assign(Error(e && e.error || ""), { status: b.status });
3939
+ g = e;
3940
+ } catch (e) {
3941
+ return p || (m.busy = !1, m.message = wa(e.status || b.status, e.message), k(), P(e.status || b.status, "send"), (b.status === 409 || b.status === 429) && o === m.key && (V(o), F({ fresh: !0 }))), !1;
3942
+ }
3943
+ if (m.busy = !1, o !== m.key) return t.emit("decision", {
3944
+ outcome: e,
3945
+ review: g,
3946
+ slug: s,
3947
+ source: l,
3948
+ open: !1
3949
+ }), !0;
3950
+ m.review = {
3951
+ verdict: g.verdict,
3952
+ at: g.at,
3953
+ current: g.verdict === "approved"
3954
+ }, m.hint = e === "approved" ? Ve(e, u.edits.length) : "", g.posted === !1 && (m.hint = `It was approved already${g.by ? ` by ${g.by}` : ""}; nothing new was posted.`), z(o), e === "notes" && f.length && (m.sent = {
3955
+ key: `${g.at}`,
3956
+ lines: f
3957
+ }), i.value = "";
3958
+ let C = m.noting;
3959
+ m.noting = !1, k();
3960
+ let T = t.active(), E = !T || T === t.doc.body || !T.isConnected || T.hidden;
3961
+ return e === "approved" ? E && S("approved")?.focus() : (C || E) && S("notes")?.focus(), t.emit("decision", {
3962
+ outcome: e,
3963
+ review: g,
3964
+ slug: s,
3965
+ source: l,
3966
+ open: !0
3967
+ }), t.emit("mockups:refresh"), e === "notes" && t.emit("whatif:clear"), F({ fresh: !0 }), !0;
3968
+ }
3969
+ i.listen(u, "click", te), i.listen(d, "input", (e) => {
3970
+ e.target && e.target.id === "review-note" && L(m.key, e.target.value), m.message && (m.message = "", k());
3971
+ }), i.listen(d, "keydown", (e) => {
3972
+ e.key === "Escape" && m.noting && !m.asking && !m.hold && (e.stopPropagation(), M());
3973
+ }), i.listen(t.root, "keydown", (e) => {
3974
+ e.repeat && (e.key === "Enter" || e.key === " ") && e.target && e.target.closest && e.target.closest("#review-decision [data-review], #review-decision [data-review-undo]") ? (e.preventDefault(), e.stopPropagation()) : e.key === "Escape" && m.key && (m.hold ? (e.stopPropagation(), e.preventDefault(), W("escape")) : m.asking && (e.stopPropagation(), e.preventDefault(), m.asking = null, k()));
3975
+ }, !0), i.own(t.onNetwork((e) => {
3976
+ e ? m.hold && W("offline") : m.loadFailed && m.key && V(m.key);
3977
+ })), i.own(t.onWindowFocus(() => B(5e3))), i.own(t.onPageHide(() => {
3978
+ m.hold && W("closed", { quiet: !0 });
3979
+ })), i.own(t.onHide(() => {
3980
+ m.hold && W("hidden");
3981
+ })), i.own(t.onShown(() => B(5e3))), i.on("proposal:bar", N), i.on("whatif:edits-changed", () => {
3982
+ m.hold && W("edits"), k();
3983
+ }), i.on("changes:paint", () => k());
3984
+ let se = setInterval(() => {
3985
+ m.review && k();
3986
+ }, ka), ce = setInterval(() => B(), Aa);
3987
+ return i.own(() => {
3988
+ clearInterval(se), clearInterval(ce);
3989
+ }), i.own(() => {
3990
+ p = !0, m.hold &&= (clearInterval(m.hold.tick), clearTimeout(m.hold.end), null), l.forEach((e) => e.remove());
3991
+ }), N({ open: !!r.proposal }), {
3992
+ elements: l,
3993
+ sendReview: ae,
3994
+ loadFacts: F,
3995
+ paint: k,
3996
+ update() {
3997
+ N({ open: !!r.proposal });
3998
+ },
3999
+ destroy: () => i.destroy()
4000
+ };
4001
+ }
4002
+ // ../explorer/pieces/review.js
4003
+ var Pa = "Arrow keys pan, plus and minus zoom, 0 fits the map. N and P select the next and the previous node, Home and End the first and the last. F frames the selected node and what it lights. Enter goes to the selected node's panel, Escape closes it.", Fa = [
4004
+ "map",
4005
+ "orbit",
4006
+ "dataflow"
4007
+ ], Ia = "There is no map to show: the topology has no nodes.", La = "<div class=\"hx-stage\" data-corn=\"stage\"><!--corn-piece:map/stage--><div id=\"sheet-dock\" class=\"hx-dock\" data-corn=\"dock\"><!--corn-piece:proposal/bar--><!--corn-piece:changes/column--><!--corn-piece:node-panel/drawer--></div><!--corn-piece:node-panel/backdrop--><p class=\"hx-review-empty\" data-corn=\"empty\" role=\"status\" hidden></p></div><div class=\"hx-review-spare\" hidden><!--corn-piece:proposal/menu--></div>";
4008
+ function Ra(e, t) {
4009
+ let n = {}, r = e.createTreeWalker(t, 128);
4010
+ for (let e = r.nextNode(); e; e = r.nextNode()) e.data.startsWith("corn-piece:") && (n[e.data.slice(11)] = e);
4011
+ return n;
4012
+ }
4013
+ function za(e, t, n = {}) {
4014
+ let r = e.ownerDocument || e, i = r.createElement("div");
4015
+ i.setAttribute("data-corn", "review"), i.setAttribute("part", "review"), i.setAttribute("role", "region"), i.setAttribute("aria-label", typeof n.label == "string" && n.label.trim() ? n.label.trim() : "Proposal review"), i.innerHTML = N(La), e.append(i);
4016
+ let a = !t, o = a && typeof n.src == "string" ? n.src !== "" : a && n.src !== void 0 && n.src !== null, c = o ? Te(n.src) : null, l = !!c && !c.ok;
4017
+ a ? t = B({
4018
+ root: i,
4019
+ base: c ? c.ok ? c.base : "" : n.base || "",
4020
+ fetch: l ? () => Promise.reject(/* @__PURE__ */ TypeError("The review has no server: its src is not an address.")) : n.fetch,
4021
+ strings: n.strings
4022
+ }) : n.strings !== void 0 && R(t, n.strings);
4023
+ let { state: u } = t;
4024
+ on(t, i), _(t, i);
4025
+ let d = !1, f = !1, p = !0, m = !1, h = !1, g = () => {
4026
+ if (m || h || d || !f || !p) return;
4027
+ let e = t.map;
4028
+ if (!e || typeof e.onPaint != "function") {
4029
+ m = !0, n.onReady && n.onReady();
4030
+ return;
4031
+ }
4032
+ h = !0;
4033
+ let r = e.onPaint(() => {
4034
+ r(), h = !1, m || d || !p || (m = !0, n.onReady && n.onReady());
4035
+ });
4036
+ e.render();
4037
+ }, v = Ra(r, i), y = he(i, t, {
4038
+ slots: { stage: v["map/stage"] },
4039
+ measureCovered: () => s(t),
4040
+ keysHelp: Pa,
4041
+ renderer: n.renderer,
4042
+ theme: n.theme,
4043
+ tokens: n.tokens,
4044
+ onSelect: n.onSelect,
4045
+ onReady: () => {
4046
+ f = !0, g();
4047
+ }
4048
+ }), b = mr(i, t, { slots: {
4049
+ drawer: v["node-panel/drawer"],
4050
+ backdrop: v["node-panel/backdrop"]
4051
+ } }), x = Wr(i, t, {
4052
+ slots: {
4053
+ bar: v["proposal/bar"],
4054
+ menu: v["proposal/menu"]
4055
+ },
4056
+ edit: !1
4057
+ }), S = na(i, t, {
4058
+ slots: { column: v["changes/column"] },
4059
+ checker: n.checker
4060
+ }), C = Ra(r, i)["decision/foot"], w = Na(i, t, {
4061
+ slots: { foot: C },
4062
+ now: n.now,
4063
+ unnamed: ba
4064
+ }), T = t.on("map:set", ({ nodes: e, edges: n }) => (me(t, e, n), !0)), E = !n.base && !n.fetch && !(c && c.ok), D = {
4065
+ topology: void 0,
4066
+ proposal: null,
4067
+ source: null,
4068
+ slug: null,
4069
+ sha256: null,
4070
+ proposalView: null,
4071
+ shown: null,
4072
+ hasTopology: !1,
4073
+ held: !1
4074
+ }, O = () => {
4075
+ x.update(), S.update(), w.update(), b.update();
4076
+ };
4077
+ function k() {
4078
+ if (d) return;
4079
+ let e = D.proposal;
4080
+ if (e == null || e === "") {
4081
+ D.held = !1, D.shown = null, p = !0, u.proposal && Dr(t), g();
4082
+ return;
4083
+ }
4084
+ if (!D.hasTopology) {
4085
+ D.held = !0, p = !1;
4086
+ return;
4087
+ }
4088
+ D.held = !1;
4089
+ let n = D.proposalView;
4090
+ if (typeof e == "string" && l) {
4091
+ p = !0, g();
4092
+ return;
4093
+ }
4094
+ if (typeof e == "string" && E) {
4095
+ let n = lt(e) ? `${e} cannot be opened here: there is no cornfield server to read it from (the review has no src).` : ut(e);
4096
+ D.shown = null, br(t, n, !0, []), t.emit("proposal:failed", {
4097
+ slug: e,
4098
+ source: D.source,
4099
+ status: 0,
4100
+ notFound: !1,
4101
+ message: n
4102
+ }), p = !0, g();
4103
+ return;
4104
+ }
4105
+ if (typeof e == "string") {
4106
+ if (u.proposal && u.proposalSlug === e && (!D.source || D.source === u.proposalSource)) {
4107
+ D.shown = `${e}\u0000${D.source || ""}`, tt.includes(n) && u.proposalView !== n && x.update({ view: n }), p = !0;
4108
+ return;
4109
+ }
4110
+ let t = `${e}\u0000${D.source || ""}`;
4111
+ if (D.shown === t && u.proposal) return;
4112
+ D.shown = t, p = !1;
4113
+ let r = x.update({
4114
+ proposal: e,
4115
+ source: D.source,
4116
+ view: n
4117
+ });
4118
+ return Promise.resolve(r).then(() => {
4119
+ D.shown === t && (p = !0, g());
4120
+ }), r;
4121
+ }
4122
+ if (D.shown === e && u.proposal) return;
4123
+ D.shown = e;
4124
+ let r = E ? {} : {
4125
+ source: D.source,
4126
+ slug: D.slug,
4127
+ sha256: D.sha256
4128
+ };
4129
+ x.update({
4130
+ proposal: e,
4131
+ ...r,
4132
+ view: n
4133
+ }), p = !0, g();
4134
+ }
4135
+ function A(e) {
4136
+ D.hasTopology = fe(t, e);
4137
+ let n = i.querySelector(".hx-review-empty");
4138
+ n.textContent = D.hasTopology ? "" : Ia, n.hidden = D.hasTopology, D.hasTopology ? (pe(t), u.proposal ? Er(t, void 0, { fit: !0 }) : y.fit(), t.map.render(), t.map.ensureFlowLoop(), D.held && k()) : t.map.render();
4139
+ }
4140
+ function j(e) {
4141
+ let n = e === "dataflow" ? "dataflow" : "orbit";
4142
+ u.view !== n && (u.view = n, t.emit("scenario:clear"), t.touchScene(), u.nodes.length && (me(t, u.mapNodes, u.mapEdges), y.fit(), t.map.ensureFlowLoop()), t.emit("view", u.view));
4143
+ }
4144
+ function M(e) {
4145
+ tt.includes(e) ? (D.proposalView = e, u.proposal && x.update({ view: e })) : Fa.includes(e) && j(e);
4146
+ }
4147
+ function P(e) {
4148
+ e && typeof e == "object" && ("layers" in e && be(t, e.layers), e.theme && y.applyTheme(e.theme));
4149
+ }
4150
+ function F(e) {
4151
+ e !== D.topology && (D.topology = e, A(e));
4152
+ }
4153
+ let I = {}, L = null, z = (e) => {
4154
+ L ? L.provide(e) : o && Object.assign(I, e);
4155
+ };
4156
+ D.useTheme = !!n.useTheme, D.theme = n.theme, o && n.strings !== void 0 && z({ strings: n.strings });
4157
+ let ee = () => t.base ? De(t.base, typeof n.pageUrl == "function" ? n.pageUrl() : "") : "", V = [], te = "";
4158
+ V.push(t.on("auth", ({ status: e, during: t }) => {
4159
+ let r = ee();
4160
+ if (L && L.showSignIn({
4161
+ status: e,
4162
+ signIn: r
4163
+ }), t === "facts") {
4164
+ if (te === `${e}`) return;
4165
+ te = `${e}`;
4166
+ } else te = "";
4167
+ n.onAuth && n.onAuth({
4168
+ status: e,
4169
+ signIn: r,
4170
+ during: t
4171
+ });
4172
+ })), V.push(t.on("decision", () => {
4173
+ te = "", L && L.clearSignIn();
4174
+ })), n.onDecision && V.push(t.on("decision", ({ outcome: e, review: t, slug: r, source: i, open: a }) => n.onDecision({
4175
+ outcome: e,
4176
+ proposal: r,
4177
+ source: i,
4178
+ open: a,
4179
+ review: t
4180
+ }))), n.onNavigate && V.push(t.on("proposal", ({ change: e, slug: t, source: r, pinSource: i, view: a }) => n.onNavigate({
4181
+ proposal: t,
4182
+ source: i ? r : null,
4183
+ view: e === "closed" ? null : a,
4184
+ change: e
4185
+ }))), n.onError && V.push(t.on("proposal:failed", ({ message: e }) => n.onError({
4186
+ kind: "proposal",
4187
+ message: e
4188
+ }))), V.push(t.on("proposal:specs-list", () => !1)), o && import("./review-source-CPiFTfyc.js").then(({ attachSource: r }) => {
4189
+ d || (L = r(t, {
4190
+ root: e,
4191
+ stage: i.querySelector("[data-corn=\"stage\"]"),
4192
+ parsed: c,
4193
+ tokens: n.tokens,
4194
+ version: n.version,
4195
+ pageUrl: n.pageUrl,
4196
+ useTheme: D.useTheme,
4197
+ theme: D.theme,
4198
+ topology: I.topology,
4199
+ config: I.config,
4200
+ strings: I.strings,
4201
+ onTopology: (e) => F(e),
4202
+ onConfig: () => {
4203
+ _(t, i), O();
4204
+ },
4205
+ onAuth: (e) => {
4206
+ n.onAuth && n.onAuth(e);
4207
+ },
4208
+ onError: (e) => {
4209
+ n.onError && n.onError(e);
4210
+ },
4211
+ onMode: () => y.refresh(),
4212
+ focusMap: () => {
4213
+ u.canvas && u.canvas.focus();
4214
+ }
4215
+ }));
4216
+ }, (e) => {
4217
+ !d && n.onError && n.onError({
4218
+ kind: "offline",
4219
+ message: `the review's loader did not load: ${e && e.message ? e.message : e}`
4220
+ });
4221
+ });
4222
+ function H(e = {}) {
4223
+ if (d) return;
4224
+ let n = !1;
4225
+ "strings" in e && (R(t, e.strings), _(t, i), n = !0, z({ strings: e.strings })), "useTheme" in e && (D.useTheme = !!e.useTheme, L && L.setUseTheme(D.useTheme)), "config" in e && (o ? z({ config: e.config || null }) : P(e.config)), "theme" in e && (y.update({ theme: e.theme }), D.theme = e.theme, L && L.setTheme(e.theme)), "checker" in e && S.update({ checker: e.checker }), "topology" in e && (o ? z({ topology: e.topology || null }) : F(e.topology));
4226
+ let r, a = [
4227
+ "proposal",
4228
+ "source",
4229
+ "slug",
4230
+ "sha256"
4231
+ ].some((t) => t in e);
4232
+ return a && ("source" in e && (D.source = e.source || null), "slug" in e && (D.slug = e.slug || null), "sha256" in e && (D.sha256 = e.sha256 || null), "proposal" in e && (D.proposal = e.proposal, D.shown = null), "view" in e && tt.includes(e.view) && (D.proposalView = e.view), r = k()), "view" in e && !(a && tt.includes(e.view)) && M(e.view), "node" in e && y.update({ node: e.node }), n && O(), r;
4233
+ }
4234
+ function ne() {
4235
+ if (!d) {
4236
+ d = !0, T(), V.forEach((e) => e()), L && L.destroy(), L = null;
4237
+ for (let e of [
4238
+ w,
4239
+ S,
4240
+ x,
4241
+ b,
4242
+ y
4243
+ ]) e.destroy();
4244
+ on(t, null), i.remove(), a && t.destroy();
4245
+ }
4246
+ }
4247
+ let U = {};
4248
+ for (let e of [
4249
+ "config",
4250
+ "topology",
4251
+ "proposal",
4252
+ "source",
4253
+ "slug",
4254
+ "sha256",
4255
+ "view",
4256
+ "node"
4257
+ ]) n[e] !== void 0 && (U[e] = n[e]);
4258
+ if (o) for (let e of ["topology", "config"]) e in U && (z({ [e]: U[e] || null }), delete U[e]);
4259
+ return H(U), {
4260
+ inst: t,
4261
+ elements: [i],
4262
+ map: y,
4263
+ proposal: x,
4264
+ changes: S,
4265
+ decision: w,
4266
+ nodePanel: b,
4267
+ update: H,
4268
+ destroy: ne,
4269
+ fit: () => y.fit(),
4270
+ focusNode: (e) => y.focusNode(e),
4271
+ refresh: () => y.refresh()
4272
+ };
4273
+ }
4274
+ // \0stencil-css:/home/runner/work/CornField/CornField/components/src/components/corn-review/corn-review?tag=corn-review&encapsulation=shadow&__ext=css
4275
+ var Ba = () => ":host{contain:layout;min-width:0;height:100%;color:var(--corn-text);font-family:var(--corn-font);display:block}:host([hidden]){display:none!important}", Va = () => "*,:before,:after{box-sizing:border-box}*{--hx-control-h:var(--corn-control-height);--hx-seg-inner:calc(var(--hx-control-h) - var(--corn-space-1) - 2 * var(--corn-border))}@container corn-box (width<=767px){*{--hx-control-h:max(44px, var(--corn-control-height));--hx-seg-inner:var(--hx-control-h)}}img{image-rendering:var(--hx-pixelated,auto)}[hidden]{display:none!important}button{font:inherit;color:inherit;cursor:pointer}h1,h2,h3,p{margin:0}.glass{background:var(--corn-surface-1);-webkit-backdrop-filter:blur(var(--corn-blur));border:var(--corn-border) solid var(--corn-line);box-shadow:var(--corn-shadow)}.glass-header{background:color-mix(in srgb, var(--corn-ground) 88%, transparent);-webkit-backdrop-filter:blur(var(--corn-blur));border-bottom:var(--corn-border) solid var(--corn-line)}::-webkit-scrollbar{width:5px;height:5px}::-webkit-scrollbar-track{background:0 0}::-webkit-scrollbar-thumb{background:color-mix(in srgb, var(--corn-text) 18%, transparent);border-radius:var(--corn-radius-pill)}::-webkit-scrollbar-thumb:hover{background:color-mix(in srgb, var(--corn-text) 28%, transparent)}.hx-faint{color:var(--corn-text-3)}.hx-mono{font-family:var(--corn-mono);font-size:var(--corn-text-2xs)}.hx-strong{color:var(--corn-text-2)}.hx-bold{font-weight:700}.hx-name{color:var(--corn-text-2)}.hx-accent{color:var(--corn-accent-text)}.hx-good{color:var(--corn-ok)}.hx-warn{color:var(--corn-warn)}.hx-rom{color:var(--corn-hue-fuchsia)}.hx-link{color:var(--corn-info);text-decoration:underline}.hx-link-faint{color:var(--corn-text-3);font-family:var(--corn-mono);font-size:var(--corn-text-2xs)}.hx-link-faint:hover{color:var(--corn-warn)}.hx-code{color:var(--corn-warn);font-family:var(--corn-mono);font-size:var(--corn-text-2xs)}.hx-chips{gap:var(--corn-space-1);padding-top:var(--corn-space-1);flex-wrap:wrap;display:flex}.hx-pt{padding-top:var(--corn-space-3)}.hx-switch{border-radius:var(--corn-radius-pill);border:var(--corn-border) solid var(--corn-line);background:var(--corn-surface-3);flex:none;width:28px;height:16px;position:relative}.hx-switch:after{content:\"\";background:var(--corn-text-3);border-radius:50%;width:10px;height:10px;transition:transform .15s;position:absolute;top:2px;left:2px}[aria-checked=true]>.hx-switch{background:var(--corn-accent);border-color:var(--corn-accent)}[aria-checked=true]>.hx-switch:after{background:var(--corn-text-on-accent);transform:translate(12px)}@media (prefers-reduced-motion:reduce){.hx-switch:after{transition:none}}.hx-btn{align-items:center;gap:var(--corn-space-2);padding:var(--corn-space-1) var(--corn-space-3);border-radius:var(--corn-radius-sm);border:var(--corn-border) solid var(--corn-line);background:var(--corn-surface-2);color:var(--corn-text-2);font-size:var(--corn-text-xs);white-space:nowrap;font-weight:600;transition:background .15s,color .15s,border-color .15s;display:inline-flex}.hx-btn:hover{background:var(--corn-surface-3);color:var(--corn-text)}.hx-btn:focus-visible,.hx-textbtn:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:var(--corn-focus-offset)}.hx-btn--active,.hx-btn--active:hover{background:var(--corn-accent);border-color:var(--corn-accent-text);color:var(--corn-text-on-accent);box-shadow:var(--corn-shadow-sm)}.hx-btn--quiet{color:var(--corn-text-3);font-weight:500}.hx-btn--icon{width:28px;height:28px;font-size:var(--corn-text-base);justify-content:center;padding:0}.hx-btn--rom{width:100%;margin-top:var(--corn-space-1);padding:var(--corn-space-2);background:color-mix(in srgb, var(--corn-hue-fuchsia) 20%, transparent);border-color:color-mix(in srgb, var(--corn-hue-fuchsia) 40%, transparent);color:color-mix(in srgb, var(--corn-hue-fuchsia) 60%, var(--corn-text));justify-content:center;font-weight:700}.hx-btn--rom:hover{background:color-mix(in srgb, var(--corn-hue-fuchsia) 30%, transparent)}.hx-input{width:128px;padding:var(--corn-space-1) var(--corn-space-3) var(--corn-space-1) var(--corn-space-6);border-radius:var(--corn-radius-sm);border:var(--corn-border) solid var(--corn-line);background:color-mix(in srgb, var(--corn-ground) 80%, transparent);color:var(--corn-text);font:inherit;font-size:var(--corn-text-sm);user-select:text;outline:none;transition:width .2s,border-color .2s}.hx-input:focus{border-color:var(--corn-focus);width:208px}.hx-input::placeholder{color:var(--corn-text-3)}.hx-input--wide,.hx-input--wide:focus{flex:1;width:100%}.hx-menu-wrap{flex:none;position:relative}.hx-menu{margin-top:var(--corn-space-3);width:288px;max-width:calc(100cqw - 24px);max-height:calc(100cqh - 80px);padding:var(--corn-space-4);border-radius:var(--corn-radius-lg);font-size:var(--corn-text-xs);z-index:50;user-select:none;position:absolute;top:100%;left:0;overflow-y:auto}.hx-textbtn{padding:calc(var(--corn-space-1) / 2) var(--corn-space-1);border-radius:var(--corn-radius-xs);color:var(--corn-text-3);font-size:var(--corn-text-2xs);background:0 0;border:0;font-weight:600}.hx-textbtn:hover{background:var(--corn-line-soft);color:var(--corn-text-2)}.hx-textbtn--accent{color:var(--corn-accent-text)}.hx-close{width:var(--hx-control-h);height:var(--hx-control-h);border-radius:var(--corn-radius-sm);background:var(--corn-surface-2);color:var(--corn-text-3);font-weight:700;font-size:var(--corn-text-base);border:0;flex:none}.hx-close:hover{color:var(--corn-text)}.hx-mark-dot{width:12px;height:12px;margin-right:var(--corn-space-2);border:var(--corn-border-strong) solid var(--corn-changed);vertical-align:-2px;border-radius:50%;flex:none;display:inline-block}.hx-mark-dot--added{border-color:var(--corn-added);border-style:dashed}.hx-mark-dot--changed{border-color:var(--corn-changed)}.hx-mark-dot--removed{border-color:var(--corn-removed);background:color-mix(in srgb, var(--corn-removed) 25%, transparent)}.hx-mark-dot--edit{border-color:var(--corn-edit);border-style:dotted}.hx-glyph{color:color-mix(in srgb, var(--glyph) var(--corn-glyph-mix), var(--corn-text))}.hx-sr-only{clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;overflow:hidden;position:absolute!important}:where(button,a[href],summary,select,textarea,[tabindex]):focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:var(--corn-focus-offset)}@media (prefers-reduced-motion:reduce){.hx-input,.hx-btn,.hx-menu{transition:none;animation:none}}.hx-btn[aria-disabled=true]{opacity:.6;cursor:progress}@container corn-box (width<=767px){.hx-textbtn{min-width:44px;min-height:44px}}@media (pointer:coarse){.hx-textbtn{min-width:44px;min-height:44px}}", Ha = () => "@container corn-box (width<=767px){.hx-stage .hx-hint{top:68px}}#graph-canvas{cursor:grab;touch-action:none;width:100%;height:100%;display:block}#graph-canvas:active{cursor:grabbing}#label-canvas{pointer-events:none;width:100%;height:100%;position:absolute;inset:0}.hx-overlay{pointer-events:none;width:100%;height:100%;position:absolute;top:0;left:0}.hx-hint{align-items:center;gap:var(--corn-space-2);max-width:85cqw;padding:var(--corn-space-1) var(--corn-space-4);border-radius:var(--corn-radius-pill);font-size:var(--corn-text-2xs);color:var(--corn-text-2);pointer-events:none;z-index:10;white-space:nowrap;display:flex;position:absolute;top:12px;left:50%;transform:translate(-50%)}.hx-hint span:last-child{text-overflow:ellipsis;overflow:hidden}@container corn-box (width>=640px){.hx-hint{font-size:var(--corn-text-xs)}}.hx-state{color:var(--corn-text-3);font-size:var(--corn-text-md);z-index:5;text-align:center;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.hx-state--error{align-items:center;gap:var(--corn-space-3);width:min(440px,100cqw - 32px);padding:var(--corn-space-6);border-radius:var(--corn-radius-lg);color:var(--corn-text-2);user-select:text;flex-direction:column;display:flex}.hx-state--error strong{color:var(--corn-bad);font-size:var(--corn-text-lg)}.hx-state--error p{font-size:var(--corn-text-sm);line-height:1.5}.hx-state--error #error-message{font-family:var(--corn-mono);color:var(--corn-warn);word-break:break-word}#graph-canvas.is-drawing-edge{touch-action:none}#graph-canvas:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:calc(var(--corn-focus-width) * -1)}.hx-run-overlay{z-index:2;pointer-events:none;position:absolute;inset:0;overflow:hidden}.hx-run-overlay[hidden]{display:none}.hx-run-mark{--r:14px;width:0;height:0;position:absolute}.hx-run-ring{left:calc(var(--r) * -1);top:calc(var(--r) * -1);width:calc(var(--r) * 2);height:calc(var(--r) * 2);box-sizing:border-box;border:var(--corn-border-strong) solid var(--corn-added);border-radius:50%;position:absolute}.hx-run-mark--flight .hx-run-ring{animation:1.8s ease-out infinite hx-run-pulse}@keyframes hx-run-pulse{0%{opacity:1;transform:scale(.9)}to{opacity:.1;transform:scale(1.55)}}.hx-run-overlay.is-static .hx-run-ring{opacity:1;border-width:calc(var(--corn-border-strong) + var(--corn-border));animation:none;transform:none}@media (prefers-reduced-motion:reduce){.hx-run-ring{opacity:1;border-width:calc(var(--corn-border-strong) + var(--corn-border));transform:none;animation:none!important}}.hx-run-mark--collision .hx-run-ring{border:calc(var(--corn-border-strong) + var(--corn-border)) dashed var(--corn-map-collision);animation:none}.hx-run-tag{left:0;top:calc(var(--r) + 4px);white-space:nowrap;padding:calc(var(--corn-space-1) / 2) var(--corn-space-2);border-radius:var(--corn-radius-pill);border:var(--corn-border) solid var(--corn-map-collision);background:color-mix(in srgb, var(--corn-ground) 80%, transparent);color:var(--corn-map-collision);font-size:var(--corn-text-xs);font-weight:700;position:absolute;transform:translate(-50%)}.hx-run-swatch{box-sizing:border-box;border:var(--corn-border-strong) solid var(--corn-added);border-radius:50%;flex:none;width:14px;height:14px;display:inline-block}.hx-run-swatch--collision{border:var(--corn-border-strong) dashed var(--corn-map-collision)}", Ua = () => ".hx-var{color:var(--corn-hue-pink);font-family:var(--corn-mono);font-size:var(--corn-text-2xs);background:color-mix(in srgb, var(--corn-ground) 55%, transparent);padding:0 var(--corn-space-1);border-radius:var(--corn-radius-xs)}.hx-drawer-title{font-family:var(--corn-font-display)}.hx-backdrop{z-index:40;background:var(--corn-scrim);backdrop-filter:blur(calc(var(--corn-blur) / 4));position:fixed;inset:0}@container corn-box (width>=768px){.hx-backdrop{display:none}}.hx-drawer{z-index:40;border-color:var(--corn-line);box-shadow:var(--corn-shadow-lg);pointer-events:none;touch-action:pan-y;flex-direction:column;transition:transform .2s ease-out;display:flex}.hx-drawer *{touch-action:pan-y}.hx-drawer.drawer-open{pointer-events:auto}.hx-drawer:not(.drawer-open){box-shadow:none}@container corn-box (width<=767px){.hx-drawer{border-radius:var(--corn-radius-lg) var(--corn-radius-lg) 0 0;z-index:auto;border-left:0;width:100%;position:relative;transform:none}.hx-drawer:not(.drawer-open){display:none}}@container corn-box (width>=768px){.hx-drawer{width:480px;position:absolute;top:0;bottom:0;right:0;transform:translate(100%)}.hx-drawer.drawer-open{transform:translate(0)}}.hx-drawer-handle{padding:var(--corn-space-3) 0 var(--corn-space-1);justify-content:center;display:flex}.hx-drawer-handle span{border-radius:var(--corn-radius-pill);background:var(--corn-surface-3);width:48px;height:6px}.hx-drawer-body{gap:var(--corn-space-5);padding:var(--corn-panel-pad);user-select:text;flex-direction:column;flex:1;display:flex;overflow-y:auto}.hx-drawer-head{justify-content:space-between;align-items:flex-start;gap:var(--corn-space-3);display:flex}.hx-drawer-title{font-size:var(--corn-text-lg);color:var(--corn-text);overflow-wrap:anywhere;font-weight:700}.hx-lead{font-size:var(--corn-text-base);color:var(--corn-text-2);line-height:1.5}.hx-block{gap:var(--corn-space-3);flex-direction:column;display:flex}.hx-meta{gap:var(--corn-space-5);font-size:var(--corn-text-md);color:var(--corn-text-2);overflow-wrap:anywhere;flex-direction:column;display:flex}.hx-meta>:empty{display:none}.hx-sec{margin-top:var(--corn-space-2);padding-top:var(--corn-space-2);border-top:var(--corn-border) solid var(--corn-line)}.hx-line{align-items:flex-start;gap:var(--corn-space-2);padding:calc(var(--corn-space-1) / 2) 0;display:flex}.hx-linkbtn{margin-left:var(--corn-space-1);color:var(--corn-hue-fuchsia);font-size:inherit;background:0 0;border:0;padding:0;text-decoration:underline}.hx-sim{gap:var(--corn-space-2);padding-top:var(--corn-space-1);font-family:var(--corn-font);flex-direction:column;display:flex}.hx-field-label{font-size:var(--corn-text-2xs);color:var(--corn-text-3)}.hx-field{width:100%;padding:var(--corn-space-1) var(--corn-space-3);border-radius:var(--corn-radius-sm);border:var(--corn-border) solid var(--corn-line);background:color-mix(in srgb, var(--corn-ground) 80%, transparent);color:var(--corn-text-2);font-family:var(--corn-mono);font-size:var(--corn-text-xs)}.hx-sim-result{font-size:var(--corn-text-xs)}.hx-error-text{padding-top:var(--corn-space-3);color:var(--corn-bad)}.hx-ms{text-align:right;width:56px;color:var(--corn-hue-fuchsia);flex:none}.hx-file{padding:calc(var(--corn-space-1) / 2) 0}.hx-sandbox{gap:var(--corn-space-4);padding:var(--corn-space-5);border-radius:var(--corn-radius);border:var(--corn-border) solid var(--corn-line);background:color-mix(in srgb, var(--corn-ground) 80%, transparent);flex-direction:column;display:flex}.hx-sandbox-title{font-size:var(--corn-text-2xs);text-transform:uppercase;letter-spacing:.05em;color:var(--corn-text-3);justify-content:space-between;align-items:center;font-weight:700;display:flex}.hx-sandbox-name{align-items:center;gap:var(--corn-space-2);display:flex}.hx-sandbox-stage{min-height:90px;padding:var(--corn-space-5);border-radius:var(--corn-radius-sm);border:var(--corn-border) dashed var(--corn-surface-2);background:var(--corn-ground);justify-content:center;align-items:center;display:flex;overflow-x:auto}.hx-sandbox-controls{gap:var(--corn-space-2);padding-top:var(--corn-space-3);border-top:var(--corn-border) solid var(--corn-line);font-size:var(--corn-text-xs);flex-direction:column;display:flex}.hx-ctl-row{align-items:center;gap:var(--corn-space-2);color:var(--corn-text-2);flex-wrap:wrap;display:flex}.hx-check{align-items:center;gap:var(--corn-space-1);margin-right:var(--corn-space-3);cursor:pointer;display:inline-flex}.hx-chip{padding:calc(var(--corn-space-1) / 2) var(--corn-space-3);border-radius:var(--corn-radius-xs);font-size:var(--corn-text-xs);color:var(--corn-text-on-accent);border:0;font-weight:500}.hx-chip--ghost{background:var(--corn-surface-2);color:var(--corn-text-2)}.hx-chip--outline{background:var(--corn-surface-2);color:var(--corn-accent-text)}.hx-chip--primary{background:var(--corn-accent)}.hx-chip--danger{background:var(--corn-bad)}.hx-chip--success{background:var(--corn-ok)}.hx-chip--warning{background:var(--corn-warn)}.hx-chip--danger,.hx-chip--success,.hx-chip--warning{color:var(--corn-ground)}.hx-drawer-foot{align-items:stretch;gap:var(--corn-space-3);padding:var(--corn-space-4) var(--corn-space-5) calc(var(--corn-space-4) + env(safe-area-inset-bottom,0px));border-top:var(--corn-border) solid var(--corn-line-soft);flex:none;display:flex}.hx-open{justify-content:center;align-items:center;gap:var(--corn-space-2);min-height:var(--hx-control-h);padding:0 var(--corn-space-4);border-radius:var(--corn-radius-sm);background:var(--corn-accent);color:var(--corn-text-on-accent);font-size:var(--corn-text-sm);text-align:center;flex:auto;font-weight:600;text-decoration:none;transition:background .15s;display:flex}.hx-open:hover{background:var(--corn-accent-hover)}.hx-proposal-sec{padding:var(--corn-space-3) var(--corn-space-3);border:var(--corn-border) solid var(--corn-line);border-left-width:var(--corn-border-strong);border-radius:var(--corn-radius-sm);background:color-mix(in srgb, var(--corn-ground) 55%, transparent);margin:0 0 var(--corn-space-2);font-family:var(--corn-font)}.hx-proposal-sec--added{border-left-color:var(--corn-added)}.hx-proposal-sec--changed{border-left-color:var(--corn-changed)}.hx-proposal-sec--removed{border-left-color:var(--corn-removed)}.hx-proposal-sec--edit{border-left-color:var(--corn-edit)}.hx-why{margin:var(--corn-space-1) 0 var(--corn-space-2);color:var(--corn-text-2);font-size:var(--corn-text-sm);line-height:1.5}.hx-change{align-items:baseline;gap:calc(var(--corn-space-1) / 2) var(--corn-space-3);padding:var(--corn-space-1) 0;border-top:var(--corn-border) solid var(--corn-line-soft);font-family:var(--corn-mono);font-size:var(--corn-text-xs);flex-wrap:wrap;display:flex}.hx-change-field{min-width:64px;color:var(--corn-text-3);flex:none}.hx-change-before{color:var(--corn-bad);text-decoration:line-through;text-decoration-color:color-mix(in srgb, var(--corn-bad) 50%, transparent);overflow-wrap:anywhere}.hx-change-arrow{color:var(--corn-text-3)}.hx-change-after{color:var(--corn-ok);overflow-wrap:anywhere}.hx-change em{color:var(--corn-text-3);text-decoration:none}.hx-mockup-list{margin:var(--corn-space-1) 0 0;gap:var(--corn-space-2);flex-direction:column;padding:0;list-style:none;display:flex}.hx-mockup-item{align-items:center;gap:var(--corn-space-1) var(--corn-space-3);flex-wrap:wrap;display:flex}.hx-mockup-open{white-space:normal;text-align:left;max-width:100%}.hx-mockup-state{font-size:var(--corn-text-xs);color:var(--corn-text-2);margin:0}.hx-mockup-state--approved{color:var(--corn-added-text)}.hx-mockup-state--changed{color:var(--corn-warn);font-weight:600}.hx-mockup-state--missing{color:var(--corn-bad)}@container corn-box (width<=767px){.hx-backdrop{display:none}.hx-drawer{max-height:60cqh}}.hx-cloud-browser{color:var(--corn-text-3);font-size:var(--corn-text-sm)}.hx-drawer-title:focus{outline:none}.hx-drawer-title:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:var(--corn-focus-offset)}.hx-drawer-id{flex:1;min-width:0}.hx-kicker{margin:0 0 var(--corn-space-2);font-size:var(--corn-text-sm);color:var(--corn-text-3);flex-wrap:wrap;align-items:center;display:flex}.hx-kicker [data-corn=badge]{overflow-wrap:anywhere;min-width:0;max-width:100%}#drawer-host{white-space:pre}.hx-diffpill{margin-left:var(--corn-space-3);padding:0 var(--corn-space-3);border-radius:var(--corn-radius-pill);border:var(--corn-border) dashed var(--corn-added);color:var(--corn-added-text);font-size:var(--corn-text-xs)}.hx-drawer-id .hx-drawer-title.hx-mono{font-family:var(--corn-mono)}.hx-facts{gap:var(--corn-space-2);flex-direction:column;display:flex}.hx-fact{gap:var(--corn-space-4);grid-template-columns:96px minmax(0,1fr);display:grid}.hx-fact-k{color:var(--corn-text-3)}.hx-fact-v{min-width:0;color:var(--corn-text)}.hx-fact-v .hx-line{padding:0}.hx-fact-v .hx-name{color:var(--corn-text)}.hx-fact-v .hx-code{color:var(--corn-text-2);font-size:var(--corn-text-sm)}.hx-fact-v .hx-chips{padding-top:0}.hx-sec-block{gap:var(--corn-space-3);flex-direction:column;display:flex}.hx-sec-title{font-size:var(--corn-text-sm);color:var(--corn-text-3);margin:0;font-weight:600}.hx-drawer .hx-mockups{border:0;margin:0;padding:0}.hx-rows{gap:var(--corn-space-2);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.hx-row{align-items:center;gap:var(--corn-space-4);width:100%;min-height:36px;padding:var(--corn-space-3) var(--corn-space-4);border:var(--corn-border) solid var(--corn-line);border-radius:var(--corn-radius-sm);background:var(--corn-surface-2);color:var(--corn-text);font:inherit;text-align:left;display:flex}.hx-row:hover{background:var(--corn-accent-soft)}.hx-row:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:var(--corn-focus-offset)}.hx-row-title{overflow-wrap:anywhere;flex:1;min-width:0}.hx-row-meta{font-size:var(--corn-text-sm);color:var(--corn-text-3);font-variant-numeric:tabular-nums;flex:none}.hx-drawer .hx-mockup-list{margin:var(--corn-space-3) 0 0}.hx-drawer .hx-mockup-item{gap:var(--corn-space-4);padding:var(--corn-space-1) var(--corn-space-1) var(--corn-space-1) 0;border:var(--corn-border) solid var(--corn-line);border-radius:var(--corn-radius-sm);background:var(--corn-surface-2);flex-wrap:nowrap}.hx-drawer .hx-mockup-open{min-width:0;min-height:36px;color:var(--corn-text);background:0 0;border:0;flex:1;font-weight:400}.hx-drawer .hx-mockup-state{padding-right:var(--corn-space-3);color:var(--corn-text-3);flex:none}.hx-drawer .hx-mockup-state--approved{color:var(--corn-added-text)}.hx-drawer .hx-mockup-state--changed{color:var(--corn-warn)}.hx-drawer .hx-mockup-state--missing{color:var(--corn-bad)}.hx-textact{background:0 0;border:0;align-self:flex-start;padding-left:0}.hx-diff{gap:var(--corn-space-1) var(--corn-space-4);padding:var(--corn-space-1) 0 var(--corn-space-1) var(--corn-space-4);border-left:var(--corn-border-strong) solid var(--corn-changed);font-family:var(--corn-mono);font-size:var(--corn-text-sm);color:var(--corn-text-2);grid-template-columns:70px minmax(0,1fr);display:grid}.hx-diff--added{border-left-color:var(--corn-added)}.hx-diff--removed{border-left-color:var(--corn-removed)}.hx-diff--edit{border-left-color:var(--corn-edit)}.hx-diff-k{color:var(--corn-text-3)}.hx-diff-v{overflow-wrap:anywhere;min-width:0}.hx-drawer .hx-why{margin:0}.hx-drawer-foot .hx-open[hidden],.hx-drawer-foot .hx-foot-btn[hidden]{display:none}.hx-foot-btn{min-height:var(--hx-control-h);padding:0 var(--corn-space-4);justify-content:center}@container corn-box (width<=767px){.hx-drawer-foot{flex-direction:column}.hx-drawer-foot .hx-open,.hx-foot-btn,.hx-drawer .hx-row,.hx-drawer .hx-mockup-open,.hx-textact,.hx-drawer .hx-whatif-drawer .hx-btn,.hx-cloud-play{min-height:44px}.hx-drawer .hx-close{width:44px;height:44px}}.hx-cloud-play{align-self:flex-start}.hx-drawer-foot .hx-btn--quiet{background:0 0;border-color:#0000;text-decoration:none}.hx-more{display:contents}.hx-more[hidden]{display:none}.hx-more-btn{margin-top:var(--corn-space-1);min-height:0;font-size:var(--corn-text-sm);padding:0;display:block}@container corn-box (width<=767px){.hx-more-btn{min-height:44px}}.hx-drawer-body{scroll-padding-block:calc(var(--corn-focus-width) + var(--corn-focus-offset) + var(--corn-space-1))}.hx-ms,.hx-row-meta{font-family:var(--corn-font-num);font-variant-numeric:tabular-nums}@media (prefers-reduced-motion:reduce){.hx-drawer{transition:none;animation:none}}.hx-fact-v{overflow-wrap:break-word;word-break:normal}.hx-drawer-foot .hx-forge-result{flex-basis:100%}.hx-lines{gap:var(--corn-space-2);flex-direction:column;display:flex}.hx-lines .hx-chips{padding-top:0}.hx-lines-kind{align-items:baseline;gap:var(--corn-space-1);min-height:28px;padding:0 var(--corn-space-3);border:var(--corn-border) solid var(--corn-line);border-radius:var(--corn-radius-pill);color:var(--corn-text-2);font:inherit;font-size:var(--corn-text-xs);cursor:pointer;background:0 0;font-weight:600;display:inline-flex}.hx-lines-kind:hover{background:var(--corn-surface-3);color:var(--corn-text)}.hx-lines-kind[aria-pressed=true]{border-color:var(--corn-accent);background:var(--corn-accent-soft);color:var(--corn-accent-text)}.hx-lines-kind:focus-visible,.hx-lines-switch input:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:var(--corn-focus-offset)}.hx-lines-count{font-variant-numeric:tabular-nums;color:var(--corn-text-3)}.hx-lines-list{align-items:flex-start;gap:calc(var(--corn-space-1) / 2);flex-direction:column;display:flex}.hx-lines-list .hx-linkbtn{text-align:left;overflow-wrap:anywhere;margin-left:0}.hx-lines-switch{align-items:center;gap:var(--corn-space-2);min-height:28px;font-size:var(--corn-text-sm);color:var(--corn-text-2);cursor:pointer;display:flex}.hx-lines-reach{align-items:center;gap:var(--corn-space-3);font-size:var(--corn-text-sm);color:var(--corn-text-2);font-variant-numeric:tabular-nums;flex-wrap:wrap;display:flex}@container corn-box (width<=767px){.hx-lines-kind,.hx-lines-switch,.hx-lines-list .hx-linkbtn,.hx-lines-reach .hx-btn{min-height:44px}.hx-lines-kind{align-items:center}.hx-lines-switch input{width:24px;height:24px}}@media (pointer:coarse){.hx-lines-kind,.hx-lines-switch,.hx-lines-list .hx-linkbtn,.hx-lines-reach .hx-btn{min-height:44px}.hx-lines-kind{align-items:center}.hx-lines-switch input{width:24px;height:24px}}.hx-drawer-title{font-size:var(--corn-text-lg);letter-spacing:normal;font-weight:700;line-height:1.25}.hx-drawer-head{min-height:var(--corn-panel-head-height)}", Wa = () => ".hx-menu--proposals{width:360px}.hx-proposal-list{gap:var(--corn-space-1);flex-direction:column;display:flex}.hx-proposal-empty{padding:var(--corn-space-3) calc(var(--corn-space-1) / 2);font-size:var(--corn-text-sm)}.hx-proposal-item{align-items:flex-start;gap:var(--corn-space-1);width:100%;padding:var(--corn-space-3) var(--corn-space-3);border-radius:var(--corn-radius);border:var(--corn-border) solid var(--corn-line);background:var(--corn-surface-2);color:var(--corn-text);text-align:left;font-size:var(--corn-text-xs);flex-direction:column;display:flex}button.hx-proposal-item:hover{background:var(--corn-surface-3)}button.hx-proposal-item:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:var(--corn-focus-offset)}.hx-proposal-item.is-current{border-color:var(--corn-added-text);background:color-mix(in srgb, var(--corn-added) 12%, transparent)}.hx-proposal-item.is-broken{opacity:.8;cursor:default}.hx-proposal-title{font-size:var(--corn-text-sm);color:var(--corn-text);overflow-wrap:anywhere;font-weight:600}.hx-proposal-sum{color:var(--corn-text-2);line-height:1.4}.hx-proposal-meta{gap:calc(var(--corn-space-1) / 2) var(--corn-space-3);color:var(--corn-text-3);font-size:var(--corn-text-2xs);flex-wrap:wrap;display:flex}.hx-proposal-where{color:var(--corn-added-text)}.hx-proposal-bar{width:min(960px,100% - 24px);padding:var(--corn-space-3) var(--corn-space-3);border-radius:var(--corn-radius-lg);font-size:var(--corn-text-sm);z-index:15;user-select:text;position:absolute;top:48px;left:12px}.hx-proposal-bar.is-error{border-color:color-mix(in srgb, var(--corn-removed) 50%, transparent)}.hx-proposal-message{color:var(--corn-text-2)}.hx-proposal-bar.is-error .hx-proposal-message{color:var(--corn-bad)}.hx-proposal-count:focus-visible,.hx-proposal-mode:focus-visible,.hx-seg-btn:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:var(--corn-focus-offset)}.hx-proposal-summary{margin-top:var(--corn-space-2);color:var(--corn-text-2);line-height:1.5}.hx-seg{padding:calc(var(--corn-space-1) / 2);border-radius:var(--corn-radius-sm);border:var(--corn-border) solid var(--corn-line);background:color-mix(in srgb, var(--corn-ground) 55%, transparent);display:inline-flex}.hx-seg-btn{height:var(--hx-seg-inner);padding:0 var(--corn-space-4);border-radius:var(--corn-radius-sm);color:var(--corn-text-3);font-size:var(--corn-text-sm);background:0 0;border:0;font-weight:500}.hx-seg-btn:hover{color:var(--corn-text)}.hx-seg-btn.is-on,.hx-seg-btn[aria-pressed=true]{background:var(--corn-accent);color:var(--corn-text-on-accent)}.hx-proposal-errors{margin-top:var(--corn-space-2);padding:var(--corn-space-2) var(--corn-space-3);border-radius:var(--corn-radius-sm);background:color-mix(in srgb, var(--corn-removed) 10%, transparent);border:var(--corn-border) solid color-mix(in srgb, var(--corn-removed) 30%, transparent);color:var(--corn-text-2)}.hx-proposal-errors summary{cursor:pointer;color:var(--corn-bad);font-weight:600}.hx-proposal-errors ul{margin:var(--corn-space-2) 0 var(--corn-space-1);padding-left:var(--corn-space-5);line-height:1.5}.hx-proposal-errors p{margin-top:var(--corn-space-1);font-size:var(--corn-text-xs)}@container corn-box (width>=768px){.hx-stage:has(.drawer-open) .hx-proposal-bar{width:min(960px,100% - 504px)}}@container corn-box (width<=639px){.hx-menu--proposals{width:auto;max-width:none;position:fixed;top:60px;left:12px;right:12px}}.hx-proposal-reviewed{color:var(--corn-added-text)}.hx-proposal-head{align-items:center;gap:var(--corn-space-3) var(--corn-space-4);flex-wrap:wrap;display:flex}.hx-proposal-name{text-overflow:ellipsis;white-space:nowrap;min-width:0;max-width:28ch;color:var(--corn-text);flex:0 auto;overflow:hidden}.hx-proposal-counts{display:contents}.hx-proposal-chip{color:var(--corn-text-2);font-size:var(--corn-text-sm);font-variant-numeric:tabular-nums;white-space:nowrap;flex-wrap:wrap;align-items:center;display:inline-flex}.hx-proposal-count{min-height:var(--hx-control-h);padding:var(--corn-space-1) var(--corn-space-2);border-radius:var(--corn-radius-sm);color:inherit;font:inherit;white-space:inherit;cursor:pointer;background:0 0;border:0;align-items:center;display:inline-flex}.hx-proposal-count:hover{color:var(--corn-text);text-decoration:underline}.hx-proposal-peek{margin:0;display:none}.hx-proposal-chip .hx-mark-dot{margin:0 var(--corn-space-2) 0 0}h2.hx-proposal-name{margin:0}.hx-proposal-sep{margin:0 var(--corn-space-2);color:var(--corn-text-3)}.hx-proposal-mode{display:none}.hx-proposal-tools{align-items:center;gap:var(--corn-space-3);display:flex}.hx-proposal-tools .hx-btn{height:var(--hx-control-h);font-size:var(--corn-text-sm);font-weight:500}#proposal-edit.hx-btn--active{background:var(--corn-edit-text);border-color:var(--corn-edit);color:var(--corn-ground)}.hx-proposal-more{position:relative}.hx-proposal-more .hx-btn--icon{width:var(--hx-control-h);height:var(--hx-control-h);color:var(--corn-text-3);background:0 0;border-color:#0000}.hx-proposal-more .hx-btn--icon:hover,.hx-proposal-more .hx-btn--icon[aria-expanded=true]{background:var(--corn-surface-3);color:var(--corn-text)}.hx-proposal-more-menu{z-index:20;min-width:160px;margin-top:var(--corn-space-2);padding:var(--corn-space-2);border-radius:var(--corn-radius);border:var(--corn-border) solid var(--corn-line);box-shadow:var(--corn-shadow);flex-direction:column;display:flex;position:absolute;top:100%;right:0}.hx-proposal-more-menu[hidden]{display:none}.hx-proposal-more-menu .hx-btn{width:100%;height:var(--hx-control-h);color:var(--corn-text-2);font-size:var(--corn-text-sm);background:0 0;border-color:#0000}.hx-proposal-more-menu .hx-btn:hover{background:var(--corn-surface-3);color:var(--corn-text)}@container corn-box (width<=767px){.hx-proposal-head{gap:var(--corn-space-2) var(--corn-space-3);grid-template-columns:1fr auto;display:grid}.hx-proposal-name{order:1;grid-column:1/-1;max-width:none}.hx-proposal-counts{align-items:center;column-gap:var(--corn-space-2);flex-wrap:wrap;order:2;grid-column:1/-1;display:flex}.hx-proposal-count,.hx-proposal-mode{min-height:44px}.hx-proposal-mode{align-items:center;gap:var(--corn-space-2);padding:0 var(--corn-space-3);border:var(--corn-border) solid var(--corn-line);border-radius:var(--corn-radius-sm);background:var(--corn-surface-2);color:var(--corn-text);font-size:var(--corn-text-sm);font-weight:600;display:inline-flex}.hx-proposal-mode:after{content:\"\";background:currentColor;width:10px;height:10px;-webkit-mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 3.5l3 3 3-3'/%3E%3C/svg%3E\") 50%/contain no-repeat;mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 3.5l3 3 3-3'/%3E%3C/svg%3E\") 50%/contain no-repeat}.hx-proposal-mode[aria-expanded=true]:after{transform:rotate(180deg)}.hx-seg{order:3;grid-column:1/-1}.hx-proposal-bar:not([data-mode-open=true]) .hx-seg{display:none}.hx-seg-btn{height:var(--hx-seg-inner);font-size:var(--corn-text-md);flex:1}.hx-proposal-tools{order:5}.hx-proposal-tools .hx-btn{height:auto;min-height:44px;padding:0 var(--corn-space-5);font-size:var(--corn-text-md)}.hx-proposal-more{display:contents}.hx-proposal-more .hx-btn--icon{width:var(--hx-control-h);height:var(--hx-control-h);order:6}.hx-proposal-more-menu{box-shadow:none;order:7;grid-column:1/-1;position:static}.hx-proposal-more-menu .hx-btn{height:auto;min-height:44px;font-size:var(--corn-text-md)}.hx-proposal-bar{max-height:50cqh;padding:0 var(--corn-space-4) var(--corn-space-3);overflow-y:auto}}@container corn-box (width>=768px){.hx-stage:has(.forge-open) .hx-proposal-bar{left:calc(var(--hx-forge-w) + 12px);width:min(960px, calc(100% - var(--hx-forge-w) - 36px))}.hx-stage:has(.forge-open):has(.drawer-open) .hx-proposal-bar{width:min(960px, calc(100% - var(--hx-forge-w) - 540px))}}.hx-proposal-bar{scroll-padding-block:calc(var(--corn-focus-width) + var(--corn-focus-offset) + var(--corn-space-1))}@media (forced-colors:active){.hx-proposal-mode:after{background:canvastext}}.hx-proposal-source{min-width:0;max-width:100%;padding:calc(var(--corn-space-1) / 2) var(--corn-space-3);border:var(--corn-border) solid var(--corn-line);border-radius:var(--corn-radius-pill);background:var(--corn-surface-2);color:var(--corn-text-2);font-size:var(--corn-text-xs);overflow-wrap:anywhere;align-items:center;line-height:1.4;text-decoration:none;display:inline-flex}.hx-proposal-source[hidden]{display:none}a.hx-proposal-source{min-height:24px}a.hx-proposal-source:hover{color:var(--corn-text);text-decoration:underline}a.hx-proposal-source:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:var(--corn-focus-offset)}.hx-proposal-source[data-corn-state=draft]{border-color:color-mix(in srgb, var(--corn-changed) 50%, transparent)}.hx-proposal-ways{gap:var(--corn-space-2) var(--corn-space-3);margin-top:var(--corn-space-3);flex-wrap:wrap;display:flex}.hx-proposal-ways[hidden]{display:none}.hx-proposal-ways .hx-btn{height:auto;min-height:32px;padding:var(--corn-space-1) var(--corn-space-4);white-space:normal;text-align:left}@container corn-box (width<=767px){.hx-proposal-source{order:1;grid-column:1/-1;justify-self:start}.hx-proposal-ways .hx-btn,a.hx-proposal-source{min-height:44px}.hx-proposal-source{background:0 0;border:0;border-radius:0;padding:0}a.hx-proposal-source{text-underline-offset:3px;text-decoration:underline}.hx-proposal-bar:has(.hx-review-form:not([hidden])) :is(.hx-proposal-name,.hx-proposal-source,.hx-proposal-counts,.hx-proposal-tools,.hx-proposal-more,.hx-review-status,.hx-review-line,.hx-rc-scroll,.hx-rc-tabs,.hx-proposal-peek){display:none}.hx-proposal-bar{overflow-wrap:anywhere;overflow-x:hidden}.hx-proposal-head{grid-template-columns:minmax(0,1fr) auto}.hx-proposal-chip{white-space:normal;text-align:left;flex-wrap:wrap;max-width:100%}.hx-proposal-counts{min-width:0}.hx-proposal-chip{white-space:normal;text-align:left;flex-wrap:wrap}.hx-proposal-count{white-space:normal;text-align:left}}@media (pointer:coarse){.hx-proposal-chip{white-space:normal;text-align:left;flex-wrap:wrap}.hx-proposal-count{white-space:normal;text-align:left}}.hx-proposal-summary{-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;flex:none;margin:0;display:-webkit-box;overflow:hidden}@container corn-box (width<=767px){.hx-proposal-summary{display:none}}.hx-waiting-line{align-items:center;gap:var(--corn-space-2) var(--corn-space-3);margin:var(--corn-space-2) 0 0;padding:var(--corn-space-1) var(--corn-space-3);border-left:calc(var(--corn-border-strong) * 2) solid var(--corn-run-waiting);border-radius:var(--corn-radius-sm);background:var(--corn-surface-2);color:var(--corn-text);overflow-wrap:anywhere;flex-wrap:wrap;line-height:1.4;display:flex}.hx-waiting-line[hidden]{display:none}@container corn-box (width<=767px){.hx-waiting-line .hx-btn{min-width:44px;min-height:44px}}.hx-proposal-yours{align-items:center;gap:var(--corn-space-1);color:var(--corn-text-2);display:inline-flex}.hx-proposal-tools [aria-pressed=false]:not([data-corn=whole-map]){opacity:.8}.hx-proposal-name{font-size:var(--corn-text-lg);letter-spacing:normal;font-weight:700;line-height:1.25}@container corn-box (width>=768px){.hx-proposal-tools{display:contents}.hx-proposal-name,.hx-proposal-source{order:-2}:where(.hx-proposal-head) [data-corn=whole-map]{margin-block:calc((var(--corn-space-6) - var(--hx-control-h)) / 2);order:-1}}", Ga = () => ".hx-change-row:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:var(--corn-focus-offset)}.hx-change-row{align-items:center;gap:var(--corn-space-3);width:100%;padding:var(--corn-space-1) var(--corn-space-2);border-radius:var(--corn-radius-sm);text-align:left;font-size:var(--corn-text-xs);background:0 0;border:0;display:flex}.hx-change-row:hover{background:var(--corn-line-soft)}.hx-change-what{width:56px;color:var(--corn-text-3);flex:none}.hx-change-row .hx-name{overflow-wrap:anywhere;min-width:0}.hx-change-row .hx-mark-dot{margin-right:0}.hx-player{left:calc(var(--hx-col-w,0px) + 24px);align-items:center;gap:var(--corn-space-2) var(--corn-space-4);padding:var(--corn-space-3) var(--corn-space-4);border-radius:var(--corn-radius-lg);z-index:25;flex-wrap:wrap;display:flex;position:absolute;bottom:12px;right:12px;overflow:hidden}.hx-player .hx-close{width:var(--hx-control-h);height:var(--hx-control-h);font-size:var(--corn-text-sm)}.hx-player-speed{height:var(--hx-control-h);padding:0 var(--corn-space-2);border-radius:var(--corn-radius-sm);border:var(--corn-border) solid var(--corn-line);background:color-mix(in srgb, var(--corn-ground) 80%, transparent);color:var(--corn-text);font:inherit;font-size:var(--corn-text-sm);cursor:pointer;flex:none}.hx-player-speed:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:calc(var(--corn-focus-offset) / 2)}.hx-player-text{min-width:0;font-size:var(--corn-text-base);color:var(--corn-text);user-select:text;overflow-wrap:anywhere;flex:18em;margin:0;line-height:1.4}.hx-player-who{color:var(--corn-text-2);font-weight:600}.hx-player-text .hx-player-verdict{margin-left:var(--corn-space-2)}.hx-player-count{color:var(--corn-accent-text);white-space:nowrap;font-weight:600}.hx-player-controls{gap:var(--corn-space-3);flex:none;display:flex}.hx-player-side{align-items:center;gap:var(--corn-space-3);flex:none;margin-left:auto;display:flex}.hx-player-controls .hx-btn{white-space:nowrap;justify-content:center}.hx-player-controls .hx-btn[hidden]{display:none}.hx-player-prev:before{content:\"◀\" / \"\";margin-right:var(--corn-space-2)}.hx-player-next:after{content:\"▶\" / \"\";margin-left:var(--corn-space-2)}.hx-player-toggle[data-state=playing]:before{content:\"\" / \"\";box-sizing:border-box;width:1em;height:1em;margin-right:var(--corn-space-2);border-left:calc(var(--corn-border-strong) * 1.5) solid currentColor;border-right:calc(var(--corn-border-strong) * 1.5) solid currentColor;display:inline-block}.hx-player-toggle[data-state=paused]:before{content:\"▶\" / \"\";margin-right:var(--corn-space-2)}.hx-player-toggle[data-state=done]:before{content:\"↻\" / \"\";margin-right:var(--corn-space-2)}.hx-player-controls .hx-btn:disabled{opacity:.4;cursor:default}.hx-player-track{background:var(--corn-line-soft);height:3px;position:absolute;bottom:0;left:0;right:0}.hx-player-fill{background:var(--corn-accent-text);width:0;height:100%;display:block}@container corn-box (width<=767px){.hx-player{gap:0 var(--corn-space-3);max-height:50cqh;padding:0 var(--corn-space-4) var(--corn-space-3);--sheet-pb:var(--corn-space-3);flex-wrap:wrap;position:relative;bottom:auto;left:auto;right:auto;overflow:hidden}}.hx-player-verdict{padding:calc(var(--corn-space-1) / 2) var(--corn-space-3);border-radius:var(--corn-radius-pill);font-size:var(--corn-text-xs);white-space:nowrap;border:var(--corn-border) solid var(--corn-line);color:var(--corn-text-2);background:color-mix(in srgb, var(--corn-text-3) 12%, transparent);flex:none;font-weight:600}.hx-player-check{padding:var(--corn-space-2) var(--corn-space-3);border-radius:var(--corn-radius-sm);font-size:var(--corn-text-md);color:var(--corn-text-2);background:color-mix(in srgb, var(--corn-text-3) 10%, transparent);border-left:var(--corn-border-strong) solid color-mix(in srgb, var(--corn-text-3) 50%, transparent);user-select:text;margin:0;line-height:1.4}.hx-player-check-detail{font-size:var(--corn-text-xs);color:var(--corn-text-3);display:block}.hx-player-verdict[data-tone=allowed],.hx-player-check[data-tone=allowed]{color:var(--corn-ok);background:var(--corn-ok-soft);border-color:color-mix(in srgb, var(--corn-ok) 60%, transparent)}.hx-player-verdict[data-tone=refused],.hx-player-check[data-tone=refused]{color:var(--corn-bad);background:color-mix(in srgb, var(--corn-removed) 16%, transparent);border-color:color-mix(in srgb, var(--corn-removed) 70%, transparent)}.hx-player-verdict[data-tone=mismatch],.hx-player-check[data-tone=mismatch]{color:var(--corn-warn);background:color-mix(in srgb, var(--corn-changed) 16%, transparent);border-color:color-mix(in srgb, var(--corn-changed) 70%, transparent)}.hx-player-verdict[data-tone=pending]{opacity:.75}.hx-player-as{align-items:center;gap:var(--corn-space-3);font-size:var(--corn-text-sm);color:var(--corn-text-2);flex-wrap:wrap;display:flex}.hx-player-as-label{align-items:center;gap:var(--corn-space-2);display:inline-flex}.hx-player-as .hx-btn{padding:var(--corn-space-1) var(--corn-space-3);font-size:var(--corn-text-sm)}.hx-player-as .hx-btn:disabled{opacity:.4;cursor:default}.hx-player-as-sum{font-size:var(--corn-text-xs);margin-left:auto}.hx-player-as[hidden],.hx-player-verdict[hidden],.hx-player-check[hidden]{display:none}.hx-rc-scroll{scroll-padding-block:calc(var(--corn-focus-width) + var(--corn-focus-offset) + var(--corn-space-1))}.hx-player-count{font-family:var(--corn-font-num);font-variant-numeric:tabular-nums}@container corn-box (width<=767px){.hx-player-controls .hx-btn{min-width:44px;min-height:44px;padding:0 var(--corn-space-3);white-space:nowrap}.hx-player-prev .hx-player-label,.hx-player-next .hx-player-label,.hx-player-toggle .hx-player-label{clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;position:absolute;overflow:hidden}.hx-player-prev:before,.hx-player-next:after,.hx-player-toggle:before{margin:0}.hx-player-next-scenario{font-size:var(--corn-text-sm)}.hx-player-controls{gap:var(--corn-space-2)}}.hx-change-row{min-height:28px}@container corn-box (width<=767px){.hx-change-row,.hx-sc-row,.hx-step,.hx-rc-tab,.hx-player-speed,.hx-player .hx-close{min-height:44px}.hx-player-speed,.hx-player .hx-close{min-width:44px}}@media (pointer:coarse){.hx-change-row,.hx-sc-row,.hx-step,.hx-rc-tab,.hx-player-speed,.hx-player .hx-close{min-height:44px}.hx-player-speed,.hx-player .hx-close{min-width:44px}}.hx-review-column{bottom:12px;left:12px;top:var(--hx-column-top,150px);z-index:14;border-radius:var(--corn-radius-lg);width:400px;font-size:var(--corn-text-sm);user-select:text;flex-direction:column;display:flex;position:absolute;overflow:hidden}.hx-review-column[hidden]{display:none}@container corn-box (width<=1023px){.hx-review-column{width:320px}}@container corn-box (width>=1280px){.hx-stage:has(.forge-open) .hx-review-column{left:calc(var(--hx-forge-w) + 12px)}}@container corn-box (width>=768px) and (width<=1023px){.hx-stage:has(.drawer-open) .hx-review-column{width:min(320px,100% - 504px)}}.hx-rc-scroll{gap:var(--corn-space-2);min-height:0;padding:var(--corn-space-3) var(--corn-space-4);flex-direction:column;flex:1;display:flex;overflow:hidden}.hx-rc-lists{gap:var(--corn-space-4);flex-direction:column;flex:1;min-height:0;display:flex}.hx-rc-section{flex-direction:column;min-height:0;display:flex}#rc-changes{max-height:var(--hx-changes-max,40%);flex:0 auto}#rc-scenarios{min-height:min(12em, var(--hx-scenarios-need,12em));flex:1 1 0}.hx-change-list,.hx-rc-sbody{min-height:0;scroll-padding-block:var(--corn-space-2);overflow-y:auto}.hx-rc-h{flex:none}.hx-rc-tabs{gap:var(--corn-space-2);display:flex}.hx-rc-tabs[hidden]{display:none}.hx-rc-tab{min-height:var(--hx-control-h);padding:0 var(--corn-space-3);border:var(--corn-border) solid var(--corn-line);border-radius:var(--corn-radius-sm);color:var(--corn-text-3);font:inherit;cursor:pointer;background:0 0;flex:1;font-weight:600}.hx-rc-tab[aria-selected=true]{background:var(--corn-accent);border-color:var(--corn-accent);color:var(--corn-text-on-accent)}.hx-rc-tab:focus-visible,.hx-sc-row:focus-visible,.hx-step:focus-visible,.hx-rc-h:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:var(--corn-focus-offset)}.hx-rc-section[hidden]{display:none}.hx-rc-h{margin:0 0 var(--corn-space-2);font-size:var(--corn-text-sm);color:var(--corn-text);font-weight:700}.hx-rc-h [data-corn=count]{color:var(--corn-text-3);font-variant-numeric:tabular-nums}.hx-rc-empty,.hx-rc-note,.hx-rc-coverage{margin:var(--corn-space-2) 0 0;line-height:1.5}.hx-rc-coverage{color:var(--corn-text-2)}.hx-change-list,.hx-sc-list,.hx-steps{margin:0;padding:0;list-style:none}.hx-change-list{gap:calc(var(--corn-space-1) / 2);flex-direction:column;display:flex}.hx-persona{margin-top:var(--corn-space-4)}.hx-persona:first-of-type{margin-top:0}.hx-persona-name{margin:0 0 var(--corn-space-1);font-size:var(--corn-text-xs);letter-spacing:.02em;color:var(--corn-text-3);overflow-wrap:anywhere;font-weight:600}.hx-sc-list{gap:var(--corn-space-1);flex-direction:column;display:flex}.hx-sc-row{align-items:flex-start;gap:var(--corn-space-3);width:100%;padding:var(--corn-space-2) var(--corn-space-2);border:var(--corn-border) solid var(--corn-line-soft);border-radius:var(--corn-radius-sm);color:var(--corn-text);font:inherit;text-align:left;cursor:pointer;background:0 0;display:flex}.hx-sc-row:hover{background:color-mix(in srgb, var(--corn-accent-hover) 18%, transparent)}.hx-sc-caret{width:1em;color:var(--corn-text-3);flex:none}.hx-sc-main{gap:calc(var(--corn-space-1) / 2);flex-direction:column;flex:1;min-width:0;display:flex}.hx-sc-title{overflow-wrap:anywhere;font-weight:600}.hx-sc-meta{font-size:var(--corn-text-xs);color:var(--corn-text-3)}.hx-sc-seen{font-size:var(--corn-text-xs);color:var(--corn-added-text);white-space:nowrap;flex:none}.hx-steps{margin:var(--corn-space-1) 0 var(--corn-space-2) var(--corn-space-4);gap:calc(var(--corn-space-1) / 2);flex-direction:column;display:flex}.hx-steps[hidden]{display:none}.hx-step{align-items:flex-start;gap:var(--corn-space-3);width:100%;padding:var(--corn-space-2) var(--corn-space-2);border:0;border-left:var(--corn-border-strong) solid transparent;border-radius:var(--corn-radius-sm);color:var(--corn-text);font:inherit;font-size:var(--corn-text-xs);text-align:left;cursor:pointer;background:0 0;display:flex}.hx-step:hover{background:var(--corn-line-soft)}.hx-step[aria-current=step]{border-left-color:var(--corn-accent-text);background:color-mix(in srgb, var(--corn-accent-hover) 22%, transparent)}.hx-step-n{min-width:1.4em;color:var(--corn-accent-text);font-variant-numeric:tabular-nums;flex:none;font-weight:600}.hx-step-body{gap:calc(var(--corn-space-1) / 2);flex-direction:column;flex:1;min-width:0;display:flex}.hx-step-line{align-items:baseline;gap:0 var(--corn-space-3);flex-wrap:wrap;display:flex}.hx-step-who{color:var(--corn-text-2);font-weight:600}.hx-step-where{overflow-wrap:anywhere;font-weight:600}.hx-step-mark{align-items:center;gap:var(--corn-space-1);color:var(--corn-text-3);display:inline-flex}.hx-step-mark .hx-mark-dot{margin:0}.hx-step-text{color:var(--corn-text-2);overflow-wrap:anywhere;line-height:1.4}.hx-step-off{color:var(--corn-text-3);font-style:italic}.hx-step-verdict{white-space:normal;text-align:right;overflow-wrap:anywhere;align-self:flex-start;max-width:40%}@container corn-box (width<=767px){.hx-review-column{width:auto;max-height:none;box-shadow:none;-webkit-backdrop-filter:none;background:0 0;border:0;border-radius:0;position:static;overflow:visible}.hx-rc-scroll,.hx-rc-lists,.hx-rc-section,.hx-change-list,.hx-rc-sbody{min-height:0;max-height:none;display:block;overflow:visible}.hx-rc-scroll{padding:var(--corn-space-2) 0}.hx-rc-section[hidden]{display:none}#rc-changes,#rc-scenarios{flex:none;min-height:0;max-height:none}.hx-rc-lists{flex-direction:column;display:flex}.hx-change-list{display:flex}.hx-step,.hx-sc-row,.hx-rc-tab{min-height:44px}.hx-step-verdict{max-width:45%}}@container corn-box (width>=768px){.hx-stage:has(.drawer-open) .hx-player{right:504px}}.hx-player-as,.hx-player-check{flex:1 0 100%}.hx-player-speed[data-corn=control]{color:var(--corn-text)}.hx-rc-sub{margin:var(--corn-space-2) 0 var(--corn-space-1);font-size:var(--corn-text-sm);color:var(--corn-text);font-weight:600}", Ka = () => ".hx-review{gap:var(--corn-space-2);flex-direction:column;flex:1 0 100%;order:1;display:flex}.hx-review[hidden],.hx-review:not(:has(>:not([hidden]))){display:none}.hx-review-form{gap:var(--corn-space-2);flex-direction:column;display:flex}.hx-review-form[hidden]{display:none}.hx-review-label{color:var(--corn-text-3);font-size:var(--corn-text-xs)}.hx-review-note{resize:vertical;width:100%;min-height:44px;padding:var(--corn-space-2) var(--corn-space-3);border-radius:var(--corn-radius-sm);border:var(--corn-border) solid var(--corn-line);background:color-mix(in srgb, var(--corn-ground) 80%, transparent);color:var(--corn-text);font:inherit;font-size:var(--corn-text-sm);user-select:text;line-height:1.4}.hx-review-note:focus{outline:var(--corn-focus-width) solid var(--corn-added-text);outline-offset:calc(var(--corn-focus-offset) / 2)}.hx-review-row{align-items:center;gap:var(--corn-space-2) var(--corn-space-3);flex-wrap:wrap;display:flex}.hx-btn--approve{border-color:color-mix(in srgb, var(--corn-added) 50%, transparent);color:var(--corn-added-text)}.hx-btn--approve:hover{background:color-mix(in srgb, var(--corn-added) 20%, transparent);color:var(--corn-added-text)}.hx-review-status{color:var(--corn-added-text);font-variant-numeric:tabular-nums;margin:0}.hx-review-status[hidden],.hx-review-msg[hidden],.hx-review-line[hidden]{display:none}.hx-review-msg{padding:var(--corn-space-1) var(--corn-space-3);border-radius:var(--corn-radius-sm);background:color-mix(in srgb, var(--corn-removed) 12%, transparent);border:var(--corn-border) solid color-mix(in srgb, var(--corn-removed) 35%, transparent);color:var(--corn-bad);margin:0;line-height:1.4}.hx-review-line{color:var(--corn-text-2);margin:0;line-height:1.4}.hx-proposal-actions{align-items:center;gap:var(--corn-space-3);margin-left:auto;display:flex}.hx-proposal-actions .hx-btn{height:var(--hx-control-h);padding:0 var(--corn-space-5);font-size:var(--corn-text-sm);justify-content:center;font-weight:500}.hx-proposal-actions .hx-btn--approve,.hx-proposal-actions .hx-btn--approve:hover{background:var(--corn-accent);border-color:var(--corn-accent);color:var(--corn-text-on-accent);font-weight:600}.hx-proposal-actions .hx-btn:disabled{opacity:.4;cursor:default}@container corn-box (width<=767px){.hx-review{order:3;grid-column:1/-1}.hx-proposal-actions{gap:var(--corn-space-3);order:4;grid-column:1/-1;grid-template-columns:1fr 1fr;margin-left:0;display:grid}.hx-proposal-actions .hx-btn{height:auto;min-height:44px;padding:var(--corn-space-2) var(--corn-space-3);white-space:normal;text-align:center;font-size:var(--corn-text-md)}.hx-review .hx-btn{min-height:44px}}.hx-forge-cta .hx-btn--approve{flex:1}@container corn-box (width<=767px){.hx-proposal-bar:has(.hx-review-form:not([hidden])) .hx-proposal-actions{order:4;grid-template-columns:1fr}.hx-proposal-bar:has(.hx-review-form:not([hidden])) .hx-proposal-actions .hx-btn--approve{display:none}}.hx-rc-foot{gap:var(--corn-space-2);padding:var(--corn-space-3) var(--corn-space-4);border-top:var(--corn-border) solid var(--corn-line);flex-direction:column;flex:none;display:flex}.hx-rc-foot .hx-review{flex:none;order:0}.hx-rc-foot .hx-proposal-actions{margin-left:auto}@container corn-box (width<=767px){.hx-rc-foot{padding:var(--corn-space-3) 0 0}.hx-rc-foot .hx-proposal-actions{width:100%;margin-left:0}}.hx-decision-line{color:var(--corn-text-2);font-size:var(--corn-text-sm);margin:0;line-height:1.5}.hx-decision-line[hidden],.hx-review-ask[hidden],.hx-hold[hidden],.hx-review-landing[hidden],.hx-sent-edits[hidden]{display:none}.hx-review-ask{padding:var(--corn-space-2) var(--corn-space-3);border-radius:var(--corn-radius-sm);border:var(--corn-border) solid color-mix(in srgb, var(--corn-warn) 55%, transparent);background:color-mix(in srgb, var(--corn-warn) 14%, transparent);color:var(--corn-text);margin:0;line-height:1.4}.hx-review-landing{justify-content:space-between;align-items:center;gap:var(--corn-space-3);padding:var(--corn-space-2) var(--corn-space-3);border-radius:var(--corn-radius-sm);border:var(--corn-border) solid var(--corn-line);color:var(--corn-text-2);display:flex}.hx-review-landing p{margin:0;line-height:1.4}.hx-sent-edits{color:var(--corn-text-2)}.hx-sent-edits summary{cursor:pointer;min-height:24px}.hx-hold{border-radius:var(--corn-radius-sm);background:color-mix(in srgb, var(--corn-accent) 22%, transparent);height:3px;overflow:hidden}.hx-hold-fill{background:var(--corn-accent);transform-origin:0;width:100%;height:100%;animation-name:hx-hold-drain;animation-timing-function:linear;animation-fill-mode:forwards;display:block}@keyframes hx-hold-drain{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.hx-proposal-actions .hx-btn[aria-disabled=true]{opacity:.55;cursor:default}.hx-proposal-actions .hx-btn[data-holding=true]{opacity:1;font-variant-numeric:tabular-nums}.hx-review-undo[hidden]{display:none}@container corn-box (width<=767px){.hx-review-undo{order:1;grid-column:1/-1;min-width:44px;min-height:44px}.hx-review-landing .hx-btn{min-height:44px}.hx-proposal-bar:has(.hx-review-form:not([hidden])) .hx-decision-line{display:none}}@media (prefers-reduced-motion:reduce){.hx-hold{display:none}.hx-hold-fill{animation:none}}", qa = () => ".hx-dock{display:contents}.hx-sheet-handle{display:none}@keyframes hx-sheet-in{0%{opacity:0;transform:translateY(28px)}}@container corn-box (width<=767px){.hx-dock{z-index:45;pointer-events:none;flex-direction:column;justify-content:flex-end;display:flex;position:absolute;bottom:0;left:0;right:0}.hx-dock>*{pointer-events:auto}.hx-dock>.hx-sheet{border-radius:var(--corn-radius-lg) var(--corn-radius-lg) 0 0;width:100%;max-width:none;box-shadow:var(--corn-shadow-sheet);overscroll-behavior:contain;--sheet-pb:var(--corn-space-3);border-bottom:0;margin:0;animation:.2s ease-out hx-sheet-in;position:relative;inset:auto;transform:none}.hx-dock>.hx-sheet[data-sheet-last]:not(.hx-drawer){padding-bottom:calc(var(--sheet-pb) + env(safe-area-inset-bottom,0px))}.hx-sheet-handle{cursor:grab;touch-action:none;background:0 0;border:0;flex:none;justify-content:center;align-items:center;width:100%;height:22px;padding:0;display:flex}.hx-sheet-handle span{border-radius:var(--corn-radius-pill);background:var(--corn-surface-3);width:40px;height:5px}.hx-sheet-handle:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:calc(var(--corn-focus-width) * -1);border-radius:var(--corn-radius)}.hx-player>.hx-sheet-handle{flex:0 0 100%}}@media (prefers-reduced-motion:reduce){.hx-dock>.hx-sheet{animation:none}.hx-sheet,.hx-dock>.hx-sheet{transition:none;animation:none}}@container corn-box (width<=767px){.hx-sheet-handle{height:44px}}@media (pointer:coarse){.hx-sheet-handle{height:44px}}.hx-sheet-stub{display:none}@container corn-box (width<=767px){.hx-dock>.hx-sheet[data-sheet-away]{display:none}.hx-dock>.hx-sheet[data-sheet-state=stub]{min-height:44px;max-height:44px;padding-top:0;padding-bottom:0;overflow:hidden}.hx-dock>.hx-sheet[data-sheet-state=stub]>:not(.hx-sheet-stub){display:none!important}.hx-sheet-stub{align-items:center;gap:var(--corn-space-3);width:100%;min-height:44px;padding:0 var(--corn-space-1);color:var(--corn-text);font:inherit;text-align:left;background:0 0;border:0;font-weight:600;display:flex}.hx-sheet-stub[hidden]{display:none}.hx-sheet-stub:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:calc(var(--corn-focus-width) * -1);border-radius:var(--corn-radius)}.hx-sheet-stub-title{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;overflow:hidden}.hx-proposal-bar[data-sheet-state=peek] .hx-review>:not([data-review-hint]):not([data-review-msg]):not([data-review-line]):not([data-review-ask]):not([data-review-hold]):not([data-review-hold-live]):not([data-review-landing]),.hx-dock:has(>.hx-player) .hx-proposal-bar[data-sheet-state=peek] .hx-rc-foot{display:none}.hx-proposal-bar[data-sheet-state=expanded] .hx-whatif-panel{max-height:none;overflow:visible}.hx-proposal-bar[data-sheet-state=peek]>:not(.hx-sheet-handle):not(#proposal-message):not(#proposal-ways):not(#proposal-body),.hx-proposal-bar[data-sheet-state=peek] #proposal-body>:not(.hx-proposal-head),.hx-proposal-bar[data-sheet-state=peek] .hx-proposal-head>:is(.hx-proposal-tools,.hx-proposal-more,.hx-proposal-more-menu){display:none}@container corn-page (height<=480px){.hx-proposal-bar[data-sheet-state=expanded]{max-height:calc(100cqh - var(--corn-space-3))}}.hx-proposal-bar[data-sheet-state=peek] .hx-proposal-chip{display:none}.hx-proposal-bar[data-sheet-state=expanded]{max-height:62cqh}.hx-proposal-bar[data-sheet-state=expanded] .hx-proposal-chip,.hx-proposal-bar[data-sheet-state=expanded] .hx-proposal-summary{display:none}.hx-proposal-bar[data-sheet-state=expanded] .hx-proposal-counts{order:3;grid-column:1}.hx-proposal-bar[data-sheet-state=expanded] .hx-proposal-tools{order:4;grid-column:2}.hx-proposal-bar[data-sheet-state=expanded] .hx-proposal-head{grid-template-columns:minmax(0,1fr) auto auto}.hx-proposal-bar[data-sheet-state=expanded] .hx-proposal-more .hx-btn--icon{order:4;grid-column:3}.hx-proposal-bar[data-sheet-state=peek] .hx-proposal-peek{color:var(--corn-text-2);display:block}@container corn-page (height>=481px){.hx-dock>.hx-proposal-bar[data-sheet-state=expanded]{max-height:min(var(--hx-sheet-cap,50cqh), 50cqh)}}.hx-player[data-sheet-state=expanded]{overflow-y:auto}.hx-player[data-sheet-state=peek]>:not(.hx-sheet-handle):not(.hx-player-controls):not(.hx-player-text):not(.hx-player-side):not(.hx-player-track):not(.hx-player-says){display:none}.hx-player[data-sheet-state=peek] .hx-player-text{align-items:center;gap:var(--corn-space-2);min-height:44px;font-size:var(--corn-text-md);white-space:nowrap;flex:1 1 0;display:flex;overflow:hidden}.hx-player[data-sheet-state=peek] .hx-player-step,.hx-player[data-sheet-state=peek] .hx-player-who,.hx-player[data-sheet-state=peek] .hx-player-sep,.hx-player[data-sheet-state=peek] .hx-player-side .hx-player-speed{display:none}.hx-player[data-sheet-state=expanded] .hx-player-text{flex:1 0 100%;order:3}.hx-player[data-sheet-state=expanded] .hx-player-title{clip:auto;clip-path:none;width:auto;height:auto;font-size:var(--corn-text-sm);color:var(--corn-text-2);flex:0 0 100%;order:0;font-weight:600;position:static;overflow:visible}@container corn-page (height<=480px){.hx-player[data-sheet-state=expanded]{max-height:calc(100cqh - var(--corn-space-3))}}.hx-proposal-bar[data-sheet-state=peek] #proposal-body>.hx-review-column{display:flex}.hx-proposal-bar[data-sheet-state=peek] .hx-review-column>:not(.hx-rc-foot){display:none}@container corn-page (height>=481px){.hx-dock>.hx-player[data-sheet-state=expanded]{max-height:min(var(--hx-sheet-cap,50cqh), 50cqh)}}.hx-dock>.hx-drawer[data-sheet-last][data-sheet-state=peek]{padding-bottom:calc(var(--sheet-pb) + env(safe-area-inset-bottom,0px))}.hx-stage[data-sheet-open=drawer] .hx-backdrop:not([hidden]){-webkit-backdrop-filter:none;background:0 0;display:block}.hx-drawer[data-sheet-state=peek] .hx-drawer-body{padding:0 var(--corn-space-5) var(--corn-space-3);flex:none;gap:0;overflow:hidden}.hx-drawer[data-sheet-state=peek] .hx-drawer-body>:not(.hx-drawer-head),.hx-drawer[data-sheet-state=peek] .hx-drawer-foot{display:none}.hx-drawer[data-sheet-state=peek] .hx-drawer-title{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}@container corn-page (height<=480px){.hx-drawer[data-sheet-state=peek] .hx-drawer-title{text-overflow:clip;white-space:normal;overflow:visible}}@container corn-page (height>=481px){.hx-dock>.hx-drawer[data-sheet-state=expanded]{max-height:min(var(--hx-sheet-cap,60cqh), 60cqh)}}.hx-forge[data-sheet-state=peek] .hx-forge-body{padding:0 var(--corn-space-5) var(--corn-space-3);gap:var(--corn-space-1);flex:none;overflow:hidden}.hx-forge[data-sheet-state=peek] .hx-forge-body>:not(.hx-forge-top):not(#forge-bar),.hx-forge[data-sheet-state=peek] #forge-filter-chip,.hx-forge[data-sheet-state=peek] .hx-forge-tabs{display:none}.hx-forge[data-sheet-state=peek] .hx-forge-head{border-bottom:0;padding-bottom:0}.hx-forge[data-sheet-state=peek] .hx-forge-head .hx-btn{display:none}@container corn-page (height>=481px){.hx-dock>.hx-forge[data-sheet-state=expanded]{max-height:min(var(--hx-sheet-cap,60cqh), 60cqh)}}}", Ja = () => "[data-corn=review]{all:initial;box-sizing:border-box;contain:layout;background-color:var(--corn-ground);background-image:var(--corn-ground-image);width:100%;height:100%;min-height:24rem;color:var(--corn-text);font-family:var(--corn-font);-webkit-font-smoothing:antialiased;user-select:none;flex-direction:column;display:flex;position:relative;overflow:hidden;container:corn-box corn-page/size}.hx-stage{flex:1;width:100%;min-height:0;position:relative;overflow:hidden}@container corn-box (width>=768px){.hx-stage:has(.hx-review-column:not([hidden])){--hx-col-w:400px}}@container corn-box (width>=768px) and (width<=1023px){.hx-stage:has(.hx-review-column:not([hidden])){--hx-col-w:320px}}.hx-review-empty{z-index:1;padding:var(--corn-space-5);text-align:center;color:var(--corn-text-2);font-size:var(--corn-text-md);pointer-events:none;justify-content:center;align-items:center;margin:0;display:flex;position:absolute;inset:0}.hx-proposal-bar{top:12px}[data-corn=review] canvas{border:0}[data-corn=review] :is(p,h1,h2,h3,h4){text-indent:0;font-variant:normal}[data-corn=review] [data-corn=source-status],[data-corn=review] [data-corn=source-notice]{z-index:50}", Ya = () => "[data-corn=source-status]{z-index:2;box-sizing:border-box;align-items:center;gap:var(--corn-space-3);width:min(26rem, calc(100% - var(--corn-space-6) * 2));padding:var(--corn-space-6);border:var(--corn-border) solid var(--corn-line);border-radius:var(--corn-radius-lg);background:var(--corn-surface-1);color:var(--corn-text-2);box-shadow:var(--corn-shadow);text-align:center;font-family:var(--corn-font);font-size:var(--corn-text-md);flex-direction:column;line-height:1.5;display:flex;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}[data-corn=source-status][hidden]{display:none}[data-corn=source-status]:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:var(--corn-focus-offset)}[data-corn=source-status][data-corn-state=running]{box-shadow:none;color:var(--corn-text-3);background:0 0;border-color:#0000;padding:0}[data-corn=source-status][data-corn-state=running] [data-corn=source-title]{font-size:var(--corn-text-md);color:var(--corn-text-3);font-weight:400}[data-corn=source-status][data-corn-state=failure] [data-corn=source-title]{color:var(--corn-bad)}[data-corn=source-status][data-corn-state=waiting] [data-corn=source-title]{color:var(--corn-accent-text)}[data-corn=source-title],[data-corn=source-text]{margin:0}[data-corn=source-title]{font-size:var(--corn-text-lg);color:var(--corn-text);font-weight:600}[data-corn=source-text]{overflow-wrap:anywhere;user-select:text}[data-corn=source-origin]{font-family:var(--corn-mono);color:var(--corn-warn);overflow-wrap:anywhere;user-select:all}[data-corn=source-sign-in],[data-corn=source-retry]{box-sizing:border-box;min-height:max(var(--corn-control-height), 2.75rem);padding:0 var(--corn-space-6);border:var(--corn-border) solid var(--corn-line);border-radius:var(--corn-radius);background:var(--corn-surface-2);color:var(--corn-text);font-family:inherit;font-size:inherit;cursor:pointer;justify-content:center;align-items:center;text-decoration:none;display:inline-flex}[data-corn=source-sign-in]{border-color:var(--corn-accent);background:var(--corn-accent);color:var(--corn-text-on-accent);font-weight:600}[data-corn=source-sign-in]:hover{background:var(--corn-accent-hover)}[data-corn=source-retry]:hover{background:var(--corn-surface-3)}[data-corn=source-sign-in]:focus-visible,[data-corn=source-retry]:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:var(--corn-focus-offset)}[data-corn=source-notice]{z-index:2;box-sizing:border-box;padding:var(--corn-space-3) var(--corn-space-6);background:var(--corn-surface-1);border-top:var(--corn-border) solid var(--corn-line-soft);color:var(--corn-text-2);font-family:var(--corn-font);font-size:var(--corn-text-sm);text-align:center;overflow-wrap:anywhere;margin:0;position:absolute;bottom:0;left:0;right:0}[data-corn=source-notice][hidden]{display:none}", Xa = class extends n {
4276
+ constructor(t) {
4277
+ super(), t !== !1 && this.__registerHost(), this.__attachShadow(), this.cornReady = e(this, "cornReady", 7), this.cornSelect = e(this, "cornSelect", 7), this.cornNavigate = e(this, "cornNavigate", 7), this.cornDecision = e(this, "cornDecision", 7), this.cornAuth = e(this, "cornAuth", 7), this.cornError = e(this, "cornError", 7);
4278
+ }
4279
+ get el() {
4280
+ return this;
4281
+ }
4282
+ src;
4283
+ proposal;
4284
+ source;
4285
+ view;
4286
+ node;
4287
+ theme;
4288
+ useTheme = !1;
4289
+ topology;
4290
+ config;
4291
+ strings;
4292
+ checker;
4293
+ cornReady;
4294
+ cornSelect;
4295
+ cornNavigate;
4296
+ cornDecision;
4297
+ cornAuth;
4298
+ cornError;
4299
+ piece = null;
4300
+ loaded = !1;
4301
+ changes = {};
4302
+ connectedCallback() {
4303
+ this.loaded && this.mountPiece();
4304
+ }
4305
+ componentDidLoad() {
4306
+ this.loaded = !0, this.mountPiece();
4307
+ }
4308
+ disconnectedCallback() {
4309
+ this.unmountPiece();
4310
+ }
4311
+ unmountPiece() {
4312
+ this.piece && this.piece.destroy(), this.piece = null;
4313
+ }
4314
+ remount() {
4315
+ this.unmountPiece(), this.loaded && this.el.isConnected && this.mountPiece();
4316
+ }
4317
+ mountPiece() {
4318
+ !this.piece && this.el.shadowRoot && (this.changes = {}, this.piece = za(this.el.shadowRoot, null, {
4319
+ src: this.src,
4320
+ useTheme: this.useTheme,
4321
+ version: "0.51.0",
4322
+ pageUrl: () => typeof location > "u" ? "" : location.href,
4323
+ tokens: ie,
4324
+ topology: this.topology,
4325
+ config: this.config,
4326
+ strings: this.strings,
4327
+ checker: this.checker,
4328
+ proposal: this.proposal,
4329
+ source: this.source,
4330
+ view: this.view,
4331
+ node: this.node,
4332
+ theme: this.theme,
4333
+ onSelect: (e) => {
4334
+ this.node = e.kind === "node" ? e.id : null, delete this.changes.node, this.cornSelect.emit(e);
4335
+ },
4336
+ onNavigate: (e) => {
4337
+ e.view && (this.view = e.view, delete this.changes.view), e.change === "closed" && (this.proposal = null, delete this.changes.proposal), e.change === "opened" && e.proposal && (this.proposal = e.proposal, delete this.changes.proposal), this.cornNavigate.emit(e);
4338
+ },
4339
+ onDecision: (e) => this.cornDecision.emit(e),
4340
+ onAuth: (e) => this.cornAuth.emit(e),
4341
+ onError: (e) => this.cornError.emit(e),
4342
+ onReady: () => this.cornReady.emit()
4343
+ }));
4344
+ }
4345
+ componentDidRender() {
4346
+ let e = this.changes;
4347
+ this.changes = {}, this.piece && Object.keys(e).length && this.piece.update(e);
4348
+ }
4349
+ changed(e, t, n) {
4350
+ this.changes[n] = e;
4351
+ }
4352
+ addressChanged() {
4353
+ this.piece && this.remount();
4354
+ }
4355
+ async fit() {
4356
+ this.piece && this.piece.fit();
4357
+ }
4358
+ async focusNode(e) {
4359
+ this.piece && this.piece.focusNode(e);
4360
+ }
4361
+ async refresh() {
4362
+ this.piece && this.piece.refresh();
4363
+ }
4364
+ static get watchers() {
4365
+ return {
4366
+ proposal: [{ changed: 0 }],
4367
+ source: [{ changed: 0 }],
4368
+ view: [{ changed: 0 }],
4369
+ node: [{ changed: 0 }],
4370
+ theme: [{ changed: 0 }],
4371
+ useTheme: [{ changed: 0 }],
4372
+ topology: [{ changed: 0 }],
4373
+ config: [{ changed: 0 }],
4374
+ strings: [{ changed: 0 }],
4375
+ checker: [{ changed: 0 }],
4376
+ src: [{ addressChanged: 0 }]
4377
+ };
4378
+ }
4379
+ static get style() {
4380
+ return Ba() + Va() + Ha() + Ua() + Wa() + Ga() + Ka() + qa() + Ja() + Ya();
4381
+ }
4382
+ };
4383
+ t(Xa, [
4384
+ 513,
4385
+ "corn-review",
4386
+ {
4387
+ src: [1],
4388
+ proposal: [1025],
4389
+ source: [1],
4390
+ view: [1537],
4391
+ node: [1537],
4392
+ theme: [513],
4393
+ useTheme: [4, "use-theme"],
4394
+ topology: [16],
4395
+ config: [16],
4396
+ strings: [16],
4397
+ checker: [16],
4398
+ fit: [64],
4399
+ focusNode: [64],
4400
+ refresh: [64]
4401
+ },
4402
+ void 0,
4403
+ {
4404
+ proposal: [{ changed: 0 }],
4405
+ source: [{ changed: 0 }],
4406
+ view: [{ changed: 0 }],
4407
+ node: [{ changed: 0 }],
4408
+ theme: [{ changed: 0 }],
4409
+ useTheme: [{ changed: 0 }],
4410
+ topology: [{ changed: 0 }],
4411
+ config: [{ changed: 0 }],
4412
+ strings: [{ changed: 0 }],
4413
+ checker: [{ changed: 0 }],
4414
+ src: [{ addressChanged: 0 }]
4415
+ }
4416
+ ]);
4417
+ export { Xa as t };