pi-straw-boss 0.76.0 → 0.77.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +1 -1
  2. package/README.zh-TW.md +1 -4
  3. package/dist/gui/assets/{allyasks-Czxu9N0_.js → allyasks-B157BVSK.js} +1 -1
  4. package/dist/gui/assets/{allyunits-Cu820tRD.js → allyunits-D49tC5yS.js} +1 -1
  5. package/dist/gui/assets/{answer-D3Fc6DBr.js → answer-B_eEaZuu.js} +1 -1
  6. package/dist/gui/assets/{ask-DK8Sf6Pa.js → ask-Cf4u8awy.js} +1 -1
  7. package/dist/gui/assets/{asks-DqkFBBS7.js → asks-BP9fh8zE.js} +1 -1
  8. package/dist/gui/assets/{askview-gHx_Hk2d.js → askview-BzFy3A9l.js} +1 -1
  9. package/dist/gui/assets/{autoback-CZkFJtdj.js → autoback-mQmgZrYL.js} +1 -1
  10. package/dist/gui/assets/{blockschunk-DUknCMor.js → blockschunk-Bcf8T3l_.js} +1 -1
  11. package/dist/gui/assets/{box-BUf9E97Z.js → box-CdTJxlY3.js} +1 -1
  12. package/dist/gui/assets/{chat-CraWb-vz.js → chat-pwXYtfIJ.js} +1 -1
  13. package/dist/gui/assets/{drawer-DyN2PbF3.js → drawer-C4b67hAK.js} +1 -1
  14. package/dist/gui/assets/index-Dvw58cHb.js +4 -0
  15. package/dist/gui/assets/{lanwait-y3ZgXxvk.js → lanwait-D8XQhI49.js} +1 -1
  16. package/dist/gui/assets/{layer-BMeWKQ6w.js → layer-CcPpb9oC.js} +1 -1
  17. package/dist/gui/assets/{lightbox-BtmIeJYB.js → lightbox-cGNtXXLf.js} +1 -1
  18. package/dist/gui/assets/{link-_ku8_F1J.js → link-CfF8WoKX.js} +1 -1
  19. package/dist/gui/assets/{linkdialogs-BHiWLB73.js → linkdialogs-BtrIR5oZ.js} +1 -1
  20. package/dist/gui/assets/{mdbody-DmC2OoJ3.js → mdbody-CM0vyeve.js} +1 -1
  21. package/dist/gui/assets/{pair-6RKgnkV8.js → pair-BdBNEx-I.js} +1 -1
  22. package/dist/gui/assets/{picker-C9mN-2Ml.js → picker-CBlvQLT5.js} +1 -1
  23. package/dist/gui/assets/{server-D8Peiga1.js → server-CSZVUOSr.js} +1 -1
  24. package/dist/gui/assets/{sessionfacts-C-3Lh2Gu.js → sessionfacts-R0PNxQ07.js} +1 -1
  25. package/dist/gui/assets/{settings-C5nXwYtK.js → settings-Bqjz9KP-.js} +1 -1
  26. package/dist/gui/assets/{spawn-DmP1vT7z.js → spawn-DlKByPlr.js} +1 -1
  27. package/dist/gui/assets/{termcard-BWctoI4H.js → termcard-acLQMoog.js} +1 -1
  28. package/dist/gui/assets/{towerturns-Cd9alhqa.js → towerturns-Cldgw4hX.js} +1 -1
  29. package/dist/gui/assets/{trains-GY_I0p6W.js → trains-CY_wPPrG.js} +1 -1
  30. package/dist/gui/assets/{trust-D-_wrdAz.js → trust-DYlVFo7K.js} +1 -1
  31. package/dist/gui/assets/{views-SvadD2NQ.js → views-BxBhtxB1.js} +1 -1
  32. package/dist/gui/assets/{waitcard-Xgi9yQRE.js → waitcard-BF4toG4g.js} +1 -1
  33. package/dist/gui/assets/{yard-C6xyMp5L.js → yard-Bqrbq1yf.js} +1 -1
  34. package/dist/gui/index.html +2 -2
  35. package/dist/gui/themes/raven/{raven-DGx4eH2o.js → raven-Dr7te0ib.js} +2 -2
  36. package/dist/gui/themes/zen/{zen-BQrgqRoA.js → zen-C2J8hYV2.js} +1 -1
  37. package/dist/gui/themes.json +2 -2
  38. package/dist/server/{chunk-7HXSLT4U.mjs → chunk-ENYILM47.mjs} +4 -0
  39. package/dist/server/cli.mjs +1 -1
  40. package/dist/server/main.mjs +208 -42
  41. package/package.json +1 -1
  42. package/prompts/apps-config.md +1 -1
  43. package/prompts/integrator.md +1 -1
  44. package/prompts/main.md +1 -1
  45. package/prompts/planning.md +1 -1
  46. package/prompts/tower-run.md +1 -1
  47. package/prompts/train.md +1 -1
  48. package/src/carwait.ts +105 -0
  49. package/src/index.ts +1 -1
  50. package/src/server/carbook.ts +186 -33
  51. package/src/server/carnotices.ts +14 -8
  52. package/src/server/carops.ts +3 -1
  53. package/src/train/cars.ts +12 -2
  54. package/src/train/contract-legacy.ts +19 -0
  55. package/src/train/contract.ts +51 -0
  56. package/src/traincar.ts +32 -6
  57. package/src/trainguard.ts +11 -12
  58. package/dist/gui/assets/index-LCc1BzpW.js +0 -4
  59. package/src/train/anchorloop.ts +0 -78
package/src/train/cars.ts CHANGED
@@ -57,11 +57,14 @@ export interface CarFile {
57
57
  states: StateEntry[];
58
58
  }
59
59
 
60
+ /** The state a car's life ended with (`returned`, `dropped` or `landed`), or nothing while it has not ended. */
61
+ export const endOf = (file: { states: readonly StateEntry[] }): StateEntry | undefined => file.states.find((s) => isTerminal(s.state));
62
+
60
63
  export function emptyCar(car: { project: string; app: string; tickets: string[]; branch: string; head: string; coordinator: string }): CarFile {
61
64
  return { v: 1, project: car.project, app: car.app, car: { tickets: [...car.tickets], branch: car.branch, head: car.head }, coordinator: car.coordinator, states: [] };
62
65
  }
63
66
 
