glimmervoid 0.49.1-next.492 → 0.49.1-next.493
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/glimmervoid.js +4 -4
- package/dist/chunks/{agent-api-cli-v5XFXoB7.js → agent-api-cli-D9r9SgcA.js} +1 -1
- package/dist/chunks/{agent-api-cli-C8j21cou.js → agent-api-cli-DL0LtLb4.js} +1 -1
- package/dist/chunks/{main-CAcF9Ov-.js → main-BhBjSxml.js} +1 -1
- package/dist/chunks/{settings-cli-jMVnEXW5.js → settings-cli-Bqx24u1B.js} +1 -1
- package/dist/chunks/{shown-files-core-C4BZsn-W.js → shown-files-core-CiEXUXvy.js} +143 -71
- package/dist/chunks/{ssh-sign-cli-DjJRd8eb.js → ssh-sign-cli-C3z7XlGq.js} +1 -1
- package/dist/client/assets/{benchmark-panel-6UVEMpaF.js → benchmark-panel-vOgfQQKW.js} +1 -1
- package/dist/client/assets/benchmark-panel-vOgfQQKW.js.br +0 -0
- package/dist/client/assets/{boards-view-Cu7YCYxA.js → boards-view-CtJw60S2.js} +1 -1
- package/dist/client/assets/boards-view-CtJw60S2.js.br +0 -0
- package/dist/client/assets/{community-panel-DkrHMcp9.js → community-panel-DLx9C93w.js} +1 -1
- package/dist/client/assets/community-panel-DLx9C93w.js.br +0 -0
- package/dist/client/assets/{dialogs-BGSu7tFg.js → dialogs-BFJtB9Xj.js} +1 -1
- package/dist/client/assets/dialogs-BFJtB9Xj.js.br +0 -0
- package/dist/client/assets/{doc-editor-ui-D-4h8ZTX.js → doc-editor-ui-Dbr12RPe.js} +1 -1
- package/dist/client/assets/doc-editor-ui-Dbr12RPe.js.br +0 -0
- package/dist/client/assets/{feature-hint-CLRd40fA.js → feature-hint-BFxtPS1U.js} +1 -1
- package/dist/client/assets/feature-hint-BFxtPS1U.js.br +0 -0
- package/dist/client/assets/{first-run-checklist-DgxIHBwk.js → first-run-checklist-BePkGfSJ.js} +1 -1
- package/dist/client/assets/first-run-checklist-BePkGfSJ.js.br +0 -0
- package/dist/client/assets/{hooks-panel-BZAJBZ-p.js → hooks-panel-CKFKUdIC.js} +1 -1
- package/dist/client/assets/hooks-panel-CKFKUdIC.js.br +0 -0
- package/dist/client/assets/{index-DOa6kn1l.js → index-DA0egBFL.js} +5 -5
- package/dist/client/assets/index-DA0egBFL.js.br +0 -0
- package/dist/client/assets/{issues-panel-BwIlKIG_.js → issues-panel-C7mperfJ.js} +1 -1
- package/dist/client/assets/issues-panel-C7mperfJ.js.br +0 -0
- package/dist/client/assets/{my-prs-panel-9LYUWqZu.js → my-prs-panel-DmpQ1try.js} +1 -1
- package/dist/client/assets/my-prs-panel-DmpQ1try.js.br +0 -0
- package/dist/client/assets/{nyan-cat-2F5mkv_v.js → nyan-cat-BCzXZCyT.js} +1 -1
- package/dist/client/assets/nyan-cat-BCzXZCyT.js.br +0 -0
- package/dist/client/assets/{phone-shell-BiZs-7vv.js → phone-shell-CHcJr-SZ.js} +1 -1
- package/dist/client/assets/phone-shell-CHcJr-SZ.js.br +0 -0
- package/dist/client/assets/{plan-face-CJLSxO-8.js → plan-face-BblMxP0F.js} +1 -1
- package/dist/client/assets/plan-face-BblMxP0F.js.br +0 -0
- package/dist/client/assets/{pr-queue-columns-xgl08uBK.js → pr-queue-columns-C5WBikyo.js} +1 -1
- package/dist/client/assets/pr-queue-columns-C5WBikyo.js.br +0 -0
- package/dist/client/assets/{radar-panel-CHZgBAua.js → radar-panel-CqHDQlGi.js} +1 -1
- package/dist/client/assets/radar-panel-CqHDQlGi.js.br +0 -0
- package/dist/client/assets/{repo-roots-adder-BFgiaKRN.js → repo-roots-adder-B33jwoYF.js} +1 -1
- package/dist/client/assets/repo-roots-adder-B33jwoYF.js.br +0 -0
- package/dist/client/assets/{resume-dialog-mYsiPxaT.js → resume-dialog-BPa6mJ_l.js} +1 -1
- package/dist/client/assets/resume-dialog-BPa6mJ_l.js.br +0 -0
- package/dist/client/assets/{review-queue-panel-DqWEecqh.js → review-queue-panel-BTKEd5zL.js} +1 -1
- package/dist/client/assets/review-queue-panel-BTKEd5zL.js.br +0 -0
- package/dist/client/assets/{settings-panel-DpkkLC1v.js → settings-panel--nGRQRhI.js} +2 -2
- package/dist/client/assets/settings-panel--nGRQRhI.js.br +0 -0
- package/dist/client/assets/{shown-face-BIIdpVjh.js → shown-face-BWZKfYYo.js} +1 -1
- package/dist/client/assets/shown-face-BWZKfYYo.js.br +0 -0
- package/dist/client/assets/{team-review-panel-Dr-Yb5wn.js → team-review-panel-CK23VYR0.js} +1 -1
- package/dist/client/assets/team-review-panel-CK23VYR0.js.br +0 -0
- package/dist/client/assets/{trace-panel-Dxq8g2S0.js → trace-panel-CGdZhT1O.js} +1 -1
- package/dist/client/assets/trace-panel-CGdZhT1O.js.br +0 -0
- package/dist/client/assets/{usage-panel-HvtQ_7A5.js → usage-panel-vwH52vio.js} +1 -1
- package/dist/client/assets/usage-panel-vwH52vio.js.br +0 -0
- package/dist/client/assets/{your-day-tip-DZ5hTwMh.js → your-day-tip-D5WZXnDZ.js} +1 -1
- package/dist/client/assets/your-day-tip-D5WZXnDZ.js.br +6 -0
- package/dist/client/index.html +1 -1
- package/dist/client/index.html.br +0 -0
- package/dist/server/index.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/benchmark-panel-6UVEMpaF.js.br +0 -0
- package/dist/client/assets/boards-view-Cu7YCYxA.js.br +0 -0
- package/dist/client/assets/community-panel-DkrHMcp9.js.br +0 -0
- package/dist/client/assets/dialogs-BGSu7tFg.js.br +0 -0
- package/dist/client/assets/doc-editor-ui-D-4h8ZTX.js.br +0 -0
- package/dist/client/assets/feature-hint-CLRd40fA.js.br +0 -0
- package/dist/client/assets/first-run-checklist-DgxIHBwk.js.br +0 -0
- package/dist/client/assets/hooks-panel-BZAJBZ-p.js.br +0 -0
- package/dist/client/assets/index-DOa6kn1l.js.br +0 -0
- package/dist/client/assets/issues-panel-BwIlKIG_.js.br +0 -0
- package/dist/client/assets/my-prs-panel-9LYUWqZu.js.br +0 -0
- package/dist/client/assets/nyan-cat-2F5mkv_v.js.br +0 -0
- package/dist/client/assets/phone-shell-BiZs-7vv.js.br +0 -0
- package/dist/client/assets/plan-face-CJLSxO-8.js.br +0 -0
- package/dist/client/assets/pr-queue-columns-xgl08uBK.js.br +0 -0
- package/dist/client/assets/radar-panel-CHZgBAua.js.br +0 -0
- package/dist/client/assets/repo-roots-adder-BFgiaKRN.js.br +0 -0
- package/dist/client/assets/resume-dialog-mYsiPxaT.js.br +0 -0
- package/dist/client/assets/review-queue-panel-DqWEecqh.js.br +0 -0
- package/dist/client/assets/settings-panel-DpkkLC1v.js.br +0 -0
- package/dist/client/assets/shown-face-BIIdpVjh.js.br +0 -0
- package/dist/client/assets/team-review-panel-Dr-Yb5wn.js.br +0 -0
- package/dist/client/assets/trace-panel-Dxq8g2S0.js.br +0 -0
- package/dist/client/assets/usage-panel-HvtQ_7A5.js.br +0 -0
- package/dist/client/assets/your-day-tip-DZ5hTwMh.js.br +0 -3
package/dist/bin/glimmervoid.js
CHANGED
|
@@ -75,7 +75,7 @@ var OWNED_COMMAND_RUNNERS = {
|
|
|
75
75
|
return runAgentSetupCli();
|
|
76
76
|
},
|
|
77
77
|
settings: async (parsed) => {
|
|
78
|
-
const { runParsedSettingsCli } = await import("../chunks/settings-cli-
|
|
78
|
+
const { runParsedSettingsCli } = await import("../chunks/settings-cli-Bqx24u1B.js");
|
|
79
79
|
return runParsedSettingsCli(parsed);
|
|
80
80
|
},
|
|
81
81
|
why: async ({ positionals }) => {
|
|
@@ -83,7 +83,7 @@ var OWNED_COMMAND_RUNNERS = {
|
|
|
83
83
|
return runWhyCli({ targetArgument: positionals[0] ?? "" });
|
|
84
84
|
},
|
|
85
85
|
"ssh-sign": async ({ rawArgs }) => {
|
|
86
|
-
const { runSshSignCli } = await import("../chunks/ssh-sign-cli-
|
|
86
|
+
const { runSshSignCli } = await import("../chunks/ssh-sign-cli-C3z7XlGq.js");
|
|
87
87
|
return runSshSignCli(rawArgs);
|
|
88
88
|
}
|
|
89
89
|
};
|
|
@@ -105,7 +105,7 @@ async function runOwnedCommand(name, subcommandArgs) {
|
|
|
105
105
|
return OWNED_COMMAND_RUNNERS[name](parsed);
|
|
106
106
|
}
|
|
107
107
|
var SUBCOMMAND_RUNNERS = new Map([...Object.keys(OWNED_COMMAND_SPECS).filter(isOwnedCommandName).map((name) => [name, (subcommandArgs) => runOwnedCommand(name, subcommandArgs)]), ...AGENT_API_VERBS.filter((verb) => !isOwnedCommandName(verb)).map((verb) => [verb, async (subcommandArgs, subcommandName) => {
|
|
108
|
-
const { runAgentApiCli } = await import("../chunks/agent-api-cli-
|
|
108
|
+
const { runAgentApiCli } = await import("../chunks/agent-api-cli-DL0LtLb4.js");
|
|
109
109
|
return runAgentApiCli([subcommandName, ...subcommandArgs]);
|
|
110
110
|
}])]);
|
|
111
111
|
var AGENT_INSTALL_COMMAND_BY_ID = {
|
|
@@ -119,7 +119,7 @@ function missingAgentText(agentId) {
|
|
|
119
119
|
}
|
|
120
120
|
async function printSessionLimits() {
|
|
121
121
|
if (!process.env["GLIMMERVOID_AGENT_URL"]) return;
|
|
122
|
-
const { sessionLimitsHelpLines } = await import("../chunks/agent-api-cli-
|
|
122
|
+
const { sessionLimitsHelpLines } = await import("../chunks/agent-api-cli-DL0LtLb4.js");
|
|
123
123
|
const limitsLines = await sessionLimitsHelpLines();
|
|
124
124
|
console.log(`\n${limitsLines.join("\n")}`);
|
|
125
125
|
}
|
|
@@ -2,7 +2,7 @@ import { Z as UNIT_STATUSES, et as WhiteboardAgentReply, l as AgentLimitsReply,
|
|
|
2
2
|
import { J as formatSessionLimits, i as agentCommandSpec, m as isAgentApiVerb, rt as parseCommand, t as AGENT_COMMAND_HELP } from "./agent-api-core-BQQGuOAb.js";
|
|
3
3
|
import { i as resolveHookTarget } from "./hook-relay-core-DA_bz2KA.js";
|
|
4
4
|
import { t as parseJsonOrNull } from "./json-core-If8h-Qgy.js";
|
|
5
|
-
import { _ as planSteps, i as describeOverCap, m as layoutBoard, p as escapeMarkup } from "./shown-files-core-
|
|
5
|
+
import { _ as planSteps, i as describeOverCap, m as layoutBoard, p as escapeMarkup } from "./shown-files-core-CiEXUXvy.js";
|
|
6
6
|
import fs from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import http from "node:http";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as askAgentApi, r as runAgentApiCli, i as sessionLimitsHelpLines } from "./agent-api-cli-
|
|
1
|
+
export { t as askAgentApi, r as runAgentApiCli, i as sessionLimitsHelpLines } from "./agent-api-cli-D9r9SgcA.js";
|
|
@@ -14,7 +14,7 @@ import { n as promptContextReplyOf, o as toolHookContextReplyOf, r as refocusRep
|
|
|
14
14
|
import { n as parseJsonRecord, t as parseJsonOrNull } from "./json-core-If8h-Qgy.js";
|
|
15
15
|
import { a as saneYoloFiles } from "./sane-yolo-BjUkqIoH.js";
|
|
16
16
|
import { r as knownWriteHookInput } from "./posthog-read-gate-core-CeSY56AB.js";
|
|
17
|
-
import { a as filesAfterRetention, c as readPageTitle, d as thumbnailOwnerIdOf, f as thumbnailRecipeFor, g as findDependencyCycle, h as cappedWarnings, i as describeOverCap, l as shownMimeForFilename, m as layoutBoard, n as SHOWN_SNIFF_BYTES, o as isShownPageMime, p as escapeMarkup, r as decideShownKind, s as leavesVisibleRawTextOpen, t as SHOWN_PAGE_ZOOM_BRIDGE, u as thumbnailFilenameOf, v as unitsOf } from "./shown-files-core-
|
|
17
|
+
import { a as filesAfterRetention, c as readPageTitle, d as thumbnailOwnerIdOf, f as thumbnailRecipeFor, g as findDependencyCycle, h as cappedWarnings, i as describeOverCap, l as shownMimeForFilename, m as layoutBoard, n as SHOWN_SNIFF_BYTES, o as isShownPageMime, p as escapeMarkup, r as decideShownKind, s as leavesVisibleRawTextOpen, t as SHOWN_PAGE_ZOOM_BRIDGE, u as thumbnailFilenameOf, v as unitsOf } from "./shown-files-core-CiEXUXvy.js";
|
|
18
18
|
import { n as shellQuote } from "./hook-command-core-qTNK-xMF.js";
|
|
19
19
|
import { C as parseCgroupBytes, D as DEFAULT_MAX_MS, E as DEFAULT_BASE_MS, O as nextBackoffMs, S as memoryReserveBytes, T as parseMemAvailableBytes, _ as createSpawnGate, a as jsonStateLoadError, b as cgroupLimitBytes, c as loadedJsonValue, d as writeJsonAtomicSync, g as createSerialQueue, h as createMemoryAdmission, i as createJsonStateWriter, m as createKeyedSerialQueue, n as appendJsonLines, o as loadJsonStateFile, p as writeTextAtomicSync, r as createJsonStateStore, s as loadJsonStateFileSync, t as appendJsonLine, u as writeJsonAtomic, v as isQueueAdmissionTimeout, w as parseCgroupV2Path, x as headroomFromReadings, y as cgroupAncestorPaths } from "./json-file-AKRVPqG1.js";
|
|
20
20
|
import { $ as decideRemoteTelemetryState, B as parseDataClientMessage, F as DEEP_HISTORY_SCROLLBACK_LINES, G as buildAiGenerationEvents, H as TELEMETRY_BATCH_URL, J as buildPersonProperties, K as buildBrowserExceptionProperties, L as LOGGED_FAST_CLOSE_COUNTS, P as isExperimentalSetting, Q as decideIsDevInstall, R as describeDataAttach, St as isSameDirectoryPath, U as TELEMETRY_FLAGS_URL, V as FIRST_RUN_NOTICE, W as adapterBucket, X as claudeAccountUuidOf, Y as classifySessionExit, Z as codexUserIdOf, _t as sessionIdFromBranch, a as ensureProjectIds, at as DashboardTelemetryReport, b as validateSettingsBlock, bt as canonicalizePath, ct as TelemetryState, dt as stableConfigKey, et as decideTelemetryConsent, f as DEFAULT_TIMER_FNS, gt as planWorktreeGc, ht as planBranchGc, i as createConfigStore, it as resolveProjectToken, j as valueAtPath, mt as matchedPrefix, n as DEFAULT_CONFIG, nt as nodeMajorVersion, o as generateProjectId, ot as PendingCrashReport, p as unrefTimer, pt as DEFAULT_BRANCH_GC_PREFIXES, q as buildExceptionProperties, rt as parsePosthogReleaseId, s as glimmervoidHomeDir$1, st as TELEMETRY_EVENT_SCHEMAS, t as ABORT_CONFIG_SAVE, tt as exceptionFingerprint, v as mergeSettingsBlock, vt as usablePrefixes, x as SETTINGS_INDEX, xt as comparableDirectoryPath, y as settingsBlockSpecFor, yt as worktreeIntegrationTips, z as parseDataAttach } from "./config-store-Cu8-ZMk7.js";
|
|
@@ -303,7 +303,7 @@ function runParsedSettingsCommand(parsed, io) {
|
|
|
303
303
|
async function runParsedSettingsCli(parsed, io = processIo()) {
|
|
304
304
|
const serverRequest = settingsRequestForServer(parsed, process.env);
|
|
305
305
|
if (!serverRequest) return runParsedSettingsCommand(parsed, io);
|
|
306
|
-
const { askAgentApi } = await import("./agent-api-cli-
|
|
306
|
+
const { askAgentApi } = await import("./agent-api-cli-DL0LtLb4.js");
|
|
307
307
|
const reply = AgentSettingsReply.safeParse(await askAgentApi("settings", serverRequest).catch((error) => ({
|
|
308
308
|
ok: false,
|
|
309
309
|
error: errorMessage(error)
|
|
@@ -92,6 +92,7 @@ var MAX_EXPANSIONS = 2e4;
|
|
|
92
92
|
var MAX_TOTAL_EXPANSIONS = 4e5;
|
|
93
93
|
var MAX_BENDS = 6;
|
|
94
94
|
var MAX_WIRES_FOR_PORT_SEARCH = 12;
|
|
95
|
+
var PROBE_EXPANSIONS = 3e3;
|
|
95
96
|
var PORT_SPACING = 14;
|
|
96
97
|
var PORT_INSET = 8;
|
|
97
98
|
var BOX_CROSSING_COST = 100;
|
|
@@ -233,111 +234,182 @@ function cappedWarnings(warnings) {
|
|
|
233
234
|
function hasHorizontalGap(first, second) {
|
|
234
235
|
return second.x >= first.x + first.width || second.x + second.width <= first.x;
|
|
235
236
|
}
|
|
236
|
-
function
|
|
237
|
-
const exitSide = centerOf(to).x > centerOf(from).x ? "right" : "left";
|
|
238
|
-
const facingEntrySide = exitSide === "right" ? "left" : "right";
|
|
239
|
-
if (startSpan.bottom < to.y) return {
|
|
240
|
-
exitSide,
|
|
241
|
-
entrySide: "top",
|
|
242
|
-
facingEntrySide
|
|
243
|
-
};
|
|
244
|
-
if (startSpan.top > to.y + to.height) return {
|
|
245
|
-
exitSide,
|
|
246
|
-
entrySide: "bottom",
|
|
247
|
-
facingEntrySide
|
|
248
|
-
};
|
|
249
|
-
return {
|
|
250
|
-
exitSide,
|
|
251
|
-
entrySide: facingEntrySide,
|
|
252
|
-
facingEntrySide: null
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
function defaultSides(from, to, isBack, startSpan) {
|
|
237
|
+
function facingSides(from, to, isBack) {
|
|
256
238
|
if (from.id === to.id) return {
|
|
257
239
|
exitSide: "right",
|
|
258
|
-
entrySide: "top"
|
|
259
|
-
facingEntrySide: null
|
|
240
|
+
entrySide: "top"
|
|
260
241
|
};
|
|
261
242
|
if (isBack) return {
|
|
262
243
|
exitSide: "bottom",
|
|
263
|
-
entrySide: "bottom"
|
|
264
|
-
|
|
244
|
+
entrySide: "bottom"
|
|
245
|
+
};
|
|
246
|
+
const fromCenter = centerOf(from);
|
|
247
|
+
const toCenter = centerOf(to);
|
|
248
|
+
if (hasHorizontalGap(from, to)) return toCenter.x > fromCenter.x ? {
|
|
249
|
+
exitSide: "right",
|
|
250
|
+
entrySide: "left"
|
|
251
|
+
} : {
|
|
252
|
+
exitSide: "left",
|
|
253
|
+
entrySide: "right"
|
|
265
254
|
};
|
|
266
|
-
|
|
267
|
-
return centerOf(to).y > centerOf(from).y ? {
|
|
255
|
+
return toCenter.y > fromCenter.y ? {
|
|
268
256
|
exitSide: "bottom",
|
|
269
|
-
entrySide: "top"
|
|
270
|
-
facingEntrySide: null
|
|
257
|
+
entrySide: "top"
|
|
271
258
|
} : {
|
|
272
259
|
exitSide: "top",
|
|
273
|
-
entrySide: "bottom"
|
|
274
|
-
facingEntrySide: null
|
|
260
|
+
entrySide: "bottom"
|
|
275
261
|
};
|
|
276
262
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
263
|
+
var ALL_SIDES = [
|
|
264
|
+
"right",
|
|
265
|
+
"left",
|
|
266
|
+
"bottom",
|
|
267
|
+
"top"
|
|
268
|
+
];
|
|
269
|
+
function candidateSidePairs(plan, facing) {
|
|
270
|
+
const { wire, from, to } = plan;
|
|
271
|
+
if (wire.back || from.id === to.id) return [facing];
|
|
272
|
+
const exitSides = plan.outputPort || wire.fromSide ? [plan.exitSide] : [facing.exitSide, ...ALL_SIDES.filter((side) => side !== facing.exitSide)];
|
|
273
|
+
const entrySides = wire.toSide ? [wire.toSide] : [facing.entrySide, ...ALL_SIDES.filter((side) => side !== facing.entrySide)];
|
|
274
|
+
return exitSides.flatMap((exitSide) => entrySides.map((entrySide) => ({
|
|
275
|
+
exitSide,
|
|
276
|
+
entrySide
|
|
277
|
+
})));
|
|
278
|
+
}
|
|
279
|
+
function probeOf(plan, pair) {
|
|
280
|
+
const centeredStart = plan.outputPort ?? portPositions(plan.from, pair.exitSide, 1)[0] ?? centerOf(plan.from);
|
|
281
|
+
const centeredEnd = portPositions(plan.to, pair.entrySide, 1)[0] ?? centerOf(plan.to);
|
|
282
|
+
if (!isFacing(pair.exitSide, pair.entrySide)) return {
|
|
283
|
+
...plan,
|
|
284
|
+
...pair,
|
|
285
|
+
start: centeredStart,
|
|
286
|
+
end: centeredEnd
|
|
283
287
|
};
|
|
284
|
-
const
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
288
|
+
const alignedEnd = alignedAlong(centeredEnd, pair.entrySide, plan.to, centeredStart);
|
|
289
|
+
const start = alignedEnd === centeredEnd && !plan.outputPort ? alignedAlong(centeredStart, pair.exitSide, plan.from, centeredEnd) : centeredStart;
|
|
290
|
+
return {
|
|
291
|
+
...plan,
|
|
292
|
+
...pair,
|
|
293
|
+
start,
|
|
294
|
+
end: alignedEnd
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
function isBetterProbe(candidate, best) {
|
|
298
|
+
return candidate.turnsAndCrossings < best.turnsAndCrossings || candidate.turnsAndCrossings === best.turnsAndCrossings && candidate.cost < best.cost;
|
|
299
|
+
}
|
|
300
|
+
function probeRoute(grid, probe, buffers) {
|
|
301
|
+
const states = searchGrid(grid, probe, {
|
|
302
|
+
usageByEdge: /* @__PURE__ */ new Map(),
|
|
303
|
+
usageByNodeAndAxis: /* @__PURE__ */ new Map()
|
|
304
|
+
}, null, buffers, { remainingExpansions: PROBE_EXPANSIONS });
|
|
305
|
+
const goalState = states?.at(-1);
|
|
306
|
+
const cost = goalState === void 0 ? Infinity : buffers.bestCost[goalState] ?? Infinity;
|
|
307
|
+
resetSearchBuffers(buffers);
|
|
308
|
+
if (!states || cost === Infinity) return null;
|
|
309
|
+
const points = withoutBends(states.map((state) => {
|
|
310
|
+
const node = state >> 2;
|
|
311
|
+
const xIndex = node % grid.xs.length;
|
|
312
|
+
return {
|
|
313
|
+
x: grid.xs[xIndex] ?? 0,
|
|
314
|
+
y: grid.ys[(node - xIndex) / grid.xs.length] ?? 0
|
|
315
|
+
};
|
|
316
|
+
}));
|
|
317
|
+
return {
|
|
318
|
+
segments: segmentsOf(points),
|
|
319
|
+
bends: Math.max(points.length - 2, 0),
|
|
320
|
+
cost
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
function scoreOf(route, otherRoutes) {
|
|
324
|
+
const crossings = otherRoutes.filter((other) => other.segments.some((otherSegment) => route.segments.some((segment) => segmentsCross(segment, otherSegment)))).length;
|
|
325
|
+
return {
|
|
326
|
+
turnsAndCrossings: route.bends + crossings,
|
|
327
|
+
cost: route.cost
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
function chooseSidesBySearch(plans, facingByPlan, input) {
|
|
331
|
+
const pairsByPlan = new Map(plans.map((plan) => {
|
|
332
|
+
return [plan, candidateSidePairs(plan, facingByPlan.get(plan) ?? {
|
|
333
|
+
exitSide: plan.exitSide,
|
|
334
|
+
entrySide: plan.entrySide
|
|
335
|
+
})];
|
|
336
|
+
}));
|
|
337
|
+
if (![...pairsByPlan.values()].some((pairs) => pairs.length > 1)) return;
|
|
338
|
+
const grid = buildGrid([...pairsByPlan].flatMap(([plan, pairs]) => pairs.map((pair) => probeOf(plan, pair))), [...input.boxesById.values(), ...input.panels], input.softObstacles, input.contentTop);
|
|
339
|
+
if (!grid) return;
|
|
340
|
+
const buffers = createSearchBuffers(grid);
|
|
341
|
+
const baselineByPlan = new Map(plans.flatMap((plan) => {
|
|
342
|
+
const [facing] = pairsByPlan.get(plan) ?? [];
|
|
343
|
+
const route = facing ? probeRoute(grid, probeOf(plan, facing), buffers) : null;
|
|
344
|
+
return route ? [[plan, route]] : [];
|
|
345
|
+
}));
|
|
346
|
+
for (const [plan, pairs] of pairsByPlan) {
|
|
347
|
+
const baseline = baselineByPlan.get(plan);
|
|
348
|
+
if (pairs.length < 2 || !baseline) continue;
|
|
349
|
+
const otherRoutes = [...baselineByPlan].flatMap(([other, route]) => other === plan ? [] : [route]);
|
|
350
|
+
let best = {
|
|
351
|
+
pair: pairs[0],
|
|
352
|
+
score: scoreOf(baseline, otherRoutes)
|
|
353
|
+
};
|
|
354
|
+
for (const pair of pairs.slice(1)) {
|
|
355
|
+
const route = probeRoute(grid, probeOf(plan, pair), buffers);
|
|
356
|
+
const score = route ? scoreOf(route, otherRoutes) : null;
|
|
357
|
+
if (score && isBetterProbe(score, best.score)) best = {
|
|
358
|
+
pair,
|
|
359
|
+
score
|
|
360
|
+
};
|
|
296
361
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
362
|
+
if (!best.pair) continue;
|
|
363
|
+
plan.exitSide = best.pair.exitSide;
|
|
364
|
+
plan.entrySide = best.pair.entrySide;
|
|
365
|
+
}
|
|
300
366
|
}
|
|
301
|
-
function
|
|
302
|
-
|
|
367
|
+
function joinFacingBuses(plans, facingByPlan) {
|
|
368
|
+
const isEnteringFacing = (plan) => plan.entrySide === facingByPlan.get(plan)?.entrySide;
|
|
369
|
+
for (let hasChanged = true; hasChanged;) {
|
|
370
|
+
hasChanged = false;
|
|
371
|
+
for (const plan of plans) {
|
|
372
|
+
const facing = facingByPlan.get(plan);
|
|
373
|
+
if (!facing || isEnteringFacing(plan) || plan.wire.toSide) continue;
|
|
374
|
+
if (!plans.some((other) => other !== plan && other.to.id === plan.to.id && other.styleKey === plan.styleKey && other.entrySide === facing.entrySide && isEnteringFacing(other))) continue;
|
|
375
|
+
plan.exitSide = plan.outputPort || plan.wire.fromSide ? plan.exitSide : facing.exitSide;
|
|
376
|
+
plan.entrySide = facing.entrySide;
|
|
377
|
+
hasChanged = true;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
303
380
|
}
|
|
304
381
|
function planWires(input) {
|
|
305
|
-
const
|
|
382
|
+
const facingByPlan = /* @__PURE__ */ new Map();
|
|
306
383
|
const plans = input.wires.flatMap((wire) => {
|
|
307
384
|
const from = input.boxesById.get(wire.from);
|
|
308
385
|
const to = input.boxesById.get(wire.to);
|
|
309
386
|
if (!from || !to) return [];
|
|
387
|
+
const facing = facingSides(from, to, wire.back);
|
|
310
388
|
const output = from.outputs.find((candidate) => candidate.id === wire.fromOutput);
|
|
311
|
-
const startSpan = output ? {
|
|
312
|
-
top: output.port.y,
|
|
313
|
-
bottom: output.port.y
|
|
314
|
-
} : {
|
|
315
|
-
top: from.y,
|
|
316
|
-
bottom: from.y + from.height
|
|
317
|
-
};
|
|
318
|
-
const sides = defaultSides(from, to, wire.back, startSpan);
|
|
319
|
-
const exitSide = output ? "right" : wire.fromSide ?? sides.exitSide;
|
|
320
|
-
const entrySide = wire.toSide ?? sides.entrySide;
|
|
321
389
|
const strokeHex = wire.tone === "lane" ? from.lane?.hex ?? null : null;
|
|
322
|
-
const styleKey = `${wire.dashed || wire.back}|${wire.tone}|${strokeHex}`;
|
|
323
390
|
const plan = {
|
|
324
391
|
wire,
|
|
325
392
|
from,
|
|
326
393
|
to,
|
|
327
394
|
strokeHex,
|
|
328
|
-
styleKey
|
|
329
|
-
exitSide,
|
|
330
|
-
entrySide,
|
|
395
|
+
styleKey: `${wire.dashed || wire.back}|${wire.tone}|${strokeHex}`,
|
|
396
|
+
exitSide: output ? "right" : wire.fromSide ?? facing.exitSide,
|
|
397
|
+
entrySide: wire.toSide ?? facing.entrySide,
|
|
331
398
|
busKey: null,
|
|
332
|
-
exitKey:
|
|
399
|
+
exitKey: "",
|
|
333
400
|
outputPort: output?.port ?? null,
|
|
334
401
|
start: output?.port ?? centerOf(from),
|
|
335
402
|
end: centerOf(to)
|
|
336
403
|
};
|
|
337
|
-
|
|
404
|
+
facingByPlan.set(plan, facing);
|
|
338
405
|
return [plan];
|
|
339
406
|
});
|
|
340
|
-
|
|
407
|
+
chooseSidesBySearch(plans, facingByPlan, input);
|
|
408
|
+
joinFacingBuses(plans, facingByPlan);
|
|
409
|
+
for (const plan of plans) {
|
|
410
|
+
const outputId = plan.wire.fromOutput;
|
|
411
|
+
plan.exitKey = plan.outputPort && outputId ? `${plan.from.id}|output ${outputId}|${plan.styleKey}` : `${plan.from.id}|${plan.exitSide}|${plan.styleKey}`;
|
|
412
|
+
}
|
|
341
413
|
const busKeyOf = (plan) => `${plan.to.id}|${plan.entrySide}|${plan.styleKey}`;
|
|
342
414
|
const memberCountByBusKey = /* @__PURE__ */ new Map();
|
|
343
415
|
for (const plan of plans) memberCountByBusKey.set(busKeyOf(plan), (memberCountByBusKey.get(busKeyOf(plan)) ?? 0) + 1);
|
|
@@ -2,7 +2,7 @@ import { r as errorMessage } from "./text-DoirglWV.js";
|
|
|
2
2
|
import { A as SIGN_URL_ENV, I as SshSignReply } from "./session-DUFWokKF.js";
|
|
3
3
|
import { c as spawn, r as execFileAsync } from "./child-process-safe-BCOoKfxG.js";
|
|
4
4
|
import { a as isLoopbackHostname } from "./hook-relay-core-DA_bz2KA.js";
|
|
5
|
-
import { n as postToAgentIngress } from "./agent-api-cli-
|
|
5
|
+
import { n as postToAgentIngress } from "./agent-api-cli-D9r9SgcA.js";
|
|
6
6
|
import { l as parseSshPublicKey } from "./ssh-signing-core-CRhVVWNW.js";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import fs from "node:fs/promises";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./updates-view-core-DWODr1GQ.js";import{n as e,r as t,s as n}from"./dom-helpers-qjWTsLGI.js";import{Ei as r,Ti as i,wi as a}from"./index-
|
|
1
|
+
import"./updates-view-core-DWODr1GQ.js";import{n as e,r as t,s as n}from"./dom-helpers-qjWTsLGI.js";import{Ei as r,Ti as i,wi as a}from"./index-DA0egBFL.js";var o={mine:`Mine`,run:`Run`,cancel:`Cancel`},s=null;function c(e){return e===null?`n/a`:`${Math.round(e*100)}%`}function l(e){if(e===null)return`n/a`;let t=Math.round(e*100);return t>0?`+${t}`:String(t)}function u(e,t,r){let a=n(`button`,`bench-action-button`,o[t]);return a.type=`button`,a.disabled=r,a.addEventListener(`click`,()=>i(e.id,t)),a}function d(e,t){let n=e.inFlight;if(!n||n.suiteId!==t.id)return``;let r=n.caseId?`case ${n.caseId}, `:``;return`Cell ${n.cellIndex+1} of ${n.cellCount}: ${r}arm ${n.armId}, trial ${n.trial}, ${n.phase}.`}function f(e){let t=n(`td`,`bench-score`,c(e?.recall??null));return e&&e.invalid>0&&(t.title=`${e.invalid} invalid or failed cell(s)`),e&&e.degraded>0&&(t.dataset.degraded=`true`),t}function p(e){let t=e.armIds.filter(t=>t!==e.baselineArm),r=n(`table`,`bench-table`),i=n(`tr`);i.append(n(`th`,null,`Case`),...e.armIds.map(t=>n(`th`,null,t===e.baselineArm?`${t} (baseline)`:t))),i.append(...t.map(e=>n(`th`,null,`${e} vs baseline`))),r.append(i);for(let i of e.rows){let a=n(`tr`);a.append(n(`td`,`bench-case`,i.caseId),...e.armIds.map(e=>f(i.arms[e]))),a.append(...t.map(e=>n(`td`,`bench-delta`,l(i.deltaVsBaseline[e]??null)))),r.append(a)}let a=[...new Set(e.armIds.flatMap(t=>Object.keys(e.totals[t]?.recallByTag??{})))].sort(),o=n(`tr`,`bench-total`);o.append(n(`td`,`bench-case`,`Paired recall`),...e.armIds.map(t=>f(e.totals[t]))),r.append(o);for(let t of a){let i=n(`tr`,`bench-total`);i.append(n(`td`,`bench-case`,`Recall, ${t}`),...e.armIds.map(r=>n(`td`,`bench-score`,c(e.totals[r]?.recallByTag[t]??null)))),r.append(i)}return r}function m(e,r){let{isServerConnected:i,pendingActionBySuite:o,outcomeBySuite:s}=a(),c=n(`div`,`bench-suite`),l=e.inFlight?.suiteId===r.id,f=!!e.inFlight&&!l,m=o.has(r.id)||!i,h=n(`div`,`bench-summary`);h.append(n(`span`,`bench-suite-title`,r.title),t(`bench`,r.caseCount===1?`case`:`cases`,String(r.caseCount)),t(`bench`,r.candidateCount===1?`candidate`:`candidates`,String(r.candidateCount)),t(`bench`,`arms`,String(r.armIds.length))),c.append(h);let g=n(`div`,`bench-controls`),_=e.configured===!0&&r.error===null;g.append(u(r,`mine`,!_||m||l),u(r,`run`,!_||m||l||f||r.caseCount===0),u(r,`cancel`,m||!l));let v=n(`span`,`bench-status`,(i?``:`Not connected to the server. Reconnecting.`)||d(e,r)||s.get(r.id)||``);if(v.setAttribute(`role`,`status`),g.append(v),c.append(g),r.error)return c.append(n(`p`,`bench-error`,r.error)),c;let y=r.latestReport;return y?(c.append(n(`p`,`bench-run-line`,`Latest run ${y.runId}: ${y.status}. Only cases every arm scored count toward paired recall.`)),y.rows.length>0&&c.append(p(y)),c):(c.append(n(`p`,`bench-empty`,r.caseCount===0?`Move approved candidates into the cases folder, then choose Run.`:`No run yet.`)),c)}function h(){if(!s)return;s.textContent=``;let{status:t}=a(),r=e(`bench`,`Benchmarks`,`Suites from the benchmarks folder of the Glimmervoid home, one run at a time.`);if(s.append(r),!t)s.append(n(`p`,`bench-empty`,`Waiting for the server.`));else if(!t.configured)s.append(n(`p`,`bench-empty`,t.reason||`Benchmarks are off.`));else if(t.suites.length===0)s.append(n(`p`,`bench-empty`,`No suites yet. Create a folder holding suite.json under benchmarks in the Glimmervoid home.`));else for(let e of t.suites)s.append(m(t,e))}function g(e){s||(s=n(`div`,`bench-content`),e.append(s),r(h),h())}var _={mount:g};export{_ as view};
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Dt as e,Tt as t,bt as n,yt as r}from"./updates-view-core-DWODr1GQ.js";import{f as i,s as a}from"./dom-helpers-qjWTsLGI.js";import{a as o,i as s,n as c}from"./modal-Dta3lhg0.js";import{S as l}from"./svg-dom-CQQ12iW3.js";import{i as u}from"./action-status-D7HyJ8Q5.js";import{a as d,r as f}from"./card-registry-BaNcteKc.js";import{n as p,r as m,t as h}from"./menu-DJySApM6.js";import{$ as ee,Q as te,at as g,ct as _,dt as v,et as y,ft as b,gt as x,ht as S,it as ne,lt as re,mt as ie,nt as ae,ot as oe,pt as se,ri as ce,rt as le,st as ue,tt as C,ut as de}from"./index-DOa6kn1l.js";Object.freeze({unitWarnings:[],uncoveredPaths:[],worthALookPaths:[],flaggedUnitIds:[],notChecked:null});var fe=/^([^#\s]+)(?:#L([1-9]\d*)(?:-L([1-9]\d*))?)?$/;function pe(e){return e.startsWith(`/`)||e.startsWith(`\\`)||/^[A-Za-z]:/.test(e)}function me(e){return e.split(`/`).filter(e=>e!==``&&e!==`.`).join(`/`)}function he(e){let t=fe.exec(e);if(!t?.[1])return{error:`a ref is path, path#L12 or path#L12-L30`};let n=t[1];if(pe(n))return{error:`an absolute path is never read; name the file relative to the code session worktree`};if(n.split(/[\\/]/).includes(`..`))return{error:`a path with .. is never read; name the file relative to the code session worktree`};let r=t[2]?Number(t[2]):null,i=t[3]?Number(t[3]):r;return r!==null&&i!==null&&i<r?{error:`the line range ends before it starts`}:{path:me(n),startLine:r,endLine:i}}function w(e,t,n){return n.flatMap((n,r)=>n.ref?[{elementId:t,ref:n.ref,where:`line ${r+1} of ${e}`}]:[])}function ge(e){let t=`${e.kind} ${e.id}`;switch(e.kind){case`box`:case`unit`:return[...e.refs.map(n=>({elementId:e.id,ref:n,where:t})),...w(t,e.id,e.lines)];case`panel`:return w(t,e.id,e.lines);case`note`:return e.ref?[{elementId:e.id,ref:e.ref,where:t}]:[];case`frame`:case`wire`:return[]}}function _e(e){return[...new Set(ge(e).map(e=>e.ref))]}function ve(e){let t=he(e);return`path`in t?t.path:null}var ye=4,be=200,xe=2e4,Se=1.1,Ce=[`wire`,`note`,`frame`,`box`,`panel`,`unit`],we={v:`select`,r:`box`,d:`decision`,p:`panel`,a:`wire`};function T(e){let t=Math.random().toString(36).slice(2,8);return`${e}-${Date.now().toString(36)}${t}`}function E(){return document.documentElement.dataset.layout===`phone`}function Te(e){return e instanceof SVGCircleElement&&e.classList.contains(`wb-port`)?e:null}function Ee(e){return e===`box`||e===`decision`||e===`panel`}function De(e,t,n){if(e===`panel`){let e=Math.max(-1,...Object.values(t.elements).map(e=>e.kind===`panel`?e.order:-1));return{kind:`panel`,id:T(`panel`),title:`Panel`,lines:[],order:e+1}}let r=e===`decision`;return{kind:`box`,id:T(`box`),title:r?`Decision`:`Box`,lines:[],lane:null,refs:[],change:`none`,was:null,column:null,near:null,order:0,at:n,shape:r?`decision`:`box`,outputs:r?[{id:`yes`,label:`yes`},{id:`no`,label:`no`}]:[]}}function Oe(e){return e instanceof Element?e.closest(`[data-linked-board-id]`)?.dataset.linkedBoardId??null:null}function ke(e){let{svg:t,canvas:n,renderer:r}=e,i=new Map,o=new Set,s={x:0,y:0,width:1e3,height:600},c=null,l=null,u=null,d=`select`,f=null;function p(n){d=n,t.dataset.tool=n,e.onToolChange(n)}function m(){t.setAttribute(`viewBox`,`${s.x} ${s.y} ${s.width} ${s.height}`)}function h(e){let t=n.querySelector(e);return t?.checkVisibility()?t.getBoundingClientRect():null}function ee(){let e=t.getBoundingClientRect(),n=h(`.wb-island-board`),r=[`.wb-island-tools`,`.wb-bottom-left`].flatMap(e=>{let t=h(e);return t?[t.top]:[]}),i=n?Math.max(0,n.bottom-e.top):0,a=Math.min(e.height,...r.map(t=>t-e.top))-i;return a<e.height/2?{topPx:0,heightPx:e.height}:{topPx:i,heightPx:a}}function te(){let e=r.layout();if(!e)return;let{bounds:n}=e,i=t.clientWidth,a=t.clientHeight;if(i===0||a===0){s={...n},m();return}let o=ee(),c=Math.max(1,n.width/i,n.height/o.heightPx),l=i*c,u=n.y+n.height/2,d=o.topPx+o.heightPx/2;s={x:n.x-(l-n.width)/2,y:u-d*c,width:l,height:a*c},m()}function g(e,n){let r=t.getScreenCTM();if(!r)return{x:e,y:n};let i=new DOMPoint(e,n).matrixTransform(r.inverse());return{x:i.x,y:i.y}}function _(){let e=t.clientWidth||1,n=t.clientHeight||1;return Math.max(s.width/e,s.height/n)}function v(e,t){let n=Math.min(xe,Math.max(be,s.width*t)),r=n/s.width;s={x:e.x-(e.x-s.x)*r,y:e.y-(e.y-s.y)*r,width:n,height:s.height*r},m()}function y(e,t){let n=_();s={...s,x:s.x-e*n,y:s.y-t*n},m()}function b(t){o=t,r.setSelection(o),e.onSelectionChange(o)}function x(e,t){if(!t){b(o.has(e)&&o.size===1?new Set:new Set([e]));return}let n=new Set(o);n.delete(e)||n.add(e),b(n)}function S(e){return{x:Math.round(e.start.x+e.latest.x-e.origin.x),y:Math.round(e.start.y+e.latest.y-e.origin.y-e.pinnedOffsetY)}}function ne(e,t,n){let r=e.elements[t];return r?.kind===`box`?{...e,elements:{...e.elements,[t]:{...r,at:n}}}:e}function re(e){return c?.kind!==`drag`||!c.hasMoved?e:ne(e,c.boxId,S(c))}function ie(){u!==null&&cancelAnimationFrame(u),u=null}function ae(){ie();let t=e.currentBoard();t&&r.render(re(t))}function oe(){u===null&&(u=requestAnimationFrame(ae))}function se(e){c?.kind===`drag`&&e?.elements[c.boxId]?.kind!==`box`&&(c=null);let t=new Set([...o].filter(t=>e?.elements[t]));t.size!==o.size&&b(t)}function ce(e){let t=r.layout()?.elements.find(t=>t.id===e);return t?.kind===`box`?t:null}function le(){let[e,t]=[...i.values()];return!e||!t?0:Math.hypot(e.x-t.x,e.y-t.y)}function ue(){c?.kind===`wire`&&w(c,!1),c={kind:`pinch`,distance:le(),viewWidth:s.width}}function C(n){if(n.button!==0||l)return;let a=Oe(n.target);if(a){e.onOpenLinkedBoard(a);return}if(i.set(n.pointerId,{x:n.clientX,y:n.clientY}),t.setPointerCapture(n.pointerId),i.size===2){ue();return}let o=r.elementFromTarget(n.target);if(Ee(d)){de(d,g(n.clientX,n.clientY));return}let s=Te(n.target);if(o?.kind===`box`&&s&&!E()){pe(n.pointerId,o.id,{x:s.cx.baseVal.value,y:s.cy.baseVal.value});return}let u=d===`wire`&&o?.kind===`box`?ce(o.id):null;if(o&&u){pe(n.pointerId,o.id,{x:u.x+u.width/2,y:u.y+u.height/2});return}let f=o?.kind===`box`&&!E()?ce(o.id):null;if(o&&f){let e=g(n.clientX,n.clientY),t=r.layout()?.pinnedOffsetY??0;c={kind:`drag`,pointerId:n.pointerId,boxId:o.id,origin:e,start:f,pinnedOffsetY:t,latest:e,hasMoved:!1,isAdditive:n.shiftKey};return}if(o&&!E()){x(o.id,n.shiftKey);return}let p=o?.kind===`box`?o.id:null;c={kind:`pan`,pointerId:n.pointerId,lastClient:{x:n.clientX,y:n.clientY},hasMoved:!1,tappedBoxId:p}}async function de(t,n){p(`select`);let i=e.currentBoard();if(!i)return;let a=r.layout()?.pinnedOffsetY??0,o=De(t,i,{x:Math.round(n.x),y:Math.round(n.y-a)});f=o.id;let s=await e.sendOps([{op:`add`,element:o}]);s||(f=null),s&&b(new Set([o.id])),fe()}function fe(){if(!f||!r.nodeOf(f))return;let e=f;f=null,O(e)}function pe(e,n,r){let i=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);i.setAttribute(`class`,`wb-wire-line wb-dashed wb-wire-draft`),i.setAttribute(`d`,`M ${r.x} ${r.y} L ${r.x} ${r.y}`),t.append(i),c={kind:`wire`,pointerId:e,fromBoxId:n,start:r,draftLine:i,targetBoxId:null}}function me(e,t){e.targetBoxId&&r.nodeOf(e.targetBoxId)?.classList.remove(`is-wire-target`),e.targetBoxId=t,t&&r.nodeOf(t)?.classList.add(`is-wire-target`)}function he(e,t){let n=g(t.clientX,t.clientY);e.draftLine.setAttribute(`d`,`M ${e.start.x} ${e.start.y} L ${n.x} ${n.y}`);let i=r.elementFromTarget(document.elementFromPoint(t.clientX,t.clientY));me(e,i?.kind===`box`&&i.id!==e.fromBoxId?i.id:null)}function w(t,n){let r=t.targetBoxId;me(t,null),t.draftLine.remove(),n&&r&&e.onConnectBoxes(t.fromBoxId,r)}function ge(e,t){let n=g(t.clientX,t.clientY);!e.hasMoved&&Math.hypot(n.x-e.origin.x,n.y-e.origin.y)<ye*_()||(e.hasMoved=!0,e.latest=n,oe())}function _e(e,t){let n=t.clientX-e.lastClient.x,r=t.clientY-e.lastClient.y;!e.hasMoved&&Math.hypot(n,r)<ye||(e.hasMoved=!0,e.lastClient={x:t.clientX,y:t.clientY},y(n,r))}function ve(e){let t=le();if(t<=0||e.distance<=0)return;let n=[...i.values()];v(g(n.reduce((e,t)=>e+t.x,0)/n.length,n.reduce((e,t)=>e+t.y,0)/n.length),e.viewWidth*(e.distance/t)/s.width)}function T(e){i.has(e.pointerId)&&(i.set(e.pointerId,{x:e.clientX,y:e.clientY}),c?.kind===`pinch`?ve(c):c?.kind===`drag`&&c.pointerId===e.pointerId?ge(c,e):c?.kind===`wire`&&c.pointerId===e.pointerId?he(c,e):c?.kind===`pan`&&c.pointerId===e.pointerId&&_e(c,e))}async function ke(t,n){if(!t.hasMoved){x(t.boxId,t.isAdditive);return}ie(),t.latest=g(n.clientX,n.clientY);let i=S(t),a=e.currentBoard();a&&r.render(ne(a,t.boxId,i)),await e.sendOps([{op:`set`,id:t.boxId,fields:{at:i}}])||ae()}function Ae(t){if(!i.delete(t.pointerId))return;let n=c;n?.kind===`pinch`?c=null:(c=null,n?.kind===`drag`&&n.pointerId===t.pointerId?ke(n,t):n?.kind===`wire`?(w(n,n.pointerId===t.pointerId),d===`wire`&&p(`select`)):n?.kind!==`pan`||n.hasMoved||(n.tappedBoxId&&E()?e.onPhoneTapBox(n.tappedBoxId):n.tappedBoxId||b(new Set)))}function je(e){i.delete(e.pointerId);let t=c?.kind===`drag`;c?.kind===`wire`&&w(c,!1),c=null,t&&ae()}function Me(e){e.preventDefault(),e.ctrlKey||e.metaKey?v(g(e.clientX,e.clientY),e.deltaY>0?Se:1/Se):y(-e.deltaX,-e.deltaY)}function D(){let e=l;l=null,e?.remove()}function O(i){let o=e.currentBoard()?.elements[i],s=r.nodeOf(i);if(o?.kind!==`box`&&o?.kind!==`panel`||!s)return;D();let c=n.getBoundingClientRect(),u=s.getBoundingClientRect(),d=a(`input`,`wb-title-input`);d.type=`text`,d.value=o.title,d.maxLength=80,d.setAttribute(`aria-label`,o.kind===`panel`?`Panel title`:`Box title`),d.style.left=`${u.left-c.left}px`,d.style.top=`${u.top-c.top}px`,d.style.width=`${Math.max(160,u.width)}px`,l=d,n.append(d),d.addEventListener(`keydown`,n=>{if(n.key===`Escape`){n.preventDefault(),D(),t.focus();return}if(n.key!==`Enter`)return;n.preventDefault();let r=d.value.trim();D(),t.focus(),r&&r!==o.title&&e.sendOps([{op:`set`,id:i,fields:{title:r}}])}),d.addEventListener(`blur`,D),d.focus(),d.select()}function Ne(e){if(E())return;let t=r.elementFromTarget(document.elementFromPoint(e.clientX,e.clientY));(t?.kind===`box`||t?.kind===`panel`)&&O(t.id)}function Pe(){let t=e.currentBoard();if(!t||o.size===0)return;let n=[...o].flatMap(e=>t.elements[e]??[]),r=Ce.flatMap(e=>n.filter(t=>t.kind===e)).map(e=>({op:`remove`,id:e.id}));b(new Set),e.sendOps(r)}function Fe(e){if(e.target!==t||e.metaKey||e.ctrlKey||e.altKey)return;if(e.key===`Delete`||e.key===`Backspace`){e.preventDefault(),Pe();return}let n=we[e.key.toLowerCase()];n&&!e.shiftKey?(e.preventDefault(),p(n)):e.key===`Escape`&&(b(new Set),p(`select`))}return t.tabIndex=0,t.addEventListener(`pointerdown`,C),t.addEventListener(`pointermove`,T),t.addEventListener(`pointerup`,Ae),t.addEventListener(`pointercancel`,je),t.addEventListener(`wheel`,Me,{passive:!1}),t.addEventListener(`dblclick`,Ne),t.addEventListener(`keydown`,Fe),{fit:te,selectedIds:()=>o,clearSelection:()=>b(new Set),pruneSelection:se,previewOf:re,closeTitleInput:D,setTool:p,openPendingTitleEdit:fe,focusCanvas:()=>t.focus()}}var Ae=Object.freeze({undo:[],redo:[]}),je=new Set([`box`,`unit`,`panel`]),Me=[`wire`,`note`,`frame`,`box`,`panel`,`unit`],D=new Set([`kind`,`id`]);function O(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Ne(e){return e.kind===`box`?e.near?[e.near.of]:[]:e.kind===`unit`?e.after:[]}function Pe(e){let t=new Set(e.map(e=>e.id)),n=[];for(;t.size>0;){let r=e.filter(e=>t.has(e.id)&&Ne(e).every(e=>!t.has(e))),i=r.length>0?r:e.filter(e=>t.has(e.id));for(let e of i)t.delete(e.id);n.push(...i)}return n}function Fe(e,t){let n={...e},r=Object.fromEntries(Object.entries(t).filter(([e,t])=>!D.has(e)&&!O(n[e],t)));return t.kind!==`note`||Object.keys(r).length===0?r:{...r,author:t.author,resolvedBy:t.resolvedBy}}function Ie(e,t){let n={...e.title===t.title?{}:{title:t.title},...e.caption===t.caption?{}:{caption:t.caption},...O(e.legend,t.legend)?{}:{legend:t.legend},...e.codeSessionId===t.codeSessionId?{}:{codeSessionId:t.codeSessionId}};return Object.keys(n).length===0?[]:[{op:`board`,...n}]}function Le(e,t){if(O(e.columns,t.columns))return{widen:[],narrow:[]};let n=new Set(t.columns.map(e=>e.id));return{widen:[{op:`columns`,columns:[...t.columns,...e.columns.filter(e=>!n.has(e.id))],move:{}}],narrow:[{op:`columns`,columns:t.columns,move:{}}]}}function Re(e,t){let n=Object.values(e.elements),r=Object.values(t.elements),i=Me.flatMap(e=>n.filter(n=>n.kind===e&&!t.elements[n.id])),a=Pe(r.filter(t=>!e.elements[t.id])),o=r.flatMap(t=>{let n=e.elements[t.id];if(!n)return[];let r=Fe(n,t);return Object.keys(r).length===0?[]:[{op:`set`,id:t.id,fields:r}]}),{widen:s,narrow:c}=Le(e,t);return[...O(e.lanes,t.lanes)?[]:[{op:`lanes`,lanes:t.lanes}],...s,...i.map(e=>({op:`remove`,id:e.id})),...a.filter(e=>je.has(e.kind)).map(e=>({op:`add`,element:e})),...o,...a.filter(e=>!je.has(e.kind)).map(e=>({op:`add`,element:e})),...c,...Ie(e,t)]}function ze(e,t){let n=ie(e,t,se,e.updatedAt);return n.ok?Re(n.board,e):[]}function Be(e,t){return t.length===0?[...e]:[...e,t].slice(-100)}function Ve(e,t){return t.length===0?e:{undo:Be(e.undo,t),redo:[]}}function He(e,t){let n=e[t].at(-1);return n?{entry:n,history:{...e,[t]:e[t].slice(0,-1)}}:null}function Ue(e,t,n){let r=t===`undo`?`redo`:`undo`;return{...e,[r]:Be(e[r],n)}}var We=8,Ge=12,Ke=30,qe=40,Je=40,Ye=400,Xe=200,Ze=8,Qe=`README.md`,$e=``,et=[`text`,`code`,`item`,`numbered`,`kv`],tt=[`plain`,`fail`,`join`,`lane`],nt=k(et),rt=k(tt),it=k([`box`,`decision`]),at=k(n),ot=k(t),st=[{value:``,text:`auto`},...k([`left`,`right`,`top`,`bottom`])],ct=[{id:`yes`,label:`yes`},{id:`no`,label:`no`}];function k(e){return e.map(e=>({value:e,text:e}))}function A(e){return a(`h3`,`wb-inspect-heading`,e)}function j(e,t){let n=a(`label`,`wb-inspect-field`);return n.append(a(`span`,`wb-inspect-label`,e),t),n}function M(e,t,n,r,i){let o=a(`input`,`wb-inspect-input`);return o.type=`text`,o.value=t,o.maxLength=n,o.dataset.field=e,i&&o.setAttribute(`aria-label`,i),o.addEventListener(`change`,()=>r(o.value)),o}function N(e,t,n,r,i){let o=a(`select`,`wb-inspect-select`);return o.dataset.field=e,i&&o.setAttribute(`aria-label`,i),o.append(...t.map(e=>{let t=a(`option`,null,e.text);return t.value=e.value,t.selected=e.value===n,t})),o.addEventListener(`change`,()=>r(o.value)),o}function P(e,t,n,r){let i=a(`input`,`wb-inspect-check`);i.type=`checkbox`,i.checked=n,i.dataset.field=e,i.addEventListener(`change`,()=>r(i.checked));let o=a(`label`,`wb-inspect-toggle`);return o.append(i,a(`span`,null,t)),o}function F(e,t,n,r){let i=a(`button`,`wb-button wb-inspect-action`,t);return i.type=`button`,i.dataset.field=e,r&&i.setAttribute(`aria-label`,r),i.addEventListener(`click`,n),i}function lt(e,t,n){let r=a(`div`,`wb-inspect-list`);return r.append(a(`span`,`wb-inspect-label`,e),...t,n),r}function ut(e,t){return{edit(n,r){let i=e(),a=i?.[n];i&&a!==void 0&&t(i.map((e,t)=>t===n?r(a):e))},remove(n){let r=e();r&&t(r.filter((e,t)=>t!==n))},append(n){let r=e();r&&t([...r,n(r)])}}}function dt(e){let t=e.trim();return r.safeParse(t).success?t:null}function ft(e,t,n,r){let i=M(e,t??``,Xe,e=>{if(!e.trim()){n(null);return}let t=dt(e);t&&n(t)},r);return i.placeholder=`ref: path#L12`,i}function pt(e,t,n,r){let i=ut(n,r),o=t.map((e,t)=>{let n=a(`div`,`wb-inspect-row`);return n.append(M(`ref-${t}`,e,Xe,e=>{let n=dt(e);n&&i.edit(t,()=>n)},`Ref ${t+1}`),F(`ref-${t}-remove`,`remove`,()=>i.remove(t),`Remove ref ${e}`)),n}),s=F(`ref-add`,`add ref`,()=>i.append(()=>Qe),`Add a ref to ${e}`);return s.disabled=t.length>=Ze,lt(`Refs`,o,s)}function mt(e,t){return t===`kv`?{...e,style:t,key:e.key||`key`}:{...e,style:t}}function ht(t,n,r,i){let o=ut(r,i),s=n.map((t,n)=>{let r=a(`div`,`wb-inspect-row`),i=n+1;return r.append(N(`line-${n}-style`,nt,t.style,e=>{let t=et.find(t=>t===e);t&&o.edit(n,e=>mt(e,t))},`Line ${i} style`)),t.style===`kv`&&r.append(M(`line-${n}-key`,t.key??``,Je,e=>{e.trim()&&o.edit(n,t=>({...t,key:e.trim()}))},`Line ${i} key`)),r.append(M(`line-${n}-text`,t.text,e.line,e=>o.edit(n,t=>({...t,text:e})),`Line ${i} text`),ft(`line-${n}-ref`,t.ref,e=>o.edit(n,t=>({...t,ref:e})),`Line ${i} ref`),F(`line-${n}-remove`,`remove`,()=>o.remove(n),`Remove line ${i}`)),r}),c=F(`line-add`,`add line`,()=>o.append(()=>({text:`new line`,muted:!1,style:`text`,key:null,ref:null})),`Add a line to ${t}`);return c.disabled=n.length>=e.linesPerBox,lt(`Lines`,s,c)}function gt(e){let t=new Set(e.map(e=>e.id)),n=e.length+1;for(;t.has(`exit-${n}`);)n+=1;return`exit-${n}`}function _t(e,t,n){let r=ut(t,e=>n({outputs:e})),i=e.outputs.map((e,t)=>{let n=a(`div`,`wb-inspect-row`);return n.append(M(`output-${e.id}-label`,e.label,Ke,e=>{e.trim()&&r.edit(t,t=>({...t,label:e.trim()}))},`Output ${e.id} label`),F(`output-${e.id}-remove`,`remove`,()=>r.remove(t),`Remove output ${e.label}`)),n}),o=F(`output-add`,`add output`,()=>r.append(e=>({id:gt(e),label:`exit`})));return o.disabled=e.outputs.length>=We,lt(`Outputs`,i,o)}function vt(e){return e.at===null&&e.near===null?e.column??$e:$e}function yt(t,n,r,i,a){let o=()=>{let e=r();return e?.kind===`box`?e:null},s=[{value:$e,text:`free`},...t.columns.map(e=>({value:e.id,text:e.title||e.id}))],c=[{value:``,text:`none`},...t.lanes.map(e=>({value:e.id,text:e.label||e.id}))];return[A(n.shape===`decision`?`Decision`:`Box`),j(`Title`,M(`title`,n.title,e.title,e=>{e.trim()&&a({title:e.trim()})})),j(`Shape`,N(`shape`,it,n.shape,e=>{let t=o()?.outputs??[];e===`decision`&&a({shape:e,outputs:t.length>0?t:ct}),e===`box`&&a({shape:e,outputs:[]})})),j(`Column`,N(`column`,s,vt(n),e=>{if(e!==$e){a({column:e,at:null,near:null});return}let t=i?.elements.find(e=>e.id===n.id);i&&t?.kind===`box`&&a({at:{x:t.x,y:t.y-i.pinnedOffsetY},near:null})})),j(`Lane`,N(`lane`,c,n.lane??``,e=>a({lane:e||null}))),j(`Change`,N(`change`,at,n.change,e=>{a(e===`relabeled`?{change:e,was:o()?.was??n.title}:{change:e,was:null})})),...n.change===`relabeled`?[j(`Was`,M(`was`,n.was??``,e.title,e=>{e.trim()&&a({was:e.trim()})}))]:[],...n.shape===`decision`?[_t(n,()=>o()?.outputs??null,a)]:[],pt(`this box`,n.refs,()=>o()?.refs??null,e=>a({refs:e})),ht(`this box`,n.lines,()=>o()?.lines??null,e=>a({lines:e}))]}function bt(e,t,n){let r=e.elements[t.from],i=r?.kind===`box`&&r.shape===`decision`?[{value:``,text:`none`},...r.outputs.map(e=>({value:e.id,text:e.label}))]:[];return[A(`Wire`),j(`Label`,M(`label`,t.label??``,qe,e=>n({label:e.trim()||null}))),j(`Tone`,N(`tone`,rt,t.tone,e=>n({tone:e}))),P(`dashed`,`dashed`,t.dashed,e=>n({dashed:e})),P(`back`,`returns to an earlier step`,t.back,e=>n({back:e})),j(`Leaves from`,N(`fromSide`,st,t.fromSide??``,e=>n({fromSide:e||null}))),j(`Arrives at`,N(`toSide`,st,t.toSide??``,e=>n({toSide:e||null}))),...i.length>0?[j(`From output`,N(`fromOutput`,i,t.fromOutput??``,e=>n({fromOutput:e||null})))]:[]]}function xt(t,n){return[A(`Frame`),j(`Title`,M(`title`,t.title,e.title,e=>n({title:e.trim()}))),P(`loop`,`repeats as a loop`,t.loop,e=>n({loop:e}))]}function St(t,n,r){return[A(`Panel`),j(`Title`,M(`title`,t.title,e.title,e=>{e.trim()&&r({title:e.trim()})})),ht(`this panel`,t.lines,()=>{let e=n();return e?.kind===`panel`?e.lines:null},e=>r({lines:e}))]}function Ct(e,t,n){let r=ut(t,n),i=e.map((e,t)=>{let n=a(`div`,`wb-inspect-row wb-inspect-legend-row`),i=t+1;return n.append(N(`legend-${t}-tone`,rt,e.tone,e=>{let n=tt.find(t=>t===e);n&&r.edit(t,e=>({...e,tone:n}))},`Legend entry ${i} tone`),M(`legend-${t}-label`,e.label,qe,e=>{e.trim()&&r.edit(t,t=>({...t,label:e.trim()}))},`Legend entry ${i} label`),P(`legend-${t}-dashed`,`dashed`,e.dashed,e=>r.edit(t,t=>({...t,dashed:e}))),P(`legend-${t}-back`,`returns`,e.back,e=>r.edit(t,t=>({...t,back:e}))),F(`legend-${t}-remove`,`remove`,()=>r.remove(t),`Remove legend entry ${e.label}`)),n}),o=F(`legend-add`,`add entry`,()=>r.append(()=>({tone:`plain`,dashed:!1,back:!1,label:`meaning`})));return o.disabled=e.length>=Ge,lt(`Legend`,i,o)}function wt(e,t){return[A(`Note`),j(`Ref`,ft(`ref`,e.ref,e=>t({ref:e}),`Ref`)),a(`p`,`wb-inspect-hint`,`Edit a note from its box.`)]}function Tt(e,n,r){return[A(`Unit`),j(`Status`,N(`unit-status`,ot,e.status,e=>{let n=t.find(t=>t===e);n&&r({status:n})})),pt(`this unit`,e.refs,()=>{let e=n();return e?.kind===`unit`?e.refs:null},e=>r({refs:e})),a(`p`,`wb-inspect-hint`,`Agents edit units with glimmervoid whiteboard plan.`)]}function Et(t,n,r,i,a){let o=[{value:``,text:`none`},...i];return[A(`Board`),F(`board-settings-close`,`close`,a,`Close board settings`),j(`Title`,M(`board-title`,t.title,e.title,e=>{e.trim()&&r([{op:`board`,title:e.trim()}])})),j(`Caption`,M(`board-caption`,t.caption??``,Ye,e=>r([{op:`board`,caption:e.trim()||null}]))),j(`Code session`,N(`board-code-session`,o,t.codeSessionId??``,e=>r([{op:`board`,codeSessionId:e||null}]))),Ct(t.legend,()=>n()?.legend??null,e=>r([{op:`board`,legend:e}]))]}function Dt(e,t,n,r,i){let a=e=>i([{op:`set`,id:t.id,fields:e}]),o=()=>n()?.elements[t.id];switch(t.kind){case`box`:return yt(e,t,o,r,a);case`wire`:return bt(e,t,a);case`frame`:return xt(t,a);case`panel`:return St(t,o,a);case`note`:return wt(t,a);case`unit`:return Tt(t,o,a)}}function Ot(e,t,n){let r=_e(t);if(r.length===0)return[];let i=e.codeSessionId!==null,o=r.map((e,t)=>{let r=a(`div`,`wb-inspect-row wb-inspect-review-row`),o=F(`review-${t}`,`open in review`,()=>n(e),`Open ${e} in review`);return o.disabled=!i,r.append(a(`code`,`wb-inspect-ref`,e),o),r}),s=i?[]:[a(`p`,`wb-inspect-hint`,`Set the board code session to open refs in review.`)];return[A(`In review`),...o,...s]}function kt(e,t,n){let r=a(`div`,`wb-inspect-review`);return r.append(...Ot(e,t,n)),r}function At(e){let t=document.activeElement;return e.contains(t)&&t instanceof HTMLInputElement&&t.type===`text`}function jt(e){let{container:t}=e;t.setAttribute(`aria-label`,`Properties`);let n=t=>void e.sendOps(t),r=new Set,i=!1,a=!1;function o(e,t){if(t.size!==1)return;let[n]=t;return n===void 0?void 0:e.elements[n]}function s(n,r){let i=o(n,r),a=t.querySelector(`.wb-inspect-review`);i&&a&&a.replaceChildren(...Ot(n,i,e.openRef))}function c(t,r){if(r.size>1)return[A(`${r.size} selected`)];let i=o(t,r);return i?[...Dt(t,i,e.currentBoard,e.layout(),n),kt(t,i,e.openRef)]:Et(t,e.currentBoard,n,e.codeSessionChoices(),d)}function l(n){r=n,n.size>0&&(a=!1);let o=e.currentBoard();if(t.hidden=!o||n.size===0&&!a,!o||t.hidden)return;if(At(t)){s(o,n);return}let l=document.activeElement,u=l instanceof HTMLElement&&t.contains(l)?l.dataset.field:void 0;i=!0,t.replaceChildren(...c(o,n)),u&&t.querySelector(`[data-field="${CSS.escape(u)}"]`)?.focus(),i=!1}function u(){a=!0,l(r),t.querySelector(`[data-field="board-caption"]`)?.focus()}function d(){a&&(a=!1,l(r))}return t.addEventListener(`keydown`,e=>{e.key===`Escape`&&a&&(e.preventDefault(),d())}),t.addEventListener(`focusout`,e=>{i||t.hidden||e.relatedTarget instanceof Node&&t.contains(e.relatedTarget)||queueMicrotask(()=>l(r))}),{paint:l,openBoardSettings:u,closeBoardSettings:d}}var Mt=`http://www.w3.org/2000/svg`,I=12,Nt=26,L=20,Pt=18,Ft=17,It=14,Lt=16,Rt=24,zt=18,Bt=`Plan`,Vt=`open linked board`,Ht=5,Ut=17,R=6,Wt=20,Gt=12,Kt=4,qt=3,Jt=7.2,Yt=13,Xt=17,Zt=2.2,Qt=28;function $t(e){return Object.entries(e).flatMap(([e,t])=>t===null?[]:[` ${e}="${m(t)}"`]).join(``)}function z(e,t,n=``){return`<${e}${$t(t)}>${n}</${e}>`}function B(e,t,n,r,i={}){return z(`text`,{x:t,y:n,class:r,...i},m(e))}function V(e,t,n){return z(`g`,{class:`wb-element ${t}`,"data-element-id":e.id,"data-element-kind":e.kind},n.join(``))}function en(e){return e?`stroke:${e}`:null}function tn(e){let t=e.x+e.width,n=e.y+e.headerHeight/2,r=`M${e.x+Gt},${e.y} H${t-Gt} L${t},${n}`;return e.outputs.length===0?`${r} L${t-Gt},${e.y+e.height} H${e.x+Gt} L${e.x},${n} Z`:`${r} V${e.y+e.height} H${e.x} V${n} Z`}function nn(e){return e.outputs.flatMap(t=>{let n=(e.height-e.headerHeight)/e.outputs.length/2,r=t.port.y-n;return[z(`line`,{x1:e.x,y1:r,x2:e.x+e.width,y2:r,class:`wb-output-divider`}),B(t.label,e.x+I,t.port.y+Kt,`wb-output-label`),z(`circle`,{cx:t.port.x,cy:t.port.y,r:qt,class:`wb-output-dot`})]})}function rn(e){return e.style===`code`?`wb-box-line wb-line-code`:e.muted?`wb-box-line wb-muted`:`wb-box-line`}function an(e,t,n,r){let i=t+I+(e.muted?It:0),a=[];return e.style===`code`&&a.push(z(`rect`,{x:i-4,y:r-Yt,width:t+n-I+4-i+4,height:Xt,rx:3,class:`wb-code-band`})),e.style===`item`&&e.isFirstRow&&a.push(z(`circle`,{cx:i+4,cy:r-4,r:Zt,class:`wb-item-dot`})),e.marker!==null&&a.push(B(e.marker,i,r,e.style===`kv`?`wb-line-key`:`wb-line-marker`)),e.text&&a.push(B(e.text,i+e.indentChars*Jt,r,rn(e))),a}function on(e,t,n,r){return e.flatMap((e,i)=>an(e,t,n,r+i*Pt))}function sn(e){let t=[z(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:6,class:`wb-panel-outline`})];e.titleLines.forEach((n,r)=>{t.push(B(n,e.x+I,e.y+Nt+r*L,`wb-box-title`))});let n=e.y+Nt+e.titleLines.length*L;return e.bodyLines.length>0&&t.push(z(`line`,{x1:e.x+I,y1:n-12,x2:e.x+e.width-I,y2:n-12,class:`wb-panel-rule`})),t.push(...on(e.bodyLines,e.x,e.width,n)),V(e,`wb-panel`,t)}function cn(e){return e.shape===`decision`?z(`path`,{d:tn(e),class:`wb-box-outline`,style:en(e.lane?.hex)}):z(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:8,class:`wb-box-outline`,style:en(e.lane?.hex)})}function ln(e){let t=[cn(e),...nn(e)],n=e.x+e.width/2,r=e.y+e.height/2;for(let[i,a]of[[n,e.y],[e.x+e.width,r],[n,e.y+e.height],[e.x,r]])t.push(z(`circle`,{cx:i,cy:a,r:Ht,class:`wb-port`}));e.wasLines.forEach((n,r)=>{t.push(B(n,e.x+I,e.y+Nt+r*L,`wb-box-was`))});let i=e.y+Nt+e.wasLines.length*L;e.titleLines.forEach((n,r)=>{t.push(B(n,e.x+I,i+r*L,`wb-box-title`))});let a=i+e.titleLines.length*L;if(t.push(...on(e.bodyLines,e.x,e.width,a)),e.lane&&e.showsLanePill){let n=e.y+e.headerHeight-28,r=Math.min(e.width-24,16+e.lane.label.length*8);t.push(z(`rect`,{x:e.x+I,y:n,width:r,height:18,rx:9,class:`wb-lane-pill`,style:en(e.lane.hex)}),B(e.lane.label,e.x+I+8,n+13,`wb-lane-pill-text`,{style:`fill:${e.lane.hex}`}))}return V(e,e.change===`none`?`wb-box`:`wb-box wb-change-${e.change}`,t)}function un(e){let t=e.x+e.width-Wt,n=e.y+R+6;return z(`path`,{d:`M ${t+R} ${n} A ${R} ${R} 0 1 1 ${t} ${n-R}`,"marker-end":`url(#wb-arrow)`,class:`wb-loop-badge`})}function dn(e){let t=[z(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:12,class:`wb-frame-outline`}),B(e.title,e.x+14,e.y+18,`wb-frame-title`)];return e.isLoop&&t.push(un(e)),V(e,e.isLoop?`wb-frame wb-loop`:`wb-frame`,t)}function fn(e){let t=[z(`path`,{d:e.path,class:`wb-wire-hit`}),z(`path`,{d:e.path,"marker-end":e.hasArrowhead?`url(#wb-arrow)`:null,class:e.isDashed?`wb-wire-line wb-dashed`:`wb-wire-line`,style:en(e.strokeHex??void 0)}),z(`circle`,{cx:e.start.x,cy:e.start.y,r:3,class:`wb-wire-dot`})];return e.joinAt&&t.push(z(`circle`,{cx:e.joinAt.x,cy:e.joinAt.y,r:3,class:`wb-wire-dot`})),e.label&&t.push(B(e.label,e.labelAt.x,e.labelAt.y,`wb-wire-label`)),V(e,e.isBack?`wb-wire wb-back wb-tone-${e.tone}`:`wb-wire wb-tone-${e.tone}`,t)}function pn(e){let t=[z(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:4,class:`wb-note-card`})];return e.lines.forEach((n,r)=>{t.push(B(n,e.x+10,e.y+22+r*Ft,`wb-note-text`))}),e.byline&&t.push(B(e.byline,e.x+10,e.y+22+e.lines.length*Ft,`wb-note-byline`)),V(e,e.isResolved?`wb-note wb-resolved`:`wb-note`,t)}function mn(e){let t=[z(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:8,class:`wb-unit-outline`}),B(e.label,e.x+I,e.y+Rt,`wb-unit-label`),B(e.status,e.x+e.width-I,e.y+Rt,`wb-unit-status wb-unit-${e.status}`,{"text-anchor":`end`})],n=e.y+Rt+zt;e.titleLines.forEach((r,i)=>{t.push(B(r,e.x+I,n+i*L,`wb-box-title`))});let r=n+e.titleLines.length*L;return t.push(...on(e.bodyLines,e.x,e.width,r)),e.linkedBoardId&&t.push(B(Vt,e.x+I,r+e.bodyLines.length*Pt,`wb-unit-link`,{"data-linked-board-id":e.linkedBoardId})),V(e,`wb-unit`,t)}function hn(e){switch(e.kind){case`box`:return ln(e);case`frame`:return dn(e);case`wire`:return fn(e);case`note`:return pn(e);case`unit`:return mn(e);case`panel`:return sn(e)}}function gn(e){let t=[];if(e.plan){t.push(B(Bt,e.plan.titleAt.x,e.plan.titleAt.y,`wb-column-title`));for(let n of e.plan.arrowPaths)t.push(z(`path`,{d:n,"marker-end":`url(#wb-arrow)`,class:`wb-wire-line`}))}for(let n of e.bands)t.push(z(`line`,{x1:n.x,y1:n.y,x2:n.x+n.width,y2:n.y,class:`wb-band-rule`})),n.label&&t.push(B(n.label,n.x,n.y+Ut,`wb-band-label`,{style:`fill:${n.hex}`}));for(let n of e.columns)n.titleLines.length!==0&&(n.titleLines.forEach((e,r)=>{t.push(B(e,n.x,n.titleBaselineY+r*Lt,`wb-column-title`))}),t.push(z(`line`,{x1:n.x,y1:n.ruleY,x2:n.x+n.width,y2:n.ruleY,class:`wb-column-rule`})));for(let n of e.legend)t.push(vn(n));return e.caption&&t.push(B(e.caption.text,e.caption.x,e.caption.y+16,`wb-caption`)),z(`g`,{class:`wb-chrome`},t.join(``))}function _n(e){let{swatch:t}=e;if(t.kind===`lane`)return z(`rect`,{x:e.x,y:e.y,width:14,height:14,rx:3,class:`wb-legend-swatch`,style:`fill:${t.hex}`});if(t.kind===`change`)return z(`g`,{class:`wb-change-${t.change}`},z(`rect`,{x:e.x,y:e.y,width:Qt,height:14,rx:3,class:`wb-legend-swatch wb-box-outline`}));let n=z(`path`,{d:`M${e.x},${e.y+7} H${e.x+Qt}`,"marker-end":`url(#wb-arrow)`,class:t.isDashed?`wb-wire-line wb-dashed`:`wb-wire-line`});return z(`g`,{class:t.isBack?`wb-back wb-tone-${t.tone}`:`wb-tone-${t.tone}`},n)}function vn(e){let t=e.x+(e.swatch.kind===`lane`?22:40);return _n(e)+B(e.label,t,e.y+12,`wb-legend-text`)}function yn(){return z(`defs`,{},z(`marker`,{id:`wb-arrow`,viewBox:`0 0 10 10`,refX:9,refY:5,markerWidth:8,markerHeight:8,orient:`auto-start-reverse`},z(`path`,{d:`M 0 1 L 10 5 L 0 9 z`,fill:`context-stroke`})))}var bn={worthALookIds:new Set,flaggedUnitIds:new Set},xn=9;function H(e,t=``){let n=document.createElementNS(Mt,e);return t&&n.setAttribute(`class`,t),n}function Sn(e){let t=H(`g`);return t.innerHTML=e,[...t.children]}function Cn(e){let[t]=Sn(e);if(!(t instanceof SVGGElement))throw Error(`the whiteboard markup did not draw a group`);return t}var wn={frame:`frames`,wire:`wires`,box:`boxes`,panel:`boxes`,note:`notes`,unit:`units`},Tn=[`box`,`frame`,`wire`,`note`,`unit`,`panel`];function En(e){let t={frames:H(`g`,`wb-layer`),wires:H(`g`,`wb-layer`),boxes:H(`g`,`wb-layer`),notes:H(`g`,`wb-layer`),units:H(`g`,`wb-layer`)},n=H(`g`);e.replaceChildren(...Sn(yn()),n,t.frames,t.wires,t.boxes,t.notes,t.units);let r=new Map,i=null,a=new Set,o=bn;function s(e,t){t.classList.toggle(`is-selected`,a.has(e))}function c(e){let t=H(`g`,`wb-look-marker`),n=e.x+e.width,r=e.y,i=H(`circle`);i.setAttribute(`cx`,String(n)),i.setAttribute(`cy`,String(r)),i.setAttribute(`r`,String(xn));let a=H(`text`);a.setAttribute(`x`,String(n)),a.setAttribute(`y`,String(r+4)),a.setAttribute(`text-anchor`,`middle`),a.textContent=`!`;let o=H(`title`);return o.textContent=`worth a look in review`,t.append(o,i,a),t}function l(e,t){t.classList.toggle(`is-flagged`,o.flaggedUnitIds.has(e.id));let n=t.querySelector(`:scope > .wb-look-marker`);e.kind===`wire`||!o.worthALookIds.has(e.id)?n?.remove():n||t.append(c(e))}function u(e){let a=x(e),o=Cn(gn(a));n.replaceWith(o),n=o;let c=new Set;for(let e of a.elements){c.add(e.id);let n=S(e),i=r.get(e.id);if(i?.signature===n)continue;let a=Cn(hn(e));s(e.id,a),l(e,a),i&&i.node.replaceWith(a),i||t[wn[e.kind]].append(a),r.set(e.id,{signature:n,node:a})}for(let[e,t]of r)c.has(e)||(t.node.remove(),r.delete(e));return i=a,a}function d(e){if(!(e instanceof Element))return null;let t=e.closest(`.wb-element`),n=t?.dataset.elementId,r=Tn.find(e=>e===t?.dataset.elementKind);return!n||!r?null:{id:n,kind:r}}function f(e){a=e;for(let[e,t]of r)s(e,t.node)}function p(e){o=e;for(let e of i?.elements??[]){let t=r.get(e.id)?.node;t&&l(e,t)}}function m(){for(let e of r.values())e.node.remove();r.clear();let e=H(`g`);n.replaceWith(e),n=e,i=null}return{render:u,layout:()=>i,elementFromTarget:d,nodeOf:e=>r.get(e)?.node??null,setSelection:f,setReviewMarks:p,clear:m}}var Dn=`http://www.w3.org/2000/svg`,On=`No boards yet. Make one here, or have an agent run glimmervoid whiteboard new <title>.`,kn=`Pick a board above.`,An=`wb-board-title-rename`,jn=`M2.5 4h11M2.5 8h11M2.5 12h11`,Mn=`M3 2.5h7l3 3v8H3z M10 2.5v3h3`,Nn=`M13.5 8H3 M7 4L3 8l4 4`,Pn=`M2.5 4.5h11v9h-11z M2.5 4.5v-2h5v2`,Fn=`M6 4.5h7.5 M6 8h7.5 M6 11.5h7.5 M2.5 4.5h0.01 M2.5 8h0.01 M2.5 11.5h0.01`,In=`M2.5 6V2.5H6 M10 2.5h3.5V6 M13.5 10v3.5H10 M6 13.5H2.5V10`,Ln=`M5.5 3.5l-3 3l3 3 M2.5 6.5h7a3.5 3.5 0 0 1 0 7H7`,Rn=`M10.5 3.5l3 3l-3 3 M13.5 6.5h-7a3.5 3.5 0 0 0 0 7H9`,zn=[{tool:`select`,label:`select`,key:`V`,iconPath:`M4 2.5l8.5 5.8l-4 0.7l2.2 4.3l-1.5 0.8l-2.2-4.3L4 12.5z`},{tool:`box`,label:`box`,key:`R`,iconPath:`M2.5 4h11v8h-11z`},{tool:`decision`,label:`decision`,key:`D`,iconPath:`M8 2l6 6l-6 6l-6-6z`},{tool:`panel`,label:`panel`,key:`P`,iconPath:`M2.5 3h11v10h-11z M2.5 6h11`},{tool:`wire`,label:`wire`,key:`A`,iconPath:`M2.5 13.5L13 3 M8.5 3H13v4.5`}],U=null,W=null,G=null,K=null,Bn=null,Vn=!0,q=null,Hn=null,Un=null,J=null,Y=u(`action-status wb-status`),X=u(`action-status wb-status`),Z=new Map,Wn=Promise.resolve();function Gn(e){let{dialog:t,close:n,actions:r,btnCancel:i}=c({title:e.title}),o=a(`input`,`dialog-input`);o.type=`text`,o.placeholder=e.placeholder,o.maxLength=e.maxLength,o.value=e.initialValue??``,o.autocomplete=`off`,o.setAttribute(`aria-label`,e.label);let s=a(`div`,`dialog-error`);s.setAttribute(`role`,`alert`);let l=e.choices?a(`select`,`dialog-input wb-dialog-select`):null;if(l&&e.choices){l.setAttribute(`aria-label`,e.choices.label);for(let t of e.choices.options){let e=a(`option`,null,t.text);e.value=t.value,l.append(e)}}let u=a(`button`,`btn-dialog btn-dialog-confirm`,e.confirmLabel);u.type=`button`,r.append(u),t.append(a(`label`,`dialog-label`,e.label),o,...l?[l]:[],s,r);async function d(){let t=o.value.trim();if(!t){s.textContent=`${e.label} is empty.`;return}u.disabled=!0;let r=await e.onSubmit(t,l?.value??null);u.disabled=!1,r?s.textContent=r:n()}i.addEventListener(`click`,n),u.addEventListener(`click`,()=>void d()),o.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),d())}),requestAnimationFrame(()=>o.focus())}function Q(){return U?_(U):null}function Kn(){return C().find(e=>e.id===U)??null}function qn(e){let t=Wn.then(e);return Wn=t.catch(()=>void 0),t}function Jn(e,t){return qn(()=>Yn(e,t))}async function Yn(e,t){let n=Q(),r=await v(e,t);return r.ok&&n?.id===e&&Z.set(e,Ve(Z.get(e)??Ae,ze(n,t))),r}function Xn(e){return qn(()=>Zn(e))}async function Zn(e){let t=U,n=Q();if(!t||!n)return;let r=He(Z.get(t)??Ae,e);if(!r)return;Z.set(t,r.history);let i=await v(t,r.entry);i.ok?(Y.clear(),Z.set(t,Ue(Z.get(t)??Ae,e,ze(n,r.entry)))):Y.show(`error`,`could not ${e} that change, so it was dropped: ${i.error}`)}async function Qn(e){if(!U||e.length===0)return!1;let t=await Jn(U,e);return t.ok?(Y.clear(),!0):(Y.show(`error`,t.error),!1)}async function $n(e){if(!U)return`No board is open.`;let t=await Jn(U,e);return t.ok?null:t.error}function er(e){let t=f(e);return t?d(t):`closed session`}function tr(){let e=Kn()?.connectedSessionIds??[],t=Q()?.codeSessionId;return(t&&!e.includes(t)?[t,...e]:e).map(e=>({value:e,text:er(e)}))}function nr(e){let t=Q();return[...K?.selectedIds()??new Set].flatMap(e=>t?.elements[e]??[]).filter(t=>t.kind===e)}function rr(){if(!W)return;let e=Q(),t=nr(`box`).length;for(let t of W.toolButtons.values())t.disabled=!e;W.buttons.note.disabled=t!==1,W.buttons.frame.disabled=t===0;for(let t of[W.buttons.unit,W.buttons.fit,W.buttons.undo,W.buttons.redo])t.disabled=!e;Bn?.paint(K?.selectedIds()??new Set)}function ir(){if(!W)return;let e=C();U&&!e.some(e=>e.id===U)&&(U=null),!U&&e[0]&&yr(e[0].id),W.boardMenu.paintBoards(e),lr()}function ar(){return!!W?.boardIsland.querySelector(`.${An}`)}function or(){let t=Kn();if(!W||!t||ar())return;let{boardTitle:n}=W,r=a(`input`,An);r.type=`text`,r.value=t.title,r.maxLength=e.title,r.setAttribute(`aria-label`,`Board title`),n.replaceWith(r),r.focus(),r.select();let i=!1;function o(e){if(i||!t)return;i=!0;let a=r.value.trim();r.replaceWith(n),lr(),e&&a&&a!==t.title&&Qn([{op:`board`,title:a}])}r.addEventListener(`blur`,()=>o(!0)),r.addEventListener(`keydown`,e=>{e.stopPropagation(),(e.key===`Enter`||e.key===`Escape`)&&(e.preventDefault(),o(e.key===`Enter`))})}function sr(e){let t=h(e.title,`visible wb-board-menu-board`);t.setAttribute(`role`,`menuitemradio`),t.setAttribute(`aria-checked`,String(e.id===U));let n=e.connectedSessionIds.length;return n>0&&t.append(a(`span`,`wb-board-menu-count`,String(n))),t.addEventListener(`click`,()=>yr(e.id)),t}function cr(e){let t=a(`div`,`session-overflow wb-board-menu`),n=a(`div`,`popup-menu session-overflow-menu`);n.setAttribute(`role`,`menu`),n.setAttribute(`aria-label`,`Board menu`);let r=()=>n.classList.contains(`open`),i=e=>{l.classList.toggle(`visible`,!Nr()),n.classList.toggle(`open`,e),o.setAttribute(`aria-expanded`,String(e))},o=$(`board menu`,jn,()=>i(!r()));o.setAttribute(`aria-haspopup`,`menu`),o.setAttribute(`aria-expanded`,`false`);let s=(e,t,n=``)=>{let r=h(e,`visible ${n}`.trim());return r.addEventListener(`click`,t),r},c=a(`div`,`menu-divider`);c.setAttribute(`role`,`separator`);let l=s(`board settings`,e),u=[c,s(`new board`,Tr),l,s(`delete board`,wr,`wb-board-menu-danger`)];return n.addEventListener(`click`,e=>{e.target instanceof HTMLElement&&e.target.closest(`[role^="menuitem"]`)&&i(!1)}),t.append(o,n),p({trigger:o,menu:n,menuItems:()=>[...n.querySelectorAll(`.visible[role^="menuitem"]`)],isOpen:r,open:()=>i(!0),close:()=>i(!1)}),document.addEventListener(`click`,e=>{r()&&e.target instanceof Node&&!t.contains(e.target)&&i(!1)}),{menuRoot:t,trigger:o,paintBoards:e=>n.replaceChildren(...e.map(sr),...u)}}function lr(){if(!W)return;let e=Kn(),t=C().length>0;W.canvas.hidden=!e,W.empty.hidden=!!e,W.emptyText.textContent=t?kn:On,e&&(W.boardTitle.textContent=e.title,W.boardMeta.textContent=`v${e.version}`,W.presence.replaceChildren(...e.connectedSessionIds.map(e=>a(`span`,`wb-presence-pill`,er(e)))),e.connectedSessionIds.length===0&&W.presence.append(a(`span`,`wb-presence-none`,`no sessions connected`)),rr(),dr())}function ur(e,t){let n=er(t);if(!e?.connectedSessionIds.includes(t))return`${n} is not connected to this board`;let r=e.queuedBySessionId[t]??0;return r===0?`${n} has read every change`:`${r} board ${r===1?`edit`:`edits`} queued for ${n}`}function dr(){if(!W||!q)return;let e=Kn();W.dockQueued.textContent=ur(e,q),W.sendToAgent.disabled=!e?.connectedSessionIds.includes(q)}async function fr(){if(!W||!U||!q)return;W.sendToAgent.disabled=!0,X.show(`busy`,`sending`);let e=await ne(U,q);dr(),e.ok?X.show(`ok`,`sent; the agent reads the board when it is ready`):X.show(`error`,e.error)}function pr(e,t){let n=new Set(t);return new Set(Object.values(e.elements).filter(e=>_e(e).some(e=>n.has(ve(e)??``))).map(e=>e.id))}function mr(e){let t=Q()?.codeSessionId,n=ve(e);t&&n&&re(t,n)}function hr(e,t){let n=a(`button`,`wb-uncovered-file`,t);return n.type=`button`,n.addEventListener(`click`,()=>re(e,t)),n}function gr(){if(!W||!G)return;let e=Q(),t=e&&Hn?.boardId===e.id?Hn.review:null;G.setReviewMarks({worthALookIds:e&&t?pr(e,t.worthALookPaths):new Set,flaggedUnitIds:new Set(t?.flaggedUnitIds??[])});let n=(e&&Un?.boardId===e.id?`the board review could not be loaded: ${Un.error}`:null)??t?.notChecked??null,r=t?.codeSessionId??null,i=r?t?.uncoveredPaths??[]:[];W.uncovered.hidden=!n&&i.length===0;let o=n?[a(`p`,`wb-uncovered-notice`,`Not checked: ${n}`)]:[],s=r?i.map(e=>hr(r,e)):[];W.uncovered.replaceChildren(a(`h3`,`wb-uncovered-heading`,`Not on the board`),...o,...s)}function _r(e){let t=`${e.id}@${e.version}`;J!==t&&(J=t,de(e.id).then(n=>{J===t&&(n.ok?(Un=null,Hn={boardId:e.id,review:n.review},gr()):(J=null,Un={boardId:e.id,error:n.error},gr()))}))}function vr(){if(!G)return;let e=Q();e?(_r(e),K?.pruneSelection(e),G.render(K?.previewOf(e)??e),gr(),K?.openPendingTitleEdit(),Vn&&=(K?.fit(),!1),rr()):G.clear()}function yr(e){U!==e&&(U=e,Vn=!0,K?.clearSelection(),K?.closeTitleInput(),Bn?.closeBoardSettings(),G?.clear(),Y.clear(),ir(),ue(e).then(vr))}function br(){let t=Q();if(!t)return;let n=C().filter(e=>e.id!==t.id),r=[{value:``,text:`No linked board`},...n.map(e=>({value:e.id,text:e.title}))];Gn({title:`Add a unit`,label:`Unit title`,placeholder:`index the diffs`,maxLength:e.title,confirmLabel:`Add unit`,choices:n.length>0?{label:`Linked board`,options:r}:void 0,onSubmit:(e,t)=>$n([{op:`add`,element:{kind:`unit`,id:T(`unit`),title:e,lines:[],refs:[],status:`planned`,after:[],linkedBoardId:t||null}}])})}function xr(t){Gn({title:`Pin a note`,label:`Note`,placeholder:`what about retries?`,maxLength:e.noteText,confirmLabel:`Pin note`,onSubmit:e=>$n([{op:`add`,element:{kind:`note`,id:T(`note`),on:t,text:e,ref:null,author:``,resolvedBy:null}}])})}function Sr(e,t){let n=Q();n&&e!==t&&(Object.values(n.elements).some(n=>n.kind===`wire`&&n.from===e&&n.to===t)||Qn([{op:`add`,element:{kind:`wire`,id:T(`wire`),from:e,to:t,fromOutput:null,dashed:!1,tone:`plain`,label:null,fromSide:null,toSide:null,back:!1}}]))}function Cr(){let t=nr(`box`).map(e=>e.id);t.length!==0&&Gn({title:`Frame the selected boxes`,label:`Frame title`,placeholder:`intake`,maxLength:e.title,confirmLabel:`Add frame`,onSubmit:async e=>{let n=await $n([{op:`add`,element:{kind:`frame`,id:T(`frame`),title:e,contains:t,loop:!1}}]);return n||K?.clearSelection(),n}})}function wr(){let e=Kn();if(!e)return;let t=e.connectedSessionIds.map(er),n=t.length>0?` ${t.join(`, `)} ${t.length===1?`is`:`are`} connected and will lose it.`:``;o({title:`Delete board`,message:`Delete "${e.title}" for good?${n}`,confirmLabel:`Delete board`,danger:!0,onConfirm:()=>{le(e.id).then(e=>{e.ok||Y.show(`error`,e.error)})}})}function Tr(){Gn({title:`New board`,label:`Board title`,placeholder:`knowledge writer`,maxLength:e.title,confirmLabel:`Create board`,onSubmit:async e=>{let t=await ae(e);return t.ok?(yr(t.boardId),null):t.error}})}function Er(e,t){let n=a(`button`,`wb-button`,e);return n.type=`button`,n.addEventListener(`click`,t),n}function $(e,t,n,r){let i=a(`button`,`wb-icon-button`);if(i.type=`button`,i.setAttribute(`aria-label`,e),i.title=r?`${e} (${r})`:e,i.append(l(t,`1.5`)),r){let e=a(`span`,`wb-tool-key`,r);e.setAttribute(`aria-hidden`,`true`),i.append(e),i.setAttribute(`aria-keyshortcuts`,r)}return i.addEventListener(`click`,n),i}function Dr(e,t,n,r){let i=$(t,r,()=>{K?.setTool(e),K?.focusCanvas()},n);return i.classList.add(`wb-tool`),i.setAttribute(`aria-pressed`,String(e===`select`)),i}function Or(e,t,...n){let r=a(`div`,`wb-island ${e}`);return r.setAttribute(`role`,`toolbar`),r.setAttribute(`aria-label`,t),r.append(...n),r}function kr(e){for(let[t,n]of W?.toolButtons??[])n.setAttribute(`aria-pressed`,String(t===e))}function Ar(e){return!(e.metaKey||e.ctrlKey)||e.altKey||e.code!==`KeyZ`?null:e.shiftKey?`redo`:`undo`}function jr(e,t){let n=Ar(t);n&&e.checkVisibility()&&!s()&&!i(t)&&(document.activeElement?.classList.contains(`xterm-helper-textarea`)||(t.preventDefault(),Xn(n)))}function Mr(e){let t=cr(()=>{K?.clearSelection(),Bn?.openBoardSettings()});t.trigger.dataset.phoneVisible=``;let n=a(`button`,`wb-board-title`);n.type=`button`,n.title=`Click to rename`,n.addEventListener(`click`,or);let r=a(`span`,`wb-board-meta`),i=a(`div`,`wb-presence`),o=Or(`wb-island-board`,`Board`,t.menuRoot,n,r,i,Y.element),s=new Map(zn.map(({tool:e,label:t,key:n,iconPath:r})=>[e,Dr(e,t,n,r)])),c=a(`div`,`wb-tools`);c.setAttribute(`role`,`group`),c.setAttribute(`aria-label`,`Drawing tools`),c.append(...s.values());let l={note:$(`note`,Mn,()=>{let[e]=nr(`box`);e&&xr(e.id)}),frame:$(`frame`,Pn,Cr),unit:$(`unit`,Fn,br),fit:$(`fit`,In,()=>K?.fit()),undo:$(`undo`,Ln,()=>void Xn(`undo`)),redo:$(`redo`,Rn,()=>void Xn(`redo`))};l.fit.dataset.phoneVisible=``;let u=Or(`wb-island-tools`,`Board tools`,c,l.note,l.frame,l.unit),d=Or(`wb-island-view`,`View`,l.fit,l.undo,l.redo),f=a(`div`,`wb-canvas`),p=document.createElementNS(Dn,`svg`);p.setAttribute(`class`,`wb-svg`),p.setAttribute(`role`,`img`),p.setAttribute(`aria-label`,`Whiteboard`),p.setAttribute(`preserveAspectRatio`,`xMidYMin meet`);let m=a(`aside`,`wb-inspect`),h=a(`aside`,`wb-uncovered`);h.setAttribute(`aria-label`,`Not on the board`),h.hidden=!0;let ee=a(`span`,`wb-dock-queued`),te=$(`send to agent`,Nn,()=>void fr()),_=Or(`wb-island-agent`,`Docked session`,te,ee,X.element);_.hidden=!0;let v=a(`div`,`wb-bottom-left`);v.append(h,_,d),f.append(p,m,o,v,u);let y=a(`p`,`wb-empty-text`,On),b=a(`div`,`wb-empty`);b.append(y,Er(`new board`,Tr));let x=a(`div`,`wb-dock`);x.hidden=!0,e.replaceChildren(f,b,x),W={boardIsland:o,boardMenu:t,boardTitle:n,boardMeta:r,presence:i,canvas:f,empty:b,emptyText:y,dock:x,agentIsland:_,dockQueued:ee,sendToAgent:te,buttons:l,toolButtons:s,uncovered:h};let S=En(p);G=S,Bn=jt({container:m,currentBoard:Q,layout:()=>S.layout(),sendOps:Qn,codeSessionChoices:tr,openRef:mr}),K=ke({svg:p,canvas:f,renderer:S,currentBoard:Q,sendOps:Qn,onSelectionChange:rr,onPhoneTapBox:xr,onOpenLinkedBoard:yr,onConnectBoxes:Sr,onToolChange:kr}),document.addEventListener(`keydown`,t=>jr(e,t)),oe(ir),g(e=>{e===U&&vr()}),ir()}function Nr(){return document.documentElement.dataset.layout===`phone`}function Pr(){q&&ee()===q&&y(),q=null,W&&(W.dock.hidden=!0,W.agentIsland.hidden=!0)}function Fr(e){if(!W||Nr())return;let t=f(e);t&&(q=e,W.dock.hidden=!1,W.agentIsland.hidden=!1,X.clear(),dr(),te(t,e,W.dock,{className:`wb-docked-card`}),ce(t,e,!0))}function Ir(){let e=b();e&&(yr(e.boardId),e.dockSessionId&&Fr(e.dockSessionId)),ir(),J=null,U&&ue(U).then(vr)}var Lr={mount:Mr,refresh:Ir,deactivate:Pr};export{Lr as view};
|
|
1
|
+
import{Dt as e,Tt as t,bt as n,yt as r}from"./updates-view-core-DWODr1GQ.js";import{f as i,s as a}from"./dom-helpers-qjWTsLGI.js";import{a as o,i as s,n as c}from"./modal-Dta3lhg0.js";import{S as l}from"./svg-dom-CQQ12iW3.js";import{i as u}from"./action-status-D7HyJ8Q5.js";import{a as d,r as f}from"./card-registry-BaNcteKc.js";import{n as p,r as m,t as h}from"./menu-DJySApM6.js";import{$ as ee,Q as te,at as g,ct as _,dt as v,et as y,ft as b,gt as x,ht as S,it as ne,lt as re,mt as ie,nt as ae,ot as oe,pt as se,ri as ce,rt as le,st as ue,tt as C,ut as de}from"./index-DA0egBFL.js";Object.freeze({unitWarnings:[],uncoveredPaths:[],worthALookPaths:[],flaggedUnitIds:[],notChecked:null});var fe=/^([^#\s]+)(?:#L([1-9]\d*)(?:-L([1-9]\d*))?)?$/;function pe(e){return e.startsWith(`/`)||e.startsWith(`\\`)||/^[A-Za-z]:/.test(e)}function me(e){return e.split(`/`).filter(e=>e!==``&&e!==`.`).join(`/`)}function he(e){let t=fe.exec(e);if(!t?.[1])return{error:`a ref is path, path#L12 or path#L12-L30`};let n=t[1];if(pe(n))return{error:`an absolute path is never read; name the file relative to the code session worktree`};if(n.split(/[\\/]/).includes(`..`))return{error:`a path with .. is never read; name the file relative to the code session worktree`};let r=t[2]?Number(t[2]):null,i=t[3]?Number(t[3]):r;return r!==null&&i!==null&&i<r?{error:`the line range ends before it starts`}:{path:me(n),startLine:r,endLine:i}}function w(e,t,n){return n.flatMap((n,r)=>n.ref?[{elementId:t,ref:n.ref,where:`line ${r+1} of ${e}`}]:[])}function ge(e){let t=`${e.kind} ${e.id}`;switch(e.kind){case`box`:case`unit`:return[...e.refs.map(n=>({elementId:e.id,ref:n,where:t})),...w(t,e.id,e.lines)];case`panel`:return w(t,e.id,e.lines);case`note`:return e.ref?[{elementId:e.id,ref:e.ref,where:t}]:[];case`frame`:case`wire`:return[]}}function _e(e){return[...new Set(ge(e).map(e=>e.ref))]}function ve(e){let t=he(e);return`path`in t?t.path:null}var ye=4,be=200,xe=2e4,Se=1.1,Ce=[`wire`,`note`,`frame`,`box`,`panel`,`unit`],we={v:`select`,r:`box`,d:`decision`,p:`panel`,a:`wire`};function T(e){let t=Math.random().toString(36).slice(2,8);return`${e}-${Date.now().toString(36)}${t}`}function E(){return document.documentElement.dataset.layout===`phone`}function Te(e){return e instanceof SVGCircleElement&&e.classList.contains(`wb-port`)?e:null}function Ee(e){return e===`box`||e===`decision`||e===`panel`}function De(e,t,n){if(e===`panel`){let e=Math.max(-1,...Object.values(t.elements).map(e=>e.kind===`panel`?e.order:-1));return{kind:`panel`,id:T(`panel`),title:`Panel`,lines:[],order:e+1}}let r=e===`decision`;return{kind:`box`,id:T(`box`),title:r?`Decision`:`Box`,lines:[],lane:null,refs:[],change:`none`,was:null,column:null,near:null,order:0,at:n,shape:r?`decision`:`box`,outputs:r?[{id:`yes`,label:`yes`},{id:`no`,label:`no`}]:[]}}function Oe(e){return e instanceof Element?e.closest(`[data-linked-board-id]`)?.dataset.linkedBoardId??null:null}function ke(e){let{svg:t,canvas:n,renderer:r}=e,i=new Map,o=new Set,s={x:0,y:0,width:1e3,height:600},c=null,l=null,u=null,d=`select`,f=null;function p(n){d=n,t.dataset.tool=n,e.onToolChange(n)}function m(){t.setAttribute(`viewBox`,`${s.x} ${s.y} ${s.width} ${s.height}`)}function h(e){let t=n.querySelector(e);return t?.checkVisibility()?t.getBoundingClientRect():null}function ee(){let e=t.getBoundingClientRect(),n=h(`.wb-island-board`),r=[`.wb-island-tools`,`.wb-bottom-left`].flatMap(e=>{let t=h(e);return t?[t.top]:[]}),i=n?Math.max(0,n.bottom-e.top):0,a=Math.min(e.height,...r.map(t=>t-e.top))-i;return a<e.height/2?{topPx:0,heightPx:e.height}:{topPx:i,heightPx:a}}function te(){let e=r.layout();if(!e)return;let{bounds:n}=e,i=t.clientWidth,a=t.clientHeight;if(i===0||a===0){s={...n},m();return}let o=ee(),c=Math.max(1,n.width/i,n.height/o.heightPx),l=i*c,u=n.y+n.height/2,d=o.topPx+o.heightPx/2;s={x:n.x-(l-n.width)/2,y:u-d*c,width:l,height:a*c},m()}function g(e,n){let r=t.getScreenCTM();if(!r)return{x:e,y:n};let i=new DOMPoint(e,n).matrixTransform(r.inverse());return{x:i.x,y:i.y}}function _(){let e=t.clientWidth||1,n=t.clientHeight||1;return Math.max(s.width/e,s.height/n)}function v(e,t){let n=Math.min(xe,Math.max(be,s.width*t)),r=n/s.width;s={x:e.x-(e.x-s.x)*r,y:e.y-(e.y-s.y)*r,width:n,height:s.height*r},m()}function y(e,t){let n=_();s={...s,x:s.x-e*n,y:s.y-t*n},m()}function b(t){o=t,r.setSelection(o),e.onSelectionChange(o)}function x(e,t){if(!t){b(o.has(e)&&o.size===1?new Set:new Set([e]));return}let n=new Set(o);n.delete(e)||n.add(e),b(n)}function S(e){return{x:Math.round(e.start.x+e.latest.x-e.origin.x),y:Math.round(e.start.y+e.latest.y-e.origin.y-e.pinnedOffsetY)}}function ne(e,t,n){let r=e.elements[t];return r?.kind===`box`?{...e,elements:{...e.elements,[t]:{...r,at:n}}}:e}function re(e){return c?.kind!==`drag`||!c.hasMoved?e:ne(e,c.boxId,S(c))}function ie(){u!==null&&cancelAnimationFrame(u),u=null}function ae(){ie();let t=e.currentBoard();t&&r.render(re(t))}function oe(){u===null&&(u=requestAnimationFrame(ae))}function se(e){c?.kind===`drag`&&e?.elements[c.boxId]?.kind!==`box`&&(c=null);let t=new Set([...o].filter(t=>e?.elements[t]));t.size!==o.size&&b(t)}function ce(e){let t=r.layout()?.elements.find(t=>t.id===e);return t?.kind===`box`?t:null}function le(){let[e,t]=[...i.values()];return!e||!t?0:Math.hypot(e.x-t.x,e.y-t.y)}function ue(){c?.kind===`wire`&&w(c,!1),c={kind:`pinch`,distance:le(),viewWidth:s.width}}function C(n){if(n.button!==0||l)return;let a=Oe(n.target);if(a){e.onOpenLinkedBoard(a);return}if(i.set(n.pointerId,{x:n.clientX,y:n.clientY}),t.setPointerCapture(n.pointerId),i.size===2){ue();return}let o=r.elementFromTarget(n.target);if(Ee(d)){de(d,g(n.clientX,n.clientY));return}let s=Te(n.target);if(o?.kind===`box`&&s&&!E()){pe(n.pointerId,o.id,{x:s.cx.baseVal.value,y:s.cy.baseVal.value});return}let u=d===`wire`&&o?.kind===`box`?ce(o.id):null;if(o&&u){pe(n.pointerId,o.id,{x:u.x+u.width/2,y:u.y+u.height/2});return}let f=o?.kind===`box`&&!E()?ce(o.id):null;if(o&&f){let e=g(n.clientX,n.clientY),t=r.layout()?.pinnedOffsetY??0;c={kind:`drag`,pointerId:n.pointerId,boxId:o.id,origin:e,start:f,pinnedOffsetY:t,latest:e,hasMoved:!1,isAdditive:n.shiftKey};return}if(o&&!E()){x(o.id,n.shiftKey);return}let p=o?.kind===`box`?o.id:null;c={kind:`pan`,pointerId:n.pointerId,lastClient:{x:n.clientX,y:n.clientY},hasMoved:!1,tappedBoxId:p}}async function de(t,n){p(`select`);let i=e.currentBoard();if(!i)return;let a=r.layout()?.pinnedOffsetY??0,o=De(t,i,{x:Math.round(n.x),y:Math.round(n.y-a)});f=o.id;let s=await e.sendOps([{op:`add`,element:o}]);s||(f=null),s&&b(new Set([o.id])),fe()}function fe(){if(!f||!r.nodeOf(f))return;let e=f;f=null,O(e)}function pe(e,n,r){let i=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);i.setAttribute(`class`,`wb-wire-line wb-dashed wb-wire-draft`),i.setAttribute(`d`,`M ${r.x} ${r.y} L ${r.x} ${r.y}`),t.append(i),c={kind:`wire`,pointerId:e,fromBoxId:n,start:r,draftLine:i,targetBoxId:null}}function me(e,t){e.targetBoxId&&r.nodeOf(e.targetBoxId)?.classList.remove(`is-wire-target`),e.targetBoxId=t,t&&r.nodeOf(t)?.classList.add(`is-wire-target`)}function he(e,t){let n=g(t.clientX,t.clientY);e.draftLine.setAttribute(`d`,`M ${e.start.x} ${e.start.y} L ${n.x} ${n.y}`);let i=r.elementFromTarget(document.elementFromPoint(t.clientX,t.clientY));me(e,i?.kind===`box`&&i.id!==e.fromBoxId?i.id:null)}function w(t,n){let r=t.targetBoxId;me(t,null),t.draftLine.remove(),n&&r&&e.onConnectBoxes(t.fromBoxId,r)}function ge(e,t){let n=g(t.clientX,t.clientY);!e.hasMoved&&Math.hypot(n.x-e.origin.x,n.y-e.origin.y)<ye*_()||(e.hasMoved=!0,e.latest=n,oe())}function _e(e,t){let n=t.clientX-e.lastClient.x,r=t.clientY-e.lastClient.y;!e.hasMoved&&Math.hypot(n,r)<ye||(e.hasMoved=!0,e.lastClient={x:t.clientX,y:t.clientY},y(n,r))}function ve(e){let t=le();if(t<=0||e.distance<=0)return;let n=[...i.values()];v(g(n.reduce((e,t)=>e+t.x,0)/n.length,n.reduce((e,t)=>e+t.y,0)/n.length),e.viewWidth*(e.distance/t)/s.width)}function T(e){i.has(e.pointerId)&&(i.set(e.pointerId,{x:e.clientX,y:e.clientY}),c?.kind===`pinch`?ve(c):c?.kind===`drag`&&c.pointerId===e.pointerId?ge(c,e):c?.kind===`wire`&&c.pointerId===e.pointerId?he(c,e):c?.kind===`pan`&&c.pointerId===e.pointerId&&_e(c,e))}async function ke(t,n){if(!t.hasMoved){x(t.boxId,t.isAdditive);return}ie(),t.latest=g(n.clientX,n.clientY);let i=S(t),a=e.currentBoard();a&&r.render(ne(a,t.boxId,i)),await e.sendOps([{op:`set`,id:t.boxId,fields:{at:i}}])||ae()}function Ae(t){if(!i.delete(t.pointerId))return;let n=c;n?.kind===`pinch`?c=null:(c=null,n?.kind===`drag`&&n.pointerId===t.pointerId?ke(n,t):n?.kind===`wire`?(w(n,n.pointerId===t.pointerId),d===`wire`&&p(`select`)):n?.kind!==`pan`||n.hasMoved||(n.tappedBoxId&&E()?e.onPhoneTapBox(n.tappedBoxId):n.tappedBoxId||b(new Set)))}function je(e){i.delete(e.pointerId);let t=c?.kind===`drag`;c?.kind===`wire`&&w(c,!1),c=null,t&&ae()}function Me(e){e.preventDefault(),e.ctrlKey||e.metaKey?v(g(e.clientX,e.clientY),e.deltaY>0?Se:1/Se):y(-e.deltaX,-e.deltaY)}function D(){let e=l;l=null,e?.remove()}function O(i){let o=e.currentBoard()?.elements[i],s=r.nodeOf(i);if(o?.kind!==`box`&&o?.kind!==`panel`||!s)return;D();let c=n.getBoundingClientRect(),u=s.getBoundingClientRect(),d=a(`input`,`wb-title-input`);d.type=`text`,d.value=o.title,d.maxLength=80,d.setAttribute(`aria-label`,o.kind===`panel`?`Panel title`:`Box title`),d.style.left=`${u.left-c.left}px`,d.style.top=`${u.top-c.top}px`,d.style.width=`${Math.max(160,u.width)}px`,l=d,n.append(d),d.addEventListener(`keydown`,n=>{if(n.key===`Escape`){n.preventDefault(),D(),t.focus();return}if(n.key!==`Enter`)return;n.preventDefault();let r=d.value.trim();D(),t.focus(),r&&r!==o.title&&e.sendOps([{op:`set`,id:i,fields:{title:r}}])}),d.addEventListener(`blur`,D),d.focus(),d.select()}function Ne(e){if(E())return;let t=r.elementFromTarget(document.elementFromPoint(e.clientX,e.clientY));(t?.kind===`box`||t?.kind===`panel`)&&O(t.id)}function Pe(){let t=e.currentBoard();if(!t||o.size===0)return;let n=[...o].flatMap(e=>t.elements[e]??[]),r=Ce.flatMap(e=>n.filter(t=>t.kind===e)).map(e=>({op:`remove`,id:e.id}));b(new Set),e.sendOps(r)}function Fe(e){if(e.target!==t||e.metaKey||e.ctrlKey||e.altKey)return;if(e.key===`Delete`||e.key===`Backspace`){e.preventDefault(),Pe();return}let n=we[e.key.toLowerCase()];n&&!e.shiftKey?(e.preventDefault(),p(n)):e.key===`Escape`&&(b(new Set),p(`select`))}return t.tabIndex=0,t.addEventListener(`pointerdown`,C),t.addEventListener(`pointermove`,T),t.addEventListener(`pointerup`,Ae),t.addEventListener(`pointercancel`,je),t.addEventListener(`wheel`,Me,{passive:!1}),t.addEventListener(`dblclick`,Ne),t.addEventListener(`keydown`,Fe),{fit:te,selectedIds:()=>o,clearSelection:()=>b(new Set),pruneSelection:se,previewOf:re,closeTitleInput:D,setTool:p,openPendingTitleEdit:fe,focusCanvas:()=>t.focus()}}var Ae=Object.freeze({undo:[],redo:[]}),je=new Set([`box`,`unit`,`panel`]),Me=[`wire`,`note`,`frame`,`box`,`panel`,`unit`],D=new Set([`kind`,`id`]);function O(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Ne(e){return e.kind===`box`?e.near?[e.near.of]:[]:e.kind===`unit`?e.after:[]}function Pe(e){let t=new Set(e.map(e=>e.id)),n=[];for(;t.size>0;){let r=e.filter(e=>t.has(e.id)&&Ne(e).every(e=>!t.has(e))),i=r.length>0?r:e.filter(e=>t.has(e.id));for(let e of i)t.delete(e.id);n.push(...i)}return n}function Fe(e,t){let n={...e},r=Object.fromEntries(Object.entries(t).filter(([e,t])=>!D.has(e)&&!O(n[e],t)));return t.kind!==`note`||Object.keys(r).length===0?r:{...r,author:t.author,resolvedBy:t.resolvedBy}}function Ie(e,t){let n={...e.title===t.title?{}:{title:t.title},...e.caption===t.caption?{}:{caption:t.caption},...O(e.legend,t.legend)?{}:{legend:t.legend},...e.codeSessionId===t.codeSessionId?{}:{codeSessionId:t.codeSessionId}};return Object.keys(n).length===0?[]:[{op:`board`,...n}]}function Le(e,t){if(O(e.columns,t.columns))return{widen:[],narrow:[]};let n=new Set(t.columns.map(e=>e.id));return{widen:[{op:`columns`,columns:[...t.columns,...e.columns.filter(e=>!n.has(e.id))],move:{}}],narrow:[{op:`columns`,columns:t.columns,move:{}}]}}function Re(e,t){let n=Object.values(e.elements),r=Object.values(t.elements),i=Me.flatMap(e=>n.filter(n=>n.kind===e&&!t.elements[n.id])),a=Pe(r.filter(t=>!e.elements[t.id])),o=r.flatMap(t=>{let n=e.elements[t.id];if(!n)return[];let r=Fe(n,t);return Object.keys(r).length===0?[]:[{op:`set`,id:t.id,fields:r}]}),{widen:s,narrow:c}=Le(e,t);return[...O(e.lanes,t.lanes)?[]:[{op:`lanes`,lanes:t.lanes}],...s,...i.map(e=>({op:`remove`,id:e.id})),...a.filter(e=>je.has(e.kind)).map(e=>({op:`add`,element:e})),...o,...a.filter(e=>!je.has(e.kind)).map(e=>({op:`add`,element:e})),...c,...Ie(e,t)]}function ze(e,t){let n=ie(e,t,se,e.updatedAt);return n.ok?Re(n.board,e):[]}function Be(e,t){return t.length===0?[...e]:[...e,t].slice(-100)}function Ve(e,t){return t.length===0?e:{undo:Be(e.undo,t),redo:[]}}function He(e,t){let n=e[t].at(-1);return n?{entry:n,history:{...e,[t]:e[t].slice(0,-1)}}:null}function Ue(e,t,n){let r=t===`undo`?`redo`:`undo`;return{...e,[r]:Be(e[r],n)}}var We=8,Ge=12,Ke=30,qe=40,Je=40,Ye=400,Xe=200,Ze=8,Qe=`README.md`,$e=``,et=[`text`,`code`,`item`,`numbered`,`kv`],tt=[`plain`,`fail`,`join`,`lane`],nt=k(et),rt=k(tt),it=k([`box`,`decision`]),at=k(n),ot=k(t),st=[{value:``,text:`auto`},...k([`left`,`right`,`top`,`bottom`])],ct=[{id:`yes`,label:`yes`},{id:`no`,label:`no`}];function k(e){return e.map(e=>({value:e,text:e}))}function A(e){return a(`h3`,`wb-inspect-heading`,e)}function j(e,t){let n=a(`label`,`wb-inspect-field`);return n.append(a(`span`,`wb-inspect-label`,e),t),n}function M(e,t,n,r,i){let o=a(`input`,`wb-inspect-input`);return o.type=`text`,o.value=t,o.maxLength=n,o.dataset.field=e,i&&o.setAttribute(`aria-label`,i),o.addEventListener(`change`,()=>r(o.value)),o}function N(e,t,n,r,i){let o=a(`select`,`wb-inspect-select`);return o.dataset.field=e,i&&o.setAttribute(`aria-label`,i),o.append(...t.map(e=>{let t=a(`option`,null,e.text);return t.value=e.value,t.selected=e.value===n,t})),o.addEventListener(`change`,()=>r(o.value)),o}function P(e,t,n,r){let i=a(`input`,`wb-inspect-check`);i.type=`checkbox`,i.checked=n,i.dataset.field=e,i.addEventListener(`change`,()=>r(i.checked));let o=a(`label`,`wb-inspect-toggle`);return o.append(i,a(`span`,null,t)),o}function F(e,t,n,r){let i=a(`button`,`wb-button wb-inspect-action`,t);return i.type=`button`,i.dataset.field=e,r&&i.setAttribute(`aria-label`,r),i.addEventListener(`click`,n),i}function lt(e,t,n){let r=a(`div`,`wb-inspect-list`);return r.append(a(`span`,`wb-inspect-label`,e),...t,n),r}function ut(e,t){return{edit(n,r){let i=e(),a=i?.[n];i&&a!==void 0&&t(i.map((e,t)=>t===n?r(a):e))},remove(n){let r=e();r&&t(r.filter((e,t)=>t!==n))},append(n){let r=e();r&&t([...r,n(r)])}}}function dt(e){let t=e.trim();return r.safeParse(t).success?t:null}function ft(e,t,n,r){let i=M(e,t??``,Xe,e=>{if(!e.trim()){n(null);return}let t=dt(e);t&&n(t)},r);return i.placeholder=`ref: path#L12`,i}function pt(e,t,n,r){let i=ut(n,r),o=t.map((e,t)=>{let n=a(`div`,`wb-inspect-row`);return n.append(M(`ref-${t}`,e,Xe,e=>{let n=dt(e);n&&i.edit(t,()=>n)},`Ref ${t+1}`),F(`ref-${t}-remove`,`remove`,()=>i.remove(t),`Remove ref ${e}`)),n}),s=F(`ref-add`,`add ref`,()=>i.append(()=>Qe),`Add a ref to ${e}`);return s.disabled=t.length>=Ze,lt(`Refs`,o,s)}function mt(e,t){return t===`kv`?{...e,style:t,key:e.key||`key`}:{...e,style:t}}function ht(t,n,r,i){let o=ut(r,i),s=n.map((t,n)=>{let r=a(`div`,`wb-inspect-row`),i=n+1;return r.append(N(`line-${n}-style`,nt,t.style,e=>{let t=et.find(t=>t===e);t&&o.edit(n,e=>mt(e,t))},`Line ${i} style`)),t.style===`kv`&&r.append(M(`line-${n}-key`,t.key??``,Je,e=>{e.trim()&&o.edit(n,t=>({...t,key:e.trim()}))},`Line ${i} key`)),r.append(M(`line-${n}-text`,t.text,e.line,e=>o.edit(n,t=>({...t,text:e})),`Line ${i} text`),ft(`line-${n}-ref`,t.ref,e=>o.edit(n,t=>({...t,ref:e})),`Line ${i} ref`),F(`line-${n}-remove`,`remove`,()=>o.remove(n),`Remove line ${i}`)),r}),c=F(`line-add`,`add line`,()=>o.append(()=>({text:`new line`,muted:!1,style:`text`,key:null,ref:null})),`Add a line to ${t}`);return c.disabled=n.length>=e.linesPerBox,lt(`Lines`,s,c)}function gt(e){let t=new Set(e.map(e=>e.id)),n=e.length+1;for(;t.has(`exit-${n}`);)n+=1;return`exit-${n}`}function _t(e,t,n){let r=ut(t,e=>n({outputs:e})),i=e.outputs.map((e,t)=>{let n=a(`div`,`wb-inspect-row`);return n.append(M(`output-${e.id}-label`,e.label,Ke,e=>{e.trim()&&r.edit(t,t=>({...t,label:e.trim()}))},`Output ${e.id} label`),F(`output-${e.id}-remove`,`remove`,()=>r.remove(t),`Remove output ${e.label}`)),n}),o=F(`output-add`,`add output`,()=>r.append(e=>({id:gt(e),label:`exit`})));return o.disabled=e.outputs.length>=We,lt(`Outputs`,i,o)}function vt(e){return e.at===null&&e.near===null?e.column??$e:$e}function yt(t,n,r,i,a){let o=()=>{let e=r();return e?.kind===`box`?e:null},s=[{value:$e,text:`free`},...t.columns.map(e=>({value:e.id,text:e.title||e.id}))],c=[{value:``,text:`none`},...t.lanes.map(e=>({value:e.id,text:e.label||e.id}))];return[A(n.shape===`decision`?`Decision`:`Box`),j(`Title`,M(`title`,n.title,e.title,e=>{e.trim()&&a({title:e.trim()})})),j(`Shape`,N(`shape`,it,n.shape,e=>{let t=o()?.outputs??[];e===`decision`&&a({shape:e,outputs:t.length>0?t:ct}),e===`box`&&a({shape:e,outputs:[]})})),j(`Column`,N(`column`,s,vt(n),e=>{if(e!==$e){a({column:e,at:null,near:null});return}let t=i?.elements.find(e=>e.id===n.id);i&&t?.kind===`box`&&a({at:{x:t.x,y:t.y-i.pinnedOffsetY},near:null})})),j(`Lane`,N(`lane`,c,n.lane??``,e=>a({lane:e||null}))),j(`Change`,N(`change`,at,n.change,e=>{a(e===`relabeled`?{change:e,was:o()?.was??n.title}:{change:e,was:null})})),...n.change===`relabeled`?[j(`Was`,M(`was`,n.was??``,e.title,e=>{e.trim()&&a({was:e.trim()})}))]:[],...n.shape===`decision`?[_t(n,()=>o()?.outputs??null,a)]:[],pt(`this box`,n.refs,()=>o()?.refs??null,e=>a({refs:e})),ht(`this box`,n.lines,()=>o()?.lines??null,e=>a({lines:e}))]}function bt(e,t,n){let r=e.elements[t.from],i=r?.kind===`box`&&r.shape===`decision`?[{value:``,text:`none`},...r.outputs.map(e=>({value:e.id,text:e.label}))]:[];return[A(`Wire`),j(`Label`,M(`label`,t.label??``,qe,e=>n({label:e.trim()||null}))),j(`Tone`,N(`tone`,rt,t.tone,e=>n({tone:e}))),P(`dashed`,`dashed`,t.dashed,e=>n({dashed:e})),P(`back`,`returns to an earlier step`,t.back,e=>n({back:e})),j(`Leaves from`,N(`fromSide`,st,t.fromSide??``,e=>n({fromSide:e||null}))),j(`Arrives at`,N(`toSide`,st,t.toSide??``,e=>n({toSide:e||null}))),...i.length>0?[j(`From output`,N(`fromOutput`,i,t.fromOutput??``,e=>n({fromOutput:e||null})))]:[]]}function xt(t,n){return[A(`Frame`),j(`Title`,M(`title`,t.title,e.title,e=>n({title:e.trim()}))),P(`loop`,`repeats as a loop`,t.loop,e=>n({loop:e}))]}function St(t,n,r){return[A(`Panel`),j(`Title`,M(`title`,t.title,e.title,e=>{e.trim()&&r({title:e.trim()})})),ht(`this panel`,t.lines,()=>{let e=n();return e?.kind===`panel`?e.lines:null},e=>r({lines:e}))]}function Ct(e,t,n){let r=ut(t,n),i=e.map((e,t)=>{let n=a(`div`,`wb-inspect-row wb-inspect-legend-row`),i=t+1;return n.append(N(`legend-${t}-tone`,rt,e.tone,e=>{let n=tt.find(t=>t===e);n&&r.edit(t,e=>({...e,tone:n}))},`Legend entry ${i} tone`),M(`legend-${t}-label`,e.label,qe,e=>{e.trim()&&r.edit(t,t=>({...t,label:e.trim()}))},`Legend entry ${i} label`),P(`legend-${t}-dashed`,`dashed`,e.dashed,e=>r.edit(t,t=>({...t,dashed:e}))),P(`legend-${t}-back`,`returns`,e.back,e=>r.edit(t,t=>({...t,back:e}))),F(`legend-${t}-remove`,`remove`,()=>r.remove(t),`Remove legend entry ${e.label}`)),n}),o=F(`legend-add`,`add entry`,()=>r.append(()=>({tone:`plain`,dashed:!1,back:!1,label:`meaning`})));return o.disabled=e.length>=Ge,lt(`Legend`,i,o)}function wt(e,t){return[A(`Note`),j(`Ref`,ft(`ref`,e.ref,e=>t({ref:e}),`Ref`)),a(`p`,`wb-inspect-hint`,`Edit a note from its box.`)]}function Tt(e,n,r){return[A(`Unit`),j(`Status`,N(`unit-status`,ot,e.status,e=>{let n=t.find(t=>t===e);n&&r({status:n})})),pt(`this unit`,e.refs,()=>{let e=n();return e?.kind===`unit`?e.refs:null},e=>r({refs:e})),a(`p`,`wb-inspect-hint`,`Agents edit units with glimmervoid whiteboard plan.`)]}function Et(t,n,r,i,a){let o=[{value:``,text:`none`},...i];return[A(`Board`),F(`board-settings-close`,`close`,a,`Close board settings`),j(`Title`,M(`board-title`,t.title,e.title,e=>{e.trim()&&r([{op:`board`,title:e.trim()}])})),j(`Caption`,M(`board-caption`,t.caption??``,Ye,e=>r([{op:`board`,caption:e.trim()||null}]))),j(`Code session`,N(`board-code-session`,o,t.codeSessionId??``,e=>r([{op:`board`,codeSessionId:e||null}]))),Ct(t.legend,()=>n()?.legend??null,e=>r([{op:`board`,legend:e}]))]}function Dt(e,t,n,r,i){let a=e=>i([{op:`set`,id:t.id,fields:e}]),o=()=>n()?.elements[t.id];switch(t.kind){case`box`:return yt(e,t,o,r,a);case`wire`:return bt(e,t,a);case`frame`:return xt(t,a);case`panel`:return St(t,o,a);case`note`:return wt(t,a);case`unit`:return Tt(t,o,a)}}function Ot(e,t,n){let r=_e(t);if(r.length===0)return[];let i=e.codeSessionId!==null,o=r.map((e,t)=>{let r=a(`div`,`wb-inspect-row wb-inspect-review-row`),o=F(`review-${t}`,`open in review`,()=>n(e),`Open ${e} in review`);return o.disabled=!i,r.append(a(`code`,`wb-inspect-ref`,e),o),r}),s=i?[]:[a(`p`,`wb-inspect-hint`,`Set the board code session to open refs in review.`)];return[A(`In review`),...o,...s]}function kt(e,t,n){let r=a(`div`,`wb-inspect-review`);return r.append(...Ot(e,t,n)),r}function At(e){let t=document.activeElement;return e.contains(t)&&t instanceof HTMLInputElement&&t.type===`text`}function jt(e){let{container:t}=e;t.setAttribute(`aria-label`,`Properties`);let n=t=>void e.sendOps(t),r=new Set,i=!1,a=!1;function o(e,t){if(t.size!==1)return;let[n]=t;return n===void 0?void 0:e.elements[n]}function s(n,r){let i=o(n,r),a=t.querySelector(`.wb-inspect-review`);i&&a&&a.replaceChildren(...Ot(n,i,e.openRef))}function c(t,r){if(r.size>1)return[A(`${r.size} selected`)];let i=o(t,r);return i?[...Dt(t,i,e.currentBoard,e.layout(),n),kt(t,i,e.openRef)]:Et(t,e.currentBoard,n,e.codeSessionChoices(),d)}function l(n){r=n,n.size>0&&(a=!1);let o=e.currentBoard();if(t.hidden=!o||n.size===0&&!a,!o||t.hidden)return;if(At(t)){s(o,n);return}let l=document.activeElement,u=l instanceof HTMLElement&&t.contains(l)?l.dataset.field:void 0;i=!0,t.replaceChildren(...c(o,n)),u&&t.querySelector(`[data-field="${CSS.escape(u)}"]`)?.focus(),i=!1}function u(){a=!0,l(r),t.querySelector(`[data-field="board-caption"]`)?.focus()}function d(){a&&(a=!1,l(r))}return t.addEventListener(`keydown`,e=>{e.key===`Escape`&&a&&(e.preventDefault(),d())}),t.addEventListener(`focusout`,e=>{i||t.hidden||e.relatedTarget instanceof Node&&t.contains(e.relatedTarget)||queueMicrotask(()=>l(r))}),{paint:l,openBoardSettings:u,closeBoardSettings:d}}var Mt=`http://www.w3.org/2000/svg`,I=12,Nt=26,L=20,Pt=18,Ft=17,It=14,Lt=16,Rt=24,zt=18,Bt=`Plan`,Vt=`open linked board`,Ht=5,Ut=17,R=6,Wt=20,Gt=12,Kt=4,qt=3,Jt=7.2,Yt=13,Xt=17,Zt=2.2,Qt=28;function $t(e){return Object.entries(e).flatMap(([e,t])=>t===null?[]:[` ${e}="${m(t)}"`]).join(``)}function z(e,t,n=``){return`<${e}${$t(t)}>${n}</${e}>`}function B(e,t,n,r,i={}){return z(`text`,{x:t,y:n,class:r,...i},m(e))}function V(e,t,n){return z(`g`,{class:`wb-element ${t}`,"data-element-id":e.id,"data-element-kind":e.kind},n.join(``))}function en(e){return e?`stroke:${e}`:null}function tn(e){let t=e.x+e.width,n=e.y+e.headerHeight/2,r=`M${e.x+Gt},${e.y} H${t-Gt} L${t},${n}`;return e.outputs.length===0?`${r} L${t-Gt},${e.y+e.height} H${e.x+Gt} L${e.x},${n} Z`:`${r} V${e.y+e.height} H${e.x} V${n} Z`}function nn(e){return e.outputs.flatMap(t=>{let n=(e.height-e.headerHeight)/e.outputs.length/2,r=t.port.y-n;return[z(`line`,{x1:e.x,y1:r,x2:e.x+e.width,y2:r,class:`wb-output-divider`}),B(t.label,e.x+I,t.port.y+Kt,`wb-output-label`),z(`circle`,{cx:t.port.x,cy:t.port.y,r:qt,class:`wb-output-dot`})]})}function rn(e){return e.style===`code`?`wb-box-line wb-line-code`:e.muted?`wb-box-line wb-muted`:`wb-box-line`}function an(e,t,n,r){let i=t+I+(e.muted?It:0),a=[];return e.style===`code`&&a.push(z(`rect`,{x:i-4,y:r-Yt,width:t+n-I+4-i+4,height:Xt,rx:3,class:`wb-code-band`})),e.style===`item`&&e.isFirstRow&&a.push(z(`circle`,{cx:i+4,cy:r-4,r:Zt,class:`wb-item-dot`})),e.marker!==null&&a.push(B(e.marker,i,r,e.style===`kv`?`wb-line-key`:`wb-line-marker`)),e.text&&a.push(B(e.text,i+e.indentChars*Jt,r,rn(e))),a}function on(e,t,n,r){return e.flatMap((e,i)=>an(e,t,n,r+i*Pt))}function sn(e){let t=[z(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:6,class:`wb-panel-outline`})];e.titleLines.forEach((n,r)=>{t.push(B(n,e.x+I,e.y+Nt+r*L,`wb-box-title`))});let n=e.y+Nt+e.titleLines.length*L;return e.bodyLines.length>0&&t.push(z(`line`,{x1:e.x+I,y1:n-12,x2:e.x+e.width-I,y2:n-12,class:`wb-panel-rule`})),t.push(...on(e.bodyLines,e.x,e.width,n)),V(e,`wb-panel`,t)}function cn(e){return e.shape===`decision`?z(`path`,{d:tn(e),class:`wb-box-outline`,style:en(e.lane?.hex)}):z(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:8,class:`wb-box-outline`,style:en(e.lane?.hex)})}function ln(e){let t=[cn(e),...nn(e)],n=e.x+e.width/2,r=e.y+e.height/2;for(let[i,a]of[[n,e.y],[e.x+e.width,r],[n,e.y+e.height],[e.x,r]])t.push(z(`circle`,{cx:i,cy:a,r:Ht,class:`wb-port`}));e.wasLines.forEach((n,r)=>{t.push(B(n,e.x+I,e.y+Nt+r*L,`wb-box-was`))});let i=e.y+Nt+e.wasLines.length*L;e.titleLines.forEach((n,r)=>{t.push(B(n,e.x+I,i+r*L,`wb-box-title`))});let a=i+e.titleLines.length*L;if(t.push(...on(e.bodyLines,e.x,e.width,a)),e.lane&&e.showsLanePill){let n=e.y+e.headerHeight-28,r=Math.min(e.width-24,16+e.lane.label.length*8);t.push(z(`rect`,{x:e.x+I,y:n,width:r,height:18,rx:9,class:`wb-lane-pill`,style:en(e.lane.hex)}),B(e.lane.label,e.x+I+8,n+13,`wb-lane-pill-text`,{style:`fill:${e.lane.hex}`}))}return V(e,e.change===`none`?`wb-box`:`wb-box wb-change-${e.change}`,t)}function un(e){let t=e.x+e.width-Wt,n=e.y+R+6;return z(`path`,{d:`M ${t+R} ${n} A ${R} ${R} 0 1 1 ${t} ${n-R}`,"marker-end":`url(#wb-arrow)`,class:`wb-loop-badge`})}function dn(e){let t=[z(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:12,class:`wb-frame-outline`}),B(e.title,e.x+14,e.y+18,`wb-frame-title`)];return e.isLoop&&t.push(un(e)),V(e,e.isLoop?`wb-frame wb-loop`:`wb-frame`,t)}function fn(e){let t=[z(`path`,{d:e.path,class:`wb-wire-hit`}),z(`path`,{d:e.path,"marker-end":e.hasArrowhead?`url(#wb-arrow)`:null,class:e.isDashed?`wb-wire-line wb-dashed`:`wb-wire-line`,style:en(e.strokeHex??void 0)}),z(`circle`,{cx:e.start.x,cy:e.start.y,r:3,class:`wb-wire-dot`})];return e.joinAt&&t.push(z(`circle`,{cx:e.joinAt.x,cy:e.joinAt.y,r:3,class:`wb-wire-dot`})),e.label&&t.push(B(e.label,e.labelAt.x,e.labelAt.y,`wb-wire-label`)),V(e,e.isBack?`wb-wire wb-back wb-tone-${e.tone}`:`wb-wire wb-tone-${e.tone}`,t)}function pn(e){let t=[z(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:4,class:`wb-note-card`})];return e.lines.forEach((n,r)=>{t.push(B(n,e.x+10,e.y+22+r*Ft,`wb-note-text`))}),e.byline&&t.push(B(e.byline,e.x+10,e.y+22+e.lines.length*Ft,`wb-note-byline`)),V(e,e.isResolved?`wb-note wb-resolved`:`wb-note`,t)}function mn(e){let t=[z(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:8,class:`wb-unit-outline`}),B(e.label,e.x+I,e.y+Rt,`wb-unit-label`),B(e.status,e.x+e.width-I,e.y+Rt,`wb-unit-status wb-unit-${e.status}`,{"text-anchor":`end`})],n=e.y+Rt+zt;e.titleLines.forEach((r,i)=>{t.push(B(r,e.x+I,n+i*L,`wb-box-title`))});let r=n+e.titleLines.length*L;return t.push(...on(e.bodyLines,e.x,e.width,r)),e.linkedBoardId&&t.push(B(Vt,e.x+I,r+e.bodyLines.length*Pt,`wb-unit-link`,{"data-linked-board-id":e.linkedBoardId})),V(e,`wb-unit`,t)}function hn(e){switch(e.kind){case`box`:return ln(e);case`frame`:return dn(e);case`wire`:return fn(e);case`note`:return pn(e);case`unit`:return mn(e);case`panel`:return sn(e)}}function gn(e){let t=[];if(e.plan){t.push(B(Bt,e.plan.titleAt.x,e.plan.titleAt.y,`wb-column-title`));for(let n of e.plan.arrowPaths)t.push(z(`path`,{d:n,"marker-end":`url(#wb-arrow)`,class:`wb-wire-line`}))}for(let n of e.bands)t.push(z(`line`,{x1:n.x,y1:n.y,x2:n.x+n.width,y2:n.y,class:`wb-band-rule`})),n.label&&t.push(B(n.label,n.x,n.y+Ut,`wb-band-label`,{style:`fill:${n.hex}`}));for(let n of e.columns)n.titleLines.length!==0&&(n.titleLines.forEach((e,r)=>{t.push(B(e,n.x,n.titleBaselineY+r*Lt,`wb-column-title`))}),t.push(z(`line`,{x1:n.x,y1:n.ruleY,x2:n.x+n.width,y2:n.ruleY,class:`wb-column-rule`})));for(let n of e.legend)t.push(vn(n));return e.caption&&t.push(B(e.caption.text,e.caption.x,e.caption.y+16,`wb-caption`)),z(`g`,{class:`wb-chrome`},t.join(``))}function _n(e){let{swatch:t}=e;if(t.kind===`lane`)return z(`rect`,{x:e.x,y:e.y,width:14,height:14,rx:3,class:`wb-legend-swatch`,style:`fill:${t.hex}`});if(t.kind===`change`)return z(`g`,{class:`wb-change-${t.change}`},z(`rect`,{x:e.x,y:e.y,width:Qt,height:14,rx:3,class:`wb-legend-swatch wb-box-outline`}));let n=z(`path`,{d:`M${e.x},${e.y+7} H${e.x+Qt}`,"marker-end":`url(#wb-arrow)`,class:t.isDashed?`wb-wire-line wb-dashed`:`wb-wire-line`});return z(`g`,{class:t.isBack?`wb-back wb-tone-${t.tone}`:`wb-tone-${t.tone}`},n)}function vn(e){let t=e.x+(e.swatch.kind===`lane`?22:40);return _n(e)+B(e.label,t,e.y+12,`wb-legend-text`)}function yn(){return z(`defs`,{},z(`marker`,{id:`wb-arrow`,viewBox:`0 0 10 10`,refX:9,refY:5,markerWidth:8,markerHeight:8,orient:`auto-start-reverse`},z(`path`,{d:`M 0 1 L 10 5 L 0 9 z`,fill:`context-stroke`})))}var bn={worthALookIds:new Set,flaggedUnitIds:new Set},xn=9;function H(e,t=``){let n=document.createElementNS(Mt,e);return t&&n.setAttribute(`class`,t),n}function Sn(e){let t=H(`g`);return t.innerHTML=e,[...t.children]}function Cn(e){let[t]=Sn(e);if(!(t instanceof SVGGElement))throw Error(`the whiteboard markup did not draw a group`);return t}var wn={frame:`frames`,wire:`wires`,box:`boxes`,panel:`boxes`,note:`notes`,unit:`units`},Tn=[`box`,`frame`,`wire`,`note`,`unit`,`panel`];function En(e){let t={frames:H(`g`,`wb-layer`),wires:H(`g`,`wb-layer`),boxes:H(`g`,`wb-layer`),notes:H(`g`,`wb-layer`),units:H(`g`,`wb-layer`)},n=H(`g`);e.replaceChildren(...Sn(yn()),n,t.frames,t.wires,t.boxes,t.notes,t.units);let r=new Map,i=null,a=new Set,o=bn;function s(e,t){t.classList.toggle(`is-selected`,a.has(e))}function c(e){let t=H(`g`,`wb-look-marker`),n=e.x+e.width,r=e.y,i=H(`circle`);i.setAttribute(`cx`,String(n)),i.setAttribute(`cy`,String(r)),i.setAttribute(`r`,String(xn));let a=H(`text`);a.setAttribute(`x`,String(n)),a.setAttribute(`y`,String(r+4)),a.setAttribute(`text-anchor`,`middle`),a.textContent=`!`;let o=H(`title`);return o.textContent=`worth a look in review`,t.append(o,i,a),t}function l(e,t){t.classList.toggle(`is-flagged`,o.flaggedUnitIds.has(e.id));let n=t.querySelector(`:scope > .wb-look-marker`);e.kind===`wire`||!o.worthALookIds.has(e.id)?n?.remove():n||t.append(c(e))}function u(e){let a=x(e),o=Cn(gn(a));n.replaceWith(o),n=o;let c=new Set;for(let e of a.elements){c.add(e.id);let n=S(e),i=r.get(e.id);if(i?.signature===n)continue;let a=Cn(hn(e));s(e.id,a),l(e,a),i&&i.node.replaceWith(a),i||t[wn[e.kind]].append(a),r.set(e.id,{signature:n,node:a})}for(let[e,t]of r)c.has(e)||(t.node.remove(),r.delete(e));return i=a,a}function d(e){if(!(e instanceof Element))return null;let t=e.closest(`.wb-element`),n=t?.dataset.elementId,r=Tn.find(e=>e===t?.dataset.elementKind);return!n||!r?null:{id:n,kind:r}}function f(e){a=e;for(let[e,t]of r)s(e,t.node)}function p(e){o=e;for(let e of i?.elements??[]){let t=r.get(e.id)?.node;t&&l(e,t)}}function m(){for(let e of r.values())e.node.remove();r.clear();let e=H(`g`);n.replaceWith(e),n=e,i=null}return{render:u,layout:()=>i,elementFromTarget:d,nodeOf:e=>r.get(e)?.node??null,setSelection:f,setReviewMarks:p,clear:m}}var Dn=`http://www.w3.org/2000/svg`,On=`No boards yet. Make one here, or have an agent run glimmervoid whiteboard new <title>.`,kn=`Pick a board above.`,An=`wb-board-title-rename`,jn=`M2.5 4h11M2.5 8h11M2.5 12h11`,Mn=`M3 2.5h7l3 3v8H3z M10 2.5v3h3`,Nn=`M13.5 8H3 M7 4L3 8l4 4`,Pn=`M2.5 4.5h11v9h-11z M2.5 4.5v-2h5v2`,Fn=`M6 4.5h7.5 M6 8h7.5 M6 11.5h7.5 M2.5 4.5h0.01 M2.5 8h0.01 M2.5 11.5h0.01`,In=`M2.5 6V2.5H6 M10 2.5h3.5V6 M13.5 10v3.5H10 M6 13.5H2.5V10`,Ln=`M5.5 3.5l-3 3l3 3 M2.5 6.5h7a3.5 3.5 0 0 1 0 7H7`,Rn=`M10.5 3.5l3 3l-3 3 M13.5 6.5h-7a3.5 3.5 0 0 0 0 7H9`,zn=[{tool:`select`,label:`select`,key:`V`,iconPath:`M4 2.5l8.5 5.8l-4 0.7l2.2 4.3l-1.5 0.8l-2.2-4.3L4 12.5z`},{tool:`box`,label:`box`,key:`R`,iconPath:`M2.5 4h11v8h-11z`},{tool:`decision`,label:`decision`,key:`D`,iconPath:`M8 2l6 6l-6 6l-6-6z`},{tool:`panel`,label:`panel`,key:`P`,iconPath:`M2.5 3h11v10h-11z M2.5 6h11`},{tool:`wire`,label:`wire`,key:`A`,iconPath:`M2.5 13.5L13 3 M8.5 3H13v4.5`}],U=null,W=null,G=null,K=null,Bn=null,Vn=!0,q=null,Hn=null,Un=null,J=null,Y=u(`action-status wb-status`),X=u(`action-status wb-status`),Z=new Map,Wn=Promise.resolve();function Gn(e){let{dialog:t,close:n,actions:r,btnCancel:i}=c({title:e.title}),o=a(`input`,`dialog-input`);o.type=`text`,o.placeholder=e.placeholder,o.maxLength=e.maxLength,o.value=e.initialValue??``,o.autocomplete=`off`,o.setAttribute(`aria-label`,e.label);let s=a(`div`,`dialog-error`);s.setAttribute(`role`,`alert`);let l=e.choices?a(`select`,`dialog-input wb-dialog-select`):null;if(l&&e.choices){l.setAttribute(`aria-label`,e.choices.label);for(let t of e.choices.options){let e=a(`option`,null,t.text);e.value=t.value,l.append(e)}}let u=a(`button`,`btn-dialog btn-dialog-confirm`,e.confirmLabel);u.type=`button`,r.append(u),t.append(a(`label`,`dialog-label`,e.label),o,...l?[l]:[],s,r);async function d(){let t=o.value.trim();if(!t){s.textContent=`${e.label} is empty.`;return}u.disabled=!0;let r=await e.onSubmit(t,l?.value??null);u.disabled=!1,r?s.textContent=r:n()}i.addEventListener(`click`,n),u.addEventListener(`click`,()=>void d()),o.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),d())}),requestAnimationFrame(()=>o.focus())}function Q(){return U?_(U):null}function Kn(){return C().find(e=>e.id===U)??null}function qn(e){let t=Wn.then(e);return Wn=t.catch(()=>void 0),t}function Jn(e,t){return qn(()=>Yn(e,t))}async function Yn(e,t){let n=Q(),r=await v(e,t);return r.ok&&n?.id===e&&Z.set(e,Ve(Z.get(e)??Ae,ze(n,t))),r}function Xn(e){return qn(()=>Zn(e))}async function Zn(e){let t=U,n=Q();if(!t||!n)return;let r=He(Z.get(t)??Ae,e);if(!r)return;Z.set(t,r.history);let i=await v(t,r.entry);i.ok?(Y.clear(),Z.set(t,Ue(Z.get(t)??Ae,e,ze(n,r.entry)))):Y.show(`error`,`could not ${e} that change, so it was dropped: ${i.error}`)}async function Qn(e){if(!U||e.length===0)return!1;let t=await Jn(U,e);return t.ok?(Y.clear(),!0):(Y.show(`error`,t.error),!1)}async function $n(e){if(!U)return`No board is open.`;let t=await Jn(U,e);return t.ok?null:t.error}function er(e){let t=f(e);return t?d(t):`closed session`}function tr(){let e=Kn()?.connectedSessionIds??[],t=Q()?.codeSessionId;return(t&&!e.includes(t)?[t,...e]:e).map(e=>({value:e,text:er(e)}))}function nr(e){let t=Q();return[...K?.selectedIds()??new Set].flatMap(e=>t?.elements[e]??[]).filter(t=>t.kind===e)}function rr(){if(!W)return;let e=Q(),t=nr(`box`).length;for(let t of W.toolButtons.values())t.disabled=!e;W.buttons.note.disabled=t!==1,W.buttons.frame.disabled=t===0;for(let t of[W.buttons.unit,W.buttons.fit,W.buttons.undo,W.buttons.redo])t.disabled=!e;Bn?.paint(K?.selectedIds()??new Set)}function ir(){if(!W)return;let e=C();U&&!e.some(e=>e.id===U)&&(U=null),!U&&e[0]&&yr(e[0].id),W.boardMenu.paintBoards(e),lr()}function ar(){return!!W?.boardIsland.querySelector(`.${An}`)}function or(){let t=Kn();if(!W||!t||ar())return;let{boardTitle:n}=W,r=a(`input`,An);r.type=`text`,r.value=t.title,r.maxLength=e.title,r.setAttribute(`aria-label`,`Board title`),n.replaceWith(r),r.focus(),r.select();let i=!1;function o(e){if(i||!t)return;i=!0;let a=r.value.trim();r.replaceWith(n),lr(),e&&a&&a!==t.title&&Qn([{op:`board`,title:a}])}r.addEventListener(`blur`,()=>o(!0)),r.addEventListener(`keydown`,e=>{e.stopPropagation(),(e.key===`Enter`||e.key===`Escape`)&&(e.preventDefault(),o(e.key===`Enter`))})}function sr(e){let t=h(e.title,`visible wb-board-menu-board`);t.setAttribute(`role`,`menuitemradio`),t.setAttribute(`aria-checked`,String(e.id===U));let n=e.connectedSessionIds.length;return n>0&&t.append(a(`span`,`wb-board-menu-count`,String(n))),t.addEventListener(`click`,()=>yr(e.id)),t}function cr(e){let t=a(`div`,`session-overflow wb-board-menu`),n=a(`div`,`popup-menu session-overflow-menu`);n.setAttribute(`role`,`menu`),n.setAttribute(`aria-label`,`Board menu`);let r=()=>n.classList.contains(`open`),i=e=>{l.classList.toggle(`visible`,!Nr()),n.classList.toggle(`open`,e),o.setAttribute(`aria-expanded`,String(e))},o=$(`board menu`,jn,()=>i(!r()));o.setAttribute(`aria-haspopup`,`menu`),o.setAttribute(`aria-expanded`,`false`);let s=(e,t,n=``)=>{let r=h(e,`visible ${n}`.trim());return r.addEventListener(`click`,t),r},c=a(`div`,`menu-divider`);c.setAttribute(`role`,`separator`);let l=s(`board settings`,e),u=[c,s(`new board`,Tr),l,s(`delete board`,wr,`wb-board-menu-danger`)];return n.addEventListener(`click`,e=>{e.target instanceof HTMLElement&&e.target.closest(`[role^="menuitem"]`)&&i(!1)}),t.append(o,n),p({trigger:o,menu:n,menuItems:()=>[...n.querySelectorAll(`.visible[role^="menuitem"]`)],isOpen:r,open:()=>i(!0),close:()=>i(!1)}),document.addEventListener(`click`,e=>{r()&&e.target instanceof Node&&!t.contains(e.target)&&i(!1)}),{menuRoot:t,trigger:o,paintBoards:e=>n.replaceChildren(...e.map(sr),...u)}}function lr(){if(!W)return;let e=Kn(),t=C().length>0;W.canvas.hidden=!e,W.empty.hidden=!!e,W.emptyText.textContent=t?kn:On,e&&(W.boardTitle.textContent=e.title,W.boardMeta.textContent=`v${e.version}`,W.presence.replaceChildren(...e.connectedSessionIds.map(e=>a(`span`,`wb-presence-pill`,er(e)))),e.connectedSessionIds.length===0&&W.presence.append(a(`span`,`wb-presence-none`,`no sessions connected`)),rr(),dr())}function ur(e,t){let n=er(t);if(!e?.connectedSessionIds.includes(t))return`${n} is not connected to this board`;let r=e.queuedBySessionId[t]??0;return r===0?`${n} has read every change`:`${r} board ${r===1?`edit`:`edits`} queued for ${n}`}function dr(){if(!W||!q)return;let e=Kn();W.dockQueued.textContent=ur(e,q),W.sendToAgent.disabled=!e?.connectedSessionIds.includes(q)}async function fr(){if(!W||!U||!q)return;W.sendToAgent.disabled=!0,X.show(`busy`,`sending`);let e=await ne(U,q);dr(),e.ok?X.show(`ok`,`sent; the agent reads the board when it is ready`):X.show(`error`,e.error)}function pr(e,t){let n=new Set(t);return new Set(Object.values(e.elements).filter(e=>_e(e).some(e=>n.has(ve(e)??``))).map(e=>e.id))}function mr(e){let t=Q()?.codeSessionId,n=ve(e);t&&n&&re(t,n)}function hr(e,t){let n=a(`button`,`wb-uncovered-file`,t);return n.type=`button`,n.addEventListener(`click`,()=>re(e,t)),n}function gr(){if(!W||!G)return;let e=Q(),t=e&&Hn?.boardId===e.id?Hn.review:null;G.setReviewMarks({worthALookIds:e&&t?pr(e,t.worthALookPaths):new Set,flaggedUnitIds:new Set(t?.flaggedUnitIds??[])});let n=(e&&Un?.boardId===e.id?`the board review could not be loaded: ${Un.error}`:null)??t?.notChecked??null,r=t?.codeSessionId??null,i=r?t?.uncoveredPaths??[]:[];W.uncovered.hidden=!n&&i.length===0;let o=n?[a(`p`,`wb-uncovered-notice`,`Not checked: ${n}`)]:[],s=r?i.map(e=>hr(r,e)):[];W.uncovered.replaceChildren(a(`h3`,`wb-uncovered-heading`,`Not on the board`),...o,...s)}function _r(e){let t=`${e.id}@${e.version}`;J!==t&&(J=t,de(e.id).then(n=>{J===t&&(n.ok?(Un=null,Hn={boardId:e.id,review:n.review},gr()):(J=null,Un={boardId:e.id,error:n.error},gr()))}))}function vr(){if(!G)return;let e=Q();e?(_r(e),K?.pruneSelection(e),G.render(K?.previewOf(e)??e),gr(),K?.openPendingTitleEdit(),Vn&&=(K?.fit(),!1),rr()):G.clear()}function yr(e){U!==e&&(U=e,Vn=!0,K?.clearSelection(),K?.closeTitleInput(),Bn?.closeBoardSettings(),G?.clear(),Y.clear(),ir(),ue(e).then(vr))}function br(){let t=Q();if(!t)return;let n=C().filter(e=>e.id!==t.id),r=[{value:``,text:`No linked board`},...n.map(e=>({value:e.id,text:e.title}))];Gn({title:`Add a unit`,label:`Unit title`,placeholder:`index the diffs`,maxLength:e.title,confirmLabel:`Add unit`,choices:n.length>0?{label:`Linked board`,options:r}:void 0,onSubmit:(e,t)=>$n([{op:`add`,element:{kind:`unit`,id:T(`unit`),title:e,lines:[],refs:[],status:`planned`,after:[],linkedBoardId:t||null}}])})}function xr(t){Gn({title:`Pin a note`,label:`Note`,placeholder:`what about retries?`,maxLength:e.noteText,confirmLabel:`Pin note`,onSubmit:e=>$n([{op:`add`,element:{kind:`note`,id:T(`note`),on:t,text:e,ref:null,author:``,resolvedBy:null}}])})}function Sr(e,t){let n=Q();n&&e!==t&&(Object.values(n.elements).some(n=>n.kind===`wire`&&n.from===e&&n.to===t)||Qn([{op:`add`,element:{kind:`wire`,id:T(`wire`),from:e,to:t,fromOutput:null,dashed:!1,tone:`plain`,label:null,fromSide:null,toSide:null,back:!1}}]))}function Cr(){let t=nr(`box`).map(e=>e.id);t.length!==0&&Gn({title:`Frame the selected boxes`,label:`Frame title`,placeholder:`intake`,maxLength:e.title,confirmLabel:`Add frame`,onSubmit:async e=>{let n=await $n([{op:`add`,element:{kind:`frame`,id:T(`frame`),title:e,contains:t,loop:!1}}]);return n||K?.clearSelection(),n}})}function wr(){let e=Kn();if(!e)return;let t=e.connectedSessionIds.map(er),n=t.length>0?` ${t.join(`, `)} ${t.length===1?`is`:`are`} connected and will lose it.`:``;o({title:`Delete board`,message:`Delete "${e.title}" for good?${n}`,confirmLabel:`Delete board`,danger:!0,onConfirm:()=>{le(e.id).then(e=>{e.ok||Y.show(`error`,e.error)})}})}function Tr(){Gn({title:`New board`,label:`Board title`,placeholder:`knowledge writer`,maxLength:e.title,confirmLabel:`Create board`,onSubmit:async e=>{let t=await ae(e);return t.ok?(yr(t.boardId),null):t.error}})}function Er(e,t){let n=a(`button`,`wb-button`,e);return n.type=`button`,n.addEventListener(`click`,t),n}function $(e,t,n,r){let i=a(`button`,`wb-icon-button`);if(i.type=`button`,i.setAttribute(`aria-label`,e),i.title=r?`${e} (${r})`:e,i.append(l(t,`1.5`)),r){let e=a(`span`,`wb-tool-key`,r);e.setAttribute(`aria-hidden`,`true`),i.append(e),i.setAttribute(`aria-keyshortcuts`,r)}return i.addEventListener(`click`,n),i}function Dr(e,t,n,r){let i=$(t,r,()=>{K?.setTool(e),K?.focusCanvas()},n);return i.classList.add(`wb-tool`),i.setAttribute(`aria-pressed`,String(e===`select`)),i}function Or(e,t,...n){let r=a(`div`,`wb-island ${e}`);return r.setAttribute(`role`,`toolbar`),r.setAttribute(`aria-label`,t),r.append(...n),r}function kr(e){for(let[t,n]of W?.toolButtons??[])n.setAttribute(`aria-pressed`,String(t===e))}function Ar(e){return!(e.metaKey||e.ctrlKey)||e.altKey||e.code!==`KeyZ`?null:e.shiftKey?`redo`:`undo`}function jr(e,t){let n=Ar(t);n&&e.checkVisibility()&&!s()&&!i(t)&&(document.activeElement?.classList.contains(`xterm-helper-textarea`)||(t.preventDefault(),Xn(n)))}function Mr(e){let t=cr(()=>{K?.clearSelection(),Bn?.openBoardSettings()});t.trigger.dataset.phoneVisible=``;let n=a(`button`,`wb-board-title`);n.type=`button`,n.title=`Click to rename`,n.addEventListener(`click`,or);let r=a(`span`,`wb-board-meta`),i=a(`div`,`wb-presence`),o=Or(`wb-island-board`,`Board`,t.menuRoot,n,r,i,Y.element),s=new Map(zn.map(({tool:e,label:t,key:n,iconPath:r})=>[e,Dr(e,t,n,r)])),c=a(`div`,`wb-tools`);c.setAttribute(`role`,`group`),c.setAttribute(`aria-label`,`Drawing tools`),c.append(...s.values());let l={note:$(`note`,Mn,()=>{let[e]=nr(`box`);e&&xr(e.id)}),frame:$(`frame`,Pn,Cr),unit:$(`unit`,Fn,br),fit:$(`fit`,In,()=>K?.fit()),undo:$(`undo`,Ln,()=>void Xn(`undo`)),redo:$(`redo`,Rn,()=>void Xn(`redo`))};l.fit.dataset.phoneVisible=``;let u=Or(`wb-island-tools`,`Board tools`,c,l.note,l.frame,l.unit),d=Or(`wb-island-view`,`View`,l.fit,l.undo,l.redo),f=a(`div`,`wb-canvas`),p=document.createElementNS(Dn,`svg`);p.setAttribute(`class`,`wb-svg`),p.setAttribute(`role`,`img`),p.setAttribute(`aria-label`,`Whiteboard`),p.setAttribute(`preserveAspectRatio`,`xMidYMin meet`);let m=a(`aside`,`wb-inspect`),h=a(`aside`,`wb-uncovered`);h.setAttribute(`aria-label`,`Not on the board`),h.hidden=!0;let ee=a(`span`,`wb-dock-queued`),te=$(`send to agent`,Nn,()=>void fr()),_=Or(`wb-island-agent`,`Docked session`,te,ee,X.element);_.hidden=!0;let v=a(`div`,`wb-bottom-left`);v.append(h,_,d),f.append(p,m,o,v,u);let y=a(`p`,`wb-empty-text`,On),b=a(`div`,`wb-empty`);b.append(y,Er(`new board`,Tr));let x=a(`div`,`wb-dock`);x.hidden=!0,e.replaceChildren(f,b,x),W={boardIsland:o,boardMenu:t,boardTitle:n,boardMeta:r,presence:i,canvas:f,empty:b,emptyText:y,dock:x,agentIsland:_,dockQueued:ee,sendToAgent:te,buttons:l,toolButtons:s,uncovered:h};let S=En(p);G=S,Bn=jt({container:m,currentBoard:Q,layout:()=>S.layout(),sendOps:Qn,codeSessionChoices:tr,openRef:mr}),K=ke({svg:p,canvas:f,renderer:S,currentBoard:Q,sendOps:Qn,onSelectionChange:rr,onPhoneTapBox:xr,onOpenLinkedBoard:yr,onConnectBoxes:Sr,onToolChange:kr}),document.addEventListener(`keydown`,t=>jr(e,t)),oe(ir),g(e=>{e===U&&vr()}),ir()}function Nr(){return document.documentElement.dataset.layout===`phone`}function Pr(){q&&ee()===q&&y(),q=null,W&&(W.dock.hidden=!0,W.agentIsland.hidden=!0)}function Fr(e){if(!W||Nr())return;let t=f(e);t&&(q=e,W.dock.hidden=!1,W.agentIsland.hidden=!1,X.clear(),dr(),te(t,e,W.dock,{className:`wb-docked-card`}),ce(t,e,!0))}function Ir(){let e=b();e&&(yr(e.boardId),e.dockSessionId&&Fr(e.dockSessionId)),ir(),J=null,U&&ue(U).then(vr)}var Lr={mount:Mr,refresh:Ir,deactivate:Pr};export{Lr as view};
|
|
Binary file
|