glimmervoid 0.52.2-next.676 → 0.52.2-next.677
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 +19 -14
- package/dist/chunks/{adapters-D3Jz5ubD.js → adapters-Cc8ALffl.js} +6 -6
- package/dist/chunks/{adapters-BR9uXgFY.js → adapters-DjtWvxmJ.js} +1 -1
- package/dist/chunks/{agent-api-cli-CdspB0dx.js → agent-api-cli-7xxfflVL.js} +3 -3
- package/dist/chunks/agent-api-cli-ivGOfIyv.js +1 -0
- package/dist/chunks/{agent-api-core-BVqCeZzP.js → agent-api-core-BxJOL6Ye.js} +27 -2
- package/dist/chunks/{agent-setup-cli-D5_viu2B.js → agent-setup-cli-DWGQIduP.js} +1 -1
- package/dist/chunks/{config-62c4QXQt.js → config-C43Ovt64.js} +5 -1
- package/dist/chunks/config-store-BopqXIii.js +1 -0
- package/dist/chunks/{config-store-3MDjeSxI.js → config-store-Bqag5_2n.js} +50 -14
- package/dist/chunks/{grok-9XjPCcq0.js → grok-CstIMQXr.js} +1 -1
- package/dist/chunks/kimi-DgpeyWvz.js +1 -0
- package/dist/chunks/{kimi-BcpjSEBw.js → kimi-DjNUuBkC.js} +2 -2
- package/dist/chunks/{main-15MNtLEZ.js → main-mQr6p3Ev.js} +203 -32
- package/dist/chunks/{pair-cli-DX6XERYG.js → pair-cli-rFzuZV0h.js} +2 -2
- package/dist/chunks/{pr-flows-cli-BCB9p1ex.js → pr-flows-cli-Bdt0p04k.js} +117 -4
- package/dist/chunks/{pr-flows-external-CgzY34kz.js → pr-flows-external-CbLPEQzZ.js} +470 -30
- package/dist/chunks/{remote-config-DuHGnyrW.js → remote-config-C3nVcK84.js} +1 -1
- package/dist/chunks/{session-d-TA-Vaa.js → session-D0gNPAv6.js} +102 -7
- package/dist/chunks/{settings-cli-DlsLA8Zz.js → settings-cli-Bp7SFXNh.js} +5 -5
- package/dist/chunks/{settings-readout-core-CdqNElBs.js → settings-readout-core-DhpeT094.js} +2 -2
- package/dist/chunks/{shown-files-core-DKEbS44S.js → shown-files-core-DJ4Uu8g4.js} +1 -1
- package/dist/chunks/{spawn-env-BEQeEK4h.js → spawn-env-gxqKNJaO.js} +1 -1
- package/dist/chunks/{ssh-sign-cli-CgDEJU9V.js → ssh-sign-cli-B8sdxV3y.js} +2 -2
- package/dist/client/assets/{action-status-DXlvWNQ7.js → action-status-B0E-UYey.js} +1 -1
- package/dist/client/assets/action-status-B0E-UYey.js.br +0 -0
- package/dist/client/assets/{benchmark-panel-Dt3vGyms.js → benchmark-panel-Dzhmjdmr.js} +1 -1
- package/dist/client/assets/benchmark-panel-Dzhmjdmr.js.br +0 -0
- package/dist/client/assets/{boards-view-BeZKxEeC.js → boards-view-Cz0vbt34.js} +1 -1
- package/dist/client/assets/boards-view-Cz0vbt34.js.br +0 -0
- package/dist/client/assets/button-Cnom-MQM.js +1 -0
- package/dist/client/assets/button-Cnom-MQM.js.br +0 -0
- package/dist/client/assets/{card-actions-xWiBLo91.js → card-actions-unth0mGA.js} +1 -1
- package/dist/client/assets/{card-registry-D1vs5tMh.js → card-registry-W9ss4JHS.js} +1 -1
- package/dist/client/assets/card-registry-W9ss4JHS.js.br +0 -0
- package/dist/client/assets/{community-panel-Cs7qRZIs.js → community-panel-BlEfUgu7.js} +1 -1
- package/dist/client/assets/community-panel-BlEfUgu7.js.br +0 -0
- package/dist/client/assets/{control-ws-XKBNUN2v.js → control-ws-t9cKDDGy.js} +1 -1
- package/dist/client/assets/control-ws-t9cKDDGy.js.br +0 -0
- package/dist/client/assets/{dialogs-i4MvWfcJ.js → dialogs-CvazD02b.js} +1 -1
- package/dist/client/assets/dialogs-CvazD02b.js.br +0 -0
- package/dist/client/assets/{doc-editor-ui-CRHea59O.js → doc-editor-ui-7FVQ5FEn.js} +1 -1
- package/dist/client/assets/doc-editor-ui-7FVQ5FEn.js.br +0 -0
- package/dist/client/assets/{feature-hint-BUbxqM6i.js → feature-hint-BuFmpFSY.js} +1 -1
- package/dist/client/assets/feature-hint-BuFmpFSY.js.br +0 -0
- package/dist/client/assets/{first-run-checklist-CmyO-Hst.js → first-run-checklist-CnlRPXrW.js} +1 -1
- package/dist/client/assets/first-run-checklist-CnlRPXrW.js.br +0 -0
- package/dist/client/assets/{hooks-panel-CG3S0SRu.js → hooks-panel-CHcww_jI.js} +1 -1
- package/dist/client/assets/hooks-panel-CHcww_jI.js.br +0 -0
- package/dist/client/assets/{index-Q9jU5kU4.js → index-CiJEE2GW.js} +24 -24
- package/dist/client/assets/index-CiJEE2GW.js.br +0 -0
- package/dist/client/assets/{issues-panel-DMIurtjb.js → issues-panel-C-WU_OpW.js} +1 -1
- package/dist/client/assets/issues-panel-C-WU_OpW.js.br +0 -0
- package/dist/client/assets/{lane-read-token-step-CoeCjZG1.js → lane-read-token-step-Bl2wOyl9.js} +6 -6
- package/dist/client/assets/lane-read-token-step-Bl2wOyl9.js.br +0 -0
- package/dist/client/assets/{menu-D9GiYN6D.js → menu-DK4rQWp6.js} +1 -1
- package/dist/client/assets/menu-DK4rQWp6.js.br +0 -0
- package/dist/client/assets/{modal-B1bP8CnK.js → modal-C-Lb5-jJ.js} +1 -1
- package/dist/client/assets/modal-C-Lb5-jJ.js.br +0 -0
- package/dist/client/assets/my-prs-panel-rsZ0yjXe.js +1 -0
- package/dist/client/assets/my-prs-panel-rsZ0yjXe.js.br +0 -0
- package/dist/client/assets/{nyan-cat-BJJIa95f.js → nyan-cat-DzIDMDM4.js} +1 -1
- package/dist/client/assets/nyan-cat-DzIDMDM4.js.br +0 -0
- package/dist/client/assets/{phone-shell-CAEfiwKo.js → phone-shell-BjFYeULh.js} +1 -1
- package/dist/client/assets/phone-shell-BjFYeULh.js.br +0 -0
- package/dist/client/assets/{plan-face-CosMfmeH.js → plan-face-ttBdxmdT.js} +1 -1
- package/dist/client/assets/plan-face-ttBdxmdT.js.br +0 -0
- package/dist/client/assets/{plan-render-COb_RToy.js → plan-render-DcEs6x-w.js} +1 -1
- package/dist/client/assets/plan-render-DcEs6x-w.js.br +0 -0
- package/dist/client/assets/{pr-queue-columns-Cvq0YbUw.js → pr-queue-columns-Dno6qOMY.js} +1 -1
- package/dist/client/assets/pr-queue-columns-Dno6qOMY.js.br +10 -0
- package/dist/client/assets/{pr-status-icon-BPdB3x-u.js → pr-status-icon-D1RIxNiH.js} +1 -1
- package/dist/client/assets/pr-status-icon-D1RIxNiH.js.br +0 -0
- package/dist/client/assets/{radar-panel-DplX3jhC.js → radar-panel-BaC23VCe.js} +1 -1
- package/dist/client/assets/radar-panel-BaC23VCe.js.br +0 -0
- package/dist/client/assets/{repo-roots-adder-BIUsOw3v.js → repo-roots-adder-DcY8QZax.js} +1 -1
- package/dist/client/assets/repo-roots-adder-DcY8QZax.js.br +0 -0
- package/dist/client/assets/{resume-dialog-1NN1elB8.js → resume-dialog-CvC8QV7Y.js} +1 -1
- package/dist/client/assets/resume-dialog-CvC8QV7Y.js.br +0 -0
- package/dist/client/assets/{review-queue-panel-DIr1VGtt.js → review-queue-panel-CNKVV6RH.js} +1 -1
- package/dist/client/assets/review-queue-panel-CNKVV6RH.js.br +0 -0
- package/dist/client/assets/{session-actions-D9RGL-qn.js → session-actions-HPImbYVb.js} +2 -2
- package/dist/client/assets/session-actions-HPImbYVb.js.br +0 -0
- package/dist/client/assets/{session-row-C8fi8nZv.js → session-row-CNI0g3fQ.js} +1 -1
- package/dist/client/assets/session-row-CNI0g3fQ.js.br +0 -0
- package/dist/client/assets/{session-tick-COTMmIoE.js → session-tick-CY_ByGke.js} +1 -1
- package/dist/client/assets/session-tick-CY_ByGke.js.br +0 -0
- package/dist/client/assets/settings-panel-BvXNdZZu.js +4 -0
- package/dist/client/assets/settings-panel-BvXNdZZu.js.br +0 -0
- package/dist/client/assets/{setup-step-C7wDcLSD.js → setup-step-DTtM5S-5.js} +1 -1
- package/dist/client/assets/setup-step-DTtM5S-5.js.br +0 -0
- package/dist/client/assets/{shown-face-B55zt8_T.js → shown-face-DD4AnY8c.js} +1 -1
- package/dist/client/assets/shown-face-DD4AnY8c.js.br +0 -0
- package/dist/client/assets/{trace-panel-BrUZR4UO.js → trace-panel-BfPys80r.js} +1 -1
- package/dist/client/assets/trace-panel-BfPys80r.js.br +0 -0
- package/dist/client/assets/{usage-panel-CVPMCuPf.js → usage-panel-Dt93pqYo.js} +1 -1
- package/dist/client/assets/usage-panel-Dt93pqYo.js.br +0 -0
- package/dist/client/assets/{your-day-tip-CjQ6fqIw.js → your-day-tip-CUTVfQI4.js} +1 -1
- package/dist/client/assets/your-day-tip-CUTVfQI4.js.br +0 -0
- package/dist/client/index.html +12 -12
- package/dist/client/index.html.br +0 -0
- package/dist/schema/pr-pack.v1.json +272 -0
- package/dist/server/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/agent-api-cli-BowH6sQb.js +0 -1
- package/dist/chunks/config-store-B8yJlCWU.js +0 -1
- package/dist/chunks/kimi-C_c8wPl5.js +0 -1
- package/dist/client/assets/action-status-DXlvWNQ7.js.br +0 -0
- package/dist/client/assets/benchmark-panel-Dt3vGyms.js.br +0 -0
- package/dist/client/assets/boards-view-BeZKxEeC.js.br +0 -0
- package/dist/client/assets/button-DyD4Mzjw.js +0 -1
- package/dist/client/assets/button-DyD4Mzjw.js.br +0 -0
- package/dist/client/assets/card-registry-D1vs5tMh.js.br +0 -0
- package/dist/client/assets/community-panel-Cs7qRZIs.js.br +0 -0
- package/dist/client/assets/control-ws-XKBNUN2v.js.br +0 -0
- package/dist/client/assets/dialogs-i4MvWfcJ.js.br +0 -0
- package/dist/client/assets/doc-editor-ui-CRHea59O.js.br +0 -0
- package/dist/client/assets/feature-hint-BUbxqM6i.js.br +0 -0
- package/dist/client/assets/first-run-checklist-CmyO-Hst.js.br +0 -0
- package/dist/client/assets/hooks-panel-CG3S0SRu.js.br +0 -0
- package/dist/client/assets/index-Q9jU5kU4.js.br +0 -0
- package/dist/client/assets/issues-panel-DMIurtjb.js.br +0 -0
- package/dist/client/assets/lane-read-token-step-CoeCjZG1.js.br +0 -0
- package/dist/client/assets/menu-D9GiYN6D.js.br +0 -0
- package/dist/client/assets/modal-B1bP8CnK.js.br +0 -0
- package/dist/client/assets/my-prs-panel-BlzzWsq0.js +0 -1
- package/dist/client/assets/my-prs-panel-BlzzWsq0.js.br +0 -0
- package/dist/client/assets/nyan-cat-BJJIa95f.js.br +0 -0
- package/dist/client/assets/phone-shell-CAEfiwKo.js.br +0 -0
- package/dist/client/assets/plan-face-CosMfmeH.js.br +0 -0
- package/dist/client/assets/plan-render-COb_RToy.js.br +0 -0
- package/dist/client/assets/pr-queue-columns-Cvq0YbUw.js.br +0 -0
- package/dist/client/assets/pr-status-icon-BPdB3x-u.js.br +0 -0
- package/dist/client/assets/radar-panel-DplX3jhC.js.br +0 -0
- package/dist/client/assets/repo-roots-adder-BIUsOw3v.js.br +0 -0
- package/dist/client/assets/resume-dialog-1NN1elB8.js.br +0 -0
- package/dist/client/assets/review-queue-panel-DIr1VGtt.js.br +0 -0
- package/dist/client/assets/session-actions-D9RGL-qn.js.br +0 -0
- package/dist/client/assets/session-row-C8fi8nZv.js.br +0 -0
- package/dist/client/assets/session-tick-COTMmIoE.js.br +0 -0
- package/dist/client/assets/settings-panel-bZNhVPcC.js +0 -4
- package/dist/client/assets/settings-panel-bZNhVPcC.js.br +0 -0
- package/dist/client/assets/setup-step-C7wDcLSD.js.br +0 -0
- package/dist/client/assets/shown-face-B55zt8_T.js.br +0 -0
- package/dist/client/assets/trace-panel-BrUZR4UO.js.br +0 -0
- package/dist/client/assets/usage-panel-CVPMCuPf.js.br +0 -0
- package/dist/client/assets/your-day-tip-CjQ6fqIw.js.br +0 -0
|
@@ -120,8 +120,9 @@ var PrFlowItem = z.strictObject({
|
|
|
120
120
|
url: z.url().nullable()
|
|
121
121
|
});
|
|
122
122
|
var PR_FLOW_ID = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
123
|
+
var PR_FLOW_QUALIFIED_ID = /^(?:[a-z0-9][a-z0-9-]{0,39}\/)?[a-z0-9][a-z0-9-]{0,63}$/;
|
|
123
124
|
var ONE_PRINTABLE_LINE = /^[^\u0000-\u001f\u007f-\u009f]+$/;
|
|
124
|
-
var PrFlowRunActionRef = z.templateLiteral(["run:", z.string().regex(
|
|
125
|
+
var PrFlowRunActionRef = z.templateLiteral(["run:", z.string().regex(PR_FLOW_QUALIFIED_ID)]);
|
|
125
126
|
var PrFlowDisposition = z.union([z.enum(["dismiss", "fix-local"]), PrFlowRunActionRef]);
|
|
126
127
|
var PrFlowActionRef = z.union([z.enum([
|
|
127
128
|
"ask",
|
|
@@ -145,12 +146,26 @@ var PrFlowRule = z.strictObject({
|
|
|
145
146
|
message: "a dismiss rule needs a reason",
|
|
146
147
|
path: ["reason"]
|
|
147
148
|
});
|
|
149
|
+
function prFlowRulesJsonSchema(rulesSchema) {
|
|
150
|
+
return z.toJSONSchema(rulesSchema, {
|
|
151
|
+
io: "input",
|
|
152
|
+
override: ({ zodSchema, jsonSchema }) => {
|
|
153
|
+
if (zodSchema !== PrFlowRule) return;
|
|
154
|
+
Object.assign(jsonSchema, Object.fromEntries([["if", {
|
|
155
|
+
properties: { action: { const: "dismiss" } },
|
|
156
|
+
required: ["action"]
|
|
157
|
+
}], ["then", { required: ["reason"] }]]));
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
148
161
|
var PrFlowCommand = z.strictObject({
|
|
149
162
|
id: z.string().regex(PR_FLOW_ID, { error: "an id is lowercase letters, digits and dashes" }),
|
|
150
163
|
label: z.string().trim().min(1).max(24),
|
|
151
164
|
command: z.array(z.string().min(1)).min(1, { error: "a command needs at least the program to run" }),
|
|
152
165
|
timeoutSeconds: z.number().int().positive().max(3600).default(120)
|
|
153
166
|
});
|
|
167
|
+
var RepositoryName = z.string().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/, { error: "a repository is owner/name" });
|
|
168
|
+
var PrFlowPrAction = PrFlowCommand.extend({ repos: z.array(RepositoryName).min(1).optional() });
|
|
154
169
|
var PrFlowSourceFinding = z.strictObject({
|
|
155
170
|
path: z.string().min(1).max(500).regex(ONE_PRINTABLE_LINE, { error: "a finding path must be one line with no control characters" }),
|
|
156
171
|
lineStart: z.number().int().positive().nullable(),
|
|
@@ -183,8 +198,10 @@ var ReportedPrFlowActionOutcome = z.looseObject({
|
|
|
183
198
|
var PrFlowsSettings = z.looseObject({
|
|
184
199
|
sources: z.array(z.unknown(), { error: "prFlows.sources must be an array" }).optional(),
|
|
185
200
|
actions: z.array(z.unknown(), { error: "prFlows.actions must be an array" }).optional(),
|
|
201
|
+
prActions: z.array(z.unknown(), { error: "prFlows.prActions must be an array" }).optional(),
|
|
186
202
|
rules: z.array(z.unknown(), { error: "prFlows.rules must be an array" }).optional(),
|
|
187
|
-
repoRules: z.record(z.string(), z.unknown(), { error: "prFlows.repoRules must be an object of repository names" }).optional()
|
|
203
|
+
repoRules: z.record(z.string(), z.unknown(), { error: "prFlows.repoRules must be an object of repository names" }).optional(),
|
|
204
|
+
packs: z.array(z.string().min(1), { error: "prFlows.packs must be an array of pack directory paths" }).optional()
|
|
188
205
|
});
|
|
189
206
|
var PrFlowHandled = z.strictObject({
|
|
190
207
|
itemKey: z.string().min(1),
|
|
@@ -197,6 +214,25 @@ var PrFlowHandled = z.strictObject({
|
|
|
197
214
|
threadIds: z.array(z.string().min(1)),
|
|
198
215
|
actionLabel: z.string().optional()
|
|
199
216
|
});
|
|
217
|
+
var PrActionRunState = z.enum([
|
|
218
|
+
"running",
|
|
219
|
+
"started",
|
|
220
|
+
"done",
|
|
221
|
+
"failed",
|
|
222
|
+
"refused",
|
|
223
|
+
"interrupted"
|
|
224
|
+
]);
|
|
225
|
+
var PrActionRunRecord = z.strictObject({
|
|
226
|
+
runId: z.string().min(1),
|
|
227
|
+
actionId: z.string().min(1),
|
|
228
|
+
label: z.string(),
|
|
229
|
+
head: z.string(),
|
|
230
|
+
startedAt: z.number().finite(),
|
|
231
|
+
finishedAt: z.number().finite().nullable(),
|
|
232
|
+
state: PrActionRunState,
|
|
233
|
+
message: z.string(),
|
|
234
|
+
reportToken: z.string().min(1).nullable()
|
|
235
|
+
});
|
|
200
236
|
var PrFlowsState = z.strictObject({
|
|
201
237
|
handledByPr: z.record(z.string(), z.array(PrFlowHandled)),
|
|
202
238
|
reopenedByPr: z.record(z.string(), z.array(z.string().min(1))),
|
|
@@ -205,15 +241,44 @@ var PrFlowsState = z.strictObject({
|
|
|
205
241
|
itemKey: z.string().min(1),
|
|
206
242
|
actionId: z.string().min(1),
|
|
207
243
|
head: z.string()
|
|
208
|
-
}))).default({})
|
|
244
|
+
}))).default({}),
|
|
245
|
+
prActionRunByPr: z.record(z.string(), z.record(z.string(), PrActionRunRecord)).default({})
|
|
246
|
+
});
|
|
247
|
+
var PrFlowPackRequires = z.strictObject({
|
|
248
|
+
env: z.array(z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/, { error: "an env var name is letters, digits and underscores" })).default([]),
|
|
249
|
+
programs: z.array(z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._+-]*$/, { error: "a program is a bare name found on PATH, such as gh" })).default([])
|
|
250
|
+
});
|
|
251
|
+
var PrFlowPackApprovalCommand = z.strictObject({
|
|
252
|
+
kind: z.enum([
|
|
253
|
+
"source",
|
|
254
|
+
"action",
|
|
255
|
+
"pr-action"
|
|
256
|
+
]),
|
|
257
|
+
id: z.string(),
|
|
258
|
+
label: z.string(),
|
|
259
|
+
command: z.array(z.string()),
|
|
260
|
+
repos: z.array(z.string()).optional()
|
|
209
261
|
});
|
|
210
262
|
var PrFlowPendingApproval = z.strictObject({
|
|
211
|
-
kind: z.enum([
|
|
263
|
+
kind: z.enum([
|
|
264
|
+
"source",
|
|
265
|
+
"action",
|
|
266
|
+
"pr-action",
|
|
267
|
+
"pack"
|
|
268
|
+
]),
|
|
212
269
|
id: z.string(),
|
|
213
270
|
label: z.string(),
|
|
214
271
|
command: z.array(z.string()),
|
|
215
272
|
timeoutSeconds: z.number(),
|
|
216
|
-
fingerprint: z.string().min(1)
|
|
273
|
+
fingerprint: z.string().min(1),
|
|
274
|
+
repos: z.array(z.string()).optional(),
|
|
275
|
+
pack: z.strictObject({
|
|
276
|
+
version: z.number(),
|
|
277
|
+
requires: PrFlowPackRequires,
|
|
278
|
+
missing: z.array(z.string()),
|
|
279
|
+
commands: z.array(PrFlowPackApprovalCommand),
|
|
280
|
+
rules: z.array(z.string())
|
|
281
|
+
}).optional()
|
|
217
282
|
});
|
|
218
283
|
var PrFlowSourceRunStatus = z.strictObject({
|
|
219
284
|
label: z.string(),
|
|
@@ -231,6 +296,12 @@ var PrFlowActionChoice = z.strictObject({
|
|
|
231
296
|
id: z.string(),
|
|
232
297
|
label: z.string()
|
|
233
298
|
});
|
|
299
|
+
var PrActionRunView = z.strictObject({
|
|
300
|
+
actionId: z.string(),
|
|
301
|
+
label: z.string(),
|
|
302
|
+
state: PrActionRunState,
|
|
303
|
+
message: z.string()
|
|
304
|
+
});
|
|
234
305
|
var PrFlowsStatus = z.looseObject({
|
|
235
306
|
type: z.literal("pr-flows-status"),
|
|
236
307
|
handledByPr: PrFlowsState.shape.handledByPr,
|
|
@@ -239,9 +310,33 @@ var PrFlowsStatus = z.looseObject({
|
|
|
239
310
|
sourceRunsByPr: z.record(z.string(), z.array(PrFlowSourceRunStatus)).default({}),
|
|
240
311
|
reviewItemsByPr: z.record(z.string(), z.array(PrFlowItem)).default({}),
|
|
241
312
|
actions: z.array(PrFlowActionChoice).default([]),
|
|
242
|
-
actionRunsByPr: z.record(z.string(), z.array(PrFlowActionRunStatus)).default({})
|
|
313
|
+
actionRunsByPr: z.record(z.string(), z.array(PrFlowActionRunStatus)).default({}),
|
|
314
|
+
prActionsByPr: z.record(z.string(), z.array(PrFlowActionChoice)).default({}),
|
|
315
|
+
prActionRunsByPr: z.record(z.string(), z.array(PrActionRunView)).default({})
|
|
243
316
|
});
|
|
244
317
|
var PrFlowApproveRequest = z.strictObject({ fingerprint: z.string().min(1).max(128) });
|
|
318
|
+
var PrActionRunRequest = z.strictObject({
|
|
319
|
+
repo: RepositoryName,
|
|
320
|
+
number: z.number().int().positive(),
|
|
321
|
+
actionId: z.string().regex(PR_FLOW_QUALIFIED_ID),
|
|
322
|
+
head: z.string().min(1).max(64)
|
|
323
|
+
});
|
|
324
|
+
var PR_ACTION_REPORT_URL_ENV = "GLIMMERVOID_PR_ACTION_REPORT_URL";
|
|
325
|
+
var PR_ACTION_TOKEN_ENV = "GLIMMERVOID_PR_ACTION_TOKEN";
|
|
326
|
+
var PR_ACTION_REPORT_ROUTE = "/pr-action/:runId/report";
|
|
327
|
+
var PR_ACTION_REPORT_BODY_CAP_BYTES = 4096;
|
|
328
|
+
function prActionReportPath(runId) {
|
|
329
|
+
return PR_ACTION_REPORT_ROUTE.replace(":runId", encodeURIComponent(runId));
|
|
330
|
+
}
|
|
331
|
+
var PrActionReportBody = z.strictObject({
|
|
332
|
+
outcome: z.enum([
|
|
333
|
+
"started",
|
|
334
|
+
"done",
|
|
335
|
+
"failed",
|
|
336
|
+
"refused"
|
|
337
|
+
]),
|
|
338
|
+
message: z.string().max(500).optional()
|
|
339
|
+
});
|
|
245
340
|
var PrFlowItemRequest = z.strictObject({
|
|
246
341
|
prKey: z.string().min(1),
|
|
247
342
|
itemKey: z.string().min(1)
|
|
@@ -1800,4 +1895,4 @@ var AGENT_REPLY_SCHEMAS = Object.freeze({
|
|
|
1800
1895
|
answer: z.union([AgentOkReply, AgentRefusal])
|
|
1801
1896
|
});
|
|
1802
1897
|
//#endregion
|
|
1803
|
-
export { Panel as $, TeamReviewStatus as $t, SESSION_NAME_RULE_TEXT as A,
|
|
1898
|
+
export { Panel as $, TeamReviewStatus as $t, SESSION_NAME_RULE_TEXT as A, prFlowRulesJsonSchema as An, pullRequestKeyFormat as At, TASK_TITLE_CONTROL_CHARACTERS as B, GithubPrsFreshness as Bn, PrDetail as Bt, CoherenceHooksState as C, PrFlowsSettings as Cn, MyPrSearchNode as Ct, SESSION_DOC_BODY_CAP_BYTES as D, PrThreadUnresolveResponse as Dn, MyPrsState as Dt, SESSION_COMMANDS as E, PrThreadReplyResponse as En, MyPrsSnapshot as Et, SessionSnapshot as F, NODE_ID_RE as Fn, FindingSeverity as Ft, Board as G, RESTARTABLE_STATES as Gn, ReviewResult as Gt, UnseenOutcome as H, BADGE_LABELS as Hn, ReviewComment as Ht, SessionState as I, REPO_SLUG_RE as In, GithubReviewDecision as It, BoardSummary as J, TeamReviewActionRequest as Jt, BoardRecord as K, STATES as Kn, ReviewThreadId as Kt, ShownFile as L, repoParts as Ln, GithubReviewState as Lt, SIGN_URL_ENV as M, HEX_SHA_RE as Mn, CommitSha as Mt, SSH_SIGN_BODY_CAP_BYTES as N, shortSha as Nn, DECIDING_REVIEW_STATES as Nt, SESSION_DOC_PATH_MAX_CHARS as O, ReportedPrFlowActionOutcome as On, MyPrsStatus as Ot, SessionDoc as P, GH_SEGMENT as Pn, EarlierReview as Pt, Op as Q, TeamReviewStateEntry as Qt, SshSignReply as R, GithubPollingRefreshRequest as Rn, PostedReviewEvent as Rt, CONVERSATION_TOOL_RESULT_HOOK_EVENT as S, PrFlowSourceOutput as Sn, MyPrMergeWhenReadyResult as St, RefinedTaskTitle as T, PrFlowsStatus as Tn, MyPrThreadsResponse as Tt, BOARD_MEDIA_MAX_EDGE_PX as U, KILLABLE_STATES as Un, ReviewDraft as Ut, TaskTitle as V, githubPollingShape as Vn, ReviewChecksState as Vt, BOX_CHANGES as W, MERGEABLE_LIVE_STATES as Wn, ReviewFinding as Wt, Frame as X, TeamReviewCompareFiles as Xt, Box as Y, TeamReviewActionResult as Yt, Note as Z, TeamReviewResolveResponse as Zt, AgentSpawnRequest as _, PrFlowItemRequest as _n, MyPrMergeMethod as _t, AgentAnswerRequest as a, hasRequiredActionHead as an, WhiteboardAgentRequest as at, CONVERSATION_APPROVAL_SUMMARY_MAX_CHARS as b, PrFlowRule as bn, MyPrMergeStateResponse as bt, AgentCloseRequest as c, PR_ACTION_REPORT_ROUTE as cn, sparseBoardReply as ct, AgentPullRequestRequest as d, PrActionReportBody as dn, MyPrAutoRebase as dt, TeamReviewThreadCommentsResponse as en, UNIT_STATUSES as et, AgentReadRequest as f, PrActionRunRequest as fn, MyPrCheckContext as ft, AgentSettingsRequest as g, PrFlowDisposeResult as gn, MyPrLaneEntry as gt, AgentSettingsReply as h, PrFlowDisposeRequest as hn, MyPrKeepMergeableResult as ht, ASK_USER_QUESTION_TOOL_NAME as i, decisionAsIfApprovalRequired as in, WhiteboardAgentReply as it, SHOWN_FILE_CAP_BYTES as j, FULL_SHA_RE as jn, repositoryName as jt, SESSION_NAME_PATTERN as k, prActionReportPath as kn, SessionPrLinks as kt, AgentEditRequest as l, PR_ACTION_REPORT_URL_ENV as ln, LinkedPr as lt, AgentSendRequest as m, PrFlowCommand as mn, MyPrKeepMergeableRequest as mt, AGENT_REPLY_SCHEMAS as n, TeamReviewThreadsRepository as nn, WHITEBOARD_ASSET_ROUTE as nt, AgentAttentionRequest as o, hasStandingViewerApproval as on, Wire as ot, AgentReviewsRequest as p, PrFlowApproveRequest as pn, MyPrCheckContextsResponse as pt, BoardReview as q, ReviewVerdict as qt, AGENT_URL_ENV as r, canApproveAfterComment as rn, WHITEBOARD_LIMITS as rt, AgentCheckoutRequest as s, PR_ACTION_REPORT_BODY_CAP_BYTES as sn, sparseBoardRecord as st, AGENT_API_VERBS as t, TeamReviewThreadResult as tn, Unit as tt, AgentLimitsReply as u, PR_ACTION_TOKEN_ENV as un, MyPr as ut, AgentWhyRequest as v, PrFlowPackRequires as vn, MyPrMergeRequest as vt, ConversationQuestion as w, PrFlowsState as wn, MyPrThreadNode as wt, CONVERSATION_PERMISSION_HOOK_EVENT as x, PrFlowSaveRuleRequest as xn, MyPrMergeWhenReadyRequest as xt, COHERENCE_HOOKS_INACTIVE as y, PrFlowPrAction as yn, MyPrMergeResult as yt, SshSignRequest as z, GithubPollingRefreshResult as zn, PostingPlan as zt };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { r as errorMessage, t as errorCode } from "./text-DoirglWV.js";
|
|
2
2
|
import { n as glimmervoidHomeDir, t as decideConfigPath } from "./config-path-core-DUWk0Lui.js";
|
|
3
|
-
import { h as AgentSettingsReply } from "./session-
|
|
4
|
-
import { r as BrowserConfig } from "./config-
|
|
3
|
+
import { h as AgentSettingsReply } from "./session-D0gNPAv6.js";
|
|
4
|
+
import { r as BrowserConfig } from "./config-C43Ovt64.js";
|
|
5
5
|
import { n as isRecord } from "./coerce-oz_Z_6E7.js";
|
|
6
6
|
import { t as renderTable } from "./ascii-figure-core-pDAwtlKO.js";
|
|
7
|
-
import { A as cloneValue, F as scoreSettingsSearch, I as setValueAtPath, P as parsePosthogProjectSelection, V as SETTINGS_REGISTRY, _t as ENV_SECRET_BINDINGS, bt as withEnvSecrets, j as deleteValueAtPath, l as saveConfigFileOnce, s as loadConfigFile, t as IS_EXPERIMENTAL_BUILD, u as validateConfig, vt as readEnvSecrets, w as isSettingAvailable, z as valueAtPath } from "./config-store-
|
|
8
|
-
import { a as fail, c as listSettings, d as renderSectionTables, f as requireConfigFileSetting, g as valueText, h as succeed, i as describeSetting, l as readSetting, m as settingsRequestForServer, n as configFileViewOf, o as fitColumn, p as sectionOf, r as defaultText, s as getSetting, t as availableSettings } from "./settings-readout-core-
|
|
7
|
+
import { A as cloneValue, F as scoreSettingsSearch, I as setValueAtPath, P as parsePosthogProjectSelection, V as SETTINGS_REGISTRY, _t as ENV_SECRET_BINDINGS, bt as withEnvSecrets, j as deleteValueAtPath, l as saveConfigFileOnce, s as loadConfigFile, t as IS_EXPERIMENTAL_BUILD, u as validateConfig, vt as readEnvSecrets, w as isSettingAvailable, z as valueAtPath } from "./config-store-Bqag5_2n.js";
|
|
8
|
+
import { a as fail, c as listSettings, d as renderSectionTables, f as requireConfigFileSetting, g as valueText, h as succeed, i as describeSetting, l as readSetting, m as settingsRequestForServer, n as configFileViewOf, o as fitColumn, p as sectionOf, r as defaultText, s as getSetting, t as availableSettings } from "./settings-readout-core-DhpeT094.js";
|
|
9
9
|
import fs from "node:fs";
|
|
10
10
|
import os from "node:os";
|
|
11
11
|
//#region server/settings-cli.ts
|
|
@@ -320,7 +320,7 @@ function runParsedSettingsCommand(parsed, io) {
|
|
|
320
320
|
async function runParsedSettingsCli(parsed, io = processIo()) {
|
|
321
321
|
const serverRequest = settingsRequestForServer(parsed, process.env);
|
|
322
322
|
if (!serverRequest) return runParsedSettingsCommand(parsed, io);
|
|
323
|
-
const { askAgentApi } = await import("./agent-api-cli-
|
|
323
|
+
const { askAgentApi } = await import("./agent-api-cli-ivGOfIyv.js");
|
|
324
324
|
const reply = AgentSettingsReply.safeParse(await askAgentApi("settings", serverRequest).catch((error) => ({
|
|
325
325
|
ok: false,
|
|
326
326
|
error: errorMessage(error)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as AgentSettingsRequest } from "./session-
|
|
1
|
+
import { g as AgentSettingsRequest } from "./session-D0gNPAv6.js";
|
|
2
2
|
import { t as renderTable } from "./ascii-figure-core-pDAwtlKO.js";
|
|
3
|
-
import { A as cloneValue, B as FILE_ONLY_GROUPS, L as settingsGroupOf, M as displayText, N as hasScaledUnit, R as settingsOf, V as SETTINGS_REGISTRY, k as SETTINGS_INDEX, vt as readEnvSecrets, w as isSettingAvailable, z as valueAtPath } from "./config-store-
|
|
3
|
+
import { A as cloneValue, B as FILE_ONLY_GROUPS, L as settingsGroupOf, M as displayText, N as hasScaledUnit, R as settingsOf, V as SETTINGS_REGISTRY, k as SETTINGS_INDEX, vt as readEnvSecrets, w as isSettingAvailable, z as valueAtPath } from "./config-store-Bqag5_2n.js";
|
|
4
4
|
//#region server/core/settings-readout-core.ts
|
|
5
5
|
var VALUE_COLUMN_WIDTH = 40;
|
|
6
6
|
var SECTION_BY_SETTING_ID = new Map([...SETTINGS_REGISTRY.sections.flatMap((section) => section.settings.map((setting) => [setting.id, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { W as BOX_CHANGES, et as UNIT_STATUSES, j as SHOWN_FILE_CAP_BYTES, rt as WHITEBOARD_LIMITS } from "./session-
|
|
1
|
+
import { W as BOX_CHANGES, et as UNIT_STATUSES, j as SHOWN_FILE_CAP_BYTES, rt as WHITEBOARD_LIMITS } from "./session-D0gNPAv6.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
//#region shared/whiteboard-plan-core.ts
|
|
4
4
|
var LETTERS_IN_ALPHABET = 26;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as SIGN_URL_ENV, r as AGENT_URL_ENV } from "./session-
|
|
1
|
+
import { M as SIGN_URL_ENV, r as AGENT_URL_ENV } from "./session-D0gNPAv6.js";
|
|
2
2
|
import { t as HOOK_URL_ENV } from "./hook-relay-core-DA_bz2KA.js";
|
|
3
3
|
import { i as saneYoloEnv, r as SANE_YOLO_PATH_ENV } from "./sane-yolo-BjUkqIoH.js";
|
|
4
4
|
import { r as MCP_CREDENTIAL_ENV } from "./agent-config-DDpOIcFv.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { r as errorMessage } from "./text-DoirglWV.js";
|
|
2
|
-
import { M as SIGN_URL_ENV, R as SshSignReply } from "./session-
|
|
2
|
+
import { M as SIGN_URL_ENV, R as SshSignReply } from "./session-D0gNPAv6.js";
|
|
3
3
|
import { l as spawn, r as execFileAsync } from "./child-process-safe-BIh8yQ0I.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-7xxfflVL.js";
|
|
6
6
|
import { l as parseSshPublicKey } from "./ssh-signing-core-BbhBpAhR.js";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import fs from "node:fs/promises";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,d as t,u as n}from"./control-ws-
|
|
1
|
+
import{c as e,d as t,u as n}from"./control-ws-t9cKDDGy.js";import{Ct as r,M as i,P as a,bt as o,j as s}from"./button-Cnom-MQM.js";import{S as c,s as l}from"./dom-helpers-Bs-xZEnd.js";var u=`cubic-bezier(0.22, 1, 0.36, 1)`,d=`cubic-bezier(0.4, 0, 0.2, 1)`,f=`cubic-bezier(0.1, 0.8, 0.3, 1)`,p=`cubic-bezier(0.2, 0.9, 0.3, 1)`,m=460,ee=`50% 87.5%`,h=90,g=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),_=new WeakMap,v=new WeakMap,y=new WeakMap;function b(e,t){let{class:n,...r}=t,a=s(16,16);return n!==void 0&&a.classList.add(n),a.append(i(e,r)),a}function x(e){return c[e].map(e=>b(e.tag,e.attributes))}function te(e){let t=document.createElement(`span`);return t.className=`status-icon`,t.dataset.icon=e,t.append(...x(e)),t}function S(e){return e!==void 0&&Object.hasOwn(c,e)}function C(e,t,n){return e?e.animate(t,{fill:`both`,easing:u,...n}).finished.catch(()=>void 0):Promise.resolve()}function w(e,t,n){return Promise.all(e.map(e=>C(e,t,n)))}function T(e,t,n,r){let i=e?.firstElementChild;return i instanceof SVGElement?(i.setAttribute(`pathLength`,`1`),C(i,[{strokeDasharray:`1 3`,strokeDashoffset:t},{strokeDasharray:`1 3`,strokeDashoffset:n}],r)):Promise.resolve()}var E=(e,t)=>e.find(e=>e.classList.contains(t)),D=(e,t)=>e.find(e=>e.firstElementChild?.tagName===t),O=(e,t)=>e.filter(e=>!e.classList.contains(t));function k(e){let t=getComputedStyle(e).transform;if(!t||t===`none`)return 0;let n=new DOMMatrixReadOnly(t);return Math.atan2(n.b,n.a)*(180/Math.PI)}var ne=(e,t)=>Promise.all([w(e,[{transform:`scale(1)`,opacity:1},{transform:`scale(0.6)`,opacity:0}],{duration:200,easing:`ease-in`}),w(t,[{transform:`scale(0.6)`,opacity:0},{transform:`scale(1)`,opacity:1}],{duration:280,delay:110})]),A=(e,t)=>C(e,[{transform:`scale(0.3)`,opacity:0},{transform:`scale(1.16)`,opacity:1,offset:.6},{transform:`scale(1)`,opacity:1}],{duration:350,delay:t}),j=e=>C(e,[{transform:`scale(1)`,opacity:1},{transform:`scale(0.2)`,opacity:0}],{duration:230,easing:`ease-in`});function re(e,t){let n=e[0]?k(e[0]):0,r=Math.round(n/h)*h,i=e=>+!e.classList.contains(`status-icon-spin-blur`);for(let e of t)e.style.opacity=`0`;return Promise.all(e.map(e=>C(e,[{transform:`rotate(${n}deg)`,opacity:getComputedStyle(e).opacity},{transform:`rotate(${r}deg)`,opacity:i(e)}],{duration:240,easing:f}))).then(()=>{for(let e of t)e.style.opacity=``;return Promise.all([...e.map(e=>C(e,[{transform:`rotate(${r}deg) scale(1)`,opacity:i(e)},{transform:`rotate(${r}deg) scale(0.55)`,opacity:0}],{duration:300,easing:d})),w(t,[{transform:`scale(0.7, 0.25)`,opacity:0},{transform:`scale(1, 1.06)`,opacity:1,offset:.7},{transform:`scale(1)`,opacity:1}],{duration:340,delay:40,easing:p})])})}var ie={"not-started>starting":(e,t)=>Promise.all([w(e,[{opacity:1},{opacity:0}],{duration:240,easing:`linear`}),w(O(t,`status-icon-spin-blur`),[{opacity:0},{opacity:1}],{duration:240,easing:`linear`})]),"not-started>idle":(e,t)=>Promise.all([w(e,[{transform:`scale(1)`,opacity:1},{transform:`scale(0.7)`,opacity:0}],{duration:340,easing:d}),w(t,[{transform:`scale(0.55)`,opacity:0},{transform:`scale(1)`,opacity:1}],{duration:340,delay:80,easing:d})]),"starting>idle":re,"starting>working":(e,t)=>Promise.all([...e.map(e=>{let t=k(e);return C(e,[{transform:`rotate(${t}deg) scale(1)`,opacity:getComputedStyle(e).opacity},{transform:`rotate(${t}deg) scale(0.55)`,opacity:0}],{duration:260,easing:`ease-in`})}),A(E(t,`status-icon-beat`),160)]),"working>complete":(e,t)=>Promise.all([j(E(e,`status-icon-beat`)),T(t[0],1,0,{duration:320,delay:160})]),"working>failed":(e,t)=>Promise.all([j(E(e,`status-icon-beat`)),T(t[0],1,0,{duration:300,delay:150})]),"working>needs-input":(e,t)=>Promise.all([C(E(e,`status-icon-beat`),[{transform:`none`,opacity:1},{transform:`translateY(37.5%) scale(0.34)`,opacity:1,offset:.9},{transform:`translateY(37.5%) scale(0.34)`,opacity:0}],{duration:320}),C(D(t,`circle`),[{opacity:0},{opacity:0,offset:.85},{opacity:1}],{duration:320,easing:`linear`}),T(D(t,`path`),1,0,{duration:300,delay:260})]),"needs-input>working":(e,t)=>{let n=D(e,`circle`);return n&&(n.style.transformOrigin=ee),Promise.all([T(D(e,`path`),0,1,{duration:200,easing:`ease-in`}),C(n,[{transform:`none`,opacity:1},{transform:`translateY(-37.5%) scale(2.95)`,opacity:1,offset:.95},{transform:`translateY(-37.5%) scale(2.95)`,opacity:0}],{duration:320,delay:140}),C(E(t,`status-icon-beat`),[{opacity:0},{opacity:0,offset:.9},{opacity:1}],{duration:470,easing:`linear`})])},"working>idle":(e,t)=>Promise.all([C(E(e,`status-icon-beat`),[{transform:`scale(1, 1)`,opacity:1},{transform:`scale(0.35, 1.15)`,opacity:0}],{duration:220,easing:`ease-in`}),w(t,[{transform:`scale(0.1, 0.8)`,opacity:0},{transform:`scale(1)`,opacity:1}],{duration:320,delay:120})]),"idle>working":(e,t)=>Promise.all([w(e,[{transform:`scale(1)`,opacity:1},{transform:`scale(0.1, 0.8)`,opacity:0}],{duration:220,easing:`ease-in`}),C(E(t,`status-icon-beat`),[{transform:`scale(0.35, 1.15)`,opacity:0},{transform:`scale(1.12, 1)`,opacity:1,offset:.6},{transform:`scale(1)`,opacity:1}],{duration:360,delay:120})]),"working>monitoring":(e,t)=>Promise.all([C(E(e,`status-icon-beat`),[{transform:`scale(1)`,opacity:1},{transform:`scale(1.3, 0.15)`,opacity:0}],{duration:220,easing:`ease-in`}),w(t,[{transform:`scaleY(0)`},{transform:`scaleY(1)`}],{duration:300,delay:160})]),"monitoring>working":(e,t)=>Promise.all([w(e,[{transform:`scaleY(1)`},{transform:`scaleY(0)`}],{duration:200,easing:`ease-in`}),A(E(t,`status-icon-beat`),170)]),"complete>exited":(e,t)=>Promise.all([T(e[0],0,-1,{duration:220,easing:`ease-in`}),T(t[0],1,0,{duration:380,delay:140})])};function ae(e,t){y.get(t)?.cancel();let n=_.get(e);if(!n)return;t.style.setProperty(`--status-icon-from`,n);let r=t.animate([{"--status-icon-blend":`0%`},{"--status-icon-blend":`100%`}],{duration:m,easing:d});y.set(t,r),r.finished.then(()=>t.style.removeProperty(`--status-icon-from`),()=>void 0)}function M(e){e.isConnected&&_.set(e,getComputedStyle(e).color)}function N(e){for(let t of e.getAnimations({subtree:!0}))t instanceof CSSAnimation||t instanceof CSSTransition||t.cancel()}function P(e,t,n,r){v.get(t)?.();let i=[...t.children].filter(e=>e instanceof SVGSVGElement),a=x(r);for(let e of i)e.dataset.leaving=``;let o=E(i,`status-icon-ping`);o&&(N(o),o.style.opacity=`0`),t.dataset.icon=r,ae(e,t),t.append(...a);let s=!1,c=()=>{if(!s){s=!0;for(let e of i)e.remove();for(let e of a)N(e),e.style.opacity=``;v.delete(t),M(e)}};v.set(t,c),(ie[`${n}>${r}`]??ne)(i,a).then(c,c)}function F(e){return e.isConnected&&!document.hidden&&g?.matches!==!0&&typeof e.animate==`function`}function I(e,t){let n=e.dataset.icon;if(n===t)return;e.dataset.icon=t;let r=e.querySelector(`:scope > .status-icon`);!S(n)||!(r instanceof HTMLElement)||!F(e)?(r instanceof HTMLElement&&v.get(r)?.(),e.replaceChildren(te(t)),M(e)):P(e,r,n,t)}var L={busy:`text-text-muted`,ok:`text-state-done`,error:`text-state-failed`},R=15e3,z=`Something went wrong. Details are hidden in streamer mode.`;function B(e,t){return e!==`error`||t.startsWith(`Not connected to the server. Reconnecting.`)?t:document.documentElement.hasAttribute(`data-streamer`)?z:t}var V={busy:`working`,ok:`complete`,error:`failed`};function H(e){let t=e.querySelector(`:scope > .action-status-icon`),n=e.querySelector(`:scope > .action-status-text`);if(t&&n&&e.childNodes.length===2)return{iconElement:t,textElement:n};let r=l(`span`,`action-status-icon`);r.setAttribute(`aria-hidden`,`true`);let i=l(`span`,`action-status-text`);return e.replaceChildren(r,i),{iconElement:r,textElement:i}}function U(e){e.replaceChildren(),delete e.dataset.tone}function W(e,t,n){if(!n){U(e);return}if(!t){U(e),e.textContent=n;return}e.dataset.tone=t;let{iconElement:r,textElement:i}=H(e);I(r,V[t]),i.textContent=B(t,n)}function G(e=`action-status`){let t=l(`p`,e);return t.setAttribute(`role`,`status`),t.hidden=!0,{element:t,show:(n,r)=>{t.className=`${e} text-meta ${L[n]}`,W(t,n,r),t.hidden=!r},clear:()=>{t.hidden=!0,U(t)}}}function K(e,t){return n(e)?!0:(t.show(`error`,a),!1)}function q(e,t){let n=e instanceof Error?e.message:``;return n===`Request timed out`?`The server did not answer within ${Math.round(t/1e3)} s.`:n||`Not connected to the server. Reconnecting.`}async function oe(e,n,r,{busyText:i,timeoutMs:a=R}={}){i&&r.show(`busy`,i);try{let i=await t(e,n,{timeoutMs:a});return r.clear(),i}catch(e){return r.show(`error`,q(e,a)),null}}var J=null,se=3e4,Y=null;function X(){let e=document.getElementById(`header-status`),t=document.getElementById(`header-status-text`),n=document.getElementById(`header-status-age`),r=document.getElementById(`header-status-dismiss`);return!e||!t||!n||!r?null:(r.dataset.wired===void 0&&(r.dataset.wired=``,r.addEventListener(`click`,$)),{line:e,text:t,age:n})}function Z(){let e=X();if(!e||!J)return;let t=r(Date.now()-J.raisedAt,{...o,justNowBelowSeconds:60});e.age.textContent!==t&&(e.age.textContent=t)}function Q({source:t,sessionId:n,message:r,hidesInStreamerMode:i=!0}){e(t,r);let a=X();if(!a)return;let o=i?B(`error`,r):r,s=l(`strong`,`header-status-source`,t);a.text.replaceChildren(s,` ${o}`),J={source:t,sessionId:n??null,raisedAt:Date.now()},Z(),Y??=window.setInterval(Z,se),a.line.hidden=!1}function ce(e,t){J?.source===e&&(t===void 0||J.sessionId===t)&&$()}function le(e){J?.sessionId===e&&$()}function $(){J=null,Y!==null&&window.clearInterval(Y),Y=null;let e=X();e&&(e.line.hidden=!0,e.text.replaceChildren(),e.age.textContent=``)}export{W as a,oe as c,G as i,K as l,ce as n,Q as o,le as r,q as s,R as t,I as u};
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./button-
|
|
1
|
+
import{t as e}from"./button-Cnom-MQM.js";import{n as t,r as n,s as r}from"./dom-helpers-Bs-xZEnd.js";import{Ca as i,Sa as a,xa as o}from"./index-CiJEE2GW.js";var s={mine:`Mine`,run:`Run`,cancel:`Cancel`},c=null;function l(e){return e===null?`n/a`:`${Math.round(e*100)}%`}function u(e){if(e===null)return`n/a`;let t=Math.round(e*100);return t>0?`+${t}`:String(t)}function d(t,n,r){return e({variant:n===`cancel`?`secondary`:`primary`,size:`small`,label:s[n],action:`benchmark-${n}`,disabled:r,onClick:()=>a(t.id,n)})}function f(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 p(e){let t=e&&e.invalid>0?` (${e.invalid} invalid)`:``,n=r(`td`,`bench-score`,`${l(e?.recall??null)}${t}`);return e&&e.degraded>0&&(n.dataset.degraded=`true`),n}function m(e){let t=e.armIds.filter(t=>t!==e.baselineArm),n=r(`table`,`bench-table`),i=r(`tr`);i.append(r(`th`,null,`Case`),...e.armIds.map(t=>r(`th`,null,t===e.baselineArm?`${t} (baseline)`:t))),i.append(...t.map(e=>r(`th`,null,`${e} vs baseline`))),n.append(i);for(let i of e.rows){let a=r(`tr`);a.append(r(`td`,`bench-case`,i.caseId),...e.armIds.map(e=>p(i.arms[e]))),a.append(...t.map(e=>r(`td`,`bench-delta`,u(i.deltaVsBaseline[e]??null)))),n.append(a)}let a=[...new Set(e.armIds.flatMap(t=>Object.keys(e.totals[t]?.recallByTag??{})))].sort(),o=r(`tr`,`bench-total`);o.append(r(`td`,`bench-case`,`Paired recall`),...e.armIds.map(t=>p(e.totals[t]))),n.append(o);for(let t of a){let i=r(`tr`,`bench-total`);i.append(r(`td`,`bench-case`,`Recall, ${t}`),...e.armIds.map(n=>r(`td`,`bench-score`,l(e.totals[n]?.recallByTag[t]??null)))),n.append(i)}return n}function h(e,t){let{isServerConnected:i,pendingActionBySuite:a,outcomeBySuite:s}=o(),c=r(`div`,`bench-suite`),l=e.inFlight?.suiteId===t.id,u=!!e.inFlight&&!l,p=a.has(t.id)||!i,h=r(`div`,`bench-summary`);h.append(r(`span`,`bench-suite-title`,t.title),n(`bench`,t.caseCount===1?`case`:`cases`,String(t.caseCount)),n(`bench`,t.candidateCount===1?`candidate`:`candidates`,String(t.candidateCount)),n(`bench`,`arms`,String(t.armIds.length))),c.append(h);let g=r(`div`,`bench-controls`),_=e.configured===!0&&t.error===null;g.append(d(t,`mine`,!_||p||l),d(t,`run`,!_||p||l||u||t.caseCount===0),d(t,`cancel`,p||!l));let v=r(`span`,`bench-status`,(i?``:`Not connected to the server. Reconnecting.`)||f(e,t)||s.get(t.id)||``);if(v.setAttribute(`role`,`status`),g.append(v),c.append(g),t.error)return c.append(r(`p`,`bench-error`,t.error)),c;let y=t.latestReport;return y?(c.append(r(`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(m(y)),c):(c.append(r(`p`,`bench-empty`,t.caseCount===0?`Move approved candidates into the cases folder, then choose Run.`:`No run yet.`)),c)}function g(){if(!c)return;c.textContent=``;let{status:e}=o(),n=t(`bench`,`Benchmarks`,`Suites from the benchmarks folder of the Glimmervoid home, one run at a time.`);if(c.append(n),!e)c.append(r(`p`,`bench-empty`,`Waiting for the server.`));else if(!e.configured)c.append(r(`p`,`bench-empty`,e.reason||`Benchmarks are off.`));else if(e.suites.length===0)c.append(r(`p`,`bench-empty`,`No suites yet. Create a folder holding suite.json under benchmarks in the Glimmervoid home.`));else for(let t of e.suites)c.append(h(e,t))}function _(e){c||(c=r(`div`,`bench-content`),e.append(c),i(g),g())}var v={mount:_};export{v as view};
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,a as t,en as n,fn as r,ln as i,pn as a,r as o,sn as s,t as c,tn as l,un as u}from"./button-DyD4Mzjw.js";import{f as d,s as f}from"./dom-helpers-Bs-xZEnd.js";import{a as p,i as m,n as h}from"./modal-B1bP8CnK.js";import{a as g,r as _}from"./card-registry-D1vs5tMh.js";import{i as v}from"./action-status-DXlvWNQ7.js";import{n as y,t as b}from"./menu-D9GiYN6D.js";import{Kr as x,_t as S,at as ee,bt as C,ct as te,dt as w,ft as T,gt as ne,ht as E,it as D,lt as re,mt as O,ot as k,pt as A,st as ie,ut as ae,vt as oe,yt as se}from"./index-Q9jU5kU4.js";import{t as ce}from"./sandboxed-frame-DDgtJ2Ng.js";Object.freeze({unitWarnings:[],uncoveredPaths:[],worthALookPaths:[],flaggedUnitIds:[],notChecked:null});var le=/^([^#\s]+)(?:#L([1-9]\d*)(?:-L([1-9]\d*))?)?$/;function ue(e){return e.startsWith(`/`)||e.startsWith(`\\`)||/^[A-Za-z]:/.test(e)}function de(e){return e.split(`/`).filter(e=>e!==``&&e!==`.`).join(`/`)}function fe(e){let t=le.exec(e);if(!t?.[1])return{error:`a ref is path, path#L12 or path#L12-L30`};let n=t[1];if(ue(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:de(n),startLine:r,endLine:i}}function pe(e,t,n){return n.flatMap((n,r)=>n.ref?[{elementId:t,ref:n.ref,where:`line ${r+1} of ${e}`}]:[])}function me(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})),...pe(t,e.id,e.lines)];case`panel`:return pe(t,e.id,e.lines);case`note`:return e.ref?[{elementId:e.id,ref:e.ref,where:t}]:[];case`frame`:case`wire`:return[]}}function he(e){return[...new Set(me(e).map(e=>e.ref))]}function ge(e){let t=fe(e);return`path`in t?t.path:null}var _e=4,ve=200,ye=2e4,be=1.1,xe=[`wire`,`note`,`frame`,`box`,`panel`,`unit`],Se={v:`select`,r:`box`,d:`decision`,p:`panel`,a:`wire`};function j(e){let t=Math.random().toString(36).slice(2,8);return`${e}-${Date.now().toString(36)}${t}`}function M(){return document.documentElement.dataset.layout===`phone`}function Ce(e){return e instanceof SVGCircleElement&&e.classList.contains(`wb-port`)?e:null}function we(e){return e===`box`||e===`decision`||e===`panel`}function Te(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:j(`panel`),title:`Panel`,lines:[],order:e+1}}return e===`decision`?Ee(n,`Decision`,null,!0):Ee(n,`Box`,null,!1)}function Ee(e,t,n,r){return{kind:`box`,id:j(`box`),title:t,lines:[],lane:null,refs:[],change:`none`,was:null,column:null,near:null,order:0,at:e,shape:r?`decision`:`box`,outputs:r?[{id:`yes`,label:`yes`},{id:`no`,label:`no`}]:[],media:n,width:null}}function De(e){if(!(e instanceof Element))return null;let t=e.closest(`image.wb-image`),n=t?.getAttribute(`href`);return!t||!n?null:{boxId:t.closest(`[data-element-id]`)?.dataset.elementId??null,href:n,alt:t.querySelector(`title`)?.textContent??``}}function Oe(e){return e instanceof SVGRectElement&&e.classList.contains(`wb-resize-handle`)}function ke(e){return e instanceof Element?e.closest(`[data-linked-board-id]`)?.dataset.linkedBoardId??null:null}var Ae=2,je=12/10;function Me(e){let{viewport:t,world:n,svg:r,canvas:i,renderer:a}=e,o=new Map,s=new Set,c={x:0,y:0,scale:1},l=null,d=null,p=null,m=`select`,h=null,g=!1;function _(n){m=n,t.dataset.tool=n,e.onToolChange(n)}function v(){n.style.transform=`translate(${-c.x*c.scale}px, ${-c.y*c.scale}px) scale(${c.scale})`}function y(){return(t.clientWidth||1)/c.scale}function b(){let e=t.getBoundingClientRect(),n=[...i.querySelectorAll(`.wb-island`)].filter(e=>e.checkVisibility()).map(e=>e.getBoundingClientRect()),r=e.top+e.height/2,a=n.filter(e=>e.top+e.height/2<r).map(t=>t.bottom-e.top),o=n.filter(e=>e.top+e.height/2>=r).map(t=>t.top-e.top),s=Math.max(0,...a),c=Math.min(e.height,...o)-s;return c<e.height/2?{topPx:0,heightPx:e.height}:{topPx:s,heightPx:c}}function x(){let e=a.layout();if(!e)return;let{bounds:n}=e,r=t.clientWidth,i=t.clientHeight;if(r===0||i===0){c={x:n.x,y:n.y,scale:1},v(),g=!0;return}g=!1;let o=b(),s=e.elements.length===0?1:Ae,l=Math.max(1/s,n.width/r,n.height/o.heightPx),u=l>je,d=u?je:l,f=r*d,p=n.y+n.height/2,m=o.topPx+o.heightPx/2;c={x:n.x-Math.max(0,f-n.width)/2,y:u?n.y-o.topPx*d:p-m*d,scale:1/d},v()}function S(e,n){let r=t.getBoundingClientRect();return{x:c.x+(e-r.left-t.clientLeft)/c.scale,y:c.y+(n-r.top-t.clientTop)/c.scale}}function ee(){return 1/c.scale}function C(e,t){let n=y(),r=Math.min(ye,Math.max(ve,n*t))/n;c={x:e.x-(e.x-c.x)*r,y:e.y-(e.y-c.y)*r,scale:c.scale/r},v()}function te(e,t){c={...c,x:c.x-e/c.scale,y:c.y-t/c.scale},v()}function w(t){s=t,a.setSelection(s),e.onSelectionChange(s)}function T(e,t){if(!t){w(s.has(e)&&s.size===1?new Set:new Set([e]));return}let n=new Set(s);n.delete(e)||n.add(e),w(n)}function ne(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 E(e){let t=Math.round(e.start.width+e.latest.x-e.origin.x);return Math.min(u.boxWidthMax,Math.max(u.boxWidthMin,t))}function D(e){return e.mode===`resize`?{width:E(e)}:{at:ne(e)}}function re(e,t,n){let r=e.elements[t];return r?.kind===`box`?{...e,elements:{...e.elements,[t]:{...r,...n}}}:e}function O(e){return l?.kind!==`drag`||!l.hasMoved?e:re(e,l.boxId,D(l))}function k(){p!==null&&cancelAnimationFrame(p),p=null}function A(){k();let t=e.currentBoard();t&&a.render(O(t))}function ie(){p===null&&(p=requestAnimationFrame(A))}function ae(e){l?.kind===`drag`&&e?.elements[l.boxId]?.kind!==`box`&&(l=null);let t=new Set([...s].filter(t=>e?.elements[t]));t.size!==s.size&&w(t)}function oe(e){let t=a.layout()?.elements.find(t=>t.id===e);return t?.kind===`box`?t:null}function se(){let[e,t]=[...o.values()];return!e||!t?0:Math.hypot(e.x-t.x,e.y-t.y)}function ce(){l?.kind===`wire`&&ge(l,!1),l={kind:`pinch`,distance:se(),viewWidth:y()}}function le(n){if(n.button!==0||d)return;let r=ke(n.target);if(r){e.onOpenLinkedBoard(r);return}if(o.set(n.pointerId,{x:n.clientX,y:n.clientY}),t.setPointerCapture(n.pointerId),o.size===2){ce();return}let i=a.elementFromTarget(n.target);if(we(m)){ue(m,S(n.clientX,n.clientY));return}let s=i?.kind===`box`&&Oe(n.target)&&!M()?oe(i.id):null;if(i&&s){let e=S(n.clientX,n.clientY);l={kind:`drag`,mode:`resize`,pointerId:n.pointerId,boxId:i.id,origin:e,start:s,pinnedOffsetY:0,latest:e,hasMoved:!1,isAdditive:!1,pressedImage:null};return}let c=Ce(n.target);if(i?.kind===`box`&&c&&!M()){pe(n.pointerId,i.id,{x:c.cx.baseVal.value,y:c.cy.baseVal.value});return}let u=m===`wire`&&i?.kind===`box`?oe(i.id):null;if(i&&u){pe(n.pointerId,i.id,{x:u.x+u.width/2,y:u.y+u.height/2});return}let f=i?.kind===`box`&&!M()?oe(i.id):null;if(i&&f){let e=S(n.clientX,n.clientY),t=a.layout()?.pinnedOffsetY??0;l={kind:`drag`,mode:`move`,pointerId:n.pointerId,boxId:i.id,origin:e,start:f,pinnedOffsetY:t,latest:e,hasMoved:!1,isAdditive:n.shiftKey,pressedImage:Be(n.target)};return}if(i&&!M()){T(i.id,n.shiftKey);return}let p=i?.kind===`box`?i.id:null;l={kind:`pan`,pointerId:n.pointerId,lastClient:{x:n.clientX,y:n.clientY},hasMoved:!1,tappedBoxId:p,pressedImage:Be(n.target)}}async function ue(t,n){_(`select`);let r=e.currentBoard();if(!r)return;let i=a.layout()?.pinnedOffsetY??0,o=Te(t,r,{x:Math.round(n.x),y:Math.round(n.y-i)});h=o.id;let s=await e.sendOps([{op:`add`,element:o}]);s||(h=null),s&&w(new Set([o.id])),fe()}async function de(n,r,i){if(!e.currentBoard())return!1;let o=i?S(i.x,i.y):{x:c.x+y()/2,y:c.y+(t.clientHeight||1)/c.scale/2},s=a.layout()?.pinnedOffsetY??0,l=Ee({x:Math.round(o.x),y:Math.round(o.y-s)},n,r,!1),u=await e.sendOps([{op:`add`,element:l}]);return u&&w(new Set([l.id])),u}function fe(){if(!h||!a.nodeOf(h))return;let e=h;h=null,ze(e)}function pe(e,t,n){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 ${n.x} ${n.y} L ${n.x} ${n.y}`),r.append(i),l={kind:`wire`,pointerId:e,fromBoxId:t,start:n,draftLine:i,targetBoxId:null}}function me(e,t){e.targetBoxId&&a.nodeOf(e.targetBoxId)?.classList.remove(`is-wire-target`),e.targetBoxId=t,t&&a.nodeOf(t)?.classList.add(`is-wire-target`)}function he(e,t){let n=S(t.clientX,t.clientY);e.draftLine.setAttribute(`d`,`M ${e.start.x} ${e.start.y} L ${n.x} ${n.y}`);let r=a.elementFromTarget(document.elementFromPoint(t.clientX,t.clientY));me(e,r?.kind===`box`&&r.id!==e.fromBoxId?r.id:null)}function ge(t,n){let r=t.targetBoxId;me(t,null),t.draftLine.remove(),n&&r&&e.onConnectBoxes(t.fromBoxId,r)}function j(e,t){let n=S(t.clientX,t.clientY);!e.hasMoved&&Math.hypot(n.x-e.origin.x,n.y-e.origin.y)<_e*ee()||(e.hasMoved=!0,e.latest=n,ie())}function Me(e,t){let n=t.clientX-e.lastClient.x,r=t.clientY-e.lastClient.y;!e.hasMoved&&Math.hypot(n,r)<_e||(e.hasMoved=!0,e.lastClient={x:t.clientX,y:t.clientY},te(n,r))}function Ne(e){let t=se();if(t<=0||e.distance<=0)return;let n=[...o.values()];C(S(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)/y())}function Pe(e){o.has(e.pointerId)&&(o.set(e.pointerId,{x:e.clientX,y:e.clientY}),l?.kind===`pinch`?Ne(l):l?.kind===`drag`&&l.pointerId===e.pointerId?j(l,e):l?.kind===`wire`&&l.pointerId===e.pointerId?he(l,e):l?.kind===`pan`&&l.pointerId===e.pointerId&&Me(l,e))}async function Fe(t,n){if(!t.hasMoved&&t.mode===`resize`)return;if(!t.hasMoved){T(t.boxId,t.isAdditive),t.pressedImage&&!t.isAdditive&&e.onOpenImage(t.pressedImage);return}k(),t.latest=S(n.clientX,n.clientY);let r=D(t),i=e.currentBoard();i&&a.render(re(i,t.boxId,r)),await e.sendOps([{op:`set`,id:t.boxId,fields:r}])||A()}function Ie(t){if(!o.delete(t.pointerId))return;let n=l;n?.kind===`pinch`?l=null:(l=null,n?.kind===`drag`&&n.pointerId===t.pointerId?Fe(n,t):n?.kind===`wire`?(ge(n,n.pointerId===t.pointerId),m===`wire`&&_(`select`)):n?.kind!==`pan`||n.hasMoved||(n.pressedImage&&M()?e.onOpenImage(n.pressedImage):n.tappedBoxId&&M()?e.onPhoneTapBox(n.tappedBoxId):n.tappedBoxId||w(new Set)))}function Le(e){o.delete(e.pointerId);let t=l?.kind===`drag`;l?.kind===`wire`&&ge(l,!1),l=null,t&&A()}function Re(e){e.preventDefault(),e.ctrlKey||e.metaKey?C(S(e.clientX,e.clientY),e.deltaY>0?be:1/be):te(-e.deltaX,-e.deltaY)}function N(){let e=d;d=null,e?.remove()}function ze(n){let r=e.currentBoard()?.elements[n],o=a.nodeOf(n);if(r?.kind!==`box`&&r?.kind!==`panel`||!o)return;N();let s=i.getBoundingClientRect(),c=o.getBoundingClientRect(),l=f(`input`,`wb-title-input`);l.type=`text`,l.value=r.title,l.maxLength=80,l.setAttribute(`aria-label`,r.kind===`panel`?`Panel title`:`Box title`),l.style.left=`${c.left-s.left}px`,l.style.top=`${c.top-s.top}px`,l.style.width=`${Math.max(160,c.width)}px`,d=l,i.append(l),l.addEventListener(`keydown`,i=>{if(i.key===`Escape`){i.preventDefault(),N(),t.focus();return}if(i.key!==`Enter`)return;i.preventDefault();let a=l.value.trim();N(),t.focus(),a&&a!==r.title&&e.sendOps([{op:`set`,id:n,fields:{title:a}}])}),l.addEventListener(`blur`,N),l.focus(),l.select()}function Be(e){let t=De(e),n=t?.boxId?a.layout()?.elements.find(e=>e.id===t.boxId):void 0;return n?.kind===`box`&&n.media&&n.media.kind!==`image`?null:t}function Ve(e,t){let n=S(e,t);return a.layout()?.elements.find(e=>e.kind===`box`&&e.media&&e.media.kind!==`image`&&n.x>=e.media.x&&n.x<=e.media.x+e.media.width&&n.y>=e.media.y&&n.y<=e.media.y+e.media.height)?.id??null}function He(t){let n=Ve(t.clientX,t.clientY);if(n){e.onActivateMedia(n);return}if(M())return;let r=a.elementFromTarget(document.elementFromPoint(t.clientX,t.clientY));(r?.kind===`box`||r?.kind===`panel`)&&ze(r.id)}function Ue(){let t=e.currentBoard();if(!t||s.size===0)return;let n=[...s].flatMap(e=>t.elements[e]??[]),r=xe.flatMap(e=>n.filter(t=>t.kind===e)).map(e=>({op:`remove`,id:e.id}));w(new Set),e.sendOps(r)}function We(e){if(e.target!==t||e.metaKey||e.ctrlKey||e.altKey)return;if(e.key===`Delete`||e.key===`Backspace`){e.preventDefault(),Ue();return}let n=Se[e.key.toLowerCase()];n&&!e.shiftKey?(e.preventDefault(),_(n)):e.key===`Escape`&&(w(new Set),_(`select`))}return n.style.transition=`none`,t.tabIndex=0,t.addEventListener(`pointerdown`,le),t.addEventListener(`pointermove`,Pe),t.addEventListener(`pointerup`,Ie),t.addEventListener(`pointercancel`,Le),t.addEventListener(`wheel`,Re,{passive:!1}),t.addEventListener(`dblclick`,He),t.addEventListener(`keydown`,We),new ResizeObserver(()=>{g&&t.clientWidth>0&&t.clientHeight>0&&x()}).observe(t),{fit:x,selectedIds:()=>s,clearSelection:()=>w(new Set),pruneSelection:ae,previewOf:O,closeTitleInput:N,setTool:_,placeMediaBox:de,openPendingTitleEdit:fe,focusCanvas:()=>t.focus()}}var Ne=Object.freeze({undo:[],redo:[]}),Pe=new Set([`box`,`unit`,`panel`]),Fe=[`wire`,`note`,`frame`,`box`,`panel`,`unit`],Ie=new Set([`kind`,`id`]);function Le(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Re(e){return e.kind===`box`?e.near?[e.near.of]:[]:e.kind===`unit`?e.after:[]}function N(e){let t=new Set(e.map(e=>e.id)),n=[];for(;t.size>0;){let r=e.filter(e=>t.has(e.id)&&Re(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 ze(e,t){let n={...e},r=Object.fromEntries(Object.entries(t).filter(([e,t])=>!Ie.has(e)&&!Le(n[e],t)));return t.kind!==`note`||Object.keys(r).length===0?r:{...r,author:t.author,resolvedBy:t.resolvedBy}}function Be(e,t){let n={...e.title===t.title?{}:{title:t.title},...e.caption===t.caption?{}:{caption:t.caption},...Le(e.legend,t.legend)?{}:{legend:t.legend},...e.codeSessionId===t.codeSessionId?{}:{codeSessionId:t.codeSessionId}};return Object.keys(n).length===0?[]:[{op:`board`,...n}]}function Ve(e,t){if(Le(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 He(e,t){let n=Object.values(e.elements),r=Object.values(t.elements),i=Fe.flatMap(e=>n.filter(n=>n.kind===e&&!t.elements[n.id])),a=N(r.filter(t=>!e.elements[t.id])),o=r.flatMap(t=>{let n=e.elements[t.id];if(!n)return[];let r=ze(n,t);return Object.keys(r).length===0?[]:[{op:`set`,id:t.id,fields:r}]}),{widen:s,narrow:c}=Ve(e,t);return[...Le(e.lanes,t.lanes)?[]:[{op:`lanes`,lanes:t.lanes}],...s,...i.map(e=>({op:`remove`,id:e.id})),...a.filter(e=>Pe.has(e.kind)).map(e=>({op:`add`,element:e})),...o,...a.filter(e=>!Pe.has(e.kind)).map(e=>({op:`add`,element:e})),...c,...Be(e,t)]}function Ue(e,t){let n=oe(e,t,S,e.updatedAt);return n.ok?He(n.board,e):[]}function We(e,t){return t.length===0?[...e]:[...e,t].slice(-100)}function Ge(e,t){return t.length===0?e:{undo:We(e.undo,t),redo:[]}}function Ke(e,t){let n=e[t].at(-1);return n?{entry:n,history:{...e,[t]:e[t].slice(0,-1)}}:null}function qe(e,t,n){let r=t===`undo`?`redo`:`undo`;return{...e,[r]:We(e[r],n)}}var Je=8,Ye=12,Xe=30,Ze=40,Qe=40,$e=400,et=200,tt=8,nt=`README.md`,rt=``,it=[`text`,`code`,`item`,`numbered`,`kv`],at=[`plain`,`fail`,`join`,`lane`],ot=P(it),st=P(at),ct=P([`box`,`decision`]),lt=P(l),ut=P(s),dt=[{value:``,text:`auto`},...P([`left`,`right`,`top`,`bottom`])],ft=[{id:`yes`,label:`yes`},{id:`no`,label:`no`}];function P(e){return e.map(e=>({value:e,text:e}))}function F(e){return f(`h3`,`wb-inspect-heading`,e)}function I(e,t){let n=f(`label`,`wb-inspect-field`);return n.append(f(`span`,`wb-inspect-label`,e),t),n}function L(e,t,n,r,i){let a=f(`input`,`wb-inspect-input`);return a.type=`text`,a.value=t,a.maxLength=n,a.dataset.field=e,i&&a.setAttribute(`aria-label`,i),a.addEventListener(`change`,()=>r(a.value)),a}function R(e,t,n,r,i){let a=f(`select`,`wb-inspect-select`);return a.dataset.field=e,i&&a.setAttribute(`aria-label`,i),a.append(...t.map(e=>{let t=f(`option`,null,e.text);return t.value=e.value,t.selected=e.value===n,t})),a.addEventListener(`change`,()=>r(a.value)),a}function pt(e,t,n,r){let i=f(`input`,`wb-inspect-check`);i.type=`checkbox`,i.checked=n,i.dataset.field=e,i.addEventListener(`change`,()=>r(i.checked));let a=f(`label`,`wb-inspect-toggle`);return a.append(i,f(`span`,null,t)),a}function z(e,t,n,r){let i=c({variant:`quiet`,size:`small`,label:t,action:t.replaceAll(` `,`-`),onClick:n});return i.dataset.field=e,r&&i.setAttribute(`aria-label`,r),i}function mt(e,t,n){let r=f(`div`,`wb-inspect-list`);return r.append(f(`span`,`wb-inspect-label`,e),...t,n),r}function ht(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 gt(e){let t=e.trim();return n.safeParse(t).success?t:null}function _t(e,t,n,r){let i=L(e,t??``,et,e=>{if(!e.trim()){n(null);return}let t=gt(e);t&&n(t)},r);return i.placeholder=`ref: path#L12`,i}function vt(e,t,n,r){let i=ht(n,r),a=t.map((e,t)=>{let n=f(`div`,`wb-inspect-row`);return n.append(L(`ref-${t}`,e,et,e=>{let n=gt(e);n&&i.edit(t,()=>n)},`Ref ${t+1}`),z(`ref-${t}-remove`,`remove`,()=>i.remove(t),`Remove ref ${e}`)),n}),o=z(`ref-add`,`add ref`,()=>i.append(()=>nt),`Add a ref to ${e}`);return o.disabled=t.length>=tt,mt(`Refs`,a,o)}function yt(e,t){return t===`kv`?{...e,style:t,key:e.key||`key`}:{...e,style:t}}function bt(e,t,n,r){let i=ht(n,r),a=t.map((e,t)=>{let n=f(`div`,`wb-inspect-row`),r=t+1;return n.append(R(`line-${t}-style`,ot,e.style,e=>{let n=it.find(t=>t===e);n&&i.edit(t,e=>yt(e,n))},`Line ${r} style`)),e.style===`kv`&&n.append(L(`line-${t}-key`,e.key??``,Qe,e=>{e.trim()&&i.edit(t,t=>({...t,key:e.trim()}))},`Line ${r} key`)),n.append(L(`line-${t}-text`,e.text,u.line,e=>i.edit(t,t=>({...t,text:e})),`Line ${r} text`),_t(`line-${t}-ref`,e.ref,e=>i.edit(t,t=>({...t,ref:e})),`Line ${r} ref`),z(`line-${t}-remove`,`remove`,()=>i.remove(t),`Remove line ${r}`)),n}),o=z(`line-add`,`add line`,()=>i.append(()=>({text:`new line`,muted:!1,style:`text`,key:null,ref:null})),`Add a line to ${e}`);return o.disabled=t.length>=u.linesPerBox,mt(`Lines`,a,o)}function xt(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 St(e,t,n){let r=ht(t,e=>n({outputs:e})),i=e.outputs.map((e,t)=>{let n=f(`div`,`wb-inspect-row`);return n.append(L(`output-${e.id}-label`,e.label,Xe,e=>{e.trim()&&r.edit(t,t=>({...t,label:e.trim()}))},`Output ${e.id} label`),z(`output-${e.id}-remove`,`remove`,()=>r.remove(t),`Remove output ${e.label}`)),n}),a=z(`output-add`,`add output`,()=>r.append(e=>({id:xt(e),label:`exit`})));return a.disabled=e.outputs.length>=Je,mt(`Outputs`,i,a)}function Ct(e){return e.at===null&&e.near===null?e.column??rt:rt}function wt(e,t,n,r,i){let a=()=>{let e=n();return e?.kind===`box`?e:null},o=[{value:rt,text:`free`},...e.columns.map(e=>({value:e.id,text:e.title||e.id}))],s=[{value:``,text:`none`},...e.lanes.map(e=>({value:e.id,text:e.label||e.id}))];return[F(t.shape===`decision`?`Decision`:`Box`),I(`Title`,L(`title`,t.title,u.title,e=>{e.trim()&&i({title:e.trim()})})),I(`Shape`,R(`shape`,ct,t.shape,e=>{let t=a()?.outputs??[];e===`decision`&&i({shape:e,outputs:t.length>0?t:ft}),e===`box`&&i({shape:e,outputs:[]})})),I(`Column`,R(`column`,o,Ct(t),e=>{if(e!==rt){i({column:e,at:null,near:null});return}let n=r?.elements.find(e=>e.id===t.id);r&&n?.kind===`box`&&i({at:{x:n.x,y:n.y-r.pinnedOffsetY},near:null})})),I(`Lane`,R(`lane`,s,t.lane??``,e=>i({lane:e||null}))),I(`Change`,R(`change`,lt,t.change,e=>{i(e===`relabeled`?{change:e,was:a()?.was??t.title}:{change:e,was:null})})),...t.change===`relabeled`?[I(`Was`,L(`was`,t.was??``,u.title,e=>{e.trim()&&i({was:e.trim()})}))]:[],...t.shape===`decision`?[St(t,()=>a()?.outputs??null,i)]:[],vt(`this box`,t.refs,()=>a()?.refs??null,e=>i({refs:e})),bt(`this box`,t.lines,()=>a()?.lines??null,e=>i({lines:e}))]}function Tt(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[F(`Wire`),I(`Label`,L(`label`,t.label??``,Ze,e=>n({label:e.trim()||null}))),I(`Tone`,R(`tone`,st,t.tone,e=>n({tone:e}))),pt(`dashed`,`dashed`,t.dashed,e=>n({dashed:e})),pt(`back`,`returns to an earlier step`,t.back,e=>n({back:e})),I(`Leaves from`,R(`fromSide`,dt,t.fromSide??``,e=>n({fromSide:e||null}))),I(`Arrives at`,R(`toSide`,dt,t.toSide??``,e=>n({toSide:e||null}))),...i.length>0?[I(`From output`,R(`fromOutput`,i,t.fromOutput??``,e=>n({fromOutput:e||null})))]:[]]}function Et(e,t){return[F(`Frame`),I(`Title`,L(`title`,e.title,u.title,e=>t({title:e.trim()}))),pt(`loop`,`repeats as a loop`,e.loop,e=>t({loop:e}))]}function Dt(e,t,n){return[F(`Panel`),I(`Title`,L(`title`,e.title,u.title,e=>{e.trim()&&n({title:e.trim()})})),bt(`this panel`,e.lines,()=>{let e=t();return e?.kind===`panel`?e.lines:null},e=>n({lines:e}))]}function Ot(e,t,n){let r=ht(t,n),i=e.map((e,t)=>{let n=f(`div`,`wb-inspect-row wb-inspect-legend-row`),i=t+1;return n.append(R(`legend-${t}-tone`,st,e.tone,e=>{let n=at.find(t=>t===e);n&&r.edit(t,e=>({...e,tone:n}))},`Legend entry ${i} tone`),L(`legend-${t}-label`,e.label,Ze,e=>{e.trim()&&r.edit(t,t=>({...t,label:e.trim()}))},`Legend entry ${i} label`),pt(`legend-${t}-dashed`,`dashed`,e.dashed,e=>r.edit(t,t=>({...t,dashed:e}))),pt(`legend-${t}-back`,`returns`,e.back,e=>r.edit(t,t=>({...t,back:e}))),z(`legend-${t}-remove`,`remove`,()=>r.remove(t),`Remove legend entry ${e.label}`)),n}),a=z(`legend-add`,`add entry`,()=>r.append(()=>({tone:`plain`,dashed:!1,back:!1,label:`meaning`})));return a.disabled=e.length>=Ye,mt(`Legend`,i,a)}function kt(e,t){return[F(`Note`),I(`Ref`,_t(`ref`,e.ref,e=>t({ref:e}),`Ref`)),f(`p`,`wb-inspect-hint`,`Edit a note from its box.`)]}function At(e,t,n){return[F(`Unit`),I(`Status`,R(`unit-status`,ut,e.status,e=>{let t=s.find(t=>t===e);t&&n({status:t})})),vt(`this unit`,e.refs,()=>{let e=t();return e?.kind===`unit`?e.refs:null},e=>n({refs:e})),f(`p`,`wb-inspect-hint`,`Agents edit units with glimmervoid whiteboard plan.`)]}function jt(e,t,n,r,i){let a=[{value:``,text:`none`},...r];return[F(`Board`),z(`board-settings-close`,`close`,i,`Close board settings`),I(`Title`,L(`board-title`,e.title,u.title,e=>{e.trim()&&n([{op:`board`,title:e.trim()}])})),I(`Caption`,L(`board-caption`,e.caption??``,$e,e=>n([{op:`board`,caption:e.trim()||null}]))),I(`Code session`,R(`board-code-session`,a,e.codeSessionId??``,e=>n([{op:`board`,codeSessionId:e||null}]))),Ot(e.legend,()=>t()?.legend??null,e=>n([{op:`board`,legend:e}]))]}function Mt(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 wt(e,t,o,r,a);case`wire`:return Tt(e,t,a);case`frame`:return Et(t,a);case`panel`:return Dt(t,o,a);case`note`:return kt(t,a);case`unit`:return At(t,o,a)}}function Nt(e,t,n){let r=he(t);if(r.length===0)return[];let i=e.codeSessionId!==null,a=r.map((e,t)=>{let r=f(`div`,`wb-inspect-row wb-inspect-review-row`),a=z(`review-${t}`,`open in review`,()=>n(e),`Open ${e} in review`);return a.disabled=!i,r.append(f(`code`,`wb-inspect-ref`,e),a),r}),o=i?[]:[f(`p`,`wb-inspect-hint`,`Set the board code session to open refs in review.`)];return[F(`In review`),...a,...o]}function Pt(e,t,n){let r=f(`div`,`wb-inspect-review`);return r.append(...Nt(e,t,n)),r}function Ft(e){let t=document.activeElement;return e.contains(t)&&t instanceof HTMLInputElement&&t.type===`text`}function It(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(...Nt(n,i,e.openRef))}function c(t,r){if(r.size>1)return[F(`${r.size} selected`)];let i=o(t,r);return i?[...Mt(t,i,e.currentBoard,e.layout(),n),Pt(t,i,e.openRef)]:jt(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(Ft(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 Lt=`http://www.w3.org/2000/svg`,B=12,Rt=26,V=20,zt=18,Bt=17,Vt=14,Ht=16,Ut=24,Wt=18,Gt=`Plan`,Kt=`open linked board`,qt=5,Jt=10,Yt=17,Xt=6,Zt=20,Qt=12,$t=4,en=3,tn=7.2,nn=13,rn=17,an=2.2,on=28,sn=()=>null;function cn(e){return Object.entries(e).flatMap(([e,t])=>t===null?[]:[` ${e}="${x(t)}"`]).join(``)}function H(e,t,n=``){return`<${e}${cn(t)}>${n}</${e}>`}function U(e,t,n,r,i={}){return H(`text`,{x:t,y:n,class:r,...i},x(e))}function W(e,t,n){return H(`g`,{class:`wb-element ${t}`,"data-element-id":e.id,"data-element-kind":e.kind},n.join(``))}function ln(e){return e?`stroke:${e}`:null}function un(e){let t=e.x+e.width,n=e.y+e.headerHeight/2,r=`M${e.x+Qt},${e.y} H${t-Qt} L${t},${n}`;return e.outputs.length===0?`${r} L${t-Qt},${e.y+e.height} H${e.x+Qt} L${e.x},${n} Z`:`${r} V${e.y+e.height} H${e.x} V${n} Z`}function dn(e){return e.outputs.flatMap(t=>{let n=(e.height-e.headerHeight)/e.outputs.length/2,r=t.port.y-n;return[H(`line`,{x1:e.x,y1:r,x2:e.x+e.width,y2:r,class:`wb-output-divider`}),U(t.label,e.x+B,t.port.y+$t,`wb-output-label`),H(`circle`,{cx:t.port.x,cy:t.port.y,r:en,class:`wb-output-dot`})]})}function fn(e){return e.style===`code`?`wb-box-line wb-line-code`:e.muted?`wb-box-line wb-muted`:`wb-box-line`}function pn(e,t,n,r){let i=t+B+(e.muted?Vt:0),a=[];return e.style===`code`&&a.push(H(`rect`,{x:i-4,y:r-nn,width:t+n-B+4-i+4,height:rn,rx:3,class:`wb-code-band`})),e.style===`item`&&e.isFirstRow&&a.push(H(`circle`,{cx:i+4,cy:r-4,r:an,class:`wb-item-dot`})),e.marker!==null&&a.push(U(e.marker,i,r,e.style===`kv`?`wb-line-key`:`wb-line-marker`)),e.text&&a.push(U(e.text,i+e.indentChars*tn,r,fn(e))),a}function mn(e,t,n,r){return e.flatMap((e,i)=>pn(e,t,n,r+i*zt))}function hn(e){let t=[H(`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(U(n,e.x+B,e.y+Rt+r*V,`wb-box-title`))});let n=e.y+Rt+e.titleLines.length*V;return e.bodyLines.length>0&&t.push(H(`line`,{x1:e.x+B,y1:n-12,x2:e.x+e.width-B,y2:n-12,class:`wb-panel-rule`})),t.push(...mn(e.bodyLines,e.x,e.width,n)),W(e,`wb-panel`,t)}function gn(e){return e.shape===`decision`?H(`path`,{d:un(e),class:`wb-box-outline`,style:ln(e.lane?.hex)}):H(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:8,class:`wb-box-outline`,style:ln(e.lane?.hex)})}function _n(e,t){let n=t(e),r=e.alt||e.kind,i=H(`title`,{},x(r));return n?[H(`image`,{href:n,x:e.x,y:e.y,width:e.width,height:e.height,preserveAspectRatio:`xMidYMid meet`,class:`wb-image`},i)]:[H(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:6,class:`wb-image-placeholder`},i),U(r,e.x+e.width/2,e.y+e.height/2+4,`wb-image-placeholder-text`,{"text-anchor":`middle`})]}function vn(e,t){let n=[gn(e),...dn(e)],r=e.x+e.width/2,i=e.y+e.height/2;for(let[t,a]of[[r,e.y],[e.x+e.width,i],[r,e.y+e.height],[e.x,i]])n.push(H(`circle`,{cx:t,cy:a,r:qt,class:`wb-port`}));e.wasLines.forEach((t,r)=>{n.push(U(t,e.x+B,e.y+Rt+r*V,`wb-box-was`))});let a=e.y+Rt+e.wasLines.length*V;e.titleLines.forEach((t,r)=>{n.push(U(t,e.x+B,a+r*V,`wb-box-title`))});let o=a+e.titleLines.length*V;if(n.push(...mn(e.bodyLines,e.x,e.width,o)),e.media&&n.push(..._n(e.media,t)),e.lane&&e.showsLanePill){let t=e.y+e.headerHeight-28,r=Math.min(e.width-24,16+e.lane.label.length*8);n.push(H(`rect`,{x:e.x+B,y:t,width:r,height:18,rx:9,class:`wb-lane-pill`,style:ln(e.lane.hex)}),U(e.lane.label,e.x+B+8,t+13,`wb-lane-pill-text`,{style:`fill:${e.lane.hex}`}))}return n.push(H(`rect`,{x:e.x+e.width-Jt,y:e.y+e.height-Jt,width:Jt,height:Jt,rx:2,class:`wb-resize-handle`})),W(e,e.change===`none`?`wb-box`:`wb-box wb-change-${e.change}`,n)}function yn(e){let t=e.x+e.width-Zt,n=e.y+Xt+6;return H(`path`,{d:`M ${t+Xt} ${n} A ${Xt} ${Xt} 0 1 1 ${t} ${n-Xt}`,"marker-end":`url(#wb-arrow)`,class:`wb-loop-badge`})}function bn(e){let t=[H(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:12,class:`wb-frame-outline`}),U(e.title,e.x+14,e.y+18,`wb-frame-title`)];return e.isLoop&&t.push(yn(e)),W(e,e.isLoop?`wb-frame wb-loop`:`wb-frame`,t)}function xn(e){let t=[H(`path`,{d:e.path,class:`wb-wire-hit`}),H(`path`,{d:e.path,"marker-end":e.hasArrowhead?`url(#wb-arrow)`:null,class:e.isDashed?`wb-wire-line wb-dashed`:`wb-wire-line`,style:ln(e.strokeHex??void 0)}),H(`circle`,{cx:e.start.x,cy:e.start.y,r:3,class:`wb-wire-dot`})];return e.joinAt&&t.push(H(`circle`,{cx:e.joinAt.x,cy:e.joinAt.y,r:3,class:`wb-wire-dot`})),e.label&&t.push(U(e.label,e.labelAt.x,e.labelAt.y,`wb-wire-label`)),W(e,e.isBack?`wb-wire wb-back wb-tone-${e.tone}`:`wb-wire wb-tone-${e.tone}`,t)}function Sn(e){let t=[H(`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(U(n,e.x+10,e.y+22+r*Bt,`wb-note-text`))}),e.byline&&t.push(U(e.byline,e.x+10,e.y+22+e.lines.length*Bt,`wb-note-byline`)),W(e,e.isResolved?`wb-note wb-resolved`:`wb-note`,t)}function Cn(e){let t=[H(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:8,class:`wb-unit-outline`}),U(e.label,e.x+B,e.y+Ut,`wb-unit-label`),U(e.status,e.x+e.width-B,e.y+Ut,`wb-unit-status wb-unit-${e.status}`,{"text-anchor":`end`})],n=e.y+Ut+Wt;e.titleLines.forEach((r,i)=>{t.push(U(r,e.x+B,n+i*V,`wb-box-title`))});let r=n+e.titleLines.length*V;return t.push(...mn(e.bodyLines,e.x,e.width,r)),e.linkedBoardId&&t.push(U(Kt,e.x+B,r+e.bodyLines.length*zt,`wb-unit-link`,{"data-linked-board-id":e.linkedBoardId})),W(e,`wb-unit`,t)}function wn(e,t=sn){switch(e.kind){case`box`:return vn(e,t);case`frame`:return bn(e);case`wire`:return xn(e);case`note`:return Sn(e);case`unit`:return Cn(e);case`panel`:return hn(e)}}function Tn(e){let t=[];if(e.plan){t.push(U(Gt,e.plan.titleAt.x,e.plan.titleAt.y,`wb-column-title`));for(let n of e.plan.arrowPaths)t.push(H(`path`,{d:n,"marker-end":`url(#wb-arrow)`,class:`wb-wire-line`}))}for(let n of e.bands)t.push(H(`line`,{x1:n.x,y1:n.y,x2:n.x+n.width,y2:n.y,class:`wb-band-rule`})),n.label&&t.push(U(n.label,n.x,n.y+Yt,`wb-band-label`,{style:`fill:${n.hex}`}));for(let n of e.columns)n.titleLines.length!==0&&(n.titleLines.forEach((e,r)=>{t.push(U(e,n.x,n.titleBaselineY+r*Ht,`wb-column-title`))}),t.push(H(`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(Dn(n));return e.caption&&t.push(U(e.caption.text,e.caption.x,e.caption.y+16,`wb-caption`)),H(`g`,{class:`wb-chrome`},t.join(``))}function En(e){let{swatch:t}=e;if(t.kind===`lane`)return H(`rect`,{x:e.x,y:e.y,width:14,height:14,rx:3,class:`wb-legend-swatch`,style:`fill:${t.hex}`});if(t.kind===`status`)return H(`rect`,{x:e.x,y:e.y,width:14,height:14,rx:3,class:`wb-legend-swatch wb-unit-outline wb-unit-${t.status}`});if(t.kind===`change`)return H(`g`,{class:`wb-change-${t.change}`},H(`rect`,{x:e.x,y:e.y,width:on,height:14,rx:3,class:`wb-legend-swatch wb-box-outline`}));let n=H(`path`,{d:`M${e.x},${e.y+7} H${e.x+on}`,"marker-end":`url(#wb-arrow)`,class:t.isDashed?`wb-wire-line wb-dashed`:`wb-wire-line`});return H(`g`,{class:t.isBack?`wb-back wb-tone-${t.tone}`:`wb-tone-${t.tone}`},n)}function Dn(e){let t=e.x+(e.swatch.kind===`lane`||e.swatch.kind===`status`?22:40);return En(e)+U(e.label,t,e.y+12,`wb-legend-text`)}function On(){return H(`defs`,{},H(`marker`,{id:`wb-arrow`,viewBox:`0 0 10 10`,refX:9,refY:5,markerWidth:8,markerHeight:8,orient:`auto-start-reverse`},H(`path`,{d:`M 0 1 L 10 5 L 0 9 z`,fill:`context-stroke`})))}var kn={worthALookIds:new Set,flaggedUnitIds:new Set},An=9;function G(e,t=``){let n=document.createElementNS(Lt,e);return t&&n.setAttribute(`class`,t),n}function jn(e){let t=G(`g`);return t.innerHTML=e,[...t.children]}function Mn(e){let[t]=jn(e);if(!(t instanceof SVGGElement))throw Error(`the whiteboard markup did not draw a group`);return t}function Nn(e){let t=r(e);return t?`${i}/${t}`:null}var Pn={frame:`frames`,wire:`wires`,box:`boxes`,panel:`boxes`,note:`notes`,unit:`units`},Fn=[`box`,`frame`,`wire`,`note`,`unit`,`panel`];function In(e,t){let n={frames:G(`g`,`wb-layer`),wires:G(`g`,`wb-layer`),boxes:G(`g`,`wb-layer`),notes:G(`g`,`wb-layer`),units:G(`g`,`wb-layer`)},r=G(`g`);e.replaceChildren(...jn(On()),r,n.frames,n.wires,n.boxes,n.notes,n.units);let i=new Map,a=null,o=new Set,s=kn;function c(e,t){t.classList.toggle(`is-selected`,o.has(e))}function l(e){let t=G(`g`,`wb-look-marker`),n=e.x+e.width,r=e.y,i=G(`circle`);i.setAttribute(`cx`,String(n)),i.setAttribute(`cy`,String(r)),i.setAttribute(`r`,String(An));let a=G(`text`);return a.setAttribute(`x`,String(n)),a.setAttribute(`y`,String(r+4)),a.setAttribute(`text-anchor`,`middle`),a.textContent=`!`,t.setAttribute(`role`,`img`),t.setAttribute(`aria-label`,`worth a look in review`),t.append(i,a),t}function u(e,t){t.classList.toggle(`is-flagged`,s.flaggedUnitIds.has(e.id));let n=t.querySelector(`:scope > .wb-look-marker`);e.kind===`wire`||!s.worthALookIds.has(e.id)?n?.remove():n||t.append(l(e))}function d(t){e.setAttribute(`viewBox`,`${t.x} ${t.y} ${t.width} ${t.height}`),e.setAttribute(`width`,String(t.width)),e.setAttribute(`height`,String(t.height)),e.style.left=`${t.x}px`,e.style.top=`${t.y}px`}function f(e){let o=C(e);d(o.bounds);let s=Mn(Tn(o));r.replaceWith(s),r=s;let l=new Set;for(let e of o.elements){l.add(e.id);let t=se(e),r=i.get(e.id);if(r?.signature===t)continue;let a=Mn(wn(e,Nn));c(e.id,a),u(e,a),r&&r.node.replaceWith(a),r||n[Pn[e.kind]].append(a),i.set(e.id,{signature:t,node:a})}for(let[e,t]of i)l.has(e)||(t.node.remove(),i.delete(e));return t.sync(o),a=o,o}function p(e){if(!(e instanceof Element))return null;let t=e.closest(`.wb-element`),n=t?.dataset.elementId,r=Fn.find(e=>e===t?.dataset.elementKind);return!n||!r?null:{id:n,kind:r}}function m(e){o=e;for(let[e,t]of i)c(e,t.node)}function h(e){s=e;for(let e of a?.elements??[]){let t=i.get(e.id)?.node;t&&u(e,t)}}function g(){for(let e of i.values())e.node.remove();i.clear();let e=G(`g`);r.replaceWith(e),r=e,t.clear(),a=null}return{render:f,layout:()=>a,elementFromTarget:p,nodeOf:e=>i.get(e)?.node??null,setSelection:m,setReviewMarks:h,clear:g}}var Ln=1280,Rn={video:`play`,page:`use page`};function zn(e){return e?.kind===`video`||e?.kind===`page`}function Bn(e){return`${i}/${a(e)}`}function Vn(e){return JSON.stringify([e.kind,e.asset,e.mime,e.alt])}function Hn(e,t){e.style.left=`${t.x}px`,e.style.top=`${t.y}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`;let n=e.querySelector(`iframe.wb-media-page`);if(!n)return;let r=t.width/Ln;n.style.width=`${Ln}px`,n.style.height=`${t.height/r}px`,n.style.transform=`scale(${r})`}function Un(e){let t=ce({source:{kind:`url`,url:Bn(e)},className:`wb-media-page`,title:e.alt||`page`,allowsScripts:!0});return t.tabIndex=-1,t}function Wn({viewport:e,boardHost:t,onOpenFullSize:n}){let r=f(`div`,`wb-media-layer`),i=new Map,a=null;function o(t,r){let i=f(`div`,`wb-media`);i.dataset.boxId=t,i.dataset.mediaKind=r.kind,r.kind===`page`&&i.append(Un(r)),Hn(i,r);let a=f(`div`,`wb-media-controls`),o=c({variant:`secondary`,label:Rn[r.kind],action:`activate-media`,onClick:()=>l(t)});o.classList.add(`wb-media-activate`);let s=c({variant:`secondary`,label:`done`,action:`deactivate-media`,onClick:()=>{u(),e.focus()}});s.classList.add(`wb-media-done`);let d=c({variant:`secondary`,label:`full size`,action:`open-media-full-size`,onClick:()=>{u(),n(t,r.alt)}});return a.append(o,s,d),i.append(a),i.addEventListener(`pointerdown`,e=>{(i.hasAttribute(`data-active`)||a.contains(e.target instanceof Node?e.target:null))&&e.stopPropagation()}),i.addEventListener(`dblclick`,e=>e.stopPropagation()),i.addEventListener(`wheel`,e=>{i.hasAttribute(`data-active`)&&e.stopPropagation()}),i}function s(n){n.key===`Escape`&&n.target instanceof Node&&t.contains(n.target)&&(n.preventDefault(),n.stopPropagation(),u(),e.focus())}function l(e){let t=i.get(e);if(!t||a===e)return;u(),a=e,t.node.dataset.active=``,document.addEventListener(`keydown`,s,!0);let n=t.node.querySelector(`iframe.wb-media-page`);if(n){n.tabIndex=0,t.node.querySelector(`.wb-media-done`)?.focus();return}let r=f(`video`,`wb-media-video`);r.src=Bn(t.media),r.controls=!0,r.playsInline=!0,r.autoplay=!0,t.node.prepend(r),r.focus()}function u(){let e=a?i.get(a):void 0;if(a=null,document.removeEventListener(`keydown`,s,!0),!e)return;delete e.node.dataset.active;let t=e.node.querySelector(`video.wb-media-video`);t?.pause(),t?.remove();let n=e.node.querySelector(`iframe.wb-media-page`);n&&(n.tabIndex=-1)}function d(e){let t=new Set;for(let n of e.elements){if(n.kind!==`box`||!zn(n.media))continue;t.add(n.id);let e=Vn(n.media),s=i.get(n.id);if(s?.identity===e){Hn(s.node,n.media);continue}a===n.id&&u();let c=o(n.id,n.media);s&&s.node.replaceWith(c),s||r.append(c),i.set(n.id,{identity:e,node:c,media:n.media})}for(let[e,n]of i)t.has(e)||(a===e&&u(),n.node.remove(),i.delete(e))}function p(){u();for(let e of i.values())e.node.remove();i.clear()}return document.addEventListener(`pointerdown`,e=>{let t=a?i.get(a)?.node:void 0;t&&!t.contains(e.target instanceof Node?e.target:null)&&u()},!0),new IntersectionObserver(e=>{e.some(e=>!e.isIntersecting)&&u()}).observe(e),{element:r,sync:d,clear:p,activate:l,deactivate:u,activeBoxId:()=>a}}var Gn=`http://www.w3.org/2000/svg`,Kn=`No boards yet. Make one here, or have an agent run glimmervoid whiteboard new <title>.`,qn=`Pick a board above.`,Jn=`wb-board-title-rename`,Yn=`M13.5 8H3 M7 4L3 8l4 4`,Xn=`M4.5 6.5L8 10l3.5-3.5`,Zn=4,Qn=32,$n=new Set([`video/mp4`,`video/webm`,`text/html`]),er=/\.(png|jpe?g|gif|webp|svg|mp4|webm|html?)$/i,tr=`M2.5 6V2.5H6 M10 2.5h3.5V6 M13.5 10v3.5H10 M6 13.5H2.5V10`,nr=`M5.5 3.5l-3 3l3 3 M2.5 6.5h7a3.5 3.5 0 0 1 0 7H7`,rr=`M10.5 3.5l3 3l-3 3 M13.5 6.5h-7a3.5 3.5 0 0 0 0 7H9`,ir=[{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`,hint:null},{tool:`box`,label:`box`,key:`R`,iconPath:`M2.5 4h11v8h-11z`,hint:`Click the board to place a box. Esc to cancel.`},{tool:`decision`,label:`decision`,key:`D`,iconPath:`M8 2l6 6l-6 6l-6-6z`,hint:`Click the board to place a decision. Esc to cancel.`},{tool:`panel`,label:`panel`,key:`P`,iconPath:`M2.5 3h11v10h-11z M2.5 6h11`,hint:`Click the board to place a panel. Esc to cancel.`},{tool:`wire`,label:`wire`,key:`A`,iconPath:`M2.5 13.5L13 3 M8.5 3H13v4.5`,hint:`Drag from one box to another to connect them. Esc to cancel.`}],K=null,q=null,J=null,Y=null,ar=null,or=!0,X=null,sr=null,cr=null,Z=v(`action-status wb-status`),lr=v(`action-status wb-status`),Q=new Map,ur=Promise.resolve();function dr(e){let{dialog:t,close:n,actions:r,btnCancel:i}=h({title:e.title}),a=f(`input`,`dialog-input`);a.type=`text`,a.placeholder=e.placeholder,a.maxLength=e.maxLength,a.value=e.initialValue??``,a.autocomplete=`off`,a.setAttribute(`aria-label`,e.label);let o=f(`div`,`dialog-error`);o.setAttribute(`role`,`alert`);let s=e.choices?f(`select`,`dialog-input wb-dialog-select`):null;if(s&&e.choices){s.setAttribute(`aria-label`,e.choices.label);for(let t of e.choices.options){let e=f(`option`,null,t.text);e.value=t.value,s.append(e)}}let l=c({variant:`primary`,label:e.confirmLabel,action:`confirm-board-dialog`});r.append(l),t.append(f(`label`,`dialog-label`,e.label),a,...s?[s]:[],o,r);async function u(){let t=a.value.trim();if(!t){o.textContent=`${e.label} is empty.`;return}l.disabled=!0;let r=await e.onSubmit(t,s?.value??null);l.disabled=!1,r?o.textContent=r:n()}i.addEventListener(`click`,n),l.addEventListener(`click`,()=>void u()),a.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),u())}),requestAnimationFrame(()=>a.focus())}function $(){return K?w(K):null}function fr(){return D().find(e=>e.id===K)??null}function pr(e){let t=ur.then(e);return ur=t.catch(()=>void 0),t}function mr(e,t){return pr(()=>hr(e,t))}async function hr(e,t){let n=$(),r=await O(e,t);return r.ok&&n?.id===e&&Q.set(e,Ge(Q.get(e)??Ne,Ue(n,t))),r}function gr(e){return pr(()=>_r(e))}async function _r(e){let t=K,n=$();if(!t||!n)return;let r=Ke(Q.get(t)??Ne,e);if(!r)return;Q.set(t,r.history);let i=await O(t,r.entry);i.ok?(Z.clear(),Q.set(t,qe(Q.get(t)??Ne,e,Ue(n,r.entry)))):Z.show(`error`,`could not ${e} that change, so it was dropped: ${i.error}`)}async function vr(e){if(!K||e.length===0)return!1;let t=await mr(K,e);return t.ok?(Z.clear(),!0):(Z.show(`error`,t.error),!1)}async function yr(e){if(!K)return`No board is open.`;let t=await mr(K,e);return t.ok?null:t.error}function br(e){let t=_(e);return t?g(t):`closed session`}function xr(){let e=fr()?.connectedSessionIds??[],t=$()?.codeSessionId;return(t&&!e.includes(t)?[t,...e]:e).map(e=>({value:e,text:br(e)}))}function Sr(e){let t=$();return[...Y?.selectedIds()??new Set].flatMap(e=>t?.elements[e]??[]).filter(t=>t.kind===e)}function Cr(){if(!q)return;let e=$(),t=Sr(`box`).length;for(let t of q.toolButtons.values())t.disabled=!e;q.buttons.note.disabled=t!==1,q.buttons.frame.disabled=t===0;for(let t of[q.buttons.unit,q.buttons.fit,q.buttons.undo,q.buttons.redo])t.disabled=!e;ar?.paint(Y?.selectedIds()??new Set)}function wr(){if(!q)return;let e=D();K&&!e.some(e=>e.id===K)&&(K=null);let t=e.find(e=>X!==null&&e.connectedSessionIds.includes(X))??e[0];!K&&t&&Ur(t.id),q.boardMenu.paintBoards(e),Mr()}function Tr(){return!!q?.boardIsland.querySelector(`.${Jn}`)}function Er(){let e=fr();if(!q||!e||Tr())return;let{boardTitle:t}=q,n=f(`input`,Jn);n.type=`text`,n.value=e.title,n.maxLength=u.title,n.setAttribute(`aria-label`,`Board title`),t.replaceWith(n),n.focus(),n.select();let r=!1;function i(i){if(r||!e)return;r=!0;let a=n.value.trim();n.replaceWith(t),Mr(),i&&a&&a!==e.title&&vr([{op:`board`,title:a}])}n.addEventListener(`blur`,()=>i(!0)),n.addEventListener(`keydown`,e=>{e.stopPropagation(),(e.key===`Enter`||e.key===`Escape`)&&(e.preventDefault(),i(e.key===`Enter`))})}function Dr(e){let t=b(e.title,`visible wb-board-menu-board`);t.setAttribute(`role`,`menuitemradio`),t.setAttribute(`aria-checked`,String(e.id===K));let n=e.connectedSessionIds.length;return n>0&&t.append(f(`span`,`wb-board-menu-count`,String(n))),t.addEventListener(`click`,()=>Ur(e.id)),t}function Or(e){let t=f(`div`,`session-overflow wb-board-menu`),n=f(`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`,!pi()),n.classList.toggle(`open`,e),a.setAttribute(`aria-expanded`,String(e))},a=o({label:`board menu`,action:`open-board-menu`,onClick:()=>i(!r())});a.setAttribute(`aria-haspopup`,`menu`),a.setAttribute(`aria-expanded`,`false`);let s=(e,t,n=``)=>{let r=b(e,`visible ${n}`.trim());return r.addEventListener(`click`,t),r},c=f(`div`,`menu-divider`);c.setAttribute(`role`,`separator`);let l=s(`board settings`,e),u=[c,s(`rename board`,Er),s(`new board`,Qr),l,s(`delete board`,Zr,`wb-board-menu-danger`)];return n.addEventListener(`click`,e=>{e.target instanceof HTMLElement&&e.target.closest(`[role^="menuitem"]`)&&i(!1)}),t.append(a,n),y({trigger:a,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:a,paintBoards:e=>n.replaceChildren(...e.map(Dr),...u)}}function kr(t){let n=f(`div`,`session-overflow wb-more-menu`),r=f(`div`,`popup-menu session-overflow-menu wb-more-menu-popup`);r.setAttribute(`role`,`menu`),r.setAttribute(`aria-label`,`More tools`);let i=()=>r.classList.contains(`open`),a=e=>{r.classList.toggle(`open`,e),o.setAttribute(`aria-expanded`,String(e)),e&&Ar(r,o)},o=c({variant:`quiet`,label:`more`,icon:e(Xn,`1.5`),action:`open-more-tools`,onClick:()=>a(!i())});return o.classList.add(`wb-more-trigger`),o.setAttribute(`aria-haspopup`,`menu`),o.setAttribute(`aria-expanded`,`false`),r.append(...t),r.addEventListener(`click`,e=>{e.target instanceof HTMLElement&&e.target.closest(`[role="menuitem"]`)&&a(!1)}),n.append(o),document.body.append(r),y({trigger:o,menu:r,menuItems:()=>[...r.querySelectorAll(`[role="menuitem"]:not(:disabled)`)],isOpen:i,open:()=>a(!0),close:()=>a(!1)}),document.addEventListener(`click`,e=>{i()&&e.target instanceof Node&&!n.contains(e.target)&&!r.contains(e.target)&&a(!1)}),window.addEventListener(`resize`,()=>a(!1)),n}function Ar(e,t){let n=t.getBoundingClientRect(),r=n.bottom+Zn+e.offsetHeight<=window.innerHeight;e.style.right=`${Math.max(0,window.innerWidth-n.right)}px`,e.style.top=r?`${n.bottom+Zn}px`:`auto`,e.style.bottom=r?`auto`:`${window.innerHeight-n.top+Zn}px`}function jr(e,t,n){let r=b(e,`visible`);return r.dataset.action=t,r.addEventListener(`click`,n),r}function Mr(){if(!q)return;let e=fr(),t=D().length>0;q.canvas.hidden=!e,q.empty.hidden=!!e,q.emptyText.textContent=t?qn:Kn,e&&(q.boardTitle.textContent=e.title,q.boardMeta.textContent=`v${e.version}`,Cr(),Fr())}function Nr(e){if(!q)return;let t=e.map(br),n=e.filter(e=>e!==X).map(br),r=f(`span`,t.length===0?`wb-presence-count wb-presence-none`:`wb-presence-count wb-presence-pill`,`${t.length} connected`);q.presence.replaceChildren(...n.map(e=>f(`span`,`wb-presence-pill`,e)),r),t.length===0&&q.presence.prepend(f(`span`,`wb-presence-none`,`no sessions connected`))}function Pr(e,t){let n=br(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 Fr(){if(!q)return;let e=fr();Nr(e?.connectedSessionIds??[]),q.agentIsland.hidden=!X,X&&(q.agentIsland.toggleAttribute(`data-idle`,!Ir(e,X)),q.queuedForSession.textContent=Pr(e,X),q.sendToAgent.disabled=!e?.connectedSessionIds.includes(X))}function Ir(e,t){return!e?.connectedSessionIds.includes(t)||(e.queuedBySessionId[t]??0)>0}async function Lr(){if(!q||!K||!X)return;q.sendToAgent.disabled=!0,lr.show(`busy`,`sending`);let e=await ie(K,X);Fr(),e.ok?lr.show(`ok`,`sent; the agent reads the board when it is ready`):lr.show(`error`,e.error)}function Rr(e,t){let n=new Set(t);return new Set(Object.values(e.elements).filter(e=>he(e).some(e=>n.has(ge(e)??``))).map(e=>e.id))}function zr(e){let t=$()?.codeSessionId,n=ge(e);t&&n&&T(t,n)}function Br(){if(!q||!J)return;let e=$(),t=e&&sr?.boardId===e.id?sr.review:null;J.setReviewMarks({worthALookIds:e&&t?Rr(e,t.worthALookPaths):new Set,flaggedUnitIds:new Set(t?.flaggedUnitIds??[])})}function Vr(e){let t=`${e.id}@${e.version}`;cr!==t&&(cr=t,A(e.id).then(n=>{cr===t&&(n.ok?(sr={boardId:e.id,review:n.review},Br()):cr=null)}))}function Hr(){if(!J)return;let e=$();e?(Vr(e),Y?.pruneSelection(e),J.render(Y?.previewOf(e)??e),q&&(q.emptyBoardHint.hidden=Object.keys(e.elements).length>0),Br(),Y?.openPendingTitleEdit(),or&&=(Y?.fit(),!1),Cr()):(J.clear(),q&&(q.emptyBoardHint.hidden=!0))}function Ur(e){K!==e&&(K=e,or=!0,Y?.clearSelection(),Y?.closeTitleInput(),ar?.closeBoardSettings(),J?.clear(),Z.clear(),wr(),ae(e).then(Hr))}function Wr(){let e=$();if(!e)return;let t=D().filter(t=>t.id!==e.id),n=[{value:``,text:`No linked board`},...t.map(e=>({value:e.id,text:e.title}))];dr({title:`Add a unit`,label:`Unit title`,placeholder:`index the diffs`,maxLength:u.title,confirmLabel:`Add unit`,choices:t.length>0?{label:`Linked board`,options:n}:void 0,onSubmit:(e,t)=>yr([{op:`add`,element:{kind:`unit`,id:j(`unit`),title:e,lines:[],refs:[],status:`planned`,after:[],linkedBoardId:t||null}}])})}function Gr({boxId:e}){let t=e?$()?.elements[e]:void 0;return t?.kind===`box`?t.media:null}function Kr(e,t){let n=t?`${i}/${a(t)}`:e.href;if(t?.kind===`page`)return ce({source:{kind:`url`,url:n},className:`wb-image-viewer-page`,title:e.alt||`page`,allowsScripts:!0});if(t?.kind===`video`){let e=f(`video`,`wb-image-viewer-video`);return e.src=n,e.controls=!0,e.playsInline=!0,e}let r=f(`img`,`wb-image-viewer-picture`);return r.src=n,r.alt=e.alt,r}function qr(e){let{alt:t}=e,n=Gr(e);if(!n&&!e.href)return;let{dialog:r,close:i,actions:a,btnCancel:o}=h({title:t||`Picture`,dialogClass:`dialog wb-image-viewer`,cancelLabel:`Close`});r.append(Kr(e,n),a),o.addEventListener(`click`,i),requestAnimationFrame(()=>o.focus())}function Jr(e){dr({title:`Pin a note`,label:`Note`,placeholder:`what about retries?`,maxLength:u.noteText,confirmLabel:`Pin note`,onSubmit:t=>yr([{op:`add`,element:{kind:`note`,id:j(`note`),on:e,text:t,ref:null,author:``,resolvedBy:null}}])})}function Yr(e,t){let n=$();n&&e!==t&&(Object.values(n.elements).some(n=>n.kind===`wire`&&n.from===e&&n.to===t)||vr([{op:`add`,element:{kind:`wire`,id:j(`wire`),from:e,to:t,fromOutput:null,dashed:!1,tone:`plain`,label:null,fromSide:null,toSide:null,back:!1}}]))}function Xr(){let e=Sr(`box`).map(e=>e.id);e.length!==0&&dr({title:`Frame the selected boxes`,label:`Frame title`,placeholder:`intake`,maxLength:u.title,confirmLabel:`Add frame`,onSubmit:async t=>{let n=await yr([{op:`add`,element:{kind:`frame`,id:j(`frame`),title:t,contains:e,loop:!1}}]);return n||Y?.clearSelection(),n}})}function Zr(){let e=fr();if(!e)return;let t=e.connectedSessionIds.map(br),n=t.length>0?` ${t.join(`, `)} ${t.length===1?`is`:`are`} connected and will lose it.`:``;p({title:`Delete board`,message:`Delete "${e.title}" for good?${n}`,confirmLabel:`Delete board`,danger:!0,onConfirm:()=>{k(e.id).then(e=>{e.ok||Z.show(`error`,e.error)})}})}function Qr(){$r(Ur)}function $r(e){dr({title:`New board`,label:`Board title`,placeholder:`knowledge writer`,maxLength:u.title,confirmLabel:`Create board`,onSubmit:async t=>{let n=await ee(t);return n.ok?(e(n.boardId),null):n.error}})}function ei(t,n,r,i){return c({variant:`icon`,label:t,icon:e(n,`1.5`),action:r,onClick:i})}function ti(n,r,i,a){let o=t(`wb-tool`);o.setAttribute(`aria-label`,r);let s=f(`span`,`wb-tool-key`,i);return s.setAttribute(`aria-hidden`,`true`),o.append(e(a,`1.5`),s),o.setAttribute(`aria-keyshortcuts`,i),o.setAttribute(`aria-pressed`,String(n===`select`)),o.addEventListener(`click`,()=>{Y?.setTool(n),Y?.focusCanvas()}),o}function ni(e,t,...n){let r=f(`div`,`wb-island ${e}`);return r.setAttribute(`role`,`toolbar`),r.setAttribute(`aria-label`,t),r.append(...n),r}function ri(e){if(!q)return;for(let[t,n]of q.toolButtons)n.setAttribute(`aria-pressed`,String(t===e));let t=ir.find(({tool:t})=>t===e)?.hint??null;q.toolHint.textContent=t??``,q.toolHint.hidden=t===null}function ii(e){return!(e.metaKey||e.ctrlKey)||e.altKey||e.code!==`KeyZ`?null:e.shiftKey?`redo`:`undo`}function ai(e,t){let n=ii(t);n&&e.checkVisibility()&&!m()&&!d(t)&&(document.activeElement?.classList.contains(`xterm-helper-textarea`)||(t.preventDefault(),gr(n)))}function oi(e){return e.type.startsWith(`image/`)||$n.has(e.type)?!0:e.type===``&&er.test(e.name)}function si(e){return[...e?.files??[]].filter(oi)}function ci(e){return(e.name.replace(/\.[^.]+$/,``)||`Picture`).slice(0,u.title)}async function li(e,t){if(K&&e.length!==0){Z.show(`busy`,e.length===1?`adding ${e[0]?.name}`:`adding ${e.length} files`);for(let[n,r]of e.entries()){let e=await ne(r);if(!e.ok){Z.show(`error`,e.error);return}let i=n*Qn,a=t?{x:t.x+i,y:t.y+i}:null,o={...e.media,alt:r.name.slice(0,u.line)};if(!await Y?.placeMediaBox(ci(r),o,a))return}Z.clear()}}function ui(e,t){t.addEventListener(`dragover`,e=>{K&&e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}),t.addEventListener(`drop`,e=>{let t=si(e.dataTransfer);t.length!==0&&(e.preventDefault(),li(t,{x:e.clientX,y:e.clientY}))}),document.addEventListener(`paste`,t=>{if(!e.checkVisibility()||m()||di())return;let n=si(t.clipboardData);n.length!==0&&(t.preventDefault(),li(n,null))})}function di(){let e=document.activeElement;return e?.classList.contains(`xterm-helper-textarea`)?!0:e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function fi(){if(q)return q.host;let e=f(`div`,`boards-view`),n=Or(()=>{Y?.clearSelection(),ar?.openBoardSettings()});n.trigger.dataset.phoneVisible=``;let r=t(`wb-board-title pane-header-title`);r.addEventListener(`click`,Er);let i=f(`span`,`wb-board-meta pane-header-subtitle`),a=f(`div`,`wb-presence`),o=ni(`wb-island-board`,`Board`,n.menuRoot,r,i,a,Z.element),s=new Map(ir.map(({tool:e,label:t,key:n,iconPath:r})=>[e,ti(e,t,n,r)])),l=f(`div`,`wb-tools`);l.setAttribute(`role`,`group`),l.setAttribute(`aria-label`,`Drawing tools`),l.append(...s.values());let u={note:jr(`note on box`,`add-note`,()=>{let[e]=Sr(`box`);e&&Jr(e.id)}),frame:jr(`frame selected boxes`,`add-frame`,Xr),unit:jr(`plan step`,`add-unit`,Wr),fit:ei(`fit`,tr,`fit-board`,()=>Y?.fit()),undo:ei(`undo`,nr,`undo-board-edit`,()=>void gr(`undo`)),redo:ei(`redo`,rr,`redo-board-edit`,()=>void gr(`redo`))};u.fit.dataset.phoneVisible=``;let d=f(`span`,`wb-divider`);d.setAttribute(`aria-hidden`,`true`);let p=ni(`wb-island-tools`,`Board tools`,l,d,kr([u.note,u.frame,u.unit])),m=f(`p`,`wb-tool-hint`);m.setAttribute(`aria-live`,`polite`),m.hidden=!0;let h=ni(`wb-island-view`,`View`,u.fit,u.undo,u.redo),g=f(`div`,`wb-canvas`),_=f(`div`,`wb-viewport`);_.setAttribute(`role`,`application`),_.setAttribute(`aria-label`,`Whiteboard`);let v=f(`div`,`wb-world`),y=document.createElementNS(Gn,`svg`);y.setAttribute(`class`,`wb-svg`),y.setAttribute(`aria-hidden`,`true`);let b=Wn({viewport:_,boardHost:g,onOpenFullSize:(e,t)=>qr({boxId:e,href:``,alt:t})});v.append(y,b.element),_.append(v);let x=f(`aside`,`wb-inspect`),S=f(`span`,`wb-session-queued`),ee=ei(`send to agent`,Yn,`send-board-to-agent`,()=>void Lr()),C=ni(`wb-island-agent`,`Session`,ee,S,lr.element);C.hidden=!0;let w=f(`div`,`wb-bottom-left`);w.append(C);let T=f(`div`,`wb-top-left`);T.append(o,h,p,m);let ne=f(`div`,`wb-top-right`);ne.append(x);let E=f(`div`,`wb-empty-board`);E.hidden=!0;let D=f(`p`,`wb-empty-board-desc`);D.append(f(`span`,`wb-empty-board-keys`,`Pick box (R) and click the board to place one, or ask a session to draw here.`),f(`span`,`wb-empty-board-touch`,`Ask a session to draw here.`)),E.append(f(`p`,`wb-empty-board-title`,`This board is empty.`),D),g.append(_,E,ne,T,w);let O=f(`p`,`wb-empty-text`,Kn),k=f(`div`,`wb-empty`);k.append(O,c({variant:`secondary`,label:`new board`,action:`new-board`,onClick:Qr})),e.replaceChildren(g,k),q={boardIsland:o,boardMenu:n,boardTitle:r,boardMeta:i,presence:a,host:e,chrome:T,canvas:g,empty:k,emptyText:O,agentIsland:C,queuedForSession:S,sendToAgent:ee,buttons:u,toolButtons:s,toolHint:m,emptyBoardHint:E};let A=In(y,b);return J=A,ar=It({container:x,currentBoard:$,layout:()=>A.layout(),sendOps:vr,codeSessionChoices:xr,openRef:zr}),Y=Me({viewport:_,world:v,svg:y,canvas:g,renderer:A,currentBoard:$,sendOps:vr,onSelectionChange:Cr,onPhoneTapBox:Jr,onOpenLinkedBoard:Ur,onOpenImage:qr,onActivateMedia:b.activate,onConnectBoxes:Yr,onToolChange:ri}),document.addEventListener(`keydown`,t=>ai(e,t)),ui(e,g),re(wr),te(e=>{e===K&&Hr()}),wr(),e}function pi(){return document.documentElement.dataset.layout===`phone`}function mi(e){q&&(e?q.boardIsland.parentElement!==e&&e.append(q.boardIsland):q.chrome.firstElementChild!==q.boardIsland&&q.chrome.prepend(q.boardIsland))}function hi(e,t){t!==X&&lr.clear(),X=t,e&&Ur(e),Fr()}function gi(){wr(),cr=null,K&&ae(K).then(Hr)}var _i=null;function vi(e){_i=e,e.replaceChildren(fi())}function yi(){let e=fi();_i&&e.parentElement!==_i&&_i.replaceChildren(e),mi(null),hi(E()?.boardId??null,null),gi()}var bi={mount:vi,refresh:yi};export{$r as createBoardFromDialog,fi as mountBoardHost,mi as placeBoardTitle,gi as reopenSelectedBoard,hi as showBoardBeside,bi as view};
|
|
1
|
+
import{A as e,a as t,en as n,fn as r,ln as i,pn as a,r as o,sn as s,t as c,tn as l,un as u}from"./button-Cnom-MQM.js";import{f as d,s as f}from"./dom-helpers-Bs-xZEnd.js";import{a as p,i as m,n as h}from"./modal-C-Lb5-jJ.js";import{a as g,r as _}from"./card-registry-W9ss4JHS.js";import{i as v}from"./action-status-B0E-UYey.js";import{n as y,t as b}from"./menu-DK4rQWp6.js";import{Kr as x,_t as S,at as ee,bt as C,ct as te,dt as w,ft as T,gt as ne,ht as E,it as D,lt as re,mt as O,ot as k,pt as A,st as ie,ut as ae,vt as oe,yt as se}from"./index-CiJEE2GW.js";import{t as ce}from"./sandboxed-frame-DDgtJ2Ng.js";Object.freeze({unitWarnings:[],uncoveredPaths:[],worthALookPaths:[],flaggedUnitIds:[],notChecked:null});var le=/^([^#\s]+)(?:#L([1-9]\d*)(?:-L([1-9]\d*))?)?$/;function ue(e){return e.startsWith(`/`)||e.startsWith(`\\`)||/^[A-Za-z]:/.test(e)}function de(e){return e.split(`/`).filter(e=>e!==``&&e!==`.`).join(`/`)}function fe(e){let t=le.exec(e);if(!t?.[1])return{error:`a ref is path, path#L12 or path#L12-L30`};let n=t[1];if(ue(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:de(n),startLine:r,endLine:i}}function pe(e,t,n){return n.flatMap((n,r)=>n.ref?[{elementId:t,ref:n.ref,where:`line ${r+1} of ${e}`}]:[])}function me(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})),...pe(t,e.id,e.lines)];case`panel`:return pe(t,e.id,e.lines);case`note`:return e.ref?[{elementId:e.id,ref:e.ref,where:t}]:[];case`frame`:case`wire`:return[]}}function he(e){return[...new Set(me(e).map(e=>e.ref))]}function ge(e){let t=fe(e);return`path`in t?t.path:null}var _e=4,ve=200,ye=2e4,be=1.1,xe=[`wire`,`note`,`frame`,`box`,`panel`,`unit`],Se={v:`select`,r:`box`,d:`decision`,p:`panel`,a:`wire`};function j(e){let t=Math.random().toString(36).slice(2,8);return`${e}-${Date.now().toString(36)}${t}`}function M(){return document.documentElement.dataset.layout===`phone`}function Ce(e){return e instanceof SVGCircleElement&&e.classList.contains(`wb-port`)?e:null}function we(e){return e===`box`||e===`decision`||e===`panel`}function Te(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:j(`panel`),title:`Panel`,lines:[],order:e+1}}return e===`decision`?Ee(n,`Decision`,null,!0):Ee(n,`Box`,null,!1)}function Ee(e,t,n,r){return{kind:`box`,id:j(`box`),title:t,lines:[],lane:null,refs:[],change:`none`,was:null,column:null,near:null,order:0,at:e,shape:r?`decision`:`box`,outputs:r?[{id:`yes`,label:`yes`},{id:`no`,label:`no`}]:[],media:n,width:null}}function De(e){if(!(e instanceof Element))return null;let t=e.closest(`image.wb-image`),n=t?.getAttribute(`href`);return!t||!n?null:{boxId:t.closest(`[data-element-id]`)?.dataset.elementId??null,href:n,alt:t.querySelector(`title`)?.textContent??``}}function Oe(e){return e instanceof SVGRectElement&&e.classList.contains(`wb-resize-handle`)}function ke(e){return e instanceof Element?e.closest(`[data-linked-board-id]`)?.dataset.linkedBoardId??null:null}var Ae=2,je=12/10;function Me(e){let{viewport:t,world:n,svg:r,canvas:i,renderer:a}=e,o=new Map,s=new Set,c={x:0,y:0,scale:1},l=null,d=null,p=null,m=`select`,h=null,g=!1;function _(n){m=n,t.dataset.tool=n,e.onToolChange(n)}function v(){n.style.transform=`translate(${-c.x*c.scale}px, ${-c.y*c.scale}px) scale(${c.scale})`}function y(){return(t.clientWidth||1)/c.scale}function b(){let e=t.getBoundingClientRect(),n=[...i.querySelectorAll(`.wb-island`)].filter(e=>e.checkVisibility()).map(e=>e.getBoundingClientRect()),r=e.top+e.height/2,a=n.filter(e=>e.top+e.height/2<r).map(t=>t.bottom-e.top),o=n.filter(e=>e.top+e.height/2>=r).map(t=>t.top-e.top),s=Math.max(0,...a),c=Math.min(e.height,...o)-s;return c<e.height/2?{topPx:0,heightPx:e.height}:{topPx:s,heightPx:c}}function x(){let e=a.layout();if(!e)return;let{bounds:n}=e,r=t.clientWidth,i=t.clientHeight;if(r===0||i===0){c={x:n.x,y:n.y,scale:1},v(),g=!0;return}g=!1;let o=b(),s=e.elements.length===0?1:Ae,l=Math.max(1/s,n.width/r,n.height/o.heightPx),u=l>je,d=u?je:l,f=r*d,p=n.y+n.height/2,m=o.topPx+o.heightPx/2;c={x:n.x-Math.max(0,f-n.width)/2,y:u?n.y-o.topPx*d:p-m*d,scale:1/d},v()}function S(e,n){let r=t.getBoundingClientRect();return{x:c.x+(e-r.left-t.clientLeft)/c.scale,y:c.y+(n-r.top-t.clientTop)/c.scale}}function ee(){return 1/c.scale}function C(e,t){let n=y(),r=Math.min(ye,Math.max(ve,n*t))/n;c={x:e.x-(e.x-c.x)*r,y:e.y-(e.y-c.y)*r,scale:c.scale/r},v()}function te(e,t){c={...c,x:c.x-e/c.scale,y:c.y-t/c.scale},v()}function w(t){s=t,a.setSelection(s),e.onSelectionChange(s)}function T(e,t){if(!t){w(s.has(e)&&s.size===1?new Set:new Set([e]));return}let n=new Set(s);n.delete(e)||n.add(e),w(n)}function ne(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 E(e){let t=Math.round(e.start.width+e.latest.x-e.origin.x);return Math.min(u.boxWidthMax,Math.max(u.boxWidthMin,t))}function D(e){return e.mode===`resize`?{width:E(e)}:{at:ne(e)}}function re(e,t,n){let r=e.elements[t];return r?.kind===`box`?{...e,elements:{...e.elements,[t]:{...r,...n}}}:e}function O(e){return l?.kind!==`drag`||!l.hasMoved?e:re(e,l.boxId,D(l))}function k(){p!==null&&cancelAnimationFrame(p),p=null}function A(){k();let t=e.currentBoard();t&&a.render(O(t))}function ie(){p===null&&(p=requestAnimationFrame(A))}function ae(e){l?.kind===`drag`&&e?.elements[l.boxId]?.kind!==`box`&&(l=null);let t=new Set([...s].filter(t=>e?.elements[t]));t.size!==s.size&&w(t)}function oe(e){let t=a.layout()?.elements.find(t=>t.id===e);return t?.kind===`box`?t:null}function se(){let[e,t]=[...o.values()];return!e||!t?0:Math.hypot(e.x-t.x,e.y-t.y)}function ce(){l?.kind===`wire`&&ge(l,!1),l={kind:`pinch`,distance:se(),viewWidth:y()}}function le(n){if(n.button!==0||d)return;let r=ke(n.target);if(r){e.onOpenLinkedBoard(r);return}if(o.set(n.pointerId,{x:n.clientX,y:n.clientY}),t.setPointerCapture(n.pointerId),o.size===2){ce();return}let i=a.elementFromTarget(n.target);if(we(m)){ue(m,S(n.clientX,n.clientY));return}let s=i?.kind===`box`&&Oe(n.target)&&!M()?oe(i.id):null;if(i&&s){let e=S(n.clientX,n.clientY);l={kind:`drag`,mode:`resize`,pointerId:n.pointerId,boxId:i.id,origin:e,start:s,pinnedOffsetY:0,latest:e,hasMoved:!1,isAdditive:!1,pressedImage:null};return}let c=Ce(n.target);if(i?.kind===`box`&&c&&!M()){pe(n.pointerId,i.id,{x:c.cx.baseVal.value,y:c.cy.baseVal.value});return}let u=m===`wire`&&i?.kind===`box`?oe(i.id):null;if(i&&u){pe(n.pointerId,i.id,{x:u.x+u.width/2,y:u.y+u.height/2});return}let f=i?.kind===`box`&&!M()?oe(i.id):null;if(i&&f){let e=S(n.clientX,n.clientY),t=a.layout()?.pinnedOffsetY??0;l={kind:`drag`,mode:`move`,pointerId:n.pointerId,boxId:i.id,origin:e,start:f,pinnedOffsetY:t,latest:e,hasMoved:!1,isAdditive:n.shiftKey,pressedImage:Be(n.target)};return}if(i&&!M()){T(i.id,n.shiftKey);return}let p=i?.kind===`box`?i.id:null;l={kind:`pan`,pointerId:n.pointerId,lastClient:{x:n.clientX,y:n.clientY},hasMoved:!1,tappedBoxId:p,pressedImage:Be(n.target)}}async function ue(t,n){_(`select`);let r=e.currentBoard();if(!r)return;let i=a.layout()?.pinnedOffsetY??0,o=Te(t,r,{x:Math.round(n.x),y:Math.round(n.y-i)});h=o.id;let s=await e.sendOps([{op:`add`,element:o}]);s||(h=null),s&&w(new Set([o.id])),fe()}async function de(n,r,i){if(!e.currentBoard())return!1;let o=i?S(i.x,i.y):{x:c.x+y()/2,y:c.y+(t.clientHeight||1)/c.scale/2},s=a.layout()?.pinnedOffsetY??0,l=Ee({x:Math.round(o.x),y:Math.round(o.y-s)},n,r,!1),u=await e.sendOps([{op:`add`,element:l}]);return u&&w(new Set([l.id])),u}function fe(){if(!h||!a.nodeOf(h))return;let e=h;h=null,ze(e)}function pe(e,t,n){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 ${n.x} ${n.y} L ${n.x} ${n.y}`),r.append(i),l={kind:`wire`,pointerId:e,fromBoxId:t,start:n,draftLine:i,targetBoxId:null}}function me(e,t){e.targetBoxId&&a.nodeOf(e.targetBoxId)?.classList.remove(`is-wire-target`),e.targetBoxId=t,t&&a.nodeOf(t)?.classList.add(`is-wire-target`)}function he(e,t){let n=S(t.clientX,t.clientY);e.draftLine.setAttribute(`d`,`M ${e.start.x} ${e.start.y} L ${n.x} ${n.y}`);let r=a.elementFromTarget(document.elementFromPoint(t.clientX,t.clientY));me(e,r?.kind===`box`&&r.id!==e.fromBoxId?r.id:null)}function ge(t,n){let r=t.targetBoxId;me(t,null),t.draftLine.remove(),n&&r&&e.onConnectBoxes(t.fromBoxId,r)}function j(e,t){let n=S(t.clientX,t.clientY);!e.hasMoved&&Math.hypot(n.x-e.origin.x,n.y-e.origin.y)<_e*ee()||(e.hasMoved=!0,e.latest=n,ie())}function Me(e,t){let n=t.clientX-e.lastClient.x,r=t.clientY-e.lastClient.y;!e.hasMoved&&Math.hypot(n,r)<_e||(e.hasMoved=!0,e.lastClient={x:t.clientX,y:t.clientY},te(n,r))}function Ne(e){let t=se();if(t<=0||e.distance<=0)return;let n=[...o.values()];C(S(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)/y())}function Pe(e){o.has(e.pointerId)&&(o.set(e.pointerId,{x:e.clientX,y:e.clientY}),l?.kind===`pinch`?Ne(l):l?.kind===`drag`&&l.pointerId===e.pointerId?j(l,e):l?.kind===`wire`&&l.pointerId===e.pointerId?he(l,e):l?.kind===`pan`&&l.pointerId===e.pointerId&&Me(l,e))}async function Fe(t,n){if(!t.hasMoved&&t.mode===`resize`)return;if(!t.hasMoved){T(t.boxId,t.isAdditive),t.pressedImage&&!t.isAdditive&&e.onOpenImage(t.pressedImage);return}k(),t.latest=S(n.clientX,n.clientY);let r=D(t),i=e.currentBoard();i&&a.render(re(i,t.boxId,r)),await e.sendOps([{op:`set`,id:t.boxId,fields:r}])||A()}function Ie(t){if(!o.delete(t.pointerId))return;let n=l;n?.kind===`pinch`?l=null:(l=null,n?.kind===`drag`&&n.pointerId===t.pointerId?Fe(n,t):n?.kind===`wire`?(ge(n,n.pointerId===t.pointerId),m===`wire`&&_(`select`)):n?.kind!==`pan`||n.hasMoved||(n.pressedImage&&M()?e.onOpenImage(n.pressedImage):n.tappedBoxId&&M()?e.onPhoneTapBox(n.tappedBoxId):n.tappedBoxId||w(new Set)))}function Le(e){o.delete(e.pointerId);let t=l?.kind===`drag`;l?.kind===`wire`&&ge(l,!1),l=null,t&&A()}function Re(e){e.preventDefault(),e.ctrlKey||e.metaKey?C(S(e.clientX,e.clientY),e.deltaY>0?be:1/be):te(-e.deltaX,-e.deltaY)}function N(){let e=d;d=null,e?.remove()}function ze(n){let r=e.currentBoard()?.elements[n],o=a.nodeOf(n);if(r?.kind!==`box`&&r?.kind!==`panel`||!o)return;N();let s=i.getBoundingClientRect(),c=o.getBoundingClientRect(),l=f(`input`,`wb-title-input`);l.type=`text`,l.value=r.title,l.maxLength=80,l.setAttribute(`aria-label`,r.kind===`panel`?`Panel title`:`Box title`),l.style.left=`${c.left-s.left}px`,l.style.top=`${c.top-s.top}px`,l.style.width=`${Math.max(160,c.width)}px`,d=l,i.append(l),l.addEventListener(`keydown`,i=>{if(i.key===`Escape`){i.preventDefault(),N(),t.focus();return}if(i.key!==`Enter`)return;i.preventDefault();let a=l.value.trim();N(),t.focus(),a&&a!==r.title&&e.sendOps([{op:`set`,id:n,fields:{title:a}}])}),l.addEventListener(`blur`,N),l.focus(),l.select()}function Be(e){let t=De(e),n=t?.boxId?a.layout()?.elements.find(e=>e.id===t.boxId):void 0;return n?.kind===`box`&&n.media&&n.media.kind!==`image`?null:t}function Ve(e,t){let n=S(e,t);return a.layout()?.elements.find(e=>e.kind===`box`&&e.media&&e.media.kind!==`image`&&n.x>=e.media.x&&n.x<=e.media.x+e.media.width&&n.y>=e.media.y&&n.y<=e.media.y+e.media.height)?.id??null}function He(t){let n=Ve(t.clientX,t.clientY);if(n){e.onActivateMedia(n);return}if(M())return;let r=a.elementFromTarget(document.elementFromPoint(t.clientX,t.clientY));(r?.kind===`box`||r?.kind===`panel`)&&ze(r.id)}function Ue(){let t=e.currentBoard();if(!t||s.size===0)return;let n=[...s].flatMap(e=>t.elements[e]??[]),r=xe.flatMap(e=>n.filter(t=>t.kind===e)).map(e=>({op:`remove`,id:e.id}));w(new Set),e.sendOps(r)}function We(e){if(e.target!==t||e.metaKey||e.ctrlKey||e.altKey)return;if(e.key===`Delete`||e.key===`Backspace`){e.preventDefault(),Ue();return}let n=Se[e.key.toLowerCase()];n&&!e.shiftKey?(e.preventDefault(),_(n)):e.key===`Escape`&&(w(new Set),_(`select`))}return n.style.transition=`none`,t.tabIndex=0,t.addEventListener(`pointerdown`,le),t.addEventListener(`pointermove`,Pe),t.addEventListener(`pointerup`,Ie),t.addEventListener(`pointercancel`,Le),t.addEventListener(`wheel`,Re,{passive:!1}),t.addEventListener(`dblclick`,He),t.addEventListener(`keydown`,We),new ResizeObserver(()=>{g&&t.clientWidth>0&&t.clientHeight>0&&x()}).observe(t),{fit:x,selectedIds:()=>s,clearSelection:()=>w(new Set),pruneSelection:ae,previewOf:O,closeTitleInput:N,setTool:_,placeMediaBox:de,openPendingTitleEdit:fe,focusCanvas:()=>t.focus()}}var Ne=Object.freeze({undo:[],redo:[]}),Pe=new Set([`box`,`unit`,`panel`]),Fe=[`wire`,`note`,`frame`,`box`,`panel`,`unit`],Ie=new Set([`kind`,`id`]);function Le(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Re(e){return e.kind===`box`?e.near?[e.near.of]:[]:e.kind===`unit`?e.after:[]}function N(e){let t=new Set(e.map(e=>e.id)),n=[];for(;t.size>0;){let r=e.filter(e=>t.has(e.id)&&Re(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 ze(e,t){let n={...e},r=Object.fromEntries(Object.entries(t).filter(([e,t])=>!Ie.has(e)&&!Le(n[e],t)));return t.kind!==`note`||Object.keys(r).length===0?r:{...r,author:t.author,resolvedBy:t.resolvedBy}}function Be(e,t){let n={...e.title===t.title?{}:{title:t.title},...e.caption===t.caption?{}:{caption:t.caption},...Le(e.legend,t.legend)?{}:{legend:t.legend},...e.codeSessionId===t.codeSessionId?{}:{codeSessionId:t.codeSessionId}};return Object.keys(n).length===0?[]:[{op:`board`,...n}]}function Ve(e,t){if(Le(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 He(e,t){let n=Object.values(e.elements),r=Object.values(t.elements),i=Fe.flatMap(e=>n.filter(n=>n.kind===e&&!t.elements[n.id])),a=N(r.filter(t=>!e.elements[t.id])),o=r.flatMap(t=>{let n=e.elements[t.id];if(!n)return[];let r=ze(n,t);return Object.keys(r).length===0?[]:[{op:`set`,id:t.id,fields:r}]}),{widen:s,narrow:c}=Ve(e,t);return[...Le(e.lanes,t.lanes)?[]:[{op:`lanes`,lanes:t.lanes}],...s,...i.map(e=>({op:`remove`,id:e.id})),...a.filter(e=>Pe.has(e.kind)).map(e=>({op:`add`,element:e})),...o,...a.filter(e=>!Pe.has(e.kind)).map(e=>({op:`add`,element:e})),...c,...Be(e,t)]}function Ue(e,t){let n=oe(e,t,S,e.updatedAt);return n.ok?He(n.board,e):[]}function We(e,t){return t.length===0?[...e]:[...e,t].slice(-100)}function Ge(e,t){return t.length===0?e:{undo:We(e.undo,t),redo:[]}}function Ke(e,t){let n=e[t].at(-1);return n?{entry:n,history:{...e,[t]:e[t].slice(0,-1)}}:null}function qe(e,t,n){let r=t===`undo`?`redo`:`undo`;return{...e,[r]:We(e[r],n)}}var Je=8,Ye=12,Xe=30,Ze=40,Qe=40,$e=400,et=200,tt=8,nt=`README.md`,rt=``,it=[`text`,`code`,`item`,`numbered`,`kv`],at=[`plain`,`fail`,`join`,`lane`],ot=P(it),st=P(at),ct=P([`box`,`decision`]),lt=P(l),ut=P(s),dt=[{value:``,text:`auto`},...P([`left`,`right`,`top`,`bottom`])],ft=[{id:`yes`,label:`yes`},{id:`no`,label:`no`}];function P(e){return e.map(e=>({value:e,text:e}))}function F(e){return f(`h3`,`wb-inspect-heading`,e)}function I(e,t){let n=f(`label`,`wb-inspect-field`);return n.append(f(`span`,`wb-inspect-label`,e),t),n}function L(e,t,n,r,i){let a=f(`input`,`wb-inspect-input`);return a.type=`text`,a.value=t,a.maxLength=n,a.dataset.field=e,i&&a.setAttribute(`aria-label`,i),a.addEventListener(`change`,()=>r(a.value)),a}function R(e,t,n,r,i){let a=f(`select`,`wb-inspect-select`);return a.dataset.field=e,i&&a.setAttribute(`aria-label`,i),a.append(...t.map(e=>{let t=f(`option`,null,e.text);return t.value=e.value,t.selected=e.value===n,t})),a.addEventListener(`change`,()=>r(a.value)),a}function pt(e,t,n,r){let i=f(`input`,`wb-inspect-check`);i.type=`checkbox`,i.checked=n,i.dataset.field=e,i.addEventListener(`change`,()=>r(i.checked));let a=f(`label`,`wb-inspect-toggle`);return a.append(i,f(`span`,null,t)),a}function z(e,t,n,r){let i=c({variant:`quiet`,size:`small`,label:t,action:t.replaceAll(` `,`-`),onClick:n});return i.dataset.field=e,r&&i.setAttribute(`aria-label`,r),i}function mt(e,t,n){let r=f(`div`,`wb-inspect-list`);return r.append(f(`span`,`wb-inspect-label`,e),...t,n),r}function ht(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 gt(e){let t=e.trim();return n.safeParse(t).success?t:null}function _t(e,t,n,r){let i=L(e,t??``,et,e=>{if(!e.trim()){n(null);return}let t=gt(e);t&&n(t)},r);return i.placeholder=`ref: path#L12`,i}function vt(e,t,n,r){let i=ht(n,r),a=t.map((e,t)=>{let n=f(`div`,`wb-inspect-row`);return n.append(L(`ref-${t}`,e,et,e=>{let n=gt(e);n&&i.edit(t,()=>n)},`Ref ${t+1}`),z(`ref-${t}-remove`,`remove`,()=>i.remove(t),`Remove ref ${e}`)),n}),o=z(`ref-add`,`add ref`,()=>i.append(()=>nt),`Add a ref to ${e}`);return o.disabled=t.length>=tt,mt(`Refs`,a,o)}function yt(e,t){return t===`kv`?{...e,style:t,key:e.key||`key`}:{...e,style:t}}function bt(e,t,n,r){let i=ht(n,r),a=t.map((e,t)=>{let n=f(`div`,`wb-inspect-row`),r=t+1;return n.append(R(`line-${t}-style`,ot,e.style,e=>{let n=it.find(t=>t===e);n&&i.edit(t,e=>yt(e,n))},`Line ${r} style`)),e.style===`kv`&&n.append(L(`line-${t}-key`,e.key??``,Qe,e=>{e.trim()&&i.edit(t,t=>({...t,key:e.trim()}))},`Line ${r} key`)),n.append(L(`line-${t}-text`,e.text,u.line,e=>i.edit(t,t=>({...t,text:e})),`Line ${r} text`),_t(`line-${t}-ref`,e.ref,e=>i.edit(t,t=>({...t,ref:e})),`Line ${r} ref`),z(`line-${t}-remove`,`remove`,()=>i.remove(t),`Remove line ${r}`)),n}),o=z(`line-add`,`add line`,()=>i.append(()=>({text:`new line`,muted:!1,style:`text`,key:null,ref:null})),`Add a line to ${e}`);return o.disabled=t.length>=u.linesPerBox,mt(`Lines`,a,o)}function xt(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 St(e,t,n){let r=ht(t,e=>n({outputs:e})),i=e.outputs.map((e,t)=>{let n=f(`div`,`wb-inspect-row`);return n.append(L(`output-${e.id}-label`,e.label,Xe,e=>{e.trim()&&r.edit(t,t=>({...t,label:e.trim()}))},`Output ${e.id} label`),z(`output-${e.id}-remove`,`remove`,()=>r.remove(t),`Remove output ${e.label}`)),n}),a=z(`output-add`,`add output`,()=>r.append(e=>({id:xt(e),label:`exit`})));return a.disabled=e.outputs.length>=Je,mt(`Outputs`,i,a)}function Ct(e){return e.at===null&&e.near===null?e.column??rt:rt}function wt(e,t,n,r,i){let a=()=>{let e=n();return e?.kind===`box`?e:null},o=[{value:rt,text:`free`},...e.columns.map(e=>({value:e.id,text:e.title||e.id}))],s=[{value:``,text:`none`},...e.lanes.map(e=>({value:e.id,text:e.label||e.id}))];return[F(t.shape===`decision`?`Decision`:`Box`),I(`Title`,L(`title`,t.title,u.title,e=>{e.trim()&&i({title:e.trim()})})),I(`Shape`,R(`shape`,ct,t.shape,e=>{let t=a()?.outputs??[];e===`decision`&&i({shape:e,outputs:t.length>0?t:ft}),e===`box`&&i({shape:e,outputs:[]})})),I(`Column`,R(`column`,o,Ct(t),e=>{if(e!==rt){i({column:e,at:null,near:null});return}let n=r?.elements.find(e=>e.id===t.id);r&&n?.kind===`box`&&i({at:{x:n.x,y:n.y-r.pinnedOffsetY},near:null})})),I(`Lane`,R(`lane`,s,t.lane??``,e=>i({lane:e||null}))),I(`Change`,R(`change`,lt,t.change,e=>{i(e===`relabeled`?{change:e,was:a()?.was??t.title}:{change:e,was:null})})),...t.change===`relabeled`?[I(`Was`,L(`was`,t.was??``,u.title,e=>{e.trim()&&i({was:e.trim()})}))]:[],...t.shape===`decision`?[St(t,()=>a()?.outputs??null,i)]:[],vt(`this box`,t.refs,()=>a()?.refs??null,e=>i({refs:e})),bt(`this box`,t.lines,()=>a()?.lines??null,e=>i({lines:e}))]}function Tt(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[F(`Wire`),I(`Label`,L(`label`,t.label??``,Ze,e=>n({label:e.trim()||null}))),I(`Tone`,R(`tone`,st,t.tone,e=>n({tone:e}))),pt(`dashed`,`dashed`,t.dashed,e=>n({dashed:e})),pt(`back`,`returns to an earlier step`,t.back,e=>n({back:e})),I(`Leaves from`,R(`fromSide`,dt,t.fromSide??``,e=>n({fromSide:e||null}))),I(`Arrives at`,R(`toSide`,dt,t.toSide??``,e=>n({toSide:e||null}))),...i.length>0?[I(`From output`,R(`fromOutput`,i,t.fromOutput??``,e=>n({fromOutput:e||null})))]:[]]}function Et(e,t){return[F(`Frame`),I(`Title`,L(`title`,e.title,u.title,e=>t({title:e.trim()}))),pt(`loop`,`repeats as a loop`,e.loop,e=>t({loop:e}))]}function Dt(e,t,n){return[F(`Panel`),I(`Title`,L(`title`,e.title,u.title,e=>{e.trim()&&n({title:e.trim()})})),bt(`this panel`,e.lines,()=>{let e=t();return e?.kind===`panel`?e.lines:null},e=>n({lines:e}))]}function Ot(e,t,n){let r=ht(t,n),i=e.map((e,t)=>{let n=f(`div`,`wb-inspect-row wb-inspect-legend-row`),i=t+1;return n.append(R(`legend-${t}-tone`,st,e.tone,e=>{let n=at.find(t=>t===e);n&&r.edit(t,e=>({...e,tone:n}))},`Legend entry ${i} tone`),L(`legend-${t}-label`,e.label,Ze,e=>{e.trim()&&r.edit(t,t=>({...t,label:e.trim()}))},`Legend entry ${i} label`),pt(`legend-${t}-dashed`,`dashed`,e.dashed,e=>r.edit(t,t=>({...t,dashed:e}))),pt(`legend-${t}-back`,`returns`,e.back,e=>r.edit(t,t=>({...t,back:e}))),z(`legend-${t}-remove`,`remove`,()=>r.remove(t),`Remove legend entry ${e.label}`)),n}),a=z(`legend-add`,`add entry`,()=>r.append(()=>({tone:`plain`,dashed:!1,back:!1,label:`meaning`})));return a.disabled=e.length>=Ye,mt(`Legend`,i,a)}function kt(e,t){return[F(`Note`),I(`Ref`,_t(`ref`,e.ref,e=>t({ref:e}),`Ref`)),f(`p`,`wb-inspect-hint`,`Edit a note from its box.`)]}function At(e,t,n){return[F(`Unit`),I(`Status`,R(`unit-status`,ut,e.status,e=>{let t=s.find(t=>t===e);t&&n({status:t})})),vt(`this unit`,e.refs,()=>{let e=t();return e?.kind===`unit`?e.refs:null},e=>n({refs:e})),f(`p`,`wb-inspect-hint`,`Agents edit units with glimmervoid whiteboard plan.`)]}function jt(e,t,n,r,i){let a=[{value:``,text:`none`},...r];return[F(`Board`),z(`board-settings-close`,`close`,i,`Close board settings`),I(`Title`,L(`board-title`,e.title,u.title,e=>{e.trim()&&n([{op:`board`,title:e.trim()}])})),I(`Caption`,L(`board-caption`,e.caption??``,$e,e=>n([{op:`board`,caption:e.trim()||null}]))),I(`Code session`,R(`board-code-session`,a,e.codeSessionId??``,e=>n([{op:`board`,codeSessionId:e||null}]))),Ot(e.legend,()=>t()?.legend??null,e=>n([{op:`board`,legend:e}]))]}function Mt(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 wt(e,t,o,r,a);case`wire`:return Tt(e,t,a);case`frame`:return Et(t,a);case`panel`:return Dt(t,o,a);case`note`:return kt(t,a);case`unit`:return At(t,o,a)}}function Nt(e,t,n){let r=he(t);if(r.length===0)return[];let i=e.codeSessionId!==null,a=r.map((e,t)=>{let r=f(`div`,`wb-inspect-row wb-inspect-review-row`),a=z(`review-${t}`,`open in review`,()=>n(e),`Open ${e} in review`);return a.disabled=!i,r.append(f(`code`,`wb-inspect-ref`,e),a),r}),o=i?[]:[f(`p`,`wb-inspect-hint`,`Set the board code session to open refs in review.`)];return[F(`In review`),...a,...o]}function Pt(e,t,n){let r=f(`div`,`wb-inspect-review`);return r.append(...Nt(e,t,n)),r}function Ft(e){let t=document.activeElement;return e.contains(t)&&t instanceof HTMLInputElement&&t.type===`text`}function It(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(...Nt(n,i,e.openRef))}function c(t,r){if(r.size>1)return[F(`${r.size} selected`)];let i=o(t,r);return i?[...Mt(t,i,e.currentBoard,e.layout(),n),Pt(t,i,e.openRef)]:jt(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(Ft(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 Lt=`http://www.w3.org/2000/svg`,B=12,Rt=26,V=20,zt=18,Bt=17,Vt=14,Ht=16,Ut=24,Wt=18,Gt=`Plan`,Kt=`open linked board`,qt=5,Jt=10,Yt=17,Xt=6,Zt=20,Qt=12,$t=4,en=3,tn=7.2,nn=13,rn=17,an=2.2,on=28,sn=()=>null;function cn(e){return Object.entries(e).flatMap(([e,t])=>t===null?[]:[` ${e}="${x(t)}"`]).join(``)}function H(e,t,n=``){return`<${e}${cn(t)}>${n}</${e}>`}function U(e,t,n,r,i={}){return H(`text`,{x:t,y:n,class:r,...i},x(e))}function W(e,t,n){return H(`g`,{class:`wb-element ${t}`,"data-element-id":e.id,"data-element-kind":e.kind},n.join(``))}function ln(e){return e?`stroke:${e}`:null}function un(e){let t=e.x+e.width,n=e.y+e.headerHeight/2,r=`M${e.x+Qt},${e.y} H${t-Qt} L${t},${n}`;return e.outputs.length===0?`${r} L${t-Qt},${e.y+e.height} H${e.x+Qt} L${e.x},${n} Z`:`${r} V${e.y+e.height} H${e.x} V${n} Z`}function dn(e){return e.outputs.flatMap(t=>{let n=(e.height-e.headerHeight)/e.outputs.length/2,r=t.port.y-n;return[H(`line`,{x1:e.x,y1:r,x2:e.x+e.width,y2:r,class:`wb-output-divider`}),U(t.label,e.x+B,t.port.y+$t,`wb-output-label`),H(`circle`,{cx:t.port.x,cy:t.port.y,r:en,class:`wb-output-dot`})]})}function fn(e){return e.style===`code`?`wb-box-line wb-line-code`:e.muted?`wb-box-line wb-muted`:`wb-box-line`}function pn(e,t,n,r){let i=t+B+(e.muted?Vt:0),a=[];return e.style===`code`&&a.push(H(`rect`,{x:i-4,y:r-nn,width:t+n-B+4-i+4,height:rn,rx:3,class:`wb-code-band`})),e.style===`item`&&e.isFirstRow&&a.push(H(`circle`,{cx:i+4,cy:r-4,r:an,class:`wb-item-dot`})),e.marker!==null&&a.push(U(e.marker,i,r,e.style===`kv`?`wb-line-key`:`wb-line-marker`)),e.text&&a.push(U(e.text,i+e.indentChars*tn,r,fn(e))),a}function mn(e,t,n,r){return e.flatMap((e,i)=>pn(e,t,n,r+i*zt))}function hn(e){let t=[H(`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(U(n,e.x+B,e.y+Rt+r*V,`wb-box-title`))});let n=e.y+Rt+e.titleLines.length*V;return e.bodyLines.length>0&&t.push(H(`line`,{x1:e.x+B,y1:n-12,x2:e.x+e.width-B,y2:n-12,class:`wb-panel-rule`})),t.push(...mn(e.bodyLines,e.x,e.width,n)),W(e,`wb-panel`,t)}function gn(e){return e.shape===`decision`?H(`path`,{d:un(e),class:`wb-box-outline`,style:ln(e.lane?.hex)}):H(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:8,class:`wb-box-outline`,style:ln(e.lane?.hex)})}function _n(e,t){let n=t(e),r=e.alt||e.kind,i=H(`title`,{},x(r));return n?[H(`image`,{href:n,x:e.x,y:e.y,width:e.width,height:e.height,preserveAspectRatio:`xMidYMid meet`,class:`wb-image`},i)]:[H(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:6,class:`wb-image-placeholder`},i),U(r,e.x+e.width/2,e.y+e.height/2+4,`wb-image-placeholder-text`,{"text-anchor":`middle`})]}function vn(e,t){let n=[gn(e),...dn(e)],r=e.x+e.width/2,i=e.y+e.height/2;for(let[t,a]of[[r,e.y],[e.x+e.width,i],[r,e.y+e.height],[e.x,i]])n.push(H(`circle`,{cx:t,cy:a,r:qt,class:`wb-port`}));e.wasLines.forEach((t,r)=>{n.push(U(t,e.x+B,e.y+Rt+r*V,`wb-box-was`))});let a=e.y+Rt+e.wasLines.length*V;e.titleLines.forEach((t,r)=>{n.push(U(t,e.x+B,a+r*V,`wb-box-title`))});let o=a+e.titleLines.length*V;if(n.push(...mn(e.bodyLines,e.x,e.width,o)),e.media&&n.push(..._n(e.media,t)),e.lane&&e.showsLanePill){let t=e.y+e.headerHeight-28,r=Math.min(e.width-24,16+e.lane.label.length*8);n.push(H(`rect`,{x:e.x+B,y:t,width:r,height:18,rx:9,class:`wb-lane-pill`,style:ln(e.lane.hex)}),U(e.lane.label,e.x+B+8,t+13,`wb-lane-pill-text`,{style:`fill:${e.lane.hex}`}))}return n.push(H(`rect`,{x:e.x+e.width-Jt,y:e.y+e.height-Jt,width:Jt,height:Jt,rx:2,class:`wb-resize-handle`})),W(e,e.change===`none`?`wb-box`:`wb-box wb-change-${e.change}`,n)}function yn(e){let t=e.x+e.width-Zt,n=e.y+Xt+6;return H(`path`,{d:`M ${t+Xt} ${n} A ${Xt} ${Xt} 0 1 1 ${t} ${n-Xt}`,"marker-end":`url(#wb-arrow)`,class:`wb-loop-badge`})}function bn(e){let t=[H(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:12,class:`wb-frame-outline`}),U(e.title,e.x+14,e.y+18,`wb-frame-title`)];return e.isLoop&&t.push(yn(e)),W(e,e.isLoop?`wb-frame wb-loop`:`wb-frame`,t)}function xn(e){let t=[H(`path`,{d:e.path,class:`wb-wire-hit`}),H(`path`,{d:e.path,"marker-end":e.hasArrowhead?`url(#wb-arrow)`:null,class:e.isDashed?`wb-wire-line wb-dashed`:`wb-wire-line`,style:ln(e.strokeHex??void 0)}),H(`circle`,{cx:e.start.x,cy:e.start.y,r:3,class:`wb-wire-dot`})];return e.joinAt&&t.push(H(`circle`,{cx:e.joinAt.x,cy:e.joinAt.y,r:3,class:`wb-wire-dot`})),e.label&&t.push(U(e.label,e.labelAt.x,e.labelAt.y,`wb-wire-label`)),W(e,e.isBack?`wb-wire wb-back wb-tone-${e.tone}`:`wb-wire wb-tone-${e.tone}`,t)}function Sn(e){let t=[H(`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(U(n,e.x+10,e.y+22+r*Bt,`wb-note-text`))}),e.byline&&t.push(U(e.byline,e.x+10,e.y+22+e.lines.length*Bt,`wb-note-byline`)),W(e,e.isResolved?`wb-note wb-resolved`:`wb-note`,t)}function Cn(e){let t=[H(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:8,class:`wb-unit-outline`}),U(e.label,e.x+B,e.y+Ut,`wb-unit-label`),U(e.status,e.x+e.width-B,e.y+Ut,`wb-unit-status wb-unit-${e.status}`,{"text-anchor":`end`})],n=e.y+Ut+Wt;e.titleLines.forEach((r,i)=>{t.push(U(r,e.x+B,n+i*V,`wb-box-title`))});let r=n+e.titleLines.length*V;return t.push(...mn(e.bodyLines,e.x,e.width,r)),e.linkedBoardId&&t.push(U(Kt,e.x+B,r+e.bodyLines.length*zt,`wb-unit-link`,{"data-linked-board-id":e.linkedBoardId})),W(e,`wb-unit`,t)}function wn(e,t=sn){switch(e.kind){case`box`:return vn(e,t);case`frame`:return bn(e);case`wire`:return xn(e);case`note`:return Sn(e);case`unit`:return Cn(e);case`panel`:return hn(e)}}function Tn(e){let t=[];if(e.plan){t.push(U(Gt,e.plan.titleAt.x,e.plan.titleAt.y,`wb-column-title`));for(let n of e.plan.arrowPaths)t.push(H(`path`,{d:n,"marker-end":`url(#wb-arrow)`,class:`wb-wire-line`}))}for(let n of e.bands)t.push(H(`line`,{x1:n.x,y1:n.y,x2:n.x+n.width,y2:n.y,class:`wb-band-rule`})),n.label&&t.push(U(n.label,n.x,n.y+Yt,`wb-band-label`,{style:`fill:${n.hex}`}));for(let n of e.columns)n.titleLines.length!==0&&(n.titleLines.forEach((e,r)=>{t.push(U(e,n.x,n.titleBaselineY+r*Ht,`wb-column-title`))}),t.push(H(`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(Dn(n));return e.caption&&t.push(U(e.caption.text,e.caption.x,e.caption.y+16,`wb-caption`)),H(`g`,{class:`wb-chrome`},t.join(``))}function En(e){let{swatch:t}=e;if(t.kind===`lane`)return H(`rect`,{x:e.x,y:e.y,width:14,height:14,rx:3,class:`wb-legend-swatch`,style:`fill:${t.hex}`});if(t.kind===`status`)return H(`rect`,{x:e.x,y:e.y,width:14,height:14,rx:3,class:`wb-legend-swatch wb-unit-outline wb-unit-${t.status}`});if(t.kind===`change`)return H(`g`,{class:`wb-change-${t.change}`},H(`rect`,{x:e.x,y:e.y,width:on,height:14,rx:3,class:`wb-legend-swatch wb-box-outline`}));let n=H(`path`,{d:`M${e.x},${e.y+7} H${e.x+on}`,"marker-end":`url(#wb-arrow)`,class:t.isDashed?`wb-wire-line wb-dashed`:`wb-wire-line`});return H(`g`,{class:t.isBack?`wb-back wb-tone-${t.tone}`:`wb-tone-${t.tone}`},n)}function Dn(e){let t=e.x+(e.swatch.kind===`lane`||e.swatch.kind===`status`?22:40);return En(e)+U(e.label,t,e.y+12,`wb-legend-text`)}function On(){return H(`defs`,{},H(`marker`,{id:`wb-arrow`,viewBox:`0 0 10 10`,refX:9,refY:5,markerWidth:8,markerHeight:8,orient:`auto-start-reverse`},H(`path`,{d:`M 0 1 L 10 5 L 0 9 z`,fill:`context-stroke`})))}var kn={worthALookIds:new Set,flaggedUnitIds:new Set},An=9;function G(e,t=``){let n=document.createElementNS(Lt,e);return t&&n.setAttribute(`class`,t),n}function jn(e){let t=G(`g`);return t.innerHTML=e,[...t.children]}function Mn(e){let[t]=jn(e);if(!(t instanceof SVGGElement))throw Error(`the whiteboard markup did not draw a group`);return t}function Nn(e){let t=r(e);return t?`${i}/${t}`:null}var Pn={frame:`frames`,wire:`wires`,box:`boxes`,panel:`boxes`,note:`notes`,unit:`units`},Fn=[`box`,`frame`,`wire`,`note`,`unit`,`panel`];function In(e,t){let n={frames:G(`g`,`wb-layer`),wires:G(`g`,`wb-layer`),boxes:G(`g`,`wb-layer`),notes:G(`g`,`wb-layer`),units:G(`g`,`wb-layer`)},r=G(`g`);e.replaceChildren(...jn(On()),r,n.frames,n.wires,n.boxes,n.notes,n.units);let i=new Map,a=null,o=new Set,s=kn;function c(e,t){t.classList.toggle(`is-selected`,o.has(e))}function l(e){let t=G(`g`,`wb-look-marker`),n=e.x+e.width,r=e.y,i=G(`circle`);i.setAttribute(`cx`,String(n)),i.setAttribute(`cy`,String(r)),i.setAttribute(`r`,String(An));let a=G(`text`);return a.setAttribute(`x`,String(n)),a.setAttribute(`y`,String(r+4)),a.setAttribute(`text-anchor`,`middle`),a.textContent=`!`,t.setAttribute(`role`,`img`),t.setAttribute(`aria-label`,`worth a look in review`),t.append(i,a),t}function u(e,t){t.classList.toggle(`is-flagged`,s.flaggedUnitIds.has(e.id));let n=t.querySelector(`:scope > .wb-look-marker`);e.kind===`wire`||!s.worthALookIds.has(e.id)?n?.remove():n||t.append(l(e))}function d(t){e.setAttribute(`viewBox`,`${t.x} ${t.y} ${t.width} ${t.height}`),e.setAttribute(`width`,String(t.width)),e.setAttribute(`height`,String(t.height)),e.style.left=`${t.x}px`,e.style.top=`${t.y}px`}function f(e){let o=C(e);d(o.bounds);let s=Mn(Tn(o));r.replaceWith(s),r=s;let l=new Set;for(let e of o.elements){l.add(e.id);let t=se(e),r=i.get(e.id);if(r?.signature===t)continue;let a=Mn(wn(e,Nn));c(e.id,a),u(e,a),r&&r.node.replaceWith(a),r||n[Pn[e.kind]].append(a),i.set(e.id,{signature:t,node:a})}for(let[e,t]of i)l.has(e)||(t.node.remove(),i.delete(e));return t.sync(o),a=o,o}function p(e){if(!(e instanceof Element))return null;let t=e.closest(`.wb-element`),n=t?.dataset.elementId,r=Fn.find(e=>e===t?.dataset.elementKind);return!n||!r?null:{id:n,kind:r}}function m(e){o=e;for(let[e,t]of i)c(e,t.node)}function h(e){s=e;for(let e of a?.elements??[]){let t=i.get(e.id)?.node;t&&u(e,t)}}function g(){for(let e of i.values())e.node.remove();i.clear();let e=G(`g`);r.replaceWith(e),r=e,t.clear(),a=null}return{render:f,layout:()=>a,elementFromTarget:p,nodeOf:e=>i.get(e)?.node??null,setSelection:m,setReviewMarks:h,clear:g}}var Ln=1280,Rn={video:`play`,page:`use page`};function zn(e){return e?.kind===`video`||e?.kind===`page`}function Bn(e){return`${i}/${a(e)}`}function Vn(e){return JSON.stringify([e.kind,e.asset,e.mime,e.alt])}function Hn(e,t){e.style.left=`${t.x}px`,e.style.top=`${t.y}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`;let n=e.querySelector(`iframe.wb-media-page`);if(!n)return;let r=t.width/Ln;n.style.width=`${Ln}px`,n.style.height=`${t.height/r}px`,n.style.transform=`scale(${r})`}function Un(e){let t=ce({source:{kind:`url`,url:Bn(e)},className:`wb-media-page`,title:e.alt||`page`,allowsScripts:!0});return t.tabIndex=-1,t}function Wn({viewport:e,boardHost:t,onOpenFullSize:n}){let r=f(`div`,`wb-media-layer`),i=new Map,a=null;function o(t,r){let i=f(`div`,`wb-media`);i.dataset.boxId=t,i.dataset.mediaKind=r.kind,r.kind===`page`&&i.append(Un(r)),Hn(i,r);let a=f(`div`,`wb-media-controls`),o=c({variant:`secondary`,label:Rn[r.kind],action:`activate-media`,onClick:()=>l(t)});o.classList.add(`wb-media-activate`);let s=c({variant:`secondary`,label:`done`,action:`deactivate-media`,onClick:()=>{u(),e.focus()}});s.classList.add(`wb-media-done`);let d=c({variant:`secondary`,label:`full size`,action:`open-media-full-size`,onClick:()=>{u(),n(t,r.alt)}});return a.append(o,s,d),i.append(a),i.addEventListener(`pointerdown`,e=>{(i.hasAttribute(`data-active`)||a.contains(e.target instanceof Node?e.target:null))&&e.stopPropagation()}),i.addEventListener(`dblclick`,e=>e.stopPropagation()),i.addEventListener(`wheel`,e=>{i.hasAttribute(`data-active`)&&e.stopPropagation()}),i}function s(n){n.key===`Escape`&&n.target instanceof Node&&t.contains(n.target)&&(n.preventDefault(),n.stopPropagation(),u(),e.focus())}function l(e){let t=i.get(e);if(!t||a===e)return;u(),a=e,t.node.dataset.active=``,document.addEventListener(`keydown`,s,!0);let n=t.node.querySelector(`iframe.wb-media-page`);if(n){n.tabIndex=0,t.node.querySelector(`.wb-media-done`)?.focus();return}let r=f(`video`,`wb-media-video`);r.src=Bn(t.media),r.controls=!0,r.playsInline=!0,r.autoplay=!0,t.node.prepend(r),r.focus()}function u(){let e=a?i.get(a):void 0;if(a=null,document.removeEventListener(`keydown`,s,!0),!e)return;delete e.node.dataset.active;let t=e.node.querySelector(`video.wb-media-video`);t?.pause(),t?.remove();let n=e.node.querySelector(`iframe.wb-media-page`);n&&(n.tabIndex=-1)}function d(e){let t=new Set;for(let n of e.elements){if(n.kind!==`box`||!zn(n.media))continue;t.add(n.id);let e=Vn(n.media),s=i.get(n.id);if(s?.identity===e){Hn(s.node,n.media);continue}a===n.id&&u();let c=o(n.id,n.media);s&&s.node.replaceWith(c),s||r.append(c),i.set(n.id,{identity:e,node:c,media:n.media})}for(let[e,n]of i)t.has(e)||(a===e&&u(),n.node.remove(),i.delete(e))}function p(){u();for(let e of i.values())e.node.remove();i.clear()}return document.addEventListener(`pointerdown`,e=>{let t=a?i.get(a)?.node:void 0;t&&!t.contains(e.target instanceof Node?e.target:null)&&u()},!0),new IntersectionObserver(e=>{e.some(e=>!e.isIntersecting)&&u()}).observe(e),{element:r,sync:d,clear:p,activate:l,deactivate:u,activeBoxId:()=>a}}var Gn=`http://www.w3.org/2000/svg`,Kn=`No boards yet. Make one here, or have an agent run glimmervoid whiteboard new <title>.`,qn=`Pick a board above.`,Jn=`wb-board-title-rename`,Yn=`M13.5 8H3 M7 4L3 8l4 4`,Xn=`M4.5 6.5L8 10l3.5-3.5`,Zn=4,Qn=32,$n=new Set([`video/mp4`,`video/webm`,`text/html`]),er=/\.(png|jpe?g|gif|webp|svg|mp4|webm|html?)$/i,tr=`M2.5 6V2.5H6 M10 2.5h3.5V6 M13.5 10v3.5H10 M6 13.5H2.5V10`,nr=`M5.5 3.5l-3 3l3 3 M2.5 6.5h7a3.5 3.5 0 0 1 0 7H7`,rr=`M10.5 3.5l3 3l-3 3 M13.5 6.5h-7a3.5 3.5 0 0 0 0 7H9`,ir=[{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`,hint:null},{tool:`box`,label:`box`,key:`R`,iconPath:`M2.5 4h11v8h-11z`,hint:`Click the board to place a box. Esc to cancel.`},{tool:`decision`,label:`decision`,key:`D`,iconPath:`M8 2l6 6l-6 6l-6-6z`,hint:`Click the board to place a decision. Esc to cancel.`},{tool:`panel`,label:`panel`,key:`P`,iconPath:`M2.5 3h11v10h-11z M2.5 6h11`,hint:`Click the board to place a panel. Esc to cancel.`},{tool:`wire`,label:`wire`,key:`A`,iconPath:`M2.5 13.5L13 3 M8.5 3H13v4.5`,hint:`Drag from one box to another to connect them. Esc to cancel.`}],K=null,q=null,J=null,Y=null,ar=null,or=!0,X=null,sr=null,cr=null,Z=v(`action-status wb-status`),lr=v(`action-status wb-status`),Q=new Map,ur=Promise.resolve();function dr(e){let{dialog:t,close:n,actions:r,btnCancel:i}=h({title:e.title}),a=f(`input`,`dialog-input`);a.type=`text`,a.placeholder=e.placeholder,a.maxLength=e.maxLength,a.value=e.initialValue??``,a.autocomplete=`off`,a.setAttribute(`aria-label`,e.label);let o=f(`div`,`dialog-error`);o.setAttribute(`role`,`alert`);let s=e.choices?f(`select`,`dialog-input wb-dialog-select`):null;if(s&&e.choices){s.setAttribute(`aria-label`,e.choices.label);for(let t of e.choices.options){let e=f(`option`,null,t.text);e.value=t.value,s.append(e)}}let l=c({variant:`primary`,label:e.confirmLabel,action:`confirm-board-dialog`});r.append(l),t.append(f(`label`,`dialog-label`,e.label),a,...s?[s]:[],o,r);async function u(){let t=a.value.trim();if(!t){o.textContent=`${e.label} is empty.`;return}l.disabled=!0;let r=await e.onSubmit(t,s?.value??null);l.disabled=!1,r?o.textContent=r:n()}i.addEventListener(`click`,n),l.addEventListener(`click`,()=>void u()),a.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),u())}),requestAnimationFrame(()=>a.focus())}function $(){return K?w(K):null}function fr(){return D().find(e=>e.id===K)??null}function pr(e){let t=ur.then(e);return ur=t.catch(()=>void 0),t}function mr(e,t){return pr(()=>hr(e,t))}async function hr(e,t){let n=$(),r=await O(e,t);return r.ok&&n?.id===e&&Q.set(e,Ge(Q.get(e)??Ne,Ue(n,t))),r}function gr(e){return pr(()=>_r(e))}async function _r(e){let t=K,n=$();if(!t||!n)return;let r=Ke(Q.get(t)??Ne,e);if(!r)return;Q.set(t,r.history);let i=await O(t,r.entry);i.ok?(Z.clear(),Q.set(t,qe(Q.get(t)??Ne,e,Ue(n,r.entry)))):Z.show(`error`,`could not ${e} that change, so it was dropped: ${i.error}`)}async function vr(e){if(!K||e.length===0)return!1;let t=await mr(K,e);return t.ok?(Z.clear(),!0):(Z.show(`error`,t.error),!1)}async function yr(e){if(!K)return`No board is open.`;let t=await mr(K,e);return t.ok?null:t.error}function br(e){let t=_(e);return t?g(t):`closed session`}function xr(){let e=fr()?.connectedSessionIds??[],t=$()?.codeSessionId;return(t&&!e.includes(t)?[t,...e]:e).map(e=>({value:e,text:br(e)}))}function Sr(e){let t=$();return[...Y?.selectedIds()??new Set].flatMap(e=>t?.elements[e]??[]).filter(t=>t.kind===e)}function Cr(){if(!q)return;let e=$(),t=Sr(`box`).length;for(let t of q.toolButtons.values())t.disabled=!e;q.buttons.note.disabled=t!==1,q.buttons.frame.disabled=t===0;for(let t of[q.buttons.unit,q.buttons.fit,q.buttons.undo,q.buttons.redo])t.disabled=!e;ar?.paint(Y?.selectedIds()??new Set)}function wr(){if(!q)return;let e=D();K&&!e.some(e=>e.id===K)&&(K=null);let t=e.find(e=>X!==null&&e.connectedSessionIds.includes(X))??e[0];!K&&t&&Ur(t.id),q.boardMenu.paintBoards(e),Mr()}function Tr(){return!!q?.boardIsland.querySelector(`.${Jn}`)}function Er(){let e=fr();if(!q||!e||Tr())return;let{boardTitle:t}=q,n=f(`input`,Jn);n.type=`text`,n.value=e.title,n.maxLength=u.title,n.setAttribute(`aria-label`,`Board title`),t.replaceWith(n),n.focus(),n.select();let r=!1;function i(i){if(r||!e)return;r=!0;let a=n.value.trim();n.replaceWith(t),Mr(),i&&a&&a!==e.title&&vr([{op:`board`,title:a}])}n.addEventListener(`blur`,()=>i(!0)),n.addEventListener(`keydown`,e=>{e.stopPropagation(),(e.key===`Enter`||e.key===`Escape`)&&(e.preventDefault(),i(e.key===`Enter`))})}function Dr(e){let t=b(e.title,`visible wb-board-menu-board`);t.setAttribute(`role`,`menuitemradio`),t.setAttribute(`aria-checked`,String(e.id===K));let n=e.connectedSessionIds.length;return n>0&&t.append(f(`span`,`wb-board-menu-count`,String(n))),t.addEventListener(`click`,()=>Ur(e.id)),t}function Or(e){let t=f(`div`,`session-overflow wb-board-menu`),n=f(`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`,!pi()),n.classList.toggle(`open`,e),a.setAttribute(`aria-expanded`,String(e))},a=o({label:`board menu`,action:`open-board-menu`,onClick:()=>i(!r())});a.setAttribute(`aria-haspopup`,`menu`),a.setAttribute(`aria-expanded`,`false`);let s=(e,t,n=``)=>{let r=b(e,`visible ${n}`.trim());return r.addEventListener(`click`,t),r},c=f(`div`,`menu-divider`);c.setAttribute(`role`,`separator`);let l=s(`board settings`,e),u=[c,s(`rename board`,Er),s(`new board`,Qr),l,s(`delete board`,Zr,`wb-board-menu-danger`)];return n.addEventListener(`click`,e=>{e.target instanceof HTMLElement&&e.target.closest(`[role^="menuitem"]`)&&i(!1)}),t.append(a,n),y({trigger:a,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:a,paintBoards:e=>n.replaceChildren(...e.map(Dr),...u)}}function kr(t){let n=f(`div`,`session-overflow wb-more-menu`),r=f(`div`,`popup-menu session-overflow-menu wb-more-menu-popup`);r.setAttribute(`role`,`menu`),r.setAttribute(`aria-label`,`More tools`);let i=()=>r.classList.contains(`open`),a=e=>{r.classList.toggle(`open`,e),o.setAttribute(`aria-expanded`,String(e)),e&&Ar(r,o)},o=c({variant:`quiet`,label:`more`,icon:e(Xn,`1.5`),action:`open-more-tools`,onClick:()=>a(!i())});return o.classList.add(`wb-more-trigger`),o.setAttribute(`aria-haspopup`,`menu`),o.setAttribute(`aria-expanded`,`false`),r.append(...t),r.addEventListener(`click`,e=>{e.target instanceof HTMLElement&&e.target.closest(`[role="menuitem"]`)&&a(!1)}),n.append(o),document.body.append(r),y({trigger:o,menu:r,menuItems:()=>[...r.querySelectorAll(`[role="menuitem"]:not(:disabled)`)],isOpen:i,open:()=>a(!0),close:()=>a(!1)}),document.addEventListener(`click`,e=>{i()&&e.target instanceof Node&&!n.contains(e.target)&&!r.contains(e.target)&&a(!1)}),window.addEventListener(`resize`,()=>a(!1)),n}function Ar(e,t){let n=t.getBoundingClientRect(),r=n.bottom+Zn+e.offsetHeight<=window.innerHeight;e.style.right=`${Math.max(0,window.innerWidth-n.right)}px`,e.style.top=r?`${n.bottom+Zn}px`:`auto`,e.style.bottom=r?`auto`:`${window.innerHeight-n.top+Zn}px`}function jr(e,t,n){let r=b(e,`visible`);return r.dataset.action=t,r.addEventListener(`click`,n),r}function Mr(){if(!q)return;let e=fr(),t=D().length>0;q.canvas.hidden=!e,q.empty.hidden=!!e,q.emptyText.textContent=t?qn:Kn,e&&(q.boardTitle.textContent=e.title,q.boardMeta.textContent=`v${e.version}`,Cr(),Fr())}function Nr(e){if(!q)return;let t=e.map(br),n=e.filter(e=>e!==X).map(br),r=f(`span`,t.length===0?`wb-presence-count wb-presence-none`:`wb-presence-count wb-presence-pill`,`${t.length} connected`);q.presence.replaceChildren(...n.map(e=>f(`span`,`wb-presence-pill`,e)),r),t.length===0&&q.presence.prepend(f(`span`,`wb-presence-none`,`no sessions connected`))}function Pr(e,t){let n=br(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 Fr(){if(!q)return;let e=fr();Nr(e?.connectedSessionIds??[]),q.agentIsland.hidden=!X,X&&(q.agentIsland.toggleAttribute(`data-idle`,!Ir(e,X)),q.queuedForSession.textContent=Pr(e,X),q.sendToAgent.disabled=!e?.connectedSessionIds.includes(X))}function Ir(e,t){return!e?.connectedSessionIds.includes(t)||(e.queuedBySessionId[t]??0)>0}async function Lr(){if(!q||!K||!X)return;q.sendToAgent.disabled=!0,lr.show(`busy`,`sending`);let e=await ie(K,X);Fr(),e.ok?lr.show(`ok`,`sent; the agent reads the board when it is ready`):lr.show(`error`,e.error)}function Rr(e,t){let n=new Set(t);return new Set(Object.values(e.elements).filter(e=>he(e).some(e=>n.has(ge(e)??``))).map(e=>e.id))}function zr(e){let t=$()?.codeSessionId,n=ge(e);t&&n&&T(t,n)}function Br(){if(!q||!J)return;let e=$(),t=e&&sr?.boardId===e.id?sr.review:null;J.setReviewMarks({worthALookIds:e&&t?Rr(e,t.worthALookPaths):new Set,flaggedUnitIds:new Set(t?.flaggedUnitIds??[])})}function Vr(e){let t=`${e.id}@${e.version}`;cr!==t&&(cr=t,A(e.id).then(n=>{cr===t&&(n.ok?(sr={boardId:e.id,review:n.review},Br()):cr=null)}))}function Hr(){if(!J)return;let e=$();e?(Vr(e),Y?.pruneSelection(e),J.render(Y?.previewOf(e)??e),q&&(q.emptyBoardHint.hidden=Object.keys(e.elements).length>0),Br(),Y?.openPendingTitleEdit(),or&&=(Y?.fit(),!1),Cr()):(J.clear(),q&&(q.emptyBoardHint.hidden=!0))}function Ur(e){K!==e&&(K=e,or=!0,Y?.clearSelection(),Y?.closeTitleInput(),ar?.closeBoardSettings(),J?.clear(),Z.clear(),wr(),ae(e).then(Hr))}function Wr(){let e=$();if(!e)return;let t=D().filter(t=>t.id!==e.id),n=[{value:``,text:`No linked board`},...t.map(e=>({value:e.id,text:e.title}))];dr({title:`Add a unit`,label:`Unit title`,placeholder:`index the diffs`,maxLength:u.title,confirmLabel:`Add unit`,choices:t.length>0?{label:`Linked board`,options:n}:void 0,onSubmit:(e,t)=>yr([{op:`add`,element:{kind:`unit`,id:j(`unit`),title:e,lines:[],refs:[],status:`planned`,after:[],linkedBoardId:t||null}}])})}function Gr({boxId:e}){let t=e?$()?.elements[e]:void 0;return t?.kind===`box`?t.media:null}function Kr(e,t){let n=t?`${i}/${a(t)}`:e.href;if(t?.kind===`page`)return ce({source:{kind:`url`,url:n},className:`wb-image-viewer-page`,title:e.alt||`page`,allowsScripts:!0});if(t?.kind===`video`){let e=f(`video`,`wb-image-viewer-video`);return e.src=n,e.controls=!0,e.playsInline=!0,e}let r=f(`img`,`wb-image-viewer-picture`);return r.src=n,r.alt=e.alt,r}function qr(e){let{alt:t}=e,n=Gr(e);if(!n&&!e.href)return;let{dialog:r,close:i,actions:a,btnCancel:o}=h({title:t||`Picture`,dialogClass:`dialog wb-image-viewer`,cancelLabel:`Close`});r.append(Kr(e,n),a),o.addEventListener(`click`,i),requestAnimationFrame(()=>o.focus())}function Jr(e){dr({title:`Pin a note`,label:`Note`,placeholder:`what about retries?`,maxLength:u.noteText,confirmLabel:`Pin note`,onSubmit:t=>yr([{op:`add`,element:{kind:`note`,id:j(`note`),on:e,text:t,ref:null,author:``,resolvedBy:null}}])})}function Yr(e,t){let n=$();n&&e!==t&&(Object.values(n.elements).some(n=>n.kind===`wire`&&n.from===e&&n.to===t)||vr([{op:`add`,element:{kind:`wire`,id:j(`wire`),from:e,to:t,fromOutput:null,dashed:!1,tone:`plain`,label:null,fromSide:null,toSide:null,back:!1}}]))}function Xr(){let e=Sr(`box`).map(e=>e.id);e.length!==0&&dr({title:`Frame the selected boxes`,label:`Frame title`,placeholder:`intake`,maxLength:u.title,confirmLabel:`Add frame`,onSubmit:async t=>{let n=await yr([{op:`add`,element:{kind:`frame`,id:j(`frame`),title:t,contains:e,loop:!1}}]);return n||Y?.clearSelection(),n}})}function Zr(){let e=fr();if(!e)return;let t=e.connectedSessionIds.map(br),n=t.length>0?` ${t.join(`, `)} ${t.length===1?`is`:`are`} connected and will lose it.`:``;p({title:`Delete board`,message:`Delete "${e.title}" for good?${n}`,confirmLabel:`Delete board`,danger:!0,onConfirm:()=>{k(e.id).then(e=>{e.ok||Z.show(`error`,e.error)})}})}function Qr(){$r(Ur)}function $r(e){dr({title:`New board`,label:`Board title`,placeholder:`knowledge writer`,maxLength:u.title,confirmLabel:`Create board`,onSubmit:async t=>{let n=await ee(t);return n.ok?(e(n.boardId),null):n.error}})}function ei(t,n,r,i){return c({variant:`icon`,label:t,icon:e(n,`1.5`),action:r,onClick:i})}function ti(n,r,i,a){let o=t(`wb-tool`);o.setAttribute(`aria-label`,r);let s=f(`span`,`wb-tool-key`,i);return s.setAttribute(`aria-hidden`,`true`),o.append(e(a,`1.5`),s),o.setAttribute(`aria-keyshortcuts`,i),o.setAttribute(`aria-pressed`,String(n===`select`)),o.addEventListener(`click`,()=>{Y?.setTool(n),Y?.focusCanvas()}),o}function ni(e,t,...n){let r=f(`div`,`wb-island ${e}`);return r.setAttribute(`role`,`toolbar`),r.setAttribute(`aria-label`,t),r.append(...n),r}function ri(e){if(!q)return;for(let[t,n]of q.toolButtons)n.setAttribute(`aria-pressed`,String(t===e));let t=ir.find(({tool:t})=>t===e)?.hint??null;q.toolHint.textContent=t??``,q.toolHint.hidden=t===null}function ii(e){return!(e.metaKey||e.ctrlKey)||e.altKey||e.code!==`KeyZ`?null:e.shiftKey?`redo`:`undo`}function ai(e,t){let n=ii(t);n&&e.checkVisibility()&&!m()&&!d(t)&&(document.activeElement?.classList.contains(`xterm-helper-textarea`)||(t.preventDefault(),gr(n)))}function oi(e){return e.type.startsWith(`image/`)||$n.has(e.type)?!0:e.type===``&&er.test(e.name)}function si(e){return[...e?.files??[]].filter(oi)}function ci(e){return(e.name.replace(/\.[^.]+$/,``)||`Picture`).slice(0,u.title)}async function li(e,t){if(K&&e.length!==0){Z.show(`busy`,e.length===1?`adding ${e[0]?.name}`:`adding ${e.length} files`);for(let[n,r]of e.entries()){let e=await ne(r);if(!e.ok){Z.show(`error`,e.error);return}let i=n*Qn,a=t?{x:t.x+i,y:t.y+i}:null,o={...e.media,alt:r.name.slice(0,u.line)};if(!await Y?.placeMediaBox(ci(r),o,a))return}Z.clear()}}function ui(e,t){t.addEventListener(`dragover`,e=>{K&&e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}),t.addEventListener(`drop`,e=>{let t=si(e.dataTransfer);t.length!==0&&(e.preventDefault(),li(t,{x:e.clientX,y:e.clientY}))}),document.addEventListener(`paste`,t=>{if(!e.checkVisibility()||m()||di())return;let n=si(t.clipboardData);n.length!==0&&(t.preventDefault(),li(n,null))})}function di(){let e=document.activeElement;return e?.classList.contains(`xterm-helper-textarea`)?!0:e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function fi(){if(q)return q.host;let e=f(`div`,`boards-view`),n=Or(()=>{Y?.clearSelection(),ar?.openBoardSettings()});n.trigger.dataset.phoneVisible=``;let r=t(`wb-board-title pane-header-title`);r.addEventListener(`click`,Er);let i=f(`span`,`wb-board-meta pane-header-subtitle`),a=f(`div`,`wb-presence`),o=ni(`wb-island-board`,`Board`,n.menuRoot,r,i,a,Z.element),s=new Map(ir.map(({tool:e,label:t,key:n,iconPath:r})=>[e,ti(e,t,n,r)])),l=f(`div`,`wb-tools`);l.setAttribute(`role`,`group`),l.setAttribute(`aria-label`,`Drawing tools`),l.append(...s.values());let u={note:jr(`note on box`,`add-note`,()=>{let[e]=Sr(`box`);e&&Jr(e.id)}),frame:jr(`frame selected boxes`,`add-frame`,Xr),unit:jr(`plan step`,`add-unit`,Wr),fit:ei(`fit`,tr,`fit-board`,()=>Y?.fit()),undo:ei(`undo`,nr,`undo-board-edit`,()=>void gr(`undo`)),redo:ei(`redo`,rr,`redo-board-edit`,()=>void gr(`redo`))};u.fit.dataset.phoneVisible=``;let d=f(`span`,`wb-divider`);d.setAttribute(`aria-hidden`,`true`);let p=ni(`wb-island-tools`,`Board tools`,l,d,kr([u.note,u.frame,u.unit])),m=f(`p`,`wb-tool-hint`);m.setAttribute(`aria-live`,`polite`),m.hidden=!0;let h=ni(`wb-island-view`,`View`,u.fit,u.undo,u.redo),g=f(`div`,`wb-canvas`),_=f(`div`,`wb-viewport`);_.setAttribute(`role`,`application`),_.setAttribute(`aria-label`,`Whiteboard`);let v=f(`div`,`wb-world`),y=document.createElementNS(Gn,`svg`);y.setAttribute(`class`,`wb-svg`),y.setAttribute(`aria-hidden`,`true`);let b=Wn({viewport:_,boardHost:g,onOpenFullSize:(e,t)=>qr({boxId:e,href:``,alt:t})});v.append(y,b.element),_.append(v);let x=f(`aside`,`wb-inspect`),S=f(`span`,`wb-session-queued`),ee=ei(`send to agent`,Yn,`send-board-to-agent`,()=>void Lr()),C=ni(`wb-island-agent`,`Session`,ee,S,lr.element);C.hidden=!0;let w=f(`div`,`wb-bottom-left`);w.append(C);let T=f(`div`,`wb-top-left`);T.append(o,h,p,m);let ne=f(`div`,`wb-top-right`);ne.append(x);let E=f(`div`,`wb-empty-board`);E.hidden=!0;let D=f(`p`,`wb-empty-board-desc`);D.append(f(`span`,`wb-empty-board-keys`,`Pick box (R) and click the board to place one, or ask a session to draw here.`),f(`span`,`wb-empty-board-touch`,`Ask a session to draw here.`)),E.append(f(`p`,`wb-empty-board-title`,`This board is empty.`),D),g.append(_,E,ne,T,w);let O=f(`p`,`wb-empty-text`,Kn),k=f(`div`,`wb-empty`);k.append(O,c({variant:`secondary`,label:`new board`,action:`new-board`,onClick:Qr})),e.replaceChildren(g,k),q={boardIsland:o,boardMenu:n,boardTitle:r,boardMeta:i,presence:a,host:e,chrome:T,canvas:g,empty:k,emptyText:O,agentIsland:C,queuedForSession:S,sendToAgent:ee,buttons:u,toolButtons:s,toolHint:m,emptyBoardHint:E};let A=In(y,b);return J=A,ar=It({container:x,currentBoard:$,layout:()=>A.layout(),sendOps:vr,codeSessionChoices:xr,openRef:zr}),Y=Me({viewport:_,world:v,svg:y,canvas:g,renderer:A,currentBoard:$,sendOps:vr,onSelectionChange:Cr,onPhoneTapBox:Jr,onOpenLinkedBoard:Ur,onOpenImage:qr,onActivateMedia:b.activate,onConnectBoxes:Yr,onToolChange:ri}),document.addEventListener(`keydown`,t=>ai(e,t)),ui(e,g),re(wr),te(e=>{e===K&&Hr()}),wr(),e}function pi(){return document.documentElement.dataset.layout===`phone`}function mi(e){q&&(e?q.boardIsland.parentElement!==e&&e.append(q.boardIsland):q.chrome.firstElementChild!==q.boardIsland&&q.chrome.prepend(q.boardIsland))}function hi(e,t){t!==X&&lr.clear(),X=t,e&&Ur(e),Fr()}function gi(){wr(),cr=null,K&&ae(K).then(Hr)}var _i=null;function vi(e){_i=e,e.replaceChildren(fi())}function yi(){let e=fi();_i&&e.parentElement!==_i&&_i.replaceChildren(e),mi(null),hi(E()?.boardId??null,null),gi()}var bi={mount:vi,refresh:yi};export{$r as createBoardFromDialog,fi as mountBoardHost,mi as placeBoardTitle,gi as reopenSelectedBoard,hi as showBoardBeside,bi as view};
|
|
Binary file
|