64
- /** `<app>-<first 12 hex of the head>.json`: a car that comes back reworked has a new head and so a new file. */
67
+ /** `<app>-<first 12 hex of the head>.json`: a car that comes back reworked has a new head and so a new file; one sent again with the same head starts a new life in the same file (the book keeps the earlier life, carbook.ts). */
65
68
  export function carFileName(app: string, head: string): string {
66
69
  if (!isName(app)) throw new Error(`sb: app "${app}" is not a path-safe name`);
67
70
  if (!SHA_RE.test(head)) throw new Error(`sb: head "${head}" is not 40 hex`);
@@ -237,9 +240,16 @@ const toldRefusals = (found: CarView, ticket: string, state: CarState): string[]
237
240
  /** A car file with its notice record: what the server answers for a car (`cars-read`). */
238
241
  export interface CarView { file: CarFile; notice?: NoticeRecord }
239
242
 
243
+ /** The lives of one car (an app and a head) among the views, and the current one: a car sent again after it was returned or dropped has a view for each life (#14), and the life whose state is newest is the one it lives now. */
244
+ export const livesOf = (cars: readonly CarView[], app: string, head: string): CarView[] => cars.filter((c) => c.file.app === app && c.file.car.head === head);
245
+ export const currentLife = (cars: readonly CarView[], app: string, head: string): CarView | undefined => livesOf(cars, app, head).reduce<CarView | undefined>((top, c) => (top && latest(top.file) >= latest(c.file) ? top : c), undefined);
246
+
247
+ /** The word for a car that is on the base already, at `received` (#15): a car lands once, so it takes no train again, and the integrator returns it with this word. `how` says how sb knows: the head is on the base's remote branch, or the book holds its `landed`. */
248
+ export const landedWord = (ticket: string, head: string, how: string) => `sb: car ${ticket} (${head.slice(0, 12)}) ${how}, so it takes no train again: a car lands once. Return it with this word (train_car returned), which tells its coordinator`;
249
+
240
250
  /** The `received` notice of a car (by app and head) is told, and the car was received by the train `train` when given: what the integrator's `train` todo waits for (§5.5, §7.4). Empty when it holds. */
241
251
  export function receivedTold(cars: readonly CarView[], car: { app: string; head: string; ticket: string }): string[] {
242
- const found = cars.find((c) => c.file.app === car.app && c.file.car.head === car.head);
252
+ const found = currentLife(cars, car.app, car.head);
243
253
  if (!found) return [`sb: car ${car.ticket} was never received: set it received with train_car first`];
244
254
  const entry = found.file.states.find((s) => s.state === "received");
245
255
  if (!entry) return [`sb: car ${car.ticket} is not received (${found.file.states.at(-1)?.state ?? "no state"}): set it received with train_car first`];
@@ -0,0 +1,19 @@
1
+ import { readFileSync, realpathSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+
4
+ // The transition of the merge-train contract (contract.ts), and the only place Straw Boss names a skills package. pi-anchorloop implemented contract 1 from 2.11.0 on, before there was a declaration to carry: a skill with no
5
+ // declaration that sits in that package (`<package>/skills/<name>/SKILL.md`), at that version or newer, counts as declaring "1". A declaration always wins over this. Remove this file, its one call in contract.ts and its test
6
+ // once the pi-anchorloop that declares the contract is the oldest in use.
7
+
8
+ const PACKAGE = "pi-anchorloop", SINCE = [2, 11, 0];
9
+
10
+ export function legacyContract(skillFile: string): string | undefined {
11
+ try {
12
+ const pkg = JSON.parse(readFileSync(join(dirname(realpathSync(skillFile)), "..", "..", "package.json"), "utf8")) as { name?: unknown; version?: unknown };
13
+ const found = pkg.name === PACKAGE && typeof pkg.version === "string" ? /^(\d+)\.(\d+)\.(\d+)(-.*)?$/.exec(pkg.version) : null;
14
+ if (!found) return undefined;
15
+ const at = [1, 2, 3].map((i) => Number(found[i])), differs = at.findIndex((n, i) => n !== SINCE[i]);
16
+ // A pre-release of the first version is older than it.
17
+ return (differs < 0 ? found[4] === undefined : at[differs]! > SINCE[differs]!) ? "1" : undefined;
18
+ } catch { return undefined; }
19
+ }
@@ -0,0 +1,51 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { legacyContract } from "./contract-legacy.ts";
3
+
4
+ // The merge-train contract (docs/specs/2026-11-07-train-workers.md §14.1, TB-F008). The train's and the integrator's prompts follow two skills by name, `integrating` and `deploying`, and assume what version 1 of the contract
5
+ // holds (the seven seams read from one `## Seam bindings` block, the Project skill headings with `## Acceptance`, the car slip); a model cannot tell a stale procedure from a current one by reading the skill. So a skill declares
6
+ // the contract versions it implements in its frontmatter, under the Agent Skills `metadata` map (the one field the specification leaves to clients):
7
+ //
8
+ // metadata:
9
+ // merge-train-contract: "1"
10
+ //
11
+ // and the guard asks this module. It names no package: the skills are the two pi loaded for this session (`pi.getCommands()`, each with the SKILL.md the model reads), whoever ships them. A skill pi did not load, a file that
12
+ // cannot be read, no declaration, or a declaration without this version refuses the train's and the integrator's mutating calls with the reason. The version is a whole number that rises only when a host written for the one
13
+ // before would go wrong; a skill that still serves the older hosts lists both ("1 2").
14
+
15
+ export const CONTRACT = 1;
16
+ export const CONTRACT_SKILLS = ["integrating", "deploying"] as const;
17
+ export type Contract = { ok: true; contract: number } | { ok: false; refusal: string };
18
+ /** A row of `pi.getCommands()`, as far as this reads it. */
19
+ export interface SkillCommand { name: string; source?: string; sourceInfo?: { path?: string } }
20
+
21
+ /** The value of `merge-train-contract` under the frontmatter's `metadata:`, unquoted; undefined when the text declares none. Any other spelling of the two lines reads as none, which refuses. */
22
+ export function declaredContract(text: string): string | undefined {
23
+ const lines = /^\uFEFF?---\r?\n([\s\S]*?)\r?\n---/.exec(text)?.[1]?.split(/\r?\n/) ?? [];
24
+ const at = lines.findIndex((line) => /^metadata:\s*(#.*)?$/.test(line));
25
+ let indent: string | undefined;
26
+ for (const line of at < 0 ? [] : lines.slice(at + 1)) {
27
+ if (/^\S/.test(line)) break;
28
+ if (/^\s*(#.*)?$/.test(line)) continue;
29
+ indent ??= /^\s+/.exec(line)![0]; // the map's own keys: a key nested deeper is another map's
30
+ const found = /^(\s+)merge-train-contract:\s*(.*?)\s*(?:\s#.*)?$/.exec(line);
31
+ if (found?.[1] === indent) return found[2]!.replace(/^(["'])(.*)\1$/, "$2");
32
+ }
33
+ return undefined;
34
+ }
35
+
36
+ export function checkContract(commands: readonly SkillCommand[] | undefined, need = CONTRACT): Contract {
37
+ const refuse = (why: string): Contract => ({ ok: false, refusal: `sb: the merge train needs the skills ${CONTRACT_SKILLS.map((name) => `\`${name}\``).join(" and ")} to declare merge-train contract ${need}, and ${why}, then try again` });
38
+ if (!commands) return refuse("this pi does not list its skills (pi.getCommands); update pi");
39
+ for (const name of CONTRACT_SKILLS) {
40
+ const file = commands.find((c) => c.source === "skill" && c.name === `skill:${name}` && c.sourceInfo?.path)?.sourceInfo?.path;
41
+ if (!file) return refuse(`pi loaded no skill named \`${name}\`; install a package that provides it and /reload`);
42
+ let text: string;
43
+ try { text = readFileSync(file, "utf8"); } catch (error) { return refuse(`${file} cannot be read (${(error as Error).message}); fix it and /reload`); }
44
+ const said = declaredContract(text) ?? legacyContract(file);
45
+ if (said === undefined) return refuse(`${file} declares none (its frontmatter needs \`metadata:\` with \`merge-train-contract: "${need}"\` under it); update the package that ships it and /reload`);
46
+ const versions = said.split(/[\s,]+/).filter(Boolean);
47
+ if (!versions.length || versions.some((v) => !/^\d+$/.test(v))) return refuse(`${file} declares ${JSON.stringify(said)}; its value lists the contract versions the skill implements, such as "${need}"`);
48
+ if (!versions.includes(String(need))) return refuse(`${file} declares ${JSON.stringify(said)}; update ${versions.every((v) => Number(v) > need) ? "pi-straw-boss" : "the package that ships it"} and /reload`);
49
+ }
50
+ return { ok: true, contract: need };
51
+ }
package/src/traincar.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { isAbsolute, join, resolve } from "node:path";
2
2
  import { Type } from "typebox";
3
+ import { createReturnWatch, type ReturnWatch } from "./carwait.ts";
3
4
  import { bodyOf, fieldsOf } from "./headerfields.ts";
4
5
  import { makeCtx, trusted } from "./server/client.ts";
5
6
  import { slotOf } from "./server/record.ts";
@@ -8,7 +9,7 @@ import { startOf } from "./startof.ts";
8
9
  import type { Kit } from "./state.ts";
9
10
  import { snapshotOfBranch } from "./todo.ts";
10
11
  import { parseSlip } from "./train/accept.ts";
11
- import { CAR_STATES, type CarState, type CarView, coordinatorWord, forwardsOf, validateStateFields } from "./train/cars.ts";
12
+ import { CAR_STATES, type CarState, type CarView, coordinatorWord, forwardsOf, noticeText, validateStateFields } from "./train/cars.ts";
12
13
  import { isName, isObject, type Json } from "./train/spec.ts";
13
14
  import { type Manifest, rowsOfSnapshot, slipBlocks, type TrainGuard } from "./trainguard.ts";
14
15
  import type { TrainId } from "./trainrole.ts";
@@ -47,7 +48,7 @@ export interface CarClientDeps {
47
48
  held?: Map<string, string>;
48
49
  }
49
50
  export interface CarSet { state: CarState; car: Json; fields: Json }
50
- export interface SetAnswer { state: CarState; at: string; file: string; coordinator: string }
51
+ export interface SetAnswer { state: CarState; at: string; file: string; coordinator: string; notice?: string; unchecked?: string }
51
52
 
52
53
  /** The session's way to the server's book of cars: it registers once, holds the secret in memory, and asks for states and for the cars of a project. */
53
54
  export function createCarClient(d: CarClientDeps) {
@@ -116,6 +117,8 @@ export interface CarToolDeps {
116
117
  manifest(ctx: CarCtx): Manifest | undefined;
117
118
  client: Pick<CarClient, "set">;
118
119
  home: string;
120
+ /** The integrator's wait for the notice of a car it returned (carwait.ts, #13): nothing else waits for that notice, so the session does. */
121
+ returns?: Pick<ReturnWatch, "add">;
119
122
  }
120
123
  export interface CarParams { car: string; state: CarState; project?: string; train?: string; departs?: string; reason?: string; round?: number; evidence?: string; version?: string; commit?: string }
121
124
  const FIELD_KEYS = ["train", "departs", "reason", "round", "evidence", "version", "commit"] as const;
@@ -179,21 +182,44 @@ export async function trainCar(deps: CarToolDeps, params: CarParams, ctx: CarCtx
179
182
  car = { app, head: mine.head, tickets: mine.row?.tickets ?? slip.tickets, branch: slip.fields.branch ?? "" };
180
183
  }
181
184
  const answer = await deps.client.set({ state, car, fields });
182
- const text = `Car ${ticket} is ${state}. sb tells its coordinator (${answer.coordinator || coordinator}) by session id and confirms the delivery; ${state === "received" ? "the train todo" : state === "landed" ? "the land step" : "the assemble that removes it"} waits for that${state === "received" ? " before the manifest goes to the tower" : ""}. You send no notice yourself.`;
185
+ const told = answer.coordinator || coordinator;
186
+ // A car returned at receipt is on no train, so no step of a train waits for its notice: this session does, and calls the tower when the server lost it.
187
+ const waiting = role === "main" && state === "returned" && deps.returns !== undefined;
188
+ if (waiting) deps.returns!.add({ project: String(car.project), app: String(car.app), head: String(car.head), ticket, coordinator: told, at: answer.at, line: answer.notice ?? noticeText("returned", { ticket, head: String(car.head), reason: String(fields.reason) }) });
189
+ const waits = waiting ? "this session waits for that and calls the tower itself if the sb server loses the notice" : `${state === "received" ? "the train todo" : state === "landed" ? "the land step" : "the assemble that removes it"} waits for that${state === "received" ? " before the manifest goes to the tower" : ""}`;
190
+ const text = `Car ${ticket} is ${state}. sb tells its coordinator (${told}) by session id and confirms the delivery; ${waits}. You send no notice yourself.${answer.unchecked ? ` Received unchecked: ${answer.unchecked}.` : ""}`;
183
191
  return { text, details: { car: ticket, ...answer } };
184
192
  }
185
193
 
186
- /** The tool of a train and of the integrator. Registered when the session has joined the net, unless the merge train is off. */
187
- export function trainCarTool(kit: Kit, guard: () => TrainGuard | undefined, link: ReturnType<typeof carLink>) {
188
- const { pi, s } = kit, { client } = link;
194
+ const FIRST_LOOK_MS = 3_000;
195
+
196
+ /** The tool of a train and of the integrator. Registered when the session has joined the net, unless the merge train is off. `callTower` is this session's `blocked` call to its tower, for a returned car whose notice the server lost (carwait.ts). */
197
+ export function trainCarTool(kit: Kit, guard: () => TrainGuard | undefined, link: ReturnType<typeof carLink>, callTower: (text: string) => Promise<unknown>) {
198
+ const { pi, s, cfg } = kit, { client } = link;
189
199
  let registered = false;
190
200
  return () => {
191
201
  if (s.isTower || registered || !link.enabled()) return;
192
202
  registered = true;
193
203
  link.keepRegistering();
204
+ // The wait for the notices of the cars this session returned: a look soon after each return, then every 15 s while one is still awaited (also after a /reload, which finds the waits of the module before it).
205
+ const watch = createReturnWatch({ session: () => kit.me() || undefined, read: (project) => client.read(project), callTower, now: cfg.now });
206
+ let timer: ReturnType<typeof setTimeout> | undefined, stopped = false;
207
+ const look = (ms: number) => {
208
+ if (stopped || timer || !watch.size()) return;
209
+ timer = setTimeout(() => { timer = undefined; void watch.tick().catch(() => undefined).then(() => look(CHECK_MS)); }, ms);
210
+ timer.unref?.();
211
+ };
212
+ look(FIRST_LOOK_MS);
213
+ // A reload keeps the waits (the module loaded next goes on with them); any other end of the session hands them to the tower, since nobody waits after it.
214
+ pi.on("session_shutdown", async (event) => {
215
+ stopped = true;
216
+ if (timer) clearTimeout(timer);
217
+ if (event.reason !== "reload" && watch.size()) await watch.end().catch(() => undefined);
218
+ });
194
219
  const deps: CarToolDeps = {
195
220
  role: () => (s.isTrain ? "train" : kit.role() === "main" ? "main" : undefined), train: () => (s.isTrain ? s.train : undefined),
196
221
  manifest: (ctx) => guard()?.manifestOf(ctx as never), client, home: process.env.HOME ?? "",
222
+ returns: { add: (wait) => { watch.add(wait); look(FIRST_LOOK_MS); } },
197
223
  };
198
224
  pi.registerTool({
199
225
  name: "train_car", label: "train_car",
package/src/trainguard.ts CHANGED
@@ -8,7 +8,7 @@ import { serverCli } from "./server/version.ts";
8
8
  import { startOf } from "./startof.ts";
9
9
  import { snapshotOfBranch } from "./todo.ts";
10
10
  import { type Acceptance, acceptanceOf, checkAcceptRef, checkCar, checkEvidence, type EvidenceOptions, parseSlip, slipBlocks } from "./train/accept.ts";
11
- import { type Anchorloop, checkAnchorloop } from "./train/anchorloop.ts";
11
+ import { checkContract, type Contract, type SkillCommand } from "./train/contract.ts";
12
12
  import { type AppIntegration, readAppIntegration } from "./train/appsconfig.ts";
13
13
  import { type BoardRead, type BoardStep, boardPath, capBoard, type CarRow, factsOf, readBoard, readTrainboards, validateTrainTodo, type Writer, writeBoard, writeYard } from "./train/board.ts";
14
14
  import { type CarView, coordinatorWord, forwardsFor, forwardsOf, noticeSatisfied, receivedTold, type TerminalState } from "./train/cars.ts";
@@ -197,8 +197,8 @@ export interface GuardEnv {
197
197
  pid?: number;
198
198
  /** The sb server's book of cars (§5.5): the one place a car's state and the delivery of its notice are read. The guard never reads the car files on disk, which the train's shell can write. Left out, a check that needs a notice is refused. */
199
199
  cars?: CarSource;
200
- /** Whether the installed pi-anchorloop is the version the train's prompts assume (train/anchorloop.ts, TB-F008): a train's and the integrator's mutating calls are refused with its reason when it is not. Left out, nothing is checked. */
201
- anchorloop?(cwd: string | undefined): Anchorloop;
200
+ /** Whether the `integrating` and `deploying` skills pi loaded declare the merge-train contract the train's prompts assume (train/contract.ts, TB-F008): a train's and the integrator's mutating calls are refused with its reason when they do not. Left out, nothing is checked. */
201
+ contract?(): Contract;
202
202
  }
203
203
  /** The sb server's answer about the cars of a project, over its socket. */
204
204
  export interface CarSource { read(project: string): Promise<CarView[]> }
@@ -255,12 +255,11 @@ export function createTrainGuard(pi: GuardPi, env: GuardEnv) {
255
255
  return { session: env.session().id, ...(env.session().pane ? { pane: env.session().pane } : {}), pid, started: Number.isNaN(at) ? created : new Date(at).toISOString() };
256
256
  };
257
257
  const alive = env.alive ?? ((w: Writer) => writerAlive(w));
258
- // The installed version changes only when the boss updates it: read at most once a minute.
259
- let versionSeen: { at: number; cwd: string | undefined; got: Anchorloop } | undefined;
260
- const anchorloopOf = (ctx: Ctx): Anchorloop => {
261
- if (!env.anchorloop) return { ok: true, version: "unchecked" };
262
- if (!versionSeen || versionSeen.cwd !== ctx.cwd || env.now() - versionSeen.at > 60_000 || !versionSeen.got.ok) versionSeen = { at: env.now(), cwd: ctx.cwd, got: env.anchorloop(ctx.cwd) };
263
- return versionSeen.got;
258
+ // The skills pi loaded change only when the boss updates them and reloads: read at most once a minute, and again on every call while they are refused.
259
+ let contractSeen: { at: number; got: Contract } | undefined;
260
+ const contractNow = (): Contract | undefined => {
261
+ if (env.contract && (!contractSeen || env.now() - contractSeen.at > 60_000 || !contractSeen.got.ok)) contractSeen = { at: env.now(), got: env.contract() };
262
+ return contractSeen?.got;
264
263
  };
265
264
 
266
265
  /** Every board of the project as the waits read them; a read that is cut or cannot list holds everything, which is a refusal here. */
@@ -543,8 +542,8 @@ export function createTrainGuard(pi: GuardPi, env: GuardEnv) {
543
542
  // The skills the prompts follow must be the ones they assume; a call that changes nothing (a todo read) is let through.
544
543
  const mutates = event.toolName === "MonitorCreate" || input.action === "create" || input.action === "update" || input.action === "delete" || input.action === "clear";
545
544
  if (!reasons.length && mutates && (me || (event.toolName === "todo" && env.isMain() && (hasSb(input) || changesTrainTodo(input, ctx))))) {
546
- const version = anchorloopOf(ctx);
547
- if (!version.ok) reasons = [version.refusal];
545
+ const contract = contractNow();
546
+ if (contract && !contract.ok) reasons = [contract.refusal];
548
547
  }
549
548
  } catch (error) {
550
549
  // A guard that fails does not let the call through: the train's checks are enforcement.
@@ -602,6 +601,6 @@ export function registerTrainGuard(kit: Kit, cars: CarSource | undefined, mainDu
602
601
  return createTrainGuard(kit.pi as unknown as GuardPi, {
603
602
  stateDir: kit.guiDir, train: () => (s.isTrain ? s.train : undefined), pending: () => !s.isTrain && !s.trainSettled && s.trainSign, isMain: () => kit.role() === "main", duty: () => mainDuty.now(), session: () => ({ id: kit.me(), ...(s.at?.paneId ? { pane: s.at.paneId } : {}) }), now: () => cfg.now(),
604
603
  node: process.execPath, cli: serverCli(), home: homedir(), tell: kit.tell, ...(cars ? { cars } : {}),
605
- anchorloop: (cwd) => checkAnchorloop({ agentDir: cfg.env.PI_CODING_AGENT_DIR ?? join(homedir(), ".pi", "agent"), ...(cwd ? { cwd } : {}) }),
604
+ contract: () => checkContract((kit.pi as { getCommands?(): readonly SkillCommand[] }).getCommands?.()),
606
605
  });
607
606
  }
@@ -1,4 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../themes/geek/geek-DKklPcga.css","../themes/zen/zen-CyPgPbzb.css","../themes/raven/raven-xbq3LIC7.css"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./rolldown-runtime-DK3Fl9T5.js";import{C as t,E as n,S as r,T as i,a,b as o,f as s,h as c,m as l,p as u,u as d,v as f,w as p,x as m}from"./towermodel-BIQTmR-P.js";import{i as h,n as g,r as _,t as v}from"./runtime-ZX6HkxDa.js";import{n as y,t as b}from"./sentencepack-DtYqpppS.js";import{t as x}from"./headkey-BhBqIerz.js";var ee=[`standard`,`geek`,`zen`,`raven`];[...ee];var te=e=>typeof e==`string`&&ee.includes(e)?e:void 0,S={view:`sb.view`,locale:`sb-locale`,effects:`sb.effects`,effectsVolume:`sb.effects.volume`,background:`sb.background`,backgroundVolume:`sb.background.volume`,remind:`sb.remind`,wide:`sb.dialog-wide`,zenHint:`sb.zen.homehint`,zenMusic:`sb.zen.music`,zenTrack:`sb.zen.track`},ne={effects:`sb.sound`,background:`sb.sound`,effectsVolume:`sb.volume`,backgroundVolume:`sb.volume`},re=e=>Math.min(100,Math.max(0,Number(e??`60`)||0)),ie={view:e=>e??`auto`,locale:e=>e??null,effects:e=>e===`1`,background:e=>e===`1`,effectsVolume:e=>re(e),backgroundVolume:e=>re(e),remind:e=>(e??`1`)===`1`,wide:e=>e===`1`,zenHint:e=>e!==null,zenMusic:e=>e===`1`,zenTrack:e=>e??null};function ae(e){let t=[];return{get(t){let n;try{n=e.getItem?.(S[t]),n===null&&ne[t]&&(n=e.getItem?.(ne[t]))}catch{}return ie[t](n)},set(t,n){try{return e.setItem(S[t],typeof n==`boolean`?n?`1`:`0`:String(n)),!0}catch{return!1}},on(e,n){t.length||addEventListener(`storage`,e=>t.forEach(([t,n])=>e.key===t&&n())),t.push([S[e],n])}}}var C=ae({getItem:e=>localStorage.getItem(e),setItem:(e,t)=>localStorage.setItem(e,t)});S.view;var oe={geek:`#000000`,zen:`#14110e`,raven:`#0d0a10`},se=e=>te(e)??`auto`,ce=(e,t=`auto`)=>t===`auto`?e?`geek`:`standard`:t,le=(e,t,n=`auto`)=>e===`auto`?ce(t,n):e;function ue(){return{root:document.documentElement,meta:document.querySelector(`meta[name="theme-color"]`),server:document.querySelector(`meta[name="sb-view"]`),media:matchMedia(`(prefers-contrast: more)`),storage:localStorage}}function de(e=ue()){let t=[],n=[],r=e.meta?.content??``,i=ae(e.storage),a=()=>se(i.get(`view`)),o=a(),s=se(e.server?.content),c,l=!1,u=()=>l?`zen`:le(o,e.media.matches,s);function d(n){l&&n===`pick`&&(l=!1);let i=u(),a=i===`zen`&&e.root.dataset.zenAway!==void 0?`standard`:i;e.root.dataset.view=a,e.meta&&(e.meta.content=a===`standard`?r:oe[a]);let o=n===`pick`||n===`follow`&&c!==void 0&&c!==i;if(c=i,o)for(let e of t)e(i,n)}return d(),e.media.addEventListener(`change`,()=>d(`follow`)),{choice:()=>o,view:u,server:()=>s,setServer(t){let r=se(typeof t==`string`?t:void 0);if(r!==s){l||=o===`auto`&&u()===`zen`&&e.root.dataset.zenAway===void 0&&le(o,e.media.matches,r)!==`zen`,s=r;for(let e of n)e(s);d(`follow`)}},set(e){o=e,i.set(`view`,e),d(`pick`)},release(){l=!1},refresh:()=>d(),reread(){o=a(),d(`pick`)},onStored:e=>i.on(`view`,e),onChange:e=>void t.push(e),onServer:e=>void n.push(e)}}function fe(e,t,n){let r=[...e.querySelectorAll(`button[data-choice]`)],i=r.find(e=>e.dataset.choice===`auto`),a=()=>{i&&n&&(i.textContent=n(t.server())),e.dataset&&e.toggleAttribute(`data-following`,t.server()!==`auto`)};a(),t.onServer(a);let o=()=>r.forEach(e=>e.setAttribute(`aria-pressed`,String(e.dataset.choice===t.choice())));for(let e of r)e.addEventListener(`click`,()=>(t.set(se(e.dataset.choice)),o()));t.onStored(()=>(t.reread(),o())),o()}var pe=(e,t)=>(delete t.dataset.zenAway,e.reread());function me(e,t,n,r=()=>pe(t,n)){let i=()=>e.hidden=t.view()!==`zen`||n.dataset.zenAway===void 0;return t.onChange(i),e.addEventListener(`click`,()=>(r(),i())),i(),i}function he(e){let t=[],n=(e,r,i)=>(t.push({base:e,unit:r,sub:i}),r.subs.forEach(t=>n(e,t,!0)));for(let t of e.bases)[...t.tower?[t.tower]:[],...t.tabs.flatMap(e=>e.units),...t.outside].forEach(e=>n(t,e,!1));return t}var ge=e=>e.mark===`waiting`||e.pending?0:1,_e=e=>[...e].filter(e=>ge(e)===0),ve=e=>`${e?.n}m`,ye=e=>`${e?.n} 分鐘`,be=((e,t={})=>(t.locale??v())===`zh-TW`?ye(e):ve(e)),xe=e=>`${e?.n}s`,Se=e=>`${e?.n} 秒`,Ce=((e,t={})=>(t.locale??v())===`zh-TW`?Se(e):xe(e)),we=((e={},t={})=>(t.locale??v())===`zh-TW`?`警示`:`Alerts`),Te=((e={},t={})=>(t.locale??v())===`zh-TW`?`所有基地`:`all bases`),Ee=e=>`ally run · ${e?.device}`,De=e=>`隊友 run · ${e?.device}`,Oe=((e,t={})=>(t.locale??v())===`zh-TW`?De(e):Ee(e)),ke=((e={},t={})=>(t.locale??v())===`zh-TW`?`唯讀查看這個隊友 run 的通訊`:`Read this ally run's comms (read only)`),Ae=((e={},t={})=>(t.locale??v())===`zh-TW`?`還看不到它的通訊:尚未取得這個 run 的工作階段檔`:`Its comms are not shown yet: the run's session file is not known`),je=e=>`${e?.team} · teammate`,Me=e=>`${e?.team} · 隊友`,Ne=((e,t={})=>(t.locale??v())===`zh-TW`?Me(e):je(e)),Pe=((e={},t={})=>(t.locale??v())===`zh-TW`?`隊友`:`teammate`),Fe=e=>`Teams: ${e?.teams}`,Ie=e=>`團隊:${e?.teams}`,Le=((e,t={})=>(t.locale??v())===`zh-TW`?Ie(e):Fe(e)),Re=((e={},t={})=>(t.locale??v())===`zh-TW`?`、`:`, `),ze=((e={},t={})=>(t.locale??v())===`zh-TW`?`代理不能再問你,正在等你的提問會被取消`:`Agents can no longer ask you, and questions waiting for you are cancelled. Tap again to start`),Be=((e={},t={})=>(t.locale??v())===`zh-TW`?`自動模式`:`Auto mode`),Ve=e=>`Auto · since ${e?.time}`,He=e=>`自動模式 · ${e?.time} 起`,Ue=((e,t={})=>(t.locale??v())===`zh-TW`?He(e):Ve(e)),We=((e={},t={})=>(t.locale??v())===`zh-TW`?`自動模式:你不在時,各代理不再問你,需要你的事先暫放,等你回來。點兩下進入。`:`Auto mode: you are away, so agents stop asking you and what needs you is parked until you are back. Two taps start it.`),Ge=((e={},t={})=>(t.locale??v())===`zh-TW`?`自動模式進行中:各代理不能問你。點一下結束。`:`Auto mode is on: agents cannot ask you. One tap ends it.`),Ke=((e={},t={})=>(t.locale??v())===`zh-TW`?`確認進入自動模式`:`Start auto mode`),qe=e=>`You said: “${e?.said}”. Once it is on, agents cannot ask you and what needs you is parked until you are back.`,Je=e=>`你說了:「${e?.said}」。進入後各代理不能再問你,需要你的事會先暫放,等你回來。`,Ye=((e,t={})=>(t.locale??v())===`zh-TW`?Je(e):qe(e)),Xe=((e={},t={})=>(t.locale??v())===`zh-TW`?`主塔台要求進入自動模式`:`The head tower asks to start auto mode`),Ze=(e,t)=>b(`auto_confirm_title`,Xe,e,t),Qe=((e={},t={})=>(t.locale??v())===`zh-TW`?`已進入自動模式。`:`Auto mode is on.`),$e=((e={},t={})=>(t.locale??v())===`zh-TW`?`這個請求已過期或被取代,請再請主塔台提出一次。`:`This request expired or was replaced. Ask the head tower again.`),et=(e,t)=>b(`auto_stale`,$e,e,t),tt=((e={},t={})=>(t.locale??v())===`zh-TW`?`返回`:`Back`),nt=((e={},t={})=>(t.locale??v())===`zh-TW`?``:`.`),rt=((e={},t={})=>(t.locale??v())===`zh-TW`?`最後更新:`:`Last update`),it=e=>`Disconnected. Gave up after ${e?.tries} tries; it reconnects when you return to this tab.`,at=e=>`連線中斷。重試 ${e?.tries} 次後放棄;回到此分頁時會重新連線。`,ot=((e,t={})=>(t.locale??v())===`zh-TW`?at(e):it(e)),st=e=>`The server is up but cannot read the net: ${e?.problem}`,ct=e=>`伺服器正常,但讀不到網:${e?.problem}`,lt=((e,t={})=>(t.locale??v())===`zh-TW`?ct(e):st(e)),ut=((e={},t={})=>(t.locale??v())===`zh-TW`?`與稻草網的連線中斷,正在重新連線…畫面顯示的是最後已知狀態。`:`Disconnected from the straw net. Reconnecting… The view shows the last known state.`),dt=e=>`Disconnected from the straw net. Reconnecting (try ${e?.attempt})… The view shows the last known state.`,ft=e=>`與稻草網的連線中斷,正在重新連線(第 ${e?.attempt} 次)…畫面顯示的是最後已知狀態。`,pt=((e,t={})=>(t.locale??v())===`zh-TW`?ft(e):dt(e)),mt=((e={},t={})=>(t.locale??v())===`zh-TW`?`這個網址在這裡無法使用(sb server 可能重新啟動過,或連結已過期):在這台電腦請開啟 /boss gui;在手機請重新掃描新的 QR code。`:`This address does not work here (the sb server may have restarted, or the link expired): on this computer open /boss gui; on a phone scan a new QR code.`),ht=((e={},t={})=>(t.locale??v())===`zh-TW`?`Straw Net:所有基地`:`Straw Net: all bases`),gt=((e={},t={})=>(t.locale??v())===`zh-TW`?`取消`:`Cancel`),_t=((e={},t={})=>(t.locale??v())===`zh-TW`?`關閉`:`Close`),vt=e=>`Quit base ${e?.name}`,yt=e=>`關掉基地 ${e?.name}`,bt=((e,t={})=>(t.locale??v())===`zh-TW`?yt(e):vt(e)),xt=e=>`Quit base ${e?.name}? Every agent in it and its tower quit. Nothing quits while anything running would be lost.`,St=e=>`要關掉基地 ${e?.name} 嗎?裡面所有 agent 和塔台都會退出。有會遺失的東西時什麼都不關。`,Ct=((e,t={})=>(t.locale??v())===`zh-TW`?St(e):xt(e)),wt=(e,t)=>b(`close_base_ask`,Ct,e,t),Tt=e=>`Quit squad ${e?.name}`,Et=e=>`關掉小隊 ${e?.name}`,Dt=((e,t={})=>(t.locale??v())===`zh-TW`?Et(e):Tt(e)),Ot=e=>`Quit squad ${e?.name}? Every agent in it quits.`,kt=e=>`要關掉小隊 ${e?.name} 嗎?裡面所有 agent 都會退出。`,At=((e,t={})=>(t.locale??v())===`zh-TW`?kt(e):Ot(e)),jt=e=>`Quit the tower ${e?.name}? The base's mains become members again.`,Mt=e=>`要關掉塔台 ${e?.name} 嗎?這個基地的主智慧體都會降格成成員。`,Nt=((e,t={})=>(t.locale??v())===`zh-TW`?Mt(e):jt(e)),Pt=(e,t)=>b(`close_tower_ask`,Nt,e,t),Ft=e=>`Quit ${e?.name}`,It=e=>`關掉 ${e?.name}`,Lt=((e,t={})=>(t.locale??v())===`zh-TW`?It(e):Ft(e)),Rt=e=>`Quit ${e?.name}? It quits pi and its pane closes.`,zt=e=>`要關掉 ${e?.name} 嗎?它會退出 pi,窗格也會關掉。`,Bt=((e,t={})=>(t.locale??v())===`zh-TW`?zt(e):Rt(e)),Vt=((e={},t={})=>(t.locale??v())===`zh-TW`?`通訊`:`Comms`),Ht=((e={},t={})=>(t.locale??v())===`zh-TW`?`連線中…`:`Connecting…`),Ut=((e={},t={})=>(t.locale??v())===`zh-TW`?`重新連線中…`:`Reconnecting…`),Wt=((e={},t={})=>(t.locale??v())===`zh-TW`?`重試`:`Try again`),Gt=e=>`control tower · ${e?.state}`,Kt=e=>`塔台 · ${e?.state}`,qt=((e,t={})=>(t.locale??v())===`zh-TW`?Kt(e):Gt(e)),Jt=(e,t)=>b(`control_tower`,qt,e,t),Yt=((e={},t={})=>(t.locale??v())===`zh-TW`?`圖示來自 game-icons.net(Lorc、Delapouite),CC BY 3.0。`:`Icons from game-icons.net by Lorc and Delapouite, CC BY 3.0.`),Xt=((e={},t={})=>(t.locale??v())===`zh-TW`?`移除`:`Dismiss`),Zt=e=>`Dismiss finished (${e?.count})`,Qt=e=>`移除已完成(${e?.count})`,$t=((e,t={})=>(t.locale??v())===`zh-TW`?Qt(e):Zt(e)),en=e=>`Dismiss ${e?.name}`,tn=e=>`從畫面移除 ${e?.name}`,nn=((e,t={})=>(t.locale??v())===`zh-TW`?tn(e):en(e)),rn=((e={},t={})=>(t.locale??v())===`zh-TW`?`文件`:`Documents`),an=e=>`${e?.name}: ${e?.from} → ${e?.to}`,on=e=>`${e?.name}:${e?.from} → ${e?.to}`,sn=((e,t={})=>(t.locale??v())===`zh-TW`?on(e):an(e)),cn=((e={},t={})=>(t.locale??v())===`zh-TW`?`分支匯流`:`fan-out`),ln=((e={},t={})=>(t.locale??v())===`zh-TW`?`多工編排`:`orchestrated`),un=((e={},t={})=>(t.locale??v())===`zh-TW`?`單一迴圈`:`single loop`),dn=((e={},t={})=>(t.locale??v())===`zh-TW`?`第一則訊息會開啟主塔台`:`The head tower opens with your first message`),fn=(e,t)=>b(`head_absent`,dn,e,t),pn=((e={},t={})=>(t.locale??v())===`zh-TW`?`已回覆`:`answered`),mn=((e={},t={})=>(t.locale??v())===`zh-TW`?`已處理`:`handled`),hn=((e={},t={})=>(t.locale??v())===`zh-TW`?`回給了別人,沒回報主塔台`:`answered someone else, not the head`),gn=(e,t)=>b(`head_ask_handled_note`,hn,e,t),_n=((e={},t={})=>(t.locale??v())===`zh-TW`?`回覆沒送到主塔台`:`its reply did not reach the head`),vn=(e,t)=>b(`head_ask_missed_note`,_n,e,t),yn=((e={},t={})=>(t.locale??v())===`zh-TW`?`沒有塔台`:`no tower`),bn=(e,t)=>b(`head_ask_no_tower`,yn,e,t),xn=((e={},t={})=>(t.locale??v())===`zh-TW`?`已收到`:`received`),Sn=((e={},t={})=>(t.locale??v())===`zh-TW`?`沒回應`:`no answer`),Cn=((e={},t={})=>(t.locale??v())===`zh-TW`?`等回覆`:`waiting`),wn=((e={},t={})=>(t.locale??v())===`zh-TW`?`交給各塔台的工作`:`Work handed to the towers`),Tn=(e,t)=>b(`head_asks_label`,wn,e,t),En=((e={},t={})=>(t.locale??v())===`zh-TW`?`關閉主塔台`:`Close the head tower`),Dn=(e,t)=>b(`head_close`,En,e,t),On=((e={},t={})=>(t.locale??v())===`zh-TW`?`要關閉主塔台嗎?對話和記憶都會保留。`:`Close the head tower? The conversation and its memory are kept.`),kn=(e,t)=>b(`head_close_ask`,On,e,t),An=e=>`${e?.age} ago · ${e?.handled}/${e?.count} handled`,jn=e=>`${e?.age}前・已處理 ${e?.handled}/${e?.count}`,Mn=((e,t={})=>(t.locale??v())===`zh-TW`?jn(e):An(e)),Nn=e=>`${e?.age} ago · ${e?.handled}/1 handled`,Pn=e=>`${e?.age}前・已處理 ${e?.handled}/1`,Fn=((e,t={})=>(t.locale??v())===`zh-TW`?Pn(e):Nn(e)),In=e=>`Orders sent (${e?.count})`,Ln=e=>`送出的指令(${e?.count})`,Rn=((e,t={})=>(t.locale??v())===`zh-TW`?Ln(e):In(e)),zn=((e={},t={})=>(t.locale??v())===`zh-TW`?`主塔台有新的話`:`The head tower said something new`),Bn=(e,t)=>b(`head_new`,zn,e,t),Vn=e=>`Older (${e?.count})`,Hn=e=>`更早(${e?.count})`,Un=((e,t={})=>(t.locale??v())===`zh-TW`?Hn(e):Vn(e)),Wn=((e={},t={})=>(t.locale??v())===`zh-TW`?`你說`:`You said`),Gn=((e={},t={})=>(t.locale??v())===`zh-TW`?`主塔台送出`:`Head sent`),Kn=(e,t)=>b(`head_part_sent`,Gn,e,t),qn=((e={},t={})=>(t.locale??v())===`zh-TW`?`送給`:`To`),Jn=((e={},t={})=>(t.locale??v())===`zh-TW`?`已被下一則更正`:`corrected by the next`),Yn=e=>`Replaced orders (${e?.count})`,Xn=e=>`被取代的舊指令(${e?.count})`,Zn=((e,t={})=>(t.locale??v())===`zh-TW`?Xn(e):Yn(e)),Qn=e=>`corrects ${e?.count} earlier`,$n=e=>`更正了前 ${e?.count} 則`,er=((e,t={})=>(t.locale??v())===`zh-TW`?$n(e):Qn(e)),tr=((e={},t={})=>(t.locale??v())===`zh-TW`?`、`:`, `),nr=((e={},t={})=>(t.locale??v())===`zh-TW`?`尚未開啟`:`not open`),rr=((e={},t={})=>(t.locale??v())===`zh-TW`?`主塔台`:`Head tower`),ir=((e={},t={})=>(t.locale??v())===`zh-TW`?`協調者`:`coordinator`),ar=((e={},t={})=>(t.locale??v())===`zh-TW`?`整合員`:`integrator`),or=((e={},t={})=>(t.locale??v())===`zh-TW`?`規劃`:`planner`),sr=((e={},t={})=>(t.locale??v())===`zh-TW`?`審查`:`reviewer`),cr=((e={},t={})=>(t.locale??v())===`zh-TW`?`偵察`:`scout`),lr=((e={},t={})=>(t.locale??v())===`zh-TW`?`值守`:`on watch`),ur=((e={},t={})=>(t.locale??v())===`zh-TW`?`監控者`:`watchdog`),dr=((e={},t={})=>(t.locale??v())===`zh-TW`?`工作者`:`worker`),fr=((e={},t={})=>(t.locale??v())===`zh-TW`?`語言`:`Language`),pr=e=>`${e?.label} (${e?.short}) asks you to confirm a ${e?.tool} call from its tower ${e?.tower}, which acts on a message you sent`,mr=e=>`${e?.label}(${e?.short})請你確認它的塔台 ${e?.tower} 的一次 ${e?.tool} 呼叫,該塔台正在處理你送出的訊息`,hr=((e,t={})=>(t.locale??v())===`zh-TW`?mr(e):pr(e)),gr=(e,t)=>b(`link_a_confirm`,hr,e,t),_r=e=>`${e?.label} (${e?.short}) asks you to confirm a ${e?.tool} call from its tower`,vr=e=>`${e?.label}(${e?.short})請你確認它塔台的一次 ${e?.tool} 呼叫`,yr=((e,t={})=>(t.locale??v())===`zh-TW`?vr(e):_r(e)),br=(e,t)=>b(`link_a_confirm_plain`,yr,e,t),xr=e=>`${e?.label} (${e?.short}) in team ${e?.team} asks a question (${e?.owner}).`,Sr=e=>`團隊 ${e?.team} 的 ${e?.label}(${e?.short})問了一個問題(${e?.owner})。`,Cr=((e,t={})=>(t.locale??v())===`zh-TW`?Sr(e):xr(e)),wr=e=>`Team ${e?.team} stopped: ${e?.reason}`,Tr=e=>`團隊 ${e?.team} 已停止:${e?.reason}`,Er=((e,t={})=>(t.locale??v())===`zh-TW`?Tr(e):wr(e)),Dr=e=>{let t=p(`en`,e?.count,{},!0);return t===`one`?`${e?.count} message has waited more than 10 minutes for an idle tower in team ${e?.team}`:t===`other`?`${e?.count} messages have waited more than 10 minutes for an idle tower in team ${e?.team}`:`link_a_held`},Or=e=>`團隊 ${e?.team} 有 ${e?.count} 則訊息已等了超過 10 分鐘,塔台一直不閒`,kr=((e,t={})=>(t.locale??v())===`zh-TW`?Or(e):Dr(e)),Ar=(e,t)=>b(`link_a_held`,kr,e,t),jr=e=>{let t=p(`en`,e?.count,{},!0);return t===`one`?`Team ${e?.team}: ${e?.who} sent ${e?.count} message ${e?.ago} ago, for ${e?.where}. It is not delivered yet; it goes through as soon as the tower can take it, and it is dropped on ${e?.drop}.`:t===`other`?`Team ${e?.team}: ${e?.who} sent ${e?.count} messages, the oldest ${e?.ago} ago, for ${e?.where}. They are not delivered yet; they go through as soon as the tower can take them, and the oldest is dropped on ${e?.drop}.`:`link_a_inbox`},Mr=e=>`團隊 ${e?.team}:${e?.who} 傳來 ${e?.count} 則訊息,${e?.ago}前起就在等,要交給${e?.where},還沒送達。塔台能接手時就會自動送達;${e?.drop} 起會開始丟棄。`,Nr=((e,t={})=>(t.locale??v())===`zh-TW`?Mr(e):jr(e)),Pr=(e,t)=>b(`link_a_inbox`,Nr,e,t),Fr=e=>`Waking the tower did not work (${e?.reason}); it is tried again later.`,Ir=e=>`叫醒塔台沒有成功(${e?.reason});稍後會再試。`,Lr=((e,t={})=>(t.locale??v())===`zh-TW`?Ir(e):Fr(e)),Rr=(e,t)=>b(`link_a_inbox_wake_failed`,Lr,e,t),zr=((e={},t={})=>(t.locale??v())===`zh-TW`?`這台電腦上沒有可以叫醒塔台的工作區。開啟專案的工作區,訊息就會送達。`:`This computer has no workspace for it to wake the tower of. Open the project's workspace and the messages go through.`),Br=(e,t)=>b(`link_a_inbox_wake_none`,zr,e,t),Vr=((e={},t={})=>(t.locale??v())===`zh-TW`?`這台電腦停用了塔台執行功能,所以沒有東西能叫醒塔台。啟用後訊息就會送達。`:`Tower runs are switched off on this computer, so nothing can wake the tower. Switch them on and the messages go through.`),Hr=(e,t)=>b(`link_a_inbox_wake_off`,Vr,e,t),Ur=e=>`the tower of project ${e?.project}`,Wr=e=>`專案 ${e?.project} 的塔台`,Gr=((e,t={})=>(t.locale??v())===`zh-TW`?Wr(e):Ur(e)),Kr=(e,t)=>b(`link_a_inbox_where_project`,Gr,e,t),qr=e=>`the tower of workspace “${e?.workspace}”`,Jr=e=>`「${e?.workspace}」工作區的塔台`,Yr=((e,t={})=>(t.locale??v())===`zh-TW`?Jr(e):qr(e)),Xr=(e,t)=>b(`link_a_inbox_where_workspace`,Yr,e,t),Zr=e=>`${e?.label} and ${e?.others} more`,Qr=e=>`${e?.label} 和另外 ${e?.others} 位`,$r=((e,t={})=>(t.locale??v())===`zh-TW`?Qr(e):Zr(e)),ei=((e={},t={})=>(t.locale??v())===`zh-TW`?`出了點問題,細節在 link.log`:`something went wrong; link.log has the details`),ti=((e={},t={})=>(t.locale??v())===`zh-TW`?`團隊的專案資料夾不存在,或不允許在這台電腦使用`:`the team's project folder is missing or not allowed on this computer`),ni=((e={},t={})=>(t.locale??v())===`zh-TW`?`塔台服務還在啟動`:`the tower service is still starting`),ri=(e,t)=>b(`link_a_inbox_why_service`,ni,e,t),ii=e=>`${e?.label} (${e?.short}) asks to join team ${e?.team}`,ai=e=>`${e?.label}(${e?.short})要求加入團隊 ${e?.team}`,oi=((e,t={})=>(t.locale??v())===`zh-TW`?ai(e):ii(e)),si=e=>`${e?.label} (${e?.short}), an unattended device, asks to join team ${e?.team}`,ci=e=>`${e?.label}(${e?.short})是無人值守的裝置,要求加入團隊 ${e?.team}`,li=((e,t={})=>(t.locale??v())===`zh-TW`?ci(e):si(e)),ui=e=>`${e?.label} (${e?.short}) shows another roster than this computer in team ${e?.team}; the relay may be showing different rosters`,di=e=>`團隊 ${e?.team} 中,${e?.label}(${e?.short})顯示的名冊和這台電腦不同;中繼站可能對不同人顯示不同名冊`,fi=((e,t={})=>(t.locale??v())===`zh-TW`?di(e):ui(e)),pi=e=>`${e?.label} (${e?.short}), unattended, in team ${e?.team} — ${e?.what}, ${e?.unit}: ${e?.text}`,mi=e=>`團隊 ${e?.team} 無人值守的 ${e?.label}(${e?.short}):${e?.what},${e?.unit}:${e?.text}`,hi=((e,t={})=>(t.locale??v())===`zh-TW`?mi(e):pi(e)),gi=e=>{let t=p(`en`,e?.count,{},!0);return t===`one`?`${e?.count} Straw Link message has waited more than 10 minutes for an ally run in team ${e?.team}. Look at the tower's card on the map: a held tower or a refused start keeps it waiting.`:t===`other`?`${e?.count} Straw Link messages have waited more than 10 minutes for an ally run in team ${e?.team}. Look at the tower's card on the map: a held tower or a refused start keeps them waiting.`:`link_a_served`},_i=e=>`團隊 ${e?.team} 有 ${e?.count} 則 Straw Link 訊息等隊友 run 接手已超過 10 分鐘。請看地圖上塔台的卡片:塔台已暫停或 run 啟動被拒,都會讓它們一直等。`,vi=((e,t={})=>(t.locale??v())===`zh-TW`?_i(e):gi(e)),yi=(e,t)=>b(`link_a_served`,vi,e,t),bi=e=>`The relay of team ${e?.team} has been unreachable for ${e?.minutes} minutes`,xi=e=>`團隊 ${e?.team} 的中繼站已經 ${e?.minutes} 分鐘連不上`,Si=((e,t={})=>(t.locale??v())===`zh-TW`?xi(e):bi(e)),Ci=e=>`Link ${e?.count}`,wi=e=>`連線 ${e?.count}`,Ti=((e,t={})=>(t.locale??v())===`zh-TW`?wi(e):Ci(e)),Ei=((e={},t={})=>(t.locale??v())===`zh-TW`?`Straw Link 通知`:`Straw Link notices`),Di=((e={},t={})=>(t.locale??v())===`zh-TW`?`允許`:`Allow`),Oi=((e={},t={})=>(t.locale??v())===`zh-TW`?`連線中`:`connecting`),ki=((e={},t={})=>(t.locale??v())===`zh-TW`?`拒絕`:`Deny`),Ai=((e={},t={})=>(t.locale??v())===`zh-TW`?`即時`:`live`),ji=((e={},t={})=>(t.locale??v())===`zh-TW`?`停止中…`:`stopping…`),Mi=((e={},t={})=>(t.locale??v())===`zh-TW`?`尚未見到`:`not seen yet`),Ni=((e={},t={})=>(t.locale??v())===`zh-TW`?`清除`:`Clear`),Pi=((e={},t={})=>(t.locale??v())===`zh-TW`?`離線`:`offline`),Fi=((e={},t={})=>(t.locale??v())===`zh-TW`?`在線`:`online`),Ii=((e={},t={})=>(t.locale??v())===`zh-TW`?`開啟團隊`:`Open Teams`),Li=((e={},t={})=>(t.locale??v())===`zh-TW`?`重新連線中`:`reconnecting`),Ri=((e={},t={})=>(t.locale??v())===`zh-TW`?`查看`:`Review`),zi=e=>`seen ${e?.ago} ago`,Bi=e=>`${e?.ago}前見到`,Vi=((e,t={})=>(t.locale??v())===`zh-TW`?Bi(e):zi(e)),Hi=((e={},t={})=>(t.locale??v())===`zh-TW`?`查看塔台`:`Show towers`),Ui=(e,t)=>b(`link_show_towers`,Hi,e,t),Wi=((e={},t={})=>(t.locale??v())===`zh-TW`?`當掉`:`crashed`),Gi=((e={},t={})=>(t.locale??v())===`zh-TW`?`當掉後暫停`:`held after crashes`),Ki=((e={},t={})=>(t.locale??v())===`zh-TW`?`本次執行中`:`run in progress`),qi=((e={},t={})=>(t.locale??v())===`zh-TW`?`執行中`:`running`),Ji=e=>{let t=p(`en`,e?.count,{},!0);return t===`one`?`${e?.count} unit online`:t===`other`?`${e?.count} units online`:`link_unit_summary`},Yi=e=>`${e?.count} 個單位在線`,Xi=((e,t={})=>(t.locale??v())===`zh-TW`?Yi(e):Ji(e)),Zi=((e={},t={})=>(t.locale??v())===`zh-TW`?`待信任`:`needs trust`),Qi=((e={},t={})=>(t.locale??v())===`zh-TW`?`正體中文`:`English`),$i=((e={},t={})=>(t.locale??v())===`zh-TW`?`位置`:`Location`),ea=e=>`${e?.name} is commanding`,ta=e=>`${e?.name} 指揮中`,na=((e,t={})=>(t.locale??v())===`zh-TW`?ta(e):ea(e)),ra=e=>`${e?.name} finished`,ia=e=>`${e?.name} 已完成`,aa=((e,t={})=>(t.locale??v())===`zh-TW`?ia(e):ra(e)),oa=e=>`${e?.name} hit an error`,sa=e=>`${e?.name} 發生錯誤`,ca=((e,t={})=>(t.locale??v())===`zh-TW`?sa(e):oa(e)),la=e=>`${e?.name} went idle`,ua=e=>`${e?.name} 轉為閒置`,da=((e,t={})=>(t.locale??v())===`zh-TW`?ua(e):la(e)),fa=e=>`${e?.name} joined`,pa=e=>`${e?.name} 加入`,ma=((e,t={})=>(t.locale??v())===`zh-TW`?pa(e):fa(e)),ha=e=>`${e?.name} left`,ga=e=>`${e?.name} 離開`,_a=((e,t={})=>(t.locale??v())===`zh-TW`?ga(e):ha(e)),va=e=>`${e?.name} lost its status`,ya=e=>`${e?.name} 失去狀態`,ba=((e,t={})=>(t.locale??v())===`zh-TW`?ya(e):va(e)),xa=e=>`${e?.name} is waiting on a question`,Sa=e=>`${e?.name} 正在等待回答`,Ca=((e,t={})=>(t.locale??v())===`zh-TW`?Sa(e):xa(e)),wa=e=>`${e?.name} started working`,Ta=e=>`${e?.name} 開始工作`,Ea=((e,t={})=>(t.locale??v())===`zh-TW`?Ta(e):wa(e)),Da=((e={},t={})=>(t.locale??v())===`zh-TW`?`指揮中`:`commanding`),Oa=((e={},t={})=>(t.locale??v())===`zh-TW`?`已完成`:`finished`),ka=((e={},t={})=>(t.locale??v())===`zh-TW`?`錯誤`:`error`),Aa=((e={},t={})=>(t.locale??v())===`zh-TW`?`閒置`:`idle`),ja=((e={},t={})=>(t.locale??v())===`zh-TW`?`無狀態`:`no status`),Ma=((e={},t={})=>(t.locale??v())===`zh-TW`?`等待回答`:`waiting on a question`),Na=((e={},t={})=>(t.locale??v())===`zh-TW`?`工作中`:`working`),Pa=((e={},t={})=>(t.locale??v())===`zh-TW`?`確認`:`Confirm`),Fa=((e={},t={})=>(t.locale??v())===`zh-TW`?`駁回`:`Reject`),Ia=((e={},t={})=>(t.locale??v())===`zh-TW`?`更多`:`More`),La=e=>`More actions for ${e?.name}`,Ra=e=>`「${e?.name}」的更多動作`,za=((e,t={})=>(t.locale??v())===`zh-TW`?Ra(e):La(e)),Ba=((e={},t={})=>(t.locale??v())===`zh-TW`?`地圖總覽`:`Overview of the map`),Va=e=>`Monitor failed: ${e?.what}`,Ha=e=>`Monitor 出錯:${e?.what}`,Ua=((e,t={})=>(t.locale??v())===`zh-TW`?Ha(e):Va(e)),Wa=e=>`Monitor went quiet and stopped: ${e?.what}`,Ga=e=>`Monitor 太久沒輸出,已停止:${e?.what}`,Ka=((e,t={})=>(t.locale??v())===`zh-TW`?Ga(e):Wa(e)),qa=((e={},t={})=>(t.locale??v())===`zh-TW`?`從未`:`never`),Ja=((e={},t={})=>(t.locale??v())===`zh-TW`?`+新基地`:`+ New base`),Ya=((e={},t={})=>(t.locale??v())===`zh-TW`?`沒有執行中的智慧體`:`no agent running`),Xa=(e,t)=>b(`no_agent`,Ya,e,t),Za=((e={},t={})=>(t.locale??v())===`zh-TW`?`無警示`:`no alerts`),w=((e={},t={})=>(t.locale??v())===`zh-TW`?`伺服器沒有回應。`:`The server did not answer.`),Qa=((e={},t={})=>(t.locale??v())===`zh-TW`?`尚無塔台`:`no tower yet`),$a=(e,t)=>b(`no_tower`,Qa,e,t),eo=((e={},t={})=>(t.locale??v())===`zh-TW`?`監看中`:`Watching a monitor`),to=((e={},t={})=>(t.locale??v())===`zh-TW`?`思考中`:`thinking`),no=e=>`Finished ${e?.note}`,ro=e=>`完成了 ${e?.note}`,io=((e,t={})=>(t.locale??v())===`zh-TW`?ro(e):no(e)),ao=e=>`Failed ${e?.note}`,oo=e=>`出錯了 ${e?.note}`,so=((e,t={})=>(t.locale??v())===`zh-TW`?oo(e):ao(e)),co=e=>`Waiting on you ${e?.note}`,lo=e=>`等你回答 ${e?.note}`,uo=((e,t={})=>(t.locale??v())===`zh-TW`?lo(e):co(e)),fo=((e={},t={})=>(t.locale??v())===`zh-TW`?`+主智慧體`:`+ Main`),po=(e,t)=>b(`open_main`,fo,e,t),mo=((e={},t={})=>(t.locale??v())===`zh-TW`?`+成員`:`+ Member`),ho=((e={},t={})=>(t.locale??v())===`zh-TW`?`前哨`:`Outposts`),go=((e={},t={})=>(t.locale??v())===`zh-TW`?`網外`:`Outside the net`),_o=((e={},t={})=>(t.locale??v())===`zh-TW`?`Herdr 開了新窗格,請到 Herdr 裡接著做。`:`A pane opened in Herdr; carry on there.`),vo=((e={},t={})=>(t.locale??v())===`zh-TW`?`接回`:`Pop`),yo=e=>`Pop ${e?.name}`,bo=e=>`接回 ${e?.name}`,xo=((e,t={})=>(t.locale??v())===`zh-TW`?bo(e):yo(e)),So=((e={},t={})=>(t.locale??v())===`zh-TW`?`伺服器送來的快照,頁面無法讀取`:`the server sent a snapshot the page cannot read`),Co=((e={},t={})=>(t.locale??v())===`zh-TW`?`伺服器回報了頁面無法讀取的問題`:`the server reported a problem the page cannot read`),wo=((e={},t={})=>(t.locale??v())===`zh-TW`?`關掉`:`Quit`),To=((e={},t={})=>(t.locale??v())===`zh-TW`?`關掉塔台`:`Quit tower`),Eo=(e,t)=>b(`quit_tower`,To,e,t),Do=e=>`Refused (${e?.status}).`,Oo=e=>`已拒絕(${e?.status})。`,T=((e,t={})=>(t.locale??v())===`zh-TW`?Oo(e):Do(e)),ko=((e={},t={})=>(t.locale??v())===`zh-TW`?`提醒`:`Remind`),Ao=((e={},t={})=>(t.locale??v())===`zh-TW`?`點一下允許瀏覽器通知`:`Press to allow browser notifications`),jo=((e={},t={})=>(t.locale??v())===`zh-TW`?`瀏覽器已封鎖通知,要到網站設定裡允許`:`The browser blocks notifications; allow them in the site settings`),Mo=((e={},t={})=>(t.locale??v())===`zh-TW`?`提醒已關`:`Reminders off`),No=((e={},t={})=>(t.locale??v())===`zh-TW`?`提醒已開:分頁不在前景時,單位等你回答、完成或出錯會跳系統通知`:`Reminders on: while the page is in the background, a unit waiting on you, finishing, or failing raises a system notification`),Po=((e={},t={})=>(t.locale??v())===`zh-TW`?`這個瀏覽器不支援通知`:`This browser has no notifications`),Fo=((e={},t={})=>(t.locale??v())===`zh-TW`?`主智慧體`:`main`),Io=((e={},t={})=>(t.locale??v())===`zh-TW`?`成員`:`member`),Lo=((e={},t={})=>(t.locale??v())===`zh-TW`?`前哨`:`outpost`),Ro=((e={},t={})=>(t.locale??v())===`zh-TW`?`未編入`:`unaligned`),zo=((e={},t={})=>(t.locale??v())===`zh-TW`?`事件 run`:`event run`),Bo=((e={},t={})=>(t.locale??v(),`session`)),Vo=((e={},t={})=>(t.locale??v())===`zh-TW`?`子智慧體`:`subagent`),Ho=((e={},t={})=>(t.locale??v())===`zh-TW`?`塔台`:`tower`),Uo=((e={},t={})=>(t.locale??v())===`zh-TW`?`火車`:`train`),Wo=((e={},t={})=>(t.locale??v())===`zh-TW`?`這台裝置`:`This device`),Go=((e={},t={})=>(t.locale??v())===`zh-TW`?`這些選擇只留在這台裝置的這個瀏覽器。`:`These choices stay on this device, in this browser.`),Ko=((e={},t={})=>(t.locale??v())===`zh-TW`?`手機與裝置`:`Phone & devices`),qo=((e={},t={})=>(t.locale??v())===`zh-TW`?`伺服器`:`Server`),Jo=((e={},t={})=>(t.locale??v())===`zh-TW`?`團隊`:`Teams`),Yo=((e={},t={})=>(t.locale??v())===`zh-TW`?`設定`:`Settings`),Xo=((e={},t={})=>(t.locale??v())===`zh-TW`?`背景音`:`Background sound`),Zo=((e={},t={})=>(t.locale??v())===`zh-TW`?`背景音:Zen 的音樂、鴉閣的雨聲與雷聲。開關與音量`:`Background sound: Zen's music, Raven's rain and thunder. On or off and volume`),Qo=((e={},t={})=>(t.locale??v())===`zh-TW`?`音效`:`Sound effects`),$o=((e={},t={})=>(t.locale??v())===`zh-TW`?`音效:有問題要回答、完成或出錯時的提示音。開關、音量與試聽`:`Sound effects: the cues for a question, a finish, or a failure. On or off, volume, and a try`),es=((e={},t={})=>(t.locale??v())===`zh-TW`?`▶ 試聽`:`▶ Try`),ts=((e={},t={})=>(t.locale??v())===`zh-TW`?`音量`:`Volume`),ns=((e={},t={})=>(t.locale??v())===`zh-TW`?`基地`:`base`),rs=((e={},t={})=>(t.locale??v())===`zh-TW`?`收起`:`Stash`),is=e=>`Stash base ${e?.name}`,as=e=>`收起基地 ${e?.name}`,os=((e,t={})=>(t.locale??v())===`zh-TW`?as(e):is(e)),ss=e=>`Stash base ${e?.name}? Its tower, mains, and members quit and come back with Pop. Nothing is stashed while anything running would be lost.`,cs=e=>`要收起基地 ${e?.name} 嗎?塔台、主智慧體和成員會結束,之後可以用「接回」叫回來。有會遺失的東西時不會收。`,ls=((e,t={})=>(t.locale??v())===`zh-TW`?cs(e):ss(e)),us=(e,t)=>b(`stash_base_ask`,ls,e,t),ds=e=>`Stashed (${e?.count})`,fs=e=>`已收起(${e?.count})`,ps=((e,t={})=>(t.locale??v())===`zh-TW`?fs(e):ds(e)),ms=((e={},t={})=>(t.locale??v())===`zh-TW`?`智慧體`:`Agents`),hs=(e,t)=>b(`stat_agents`,ms,e,t),gs=((e={},t={})=>(t.locale??v())===`zh-TW`?`基地`:`Bases`),_s=((e={},t={})=>(t.locale??v())===`zh-TW`?`指揮中`:`Commanding`),vs=((e={},t={})=>(t.locale??v())===`zh-TW`?`等待中`:`Waiting`),ys=((e={},t={})=>(t.locale??v())===`zh-TW`?`工作中`:`Working`),bs=((e={},t={})=>(t.locale??v())===`zh-TW`?`待允許`:`Allow?`),xs=((e={},t={})=>(t.locale??v())===`zh-TW`?`被擋`:`Blocked`),Ss=((e={},t={})=>(t.locale??v())===`zh-TW`?`關`:`Off`),Cs=((e={},t={})=>(t.locale??v())===`zh-TW`?`開`:`On`),ws=((e={},t={})=>(t.locale??v())===`zh-TW`?`狀態`:`States`),Ts=e=>`tab ${e?.label}`,Es=e=>`分頁 ${e?.label}`,Ds=((e,t={})=>(t.locale??v())===`zh-TW`?Es(e):Ts(e)),Os=((e={},t={})=>(t.locale??v())===`zh-TW`?`即時網況 · 通訊`:`live net · comms`),ks=((e={},t={})=>(t.locale??v())===`zh-TW`?`網路活動`:`Net activity`),As=((e={},t={})=>(t.locale??v())===`zh-TW`?`伺服器啟動後還沒有動靜`:`Nothing has happened since the server started`),js=((e={},t={})=>(t.locale??v())===`zh-TW`?`現在`:`now`),Ms=e=>`${e?.count} events in 30 min`,Ns=e=>`近 30 分鐘 ${e?.count} 筆`,Ps=((e,t={})=>(t.locale??v())===`zh-TW`?Ns(e):Ms(e)),Fs=((e={},t={})=>(t.locale??v())===`zh-TW`?`網的總計`:`Net totals`),Is=((e={},t={})=>(t.locale??v())===`zh-TW`?`去處理`:`Handle`),Ls=((e={},t={})=>(t.locale??v())===`zh-TW`?`重新送達`:`Deliver again`),Rs=((e={},t={})=>(t.locale??v())===`zh-TW`?`捨棄`:`Drop`),zs=((e={},t={})=>(t.locale??v())===`zh-TW`?`重試`:`Retry`),Bs=((e={},t={})=>(t.locale??v())===`zh-TW`?`有智慧體等你同意,才能載入資料夾的設定`:`An agent needs your OK to load a folder's settings`),Vs=(e,t)=>b(`trust_reminder`,Bs,e,t),Hs=e=>`using ${e?.tool}`,Us=e=>`使用 ${e?.tool}`,Ws=((e,t={})=>(t.locale??v())===`zh-TW`?Us(e):Hs(e)),Gs=((e={},t={})=>(t.locale??v())===`zh-TW`?`自動`:`Auto`),Ks=e=>`Follow server (${e?.view})`,qs=e=>`跟隨伺服器(${e?.view})`,Js=((e,t={})=>(t.locale??v())===`zh-TW`?qs(e):Ks(e)),Ys=((e={},t={})=>(t.locale??v())===`zh-TW`?`極客`:`Geek`),Xs=((e={},t={})=>(t.locale??v())===`zh-TW`?`檢視`:`View`),Zs=((e={},t={})=>(t.locale??v())===`zh-TW`?`鴉閣`:`Raven Keep`),Qs=((e={},t={})=>(t.locale??v())===`zh-TW`?`標準`:`Standard`),$s=((e={},t={})=>(t.locale??v())===`zh-TW`?`自動:跟隨伺服器設定的檢視(/boss gui view);伺服器沒設定時,系統要求較高對比就用極客檢視。標準、極客與禪依你在這台裝置的選擇`:`Auto follows the view the server sets (/boss gui view); with none set, it is Geek when your system asks for more contrast. Standard, Geek, and Zen stay as you choose on this device`),ec=((e={},t={})=>(t.locale??v())===`zh-TW`?`禪`:`Zen`),tc=((e={},t={})=>(t.locale??v())===`zh-TW`?`略過`:`Dismiss`),nc=((e={},t={})=>(t.locale??v())===`zh-TW`?`開啟調車場`:`Open the yard`),rc=((e={},t={})=>(t.locale??v())===`zh-TW`?`調車場`:`Yard`),ic=((e={},t={})=>(t.locale??v())===`zh-TW`?`你`:`you`),ac=((e={},t={})=>(t.locale??v())===`zh-TW`?`禪`:`Zen`),oc=((e={},t={})=>(t.locale??v())===`zh-TW`?`回到禪`:`Back to Zen`),sc=new Set,cc=e=>e.unit??e.key;function lc(e,t){let n=new Map;for(let{base:r,unit:i}of he(e)){let e=i,a=e.role??`tower`;n.set(e.key,{key:e.key,ws:r.id,name:e.name,role:a,mark:e.mark,note:e.note,at:t,since:e.since,pending:e.pending,closed:!e.control||!!e.ended});for(let e of c(r.id,i,t))n.set(e.key,e);for(let i of e.monitors??[])(i.status===`error`||i.status===`stale`)&&(o=>n.set(o,{key:o,unit:e.key,ws:r.id,name:e.name,role:a,mark:`error`,note:`monitor:${i.status}:${i.what}`,at:t}))(`${e.key}\u001fmonitor:${i.id}:${i.at}`)}for(let r of e.trust??[])r.opening&&sc.has(r.opening)||(e=>n.set(e,{key:e,ws:``,name:r.folder.split(/[\\/]/).filter(Boolean).at(-1)??r.folder,role:r.agents[0]?.role??`none`,mark:`waiting`,at:t,since:r.agents.length?Math.min(...r.agents.map(e=>e.at)):void 0,trust:r}))(`trust\u001f${r.folder}\u001f${r.digest}`);return n}function uc(e,t){return[...t.values()].filter(t=>{let n=e?.get(t.key);return ge(t)===0?!n||ge(n)!==0||n.mark!==t.mark:e!==void 0&&n?.mark!==t.mark&&(t.mark===`error`||t.mark===`done`)})}var dc={count:!0,signal:!0,announce:`arrivals`,keys:`dialogs`,drawer:!0,calm:!0,chime:!0,escape:`stay`},fc={standard:dc,raven:dc,geek:{...dc,calm:!1},zen:{count:!1,signal:!1,announce:`current`,keys:`zen`,drawer:!1,calm:!0,chime:!1,escape:`blur`}},pc=(e,t)=>fc[e===`zen`&&t?`standard`:e],mc=(...e)=>e.filter(e=>e!==!1&&e!=null),hc=(e,t)=>(e.classList.add(t),e.classList.toggle(`flip`));function E(e,t,...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t??{}))r.setAttribute(e,n);return r.append(...mc(...n)),r}var gc=[`coordinator`,`integrator`,`standing`],_c=[`worker`,`scout`,`planner`,`reviewer`,`watchdog`],vc=e=>typeof e==`string`&&gc.includes(e),yc=e=>typeof e==`string`&&_c.includes(e),D=e=>String(e??``),bc=e=>e<60?be({n:String(Math.max(1,e))}):e<1440?i({n:String(Math.floor(e/60))}):n({n:String(Math.floor(e/1440))});function xc(e){let t=e.data,n=e.teamName;switch(e.kind){case`join-request`:return t.unattended?li({label:D(t.label),short:D(t.short),team:n}):oi({label:D(t.label),short:D(t.short),team:n});case`confirm`:return t.tower?gr({label:D(t.label),short:D(t.short),tool:D(t.tool),tower:D(t.tower)}):br({label:D(t.label),short:D(t.short),tool:D(t.tool)});case`dialog`:return Cr({label:D(t.label),short:D(t.short),team:n,owner:D(t.owner)});case`fork`:return Er({team:n,reason:D(t.reason)});case`mismatch`:return fi({label:D(t.label),short:D(t.short),team:n});case`unreachable`:return Si({team:n,minutes:D(t.minutes)});case`inbox`:{let e=Number(t.others)||0,r=D(t.from),i=Pr({count:Number(t.count)||0,team:n,who:e?$r({label:r,others:e}):r,ago:bc(Number(t.ageMin)||1),where:t.workspace===void 0?Kr({project:D(t.project)}):Xr({workspace:D(t.workspace)}),drop:new Date(Number(t.drop)||0).toLocaleDateString(v(),{month:`numeric`,day:`numeric`})});return t.wake===`none`?`${i} ${Br()}`:t.wake===`off`?`${i} ${Hr()}`:t.wake===`failed`?`${i} ${Rr({reason:t.reason===`service`?ri():t.reason===`project`?ti():ei()})}`:i}case`held`:return Ar({count:Number(t.count)||0,team:n});case`served`:return yi({count:Number(t.count)||0,team:n});case`notice`:return hi({label:D(t.label),short:D(t.short),team:n,what:D(t.what),unit:D(t.unit),text:D(t.text)})}}var Sc=e=>xc({id:``,kind:`confirm`,level:`warning`,team:e.team,teamName:``,data:{label:e.fromLabel,short:e.fromShort,tool:e.tool,tower:e.tower}}),Cc=e=>{let t={error:0,warning:1,info:2};return[...e].sort((e,n)=>t[e.level]-t[n.level])};function wc(e){let t=Math.max(0,Math.ceil(e/1e3)),n=e=>String(e).padStart(2,`0`);return t>=3600?`${Math.floor(t/3600)}:${n(Math.floor(t/60)%60)}:${n(t%60)}`:`${Math.floor(t/60)}:${n(t%60)}`}function Tc(e,t){if(e===null)return Mi();if(t)return Fi();let n=Math.floor(e/1e3);return Vi({ago:bc(Math.floor(n/60))})}function Ec(e){return e.online?e.tower===`blocked`?`waiting`:e.tower===`working`?`working`:e.tower===`unknown`?`unknown`:`idle`:`unknown`}function Dc(e){switch(e){case`working`:return Na();case`blocked`:return Ma();case`idle`:return Aa();case`done`:return Oa();case`unknown`:return ja();default:return e}}function Oc(e){let{closed:t,answered:n}=e.data;return t===void 0?n?`sent`:`open`:t===`remote`?n?`done-here`:`done-other`:t===`local`?`done-local`:t===`cancel`?`cancelled`:t===`withdrawn`?`withdrawn`:`expired`}var kc={blocked:3,working:2,idle:1};function Ac(e){let t=new Map;for(let n of e)t.set(n.device,[...t.get(n.device)??[],n]);let n=e=>{let t=[];for(let n of e)t.some(e=>e.team===n.team)||t.push({team:n.team,teamName:n.teamName});return t};return[...t].flatMap(([e,t])=>{let r=t.filter(e=>e.workspace!==null),i=r.length?[...new Set(r.map(e=>e.workspace))]:[null],a=[...t].sort((e,t)=>e.team<t.team?-1:+(e.team>t.team))[0];return i.map((o,s)=>{let c=t.filter(e=>e.workspace===o),l=r.length?t.filter(e=>e.workspace===null):[],u=[...c,...l].filter(e=>e.online),d=u.length>0||!t.some(e=>e.online),f=u.length?u:c,p=d?[...f].sort((e,t)=>(kc[t.tower]??0)-(kc[e.tower]??0))[0]:{tower:`unknown`,tabs:[]},m=s===0&&l.length?{spare:{teams:n(l).map(e=>e.team),named:i}}:{};return{id:o===null?e:`${e}/${o}`,device:e,short:a.short,label:a.label,online:t.some(e=>e.online),...t.some(e=>e.unattended)?{unattended:!0}:{},workspace:o,tower:p.tower,tabs:p.tabs,teams:n([...c,...l]),...m}})})}function jc(e,t){let n=(e??[]).filter(e=>e.device===t.device&&t.teams.includes(e.team)).sort((e,n)=>t.teams.indexOf(e.team)-t.teams.indexOf(n.team)),r=new Map,i=(e,t)=>({...e,at:t.at,stale:t.stale===!0,team:t.team,device:t.device,mains:[]}),a=new Map;for(let e of n)for(let n of e.units)if(t.workspace===null||n.unit===t.workspace||t.spare?.teams.includes(e.team)&&!t.spare.named.includes(n.unit)){let t=r.get(n.unit);(!t||e.at>t.at)&&r.set(n.unit,i(n,e));let o=a.get(n.unit)??new Map;for(let t of Nc(n.unit,e))(!o.has(t.handle)||e.at>o.get(t.handle).at)&&o.set(t.handle,t);a.set(n.unit,o)}return[...r.values()].map(e=>({...e,mains:[...a.get(e.unit)?.values()??[]].map(({at:e,...t})=>t)}))}var Mc=[...gc,`train`];function Nc(e,t){return(t.mains??[]).filter(t=>t.unit===e).map(e=>{let n=t.dispatchers?.[e.by],r=e.stopping?{tone:`other`,word:ji()}:{tone:e.state===`working`?`working`:e.state===`idle`||e.state===`done`?`idle`:`other`,word:Dc(e.state)};return{handle:e.handle,team:t.team,at:t.at,name:e.name,state:e.state,...e.kind!==void 0&&Mc.includes(e.kind)?{kind:e.kind}:{},...r,...n?.self?{}:{byLabel:n?.label??e.by.slice(0,6)},stopping:e.stopping,canStop:t.canStop===!0&&t.stale!==!0&&!e.stopping}})}var Pc=[`run-crashed`,`trust-unanswered`];function Fc(e){switch(e){case`standing`:case`idle`:case`done`:return{tone:`idle`,word:r()};case`running`:case`waking`:return{tone:`working`,word:Ki()};case`working`:case`commanding`:return{tone:`working`,word:qi()};case`blocked`:return{tone:`waiting`,word:Ma()};case`held`:return{tone:`crashed`,word:Gi()};case`closing`:return{tone:`other`,word:f()};default:return{tone:`other`,word:Dc(e)}}}function Ic(e,t,n,r,i=new Map){return jc(e,n).map(e=>{let a=Fc(e.state),o=`${n.device}/${e.unit}`;a.tone===`working`&&i.set(o,Math.max(i.get(o)??0,e.at));let s=t?.filter(t=>t.kind===`notice`&&Pc.includes(String(t.data.what))&&n.teams.includes(t.team)&&t.data.device===n.device&&t.data.unit===e.unit&&Number(t.data.at)>0).map(e=>({at:Number(e.data.at),text:String(e.data.text??``),trust:e.data.what===`trust-unanswered`})).sort((e,t)=>t.at-e.at)[0],c=s!==void 0&&a.tone!==`working`&&r-s.at<18e5&&s.at>(i.get(o)??0)?{at:s.at,text:s.text,...s.trust?{trust:!0}:{}}:void 0,l=c?a.tone===`crashed`?a:c.trust?{tone:`waiting`,word:Zi()}:{tone:`crashed`,word:Wi()}:a;return{unit:e.unit,state:e.state,...l,...c?{crash:c}:{},at:e.at,stale:e.stale,monitors:e.monitors,report:e.report,team:e.team,device:e.device,mains:e.mains}})}var Lc=/(^|[\s(["'])(\*\*|__|~~|\*|_)(?=\S)(.+?)(?<=\S)\2(?=$|[\s,;:!?)\]"']|\.(?:$|\s))/g;function Rc(e){let t=(e.split(`
3
- `).map(e=>e.trim()).find(e=>e&&!/^(`{3,}|~{3,}|[-*_]{3,}$)/.test(e))??``).replace(/^(#{1,6}\s+|>\s*|[-*+]\s+|\d+[.)]\s+)+/,``).replace(/(`+)(.+?)\1/g,`$2`);for(let e=0;e<4;e++){let e=t.replace(Lc,`$1$3`);if(e===t)break;t=e}return t.trim()}var zc=3e4,Bc=[`pointermove`,`pointerdown`,`keydown`,`wheel`,`touchstart`];function Vc(e=document.documentElement){if(matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let t=Date.now(),n,r=()=>fc[e.dataset.view]?.calm===!1,i=()=>{let a=t+zc-Date.now();a>0?n=setTimeout(i,a):(n=void 0,r()||e.toggleAttribute(`data-calm`,!0))},a=()=>{t=Date.now(),n===void 0&&(e.toggleAttribute(`data-calm`,!1),r()||(n=setTimeout(i,zc)))};for(let e of Bc)addEventListener(e,a,{capture:!0,passive:!0});document.addEventListener(`visibilitychange`,()=>document.hidden||a()),a()}var Hc=0,Uc=`button:not([disabled]):not([hidden]), a[href]:not([hidden])`;function Wc(e,t){e.id||=`menu-${++Hc}`;let n=t?za({name:t}):Ia();return E(`button`,{type:`button`,class:`pair-btn menu-btn`,popovertarget:e.id,"aria-haspopup":`true`,"aria-label":n,title:n},`⋯`)}function Gc(e,t,n=``){let r=E(`div`,{class:`menu-pop hud-pop`,popover:`auto`,role:`group`,"aria-label":t?za({name:t}):Ia()},...e);return E(`span`,{class:`menu ${n}`.trim()},Wc(r,t),r)}function Kc(e){let t=document.createComment(``);e.replaceWith(t);let n=Gc([e]);return t.replaceWith(n),n}function qc(e,t){let n=za({name:t});for(let t of[e.querySelector(`.menu-btn`),e.querySelector(`.menu-pop`)])t&&t.getAttribute(`aria-label`)!==n&&t.setAttribute(`aria-label`,n);e.querySelector(`.menu-btn`)?.setAttribute(`title`,n)}function Jc(e,t,n={width:innerWidth,height:innerHeight}){let r=t.getBoundingClientRect(),i=e.offsetWidth,a=e.offsetHeight,o=r.bottom+8+a<=n.height-8||r.top-8-a<8;e.style.top=`${Math.max(8,o?r.bottom+8:r.top-8-a)}px`,e.style.left=`${Math.max(8,Math.min(r.right-i,n.width-i-8))}px`}function Yc(e,t,n){if(e.length){if(n===`Home`)return e[0];if(n===`End`)return e.at(-1);if(n===`ArrowDown`)return e[(t+1)%e.length];if(n===`ArrowUp`)return e[(t<0?0:t-1+e.length)%e.length]}}var Xc=e=>e instanceof Element?e.closest(`.menu-pop`):null,Zc=e=>document.querySelector(`[popovertarget="${CSS.escape(e.id)}"]`);function Qc(){document.addEventListener(`toggle`,e=>{let t=Xc(e.target);if(!t||e.newState!==`open`)return;let n=Zc(t);n&&Jc(t,n),t.querySelector(Uc)?.focus({preventScroll:!0})},!0),document.addEventListener(`keydown`,e=>{let t=Xc(e.target);if(!t||!t.matches(`:popover-open`))return;if(e.key===`Escape`)return void(e.preventDefault(),t.hidePopover(),Zc(t)?.focus());let n=[...t.querySelectorAll(Uc)],r=Yc(n,n.indexOf(document.activeElement),e.key);r&&(e.preventDefault(),r.focus())}),document.addEventListener(`click`,e=>{let t=Xc(e.target),n=e.target instanceof Element?e.target.closest(`button, a`):null;t&&n&&t.contains(n)&&!n.hasAttribute(`popovertarget`)&&!n.hasAttribute(`data-menu-keep`)&&t.matches(`:popover-open`)&&t.hidePopover()})}var $c={main:`main`,member:`member`,train:`train`,subagent:`subagent`,outpost:`outpost`,outside:`outside`,tower:`tower`,ally:`tower`,run:`tower`},el=(e,t)=>(e===`main`?vc(t):e===`subagent`&&yc(t))?t:void 0,tl=(e,t)=>el(e,t)??$c[e]??`member`,nl=new Map,rl=`standard`,il=e=>nl.get(rl)?.has(`${rl}-${e}`)?`#${rl}-${e}`:`#i-${e}`;function al(e=document){for(let t of e.querySelectorAll(`use[data-icon]`)){let e=il(t.dataset.icon);t.getAttribute(`href`)!==e&&t.setAttribute(`href`,e)}}function ol(e,t){if(t!==void 0&&!nl.has(e)){let n=new DOMParser().parseFromString(`<svg xmlns="http://www.w3.org/2000/svg" id="theme-sprite-${e}" width="0" height="0" style="position:absolute" aria-hidden="true">${t}</svg>`,`image/svg+xml`).documentElement;document.body.append(document.importNode(n,!0)),nl.set(e,new Set([...t.matchAll(/\bid="([^"]+)"/g)].map(e=>e[1])))}rl=e,al()}var sl={role_ally:o,role_run:zo,role_main:Fo,role_member:Io,role_train:Uo,role_subagent:Vo,role_tower:Ho,role_outpost:Lo,role_outside:Ro,role_session:Bo,head_tower:rr,outposts:ho,outside_net:go,comms:Vt,spec_base:ns,you:ic,documents:rn},cl,ll=e=>void(cl=e),O=e=>cl?.[v()]?.[e]??sl[e](),ul=e=>e.route.view===`map`||e.route.view===`head`?``:e.route.ws,dl=(e,t)=>{let n=e?.head;return n?.key===t?{u:{key:t,name:n.name,role:`tower`,head:!0,mark:n.mark,control:!0,queued:n.queued,service:n.service,subs:[]},base:{id:x,label:n.name,mark:n.mark,tower:null,tabs:[],outposts:[],outside:[]}}:void 0},fl=(e,t)=>{let n=e?.base.box?.units?.[t];return e&&n?{...e,base:{...e.base,box:{...e.base.box,state:n.state,scope:n.scope,can:n.can}}}:e};function pl(e,t){return fl(ml(e,t),t)}function ml(e,t){let n=dl(e,t);if(n)return n;for(let n of e?.bases??[]){if(n.tower?.key===t)return{u:{key:t,name:n.tower.name,role:`tower`,mark:n.tower.mark,control:n.tower.control,pending:n.tower.pending,queued:n.tower.queued,monitors:n.tower.monitors,service:n.tower.service,docs:n.tower.docs,docsCut:n.tower.docsCut,subs:n.tower.subs},base:n};for(let[e,r]of[...n.tabs.map(e=>[e.label,e.units]),[void 0,n.outside],[void 0,n.tower?.subs??[]]])for(let i of r){if(i.key===t)return{u:i,base:n,squad:e};let r=i.subs.find(e=>e.key===t);if(r)return{u:r,base:n,squad:e,launcher:i}}}}var hl=e=>e?.u.role===`tower`&&e.base.tower?.key===e.u.key?e.base:void 0,k=(e,t)=>(t?t!==`live`:!e)||!(!e?.ended||e.control);function gl(e,t,n){return n?`readonly`:k(e,t)?t===`recent`||e?.ended?`closed`:`none`:`live`}function _l(e){if(e.route.view!==`session`)return;let t=e.route.key,n=pl(e.net,t),r=n?.u;return{key:t,hit:n,u:r,mk:r?.mark??`unknown`,state:e.info?.state,name:r?.name??e.info?.name??t}}var vl=[`phone`,`wifi`,`teams`,`server`],yl=e=>{try{return decodeURIComponent(e)}catch{return e}},bl=e=>/^\.+$/.test(e)?e.replaceAll(`.`,`%2E`):encodeURIComponent(e);function xl(e){let[t,n]=e.split(`#`)[0].split(`?`),[r,i,a,o]=t.replace(/^\/+|\/+$/g,``).split(`/`).map(yl);if(r===`head`&&!i)return{view:`head`};if(r===`settings`)return vl.includes(i)?{view:`settings`,section:i}:{view:`settings`};if(r!==`w`||!i)return{view:`map`};if(a!==`s`||!o)return{view:`workspace`,ws:i};let s=new URLSearchParams(n).get(`at`);return s?{view:`session`,ws:i,key:o,at:s}:{view:`session`,ws:i,key:o}}var A=e=>e.view===`map`?``:e.view===`head`||e.view===`session`&&e.ws===`@head`?`head`:e.view===`settings`?e.section?`settings/${e.section}`:`settings`:e.view===`workspace`?`w/${bl(e.ws)}`:`w/${bl(e.ws)}/s/${bl(e.key)}${e.at?`?at=${encodeURIComponent(e.at)}`:``}`,Sl=e=>e.view===`session`&&e.ws!==`@head`?{view:`workspace`,ws:e.ws}:{view:`map`},Cl=e=>e.view===`settings`?{view:`map`}:e,wl=(e,t)=>e.view===`session`?e.key:e.view===`head`?t??null:e.view===`workspace`?`w:${e.ws}`:null,Tl=e=>Math.max(0,e?.depth||0);function El(e,t=new URL(document.baseURI).pathname){let n=()=>xl(location.pathname.slice(t.length)+location.search),r={route:n,href:e=>A(e)||`./`,go(n){let r=t+A(n);location.pathname+location.search!==r&&history.pushState({depth:Tl(history.state)+1},``,r),e(n)}};return addEventListener(`popstate`,()=>e(n())),document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`a[data-route]`);!t||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t.hasAttribute(`data-back`)&&Tl(history.state)>0?history.back():r.go(xl(t.getAttribute(`data-route`))))}),r}function Dl(e,n,r){let i=r?.allyRuns??[],a=JSON.stringify([n,i.map(e=>[e.id,e.label,e.key])]);e.dataset.sig!==a&&(e.dataset.sig=a,e.hidden=!i.length,e.replaceChildren(...i.length>1?[E(`b`,null,t({count:i.length}))]:[],...i.map(e=>{let t=Oe({device:e.label});if(!e.key)return E(`span`,{class:`ally-chip`,title:Ae()},t);let r=A({view:`session`,ws:n,key:e.key});return E(`a`,{class:`ally-chip`,href:r||`./`,"data-route":r,title:ke()},t)})))}var Ol=e({get:()=>Ml,post:()=>jl,sendFile:()=>Al}),kl=()=>document.querySelector(`meta[name="sb-csrf"]`)?.content??``,Al=(e,t)=>fetch(`api/${e}`,{method:`POST`,cache:`no-store`,headers:{"content-type":`application/octet-stream`,"x-sb-name":encodeURIComponent(t.name||`pasted`),"x-sb-csrf":kl()},body:t}).then(async e=>({ok:e.ok,status:e.status,body:await e.json().catch(()=>({}))})),jl=(e,t)=>fetch(`api/${e}`,{method:`POST`,cache:`no-store`,headers:{"content-type":`application/json`,"x-sb-csrf":kl()},body:JSON.stringify(t)}).then(async e=>({ok:e.ok,status:e.status,body:await e.json().catch(()=>({}))})),Ml=e=>fetch(`api/${e}`,{cache:`no-store`}).then(async e=>({ok:e.ok,status:e.status,body:await e.json().catch(()=>({}))})),Nl=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),Pl=function(e,t){return new URL(e,t).href},Fl={},Il=function(e){return e.pathname.endsWith(`.css`)},Ll=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},j=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Pl(t,n);let r=s(t),i=Il(r);return Ll(Fl,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:Nl,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Rl={retry:zs,deliver:Ls,drop:Rs,answer:Is,dismiss:tc,confirm:Pa,reject:Fa},M,zl,Bl=()=>zl??=Promise.all([j(()=>import(`./waitcard-Xgi9yQRE.js`).then(e=>e.i),[],import.meta.url),j(()=>import(`./asks-DqkFBBS7.js`).then(e=>e.t),[],import.meta.url),j(()=>import(`./answer-D3Fc6DBr.js`).then(e=>e.n),[],import.meta.url)]).then(([e,t,n])=>M={waitCard:e.waitCard,waitActions:t.waitActions,answerPost:n.answerPost}),Vl=new WeakMap,Hl=new WeakMap,Ul=4e3,Wl=new WeakMap,Gl=e=>E(`p`,{class:`tnote-flash`,role:`status`},e);function Kl(e,t){let n=Date.now();Wl.set(e,{text:t,at:n}),e.querySelector(`.tnote-flash`)?.remove(),e.append(Gl(t)),setTimeout(()=>{Wl.get(e)?.at===n&&(Wl.delete(e),e.querySelector(`.tnote-flash`)?.remove())},Ul).unref?.()}function ql(e,t,n,r,i,o){Hl.set(e,[t,n,r,i,o]);let s=d(n),c=JSON.stringify([t,s]),u=document.body.dataset.stale!==`true`;for(let[n,r]of Vl.get(e)?.entries()??[]){let e=s.find(e=>`${t}\u001f${e.wait}`===n)?.entry;e&&r.update(e,u)}if(e.dataset.sig===c)return;e.dataset.sig=c,!M&&r&&s.some(e=>e.wait)&&Bl().then(()=>(e.dataset.sig=``,ql(e,...Hl.get(e))));let f=Vl.get(e)??new Map,p=new Map,m=document.activeElement,h=m&&[...f.values()].some(e=>e.el.contains(m))?m:void 0;e.replaceChildren(...s.map(n=>{let s=E(`small`,{class:`tnote-fail`,role:`alert`}),c=n.wait&&n.entry&&M&&r,d=E(n.wait?`div`:`p`,{class:`tnote ${n.level}`},c?null:E(`span`,null,n.text));if(n.wait){if(M&&r&&n.entry){let a=`${t}\u001f${n.wait}`,s=f.get(a)??M.waitCard({host:`row`,wait:n.entry,...t===`@head`?{head:!0}:{},actions:M.waitActions({ws:t,id:n.wait,tower:r},M.answerPost(r)),main:e=>(t=>e&&t?{view:`session`,ws:t,key:e}:void 0)(i?.(e)??(t===`@head`?void 0:t)),done:t=>Kl(e,t),...o?{box:!0}:{}});s.update(n.entry,u),p.set(a,s),d.append(s.el)}return d}for(let e of n.actions){let r=E(`button`,{type:`button`,class:`pair-btn`},Rl[e]()),i=async()=>n.proposal&&(e===`confirm`||e===`reject`)?(await j(async()=>{let{proposalActions:e}=await import(`./asks-DqkFBBS7.js`).then(e=>e.t);return{proposalActions:e}},[],import.meta.url)).proposalActions({ws:t,id:n.proposal,rev:()=>n.rev})[e]():jl(`${l(t)}/${e}`,n.event?{id:n.event}:{});r.onclick=()=>void a(r,e=>s.textContent=e??``,i),d.append(r)}return d.append(s),d}));let g=Wl.get(e);g&&e.append(Gl(g.text)),Vl.set(e,p),h?.focus()}var Jl=140;function Yl(e,t){let n=document.createElement(`nav`),r=document.createElement(`div`),i=document.createElement(`i`);[n.className,r.className,i.className,n.hidden]=[`minimap`,`mm-in`,`mm-view`,!0],n.setAttribute(`aria-label`,Ba()),n.append(r,i),document.body.append(n);let a=1,o=0,s=()=>{o=0;let t=e.getBoundingClientRect();i.style.transform=`translateY(${Math.round(Math.max(0,-t.top)*a)}px)`,i.style.height=`${Math.round(Math.min(innerHeight-Math.max(0,t.top),t.bottom)*a)}px`,n.classList.toggle(`away`,t.bottom<innerHeight)},c=()=>{let i=e.getBoundingClientRect();n.hidden=e.hidden||i.height<innerHeight*1.05||!matchMedia(`(min-width: 900px) and (hover: hover)`).matches,!n.hidden&&(a=Math.min(Jl/i.width,innerHeight*.4/i.height),Object.assign(n.style,{width:`${Math.round(i.width*a)}px`,height:`${Math.round(i.height*a)}px`}),r.replaceChildren(...[...t.querySelectorAll(`:scope > .base:not(.leaving)`)].map(e=>{let t=e.getBoundingClientRect(),n=document.createElement(`i`);return n.dataset.mark=e.dataset.mark??`idle`,n.style.cssText=`left:${(t.left-i.left)*a}px;top:${(t.top-i.top)*a}px;width:${t.width*a}px;height:${t.height*a}px`,n})),s())};return addEventListener(`scroll`,()=>o||=requestAnimationFrame(s),{passive:!0}),addEventListener(`resize`,c),n.addEventListener(`click`,t=>{let n=e.getBoundingClientRect(),i=(t.clientY-r.getBoundingClientRect().top)/a;scrollTo({top:n.top+scrollY+i-innerHeight/2,behavior:matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`})}),c}var Xl=`sb.head.seen`;function Zl(){try{let e=Number(localStorage.getItem(Xl));return Number.isFinite(e)&&e>0?e:0}catch{return 0}}function Ql(e){try{e>Zl()&&localStorage.setItem(Xl,String(e))}catch{}}var $l=(e,t)=>!!(e?.said&&e.said>t);function eu(e,t,n,r){if(e.hidden=!t,!t)return;e.dataset.mark=t.mark,e.dataset.state=t.state,e.title=O(`head_tower`),e.setAttribute(`aria-label`,t.said&&$l(t,n)&&!r?`${O(`head_tower`)}: ${Bn()}`:O(`head_tower`)),e.toggleAttribute(`aria-current`,r),r&&e.setAttribute(`aria-current`,`page`);let i=e.querySelector(`.dot`);i&&(i.hidden=r||!$l(t,n))}var tu=e=>e&&(e.standing||e.decisions||e.proposals.length||e.problem)?e:void 0,nu=(e,t)=>e.state===`absent`?nr({},t):u(e.service,e.mark,e=>I[e](),t);function ru(e,t){let n=(t,n)=>{let r=e.querySelector(t);r&&r.textContent!==n&&(r.textContent=n)},r=e.querySelector(`.head-icon`);r&&(r.dataset.icon=`crown`,r.setAttribute(`href`,il(`crown`)));let i=e.querySelector(`.head-kicker`);i&&delete i.dataset.m,n(`.head-kicker`,``),n(`.head-title`,O(`head_tower`)),n(`.head-line`,nu(t));let a=e.querySelector(`.head-absent`);a&&(a.hidden=t.state!==`absent`,n(`.head-absent`,fn()))}var iu=864e5,au={answered:4,handled:3,received:2,waiting:1,silent:0},ou=e=>e===`answered`||e===`handled`,su=e=>Number(e.slice(1));function cu(e,t,n){let r=new Map;for(let t of e)r.set(t.group??t.id,[...r.get(t.group??t.id)??[],t]);let i=[...r].map(([e,t])=>{let r=t[0],i=[...new Set(t.map(e=>e.workspace))].map(e=>{let i=t.filter(t=>t.workspace===e),a=i.reduce((e,t)=>au[t.state]>au[e.state]?t:e),o=i.filter(e=>e.last).sort((e,t)=>t.at-e.at)[0]?.last,s=n?.bases.find(t=>t.id===e)?.tower?.key,c=i.at(-1).sent??r.sent??i.at(-1).first;return{workspace:e,label:i.at(-1).label,state:a.state,...o?{said:o}:{},...s?{route:A({view:`session`,ws:e,key:s})}:{},sent:c,...a.missed?{missed:!0}:{}}}),a=t.find(e=>e.boss)?.boss,o=t.find(t=>t.supersedes&&t.supersedes!==e)?.supersedes;return{id:e,first:r.first,sent:r.sent??r.first,...a?{boss:a}:{},towers:i,handled:i.filter(e=>ou(e.state)).length,since:Math.min(...t.map(e=>e.since)),active:Math.max(...t.map(e=>e.at)),...o?{supersedes:o}:{},replaces:[]}}).sort((e,t)=>t.since-e.since),a=new Map(i.map(e=>[e.id,e]));for(let e of i){let t=e.supersedes?a.get(e.supersedes):void 0;if(!t||!(su(t.id)<su(e.id)))continue;let n=t.replacedBy?a.get(t.replacedBy):void 0;(!n||n.since<e.since)&&(t.replacedBy=e.id)}for(let e of i)if(!e.replacedBy)for(let t=e,n=new Set([e.id]);t.supersedes;){let r=a.get(t.supersedes);if(!r||r.replacedBy!==t.id||n.has(r.id))break;e.replaces.push(r),n.add(r.id),t=r}let o=i.filter(e=>!e.replacedBy);return{recent:o.filter(e=>t-e.active<iu),older:o.filter(e=>t-e.active>=iu)}}function lu(e,t,r){let a=Math.max(0,t-e.since)/1e3,o=a<60?Ce({n:String(Math.floor(a))},r):a<3600?be({n:String(Math.floor(a/60))},r):a<86400?i({n:String(Math.floor(a/3600))},r):n({n:String(Math.floor(a/86400))},r);return(e.towers.length===1?Fn:Mn)({age:o,handled:e.handled,count:e.towers.length},r)}var uu={"「":`」`,"『":`』`,"“":`”`,'"':`"`,"'":`'`,"‘":`’`};function du(e){if(!e.sent)return e.first;let t=e.boss?e.sent.indexOf(e.boss):-1,n=e.sent;if(t>=0){let r=e.sent.slice(0,t),i=e.sent.slice(t+e.boss.length),a=`…`,o=r.at(-1);o&&uu[o]!==void 0&&i.startsWith(uu[o])&&(r=r.slice(0,-1),i=i.slice(1),a=``,/^[.。]/.test(i)&&(i=i.slice(1))),(r+i).trim()&&(n=r+a+i)}return n.split(`
4
- `).map(e=>e.replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]+/g,` `).replace(/\s+/g,` `).trim()).find(Boolean)??e.first}var fu={waiting:e=>Cn({},e),answered:e=>pn({},e),handled:e=>mn({},e),received:e=>xn({},e),silent:e=>Sn({},e)},pu=e=>!e.route&&!ou(e.state),mu=(e,t)=>pu(e)?bn({},t):fu[e.state](t);function hu(e,t,n,r=Date.now(),i){let{recent:a,older:o}=t?cu(t.asks,r,n):{recent:[],older:[]},s=a[0]??o[0];if(e.hidden=!s,!s)return;let c=(t,n)=>{let r=e.querySelector(t);r&&r.textContent!==n&&(r.textContent=n)};c(`summary b`,Rn({count:a.length+o.length},i)),c(`summary span`,du(s))}var gu=new WeakMap;function _u(e,t,n,r=Date.now()){let{recent:i,older:a}=t?cu(t.asks,r,n):{recent:[],older:[]},o=new Map([...i,...a].flatMap(e=>[e,...e.replaces]).map(e=>[e.id,lu(e,r)])),s=JSON.stringify([i,a,[...o]]);if(e.hidden=!i.length&&!a.length,e.dataset.sig===s)return;e.dataset.sig=s;let c=gu.get(e)??gu.set(e,new Set).get(e);e.setAttribute(`aria-label`,Tn());let l=(e,t)=>(c.has(t)&&e.setAttribute(`open`,``),e.addEventListener(`toggle`,()=>void(e.hasAttribute(`open`)?c.add(t):c.delete(t))),e),u=(e,t,n)=>E(`span`,{class:`ask-part`,"data-part":e},E(`b`,{class:`ask-tag`},t),E(`span`,{class:`ask-text`},n)),d=(e,t,n)=>E(`section`,{"data-part":e},E(`b`,{class:`ask-tag`},t),E(`p`,null,n)),f=e=>t=>E(`li`,{class:`ask-tower`,"data-state":pu(t)?`none`:t.state},E(`span`,{class:`ask-line`},t.route?E(`a`,{class:`ask-name`,href:t.route||`./`,"data-route":t.route},t.label):E(`b`,{class:`ask-name`},t.label),E(`span`,{class:pu(t)?`ask-none`:`ask-state`},mu(t)),...t.route||pu(t)?[]:[E(`span`,{class:`ask-none`},bn())]),...t.said?[E(`p`,{class:`ask-said`},t.said)]:[],...t.state===`handled`?[E(`p`,{class:`ask-note`},(t.missed?vn:gn)())]:[],...t.sent&&t.sent!==e.sent?[E(`p`,{class:`ask-sent`,"data-tag":Kn()},t.sent)]:[]),p=e=>{let t=e.replacedBy?Jn():e.supersedes?er({count:Math.max(1,e.replaces.length)}):``,n=e.replacedBy??(e.replaces.length?e.replaces.map(e=>e.id):[e.supersedes]).join(`, `),r=E(`details`,{class:`ask-group`,"data-id":e.id,...e.replacedBy?{"data-superseded":``}:{}},E(`summary`,null,...e.boss?[u(`boss`,Wn(),e.boss)]:[],u(`sent`,Kn(),du(e)),u(`to`,qn(),e.towers.map(e=>e.label).join(tr())),E(`span`,{class:`ask-foot`},E(`span`,{class:`ask-meta`},o.get(e.id)),...t?[E(`span`,{class:`ask-chain`,title:n},t)]:[])),E(`div`,{class:`ask-full`},...e.boss?[d(`boss`,Wn(),e.boss)]:[],d(`sent`,Kn(),e.sent)),E(`ul`,{class:`ask-towers`},...e.towers.map(f(e))),...e.replaces.length?[l(E(`details`,{class:`ask-replaced`,"data-id":`replaced-${e.id}`},E(`summary`,null,Zn({count:e.replaces.length})),...e.replaces.map(p)),`replaced-${e.id}`)]:[]);return l(r,e.id)};e.replaceChildren(...i.map(p),...a.length?[l(E(`details`,{class:`ask-older`,"data-id":`older`},E(`summary`,null,Un({count:a.length})),...a.map(p)),`older`)]:[])}var vu=e=>(e?.service?.memory?.bossWaits??[]).filter(e=>!e.state).length;function yu(e,t){let n=cu(e.asks,t,void 0).recent[0];return n?du(n):e.line??``}function bu(e,t=Date.now()){let n=e.state===`absent`,r=O(`head_tower`),i=nu(e),a=n?0:vu(e),o=n?i:yu(e,t);return{absent:n,name:r,state:i,line:o,waits:a,label:[r,i,a?`${a} · ${m()}`:``,n?``:o].filter(Boolean).join(` · `)}}var xu=(e,t,n)=>Math.round(e<=t?e/2:e-n/2);function Su(e){if(e.length<2)return[];let t=e.reduce((t,n,r)=>(t.push(r?t[r-1]+Math.hypot(n[0]-e[r-1][0],n[1]-e[r-1][1]):0),t),[]),n=t.at(-1)||1;return e.map(([e,r],i)=>({at:Math.round(t[i]/n*1e4)/100,x:e,y:r}))}function Cu(e,t){if(t||!e.length)return[];let n=document.createElement(`style`);return n.textContent=e.map((e,t)=>`@keyframes pk${t}{${Su(e).map(({at:e,x:t,y:n})=>`${e}%{transform:translate(${t}px,${n}px)}`).join(``)}}`).join(``),[n,...e.map((e,t)=>(e=>(e.className=`packet`,e.style.animationName=`pk${t}`,e))(document.createElement(`i`)))]}var N=(e,t)=>!e?.box||e.box.state===`live`&&e.box.can.includes(t),wu=(e,t)=>{let n=e.closest(`.base`);return!n||n.dataset.box===void 0||n.dataset.box===`live`&&(n.dataset.can??``).split(` `).includes(t)},Tu=e=>e.box?`${e.label} · ${e.box.label}`:e.label;function Eu(e,t){let n=e.bases.filter(e=>e.box),r=new Map,i=[];for(let e of t){let t=n.filter(t=>t.box.device===e.device&&t.box.state===`live`),a=t.find(t=>t.label===e.workspace)??t[0];a?r.set(a.id,[...r.get(a.id)??[],e]):i.push(e)}return{bases:[...e.bases.filter(e=>!e.box),...n],loose:i,under:r}}var Du=typeof document<`u`&&typeof document.querySelector==`function`&&((e=document)=>e.querySelector(`meta[name="sb-desk"]`)?.content===`1`)(),Ou=(e,t=Du)=>t||e!==`127.0.0.1`,ku=(e,t=Du)=>({phone:!Ou(e,t),server:e===`127.0.0.1`});function P(e,t,n,r,i=!1){Object.assign(e.dataset,t),[e.hidden,e.textContent]=[i,n],r&&e.setAttribute(`aria-label`,r)}var Au=()=>!0,ju=(e,t,n=Au)=>t.role===`subagent`&&t.ended&&t.key?P(e,{close:`dismiss`,key:t.key,name:t.name,role:t.role},Xt(),nn({name:t.name}),!n(`dismiss`)):P(e,{close:`unit`,key:t.key??``,name:t.name,role:t.role},wo(),Lt({name:t.name}),!(t.control&&t.key)||t.role===`subagent`||!n(`close-unit`)),Mu=(e,t,n=Au)=>P(e,{key:t?.key??``,name:t?.name??``,role:`tower`},Eo(),void 0,!t?.control||!n(`tower`)||!n(`close-unit`));function Nu(e,t){e.dataset.close=`unit`;let n=e=>N(t?.base,e);t?.u.role===`tower`&&t.base.tower?.key===t.u.key?Mu(e,t.base.tower,n):t&&ju(e,t.u,n),e.hidden=!t||e.dataset.close!==`unit`||e.hidden}var Pu=(e,t)=>P(e,{ws:t.id,name:t.label},wo(),bt({name:t.label}),!!t.box),Fu=(e,t,n=Du)=>P(e,{ws:t.id,name:t.label},rs(),os({name:t.label}),n||!!t.box),Iu=(e,t,n)=>P(e,{ws:t.id,name:n.label,tab:n.id},wo(),Dt({name:n.label}),!N(t,`close-tab`)),F=(e,t)=>new Promise(n=>{let r=document.createElement(`dialog`),i=document.createElement(`p`),a=document.createElement(`div`),o=(e,t,i)=>Object.assign(document.createElement(`button`),{type:`button`,className:t,textContent:e,onclick:()=>(r.close(),n(i))});[r.className,i.textContent,a.className]=[`sheet`,e,`sheet-row`],a.append(...t?[o(gt(),`later`,!1),o(t,`sheet-yes`,!0)]:[o(_t(),`later`,!1)]),r.append(i,a),r.addEventListener(`close`,()=>(r.remove(),n(!1))),document.body.append(r),r.showModal()}),Lu=(e,t)=>new Promise(n=>{let r=document.createElement(`dialog`),i=document.createElement(`p`),a=document.createElement(`div`),o=(e,t,i)=>Object.assign(document.createElement(`button`),{type:`button`,className:t,textContent:e,onclick:()=>(r.close(),n(i))}),s=o(t.length?gt():_t(),`later`);[r.className,i.textContent,a.className]=[`sheet`,e,`sheet-row`],a.append(s,...t.map(e=>o(e.label,e.tone===`danger`?`sheet-yes sheet-danger`:`sheet-yes`,e.value))),r.append(i,a),r.addEventListener(`close`,()=>(r.remove(),n(void 0))),document.body.append(r),r.showModal(),s.focus()}),Ru=e=>he(e).filter(e=>e.sub&&`ended`in e.unit&&e.unit.ended).map(e=>e.unit.key);function zu(e,t){let n=Ru(t).length;e.hidden=!n,n&&(e.textContent=$t({count:n}))}function Bu(e,t,n,r=Du){if(r)return void(e.hidden=!0);let i=n.stashed??[],a=JSON.stringify(i);e.hidden=!i.length;let o=t.closest(`[popover]`);!i.length&&o?.matches(`:popover-open`)&&o.hidePopover(),i.length&&(e.textContent=ps({count:i.length})),t.dataset.key!==a&&(t.dataset.key=a,t.replaceChildren(...i.map(e=>{let t=document.createElement(`li`),n=document.createElement(`span`),r=document.createElement(`button`);return n.textContent=e.name===e.label?e.label:`${e.name} (${e.label})`,[r.type,r.className]=[`button`,`pair-btn`],P(r,{close:`pop`,name:e.name},vo(),xo({name:e.name})),t.append(n,r),t})))}var Vu=e=>j(async()=>{let{post:e}=await Promise.resolve().then(()=>Ol);return{post:e}},void 0,import.meta.url).then(({post:t})=>t(`dismiss`,e)).then(e=>e.ok||(F(e.body.reason??T({status:e.status})),!1),()=>(F(w()),!1));function Hu(e,{route:t,net:n,go:r}){let i=t();if(i.view===`map`||i.view===`head`)return;if(e.close===`base`||e.close===`stash`)return void(i.ws===e.ws&&r({view:`map`}));let a=e=>e.flatMap(e=>[e.key,...a(e.subs)]),o=e.close===`tab`&&i.ws===e.ws?n()?.bases.find(t=>t.id===e.ws)?.tabs.find(t=>t.id===e.tab):void 0;i.view===`session`&&(e.close===`unit`?i.key===e.key:o&&a(o.units).includes(i.key))&&r({view:`workspace`,ws:i.ws})}function Uu(e){document.addEventListener(`click`,t=>{let n=t.target?.closest?.(`button[data-close]`),r=n?.dataset;if(n&&r){if(t.preventDefault(),r.close===`head`)return void F(kn(),Dn()).then(e=>e&&(n.toggleAttribute(`disabled`,!0),j(async()=>{let{post:e}=await Promise.resolve().then(()=>Ol);return{post:e}},void 0,import.meta.url).then(({post:e})=>e(`head/close`,{})).then(e=>e.ok||F(e.body.reason??T({status:e.status})),()=>F(w())).finally(()=>n.toggleAttribute(`disabled`,!1))));if(r.close===`dismiss`||r.close===`dismiss-all`)return void Vu(r.close===`dismiss`?{key:r.key}:{all:!0});if(r.close===`pop`)return void(n.toggleAttribute(`disabled`,!0),Promise.all([j(()=>Promise.resolve().then(()=>Ol),void 0,import.meta.url),j(()=>import(`./refusal--wJ5SRx-.js`).then(e=>e.n),[],import.meta.url)]).then(([{post:e},{reasonOf:t}])=>e(`close/pop`,{name:r.name}).then(e=>e.ok||F(t(e.body.reason,e.body.settings)??T({status:e.status})))).catch(()=>F(w())).finally(()=>n.toggleAttribute(`disabled`,!1)));F((r.close===`stash`?us:r.close===`base`?wt:r.close===`tab`?At:r.role===`tower`?Pt:Bt)({name:r.name??``}),r.close===`stash`?rs():wo()).then(t=>{t&&(n.toggleAttribute(`disabled`,!0),j(async()=>{let{post:e}=await Promise.resolve().then(()=>Ol);return{post:e}},void 0,import.meta.url).then(({post:e})=>e(`close/${r.close===`base`?`all`:r.close}`,r.close===`unit`?{key:r.key}:{workspace:r.ws,...r.tab&&{tab:r.tab}})).then(t=>t.ok?Hu(r,e):F(t.body.reason??T({status:t.status})),()=>F(w())).finally(()=>n.toggleAttribute(`disabled`,!1)))})}})}var I={commanding:Da,working:Na,waiting:Ma,idle:Aa,done:Oa,error:ka,unknown:ja},Wu={ally:`role_ally`,run:`role_run`,main:`role_main`,member:`role_member`,train:`role_train`,subagent:`role_subagent`,tower:`role_tower`,outpost:`role_outpost`,outside:`role_outside`,session:`role_session`},Gu={thinking:to,"watching a monitor":eo,idle:Aa,"waiting on a question":Ma,finished:Oa},Ku=e=>Object.hasOwn(Wu,e)?O(Wu[e]):e,qu={coordinator:ir,integrator:ar,standing:lr,worker:dr,scout:cr,planner:or,reviewer:sr,watchdog:ur},Ju={"single-loop":un,"fan-out/fan-in":cn,"orchestrator-worker":ln},Yu=(e,t,n)=>{let r=t&&Object.hasOwn(qu,t)?qu[t]():Ku(e);return e===`main`&&n&&Object.hasOwn(Ju,n)?`${r} · ${Ju[n]()}`:r},Xu=(e,t)=>`${Ku(e)} · ${t}`,Zu=e=>e===`waiting`||e===`error`,L=e=>{let t=new DOMParser().parseFromString(e.trim(),`text/html`).body.firstElementChild;if(!(t instanceof HTMLElement))throw Error(`bad template`);let n=document.importNode(t,!0);return al(n),n},R=(e,t)=>{let n=document.getElementById(e);if(!(n instanceof t))throw Error(`#${e} is missing from the page`);return n},z=(e,t,n)=>{let r=e.querySelector(t);r.textContent!==n&&(r.textContent=n)},B=(e,t)=>{if(e.dataset.mark===t)return;let n=e.dataset.mark!==void 0;e.dataset.mark=t,n&&hc(e,`flash`)},Qu=e=>(t=>(e.slice(8,t)===`stale`?Ka:Ua)({what:e.slice(t+1)}))(e.indexOf(`:`,8)),V=(e,t)=>e?e.startsWith(`tool:`)?Ws({tool:e.slice(5)}):e.startsWith(`monitor:`)?Qu(e):Object.hasOwn(Gu,e)?Gu[e]():e:I[t](),$u=(e,t,n)=>k(e,t)?``:n===`working`||n===`commanding`?V(e?.note,n):Zu(n)?I[n]():``,ed=(e,t,n)=>k(e,t)&&(n===`working`||n===`commanding`)?`done`:n,td=(e,t,n,r,i=V(n,r))=>{z(e,t,i),e.querySelector(t).toggleAttribute(`data-monitoring`,i===V(n,r)&&n===`watching a monitor`)},nd=(e,t)=>{e.toggleAttribute(`hidden`,!t),t&&(e.setAttribute(`href`,A(t)||`./`),e.setAttribute(`data-route`,A(t)))},rd=(e,t)=>{let n=t.getBoundingClientRect(),r=e.offsetWidth;e.style.top=`${n.bottom+8}px`,e.style.left=`${Math.max(8,Math.min(n.right-r,innerWidth-r-8))}px`},id=`<div class="plate"><i class="ring"></i><svg><use data-icon="main"/></svg><b class="badge"></b></div>`;function ad(e,t,n,r,i){B(e,n);let a=e.querySelector(`use`),o=tl(t,i),s=il(o),c=r?.filter(e=>e.onScreen).length;a.dataset.icon=o,a.getAttribute(`href`)!==s&&a.setAttribute(`href`,s),c?e.dataset.docs=String(c):delete e.dataset.docs}function H(e,t,n,r){let i=new Map;for(let t of e.children)!t.classList.contains(`leaving`)&&t.dataset.key&&i.set(t.dataset.key,t);let a=e.firstElementChild;for(let o of t){let t=i.get(o.id);for(t||(t=n(o),t.dataset.key=o.id,t.classList.add(`enter`),setTimeout(()=>t.classList.remove(`enter`),600)),i.delete(o.id);a?.classList.contains(`leaving`);)a=a.nextElementSibling;t===a?a=a.nextElementSibling:e.insertBefore(t,a),r(t,o)}for(let e of i.values())e.classList.add(`leaving`),setTimeout(()=>e.remove(),400)}var od=(e,t=Math.max(0,Date.now()-e)/1e3)=>t<60?Ce({n:String(Math.floor(t))}):t<3600?be({n:String(Math.floor(t/60))}):t<86400?i({n:String(Math.floor(t/3600))}):n({n:String(Math.floor(t/86400))}),sd=(e,t)=>(t===void 0?delete e.dataset.since:e.dataset.since=String(t),e.textContent=t===void 0?``:od(t));function cd(e,t=[]){let n=e.querySelector(`:scope > .ticks`),r=t.map(e=>`${e.at}${e.mark}`).join();n.dataset.sig!==r&&(n.dataset.sig=r,e.classList.toggle(`ticked`,t.length>0),n.replaceChildren(...t.map((e,n)=>{let r=document.createElement(`i`);return r.dataset.mark=e.mark,r.style.setProperty(`--o`,((n+1)/t.length).toFixed(2)),r})))}var ld=new Map,ud=new Map,dd=new Set,fd=(e,t,n=new Set)=>void([ld,ud,dd]=[e,t,n]),pd,md,hd=()=>L(`<div class="unit"><div class="card"><a class="hit"></a>${id}<div class="meta"><span class="name"></span><span class="line"><em class="role"></em><span class="note"></span><span class="age"></span></span><span class="todo" hidden><b></b><span></span></span><button type="button" class="yard-open" hidden></button></div><button type="button" class="quit-btn" data-close="unit" hidden></button><span class="ticks" aria-hidden="true"></span></div><div class="subs"></div></div>`);function gd(e,t){let n=e.closest(`.base`)?.dataset.key,r=e.querySelector(`.hit`),i=ed(t,void 0,t.mark),a=k(t)?void 0:t.note;nd(r,t.key&&n?{view:`session`,ws:n,key:t.key}:void 0),r.setAttribute(`aria-label`,`${t.name}: ${V(a,i)}`),r.toggleAttribute(`data-alert`,Zu(i)),B(e,i),ad(e.querySelector(`.plate`),t.role,i,t.docs,t.duty),z(e,`.name`,t.name),z(e,`.role`,Yu(t.role,t.duty,t.todo?.graph));let o=t.key&&!k(t)&&ld.get(t.key)||void 0,s=e.querySelector(`.note`);td(e,`.note`,a,i,o),e.toggleAttribute(`data-train-note`,!!o),e.toggleAttribute(`data-train-wait`,!!o&&!!t.key&&dd.has(t.key)),o?s.setAttribute(`title`,o):s.removeAttribute(`title`);let c=t.key?ud.get(t.key):void 0,l=e.querySelector(`:scope > .card .yard-open`);l.hidden=!c,c&&(l.dataset.yard=c,z(e,`:scope > .card .yard-open`,rc())),sd(e.querySelector(`:scope > .card .age`),t.since);let u=e.querySelector(`:scope > .card .todo`);u.hidden=!t.todo,t.todo&&(z(u,`b`,`${t.todo.done<t.todo.total?`◐`:`✓`} ${t.todo.done}/${t.todo.total}`),z(u,`span`,t.todo.now??``)),cd(e.querySelector(`:scope > .card`),t.ticks),ju(e.querySelector(`:scope > .card > .quit-btn`),t,t=>wu(e,t)),H(e.querySelector(`.subs`),t.subs??[],hd,gd)}function _d(e,t,n){let r=t.tower?`main`:`member`;e.hidden=!!(n&&t.tower||t.box),e.dataset.open=r,e.dataset.ws=t.id,n&&(e.dataset.tab=n),e.textContent!==(r===`main`?po():mo())&&(e.textContent=r===`main`?po():mo())}var vd=()=>L(`<section class="base"><header><div class="tower"><i class="sweep"></i><i class="pulse"></i><svg><use data-icon="tower"/></svg><b class="badge"></b></div><div class="title"><h2><a class="enter-base"></a></h2><p><span class="tstate"></span><span class="tqueue"></span><span class="age"></span></p><div class="allies" hidden></div><button type="button" class="pair-btn yard-chip-btn" hidden></button><p class="box-line" hidden><b class="box-dev"></b><span class="box-team"></span><span class="box-seen" hidden><span class="bs-state"></span><span class="bs-when"> · <span class="bs-pre"></span><span class="age"></span><span class="bs-post"></span></span></span></p><button type="button" class="quit-btn tower-quit" data-close="unit" hidden></button></div><button type="button" class="quit-btn" data-close="base"></button></header><div class="subs tower-subs"></div><div class="tower-notices"></div><div class="spawn-btns"><button type="button" class="pair-btn"></button><button type="button" class="pair-btn" data-close="stash"></button></div><div class="tabs"></div><div class="outposts" data-label="${O(`outposts`)}"></div><p class="box-ended" role="status" hidden></p><details class="box-runs" hidden><summary></summary><ul class="box-run-list"></ul></details><details class="box-truns" hidden><summary></summary><ul class="box-run-list box-trun-list"></ul></details><button type="button" class="pair-btn box-more" hidden></button><details class="box-ally" hidden><summary></summary><div class="box-ally-in"></div></details></section>`),yd=()=>{let e=vd();return Kc(e.querySelector(`header > .quit-btn`)),e},bd=e=>u(e.service,e.mark,e=>I[e]()),xd,Sd,Cd=new Map,wd=()=>Sd??=j(()=>import(`./box-BUf9E97Z.js`).then(e=>(xd=e,Cd.forEach((t,n)=>e.fillBox(n,...t)),Cd.clear()),()=>void(Sd=void 0)),[],import.meta.url);function Td(e,t,{under:n,link:r,yard:i}={}){B(e,t.mark),e.classList.toggle(`remote`,!!t.box),t.box?(e.dataset.box=t.box.state,e.dataset.can=t.box.can.join(` `)):(delete e.dataset.box,delete e.dataset.can),e.querySelector(`header > .menu`).hidden=e.querySelector(`.spawn-btns`).hidden=!!t.box,t.box&&(xd?xd.fillBox(e,t,n,r):(Cd.set(e,[t,n,r]),wd()));let a=e.querySelector(`.tower`);a.classList.toggle(`ghost`,!t.tower),B(a,t.tower?.mark??`unknown`),z(e,`h2 a`,t.label),nd(e.querySelector(`h2 a`),{view:`workspace`,ws:t.id}),z(e,`.title .tstate`,t.tower?Jt({state:bd(t.tower)}):$a()),z(e,`.title .tqueue`,s(t.tower?.service)??``),sd(e.querySelector(`.title .age`),t.tower?.since),_d(e.querySelector(`.spawn-btns button`),t),Pu(e.querySelector(`header .menu-pop > .quit-btn`),t),qc(e.querySelector(`header > .menu`),t.label),Fu(e.querySelector(`.spawn-btns [data-close=stash]`),t),Mu(e.querySelector(`.tower-quit`),t.tower,e=>N(t,e)),H(e.querySelector(`.tower-subs`),t.tower?.subs??[],hd,gd),Dl(e.querySelector(`.title .allies`),t.id,t.tower?.service);let o=e.querySelector(`.yard-chip-btn`);o.hidden=!i,i?(o.dataset.yard=i.projects.join(` `),o.textContent!==i.chip&&(o.textContent=i.chip),o.title=nc()):delete o.dataset.yard,ql(e.querySelector(`.tower-notices`),t.id,t.tower?.service,t.tower?.key,void 0,!!t.box),H(e.querySelector(`.tabs`),t.tabs,()=>{let e=L(`<div class="tab"><h3><span></span><button type="button" class="tab-add"></button><button type="button" class="quit-btn" data-close="tab"></button></h3><div class="units"></div></div>`);return Kc(e.querySelector(`h3 > .quit-btn`)),e},(e,n)=>{z(e,`h3 span`,Ds({label:n.label})),Iu(e.querySelector(`.menu-pop > .quit-btn`),t,n),e.querySelector(`h3 > .menu`).hidden=!N(t,`close-tab`),qc(e.querySelector(`h3 > .menu`),Ds({label:n.label})),_d(e.querySelector(`.tab-add`),t,n.id),H(e.querySelector(`.units`),n.units,hd,gd)}),e.querySelector(`.outposts`).dataset.label=O(`outposts`),H(e.querySelector(`.outposts`),t.outposts.map(e=>({id:e.id,name:e.label,role:`outpost`,mark:e.mark,note:e.mark===`unknown`?Xa():void 0,since:e.since,ticks:e.ticks})),hd,gd)}var Ed=()=>L(`<section class="base ally"><header><div class="tower"><i class="pulse"></i><svg><use data-icon="tower"/></svg><b class="badge"></b></div><div class="title"><span class="crown"><svg><use data-icon="main"/></svg><em class="ally-tag"></em></span><h2></h2><p><span class="tstate"></span></p><p class="ally-teams" hidden></p></div></header><ul class="ally-tabs"></ul><ul class="ally-units"></ul></section>`),Dd,Od=!1,kd=new Map;function Ad(e,t,n){if(t={...t,id:t.id.replace(/^ally\//,``)},Dd)return void Dd.show(e,t,n);if(!n?.alerts.some(e=>e.kind===`dialog`))return void kd.delete(e);kd.set(e,[t,n]),!Od&&(Od=!0,j(async()=>{let{mountAllyAsks:e}=await import(`./allyasks-Czxu9N0_.js`);return{mountAllyAsks:e}},[],import.meta.url).then(({mountAllyAsks:e})=>(Dd=e(),kd.forEach(([e,t],n)=>Dd.show(n,e,t)),kd.clear()),()=>void(Od=!1)))}var jd,Md=!1,Nd=new Map;function Pd(e,t,n,r){if(jd)return void jd(e.querySelector(`.ally-units`),t,n,r);if(!t.length)return void Nd.delete(e);Nd.set(e,[t,n,r]),!Md&&(Md=!0,j(async()=>{let{fillAllyUnits:e}=await import(`./allyunits-Cu820tRD.js`);return{fillAllyUnits:e}},[],import.meta.url).then(({fillAllyUnits:e})=>(jd=e,Nd.forEach(([t,n,r],i)=>e(i.querySelector(`.ally-units`),t,n,r)),Nd.clear()),()=>void(Md=!1)))}var Fd=new Map;function Id(e,t,n){let r=Ec(t),i=n?.units;B(e,r),e.classList.toggle(`offline`,!t.online),B(e.querySelector(`.tower`),r);let a=t.teams.length>1,o=e.querySelector(`.ally-teams`);z(e,`.ally-tag`,a?Pe():Ne({team:t.teams[0]?.teamName??``})),o.hidden=!a,o.textContent=a?Le({teams:t.teams.map(e=>e.teamName).join(Re())}):``,z(e,`h2`,t.workspace??t.label);let s=Ic(i,n?.alerts,{device:t.device,workspace:t.workspace,spare:t.spare,teams:t.teams.map(e=>e.team)},Date.now(),Fd);z(e,`.tstate`,`${t.workspace?`${t.label} · `:``}${t.short}${t.online?s.length?``:` · ${Dc(t.tower)}`:` · ${Pi()}`}`);let c=s.length?[]:t.unattended?t.online&&t.tabs.length?[{id:`online`,label:``,state:t.tower,says:Xi({count:t.tabs.length})}]:[]:t.tabs.map((e,t)=>({id:`${t}`,...e}));H(e.querySelector(`.ally-tabs`),c,()=>L(`<li class="ally-tab"><b></b><span></span></li>`),(e,n)=>{z(e,`b`,n.says??n.label),z(e,`span`,n.says!==void 0||!t.online?``:Dc(n.state)),e.dataset.state=n.state}),e.classList.toggle(`has-units`,s.length>0),Pd(e,s,t.workspace===null,t.label),Ad(e,t,n)}function Ld(e,t,n=Date.now()){if(e.hidden=!t,e.classList.toggle(`off`,!t),!t)return;let r=bu(t,n);e.classList.toggle(`absent`,r.absent),B(e,t.mark),e.setAttribute(`href`,`head`),e.setAttribute(`aria-label`,r.label),e.title=r.label,z(e,`.head-name`,r.name),z(e,`.head-line`,r.line);let i=e.querySelector(`.head-waits`);i.hidden=!r.waits,z(e,`.head-waits`,r.waits?String(r.waits):``)}function Rd(e,t,n){if(!e||!n.length)return{routes:[],segments:[]};let r=n.map(n=>[[e[0],e[1]],[e[0],t],[n.gutter,t],[n.gutter,n.y],[n.x,n.y]].filter((e,t,n)=>t===0||e[0]!==n[t-1][0]||e[1]!==n[t-1][1])),i=new Map;for(let e of r)for(let t=1;t<e.length;t++){let[n,r]=[e[t-1],e[t]],a=n[1]===r[1],o=a?`h${n[1]}`:`v${n[0]}`,s=a?[Math.min(n[0],r[0]),Math.max(n[0],r[0])]:[Math.min(n[1],r[1]),Math.max(n[1],r[1])];i.set(o,[...i.get(o)??[],s])}return{routes:r,segments:[...i].flatMap(([e,t])=>{let n=Number(e.slice(1)),r=[];for(let e of t.sort((e,t)=>e[0]-t[0])){let t=r.at(-1);t&&e[0]<=t[1]?t[1]=Math.max(t[1],e[1]):r.push([...e])}return r.map(([t,r])=>e[0]===`h`?{x1:t,y1:n,x2:r,y2:n}:{x1:n,y1:t,x2:n,y2:r})}).sort((e,t)=>e.y1-t.y1||e.x1-t.x1||e.y2-t.y2||e.x2-t.x2)}}function zd(e,t,n,r,i){let a=[...t.querySelectorAll(`:scope > .base:not(.leaving)`)],o=e.querySelector(`.head-node:not(.off)`)??void 0,s=e.getBoundingClientRect(),c=t.getBoundingClientRect(),l=getComputedStyle(t),[u,d]=[parseFloat(l.gridTemplateColumns),parseFloat(l.columnGap)||20];o?.style.setProperty(`--col`,Number.isFinite(u)?`${u}px`:``);let f=e=>e.getBoundingClientRect().x-s.x,p=Math.min(...a.map(f)),m=a.filter(e=>!e.classList.contains(`ally`)&&!e.classList.contains(`remote`)).map(e=>({c:e,t:e.querySelector(`.tower`)})),h=o?.getBoundingClientRect(),g=h?[Math.round(h.x+h.width/2-s.x),Math.round(h.bottom-s.y)]:void 0,_=m.map(({c:e,t})=>{let n=t.getBoundingClientRect();return{x:Math.round(n.x+n.width/2-s.x),y:Math.round(n.y+n.height/2-s.y),gutter:xu(f(e),p,d)}}),{routes:v,segments:y}=Rd(g,g?Math.round((g[1]+c.y-s.y)/2):0,_),b=y.map(({x1:e,y1:t,x2:n,y2:r})=>t===r?`M${e} ${t}H${n}`:`M${e} ${t}V${r}`),x=JSON.stringify(v);n.dataset.sig!==x&&(n.dataset.sig=x,n.replaceChildren(...b.map(e=>(t=>(t.setAttribute(`class`,`wire`),t.setAttribute(`d`,e),t))(document.createElementNS(`http://www.w3.org/2000/svg`,`path`)))),r.replaceChildren(...Cu(v,i))),r.querySelectorAll(`.packet`).forEach((e,t)=>e.toggleAttribute(`data-live`,[`working`,`commanding`].includes(o.dataset.mark??``)||[`working`,`commanding`].includes(m[t].t.dataset.mark??``)))}var Bd=2,Vd=20;function Hd(){let[e,t,n,r]=[R(`map`,HTMLElement),R(`bases`,HTMLElement),R(`links`,SVGSVGElement),R(`packets`,HTMLElement)],i=matchMedia(`(prefers-reduced-motion: reduce)`).matches,a=new Set,o=Yl(e,t),s=()=>(o(),!e.hidden&&zd(e,t,n,r,i)),c=0,l=()=>c||=requestAnimationFrame(()=>(c=0,s())),u=new ResizeObserver(e=>(e.forEach(({target:e,borderBoxSize:t})=>e.style.gridRowEnd=`span ${Math.ceil((t[0].blockSize+Vd)/Bd)}`),l()));setInterval(()=>document.querySelectorAll(`.age[data-since]`).forEach(e=>sd(e,Number(e.dataset.since))),15e3),addEventListener(`resize`,l),new ResizeObserver(([e])=>document.documentElement.style.setProperty(`--hud`,`${Math.ceil(e.borderBoxSize[0].blockSize)}px`)).observe(document.querySelector(`.hud`),{box:`border-box`}),Vc();let d,f={layout:s,stats(e){let t=e.bases.flatMap(e=>[...e.tower?.subs??[],...e.tabs.flatMap(e=>e.units.flatMap(e=>[e,...e.subs]))]),n=e=>String(t.filter(t=>!e||t.mark===e).length);R(`s-commanding`,HTMLElement).parentElement.toggleAttribute(`data-on`,t.some(e=>e.mark===`commanding`));let r=e.yards?pd:void 0,i=r?.yardMap(e).loose??[],a=R(`yard-loose`,HTMLElement);a.hidden=!r||!i.length,r&&i.length&&(a.dataset.yard=i.join(` `),a.textContent=r.chipWords(r.sumCounts(i.map(t=>r.countsOf(e.yards.projects.find(e=>e.project===t))))),a.title=nc());for(let[t,r]of[[`s-bases`,String(e.bases.length)],[`s-agents`,n()],[`s-working`,n(`working`)],[`s-commanding`,n(`commanding`)],[`s-waiting`,n(`waiting`)]])R(t,HTMLElement).textContent=r},show(e){let n=e.yards?pd:void 0,r={now:Date.now(),...e.load?{load:e.load}:{}};e.yards&&!pd&&(md??=j(()=>import(`./trains-GY_I0p6W.js`).then(e=>(pd=e,d&&(f.show(d),f.stats(d))),()=>void(md=void 0)),[],import.meta.url)),d=e;let i=n?.yardMap(e),o=new Map((e.yards?.projects??[]).map(e=>[e.project,n?.countsOf(e)]));fd(n?.trainNotes(e,r)??new Map,i?.integrators??new Map,n?.trainWaits(e));let c=e=>(e=>n&&e?.length?{projects:e,chip:n.chipWords(n.sumCounts(e.map(e=>o.get(e))))}:void 0)(i?.byBase.get(e)),{bases:l,loose:p,under:m}=Eu(e,Ac(e.link?.allies??[])),h=p.map(e=>({...e,id:`ally/${e.id}`,ally:!0}));Ld(R(`head-node`,HTMLElement),e.head),H(t,[...l,...h],e=>`ally`in e?Ed():yd(),(t,n)=>`ally`in n?Id(t,n,e.link):Td(t,n,{under:m.get(n.id),link:e.link,yard:c(n.id)}));for(let e of t.children)a.has(e)||(a.add(e),u.observe(e));for(let e of a)e.isConnected||(a.delete(e),u.unobserve(e));requestAnimationFrame(s)},pause(e){document.documentElement.classList.toggle(`paused`,e)}};return f}var Ud=(e,t)=>n=>n&&!e()&&t();function Wd(e,t){let n=R(`link-alerts`,HTMLButtonElement),r=R(`link-alerts-pop`,HTMLElement),i=R(`link-alerts-list`,HTMLElement),a=``,o=new Set,s=!0;r.addEventListener(`toggle`,e=>e.newState===`open`&&rd(r,n)),r.setAttribute(`aria-label`,Ei()),n.title=Ei();let c=(e,t,n)=>{let r=n.querySelector(`.link-note`);for(let e of n.querySelectorAll(`button`))e.disabled=!0;j(async()=>{let{confirmActions:e,confirmWhy:t}=await import(`./asks-DqkFBBS7.js`).then(e=>e.t);return{confirmActions:e,confirmWhy:t}},[],import.meta.url).then(async({confirmActions:n,confirmWhy:r})=>({r:await n(e)[t?`allow`:`deny`](),why:r})).then(({r:e,why:t})=>{e.ok||(r.textContent=t(e));for(let e of n.querySelectorAll(`button`))e.disabled=!1},()=>{r.textContent=w();for(let e of n.querySelectorAll(`button`))e.disabled=!1})},l=e=>{let t=E(`li`,{class:`link-alert`,"data-level":`warning`}),n=E(`button`,{type:`button`,class:`pair-btn`},Di()),r=E(`button`,{type:`button`,class:`pair-btn`},ki());return n.onclick=()=>c(e,!0,t),r.onclick=()=>c(e,!1,t),t.append(E(`b`,null,Sc(e)),E(`pre`,{class:`link-args`},e.args),E(`div`,{class:`devices-acts`},n,r),E(`small`,{class:`link-note`,role:`status`})),t},u,d,f=()=>void j(async()=>{let{mountDialogCards:e}=await import(`./linkdialogs-BHiWLB73.js`);return{mountDialogCards:e}},[],import.meta.url).then(({mountDialogCards:e})=>(u=e(),a=``,m.net(d))),p=new Set,m={net(c){d=c;let h=Cc((c?.alerts??[]).filter(e=>e.kind!==`confirm`&&!p.has(e.id))),g=c?.confirms??[],_=JSON.stringify([h,g]);if(_===a)return;a=_;let v=new Set([...g.map(e=>`c/${e.dialogId}`),...h.filter(e=>e.kind===`join-request`||e.kind===`dialog`&&Oc(e)===`open`).map(e=>e.id)]);u?.keep(new Set(h.map(e=>e.id))),!u&&h.some(e=>e.kind===`dialog`)&&f(),s||t([...v].filter(e=>!o.has(e)).length),[o,s]=[v,!1];let y=h.length+g.length;n.hidden=y===0,n.textContent=Ti({count:String(y)}),n.dataset.state=g.length||h.some(e=>e.level===`error`)?`error`:h.some(e=>e.level===`warning`)?`waiting`:`done`,!y&&r.matches(`:popover-open`)&&r.hidePopover(),i.replaceChildren(...mc(...g.map(l),...h.map(t=>{if(t.kind===`dialog`&&u)return u.row(t);let n=E(`li`,{class:`link-alert`,"data-level":t.level,"data-kind":t.kind},E(`span`,null,xc(t)));if(t.kind===`join-request`||t.kind===`fork`||t.kind===`mismatch`){let i=E(`button`,{type:`button`,class:`later`},t.kind===`join-request`?Ri():Ii());i.onclick=()=>(r.hidePopover(),e()),n.append(i)}if(t.kind===`notice`){let e=E(`button`,{type:`button`,class:`later`},Ni());e.onclick=()=>(p.add(t.id),a=``,m.net(d)),n.append(e)}if(t.kind===`served`){let e=E(`a`,{class:`later`,href:`./`,"data-route":``},Ui());e.onclick=()=>r.hidePopover(),n.append(e)}return n})))}};return m}var Gd=45e3,Kd=1e3,qd=3e4,Jd={state:`connecting`,attempt:0},Yd=(e,t)=>Math.min(qd,Kd*2**(e-1))*(.8+.4*t);function Xd(e){try{return JSON.parse(e)}catch{return}}function Zd(e){let t,n,r,i=0,a={state:`connecting`,attempt:0},o=t=>e.onStatus(a={...a,...t}),s=()=>(e.clearTimeout(n),e.clearTimeout(r),n=r=void 0),c=()=>{let e=t;t=void 0,e?.close()},l=()=>{e.clearTimeout(r),r=e.setTimeout(()=>u(),Gd),o({state:`live`,attempt:0,lastContact:e.now()})},u=()=>{c(),s();let t=a.attempt+1;if(t>8)return o({state:`offline`,attempt:t});o({state:`reconnecting`,attempt:t}),e.hidden()||(n=e.setTimeout(d,Yd(t,e.random())))},d=()=>{c(),s(),i=e.now();let n=t=e.open();n.onError(()=>{t===n&&(u(),e.replaced?.().then(e=>{e&&a.state!==`live`&&a.state!==`replaced`&&(c(),s(),o({state:`replaced`}))},()=>{}))}),n.listen(`message`,r=>{if(t!==n)return;let i=Xd(r);i&&e.onNet(i),o({problem:i?void 0:So()}),l()}),n.listen(`ping`,()=>t===n&&l()),n.listen(`problem`,e=>{t===n&&(o({problem:Xd(e)??Co()}),l())}),r=e.setTimeout(()=>u(),Gd)};return{start(){o({state:`connecting`,attempt:0}),d()},resume(){if(a.state===`replaced`)return;let n=e.now()-i<2e3||a.lastContact!==void 0&&e.now()-a.lastContact<=2e4;t&&n||(o({attempt:0,state:a.state===`live`||a.state===`offline`?`reconnecting`:a.state}),d())},restart:d,hide(){e.clearTimeout(n),n=void 0},stop(){c(),s()}}}function Qd(e,t,n){let r=t===`zen`;switch(e.on){case`pick`:return{away:!1,settings:n.settings,leaveSettings:r&&n.settings};case`follow`:return{away:r?n.settings?!0:n.away:!1,settings:n.settings,leaveSettings:!1};case`leave`:return{away:!0,settings:n.settings,leaveSettings:!1};case`back`:return{away:!1,settings:n.settings,leaveSettings:!1};case`route`:return{away:r?e.settings:n.away,settings:e.settings,leaveSettings:!1}}}function $d(e){let t=()=>({away:e.root.dataset.zenAway!==void 0,settings:e.settings()});function n(n){let r=t(),i=Qd(n,e.view.view(),r);n.on===`leave`&&e.view.release(),i.away?e.root.dataset.zenAway=``:delete e.root.dataset.zenAway,e.view.refresh(),e.draw(),i.leaveSettings&&e.leaveSettings()}return e.view.onChange((e,t)=>n({on:t})),{leave:()=>n({on:`leave`}),back:()=>n({on:`back`}),route:e=>n({on:`route`,settings:e})}}function ef(e){let t={view:`map`},n,r,i,a=Jd,o,s,c=null,l=null,u=[],d=()=>pc(e.view.view(),e.root.dataset.zenAway!==void 0||t.view===`settings`),f=()=>d()===fc.zen,p=()=>f()&&c||wl(t,n?.head?.key);function m(){let t=p();t!==l&&(l=t,e.restart())}let h=t=>e.icon(d().count?_e(he(t).map(e=>e.unit)).length+(t.trust?.length??0)+[...lc(t,Date.now()).values()].filter(e=>e.wait).length:0);function g(){let t=f();e.zenEl.hidden=!t,t?e.withZen(e=>f()&&(e.pairs(u),n&&e.net(lc(n,Date.now()),n),e.show())):e.zen()?.hide(),n&&h(n),m()}let _=$d({view:e.view,root:e.root,settings:()=>t.view===`settings`,leaveSettings:e.leaveSettings,draw:()=>(e.back(),g())});function v(a){n=r=a,h(a),e.link(a.link),t.view===`head`&&m();let c=lc(a,Date.now()),l=d();if(l.announce===`current`)return void(s=c,e.withZen(e=>e.net(c,a)));if(s&&l.signal&&e.signal(uc(s,c)),s=c,e.hidden())return;let u=uc(o,c);o=c,e.draw(a,u,c),t.view===`map`&&(e.map(a),i=a,r=void 0)}let y=()=>void(r&&v(r)),b=t=>e.withPanels(e=>e.stack.show(t));function x(t,n,{mode:r,at:i}={}){if(r===`term`&&f())return e.withZen(e=>f()?e.terminal({key:n}):x(t,n,{mode:r,at:i}));r===`term`&&e.panels()?.stack.close(`go`),e.go({view:`session`,ws:t,key:n,at:i}),r===`term`&&e.withFocus(e=>e.terminal(n))}function ee(t){if(f())return e.withZen(e=>f()?e.step(t):ee(t));e.withPanels(e=>e.step(t,n))}return{get current(){return t},get latest(){return n},alertOf:e=>o?.get(e),rules:d,zenOn:f,watch:p,face:_,snapshot:v,sync:g,online:()=>a.state===`live`,status(t){a=t,e.zen()?.refresh()},opened:()=>l=p(),wake:y,route(r){let a=t;t=r,r.view===`settings`!=(a.view===`settings`)&&_.route(r.view===`settings`),e.navigate(r,a),r.view===`map`&&n&&n!==i&&(v(n),e.layout()),m()},openAlert:b,openSession:x,openStep:ee,leaveZen({item:t,route:n}){_.leave(),t&&b(t),n&&e.go(n),y()},upgrade(t){let n=f()?e.zen():void 0;n?n.upgrade(t):t()},pairing(t){u=t,f()&&e.withZen(e=>e.pairs(t))},enterZen:()=>pe(e.view,e.root),notified:e=>d().announce===`current`||!!e.card||(e.trust||e.wait?b(e):x(e.ws,cc(e))),news:Ud(()=>!d().chime,e.chime),keys:()=>d().keys,modal:()=>e.modal(),hotkey:t=>(t===`next`||t===`zoom`?e.panels()?.hotkey(t):e.zen()?.key(t))??!1,newest:()=>n,openSettings:()=>e.go({view:`settings`}),noDrawer:()=>!d().drawer,escape(n,r){if(!(n.key!==`Escape`||n.defaultPrevented||e.modal())){if(r)return void(!n.isComposing&&f()&&e.zen()?.escape(n)&&n.stopPropagation());f()||(n.preventDefault(),!(e.panels()?.stack.close()||t.view===`map`)&&(t.view===`settings`?e.leaveSettings():e.go(Sl(t))))}},watchLog(e){c=e,m()}}}function tf(e){let t=/^zh\b/i.test(e)&&(/-(hant|tw|hk|mo)\b/i.test(e)?`zh-TW`:/-(hans|cn|sg|my)\b/i.test(e)?`zh-CN`:void 0);return h(e)??(t?h(t):void 0)??h(e.split(`-`)[0])}function nf(e,t){return h(e)??t.map(tf).find(Boolean)??`en`}var rf={brand_label:ht,head_tower:()=>O(`head_tower`),menu_more:Ia,tagline:Os,totals_label:Fs,stat_bases:gs,stat_agents:hs,stat_working:ys,stat_waiting:vs,stat_commanding:_s,mark_commanding:Da,alerts:we,no_alerts:Za,link_connecting:Oi,connect_connecting:Ht,connect_retry:Wt,location:$i,all_bases:Te,documents:()=>O(`documents`),comms:()=>O(`comms`),outposts:()=>O(`outposts`),outside_net:()=>O(`outside_net`),timeline:ks,states:ws,mark_working:Na,mark_waiting:Ma,mark_idle:Aa,mark_done:Oa,mark_error:ka,credit:Yt,language:fr,view_label:Xs,view_auto:Gs,view_standard:Qs,view_geek:Ys,view_zen:ec,view_raven:Zs,zen_back:ac,zen_back_title:oc,view_title:$s,settings:Yo,new_base:Ja,back:tt,remind:ko,sound_effects:Qo,sound_background:Xo,sound_volume:ts,sound_try:es,sound_effects_title:$o,sound_background_title:Zo,set_device:Wo,set_device_note:Go,set_phone:Ko,set_teams:Jo,set_server:qo};Object.keys(rf);function af(e,t=localStorage,n=()=>location.reload()){return ae(t).set(`locale`,e)?(n(),!0):!1}var of=()=>g.map(e=>({id:e,name:Qi({},{locale:e})})),sf={m:(e,t)=>e.textContent=t,mLabel:(e,t)=>e.setAttribute(`aria-label`,t),mTitle:(e,t)=>e.title=t,mEmpty:(e,t)=>e.dataset.empty=t};function cf(){for(let e of document.querySelectorAll(`[data-m], [data-m-label], [data-m-title], [data-m-empty]`))for(let[t,n]of Object.entries(sf))e.dataset[t]&&n(e,rf[e.dataset[t]]?.()??e.dataset[t])}function lf(){let e=nf(C.get(`locale`),navigator.languages??[navigator.language]);_(()=>e),document.documentElement.lang=e,cf();let t=document.getElementById(`lang`);t.replaceChildren(...g.map(t=>new Option(Qi({},{locale:t}),t,!1,t===e))),t.onchange=()=>af(t.value)||(t.value=e)}var uf={standard:Qs,geek:Ys,zen:ec,raven:Zs},df=e=>e===`auto`?Gs():Js({view:uf[e]()}),ff=6e3,pf={post:(e,t)=>jl(e,t)},mf=e=>e?.auto?.pending,hf=(e,t)=>e.body.error===`stale`?et({},t):e.body.reason??(e.status?T({status:e.status},t):w({},t));function gf(e,t,n){let r=mf(t);if(e.hidden=!r,!r)return void(delete e.dataset.id,e.replaceChildren());if(e.dataset.id===r.id)return;e.dataset.id=r.id;let i=E(`p`,{class:`auto-note`,role:`alert`}),a=E(`button`,{type:`button`,class:`auto-confirm`},Ke({},n));a.onclick=async()=>{a.disabled=!0,i.textContent=``;let e=await pf.post(`auto/confirm`,{id:r.id}).catch(()=>({ok:!1,status:0,body:{}}));if(e.ok)return void(i.textContent=Qe({},n));a.disabled=!1,i.textContent=hf(e,n)},e.replaceChildren(E(`p`,{class:`auto-title`},Ze({},n)),E(`p`,{class:`auto-said`},Ye({said:r.said},n)),a,i)}var _f=e=>{let t=e?new Date(e):void 0;return t&&!Number.isNaN(t.getTime())?`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`:`?`};function vf(e,t={}){let n=t.timers??{set:(e,t)=>globalThis.setTimeout(e,t),clear:e=>globalThis.clearTimeout(e)},r=E(`button`,{type:`button`,class:`pair-btn tog auto-chip`,"data-state":`off`,"data-menu-keep":``}),i=E(`small`,{class:`auto-sw-note`,role:`alert`}),a,o,s=!1,c=()=>(o!==void 0&&n.clear(o),o=void 0),l=()=>{let e=a?`on`:o===void 0?`off`:`arming`;r.dataset.state=e,r.setAttribute(`aria-pressed`,String(!!a)),r.title=a?Ge({},t):We({},t),r.textContent=a?Ue({time:_f(a.since)},t):o===void 0?Be({},t):ze({},t),r.disabled=s},u=async e=>{s=!0,i.textContent=``,l();let n=await pf.post(`auto`,{on:e}).catch(()=>({ok:!1,status:0,body:{}}));if(s=!1,!n.ok)return i.textContent=hf(n,t),l();a=e?{since:typeof n.body.since==`string`?n.body.since:new Date().toISOString()}:void 0,l(),e||t.after?.(!0)};return r.onclick=()=>{if(!s){if(a)return void u(!1);if(o===void 0)return i.textContent=``,o=n.set(()=>(o=void 0,l()),ff),l();c(),u(!0)}},r.addEventListener(`keydown`,e=>e.key===`Escape`&&o!==void 0&&(c(),l())),e.replaceChildren(r,i),e.hidden=!0,l(),{net(t){e.hidden=!t?.auto&&!t?.autoable,a=t?.auto?.on?{...t.auto.since?{since:t.auto.since}:{}}:void 0,a&&c(),l()}}}var yf=e=>e.state===`live`?void 0:e.state,bf={connecting:Ht,reconnecting:Ut,offline:e=>ot({tries:e.attempt-1}),replaced:mt},xf=[`click`,`dblclick`,`auxclick`,`contextmenu`,`pointerdown`,`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`keydown`,`keyup`,`keypress`,`submit`,`dragstart`],Sf=new Set([`click`,`dblclick`,`auxclick`,`contextmenu`,`submit`]),U=e=>document.getElementById(e),Cf=()=>({win:window,dialog:U(`connect`),text:U(`connect-text`),retry:U(`connect-retry`),reload:U(`connect-reload`),guarded:[document.querySelector(`.shell`),U(`dock`),U(`zen`)]});function wf(e,t=Cf()){let{win:n,dialog:r,text:i,guarded:a}=t,o,s=!1,c=!1,l=()=>{c=!0,r.close(),c=!1},u=()=>{s||=(r.open&&l(),r.showModal(),!0);for(let e of a)e.inert=!0},d=()=>{for(let e of a)e.inert=!1;r.open&&l(),s=!1};r.addEventListener(`cancel`,e=>e.preventDefault()),r.addEventListener(`close`,()=>{c||r.open||(s=!1,o&&u())});for(let e of xf)n.addEventListener(e,t=>{!o||r.contains(t.target)||t.target?.closest?.(`dialog:modal`)||(t.stopPropagation(),Sf.has(e)&&t.preventDefault())},!0),r.addEventListener(e,e=>e.stopPropagation());return t.reload?.remove(),t.retry.addEventListener(`click`,e),e=>{if(o=yf(e),!o)return d();r.dataset.state=o,i.textContent=bf[o](e),t.retry.hidden=o!==`offline`,u()}}var Tf=`input, textarea, select, [role=textbox], [role=combobox], [role=listbox], .term-scroll`,Ef=`button, a, summary, [role=button], [role=link]`,Df=`.ask-opt, [role=radio], [role=checkbox]`,Of=`dialog.sheet[open], dialog.lightbox[open], [popover]:popover-open, dialog.auto-back[open]`,kf={dialogs:[{keys:[`f`],hotkey:`zoom`},{keys:[` `],hotkey:`next`,native:`keyboard`}]};function Af(e,t,n=!1,r=`dialogs`,i){if(t||e.defaultPrevented||e.isComposing)return;let a=e.key.toLowerCase(),o=kf[r]?.find(t=>t.keys.includes(a)&&(t.takes?t.takes(e,i):!e.metaKey&&!e.ctrlKey&&!e.altKey)),s=e.target;if(!(!o||(o.blocks?o.blocks(s):s?.isContentEditable||s?.closest?.(Tf)))&&(!o.native||!s?.closest?.(Ef)||o.native!==`any`&&n)&&!(a===` `&&s?.closest?.(Df)))return o.hotkey}function jf(e,t=()=>document.querySelector(Of)!==null,n=window,r=()=>`dialogs`,i){let a,o=!1,s=null;n.addEventListener(`pointerdown`,()=>o=!0,!0),n.addEventListener(`focusin`,e=>s=o?e.target:null,!0),n.addEventListener(`keydown`,n=>{let c=n.target===s;o=!1;let l=Af(n,t(),c,r(),i?.());if(l){if(n.repeat)return a===l?n.preventDefault():void 0;e(l)&&(a=l,n.preventDefault())}}),n.addEventListener(`keyup`,e=>{(a===`next`||a===`pause`)&&e.key===` `&&e.preventDefault(),a=void 0})}function Mf(e=()=>new AudioContext,t=e=>fetch(e).then(e=>e.arrayBuffer())){let n,r={},i={effects:1,background:1},a=new Map,o=t=>(n??=e(),r[t]||((r[t]=n.createGain()).connect(n.destination),r[t].gain.value=i[t]),{c:n,g:r[t]});return{volume:(e,t)=>void(i[e]=(t/100)**2,r[e]&&(r[e].gain.value=i[e])),unlock:()=>o(`effects`).c.resume().then(()=>o(`effects`).c.state===`running`,()=>!1),out:o,running:()=>n?.state===`running`,play(e,n){let{c:r,g:i}=o(`effects`);a.has(e)||a.set(e,t(e).then(e=>r.decodeAudioData(e))),Promise.all([r.resume(),a.get(e)]).then(([,e])=>{let t=r.createBufferSource();t.buffer=e,t.connect(i),t.start()}).catch(()=>(a.delete(e),n&&n!==e&&this.play(n)))}}}var Nf=Mf(),Pf,Ff=e=>void(Pf=e),If=(e,t)=>Pf?.[e]??t,Lf=new URL(`done-jqKY4qf5.mp3`,import.meta.url).href,Rf=new URL(`error-DdTLgPEw.mp3`,import.meta.url).href,zf={waiting:new URL(`waiting-DOg8-8gu.mp3`,import.meta.url).href,error:Rf,done:Lf},Bf=e=>e.mark===`waiting`||e.pending?`waiting`:e.mark===`error`?`error`:e.mark===`done`?`done`:void 0;function Vf(e){let t=e=>document.getElementById(e),n=t(`remind`),r=typeof Notification<`u`,i=C.get(`remind`),a=()=>{let e=r?Notification.permission:`denied`;n.setAttribute(`aria-pressed`,String(i)),n.dataset.state=i?e===`granted`?`on`:e===`denied`?`blocked`:`ask`:`off`,n.title=r?i?e===`granted`?No():e===`denied`?jo():Ao():Mo():Po(),t(`remind-note`).textContent=n.title,n.textContent={off:Ss,on:Cs,blocked:xs,ask:bs}[n.dataset.state]()};n.onclick=async()=>{i&&r&&Notification.permission==="default"?await Notification.requestPermission().catch(()=>{}):C.set(`remind`,i=!i),a()};let o=(e,n,r)=>{let i=t(e),a=t(`${e}-vol`),o=t(`${e}-vol-out`),s=[],c=`${e}Volume`,l=C.get(e),u=C.get(c),d=()=>{i.dataset.state=l?`on`:`off`,i.textContent=l?Cs():Ss(),i.setAttribute(`aria-pressed`,String(l)),a.value=o.value=String(u),Nf.volume(e,u)},f=()=>(d(),s.forEach(e=>e()));C.on(e,()=>(l=C.get(e),f())),C.on(c,()=>(u=C.get(c),f()));let p=t=>(C.set(e,l=t),f(),t&&r?.());return i.onclick=()=>p(!l),a.oninput=()=>(C.set(c,u=Number(a.value)),f()),a.onchange=n,d(),{on:()=>l,volume:()=>u,set:p,setVolume:e=>(C.set(c,u=e),f()),try:n,onChange:e=>void s.push(e)}},s=e=>Nf.play(If(e,zf[e]),zf[e]),c=o(`effects`,()=>s(`done`),()=>s(`done`)),l=o(`background`,()=>{});t(`effects-try`).onclick=()=>s(`done`);function u(t,n){if(!i||!r||Notification.permission!==`granted`||!document.hidden&&document.hasFocus())return;let a=new Notification(t.name,{body:t.trust?Vs():{waiting:uo,error:so,done:io}[n]({note:t.note??``}).trim(),tag:t.key,icon:document.querySelector(`link[rel="icon"]`)?.href,silent:n!==`waiting`});a.onclick=()=>(window.focus(),a.close(),e(t))}return a(),{remind:e=>u(e,`waiting`),sound:{effects:c,background:l},chime:()=>c.on()&&s(`done`),signal(e){let t=e.flatMap(e=>(t=>t?[{a:e,k:t}]:[])(Bf(e)));if(t.length){c.on()&&s([`waiting`,`error`,`done`].find(e=>t.some(t=>t.k===e)));for(let{a:e,k:n}of t)u(e,n)}}}}var Hf,Uf=e=>void(Hf=e);function Wf(e,t){if(`terminal`in e)return void(t.key&&Hf?.({kind:`prompt`,key:t.key,asker:t.key,command:t.command,...e.run&&t.answerId?{run:t.answerId}:{}}));if(e.pane===null)return _o();Hf?.({kind:`pane`,key:`grant:${e.pane}`,asker:t.key,command:t.command})}var Gf={commanding:na,working:Ea,waiting:Ca,idle:da,done:aa,error:ca,unknown:ba},Kf=e=>(e.kind===`duty`?({name:t})=>sn({name:t,from:Yu(`main`,e.from),to:Yu(`main`,e.to)}):e.kind===`joined`?ma:e.kind===`left`?_a:Gf[e.mark])({name:e.name}),qf=18e5,Jf={waiting:0,error:0,working:1,commanding:1},Yf=e=>new Date(e).toLocaleTimeString([],{hour12:!1});function Xf(e){let[t,n,r,i,a]=[`.tl-lanes`,`.tl-axis`,`.tl-at`,`.tl-last`,`.tl-span`].map(t=>e.querySelector(t)),o=[],s=``;matchMedia(`(max-width: 640px)`).matches&&(e.open=!1);let c=()=>{let e=Date.now()-qf,s=o.filter(t=>t.at>=e),c=s.at(-1);t.replaceChildren(...s.map(t=>{let n=document.createElement(`a`),r=(t.at-e)/qf*100;return n.className=`tl-mark ${t.kind}${r>70?` end`:``}`,n.dataset.mark=t.kind===`left`?`unknown`:t.mark,n.style.cssText=`left:${r.toFixed(2)}%;top:${(Jf[t.mark]??2)*14+4}px`,n.setAttribute(`aria-label`,`${Yf(t.at)} ${Kf(t)}`),nd(n,t.key&&t.kind!==`left`?{view:`session`,ws:t.ws,key:t.key}:{view:`workspace`,ws:t.ws}),n})),n.replaceChildren(...[0,10,20].map(t=>Object.assign(document.createElement(`span`),{textContent:Yf(e+t*6e4).slice(0,5)})),Object.assign(document.createElement(`span`),{textContent:js()})),r.textContent=c?Yf(c.at):``,i.textContent=c?Kf(c):As(),a.textContent=Ps({count:String(s.length)})};return setInterval(c,3e4),c(),{net(e){let t=e.events??[],n=t.map(e=>`${e.at}${e.kind}${e.key??e.name}${e.mark}`).join();n!==s&&(s=n,o=t,c())}}}async function Zf(e,t=fetch){return e.startsWith(`data:`)?decodeURIComponent(e.slice(e.indexOf(`,`)+1)):t(e).then(e=>e.text(),()=>void 0)}var Qf={dot:`#e0af68`,ring:`#1a1b26`,text:`#16161e`};function $f(e,t,n=Qf){let r=`<circle cx='23' cy='9' r='9' fill='${n.dot}' stroke='${n.ring}' stroke-width='2'/><text x='23' y='13' text-anchor='middle' font-family='sans-serif' font-size='${t>9?9:12}' font-weight='700' fill='${n.text}'>${t>9?`9+`:t}</text>`;return`data:image/svg+xml,${encodeURIComponent(t?e.replace(`</svg>`,`${r}</svg>`):e)}`}function ep(e,t){try{let n=JSON.parse(e??`{}`)[t]?.icon;return typeof n==`string`?n:void 0}catch{return}}var tp={geek:()=>j(()=>import(`../themes/geek/geek-BKd8_UaJ.js`),__vite__mapDeps([0]),import.meta.url),zen:()=>j(()=>import(`../themes/zen/zen-BQrgqRoA.js`),__vite__mapDeps([1]),import.meta.url),raven:()=>j(()=>import(`../themes/raven/raven-DGx4eH2o.js`),__vite__mapDeps([2]),import.meta.url)},np=e=>e in tp,rp=new Map;function ip(e){let t=rp.get(e);return t||rp.set(e,t=tp[e]().catch(t=>(rp.delete(e),Promise.reject(t)))),t}var ap=[],op=e=>void ap.push(e),sp=`standard`;async function cp(e){sp=e;let t=np(e)?(await ip(e).catch(()=>void 0))?.theme:void 0;if(sp===e){ll(t?.nouns),y(t?.sentences,v),Ff(t?.sounds),ol(e,t?.sprite),cf();for(let n of ap)n(e,t)}}var W=de(void 0);lf(),Qc(),fe(document.getElementById(`view-pick`),W,df);var lp=Hd(),up=Xf(document.getElementById(`timeline`)),G=e=>document.getElementById(e),dp=document.documentElement,fp=me(G(`zen-back`),W,dp,()=>Y.enterZen()),pp=e=>e?new Date(e).toLocaleTimeString([],{hour12:!1}):qa(),mp=!1,hp=``,K,gp,_p=e=>K?e(K):void gp?.then(e);function vp(){gp??=j(async()=>{let{mountFocus:e}=await import(`./views-SvadD2NQ.js`);return{mountFocus:e}},[],import.meta.url).then(({mountFocus:e})=>(K=e({data:am,restart:()=>Q.restart(),openTile:wp,embedTerminal:(e,t,n)=>yp(e,t,n,{keys:!1}),online:Y.online}),K.show(Cl(Y.current),Cl(Y.current)),Y.latest&&K.net(Y.latest),K))}var yp=(e,t,n,r)=>new Promise(i=>Cp(a=>i(a.terminal.embed(e,t,n,r)))),bp=()=>new Promise(e=>Cp(t=>e(t.kit))),xp=e=>Y.latest?.bases.find(t=>t.id===e)?.label??e,q,Sp,Cp=e=>{if(q)return e(q);Sp??=j(async()=>{let{mountPanels:e}=await import(`./layer-BMeWKQ6w.js`);return{mountPanels:e}},[],import.meta.url).then(({mountPanels:e})=>q=e({label:xp,recent:om,post:e=>Z&&((t,n)=>Z.data(e).post(t,n)),trust:Z&&Z.trust,stream:()=>hp,showTerminal:(e,t)=>Y.openSession(e,t,{mode:`term`}),net:()=>Y.latest})),Sp.then(e)},wp=(e,t)=>Cp(n=>n.tiles.open(e,t)),Tp,Ep,Dp=e=>{Ep??=ip(`zen`).then(({mountZen:e,zenPage:t})=>{let n=t({sound:X.sound,api:Z?.api??rm,snapshot:Y.newest});return Tp=e(G(`zen`),{data:am,recent:om,label:xp,online:Y.online,post:e=>Z&&((t,n)=>Z.data(e).post(t,n)),trust:Z&&Z.trust,remind:e=>X.remind(e),sound:n.sound,menu:{language:{get:v,names:of,set:af},view:{choice:()=>W.choice(),set:e=>W.set(e),auto:()=>df(W.server())},sound:{effects:{...X.sound.effects,try:n.menuSound.try,all:n.menuSound.all},background:X.sound.background}},music:n.music,leave:Y.leaveZen,terminals:bp,watch:Y.watchLog,companions:n.companions,activity:n.activity,trains:n.trains,settings:Y.openSettings,start:Z?.start})}),Ep.then(e)},Op=ku(location.hostname),kp=Op.phone,Ap,jp=e=>void(Ap??=j(async()=>{let{mountSettings:e}=await import(`./settings-C5nXwYtK.js`);return{mountSettings:e}},[],import.meta.url).then(({mountSettings:e})=>e(G(`settings-view`),Op))).then(e),Mp=e=>Y.current.view===`settings`?jp(t=>t.show(e)):cm.go({view:`settings`,section:e}),J=document.querySelector(`link[rel="icon"]`),Np=J&&(J.dataset.standard??J.getAttribute(`href`)??``),Pp=document.querySelector(`meta[name="sb-themes"]`)?.content,Fp=new Map,Ip=e=>{let t=new URL(ep(Pp,e)??Np??``,document.baseURI).href;return Fp.has(t)||Fp.set(t,Zf(t)),Fp.get(t)},Lp=J?Ip(W.view()):void 0,Rp,zp=0;function Bp(e,t=!1){J&&Lp&&(e!==zp||t)&&(zp=e,Lp.then(t=>t&&e===zp&&(J.href=$f(t,e,Rp))))}function Vp(){let e=G(`dismiss-all`).hidden&&G(`stashed`).hidden&&G(`head-btn`).hidden&&G(`auto-sw`).hidden;G(`bar-more`).hidden=e,e&&G(`bar-pop`).matches(`:popover-open`)&&G(`bar-pop`).hidePopover()}function Hp(e,t,n){lp.stats(e),Yp.net(e),zu(G(`dismiss-all`),e),Bu(G(`stashed`),G(`stashed-list`),e),eu(G(`head-btn`),e.head,Zl(),Y.current.view===`head`||Y.current.view===`session`&&Y.current.ws===`@head`),Vp(),G(`bar-more`).toggleAttribute(`data-news`,$l(e.head,Zl())&&!(Y.current.view===`head`||Y.current.view===`session`&&Y.current.ws===`@head`)),$?.net(e),pm?.net(e),(t.length||q)&&Cp(r=>r.alerts(t,n,e)),up.net(e),_p(t=>t.net(e))}function Up(e,t){let n=e.view===`workspace`&&t.view===`map`?document.querySelector(`#bases [data-key="${CSS.escape(e.ws)}"]`)?.getBoundingClientRect():void 0,r=e.view===`head`?`session`:e.view;document.body.dataset.route=r,$?.route(e),(e.view===`workspace`||e.view===`session`||e.view===`head`)&&vp(),G(`map`).hidden=e.view!==`map`,G(`settings-view`).hidden=e.view!==`settings`,G(`crumbs`).hidden=e.view===`settings`,G(`legend`).hidden=r===`session`||e.view===`settings`,G(`prefs`).toggleAttribute(`aria-current`,e.view===`settings`),G(`stage`).dataset.view=e.view===`head`||e.view===`session`&&e.ws===`@head`?`head`:r,_p(r=>r.show(Cl(e),Cl(t),n)),e.view===`settings`?jp(t=>Y.current===e&&t.show(e.section)):t.view===`settings`&&jp(e=>e.hide())}var Wp=()=>Tl(window.history.state)>0?window.history.back():cm.go({view:`map`}),Y=ef({view:W,root:dp,zenEl:G(`zen`),zen:()=>Tp,withZen:Dp,hidden:()=>document.hidden,back:fp,leaveSettings:Wp,restart:()=>mp&&Q.restart(),icon:Bp,link:e=>Xp.net(e),signal:e=>X.signal(e),draw:Hp,map:lp.show,navigate:Up,layout:()=>requestAnimationFrame(lp.layout),panels:()=>q,withPanels:Cp,withFocus:_p,go:e=>cm.go(e),modal:()=>document.querySelector(Of)!==null,chime:()=>X.chime()});op((e,t)=>{Rp=t?.badge,J&&(Lp=Ip(e)),Bp(zp,!0),Y.latest&&Y.snapshot(Y.latest)}),W.onChange(e=>void cp(e)),cp(W.view()),Uf(Y.openStep);var Gp,Kp=e=>void(Gp??=j(async()=>{let{mountBack:e,BACK_KEY:t}=await import(`./autoback-CZkFJtdj.js`);return{mountBack:e,BACK_KEY:t}},[],import.meta.url).then(({mountBack:e,BACK_KEY:t})=>e(G(`auto-back`),{net:()=>Y.latest,store:{get:()=>localStorage.getItem(t),set:e=>localStorage.setItem(t,e)},now:Date.now}))).then(e),qp=!0,Jp=e=>qp?(qp=!1,Kp(e=>e.check())):Gp&&Kp(t=>t.net(e)),Yp=vf(G(`auto-sw`),{after:()=>(G(`bar-pop`).matches(`:popover-open`)&&G(`bar-pop`).hidePopover(),Kp(e=>e.check(!0)))}),Xp=Wd(()=>Mp(`teams`),Y.news),X=Vf(Y.notified);function Zp(e){um(e),Y.status(e);let t=e.state===`reconnecting`||e.state===`offline`||e.state===`replaced`;document.body.dataset.stale=G(`stage`).dataset.stale=String(t),G(`link`).dataset.state=e.state,G(`link-text`).textContent={connecting:Oi,live:Ai,reconnecting:Li,offline:Pi,replaced:Pi}[e.state](),K&&Y.latest&&K.net(Y.latest),q?.stack.redraw();let n=G(`banner`);n.hidden=!t&&!e.problem;let r=e.state===`replaced`?mt():e.state===`offline`?ot({tries:e.attempt-1}):e.state===`reconnecting`?e.attempt?pt({attempt:e.attempt}):ut():lt({problem:e.problem??``}),i=document.createElement(`b`);i.textContent=pp(e.lastContact),n.replaceChildren(`${r} ${rt()} `,i,nt())}function Qp(e,t){try{let n=JSON.parse(t);e===`history`&&Tp?.history(n),_p(t=>e===`history`?t.history(n):t.cards(n))}catch{}}var $p=document.querySelector(`meta[name="sb-build"]`)?.content??void 0,em=e=>!!($p&&$p!==JSON.parse(e).build);function tm(e,t=!1){try{let n=JSON.parse(e),r=t?n:n?.view;typeof r==`string`&&W.setServer(r)}catch{}}function nm(e){let t=new EventSource(e?`events?watch=${encodeURIComponent(e)}`:`events`);return{onError:e=>t.onerror=e,listen:(e,n)=>t.addEventListener(e,e=>n(e.data)),close:()=>t.close()}}var rm=e=>fetch(`api/${e}`,{cache:`no-store`}).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))),im=(e,t=``)=>rm(`history/${encodeURIComponent(e)}${t}`),Z=void 0,am=e=>({older:t=>im(e,`?before=${encodeURIComponent(t)}`),latest:()=>im(e),entry:t=>rm(`entry/${encodeURIComponent(e)}/${encodeURIComponent(t)}`).catch(()=>void 0),pic:(t,n)=>`api/image/${encodeURIComponent(e)}/${encodeURIComponent(t)}/${n}`}),om=async e=>(await im(e,`?limit=12`)).items,sm=()=>{let e=nm(Y.opened());return e.listen(`history`,e=>Qp(`history`,e)),e.listen(`cards`,e=>Qp(`cards`,e)),e.listen(`hello`,e=>em(e)?Y.upgrade(()=>location.reload()):(hp=e,tm(e),q?.terminal.hello())),e.listen(`view`,e=>tm(e,!0)),e.listen(`mirror`,e=>q?.terminal.frame(e)),e};document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`a[data-alert]`),n=t&&xl(t.getAttribute(`data-route`)??``);if(!n||n.view!==`session`||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let r=Y.alertOf(n.key);r&&(e.preventDefault(),Y.openAlert(r))},!0);var cm=El(e=>Y.route(e)),Q=Zd({open:sm,now:Date.now,setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e),random:Math.random,hidden:()=>document.hidden,onNet:e=>(Y.snapshot(e),Jp(e)),onStatus:Zp,replaced:()=>fetch(`./`,{cache:`no-store`}).then(e=>e.status===403)}),lm=()=>Q.resume(),um=wf(lm);document.addEventListener(`visibilitychange`,()=>{if(lp.pause(document.hidden),Tp?.visible(!document.hidden),document.hidden)return Q.hide();Y.wake(),_p(e=>e.wake()),lm()}),addEventListener(`keydown`,e=>Y.escape(e,!0),!0),addEventListener(`keydown`,e=>Y.escape(e,!1)),jf(Y.hotkey,Y.modal,window,Y.keys),G(`prefs`).addEventListener(`click`,e=>Y.current.view===`settings`&&(e.preventDefault(),Wp())),kp&&j(async()=>{let{mountLanWait:e}=await import(`./lanwait-y3ZgXxvk.js`);return{mountLanWait:e}},[],import.meta.url).then(({mountLanWait:e})=>e(G(`lan-wait`),()=>Mp(`wifi`),void 0,Y.pairing));var $,dm=matchMedia(`(pointer: coarse), (max-width: 640px)`),fm=()=>void j(async()=>{let{mountDrawer:e}=await import(`./drawer-DyN2PbF3.js`);return{mountDrawer:e}},[],import.meta.url).then(({mountDrawer:e})=>($??=e(Y.noDrawer),Y.latest&&$.net(Y.latest),$.route(Y.current)));dm.matches?fm():dm.addEventListener(`change`,()=>dm.matches&&!$&&fm(),{once:!0}),Uu({route:()=>Cl(Y.current),net:()=>Y.latest,go:e=>cm.go(e)}),G(`stashed-pop`).addEventListener(`toggle`,e=>e.newState===`open`&&rd(G(`stashed-pop`),G(`stashed`))),document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`button[data-open]`);t&&j(async()=>{let{openingOf:e,spawnTile:t}=await import(`./spawn-DmP1vT7z.js`);return{openingOf:e,spawnTile:t}},[],import.meta.url).then(({openingOf:e,spawnTile:n})=>{let r=e(t,Y.latest?.bases??[]);r&&wp(n(r,(e,t,n)=>(q?.tiles.close(n),Y.openSession(e,t)),()=>X.chime()),!0)})});var pm;document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`[data-yard]`);t&&j(async()=>{let{mountYard:e}=await import(`./yard-C6xyMp5L.js`);return{mountYard:e}},[],import.meta.url).then(({mountYard:e})=>(pm??=e(),Y.latest&&pm.net(Y.latest),pm.open((t.dataset.yard??``).split(` `).filter(Boolean),t)))});for(let e of[`focus`,`pageshow`,`online`])window.addEventListener(e,()=>!document.hidden&&lm());Zp(Jd),Y.route(cm.route()),Y.sync(),Q.start(),mp=!0;export{pl as $,nr as $t,Nu as A,ts as At,$l as B,Fa as Bt,Ku as C,rc as Ct,z as D,Ss as Dt,H as E,Cs as Et,Tu as F,w as Ft,j as G,ki as Gt,Ql as H,ka as Ht,N as I,Za as It,Al as J,li as Jt,Ml as K,Di as Kt,_u as L,Xa as Lt,Lu as M,Xo as Mt,Vu as N,T as Nt,Zu as O,ys as Ot,zu as P,$a as Pt,k as Q,ar as Qt,hu as R,qa as Rt,B as S,oc as St,td as T,Ds as Tt,Zl as U,Pi as Ut,tu as V,Pa as Vt,ql as W,ji as Wt,A as X,Er as Xt,Dl as Y,oi as Yt,gl as Z,fr as Zt,ad as _,E as _t,_f as a,Oe as an,il as at,ed as b,sc as bt,I as c,be as cn,Wc as ct,nd as d,_e as dn,Sc as dt,Dn as en,_l as et,_d as f,S as fn,wc as ft,Id as g,Rc as gt,V as h,ee as hn,Ac as ht,Of as i,tt as in,$c as it,ju as j,Qo as jt,Xu as k,vs as kt,id as l,ge as ln,Mc as lt,R as m,C as mn,Tc as mt,Nf as n,_t as nn,ul as nt,gf as o,Te as on,el as ot,Ed as p,ae as pn,Oc as pt,jl as q,Si as qt,kf as r,gt as rn,O as rt,uf as s,Ce as sn,tl as st,Wf as t,Jt as tn,hl as tt,od as u,he as un,xc as ut,rd as v,mc as vt,Yu as w,Xs as wt,$u as x,cc as xt,L as y,hc as yt,ru as z,Ia as zt};